videodecoder: Add API to allow subclasses to specify that they needs caps before any buffers

This commit is contained in:
Sebastian Dröge 2013-12-05 11:34:36 +01:00
parent 820d7d7798
commit 5acc099479
4 changed files with 58 additions and 0 deletions

View file

@ -2536,6 +2536,8 @@ gst_video_decoder_set_estimate_rate
gst_video_decoder_set_output_state
gst_video_decoder_set_max_errors
gst_video_decoder_set_packetized
gst_video_decoder_get_needs_format
gst_video_decoder_set_needs_format
gst_video_decoder_merge_tags
<SUBSECTION Standard>
GST_IS_VIDEO_DECODER

View file

@ -336,6 +336,7 @@ struct _GstVideoDecoderPrivate
gboolean had_output_data;
gboolean had_input_data;
gboolean needs_format;
gboolean do_caps;
/* ... being tracked here;
@ -558,6 +559,7 @@ gst_video_decoder_init (GstVideoDecoder * decoder, GstVideoDecoderClass * klass)
decoder->priv->input_adapter = gst_adapter_new ();
decoder->priv->output_adapter = gst_adapter_new ();
decoder->priv->packetized = TRUE;
decoder->priv->needs_format = FALSE;
gst_video_decoder_reset (decoder, TRUE, TRUE);
}
@ -1981,6 +1983,9 @@ gst_video_decoder_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
decoder->priv->do_caps = FALSE;
}
if (G_UNLIKELY (!decoder->priv->input_state && decoder->priv->needs_format))
goto not_negotiated;
GST_LOG_OBJECT (decoder,
"chain PTS %" GST_TIME_FORMAT ", DTS %" GST_TIME_FORMAT " duration %"
GST_TIME_FORMAT " size %" G_GSIZE_FORMAT,
@ -3446,6 +3451,50 @@ gst_video_decoder_get_max_errors (GstVideoDecoder * dec)
return dec->priv->max_errors;
}
/**
* gst_video_decoder_set_needs_format:
* @dec: a #GstVideoDecoder
* @enabled: new state
*
* Configures decoder format needs. If enabled, subclass needs to be
* negotiated with format caps before it can process any data. It will then
* never be handed any data before it has been configured.
* Otherwise, it might be handed data without having been configured and
* is then expected being able to do so either by default
* or based on the input data.
*
* Since: 1.4
*/
void
gst_video_decoder_set_needs_format (GstVideoDecoder * dec, gboolean enabled)
{
g_return_if_fail (GST_IS_VIDEO_DECODER (dec));
dec->priv->needs_format = enabled;
}
/**
* gst_video_decoder_get_needs_format:
* @dec: a #GstVideoDecoder
*
* Queries decoder required format handling.
*
* Returns: TRUE if required format handling is enabled.
*
* Since: 1.4
*/
gboolean
gst_video_decoder_get_needs_format (GstVideoDecoder * dec)
{
gboolean result;
g_return_val_if_fail (GST_IS_VIDEO_DECODER (dec), FALSE);
result = dec->priv->needs_format;
return result;
}
/**
* gst_video_decoder_set_packetized:
* @decoder: a #GstVideoDecoder

View file

@ -316,6 +316,11 @@ void gst_video_decoder_set_max_errors (GstVideoDecoder * dec,
gint gst_video_decoder_get_max_errors (GstVideoDecoder * dec);
void gst_video_decoder_set_needs_format (GstVideoDecoder * dec,
gboolean enabled);
gboolean gst_video_decoder_get_needs_format (GstVideoDecoder * dec);
void gst_video_decoder_set_latency (GstVideoDecoder *decoder,
GstClockTime min_latency,
GstClockTime max_latency);

View file

@ -95,6 +95,7 @@ EXPORTS
gst_video_decoder_get_latency
gst_video_decoder_get_max_decode_time
gst_video_decoder_get_max_errors
gst_video_decoder_get_needs_format
gst_video_decoder_get_oldest_frame
gst_video_decoder_get_output_state
gst_video_decoder_get_packetized
@ -107,6 +108,7 @@ EXPORTS
gst_video_decoder_set_estimate_rate
gst_video_decoder_set_latency
gst_video_decoder_set_max_errors
gst_video_decoder_set_needs_format
gst_video_decoder_set_output_state
gst_video_decoder_set_packetized
gst_video_encoder_allocate_output_buffer