* MOV, 3GP, MP4 muxer RTP hinting
* Copyright (c) 2010 Martin Storsjo
*
- * This file is part of Libav.
+ * This file is part of FFmpeg.
*
- * Libav is free software; you can redistribute it and/or
+ * FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
- * Libav is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
uint32_t packet_len = AV_RB32(data);
uint16_t seq;
uint32_t ts;
+ int32_t ts_diff;
data += 4;
size -= 4;
trk->prev_rtp_ts = ts;
/* Unwrap the 32-bit RTP timestamp that wraps around often
* into a not (as often) wrapping 64-bit timestamp. */
- trk->cur_rtp_ts_unwrapped += (int32_t) (ts - trk->prev_rtp_ts);
- trk->prev_rtp_ts = ts;
+ ts_diff = ts - trk->prev_rtp_ts;
+ if (ts_diff > 0) {
+ trk->cur_rtp_ts_unwrapped += ts_diff;
+ trk->prev_rtp_ts = ts;
+ ts_diff = 0;
+ }
if (*pts == AV_NOPTS_VALUE)
*pts = trk->cur_rtp_ts_unwrapped;
avio_wb32(out, 0); /* relative_time */
avio_write(out, data, 2); /* RTP header */
avio_wb16(out, seq); /* RTPsequenceseed */
- avio_wb16(out, 0); /* reserved + flags */
+ avio_wb16(out, ts_diff ? 4 : 0); /* reserved + flags (extra_flag) */
entries_pos = avio_tell(out);
avio_wb16(out, 0); /* entry count */
+ if (ts_diff) { /* if extra_flag is set */
+ avio_wb32(out, 16); /* extra_information_length */
+ avio_wb32(out, 12); /* rtpoffsetTLV box */
+ avio_write(out, "rtpo", 4);
+ avio_wb32(out, ts_diff);
+ }
data += 12;
size -= 12;