summaryrefslogtreecommitdiff
path: root/gst-libs
diff options
context:
space:
mode:
authorHavard Graff <havard.graff@gmail.com>2015-08-28 11:44:19 +0200
committerSebastian Dröge <sebastian@centricular.com>2015-10-11 11:04:53 +0100
commitdd4d6d9ed54c2a63a7e45661519d9965417707c5 (patch)
tree4026228850001232860f59e8a53d59f054f81ae9 /gst-libs
parent001ca740a778888e1a6d2e477b3aedd9c062796a (diff)
audioencoder: timestamp headers same as first buffer and use duration 0
https://bugzilla.gnome.org/show_bug.cgi?id=754224
Diffstat (limited to 'gst-libs')
-rw-r--r--gst-libs/gst/audio/gstaudioencoder.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/gst-libs/gst/audio/gstaudioencoder.c b/gst-libs/gst/audio/gstaudioencoder.c
index 17f843aeb..85eb669f6 100644
--- a/gst-libs/gst/audio/gstaudioencoder.c
+++ b/gst-libs/gst/audio/gstaudioencoder.c
@@ -880,6 +880,16 @@ gst_audio_encoder_finish_frame (GstAudioEncoder * enc, GstBuffer * buf,
/* collect output */
if (G_LIKELY (buf)) {
gsize size;
+ GstClockTime timestamp = GST_CLOCK_TIME_NONE;
+
+ if (G_LIKELY (GST_CLOCK_TIME_IS_VALID (priv->base_ts))) {
+ /* FIXME ? lookahead could lead to weird ts and duration ?
+ * (particularly if not in perfect mode) */
+ /* mind sample rounding and produce perfect output */
+ timestamp = priv->base_ts +
+ gst_util_uint64_scale (priv->samples - ctx->lookahead, GST_SECOND,
+ ctx->info.rate);
+ }
/* Pushing headers first */
if (G_UNLIKELY (priv->ctx.new_headers)) {
@@ -893,6 +903,12 @@ gst_audio_encoder_finish_frame (GstAudioEncoder * enc, GstBuffer * buf,
tmpbuf = gst_buffer_make_writable (tmpbuf);
size = gst_buffer_get_size (tmpbuf);
+ /* we timestamp the headers with the same timestamp as the first
+ buffer, and set their duration to 0 */
+ GST_BUFFER_PTS (tmpbuf) = timestamp;
+ GST_BUFFER_DTS (tmpbuf) = timestamp;
+ GST_BUFFER_DURATION (tmpbuf) = 0;
+
if (G_UNLIKELY (priv->discont)) {
GST_LOG_OBJECT (enc, "marking discont");
GST_BUFFER_FLAG_SET (tmpbuf, GST_BUFFER_FLAG_DISCONT);
@@ -923,13 +939,8 @@ gst_audio_encoder_finish_frame (GstAudioEncoder * enc, GstBuffer * buf,
/* decorate */
if (G_LIKELY (GST_CLOCK_TIME_IS_VALID (priv->base_ts))) {
- /* FIXME ? lookahead could lead to weird ts and duration ?
- * (particularly if not in perfect mode) */
- /* mind sample rounding and produce perfect output */
- GST_BUFFER_TIMESTAMP (buf) = priv->base_ts +
- gst_util_uint64_scale (priv->samples - ctx->lookahead, GST_SECOND,
- ctx->info.rate);
- GST_BUFFER_DTS (buf) = GST_BUFFER_TIMESTAMP (buf);
+ GST_BUFFER_PTS (buf) = timestamp;
+ GST_BUFFER_DTS (buf) = timestamp;
GST_DEBUG_OBJECT (enc, "out samples %d", samples);
if (G_LIKELY (samples > 0)) {
priv->samples += samples;