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.

1030 lines
28 KiB

  1. /* *************************************************************************
  2. ** INTEL Corporation Proprietary Information
  3. **
  4. ** This listing is supplied under the terms of a license
  5. ** agreement with INTEL Corporation and may not be copied
  6. ** nor disclosed except in accordance with the terms of
  7. ** that agreement.
  8. **
  9. ** Copyright (c) 1995 Intel Corporation.
  10. ** All Rights Reserved.
  11. **
  12. ** *************************************************************************
  13. */
  14. #include "precomp.h"
  15. #ifndef MF_SHELL
  16. #ifndef RING0
  17. extern HINSTANCE hDriverModule;
  18. #endif
  19. #endif
  20. /*****************************************************************************
  21. *
  22. * cdialog.cpp
  23. *
  24. * DESCRIPTION:
  25. * Dialog functions.
  26. *
  27. * Routines: Prototypes in:
  28. * About cdialog.h
  29. * DrvConfigure cdialog.h
  30. * GetConfigurationDefaults cdialogs.h
  31. */
  32. // $Header: S:\h26x\src\common\cdialogs.cpv 1.25 06 Mar 1997 14:48:58 KLILLEVO $
  33. // $Log: S:\h26x\src\common\cdialogs.cpv $
  34. //
  35. // Rev 1.25 06 Mar 1997 14:48:58 KLILLEVO
  36. // Added check for valid pComp for release version.
  37. //
  38. // Rev 1.24 05 Mar 1997 16:17:10 JMCVEIGH
  39. // No longer support configuration dialog box.
  40. //
  41. // Rev 1.23 13 Feb 1997 14:13:34 MBODART
  42. //
  43. // Made Active Movie constant definitions consistent with those in cdialogs.
  44. //
  45. // Rev 1.22 12 Feb 1997 15:51:10 AGUPTA2
  46. // Decreased minimum packet size allowed to 64.
  47. //
  48. // Rev 1.21 05 Feb 1997 12:13:58 JMCVEIGH
  49. // Support for improved PB-frames custom message handling.
  50. //
  51. // Rev 1.20 16 Dec 1996 17:37:28 JMCVEIGH
  52. // Setting/getting of H.263+ optional mode states.
  53. //
  54. // Rev 1.19 11 Dec 1996 14:55:26 JMCVEIGH
  55. //
  56. // Functions for setting/getting in-the-loop deblocking filter and
  57. // true B-frame mode states.
  58. //
  59. // Rev 1.18 04 Dec 1996 14:38:18 RHAZRA
  60. // Fixed a couple of bugs: (1) SetResiliencyParameters was never called when
  61. // an application sent a custom message to us turning on resiliency and
  62. // (ii) in ReadDialogBox() the resiliency parameters were being set from
  63. // the defaults rather than the values set by the user.
  64. //
  65. // Upon Chad's suggestion, I have decided NOT to tie RTP header generation
  66. // and resiliency as per discussion with Ben. This is to stay compliant with
  67. // existing applications such as AV phone and XnetMM that haven't gone to
  68. // ActiveMovie yet.
  69. //
  70. // Rev 1.17 25 Nov 1996 09:12:40 BECHOLS
  71. // Bumped packet size to 9600.
  72. //
  73. // Rev 1.16 13 Nov 1996 00:33:50 BECHOLS
  74. //
  75. // Removed registry persistance.
  76. //
  77. // Rev 1.15 31 Oct 1996 10:12:46 KLILLEVO
  78. // changed from DBOUT to DBgLog
  79. //
  80. // Rev 1.14 21 Oct 1996 10:50:08 RHAZRA
  81. // fixed a problem with H.261 initialization of RTP BS info call
  82. //
  83. // Rev 1.13 16 Sep 1996 16:38:46 CZHU
  84. // Extended the minimum packet size to 128 bytes. Fixed buffer overflow bug
  85. //
  86. // Rev 1.12 10 Sep 1996 16:13:00 KLILLEVO
  87. // added custom message in decoder to turn block edge filter on or off
  88. //
  89. // Rev 1.11 29 Aug 1996 09:27:18 CZHU
  90. // Simplified handling of packet loss settings.
  91. //
  92. // Rev 1.10 26 Aug 1996 13:38:18 BECHOLS
  93. // Fixed 2 bugs: The first was where if -1 was entered, it would be changed
  94. // to (unsigned) -1, both of which are illegal values. The second is where
  95. // if an invalid value is entered, and the checkbox is unchecked, the user
  96. // would be required to check the box, enter a valid value, and then uncheck
  97. // the checkbox. The fixed code notifies the user of the problem if the box
  98. // is checked, and fills in the previous good value. If the box is unchecked
  99. // it fills in the previous good value, and doesn't notify the user, since
  100. // the value being unchecked is of no concern to the user.
  101. // Finally, I added an IFDEF H261 to the Key path assignment so that H261
  102. // would use a separate Registry Entry.
  103. //
  104. // Rev 1.9 21 Aug 1996 18:53:42 RHAZRA
  105. //
  106. // Added #ifdef s to accomodate both H.261 and H.263 in RTP related
  107. // tasks.
  108. //
  109. // Rev 1.7 13 Jun 1996 14:23:36 CZHU
  110. // Fix bugs in custom message handing for RTP related tasks.
  111. //
  112. // Rev 1.6 22 May 1996 18:46:02 BECHOLS
  113. // Added CustomResetToFactoryDefaults.
  114. //
  115. // Rev 1.5 08 May 1996 10:06:42 BECHOLS
  116. //
  117. // Changed the checking of the Packet size raising the minimum acceptable to
  118. // 256 vs. 64. This will hopefully kludge around a known bug. I also fixed a
  119. // by preventing field overflow on the numerics.
  120. //
  121. // Rev 1.4 06 May 1996 12:53:56 BECHOLS
  122. // Changed the bits per second to bytes per second.
  123. //
  124. // Rev 1.3 06 May 1996 00:40:04 BECHOLS
  125. //
  126. // Added code to support the bit rate control stuff in the resource file.
  127. // I also added the code necessary to handle messages to control the new
  128. // dialog features.
  129. //
  130. // Rev 1.2 28 Apr 1996 20:24:54 BECHOLS
  131. //
  132. // Merged RTP code into the Main Base.
  133. //
  134. // Rev 1.1 17 Nov 1995 14:50:54 BECHOLS
  135. // Made modifications to make this file as a mini-filter. The flags
  136. // RING0 and MF_SHELL were added.
  137. //
  138. // Rev 1.0 17 Oct 1995 15:07:22 DBRUCKS
  139. // add about box files
  140. //
  141. // Added code to process Custom messages, and also code to differentiate
  142. // between different values for packet loss, and set the defaults for no
  143. // RTP header or resiliency.
  144. // Modified RTP dialog box.
  145. // Add Configure dialog
  146. //
  147. static INT_PTR CALLBACK AboutDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
  148. extern void SetResiliencyParams(T_CONFIGURATION * pConfiguration);
  149. #define VALID_BOOLEAN(v) (v == 0 || v == 1)
  150. #if defined(H261)
  151. #define VALID_PACKET_SIZE(v) ((v) >= 128 && (v) <= 9600)
  152. #else
  153. #define VALID_PACKET_SIZE(v) ((v) >= 64 && (v) <= 9600)
  154. #endif
  155. #define VALID_PACKET_LOSS(v) (v >= 0 && v <= 100)
  156. #define VALID_BITRATE(v) (v >= 1024 && v <= 13312)
  157. /**************************************************************************
  158. * CustomGetRTPHeaderState() is called from CDRVPROC.CPP.
  159. *
  160. * Returns the state of ->bRTPHeader.
  161. *
  162. * Returns ICERR_BADPARAM if either parameter is zero, else ICERR_OK.
  163. */
  164. LRESULT CustomGetRTPHeaderState(LPCODINST pComp, DWORD FAR *pRTPHeaderState)
  165. {
  166. LRESULT lRet = ICERR_BADPARAM;
  167. ASSERT(pComp);
  168. ASSERT(pRTPHeaderState);
  169. if(pComp && (pComp->Configuration.bInitialized == FALSE))
  170. {
  171. lRet = ICERR_ERROR;
  172. goto EXIT_GetRTPHeaderState;
  173. }
  174. if(pComp && pRTPHeaderState)
  175. {
  176. *pRTPHeaderState = (DWORD)pComp->Configuration.bRTPHeader;
  177. lRet = ICERR_OK;
  178. }
  179. EXIT_GetRTPHeaderState:
  180. return(lRet);
  181. }
  182. /**************************************************************************
  183. * CustomGetResiliencyState() is called from CDRVPROC.CPP.
  184. *
  185. * Returns the state of ->bEncoderResiliency.
  186. *
  187. * Returns ICERR_BADPARAM if either parameter is zero, else ICERR_OK.
  188. */
  189. LRESULT CustomGetResiliencyState(LPCODINST pComp, DWORD FAR *pResiliencyState)
  190. {
  191. LRESULT lRet = ICERR_BADPARAM;
  192. ASSERT(pComp);
  193. ASSERT(pResiliencyState);
  194. if(pComp && (pComp->Configuration.bInitialized == FALSE))
  195. {
  196. lRet = ICERR_ERROR;
  197. goto EXIT_GetResiliencyState;
  198. }
  199. if(pComp && pResiliencyState)
  200. {
  201. *pResiliencyState = (DWORD)pComp->Configuration.bEncoderResiliency;
  202. lRet = ICERR_OK;
  203. }
  204. EXIT_GetResiliencyState:
  205. return(lRet);
  206. }
  207. /**************************************************************************
  208. * CustomGetBitRateState() is called from CDRVPROC.CPP.
  209. *
  210. * Returns the state of ->bBitRateState.
  211. *
  212. * Returns ICERR_BADPARAM if either parameter is zero, else ICERR_OK.
  213. */
  214. LRESULT CustomGetBitRateState(LPCODINST pComp, DWORD FAR *pBitRateState)
  215. {
  216. LRESULT lRet = ICERR_BADPARAM;
  217. ASSERT(pComp);
  218. ASSERT(pBitRateState);
  219. if(pComp && (pComp->Configuration.bInitialized == FALSE))
  220. {
  221. lRet = ICERR_ERROR;
  222. goto EXIT_GetBitRateState;
  223. }
  224. if(pComp && pBitRateState)
  225. {
  226. *pBitRateState = (DWORD)pComp->Configuration.bBitRateState;
  227. lRet = ICERR_OK;
  228. }
  229. EXIT_GetBitRateState:
  230. return(lRet);
  231. }
  232. /**************************************************************************
  233. * CustomGetPacketSize() is called from CDRVPROC.CPP.
  234. *
  235. * Returns the Packet Size.
  236. *
  237. * Returns ICERR_BADPARAM if either parameter is zero, else ICERR_OK.
  238. */
  239. LRESULT CustomGetPacketSize(LPCODINST pComp, DWORD FAR *pPacketSize)
  240. {
  241. LRESULT lRet = ICERR_BADPARAM;
  242. ASSERT(pComp);
  243. ASSERT(pPacketSize);
  244. if(pComp && (pComp->Configuration.bInitialized == FALSE))
  245. {
  246. lRet = ICERR_ERROR;
  247. goto EXIT_GetPacketSize;
  248. }
  249. if(pComp && pPacketSize)
  250. {
  251. *pPacketSize = (DWORD)pComp->Configuration.unPacketSize;
  252. lRet = ICERR_OK;
  253. }
  254. EXIT_GetPacketSize:
  255. return(lRet);
  256. }
  257. /**************************************************************************
  258. * CustomGetPacketLoss() is called from CDRVPROC.CPP.
  259. *
  260. * Returns the Packet Loss.
  261. *
  262. * Returns ICERR_BADPARAM if either parameter is zero, else ICERR_OK.
  263. */
  264. LRESULT CustomGetPacketLoss(LPCODINST pComp, DWORD FAR *pPacketLoss)
  265. {
  266. LRESULT lRet = ICERR_BADPARAM;
  267. ASSERT(pComp);
  268. ASSERT(pPacketLoss);
  269. if(pComp && (pComp->Configuration.bInitialized == FALSE))
  270. {
  271. lRet = ICERR_ERROR;
  272. goto EXIT_GetPacketLoss;
  273. }
  274. if(pComp && pPacketLoss)
  275. {
  276. *pPacketLoss = (DWORD)pComp->Configuration.unPacketLoss;
  277. lRet = ICERR_OK;
  278. }
  279. EXIT_GetPacketLoss:
  280. return(lRet);
  281. }
  282. /**************************************************************************
  283. * CustomGetBitRate() is called from CDRVPROC.CPP.
  284. *
  285. * Returns the Bit Rate in bytes per second.
  286. *
  287. * Returns ICERR_BADPARAM if either parameter is zero, else ICERR_OK.
  288. */
  289. LRESULT CustomGetBitRate(LPCODINST pComp, DWORD FAR *pBitRate)
  290. {
  291. LRESULT lRet = ICERR_BADPARAM;
  292. ASSERT(pComp);
  293. ASSERT(pBitRate);
  294. if(pComp && (pComp->Configuration.bInitialized == FALSE))
  295. {
  296. lRet = ICERR_ERROR;
  297. goto EXIT_GetBitRate;
  298. }
  299. if(pComp && pBitRate)
  300. {
  301. *pBitRate = (DWORD)pComp->Configuration.unBytesPerSecond;
  302. lRet = ICERR_OK;
  303. }
  304. EXIT_GetBitRate:
  305. return(lRet);
  306. }
  307. #ifdef H263P
  308. /**************************************************************************
  309. * CustomGetH263PlusState() is called from CDRVPROC.CPP.
  310. *
  311. * Returns the state of ->bH263Plus
  312. *
  313. * Returns ICERR_BADPARAM if either parameter is zero, else ICERR_OK.
  314. */
  315. LRESULT CustomGetH263PlusState(LPCODINST pComp, DWORD FAR *pH263PlusState)
  316. {
  317. LRESULT lRet = ICERR_BADPARAM;
  318. ASSERT(pComp);
  319. ASSERT(pH263PlusState);
  320. if(pComp && (pComp->Configuration.bInitialized == FALSE))
  321. {
  322. lRet = ICERR_ERROR;
  323. goto EXIT_GetH263PlusState;
  324. }
  325. if(pComp && pH263PlusState)
  326. {
  327. *pH263PlusState = (DWORD)pComp->Configuration.bH263PlusState;
  328. lRet = ICERR_OK;
  329. }
  330. EXIT_GetH263PlusState:
  331. return(lRet);
  332. }
  333. /**************************************************************************
  334. * CustomGetImprovedPBState() is called from CDRVPROC.CPP.
  335. *
  336. * Returns the state of ->bImprovedPBState.
  337. *
  338. * Returns ICERR_BADPARAM if either parameter is zero, else ICERR_OK.
  339. */
  340. LRESULT CustomGetImprovedPBState(LPCODINST pComp, DWORD FAR *pImprovedPBState)
  341. {
  342. LRESULT lRet = ICERR_BADPARAM;
  343. ASSERT(pComp);
  344. ASSERT(pImprovedPBState);
  345. if(pComp && (pComp->Configuration.bInitialized == FALSE))
  346. {
  347. lRet = ICERR_ERROR;
  348. goto EXIT_GetImprovedPBState;
  349. }
  350. if(pComp && pImprovedPBState)
  351. {
  352. *pImprovedPBState = (DWORD)pComp->Configuration.bImprovedPBState;
  353. lRet = ICERR_OK;
  354. }
  355. EXIT_GetImprovedPBState:
  356. return(lRet);
  357. }
  358. /**************************************************************************
  359. * CustomGetDeblockingFilterState() is called from CDRVPROC.CPP.
  360. *
  361. * Returns the state of ->bDeblockingFilterState.
  362. *
  363. * Returns ICERR_BADPARAM if either parameter is zero, else ICERR_OK.
  364. */
  365. LRESULT CustomGetDeblockingFilterState(LPCODINST pComp, DWORD FAR *pDeblockingFilterState)
  366. {
  367. LRESULT lRet = ICERR_BADPARAM;
  368. ASSERT(pComp);
  369. ASSERT(pDeblockingFilterState);
  370. if(pComp && (pComp->Configuration.bInitialized == FALSE))
  371. {
  372. lRet = ICERR_ERROR;
  373. goto EXIT_GetDeblockingFilterState;
  374. }
  375. if(pComp && pDeblockingFilterState)
  376. {
  377. *pDeblockingFilterState = (DWORD)pComp->Configuration.bDeblockingFilterState;
  378. lRet = ICERR_OK;
  379. }
  380. EXIT_GetDeblockingFilterState:
  381. return(lRet);
  382. }
  383. #endif // H263P
  384. /**************************************************************************
  385. * CustomSetRTPHeaderState() is called from CDRVPROC.CPP.
  386. *
  387. * Sets the state of ->bRTPHeader.
  388. *
  389. * Returns ICERR_BADPARAM if pComp is zero or RTPHeaderState is not a valid
  390. * boolean, else ICERR_OK.
  391. */
  392. LRESULT CustomSetRTPHeaderState(LPCODINST pComp, DWORD RTPHeaderState)
  393. {
  394. LRESULT lRet = ICERR_BADPARAM;
  395. BOOL bState;
  396. FX_ENTRY("CustomSetRTPHeaderState")
  397. bState = (BOOL)RTPHeaderState;
  398. ASSERT(pComp);
  399. ASSERT(VALID_BOOLEAN(bState));
  400. if(pComp && (pComp->Configuration.bInitialized == FALSE))
  401. {
  402. lRet = ICERR_ERROR;
  403. goto EXIT_SetRTPHeaderState;
  404. }
  405. if(pComp && VALID_BOOLEAN(bState))
  406. {
  407. T_H263EncoderInstanceMemory *P32Inst;
  408. T_H263EncoderCatalog *EC;
  409. LPVOID EncoderInst;
  410. EncoderInst = pComp->hEncoderInst;
  411. if (EncoderInst == NULL)
  412. {
  413. ERRORMESSAGE(("%s: ICERR_MEMORY\r\n", _fx_));
  414. lRet = ICERR_MEMORY;
  415. goto EXIT_SetRTPHeaderState;
  416. }
  417. /*
  418. * Generate the pointer to the encoder instance memory aligned to the
  419. * required boundary.
  420. */
  421. #ifndef H261
  422. P32Inst = (T_H263EncoderInstanceMemory *)
  423. ((((U32) EncoderInst) +
  424. (sizeof(T_MBlockActionStream) - 1)) &
  425. ~(sizeof(T_MBlockActionStream) - 1));
  426. #else
  427. P32Inst = (T_H263EncoderInstanceMemory *)
  428. ((((U32) pComp->EncoderInst) +
  429. (sizeof(T_MBlockActionStream) - 1)) &
  430. ~(sizeof(T_MBlockActionStream) - 1));
  431. #endif
  432. EC = &(P32Inst->EC);
  433. // Get pointer to encoder catalog.
  434. if (!pComp->Configuration.bRTPHeader && bState)
  435. {
  436. #ifndef H261
  437. H263RTP_InitBsInfoStream(pComp,EC);
  438. #else
  439. H261RTP_InitBsInfoStream(EC,pComp->Configuration.unPacketSize);
  440. #endif
  441. }
  442. if (pComp->Configuration.bRTPHeader && !bState)
  443. {
  444. #ifndef H261
  445. H263RTP_TermBsInfoStream(EC);
  446. #else
  447. H261RTP_TermBsInfoStream(EC);
  448. #endif
  449. }
  450. pComp->Configuration.bRTPHeader = bState;
  451. lRet = ICERR_OK;
  452. }
  453. EXIT_SetRTPHeaderState:
  454. return(lRet);
  455. }
  456. /**************************************************************************
  457. * CustomSetResiliencyState() is called from CDRVPROC.CPP.
  458. *
  459. * Sets the state of ->bEncoderResiliency.
  460. *
  461. * Returns ICERR_BADPARAM if pComp is zero or ResiliencyState is not a valid
  462. * boolean, else ICERR_OK.
  463. */
  464. LRESULT CustomSetResiliencyState(LPCODINST pComp, DWORD ResiliencyState)
  465. {
  466. LRESULT lRet = ICERR_BADPARAM;
  467. BOOL bState;
  468. bState = (BOOL)ResiliencyState;
  469. ASSERT(pComp);
  470. ASSERT(VALID_BOOLEAN(bState));
  471. if(pComp && (pComp->Configuration.bInitialized == FALSE))
  472. {
  473. lRet = ICERR_ERROR;
  474. goto EXIT_SetResiliencyState;
  475. }
  476. if(pComp && VALID_BOOLEAN(bState))
  477. {
  478. pComp->Configuration.bEncoderResiliency = bState;
  479. SetResiliencyParams(&(pComp->Configuration));
  480. lRet = ICERR_OK;
  481. }
  482. EXIT_SetResiliencyState:
  483. return(lRet);
  484. }
  485. /**************************************************************************
  486. * CustomSetBitRateState() is called from CDRVPROC.CPP.
  487. *
  488. * Sets the state of ->bBitRateState.
  489. *
  490. * Returns ICERR_BADPARAM if pComp is zero or BitRateState is not a valid
  491. * boolean, else ICERR_OK.
  492. */
  493. LRESULT CustomSetBitRateState(LPCODINST pComp, DWORD BitRateState)
  494. {
  495. LRESULT lRet = ICERR_BADPARAM;
  496. BOOL bState;
  497. bState = (BOOL)BitRateState;
  498. ASSERT(pComp);
  499. ASSERT(VALID_BOOLEAN(bState));
  500. if(pComp && (pComp->Configuration.bInitialized == FALSE))
  501. {
  502. lRet = ICERR_ERROR;
  503. goto EXIT_SetBitRateState;
  504. }
  505. if(pComp && VALID_BOOLEAN(bState))
  506. {
  507. pComp->Configuration.bBitRateState = bState;
  508. lRet = ICERR_OK;
  509. }
  510. EXIT_SetBitRateState:
  511. return(lRet);
  512. }
  513. /**************************************************************************
  514. * CustomSetPacketSize() is called from CDRVPROC.CPP.
  515. *
  516. * Sets the size of ->unPacketSize.
  517. *
  518. * Returns ICERR_BADPARAM if pComp is zero or PacketSize is not a valid size,
  519. * else ICERR_OK.
  520. */
  521. LRESULT CustomSetPacketSize(LPCODINST pComp, DWORD PacketSize)
  522. {
  523. LRESULT lRet = ICERR_BADPARAM;
  524. UINT unSize;
  525. FX_ENTRY("CustomSetPacketSize")
  526. unSize = (UINT)PacketSize;
  527. ASSERT(pComp);
  528. ASSERT(VALID_PACKET_SIZE(unSize));
  529. if(pComp && (pComp->Configuration.bInitialized == FALSE))
  530. {
  531. lRet = ICERR_ERROR;
  532. goto EXIT_SetPacketSize;
  533. }
  534. if(pComp && VALID_PACKET_SIZE(unSize))
  535. {
  536. T_H263EncoderInstanceMemory *P32Inst;
  537. T_H263EncoderCatalog *EC;
  538. LPVOID EncoderInst;
  539. EncoderInst = pComp->hEncoderInst;
  540. if (EncoderInst == NULL)
  541. {
  542. ERRORMESSAGE(("%s: ICERR_MEMORY\r\n", _fx_));
  543. lRet = ICERR_MEMORY;
  544. goto EXIT_SetPacketSize;
  545. }
  546. /*
  547. * Generate the pointer to the encoder instance memory aligned to the
  548. * required boundary.
  549. */
  550. #ifndef H261
  551. P32Inst = (T_H263EncoderInstanceMemory *)
  552. ((((U32) EncoderInst) +
  553. (sizeof(T_MBlockActionStream) - 1)) &
  554. ~(sizeof(T_MBlockActionStream) - 1));
  555. #else
  556. P32Inst = (T_H263EncoderInstanceMemory *)
  557. ((((U32) pComp->EncoderInst) +
  558. (sizeof(T_MBlockActionStream) - 1)) &
  559. ~(sizeof(T_MBlockActionStream) - 1));
  560. #endif
  561. // Get pointer to encoder catalog.
  562. EC = &(P32Inst->EC);
  563. if (!pComp->Configuration.bRTPHeader)
  564. { lRet = ICERR_ERROR;
  565. goto EXIT_SetPacketSize;
  566. }
  567. if (pComp->Configuration.unPacketSize != unSize )
  568. {
  569. #ifndef H261
  570. H263RTP_TermBsInfoStream(EC);
  571. #else
  572. H261RTP_TermBsInfoStream(EC);
  573. #endif
  574. pComp->Configuration.unPacketSize = unSize;
  575. #ifndef H261
  576. H263RTP_InitBsInfoStream(pComp,EC);
  577. #else
  578. H261RTP_InitBsInfoStream(EC,pComp->Configuration.unPacketSize);
  579. #endif
  580. }
  581. lRet = ICERR_OK;
  582. }
  583. EXIT_SetPacketSize:
  584. return(lRet);
  585. }
  586. /**************************************************************************
  587. * CustomSetPacketLoss() is called from CDRVPROC.CPP.
  588. *
  589. * Sets the amount of ->unPacketLoss.
  590. *
  591. * Returns ICERR_BADPARAM if pComp is zero or PacketLoss is not a valid size,
  592. * else ICERR_OK.
  593. */
  594. LRESULT CustomSetPacketLoss(LPCODINST pComp, DWORD PacketLoss)
  595. {
  596. LRESULT lRet = ICERR_BADPARAM;
  597. UINT unLoss;
  598. unLoss = (UINT)PacketLoss;
  599. ASSERT(pComp);
  600. // ASSERT(VALID_PACKET_LOSS(unLoss)); Always True
  601. if(pComp && (pComp->Configuration.bInitialized == FALSE))
  602. {
  603. lRet = ICERR_ERROR;
  604. goto EXIT_SetPacketLoss;
  605. }
  606. if(pComp) // && VALID_PACKET_LOSS(unLoss)) Always True
  607. {
  608. pComp->Configuration.unPacketLoss = unLoss;
  609. SetResiliencyParams(&(pComp->Configuration));
  610. lRet = ICERR_OK;
  611. }
  612. EXIT_SetPacketLoss:
  613. return(lRet);
  614. }
  615. /**************************************************************************
  616. * CustomSetBitRate() is called from CDRVPROC.CPP.
  617. *
  618. * Sets the amount of ->unBytesPerSecond.
  619. *
  620. * Returns ICERR_BADPARAM if pComp is zero or BitRate is not a valid size,
  621. * else ICERR_OK.
  622. */
  623. LRESULT CustomSetBitRate(LPCODINST pComp, DWORD BitRate)
  624. {
  625. LRESULT lRet = ICERR_BADPARAM;
  626. UINT unBitRate;
  627. unBitRate = (UINT)BitRate;
  628. ASSERT(pComp);
  629. ASSERT(VALID_BITRATE(unBitRate));
  630. if(pComp && (pComp->Configuration.bInitialized == FALSE))
  631. {
  632. lRet = ICERR_ERROR;
  633. goto EXIT_SetBitRate;
  634. }
  635. if(pComp && VALID_BITRATE(unBitRate))
  636. {
  637. pComp->Configuration.unBytesPerSecond = unBitRate;
  638. lRet = ICERR_OK;
  639. }
  640. EXIT_SetBitRate:
  641. return(lRet);
  642. }
  643. #ifdef H263P
  644. /**************************************************************************
  645. * CustomSetH263PlusState() is called from CDRVPROC.CPP.
  646. *
  647. * Sets the state of ->bH263PlusState.
  648. *
  649. * Returns ICERR_BADPARAM if pComp is zero or H263PlusState is not a valid
  650. * boolean, else ICERR_OK.
  651. */
  652. LRESULT CustomSetH263PlusState(LPCODINST pComp, DWORD H263PlusState)
  653. {
  654. LRESULT lRet = ICERR_BADPARAM;
  655. BOOL bState;
  656. bState = (BOOL)H263PlusState;
  657. ASSERT(pComp);
  658. ASSERT(VALID_BOOLEAN(bState));
  659. if(pComp && (pComp->Configuration.bInitialized == FALSE))
  660. {
  661. lRet = ICERR_ERROR;
  662. goto EXIT_SetH263PlusState;
  663. }
  664. if(pComp && VALID_BOOLEAN(bState))
  665. {
  666. pComp->Configuration.bH263PlusState = bState;
  667. lRet = ICERR_OK;
  668. }
  669. EXIT_SetH263PlusState:
  670. return(lRet);
  671. }
  672. /**************************************************************************
  673. * CustomSetImprovedPBState() is called from CDRVPROC.CPP.
  674. *
  675. * Sets the state of ->bImprovedPBState.
  676. *
  677. * Returns ICERR_BADPARAM if pComp is zero or ImprovedPB is not a valid
  678. * boolean, else ICERR_OK.
  679. */
  680. LRESULT CustomSetImprovedPBState(LPCODINST pComp, DWORD ImprovedPBState)
  681. {
  682. LRESULT lRet = ICERR_BADPARAM;
  683. BOOL bState;
  684. BOOL bH263PlusState;
  685. bState = (BOOL)ImprovedPBState;
  686. ASSERT(pComp);
  687. ASSERT(VALID_BOOLEAN(bState));
  688. // ->bH263PlusState must be TRUE
  689. if(pComp && (pComp->Configuration.bInitialized == FALSE) ||
  690. (CustomGetH263PlusState(pComp, (DWORD FAR *)&bH263PlusState) != ICERR_OK) ||
  691. (bH263PlusState == FALSE))
  692. {
  693. lRet = ICERR_ERROR;
  694. goto EXIT_SetImprovedPBState;
  695. }
  696. if(pComp && VALID_BOOLEAN(bState))
  697. {
  698. pComp->Configuration.bImprovedPBState = bState;
  699. lRet = ICERR_OK;
  700. }
  701. EXIT_SetImprovedPBState:
  702. return(lRet);
  703. }
  704. /**************************************************************************
  705. * CustomSetDeblockingFilterState() is called from CDRVPROC.CPP.
  706. *
  707. * Sets the state of ->bDeblockingFilterState.
  708. *
  709. * Returns ICERR_BADPARAM if pComp is zero or DeblockingFilter is not a valid
  710. * boolean, else ICERR_OK.
  711. */
  712. LRESULT CustomSetDeblockingFilterState(LPCODINST pComp, DWORD DeblockingFilterState)
  713. {
  714. LRESULT lRet = ICERR_BADPARAM;
  715. BOOL bState;
  716. BOOL bH263PlusState;
  717. bState = (BOOL)DeblockingFilterState;
  718. ASSERT(pComp);
  719. ASSERT(VALID_BOOLEAN(bState));
  720. // ->bH263PlusState must be TRUE
  721. if(pComp && (pComp->Configuration.bInitialized == FALSE) ||
  722. (CustomGetH263PlusState(pComp, (DWORD FAR *)&bH263PlusState) != ICERR_OK) ||
  723. (bH263PlusState == FALSE))
  724. {
  725. lRet = ICERR_ERROR;
  726. goto EXIT_SetDeblockingFilterState;
  727. }
  728. if(pComp && VALID_BOOLEAN(bState))
  729. {
  730. pComp->Configuration.bDeblockingFilterState = bState;
  731. lRet = ICERR_OK;
  732. }
  733. EXIT_SetDeblockingFilterState:
  734. return(lRet);
  735. }
  736. #endif // H263P
  737. /**************************************************************************
  738. * CustomResetToFactoryDefaults() is called from CDRVPROC.CPP.
  739. *
  740. * Sets the amount of ->unBytesPerSecond.
  741. *
  742. * Returns ICERR_BADPARAM if pComp is zero or BitRate is not a valid size,
  743. * else ICERR_OK.
  744. */
  745. LRESULT CustomResetToFactoryDefaults(LPCODINST pComp)
  746. {
  747. LRESULT lRet = ICERR_BADPARAM;
  748. ASSERT(pComp);
  749. if(pComp)
  750. {
  751. GetConfigurationDefaults(&pComp->Configuration); /* Overwrite the configuration data */
  752. lRet = ICERR_OK;
  753. }
  754. return(lRet);
  755. }
  756. /**************************************************************************
  757. * CustomSetBlockEdgeFilter() is called from CDRVPROC.CPP.
  758. *
  759. * Turns block edge filter on or off.
  760. *
  761. * Returns ICERR_OK if successfull, ICERR_BADPARAM otherwise
  762. */
  763. LRESULT CustomSetBlockEdgeFilter(LPDECINST pDeComp, DWORD dwValue)
  764. {
  765. LRESULT lRet = ICERR_BADPARAM;
  766. if (dwValue == 1) {
  767. pDeComp->bUseBlockEdgeFilter = 1;
  768. lRet = ICERR_OK;
  769. }
  770. else if (dwValue == 0) {
  771. pDeComp->bUseBlockEdgeFilter = 0;
  772. lRet = ICERR_OK;
  773. }
  774. return(lRet);
  775. }
  776. /**************************************************************************
  777. *
  778. * About() implements the ICM_ABOUT message.
  779. *
  780. * Puts up an about box.
  781. *
  782. */
  783. I32
  784. About(
  785. HWND hwnd)
  786. {
  787. int inResult = 0;
  788. I32 iStatus = ICERR_OK;
  789. #ifndef MF_SHELL
  790. #ifndef RING0
  791. FX_ENTRY("About")
  792. if (hwnd != ((HWND)-1))
  793. {
  794. inResult = DialogBox(hDriverModule, "AboutDlg", hwnd, AboutDialogProc);
  795. if (inResult == -1)
  796. {
  797. iStatus = ICERR_ERROR;
  798. ERRORMESSAGE(("%s: DialogBox returned -1\r\n", _fx_));
  799. }
  800. }
  801. #endif
  802. #endif
  803. return iStatus;
  804. } /* end About() */
  805. #ifdef QUARTZ
  806. void QTZAbout(U32 uData)
  807. {
  808. About((HWND) uData);
  809. }
  810. #endif
  811. /**************************************************************************
  812. *
  813. * DrvConfigure() is called from the DRV_CONFIGURE message.
  814. *
  815. * Puts up an about box.
  816. *
  817. * Always returns DRV_CANCEL as nothing has changed and no action is required.
  818. */
  819. I32 DrvConfigure(
  820. HWND hwnd)
  821. {
  822. I32 iStatus = DRV_CANCEL;
  823. #ifndef MF_SHELL
  824. #ifndef RING0
  825. int inResult;
  826. FX_ENTRY("DrvConfigure")
  827. inResult = DialogBox(hDriverModule, "SetupDlg", hwnd, AboutDialogProc);
  828. if (inResult == -1)
  829. {
  830. ERRORMESSAGE(("%s: DialogBox returned -1\r\n", _fx_));
  831. }
  832. #endif
  833. #endif
  834. return iStatus;
  835. } /* end DrvConfigure() */
  836. /************************************************************************
  837. *
  838. * SetResiliencyParams
  839. *
  840. * If ->bEncoderResiliency is TRUE, then set the configuration
  841. * parameters according to the expected packet loss.
  842. */
  843. extern void SetResiliencyParams(T_CONFIGURATION * pConfiguration)
  844. {
  845. if (pConfiguration->bEncoderResiliency)
  846. {
  847. if(pConfiguration->unPacketLoss > 30)
  848. { pConfiguration->bDisallowPosVerMVs = 1;
  849. pConfiguration->bDisallowAllVerMVs = 1;
  850. pConfiguration->unPercentForcedUpdate = 100; // rather severe eh Jeeves ?
  851. pConfiguration->unDefaultIntraQuant = 8;
  852. pConfiguration->unDefaultInterQuant = 16;
  853. }
  854. else if(pConfiguration->unPacketLoss > 0 )
  855. {
  856. pConfiguration->bDisallowPosVerMVs = 0;
  857. pConfiguration->bDisallowAllVerMVs = 0;
  858. pConfiguration->unPercentForcedUpdate = pConfiguration->unPacketLoss;
  859. pConfiguration->unDefaultIntraQuant = 16;
  860. pConfiguration->unDefaultInterQuant = 16;
  861. }
  862. else // no packet loss
  863. { pConfiguration->bDisallowPosVerMVs = 0;
  864. pConfiguration->bDisallowAllVerMVs = 0;
  865. pConfiguration->unPercentForcedUpdate = 0;
  866. pConfiguration->unDefaultIntraQuant = 16;
  867. pConfiguration->unDefaultInterQuant = 16;
  868. }
  869. }
  870. return;
  871. }
  872. /************************************************************************
  873. *
  874. * GetConfigurationDefaults
  875. *
  876. * Get the hard-coded configuration defaults
  877. */
  878. void GetConfigurationDefaults(
  879. T_CONFIGURATION * pConfiguration)
  880. {
  881. pConfiguration->bRTPHeader = 0;
  882. pConfiguration->unPacketSize = 512L;
  883. pConfiguration->bEncoderResiliency = 0;
  884. //Moji says to tune the encoder for 10% packet loss.
  885. pConfiguration->unPacketLoss = 10L;
  886. pConfiguration->bBitRateState = 0;
  887. pConfiguration->unBytesPerSecond = 1664L;
  888. SetResiliencyParams(pConfiguration); // Determine config values from packet loss.
  889. pConfiguration->bInitialized = TRUE;
  890. #ifdef H263P
  891. pConfiguration->bH263PlusState = 0;
  892. pConfiguration->bImprovedPBState = 0;
  893. pConfiguration->bDeblockingFilterState = 0;
  894. #endif
  895. } /* end GetConfigurationDefaults() */
  896. /**************************************************************************
  897. *
  898. * AboutDialogProc
  899. *
  900. * Display the about box.
  901. */
  902. static INT_PTR CALLBACK AboutDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  903. {
  904. #ifndef MF_SHELL
  905. #ifndef RING0
  906. switch(message) {
  907. case WM_INITDIALOG:
  908. return TRUE;
  909. break;
  910. case WM_CLOSE:
  911. PostMessage(hDlg, WM_COMMAND, IDOK, 0L);
  912. return TRUE;
  913. case WM_COMMAND:
  914. switch(wParam) {
  915. case IDOK:
  916. EndDialog(hDlg, TRUE);
  917. return TRUE;
  918. }
  919. }
  920. return FALSE;
  921. #else
  922. return TRUE;
  923. #endif
  924. #else
  925. return TRUE;
  926. #endif
  927. }