X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Frtpenc_xiph.c;h=f6ab77f55e6fa9a94d0fdece02166df2bd5ca95e;hb=2f806622e1270d3ed1d41a53049a19673dafbe70;hp=ef31c048deac81c7d478d95d6347ffc9297ae3b5;hpb=7c1e2e64667421f931ab48141517f19d309c7eea;p=ffmpeg diff --git a/libavformat/rtpenc_xiph.c b/libavformat/rtpenc_xiph.c index ef31c048dea..f6ab77f55e6 100644 --- a/libavformat/rtpenc_xiph.c +++ b/libavformat/rtpenc_xiph.c @@ -32,10 +32,11 @@ void ff_rtp_send_xiph(AVFormatContext *s1, const uint8_t *buff, int size) { RTPMuxContext *s = s1->priv_data; + AVStream *st = s1->streams[0]; int max_pkt_size, xdt, frag; uint8_t *q; - max_pkt_size = s->max_payload_size; + max_pkt_size = s->max_payload_size - 6; // ident+frag+tdt/vdt+pkt_num+pkt_length // set xiph data type switch (*buff) { @@ -66,7 +67,7 @@ void ff_rtp_send_xiph(AVFormatContext *s1, const uint8_t *buff, int size) // 0 - whole frame (possibly multiple frames) // 1 - first fragment // 2 - fragment continuation - // 3 - last fragmement + // 3 - last fragment frag = size <= max_pkt_size ? 0 : 1; if (!frag && !xdt) { // do we have a whole frame of raw data? @@ -75,9 +76,12 @@ void ff_rtp_send_xiph(AVFormatContext *s1, const uint8_t *buff, int size) int remaining = end_ptr - ptr; assert(s->num_frames <= s->max_frames_per_packet); - if ((s->num_frames > 0 && remaining < 0) || - s->num_frames == s->max_frames_per_packet) { - // send previous packets now; no room for new data + if (s->num_frames > 0 && + (remaining < 0 || + s->num_frames == s->max_frames_per_packet || + av_compare_ts(s->cur_timestamp - s->timestamp, st->time_base, + s1->max_delay, AV_TIME_BASE_Q) >= 0)) { + // send previous packets now; no room for new data, or too much delay ff_rtp_send_data(s1, s->buf, s->buf_ptr - s->buf, 0); s->num_frames = 0; }