Changeset 49120 in vbox for trunk/src/VBox/Main
- Timestamp:
- Oct 15, 2013 3:12:06 PM (11 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/ConsoleImpl.h
r48983 r49120 36 36 class AudioSniffer; 37 37 class Nvram; 38 class EmWebcam;39 38 #ifdef VBOX_WITH_USB_CARDREADER 40 39 class UsbCardReader; … … 243 242 UsbCardReader *getUsbCardReader() { return mUsbCardReader; } 244 243 #endif 245 EmWebcam *getEmWebcam() { return mEmWebcam; }246 244 247 245 int VRDPClientLogon(uint32_t u32ClientId, const char *pszUser, const char *pszPassword, const char *pszDomain); … … 306 304 VMMDevMouseInterface *getVMMDevMouseInterface(); 307 305 DisplayMouseInterface *getDisplayMouseInterface(); 306 307 EmulatedUSB *getEmulatedUSB(void) { return mEmulatedUSB; } 308 308 309 309 private: … … 825 825 AudioSniffer * const mAudioSniffer; 826 826 Nvram * const mNvram; 827 EmWebcam * const mEmWebcam;828 827 #ifdef VBOX_WITH_USB_CARDREADER 829 828 UsbCardReader * const mUsbCardReader; -
trunk/src/VBox/Main/include/ConsoleVRDPServer.h
r48406 r49120 40 40 /////////////////////////////////////////////////////////////////////////////// 41 41 42 class EmWebcam; 43 42 44 typedef struct _VRDPInputSynch 43 45 { … … 152 154 int VideoInControl(void *pvUser, const VRDEVIDEOINDEVICEHANDLE *pDeviceHandle, 153 155 const VRDEVIDEOINCTRLHDR *pReq, uint32_t cbReq); 156 157 Console *getConsole(void) { return mConsole; } 154 158 155 159 private: … … 339 343 const VRDEVIDEOINPAYLOADHDR *pFrame, 340 344 uint32_t cbFrame); 345 EmWebcam *mEmWebcam; 341 346 342 347 /* Input interface. */ -
trunk/src/VBox/Main/include/EmulatedUSBImpl.h
r48955 r49120 46 46 const void *pvData, uint32_t cbData); 47 47 48 HRESULT webcamAttachInternal(const com::Utf8Str &aPath, 49 const com::Utf8Str &aSettings, 50 const char *pszDriver, 51 void *pvObject); 52 HRESULT webcamDetachInternal(const com::Utf8Str &aPath); 53 48 54 private: 49 55 -
trunk/src/VBox/Main/include/UsbWebcamInterface.h
r44758 r49120 23 23 #include <VBox/RemoteDesktop/VRDEVideoIn.h> 24 24 25 class Console ;25 class ConsoleVRDPServer; 26 26 typedef struct EMWEBCAMDRV EMWEBCAMDRV; 27 27 typedef struct EMWEBCAMREMOTE EMWEBCAMREMOTE; … … 30 30 { 31 31 public: 32 EmWebcam(Console *console);32 EmWebcam(ConsoleVRDPServer *pServer); 33 33 virtual ~EmWebcam(); 34 34 … … 56 56 static DECLCALLBACK(void) drvDestruct(PPDMDRVINS pDrvIns); 57 57 58 Console * const mParent;58 ConsoleVRDPServer * const mParent; 59 59 60 60 EMWEBCAMDRV *mpDrv; -
trunk/src/VBox/Main/src-client/ConsoleImpl.cpp
r48983 r49120 58 58 #include "AudioSnifferInterface.h" 59 59 #include "Nvram.h" 60 #include "UsbWebcamInterface.h"61 60 #ifdef VBOX_WITH_USB_CARDREADER 62 61 # include "UsbCardReader.h" … … 386 385 , mAudioSniffer(NULL) 387 386 , mNvram(NULL) 388 , mEmWebcam(NULL)389 387 #ifdef VBOX_WITH_USB_CARDREADER 390 388 , mUsbCardReader(NULL) … … 559 557 } 560 558 561 unconst(mEmWebcam) = new EmWebcam(this);562 AssertReturn(mEmWebcam, E_FAIL);563 559 #ifdef VBOX_WITH_USB_CARDREADER 564 560 unconst(mUsbCardReader) = new UsbCardReader(this); … … 656 652 delete mNvram; 657 653 unconst(mNvram) = NULL; 658 }659 660 if (mEmWebcam)661 {662 delete mEmWebcam;663 unconst(mEmWebcam) = NULL;664 654 } 665 655 -
trunk/src/VBox/Main/src-client/ConsoleVRDPServer.cpp
r48406 r49120 1407 1407 rc = RTCritSectInit(&mTSMFLock); 1408 1408 AssertRC(rc); 1409 1410 mEmWebcam = new EmWebcam(this); 1411 AssertPtr(mEmWebcam); 1409 1412 } 1410 1413 … … 1429 1432 maFramebuffers[i] = NULL; 1430 1433 } 1434 } 1435 1436 if (mEmWebcam) 1437 { 1438 delete mEmWebcam; 1439 mEmWebcam = NULL; 1431 1440 } 1432 1441 … … 2647 2656 { 2648 2657 ConsoleVRDPServer *pThis = static_cast<ConsoleVRDPServer*>(pvCallback); 2649 EmWebcam *pWebcam = pThis->mConsole->getEmWebcam(); 2650 pWebcam->EmWebcamCbNotify(u32Id, pvData, cbData); 2658 if (pThis->mEmWebcam) 2659 { 2660 pThis->mEmWebcam->EmWebcamCbNotify(u32Id, pvData, cbData); 2661 } 2651 2662 } 2652 2663 … … 2659 2670 { 2660 2671 ConsoleVRDPServer *pThis = static_cast<ConsoleVRDPServer*>(pvCallback); 2661 EmWebcam *pWebcam = pThis->mConsole->getEmWebcam(); 2662 pWebcam->EmWebcamCbDeviceDesc(rcRequest, pDeviceCtx, pvUser, pDeviceDesc, cbDevice); 2672 if (pThis->mEmWebcam) 2673 { 2674 pThis->mEmWebcam->EmWebcamCbDeviceDesc(rcRequest, pDeviceCtx, pvUser, pDeviceDesc, cbDevice); 2675 } 2663 2676 } 2664 2677 … … 2671 2684 { 2672 2685 ConsoleVRDPServer *pThis = static_cast<ConsoleVRDPServer*>(pvCallback); 2673 EmWebcam *pWebcam = pThis->mConsole->getEmWebcam(); 2674 pWebcam->EmWebcamCbControl(rcRequest, pDeviceCtx, pvUser, pControl, cbControl); 2686 if (pThis->mEmWebcam) 2687 { 2688 pThis->mEmWebcam->EmWebcamCbControl(rcRequest, pDeviceCtx, pvUser, pControl, cbControl); 2689 } 2675 2690 } 2676 2691 … … 2682 2697 { 2683 2698 ConsoleVRDPServer *pThis = static_cast<ConsoleVRDPServer*>(pvCallback); 2684 EmWebcam *pWebcam = pThis->mConsole->getEmWebcam(); 2685 pWebcam->EmWebcamCbFrame(rcRequest, pDeviceCtx, pFrame, cbFrame); 2699 if (pThis->mEmWebcam) 2700 { 2701 pThis->mEmWebcam->EmWebcamCbFrame(rcRequest, pDeviceCtx, pFrame, cbFrame); 2702 } 2686 2703 } 2687 2704 -
trunk/src/VBox/Main/src-client/EmulatedUSBImpl.cpp
r48969 r49120 54 54 EUSBSettingsMap mDrvSettings; 55 55 56 static DECLCALLBACK(int) emulatedWebcamAttach(PUVM pUVM, EUSBWEBCAM *pThis); 56 void *mpvObject; 57 58 static DECLCALLBACK(int) emulatedWebcamAttach(PUVM pUVM, EUSBWEBCAM *pThis, const char *pszDriver); 57 59 static DECLCALLBACK(int) emulatedWebcamDetach(PUVM pUVM, EUSBWEBCAM *pThis); 58 60 … … 68 70 mcRefs(1), 69 71 mpEmulatedUSB(NULL), 70 enmStatus(EUSBDEVICE_CREATED) 72 enmStatus(EUSBDEVICE_CREATED), 73 mpvObject(NULL) 71 74 { 72 75 RT_ZERO(mUuid); … … 91 94 EmulatedUSB *pEmulatedUSB, 92 95 const com::Utf8Str *aPath, 93 const com::Utf8Str *aSettings); 96 const com::Utf8Str *aSettings, 97 void *pvObject); 94 98 HRESULT Attach(Console *pConsole, 95 PUVM pUVM); 99 PUVM pUVM, 100 const char *pszDriver); 96 101 HRESULT Detach(Console *pConsole, 97 102 PUVM pUVM); … … 103 108 104 109 105 /* static */ DECLCALLBACK(int) EUSBWEBCAM::emulatedWebcamAttach(PUVM pUVM, EUSBWEBCAM *pThis )110 /* static */ DECLCALLBACK(int) EUSBWEBCAM::emulatedWebcamAttach(PUVM pUVM, EUSBWEBCAM *pThis, const char *pszDriver) 106 111 { 107 112 EUSBSettingsMap::const_iterator it; … … 120 125 PCFGMNODE pLunL0; 121 126 CFGMR3InsertNode(pInstance, "LUN#0", &pLunL0); 122 CFGMR3InsertString(pLunL0, "Driver", "HostWebcam");127 CFGMR3InsertString(pLunL0, "Driver", pszDriver); 123 128 CFGMR3InsertNode(pLunL0, "Config", &pConfig); 124 129 CFGMR3InsertString(pConfig, "DevicePath", pThis->mPath.c_str()); 130 CFGMR3InsertInteger(pConfig, "Object", (uintptr_t)pThis->mpvObject); 125 131 for (it = pThis->mDrvSettings.begin(); it != pThis->mDrvSettings.end(); ++it) 126 132 CFGMR3InsertString(pConfig, it->first.c_str(), it->second.c_str()); … … 140 146 EmulatedUSB *pEmulatedUSB, 141 147 const com::Utf8Str *aPath, 142 const com::Utf8Str *aSettings) 148 const com::Utf8Str *aSettings, 149 void *pvObject) 143 150 { 144 151 HRESULT hrc = S_OK; … … 161 168 { 162 169 mpEmulatedUSB = pEmulatedUSB; 170 mpvObject = pvObject; 163 171 } 164 172 } … … 183 191 184 192 HRESULT EUSBWEBCAM::Attach(Console *pConsole, 185 PUVM pUVM) 193 PUVM pUVM, 194 const char *pszDriver) 186 195 { 187 196 HRESULT hrc = S_OK; 188 197 189 198 int vrc = VMR3ReqCallWaitU(pUVM, 0 /* idDstCpu (saved state, see #6232) */, 190 (PFNRT)emulatedWebcamAttach, 2,191 pUVM, this );199 (PFNRT)emulatedWebcamAttach, 3, 200 pUVM, this, pszDriver); 192 201 193 202 if (SUCCEEDED(hrc) && RT_FAILURE(vrc)) … … 322 331 const com::Utf8Str &aSettings) 323 332 { 333 return webcamAttachInternal(aPath, aSettings, "HostWebcam", NULL); 334 } 335 336 HRESULT EmulatedUSB::webcamAttachInternal(const com::Utf8Str &aPath, 337 const com::Utf8Str &aSettings, 338 const char *pszDriver, 339 void *pvObject) 340 { 324 341 HRESULT hrc = S_OK; 325 342 … … 332 349 if (p) 333 350 { 334 hrc = p->Initialize(m.pConsole, this, &path, &aSettings );351 hrc = p->Initialize(m.pConsole, this, &path, &aSettings, pvObject); 335 352 if (SUCCEEDED(hrc)) 336 353 { … … 362 379 if (SUCCEEDED(hrc)) 363 380 { 364 hrc = p->Attach(m.pConsole, ptrVM.rawUVM() );381 hrc = p->Attach(m.pConsole, ptrVM.rawUVM(), pszDriver); 365 382 } 366 383 … … 395 412 396 413 HRESULT EmulatedUSB::webcamDetach(const com::Utf8Str &aPath) 414 { 415 return webcamDetachInternal(aPath); 416 } 417 418 HRESULT EmulatedUSB::webcamDetachInternal(const com::Utf8Str &aPath) 397 419 { 398 420 HRESULT hrc = S_OK; -
trunk/src/VBox/Main/src-client/UsbWebcamInterface.cpp
r47416 r49120 21 21 #include "ConsoleImpl.h" 22 22 #include "ConsoleVRDPServer.h" 23 #include "EmulatedUSBImpl.h" 23 24 24 25 #include <VBox/vmm/pdmwebcaminfs.h> 25 26 26 27 28 typedef struct EMWEBCAMREMOTE 29 { 30 EmWebcam *pEmWebcam; 31 32 VRDEVIDEOINDEVICEHANDLE deviceHandle; /* The remote identifier. */ 33 34 /* Received from the remote client. */ 35 uint32_t u32Version; /* VRDE_VIDEOIN_NEGOTIATE_VERSION */ 36 uint32_t fu32Capabilities; /* VRDE_VIDEOIN_NEGOTIATE_CAP_* */ 37 VRDEVIDEOINDEVICEDESC *pDeviceDesc; 38 uint32_t cbDeviceDesc; 39 40 /* The device identifier for the PDM device.*/ 41 uint64_t u64DeviceId; 42 } EMWEBCAMREMOTE; 43 27 44 typedef struct EMWEBCAMDRV 28 45 { 29 E mWebcam *pEmWebcam;46 EMWEBCAMREMOTE *pRemote; 30 47 PPDMIWEBCAMUP pIWebcamUp; 31 48 PDMIWEBCAMDOWN IWebcamDown; 32 49 } EMWEBCAMDRV, *PEMWEBCAMDRV; 33 50 34 typedef struct EMWEBCAMREMOTE35 {36 EmWebcam *pEmWebcam;37 38 VRDEVIDEOINDEVICEHANDLE deviceHandle; /* The remote identifier. */39 uint32_t u32Version; /* VRDE_VIDEOIN_NEGOTIATE_VERSION */40 uint32_t fu32Capabilities; /* VRDE_VIDEOIN_NEGOTIATE_CAP_* */41 42 /* The device identifier for the PDM device.*/43 uint64_t u64DeviceId;44 } EMWEBCAMREMOTE;45 46 51 typedef struct EMWEBCAMREQCTX 47 52 { … … 54 59 bool fReady) 55 60 { 61 NOREF(fReady); 62 56 63 PEMWEBCAMDRV pThis = RT_FROM_MEMBER(pInterface, EMWEBCAMDRV, IWebcamDown); 57 NOREF(pThis); 58 NOREF(fReady); 64 EMWEBCAMREMOTE *pRemote = pThis->pRemote; 65 66 LogFlowFunc(("pRemote:%p\n", pThis->pRemote)); 67 68 if (pThis->pIWebcamUp) 69 { 70 pThis->pIWebcamUp->pfnWebcamUpAttached(pThis->pIWebcamUp, 71 pRemote->u64DeviceId, 72 (const PDMIWEBCAM_DEVICEDESC *)pRemote->pDeviceDesc, 73 pRemote->cbDeviceDesc, 74 pRemote->u32Version, 75 pRemote->fu32Capabilities); 76 } 59 77 } 60 78 … … 66 84 { 67 85 PEMWEBCAMDRV pThis = RT_FROM_MEMBER(pInterface, EMWEBCAMDRV, IWebcamDown); 68 69 LogFlowFunc(("pEmWebcam:%p, u64DeviceId %lld\n", pThis->pEmWebcam, u64DeviceId)); 70 71 return pThis->pEmWebcam->SendControl(pThis, pvUser, u64DeviceId, (const VRDEVIDEOINCTRLHDR *)pCtrl, cbCtrl); 72 } 73 74 75 EmWebcam::EmWebcam(Console *console) 86 EMWEBCAMREMOTE *pRemote = pThis->pRemote; 87 88 LogFlowFunc(("pRemote:%p, u64DeviceId %lld\n", pRemote, u64DeviceId)); 89 90 return pRemote->pEmWebcam->SendControl(pThis, pvUser, u64DeviceId, (const VRDEVIDEOINCTRLHDR *)pCtrl, cbCtrl); 91 } 92 93 94 EmWebcam::EmWebcam(ConsoleVRDPServer *pServer) 76 95 : 77 mParent( console),96 mParent(pServer), 78 97 mpDrv(NULL), 79 98 mpRemote(NULL), … … 86 105 if (mpDrv) 87 106 { 88 mpDrv->p EmWebcam= NULL;107 mpDrv->pRemote = NULL; 89 108 mpDrv = NULL; 90 109 } … … 104 123 if (mpRemote) 105 124 { 106 mParent->consoleVRDPServer()->VideoInDeviceDetach(&mpRemote->deviceHandle); 125 mParent->VideoInDeviceDetach(&mpRemote->deviceHandle); 126 127 RTMemFree(mpRemote->pDeviceDesc); 128 mpRemote->pDeviceDesc = NULL; 129 mpRemote->cbDeviceDesc = 0; 130 107 131 RTMemFree(mpRemote); 108 132 mpRemote = NULL; 109 133 } 110 134 135 mpDrv->pRemote = NULL; 111 136 mpDrv = NULL; 112 137 } … … 159 184 pRemote->u32Version = u32Version; 160 185 pRemote->fu32Capabilities = fu32Capabilities; 186 pRemote->pDeviceDesc = NULL; 187 pRemote->cbDeviceDesc = 0; 161 188 pRemote->u64DeviceId = ASMAtomicIncU64(&mu64DeviceIdSrc); 162 189 … … 164 191 165 192 /* Tell the server that this webcam will be used. */ 166 rc = mParent-> consoleVRDPServer()->VideoInDeviceAttach(&mpRemote->deviceHandle, mpRemote);193 rc = mParent->VideoInDeviceAttach(&mpRemote->deviceHandle, mpRemote); 167 194 if (RT_FAILURE(rc)) 168 195 { … … 173 200 174 201 /* Get the device description. */ 175 rc = mParent-> consoleVRDPServer()->VideoInGetDeviceDesc(NULL, &mpRemote->deviceHandle);202 rc = mParent->VideoInGetDeviceDesc(NULL, &mpRemote->deviceHandle); 176 203 177 204 if (RT_FAILURE(rc)) 178 205 { 179 mParent-> consoleVRDPServer()->VideoInDeviceDetach(&mpRemote->deviceHandle);206 mParent->VideoInDeviceDetach(&mpRemote->deviceHandle); 180 207 RTMemFree(mpRemote); 181 208 mpRemote = NULL; … … 201 228 mpRemote->u64DeviceId); 202 229 } 203 204 /* No need to tell the server by calling VideoInDeviceDetach because the server is telling. */ 205 RTMemFree(mpRemote); 206 mpRemote = NULL; 230 /* mpRemote is deallocated in EmWebcamDestruct */ 207 231 } 208 232 } break; … … 228 252 if (RT_SUCCESS(rcRequest)) 229 253 { 230 if (mpDrv && mpDrv->pIWebcamUp) 231 { 232 mpDrv->pIWebcamUp->pfnWebcamUpAttached(mpDrv->pIWebcamUp, 233 pRemote->u64DeviceId, 234 (const PDMIWEBCAM_DEVICEDESC *)pDeviceDesc, 235 cbDeviceDesc, 236 pRemote->u32Version, 237 pRemote->fu32Capabilities); 238 } 254 /* Save device description. */ 255 Assert(pRemote->pDeviceDesc == NULL); 256 pRemote->pDeviceDesc = (VRDEVIDEOINDEVICEDESC *)RTMemDup(pDeviceDesc, cbDeviceDesc); 257 pRemote->cbDeviceDesc = cbDeviceDesc; 258 259 /* Try to attach the device. */ 260 EmulatedUSB *pEUSB = mParent->getConsole()->getEmulatedUSB(); 261 pEUSB->webcamAttachInternal("", "", "EmWebcam", pRemote); 239 262 } 240 263 else 241 264 { 242 mParent-> consoleVRDPServer()->VideoInDeviceDetach(&mpRemote->deviceHandle);265 mParent->VideoInDeviceDetach(&mpRemote->deviceHandle); 243 266 RTMemFree(mpRemote); 244 267 mpRemote = NULL; … … 324 347 pCtx->pvUser = pvUser; 325 348 326 rc = mParent-> consoleVRDPServer()->VideoInControl(pCtx, &mpRemote->deviceHandle, pControl, cbControl);349 rc = mParent->VideoInControl(pCtx, &mpRemote->deviceHandle, pControl, cbControl); 327 350 328 351 if (RT_FAILURE(rc)) … … 351 374 PDMDRV_CHECK_VERSIONS_RETURN_VOID(pDrvIns); 352 375 PEMWEBCAMDRV pThis = PDMINS_2_DATA(pDrvIns, PEMWEBCAMDRV); 353 354 LogFlowFunc(("iInstance %d, pEmWebcam %p, pIWebcamUp %p\n", 355 pDrvIns->iInstance, pThis->pEmWebcam, pThis->pIWebcamUp));356 357 if (pThis->pEmWebcam) 358 {359 pThis->pEmWebcam->EmWebcamDestruct(pThis);360 p This->pEmWebcam = NULL;376 EMWEBCAMREMOTE *pRemote = pThis->pRemote; 377 378 LogFlowFunc(("iInstance %d, pRemote %p, pIWebcamUp %p\n", 379 pDrvIns->iInstance, pRemote, pThis->pIWebcamUp)); 380 381 if (pRemote && pRemote->pEmWebcam) 382 { 383 pRemote->pEmWebcam->EmWebcamDestruct(pThis); 361 384 } 362 385 } … … 368 391 369 392 PEMWEBCAMDRV pThis = PDMINS_2_DATA(pDrvIns, PEMWEBCAMDRV); 370 371 if (!CFGMR3AreValuesValid(pCfg, "Object\0"))372 return VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES;373 393 374 394 AssertMsgReturn(PDMDrvHlpNoAttach(pDrvIns) == VERR_PDM_NO_ATTACHED_DRIVER, … … 392 412 393 413 /* Everything ok. Initialize. */ 394 pThis->p EmWebcam = (EmWebcam*)pv;395 pThis->p EmWebcam->EmWebcamConstruct(pThis);414 pThis->pRemote = (EMWEBCAMREMOTE *)pv; 415 pThis->pRemote->pEmWebcam->EmWebcamConstruct(pThis); 396 416 397 417 pDrvIns->IBase.pfnQueryInterface = drvQueryInterface;
Note:
See TracChangeset
for help on using the changeset viewer.