Source code of Windows XP (NT5)
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.

1350 lines
35 KiB

  1. /*=============================================================================
  2. |
  3. | File: dmotest.cpp
  4. |
  5. | Copyright (c) 2000 Microsoft Corporation. All rights reserved
  6. |
  7. | Abstract:
  8. | bridge code between dmo test case functions and shell98
  9. |
  10. | Contents:
  11. |
  12. | History:
  13. | 5/3/2000 wendyliu initial version
  14. |
  15. |
  16. \============================================================================*/
  17. #include <stdio.h>
  18. #include <windows.h>
  19. #include <commctrl.h>
  20. #include <s98inc.h>
  21. #include <cderr.h> // controls which shell (EXE or DLL form) is used
  22. #include <commdlg.h> // includes common dialog functionality
  23. #include <dlgs.h> // includes common dialog template defines
  24. #include "dmotest.h" // Derives a variable passing test module Class
  25. // from CTreeModule
  26. #include "dmoApiTst.h" // test case functions
  27. #include "resource.h"
  28. #include "DmoTestCases.h"
  29. BOOL AddListViewItems(HWND hLV);
  30. BOOL AddTestFilesInListView(HWND hLV);
  31. BOOL GetTestFileName( HWND hWnd, HWND hLV );
  32. BOOL GetInOutFileName( HWND hWnd, HWND hLV );
  33. BOOL SaveSelectedTestFiles(HWND hLV);
  34. BOOL WriteSelectedDmos();
  35. BOOL GetRegisteredDmos();
  36. int g_dwNumOfComponents;
  37. int g_dwNumOfSelectedComponents;
  38. //struct of components to be tested
  39. typedef struct
  40. {
  41. char szComName[MAX_LEN];
  42. char szClsid[MAX_LEN];
  43. int iSelectedForTest;
  44. int iNumTestFiles;
  45. char szInputFile[MAX_LEN][MAX_LEN];
  46. } ComInfo;
  47. ComInfo g_component[MAX_LEN];
  48. CDmoTest* pThis = NULL;
  49. HWND CDmoTest::m_hSelectFilesDlg = NULL;
  50. HWND CDmoTest::m_hSelectDmoDlg = NULL;
  51. HWND CDmoTest::m_hMediaTypeDlg = NULL;
  52. HWND CDmoTest::m_hDataGenDlg = NULL;
  53. /*=============================================================================
  54. | Test file selection dialog stuff
  55. |------------------------------------------------------------------------------
  56. |
  57. \============================================================================*/
  58. typedef struct _MYDATA
  59. {
  60. char szTest1[80]; // a test buffer containing the file selected
  61. char szTest2[80]; // a test buffer containing the file path
  62. } MYDATA, FAR * LPMYDATA;
  63. MYDATA sMyData; // an instance of a MYDATA
  64. CFactoryTemplate g_Templates[2]= { { 0 // CFactoryTemplate.m_name
  65. , 0 // CFactoryTemplate.m_ClsID
  66. , 0 // CFactoryTemplate.m_lpfnNew
  67. , NULL // CFactoryTemplate.m_lpfnInit
  68. , 0 // CFactoryTemplate.m_pAMovieSetup_Filter
  69. }
  70. };
  71. int g_cTemplates = sizeof(g_Templates) / sizeof(g_Templates[0]);
  72. /*=============================================================================
  73. | Shell98 / ModMgr98 stuff
  74. |------------------------------------------------------------------------------
  75. | Notes:
  76. | The only things that should need to be changed in this area are the
  77. | derived class name, the module name, and the App ID.
  78. \============================================================================*/
  79. static LPSTR szModuleName = "DMO TEST";
  80. static DWORD dwAppID = 1104;
  81. CTreeModule* g_pVariableModule;
  82. /*=============================================================================
  83. | Function: InitCaseTree
  84. | Purpose:
  85. | Arguments: None
  86. | Returns: None
  87. | Notes:
  88. | This function is called by the constructor of this Module, providing a central
  89. | function from them. Rather than statically adding cases to a public
  90. | structure, these functions provide a consistent interface through which
  91. | to add cases to a test application.
  92. | Full descriptions of AddCase(), AddGroup(), EndGroup(), and EndBranch()
  93. | can be found in "treemod.cpp".
  94. | Additional:
  95. | In this particular version, through the use of CDmoTestCase (derived from
  96. | CTestNodeItem), AddCase has been overloaded to allow the
  97. | passing of the container dmotest to the test function.
  98. \============================================================================*/
  99. void CDmoTest::InitCaseTree()
  100. {
  101. AddGroup("DMOTest", 0);
  102. AddGroup("Functional Test",0);
  103. AddCase("1.0", "DMO Functional Test 1: Positive Timestamp Offset Test", FunctionalTest1, pThis );
  104. AddCase("1.1", "DMO Functional Test 2: Negative Timestamp Offset Test", FunctionalTest2, pThis );
  105. EndGroup();
  106. AddGroup("IMediaObject Interface Test",0);
  107. AddCase("2.0", "Test GetStreamCount()", TestGetStreamCount, pThis );
  108. AddCase("2.1", "Test GetInputType()", TestGetTypes, pThis );
  109. AddCase("2.2", "Test Stream Index on GetInputStreamInfo()", TestStreamIndexOnGetInputStreamInfo, pThis);
  110. AddCase("2.3", "Test Stream Index on GetOutputStreamInfo()", TestStreamIndexOnGetOutputStreamInfo, pThis );
  111. AddCase("2.4", "Test Invalide Parameter on GetInputStreamInfo()", TestInvalidParamOnGetInputStreamInfo, pThis );
  112. AddCase("2.5", "Test Invalide Parameter on GetOutputStreamInfo()", TestInvalidParamOnGetOutputStreamInfo, pThis );
  113. EndGroup();
  114. }
  115. /*-----------------------------------------------------------------------------
  116. | Function: DllMain
  117. | Purpose: DLL initialization and exit code
  118. | Arguments:
  119. | Returns: FALSE on failure, TRUE on success
  120. | Notes:
  121. | If this module ends up being used by ModMgr98 this will be needed.
  122. | If not it doesn't hurt.
  123. \----------------------------------------------------------------------------*/
  124. BOOL CALLBACK DllMain
  125. (
  126. HINSTANCE hinst,
  127. DWORD dwReason,
  128. LPVOID lpReserved
  129. )
  130. {
  131. BOOL fRes = TRUE;
  132. g_hInst = hinst;
  133. switch (dwReason)
  134. {
  135. case DLL_PROCESS_ATTACH:
  136. break;
  137. case DLL_PROCESS_DETACH:
  138. break;
  139. }
  140. return fRes;
  141. }
  142. ITestShell* g_IShell;
  143. /*-----------------------------------------------------------------------------
  144. | Function: NewTestModule
  145. | Purpose: Called as the shell loads to setup the derived test module
  146. | class inside the shell
  147. | Arguments: pShell - Pointer to shell for tests' access
  148. | hInstDLL -
  149. | Returns: CTestModule* to this test module class
  150. \----------------------------------------------------------------------------*/
  151. CTestModule* WINAPI
  152. NewTestModule
  153. (
  154. CTestShell* pShell,
  155. HINSTANCE hInstDLL
  156. )
  157. {
  158. g_IShell = (ITestShell*)pShell;
  159. g_pVariableModule = new CDmoTest(pShell, hInstDLL);
  160. g_hInst = hInstDLL;
  161. return (CTestModule*)g_pVariableModule;
  162. }
  163. /*-----------------------------------------------------------------------------
  164. | Function: CDmoTest::CDmoTest
  165. | Purpose: Constructor for derived module class.
  166. | Arguments: pShell - Pointer to shell for tests' access
  167. | hInstDLL -
  168. | Returns: None
  169. | Notes: Additional Initialization for this module should
  170. | _NOT_ be put here
  171. \----------------------------------------------------------------------------*/
  172. CDmoTest::CDmoTest
  173. (
  174. CTestShell* pShell,
  175. HINSTANCE hInstDLL
  176. ) : CTreeModule(pShell, hInstDLL)
  177. {
  178. m_dwAppID = dwAppID;
  179. m_pstrModuleName = szModuleName;
  180. InitCaseTree();
  181. g_hInst = hInstDLL;
  182. m_nIconID = APPICON;
  183. m_dwModuleType = STTYPE_DSOUND | STTYPE_DSCAPTURE | STTYPE_WAVEOUT | STTYPE_WAVEIN | STTYPE_MIXER;
  184. }
  185. /*-----------------------------------------------------------------------------
  186. | Function: CDmoTest::~CDmoTest
  187. | Purpose: Destructor for derived module class.
  188. | Arguments: None
  189. | Returns: None
  190. | Notes: Any clean up from the Initialize function should be put here.
  191. \----------------------------------------------------------------------------*/
  192. CDmoTest::~CDmoTest
  193. (
  194. void
  195. )
  196. {
  197. SaveSettings(" ", " ");
  198. }
  199. /*-----------------------------------------------------------------------------
  200. | Function: CDmoTest::Initialize
  201. | Purpose: Initialize derived module class
  202. | Arguments: None
  203. | Returns: 0 = Success, otherwise failure
  204. | Notes: Additional Initialization for this module should be put here
  205. \----------------------------------------------------------------------------*/
  206. DWORD
  207. CDmoTest::Initialize
  208. (
  209. void
  210. )
  211. {
  212. return 0;
  213. }
  214. //wrapper for AddCase in tree module
  215. void
  216. CDmoTest::AddCase(LPSTR pszCaseID, LPSTR pszName, DMOTESTFNPROC1 pfnTest, CDmoTest* pDmoTest)
  217. {
  218. AddNode(new CDmoTestCase1(pszCaseID, pszName, pfnTest, pDmoTest));
  219. }
  220. //wrapper for AddCase in tree module
  221. void
  222. CDmoTest::AddCase(LPSTR pszCaseID, LPSTR pszName, DMOTESTFNPROC2 pfnTest, CDmoTest* pDmoTest)
  223. {
  224. AddNode(new CDmoTestCase2(pszCaseID, pszName, pfnTest, pDmoTest));
  225. }
  226. // access function
  227. int
  228. CDmoTest::GetNumComponent()
  229. {
  230. return g_dwNumOfComponents;
  231. }
  232. // access function
  233. LPSTR
  234. CDmoTest::GetDmoName(int i)
  235. {
  236. return g_component[i].szComName;
  237. }
  238. // access function
  239. LPSTR
  240. CDmoTest::GetDmoClsid(int i)
  241. {
  242. return g_component[i].szClsid;
  243. }
  244. // access function
  245. BOOL
  246. CDmoTest::IsDmoSelected(int i)
  247. {
  248. if(0 != ListView_GetCheckState(
  249. pThis->m_hDmoList,
  250. i))
  251. {
  252. return TRUE;
  253. }
  254. return FALSE;
  255. }
  256. // access function
  257. int
  258. CDmoTest::GetNumTestFile(int i)
  259. {
  260. return g_component[i].iNumTestFiles ;
  261. }
  262. // access function
  263. LPSTR
  264. CDmoTest::GetFileName(int comIndex, int fileIndex)
  265. {
  266. return g_component[comIndex].szInputFile[fileIndex];
  267. }
  268. // access function
  269. HWND
  270. CDmoTest::GetWindowHandle()
  271. {
  272. return m_pShell->m_hwndShell;
  273. }
  274. // access function
  275. int
  276. CDmoTest::GetNumSelectedDmo()
  277. {
  278. return g_dwNumOfSelectedComponents;
  279. }
  280. /*-----------------------------------------------------------------------------
  281. | Function: CDmoTest::SaveSettings
  282. | Purpose: Save the custom entries to the profile or ini file
  283. | Arguments: pszFileName - Profile Name or ini file name
  284. | pzsSection - section name
  285. | Returns: 0 = Success, otherwise failure
  286. | Notes: Additional custom entries for this module should be saved here
  287. \----------------------------------------------------------------------------*/
  288. DWORD CDmoTest::SaveSettings(LPSTR pszFileName, LPSTR pszSetction)
  289. {
  290. char szEntryStr[MAX_LEN];
  291. char szNumTestFiles[MAX_NUM];
  292. char szNumFiles[MAX_NUM];
  293. char szSelected[MAX_NUM];
  294. sprintf(szEntryStr, "%s", TX_NO_OF_COMPONENTS_ENTRY);
  295. _itoa(g_dwNumOfComponents, szNumFiles, 10);
  296. g_IShell->WriteProfileString( szEntryStr, szNumFiles );
  297. sprintf(szEntryStr, "%s", TX_NO_OF_SELECTED_COMPONENTS_ENTRY);
  298. _itoa(g_dwNumOfSelectedComponents, szNumFiles, 10);
  299. g_IShell->WriteProfileString( szEntryStr, szNumFiles );
  300. for(int i = 0; i< g_dwNumOfComponents; i++)
  301. {
  302. sprintf(szEntryStr, "%s.%d", TX_COMPONENT_ENTRY, i);
  303. g_IShell->WriteProfileString( szEntryStr, g_component[i].szComName );
  304. sprintf(szEntryStr, "%s.%d", TX_CLASSID_ENTRY, i);
  305. g_IShell->WriteProfileString( szEntryStr, g_component[i].szClsid );
  306. sprintf(szEntryStr, "%s.%d", TX_SELECTED_FOR_TEST, i);
  307. _itoa(g_component[i].iSelectedForTest, szSelected, 10);
  308. g_IShell->WriteProfileString( szEntryStr, szSelected );
  309. sprintf(szEntryStr, "%s.%d", TX_NO_OF_TEST_FILES_ENTRY, i);
  310. _itoa(g_component[i].iNumTestFiles, szNumFiles, 10);
  311. g_IShell->WriteProfileString( szEntryStr, szNumFiles );
  312. if( g_component[i].iSelectedForTest != 0 ) // selected
  313. {
  314. for (int j = 0; j<g_component[i].iNumTestFiles; j++)
  315. {
  316. sprintf(szEntryStr, "%s.%d.%d", TX_FILENAME_ENTRY, i, j);
  317. g_IShell->WriteProfileString( szEntryStr, g_component[i].szInputFile[j] );
  318. }
  319. }
  320. }
  321. return 0;
  322. }
  323. /*-----------------------------------------------------------------------------
  324. | Function: CDmoTest::LoadSettings
  325. | Purpose: Load the custom entries from the profile or ini file
  326. | Arguments: pszFileName - Profile Name or ini file name
  327. | pzsSection - section name
  328. | Returns: 0 = Success, otherwise failure
  329. | Notes: Additional custom entries for this module should be loaded here
  330. \----------------------------------------------------------------------------*/
  331. DWORD
  332. CDmoTest::LoadSettings(LPSTR pszFileName, LPSTR pszSetction)
  333. {
  334. char szEntryStr[MAX_LEN];
  335. char szNumFiles[MAX_NUM];
  336. int iSelected;
  337. char szComName[MAX_NUM];
  338. GetRegisteredDmos();
  339. int iNumOfComponentsInProfile = g_IShell->GetProfileInt( TX_NO_OF_COMPONENTS_ENTRY,0 );
  340. g_dwNumOfSelectedComponents = g_IShell->GetProfileInt(TX_NO_OF_SELECTED_COMPONENTS_ENTRY,0);
  341. //get component name, classid, test file name for each component
  342. if( g_dwNumOfSelectedComponents > 0)
  343. {
  344. for( int i=0; i<iNumOfComponentsInProfile; i++)
  345. {
  346. // check if the component was selected for test
  347. sprintf(szEntryStr, "%s.%d", TX_SELECTED_FOR_TEST, i);
  348. iSelected = g_IShell->GetProfileInt(szEntryStr, 0 );
  349. if(iSelected != 0 ) // selected
  350. {
  351. sprintf(szEntryStr, "%s.%d", TX_COMPONENT_ENTRY, i);
  352. g_IShell->GetProfileString(szEntryStr, TX_NOT_EXIST, szComName, 256 );
  353. for(int j=0; j<g_dwNumOfComponents; j++)
  354. {
  355. if(0 == lstrcmp( szComName, g_component[j].szComName))
  356. {
  357. g_component[j].iSelectedForTest = 1;
  358. // get test file num for this selected DMO
  359. sprintf(szEntryStr, "%s.%d", TX_NO_OF_TEST_FILES_ENTRY, i);
  360. g_component[j].iNumTestFiles = g_IShell->GetProfileInt(szEntryStr, 0 );
  361. // g_IShell->GetProfileString(szEntryStr, TX_NOT_EXIST, szNumFiles , 256 );
  362. // = atoi( szNumFiles);
  363. for (int k = 0; k<g_component[j].iNumTestFiles; k++)
  364. {
  365. sprintf(szEntryStr, "%s.%d.%d", TX_FILENAME_ENTRY, j, k);
  366. g_IShell->GetProfileString( szEntryStr, TX_NOT_EXIST, g_component[j].szInputFile[k], 256);
  367. }
  368. }
  369. }
  370. }
  371. }
  372. }
  373. return 0;
  374. }
  375. //=====================================================================
  376. //
  377. // run the test cases for each of the selected components
  378. //
  379. //=====================================================================
  380. DWORD
  381. CDmoTest::RunTest
  382. (
  383. DWORD dwTestID
  384. )
  385. {
  386. DWORD dw;
  387. m_pShell->IncrementIndent();
  388. PPCDmoTestCase CaseArray = ((PPCDmoTestCase)m_rgTestCaseInfo);
  389. dw = CaseArray[dwTestID]->RunTest();
  390. m_pShell->DecrementIndent();
  391. return(dw);
  392. }
  393. /*-----------------------------------------------------------------------------
  394. | Function: CDmoTest::OnInitialUpdate
  395. | Purpose: create event window
  396. | Arguments: None
  397. | Returns: 0 = Success, otherwise failure
  398. \----------------------------------------------------------------------------*/
  399. DWORD
  400. CDmoTest::OnInitialUpdate()
  401. {
  402. // install customized menu item
  403. m_pShell->InstallMenuItem("&Tests", "Select DMOs ...", IDM_SELECTDMO);
  404. m_pShell->InstallMenuItem("&Tests", "Generate DMO Data ...", IDM_DATAGEN);
  405. m_hSelectDmoDlg = CreateDialogParam(m_hInstance,
  406. MAKEINTRESOURCE(IDD_DMODIALOG),
  407. m_pShell->m_hwndShell,
  408. SelectDmoDialogProc,
  409. (LPARAM)this);
  410. m_hSelectFilesDlg = CreateDialogParam(m_hInstance,
  411. MAKEINTRESOURCE(IDD_TESTFILEDIALOG),
  412. m_pShell->m_hwndShell,
  413. SelectTestFileDialogProc,
  414. (LPARAM)this);
  415. m_hMediaTypeDlg = CreateDialogParam(m_hInstance,
  416. MAKEINTRESOURCE(IDD_MEDIATYPEDIALOG),
  417. m_pShell->m_hwndShell,
  418. MediaTypeDialogProc,
  419. (LPARAM)this);
  420. m_hDataGenDlg = CreateDialogParam(m_hInstance,
  421. MAKEINTRESOURCE(IDD_DATAGENDIALOG),
  422. m_pShell->m_hwndShell,
  423. DataGenDialogProc,
  424. (LPARAM)this);
  425. return FNS_PASS;
  426. }
  427. /*-----------------------------------------------------------------------------
  428. | Function: CDmoTest::ProcessMenuItem
  429. | Purpose: processing custom menuitem
  430. \----------------------------------------------------------------------------*/
  431. void CDmoTest::ProcessMenuItem(DWORD nID,
  432. HWND hWndCtl,
  433. DWORD codeNotify,
  434. HMENU hOptionMenu)
  435. {
  436. switch(nID)
  437. {
  438. case IDM_SELECTDMO:
  439. pThis->InitListView( pThis->m_hDmoList);
  440. ShowWindow(m_hSelectDmoDlg, SW_SHOW);
  441. break;
  442. case IDM_DATAGEN:
  443. //pThis->InitListView( pThis->m_hDmoList);
  444. ShowWindow(m_hDataGenDlg, SW_SHOW);
  445. break;
  446. default:
  447. break;
  448. }
  449. return;
  450. }
  451. /*-----------------------------------------------------------------------------
  452. | Function: CDmoTest::SelectDmoDialogProc
  453. | Purpose: processing messages for Play path/Duration window
  454. \----------------------------------------------------------------------------*/
  455. INT_PTR CALLBACK
  456. CDmoTest::SelectDmoDialogProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  457. {
  458. static HWND hwndEdit;
  459. INT dIndex = 0;
  460. int iMarkedDmo = 0;
  461. int iItemNum = 0;
  462. switch( msg )
  463. {
  464. case WM_INITDIALOG:
  465. pThis = (CDmoTest*) lParam;
  466. pThis->m_hDmoList = ::GetDlgItem(hDlg, IDC_DMOLIST);
  467. ListView_SetExtendedListViewStyle(pThis->m_hDmoList,
  468. LVS_EX_CHECKBOXES);
  469. return TRUE;
  470. case WM_NOTIFY:
  471. switch (wParam)
  472. {
  473. case IDC_DMOLIST:
  474. POINT p;
  475. LPNM_LISTVIEW pnlv = (LPNM_LISTVIEW)lParam;
  476. switch (pnlv->hdr.code)
  477. {
  478. case NM_RCLICK:
  479. HMENU hMenu;
  480. hMenu = CreatePopupMenu();
  481. AppendMenu(hMenu,
  482. MF_ENABLED | MF_STRING,
  483. ID_GETTESTFILE,
  484. (LPSTR)&"&Select Test File");
  485. AppendMenu(hMenu,
  486. MF_ENABLED | MF_STRING,
  487. ID_GETPROPERTY,
  488. (LPSTR)&"&Get Properties");
  489. GetCursorPos(&p);
  490. TrackPopupMenu(hMenu,
  491. TPM_LEFTBUTTON,
  492. p.x,
  493. p.y,
  494. 0,
  495. hDlg,
  496. NULL);
  497. DestroyMenu(hMenu);
  498. break;
  499. default:
  500. break;
  501. }
  502. } // end switch (wParam)
  503. case WM_COMMAND:
  504. switch (LOWORD(wParam))
  505. {
  506. case ID_GETTESTFILE:
  507. // get registered DMO names and display them
  508. // delete previous content from list view and load new content from memory for display
  509. ListView_DeleteAllItems(pThis->m_hTestFileList);
  510. pThis->InitTestFileListView( pThis->m_hTestFileList );
  511. ShowWindow(m_hSelectFilesDlg, SW_SHOW);
  512. break;
  513. case ID_GETPROPERTY:
  514. // get the CLSID of the selected DMO
  515. UINT ii;
  516. LPSTR szDmoClsid;
  517. ii = ListView_GetItemCount(pThis->m_hDmoList);
  518. for(; ii; ii--)
  519. {
  520. if(0!= ListView_GetItemState(
  521. pThis->m_hDmoList,
  522. ii-1,
  523. LVIS_SELECTED))
  524. {
  525. szDmoClsid = pThis->GetDmoClsid(ii-1);
  526. }
  527. }
  528. // clean the MEDIATYPELIST
  529. iItemNum = SendMessage(pThis->m_hMediaTypeList, LB_GETCOUNT, 0,0);
  530. if(iItemNum > 0)
  531. {
  532. for(int i = 0; i< iItemNum; i++)
  533. SendMessage(pThis->m_hMediaTypeList, LB_DELETESTRING, (WPARAM)0,0);
  534. }
  535. // add types to the media type list
  536. GetDmoTypeInfo(szDmoClsid,pThis->m_hMediaTypeList);
  537. ShowWindow(m_hMediaTypeDlg, SW_SHOW);
  538. break;
  539. case IDOK:
  540. // get a list of selected DMOs and test files (struct)
  541. // and write to the profile:
  542. WriteSelectedDmos();
  543. EndDialog(hDlg, TRUE);
  544. return TRUE ;
  545. case IDCANCEL:
  546. EndDialog(hDlg, TRUE);
  547. return TRUE;
  548. }
  549. break;
  550. }
  551. return FALSE;
  552. }
  553. /******************************************************************************
  554. InitListView
  555. ******************************************************************************/
  556. BOOL
  557. CDmoTest::InitListView(HWND hwndListView)
  558. {
  559. LV_COLUMN lvColumn;
  560. int i;
  561. TCHAR szString[3][MAX_LEN] = {"DMO Component", "Class ID", "Number of Test Files Selected"};
  562. //empty the list
  563. ListView_DeleteAllItems(hwndListView);
  564. for(i = 0; i < NUM_OF_DMO_SUBITEM_COLUMN; i++)
  565. {
  566. ListView_DeleteColumn(hwndListView, 0);
  567. }
  568. //initialize the columns
  569. lvColumn.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
  570. lvColumn.fmt = LVCFMT_LEFT;
  571. lvColumn.cx = 200;
  572. for(i = 0; i < NUM_OF_DMO_SUBITEM_COLUMN; i++)
  573. {
  574. lvColumn.pszText = szString[i];
  575. lvColumn.iSubItem = 0;
  576. ListView_InsertColumn(hwndListView, i, &lvColumn);
  577. }
  578. // set the number of items in the list
  579. ListView_SetItemCount(hwndListView, ITEM_COUNT);
  580. AddListViewItems(pThis->m_hDmoList);
  581. return TRUE;
  582. }
  583. //*****************************************************************
  584. BOOL AddListViewItems(HWND hLV)
  585. {
  586. LVITEM lvI;
  587. INT dIndex;
  588. char szNumFile[MAX_NUM];
  589. for(int i = g_dwNumOfComponents-1; i>=0;i--)
  590. {
  591. lvI.mask = LVIF_TEXT|LVIF_IMAGE;
  592. lvI.iItem = 0;
  593. lvI.iSubItem = 0;
  594. lvI.pszText = g_component[i].szComName;
  595. dIndex = ListView_InsertItem(hLV,&lvI);
  596. if( g_component[i].iSelectedForTest != 0 ) // selected
  597. {
  598. ListView_SetCheckState( pThis->m_hDmoList,
  599. dIndex,
  600. TRUE);
  601. }
  602. lvI.mask = TVIF_TEXT;
  603. lvI.iItem = dIndex;
  604. lvI.iSubItem = 1;
  605. lvI.pszText = g_component[i].szClsid;
  606. ListView_SetItem(hLV,&lvI);
  607. _itoa( g_component[i].iNumTestFiles, szNumFile, 10);
  608. lvI.mask = TVIF_TEXT;
  609. lvI.iItem = dIndex;
  610. lvI.iSubItem = 2;
  611. lvI.pszText = szNumFile;
  612. ListView_SetItem(hLV,&lvI);
  613. }
  614. return TRUE;
  615. }
  616. /*-----------------------------------------------------------------------------
  617. | Function: CQAsfModule::SelectDmoDialogProc
  618. | Purpose: processing messages for Play path/Duration window
  619. \----------------------------------------------------------------------------*/
  620. INT_PTR CALLBACK
  621. CDmoTest::SelectTestFileDialogProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  622. {
  623. // static HWND hwndEdit;
  624. INT dIndex = 0;
  625. int iSelectedDmo = ListView_GetSelectionMark( pThis->m_hDmoList );
  626. switch( msg )
  627. {
  628. case WM_INITDIALOG:
  629. pThis = (CDmoTest*) lParam;
  630. pThis->m_hTestFileList = ::GetDlgItem(hDlg, IDC_TESTFILELIST);
  631. return TRUE;
  632. case WM_COMMAND:
  633. switch (LOWORD(wParam))
  634. {
  635. case ID_ADDFILE:
  636. // Call the FileOpen common dialog to get test files
  637. // and display in file selection dialog
  638. GetTestFileName( hDlg, pThis->m_hTestFileList );
  639. break;
  640. case IDOK:
  641. //save selected files in global variables.
  642. SaveSelectedTestFiles(pThis->m_hTestFileList);
  643. EndDialog(hDlg, TRUE);
  644. return TRUE ;
  645. case IDREMOVEALL:
  646. ListView_DeleteAllItems(pThis->m_hTestFileList);
  647. return TRUE;
  648. case ID_REMOVEFILE:
  649. UINT ii;
  650. ii = ListView_GetItemCount(pThis->m_hTestFileList);
  651. for(; ii; ii--)
  652. {
  653. if(0!= ListView_GetItemState(
  654. pThis->m_hTestFileList,
  655. ii-1,
  656. LVIS_SELECTED))
  657. {
  658. ListView_DeleteItem(pThis->m_hTestFileList, ii-1);
  659. }
  660. }
  661. return TRUE;
  662. case IDCANCEL:
  663. EndDialog(hDlg, TRUE);
  664. return TRUE;
  665. }
  666. break;
  667. }
  668. return FALSE;
  669. }
  670. /******************************************************************************
  671. InitListView
  672. ******************************************************************************/
  673. BOOL
  674. CDmoTest::InitTestFileListView(HWND hwndListView)
  675. {
  676. LV_COLUMN lvColumn;
  677. int i;
  678. TCHAR szString[2][20] = {"File Name", "Media Format"};
  679. //empty the list
  680. ListView_DeleteAllItems(hwndListView);
  681. //initialize the columns
  682. lvColumn.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
  683. lvColumn.fmt = LVCFMT_LEFT;
  684. lvColumn.cx = 400;
  685. for(i = 0; i < NUM_OF_FILE_SUBITEM_COLUMN+1; i++)
  686. {
  687. lvColumn.pszText = szString[i];
  688. ListView_InsertColumn(hwndListView, i, &lvColumn);
  689. }
  690. //set the number of items in the list
  691. ListView_SetItemCount(hwndListView, ITEM_COUNT);
  692. // get and highlight selected DMOs from ini or profile
  693. // TBD
  694. AddTestFilesInListView(hwndListView);
  695. return TRUE;
  696. }
  697. /******************************************************************************
  698. InsertListViewItems
  699. ******************************************************************************/
  700. BOOL AddTestFilesInListView(HWND hLV)
  701. {
  702. LVITEM lvI;
  703. int iNumDmo = 0;
  704. CHAR szFileNum[81];
  705. int iSelectedDmo = ListView_GetSelectionMark( pThis->m_hDmoList );
  706. for(int i=g_component[iSelectedDmo].iNumTestFiles-1; i>=0; i--)
  707. {
  708. lvI.mask = LVIF_TEXT|LVIF_IMAGE;
  709. lvI.iItem = i;
  710. lvI.iSubItem = 0;
  711. lvI.pszText = (LPSTR)(g_component[iSelectedDmo].szInputFile[i]);
  712. //lvI.pszText = " ";
  713. ListView_InsertItem(hLV,&lvI);
  714. }
  715. return TRUE;
  716. }
  717. /*-----------------------------------------------------------------------------
  718. | Function: CQAsfModule::SelectDmoDialogProc
  719. | Purpose: processing messages for Play path/Duration window
  720. \----------------------------------------------------------------------------*/
  721. INT_PTR CALLBACK
  722. CDmoTest::MediaTypeDialogProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  723. {
  724. switch( msg )
  725. {
  726. case WM_INITDIALOG:
  727. pThis = (CDmoTest*) lParam;
  728. pThis->m_hMediaTypeList = ::GetDlgItem(hDlg, IDC_MEDIATYPELIST);
  729. return TRUE;
  730. case WM_COMMAND:
  731. switch (LOWORD(wParam))
  732. {
  733. case IDOK:
  734. EndDialog(hDlg, TRUE);
  735. return TRUE ;
  736. case IDCANCEL:
  737. EndDialog(hDlg, TRUE);
  738. return TRUE;
  739. }
  740. break;
  741. }
  742. return FALSE;
  743. }
  744. /*-----------------------------------------------------------------------------
  745. | Function: CDmoTest::DataGenDialogProc
  746. | Purpose: processing messages for Play path/Duration window
  747. \----------------------------------------------------------------------------*/
  748. INT_PTR CALLBACK
  749. CDmoTest::DataGenDialogProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  750. {
  751. char lpszInFilename[100];
  752. DWORD dwInFilenameLen;
  753. char lpszOutFilename[100];
  754. DWORD dwOutFilenameLen;
  755. switch( msg )
  756. {
  757. case WM_INITDIALOG:
  758. pThis = (CDmoTest*) lParam;
  759. pThis->m_hInputFileField = ::GetDlgItem(hDlg, IDC_INPUTFIELD);
  760. pThis->m_hOutputFileField = ::GetDlgItem(hDlg, IDC_OUTPUTFIELD);
  761. return TRUE;
  762. case WM_COMMAND:
  763. switch (LOWORD(wParam))
  764. {
  765. case IDC_INPUTBROWSE:
  766. // Call the FileOpen common dialog to get test files
  767. // and display in DataGenDialog
  768. GetInOutFileName( hDlg, pThis->m_hInputFileField);
  769. break;
  770. case IDC_OUTPUTBROWSE:
  771. // Call the FileOpen common dialog to get test files
  772. // and display in DataGenDialog
  773. GetInOutFileName( hDlg, pThis->m_hOutputFileField);
  774. break;
  775. case IDOK:
  776. // get the input/output file names and use spliter and data dump filter
  777. // to generate output data
  778. //TBD
  779. // Get number of characters.
  780. dwInFilenameLen = (DWORD) SendDlgItemMessage(hDlg,
  781. IDC_INPUTFIELD,
  782. EM_LINELENGTH,
  783. (WPARAM) 0,
  784. (LPARAM) 0);
  785. dwOutFilenameLen = (DWORD) SendDlgItemMessage(hDlg,
  786. IDC_OUTPUTFIELD,
  787. EM_LINELENGTH,
  788. (WPARAM) 0,
  789. (LPARAM) 0);
  790. if (dwInFilenameLen == 0)
  791. {
  792. MessageBox(hDlg,
  793. "No characters entered.",
  794. "Error",
  795. MB_OK);
  796. EndDialog(hDlg, TRUE);
  797. return FALSE;
  798. }
  799. if (dwOutFilenameLen == 0)
  800. {
  801. MessageBox(hDlg,
  802. "No characters entered.",
  803. "Error",
  804. MB_OK);
  805. EndDialog(hDlg, TRUE);
  806. return FALSE;
  807. }
  808. // Get the characters.
  809. SendDlgItemMessage(hDlg,
  810. IDC_INPUTFIELD,
  811. EM_GETLINE,
  812. (WPARAM) 0, // line 0
  813. (LPARAM) lpszInFilename);
  814. SendDlgItemMessage(hDlg,
  815. IDC_OUTPUTFIELD,
  816. EM_GETLINE,
  817. (WPARAM) 0, // line 0
  818. (LPARAM) lpszOutFilename);
  819. // Null-terminate the string.
  820. lpszInFilename[dwInFilenameLen] = 0;
  821. lpszOutFilename[dwOutFilenameLen] = 0;
  822. g_IShell->Log(1, "retrieved input filename is %s", lpszInFilename);
  823. g_IShell->Log(1, "retrieved output filename is %s", lpszOutFilename);
  824. EndDialog(hDlg, TRUE);
  825. return TRUE ;
  826. case IDCANCEL:
  827. EndDialog(hDlg, TRUE);
  828. return TRUE;
  829. }
  830. break;
  831. }
  832. return FALSE;
  833. }
  834. //
  835. // FUNCTION: OpenTheFile(HWND hwnd, HWND hwndEdit)
  836. //
  837. // PURPOSE: Invokes common dialog function to open a file and opens it.
  838. //
  839. // COMMENTS:
  840. //
  841. // This function initializes the OPENFILENAME structure and calls
  842. // the GetOpenFileName() common dialog function.
  843. //
  844. // RETURN VALUES:
  845. // TRUE - The file was opened successfully and read into the buffer.
  846. // FALSE - No files were opened.
  847. //
  848. //
  849. unsigned int CALLBACK ComDlg32DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  850. {
  851. switch (uMsg)
  852. {
  853. case WM_INITDIALOG:
  854. break;
  855. case WM_DESTROY:
  856. break;
  857. case WM_NOTIFY:
  858. default:
  859. return FALSE;
  860. }
  861. return TRUE;
  862. }
  863. /******************************************************************************
  864. **********************************************************************************/
  865. BOOL GetTestFileName( HWND hWnd, HWND hLV )
  866. {
  867. HANDLE hFile;
  868. DWORD dwBytesRead;
  869. DWORD dwFileSize;
  870. OPENFILENAME OpenFileName;
  871. TCHAR szFile[MAX_PATH] = "\0";
  872. char *lpBufPtr;
  873. DWORD ret = 0;
  874. strcpy( szFile, "");
  875. // Fill in the OPENFILENAME structure to support a template and hook.
  876. OpenFileName.lStructSize = sizeof(OPENFILENAME);
  877. OpenFileName.hwndOwner = hWnd;
  878. OpenFileName.hInstance = g_hInst;
  879. OpenFileName.lpstrFilter = NULL;
  880. OpenFileName.lpstrCustomFilter = NULL;
  881. OpenFileName.nMaxCustFilter = 0;
  882. OpenFileName.nFilterIndex = 0;
  883. OpenFileName.lpstrFile = szFile;
  884. OpenFileName.nMaxFile = sizeof(szFile);
  885. OpenFileName.lpstrFileTitle = NULL;
  886. OpenFileName.nMaxFileTitle = 0;
  887. OpenFileName.lpstrInitialDir = NULL;
  888. OpenFileName.lpstrTitle = "Open a File";
  889. OpenFileName.nFileOffset = 0;
  890. OpenFileName.nFileExtension = 0;
  891. OpenFileName.lpstrDefExt = NULL;
  892. OpenFileName.lCustData = (LPARAM)&sMyData;
  893. // OpenFileName.lpfnHook = pThis->SelectDmoDialogProc;
  894. // OpenFileName.lpfnHook = ComDlg32DlgProc;
  895. OpenFileName.lpTemplateName = MAKEINTRESOURCE(IDD_DMODIALOG);
  896. OpenFileName.Flags = OFN_EXPLORER|OFN_ALLOWMULTISELECT; //OFN_SHOWHELP | OFN_EXPLORER | OFN_ENABLEHOOK | OFN_ENABLETEMPLATE;
  897. // add error checking ...
  898. if (GetOpenFileName(&OpenFileName) == 0)
  899. {
  900. char buffer[20];
  901. ret = CommDlgExtendedError();
  902. sprintf(buffer,"(%x)",ret);
  903. OutputDebugStringA(buffer);
  904. }
  905. // display selected files
  906. LVITEM lvI;
  907. INT dIndex;
  908. // get the file path and names from OpenFileName.lpstrFile:
  909. char szPath[MAX_LEN];
  910. char szFileNames[MAX_NUM][MAX_LEN]={0};
  911. char szFullFileName[MAX_NUM][MAX_LEN]={0};
  912. int iNumFiles = 0;
  913. int offset = 0;
  914. char* strFile;
  915. lstrcpyn( szPath, (LPSTR)OpenFileName.lpstrFile,OpenFileName.nFileOffset );
  916. for(;;)
  917. {
  918. lstrcpy(szFileNames[iNumFiles], OpenFileName.lpstrFile + OpenFileName.nFileOffset + offset);
  919. int size = lstrlen(szFileNames[iNumFiles]);
  920. if (size == 0)
  921. break;
  922. sprintf(szFullFileName[iNumFiles], "%s\\%s", szPath, szFileNames[iNumFiles]);
  923. offset += size + 1;
  924. lvI.mask = LVIF_TEXT|LVIF_IMAGE;
  925. lvI.iItem = iNumFiles;
  926. lvI.iSubItem = 0;
  927. lvI.pszText = (LPSTR)(szFullFileName[iNumFiles]);
  928. dIndex = ListView_InsertItem(hLV,&lvI);
  929. iNumFiles++;
  930. }
  931. return TRUE;
  932. }
  933. BOOL GetInOutFileName( HWND hWnd, HWND hLV )
  934. {
  935. HANDLE hFile;
  936. DWORD dwBytesRead;
  937. DWORD dwFileSize;
  938. OPENFILENAME OpenFileName;
  939. TCHAR szFile[MAX_PATH] = "\0";
  940. char *lpBufPtr;
  941. DWORD ret = 0;
  942. strcpy( szFile, "");
  943. // Fill in the OPENFILENAME structure to support a template and hook.
  944. OpenFileName.lStructSize = sizeof(OPENFILENAME);
  945. OpenFileName.hwndOwner = hWnd;
  946. OpenFileName.hInstance = g_hInst;
  947. OpenFileName.lpstrFilter = NULL;
  948. OpenFileName.lpstrCustomFilter = NULL;
  949. OpenFileName.nMaxCustFilter = 0;
  950. OpenFileName.nFilterIndex = 0;
  951. OpenFileName.lpstrFile = szFile;
  952. OpenFileName.nMaxFile = sizeof(szFile);
  953. OpenFileName.lpstrFileTitle = NULL;
  954. OpenFileName.nMaxFileTitle = 0;
  955. OpenFileName.lpstrInitialDir = NULL;
  956. OpenFileName.lpstrTitle = "Open a File";
  957. OpenFileName.nFileOffset = 0;
  958. OpenFileName.nFileExtension = 0;
  959. OpenFileName.lpstrDefExt = NULL;
  960. OpenFileName.lCustData = (LPARAM)&sMyData;
  961. // OpenFileName.lpfnHook = pThis->SelectDmoDialogProc;
  962. // OpenFileName.lpfnHook = ComDlg32DlgProc;
  963. OpenFileName.lpTemplateName = MAKEINTRESOURCE(IDD_DATAGENDIALOG);
  964. OpenFileName.Flags = OFN_EXPLORER|OFN_ALLOWMULTISELECT; //OFN_SHOWHELP | OFN_EXPLORER | OFN_ENABLEHOOK | OFN_ENABLETEMPLATE;
  965. // add error checking ...
  966. if (GetOpenFileName(&OpenFileName) == 0)
  967. {
  968. char buffer[20];
  969. ret = CommDlgExtendedError();
  970. sprintf(buffer,"(%x)",ret);
  971. OutputDebugStringA(buffer);
  972. }
  973. // display selected files
  974. // get the file path and names from OpenFileName.lpstrFile:
  975. char szPath[MAX_LEN];
  976. char szFileNames[MAX_NUM][MAX_LEN]={0};
  977. char szFullFileName[MAX_NUM][MAX_LEN]={0};
  978. int iNumFiles = 0;
  979. int offset = 0;
  980. char* strFile;
  981. lstrcpyn( szPath, (LPSTR)OpenFileName.lpstrFile, OpenFileName.nFileOffset );
  982. for(;;)
  983. {
  984. lstrcpy(szFileNames[iNumFiles], OpenFileName.lpstrFile + OpenFileName.nFileOffset + offset);
  985. int size = lstrlen(szFileNames[iNumFiles]);
  986. if (size == 0)
  987. break;
  988. sprintf(szFullFileName[iNumFiles], "%s\\%s", szPath, szFileNames[iNumFiles]);
  989. offset += size + 1;
  990. g_IShell->Log(1, "%d selected files is %s", iNumFiles, szFullFileName[iNumFiles]);
  991. SendMessage(hLV, WM_SETTEXT, 0, (LPARAM) szFullFileName[iNumFiles]);
  992. iNumFiles++;
  993. }
  994. return TRUE;
  995. }
  996. /*********************************************************************************
  997. Save selected test files:
  998. ********************************************************************************/
  999. BOOL SaveSelectedTestFiles(HWND hLV)
  1000. {
  1001. // save the selected test files and number in global variables:
  1002. int iSelectedDmo = ListView_GetSelectionMark( pThis->m_hDmoList );
  1003. g_component[iSelectedDmo].iNumTestFiles = ListView_GetItemCount(hLV);
  1004. for(int j= 0; j<g_component[iSelectedDmo].iNumTestFiles; j++)
  1005. {
  1006. ListView_GetItemText( hLV,
  1007. j,
  1008. 0,
  1009. g_component[iSelectedDmo].szInputFile[j],
  1010. MAX_LEN);
  1011. }
  1012. // display the number of test files in the DMO selection dialog
  1013. LVITEM lvDmoItem;
  1014. char szNumFiles[MAX_NUM];
  1015. _itoa(g_component[iSelectedDmo].iNumTestFiles, szNumFiles, 10);
  1016. lvDmoItem.mask = TVIF_TEXT;
  1017. lvDmoItem.iItem = iSelectedDmo;
  1018. lvDmoItem.iSubItem = 2;
  1019. lvDmoItem.pszText = szNumFiles;
  1020. ListView_SetItem(pThis->m_hDmoList,&lvDmoItem);
  1021. return TRUE;
  1022. }
  1023. /*************************************************************************************
  1024. // get a list of selected DMOs and test files, save to global variables
  1025. // and write to the .ini file:
  1026. **************************************************************************************/
  1027. BOOL WriteSelectedDmos()
  1028. {
  1029. int count = 0;
  1030. for(int i=0; i<g_dwNumOfComponents; i++)
  1031. {
  1032. if(0 != ListView_GetCheckState(pThis->m_hDmoList, i))
  1033. {
  1034. g_component[i].iSelectedForTest = 1;
  1035. count++;
  1036. }
  1037. else
  1038. {
  1039. g_component[i].iSelectedForTest = 0;
  1040. }
  1041. }
  1042. g_dwNumOfSelectedComponents = count;
  1043. pThis->SaveSettings(" "," ");
  1044. return TRUE;
  1045. }
  1046. /*************************************************************************************
  1047. // get a list of registered DMOs, save to global variables
  1048. **************************************************************************************/
  1049. BOOL GetRegisteredDmos()
  1050. {
  1051. DMOINFO rgDmoInfo[ITEM_COUNT];
  1052. int iNumDmo = 0;
  1053. LPSTR pDMO[1000];
  1054. OutputDMOs( &iNumDmo, rgDmoInfo );
  1055. g_dwNumOfComponents = iNumDmo;
  1056. for(int i=0; i<iNumDmo; i++)
  1057. {
  1058. lstrcpy( g_component[i].szComName, rgDmoInfo[i].szName);
  1059. lstrcpy( g_component[i].szClsid, rgDmoInfo[i].szClsId);
  1060. }
  1061. return TRUE;
  1062. }