mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-25 01:30:38 +00:00
omxaudioenc: Use correct timestamp, duration and filled length for the EOS buffers
This commit is contained in:
parent
05ad3343bf
commit
064e4c628c
2 changed files with 16 additions and 1 deletions
|
@ -622,6 +622,7 @@ gst_omx_audio_enc_start (GstAudioEncoder * encoder)
|
||||||
|
|
||||||
self = GST_OMX_AUDIO_ENC (encoder);
|
self = GST_OMX_AUDIO_ENC (encoder);
|
||||||
|
|
||||||
|
self->last_upstream_ts = 0;
|
||||||
self->eos = FALSE;
|
self->eos = FALSE;
|
||||||
self->downstream_flow_ret = GST_FLOW_OK;
|
self->downstream_flow_ret = GST_FLOW_OK;
|
||||||
ret =
|
ret =
|
||||||
|
@ -849,6 +850,7 @@ gst_omx_audio_enc_flush (GstAudioEncoder * encoder)
|
||||||
gst_omx_port_set_flushing (self->out_port, FALSE);
|
gst_omx_port_set_flushing (self->out_port, FALSE);
|
||||||
|
|
||||||
/* Start the srcpad loop again */
|
/* Start the srcpad loop again */
|
||||||
|
self->last_upstream_ts = 0;
|
||||||
self->downstream_flow_ret = GST_FLOW_OK;
|
self->downstream_flow_ret = GST_FLOW_OK;
|
||||||
self->eos = FALSE;
|
self->eos = FALSE;
|
||||||
gst_pad_start_task (GST_AUDIO_ENCODER_SRC_PAD (self),
|
gst_pad_start_task (GST_AUDIO_ENCODER_SRC_PAD (self),
|
||||||
|
@ -942,14 +944,15 @@ gst_omx_audio_enc_handle_frame (GstAudioEncoder * encoder, GstBuffer * inbuf)
|
||||||
buf->omx_buf->nTimeStamp =
|
buf->omx_buf->nTimeStamp =
|
||||||
gst_util_uint64_scale (timestamp + timestamp_offset,
|
gst_util_uint64_scale (timestamp + timestamp_offset,
|
||||||
OMX_TICKS_PER_SECOND, GST_SECOND);
|
OMX_TICKS_PER_SECOND, GST_SECOND);
|
||||||
|
self->last_upstream_ts = timestamp + timestamp_offset;
|
||||||
}
|
}
|
||||||
if (duration != GST_CLOCK_TIME_NONE) {
|
if (duration != GST_CLOCK_TIME_NONE) {
|
||||||
buf->omx_buf->nTickCount =
|
buf->omx_buf->nTickCount =
|
||||||
gst_util_uint64_scale (buf->omx_buf->nFilledLen, duration,
|
gst_util_uint64_scale (buf->omx_buf->nFilledLen, duration,
|
||||||
GST_BUFFER_SIZE (inbuf));
|
GST_BUFFER_SIZE (inbuf));
|
||||||
|
self->last_upstream_ts += duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
offset += buf->omx_buf->nFilledLen;
|
offset += buf->omx_buf->nFilledLen;
|
||||||
self->started = TRUE;
|
self->started = TRUE;
|
||||||
gst_omx_port_release_buffer (self->in_port, buf);
|
gst_omx_port_release_buffer (self->in_port, buf);
|
||||||
|
@ -1016,6 +1019,11 @@ gst_omx_audio_enc_event (GstAudioEncoder * encoder, GstEvent * event)
|
||||||
* the EOS buffer arrives on the output port. */
|
* the EOS buffer arrives on the output port. */
|
||||||
acq_ret = gst_omx_port_acquire_buffer (self->in_port, &buf);
|
acq_ret = gst_omx_port_acquire_buffer (self->in_port, &buf);
|
||||||
if (acq_ret == GST_OMX_ACQUIRE_BUFFER_OK) {
|
if (acq_ret == GST_OMX_ACQUIRE_BUFFER_OK) {
|
||||||
|
buf->omx_buf->nFilledLen = 0;
|
||||||
|
buf->omx_buf->nTimeStamp =
|
||||||
|
gst_util_uint64_scale (self->last_upstream_ts, OMX_TICKS_PER_SECOND,
|
||||||
|
GST_SECOND);
|
||||||
|
buf->omx_buf->nTickCount = 0;
|
||||||
buf->omx_buf->nFlags |= OMX_BUFFERFLAG_EOS;
|
buf->omx_buf->nFlags |= OMX_BUFFERFLAG_EOS;
|
||||||
gst_omx_port_release_buffer (self->in_port, buf);
|
gst_omx_port_release_buffer (self->in_port, buf);
|
||||||
GST_DEBUG_OBJECT (self, "Sent EOS to the component");
|
GST_DEBUG_OBJECT (self, "Sent EOS to the component");
|
||||||
|
@ -1069,6 +1077,11 @@ gst_omx_audio_enc_drain (GstOMXAudioEnc * self)
|
||||||
|
|
||||||
g_mutex_lock (self->drain_lock);
|
g_mutex_lock (self->drain_lock);
|
||||||
self->draining = TRUE;
|
self->draining = TRUE;
|
||||||
|
buf->omx_buf->nFilledLen = 0;
|
||||||
|
buf->omx_buf->nTimeStamp =
|
||||||
|
gst_util_uint64_scale (self->last_upstream_ts, OMX_TICKS_PER_SECOND,
|
||||||
|
GST_SECOND);
|
||||||
|
buf->omx_buf->nTickCount = 0;
|
||||||
buf->omx_buf->nFlags |= OMX_BUFFERFLAG_EOS;
|
buf->omx_buf->nFlags |= OMX_BUFFERFLAG_EOS;
|
||||||
gst_omx_port_release_buffer (self->in_port, buf);
|
gst_omx_port_release_buffer (self->in_port, buf);
|
||||||
GST_DEBUG_OBJECT (self, "Waiting until component is drained");
|
GST_DEBUG_OBJECT (self, "Waiting until component is drained");
|
||||||
|
|
|
@ -58,6 +58,8 @@ struct _GstOMXAudioEnc
|
||||||
* the first buffer */
|
* the first buffer */
|
||||||
gboolean started;
|
gboolean started;
|
||||||
|
|
||||||
|
GstClockTime last_upstream_ts;
|
||||||
|
|
||||||
/* TRUE if upstream is EOS */
|
/* TRUE if upstream is EOS */
|
||||||
gboolean eos;
|
gboolean eos;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue