From ff3034af814a1216750ca736975dca6aebb3906d Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Wed, 30 Jan 2008 17:30:27 +0000 Subject: [PATCH] bluez: Enable gstreamer plugin to use autoconnect flag. --- sys/bluez/gsta2dpsink.c | 28 +++++++++++++++++++++++++++- sys/bluez/gsta2dpsink.h | 1 + sys/bluez/gstavdtpsink.c | 19 +++++++++++++++++++ sys/bluez/gstavdtpsink.h | 1 + 4 files changed, 48 insertions(+), 1 deletion(-) diff --git a/sys/bluez/gsta2dpsink.c b/sys/bluez/gsta2dpsink.c index a181140..a3d092c 100644 --- a/sys/bluez/gsta2dpsink.c +++ b/sys/bluez/gsta2dpsink.c @@ -37,10 +37,13 @@ GST_DEBUG_CATEGORY_STATIC (gst_a2dp_sink_debug); #define A2DP_SBC_RTP_PAYLOAD_TYPE 1 #define TEMPLATE_MAX_BITPOOL_STR "64" +#define DEFAULT_AUTOCONNECT TRUE + enum { PROP_0, - PROP_DEVICE + PROP_DEVICE, + PROP_AUTOCONNECT }; GST_BOILERPLATE (GstA2dpSink, gst_a2dp_sink, GstBin, GST_TYPE_BIN); @@ -167,6 +170,14 @@ gst_a2dp_sink_set_property (GObject * object, guint prop_id, self->device = g_value_dup_string (value); break; + case PROP_AUTOCONNECT: + self->autoconnect = g_value_get_boolean (value); + + if (self->sink != NULL) + g_object_set (G_OBJECT (self->sink), "auto-connect", + self->autoconnect, NULL); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -188,7 +199,13 @@ gst_a2dp_sink_get_property (GObject * object, guint prop_id, g_value_take_string (value, device); } break; + case PROP_AUTOCONNECT: + if (self->sink != NULL) + g_object_get (G_OBJECT (self->sink), "auto-connect", + &self->autoconnect, NULL); + g_value_set_boolean (value, self->autoconnect); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -263,6 +280,9 @@ gst_a2dp_sink_change_state (GstElement * element, GstStateChange transition) if (self->device != NULL) gst_avdtp_sink_set_device (self->sink, self->device); + g_object_set (G_OBJECT (self->sink), "auto-connect", + self->autoconnect, NULL); + ret = gst_element_set_state (GST_ELEMENT (self->sink), GST_STATE_READY); break; default: @@ -328,6 +348,11 @@ gst_a2dp_sink_class_init (GstA2dpSinkClass * klass) g_param_spec_string ("device", "Device", "Bluetooth remote device address", NULL, G_PARAM_READWRITE)); + g_object_class_install_property (object_class, PROP_AUTOCONNECT, + g_param_spec_boolean ("auto-connect", "Auto-connect", + "Automatically attempt to connect to device", + DEFAULT_AUTOCONNECT, G_PARAM_READWRITE)); + GST_DEBUG_CATEGORY_INIT (gst_a2dp_sink_debug, "a2dpsink", 0, "A2DP sink element"); } @@ -639,6 +664,7 @@ gst_a2dp_sink_init (GstA2dpSink * self, GstA2dpSinkClass * klass) self->fakesink = NULL; self->rtp = NULL; self->device = NULL; + self->autoconnect = DEFAULT_AUTOCONNECT; self->capsfilter = NULL; self->newseg_event = NULL; self->taglist = NULL; diff --git a/sys/bluez/gsta2dpsink.h b/sys/bluez/gsta2dpsink.h index 676c37e..0eeaf14 100644 --- a/sys/bluez/gsta2dpsink.h +++ b/sys/bluez/gsta2dpsink.h @@ -53,6 +53,7 @@ struct _GstA2dpSink { GstElement *fakesink; gchar *device; + gboolean autoconnect; gboolean sink_is_in_bin; GstGhostPad *ghostpad; diff --git a/sys/bluez/gstavdtpsink.c b/sys/bluez/gstavdtpsink.c index 1bd7534..03e0a7d 100644 --- a/sys/bluez/gstavdtpsink.c +++ b/sys/bluez/gstavdtpsink.c @@ -51,6 +51,8 @@ GST_DEBUG_CATEGORY_STATIC (avdtp_sink_debug); #define CRC_PROTECTED 1 #define CRC_UNPROTECTED 0 +#define DEFAULT_AUTOCONNECT TRUE + #define GST_AVDTP_SINK_MUTEX_LOCK(s) G_STMT_START { \ g_mutex_lock (s->sink_lock); \ } G_STMT_END @@ -75,6 +77,7 @@ enum { PROP_0, PROP_DEVICE, + PROP_AUTOCONNECT }; GST_BOILERPLATE (GstAvdtpSink, gst_avdtp_sink, GstBaseSink, GST_TYPE_BASE_SINK); @@ -194,6 +197,9 @@ gst_avdtp_sink_set_property (GObject * object, guint prop_id, sink->device = g_value_dup_string (value); break; + case PROP_AUTOCONNECT: + sink->autoconnect = g_value_get_boolean (value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -211,6 +217,9 @@ gst_avdtp_sink_get_property (GObject * object, guint prop_id, g_value_set_string (value, sink->device); break; + case PROP_AUTOCONNECT: + g_value_set_boolean (value, sink->autoconnect); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -758,6 +767,8 @@ gst_avdtp_sink_get_capabilities (GstAvdtpSink * self) if (self->device == NULL) return FALSE; strncpy (req->device, self->device, 18); + if (self->autoconnect) + req->flags |= BT_FLAG_AUTOCONNECT; io_error = gst_avdtp_sink_audioservice_send (self, &req->h); if (io_error != G_IO_ERROR_NONE) { @@ -1176,6 +1187,12 @@ gst_avdtp_sink_class_init (GstAvdtpSinkClass * klass) g_param_spec_string ("device", "Device", "Bluetooth remote device address", NULL, G_PARAM_READWRITE)); + g_object_class_install_property (object_class, PROP_AUTOCONNECT, + g_param_spec_boolean ("auto-connect", + "Auto-connect", + "Automatically attempt to connect " + "to device", DEFAULT_AUTOCONNECT, G_PARAM_READWRITE)); + GST_DEBUG_CATEGORY_INIT (avdtp_sink_debug, "avdtpsink", 0, "A2DP headset sink element"); } @@ -1190,6 +1207,8 @@ gst_avdtp_sink_init (GstAvdtpSink * self, GstAvdtpSinkClass * klass) self->dev_caps = NULL; + self->autoconnect = DEFAULT_AUTOCONNECT; + self->sink_lock = g_mutex_new (); /* FIXME this is for not synchronizing with clock, should be tested diff --git a/sys/bluez/gstavdtpsink.h b/sys/bluez/gstavdtpsink.h index 237597d..333f1a4 100644 --- a/sys/bluez/gstavdtpsink.h +++ b/sys/bluez/gstavdtpsink.h @@ -54,6 +54,7 @@ struct _GstAvdtpSink { GIOChannel *stream; struct bluetooth_data *data; + gboolean autoconnect; GIOChannel *server; /* mp3 stream data (outside caps data)*/ -- 2.7.4