From 6c56980cbeecaaeac0367ad9aa48eaa84fd8314b Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sat, 29 Jul 2017 15:13:00 +0200 Subject: Video timestamp (#286) * add timestamp to video encoder/decoder * update vp8 vp9 * random offset * revert decoder timestamp * cleanup * gst_video1: add timestamp * change timestamp to RTP-timestamp * update modules * timestamp things * save rtp timestamp * packet_handler: align params same as RTP header * align parameters same way like RTP-header * avcodec: calc ts for old FFmpeg versions * cleanup * fix gst avcodec: use correct AVPacket * minor cleanup --- modules/gst_video1/encode.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'modules/gst_video1/encode.c') diff --git a/modules/gst_video1/encode.c b/modules/gst_video1/encode.c index b563d07..d0a3d44 100644 --- a/modules/gst_video1/encode.c +++ b/modules/gst_video1/encode.c @@ -122,13 +122,27 @@ static GstFlowReturn appsink_new_sample_cb(GstAppSink *sink, sample = gst_app_sink_pull_sample(sink); if (sample) { + GstClockTime ts; + uint32_t rtp_ts; + buffer = gst_sample_get_buffer(sample); gst_buffer_map( buffer, &info, (GstMapFlags)(GST_MAP_READ) ); data = info.data; size = info.size; - h264_packetize(data, size, st->encoder.pktsize, + ts = GST_BUFFER_DTS_OR_PTS(buffer); + + if (ts == GST_CLOCK_TIME_NONE) { + warning("gst_video: timestamp is unknown\n"); + rtp_ts = 0; + } + else { + /* convert from nanoseconds to RTP clock */ + rtp_ts = (uint32_t)((90000ULL * ts) / 1000000000UL); + } + + h264_packetize(rtp_ts, data, size, st->encoder.pktsize, st->pkth, st->arg); gst_buffer_unmap(buffer, &info); -- cgit v1.2.3