Changeset 6043
- Timestamp:
- Jul 25, 2019 3:00:33 AM (5 years ago)
- Location:
- pjproject/trunk/pjmedia/src/pjmedia
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia/jbuf.c
r5887 r6043 45 45 */ 46 46 #define INIT_CYCLE 10 47 48 49 /* Maximum frame index in JB framelist (estimated). 50 * As index is calculated as (RTP-timestamp/timestamp-span), the maximum index 51 * usually ranging from MAXUINT32/9000 (10 fps video at 90kHz) to MAXUINT32/80 52 * (10 ms audio at 8000Hz), lets take the 'lowest'. 53 */ 54 #define MAX_FRAME_INDEX (0xFFFFFFFF/9000) 47 55 48 56 … … 471 479 PJ_ASSERT_RETURN(frame_size <= framelist->frame_size, PJ_EINVAL); 472 480 473 /* too late or sequence restart */ 474 if (index < framelist->origin) { 481 /* get distance of this frame to the first frame in the buffer */ 482 distance = index - framelist->origin; 483 484 /* too late or sequence restart or far jump */ 485 if (distance < 0) { 475 486 if (framelist->origin - index < MAX_MISORDER) { 476 487 /* too late */ 488 TRACE__((THIS_FILE,"Put frame #%d: too late (distance=%d)", 489 index, distance)); 477 490 return PJ_ETOOSMALL; 491 } else if (framelist->origin + framelist->size >= MAX_FRAME_INDEX) { 492 /* sequence restart */ 493 TRACE__((THIS_FILE,"Put frame #%d: sequence restart (distance=%d, " 494 "orig=%d, size=%d)", 495 index, distance, framelist->origin, 496 framelist->size)); 497 framelist->origin = index - framelist->size; 498 distance = framelist->size; 478 499 } else { 479 /* sequence restart */ 480 framelist->origin = index - framelist->size; 500 /* jump too far, reset the buffer */ 501 TRACE__((THIS_FILE,"Put frame #%d: far jump (distance=%d)", 502 index, distance)); 503 jb_framelist_reset(framelist); 504 framelist->origin = index; 505 distance = 0; 481 506 } 482 507 } … … 485 510 if (framelist->size == 0) { 486 511 pj_assert(framelist->discarded_num == 0); 512 TRACE__((THIS_FILE,"Put frame #%d: origin reset (from %d) as JB empty", 513 index, framelist->origin)); 487 514 framelist->origin = index; 488 } 489 490 /* get distance of this frame to the first frame in the buffer */ 491 distance = index - framelist->origin; 515 distance = 0; 516 } 492 517 493 518 /* far jump, the distance is greater than buffer capacity */ … … 495 520 if (distance > MAX_DROPOUT) { 496 521 /* jump too far, reset the buffer */ 522 TRACE__((THIS_FILE,"Put frame #%d: far jump (distance=%d)", 523 index, distance)); 497 524 jb_framelist_reset(framelist); 498 525 framelist->origin = index; … … 500 527 } else { 501 528 /* otherwise, reject the frame */ 529 TRACE__((THIS_FILE,"Put frame #%d: rejected due to JB full", 530 index)); 502 531 return PJ_ETOOMANY; 503 532 } … … 508 537 509 538 /* if the slot is occupied, it must be duplicated frame, ignore it. */ 510 if (framelist->frame_type[pos] != PJMEDIA_JB_MISSING_FRAME) 539 if (framelist->frame_type[pos] != PJMEDIA_JB_MISSING_FRAME) { 540 TRACE__((THIS_FILE,"Put frame #%d maybe a duplicate, ignored", index)); 511 541 return PJ_EEXISTS; 542 } 512 543 513 544 /* put the frame into the slot */ -
pjproject/trunk/pjmedia/src/pjmedia/stream.c
r6005 r6043 1962 1962 stream->dec_ptime = (pj_uint16_t)dec_ptime; 1963 1963 pjmedia_jbuf_set_ptime(stream->jb, stream->dec_ptime); 1964 1965 /* Reset jitter buffer after ptime changed */ 1966 pjmedia_jbuf_reset(stream->jb); 1964 1967 } 1965 1968
Note: See TracChangeset
for help on using the changeset viewer.