[Nice] [nice/master] Error if the elements try to go to ready without an agent set

Olivier Crete olivier.crete at collabora.co.uk
Wed Nov 5 14:00:57 PST 2008


darcs-hash:20080403231722-3e2dc-bded4a5e1db4984708083e3d94ce58471de156d1.gz
---
 gst/gstnicesink.c |   33 +++++++++++++++++++++++++++++++++
 gst/gstnicesrc.c  |   36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 69 insertions(+), 0 deletions(-)

diff --git a/gst/gstnicesink.c b/gst/gstnicesink.c
index 04f7fa1..53a4752 100644
--- a/gst/gstnicesink.c
+++ b/gst/gstnicesink.c
@@ -58,6 +58,10 @@ gst_nice_sink_get_property (
   guint prop_id,
   GValue *value,
   GParamSpec *pspec);
+static GstStateChangeReturn
+gst_nice_sink_change_state (
+    GstElement * element,
+    GstStateChange transition);
 
 static const GstElementDetails gst_nice_sink_details =
 GST_ELEMENT_DETAILS (
@@ -96,6 +100,7 @@ static void
 gst_nice_sink_class_init (GstNiceSinkClass *klass)
 {
   GstBaseSinkClass *gstbasesink_class;
+  GstElementClass *gstelement_class;
   GObjectClass *gobject_class;
 
   gstbasesink_class = (GstBaseSinkClass *) klass;
@@ -105,6 +110,9 @@ gst_nice_sink_class_init (GstNiceSinkClass *klass)
   gobject_class->set_property = gst_nice_sink_set_property;
   gobject_class->get_property = gst_nice_sink_get_property;
 
+  gstelement_class = (GstElementClass *) klass;
+  gstelement_class->change_state = gst_nice_sink_change_state;
+
   g_object_class_install_property (gobject_class, PROP_AGENT,
       g_param_spec_pointer (
          "agent",
@@ -212,3 +220,28 @@ gst_nice_sink_get_property (
     }
 }
 
+static GstStateChangeReturn
+gst_nice_sink_change_state (GstElement * element, GstStateChange transition)
+{
+  GstNiceSink *sink;
+  GstStateChangeReturn ret;
+
+  sink = GST_NICE_SINK (element);
+
+  switch (transition) {
+    case GST_STATE_CHANGE_NULL_TO_READY:
+      if (sink->agent == NULL)
+        {
+          GST_ERROR_OBJECT (element,
+              "Trying to start Nice sink without an agent set");
+          return GST_STATE_CHANGE_FAILURE;
+        }
+      break;
+    default:
+      break;
+  }
+
+  ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
+
+  return ret;
+}
diff --git a/gst/gstnicesrc.c b/gst/gstnicesrc.c
index 3dab030..7075c36 100644
--- a/gst/gstnicesrc.c
+++ b/gst/gstnicesrc.c
@@ -66,6 +66,11 @@ gst_nice_src_get_property (
   GValue *value,
   GParamSpec *pspec);
 
+static GstStateChangeReturn
+gst_nice_src_change_state (
+    GstElement * element,
+    GstStateChange transition);
+
 static const GstElementDetails gst_nice_src_details =
 GST_ELEMENT_DETAILS (
     "ICE source",
@@ -103,6 +108,7 @@ static void
 gst_nice_src_class_init (GstNiceSrcClass *klass)
 {
   GstBaseSrcClass *gstbasesrc_class;
+  GstElementClass *gstelement_class;
   GObjectClass *gobject_class;
 
   gstbasesrc_class = (GstBaseSrcClass *) klass;
@@ -112,6 +118,9 @@ gst_nice_src_class_init (GstNiceSrcClass *klass)
   gobject_class->set_property = gst_nice_src_set_property;
   gobject_class->get_property = gst_nice_src_get_property;
 
+  gstelement_class = (GstElementClass *) klass;
+  gstelement_class->change_state = gst_nice_src_change_state;
+
   g_object_class_install_property (gobject_class, PROP_AGENT,
       g_param_spec_pointer (
          "agent",
@@ -231,3 +240,30 @@ gst_nice_src_get_property (
     }
 }
 
+static GstStateChangeReturn
+gst_nice_src_change_state (GstElement * element, GstStateChange transition)
+{
+  GstNiceSrc *src;
+  GstStateChangeReturn ret;
+
+  src = GST_NICE_SRC (element);
+
+  switch (transition) {
+    case GST_STATE_CHANGE_NULL_TO_READY:
+      if (src->agent == NULL)
+        {
+          GST_ERROR_OBJECT (element,
+              "Trying to start Nice source without an agent set");
+          return GST_STATE_CHANGE_FAILURE;
+        }
+      break;
+    default:
+      break;
+  }
+
+  ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
+
+  return ret;
+}
+
+
-- 
1.5.6.5




More information about the Nice mailing list