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.

774 lines
23 KiB

  1. /*----------------------------------------------------------------------------
  2. * File: RRCMMISC.C
  3. * Product: RTP/RTCP implementation.
  4. * Description: Provides common RTP/RTCP support functionality.
  5. *
  6. *
  7. * INTEL Corporation Proprietary Information
  8. * This listing is supplied under the terms of a license agreement with
  9. * Intel Corporation and may not be copied nor disclosed except in
  10. * accordance with the terms of that agreement.
  11. * Copyright (c) 1995 Intel Corporation.
  12. *--------------------------------------------------------------------------*/
  13. #include "rrcm.h"
  14. /*---------------------------------------------------------------------------
  15. / Global Variables
  16. /--------------------------------------------------------------------------*/
  17. /*---------------------------------------------------------------------------
  18. / External Variables
  19. /--------------------------------------------------------------------------*/
  20. #ifdef ENABLE_ISDM2
  21. extern KEY_HANDLE hRRCMRootKey;
  22. extern ISDM2 Isdm2;
  23. #endif
  24. extern RRCM_WS RRCMws;
  25. #ifdef _DEBUG
  26. extern char debug_string[];
  27. #endif
  28. #ifdef ISRDBG
  29. extern WORD ghISRInst;
  30. #endif
  31. /*--------------------------------------------------------------------------
  32. * Function : searchForMySSRC
  33. * Description: Find the SSRC for this stream.
  34. *
  35. * Input : pSSRC : -> to the SSRC entry
  36. * RTPSocket : RTP socket descriptor
  37. *
  38. * Return: NULL ==> Session not found.
  39. * Buffer Address ==> OK, Session ptr returned
  40. --------------------------------------------------------------------------*/
  41. PSSRC_ENTRY searchForMySSRC(PSSRC_ENTRY pSSRC,
  42. SOCKET RTPSocket)
  43. {
  44. PSSRC_ENTRY pRRCMSession;
  45. IN_OUT_STR ("RTP : Enter searchForMySSRC()\n");
  46. for (pRRCMSession = NULL;
  47. (pSSRC != NULL);
  48. pSSRC = (PSSRC_ENTRY)pSSRC->SSRCList.prev)
  49. {
  50. if (pSSRC->RTPsd == RTPSocket)
  51. {
  52. pRRCMSession = pSSRC;
  53. break;
  54. }
  55. }
  56. IN_OUT_STR ("RTP : Exit searchForMySSRC()\n");
  57. return (pRRCMSession);
  58. }
  59. /*--------------------------------------------------------------------------
  60. * Function : searchforSSRCatHead
  61. * Description: Search through linked list of RTCP entries starting at the
  62. * head of the list.
  63. *
  64. * Input : pSSRC : -> to the SSRC entry
  65. * ssrc : ssrc to look for
  66. *
  67. * Return: NULL ==> Session not found.
  68. * Non-NULL ==> OK, SSRC entry found
  69. --------------------------------------------------------------------------*/
  70. PSSRC_ENTRY searchforSSRCatHead(PSSRC_ENTRY pSSRC,
  71. DWORD ssrc)
  72. {
  73. PSSRC_ENTRY pRRCMSession;
  74. IN_OUT_STR ("RTP : Enter searchForMySSRCatHead()\n");
  75. for (pRRCMSession = NULL;
  76. (pSSRC != NULL) &&
  77. (pRRCMSession == NULL) && (ssrc <= pSSRC->SSRC);
  78. pSSRC = (PSSRC_ENTRY)pSSRC->SSRCList.prev)
  79. {
  80. if (pSSRC->SSRC == ssrc)
  81. {
  82. pRRCMSession = pSSRC;
  83. }
  84. }
  85. IN_OUT_STR ("RTP : Exit searchForMySSRCatHead()\n");
  86. return (pRRCMSession);
  87. }
  88. /*--------------------------------------------------------------------------
  89. * Function : searchforSSRCatTail
  90. * Description: Search through linked list of RTCP entries starting at the
  91. * tail of the list.
  92. *
  93. * Input : pSSRC : -> to the SSRC entry
  94. * ssrc : SSRC to look for
  95. *
  96. * Return: NULL ==> Session not found.
  97. * Non-NULL ==> OK, SSRC entry found
  98. --------------------------------------------------------------------------*/
  99. PSSRC_ENTRY searchforSSRCatTail(PSSRC_ENTRY pSSRC,
  100. DWORD ssrc)
  101. {
  102. PSSRC_ENTRY pRRCMSession;
  103. IN_OUT_STR ("RTP : Enter searchForMySSRCatTail()\n");
  104. for (pRRCMSession = NULL;
  105. (pSSRC != NULL) &&
  106. (pRRCMSession == NULL) && (ssrc >= pSSRC->SSRC);
  107. pSSRC = (PSSRC_ENTRY)pSSRC->SSRCList.next)
  108. {
  109. if (pSSRC->SSRC == ssrc)
  110. {
  111. pRRCMSession = pSSRC;
  112. }
  113. }
  114. IN_OUT_STR ("RTP : Exit searchForMySSRCatTail()\n");
  115. return (pRRCMSession);
  116. }
  117. /*---------------------------------------------------------------------------
  118. * Function : saveNetworkAddress
  119. * Description: Saves the received or local network Address in the local
  120. * context.
  121. *
  122. * Input : pSSRCEntry : -> to the SSRC entry
  123. * pNetAddr : -> to the network address
  124. * addrLen : Address length
  125. *
  126. * Return: OK: RRCM_NoError
  127. --------------------------------------------------------------------------*/
  128. DWORD saveNetworkAddress (PSSRC_ENTRY pSSRC,
  129. PSOCKADDR pNetAddr,
  130. int addrLen)
  131. {
  132. IN_OUT_STR ("RTP : Enter saveNetworkAddress()\n");
  133. pSSRC->dwSSRCStatus |= NETWK_ADDR_UPDATED;
  134. pSSRC->fromLen = addrLen;
  135. memcpy (&pSSRC->from, pNetAddr, addrLen);
  136. IN_OUT_STR ("RTP : Exit saveNetworkAddress()\n");
  137. return RRCM_NoError;
  138. }
  139. /*---------------------------------------------------------------------------
  140. * Function : updateRTCPDestinationAddress
  141. * Description: The applicatino updates the RTCP destination address
  142. *
  143. * Input : hRTPSess : RTP session
  144. * pAddr : -> to address structure of RTCP information
  145. * addrLen : Address length
  146. *
  147. * Return: RRCM_NoError = OK.
  148. * Otherwise(!=0) = Check RRCM.h file for references.
  149. --------------------------------------------------------------------------*/
  150. DWORD WINAPI updateRTCPDestinationAddress (HANDLE hRTPSess,
  151. PSOCKADDR pRtcpAddr,
  152. int addrLen)
  153. {
  154. PRTP_SESSION pRTPSession = (PRTP_SESSION) hRTPSess;
  155. PRTCP_SESSION pRTCPses;
  156. #ifdef ENABLE_ISDM2
  157. PSSRC_ENTRY pSSRC;
  158. #endif
  159. IN_OUT_STR ("RTP : Enter updateRTCPDestinationAddress()\n");
  160. if (pRTPSession == NULL)
  161. {
  162. RRCM_DBG_MSG ("RTP : ERROR - Invalid RTP session", 0,
  163. __FILE__, __LINE__, DBG_CRITICAL);
  164. IN_OUT_STR ("RTP : Exit updateRTCPDestinationAddress()\n");
  165. return (MAKE_RRCM_ERROR(RRCMError_RTPInvalidSession));
  166. }
  167. // get the RTCP session
  168. pRTCPses = pRTPSession->pRTCPSession;
  169. if (pRTCPses == NULL)
  170. {
  171. RRCM_DBG_MSG ("RTP : ERROR - Invalid RTCP session", 0,
  172. __FILE__, __LINE__, DBG_CRITICAL);
  173. IN_OUT_STR ("RTP : Exit updateRTCPDestinationAddress()\n");
  174. return (MAKE_RRCM_ERROR(RRCMError_RTCPInvalidSession));
  175. }
  176. if (!(pRTCPses->dwSessionStatus & RTCP_DEST_LEARNED))
  177. {
  178. pRTCPses->dwSessionStatus |= RTCP_DEST_LEARNED;
  179. pRTCPses->toLen = addrLen;
  180. memcpy (&pRTCPses->toBfr, pRtcpAddr, addrLen);
  181. // register our Xmt SSRC - Rcvd one will be found later
  182. #ifdef ENABLE_ISDM2
  183. if (Isdm2.hISDMdll)
  184. {
  185. pSSRC = (PSSRC_ENTRY)pRTCPses->XmtSSRCList.prev;
  186. if (pSSRC != NULL)
  187. registerSessionToISDM (pSSRC, pRTCPses, &Isdm2);
  188. }
  189. #endif
  190. }
  191. IN_OUT_STR ("RTP : Exit updateRTCPDestinationAddress()\n");
  192. return RRCM_NoError;
  193. }
  194. /*---------------------------------------------------------------------------
  195. * Function : updateSSRCentry
  196. * Description: The application updates some of the SSRC information
  197. *
  198. * Input : RTPsd : RTP socket descriptor
  199. * updateType : Type of update desired
  200. * updateInfo : Update information
  201. * misc : Miscelleanous information
  202. *
  203. * Return: RRCM_NoError = OK.
  204. * Otherwise(!=0) = Check RRCM.h file for references.
  205. --------------------------------------------------------------------------*/
  206. HRESULT WINAPI updateSSRCentry ( HANDLE hRTPSess,
  207. SOCKET RTPsd,
  208. DWORD updateType,
  209. DWORD_PTR updateInfo,
  210. DWORD_PTR misc)
  211. {
  212. PRTP_SESSION pRTPSession = (PRTP_SESSION) hRTPSess;
  213. PRTCP_SESSION pRTCPses;
  214. PSSRC_ENTRY pSSRC;
  215. PLINK_LIST pTmp;
  216. PSDES_DATA pSdes;
  217. IN_OUT_STR ("RTP : Enter updateRTCPSdes ()\n");
  218. if (pRTPSession == NULL)
  219. {
  220. RRCM_DBG_MSG ("RTP : ERROR - Invalid RTP session", 0,
  221. __FILE__, __LINE__, DBG_CRITICAL);
  222. IN_OUT_STR ("RTP : Exit updateRTCPSdes ()\n");
  223. return (MAKE_RRCM_ERROR(RRCMError_RTPInvalidSession));
  224. }
  225. // get the RTCP session
  226. pRTCPses = pRTPSession->pRTCPSession;
  227. if (pRTCPses == NULL)
  228. {
  229. RRCM_DBG_MSG ("RTP : ERROR - Invalid RTCP session", 0,
  230. __FILE__, __LINE__, DBG_CRITICAL);
  231. IN_OUT_STR ("RTP : Exit updateRTCPSdes ()\n");
  232. return (MAKE_RRCM_ERROR(RRCMError_RTCPInvalidSession));
  233. }
  234. // search for the socket descriptor (unique per session)
  235. // walk through the list from the tail
  236. pTmp = (PLINK_LIST)pRTCPses->XmtSSRCList.prev;
  237. while (pTmp)
  238. {
  239. if (((PSSRC_ENTRY)pTmp)->RTPsd == RTPsd)
  240. {
  241. // lock access to this entry
  242. EnterCriticalSection (&((PSSRC_ENTRY)pTmp)->critSect);
  243. pSSRC = (PSSRC_ENTRY)pTmp;
  244. switch (updateType)
  245. {
  246. case RRCM_UPDATE_SDES:
  247. // update the SDES
  248. pSdes = (PSDES_DATA)updateInfo;
  249. switch (pSdes->dwSdesType)
  250. {
  251. case RTCP_SDES_CNAME:
  252. pSSRC->cnameInfo.dwSdesLength = pSdes->dwSdesLength;
  253. memcpy (pSSRC->cnameInfo.sdesBfr, pSdes->sdesBfr,
  254. pSdes->dwSdesLength);
  255. pSSRC->cnameInfo.dwSdesFrequency =
  256. frequencyToPckt (pSdes->dwSdesFrequency);
  257. pSSRC->cnameInfo.dwSdesEncrypted = pSdes->dwSdesEncrypted;
  258. break;
  259. case RTCP_SDES_NAME:
  260. pSSRC->nameInfo.dwSdesLength = pSdes->dwSdesLength;
  261. memcpy (pSSRC->nameInfo.sdesBfr, pSdes->sdesBfr,
  262. pSdes->dwSdesLength);
  263. pSSRC->nameInfo.dwSdesFrequency =
  264. frequencyToPckt (pSdes->dwSdesFrequency);
  265. pSSRC->nameInfo.dwSdesEncrypted = pSdes->dwSdesEncrypted;
  266. break;
  267. case RTCP_SDES_EMAIL:
  268. pSSRC->emailInfo.dwSdesLength = pSdes->dwSdesLength;
  269. memcpy (pSSRC->emailInfo.sdesBfr, pSdes->sdesBfr,
  270. pSdes->dwSdesLength);
  271. pSSRC->emailInfo.dwSdesFrequency =
  272. frequencyToPckt (pSdes->dwSdesFrequency);
  273. pSSRC->emailInfo.dwSdesEncrypted = pSdes->dwSdesEncrypted;
  274. break;
  275. case RTCP_SDES_PHONE:
  276. pSSRC->phoneInfo.dwSdesLength = pSdes->dwSdesLength;
  277. memcpy (pSSRC->phoneInfo.sdesBfr, pSdes->sdesBfr,
  278. pSdes->dwSdesLength);
  279. pSSRC->phoneInfo.dwSdesFrequency =
  280. frequencyToPckt (pSdes->dwSdesFrequency);
  281. pSSRC->phoneInfo.dwSdesEncrypted = pSdes->dwSdesEncrypted;
  282. break;
  283. case RTCP_SDES_LOC:
  284. pSSRC->locInfo.dwSdesLength = pSdes->dwSdesLength;
  285. memcpy (pSSRC->locInfo.sdesBfr, pSdes->sdesBfr,
  286. pSdes->dwSdesLength);
  287. pSSRC->locInfo.dwSdesFrequency =
  288. frequencyToPckt (pSdes->dwSdesFrequency);
  289. pSSRC->locInfo.dwSdesEncrypted = pSdes->dwSdesEncrypted;
  290. break;
  291. case RTCP_SDES_TOOL:
  292. pSSRC->toolInfo.dwSdesLength = pSdes->dwSdesLength;
  293. memcpy (pSSRC->toolInfo.sdesBfr, pSdes->sdesBfr,
  294. pSdes->dwSdesLength);
  295. pSSRC->toolInfo.dwSdesFrequency =
  296. frequencyToPckt (pSdes->dwSdesFrequency);
  297. pSSRC->toolInfo.dwSdesEncrypted = pSdes->dwSdesEncrypted;
  298. break;
  299. case RTCP_SDES_TXT:
  300. pSSRC->txtInfo.dwSdesLength = pSdes->dwSdesLength;
  301. memcpy (pSSRC->txtInfo.sdesBfr, pSdes->sdesBfr,
  302. pSdes->dwSdesLength);
  303. pSSRC->txtInfo.dwSdesFrequency =
  304. frequencyToPckt (pSdes->dwSdesFrequency);
  305. pSSRC->txtInfo.dwSdesEncrypted = pSdes->dwSdesEncrypted;
  306. break;
  307. case RTCP_SDES_PRIV:
  308. pSSRC->privInfo.dwSdesLength = pSdes->dwSdesLength;
  309. memcpy (pSSRC->privInfo.sdesBfr, pSdes->sdesBfr,
  310. pSdes->dwSdesLength);
  311. pSSRC->privInfo.dwSdesFrequency =
  312. frequencyToPckt (pSdes->dwSdesFrequency);
  313. pSSRC->privInfo.dwSdesEncrypted = pSdes->dwSdesEncrypted;
  314. break;
  315. }
  316. break;
  317. case RRCM_UPDATE_STREAM_FREQUENCY:
  318. // upate the stream clocking frequency
  319. pSSRC->dwStreamClock = (DWORD)updateInfo;
  320. break;
  321. case RRCM_UPDATE_RTCP_STREAM_MIN_BW:
  322. // upate the stream clocking frequency
  323. pSSRC->xmtInfo.dwRtcpStreamMinBW = (DWORD)updateInfo;
  324. break;
  325. case RRCM_UPDATE_CALLBACK:
  326. // update the callback information
  327. EnterCriticalSection (&pRTCPses->critSect);
  328. pRTCPses->pRRCMcallback = (PRRCM_EVENT_CALLBACK)updateInfo;
  329. pRTCPses->dwCallbackUserInfo = misc;
  330. LeaveCriticalSection (&pRTCPses->critSect);
  331. break;
  332. }
  333. // unlock access to this entry
  334. LeaveCriticalSection (&((PSSRC_ENTRY)pTmp)->critSect);
  335. }
  336. pTmp = pTmp->next;
  337. }
  338. IN_OUT_STR ("RTP : Exit updateRTCPSdes ()\n");
  339. return RRCM_NoError;
  340. }
  341. /*---------------------------------------------------------------------------
  342. * Function : RRCMnotification
  343. * Description: Notify the application that one of the RTP/RTCP events that
  344. * we keep track of has occured.
  345. *
  346. * Input : RRCMevent : RRCM event to report
  347. * pSSRC : -> to the SSRC entry
  348. * ssrc : SSRC which generated the event
  349. * misc : Miscelleanous value
  350. *
  351. * Return: OK: RRCM_NoError
  352. --------------------------------------------------------------------------*/
  353. void RRCMnotification (RRCM_EVENT_T RRCMevent,
  354. PSSRC_ENTRY pSSRC,
  355. DWORD dwSSRC,
  356. DWORD misc)
  357. {
  358. IN_OUT_STR ("RRCM: Enter RRCMnotification()\n");
  359. // check to see if the application is interested by the RRCM event
  360. if (pSSRC->pRTCPses->pRRCMcallback == NULL)
  361. return;
  362. switch (RRCMevent)
  363. {
  364. case RRCM_NEW_SOURCE_EVENT:
  365. pSSRC->pRTCPses->pRRCMcallback (RRCMevent, dwSSRC, misc,
  366. pSSRC->pRTCPses->dwCallbackUserInfo);
  367. break;
  368. case RRCM_LOCAL_COLLISION_EVENT:
  369. pSSRC->pRTCPses->pRRCMcallback (RRCMevent, pSSRC->SSRC, dwSSRC,
  370. pSSRC->pRTCPses->dwCallbackUserInfo);
  371. break;
  372. case RRCM_REMOTE_COLLISION_EVENT:
  373. pSSRC->pRTCPses->pRRCMcallback (RRCMevent, dwSSRC, 0,
  374. pSSRC->pRTCPses->dwCallbackUserInfo);
  375. break;
  376. case RRCM_RECV_RTCP_SNDR_REPORT_EVENT:
  377. pSSRC->pRTCPses->pRRCMcallback (RRCMevent, dwSSRC, pSSRC->RTCPsd,
  378. pSSRC->pRTCPses->dwCallbackUserInfo);
  379. break;
  380. case RRCM_RECV_RTCP_RECV_REPORT_EVENT:
  381. pSSRC->pRTCPses->pRRCMcallback (RRCMevent, dwSSRC, pSSRC->RTCPsd,
  382. pSSRC->pRTCPses->dwCallbackUserInfo);
  383. break;
  384. case RRCM_TIMEOUT_EVENT:
  385. pSSRC->pRTCPses->pRRCMcallback (RRCMevent, dwSSRC, 0,
  386. pSSRC->pRTCPses->dwCallbackUserInfo);
  387. break;
  388. case RRCM_BYE_EVENT:
  389. pSSRC->pRTCPses->pRRCMcallback (RRCMevent, dwSSRC, 0,
  390. pSSRC->pRTCPses->dwCallbackUserInfo);
  391. break;
  392. case RRCM_RTCP_WS_RCV_ERROR:
  393. pSSRC->pRTCPses->pRRCMcallback (RRCMevent, dwSSRC, misc,
  394. pSSRC->pRTCPses->dwCallbackUserInfo);
  395. break;
  396. case RRCM_RTCP_WS_XMT_ERROR:
  397. pSSRC->pRTCPses->pRRCMcallback (RRCMevent, dwSSRC, misc,
  398. pSSRC->pRTCPses->dwCallbackUserInfo);
  399. break;
  400. default:
  401. break;
  402. }
  403. IN_OUT_STR ("RRCM: Exit RRCMnotification()\n");
  404. }
  405. /*----------------------------------------------------------------------------
  406. * Function : registerSessionToISDM
  407. * Description: Register an RTP/RTCP session with ISDM
  408. *
  409. * Input : pSSRC : -> to the SSRC's entry
  410. * pRTCP : -> to the RTCP session's information
  411. * pIsdm : -> to the ISDM information
  412. *
  413. * Return: None
  414. ---------------------------------------------------------------------------*/
  415. #ifdef ENABLE_ISDM2
  416. #define SESSION_BFR_SIZE 30
  417. void registerSessionToISDM (PSSRC_ENTRY pSSRC,
  418. PRTCP_SESSION pRTCPses,
  419. PISDM2 pIsdm2)
  420. {
  421. struct sockaddr_in *pSSRCadr;
  422. unsigned short port;
  423. unsigned long netAddr;
  424. CHAR SsrcBfr[10];
  425. CHAR sessionBfr[SESSION_BFR_SIZE];
  426. unsigned char *ptr;
  427. int num;
  428. HRESULT hError;
  429. ISDM2_ENTRY Isdm2Stat;
  430. // get the destination address as the session identifier
  431. pSSRCadr = (struct sockaddr_in *)&pRTCPses->toBfr;
  432. RRCMws.htons (pSSRC->RTPsd, pSSRCadr->sin_port, &port);
  433. netAddr = pSSRCadr->sin_addr.S_un.S_addr;
  434. ptr = (unsigned char *)&netAddr;
  435. memset (sessionBfr, 0x00, SESSION_BFR_SIZE);
  436. num = (int)*ptr++;
  437. RRCMitoa (num, sessionBfr, 10);
  438. strcat (sessionBfr, ".");
  439. num = (int)*ptr++;
  440. RRCMitoa (num, (sessionBfr + strlen(sessionBfr)), 10);
  441. strcat (sessionBfr, ".");
  442. num = (int)*ptr++;
  443. RRCMitoa (num, (sessionBfr + strlen(sessionBfr)), 10);
  444. strcat (sessionBfr, ".");
  445. num = (int)*ptr;
  446. RRCMitoa (num, (sessionBfr + strlen(sessionBfr)), 10);
  447. strcat (sessionBfr, ".");
  448. RRCMitoa (port, (sessionBfr + strlen(sessionBfr)), 10);
  449. // get the SSRC
  450. RRCMultoa (pSSRC->SSRC, SsrcBfr, 16);
  451. // register the session
  452. if (pRTCPses->hSessKey == NULL)
  453. {
  454. hError = Isdm2.ISDMEntry.ISD_CreateKey (hRRCMRootKey,
  455. sessionBfr,
  456. &pRTCPses->hSessKey);
  457. if(FAILED(hError))
  458. RRCM_DBG_MSG ("RTP: ISD_CreateKey Failed",0, NULL, 0, DBG_NOTIFY);
  459. }
  460. memset(&Isdm2Stat, 0x00, sizeof(ISDM2_ENTRY));
  461. hError = Isdm2.ISDMEntry.ISD_CreateValue (pRTCPses->hSessKey,
  462. SsrcBfr,
  463. BINARY_VALUE,
  464. (BYTE *)&Isdm2Stat,
  465. sizeof(ISDM2_ENTRY),
  466. &pSSRC->hISDM);
  467. if(FAILED(hError))
  468. RRCM_DBG_MSG ("RTP: ISD_CreateValue Failed",0, NULL, 0, DBG_NOTIFY);
  469. }
  470. /*----------------------------------------------------------------------------
  471. * Function : udpateISDMsta
  472. * Description: Update an ISDM data structure
  473. *
  474. * Input : pSSRC : -> to the SSRC's entry
  475. * pIsdm : -> to the ISDM entry
  476. * flag : Sender/Receive flag
  477. * LocalFB : do or dont't update the local feedback
  478. *
  479. * Return: None
  480. ---------------------------------------------------------------------------*/
  481. void updateISDMstat (PSSRC_ENTRY pSSRC,
  482. PISDM2 pIsdm2,
  483. DWORD flag,
  484. BOOL LocalFB)
  485. {
  486. DWORD curTime = timeGetTime();
  487. DWORD dwTmp;
  488. DWORD dwValue;
  489. ISDM2_ENTRY Isdm2Stat;
  490. HRESULT hError;
  491. unsigned short idx = 0;
  492. EnterCriticalSection (&pIsdm2->critSect);
  493. Isdm2Stat.SSRC = pSSRC->SSRC;
  494. Isdm2Stat.PayLoadType = pSSRC->PayLoadType;
  495. if (flag == RECVR)
  496. {
  497. Isdm2Stat.dwSSRCStatus = RECVR;
  498. Isdm2Stat.rcvInfo.dwNumPcktRcvd = pSSRC->rcvInfo.dwNumPcktRcvd;
  499. Isdm2Stat.rcvInfo.dwPrvNumPcktRcvd = pSSRC->rcvInfo.dwPrvNumPcktRcvd;
  500. Isdm2Stat.rcvInfo.dwExpectedPrior = pSSRC->rcvInfo.dwExpectedPrior;
  501. Isdm2Stat.rcvInfo.dwNumBytesRcvd = pSSRC->rcvInfo.dwNumBytesRcvd;
  502. Isdm2Stat.rcvInfo.dwBaseRcvSeqNum = pSSRC->rcvInfo.dwBaseRcvSeqNum;
  503. Isdm2Stat.rcvInfo.dwBadSeqNum = pSSRC->rcvInfo.dwBadSeqNum;
  504. Isdm2Stat.rcvInfo.dwProbation = pSSRC->rcvInfo.dwProbation;
  505. Isdm2Stat.rcvInfo.dwPropagationTime= pSSRC->rcvInfo.dwPropagationTime;
  506. Isdm2Stat.rcvInfo.interJitter = pSSRC->rcvInfo.interJitter;
  507. Isdm2Stat.rcvInfo.XtendedSeqNum.seq_union.dwXtndedHighSeqNumRcvd =
  508. pSSRC->rcvInfo.XtendedSeqNum.seq_union.dwXtndedHighSeqNumRcvd;
  509. }
  510. else // (flag == ISDM_UPDATE_XMTSTAT)
  511. {
  512. Isdm2Stat.dwSSRCStatus = XMITR;
  513. Isdm2Stat.xmitinfo.dwNumPcktSent = pSSRC->xmtInfo.dwNumPcktSent;
  514. Isdm2Stat.xmitinfo.dwNumBytesSent = pSSRC->xmtInfo.dwNumBytesSent;
  515. Isdm2Stat.xmitinfo.dwNTPmsw = pSSRC->xmtInfo.dwNTPmsw;
  516. Isdm2Stat.xmitinfo.dwNTPlsw = pSSRC->xmtInfo.dwNTPlsw;
  517. Isdm2Stat.xmitinfo.dwRTPts = pSSRC->xmtInfo.dwRTPts;
  518. Isdm2Stat.xmitinfo.dwCurXmtSeqNum = pSSRC->xmtInfo.dwCurXmtSeqNum;
  519. Isdm2Stat.xmitinfo.dwPrvXmtSeqNum = pSSRC->xmtInfo.dwPrvXmtSeqNum;
  520. Isdm2Stat.xmitinfo.sessionBW = pSSRC->xmtInfo.dwRtcpStreamMinBW;
  521. Isdm2Stat.xmitinfo.dwLastSR = pSSRC->xmtInfo.dwLastSR;
  522. Isdm2Stat.xmitinfo.dwLastSRLocalTime =
  523. pSSRC->xmtInfo.dwLastSRLocalTime;
  524. Isdm2Stat.xmitinfo.dwLastSendRTPSystemTime =
  525. pSSRC->xmtInfo.dwLastSendRTPSystemTime;
  526. Isdm2Stat.xmitinfo.dwLastSendRTPTimeStamp =
  527. pSSRC->xmtInfo.dwLastSendRTPTimeStamp;
  528. }
  529. if(LocalFB)
  530. {
  531. memcpy(&Isdm2Stat.rrFeedback, &pSSRC->rrFeedback, sizeof(RTCP_FEEDBACK));
  532. }
  533. else
  534. {
  535. Isdm2Stat.rrFeedback.SSRC = pSSRC->rrFeedback.SSRC;
  536. #ifdef ENABLE_FLOATING_POINT
  537. Isdm2Stat.rrFeedback.dwInterJitter = pSSRC->rcvInfo.interJitter;
  538. #else
  539. // Check RFC for details of the round off
  540. Isdm2Stat.rrFeedback.dwInterJitter = pSSRC->rcvInfo.interJitter >> 4;
  541. #endif
  542. Isdm2Stat.rrFeedback.XtendedSeqNum.seq_union.dwXtndedHighSeqNumRcvd =
  543. pSSRC->rcvInfo.XtendedSeqNum.seq_union.dwXtndedHighSeqNumRcvd;
  544. // fraction/cumulative number lost are in network order
  545. dwTmp = getSSRCpcktLoss (pSSRC, FALSE);
  546. Isdm2Stat.rrFeedback.fractionLost = (dwTmp & 0xFF);
  547. RRCMws.ntohl (pSSRC->RTPsd, dwTmp, &dwValue);
  548. Isdm2Stat.rrFeedback.cumNumPcktLost = (dwValue & 0x00FFFFFF);
  549. Isdm2Stat.rrFeedback.dwLastRcvRpt = pSSRC->rrFeedback.dwLastRcvRpt;
  550. Isdm2Stat.rrFeedback.dwLastSR = pSSRC->xmtInfo.dwLastSR;
  551. Isdm2Stat.rrFeedback.dwDelaySinceLastSR = getDLSR (pSSRC);
  552. }
  553. Isdm2Stat.dwLastReportRcvdTime = pSSRC->dwLastReportRcvdTime;
  554. memcpy(&Isdm2Stat.cnameInfo, &pSSRC->cnameInfo, sizeof(SDES_DATA));
  555. memcpy(&Isdm2Stat.nameInfo, &pSSRC->nameInfo, sizeof(SDES_DATA));
  556. memcpy(&Isdm2Stat.from, &pSSRC->from, sizeof(SOCKADDR));
  557. Isdm2Stat.fromLen = pSSRC->fromLen;
  558. Isdm2Stat.dwNumRptSent = pSSRC->dwNumRptSent;
  559. Isdm2Stat.dwNumRptRcvd = pSSRC->dwNumRptRcvd;
  560. Isdm2Stat.dwNumXmtIoPending = pSSRC->dwNumXmtIoPending;
  561. Isdm2Stat.dwStreamClock = pSSRC->dwStreamClock;
  562. hError = Isdm2.ISDMEntry.ISD_SetValue (NULL,
  563. pSSRC->hISDM,
  564. NULL,
  565. BINARY_VALUE,
  566. (BYTE *)&Isdm2Stat,
  567. sizeof(ISDM2_ENTRY));
  568. if(FAILED(hError))
  569. RRCM_DBG_MSG ("RTP: ISD_SetValue Failed",0, NULL, 0, DBG_NOTIFY);
  570. LeaveCriticalSection (&pIsdm2->critSect);
  571. }
  572. #endif // #ifdef ENABLE_ISDM2
  573. /*---------------------------------------------------------------------------
  574. * Function : RRCMdebugMsg
  575. * Description: Output RRCM debug messages
  576. *
  577. * Input : pMsg: -> to message
  578. * err: Error code
  579. * pFile: -> to file where the error occured
  580. * line: Line number where the error occured
  581. *
  582. * Return: None
  583. --------------------------------------------------------------------------*/
  584. void RRCMdebugMsg (PCHAR pMsg,
  585. DWORD err,
  586. PCHAR pFile,
  587. DWORD line,
  588. DWORD type)
  589. {
  590. #ifdef ISRDBG
  591. wsprintf (debug_string, "%s", pMsg);
  592. if (err)
  593. wsprintf (debug_string+strlen(debug_string), " Error:%d", err);
  594. if (pFile != NULL)
  595. wsprintf (debug_string+strlen(debug_string), " - %s, line:%d",
  596. pFile, line);
  597. switch (type)
  598. {
  599. case DBG_NOTIFY:
  600. ISRNOTIFY(ghISRInst, debug_string, 0);
  601. break;
  602. case DBG_TRACE:
  603. ISRTRACE(ghISRInst, debug_string, 0);
  604. break;
  605. case DBG_ERROR:
  606. ISRERROR(ghISRInst, debug_string, 0);
  607. break;
  608. case DBG_WARNING:
  609. ISRWARNING(ghISRInst, debug_string, 0);
  610. break;
  611. case DBG_TEMP:
  612. ISRTEMP(ghISRInst, debug_string, 0);
  613. break;
  614. case DBG_CRITICAL:
  615. ISRCRITICAL(ghISRInst, debug_string, 0);
  616. break;
  617. default:
  618. break;
  619. }
  620. #elif DEBUG
  621. extern HDBGZONE ghDbgZoneRRCM ;
  622. lstrcpyn(debug_string, pMsg, DBG_STRING_LEN);
  623. if (err)
  624. wsprintf (debug_string+strlen(debug_string), " Error:%d", err);
  625. if (pFile != NULL)
  626. wsprintf (debug_string+strlen(debug_string), " - %s, line:%d",
  627. pFile, line);
  628. switch (type)
  629. {
  630. case DBG_NOTIFY:
  631. case DBG_TRACE:
  632. case DBG_WARNING:
  633. case DBG_TEMP:
  634. DBGMSG(ghDbgZoneRRCM,0,(debug_string)); // Trace Zone
  635. break;
  636. case DBG_ERROR:
  637. case DBG_CRITICAL:
  638. DBGMSG(ghDbgZoneRRCM,1,(debug_string)); // Error Zone
  639. break;
  640. default:
  641. break;
  642. }
  643. #endif
  644. }
  645. // [EOF]