Changeset 3224
- Timestamp:
- Jun 26, 2010 4:43:50 AM (14 years ago)
- Location:
- pjproject/trunk/pjmedia
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/include/pjmedia/rtcp.h
r2394 r3224 247 247 pj_timestamp ts_base; /**< Base system timestamp. */ 248 248 pj_timestamp ts_freq; /**< System timestamp frequency. */ 249 pj_uint32_t rtp_ts_base;/**< Base RTP timestamp. */ 249 250 250 251 pj_uint32_t rx_lsr; /**< NTP ts in last SR received */ … … 275 276 276 277 /** 278 * RTCP session settings. 279 */ 280 typedef struct pjmedia_rtcp_session_setting 281 { 282 char *name; /**< RTCP session name. */ 283 unsigned clock_rate; /**< Sequence. */ 284 unsigned samples_per_frame; /**< Timestamp. */ 285 pj_uint32_t ssrc; /**< Sender SSRC. */ 286 pj_uint32_t rtp_ts_base; /**< Base RTP timestamp. */ 287 } pjmedia_rtcp_session_setting; 288 289 290 /** 291 * Initialize RTCP session setting. 292 * 293 * @param settings The RTCP session setting to be initialized. 294 */ 295 PJ_DECL(void) pjmedia_rtcp_session_setting_default( 296 pjmedia_rtcp_session_setting *settings); 297 298 299 /** 277 300 * Initialize RTCP session. 278 301 * … … 292 315 293 316 /** 317 * Initialize RTCP session. 318 * 319 * @param session The session 320 * @param settings The RTCP session settings. 321 */ 322 PJ_DECL(void) pjmedia_rtcp_init2(pjmedia_rtcp_session *session, 323 const pjmedia_rtcp_session_setting *settings); 324 325 326 /** 294 327 * Utility function to retrieve current NTP timestamp. 295 328 * -
pjproject/trunk/pjmedia/src/pjmedia/rtcp.c
r2422 r3224 126 126 127 127 128 /* 129 * Initialize RTCP session setting. 130 */ 131 PJ_DEF(void) pjmedia_rtcp_session_setting_default( 132 pjmedia_rtcp_session_setting *settings) 133 { 134 pj_bzero(&settings, sizeof(*settings)); 135 } 136 137 138 /* 139 * Initialize RTCP session. 140 */ 128 141 PJ_DEF(void) pjmedia_rtcp_init(pjmedia_rtcp_session *sess, 129 142 char *name, … … 132 145 pj_uint32_t ssrc) 133 146 { 147 pjmedia_rtcp_session_setting settings; 148 149 pjmedia_rtcp_session_setting_default(&settings); 150 settings.name = name; 151 settings.clock_rate = clock_rate; 152 settings.samples_per_frame = samples_per_frame; 153 settings.ssrc = ssrc; 154 155 pjmedia_rtcp_init2(sess, &settings); 156 } 157 158 159 /* 160 * Initialize RTCP session. 161 */ 162 PJ_DEF(void) pjmedia_rtcp_init2( pjmedia_rtcp_session *sess, 163 const pjmedia_rtcp_session_setting *settings) 164 { 134 165 pjmedia_rtcp_sr_pkt *sr_pkt = &sess->rtcp_sr_pkt; 135 166 pj_time_val now; … … 142 173 143 174 /* Name */ 144 sess->name = name ? name : (char*)THIS_FILE,175 sess->name = settings->name ? settings->name : (char*)THIS_FILE; 145 176 146 177 /* Set clock rate */ 147 sess->clock_rate = clock_rate;148 sess->pkt_size = s amples_per_frame;178 sess->clock_rate = settings->clock_rate; 179 sess->pkt_size = settings->samples_per_frame; 149 180 150 181 /* Init common RTCP SR header */ … … 153 184 sr_pkt->common.pt = RTCP_SR; 154 185 sr_pkt->common.length = pj_htons(12); 155 sr_pkt->common.ssrc = pj_htonl(s src);186 sr_pkt->common.ssrc = pj_htonl(settings->ssrc); 156 187 157 188 /* Copy to RTCP RR header */ … … 167 198 pj_get_timestamp(&sess->ts_base); 168 199 pj_get_timestamp_freq(&sess->ts_freq); 200 sess->rtp_ts_base = settings->rtp_ts_base; 169 201 170 202 /* Initialize statistics states */ … … 572 604 */ 573 605 if (sess->stat.tx.pkt != pj_ntohl(sess->rtcp_sr_pkt.sr.sender_pcount)) { 606 pj_time_val ts_time; 607 pj_uint32_t rtp_ts; 574 608 575 609 /* So we should send RTCP SR */ … … 589 623 sr->ntp_sec = pj_htonl(ntp.hi); 590 624 sr->ntp_frac = pj_htonl(ntp.lo); 625 626 /* Fill in RTP timestamp (corresponds to NTP timestamp) in SR. */ 627 ts_time.sec = ntp.hi - sess->tv_base.sec - JAN_1970; 628 ts_time.msec = (long)(ntp.lo * 1000.0 / 0xFFFFFFFF); 629 rtp_ts = sess->rtp_ts_base + 630 (pj_uint32_t)(sess->clock_rate*ts_time.sec) + 631 (pj_uint32_t)(sess->clock_rate*ts_time.msec/1000); 632 sr->rtp_ts = pj_htonl(rtp_ts); 591 633 592 634 TRACE_((sess->name, "TX RTCP SR: ntp_ts=%p", -
pjproject/trunk/pjmedia/src/pjmedia/stream.c
r3220 r3224 2122 2122 stream->codec_param.info.channel_cnt; 2123 2123 2124 /* Init RTCP session: */2125 2126 /* Special case for G.722 */2127 2124 if (info->fmt.pt == PJMEDIA_RTP_PT_G722) { 2128 pjmedia_rtcp_init(&stream->rtcp, stream->port.info.name.ptr,2129 8000,2130 160,2131 info->ssrc);2132 2125 stream->has_g722_mpeg_bug = PJ_TRUE; 2133 2126 /* RTP clock rate = 1/2 real clock rate */ 2134 2127 stream->rtp_tx_ts_len_per_pkt >>= 1; 2135 } else { 2136 pjmedia_rtcp_init(&stream->rtcp, stream->port.info.name.ptr, 2137 info->fmt.clock_rate, 2138 stream->port.info.samples_per_frame, 2139 info->ssrc); 2140 } 2141 #else 2142 pjmedia_rtcp_init(&stream->rtcp, stream->port.info.name.ptr, 2143 info->fmt.clock_rate, 2144 stream->port.info.samples_per_frame, 2145 info->ssrc); 2128 } 2146 2129 #endif 2147 2130 … … 2198 2181 goto err_cleanup; 2199 2182 2183 2184 /* Init RTCP session: */ 2185 2186 { 2187 pjmedia_rtcp_session_setting rtcp_setting; 2188 2189 pjmedia_rtcp_session_setting_default(&rtcp_setting); 2190 rtcp_setting.name = stream->port.info.name.ptr; 2191 rtcp_setting.ssrc = info->ssrc; 2192 rtcp_setting.rtp_ts_base = pj_ntohl(stream->enc->rtp.out_hdr.ts); 2193 rtcp_setting.clock_rate = info->fmt.clock_rate; 2194 rtcp_setting.samples_per_frame = stream->port.info.samples_per_frame; 2195 2196 #if defined(PJMEDIA_HANDLE_G722_MPEG_BUG) && (PJMEDIA_HANDLE_G722_MPEG_BUG!=0) 2197 /* Special case for G.722 */ 2198 if (info->fmt.pt == PJMEDIA_RTP_PT_G722) { 2199 rtcp_setting.clock_rate = 8000; 2200 rtcp_setting.samples_per_frame = 160; 2201 } 2202 #endif 2203 2204 pjmedia_rtcp_init2(&stream->rtcp, &rtcp_setting); 2205 } 2200 2206 2201 2207 /* Only attach transport when stream is ready. */
Note: See TracChangeset
for help on using the changeset viewer.