Changeset 1945
- Timestamp:
- May 2, 2008 3:01:10 PM (17 years ago)
- Location:
- pjproject/trunk/pjmedia
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/include/pjmedia/stream.h
r1943 r1945 99 99 pj_bool_t rtcp_xr_enabled; 100 100 /**< Specify whether RTCP XR is enabled.*/ 101 pj_uint32_t rtcp_xr_interval; /**< RTCP XR interval. */ 102 pj_sockaddr rtcp_xr_dest;/**<Additional remote RTCP XR address. 103 This is useful for third-party (e.g: 104 network monitor) to monitor the 105 stream. If sin_family is zero, 106 this will be ignored. */ 101 107 #endif 102 108 pjmedia_codec_info fmt; /**< Incoming codec format info. */ -
pjproject/trunk/pjmedia/src/pjmedia/rtcp_xr.c
r1943 r1945 270 270 pj_uint32_t c33; 271 271 pj_uint32_t ctotal, p32, p23, m; 272 unsigned est_extra_delay; 272 273 273 274 r = (pjmedia_rtcp_xr_rb_voip_mtc*) &sess->pkt.buf[size]; … … 342 343 (sess->rtcp_session->stat.rtt.last / 1000); 343 344 344 /* End system delay estimation = RTT/2 + current jitter buffer size +345 * EXTRA345 /* End system delay = RTT/2 + current jitter buffer size + 346 * EXTRA (estimated extra delay) 346 347 * EXTRA will cover additional delay introduced by other components of 347 348 * audio engine, e.g: sound device, codec, AEC, PLC, WSOLA. 348 349 * Since it is difficult to get the exact value of EXTRA, estimation 349 * is taken to be totally around 50 ms.350 * is taken to be totally around 30ms + sound device latency. 350 351 */ 352 est_extra_delay = 30 + 353 #if PJMEDIA_SOUND_IMPLEMENTATION==PJMEDIA_SOUND_PORTAUDIO_SOUND 354 PJMEDIA_PASOUND_MAX_LATENCY 355 #elif PJMEDIA_SOUND_IMPLEMENTATION==PJMEDIA_SOUND_NULL_SOUND 356 0 357 #else 358 (PJMEDIA_SOUND_BUFFER_COUNT * 15) 359 #endif 360 ; 351 361 sess->stat.rx.voip_mtc.end_sys_delay = (pj_uint16_t) 352 (sess->stat.rx.voip_mtc.rnd_trip_delay / 2 + 353 sess->stat.rx.voip_mtc.jb_nom + 50); 362 (sess->stat.rx.voip_mtc.rnd_trip_delay / 2 + 363 sess->stat.rx.voip_mtc.jb_nom + 364 est_extra_delay); 354 365 355 366 /* Generate block contents */ -
pjproject/trunk/pjmedia/src/pjmedia/stream.c
r1943 r1945 158 158 #endif 159 159 160 #if defined(PJMEDIA_HAS_RTCP_XR) && (PJMEDIA_HAS_RTCP_XR != 0) 161 pj_uint32_t rtcp_xr_last_tx; /**< RTCP XR tx time 162 in timestamp. */ 163 pj_uint32_t rtcp_xr_interval; /**< Interval, in timestamp. */ 164 pj_sockaddr rtcp_xr_dest; /**< Additional remote RTCP XR 165 dest. If sin_family is 166 zero, it will be ignored*/ 167 unsigned rtcp_xr_dest_len; /**< Length of RTCP XR dest 168 address */ 169 #endif 160 170 }; 161 171 … … 468 478 pjmedia_rtcp_build_rtcp(&stream->rtcp, &rtcp_pkt, &len); 469 479 470 (*stream->transport->op->send_rtcp)(stream->transport, 471 rtcp_pkt, len); 480 pjmedia_transport_send_rtcp(stream->transport, rtcp_pkt, len); 481 482 stream->rtcp_last_tx = timestamp; 483 } 472 484 473 485 #if defined(PJMEDIA_HAS_RTCP_XR) && (PJMEDIA_HAS_RTCP_XR != 0) 474 /* Temporarily always send RTCP XR after RTCP */ 475 if (stream->rtcp.xr_enabled) 486 if (stream->rtcp.xr_enabled) { 487 488 if (stream->rtcp_xr_last_tx == 0) { 489 490 stream->rtcp_xr_last_tx = timestamp; 491 492 } else if (timestamp - stream->rtcp_xr_last_tx >= 493 stream->rtcp_xr_interval) 476 494 { 477 495 int i; 478 496 pjmedia_jb_state jb_state; 479 497 void *rtcp_pkt; 498 int len; 499 500 /* Update RTCP XR with current JB states */ 480 501 pjmedia_jbuf_get_state(stream->jb, &jb_state); 481 502 482 503 i = jb_state.size * stream->codec_param.info.frm_ptime; 483 504 pjmedia_rtcp_xr_update_info(&stream->rtcp.xr_session, … … 490 511 i); 491 512 513 /* Build RTCP XR packet */ 492 514 pjmedia_rtcp_build_rtcp_xr(&stream->rtcp.xr_session, 0, 493 515 &rtcp_pkt, &len); 494 516 495 (*stream->transport->op->send_rtcp)(stream->transport, 496 rtcp_pkt, len); 517 /* Send the RTCP XR to remote address */ 518 pjmedia_transport_send_rtcp(stream->transport, rtcp_pkt, len); 519 520 /* Send the RTCP XR to third-party destination if specified */ 521 if (stream->rtcp_xr_dest_len) { 522 pjmedia_transport_send_rtcp2(stream->transport, 523 &stream->rtcp_xr_dest, 524 stream->rtcp_xr_dest_len, 525 rtcp_pkt, len); 526 } 527 528 /* Update last tx RTCP XR */ 529 stream->rtcp_xr_last_tx = timestamp; 497 530 } 531 } 498 532 #endif 499 500 stream->rtcp_last_tx = timestamp;501 }502 533 } 503 534 … … 768 799 769 800 /* Send the RTP packet to the transport. */ 770 (*stream->transport->op->send_rtp)(stream->transport, 771 channel->out_pkt, 772 frame_out.size + 773 sizeof(pjmedia_rtp_hdr)); 774 801 pjmedia_transport_send_rtp(stream->transport, channel->out_pkt, 802 frame_out.size + sizeof(pjmedia_rtp_hdr)); 775 803 776 804 /* Update stat */ … … 1565 1593 pjmedia_rtcp_enable_xr(&stream->rtcp, PJ_TRUE); 1566 1594 1595 /* Set RTCP XR TX interval */ 1596 if (info->rtcp_xr_interval != 0) 1597 stream->rtcp_xr_interval = info->rtcp_xr_interval; 1598 else 1599 stream->rtcp_xr_interval = (PJMEDIA_RTCP_INTERVAL + 1600 (pj_rand() % 8000)) * 1601 info->fmt.clock_rate / 1000; 1602 1603 /* Additional third-party RTCP XR destination */ 1604 if (info->rtcp_xr_dest.addr.sa_family != 0) { 1605 stream->rtcp_xr_dest_len = pj_sockaddr_get_len(&info->rtcp_xr_dest); 1606 pj_memcpy(&stream->rtcp_xr_dest, &info->rtcp_xr_dest, 1607 stream->rtcp_xr_dest_len); 1608 } 1609 1567 1610 /* jitter buffer adaptive info */ 1568 1611 i = PJMEDIA_RTCP_XR_JB_ADAPTIVE; … … 1620 1663 PJ_ASSERT_RETURN(stream != NULL, PJ_EINVAL); 1621 1664 1665 #if defined(PJMEDIA_HAS_RTCP_XR) && (PJMEDIA_HAS_RTCP_XR != 0) 1666 /* Send RTCP XR on stream destroy */ 1667 if (stream->rtcp.xr_enabled) { 1668 int i; 1669 pjmedia_jb_state jb_state; 1670 void *rtcp_pkt; 1671 int len; 1672 1673 /* Update RTCP XR with current JB states */ 1674 pjmedia_jbuf_get_state(stream->jb, &jb_state); 1675 1676 i = jb_state.size * stream->codec_param.info.frm_ptime; 1677 pjmedia_rtcp_xr_update_info(&stream->rtcp.xr_session, 1678 PJMEDIA_RTCP_XR_INFO_JB_NOM, 1679 i); 1680 1681 i = jb_state.max_size* stream->codec_param.info.frm_ptime; 1682 pjmedia_rtcp_xr_update_info(&stream->rtcp.xr_session, 1683 PJMEDIA_RTCP_XR_INFO_JB_MAX, 1684 i); 1685 1686 /* Build RTCP XR packet */ 1687 pjmedia_rtcp_build_rtcp_xr(&stream->rtcp.xr_session, 0, 1688 &rtcp_pkt, &len); 1689 1690 /* Send the RTCP XR to remote address */ 1691 pjmedia_transport_send_rtcp(stream->transport, rtcp_pkt, len); 1692 1693 /* Send the RTCP XR to third-party destination if specified */ 1694 if (stream->rtcp_xr_dest_len) { 1695 pjmedia_transport_send_rtcp2(stream->transport, 1696 &stream->rtcp_xr_dest, 1697 stream->rtcp_xr_dest_len, 1698 rtcp_pkt, len); 1699 } 1700 } 1701 #endif 1622 1702 1623 1703 /* Detach from transport
Note: See TracChangeset
for help on using the changeset viewer.