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.

1186 lines
39 KiB

  1. /****************************************************************************
  2. * @doc INTERNAL CAPTUREP
  3. *
  4. * @module CaptureP.cpp | Source file for the <c CCaptureProperty>
  5. * class used to implement a property page to test the TAPI control
  6. * interfaces <i ITFormatControl> and <i ITQualityControl>.
  7. ***************************************************************************/
  8. #include "Precomp.h"
  9. extern HINSTANCE ghInst;
  10. // Returns the address of the BITMAPINFOHEADER from the VIDEOINFOHEADER
  11. //#define HEADER(pVideoInfo) (&(((VIDEOINFOHEADER *) (pVideoInfo))->bmiHeader))
  12. // Video subtypes
  13. const GUID MEDIASUBTYPE_H263_V1 = {0x33363248L, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71}};
  14. const GUID MEDIASUBTYPE_H261 = {0x31363248L, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71}};
  15. const GUID MEDIASUBTYPE_H263_V2 = {0x3336324EL, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71}};
  16. /****************************************************************************
  17. * @doc INTERNAL CCAPTUREPMETHOD
  18. *
  19. * @mfunc void | CCaptureProperty | CCaptureProperty | This
  20. * method is the constructor for bitrate and frame rate property objects. It
  21. * calls the base class constructor, calls InitCommonControlsEx, and saves
  22. * pointers to the <i ITQualityControl> interfaces.
  23. *
  24. * @parm HWND | hDlg | Specifies a handle to the parent property page.
  25. *
  26. * @parm ULONG | IDLabel | Specifies a label ID for the property.
  27. *
  28. * @parm ULONG | IDMinControl | Specifies a label ID for the associated
  29. * property edit control where the Minimum value of the property appears.
  30. *
  31. * @parm ULONG | IDMaxControl | Specifies a label ID for the associated
  32. * property edit control where the Maximum value of the property appears.
  33. *
  34. * @parm ULONG | IDDefaultControl | Specifies a label ID for the associated
  35. * property edit control where the Default value of the property appears.
  36. *
  37. * @parm ULONG | IDStepControl | Specifies a label ID for the associated
  38. * property edit control where the Stepping Delta value of the property appears.
  39. *
  40. * @parm ULONG | IDEditControl | Specifies a label ID for the associated
  41. * property edit control where the value of the property appears.
  42. *
  43. * @parm ULONG | IDTrackbarControl | Specifies a label ID for the associated
  44. * property slide bar.
  45. *
  46. * @parm ULONG | IDProgressControl | Specifies a label ID for the associated
  47. * property slide bar.
  48. *
  49. * @parm ULONG | IDProperty | Specifies the ID of the Ks property.
  50. *
  51. * @parm ITQualityControl* | pITQualityControl | Specifies a pointer to the
  52. * <i ITQualityControl> interface.
  53. *
  54. * @rdesc Nada.
  55. ***************************************************************************/
  56. CCaptureProperty::CCaptureProperty(HWND hDlg, ULONG IDLabel, ULONG IDMinControl, ULONG IDMaxControl, ULONG IDDefaultControl, ULONG IDStepControl, ULONG IDEditControl, ULONG IDTrackbarControl, ULONG IDProgressControl, ULONG IDProperty, ITStreamQualityControl *pITQualityControl)
  57. : CPropertyEditor(hDlg, IDLabel, IDMinControl, IDMaxControl, IDDefaultControl, IDStepControl, IDEditControl, IDTrackbarControl, IDProgressControl, IDProperty, 0)
  58. {
  59. INITCOMMONCONTROLSEX cc;
  60. FX_ENTRY("CCaptureProperty::CCaptureProperty")
  61. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: begin"), _fx_));
  62. cc.dwSize = sizeof (INITCOMMONCONTROLSEX);
  63. cc.dwICC = ICC_UPDOWN_CLASS | ICC_BAR_CLASSES;
  64. InitCommonControlsEx(&cc);
  65. // It's fine if the interface pointers are NULL, we'll grey the
  66. // associated items in the property page
  67. m_pITQualityControl = pITQualityControl;
  68. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  69. }
  70. /****************************************************************************
  71. * @doc INTERNAL CCAPTUREPMETHOD
  72. *
  73. * @mfunc void | CCaptureProperty | ~CCaptureProperty | This
  74. * method is the destructor for capture property objects. It
  75. * simply calls the base class destructor.
  76. *
  77. * @rdesc Nada.
  78. ***************************************************************************/
  79. CCaptureProperty::~CCaptureProperty()
  80. {
  81. FX_ENTRY("CCaptureProperty::~CCaptureProperty")
  82. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: begin"), _fx_));
  83. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  84. }
  85. /****************************************************************************
  86. * @doc INTERNAL CCAPTUREPMETHOD
  87. *
  88. * @mfunc HRESULT | CCaptureProperty | GetValue | This method queries for
  89. * the value of a property.
  90. *
  91. * @rdesc This method returns an HRESULT value that depends on the
  92. * implementation of the interface. HRESULT can include one of the
  93. * following standard constants, or other values not listed:
  94. *
  95. * @flag E_FAIL | Failure
  96. * @flag E_POINTER | Null pointer argument
  97. * @flag E_NOTIMPL | Method is not supported
  98. * @flag NOERROR | No error
  99. ***************************************************************************/
  100. HRESULT CCaptureProperty::GetValue()
  101. {
  102. HRESULT Hr = E_NOTIMPL;
  103. LONG CurrentValue;
  104. TAPIControlFlags CurrentFlag;
  105. LONG Mode;
  106. FX_ENTRY("CCaptureProperty::GetValue")
  107. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: begin"), _fx_));
  108. /*
  109. switch (m_IDProperty)
  110. {
  111. case IDC_Capture_FrameRate:
  112. if (m_pITQualityControl && SUCCEEDED (Hr = m_pITQualityControl->Get(Quality_MaxStreamFrameRate, &CurrentValue, &CurrentFlag)))
  113. {
  114. // Displayed as fps
  115. if (CurrentValue)
  116. m_CurrentValue = (LONG)(10000000 / CurrentValue);
  117. else
  118. m_CurrentValue = 0;
  119. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: *pAvgTimePerFrame=%ld"), _fx_, CurrentValue));
  120. }
  121. else
  122. {
  123. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: Failed Hr=0x%08lX"), _fx_, Hr));
  124. }
  125. break;
  126. case IDC_Capture_CurrentFrameRate:
  127. if (m_pITQualityControl && SUCCEEDED (Hr = m_pITQualityControl->Get(Quality_CurrStreamFrameRate, &CurrentValue, &CurrentFlag)))
  128. {
  129. // Displayed as fps
  130. if (CurrentValue)
  131. m_CurrentValue = (LONG)(10000000 / CurrentValue);
  132. else
  133. m_CurrentValue = 0;
  134. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: *pAvgTimePerFrame=%ld"), _fx_, CurrentValue));
  135. }
  136. else
  137. {
  138. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: Failed Hr=0x%08lX"), _fx_, Hr));
  139. }
  140. break;
  141. case IDC_Capture_Bitrate:
  142. if (m_pITQualityControl && SUCCEEDED (Hr = m_pITQualityControl->Get(Quality_MaxBitrate, &m_CurrentValue, &CurrentFlag)))
  143. {
  144. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: *pdwMaxBitrate=%ld, dwLayerId=0"), _fx_, m_CurrentValue));
  145. }
  146. else
  147. {
  148. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: Failed Hr=0x%08lX"), _fx_, Hr));
  149. }
  150. break;
  151. case IDC_Capture_CurrentBitrate:
  152. if (m_pITQualityControl && SUCCEEDED (Hr = m_pITQualityControl->Get(Quality_CurrBitrate, &m_CurrentValue, &CurrentFlag)))
  153. {
  154. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: *pdwCurrentBitrate=%ld, dwLayerId=0"), _fx_, m_CurrentValue));
  155. }
  156. else
  157. {
  158. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: Failed Hr=0x%08lX"), _fx_, Hr));
  159. }
  160. break;
  161. default:
  162. Hr = E_UNEXPECTED;
  163. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: Unknown capture property"), _fx_));
  164. }
  165. */
  166. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  167. return Hr;
  168. }
  169. /****************************************************************************
  170. * @doc INTERNAL CCAPTUREPMETHOD
  171. *
  172. * @mfunc HRESULT | CCaptureProperty | SetValue | This method sets the
  173. * value of a property.
  174. *
  175. * @rdesc This method returns an HRESULT value that depends on the
  176. * implementation of the interface. HRESULT can include one of the
  177. * following standard constants, or other values not listed:
  178. *
  179. * @flag E_FAIL | Failure
  180. * @flag E_POINTER | Null pointer argument
  181. * @flag E_NOTIMPL | Method is not supported
  182. * @flag NOERROR | No error
  183. ***************************************************************************/
  184. HRESULT CCaptureProperty::SetValue()
  185. {
  186. HRESULT Hr = E_NOTIMPL;
  187. LONG CurrentValue;
  188. FX_ENTRY("CCaptureProperty::SetValue")
  189. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: begin"), _fx_));
  190. /*
  191. switch (m_IDProperty)
  192. {
  193. case IDC_Capture_FrameRate:
  194. // Displayed as fps
  195. if (m_CurrentValue)
  196. CurrentValue = 10000000 / m_CurrentValue;
  197. if (m_pITQualityControl && SUCCEEDED (Hr = m_pITQualityControl->Set(Quality_MaxStreamFrameRate, CurrentValue, TAPIControl_Flags_None)))
  198. {
  199. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: AvgTimePerFrame=%ld"), _fx_, CurrentValue));
  200. }
  201. else
  202. {
  203. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: Failed Hr=0x%08lX"), _fx_, Hr));
  204. }
  205. break;
  206. case IDC_Capture_Bitrate:
  207. if (m_pITQualityControl && SUCCEEDED (Hr = m_pITQualityControl->Set(Quality_MaxBitrate, m_CurrentValue, TAPIControl_Flags_None)))
  208. {
  209. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: dwMaxBitrate=%ld, dwLayerId=0"), _fx_, m_CurrentValue));
  210. }
  211. else
  212. {
  213. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: Failed Hr=0x%08lX"), _fx_, Hr));
  214. }
  215. break;
  216. case IDC_Capture_CurrentBitrate:
  217. case IDC_Capture_CurrentFrameRate:
  218. // This is a read-only property. Don't do anything.
  219. Hr = NOERROR;
  220. break;
  221. default:
  222. Hr = E_UNEXPECTED;
  223. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: Unknown capture property"), _fx_));
  224. }
  225. */
  226. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  227. return Hr;
  228. }
  229. /****************************************************************************
  230. * @doc INTERNAL CCAPTUREPMETHOD
  231. *
  232. * @mfunc HRESULT | CCaptureProperty | GetRange | This method retrieves
  233. * the range information of a property.
  234. *
  235. * @rdesc This method returns an HRESULT value that depends on the
  236. * implementation of the interface. HRESULT can include one of the
  237. * following standard constants, or other values not listed:
  238. *
  239. * @flag E_FAIL | Failure
  240. * @flag E_POINTER | Null pointer argument
  241. * @flag E_NOTIMPL | Method is not supported
  242. * @flag NOERROR | No error
  243. ***************************************************************************/
  244. HRESULT CCaptureProperty::GetRange()
  245. {
  246. HRESULT Hr = E_NOTIMPL;
  247. LONG Min;
  248. LONG Max;
  249. LONG SteppingDelta;
  250. LONG Default;
  251. TAPIControlFlags CapsFlags;
  252. FX_ENTRY("CCaptureProperty::GetRange")
  253. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: begin"), _fx_));
  254. /*
  255. switch (m_IDProperty)
  256. {
  257. case IDC_Capture_FrameRate:
  258. if (m_pITQualityControl && SUCCEEDED (Hr = m_pITQualityControl->GetRange(Quality_MaxStreamFrameRate, &Min, &Max, &SteppingDelta, &Default, &CapsFlags)))
  259. {
  260. // Displayed as fps
  261. if (Min)
  262. m_Max = (LONG)(10000000 / Min);
  263. else
  264. m_Max = 0;
  265. if (Max)
  266. m_Min = (LONG)(10000000 / Max);
  267. else
  268. m_Min = 0;
  269. if (SteppingDelta)
  270. m_SteppingDelta = (m_Max - m_Min) / (LONG)((Max - Min) / SteppingDelta);
  271. else
  272. m_SteppingDelta = 0;
  273. if (Default)
  274. m_DefaultValue = (LONG)(10000000 / Default);
  275. else
  276. m_DefaultValue = 0;
  277. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: *pMin=%ld, *pMax=%ld, *pSteppingDelta=%ld, *pDefault=%ld"), _fx_, Min, Max, SteppingDelta, Default));
  278. }
  279. else
  280. {
  281. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: Failed Hr=0x%08lX"), _fx_, Hr));
  282. }
  283. break;
  284. case IDC_Capture_CurrentFrameRate:
  285. if (m_pITQualityControl && SUCCEEDED (Hr = m_pITQualityControl->GetRange(Quality_CurrStreamFrameRate, &Min, &Max, &SteppingDelta, &Default, &CapsFlags)))
  286. {
  287. if (Min)
  288. m_Max = (LONG)(10000000 / Min);
  289. else
  290. m_Max = 0;
  291. if (Max)
  292. m_Min = (LONG)(10000000 / Max);
  293. else
  294. m_Min = 0;
  295. if (SteppingDelta)
  296. m_SteppingDelta = (LONG)(10000000 / SteppingDelta);
  297. else
  298. m_SteppingDelta = 0;
  299. if (Default)
  300. m_DefaultValue = (LONG)(10000000 / Default);
  301. else
  302. m_DefaultValue = 0;
  303. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: *pMin=%ld, *pMax=%ld, *pSteppingDelta=%ld, *pDefault=%ld"), _fx_, Min, Max, SteppingDelta, Default));
  304. }
  305. else
  306. {
  307. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: Failed Hr=0x%08lX"), _fx_, Hr));
  308. }
  309. break;
  310. case IDC_Capture_Bitrate:
  311. case IDC_Capture_CurrentBitrate:
  312. if (m_pITQualityControl && SUCCEEDED (Hr = m_pITQualityControl->GetRange(Quality_MaxBitrate, &m_Min, &m_Max, &m_SteppingDelta, &m_DefaultValue, &m_CapsFlags)))
  313. {
  314. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: *pdwMin=%ld, *pdwMax=%ld, *pdwSteppingDelta=%ld, *pdwDefault=%ld, dwLayerId=0"), _fx_, m_Min, m_Max, m_SteppingDelta, m_DefaultValue));
  315. }
  316. else
  317. {
  318. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: Failed Hr=0x%08lX"), _fx_, Hr));
  319. }
  320. break;
  321. default:
  322. Hr = E_UNEXPECTED;
  323. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: Unknown capture property"), _fx_));
  324. }
  325. */
  326. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  327. return Hr;
  328. }
  329. /****************************************************************************
  330. * @doc INTERNAL CCAPTUREPMETHOD
  331. *
  332. * @mfunc HPROPSHEETPAGE | CCaptureProperties | OnCreate | This
  333. * method creates a new page for a property sheet.
  334. *
  335. * @rdesc Returns the handle to the new property sheet if successful, or
  336. * NULL otherwise.
  337. ***************************************************************************/
  338. HPROPSHEETPAGE CCaptureProperties::OnCreate()
  339. {
  340. PROPSHEETPAGE psp;
  341. psp.dwSize = sizeof(psp);
  342. psp.dwFlags = PSP_USEREFPARENT;
  343. psp.hInstance = ghInst;
  344. psp.pszTemplate = MAKEINTRESOURCE(IDD_CaptureFormatProperties);
  345. psp.pfnDlgProc = BaseDlgProc;
  346. psp.pcRefParent = 0;
  347. psp.pfnCallback = (LPFNPSPCALLBACK)NULL;
  348. psp.lParam = (LPARAM)this;
  349. return CreatePropertySheetPage(&psp);
  350. }
  351. /****************************************************************************
  352. * @doc INTERNAL CCAPTUREPMETHOD
  353. *
  354. * @mfunc void | CCaptureProperties | CCaptureProperties | This
  355. * method is the constructor for the property page object. It simply
  356. * calls the constructor of the property page base class.
  357. *
  358. * @rdesc Nada.
  359. ***************************************************************************/
  360. CCaptureProperties::CCaptureProperties()
  361. {
  362. FX_ENTRY("CCaptureProperties::CCaptureProperties")
  363. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: begin"), _fx_));
  364. m_pITQualityControl = NULL;
  365. m_pITFormatControl = NULL;
  366. m_NumProperties = NUM_CAPTURE_CONTROLS;
  367. m_hWndFormat = m_hDlg = NULL;
  368. m_dwRangeCount = 0;
  369. m_FormatList = NULL;
  370. m_CapsList = NULL;
  371. m_CurrentMediaType = NULL;
  372. m_CurrentFormat = 0;
  373. m_OriginalFormat = 0;
  374. for (int i = 0; i < m_NumProperties; i++)
  375. m_Controls[i] = NULL;
  376. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  377. }
  378. /****************************************************************************
  379. * @doc INTERNAL CCAPTUREPMETHOD
  380. *
  381. * @mfunc void | CCaptureProperties | ~CCaptureProperties | This
  382. * method is the destructor for the capture pin property page. It
  383. * simply calls the base class destructor after deleting all the controls.
  384. *
  385. * @rdesc Nada.
  386. ***************************************************************************/
  387. CCaptureProperties::~CCaptureProperties()
  388. {
  389. int j;
  390. FX_ENTRY("CCaptureProperties::~CCaptureProperties")
  391. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: begin"), _fx_));
  392. // Free the controls
  393. for (j = 0; j < m_NumProperties; j++)
  394. {
  395. if (m_Controls[j])
  396. {
  397. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: deleting m_Controls[%ld]=0x%08lX"), _fx_, j, m_Controls[j]));
  398. delete m_Controls[j], m_Controls[j] = NULL;
  399. }
  400. else
  401. {
  402. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: WARNING: control already freed"), _fx_));
  403. }
  404. }
  405. // Free the list of formats
  406. if (m_FormatList)
  407. {
  408. for (DWORD dw=0; dw<m_dwRangeCount; dw++)
  409. {
  410. if (m_FormatList[dw])
  411. {
  412. // Release the memory allocated for the format structures
  413. DeleteAMMediaType(m_FormatList[dw]);
  414. }
  415. }
  416. delete[] m_FormatList, m_FormatList = NULL;
  417. }
  418. // Free the list of caps
  419. if (m_CapsList)
  420. delete[] m_CapsList, m_CapsList = NULL;
  421. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  422. }
  423. /****************************************************************************
  424. * @doc INTERNAL CCAPTUREPMETHOD
  425. *
  426. * @mfunc HRESULT | CCaptureProperties | OnConnect | This
  427. * method is called when the property page is connected to a TAPI object.
  428. *
  429. * @parm ITStream* | pStream | Specifies a pointer to the <i ITStream>
  430. * interface. It is used to QI for the <i ITQualityControl> and
  431. * <i ITFormatControl> interfaces.
  432. *
  433. * @rdesc This method returns an HRESULT value that depends on the
  434. * implementation of the interface. HRESULT can include one of the
  435. * following standard constants, or other values not listed:
  436. *
  437. * @flag E_FAIL | Failure
  438. * @flag E_POINTER | Null pointer argument
  439. * @flag E_NOTIMPL | Method is not supported
  440. * @flag NOERROR | No error
  441. ***************************************************************************/
  442. HRESULT CCaptureProperties::OnConnect(ITStream *pStream)
  443. {
  444. HRESULT Hr = NOERROR;
  445. FX_ENTRY("CCaptureProperties::OnConnect")
  446. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: begin"), _fx_));
  447. // Validate input parameters
  448. if (!pStream)
  449. {
  450. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: invalid input parameter"), _fx_));
  451. Hr = E_POINTER;
  452. goto MyExit;
  453. }
  454. // Get the quality control interface
  455. if (SUCCEEDED (Hr = pStream->QueryInterface(__uuidof(ITStreamQualityControl), (void **)&m_pITQualityControl)))
  456. {
  457. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: m_pITQualityControl=0x%08lX"), _fx_, m_pITQualityControl));
  458. }
  459. else
  460. {
  461. m_pITQualityControl = NULL;
  462. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: Failed Hr=0x%08lX"), _fx_, Hr));
  463. }
  464. // Get the format control interface
  465. if (SUCCEEDED (Hr = pStream->QueryInterface(__uuidof(ITFormatControl), (void **)&m_pITFormatControl)))
  466. {
  467. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: m_pITFormatControl=0x%08lX"), _fx_, m_pITFormatControl));
  468. }
  469. else
  470. {
  471. m_pITFormatControl = NULL;
  472. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: Failed Hr=0x%08lX"), _fx_, Hr));
  473. }
  474. // It's Ok if we couldn't get interface pointers
  475. // We'll just grey the controls in the property page
  476. // to make it clear to the user that they can't
  477. // control those properties on the capture device
  478. Hr = NOERROR;
  479. MyExit:
  480. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  481. return Hr;
  482. }
  483. /****************************************************************************
  484. * @doc INTERNAL CCAPTUREPMETHOD
  485. *
  486. * @mfunc HRESULT | CCaptureProperties | OnDisconnect | This
  487. * method is called when the property page is disconnected from the owning
  488. * filter.
  489. *
  490. * @rdesc This method returns an HRESULT value that depends on the
  491. * implementation of the interface. HRESULT can include one of the
  492. * following standard constants, or other values not listed:
  493. *
  494. * @flag NOERROR | No error
  495. ***************************************************************************/
  496. HRESULT CCaptureProperties::OnDisconnect()
  497. {
  498. FX_ENTRY("CCaptureProperties::OnDisconnect")
  499. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: begin"), _fx_));
  500. // Validate input parameters
  501. if (!m_pITQualityControl)
  502. {
  503. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: WARNING: already disconnected!"), _fx_));
  504. }
  505. else
  506. {
  507. // Release the interface
  508. m_pITQualityControl->Release();
  509. m_pITQualityControl = NULL;
  510. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: releasing m_pITQualityControl"), _fx_));
  511. }
  512. if (!m_pITFormatControl)
  513. {
  514. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: WARNING: already disconnected!"), _fx_));
  515. }
  516. else
  517. {
  518. // Release the interface
  519. m_pITFormatControl->Release();
  520. m_pITFormatControl = NULL;
  521. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: releasing m_pITFormatControl"), _fx_));
  522. }
  523. // Release format memory
  524. if (m_CurrentMediaType)
  525. {
  526. DeleteAMMediaType(m_CurrentMediaType);
  527. m_CurrentMediaType = NULL;
  528. }
  529. // Free the list of formats
  530. if (m_FormatList)
  531. {
  532. for (DWORD dw=0; dw<m_dwRangeCount; dw++)
  533. {
  534. if (m_FormatList[dw])
  535. {
  536. // Release the memory allocated for the format structures
  537. DeleteAMMediaType(m_FormatList[dw]);
  538. }
  539. }
  540. delete[] m_FormatList, m_FormatList = NULL;
  541. }
  542. // Free the list of caps
  543. if (m_CapsList)
  544. delete[] m_CapsList, m_CapsList = NULL;
  545. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  546. return NOERROR;
  547. }
  548. /****************************************************************************
  549. * @doc INTERNAL CCAPTUREPMETHOD
  550. *
  551. * @mfunc HRESULT | CCaptureProperties | OnActivate | This
  552. * method is called when the property page is activated.
  553. *
  554. * @rdesc This method returns an HRESULT value that depends on the
  555. * implementation of the interface. HRESULT can include one of the
  556. * following standard constants, or other values not listed:
  557. *
  558. * @flag E_FAIL | Failure
  559. * @flag E_POINTER | Null pointer argument
  560. * @flag E_NOTIMPL | Method is not supported
  561. * @flag NOERROR | No error
  562. ***************************************************************************/
  563. HRESULT CCaptureProperties::OnActivate()
  564. {
  565. HRESULT Hr = NOERROR;
  566. DWORD dw;
  567. int i;
  568. TCHAR buf[280];
  569. FX_ENTRY("CCaptureProperties::OnActivate")
  570. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: begin"), _fx_));
  571. // Initialize format control structures
  572. m_hWndFormat = GetDlgItem(m_hDlg, IDC_FORMAT_Compression);
  573. // Disable everything if we didn't initialize correctly
  574. if (!m_pITFormatControl || (FAILED (Hr = InitialRangeScan())))
  575. {
  576. EnableWindow(m_hWndFormat, FALSE);
  577. }
  578. else
  579. {
  580. // Update the content of the format combo box
  581. ComboBox_ResetContent(m_hWndFormat);
  582. for (dw = 0; dw < m_dwRangeCount; dw++)
  583. {
  584. wsprintf(buf, L"%ls %ldx%ld", &m_CapsList[dw].VideoCap.Description, HEADER(m_FormatList[dw]->pbFormat)->biWidth, HEADER(m_FormatList[dw]->pbFormat)->biHeight);
  585. ComboBox_AddString(m_hWndFormat, buf);
  586. if (m_CurrentMediaType->subtype == m_FormatList[dw]->subtype && HEADER(m_CurrentMediaType->pbFormat)->biWidth == HEADER(m_FormatList[dw]->pbFormat)->biWidth && HEADER(m_CurrentMediaType->pbFormat)->biHeight == HEADER(m_FormatList[dw]->pbFormat)->biHeight)
  587. {
  588. ComboBox_SetCurSel(m_hWndFormat, dw);
  589. }
  590. }
  591. // Update current format
  592. OnFormatChanged();
  593. // Remember the original format
  594. m_OriginalFormat = m_CurrentFormat;
  595. }
  596. // Create the controls for the properties
  597. if (m_Controls[0] = new CCaptureProperty(m_hDlg, IDC_BitrateControl_Label, IDC_BitrateControl_Minimum, IDC_BitrateControl_Maximum, IDC_BitrateControl_Default, IDC_BitrateControl_Stepping, IDC_BitrateControl_Edit, IDC_BitrateControl_Slider, 0, IDC_Capture_Bitrate, m_pITQualityControl))
  598. {
  599. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: m_Controls[0]=0x%08lX"), _fx_, m_Controls[0]));
  600. if (m_Controls[1] = new CCaptureProperty(m_hDlg, IDC_FrameRateControl_Label, IDC_FrameRateControl_Minimum, IDC_FrameRateControl_Maximum, IDC_FrameRateControl_Default, IDC_FrameRateControl_Stepping, IDC_FrameRateControl_Edit, IDC_FrameRateControl_Slider, 0, IDC_Capture_FrameRate, m_pITQualityControl))
  601. {
  602. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: m_Controls[1]=0x%08lX"), _fx_, m_Controls[1]));
  603. if (m_Controls[2] = new CCaptureProperty(m_hDlg, 0, 0, 0, 0, 0, IDC_FrameRateControl_Actual, 0, IDC_FrameRateControl_Meter, IDC_Capture_CurrentFrameRate, m_pITQualityControl))
  604. {
  605. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: m_Controls[2]=0x%08lX"), _fx_, m_Controls[2]));
  606. if (m_Controls[3] = new CCaptureProperty(m_hDlg, 0, 0, 0, 0, 0, IDC_BitrateControl_Actual, 0, IDC_BitrateControl_Meter, IDC_Capture_CurrentBitrate, m_pITQualityControl))
  607. {
  608. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: m_Controls[3]=0x%08lX"), _fx_, m_Controls[3]));
  609. }
  610. else
  611. {
  612. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: Out of memory"), _fx_));
  613. delete m_Controls[0], m_Controls[0] = NULL;
  614. delete m_Controls[1], m_Controls[1] = NULL;
  615. delete m_Controls[2], m_Controls[2] = NULL;
  616. Hr = E_OUTOFMEMORY;
  617. goto MyExit;
  618. }
  619. }
  620. else
  621. {
  622. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: Out of memory"), _fx_));
  623. delete m_Controls[0], m_Controls[0] = NULL;
  624. delete m_Controls[1], m_Controls[1] = NULL;
  625. Hr = E_OUTOFMEMORY;
  626. goto MyExit;
  627. }
  628. }
  629. else
  630. {
  631. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: Out of memory"), _fx_));
  632. delete m_Controls[0], m_Controls[0] = NULL;
  633. Hr = E_OUTOFMEMORY;
  634. goto MyExit;
  635. }
  636. }
  637. else
  638. {
  639. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: Out of memory"), _fx_));
  640. Hr = E_OUTOFMEMORY;
  641. goto MyExit;
  642. }
  643. // Initialize all the controls. If the initialization fails, it's Ok. It just means
  644. // that the TAPI control interface isn't implemented by the device. The dialog item
  645. // in the property page will be greyed, showing this to the user.
  646. for (i = 0; i < m_NumProperties; i++)
  647. {
  648. if (m_Controls[i]->Init())
  649. {
  650. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: m_Controls[%ld]->Init()"), _fx_, i));
  651. }
  652. else
  653. {
  654. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: WARNING: m_Controls[%ld]->Init() failed"), _fx_, i));
  655. }
  656. }
  657. MyExit:
  658. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  659. return Hr;
  660. }
  661. /****************************************************************************
  662. * @doc INTERNAL CCAPTUREPMETHOD
  663. *
  664. * @mfunc HRESULT | CCaptureProperties | OnDeactivate | This
  665. * method is called when the property page is dismissed.
  666. *
  667. * @rdesc This method returns an HRESULT value that depends on the
  668. * implementation of the interface. HRESULT can include one of the
  669. * following standard constants, or other values not listed:
  670. *
  671. * @flag NOERROR | No error
  672. ***************************************************************************/
  673. HRESULT CCaptureProperties::OnDeactivate()
  674. {
  675. int j;
  676. FX_ENTRY("CCaptureProperties::OnDeactivate")
  677. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: begin"), _fx_));
  678. // Free the controls
  679. for (j = 0; j < m_NumProperties; j++)
  680. {
  681. if (m_Controls[j])
  682. {
  683. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: deleting m_Controls[%ld]=0x%08lX"), _fx_, j, m_Controls[j]));
  684. delete m_Controls[j], m_Controls[j] = NULL;
  685. }
  686. else
  687. {
  688. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: WARNING: control already freed"), _fx_));
  689. }
  690. }
  691. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  692. return NOERROR;
  693. }
  694. /****************************************************************************
  695. * @doc INTERNAL CCAPTUREPMETHOD
  696. *
  697. * @mfunc HRESULT | CCaptureProperties | GetCurrentMediaType | This
  698. * method is used to retrieve the current media format used by the pin.
  699. *
  700. * @rdesc This method returns an HRESULT value that depends on the
  701. * implementation of the interface. HRESULT can include one of the
  702. * following standard constants, or other values not listed:
  703. *
  704. * @flag NOERROR | No error
  705. ***************************************************************************/
  706. HRESULT CCaptureProperties::GetCurrentMediaType(void)
  707. {
  708. HRESULT Hr = NOERROR;
  709. FX_ENTRY("CCaptureProperties::GetCurrentMediaType")
  710. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: begin"), _fx_));
  711. if (m_CurrentMediaType)
  712. {
  713. DeleteAMMediaType(m_CurrentMediaType);
  714. m_CurrentMediaType = NULL;
  715. }
  716. if (FAILED (Hr = m_pITFormatControl->GetCurrentFormat((AM_MEDIA_TYPE **)&m_CurrentMediaType)))
  717. {
  718. // Otherwise, just get the first enumerated media type
  719. TAPI_STREAM_CONFIG_CAPS RangeCaps;
  720. BOOL fEnabled; // Is this format currently enabled (according to the H.245 capability resolver)
  721. if (FAILED (Hr = m_pITFormatControl->GetStreamCaps(0, (AM_MEDIA_TYPE **)&m_CurrentMediaType, &RangeCaps, &fEnabled)))
  722. {
  723. m_CurrentMediaType = NULL;
  724. }
  725. }
  726. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  727. return Hr;
  728. }
  729. /****************************************************************************
  730. * @doc INTERNAL CCAPTUREPMETHOD
  731. *
  732. * @mfunc HRESULT | CCaptureProperties | DeleteAMMediaType | This
  733. * method is used to delete a task-allocated AM_MEDIA_TYPE structure.
  734. *
  735. * @rdesc This method returns an HRESULT value that depends on the
  736. * implementation of the interface. HRESULT can include one of the
  737. * following standard constants, or other values not listed:
  738. *
  739. * @flag NOERROR | No error
  740. *
  741. * @comm There is a DShow DeleteMediaType, but it'd be pretty dumb to link to
  742. * strmbase.lib just for this little guy, would it?
  743. ***************************************************************************/
  744. HRESULT CCaptureProperties::DeleteAMMediaType(AM_MEDIA_TYPE *pAMMT)
  745. {
  746. HRESULT Hr = NOERROR;
  747. FX_ENTRY("CCaptureProperties::DeleteAMMediaType")
  748. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: begin"), _fx_));
  749. if (pAMMT)
  750. {
  751. if (pAMMT->cbFormat != 0 && pAMMT->pbFormat)
  752. {
  753. CoTaskMemFree((PVOID)pAMMT->pbFormat);
  754. }
  755. if (pAMMT->pUnk != NULL)
  756. {
  757. pAMMT->pUnk->Release();
  758. }
  759. }
  760. CoTaskMemFree((PVOID)pAMMT);
  761. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  762. return Hr;
  763. }
  764. /****************************************************************************
  765. * @doc INTERNAL CCAPTUREPMETHOD
  766. *
  767. * @mfunc HRESULT | CCaptureProperties | OnFormatChanged | This
  768. * method is used to retrieve the format selected by the user.
  769. *
  770. * @rdesc This method returns an HRESULT value that depends on the
  771. * implementation of the interface. HRESULT can include one of the
  772. * following standard constants, or other values not listed:
  773. *
  774. * @flag NOERROR | No error
  775. ***************************************************************************/
  776. HRESULT CCaptureProperties::OnFormatChanged()
  777. {
  778. HRESULT Hr = E_UNEXPECTED;
  779. DWORD dw;
  780. FX_ENTRY("CCaptureProperties::OnFormatChanged")
  781. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: begin"), _fx_));
  782. if (!m_pITFormatControl)
  783. {
  784. Hr = E_INVALIDARG;
  785. goto MyExit;
  786. }
  787. // Associate the current compression index with the right range index
  788. m_CurrentFormat = ComboBox_GetCurSel(m_hWndFormat);
  789. if (m_CurrentFormat < m_dwRangeCount)
  790. {
  791. // Hr = m_pITFormatControl->SetPreferredFormat(m_FormatList[m_CurrentFormat]);
  792. }
  793. MyExit:
  794. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  795. return Hr;
  796. }
  797. /****************************************************************************
  798. * @doc INTERNAL CCAPTUREPMETHOD
  799. *
  800. * @mfunc HRESULT | CCaptureProperties | InitialRangeScan | This
  801. * method is used to retrieve the list of supported formats on the stream.
  802. *
  803. * @rdesc This method returns an HRESULT value that depends on the
  804. * implementation of the interface. HRESULT can include one of the
  805. * following standard constants, or other values not listed:
  806. *
  807. * @flag NOERROR | No error
  808. ***************************************************************************/
  809. HRESULT CCaptureProperties::InitialRangeScan()
  810. {
  811. HRESULT Hr = NOERROR;
  812. DWORD dw;
  813. AM_MEDIA_TYPE *pmt = NULL;
  814. FX_ENTRY("CCaptureProperties::InitialRangeScan")
  815. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: begin"), _fx_));
  816. if (!m_pITFormatControl)
  817. {
  818. Hr = E_INVALIDARG;
  819. goto MyExit;
  820. }
  821. Hr = m_pITFormatControl->GetNumberOfCapabilities(&m_dwRangeCount);
  822. if (!SUCCEEDED(Hr))
  823. {
  824. Hr = E_FAIL;
  825. goto MyExit;
  826. }
  827. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: NumberOfRanges=%d"), _fx_, m_dwRangeCount));
  828. if (!(m_CapsList = new TAPI_STREAM_CONFIG_CAPS [m_dwRangeCount]))
  829. {
  830. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: new failed"), _fx_));
  831. Hr = E_OUTOFMEMORY;
  832. goto MyExit;
  833. }
  834. if (!(m_FormatList = new AM_MEDIA_TYPE* [m_dwRangeCount]))
  835. {
  836. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: new failed"), _fx_));
  837. Hr = E_OUTOFMEMORY;
  838. goto MyError;
  839. }
  840. ZeroMemory(m_FormatList, m_dwRangeCount * sizeof(AM_MEDIA_TYPE*));
  841. for (dw = 0; dw < m_dwRangeCount; dw++)
  842. {
  843. BOOL fEnabled; // Is this format currently enabled (according to the H.245 capability resolver)
  844. Hr = m_pITFormatControl->GetStreamCaps(dw, &m_FormatList[dw], &m_CapsList[dw], &fEnabled);
  845. }
  846. // Get default format
  847. Hr = GetCurrentMediaType();
  848. goto MyExit;
  849. MyError:
  850. if (m_CapsList)
  851. delete[] m_CapsList, m_CapsList = NULL;
  852. MyExit:
  853. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  854. return Hr;
  855. }
  856. /****************************************************************************
  857. * @doc INTERNAL CCAPTUREPMETHOD
  858. *
  859. * @mfunc HRESULT | CCaptureProperties | OnApplyChanges | This
  860. * method is called when the user applies changes to the property page.
  861. *
  862. * @rdesc This method returns an HRESULT value that depends on the
  863. * implementation of the interface. HRESULT can include one of the
  864. * following standard constants, or other values not listed:
  865. *
  866. * @flag E_FAIL | Failure
  867. * @flag E_POINTER | Null pointer argument
  868. * @flag E_NOTIMPL | Method is not supported
  869. * @flag NOERROR | No error
  870. ***************************************************************************/
  871. HRESULT CCaptureProperties::OnApplyChanges()
  872. {
  873. HRESULT Hr = NOERROR;
  874. int j;
  875. CMediaType *pmt = NULL;
  876. BOOL fEnabled; // Is this format currently enabled (according to the H.245 capability resolver)
  877. FX_ENTRY("CCaptureProperties::OnApplyChanges")
  878. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: begin"), _fx_));
  879. // Apply format changes on video stream
  880. m_CurrentFormat = ComboBox_GetCurSel(m_hWndFormat);
  881. // Only apply change if the format is different
  882. if (m_CurrentFormat != m_OriginalFormat)
  883. {
  884. // if (FAILED(Hr = m_pITFormatControl->SetPreferredFormat(m_FormatList[m_CurrentFormat])))
  885. {
  886. // Why did you mess with the format that was returned to you?
  887. }
  888. // Update our copy of the current format
  889. GetCurrentMediaType();
  890. }
  891. // Apply target bitrate and target frame rate changes on video stream
  892. for (j = 0; j < IDC_Capture_CurrentBitrate; j++)
  893. {
  894. if (m_Controls[j])
  895. {
  896. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: calling m_Controls[%ld]=0x%08lX->OnApply"), _fx_, j, m_Controls[j]));
  897. if (m_Controls[j]->HasChanged())
  898. m_Controls[j]->OnApply();
  899. Hr = NOERROR;
  900. }
  901. else
  902. {
  903. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: can't calling m_Controls[%ld]=NULL->OnApply"), _fx_, j));
  904. Hr = E_UNEXPECTED;
  905. }
  906. }
  907. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  908. return Hr;
  909. }
  910. /****************************************************************************
  911. * @doc INTERNAL CCAPTUREPMETHOD
  912. *
  913. * @mfunc BOOL | CCaptureProperties | BaseDlgProc | This
  914. * method is called when a message is sent to the property page dialog box.
  915. *
  916. * @rdesc By default, returns the value returned by the Win32 DefWindowProc function.
  917. ***************************************************************************/
  918. INT_PTR CALLBACK CCaptureProperties::BaseDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  919. {
  920. CCaptureProperties *pSV = (CCaptureProperties*)GetWindowLong(hDlg, DWL_USER);
  921. int iNotify = HIWORD (wParam);
  922. int j;
  923. switch (uMsg)
  924. {
  925. case WM_INITDIALOG:
  926. {
  927. LPPROPSHEETPAGE psp = (LPPROPSHEETPAGE)lParam;
  928. pSV = (CCaptureProperties*)psp->lParam;
  929. pSV->m_hDlg = hDlg;
  930. SetWindowLong(hDlg, DWL_USER, (LPARAM)pSV);
  931. pSV->m_bInit = FALSE;
  932. //pSV->OnActivate();
  933. //pSV->m_bInit = TRUE;
  934. return TRUE;
  935. }
  936. break;
  937. case WM_TIMER:
  938. if (pSV && pSV->m_bInit)
  939. {
  940. // Update the Vu-Meters
  941. for (j = 0; j < pSV->m_NumProperties; j++)
  942. {
  943. if (pSV->m_Controls[j]->GetProgressHWnd())
  944. {
  945. pSV->m_Controls[j]->UpdateProgress();
  946. pSV->SetDirty();
  947. }
  948. }
  949. }
  950. break;
  951. case WM_HSCROLL:
  952. case WM_VSCROLL:
  953. if (pSV && pSV->m_bInit)
  954. {
  955. // Process all of the Trackbar messages
  956. for (j = 0; j < pSV->m_NumProperties; j++)
  957. {
  958. if (pSV->m_Controls[j]->GetTrackbarHWnd() == (HWND)lParam)
  959. {
  960. pSV->m_Controls[j]->OnScroll(uMsg, wParam, lParam);
  961. pSV->SetDirty();
  962. }
  963. }
  964. // pSV->OnApplyChanges();
  965. }
  966. break;
  967. case WM_COMMAND:
  968. if (pSV && pSV->m_bInit)
  969. {
  970. // Process all of the auto checkbox messages
  971. for (j = 0; j < pSV->m_NumProperties; j++)
  972. {
  973. if (pSV->m_Controls[j] && pSV->m_Controls[j]->GetAutoHWnd() == (HWND)lParam)
  974. {
  975. pSV->m_Controls[j]->OnAuto(uMsg, wParam, lParam);
  976. pSV->SetDirty();
  977. break;
  978. }
  979. }
  980. // Process all of the edit box messages
  981. for (j = 0; j < pSV->m_NumProperties; j++)
  982. {
  983. if (pSV->m_Controls[j] && pSV->m_Controls[j]->GetEditHWnd() == (HWND)lParam)
  984. {
  985. pSV->m_Controls[j]->OnEdit(uMsg, wParam, lParam);
  986. pSV->SetDirty();
  987. break;
  988. }
  989. }
  990. switch (LOWORD(wParam))
  991. {
  992. case IDC_CONTROL_DEFAULT:
  993. for (j = 0; j < pSV->m_NumProperties; j++)
  994. {
  995. if (pSV->m_Controls[j])
  996. pSV->m_Controls[j]->OnDefault();
  997. }
  998. break;
  999. case IDC_FORMAT_Compression:
  1000. if (HIWORD(wParam) == CBN_SELCHANGE)
  1001. {
  1002. pSV->OnFormatChanged();
  1003. }
  1004. break;
  1005. default:
  1006. break;
  1007. }
  1008. //pSV->OnApplyChanges();
  1009. }
  1010. break;
  1011. case WM_NOTIFY:
  1012. if (pSV)
  1013. {
  1014. switch (((NMHDR FAR *)lParam)->code)
  1015. {
  1016. case PSN_SETACTIVE:
  1017. {
  1018. // We call out here specially so we can mark this page as having been init'd.
  1019. int iRet = pSV->OnActivate();
  1020. pSV->m_bInit = TRUE;
  1021. return iRet;
  1022. }
  1023. break;
  1024. case PSN_APPLY:
  1025. pSV->OnApplyChanges();
  1026. break;
  1027. case PSN_QUERYCANCEL:
  1028. // return pSV->QueryCancel();
  1029. break;
  1030. default:
  1031. break;
  1032. }
  1033. }
  1034. break;
  1035. default:
  1036. return FALSE;
  1037. }
  1038. return TRUE;
  1039. }
  1040. /****************************************************************************
  1041. * @doc INTERNAL CCAPTUREPMETHOD
  1042. *
  1043. * @mfunc BOOL | CCaptureProperties | SetDirty | This
  1044. * method notifies the property page site of changes.
  1045. *
  1046. * @rdesc Nada.
  1047. ***************************************************************************/
  1048. void CCaptureProperties::SetDirty()
  1049. {
  1050. PropSheet_Changed(GetParent(m_hDlg), m_hDlg);
  1051. }