Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

956 lines
25 KiB

  1. /*****************************************************************************
  2. *
  3. * (C) COPYRIGHT MICROSOFT CORPORATION, 1999-2000
  4. *
  5. * TITLE: ItemTree.cpp
  6. *
  7. * VERSION: 1.0
  8. *
  9. * AUTHOR: RickTu
  10. *
  11. * DATE: 9/10/99 RickTu
  12. * 2000/11/09 OrenR
  13. *
  14. * DESCRIPTION: This code was originally in 'camera.cpp' but was broken out.
  15. * This code builds and maintains the camera's IWiaDrvItem tree.
  16. *
  17. *
  18. *****************************************************************************/
  19. #include <precomp.h>
  20. #pragma hdrstop
  21. /*****************************************************************************
  22. CVideoStiUsd::BuildItemTree
  23. Constructs an item tree which represents the layout of this
  24. WIA camera...
  25. *****************************************************************************/
  26. STDMETHODIMP
  27. CVideoStiUsd::BuildItemTree(IWiaDrvItem ** ppIDrvItemRoot,
  28. LONG * plDevErrVal)
  29. {
  30. HRESULT hr;
  31. DBG_FN("CVideoStiUsd::BuildItemTree");
  32. EnterCriticalSection( &m_csItemTree );
  33. //
  34. // Check for bad args
  35. //
  36. if (!ppIDrvItemRoot)
  37. {
  38. hr = E_POINTER;
  39. }
  40. //
  41. // Make sure that there is only one item tree
  42. //
  43. else if (m_pRootItem)
  44. {
  45. *ppIDrvItemRoot = m_pRootItem;
  46. //
  47. // refresh our tree. We prune out all files which no longer exist
  48. // but for some reason remain in our tree (this can happen if someone
  49. // manually deletes a file from the temp WIA directory where we store
  50. // these images before they are transfered)
  51. //
  52. RefreshTree(m_pRootItem, plDevErrVal);
  53. hr = S_OK;
  54. }
  55. //
  56. // Lastly, build the tree if we need to
  57. //
  58. else
  59. {
  60. //
  61. // First check to see if we have a corresponding DShow device id
  62. // in the registry -- if not, then bail.
  63. //
  64. if (!m_strDShowDeviceId.Length())
  65. {
  66. hr = E_FAIL;
  67. CHECK_S_OK2(hr, ("CVideoStiUsd::BuildItemTree, the DShow Device ID"
  68. "is empty, this should never happen"));
  69. }
  70. else
  71. {
  72. //
  73. // Create the new root
  74. //
  75. CSimpleBStr bstrRoot(L"Root");
  76. //
  77. // Call Wia service library to create new root item
  78. //
  79. hr = wiasCreateDrvItem(WiaItemTypeFolder |
  80. WiaItemTypeRoot |
  81. WiaItemTypeDevice,
  82. bstrRoot.BString(),
  83. CSimpleBStr(m_strRootFullItemName),
  84. (IWiaMiniDrv *)this,
  85. sizeof(STILLCAM_IMAGE_CONTEXT),
  86. NULL,
  87. ppIDrvItemRoot);
  88. CHECK_S_OK2( hr, ("wiaCreateDrvItem" ));
  89. if (SUCCEEDED(hr) && *ppIDrvItemRoot)
  90. {
  91. m_pRootItem = *ppIDrvItemRoot;
  92. //
  93. // Add the items for this device
  94. //
  95. hr = EnumSavedImages( m_pRootItem );
  96. CHECK_S_OK2( hr, ("EnumSavedImages" ));
  97. }
  98. }
  99. }
  100. LeaveCriticalSection(&m_csItemTree);
  101. CHECK_S_OK(hr);
  102. return hr;
  103. }
  104. /*****************************************************************************
  105. CVideoStiUsd::AddTreeItem
  106. <Notes>
  107. *****************************************************************************/
  108. HRESULT
  109. CVideoStiUsd::AddTreeItem(CSimpleString *pstrFullImagePath,
  110. IWiaDrvItem **ppDrvItem)
  111. {
  112. HRESULT hr = S_OK;
  113. INT iPos = 0;
  114. LPCTSTR pszFileName = NULL;
  115. if (pstrFullImagePath == NULL)
  116. {
  117. hr = E_INVALIDARG;
  118. CHECK_S_OK2(hr, ("CVideoStiUsd::AddTreeItem, received NULL "
  119. "param"));
  120. return hr;
  121. }
  122. //
  123. // Extract the file name from the full path. We do this by searching
  124. // for the first '\' from the end of the string.
  125. //
  126. iPos = pstrFullImagePath->ReverseFind('\\');
  127. if (iPos < (INT) pstrFullImagePath->Length())
  128. {
  129. //
  130. // increment the position by 1 because we want to skip over the
  131. // backslash.
  132. //
  133. ++iPos;
  134. //
  135. // point to the filename within the full path.
  136. //
  137. pszFileName = &(*pstrFullImagePath)[iPos];
  138. }
  139. if (pszFileName)
  140. {
  141. //
  142. // Create a new DrvItem for this image and add it to the
  143. // DrvItem tree.
  144. //
  145. IWiaDrvItem *pNewFolder = NULL;
  146. hr = CreateItemFromFileName(WiaItemTypeFile | WiaItemTypeImage,
  147. pstrFullImagePath->String(),
  148. pszFileName,
  149. &pNewFolder);
  150. CHECK_S_OK2( hr, ("CVideoStiUsd::AddTreeItem, "
  151. "CreateItemFromFileName failed"));
  152. if (hr == S_OK)
  153. {
  154. hr = pNewFolder->AddItemToFolder(m_pRootItem);
  155. CHECK_S_OK2( hr, ("CVideoStiUsd::AddTreeItem, "
  156. "pNewFolder->AddItemToFolder failed"));
  157. }
  158. if (ppDrvItem)
  159. {
  160. *ppDrvItem = pNewFolder;
  161. (*ppDrvItem)->AddRef();
  162. }
  163. pNewFolder->Release();
  164. }
  165. return hr;
  166. }
  167. /*****************************************************************************
  168. CVideoStiUsd::EnumSavedImages
  169. <Notes>
  170. *****************************************************************************/
  171. STDMETHODIMP
  172. CVideoStiUsd::EnumSavedImages(IWiaDrvItem * pRootItem)
  173. {
  174. DBG_FN("CVideoStiUsd::EnumSavedImages");
  175. HRESULT hr = S_OK;
  176. WIN32_FIND_DATA FindData;
  177. if (!m_strStillPath.Length())
  178. {
  179. DBG_ERR(("m_strStillPath is NULL, can't continue!"));
  180. return E_FAIL;
  181. }
  182. CSimpleString strTempName(m_strStillPath);
  183. strTempName.Concat( TEXT("\\*.jpg") );
  184. //
  185. // look for files at this level
  186. //
  187. HANDLE hFile = FindFirstFile(strTempName.String(), &FindData);
  188. if (hFile != INVALID_HANDLE_VALUE)
  189. {
  190. BOOL bStatus = FALSE;
  191. do
  192. {
  193. //
  194. // generate file name
  195. //
  196. strTempName.Assign( m_strStillPath );
  197. strTempName.Concat( TEXT("\\") );
  198. strTempName.Concat( FindData.cFileName );
  199. hr = AddTreeItem(&strTempName, NULL);
  200. if (FAILED(hr))
  201. {
  202. continue;
  203. }
  204. //
  205. // look for more images
  206. //
  207. bStatus = FindNextFile(hFile,&FindData);
  208. } while (bStatus);
  209. FindClose(hFile);
  210. }
  211. return S_OK;
  212. }
  213. /*****************************************************************************
  214. CVideoStiUsd::DoesFileExist
  215. <Notes>
  216. *****************************************************************************/
  217. BOOL
  218. CVideoStiUsd::DoesFileExist(BSTR bstrFileName)
  219. {
  220. DBG_FN("CVideoStiUsd::DoesFileExist");
  221. BOOL bExists = FALSE;
  222. DWORD dwAttrib = 0;
  223. if (bstrFileName == NULL)
  224. {
  225. return FALSE;
  226. }
  227. CSimpleString strTempName(m_strStillPath);
  228. strTempName.Concat(TEXT("\\"));
  229. strTempName.Concat(bstrFileName);
  230. strTempName.Concat(TEXT(".jpg"));
  231. dwAttrib = ::GetFileAttributes(strTempName);
  232. if (dwAttrib != 0xFFFFFFFF)
  233. {
  234. bExists = TRUE;
  235. }
  236. else
  237. {
  238. bExists = FALSE;
  239. }
  240. return bExists;
  241. }
  242. /*****************************************************************************
  243. CVideoStiUsd::PruneTree
  244. Removes nodes from the tree whose filenames no longer exist in the temp
  245. directory
  246. *****************************************************************************/
  247. HRESULT
  248. CVideoStiUsd::PruneTree(IWiaDrvItem * pRootItem,
  249. BOOL * pbTreeChanged)
  250. {
  251. DBG_FN("CVideoStiUsd::PruneTree");
  252. HRESULT hr = S_OK;
  253. BOOL bTreeChanged = FALSE;
  254. IWiaDrvItem *pCurrentItem = NULL;
  255. IWiaDrvItem *pNextItem = NULL;
  256. BSTR bstrItemName = NULL;
  257. if ((pRootItem == NULL) || (pbTreeChanged == NULL))
  258. {
  259. return E_INVALIDARG;
  260. }
  261. else if (!m_strStillPath.Length())
  262. {
  263. DBG_ERR(("m_strStillPath is NULL, can't continue!"));
  264. return E_FAIL;
  265. }
  266. // This function DOES NOT do an AddRef
  267. hr = pRootItem->GetFirstChildItem(&pCurrentItem);
  268. while ((hr == S_OK) && (pCurrentItem != NULL))
  269. {
  270. pNextItem = NULL;
  271. pCurrentItem->AddRef();
  272. hr = pCurrentItem->GetItemName(&bstrItemName);
  273. if (SUCCEEDED(hr) && (bstrItemName != NULL))
  274. {
  275. //
  276. // if the filename for this item does not exist,
  277. // then remove it from our tree.
  278. //
  279. if (!DoesFileExist(bstrItemName))
  280. {
  281. //
  282. // get the next item in the list so we don't lose our place
  283. // in the list after removing the current item.
  284. //
  285. hr = pCurrentItem->GetNextSiblingItem(&pNextItem);
  286. CHECK_S_OK2(hr, ("pCurrentItem->GetNextSiblingItem"));
  287. //
  288. // remove the item from the folder, we no longer need it.
  289. //
  290. hr = pCurrentItem->RemoveItemFromFolder(WiaItemTypeDeleted);
  291. CHECK_S_OK2(hr, ("pItemToRemove->RemoveItemFromFolder"));
  292. //
  293. // Report the error, but continue. If we failed to
  294. // remove the item from the tree, for whatever reason,
  295. // there really is nothing we can do but proceed and
  296. // prune the remainder of the tree.
  297. //
  298. if (hr != S_OK)
  299. {
  300. DBG_ERR(("Failed to remove item from folder, "
  301. "hr = 0x%08lx",
  302. hr));
  303. hr = S_OK;
  304. }
  305. if (m_lPicsTaken > 0)
  306. {
  307. //
  308. // Decrement the # of pics taken only if the
  309. // current # of pics is greater than 0.
  310. //
  311. InterlockedCompareExchange(
  312. &m_lPicsTaken,
  313. m_lPicsTaken - 1,
  314. (m_lPicsTaken > 0) ? m_lPicsTaken : -1);
  315. }
  316. //
  317. // Indicate the tree was changed so we can send a notification
  318. // when we are done.
  319. //
  320. bTreeChanged = TRUE;
  321. }
  322. else
  323. {
  324. // file does exist, all is well in the world, move on to next
  325. // item in the tree.
  326. hr = pCurrentItem->GetNextSiblingItem(&pNextItem);
  327. }
  328. }
  329. //
  330. // release the current item since we AddRef'd it at the start of this
  331. // loop.
  332. //
  333. pCurrentItem->Release();
  334. pCurrentItem = NULL;
  335. //
  336. // set our next item to be our current item. It is possible that
  337. // pNextItem is NULL.
  338. //
  339. pCurrentItem = pNextItem;
  340. //
  341. // Free the BSTR.
  342. //
  343. if (bstrItemName)
  344. {
  345. ::SysFreeString(bstrItemName);
  346. bstrItemName = NULL;
  347. }
  348. }
  349. hr = S_OK;
  350. if (pbTreeChanged)
  351. {
  352. *pbTreeChanged = bTreeChanged;
  353. }
  354. return hr;
  355. }
  356. /*****************************************************************************
  357. CVideoStiUsd::IsFileAlreadyInTree
  358. <Notes>
  359. *****************************************************************************/
  360. BOOL
  361. CVideoStiUsd::IsFileAlreadyInTree(IWiaDrvItem * pRootItem,
  362. LPCTSTR pszFileName)
  363. {
  364. DBG_FN("CVideoStiUsd::IsFileAlreadyInTree");
  365. HRESULT hr = S_OK;
  366. BOOL bFound = FALSE;
  367. IWiaDrvItem *pCurrentItem = NULL;
  368. if ((pRootItem == NULL) ||
  369. (pszFileName == NULL))
  370. {
  371. bFound = FALSE;
  372. DBG_ERR(("CVideoStiUsd::IsFileAlreadyInTree received a NULL pointer, "
  373. "returning FALSE, item not found in tree."));
  374. return bFound;
  375. }
  376. CSimpleString strFileName( m_strStillPath );
  377. CSimpleString strBaseName( pszFileName );
  378. strFileName.Concat( TEXT("\\") );
  379. strFileName.Concat( strBaseName );
  380. CImage Image(m_strStillPath,
  381. CSimpleBStr(m_strRootFullItemName),
  382. strFileName.String(),
  383. strBaseName.String(),
  384. WiaItemTypeFile | WiaItemTypeImage);
  385. hr = pRootItem->FindItemByName(0,
  386. Image.bstrFullItemName(),
  387. &pCurrentItem);
  388. if (hr == S_OK)
  389. {
  390. bFound = TRUE;
  391. //
  392. // Don't forget to release the driver item, since it was AddRef'd by
  393. // FindItemByName(..)
  394. //
  395. pCurrentItem->Release();
  396. }
  397. else
  398. {
  399. bFound = FALSE;
  400. }
  401. return bFound;
  402. }
  403. /*****************************************************************************
  404. CVideoStiUsd::AddNewFilesToTree
  405. <Notes>
  406. *****************************************************************************/
  407. HRESULT
  408. CVideoStiUsd::AddNewFilesToTree(IWiaDrvItem * pRootItem,
  409. BOOL * pbTreeChanged)
  410. {
  411. DBG_FN("CVideoStiUsd::AddNewFilesToTree");
  412. HRESULT hr = E_FAIL;
  413. BOOL bTreeChanged = FALSE;
  414. HANDLE hFile = NULL;
  415. BOOL bFileFound = FALSE;
  416. WIN32_FIND_DATA FindData;
  417. if ((pRootItem == NULL) ||
  418. (pbTreeChanged == NULL))
  419. {
  420. return E_INVALIDARG;
  421. }
  422. if (!m_strStillPath.Length())
  423. {
  424. DBG_ERR(("m_strStillPath is NULL, can't continue!"));
  425. return E_FAIL;
  426. }
  427. CSimpleString strTempName(m_strStillPath);
  428. strTempName.Concat( TEXT("\\*.jpg") );
  429. //
  430. // Find all JPG files in the m_strStillPath directory.
  431. // This directory is %windir%\temp\wia\{Device GUID}\XXXX
  432. // where X is numeric.
  433. //
  434. hFile = FindFirstFile(strTempName.String(), &FindData);
  435. if (hFile != INVALID_HANDLE_VALUE)
  436. {
  437. bFileFound = TRUE;
  438. }
  439. //
  440. // Iterate through all files in the directory and for each
  441. // one check to see if it is already in the tree. If it
  442. // isn't, then add it to the tree. If it is, do nothing
  443. // and move to the next file in the directory
  444. //
  445. while (bFileFound)
  446. {
  447. //
  448. // Check if the file in the directory is already in our
  449. // tree.
  450. //
  451. if (!IsFileAlreadyInTree(pRootItem, FindData.cFileName))
  452. {
  453. //
  454. // add an image to this folder
  455. //
  456. // generate file name
  457. //
  458. strTempName.Assign( m_strStillPath );
  459. strTempName.Concat( TEXT("\\") );
  460. strTempName.Concat( FindData.cFileName );
  461. hr = AddTreeItem(&strTempName, NULL);
  462. //
  463. // Set this flag to indicate that changes were made to the
  464. // tree, hence we will send an event indicating this when we
  465. // are done.
  466. //
  467. bTreeChanged = TRUE;
  468. }
  469. //
  470. // look for more images
  471. //
  472. bFileFound = FindNextFile(hFile,&FindData);
  473. }
  474. if (hFile)
  475. {
  476. FindClose(hFile);
  477. hFile = NULL;
  478. }
  479. if (pbTreeChanged)
  480. {
  481. *pbTreeChanged = bTreeChanged;
  482. }
  483. return S_OK;
  484. }
  485. /*****************************************************************************
  486. CVideoStiUsd::RefreshTree
  487. <Notes>
  488. *****************************************************************************/
  489. STDMETHODIMP
  490. CVideoStiUsd::RefreshTree(IWiaDrvItem * pRootItem,
  491. LONG * plDevErrVal)
  492. {
  493. DBG_FN("CVideoStiUsd::RefreshTree");
  494. BOOL bItemsAdded = FALSE;
  495. BOOL bItemsRemoved = FALSE;
  496. HRESULT hr = S_OK;
  497. //
  498. // Remove any dead nodes from the tree. A dead node is a node in the tree
  499. // whose file has been deleted from the directory in m_strStillPath,
  500. // but we still have a tree item for it.
  501. //
  502. hr = PruneTree(pRootItem, &bItemsRemoved);
  503. CHECK_S_OK2(hr, ("PruneTree"));
  504. //
  505. // Add any news files that have been added to the folder but for some
  506. // reason we don't have a tree node for them.
  507. //
  508. hr = AddNewFilesToTree(pRootItem, &bItemsAdded);
  509. CHECK_S_OK2(hr, ("AddNewFilesToTree"));
  510. //
  511. // If we added new nodes, removed some nodes, or both, then notify the
  512. // guys upstairs (in the UI world) that the tree has been updated.
  513. //
  514. if ((bItemsAdded) || (bItemsRemoved))
  515. {
  516. hr = wiasQueueEvent(CSimpleBStr(m_strDeviceId),
  517. &WIA_EVENT_TREE_UPDATED,
  518. NULL);
  519. }
  520. return hr;
  521. }
  522. /*****************************************************************************
  523. CVideoStiUsd::CreateItemFromFileName
  524. Helper function that creates a WIA item from a filename (which is a .jpg).
  525. *****************************************************************************/
  526. STDMETHODIMP
  527. CVideoStiUsd::CreateItemFromFileName(LONG FolderType,
  528. LPCTSTR pszPath,
  529. LPCTSTR pszName,
  530. IWiaDrvItem ** ppNewFolder)
  531. {
  532. HRESULT hr = E_FAIL;
  533. IWiaDrvItem * pNewFolder = NULL;
  534. PSTILLCAM_IMAGE_CONTEXT pContext = NULL;
  535. DBG_FN("CVideoStiUsd::CreateItemFromFileName");
  536. //
  537. // Check for bad args
  538. //
  539. if (!ppNewFolder)
  540. {
  541. DBG_ERR(("ppNewFolder is NULL, returning E_INVALIDARG"));
  542. return E_INVALIDARG;
  543. }
  544. //
  545. // Set up return value
  546. //
  547. *ppNewFolder = NULL;
  548. //
  549. // Create new image object
  550. //
  551. CImage * pImage = new CImage(m_strStillPath,
  552. CSimpleBStr(m_strRootFullItemName),
  553. pszPath,
  554. pszName,
  555. FolderType);
  556. if (!pImage)
  557. {
  558. DBG_ERR(("Couldn't create new CImage, returning E_OUTOFMEMORY"));
  559. return E_OUTOFMEMORY;
  560. }
  561. //
  562. // call Wia to create new DrvItem
  563. //
  564. hr = wiasCreateDrvItem(FolderType,
  565. pImage->bstrItemName(),
  566. pImage->bstrFullItemName(),
  567. (IWiaMiniDrv *)this,
  568. sizeof(STILLCAM_IMAGE_CONTEXT),
  569. (BYTE **)&pContext,
  570. &pNewFolder);
  571. CHECK_S_OK2( hr, ("wiasCreateDrvItem"));
  572. if (SUCCEEDED(hr) && pNewFolder)
  573. {
  574. //
  575. // init device specific context
  576. //
  577. pContext->pImage = pImage;
  578. //
  579. // Return the item
  580. //
  581. *ppNewFolder = pNewFolder;
  582. //
  583. // Inc the number of pictures taken
  584. //
  585. InterlockedIncrement(&m_lPicsTaken);
  586. }
  587. else
  588. {
  589. DBG_ERR(("CVideoStiUsd::CreateItemFromFileName - wiasCreateItem "
  590. "failed or returned NULL pNewFolder, hr = 0x%08lx, "
  591. "pNewFolder = 0x%08lx, pContext = 0x%08lx",
  592. hr,
  593. pNewFolder,pContext ));
  594. delete pImage;
  595. hr = E_OUTOFMEMORY;
  596. }
  597. return hr;
  598. }
  599. /*****************************************************************************
  600. CVideoStiUsd::InitDeviceProperties
  601. Initializes properties for the device on the device root item.
  602. *****************************************************************************/
  603. STDMETHODIMP
  604. CVideoStiUsd::InitDeviceProperties(BYTE * pWiasContext,
  605. LONG * plDevErrVal)
  606. {
  607. HRESULT hr = S_OK;
  608. BSTR bstrFirmwreVer = NULL;
  609. int i = 0;
  610. SYSTEMTIME camTime;
  611. PROPVARIANT propVar;
  612. DBG_FN("CVideoStiUsd::InitDeviceProperties");
  613. //
  614. // This device doesn't touch hardware to initialize the device properties.
  615. //
  616. if (plDevErrVal)
  617. {
  618. *plDevErrVal = 0;
  619. }
  620. //
  621. // Parameter validation.
  622. //
  623. if (pWiasContext == NULL)
  624. {
  625. hr = E_INVALIDARG;
  626. CHECK_S_OK2(hr, ("CVideoStiUsd::InitDeviceProperties received "
  627. "NULL param."));
  628. return hr;
  629. }
  630. //
  631. // Write standard property names
  632. //
  633. hr = wiasSetItemPropNames(pWiasContext,
  634. sizeof(gDevicePropIDs)/sizeof(PROPID),
  635. gDevicePropIDs,
  636. gDevicePropNames);
  637. CHECK_S_OK2(hr, ("wiaSetItemPropNames"));
  638. if (hr == S_OK)
  639. {
  640. //
  641. // Write the properties supported by all WIA devices
  642. //
  643. bstrFirmwreVer = SysAllocString(L"<NA>");
  644. if (bstrFirmwreVer)
  645. {
  646. wiasWritePropStr(pWiasContext,
  647. WIA_DPA_FIRMWARE_VERSION,
  648. bstrFirmwreVer);
  649. SysFreeString(bstrFirmwreVer);
  650. }
  651. hr = wiasWritePropLong(pWiasContext, WIA_DPA_CONNECT_STATUS, 1);
  652. hr = wiasWritePropLong(pWiasContext, WIA_DPC_PICTURES_TAKEN, 0);
  653. //
  654. // Write the camera properties, just default values, it may
  655. // vary with items
  656. //
  657. hr = wiasWritePropLong(pWiasContext, WIA_DPC_THUMB_WIDTH, 80);
  658. hr = wiasWritePropLong(pWiasContext, WIA_DPC_THUMB_HEIGHT, 60);
  659. //
  660. // Write the Directshow Device ID
  661. //
  662. hr = wiasWritePropStr(pWiasContext,
  663. WIA_DPV_DSHOW_DEVICE_PATH,
  664. CSimpleBStr(m_strDShowDeviceId));
  665. //
  666. // Write the Images Directory
  667. //
  668. hr = wiasWritePropStr(pWiasContext,
  669. WIA_DPV_IMAGES_DIRECTORY,
  670. CSimpleBStr(m_strStillPath));
  671. //
  672. // Write the Last Picture Taken
  673. //
  674. hr = wiasWritePropStr(pWiasContext,
  675. WIA_DPV_LAST_PICTURE_TAKEN,
  676. CSimpleBStr(TEXT("")));
  677. //
  678. // Use WIA services to set the property access and
  679. // valid value information from gDevPropInfoDefaults.
  680. //
  681. hr = wiasSetItemPropAttribs(pWiasContext,
  682. NUM_CAM_DEV_PROPS,
  683. gDevicePropSpecDefaults,
  684. gDevPropInfoDefaults);
  685. }
  686. return S_OK;
  687. }
  688. /*****************************************************************************
  689. CVideoStiUsd::InitImageInformation
  690. Used to initialize device items (images) from this device.
  691. *****************************************************************************/
  692. STDMETHODIMP
  693. CVideoStiUsd::InitImageInformation( BYTE * pWiasContext,
  694. PSTILLCAM_IMAGE_CONTEXT pContext,
  695. LONG * plDevErrVal
  696. )
  697. {
  698. HRESULT hr = S_OK;
  699. DBG_FN("CVideoStiUsd::InitImageInformation");
  700. //
  701. // Check for bad args
  702. //
  703. if ((pWiasContext == NULL) ||
  704. (pContext == NULL))
  705. {
  706. hr = E_INVALIDARG;
  707. CHECK_S_OK2(hr, ("CVideoStiUsd::InitImageInformation, received "
  708. "NULL params"));
  709. return hr;
  710. }
  711. //
  712. // Get the image in question
  713. //
  714. CImage * pImage = pContext->pImage;
  715. if (pImage == NULL)
  716. {
  717. hr = E_INVALIDARG;
  718. }
  719. if (hr == S_OK)
  720. {
  721. //
  722. // Ask the image to initialize the information
  723. //
  724. hr = pImage->InitImageInformation(pWiasContext, plDevErrVal);
  725. }
  726. return hr;
  727. }