const gchar *profile;
profile =
- gst_amc_mpeg4_profile_to_string (type->
- profile_levels[j].profile);
+ gst_amc_mpeg4_profile_to_string (type->profile_levels[j].
+ profile);
if (!profile) {
GST_ERROR ("Unable to map MPEG4 profile 0x%08x",
type->profile_levels[j].profile);
gint profile;
profile =
- gst_amc_h263_profile_to_gst_id (type->
- profile_levels[j].profile);
+ gst_amc_h263_profile_to_gst_id (type->profile_levels[j].
+ profile);
if (profile == -1) {
GST_ERROR ("Unable to map h263 profile 0x%08x",
const gchar *profile, *alternative = NULL;
profile =
- gst_amc_avc_profile_to_string (type->
- profile_levels[j].profile, &alternative);
+ gst_amc_avc_profile_to_string (type->profile_levels[j].
+ profile, &alternative);
if (!profile) {
GST_ERROR ("Unable to map H264 profile 0x%08x",
guint32 gst_amc_audio_channel_mask_from_positions (GstAudioChannelPosition *positions, gint channels);
void gst_amc_codec_info_to_caps (const GstAmcCodecInfo * codec_info, GstCaps **sink_caps, GstCaps **src_caps);
+#define GST_ELEMENT_ERROR_FROM_ERROR(el, err) G_STMT_START { \
+ gchar *__dbg = g_strdup (err->message); \
+ GST_WARNING_OBJECT (el, "error: %s", __dbg); \
+ gst_element_message_full (GST_ELEMENT(el), GST_MESSAGE_ERROR, \
+ err->domain, err->code, \
+ NULL, __dbg, __FILE__, GST_FUNCTION, __LINE__); \
+ g_clear_error (&err); \
+} G_STMT_END
+
+#define GST_ELEMENT_WARNING_FROM_ERROR(el, err) G_STMT_START { \
+ gchar *__dbg = g_strdup (err->message); \
+ GST_WARNING_OBJECT (el, "error: %s", __dbg); \
+ gst_element_message_full (GST_ELEMENT(el), GST_MESSAGE_WARNING, \
+ err->domain, err->code, \
+ NULL, __dbg, __FILE__, GST_FUNCTION, __LINE__); \
+ g_clear_error (&err); \
+} G_STMT_END
G_END_DECLS
{
GstAmcAudioDec *self = GST_AMC_AUDIO_DEC (decoder);
GstAmcAudioDecClass *klass = GST_AMC_AUDIO_DEC_GET_CLASS (self);
+ GError *err = NULL;
GST_DEBUG_OBJECT (self, "Opening decoder");
- self->codec = gst_amc_codec_new (klass->codec_info->name);
- if (!self->codec)
+ self->codec = gst_amc_codec_new (klass->codec_info->name, &err);
+ if (!self->codec) {
+ GST_ELEMENT_ERROR_FROM_ERROR (self, err);
return FALSE;
+ }
self->started = FALSE;
self->flushing = TRUE;
GST_DEBUG_OBJECT (self, "Closing decoder");
if (self->codec) {
- gst_amc_codec_release (self->codec);
+ GError *err = NULL;
+
+ gst_amc_codec_release (self->codec, &err);
+ if (err)
+ GST_ELEMENT_WARNING_FROM_ERROR (self, err);
+
gst_amc_codec_free (self->codec);
}
self->codec = NULL;
{
GstAmcAudioDec *self;
GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
+ GError *err = NULL;
g_return_val_if_fail (GST_IS_AMC_AUDIO_DEC (element),
GST_STATE_CHANGE_FAILURE);
break;
case GST_STATE_CHANGE_PAUSED_TO_READY:
self->flushing = TRUE;
- gst_amc_codec_flush (self->codec);
+ gst_amc_codec_flush (self->codec, &err);
+ if (err)
+ GST_ELEMENT_WARNING_FROM_ERROR (self, err);
g_mutex_lock (&self->drain_lock);
self->draining = FALSE;
g_cond_broadcast (&self->drain_cond);
gint rate, channels;
guint32 channel_mask = 0;
GstAudioChannelPosition to[64];
+ GError *err = NULL;
- if (!gst_amc_format_get_int (format, "sample-rate", &rate) ||
- !gst_amc_format_get_int (format, "channel-count", &channels)) {
- GST_ERROR_OBJECT (self, "Failed to get output format metadata");
+ if (!gst_amc_format_get_int (format, "sample-rate", &rate, &err) ||
+ !gst_amc_format_get_int (format, "channel-count", &channels, &err)) {
+ GST_ERROR_OBJECT (self, "Failed to get output format metadata: %s",
+ err->message);
+ g_clear_error (&err);
return FALSE;
}
}
/* Not always present */
- if (gst_amc_format_contains_key (format, "channel-mask"))
- gst_amc_format_get_int (format, "channel-mask", (gint *) & channel_mask);
+ if (gst_amc_format_contains_key (format, "channel-mask", NULL))
+ gst_amc_format_get_int (format, "channel-mask", (gint *) & channel_mask,
+ NULL);
gst_amc_audio_channel_mask_to_positions (channel_mask, channels,
self->positions);
gboolean is_eos;
GstAmcBufferInfo buffer_info;
gint idx;
+ GError *err = NULL;
GST_AUDIO_DECODER_STREAM_LOCK (self);
GST_AUDIO_DECODER_STREAM_UNLOCK (self);
/* Wait at most 100ms here, some codecs don't fail dequeueing if
* the codec is flushing, causing deadlocks during shutdown */
- idx = gst_amc_codec_dequeue_output_buffer (self->codec, &buffer_info, 100000);
+ idx =
+ gst_amc_codec_dequeue_output_buffer (self->codec, &buffer_info, 100000,
+ &err);
GST_AUDIO_DECODER_STREAM_LOCK (self);
/*} */
if (idx < 0) {
- if (self->flushing)
+ if (self->flushing) {
+ g_clear_error (&err);
goto flushing;
+ }
switch (idx) {
case INFO_OUTPUT_BUFFERS_CHANGED:{
self->n_output_buffers);
self->output_buffers =
gst_amc_codec_get_output_buffers (self->codec,
- &self->n_output_buffers);
+ &self->n_output_buffers, &err);
if (!self->output_buffers)
goto get_output_buffers_error;
break;
GST_DEBUG_OBJECT (self, "Output format has changed");
- format = gst_amc_codec_get_output_format (self->codec);
+ format = gst_amc_codec_get_output_format (self->codec, &err);
if (!format)
goto format_error;
- format_string = gst_amc_format_to_string (format);
+ format_string = gst_amc_format_to_string (format, &err);
+ if (err) {
+ gst_amc_format_free (format);
+ goto format_error;
+ }
GST_DEBUG_OBJECT (self, "Got new output format: %s", format_string);
g_free (format_string);
self->n_output_buffers);
self->output_buffers =
gst_amc_codec_get_output_buffers (self->codec,
- &self->n_output_buffers);
+ &self->n_output_buffers, &err);
if (!self->output_buffers)
goto get_output_buffers_error;
}
done:
- if (!gst_amc_codec_release_output_buffer (self->codec, idx))
+ if (!gst_amc_codec_release_output_buffer (self->codec, idx, &err))
goto failed_release;
if (is_eos || flow_ret == GST_FLOW_EOS) {
dequeue_error:
{
- GST_ELEMENT_ERROR (self, LIBRARY, FAILED, (NULL),
- ("Failed to dequeue output buffer"));
+ GST_ELEMENT_ERROR_FROM_ERROR (self, err);
gst_pad_push_event (GST_AUDIO_DECODER_SRC_PAD (self), gst_event_new_eos ());
gst_pad_pause_task (GST_AUDIO_DECODER_SRC_PAD (self));
self->downstream_flow_ret = GST_FLOW_ERROR;
get_output_buffers_error:
{
- GST_ELEMENT_ERROR (self, LIBRARY, FAILED, (NULL),
- ("Failed to get output buffers"));
+ GST_ELEMENT_ERROR_FROM_ERROR (self, err);
gst_pad_push_event (GST_AUDIO_DECODER_SRC_PAD (self), gst_event_new_eos ());
gst_pad_pause_task (GST_AUDIO_DECODER_SRC_PAD (self));
self->downstream_flow_ret = GST_FLOW_ERROR;
format_error:
{
- GST_ELEMENT_ERROR (self, LIBRARY, FAILED, (NULL),
- ("Failed to handle format"));
+ if (err)
+ GST_ELEMENT_ERROR_FROM_ERROR (self, err);
+ else
+ GST_ELEMENT_ERROR (self, LIBRARY, FAILED, (NULL),
+ ("Failed to handle format"));
gst_pad_push_event (GST_AUDIO_DECODER_SRC_PAD (self), gst_event_new_eos ());
gst_pad_pause_task (GST_AUDIO_DECODER_SRC_PAD (self));
self->downstream_flow_ret = GST_FLOW_ERROR;
}
failed_release:
{
- GST_ELEMENT_ERROR (self, LIBRARY, FAILED, (NULL),
- ("Failed to release output buffer index %d", idx));
+ GST_ELEMENT_ERROR_FROM_ERROR (self, err);
gst_pad_push_event (GST_AUDIO_DECODER_SRC_PAD (self), gst_event_new_eos ());
gst_pad_pause_task (GST_AUDIO_DECODER_SRC_PAD (self));
self->downstream_flow_ret = GST_FLOW_ERROR;
{
GST_ELEMENT_ERROR (self, LIBRARY, FAILED, (NULL),
("Invalid buffer size %u (bfp %d)", buffer_info.size, self->info.bpf));
- gst_amc_codec_release_output_buffer (self->codec, idx);
+ gst_amc_codec_release_output_buffer (self->codec, idx, &err);
+ if (err)
+ GST_ELEMENT_WARNING_FROM_ERROR (self, err);
gst_pad_push_event (GST_AUDIO_DECODER_SRC_PAD (self), gst_event_new_eos ());
gst_pad_pause_task (GST_AUDIO_DECODER_SRC_PAD (self));
self->downstream_flow_ret = GST_FLOW_ERROR;
{
GST_ELEMENT_ERROR (self, LIBRARY, SETTINGS, (NULL),
("Failed to allocate output buffer"));
- gst_amc_codec_release_output_buffer (self->codec, idx);
+ gst_amc_codec_release_output_buffer (self->codec, idx, &err);
+ if (err)
+ GST_ELEMENT_WARNING_FROM_ERROR (self, err);
gst_pad_push_event (GST_AUDIO_DECODER_SRC_PAD (self), gst_event_new_eos ());
gst_pad_pause_task (GST_AUDIO_DECODER_SRC_PAD (self));
self->downstream_flow_ret = GST_FLOW_ERROR;
gst_amc_audio_dec_stop (GstAudioDecoder * decoder)
{
GstAmcAudioDec *self;
+ GError *err = NULL;
self = GST_AMC_AUDIO_DEC (decoder);
GST_DEBUG_OBJECT (self, "Stopping decoder");
self->flushing = TRUE;
if (self->started) {
- gst_amc_codec_flush (self->codec);
- gst_amc_codec_stop (self->codec);
+ gst_amc_codec_flush (self->codec, &err);
+ if (err)
+ GST_ELEMENT_WARNING_FROM_ERROR (self, err);
+ gst_amc_codec_stop (self->codec, &err);
+ if (err)
+ GST_ELEMENT_WARNING_FROM_ERROR (self, err);
self->started = FALSE;
if (self->input_buffers)
gst_amc_codec_free_buffers (self->input_buffers, self->n_input_buffers);
gboolean needs_disable = FALSE;
gchar *format_string;
gint rate, channels;
+ GError *err = NULL;
self = GST_AMC_AUDIO_DEC (decoder);
return FALSE;
}
- format = gst_amc_format_new_audio (mime, rate, channels);
+ format = gst_amc_format_new_audio (mime, rate, channels, &err);
if (!format) {
- GST_ERROR_OBJECT (self, "Failed to create audio format");
+ GST_ELEMENT_ERROR_FROM_ERROR (self, err);
return FALSE;
}
gst_buffer_map (codec_data, &minfo, GST_MAP_READ);
data = g_memdup (minfo.data, minfo.size);
self->codec_datas = g_list_prepend (self->codec_datas, data);
- gst_amc_format_set_buffer (format, "csd-0", data, minfo.size);
+ gst_amc_format_set_buffer (format, "csd-0", data, minfo.size, &err);
+ if (err)
+ GST_ELEMENT_WARNING_FROM_ERROR (self, err);
gst_buffer_unmap (codec_data, &minfo);
} else if (gst_structure_has_field (s, "streamheader")) {
const GValue *sh = gst_structure_get_value (s, "streamheader");
gst_buffer_map (buf, &minfo, GST_MAP_READ);
data = g_memdup (minfo.data, minfo.size);
self->codec_datas = g_list_prepend (self->codec_datas, data);
- gst_amc_format_set_buffer (format, fname, data, minfo.size);
+ gst_amc_format_set_buffer (format, fname, data, minfo.size, &err);
+ if (err)
+ GST_ELEMENT_WARNING_FROM_ERROR (self, err);
gst_buffer_unmap (buf, &minfo);
g_free (fname);
j++;
}
}
- format_string = gst_amc_format_to_string (format);
- GST_DEBUG_OBJECT (self, "Configuring codec with format: %s", format_string);
+ format_string = gst_amc_format_to_string (format, &err);
+ if (err)
+ GST_ELEMENT_WARNING_FROM_ERROR (self, err);
+ GST_DEBUG_OBJECT (self, "Configuring codec with format: %s",
+ GST_STR_NULL (format_string));
g_free (format_string);
self->n_buffers = 0;
- if (!gst_amc_codec_configure (self->codec, format, 0)) {
+ if (!gst_amc_codec_configure (self->codec, format, 0, &err)) {
GST_ERROR_OBJECT (self, "Failed to configure codec");
+ GST_ELEMENT_ERROR_FROM_ERROR (self, err);
return FALSE;
}
gst_amc_format_free (format);
- if (!gst_amc_codec_start (self->codec)) {
+ if (!gst_amc_codec_start (self->codec, &err)) {
GST_ERROR_OBJECT (self, "Failed to start codec");
+ GST_ELEMENT_ERROR_FROM_ERROR (self, err);
return FALSE;
}
if (self->input_buffers)
gst_amc_codec_free_buffers (self->input_buffers, self->n_input_buffers);
self->input_buffers =
- gst_amc_codec_get_input_buffers (self->codec, &self->n_input_buffers);
+ gst_amc_codec_get_input_buffers (self->codec, &self->n_input_buffers,
+ &err);
if (!self->input_buffers) {
GST_ERROR_OBJECT (self, "Failed to get input buffers");
+ GST_ELEMENT_ERROR_FROM_ERROR (self, err);
return FALSE;
}
gst_amc_audio_dec_flush (GstAudioDecoder * decoder, gboolean hard)
{
GstAmcAudioDec *self;
+ GError *err = NULL;
self = GST_AMC_AUDIO_DEC (decoder);
GST_PAD_STREAM_LOCK (GST_AUDIO_DECODER_SRC_PAD (self));
GST_PAD_STREAM_UNLOCK (GST_AUDIO_DECODER_SRC_PAD (self));
GST_AUDIO_DECODER_STREAM_LOCK (self);
- gst_amc_codec_flush (self->codec);
+ gst_amc_codec_flush (self->codec, &err);
+ if (err)
+ GST_ELEMENT_WARNING_FROM_ERROR (self, err);
self->flushing = FALSE;
/* Start the srcpad loop again */
guint offset = 0;
GstClockTime timestamp, duration, timestamp_offset = 0;
GstMapInfo minfo;
+ GError *err = NULL;
memset (&minfo, 0, sizeof (minfo));
GST_AUDIO_DECODER_STREAM_UNLOCK (self);
/* Wait at most 100ms here, some codecs don't fail dequeueing if
* the codec is flushing, causing deadlocks during shutdown */
- idx = gst_amc_codec_dequeue_input_buffer (self->codec, 100000);
+ idx = gst_amc_codec_dequeue_input_buffer (self->codec, 100000, &err);
GST_AUDIO_DECODER_STREAM_LOCK (self);
if (idx < 0) {
- if (self->flushing)
+ if (self->flushing) {
+ g_clear_error (&err);
goto flushing;
+ }
+
switch (idx) {
case INFO_TRY_AGAIN_LATER:
GST_DEBUG_OBJECT (self, "Dequeueing input buffer timed out");
if (self->downstream_flow_ret != GST_FLOW_OK) {
memset (&buffer_info, 0, sizeof (buffer_info));
- gst_amc_codec_queue_input_buffer (self->codec, idx, &buffer_info);
+ gst_amc_codec_queue_input_buffer (self->codec, idx, &buffer_info, &err);
+ if (err)
+ GST_ELEMENT_WARNING_FROM_ERROR (self, err);
goto downstream_error;
}
"Queueing buffer %d: size %d time %" G_GINT64_FORMAT " flags 0x%08x",
idx, buffer_info.size, buffer_info.presentation_time_us,
buffer_info.flags);
- if (!gst_amc_codec_queue_input_buffer (self->codec, idx, &buffer_info))
+ if (!gst_amc_codec_queue_input_buffer (self->codec, idx, &buffer_info,
+ &err))
goto queue_error;
}
gst_buffer_unmap (inbuf, &minfo);
}
dequeue_error:
{
- GST_ELEMENT_ERROR (self, LIBRARY, FAILED, (NULL),
- ("Failed to dequeue input buffer"));
+ GST_ELEMENT_ERROR_FROM_ERROR (self, err);
if (minfo.data)
gst_buffer_unmap (inbuf, &minfo);
if (inbuf)
}
queue_error:
{
- GST_ELEMENT_ERROR (self, LIBRARY, FAILED, (NULL),
- ("Failed to queue input buffer"));
+ GST_ELEMENT_ERROR_FROM_ERROR (self, err);
if (minfo.data)
gst_buffer_unmap (inbuf, &minfo);
if (inbuf)
{
GstFlowReturn ret;
gint idx;
+ GError *err = NULL;
GST_DEBUG_OBJECT (self, "Draining codec");
if (!self->started) {
* class drop the EOS event. We will send it later when
* the EOS buffer arrives on the output port.
* Wait at most 0.5s here. */
- idx = gst_amc_codec_dequeue_input_buffer (self->codec, 500000);
+ idx = gst_amc_codec_dequeue_input_buffer (self->codec, 500000, &err);
GST_AUDIO_DECODER_STREAM_LOCK (self);
if (idx >= 0 && idx < self->n_input_buffers) {
gst_util_uint64_scale (self->last_upstream_ts, 1, GST_USECOND);
buffer_info.flags |= BUFFER_FLAG_END_OF_STREAM;
- if (gst_amc_codec_queue_input_buffer (self->codec, idx, &buffer_info)) {
+ if (gst_amc_codec_queue_input_buffer (self->codec, idx, &buffer_info, &err)) {
GST_DEBUG_OBJECT (self, "Waiting until codec is drained");
g_cond_wait (&self->drain_cond, &self->drain_lock);
GST_DEBUG_OBJECT (self, "Drained codec");
ret = GST_FLOW_OK;
} else {
GST_ERROR_OBJECT (self, "Failed to queue input buffer");
+ GST_ELEMENT_WARNING_FROM_ERROR (self, err);
ret = GST_FLOW_ERROR;
}
ret = GST_FLOW_ERROR;
} else {
GST_ERROR_OBJECT (self, "Failed to acquire buffer for EOS: %d", idx);
+ if (err)
+ GST_ELEMENT_WARNING_FROM_ERROR (self, err);
ret = GST_FLOW_ERROR;
}
{
GstAmcVideoDec *self = GST_AMC_VIDEO_DEC (decoder);
GstAmcVideoDecClass *klass = GST_AMC_VIDEO_DEC_GET_CLASS (self);
+ GError *err = NULL;
GST_DEBUG_OBJECT (self, "Opening decoder");
- self->codec = gst_amc_codec_new (klass->codec_info->name);
- if (!self->codec)
+ self->codec = gst_amc_codec_new (klass->codec_info->name, &err);
+ if (!self->codec) {
+ GST_ELEMENT_ERROR_FROM_ERROR (self, err);
return FALSE;
+ }
self->started = FALSE;
self->flushing = TRUE;
GST_DEBUG_OBJECT (self, "Closing decoder");
if (self->codec) {
- gst_amc_codec_release (self->codec);
+ GError *err = NULL;
+
+ gst_amc_codec_release (self->codec, &err);
+ if (err)
+ GST_ELEMENT_WARNING_FROM_ERROR (self, err);
+
gst_amc_codec_free (self->codec);
}
self->codec = NULL;
{
GstAmcVideoDec *self;
GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
+ GError *err = NULL;
g_return_val_if_fail (GST_IS_AMC_VIDEO_DEC (element),
GST_STATE_CHANGE_FAILURE);
break;
case GST_STATE_CHANGE_PAUSED_TO_READY:
self->flushing = TRUE;
- gst_amc_codec_flush (self->codec);
+ gst_amc_codec_flush (self->codec, &err);
+ if (err)
+ GST_ELEMENT_WARNING_FROM_ERROR (self, err);
g_mutex_lock (&self->drain_lock);
self->draining = FALSE;
g_cond_broadcast (&self->drain_cond);
gint crop_top, crop_bottom;
GstVideoFormat gst_format;
GstAmcVideoDecClass *klass = GST_AMC_VIDEO_DEC_GET_CLASS (self);
-
- if (!gst_amc_format_get_int (format, "color-format", &color_format) ||
- !gst_amc_format_get_int (format, "width", &width) ||
- !gst_amc_format_get_int (format, "height", &height)) {
- GST_ERROR_OBJECT (self, "Failed to get output format metadata");
+ GError *err = NULL;
+
+ if (!gst_amc_format_get_int (format, "color-format", &color_format, &err) ||
+ !gst_amc_format_get_int (format, "width", &width, &err) ||
+ !gst_amc_format_get_int (format, "height", &height, &err)) {
+ GST_ERROR_OBJECT (self, "Failed to get output format metadata: %s",
+ err->message);
+ g_clear_error (&err);
return FALSE;
}
- if (!gst_amc_format_get_int (format, "stride", &stride) ||
- !gst_amc_format_get_int (format, "slice-height", &slice_height)) {
- GST_ERROR_OBJECT (self, "Failed to get stride and slice-height");
+ if (!gst_amc_format_get_int (format, "stride", &stride, &err) ||
+ !gst_amc_format_get_int (format, "slice-height", &slice_height, &err)) {
+ GST_ERROR_OBJECT (self, "Failed to get stride and slice-height: %s",
+ err->message);
+ g_clear_error (&err);
return FALSE;
}
- if (!gst_amc_format_get_int (format, "crop-left", &crop_left) ||
- !gst_amc_format_get_int (format, "crop-right", &crop_right) ||
- !gst_amc_format_get_int (format, "crop-top", &crop_top) ||
- !gst_amc_format_get_int (format, "crop-bottom", &crop_bottom)) {
- GST_ERROR_OBJECT (self, "Failed to get crop rectangle");
+ if (!gst_amc_format_get_int (format, "crop-left", &crop_left, &err) ||
+ !gst_amc_format_get_int (format, "crop-right", &crop_right, &err) ||
+ !gst_amc_format_get_int (format, "crop-top", &crop_top, &err) ||
+ !gst_amc_format_get_int (format, "crop-bottom", &crop_bottom, &err)) {
+ GST_ERROR_OBJECT (self, "Failed to get crop rectangle: %s", err->message);
+ g_clear_error (&err);
return FALSE;
}
gboolean is_eos;
GstAmcBufferInfo buffer_info;
gint idx;
+ GError *err = NULL;
GST_VIDEO_DECODER_STREAM_LOCK (self);
GST_VIDEO_DECODER_STREAM_UNLOCK (self);
/* Wait at most 100ms here, some codecs don't fail dequeueing if
* the codec is flushing, causing deadlocks during shutdown */
- idx = gst_amc_codec_dequeue_output_buffer (self->codec, &buffer_info, 100000);
+ idx =
+ gst_amc_codec_dequeue_output_buffer (self->codec, &buffer_info, 100000,
+ &err);
GST_VIDEO_DECODER_STREAM_LOCK (self);
/*} */
if (idx < 0) {
- if (self->flushing || self->downstream_flow_ret == GST_FLOW_FLUSHING)
+ if (self->flushing || self->downstream_flow_ret == GST_FLOW_FLUSHING) {
+ g_clear_error (&err);
goto flushing;
+ }
switch (idx) {
case INFO_OUTPUT_BUFFERS_CHANGED:{
self->n_output_buffers);
self->output_buffers =
gst_amc_codec_get_output_buffers (self->codec,
- &self->n_output_buffers);
+ &self->n_output_buffers, &err);
if (!self->output_buffers)
goto get_output_buffers_error;
break;
GST_DEBUG_OBJECT (self, "Output format has changed");
- format = gst_amc_codec_get_output_format (self->codec);
+ format = gst_amc_codec_get_output_format (self->codec, &err);
if (!format)
goto format_error;
- format_string = gst_amc_format_to_string (format);
+ format_string = gst_amc_format_to_string (format, &err);
+ if (!format) {
+ gst_amc_format_free (format);
+ goto format_error;
+ }
GST_DEBUG_OBJECT (self, "Got new output format: %s", format_string);
g_free (format_string);
self->n_output_buffers);
self->output_buffers =
gst_amc_codec_get_output_buffers (self->codec,
- &self->n_output_buffers);
+ &self->n_output_buffers, &err);
if (!self->output_buffers)
goto get_output_buffers_error;
goto retry;
break;
case G_MININT:
- GST_ERROR_OBJECT (self, "Failure dequeueing input buffer");
+ GST_ERROR_OBJECT (self, "Failure dequeueing output buffer");
goto dequeue_error;
break;
default:
_find_nearest_frame (self,
gst_util_uint64_scale (buffer_info.presentation_time_us, GST_USECOND, 1));
- is_eos = !!(buffer_info.flags & BUFFER_FLAG_END_OF_STREAM);
+ is_eos = ! !(buffer_info.flags & BUFFER_FLAG_END_OF_STREAM);
if (frame
&& (deadline =
if (!gst_amc_video_dec_fill_buffer (self, idx, &buffer_info, outbuf)) {
gst_buffer_unref (outbuf);
- if (!gst_amc_codec_release_output_buffer (self->codec, idx))
+ if (!gst_amc_codec_release_output_buffer (self->codec, idx, &err))
GST_ERROR_OBJECT (self, "Failed to release output buffer index %d",
idx);
+ if (err)
+ GST_ELEMENT_WARNING_FROM_ERROR (self, err);
goto invalid_buffer;
}
if ((flow_ret = gst_video_decoder_allocate_output_frame (GST_VIDEO_DECODER
(self), frame)) != GST_FLOW_OK) {
GST_ERROR_OBJECT (self, "Failed to allocate buffer");
- if (!gst_amc_codec_release_output_buffer (self->codec, idx))
+ if (!gst_amc_codec_release_output_buffer (self->codec, idx, &err))
GST_ERROR_OBJECT (self, "Failed to release output buffer index %d",
idx);
+ if (err)
+ GST_ELEMENT_WARNING_FROM_ERROR (self, err);
goto flow_error;
}
frame->output_buffer)) {
gst_buffer_replace (&frame->output_buffer, NULL);
gst_video_decoder_drop_frame (GST_VIDEO_DECODER (self), frame);
- if (!gst_amc_codec_release_output_buffer (self->codec, idx))
+ if (!gst_amc_codec_release_output_buffer (self->codec, idx, &err))
GST_ERROR_OBJECT (self, "Failed to release output buffer index %d",
idx);
+ if (err)
+ GST_ELEMENT_WARNING_FROM_ERROR (self, err);
goto invalid_buffer;
}
flow_ret = gst_video_decoder_drop_frame (GST_VIDEO_DECODER (self), frame);
}
- if (!gst_amc_codec_release_output_buffer (self->codec, idx))
+ if (!gst_amc_codec_release_output_buffer (self->codec, idx, &err))
goto failed_release;
if (is_eos || flow_ret == GST_FLOW_EOS) {
dequeue_error:
{
- GST_ELEMENT_ERROR (self, LIBRARY, FAILED, (NULL),
- ("Failed to dequeue output buffer"));
+ GST_ELEMENT_ERROR_FROM_ERROR (self, err);
gst_pad_push_event (GST_VIDEO_DECODER_SRC_PAD (self), gst_event_new_eos ());
gst_pad_pause_task (GST_VIDEO_DECODER_SRC_PAD (self));
self->downstream_flow_ret = GST_FLOW_ERROR;
get_output_buffers_error:
{
- GST_ELEMENT_ERROR (self, LIBRARY, FAILED, (NULL),
- ("Failed to get output buffers"));
+ GST_ELEMENT_ERROR_FROM_ERROR (self, err);
gst_pad_push_event (GST_VIDEO_DECODER_SRC_PAD (self), gst_event_new_eos ());
gst_pad_pause_task (GST_VIDEO_DECODER_SRC_PAD (self));
self->downstream_flow_ret = GST_FLOW_ERROR;
format_error:
{
- GST_ELEMENT_ERROR (self, LIBRARY, FAILED, (NULL),
- ("Failed to handle format"));
+ if (err)
+ GST_ELEMENT_ERROR_FROM_ERROR (self, err);
+ else
+ GST_ELEMENT_ERROR (self, LIBRARY, FAILED, (NULL),
+ ("Failed to handle format"));
gst_pad_push_event (GST_VIDEO_DECODER_SRC_PAD (self), gst_event_new_eos ());
gst_pad_pause_task (GST_VIDEO_DECODER_SRC_PAD (self));
self->downstream_flow_ret = GST_FLOW_ERROR;
}
failed_release:
{
- GST_ELEMENT_ERROR (self, LIBRARY, FAILED, (NULL),
- ("Failed to release output buffer index %d", idx));
+ GST_ELEMENT_ERROR_FROM_ERROR (self, err);
gst_pad_push_event (GST_VIDEO_DECODER_SRC_PAD (self), gst_event_new_eos ());
gst_pad_pause_task (GST_VIDEO_DECODER_SRC_PAD (self));
self->downstream_flow_ret = GST_FLOW_ERROR;
gst_amc_video_dec_stop (GstVideoDecoder * decoder)
{
GstAmcVideoDec *self;
+ GError *err = NULL;
self = GST_AMC_VIDEO_DEC (decoder);
GST_DEBUG_OBJECT (self, "Stopping decoder");
self->flushing = TRUE;
if (self->started) {
- gst_amc_codec_flush (self->codec);
- gst_amc_codec_stop (self->codec);
+ gst_amc_codec_flush (self->codec, &err);
+ if (err)
+ GST_ELEMENT_WARNING_FROM_ERROR (self, err);
+ gst_amc_codec_stop (self->codec, &err);
+ if (err)
+ GST_ELEMENT_WARNING_FROM_ERROR (self, err);
self->started = FALSE;
if (self->input_buffers)
gst_amc_codec_free_buffers (self->input_buffers, self->n_input_buffers);
gchar *format_string;
guint8 *codec_data = NULL;
gsize codec_data_size = 0;
+ GError *err = NULL;
self = GST_AMC_VIDEO_DEC (decoder);
}
format =
- gst_amc_format_new_video (mime, state->info.width, state->info.height);
+ gst_amc_format_new_video (mime, state->info.width, state->info.height,
+ &err);
if (!format) {
GST_ERROR_OBJECT (self, "Failed to create video format");
+ GST_ELEMENT_ERROR_FROM_ERROR (self, err);
return FALSE;
}
/* FIXME: This buffer needs to be valid until the codec is stopped again */
- if (self->codec_data)
+ if (self->codec_data) {
gst_amc_format_set_buffer (format, "csd-0", self->codec_data,
- self->codec_data_size);
+ self->codec_data_size, &err);
+ if (err)
+ GST_ELEMENT_WARNING_FROM_ERROR (self, err);
+ }
- format_string = gst_amc_format_to_string (format);
- GST_DEBUG_OBJECT (self, "Configuring codec with format: %s", format_string);
+ format_string = gst_amc_format_to_string (format, &err);
+ if (err)
+ GST_ELEMENT_WARNING_FROM_ERROR (self, err);
+ GST_DEBUG_OBJECT (self, "Configuring codec with format: %s",
+ GST_STR_NULL (format_string));
g_free (format_string);
- if (!gst_amc_codec_configure (self->codec, format, 0)) {
+ if (!gst_amc_codec_configure (self->codec, format, 0, &err)) {
GST_ERROR_OBJECT (self, "Failed to configure codec");
+ GST_ELEMENT_ERROR_FROM_ERROR (self, err);
return FALSE;
}
gst_amc_format_free (format);
- if (!gst_amc_codec_start (self->codec)) {
+ if (!gst_amc_codec_start (self->codec, &err)) {
GST_ERROR_OBJECT (self, "Failed to start codec");
+ GST_ELEMENT_ERROR_FROM_ERROR (self, err);
return FALSE;
}
if (self->input_buffers)
gst_amc_codec_free_buffers (self->input_buffers, self->n_input_buffers);
self->input_buffers =
- gst_amc_codec_get_input_buffers (self->codec, &self->n_input_buffers);
+ gst_amc_codec_get_input_buffers (self->codec, &self->n_input_buffers,
+ &err);
if (!self->input_buffers) {
GST_ERROR_OBJECT (self, "Failed to get input buffers");
+ GST_ELEMENT_ERROR_FROM_ERROR (self, err);
return FALSE;
}
gst_amc_video_dec_flush (GstVideoDecoder * decoder)
{
GstAmcVideoDec *self;
+ GError *err = NULL;
self = GST_AMC_VIDEO_DEC (decoder);
GST_PAD_STREAM_LOCK (GST_VIDEO_DECODER_SRC_PAD (self));
GST_PAD_STREAM_UNLOCK (GST_VIDEO_DECODER_SRC_PAD (self));
GST_VIDEO_DECODER_STREAM_LOCK (self);
- gst_amc_codec_flush (self->codec);
+ gst_amc_codec_flush (self->codec, &err);
+ if (err)
+ GST_ELEMENT_WARNING_FROM_ERROR (self, err);
self->flushing = FALSE;
/* Start the srcpad loop again */
guint offset = 0;
GstClockTime timestamp, duration, timestamp_offset = 0;
GstMapInfo minfo;
+ GError *err = NULL;
memset (&minfo, 0, sizeof (minfo));
GST_VIDEO_DECODER_STREAM_UNLOCK (self);
/* Wait at most 100ms here, some codecs don't fail dequeueing if
* the codec is flushing, causing deadlocks during shutdown */
- idx = gst_amc_codec_dequeue_input_buffer (self->codec, 100000);
+ idx = gst_amc_codec_dequeue_input_buffer (self->codec, 100000, &err);
GST_VIDEO_DECODER_STREAM_LOCK (self);
if (idx < 0) {
- if (self->flushing)
+ if (self->flushing) {
+ g_clear_error (&err);
goto flushing;
+ }
+
switch (idx) {
case INFO_TRY_AGAIN_LATER:
GST_DEBUG_OBJECT (self, "Dequeueing input buffer timed out");
if (self->downstream_flow_ret != GST_FLOW_OK) {
memset (&buffer_info, 0, sizeof (buffer_info));
- gst_amc_codec_queue_input_buffer (self->codec, idx, &buffer_info);
+ gst_amc_codec_queue_input_buffer (self->codec, idx, &buffer_info, &err);
+ if (err)
+ GST_ELEMENT_WARNING_FROM_ERROR (self, err);
goto downstream_error;
}
"Queueing buffer %d: size %d time %" G_GINT64_FORMAT " flags 0x%08x",
idx, buffer_info.size, buffer_info.presentation_time_us,
buffer_info.flags);
- if (!gst_amc_codec_queue_input_buffer (self->codec, idx, &buffer_info))
+ if (!gst_amc_codec_queue_input_buffer (self->codec, idx, &buffer_info,
+ &err))
goto queue_error;
}
}
dequeue_error:
{
- GST_ELEMENT_ERROR (self, LIBRARY, FAILED, (NULL),
- ("Failed to dequeue input buffer"));
+ GST_ELEMENT_ERROR_FROM_ERROR (self, err);
if (minfo.data)
gst_buffer_unmap (frame->input_buffer, &minfo);
gst_video_codec_frame_unref (frame);
}
queue_error:
{
- GST_ELEMENT_ERROR (self, LIBRARY, FAILED, (NULL),
- ("Failed to queue input buffer"));
+ GST_ELEMENT_ERROR_FROM_ERROR (self, err);
if (minfo.data)
gst_buffer_unmap (frame->input_buffer, &minfo);
gst_video_codec_frame_unref (frame);
{
GstFlowReturn ret;
gint idx;
+ GError *err = NULL;
GST_DEBUG_OBJECT (self, "Draining codec");
if (!self->started) {
* class drop the EOS event. We will send it later when
* the EOS buffer arrives on the output port.
* Wait at most 0.5s here. */
- idx = gst_amc_codec_dequeue_input_buffer (self->codec, 500000);
+ idx = gst_amc_codec_dequeue_input_buffer (self->codec, 500000, &err);
GST_VIDEO_DECODER_STREAM_LOCK (self);
if (idx >= 0 && idx < self->n_input_buffers) {
gst_util_uint64_scale (self->last_upstream_ts, 1, GST_USECOND);
buffer_info.flags |= BUFFER_FLAG_END_OF_STREAM;
- if (gst_amc_codec_queue_input_buffer (self->codec, idx, &buffer_info)) {
+ if (gst_amc_codec_queue_input_buffer (self->codec, idx, &buffer_info, &err)) {
GST_DEBUG_OBJECT (self, "Waiting until codec is drained");
g_cond_wait (&self->drain_cond, &self->drain_lock);
GST_DEBUG_OBJECT (self, "Drained codec");
ret = GST_FLOW_OK;
} else {
GST_ERROR_OBJECT (self, "Failed to queue input buffer");
+ GST_ELEMENT_WARNING_FROM_ERROR (self, err);
ret = GST_FLOW_ERROR;
}
ret = GST_FLOW_ERROR;
} else {
GST_ERROR_OBJECT (self, "Failed to acquire buffer for EOS: %d", idx);
+ if (err)
+ GST_ELEMENT_WARNING_FROM_ERROR (self, err);
ret = GST_FLOW_ERROR;
}
gint stride, slice_height;
GstAmcFormat *format = NULL;
GstVideoInfo *info = &input_state->info;
+ GError *err = NULL;
klass = GST_AMC_VIDEO_ENC_GET_CLASS (encoder);
s = gst_caps_get_structure (src_caps, 0);
return NULL;
}
- format = gst_amc_format_new_video (mime, info->width, info->height);
+ format = gst_amc_format_new_video (mime, info->width, info->height, &err);
if (!format) {
GST_ERROR_OBJECT (encoder, "Failed to create a \"%s,%dx%d\" MediaFormat",
mime, info->width, info->height);
+ GST_ELEMENT_ERROR_FROM_ERROR (encoder, err);
return NULL;
}
if (color_format == -1)
goto video_format_failed_to_convert;
- gst_amc_format_set_int (format, "bitrate", encoder->bitrate);
- gst_amc_format_set_int (format, "color-format", color_format);
+ gst_amc_format_set_int (format, "bitrate", encoder->bitrate, &err);
+ if (err)
+ GST_ELEMENT_WARNING_FROM_ERROR (encoder, err);
+ gst_amc_format_set_int (format, "color-format", color_format, &err);
+ if (err)
+ GST_ELEMENT_WARNING_FROM_ERROR (encoder, err);
stride = GST_ROUND_UP_4 (info->width); /* safe (?) */
- gst_amc_format_set_int (format, "stride", stride);
+ gst_amc_format_set_int (format, "stride", stride, &err);
+ if (err)
+ GST_ELEMENT_WARNING_FROM_ERROR (encoder, err);
slice_height = info->height;
- gst_amc_format_set_int (format, "slice-height", slice_height);
+ gst_amc_format_set_int (format, "slice-height", slice_height, &err);
+ if (err)
+ GST_ELEMENT_WARNING_FROM_ERROR (encoder, err);
if (profile_string) {
if (amc_profile.id == -1)
}
if (encoder->i_frame_int)
- gst_amc_format_set_int (format, "i-frame-interval", encoder->i_frame_int);
+ gst_amc_format_set_int (format, "i-frame-interval", encoder->i_frame_int,
+ &err);
+ if (err)
+ GST_ELEMENT_WARNING_FROM_ERROR (encoder, err);
if (info->fps_d)
gst_amc_format_set_float (format, "frame-rate",
- ((gfloat) info->fps_n) / info->fps_d);
+ ((gfloat) info->fps_n) / info->fps_d, &err);
+ if (err)
+ GST_ELEMENT_WARNING_FROM_ERROR (encoder, err);
encoder->format = info->finfo->format;
if (!gst_amc_color_format_info_set (&encoder->color_format_info,
gint amc_profile, amc_level;
gfloat frame_rate = 0.0;
gint fraction_n, fraction_d;
+ GError *err = NULL;
- if (!gst_amc_format_get_string (amc_format, "mime", &mime)) {
- GST_ERROR ("Failed to get 'mime'");
+ if (!gst_amc_format_get_string (amc_format, "mime", &mime, &err)) {
+ GST_ERROR ("Failed to get 'mime': %s", err->message);
+ g_clear_error (&err);
return NULL;
}
- if (!gst_amc_format_get_int (amc_format, "width", &width) ||
- !gst_amc_format_get_int (amc_format, "height", &height)) {
- GST_ERROR ("Failed to get size");
+ if (!gst_amc_format_get_int (amc_format, "width", &width, &err) ||
+ !gst_amc_format_get_int (amc_format, "height", &height, &err)) {
+ GST_ERROR ("Failed to get size: %s", err->message);
+ g_clear_error (&err);
g_free (mime);
return NULL;
}
- gst_amc_format_get_float (amc_format, "frame-rate", &frame_rate);
+ gst_amc_format_get_float (amc_format, "frame-rate", &frame_rate, NULL);
gst_util_double_to_fraction (frame_rate, &fraction_n, &fraction_d);
if (strcmp (mime, "video/mp4v-es") == 0) {
"systemstream", G_TYPE_BOOLEAN, FALSE,
"parsed", G_TYPE_BOOLEAN, TRUE, NULL);
- if (gst_amc_format_get_int (amc_format, "profile", &amc_profile)) {
+ if (gst_amc_format_get_int (amc_format, "profile", &amc_profile, NULL)) {
profile_string = gst_amc_mpeg4_profile_to_string (amc_profile);
if (!profile_string)
goto unsupported_profile;
NULL);
}
- if (gst_amc_format_get_int (amc_format, "level", &amc_level)) {
+ if (gst_amc_format_get_int (amc_format, "level", &amc_level, NULL)) {
level_string = gst_amc_mpeg4_level_to_string (amc_profile);
if (!level_string)
goto unsupported_level;
"stream-format", G_TYPE_STRING, "byte-stream",
"alignment", G_TYPE_STRING, "au", NULL);
- if (gst_amc_format_get_int (amc_format, "profile", &amc_profile)) {
+ if (gst_amc_format_get_int (amc_format, "profile", &amc_profile, NULL)) {
profile_string = gst_amc_avc_profile_to_string (amc_profile, NULL);
if (!profile_string)
goto unsupported_profile;
NULL);
}
- if (gst_amc_format_get_int (amc_format, "level", &amc_level)) {
+ if (gst_amc_format_get_int (amc_format, "level", &amc_level, NULL)) {
level_string = gst_amc_avc_level_to_string (amc_profile);
if (!level_string)
goto unsupported_level;
{
GstAmcVideoEnc *self = GST_AMC_VIDEO_ENC (encoder);
GstAmcVideoEncClass *klass = GST_AMC_VIDEO_ENC_GET_CLASS (self);
+ GError *err = NULL;
GST_DEBUG_OBJECT (self, "Opening encoder");
- self->codec = gst_amc_codec_new (klass->codec_info->name);
- if (!self->codec)
+ self->codec = gst_amc_codec_new (klass->codec_info->name, &err);
+ if (!self->codec) {
+ GST_ELEMENT_ERROR_FROM_ERROR (self, err);
return FALSE;
+ }
self->started = FALSE;
self->flushing = TRUE;
GST_DEBUG_OBJECT (self, "Closing encoder");
- if (self->codec)
+ if (self->codec) {
+ GError *err = NULL;
+
+ gst_amc_codec_release (self->codec, &err);
+ if (err)
+ GST_ELEMENT_WARNING_FROM_ERROR (self, err);
+
gst_amc_codec_free (self->codec);
+ }
self->codec = NULL;
self->started = FALSE;
{
GstAmcVideoEnc *self;
GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
+ GError *err = NULL;
g_return_val_if_fail (GST_IS_AMC_VIDEO_ENC (element),
GST_STATE_CHANGE_FAILURE);
break;
case GST_STATE_CHANGE_PAUSED_TO_READY:
self->flushing = TRUE;
- gst_amc_codec_flush (self->codec);
+ gst_amc_codec_flush (self->codec, &err);
+ if (err)
+ GST_ELEMENT_WARNING_FROM_ERROR (self, err);
g_mutex_lock (&self->drain_lock);
self->draining = FALSE;
g_cond_broadcast (&self->drain_cond);
GstAmcBufferInfo buffer_info;
GstAmcBuffer *buf;
gint idx;
+ GError *err = NULL;
GST_VIDEO_ENCODER_STREAM_LOCK (self);
GST_VIDEO_ENCODER_STREAM_UNLOCK (self);
/* Wait at most 100ms here, some codecs don't fail dequeueing if
* the codec is flushing, causing deadlocks during shutdown */
- idx = gst_amc_codec_dequeue_output_buffer (self->codec, &buffer_info, 100000);
+ idx =
+ gst_amc_codec_dequeue_output_buffer (self->codec, &buffer_info, 100000,
+ &err);
GST_VIDEO_ENCODER_STREAM_LOCK (self);
/*} */
if (idx < 0 || self->amc_format) {
- if (self->flushing || self->downstream_flow_ret == GST_FLOW_FLUSHING)
+ if (self->flushing || self->downstream_flow_ret == GST_FLOW_FLUSHING) {
+ g_clear_error (&err);
goto flushing;
+ }
/* The comments from https://android.googlesource.com/platform/cts/+/android-4.3_r3.1/tests/tests/media/src/android/media/cts/EncodeDecodeTest.java
* line 539 says INFO_OUTPUT_FORMAT_CHANGED is not expected for an encoder
GST_DEBUG_OBJECT (self, "Output format has changed");
format = (idx == INFO_OUTPUT_FORMAT_CHANGED) ?
- gst_amc_codec_get_output_format (self->codec) : self->amc_format;
+ gst_amc_codec_get_output_format (self->codec,
+ &err) : self->amc_format;
+ if (err) {
+ format = self->amc_format;
+ GST_ELEMENT_WARNING_FROM_ERROR (self, err);
+ }
if (self->amc_format) {
if (format != self->amc_format)
if (!format)
goto format_error;
-
- format_string = gst_amc_format_to_string (format);
+ format_string = gst_amc_format_to_string (format, &err);
+ if (err) {
+ gst_amc_format_free (format);
+ goto format_error;
+ }
GST_DEBUG_OBJECT (self, "Got new output format: %s", format_string);
g_free (format_string);
self->n_output_buffers);
self->output_buffers =
gst_amc_codec_get_output_buffers (self->codec,
- &self->n_output_buffers);
+ &self->n_output_buffers, &err);
if (!self->output_buffers)
goto get_output_buffers_error;
self->n_output_buffers);
self->output_buffers =
gst_amc_codec_get_output_buffers (self->codec,
- &self->n_output_buffers);
+ &self->n_output_buffers, &err);
if (!self->output_buffers)
goto get_output_buffers_error;
break;
GST_ERROR_OBJECT (self, "Invalid output buffer index %d of %d",
idx, self->n_output_buffers);
- if (!gst_amc_codec_release_output_buffer (self->codec, idx))
+ if (!gst_amc_codec_release_output_buffer (self->codec, idx, &err))
GST_ERROR_OBJECT (self, "Failed to release output buffer index %d", idx);
+ if (err)
+ GST_ELEMENT_WARNING_FROM_ERROR (self, err);
goto invalid_buffer;
}
buf = &self->output_buffers[idx];
flow_ret =
gst_amc_video_enc_handle_output_frame (self, buf, &buffer_info, frame);
- if (!gst_amc_codec_release_output_buffer (self->codec, idx))
+ if (!gst_amc_codec_release_output_buffer (self->codec, idx, &err))
goto failed_release;
if (is_eos || flow_ret == GST_FLOW_EOS) {
dequeue_error:
{
- GST_ELEMENT_ERROR (self, LIBRARY, FAILED, (NULL),
- ("Failed to dequeue output buffer"));
+ GST_ELEMENT_ERROR_FROM_ERROR (self, err);
gst_pad_push_event (GST_VIDEO_ENCODER_SRC_PAD (self), gst_event_new_eos ());
gst_pad_pause_task (GST_VIDEO_ENCODER_SRC_PAD (self));
self->downstream_flow_ret = GST_FLOW_ERROR;
get_output_buffers_error:
{
- GST_ELEMENT_ERROR (self, LIBRARY, FAILED, (NULL),
- ("Failed to get output buffers"));
+ GST_ELEMENT_ERROR_FROM_ERROR (self, err);
gst_pad_push_event (GST_VIDEO_ENCODER_SRC_PAD (self), gst_event_new_eos ());
gst_pad_pause_task (GST_VIDEO_ENCODER_SRC_PAD (self));
self->downstream_flow_ret = GST_FLOW_ERROR;
format_error:
{
- GST_ELEMENT_ERROR (self, LIBRARY, FAILED, (NULL),
- ("Failed to handle format"));
+ if (err)
+ GST_ELEMENT_ERROR_FROM_ERROR (self, err);
+ else
+ GST_ELEMENT_ERROR (self, LIBRARY, FAILED, (NULL),
+ ("Failed to handle format"));
gst_pad_push_event (GST_VIDEO_ENCODER_SRC_PAD (self), gst_event_new_eos ());
gst_pad_pause_task (GST_VIDEO_ENCODER_SRC_PAD (self));
self->downstream_flow_ret = GST_FLOW_ERROR;
}
failed_release:
{
- GST_ELEMENT_ERROR (self, LIBRARY, FAILED, (NULL),
- ("Failed to release output buffer index %d", idx));
+ GST_ELEMENT_ERROR_FROM_ERROR (self, err);
gst_pad_push_event (GST_VIDEO_ENCODER_SRC_PAD (self), gst_event_new_eos ());
gst_pad_pause_task (GST_VIDEO_ENCODER_SRC_PAD (self));
self->downstream_flow_ret = GST_FLOW_ERROR;
gst_amc_video_enc_stop (GstVideoEncoder * encoder)
{
GstAmcVideoEnc *self;
+ GError *err = NULL;
self = GST_AMC_VIDEO_ENC (encoder);
GST_DEBUG_OBJECT (self, "Stopping encoder");
self->flushing = TRUE;
if (self->started) {
- gst_amc_codec_flush (self->codec);
- gst_amc_codec_stop (self->codec);
+ gst_amc_codec_flush (self->codec, &err);
+ if (err)
+ GST_ELEMENT_WARNING_FROM_ERROR (self, err);
+ gst_amc_codec_stop (self->codec, &err);
+ if (err)
+ GST_ELEMENT_WARNING_FROM_ERROR (self, err);
self->started = FALSE;
if (self->input_buffers)
gst_amc_codec_free_buffers (self->input_buffers, self->n_input_buffers);
gboolean needs_disable = FALSE;
gchar *format_string;
gboolean r = FALSE;
+ GError *err = NULL;
self = GST_AMC_VIDEO_ENC (encoder);
if (!format)
goto quit;
- format_string = gst_amc_format_to_string (format);
- GST_DEBUG_OBJECT (self, "Configuring codec with format: %s", format_string);
+ format_string = gst_amc_format_to_string (format, &err);
+ if (err)
+ GST_ELEMENT_WARNING_FROM_ERROR (self, err);
+ GST_DEBUG_OBJECT (self, "Configuring codec with format: %s",
+ GST_STR_NULL (format_string));
g_free (format_string);
- if (!gst_amc_codec_configure (self->codec, format, 1)) {
+ if (!gst_amc_codec_configure (self->codec, format, 1, &err)) {
GST_ERROR_OBJECT (self, "Failed to configure codec");
+ GST_ELEMENT_ERROR_FROM_ERROR (self, err);
goto quit;
}
- if (!gst_amc_codec_start (self->codec)) {
+ if (!gst_amc_codec_start (self->codec, &err)) {
GST_ERROR_OBJECT (self, "Failed to start codec");
+ GST_ELEMENT_ERROR_FROM_ERROR (self, err);
goto quit;
}
if (self->input_buffers)
gst_amc_codec_free_buffers (self->input_buffers, self->n_input_buffers);
self->input_buffers =
- gst_amc_codec_get_input_buffers (self->codec, &self->n_input_buffers);
+ gst_amc_codec_get_input_buffers (self->codec, &self->n_input_buffers,
+ &err);
if (!self->input_buffers) {
GST_ERROR_OBJECT (self, "Failed to get input buffers");
+ GST_ELEMENT_ERROR_FROM_ERROR (self, err);
goto quit;
}
gst_amc_video_enc_flush (GstVideoEncoder * encoder)
{
GstAmcVideoEnc *self;
+ GError *err = NULL;
self = GST_AMC_VIDEO_ENC (encoder);
}
self->flushing = TRUE;
- gst_amc_codec_flush (self->codec);
+ gst_amc_codec_flush (self->codec, &err);
+ if (err)
+ GST_ELEMENT_WARNING_FROM_ERROR (self, err);
/* Wait until the srcpad loop is finished,
* unlock GST_VIDEO_ENCODER_STREAM_LOCK to prevent deadlocks
GstAmcBufferInfo buffer_info;
GstClockTime timestamp, duration, timestamp_offset = 0;
BufferIdentification *id;
+ GError *err = NULL;
self = GST_AMC_VIDEO_ENC (encoder);
GST_VIDEO_ENCODER_STREAM_UNLOCK (self);
/* Wait at most 100ms here, some codecs don't fail dequeueing if
* the codec is flushing, causing deadlocks during shutdown */
- idx = gst_amc_codec_dequeue_input_buffer (self->codec, 100000);
+ idx = gst_amc_codec_dequeue_input_buffer (self->codec, 100000, &err);
GST_VIDEO_ENCODER_STREAM_LOCK (self);
if (idx < 0) {
- if (self->flushing)
+ if (self->flushing) {
+ g_clear_error (&err);
goto flushing;
+ }
+
switch (idx) {
case INFO_TRY_AGAIN_LATER:
GST_DEBUG_OBJECT (self, "Dequeueing input buffer timed out");
if (self->downstream_flow_ret != GST_FLOW_OK) {
memset (&buffer_info, 0, sizeof (buffer_info));
- gst_amc_codec_queue_input_buffer (self->codec, idx, &buffer_info);
+ gst_amc_codec_queue_input_buffer (self->codec, idx, &buffer_info, &err);
+ if (err)
+ GST_ELEMENT_WARNING_FROM_ERROR (self, err);
goto downstream_error;
}
if (!gst_amc_video_enc_fill_buffer (self, frame->input_buffer, buf,
&buffer_info)) {
memset (&buffer_info, 0, sizeof (buffer_info));
- gst_amc_codec_queue_input_buffer (self->codec, idx, &buffer_info);
+ gst_amc_codec_queue_input_buffer (self->codec, idx, &buffer_info, &err);
+ if (err)
+ GST_ELEMENT_WARNING_FROM_ERROR (self, err);
goto buffer_fill_error;
}
"Queueing buffer %d: size %d time %" G_GINT64_FORMAT " flags 0x%08x",
idx, buffer_info.size, buffer_info.presentation_time_us,
buffer_info.flags);
- if (!gst_amc_codec_queue_input_buffer (self->codec, idx, &buffer_info))
+ if (!gst_amc_codec_queue_input_buffer (self->codec, idx, &buffer_info, &err))
goto queue_error;
gst_video_codec_frame_unref (frame);
}
dequeue_error:
{
- GST_ELEMENT_ERROR (self, LIBRARY, FAILED, (NULL),
- ("Failed to dequeue input buffer"));
+ GST_ELEMENT_ERROR_FROM_ERROR (self, err);
gst_video_codec_frame_unref (frame);
return GST_FLOW_ERROR;
}
queue_error:
{
- GST_ELEMENT_ERROR (self, LIBRARY, FAILED, (NULL),
- ("Failed to queue input buffer"));
+ GST_ELEMENT_ERROR_FROM_ERROR (self, err);
gst_video_codec_frame_unref (frame);
return GST_FLOW_ERROR;
}
{
GstAmcVideoEnc *self;
gint idx;
+ GError *err = NULL;
self = GST_AMC_VIDEO_ENC (encoder);
GST_DEBUG_OBJECT (self, "Sending EOS to the component");
* class drop the EOS event. We will send it later when
* the EOS buffer arrives on the output port.
* Wait at most 0.5s here. */
- idx = gst_amc_codec_dequeue_input_buffer (self->codec, 500000);
+ idx = gst_amc_codec_dequeue_input_buffer (self->codec, 500000, &err);
GST_VIDEO_ENCODER_STREAM_LOCK (self);
if (idx >= 0 && idx < self->n_input_buffers) {
gst_util_uint64_scale (self->last_upstream_ts, 1, GST_USECOND);
buffer_info.flags |= BUFFER_FLAG_END_OF_STREAM;
- if (gst_amc_codec_queue_input_buffer (self->codec, idx, &buffer_info))
+ if (gst_amc_codec_queue_input_buffer (self->codec, idx, &buffer_info, &err)) {
GST_DEBUG_OBJECT (self, "Sent EOS to the codec");
- else
+ } else {
GST_ERROR_OBJECT (self, "Failed to send EOS to the codec");
+ GST_ELEMENT_WARNING_FROM_ERROR (self, err);
+ }
} else if (idx >= self->n_input_buffers) {
GST_ERROR_OBJECT (self, "Invalid input buffer index %d of %d",
idx, self->n_input_buffers);
} else {
GST_ERROR_OBJECT (self, "Failed to dequeue input buffer for EOS: %d", idx);
+ if (err)
+ GST_ELEMENT_WARNING_FROM_ERROR (self, err);
}
return GST_VIDEO_ENCODER_FLOW_DROPPED;
{
GstFlowReturn ret;
gint idx;
+ GError *err = NULL;
GST_DEBUG_OBJECT (self, "Draining codec");
if (!self->started) {
* class drop the EOS event. We will send it later when
* the EOS buffer arrives on the output port.
* Wait at most 0.5s here. */
- idx = gst_amc_codec_dequeue_input_buffer (self->codec, 500000);
+ idx = gst_amc_codec_dequeue_input_buffer (self->codec, 500000, &err);
GST_VIDEO_ENCODER_STREAM_LOCK (self);
if (idx >= 0 && idx < self->n_input_buffers) {
gst_util_uint64_scale (self->last_upstream_ts, 1, GST_USECOND);
buffer_info.flags |= BUFFER_FLAG_END_OF_STREAM;
- if (gst_amc_codec_queue_input_buffer (self->codec, idx, &buffer_info)) {
+ if (gst_amc_codec_queue_input_buffer (self->codec, idx, &buffer_info, &err)) {
GST_DEBUG_OBJECT (self, "Waiting until codec is drained");
g_cond_wait (&self->drain_cond, &self->drain_lock);
GST_DEBUG_OBJECT (self, "Drained codec");
ret = GST_FLOW_OK;
} else {
GST_ERROR_OBJECT (self, "Failed to queue input buffer");
+ GST_ELEMENT_WARNING_FROM_ERROR (self, err);
ret = GST_FLOW_ERROR;
}
ret = GST_FLOW_ERROR;
} else {
GST_ERROR_OBJECT (self, "Failed to acquire buffer for EOS: %d", idx);
+ if (err)
+ GST_ELEMENT_WARNING_FROM_ERROR (self, err);
ret = GST_FLOW_ERROR;
}