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.

1019 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. bState = (BOOL)RTPHeaderState;
  397. ASSERT(pComp);
  398. ASSERT(VALID_BOOLEAN(bState));
  399. if(pComp && (pComp->Configuration.bInitialized == FALSE))
  400. {
  401. lRet = ICERR_ERROR;
  402. goto EXIT_SetRTPHeaderState;
  403. }
  404. if(pComp && VALID_BOOLEAN(bState))
  405. {
  406. T_H263EncoderInstanceMemory *P32Inst;
  407. T_H263EncoderCatalog *EC;
  408. LPVOID EncoderInst;
  409. EncoderInst = pComp->hEncoderInst;
  410. if (EncoderInst == NULL)
  411. {
  412. DBOUT("ERROR :: H26XCompress :: ICERR_MEMORY");
  413. lRet = ICERR_MEMORY;
  414. goto EXIT_SetRTPHeaderState;
  415. }
  416. /*
  417. * Generate the pointer to the encoder instance memory aligned to the
  418. * required boundary.
  419. */
  420. #ifndef H261
  421. P32Inst = (T_H263EncoderInstanceMemory *)
  422. ((((U32) EncoderInst) +
  423. (sizeof(T_MBlockActionStream) - 1)) &
  424. ~(sizeof(T_MBlockActionStream) - 1));
  425. #else
  426. P32Inst = (T_H263EncoderInstanceMemory *)
  427. ((((U32) pComp->EncoderInst) +
  428. (sizeof(T_MBlockActionStream) - 1)) &
  429. ~(sizeof(T_MBlockActionStream) - 1));
  430. #endif
  431. EC = &(P32Inst->EC);
  432. // Get pointer to encoder catalog.
  433. if (!pComp->Configuration.bRTPHeader && bState)
  434. {
  435. #ifndef H261
  436. H263RTP_InitBsInfoStream(pComp,EC);
  437. #else
  438. H261RTP_InitBsInfoStream(EC,pComp->Configuration.unPacketSize);
  439. #endif
  440. }
  441. if (pComp->Configuration.bRTPHeader && !bState)
  442. {
  443. #ifndef H261
  444. H263RTP_TermBsInfoStream(EC);
  445. #else
  446. H261RTP_TermBsInfoStream(EC);
  447. #endif
  448. }
  449. pComp->Configuration.bRTPHeader = bState;
  450. lRet = ICERR_OK;
  451. }
  452. EXIT_SetRTPHeaderState:
  453. return(lRet);
  454. }
  455. /**************************************************************************
  456. * CustomSetResiliencyState() is called from CDRVPROC.CPP.
  457. *
  458. * Sets the state of ->bEncoderResiliency.
  459. *
  460. * Returns ICERR_BADPARAM if pComp is zero or ResiliencyState is not a valid
  461. * boolean, else ICERR_OK.
  462. */
  463. LRESULT CustomSetResiliencyState(LPCODINST pComp, DWORD ResiliencyState)
  464. {
  465. LRESULT lRet = ICERR_BADPARAM;
  466. BOOL bState;
  467. bState = (BOOL)ResiliencyState;
  468. ASSERT(pComp);
  469. ASSERT(VALID_BOOLEAN(bState));
  470. if(pComp && (pComp->Configuration.bInitialized == FALSE))
  471. {
  472. lRet = ICERR_ERROR;
  473. goto EXIT_SetResiliencyState;
  474. }
  475. if(pComp && VALID_BOOLEAN(bState))
  476. {
  477. pComp->Configuration.bEncoderResiliency = bState;
  478. SetResiliencyParams(&(pComp->Configuration));
  479. lRet = ICERR_OK;
  480. }
  481. EXIT_SetResiliencyState:
  482. return(lRet);
  483. }
  484. /**************************************************************************
  485. * CustomSetBitRateState() is called from CDRVPROC.CPP.
  486. *
  487. * Sets the state of ->bBitRateState.
  488. *
  489. * Returns ICERR_BADPARAM if pComp is zero or BitRateState is not a valid
  490. * boolean, else ICERR_OK.
  491. */
  492. LRESULT CustomSetBitRateState(LPCODINST pComp, DWORD BitRateState)
  493. {
  494. LRESULT lRet = ICERR_BADPARAM;
  495. BOOL bState;
  496. bState = (BOOL)BitRateState;
  497. ASSERT(pComp);
  498. ASSERT(VALID_BOOLEAN(bState));
  499. if(pComp && (pComp->Configuration.bInitialized == FALSE))
  500. {
  501. lRet = ICERR_ERROR;
  502. goto EXIT_SetBitRateState;
  503. }
  504. if(pComp && VALID_BOOLEAN(bState))
  505. {
  506. pComp->Configuration.bBitRateState = bState;
  507. lRet = ICERR_OK;
  508. }
  509. EXIT_SetBitRateState:
  510. return(lRet);
  511. }
  512. /**************************************************************************
  513. * CustomSetPacketSize() is called from CDRVPROC.CPP.
  514. *
  515. * Sets the size of ->unPacketSize.
  516. *
  517. * Returns ICERR_BADPARAM if pComp is zero or PacketSize is not a valid size,
  518. * else ICERR_OK.
  519. */
  520. LRESULT CustomSetPacketSize(LPCODINST pComp, DWORD PacketSize)
  521. {
  522. LRESULT lRet = ICERR_BADPARAM;
  523. UINT unSize;
  524. unSize = (UINT)PacketSize;
  525. ASSERT(pComp);
  526. ASSERT(VALID_PACKET_SIZE(unSize));
  527. if(pComp && (pComp->Configuration.bInitialized == FALSE))
  528. {
  529. lRet = ICERR_ERROR;
  530. goto EXIT_SetPacketSize;
  531. }
  532. if(pComp && VALID_PACKET_SIZE(unSize))
  533. {
  534. T_H263EncoderInstanceMemory *P32Inst;
  535. T_H263EncoderCatalog *EC;
  536. LPVOID EncoderInst;
  537. EncoderInst = pComp->hEncoderInst;
  538. if (EncoderInst == NULL)
  539. {
  540. DBOUT("ERROR :: H26XCompress :: ICERR_MEMORY");
  541. lRet = ICERR_MEMORY;
  542. goto EXIT_SetPacketSize;
  543. }
  544. /*
  545. * Generate the pointer to the encoder instance memory aligned to the
  546. * required boundary.
  547. */
  548. #ifndef H261
  549. P32Inst = (T_H263EncoderInstanceMemory *)
  550. ((((U32) EncoderInst) +
  551. (sizeof(T_MBlockActionStream) - 1)) &
  552. ~(sizeof(T_MBlockActionStream) - 1));
  553. #else
  554. P32Inst = (T_H263EncoderInstanceMemory *)
  555. ((((U32) pComp->EncoderInst) +
  556. (sizeof(T_MBlockActionStream) - 1)) &
  557. ~(sizeof(T_MBlockActionStream) - 1));
  558. #endif
  559. // Get pointer to encoder catalog.
  560. EC = &(P32Inst->EC);
  561. if (!pComp->Configuration.bRTPHeader)
  562. { lRet = ICERR_ERROR;
  563. goto EXIT_SetPacketSize;
  564. }
  565. if (pComp->Configuration.unPacketSize != unSize )
  566. {
  567. #ifndef H261
  568. H263RTP_TermBsInfoStream(EC);
  569. #else
  570. H261RTP_TermBsInfoStream(EC);
  571. #endif
  572. pComp->Configuration.unPacketSize = unSize;
  573. #ifndef H261
  574. H263RTP_InitBsInfoStream(pComp,EC);
  575. #else
  576. H261RTP_InitBsInfoStream(EC,pComp->Configuration.unPacketSize);
  577. #endif
  578. }
  579. lRet = ICERR_OK;
  580. }
  581. EXIT_SetPacketSize:
  582. return(lRet);
  583. }
  584. /**************************************************************************
  585. * CustomSetPacketLoss() is called from CDRVPROC.CPP.
  586. *
  587. * Sets the amount of ->unPacketLoss.
  588. *
  589. * Returns ICERR_BADPARAM if pComp is zero or PacketLoss is not a valid size,
  590. * else ICERR_OK.
  591. */
  592. LRESULT CustomSetPacketLoss(LPCODINST pComp, DWORD PacketLoss)
  593. {
  594. LRESULT lRet = ICERR_BADPARAM;
  595. UINT unLoss;
  596. unLoss = (UINT)PacketLoss;
  597. ASSERT(pComp);
  598. // ASSERT(VALID_PACKET_LOSS(unLoss)); Always True
  599. if(pComp && (pComp->Configuration.bInitialized == FALSE))
  600. {
  601. lRet = ICERR_ERROR;
  602. goto EXIT_SetPacketLoss;
  603. }
  604. if(pComp) // && VALID_PACKET_LOSS(unLoss)) Always True
  605. {
  606. pComp->Configuration.unPacketLoss = unLoss;
  607. SetResiliencyParams(&(pComp->Configuration));
  608. lRet = ICERR_OK;
  609. }
  610. EXIT_SetPacketLoss:
  611. return(lRet);
  612. }
  613. /**************************************************************************
  614. * CustomSetBitRate() is called from CDRVPROC.CPP.
  615. *
  616. * Sets the amount of ->unBytesPerSecond.
  617. *
  618. * Returns ICERR_BADPARAM if pComp is zero or BitRate is not a valid size,
  619. * else ICERR_OK.
  620. */
  621. LRESULT CustomSetBitRate(LPCODINST pComp, DWORD BitRate)
  622. {
  623. LRESULT lRet = ICERR_BADPARAM;
  624. UINT unBitRate;
  625. unBitRate = (UINT)BitRate;
  626. ASSERT(pComp);
  627. ASSERT(VALID_BITRATE(unBitRate));
  628. if(pComp && (pComp->Configuration.bInitialized == FALSE))
  629. {
  630. lRet = ICERR_ERROR;
  631. goto EXIT_SetBitRate;
  632. }
  633. if(pComp && VALID_BITRATE(unBitRate))
  634. {
  635. pComp->Configuration.unBytesPerSecond = unBitRate;
  636. lRet = ICERR_OK;
  637. }
  638. EXIT_SetBitRate:
  639. return(lRet);
  640. }
  641. #ifdef H263P
  642. /**************************************************************************
  643. * CustomSetH263PlusState() is called from CDRVPROC.CPP.
  644. *
  645. * Sets the state of ->bH263PlusState.
  646. *
  647. * Returns ICERR_BADPARAM if pComp is zero or H263PlusState is not a valid
  648. * boolean, else ICERR_OK.
  649. */
  650. LRESULT CustomSetH263PlusState(LPCODINST pComp, DWORD H263PlusState)
  651. {
  652. LRESULT lRet = ICERR_BADPARAM;
  653. BOOL bState;
  654. bState = (BOOL)H263PlusState;
  655. ASSERT(pComp);
  656. ASSERT(VALID_BOOLEAN(bState));
  657. if(pComp && (pComp->Configuration.bInitialized == FALSE))
  658. {
  659. lRet = ICERR_ERROR;
  660. goto EXIT_SetH263PlusState;
  661. }
  662. if(pComp && VALID_BOOLEAN(bState))
  663. {
  664. pComp->Configuration.bH263PlusState = bState;
  665. lRet = ICERR_OK;
  666. }
  667. EXIT_SetH263PlusState:
  668. return(lRet);
  669. }
  670. /**************************************************************************
  671. * CustomSetImprovedPBState() is called from CDRVPROC.CPP.
  672. *
  673. * Sets the state of ->bImprovedPBState.
  674. *
  675. * Returns ICERR_BADPARAM if pComp is zero or ImprovedPB is not a valid
  676. * boolean, else ICERR_OK.
  677. */
  678. LRESULT CustomSetImprovedPBState(LPCODINST pComp, DWORD ImprovedPBState)
  679. {
  680. LRESULT lRet = ICERR_BADPARAM;
  681. BOOL bState;
  682. BOOL bH263PlusState;
  683. bState = (BOOL)ImprovedPBState;
  684. ASSERT(pComp);
  685. ASSERT(VALID_BOOLEAN(bState));
  686. // ->bH263PlusState must be TRUE
  687. if(pComp && (pComp->Configuration.bInitialized == FALSE) ||
  688. (CustomGetH263PlusState(pComp, (DWORD FAR *)&bH263PlusState) != ICERR_OK) ||
  689. (bH263PlusState == FALSE))
  690. {
  691. lRet = ICERR_ERROR;
  692. goto EXIT_SetImprovedPBState;
  693. }
  694. if(pComp && VALID_BOOLEAN(bState))
  695. {
  696. pComp->Configuration.bImprovedPBState = bState;
  697. lRet = ICERR_OK;
  698. }
  699. EXIT_SetImprovedPBState:
  700. return(lRet);
  701. }
  702. /**************************************************************************
  703. * CustomSetDeblockingFilterState() is called from CDRVPROC.CPP.
  704. *
  705. * Sets the state of ->bDeblockingFilterState.
  706. *
  707. * Returns ICERR_BADPARAM if pComp is zero or DeblockingFilter is not a valid
  708. * boolean, else ICERR_OK.
  709. */
  710. LRESULT CustomSetDeblockingFilterState(LPCODINST pComp, DWORD DeblockingFilterState)
  711. {
  712. LRESULT lRet = ICERR_BADPARAM;
  713. BOOL bState;
  714. BOOL bH263PlusState;
  715. bState = (BOOL)DeblockingFilterState;
  716. ASSERT(pComp);
  717. ASSERT(VALID_BOOLEAN(bState));
  718. // ->bH263PlusState must be TRUE
  719. if(pComp && (pComp->Configuration.bInitialized == FALSE) ||
  720. (CustomGetH263PlusState(pComp, (DWORD FAR *)&bH263PlusState) != ICERR_OK) ||
  721. (bH263PlusState == FALSE))
  722. {
  723. lRet = ICERR_ERROR;
  724. goto EXIT_SetDeblockingFilterState;
  725. }
  726. if(pComp && VALID_BOOLEAN(bState))
  727. {
  728. pComp->Configuration.bDeblockingFilterState = bState;
  729. lRet = ICERR_OK;
  730. }
  731. EXIT_SetDeblockingFilterState:
  732. return(lRet);
  733. }
  734. #endif // H263P
  735. /**************************************************************************
  736. * CustomResetToFactoryDefaults() is called from CDRVPROC.CPP.
  737. *
  738. * Sets the amount of ->unBytesPerSecond.
  739. *
  740. * Returns ICERR_BADPARAM if pComp is zero or BitRate is not a valid size,
  741. * else ICERR_OK.
  742. */
  743. LRESULT CustomResetToFactoryDefaults(LPCODINST pComp)
  744. {
  745. LRESULT lRet = ICERR_BADPARAM;
  746. ASSERT(pComp);
  747. if(pComp)
  748. {
  749. GetConfigurationDefaults(&pComp->Configuration); /* Overwrite the configuration data */
  750. lRet = ICERR_OK;
  751. }
  752. return(lRet);
  753. }
  754. /**************************************************************************
  755. * CustomSetBlockEdgeFilter() is called from CDRVPROC.CPP.
  756. *
  757. * Turns block edge filter on or off.
  758. *
  759. * Returns ICERR_OK if successfull, ICERR_BADPARAM otherwise
  760. */
  761. LRESULT CustomSetBlockEdgeFilter(LPDECINST pDeComp, DWORD dwValue)
  762. {
  763. LRESULT lRet = ICERR_BADPARAM;
  764. if (dwValue == 1) {
  765. pDeComp->bUseBlockEdgeFilter = 1;
  766. lRet = ICERR_OK;
  767. }
  768. else if (dwValue == 0) {
  769. pDeComp->bUseBlockEdgeFilter = 0;
  770. lRet = ICERR_OK;
  771. }
  772. return(lRet);
  773. }
  774. /**************************************************************************
  775. *
  776. * About() implements the ICM_ABOUT message.
  777. *
  778. * Puts up an about box.
  779. *
  780. */
  781. I32
  782. About(
  783. HWND hwnd)
  784. {
  785. int inResult = 0;
  786. I32 iStatus = ICERR_OK;
  787. #ifndef MF_SHELL
  788. #ifndef RING0
  789. if (hwnd != ((HWND)-1))
  790. {
  791. inResult = DialogBox(hDriverModule, "AboutDlg", hwnd, AboutDialogProc);
  792. if (inResult == -1)
  793. {
  794. iStatus = ICERR_ERROR;
  795. DBOUT("\n DialogBox returned -1");
  796. }
  797. }
  798. #endif
  799. #endif
  800. return iStatus;
  801. } /* end About() */
  802. #ifdef QUARTZ
  803. void QTZAbout(U32 uData)
  804. {
  805. About((HWND) uData);
  806. }
  807. #endif
  808. /**************************************************************************
  809. *
  810. * DrvConfigure() is called from the DRV_CONFIGURE message.
  811. *
  812. * Puts up an about box.
  813. *
  814. * Always returns DRV_CANCEL as nothing has changed and no action is required.
  815. */
  816. I32 DrvConfigure(
  817. HWND hwnd)
  818. {
  819. I32 iStatus = DRV_CANCEL;
  820. #ifndef MF_SHELL
  821. #ifndef RING0
  822. int inResult;
  823. inResult = DialogBox(hDriverModule, "SetupDlg", hwnd, AboutDialogProc);
  824. if (inResult == -1)
  825. {
  826. DBOUT("\n DialogBox returned -1");
  827. }
  828. #endif
  829. #endif
  830. return iStatus;
  831. } /* end DrvConfigure() */
  832. /************************************************************************
  833. *
  834. * SetResiliencyParams
  835. *
  836. * If ->bEncoderResiliency is TRUE, then set the configuration
  837. * parameters according to the expected packet loss.
  838. */
  839. extern void SetResiliencyParams(T_CONFIGURATION * pConfiguration)
  840. {
  841. if (pConfiguration->bEncoderResiliency)
  842. {
  843. if(pConfiguration->unPacketLoss > 30)
  844. { pConfiguration->bDisallowPosVerMVs = 1;
  845. pConfiguration->bDisallowAllVerMVs = 1;
  846. pConfiguration->unPercentForcedUpdate = 100; // rather severe eh Jeeves ?
  847. pConfiguration->unDefaultIntraQuant = 8;
  848. pConfiguration->unDefaultInterQuant = 16;
  849. }
  850. else if(pConfiguration->unPacketLoss > 0 )
  851. {
  852. pConfiguration->bDisallowPosVerMVs = 0;
  853. pConfiguration->bDisallowAllVerMVs = 0;
  854. pConfiguration->unPercentForcedUpdate = pConfiguration->unPacketLoss;
  855. pConfiguration->unDefaultIntraQuant = 16;
  856. pConfiguration->unDefaultInterQuant = 16;
  857. }
  858. else // no packet loss
  859. { pConfiguration->bDisallowPosVerMVs = 0;
  860. pConfiguration->bDisallowAllVerMVs = 0;
  861. pConfiguration->unPercentForcedUpdate = 0;
  862. pConfiguration->unDefaultIntraQuant = 16;
  863. pConfiguration->unDefaultInterQuant = 16;
  864. }
  865. }
  866. return;
  867. }
  868. /************************************************************************
  869. *
  870. * GetConfigurationDefaults
  871. *
  872. * Get the hard-coded configuration defaults
  873. */
  874. void GetConfigurationDefaults(
  875. T_CONFIGURATION * pConfiguration)
  876. {
  877. pConfiguration->bRTPHeader = 0;
  878. pConfiguration->unPacketSize = 512L;
  879. pConfiguration->bEncoderResiliency = 0;
  880. //Moji says to tune the encoder for 10% packet loss.
  881. pConfiguration->unPacketLoss = 10L;
  882. pConfiguration->bBitRateState = 0;
  883. pConfiguration->unBytesPerSecond = 1664L;
  884. SetResiliencyParams(pConfiguration); // Determine config values from packet loss.
  885. pConfiguration->bInitialized = TRUE;
  886. #ifdef H263P
  887. pConfiguration->bH263PlusState = 0;
  888. pConfiguration->bImprovedPBState = 0;
  889. pConfiguration->bDeblockingFilterState = 0;
  890. #endif
  891. } /* end GetConfigurationDefaults() */
  892. /**************************************************************************
  893. *
  894. * AboutDialogProc
  895. *
  896. * Display the about box.
  897. */
  898. static INT_PTR CALLBACK AboutDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  899. {
  900. #ifndef MF_SHELL
  901. #ifndef RING0
  902. switch(message) {
  903. case WM_INITDIALOG:
  904. return TRUE;
  905. break;
  906. case WM_CLOSE:
  907. PostMessage(hDlg, WM_COMMAND, IDOK, 0L);
  908. return TRUE;
  909. case WM_COMMAND:
  910. switch(wParam) {
  911. case IDOK:
  912. EndDialog(hDlg, TRUE);
  913. return TRUE;
  914. }
  915. }
  916. return FALSE;
  917. #else
  918. return TRUE;
  919. #endif
  920. #else
  921. return TRUE;
  922. #endif
  923. }