mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
audio: Use GST_BUFFER_PTS instead of deprecated GST_BUFFER_TIMESTAMP
GST_BUFFER_PTS already used in audio code base (e.g. gstaudiodecoder), so migrate completely from deprecated GST_BUFFER_TIMESTAMP for better readability, as gstcompat.h defines GST_BUFFER_TIMESTAMP directly to PTS anyway. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/1048>
This commit is contained in:
parent
f5381ba9f5
commit
e99a6f3142
6 changed files with 46 additions and 47 deletions
|
@ -91,7 +91,7 @@ gst_audio_buffer_clip (GstBuffer * buffer, const GstSegment * segment,
|
||||||
segment->format == GST_FORMAT_DEFAULT, buffer);
|
segment->format == GST_FORMAT_DEFAULT, buffer);
|
||||||
g_return_val_if_fail (GST_IS_BUFFER (buffer), NULL);
|
g_return_val_if_fail (GST_IS_BUFFER (buffer), NULL);
|
||||||
|
|
||||||
if (!GST_BUFFER_TIMESTAMP_IS_VALID (buffer))
|
if (!GST_BUFFER_PTS_IS_VALID (buffer))
|
||||||
/* No timestamp - assume the buffer is completely in the segment */
|
/* No timestamp - assume the buffer is completely in the segment */
|
||||||
return buffer;
|
return buffer;
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ gst_audio_buffer_clip (GstBuffer * buffer, const GstSegment * segment,
|
||||||
if (!size)
|
if (!size)
|
||||||
return buffer;
|
return buffer;
|
||||||
|
|
||||||
timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
timestamp = GST_BUFFER_PTS (buffer);
|
||||||
GST_DEBUG ("timestamp %" GST_TIME_FORMAT, GST_TIME_ARGS (timestamp));
|
GST_DEBUG ("timestamp %" GST_TIME_FORMAT, GST_TIME_ARGS (timestamp));
|
||||||
if (GST_BUFFER_DURATION_IS_VALID (buffer)) {
|
if (GST_BUFFER_DURATION_IS_VALID (buffer)) {
|
||||||
duration = GST_BUFFER_DURATION (buffer);
|
duration = GST_BUFFER_DURATION (buffer);
|
||||||
|
@ -214,9 +214,9 @@ gst_audio_buffer_clip (GstBuffer * buffer, const GstSegment * segment,
|
||||||
if (trim == 0 && size == osize) {
|
if (trim == 0 && size == osize) {
|
||||||
ret = buffer;
|
ret = buffer;
|
||||||
|
|
||||||
if (GST_BUFFER_TIMESTAMP (ret) != timestamp) {
|
if (GST_BUFFER_PTS (ret) != timestamp) {
|
||||||
ret = gst_buffer_make_writable (ret);
|
ret = gst_buffer_make_writable (ret);
|
||||||
GST_BUFFER_TIMESTAMP (ret) = timestamp;
|
GST_BUFFER_PTS (ret) = timestamp;
|
||||||
}
|
}
|
||||||
if (GST_BUFFER_DURATION (ret) != duration) {
|
if (GST_BUFFER_DURATION (ret) != duration) {
|
||||||
ret = gst_buffer_make_writable (ret);
|
ret = gst_buffer_make_writable (ret);
|
||||||
|
@ -229,7 +229,7 @@ gst_audio_buffer_clip (GstBuffer * buffer, const GstSegment * segment,
|
||||||
|
|
||||||
GST_DEBUG ("timestamp %" GST_TIME_FORMAT, GST_TIME_ARGS (timestamp));
|
GST_DEBUG ("timestamp %" GST_TIME_FORMAT, GST_TIME_ARGS (timestamp));
|
||||||
if (ret) {
|
if (ret) {
|
||||||
GST_BUFFER_TIMESTAMP (ret) = timestamp;
|
GST_BUFFER_PTS (ret) = timestamp;
|
||||||
|
|
||||||
if (change_duration)
|
if (change_duration)
|
||||||
GST_BUFFER_DURATION (ret) = duration;
|
GST_BUFFER_DURATION (ret) = duration;
|
||||||
|
|
|
@ -1864,7 +1864,7 @@ gst_audio_base_sink_render (GstBaseSink * bsink, GstBuffer * buf)
|
||||||
|
|
||||||
samples = size / bpf;
|
samples = size / bpf;
|
||||||
|
|
||||||
time = GST_BUFFER_TIMESTAMP (buf);
|
time = GST_BUFFER_PTS (buf);
|
||||||
|
|
||||||
/* Last ditch attempt to ensure that we only play silence if
|
/* Last ditch attempt to ensure that we only play silence if
|
||||||
* we are in trickmode no-audio mode (or if a buffer is marked as a GAP)
|
* we are in trickmode no-audio mode (or if a buffer is marked as a GAP)
|
||||||
|
|
|
@ -1027,7 +1027,7 @@ gst_audio_base_src_create (GstBaseSrc * bsrc, guint64 offset, guint length,
|
||||||
no_sync:
|
no_sync:
|
||||||
GST_OBJECT_UNLOCK (src);
|
GST_OBJECT_UNLOCK (src);
|
||||||
|
|
||||||
GST_BUFFER_TIMESTAMP (buf) = timestamp;
|
GST_BUFFER_PTS (buf) = timestamp;
|
||||||
GST_BUFFER_DURATION (buf) = duration;
|
GST_BUFFER_DURATION (buf) = duration;
|
||||||
GST_BUFFER_OFFSET (buf) = sample;
|
GST_BUFFER_OFFSET (buf) = sample;
|
||||||
GST_BUFFER_OFFSET_END (buf) = sample + samples;
|
GST_BUFFER_OFFSET_END (buf) = sample + samples;
|
||||||
|
@ -1035,7 +1035,7 @@ no_sync:
|
||||||
*outbuf = buf;
|
*outbuf = buf;
|
||||||
|
|
||||||
GST_LOG_OBJECT (src, "Pushed buffer timestamp %" GST_TIME_FORMAT,
|
GST_LOG_OBJECT (src, "Pushed buffer timestamp %" GST_TIME_FORMAT,
|
||||||
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)));
|
GST_TIME_ARGS (GST_BUFFER_PTS (buf)));
|
||||||
|
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
|
|
||||||
|
|
|
@ -1764,7 +1764,7 @@ gst_audio_cd_src_create (GstPushSrc * pushsrc, GstBuffer ** buffer)
|
||||||
GST_SECOND, 44100);
|
GST_SECOND, 44100);
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_BUFFER_TIMESTAMP (buf) = position;
|
GST_BUFFER_PTS (buf) = position;
|
||||||
GST_BUFFER_DURATION (buf) = duration;
|
GST_BUFFER_DURATION (buf) = duration;
|
||||||
|
|
||||||
GST_LOG_OBJECT (src, "pushing sector %d with timestamp %" GST_TIME_FORMAT,
|
GST_LOG_OBJECT (src, "pushing sector %d with timestamp %" GST_TIME_FORMAT,
|
||||||
|
|
|
@ -978,12 +978,12 @@ gst_audio_decoder_push_forward (GstAudioDecoder * dec, GstBuffer * buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->had_output_data = TRUE;
|
ctx->had_output_data = TRUE;
|
||||||
ts = GST_BUFFER_TIMESTAMP (buf);
|
ts = GST_BUFFER_PTS (buf);
|
||||||
|
|
||||||
GST_LOG_OBJECT (dec,
|
GST_LOG_OBJECT (dec,
|
||||||
"clipping buffer of size %" G_GSIZE_FORMAT " with ts %" GST_TIME_FORMAT
|
"clipping buffer of size %" G_GSIZE_FORMAT " with ts %" GST_TIME_FORMAT
|
||||||
", duration %" GST_TIME_FORMAT, gst_buffer_get_size (buf),
|
", duration %" GST_TIME_FORMAT, gst_buffer_get_size (buf),
|
||||||
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),
|
GST_TIME_ARGS (GST_BUFFER_PTS (buf)),
|
||||||
GST_TIME_ARGS (GST_BUFFER_DURATION (buf)));
|
GST_TIME_ARGS (GST_BUFFER_DURATION (buf)));
|
||||||
|
|
||||||
/* clip buffer */
|
/* clip buffer */
|
||||||
|
@ -1012,11 +1012,11 @@ gst_audio_decoder_push_forward (GstAudioDecoder * dec, GstBuffer * buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* track where we are */
|
/* track where we are */
|
||||||
if (G_LIKELY (GST_BUFFER_TIMESTAMP_IS_VALID (buf))) {
|
if (G_LIKELY (GST_BUFFER_PTS_IS_VALID (buf))) {
|
||||||
/* duration should always be valid for raw audio */
|
/* duration should always be valid for raw audio */
|
||||||
g_assert (GST_BUFFER_DURATION_IS_VALID (buf));
|
g_assert (GST_BUFFER_DURATION_IS_VALID (buf));
|
||||||
dec->output_segment.position =
|
dec->output_segment.position =
|
||||||
GST_BUFFER_TIMESTAMP (buf) + GST_BUFFER_DURATION (buf);
|
GST_BUFFER_PTS (buf) + GST_BUFFER_DURATION (buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (klass->pre_push) {
|
if (klass->pre_push) {
|
||||||
|
@ -1034,7 +1034,7 @@ gst_audio_decoder_push_forward (GstAudioDecoder * dec, GstBuffer * buf)
|
||||||
GST_LOG_OBJECT (dec,
|
GST_LOG_OBJECT (dec,
|
||||||
"pushing buffer of size %" G_GSIZE_FORMAT " with ts %" GST_TIME_FORMAT
|
"pushing buffer of size %" G_GSIZE_FORMAT " with ts %" GST_TIME_FORMAT
|
||||||
", duration %" GST_TIME_FORMAT, gst_buffer_get_size (buf),
|
", duration %" GST_TIME_FORMAT, gst_buffer_get_size (buf),
|
||||||
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),
|
GST_TIME_ARGS (GST_BUFFER_PTS (buf)),
|
||||||
GST_TIME_ARGS (GST_BUFFER_DURATION (buf)));
|
GST_TIME_ARGS (GST_BUFFER_DURATION (buf)));
|
||||||
|
|
||||||
ret = gst_pad_push (dec->srcpad, buf);
|
ret = gst_pad_push (dec->srcpad, buf);
|
||||||
|
@ -1061,7 +1061,7 @@ gst_audio_decoder_output (GstAudioDecoder * dec, GstBuffer * buf)
|
||||||
GST_LOG_OBJECT (dec,
|
GST_LOG_OBJECT (dec,
|
||||||
"output buffer of size %" G_GSIZE_FORMAT " with ts %" GST_TIME_FORMAT
|
"output buffer of size %" G_GSIZE_FORMAT " with ts %" GST_TIME_FORMAT
|
||||||
", duration %" GST_TIME_FORMAT, gst_buffer_get_size (buf),
|
", duration %" GST_TIME_FORMAT, gst_buffer_get_size (buf),
|
||||||
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),
|
GST_TIME_ARGS (GST_BUFFER_PTS (buf)),
|
||||||
GST_TIME_ARGS (GST_BUFFER_DURATION (buf)));
|
GST_TIME_ARGS (GST_BUFFER_DURATION (buf)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1079,9 +1079,9 @@ again:
|
||||||
/* forcibly send current */
|
/* forcibly send current */
|
||||||
assemble = TRUE;
|
assemble = TRUE;
|
||||||
GST_LOG_OBJECT (dec, "forcing fragment flush");
|
GST_LOG_OBJECT (dec, "forcing fragment flush");
|
||||||
} else if (av && (!GST_BUFFER_TIMESTAMP_IS_VALID (buf) ||
|
} else if (av && (!GST_BUFFER_PTS_IS_VALID (buf) ||
|
||||||
!GST_CLOCK_TIME_IS_VALID (priv->out_ts) ||
|
!GST_CLOCK_TIME_IS_VALID (priv->out_ts) ||
|
||||||
((diff = GST_CLOCK_DIFF (GST_BUFFER_TIMESTAMP (buf),
|
((diff = GST_CLOCK_DIFF (GST_BUFFER_PTS (buf),
|
||||||
priv->out_ts + priv->out_dur)) > tol) || diff < -tol)) {
|
priv->out_ts + priv->out_dur)) > tol) || diff < -tol)) {
|
||||||
assemble = TRUE;
|
assemble = TRUE;
|
||||||
GST_LOG_OBJECT (dec, "buffer %d ms apart from current fragment",
|
GST_LOG_OBJECT (dec, "buffer %d ms apart from current fragment",
|
||||||
|
@ -1090,7 +1090,7 @@ again:
|
||||||
/* add or start collecting */
|
/* add or start collecting */
|
||||||
if (!av) {
|
if (!av) {
|
||||||
GST_LOG_OBJECT (dec, "starting new fragment");
|
GST_LOG_OBJECT (dec, "starting new fragment");
|
||||||
priv->out_ts = GST_BUFFER_TIMESTAMP (buf);
|
priv->out_ts = GST_BUFFER_PTS (buf);
|
||||||
} else {
|
} else {
|
||||||
GST_LOG_OBJECT (dec, "adding to fragment");
|
GST_LOG_OBJECT (dec, "adding to fragment");
|
||||||
}
|
}
|
||||||
|
@ -1105,7 +1105,7 @@ again:
|
||||||
GST_LOG_OBJECT (dec, "assembling fragment");
|
GST_LOG_OBJECT (dec, "assembling fragment");
|
||||||
inbuf = buf;
|
inbuf = buf;
|
||||||
buf = gst_adapter_take_buffer (priv->adapter_out, av);
|
buf = gst_adapter_take_buffer (priv->adapter_out, av);
|
||||||
GST_BUFFER_TIMESTAMP (buf) = priv->out_ts;
|
GST_BUFFER_PTS (buf) = priv->out_ts;
|
||||||
GST_BUFFER_DURATION (buf) = priv->out_dur;
|
GST_BUFFER_DURATION (buf) = priv->out_dur;
|
||||||
priv->out_ts = GST_CLOCK_TIME_NONE;
|
priv->out_ts = GST_CLOCK_TIME_NONE;
|
||||||
priv->out_dur = 0;
|
priv->out_dur = 0;
|
||||||
|
@ -1420,7 +1420,7 @@ gst_audio_decoder_finish_frame_or_subframe (GstAudioDecoder * dec,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (G_LIKELY (priv->frames.length))
|
if (G_LIKELY (priv->frames.length))
|
||||||
ts = GST_BUFFER_TIMESTAMP (priv->frames.head->data);
|
ts = GST_BUFFER_PTS (priv->frames.head->data);
|
||||||
else
|
else
|
||||||
ts = GST_CLOCK_TIME_NONE;
|
ts = GST_CLOCK_TIME_NONE;
|
||||||
|
|
||||||
|
@ -1499,14 +1499,14 @@ gst_audio_decoder_finish_frame_or_subframe (GstAudioDecoder * dec,
|
||||||
|
|
||||||
buf = gst_buffer_make_writable (buf);
|
buf = gst_buffer_make_writable (buf);
|
||||||
if (G_LIKELY (GST_CLOCK_TIME_IS_VALID (priv->base_ts))) {
|
if (G_LIKELY (GST_CLOCK_TIME_IS_VALID (priv->base_ts))) {
|
||||||
GST_BUFFER_TIMESTAMP (buf) =
|
GST_BUFFER_PTS (buf) =
|
||||||
priv->base_ts +
|
priv->base_ts +
|
||||||
GST_FRAMES_TO_CLOCK_TIME (priv->samples, ctx->info.rate);
|
GST_FRAMES_TO_CLOCK_TIME (priv->samples, ctx->info.rate);
|
||||||
GST_BUFFER_DURATION (buf) = priv->base_ts +
|
GST_BUFFER_DURATION (buf) = priv->base_ts +
|
||||||
GST_FRAMES_TO_CLOCK_TIME (priv->samples + samples, ctx->info.rate) -
|
GST_FRAMES_TO_CLOCK_TIME (priv->samples + samples, ctx->info.rate) -
|
||||||
GST_BUFFER_TIMESTAMP (buf);
|
GST_BUFFER_PTS (buf);
|
||||||
} else {
|
} else {
|
||||||
GST_BUFFER_TIMESTAMP (buf) = GST_CLOCK_TIME_NONE;
|
GST_BUFFER_PTS (buf) = GST_CLOCK_TIME_NONE;
|
||||||
GST_BUFFER_DURATION (buf) =
|
GST_BUFFER_DURATION (buf) =
|
||||||
GST_FRAMES_TO_CLOCK_TIME (samples, ctx->info.rate);
|
GST_FRAMES_TO_CLOCK_TIME (samples, ctx->info.rate);
|
||||||
}
|
}
|
||||||
|
@ -1624,7 +1624,7 @@ gst_audio_decoder_handle_frame (GstAudioDecoder * dec,
|
||||||
/* keep around for admin */
|
/* keep around for admin */
|
||||||
GST_LOG_OBJECT (dec,
|
GST_LOG_OBJECT (dec,
|
||||||
"tracking frame size %" G_GSIZE_FORMAT ", ts %" GST_TIME_FORMAT, size,
|
"tracking frame size %" G_GSIZE_FORMAT ", ts %" GST_TIME_FORMAT, size,
|
||||||
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)));
|
GST_TIME_ARGS (GST_BUFFER_PTS (buffer)));
|
||||||
g_queue_push_tail (&dec->priv->frames, buffer);
|
g_queue_push_tail (&dec->priv->frames, buffer);
|
||||||
dec->priv->ctx.delay = dec->priv->frames.length;
|
dec->priv->ctx.delay = dec->priv->frames.length;
|
||||||
GST_OBJECT_LOCK (dec);
|
GST_OBJECT_LOCK (dec);
|
||||||
|
@ -1718,7 +1718,7 @@ gst_audio_decoder_push_buffers (GstAudioDecoder * dec, gboolean force)
|
||||||
}
|
}
|
||||||
buffer = gst_adapter_take_buffer (priv->adapter, len);
|
buffer = gst_adapter_take_buffer (priv->adapter, len);
|
||||||
buffer = gst_buffer_make_writable (buffer);
|
buffer = gst_buffer_make_writable (buffer);
|
||||||
GST_BUFFER_TIMESTAMP (buffer) = ts;
|
GST_BUFFER_PTS (buffer) = ts;
|
||||||
flush += len;
|
flush += len;
|
||||||
priv->force = FALSE;
|
priv->force = FALSE;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1952,7 +1952,7 @@ gst_audio_decoder_flush_decode (GstAudioDecoder * dec)
|
||||||
GstBuffer *buf = GST_BUFFER_CAST (walk->data);
|
GstBuffer *buf = GST_BUFFER_CAST (walk->data);
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (dec, "decoding buffer %p, ts %" GST_TIME_FORMAT,
|
GST_DEBUG_OBJECT (dec, "decoding buffer %p, ts %" GST_TIME_FORMAT,
|
||||||
buf, GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)));
|
buf, GST_TIME_ARGS (GST_BUFFER_PTS (buf)));
|
||||||
|
|
||||||
next = g_list_next (walk);
|
next = g_list_next (walk);
|
||||||
/* decode buffer, resulting data prepended to output queue */
|
/* decode buffer, resulting data prepended to output queue */
|
||||||
|
@ -1993,13 +1993,13 @@ gst_audio_decoder_flush_decode (GstAudioDecoder * dec)
|
||||||
timestamp = 0;
|
timestamp = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!GST_BUFFER_TIMESTAMP_IS_VALID (buf)) {
|
if (!GST_BUFFER_PTS_IS_VALID (buf)) {
|
||||||
GST_LOG_OBJECT (dec, "applying reverse interpolated ts %"
|
GST_LOG_OBJECT (dec, "applying reverse interpolated ts %"
|
||||||
GST_TIME_FORMAT, GST_TIME_ARGS (timestamp));
|
GST_TIME_FORMAT, GST_TIME_ARGS (timestamp));
|
||||||
GST_BUFFER_TIMESTAMP (buf) = timestamp;
|
GST_BUFFER_PTS (buf) = timestamp;
|
||||||
} else {
|
} else {
|
||||||
/* track otherwise */
|
/* track otherwise */
|
||||||
timestamp = GST_BUFFER_TIMESTAMP (buf);
|
timestamp = GST_BUFFER_PTS (buf);
|
||||||
GST_LOG_OBJECT (dec, "tracking ts %" GST_TIME_FORMAT,
|
GST_LOG_OBJECT (dec, "tracking ts %" GST_TIME_FORMAT,
|
||||||
GST_TIME_ARGS (timestamp));
|
GST_TIME_ARGS (timestamp));
|
||||||
}
|
}
|
||||||
|
@ -2007,7 +2007,7 @@ gst_audio_decoder_flush_decode (GstAudioDecoder * dec)
|
||||||
if (G_LIKELY (res == GST_FLOW_OK)) {
|
if (G_LIKELY (res == GST_FLOW_OK)) {
|
||||||
GST_DEBUG_OBJECT (dec, "pushing buffer %p of size %" G_GSIZE_FORMAT ", "
|
GST_DEBUG_OBJECT (dec, "pushing buffer %p of size %" G_GSIZE_FORMAT ", "
|
||||||
"time %" GST_TIME_FORMAT ", dur %" GST_TIME_FORMAT, buf,
|
"time %" GST_TIME_FORMAT ", dur %" GST_TIME_FORMAT, buf,
|
||||||
gst_buffer_get_size (buf), GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),
|
gst_buffer_get_size (buf), GST_TIME_ARGS (GST_BUFFER_PTS (buf)),
|
||||||
GST_TIME_ARGS (GST_BUFFER_DURATION (buf)));
|
GST_TIME_ARGS (GST_BUFFER_DURATION (buf)));
|
||||||
/* should be already, but let's be sure */
|
/* should be already, but let's be sure */
|
||||||
buf = gst_buffer_make_writable (buf);
|
buf = gst_buffer_make_writable (buf);
|
||||||
|
@ -2050,7 +2050,7 @@ gst_audio_decoder_chain_reverse (GstAudioDecoder * dec, GstBuffer * buf)
|
||||||
if (G_LIKELY (buf)) {
|
if (G_LIKELY (buf)) {
|
||||||
GST_DEBUG_OBJECT (dec, "gathering buffer %p of size %" G_GSIZE_FORMAT ", "
|
GST_DEBUG_OBJECT (dec, "gathering buffer %p of size %" G_GSIZE_FORMAT ", "
|
||||||
"time %" GST_TIME_FORMAT ", dur %" GST_TIME_FORMAT, buf,
|
"time %" GST_TIME_FORMAT ", dur %" GST_TIME_FORMAT, buf,
|
||||||
gst_buffer_get_size (buf), GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),
|
gst_buffer_get_size (buf), GST_TIME_ARGS (GST_BUFFER_PTS (buf)),
|
||||||
GST_TIME_ARGS (GST_BUFFER_DURATION (buf)));
|
GST_TIME_ARGS (GST_BUFFER_DURATION (buf)));
|
||||||
|
|
||||||
/* add buffer to gather queue */
|
/* add buffer to gather queue */
|
||||||
|
@ -2071,7 +2071,7 @@ gst_audio_decoder_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
||||||
GST_LOG_OBJECT (dec,
|
GST_LOG_OBJECT (dec,
|
||||||
"received buffer of size %" G_GSIZE_FORMAT " with ts %" GST_TIME_FORMAT
|
"received buffer of size %" G_GSIZE_FORMAT " with ts %" GST_TIME_FORMAT
|
||||||
", duration %" GST_TIME_FORMAT, gst_buffer_get_size (buffer),
|
", duration %" GST_TIME_FORMAT, gst_buffer_get_size (buffer),
|
||||||
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)),
|
GST_TIME_ARGS (GST_BUFFER_PTS (buffer)),
|
||||||
GST_TIME_ARGS (GST_BUFFER_DURATION (buffer)));
|
GST_TIME_ARGS (GST_BUFFER_DURATION (buffer)));
|
||||||
|
|
||||||
GST_AUDIO_DECODER_STREAM_LOCK (dec);
|
GST_AUDIO_DECODER_STREAM_LOCK (dec);
|
||||||
|
@ -2096,8 +2096,7 @@ gst_audio_decoder_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
||||||
/* buffer may claim DISCONT loudly, if it can't tell us where we are now,
|
/* buffer may claim DISCONT loudly, if it can't tell us where we are now,
|
||||||
* we'll stick to where we were ...
|
* we'll stick to where we were ...
|
||||||
* Particularly useful/needed for upstream BYTE based */
|
* Particularly useful/needed for upstream BYTE based */
|
||||||
if (dec->input_segment.rate > 0.0
|
if (dec->input_segment.rate > 0.0 && !GST_BUFFER_PTS_IS_VALID (buffer)) {
|
||||||
&& !GST_BUFFER_TIMESTAMP_IS_VALID (buffer)) {
|
|
||||||
GST_DEBUG_OBJECT (dec, "... but restoring previous ts tracking");
|
GST_DEBUG_OBJECT (dec, "... but restoring previous ts tracking");
|
||||||
dec->priv->base_ts = ts;
|
dec->priv->base_ts = ts;
|
||||||
dec->priv->samples = samples;
|
dec->priv->samples = samples;
|
||||||
|
@ -2293,7 +2292,7 @@ gst_audio_decoder_handle_gap (GstAudioDecoder * dec, GstEvent * event)
|
||||||
|
|
||||||
/* hand subclass empty frame with duration that needs covering */
|
/* hand subclass empty frame with duration that needs covering */
|
||||||
buf = gst_buffer_new ();
|
buf = gst_buffer_new ();
|
||||||
GST_BUFFER_TIMESTAMP (buf) = timestamp;
|
GST_BUFFER_PTS (buf) = timestamp;
|
||||||
GST_BUFFER_DURATION (buf) = duration;
|
GST_BUFFER_DURATION (buf) = duration;
|
||||||
/* best effort, not much error handling */
|
/* best effort, not much error handling */
|
||||||
gst_audio_decoder_handle_frame (dec, klass, buf);
|
gst_audio_decoder_handle_frame (dec, klass, buf);
|
||||||
|
|
|
@ -937,16 +937,16 @@ gst_audio_encoder_finish_frame (GstAudioEncoder * enc, GstBuffer * buf,
|
||||||
/* FIXME ? lookahead could lead to weird ts and duration ?
|
/* FIXME ? lookahead could lead to weird ts and duration ?
|
||||||
* (particularly if not in perfect mode) */
|
* (particularly if not in perfect mode) */
|
||||||
/* mind sample rounding and produce perfect output */
|
/* mind sample rounding and produce perfect output */
|
||||||
GST_BUFFER_TIMESTAMP (buf) = priv->base_ts +
|
GST_BUFFER_PTS (buf) = priv->base_ts +
|
||||||
gst_util_uint64_scale (priv->samples - ctx->lookahead, GST_SECOND,
|
gst_util_uint64_scale (priv->samples - ctx->lookahead, GST_SECOND,
|
||||||
ctx->info.rate);
|
ctx->info.rate);
|
||||||
GST_BUFFER_DTS (buf) = GST_BUFFER_TIMESTAMP (buf);
|
GST_BUFFER_DTS (buf) = GST_BUFFER_PTS (buf);
|
||||||
GST_DEBUG_OBJECT (enc, "out samples %d", samples);
|
GST_DEBUG_OBJECT (enc, "out samples %d", samples);
|
||||||
if (G_LIKELY (samples > 0)) {
|
if (G_LIKELY (samples > 0)) {
|
||||||
priv->samples += samples;
|
priv->samples += samples;
|
||||||
GST_BUFFER_DURATION (buf) = priv->base_ts +
|
GST_BUFFER_DURATION (buf) = priv->base_ts +
|
||||||
gst_util_uint64_scale (priv->samples - ctx->lookahead, GST_SECOND,
|
gst_util_uint64_scale (priv->samples - ctx->lookahead, GST_SECOND,
|
||||||
ctx->info.rate) - GST_BUFFER_TIMESTAMP (buf);
|
ctx->info.rate) - GST_BUFFER_PTS (buf);
|
||||||
priv->last_duration = GST_BUFFER_DURATION (buf);
|
priv->last_duration = GST_BUFFER_DURATION (buf);
|
||||||
} else {
|
} else {
|
||||||
/* duration forecast in case of handling remainder;
|
/* duration forecast in case of handling remainder;
|
||||||
|
@ -1008,7 +1008,7 @@ gst_audio_encoder_finish_frame (GstAudioEncoder * enc, GstBuffer * buf,
|
||||||
GST_LOG_OBJECT (enc,
|
GST_LOG_OBJECT (enc,
|
||||||
"pushing buffer of size %" G_GSIZE_FORMAT " with ts %" GST_TIME_FORMAT
|
"pushing buffer of size %" G_GSIZE_FORMAT " with ts %" GST_TIME_FORMAT
|
||||||
", duration %" GST_TIME_FORMAT, size,
|
", duration %" GST_TIME_FORMAT, size,
|
||||||
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),
|
GST_TIME_ARGS (GST_BUFFER_PTS (buf)),
|
||||||
GST_TIME_ARGS (GST_BUFFER_DURATION (buf)));
|
GST_TIME_ARGS (GST_BUFFER_DURATION (buf)));
|
||||||
|
|
||||||
ret = gst_pad_push (enc->srcpad, buf);
|
ret = gst_pad_push (enc->srcpad, buf);
|
||||||
|
@ -1236,7 +1236,7 @@ gst_audio_encoder_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
||||||
GST_LOG_OBJECT (enc,
|
GST_LOG_OBJECT (enc,
|
||||||
"received buffer of size %" G_GSIZE_FORMAT " with ts %" GST_TIME_FORMAT
|
"received buffer of size %" G_GSIZE_FORMAT " with ts %" GST_TIME_FORMAT
|
||||||
", duration %" GST_TIME_FORMAT, size,
|
", duration %" GST_TIME_FORMAT, size,
|
||||||
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)),
|
GST_TIME_ARGS (GST_BUFFER_PTS (buffer)),
|
||||||
GST_TIME_ARGS (GST_BUFFER_DURATION (buffer)));
|
GST_TIME_ARGS (GST_BUFFER_DURATION (buffer)));
|
||||||
|
|
||||||
/* input should be whole number of sample frames */
|
/* input should be whole number of sample frames */
|
||||||
|
@ -1282,11 +1282,11 @@ gst_audio_encoder_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
||||||
GST_LOG_OBJECT (enc,
|
GST_LOG_OBJECT (enc,
|
||||||
"buffer after segment clipping has size %" G_GSIZE_FORMAT " with ts %"
|
"buffer after segment clipping has size %" G_GSIZE_FORMAT " with ts %"
|
||||||
GST_TIME_FORMAT ", duration %" GST_TIME_FORMAT, size,
|
GST_TIME_FORMAT ", duration %" GST_TIME_FORMAT, size,
|
||||||
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)),
|
GST_TIME_ARGS (GST_BUFFER_PTS (buffer)),
|
||||||
GST_TIME_ARGS (GST_BUFFER_DURATION (buffer)));
|
GST_TIME_ARGS (GST_BUFFER_DURATION (buffer)));
|
||||||
|
|
||||||
if (!GST_CLOCK_TIME_IS_VALID (priv->base_ts)) {
|
if (!GST_CLOCK_TIME_IS_VALID (priv->base_ts)) {
|
||||||
priv->base_ts = GST_BUFFER_TIMESTAMP (buffer);
|
priv->base_ts = GST_BUFFER_PTS (buffer);
|
||||||
GST_DEBUG_OBJECT (enc, "new base ts %" GST_TIME_FORMAT,
|
GST_DEBUG_OBJECT (enc, "new base ts %" GST_TIME_FORMAT,
|
||||||
GST_TIME_ARGS (priv->base_ts));
|
GST_TIME_ARGS (priv->base_ts));
|
||||||
gst_audio_encoder_set_base_gp (enc);
|
gst_audio_encoder_set_base_gp (enc);
|
||||||
|
@ -1298,7 +1298,7 @@ gst_audio_encoder_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
||||||
GstClockTimeDiff diff = 0;
|
GstClockTimeDiff diff = 0;
|
||||||
GstClockTime next_ts = 0;
|
GstClockTime next_ts = 0;
|
||||||
|
|
||||||
if (GST_BUFFER_TIMESTAMP_IS_VALID (buffer) &&
|
if (GST_BUFFER_PTS_IS_VALID (buffer) &&
|
||||||
GST_CLOCK_TIME_IS_VALID (priv->base_ts)) {
|
GST_CLOCK_TIME_IS_VALID (priv->base_ts)) {
|
||||||
guint64 samples;
|
guint64 samples;
|
||||||
|
|
||||||
|
@ -1310,7 +1310,7 @@ gst_audio_encoder_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
||||||
" samples past base_ts %" GST_TIME_FORMAT
|
" samples past base_ts %" GST_TIME_FORMAT
|
||||||
", expected ts %" GST_TIME_FORMAT, samples,
|
", expected ts %" GST_TIME_FORMAT, samples,
|
||||||
GST_TIME_ARGS (priv->base_ts), GST_TIME_ARGS (next_ts));
|
GST_TIME_ARGS (priv->base_ts), GST_TIME_ARGS (next_ts));
|
||||||
diff = GST_CLOCK_DIFF (next_ts, GST_BUFFER_TIMESTAMP (buffer));
|
diff = GST_CLOCK_DIFF (next_ts, GST_BUFFER_PTS (buffer));
|
||||||
GST_LOG_OBJECT (enc, "ts diff %d ms", (gint) (diff / GST_MSECOND));
|
GST_LOG_OBJECT (enc, "ts diff %d ms", (gint) (diff / GST_MSECOND));
|
||||||
/* if within tolerance,
|
/* if within tolerance,
|
||||||
* discard buffer ts and carry on producing perfect stream,
|
* discard buffer ts and carry on producing perfect stream,
|
||||||
|
@ -1339,7 +1339,7 @@ gst_audio_encoder_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
||||||
buffer = gst_buffer_make_writable (buffer);
|
buffer = gst_buffer_make_writable (buffer);
|
||||||
gst_buffer_resize (buffer, diff_bytes, size - diff_bytes);
|
gst_buffer_resize (buffer, diff_bytes, size - diff_bytes);
|
||||||
|
|
||||||
GST_BUFFER_TIMESTAMP (buffer) += diff;
|
GST_BUFFER_PTS (buffer) += diff;
|
||||||
/* care even less about duration after this */
|
/* care even less about duration after this */
|
||||||
} else {
|
} else {
|
||||||
/* drain stuff prior to resync */
|
/* drain stuff prior to resync */
|
||||||
|
@ -1352,13 +1352,13 @@ gst_audio_encoder_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
||||||
gst_util_uint64_scale (gst_adapter_available (priv->adapter),
|
gst_util_uint64_scale (gst_adapter_available (priv->adapter),
|
||||||
GST_SECOND, ctx->info.rate * ctx->info.bpf);
|
GST_SECOND, ctx->info.rate * ctx->info.bpf);
|
||||||
|
|
||||||
if (G_UNLIKELY (shift > GST_BUFFER_TIMESTAMP (buffer))) {
|
if (G_UNLIKELY (shift > GST_BUFFER_PTS (buffer))) {
|
||||||
/* ERROR */
|
/* ERROR */
|
||||||
goto wrong_time;
|
goto wrong_time;
|
||||||
}
|
}
|
||||||
/* arrange for newly added samples to come out with the ts
|
/* arrange for newly added samples to come out with the ts
|
||||||
* of the incoming buffer that adds these */
|
* of the incoming buffer that adds these */
|
||||||
priv->base_ts = GST_BUFFER_TIMESTAMP (buffer) - shift;
|
priv->base_ts = GST_BUFFER_PTS (buffer) - shift;
|
||||||
priv->samples = 0;
|
priv->samples = 0;
|
||||||
gst_audio_encoder_set_base_gp (enc);
|
gst_audio_encoder_set_base_gp (enc);
|
||||||
priv->discont |= discont;
|
priv->discont |= discont;
|
||||||
|
|
Loading…
Reference in a new issue