Lines Matching refs:packet
85 int curr_count; /**< Number of packet timings we got (including those we discarded) */
96 /* Add the timing of a new packet to the TimingBuffer */
100 /* Discard packet that won't make it into the list because they're too early */
140 spx_uint32_t last_returned_timestamp; /**< Useful for getting the next packet with the same timestamp (for fragmented media) */
146 spx_uint32_t arrival[SPEEX_JITTER_MAX_BUFFER_SIZE]; /**< Packet arrival time (0 means it was late, even though it's a valid timestamp) */
148 void (*destroy) (void *); /**< Callback for destroying a packet */
151 spx_int32_t concealment_size; /**< Size of the packet loss concealment "units" */
154 int late_cutoff; /**< How late must a packet be for it not to be considered at all */
192 /* Number of packet timings we have received (including those we didn't keep) */
199 /* Compute cost for one lost packet */
247 /* For the next timing we will consider, there will be one more late packet to count */
367 /** Put one packet into the jitter buffer */
368 EXPORT void jitter_buffer_put(JitterBuffer *jitter, const JitterBufferPacket *packet)
372 /*fprintf (stderr, "put packet %d %d\n", timestamp, span);*/
379 /* Make sure we don't discard a "just-late" packet in case we want to play it next (if we interpolate). */
392 /*fprintf(stderr, "arrival: %d %d %d\n", packet->timestamp, jitter->next_stop, jitter->pointer_timestamp);*/
393 /* Check if packet is late (could still be useful though) */
394 if (!jitter->reset_state && LT32(packet->timestamp, jitter->next_stop))
396 update_timings(jitter, ((spx_int32_t)packet->timestamp) - ((spx_int32_t)jitter->next_stop) - jitter->buffer_margin);
402 /* For some reason, the consumer has failed the last 20 fetches. Make sure this packet is
409 /* Only insert the packet if it's not hopelessly late (i.e. totally useless) */
410 if (jitter->reset_state || GE32(packet->timestamp+packet->span+jitter->delay_step, jitter->pointer_timestamp))
420 /*No place left in the buffer, need to make room for it by discarding the oldest packet */
441 /* Copy packet in buffer */
444 jitter->packets[i].data = packet->data;
446 jitter->packets[i].data=(char*)speex_alloc(packet->len);
447 for (j=0;j<packet->len;j++)
448 jitter->packets[i].data[j]=packet->data[j];
450 jitter->packets[i].timestamp=packet->timestamp;
451 jitter->packets[i].span=packet->span;
452 jitter->packets[i].len=packet->len;
453 packet->sequence;
454 jitter->packets[i].user_data=packet->user_data;
464 /** Get one packet from the jitter buffer */
465 EXPORT int jitter_buffer_get(JitterBuffer *jitter, JitterBufferPacket *packet, spx_int32_t desired_span, spx_int32_t *start_offset)
479 /* Find the oldest packet */
495 packet->timestamp = 0;
496 packet->span = jitter->interp_requested;
506 packet->timestamp = jitter->pointer_timestamp;
507 packet->span = jitter->interp_requested;
511 packet->len = 0;
516 jitter->buffered = packet->span - desired_span;
521 /* Searching for the packet that fits best */
523 /* Search the buffer for a packet with the right timestamp and spanning the whole current chunk */
530 /* If no match, try for an "older" packet that still spans (fully) the current chunk */
540 /* If still no match, try for an "older" packet that spans part of the current chunk */
550 /* If still no match, try for earliest packet possible */
559 /* check if packet starts within current chunk */
584 /* We (obviously) haven't lost this packet */
594 /* Copy packet */
597 packet->data = jitter->packets[i].data;
598 packet->len = jitter->packets[i].len;
600 if (jitter->packets[i].len > packet->len)
602 speex_warning_int("jitter_buffer_get(): packet too large to fit. Size is", jitter->packets[i].len);
604 packet->len = jitter->packets[i].len;
606 for (j=0;j<packet->len;j++)
607 packet->data[j] = jitter->packets[i].data[j];
608 /* Remove packet */
619 packet->timestamp = jitter->packets[i].timestamp;
620 jitter->last_returned_timestamp = packet->timestamp;
622 packet->span = jitter->packets[i].span;
623 packet->sequence = jitter->packets[i].sequence;
624 packet->user_data = jitter->packets[i].user_data;
625 /* Point to the end of the current packet */
628 jitter->buffered = packet->span - desired_span;
654 packet->timestamp = jitter->pointer_timestamp;
655 packet->span = -opt;
657 packet->len = 0;
659 jitter->buffered = packet->span - desired_span;
664 /* Normal packet loss */
665 packet->timestamp = jitter->pointer_timestamp;
668 packet->span = desired_span;
670 packet->len = 0;
672 jitter->buffered = packet->span - desired_span;
680 EXPORT int jitter_buffer_get_another(JitterBuffer *jitter, JitterBufferPacket *packet)
690 /* Copy packet */
691 packet->len = jitter->packets[i].len;
694 packet->data = jitter->packets[i].data;
696 for (j=0;j<packet->len;j++)
697 packet->data[j] = jitter->packets[i].data[j];
698 /* Remove packet */
702 packet->timestamp = jitter->packets[i].timestamp;
703 packet->span = jitter->packets[i].span;
704 packet->sequence = jitter->packets[i].sequence;
705 packet->user_data = jitter->packets[i].user_data;
708 packet->data = NULL;
709 packet->len = 0;
710 packet->span = 0;
716 static int _jitter_buffer_update_delay(JitterBuffer *jitter, JitterBufferPacket *packet, spx_int32_t *start_offset)
739 EXPORT int jitter_buffer_update_delay(JitterBuffer *jitter, JitterBufferPacket *packet, spx_int32_t *start_offset)
745 return _jitter_buffer_update_delay(jitter, packet, start_offset);