EmulatedUSBImpl.cpp revision 9e06f22a5a8961cd7a7da569d683097b17f04dd1
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync * Emulated USB manager implementation.
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync * Copyright (C) 2013 Oracle Corporation
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync * available from http://www.virtualbox.org. This file is free software;
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync * you can redistribute it and/or modify it under the terms of the GNU
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync * General Public License (GPL) as published by the Free Software
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync#define LOG_GROUP_MAIN_OVERRIDE LOG_GROUP_MAIN_EMULATEDUSB
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync * Emulated USB webcam device instance.
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsynctypedef std::map <Utf8Str, Utf8Str> EUSBSettingsMap;
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync static DECLCALLBACK(int) emulatedWebcamAttach(PUVM pUVM, EUSBWEBCAM *pThis);
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync static DECLCALLBACK(int) emulatedWebcamDetach(PUVM pUVM, EUSBWEBCAM *pThis);
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync if (c == 0)
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync delete this;
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync bool HasId(const char *pszId) { return RTStrCmp(pszId, mszUuid) == 0;}
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync/* static */ DECLCALLBACK(int) EUSBWEBCAM::emulatedWebcamAttach(PUVM pUVM, EUSBWEBCAM *pThis)
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync for (it = pThis->mDevSettings.begin(); it != pThis->mDevSettings.end(); ++it)
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync CFGMR3InsertString(pConfig, it->first.c_str(), it->second.c_str());
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync CFGMR3InsertInteger(pEUSB, "pfnCallback", (uintptr_t)EmulatedUSB::eusbCallback);
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync CFGMR3InsertInteger(pEUSB, "pvCallback", (uintptr_t)pThis->mpEmulatedUSB);
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync CFGMR3InsertString(pLunL0, "Driver", "HostWebcam");
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync CFGMR3InsertString(pConfig, "DevicePath", pThis->mPath.c_str());
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync for (it = pThis->mDrvSettings.begin(); it != pThis->mDrvSettings.end(); ++it)
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync CFGMR3InsertString(pConfig, it->first.c_str(), it->second.c_str());
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync int rc = PDMR3UsbCreateEmulatedDevice(pUVM, "Webcam", pInstance, &pThis->mUuid);
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync LogRelFlowFunc(("PDMR3UsbCreateEmulatedDevice %Rrc\n", rc));
f5ab5688c35373443d953e2a9fa8a054defdece8vboxsync/* static */ DECLCALLBACK(int) EUSBWEBCAM::emulatedWebcamDetach(PUVM pUVM, EUSBWEBCAM *pThis)
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync RTStrPrintf(mszUuid, sizeof(mszUuid), "%RTuuid", &mUuid);
pUVM, this);
return hrc;
pUVM, this);
return hrc;
return BaseFinalConstruct();
uninit();
return S_OK;
p->Release();
size_t i;
return hrc;
p->AddRef();
p->Release();
return hrc;
p->Release();
return hrc;
/* static */ DECLCALLBACK(int) EmulatedUSB::eusbCallbackEMT(EmulatedUSB *pThis, char *pszId, uint32_t iEvent,
if (iEvent == 0)
return rc;
/* static */ DECLCALLBACK(int) EmulatedUSB::eusbCallback(void *pv, const char *pszId, uint32_t iEvent,
/* Make a copy of parameters, forward to EMT and leave the callback to not hold any lock in the device. */
if (cbData > 0)
if (!pvDataCopy)
if (!pvIdCopy)
return rc;
return hr;