- Timestamp:
- Oct 16, 2013 12:09:56 PM (11 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/Makefile.kmk
r48669 r49132 304 304 $(PATH_STAGE_LIB)/SSMStandalone$(VBOX_SUFF_LIB) \ 305 305 $(LIB_DDU) 306 VBoxSVC_LIBS.win += strmiids.lib307 306 VBoxSVC_SDKS = VBOX_LIBPNG VBOX_ZLIB 308 307 VBoxSVC_LIBS.solaris = \ -
trunk/src/VBox/Main/include/HostVideoInputDeviceImpl.h
r48955 r49132 43 43 void uninit(); 44 44 45 static HRESULT queryHostDevices( HostVideoInputDeviceList *pList);45 static HRESULT queryHostDevices(VirtualBox *pVirtualBox, HostVideoInputDeviceList *pList); 46 46 47 47 private: -
trunk/src/VBox/Main/src-server/HostImpl.cpp
r48955 r49132 1760 1760 HostVideoInputDeviceList list; 1761 1761 1762 HRESULT hr = HostVideoInputDevice::queryHostDevices( &list);1762 HRESULT hr = HostVideoInputDevice::queryHostDevices(m->pParent, &list); 1763 1763 1764 1764 if (SUCCEEDED(hr)) -
trunk/src/VBox/Main/src-server/HostVideoInputDeviceImpl.cpp
r48607 r49132 19 19 #include "HostVideoInputDeviceImpl.h" 20 20 #include "Logging.h" 21 22 #ifdef RT_OS_WINDOWS23 # include <dshow.h>21 #include "VirtualBoxImpl.h" 22 #ifdef VBOX_WITH_EXTPACK 23 # include "ExtPackManagerImpl.h" 24 24 #endif 25 26 #include <iprt/ldr.h> 27 #include <iprt/path.h> 28 29 #include <VBox/sup.h> 25 30 26 31 /* … … 96 101 } 97 102 98 #ifdef RT_OS_WINDOWS 99 static HRESULT hvcdCreateEnumerator(IEnumMoniker **ppEnumMoniker) 100 { 101 ICreateDevEnum *pCreateDevEnum = NULL; 102 HRESULT hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, 103 IID_PPV_ARGS(&pCreateDevEnum)); 103 static DECLCALLBACK(int) hostWebcamAdd(void *pvUser, 104 const char *pszName, 105 const char *pszPath, 106 const char *pszAlias, 107 uint64_t *pu64Result) 108 { 109 HostVideoInputDeviceList *pList = (HostVideoInputDeviceList *)pvUser; 110 HRESULT hr = hostVideoInputDeviceAdd(pList, pszName, pszPath, pszAlias); 111 if (FAILED(hr)) 112 { 113 *pu64Result = (uint64_t)hr; 114 return VERR_NOT_SUPPORTED; 115 } 116 return VINF_SUCCESS; 117 } 118 119 /** @todo These typedefs must be in a header. */ 120 typedef DECLCALLBACK(int) FNVBOXHOSTWEBCAMADD(void *pvUser, 121 const char *pszName, 122 const char *pszPath, 123 const char *pszAlias, 124 uint64_t *pu64Result); 125 typedef FNVBOXHOSTWEBCAMADD *PFNVBOXHOSTWEBCAMADD; 126 127 typedef DECLCALLBACK(int) FNVBOXHOSTWEBCAMLIST(PFNVBOXHOSTWEBCAMADD pfnWebcamAdd, 128 void *pvUser, 129 uint64_t *pu64WebcamAddResult); 130 typedef FNVBOXHOSTWEBCAMLIST *PFNVBOXHOSTWEBCAMLIST; 131 132 static int loadHostWebcamLibrary(const char *pszPath, RTLDRMOD *phmod, PFNVBOXHOSTWEBCAMLIST *ppfn) 133 { 134 int rc = VINF_SUCCESS; 135 RTLDRMOD hmod = NIL_RTLDRMOD; 136 137 RTERRINFOSTATIC ErrInfo; 138 RTErrInfoInitStatic(&ErrInfo); 139 if (RTPathHavePath(pszPath)) 140 rc = SUPR3HardenedLdrLoadPlugIn(pszPath, &hmod, &ErrInfo.Core); 141 else 142 rc = VERR_INVALID_PARAMETER; 143 if (RT_SUCCESS(rc)) 144 { 145 static const char *pszSymbol = "VBoxHostWebcamList"; 146 rc = RTLdrGetSymbol(hmod, pszSymbol, (void **)ppfn); 147 148 if (RT_FAILURE(rc) && rc != VERR_SYMBOL_NOT_FOUND) 149 LogRel(("Resolving symbol '%s': %Rrc\n", pszSymbol, rc)); 150 } 151 else 152 { 153 LogRel(("Loading the library '%s': %Rrc\n", pszPath, rc)); 154 if (RTErrInfoIsSet(&ErrInfo.Core)) 155 LogRel((" %s\n", ErrInfo.Core.pszMsg)); 156 157 hmod = NIL_RTLDRMOD; 158 } 159 160 if (RT_SUCCESS(rc)) 161 { 162 *phmod = hmod; 163 } 164 else 165 { 166 if (hmod != NIL_RTLDRMOD) 167 { 168 RTLdrClose(hmod); 169 hmod = NIL_RTLDRMOD; 170 } 171 } 172 173 return rc; 174 } 175 176 static const Utf8Str strExtPackPuel("Oracle VM VirtualBox Extension Pack"); 177 178 static HRESULT fillDeviceList(VirtualBox *pVirtualBox, HostVideoInputDeviceList *pList) 179 { 180 HRESULT hr; 181 Utf8Str strLibrary; 182 183 #ifdef VBOX_WITH_EXTPACK 184 ExtPackManager *pExtPackMgr = pVirtualBox->getExtPackManager(); 185 hr = pExtPackMgr->getLibraryPathForExtPack("VBoxHostWebcam", &strExtPackPuel, &strLibrary); 186 #else 187 hr = E_NOTIMPL; 188 #endif 189 104 190 if (SUCCEEDED(hr)) 105 191 { 106 hr = pCreateDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, ppEnumMoniker, 0); 107 pCreateDevEnum->Release(); 108 } 109 return hr; 110 } 111 112 static HRESULT hvcdFillList(HostVideoInputDeviceList *pList, IEnumMoniker *pEnumMoniker) 113 { 114 int iDevice = 0; 115 IMoniker *pMoniker = NULL; 116 while (pEnumMoniker->Next(1, &pMoniker, NULL) == S_OK) 117 { 118 IPropertyBag *pPropBag = NULL; 119 HRESULT hr = pMoniker->BindToStorage(0, 0, IID_PPV_ARGS(&pPropBag)); 120 if (FAILED(hr)) 192 PFNVBOXHOSTWEBCAMLIST pfn = NULL; 193 RTLDRMOD hmod = NIL_RTLDRMOD; 194 int rc = loadHostWebcamLibrary(strLibrary.c_str(), &hmod, &pfn); 195 196 LogRel(("Load [%s] rc %Rrc\n", strLibrary.c_str(), rc)); 197 198 if (RT_SUCCESS(rc)) 121 199 { 122 pMoniker->Release(); 123 continue; 200 uint64_t u64Result = S_OK; 201 rc = pfn(hostWebcamAdd, pList, &u64Result); 202 Log(("VBoxHostWebcamList rc %Rrc, result 0x%08X\n", rc, u64Result)); 203 if (RT_FAILURE(rc)) 204 { 205 hr = (HRESULT)u64Result; 206 } 207 208 RTLdrClose(hmod); 209 hmod = NIL_RTLDRMOD; 124 210 } 125 211 126 VARIANT var;127 VariantInit(&var);128 129 hr = pPropBag->Read(L"DevicePath", &var, 0);130 if (FAILED(hr))131 {132 /* Can't use a device without path. */133 pMoniker->Release();134 continue;135 }136 137 ++iDevice;138 139 com::Utf8Str path = var.bstrVal;140 VariantClear(&var);141 142 hr = pPropBag->Read(L"FriendlyName", &var, 0);143 if (FAILED(hr))144 {145 hr = pPropBag->Read(L"Description", &var, 0);146 }147 148 com::Utf8Str name;149 212 if (SUCCEEDED(hr)) 150 213 { 151 name = var.bstrVal; 152 VariantClear(&var); 214 if (RT_FAILURE(rc)) 215 hr = pVirtualBox->setError(VBOX_E_IPRT_ERROR, 216 "Failed to get webcam list: %Rrc", rc); 153 217 } 154 else 155 { 156 name = com::Utf8StrFmt("Video Input Device #%d", iDevice); 157 } 158 159 com::Utf8Str alias = com::Utf8StrFmt(".%d", iDevice); 160 161 hr = hostVideoInputDeviceAdd(pList, name, path, alias); 162 163 pPropBag->Release(); 164 pMoniker->Release(); 165 166 if (FAILED(hr)) 167 return hr; 168 } 169 170 return S_OK; 171 } 172 173 static HRESULT fillDeviceList(HostVideoInputDeviceList *pList) 174 { 175 IEnumMoniker *pEnumMoniker = NULL; 176 HRESULT hr = hvcdCreateEnumerator(&pEnumMoniker); 177 if (SUCCEEDED(hr)) 178 { 179 if (hr != S_FALSE) 180 { 181 /* List not empty */ 182 hr = hvcdFillList(pList, pEnumMoniker); 183 pEnumMoniker->Release(); 184 } 185 else 186 { 187 hr = S_OK; /* Return empty list. */ 188 } 189 } 218 } 219 190 220 return hr; 191 221 } 192 #else 193 static HRESULT fillDeviceList(HostVideoInputDeviceList *pList) 194 { 195 NOREF(pList); 196 return E_NOTIMPL; 197 } 198 #endif /* RT_OS_WINDOWS */ 199 200 /* static */ HRESULT HostVideoInputDevice::queryHostDevices(HostVideoInputDeviceList *pList) 201 { 202 HRESULT hr = fillDeviceList(pList); 222 223 /* static */ HRESULT HostVideoInputDevice::queryHostDevices(VirtualBox *pVirtualBox, HostVideoInputDeviceList *pList) 224 { 225 HRESULT hr = fillDeviceList(pVirtualBox, pList); 203 226 204 227 if (FAILED(hr))
Note:
See TracChangeset
for help on using the changeset viewer.