summaryrefslogtreecommitdiffstats
path: root/gst/autodetect
diff options
context:
space:
mode:
authorJan Schmidt <thaytan@mad.scientist.com>2007-02-13 16:01:29 +0000
committerJan Schmidt <thaytan@mad.scientist.com>2007-02-13 16:01:29 +0000
commitb1aa8fef181a00cc6dc6fa38654ceb937cec3898 (patch)
tree9e22511ad16ba44c88d8335cdbc1d46418bd5398 /gst/autodetect
parent5116ff603e735bf5045db60df8025e4b824acb81 (diff)
Re-factor the gconfaudiosink into a "GstSwitchSink" base class and a child that implements the GConf key monitoring. ...
Original commit message from CVS: * ext/gconf/Makefile.am: * ext/gconf/gconf.c: (gst_gconf_get_string), (gst_gconf_get_key_for_sink_profile), (gst_gconf_set_string), (gst_gconf_render_bin_with_default): * ext/gconf/gconf.h: * ext/gconf/gstgconfaudiosink.c: (gst_gconf_audio_sink_base_init), (gst_gconf_audio_sink_reset), (gst_gconf_audio_sink_init), (gst_gconf_audio_sink_dispose), (do_change_child), (gst_gconf_switch_profile), (gst_gconf_audio_sink_set_property), (cb_change_child), (gst_gconf_audio_sink_change_state): * ext/gconf/gstgconfaudiosink.h: * ext/gconf/gstswitchsink.c: (gst_switch_sink_base_init), (gst_switch_sink_class_init), (gst_switch_sink_reset), (gst_switch_sink_init), (gst_switch_sink_dispose), (gst_switch_commit_new_kid), (gst_switch_sink_set_child), (gst_switch_sink_set_property), (gst_switch_sink_handle_event), (gst_switch_sink_get_property), (gst_switch_sink_change_state): * ext/gconf/gstswitchsink.h: * gst/autodetect/gstautoaudiosink.c: (gst_auto_audio_sink_class_init), (gst_auto_audio_sink_dispose), (gst_auto_audio_sink_clear_kid), (gst_auto_audio_sink_reset), (gst_auto_audio_sink_detect): * gst/autodetect/gstautovideosink.c: (gst_auto_video_sink_class_init), (gst_auto_video_sink_dispose), (gst_auto_video_sink_clear_kid), (gst_auto_video_sink_reset), (gst_auto_video_sink_detect): Re-factor the gconfaudiosink into a "GstSwitchSink" base class and a child that implements the GConf key monitoring. The end goal of this is an audio sink that can be changed on the fly, but at the moment it still only changes on the next READY transition.
Diffstat (limited to 'gst/autodetect')
-rw-r--r--gst/autodetect/gstautoaudiosink.c40
-rw-r--r--gst/autodetect/gstautovideosink.c41
2 files changed, 61 insertions, 20 deletions
diff --git a/gst/autodetect/gstautoaudiosink.c b/gst/autodetect/gstautoaudiosink.c
index ccaa413a..379113af 100644
--- a/gst/autodetect/gstautoaudiosink.c
+++ b/gst/autodetect/gstautoaudiosink.c
@@ -1,5 +1,6 @@
/* GStreamer
* (c) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
+ * (c) 2006 Jan Schmidt <thaytan@noraisin.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -49,6 +50,8 @@
static GstStateChangeReturn
gst_auto_audio_sink_change_state (GstElement * element,
GstStateChange transition);
+static void gst_auto_audio_sink_dispose (GstAutoAudioSink * sink);
+static void gst_auto_audio_sink_clear_kid (GstAutoAudioSink * sink);
GST_BOILERPLATE (GstAutoAudioSink, gst_auto_audio_sink, GstBin, GST_TYPE_BIN);
@@ -56,7 +59,8 @@ static const GstElementDetails gst_auto_audio_sink_details =
GST_ELEMENT_DETAILS ("Auto audio sink",
"Sink/Audio",
"Wrapper audio sink for automatically detected audio sink",
- "Ronald Bultje <rbultje@ronald.bitfreak.net>");
+ "Ronald Bultje <rbultje@ronald.bitfreak.net>\n"
+ "Jan Schmidt <thaytan@noraisin.net");
static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
@@ -77,13 +81,35 @@ gst_auto_audio_sink_base_init (gpointer klass)
static void
gst_auto_audio_sink_class_init (GstAutoAudioSinkClass * klass)
{
+ GObjectClass *gobject_class;
GstElementClass *eklass;
+ gobject_class = G_OBJECT_CLASS (klass);
eklass = GST_ELEMENT_CLASS (klass);
+ gobject_class->dispose =
+ (GObjectFinalizeFunc) GST_DEBUG_FUNCPTR (gst_auto_audio_sink_dispose);
eklass->change_state = GST_DEBUG_FUNCPTR (gst_auto_audio_sink_change_state);
}
+static void
+gst_auto_audio_sink_dispose (GstAutoAudioSink * sink)
+{
+ gst_auto_audio_sink_clear_kid (sink);
+
+ G_OBJECT_CLASS (parent_class)->dispose ((GObject *) sink);
+}
+
+static void
+gst_auto_audio_sink_clear_kid (GstAutoAudioSink * sink)
+{
+ if (sink->kid) {
+ gst_element_set_state (sink->kid, GST_STATE_NULL);
+ gst_bin_remove (GST_BIN (sink), sink->kid);
+ sink->kid = NULL;
+ }
+}
+
/*
* Hack to make initial linking work; ideally, this'd work even when
* no target has been assigned to the ghostpad yet.
@@ -94,11 +120,9 @@ gst_auto_audio_sink_reset (GstAutoAudioSink * sink)
{
GstPad *targetpad;
+ gst_auto_audio_sink_clear_kid (sink);
+
/* fakesink placeholder */
- if (sink->kid) {
- gst_element_set_state (sink->kid, GST_STATE_NULL);
- gst_bin_remove (GST_BIN (sink), sink->kid);
- }
sink->kid = gst_element_factory_make ("fakesink", "tempsink");
gst_bin_add (GST_BIN (sink), sink->kid);
@@ -258,11 +282,7 @@ gst_auto_audio_sink_detect (GstAutoAudioSink * sink)
GstElement *esink;
GstPad *targetpad;
- if (sink->kid) {
- gst_element_set_state (sink->kid, GST_STATE_NULL);
- gst_bin_remove (GST_BIN (sink), sink->kid);
- sink->kid = NULL;
- }
+ gst_auto_audio_sink_clear_kid (sink);
/* find element */
GST_DEBUG_OBJECT (sink, "Creating new kid");
diff --git a/gst/autodetect/gstautovideosink.c b/gst/autodetect/gstautovideosink.c
index 085dea1b..0e0bc7ec 100644
--- a/gst/autodetect/gstautovideosink.c
+++ b/gst/autodetect/gstautovideosink.c
@@ -1,5 +1,6 @@
/* GStreamer
* (c) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
+ * (c) 2006 Jan Schmidt <thaytan@noraisin.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -49,6 +50,8 @@
static GstStateChangeReturn
gst_auto_video_sink_change_state (GstElement * element,
GstStateChange transition);
+static void gst_auto_video_sink_dispose (GstAutoVideoSink * sink);
+static void gst_auto_video_sink_clear_kid (GstAutoVideoSink * sink);
GST_BOILERPLATE (GstAutoVideoSink, gst_auto_video_sink, GstBin, GST_TYPE_BIN);
@@ -56,7 +59,8 @@ static const GstElementDetails gst_auto_video_sink_details =
GST_ELEMENT_DETAILS ("Auto video sink",
"Sink/Video",
"Wrapper video sink for automatically detected video sink",
- "Ronald Bultje <rbultje@ronald.bitfreak.net>");
+ "Ronald Bultje <rbultje@ronald.bitfreak.net>\n"
+ "Jan Schmidt <thaytan@noraisin.net");
static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
@@ -76,11 +80,33 @@ gst_auto_video_sink_base_init (gpointer klass)
static void
gst_auto_video_sink_class_init (GstAutoVideoSinkClass * klass)
{
+ GObjectClass *gobject_class;
GstElementClass *eklass = GST_ELEMENT_CLASS (klass);
+ gobject_class = G_OBJECT_CLASS (klass);
+ gobject_class->dispose =
+ (GObjectFinalizeFunc) GST_DEBUG_FUNCPTR (gst_auto_video_sink_dispose);
eklass->change_state = GST_DEBUG_FUNCPTR (gst_auto_video_sink_change_state);
}
+static void
+gst_auto_video_sink_dispose (GstAutoVideoSink * sink)
+{
+ gst_auto_video_sink_clear_kid (sink);
+
+ G_OBJECT_CLASS (parent_class)->dispose ((GObject *) sink);
+}
+
+static void
+gst_auto_video_sink_clear_kid (GstAutoVideoSink * sink)
+{
+ if (sink->kid) {
+ gst_element_set_state (sink->kid, GST_STATE_NULL);
+ gst_bin_remove (GST_BIN (sink), sink->kid);
+ sink->kid = NULL;
+ }
+}
+
/*
* Hack to make initial linking work; ideally, this'd work even when
* no target has been assigned to the ghostpad yet.
@@ -91,11 +117,10 @@ gst_auto_video_sink_reset (GstAutoVideoSink * sink)
{
GstPad *targetpad;
+ /* Remove any existing element */
+ gst_auto_video_sink_clear_kid (sink);
+
/* fakesink placeholder */
- if (sink->kid) {
- gst_element_set_state (sink->kid, GST_STATE_NULL);
- gst_bin_remove (GST_BIN (sink), sink->kid);
- }
sink->kid = gst_element_factory_make ("fakesink", "tempsink");
gst_bin_add (GST_BIN (sink), sink->kid);
@@ -204,11 +229,7 @@ gst_auto_video_sink_detect (GstAutoVideoSink * sink)
GstElement *esink;
GstPad *targetpad;
- if (sink->kid) {
- gst_element_set_state (sink->kid, GST_STATE_NULL);
- gst_bin_remove (GST_BIN (sink), sink->kid);
- sink->kid = NULL;
- }
+ gst_auto_video_sink_clear_kid (sink);
/* find element */
GST_DEBUG_OBJECT (sink, "Creating new kid");