summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Raghavan <git@arunraghavan.net>2018-07-09 06:40:24 +0530
committerArun Raghavan <git@arunraghavan.net>2018-07-09 06:40:24 +0530
commitc43e74d8854b40b664869674a6b2d2b82149d87c (patch)
treeff8468729f652150162ada7fd155152f6c0f585f
parentdd981d4953af34fa343ef0c98a9503936783428d (diff)
downloadgstreamer-plugins-bad-c43e74d8854b40b664869674a6b2d2b82149d87c.tar.gz
bluez: Expose transport volume as a property on avdtpsrc
This can be handy if we want to track Bluetooth volume changes from the device, or if we want to set it. https://bugzilla.gnome.org/show_bug.cgi?id=787020
-rw-r--r--sys/bluez/gstavdtpsrc.c21
-rw-r--r--sys/bluez/gstavdtputil.c24
-rw-r--r--sys/bluez/gstavdtputil.h5
3 files changed, 50 insertions, 0 deletions
diff --git a/sys/bluez/gstavdtpsrc.c b/sys/bluez/gstavdtpsrc.c
index f40ef00a1..cf427ec6f 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 efc4f4298..8f9f9a0cf 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 131944186..99394600b 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