mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-27 10:40:34 +00:00
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
This commit is contained in:
parent
dd981d4953
commit
c43e74d885
3 changed files with 50 additions and 0 deletions
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue