Changeset 2850 for pjproject/trunk/pjmedia/src/pjmedia/stream.c
- Timestamp:
- Aug 1, 2009 9:20:59 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia/stream.c
r2844 r2850 44 44 #define BYTES_PER_SAMPLE 2 45 45 46 /* Limit the number of synthetic audio samples that are generated by PLC. 47 * Normally PLC should have it's own means to limit the number of 48 * synthetic frames, so we need to set this to a reasonably large value 49 * just as precaution 50 */ 51 #define MAX_PLC_MSEC 240 52 46 53 /** 47 54 * Media channel. … … 99 106 unsigned enc_buf_count; /**< Number of samples in the 100 107 encoding buffer. */ 108 109 unsigned plc_cnt; /**< # of consecutive PLC frames*/ 110 unsigned max_plc_cnt; /**< Max # of PLC frames */ 101 111 102 112 unsigned vad_enabled; /**< VAD enabled in param. */ … … 198 208 } 199 209 210 #if defined(PJMEDIA_STREAM_ENABLE_KA) && PJMEDIA_STREAM_ENABLE_KA != 0 200 211 /* 201 * Send keep-alive packet .212 * Send keep-alive packet using non-codec frame. 202 213 */ 203 214 static void send_keep_alive_packet(pjmedia_stream *stream) 204 215 { 205 #if defined(PJMEDIA_STREAM_ENABLE_KA) && \ 206 PJMEDIA_STREAM_ENABLE_KA == PJMEDIA_STREAM_KA_EMPTY_RTP 216 #if PJMEDIA_STREAM_ENABLE_KA == PJMEDIA_STREAM_KA_EMPTY_RTP 207 217 208 218 /* Keep-alive packet is empty RTP */ … … 225 235 TRC_((stream->port.info.name.ptr, "Keep-alive sent (empty RTP)")); 226 236 227 #elif defined(PJMEDIA_STREAM_ENABLE_KA) && \ 228 PJMEDIA_STREAM_ENABLE_KA == PJMEDIA_STREAM_KA_USER 237 #elif PJMEDIA_STREAM_ENABLE_KA == PJMEDIA_STREAM_KA_USER 229 238 230 239 /* Keep-alive packet is defined in PJMEDIA_STREAM_KA_USER_PKT */ … … 244 253 #endif 245 254 } 255 #endif /* defined(PJMEDIA_STREAM_ENABLE_KA) */ 246 256 247 257 /* … … 295 305 /* Activate PLC */ 296 306 if (stream->codec->op->recover && 297 stream->codec_param.setting.plc) 307 stream->codec_param.setting.plc && 308 stream->plc_cnt < stream->max_plc_cnt) 298 309 { 299 310 pjmedia_frame frame_out; … … 305 316 &frame_out); 306 317 318 ++stream->plc_cnt; 319 307 320 } else { 308 321 status = -1; … … 319 332 "Lost frame recovered")); 320 333 } 321 334 322 335 } else if (frame_type == PJMEDIA_JB_ZERO_EMPTY_FRAME) { 323 336 … … 326 339 * the frame. 327 340 */ 328 if (frame_type != stream->jb_last_frm) { 341 //Using this "if" will only invoke PLC for the first packet 342 //lost and not the subsequent ones. 343 //if (frame_type != stream->jb_last_frm) { 344 if (1) { 329 345 pjmedia_jb_state jb_state; 330 346 const char *with_plc = ""; … … 332 348 /* Activate PLC to smoothen the missing frame */ 333 349 if (stream->codec->op->recover && 334 stream->codec_param.setting.plc) 350 stream->codec_param.setting.plc && 351 stream->plc_cnt < stream->max_plc_cnt) 335 352 { 336 353 pjmedia_frame frame_out; … … 344 361 if (status != PJ_SUCCESS) 345 362 break; 363 346 364 samples_count += samples_per_frame; 347 348 } while (samples_count < samples_required); 365 ++stream->plc_cnt; 366 367 } while (samples_count < samples_required && 368 stream->plc_cnt < stream->max_plc_cnt); 349 369 350 370 with_plc = ", plc invoked"; … … 380 400 /* Always activate PLC when it's available.. */ 381 401 if (stream->codec->op->recover && 382 stream->codec_param.setting.plc) 402 stream->codec_param.setting.plc && 403 stream->plc_cnt < stream->max_plc_cnt) 383 404 { 384 405 pjmedia_frame frame_out; … … 394 415 samples_count += samples_per_frame; 395 416 396 } while (samples_count < samples_required); 397 398 if (stream->jb_last_frm != frame_type) { 417 ++stream->plc_cnt; 418 419 } while (samples_count < samples_required && 420 stream->plc_cnt < stream->max_plc_cnt); 421 422 //if (stream->jb_last_frm != frame_type) { 423 if (1) { 399 424 PJ_LOG(5,(stream->port.info.name.ptr, 400 425 "Jitter buffer is bufferring with plc (prefetch=%d)", … … 419 444 /* Got "NORMAL" frame from jitter buffer */ 420 445 pjmedia_frame frame_in, frame_out; 446 447 stream->plc_cnt = 0; 421 448 422 449 /* Decode */ … … 1822 1849 ++stream->frame_size; 1823 1850 } 1851 1852 /* How many consecutive PLC frames can be generated */ 1853 stream->max_plc_cnt = (MAX_PLC_MSEC+stream->codec_param.info.frm_ptime-1)/ 1854 stream->codec_param.info.frm_ptime; 1824 1855 1825 1856 #if defined(PJMEDIA_HANDLE_G722_MPEG_BUG) && (PJMEDIA_HANDLE_G722_MPEG_BUG!=0)
Note: See TracChangeset
for help on using the changeset viewer.