diff options
author | Alfred E. Heggestad <alfred.heggestad@gmail.com> | 2017-07-29 15:13:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-29 15:13:00 +0200 |
commit | 6c56980cbeecaaeac0367ad9aa48eaa84fd8314b (patch) | |
tree | 062e0fa2e0ecf1a3072386972a87886fa38fe3ec /modules/gst_video1/encode.c | |
parent | 5d297b1594765b681466b13257af0a59bf765ff8 (diff) |
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
Diffstat (limited to 'modules/gst_video1/encode.c')
-rw-r--r-- | modules/gst_video1/encode.c | 16 |
1 files changed, 15 insertions, 1 deletions
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); |