diff --git a/sys/bluez/gstavdtpsrc.c b/sys/bluez/gstavdtpsrc.c index f40ef00a1c..cf427ec6f1 100644 --- a/sys/bluez/gstavdtpsrc.c +++ b/sys/bluez/gstavdtpsrc.c @@ -40,6 +40,7 @@ enum { PROP_0, PROP_TRANSPORT, + PROP_TRANSPORT_VOLUME, }; #define parent_class gst_avdtp_src_parent_class @@ -101,6 +102,12 @@ gst_avdtp_src_class_init (GstAvdtpSrcClass * klass) g_param_spec_string ("transport", "Transport", "Use configured transport", NULL, G_PARAM_READWRITE)); + g_object_class_install_property (gobject_class, PROP_TRANSPORT_VOLUME, + g_param_spec_uint ("transport-volume", + "Transport volume", + "Volume of the transport (only valid if transport is acquired)", + 0, 127, 127, G_PARAM_READWRITE)); + gst_element_class_set_static_metadata (element_class, "Bluetooth AVDTP Source", "Source/Audio/Network/RTP", @@ -149,6 +156,11 @@ gst_avdtp_src_get_property (GObject * object, guint prop_id, g_value_set_string (value, avdtpsrc->conn.transport); break; + case PROP_TRANSPORT_VOLUME: + g_value_set_uint (value, + gst_avdtp_connection_get_volume (&avdtpsrc->conn)); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -167,6 +179,10 @@ gst_avdtp_src_set_property (GObject * object, guint prop_id, g_value_get_string (value)); break; + case PROP_TRANSPORT_VOLUME: + /* This is no-op because setting is handled via a GBinding */ + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -376,6 +392,11 @@ gst_avdtp_src_start (GstBaseSrc * bsrc) g_atomic_int_set (&avdtpsrc->unlocked, FALSE); + /* The life time of the connection is shorter than the src object, so we + * don't need to worry about memory management */ + gst_avdtp_connection_notify_volume (&avdtpsrc->conn, G_OBJECT (avdtpsrc), + "transport-volume"); + gst_avdtp_src_start_avrcp (avdtpsrc); return TRUE; diff --git a/sys/bluez/gstavdtputil.c b/sys/bluez/gstavdtputil.c index efc4f42985..8f9f9a0cf3 100644 --- a/sys/bluez/gstavdtputil.c +++ b/sys/bluez/gstavdtputil.c @@ -722,6 +722,30 @@ gst_avdtp_connection_get_caps (GstAvdtpConnection * conn) return caps; } +guint +gst_avdtp_connection_get_volume (GstAvdtpConnection * conn) +{ + if (conn->data.is_acquired) + return bluez_media_transport1_get_volume (conn->data.conn); + else + return 127; +} + +void +gst_avdtp_connection_set_volume (GstAvdtpConnection * conn, guint16 volume) +{ + if (conn->data.is_acquired) + bluez_media_transport1_set_volume (conn->data.conn, volume); +} + +void +gst_avdtp_connection_notify_volume (GstAvdtpConnection * conn, + GObject * target, const gchar * property) +{ + g_object_bind_property (conn->data.conn, "volume", target, property, + G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); +} + gboolean gst_avdtp_connection_conf_recv_stream_fd (GstAvdtpConnection * conn) { diff --git a/sys/bluez/gstavdtputil.h b/sys/bluez/gstavdtputil.h index 1319441861..99394600bf 100644 --- a/sys/bluez/gstavdtputil.h +++ b/sys/bluez/gstavdtputil.h @@ -69,6 +69,11 @@ void gst_avdtp_connection_set_device (GstAvdtpConnection * conn, const char *device); void gst_avdtp_connection_set_transport (GstAvdtpConnection * conn, const char *transport); +guint gst_avdtp_connection_get_volume (GstAvdtpConnection * conn); +void gst_avdtp_connection_set_volume (GstAvdtpConnection * conn, + guint16 volume); +void gst_avdtp_connection_notify_volume (GstAvdtpConnection * conn, + GObject * target, const gchar * property); gboolean gst_avdtp_connection_conf_recv_stream_fd (GstAvdtpConnection * conn); G_END_DECLS