mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-05 06:58:56 +00:00
bluez: Introduce BT_OPEN command to audio ipc.
BT_OPEN make it possible to lock a given seid which is automacally release if the client disconnects from the unix socket.
This commit is contained in:
parent
35e57f99f0
commit
08dd7e709d
1 changed files with 39 additions and 8 deletions
|
@ -1026,32 +1026,63 @@ static gboolean
|
||||||
gst_avdtp_sink_configure (GstAvdtpSink * self, GstCaps * caps)
|
gst_avdtp_sink_configure (GstAvdtpSink * self, GstCaps * caps)
|
||||||
{
|
{
|
||||||
gchar buf[BT_SUGGESTED_BUFFER_SIZE];
|
gchar buf[BT_SUGGESTED_BUFFER_SIZE];
|
||||||
|
struct bt_open_req *open_req = (void *) buf;
|
||||||
|
struct bt_open_rsp *open_rsp = (void *) buf;
|
||||||
struct bt_set_configuration_req *req = (void *) buf;
|
struct bt_set_configuration_req *req = (void *) buf;
|
||||||
struct bt_set_configuration_rsp *rsp = (void *) buf;
|
struct bt_set_configuration_rsp *rsp = (void *) buf;
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
GIOError io_error;
|
GIOError io_error;
|
||||||
gchar *temp;
|
gchar *temp;
|
||||||
GstStructure *structure;
|
GstStructure *structure;
|
||||||
|
codec_capabilities_t *codec = NULL;
|
||||||
|
|
||||||
temp = gst_caps_to_string (caps);
|
temp = gst_caps_to_string (caps);
|
||||||
GST_DEBUG_OBJECT (self, "configuring device with caps: %s", temp);
|
GST_DEBUG_OBJECT (self, "configuring device with caps: %s", temp);
|
||||||
g_free (temp);
|
g_free (temp);
|
||||||
|
|
||||||
|
structure = gst_caps_get_structure (caps, 0);
|
||||||
|
|
||||||
|
if (gst_structure_has_name (structure, "audio/x-sbc"))
|
||||||
|
codec = (void *) gst_avdtp_find_caps (self, BT_A2DP_CODEC_SBC);
|
||||||
|
else if (gst_structure_has_name (structure, "audio/mpeg"))
|
||||||
|
codec = (void *) gst_avdtp_find_caps (self, BT_A2DP_CODEC_MPEG12);
|
||||||
|
|
||||||
|
if (codec == NULL) {
|
||||||
|
GST_ERROR_OBJECT (self, "Couldn't parse caps " "to packet configuration");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset (req, 0, BT_SUGGESTED_BUFFER_SIZE);
|
||||||
|
open_req->h.type = BT_REQUEST;
|
||||||
|
open_req->h.name = BT_OPEN;
|
||||||
|
open_req->h.length = sizeof (*open_req);
|
||||||
|
|
||||||
|
strncpy (open_req->destination, self->device, 18);
|
||||||
|
open_req->seid = codec->seid;
|
||||||
|
open_req->lock = BT_WRITE_LOCK;
|
||||||
|
|
||||||
|
io_error = gst_avdtp_sink_audioservice_send (self, &open_req->h);
|
||||||
|
if (io_error != G_IO_ERROR_NONE) {
|
||||||
|
GST_ERROR_OBJECT (self, "Error ocurred while sending " "open packet");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
open_rsp->h.length = sizeof (*open_rsp);
|
||||||
|
io_error = gst_avdtp_sink_audioservice_expect (self, &open_rsp->h, BT_OPEN);
|
||||||
|
if (io_error != G_IO_ERROR_NONE) {
|
||||||
|
GST_ERROR_OBJECT (self, "Error while receiving device " "confirmation");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
memset (req, 0, sizeof (buf));
|
memset (req, 0, sizeof (buf));
|
||||||
req->h.type = BT_REQUEST;
|
req->h.type = BT_REQUEST;
|
||||||
req->h.name = BT_SET_CONFIGURATION;
|
req->h.name = BT_SET_CONFIGURATION;
|
||||||
req->h.length = sizeof (*req);
|
req->h.length = sizeof (*req);
|
||||||
|
|
||||||
req->access_mode = BT_CAPABILITIES_ACCESS_MODE_WRITE;
|
if (codec->type == BT_A2DP_CODEC_SBC)
|
||||||
strncpy (req->destination, self->device, 18);
|
|
||||||
structure = gst_caps_get_structure (caps, 0);
|
|
||||||
|
|
||||||
if (gst_structure_has_name (structure, "audio/x-sbc"))
|
|
||||||
ret = gst_avdtp_sink_init_sbc_pkt_conf (self, caps, (void *) &req->codec);
|
ret = gst_avdtp_sink_init_sbc_pkt_conf (self, caps, (void *) &req->codec);
|
||||||
else if (gst_structure_has_name (structure, "audio/mpeg"))
|
|
||||||
ret = gst_avdtp_sink_init_mp3_pkt_conf (self, caps, (void *) &req->codec);
|
|
||||||
else
|
else
|
||||||
ret = FALSE;
|
ret = gst_avdtp_sink_init_mp3_pkt_conf (self, caps, (void *) &req->codec);
|
||||||
|
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
GST_ERROR_OBJECT (self, "Couldn't parse caps " "to packet configuration");
|
GST_ERROR_OBJECT (self, "Couldn't parse caps " "to packet configuration");
|
||||||
|
|
Loading…
Reference in a new issue