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.

838 lines
14 KiB

  1. #include "stdafx.h"
  2. #include "formats.h"
  3. CTAudioFormat::CTAudioFormat() :
  4. m_pFTM(NULL)
  5. {
  6. }
  7. CTAudioFormat::~CTAudioFormat()
  8. {
  9. if( m_pFTM )
  10. {
  11. m_pFTM->Release();
  12. m_pFTM = NULL;
  13. }
  14. }
  15. HRESULT CTAudioFormat::FinalConstruct(void)
  16. {
  17. LOG((MSP_TRACE, "CTAudioFormat::FinalConstruct - enter"));
  18. HRESULT hr = CoCreateFreeThreadedMarshaler( GetControllingUnknown(),
  19. & m_pFTM );
  20. if ( FAILED(hr) )
  21. {
  22. LOG((MSP_ERROR, "CTAudioFormat::FinalConstruct - "
  23. "create FTM returned 0x%08x; exit", hr));
  24. return hr;
  25. }
  26. LOG((MSP_TRACE, "CTAudioFormat::FinalConstruct - exit S_OK"));
  27. return S_OK;
  28. }
  29. HRESULT CTAudioFormat::get_Channels(
  30. OUT long* pVal
  31. )
  32. {
  33. LOG((MSP_TRACE, "CTAudioFormat::get_Channels enter"));
  34. //
  35. // Validates argument
  36. //
  37. if( IsBadWritePtr( pVal, sizeof(long)) )
  38. {
  39. LOG((MSP_ERROR, "CTAudioFormat::get_Channels exit"
  40. "pVal is a bad pointer. returns E_POINTER"));
  41. return E_POINTER;
  42. }
  43. //
  44. // Critical section
  45. //
  46. CLock lock(m_Lock);
  47. //
  48. // Return value
  49. //
  50. *pVal = m_wfx.nChannels;
  51. LOG((MSP_TRACE, "CTAudioFormat::get_Channels exit S_OK"));
  52. return S_OK;
  53. }
  54. HRESULT CTAudioFormat::put_Channels(
  55. IN const long nNewVal
  56. )
  57. {
  58. LOG((MSP_TRACE, "CTAudioFormat::put_Channels enter"));
  59. //
  60. // Critical section
  61. //
  62. CLock lock(m_Lock);
  63. //
  64. // Set value
  65. //
  66. m_wfx.nChannels = (WORD)nNewVal;
  67. LOG((MSP_TRACE, "CTAudioFormat::put_Channels exit S_OK"));
  68. return S_OK;
  69. }
  70. HRESULT CTAudioFormat::get_SamplesPerSec(
  71. OUT long* pVal
  72. )
  73. {
  74. LOG((MSP_TRACE, "CTAudioFormat::get_SamplesPerSec enter"));
  75. //
  76. // Validates argument
  77. //
  78. if( IsBadWritePtr( pVal, sizeof(long)) )
  79. {
  80. LOG((MSP_ERROR, "CTAudioFormat::get_SamplesPerSec exit"
  81. "pVal is a bad pointer. returns E_POINTER"));
  82. return E_POINTER;
  83. }
  84. //
  85. // Critical section
  86. //
  87. CLock lock(m_Lock);
  88. //
  89. // Return value
  90. //
  91. *pVal = m_wfx.nSamplesPerSec;
  92. LOG((MSP_TRACE, "CTAudioFormat::get_SamplesPerSec exit S_OK"));
  93. return S_OK;
  94. }
  95. HRESULT CTAudioFormat::put_SamplesPerSec(
  96. IN const long nNewVal
  97. )
  98. {
  99. LOG((MSP_TRACE, "CTAudioFormat::put_SamplesPerSec enter"));
  100. //
  101. // Critical section
  102. //
  103. CLock lock(m_Lock);
  104. //
  105. // Set value
  106. //
  107. m_wfx.nSamplesPerSec = (DWORD)nNewVal;
  108. LOG((MSP_TRACE, "CTAudioFormat::put_SamplesPerSec exit S_OK"));
  109. return S_OK;
  110. }
  111. HRESULT CTAudioFormat::get_AvgBytesPerSec(
  112. OUT long* pVal
  113. )
  114. {
  115. LOG((MSP_TRACE, "CTAudioFormat::get_AvgBytesPerSec enter"));
  116. //
  117. // Validates argument
  118. //
  119. if( IsBadWritePtr( pVal, sizeof(long)) )
  120. {
  121. LOG((MSP_ERROR, "CTAudioFormat::get_AvgBytesPerSec exit"
  122. "pVal is a bad pointer. returns E_POINTER"));
  123. return E_POINTER;
  124. }
  125. //
  126. // Critical section
  127. //
  128. CLock lock(m_Lock);
  129. //
  130. // Return value
  131. //
  132. *pVal = m_wfx.nAvgBytesPerSec;
  133. LOG((MSP_TRACE, "CTAudioFormat::get_AvgBytesPerSec exit S_OK"));
  134. return S_OK;
  135. }
  136. HRESULT CTAudioFormat::put_AvgBytesPerSec(
  137. IN const long nNewVal
  138. )
  139. {
  140. LOG((MSP_TRACE, "CTAudioFormat::put_AvgBytesPerSec enter"));
  141. //
  142. // Critical section
  143. //
  144. CLock lock(m_Lock);
  145. //
  146. // Set value
  147. //
  148. m_wfx.nAvgBytesPerSec = (DWORD)nNewVal;
  149. LOG((MSP_TRACE, "CTAudioFormat::put_AvgBytesPerSec exit S_OK"));
  150. return S_OK;
  151. }
  152. HRESULT CTAudioFormat::get_BlockAlign(
  153. OUT long* pVal
  154. )
  155. {
  156. LOG((MSP_TRACE, "CTAudioFormat::get_BlockAlign enter"));
  157. //
  158. // Validates argument
  159. //
  160. if( IsBadWritePtr( pVal, sizeof(long)) )
  161. {
  162. LOG((MSP_ERROR, "CTAudioFormat::get_BlockAlign exit"
  163. "pVal is a bad pointer. returns E_POINTER"));
  164. return E_POINTER;
  165. }
  166. //
  167. // Critical section
  168. //
  169. CLock lock(m_Lock);
  170. //
  171. // Return value
  172. //
  173. *pVal = m_wfx.nBlockAlign;
  174. LOG((MSP_TRACE, "CTAudioFormat::get_BlockAlign exit S_OK"));
  175. return S_OK;
  176. }
  177. HRESULT CTAudioFormat::put_BlockAlign(
  178. IN const long nNewVal
  179. )
  180. {
  181. LOG((MSP_TRACE, "CTAudioFormat::put_BlockAlign enter"));
  182. //
  183. // Critical section
  184. //
  185. CLock lock(m_Lock);
  186. //
  187. // Set value
  188. //
  189. m_wfx.nBlockAlign = (WORD)nNewVal;
  190. LOG((MSP_TRACE, "CTAudioFormat::put_BlockAlign exit S_OK"));
  191. return S_OK;
  192. }
  193. HRESULT CTAudioFormat::get_BitsPerSample(
  194. OUT long* pVal
  195. )
  196. {
  197. LOG((MSP_TRACE, "CTAudioFormat::get_BitsPerSample enter"));
  198. //
  199. // Validates argument
  200. //
  201. if( IsBadWritePtr( pVal, sizeof(long)) )
  202. {
  203. LOG((MSP_ERROR, "CTAudioFormat::get_BitsPerSample exit"
  204. "pVal is a bad pointer. returns E_POINTER"));
  205. return E_POINTER;
  206. }
  207. //
  208. // Critical section
  209. //
  210. CLock lock(m_Lock);
  211. //
  212. // Return value
  213. //
  214. *pVal = m_wfx.wBitsPerSample;
  215. LOG((MSP_TRACE, "CTAudioFormat::get_BitsPerSample exit S_OK"));
  216. return S_OK;
  217. }
  218. HRESULT CTAudioFormat::put_BitsPerSample(
  219. IN const long nNewVal
  220. )
  221. {
  222. LOG((MSP_TRACE, "CTAudioFormat::put_BitsPerSample enter"));
  223. //
  224. // Critical section
  225. //
  226. CLock lock(m_Lock);
  227. //
  228. // Set value
  229. //
  230. m_wfx.wBitsPerSample = (WORD)nNewVal;
  231. LOG((MSP_TRACE, "CTAudioFormat::put_BitsPerSample exit S_OK"));
  232. return S_OK;
  233. }
  234. HRESULT CTAudioFormat::get_FormatTag(
  235. OUT long* pVal
  236. )
  237. {
  238. LOG((MSP_TRACE, "CTAudioFormat::get_FormatTag enter"));
  239. //
  240. // Validates argument
  241. //
  242. if( IsBadWritePtr( pVal, sizeof(long)) )
  243. {
  244. LOG((MSP_ERROR, "CTAudioFormat::get_FormatTag exit"
  245. "pVal is a bad pointer. returns E_POINTER"));
  246. return E_POINTER;
  247. }
  248. //
  249. // Critical section
  250. //
  251. CLock lock(m_Lock);
  252. //
  253. // Return value
  254. //
  255. *pVal = m_wfx.wFormatTag;
  256. LOG((MSP_TRACE, "CTAudioFormat::get_FormatTag exit S_OK"));
  257. return S_OK;
  258. }
  259. HRESULT CTAudioFormat::put_FormatTag(
  260. IN const long nNewVal
  261. )
  262. {
  263. LOG((MSP_TRACE, "CTAudioFormat::put_FormatTag enter"));
  264. //
  265. // Critical section
  266. //
  267. CLock lock(m_Lock);
  268. //
  269. // Set value
  270. //
  271. m_wfx.wFormatTag = (WORD)nNewVal;
  272. LOG((MSP_TRACE, "CTAudioFormat::put_FormatTag exit S_OK"));
  273. return S_OK;
  274. }
  275. /*
  276. //
  277. // CTVideoFormat
  278. //
  279. CTVideoFormat::CTVideoFormat() :
  280. m_pFTM( NULL )
  281. {
  282. }
  283. CTVideoFormat::~CTVideoFormat()
  284. {
  285. if( m_pFTM )
  286. {
  287. m_pFTM->Release();
  288. m_pFTM = NULL;
  289. }
  290. }
  291. HRESULT CTVideoFormat::FinalConstruct(void)
  292. {
  293. LOG((MSP_TRACE, "CTVideoFormat::FinalConstruct - enter"));
  294. HRESULT hr = CoCreateFreeThreadedMarshaler( GetControllingUnknown(),
  295. & m_pFTM );
  296. if ( FAILED(hr) )
  297. {
  298. LOG((MSP_ERROR, "CTVideoFormat::FinalConstruct - "
  299. "create FTM returned 0x%08x; exit", hr));
  300. return hr;
  301. }
  302. LOG((MSP_TRACE, "CTVideoFormat::FinalConstruct - exit S_OK"));
  303. return S_OK;
  304. }
  305. HRESULT CTVideoFormat::get_BitRate(
  306. OUT long* pVal
  307. )
  308. {
  309. LOG((MSP_TRACE, "CTVideoFormat::get_BitRate enter"));
  310. //
  311. // Validates argument
  312. //
  313. if( IsBadWritePtr( pVal, sizeof(long)) )
  314. {
  315. LOG((MSP_ERROR, "CTVideoFormat::get_BitRate exit"
  316. "pVal is a bad pointer. returns E_POINTER"));
  317. return E_POINTER;
  318. }
  319. //
  320. // Critical section
  321. //
  322. CLock lock(m_Lock);
  323. //
  324. // Returns value
  325. //
  326. *pVal = m_vih.dwBitRate;
  327. LOG((MSP_TRACE, "CTVideoFormat::get_BitRate exit S_OK"));
  328. return S_OK;
  329. }
  330. HRESULT CTVideoFormat::put_BitRate(
  331. IN const long nNewVal
  332. )
  333. {
  334. LOG((MSP_TRACE, "CTVideoFormat::put_BitRate enter"));
  335. //
  336. // Critical section
  337. //
  338. CLock lock(m_Lock);
  339. //
  340. // Set value
  341. //
  342. m_vih.dwBitRate = nNewVal;
  343. LOG((MSP_TRACE, "CTVideoFormat::put_BitRate exit S_OK"));
  344. return S_OK;
  345. }
  346. HRESULT CTVideoFormat::get_BitErrorRate(
  347. OUT long* pVal
  348. )
  349. {
  350. LOG((MSP_TRACE, "CTVideoFormat::get_BitErrorRate enter"));
  351. //
  352. // Validates argument
  353. //
  354. if( IsBadWritePtr( pVal, sizeof(long)) )
  355. {
  356. LOG((MSP_ERROR, "CTVideoFormat::get_BitErrorRate exit"
  357. "pVal is a bad pointer. returns E_POINTER"));
  358. return E_POINTER;
  359. }
  360. //
  361. // Critical section
  362. //
  363. CLock lock(m_Lock);
  364. //
  365. // Returns value
  366. //
  367. *pVal = m_vih.dwBitErrorRate;
  368. LOG((MSP_TRACE, "CTVideoFormat::get_BitErrorRate exit S_OK"));
  369. return S_OK;
  370. }
  371. HRESULT CTVideoFormat::put_BitErrorRate(
  372. IN const long nNewVal
  373. )
  374. {
  375. LOG((MSP_TRACE, "CTVideoFormat::put_BitErrorRate enter"));
  376. //
  377. // Critical section
  378. //
  379. CLock lock(m_Lock);
  380. //
  381. // Set value
  382. //
  383. m_vih.dwBitErrorRate = nNewVal;
  384. LOG((MSP_TRACE, "CTVideoFormat::put_BitErrorRate exit S_OK"));
  385. return S_OK;
  386. }
  387. HRESULT CTVideoFormat::get_AvgTimePerFrame(
  388. OUT double* pVal
  389. )
  390. {
  391. LOG((MSP_TRACE, "CTVideoFormat::get_AvgTimePerFrame enter"));
  392. //
  393. // Validates argument
  394. //
  395. if( IsBadWritePtr( pVal, sizeof(double)) )
  396. {
  397. LOG((MSP_ERROR, "CTVideoFormat::get_AvgTimePerFrame exit"
  398. "pVal is a bad pointer. returns E_POINTER"));
  399. return E_POINTER;
  400. }
  401. //
  402. // Critical section
  403. //
  404. CLock lock(m_Lock);
  405. //
  406. // Returns value
  407. //
  408. *pVal = (double)m_vih.AvgTimePerFrame;
  409. LOG((MSP_TRACE, "CTVideoFormat::get_AvgTimePerFrame exit S_OK"));
  410. return S_OK;
  411. }
  412. HRESULT CTVideoFormat::put_AvgTimePerFrame(
  413. IN const double nNewVal
  414. )
  415. {
  416. LOG((MSP_TRACE, "CTVideoFormat::put_AvgTimePerFrame enter"));
  417. //
  418. // Critical section
  419. //
  420. CLock lock(m_Lock);
  421. //
  422. // Set value
  423. //
  424. m_vih.AvgTimePerFrame = (REFERENCE_TIME)nNewVal;
  425. LOG((MSP_TRACE, "CTVideoFormat::put_AvgTimePerFrame exit S_OK"));
  426. return S_OK;
  427. }
  428. HRESULT CTVideoFormat::get_Width(
  429. OUT long* pVal
  430. )
  431. {
  432. LOG((MSP_TRACE, "CTVideoFormat::get_Width enter"));
  433. //
  434. // Validates argument
  435. //
  436. if( IsBadWritePtr( pVal, sizeof(long)) )
  437. {
  438. LOG((MSP_ERROR, "CTVideoFormat::get_Width exit"
  439. "pVal is a bad pointer. returns E_POINTER"));
  440. return E_POINTER;
  441. }
  442. //
  443. // Critical section
  444. //
  445. CLock lock(m_Lock);
  446. //
  447. // Returns value
  448. //
  449. *pVal = m_vih.bmiHeader.biWidth;
  450. LOG((MSP_TRACE, "CTVideoFormat::get_Width exit S_OK"));
  451. return S_OK;
  452. }
  453. HRESULT CTVideoFormat::put_Width(
  454. IN const long nNewVal
  455. )
  456. {
  457. LOG((MSP_TRACE, "CTVideoFormat::put_Width enter"));
  458. //
  459. // Critical section
  460. //
  461. CLock lock(m_Lock);
  462. //
  463. // Set value
  464. //
  465. m_vih.bmiHeader.biWidth = nNewVal;
  466. LOG((MSP_TRACE, "CTVideoFormat::put_Width exit S_OK"));
  467. return S_OK;
  468. }
  469. HRESULT CTVideoFormat::get_Height(
  470. OUT long* pVal
  471. )
  472. {
  473. LOG((MSP_TRACE, "CTVideoFormat::get_Height enter"));
  474. //
  475. // Validates argument
  476. //
  477. if( IsBadWritePtr( pVal, sizeof(long)) )
  478. {
  479. LOG((MSP_ERROR, "CTVideoFormat::get_Height exit"
  480. "pVal is a bad pointer. returns E_POINTER"));
  481. return E_POINTER;
  482. }
  483. //
  484. // Critical section
  485. //
  486. CLock lock(m_Lock);
  487. //
  488. // Returns value
  489. //
  490. *pVal = m_vih.bmiHeader.biHeight;
  491. LOG((MSP_TRACE, "CTVideoFormat::get_Height exit S_OK"));
  492. return S_OK;
  493. }
  494. HRESULT CTVideoFormat::put_Height(
  495. IN const long nNewVal
  496. )
  497. {
  498. LOG((MSP_TRACE, "CTVideoFormat::put_Height enter"));
  499. //
  500. // Critical section
  501. //
  502. CLock lock(m_Lock);
  503. //
  504. // Set value
  505. //
  506. m_vih.bmiHeader.biHeight = nNewVal;
  507. LOG((MSP_TRACE, "CTVideoFormat::put_Height exit S_OK"));
  508. return S_OK;
  509. }
  510. HRESULT CTVideoFormat::get_BitCount(
  511. OUT long* pVal
  512. )
  513. {
  514. LOG((MSP_TRACE, "CTVideoFormat::get_BitCount enter"));
  515. //
  516. // Validates argument
  517. //
  518. if( IsBadWritePtr( pVal, sizeof(long)) )
  519. {
  520. LOG((MSP_ERROR, "CTVideoFormat::get_BitCount exit"
  521. "pVal is a bad pointer. returns E_POINTER"));
  522. return E_POINTER;
  523. }
  524. //
  525. // Critical section
  526. //
  527. CLock lock(m_Lock);
  528. //
  529. // Returns value
  530. //
  531. *pVal = m_vih.bmiHeader.biBitCount;
  532. LOG((MSP_TRACE, "CTVideoFormat::get_BitCount exit S_OK"));
  533. return S_OK;
  534. }
  535. HRESULT CTVideoFormat::put_BitCount(
  536. IN const long nNewVal
  537. )
  538. {
  539. LOG((MSP_TRACE, "CTVideoFormat::put_BitCount enter"));
  540. //
  541. // Critical section
  542. //
  543. CLock lock(m_Lock);
  544. //
  545. // Set value
  546. //
  547. m_vih.bmiHeader.biBitCount = (WORD)nNewVal;
  548. LOG((MSP_TRACE, "CTVideoFormat::put_BitCount exit S_OK"));
  549. return S_OK;
  550. }
  551. HRESULT CTVideoFormat::get_Compression(
  552. OUT long* pVal
  553. )
  554. {
  555. LOG((MSP_TRACE, "CTVideoFormat::get_Compression enter"));
  556. //
  557. // Validates argument
  558. //
  559. if( IsBadWritePtr( pVal, sizeof(long)) )
  560. {
  561. LOG((MSP_ERROR, "CTVideoFormat::get_Compresion exit"
  562. "pVal is a bad pointer. returns E_POINTER"));
  563. return E_POINTER;
  564. }
  565. //
  566. // Critical section
  567. //
  568. CLock lock(m_Lock);
  569. //
  570. // Returns value
  571. //
  572. *pVal = m_vih.bmiHeader.biCompression;
  573. LOG((MSP_TRACE, "CTVideoFormat::get_Compression exit S_OK"));
  574. return S_OK;
  575. }
  576. HRESULT CTVideoFormat::put_Compression(
  577. IN const long nNewVal
  578. )
  579. {
  580. LOG((MSP_TRACE, "CTVideoFormat::put_Compression enter"));
  581. //
  582. // Critical section
  583. //
  584. CLock lock(m_Lock);
  585. //
  586. // Set value
  587. //
  588. m_vih.bmiHeader.biCompression = nNewVal;
  589. LOG((MSP_TRACE, "CTVideoFormat::put_Compression exit S_OK"));
  590. return S_OK;
  591. }
  592. HRESULT CTVideoFormat::get_SizeImage(
  593. OUT long* pVal
  594. )
  595. {
  596. LOG((MSP_TRACE, "CTVideoFormat::get_SizeImage enter"));
  597. //
  598. // Validates argument
  599. //
  600. if( IsBadWritePtr( pVal, sizeof(long)) )
  601. {
  602. LOG((MSP_ERROR, "CTVideoFormat::put_SizeImage exit"
  603. "pVal is a bad pointer. returns E_POINTER"));
  604. return E_POINTER;
  605. }
  606. //
  607. // Critical section
  608. //
  609. CLock lock(m_Lock);
  610. //
  611. // Returns value
  612. //
  613. *pVal = m_vih.bmiHeader.biSizeImage;
  614. LOG((MSP_TRACE, "CTVideoFormat::get_SizeImage exit S_OK"));
  615. return S_OK;
  616. }
  617. HRESULT CTVideoFormat::put_SizeImage(
  618. IN const long nNewVal
  619. )
  620. {
  621. LOG((MSP_TRACE, "CTVideoFormat::put_SizeImage enter"));
  622. //
  623. // Critical section
  624. //
  625. CLock lock(m_Lock);
  626. //
  627. // Set value
  628. //
  629. m_vih.bmiHeader.biSizeImage = nNewVal;
  630. LOG((MSP_TRACE, "CTVideoFormat::put_SizeImage exit S_OK"));
  631. return S_OK;
  632. }
  633. */
  634. //eof