diff options
Diffstat (limited to 'gst-libs/gst/audio/gstaudioencoder.c')
-rw-r--r-- | gst-libs/gst/audio/gstaudioencoder.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/gst-libs/gst/audio/gstaudioencoder.c b/gst-libs/gst/audio/gstaudioencoder.c index 1ff557371..d45e6fb14 100644 --- a/gst-libs/gst/audio/gstaudioencoder.c +++ b/gst-libs/gst/audio/gstaudioencoder.c @@ -315,13 +315,17 @@ static gboolean gst_audio_encoder_src_query (GstPad * pad, GstObject * parent, GstQuery * query); static gboolean gst_audio_encoder_sink_query (GstPad * pad, GstObject * parent, GstQuery * query); +static GstStateChangeReturn gst_audio_encoder_change_state (GstElement * + element, GstStateChange transition); static void gst_audio_encoder_class_init (GstAudioEncoderClass * klass) { GObjectClass *gobject_class; + GstElementClass *gstelement_class; gobject_class = G_OBJECT_CLASS (klass); + gstelement_class = GST_ELEMENT_CLASS (klass); parent_class = g_type_class_peek_parent (klass); GST_DEBUG_CATEGORY_INIT (gst_audio_encoder_debug, "audioencoder", 0, @@ -353,6 +357,9 @@ gst_audio_encoder_class_init (GstAudioEncoderClass * klass) 0, G_MAXINT64, DEFAULT_TOLERANCE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + gstelement_class->change_state = + GST_DEBUG_FUNCPTR (gst_audio_encoder_change_state); + klass->getcaps = gst_audio_encoder_getcaps_default; klass->event = gst_audio_encoder_sink_event_default; } @@ -460,6 +467,49 @@ gst_audio_encoder_finalize (GObject * object) G_OBJECT_CLASS (parent_class)->finalize (object); } +static GstStateChangeReturn +gst_audio_encoder_change_state (GstElement * element, GstStateChange transition) +{ + GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS; + GstAudioEncoder *enc = GST_AUDIO_ENCODER (element); + GstAudioEncoderClass *klass = GST_AUDIO_ENCODER_GET_CLASS (enc); + + switch (transition) { + case GST_STATE_CHANGE_NULL_TO_READY: + if (klass->open) { + if (!klass->open (enc)) + goto open_failed; + } + default: + break; + } + + ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition); + + switch (transition) { + case GST_STATE_CHANGE_READY_TO_NULL: + if (klass->close) { + if (!klass->close (enc)) + goto close_failed; + } + default: + break; + } + + return ret; + +open_failed: + { + GST_ELEMENT_ERROR (enc, LIBRARY, INIT, (NULL), ("Failed to open codec")); + return GST_STATE_CHANGE_FAILURE; + } +close_failed: + { + GST_ELEMENT_ERROR (enc, LIBRARY, INIT, (NULL), ("Failed to close codec")); + return GST_STATE_CHANGE_FAILURE; + } +} + /** * gst_audio_encoder_finish_frame: * @enc: a #GstAudioEncoder |