Skip to contentSkip to conversation

Initial VDP implementation

PATCH In review Prasad Bhat 2 participants 12 messages Aug 16, 2011 – Aug 18, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/6 Initial VDP implementation

---
 Makefile.am |    1 +
 audio/vdp.c | 2026 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 audio/vdp.h |  112 ++++
 3 files changed, 2139 insertions(+), 0 deletions(-)
 create mode 100644 audio/vdp.c
 create mode 100644 audio/vdp.h
Makefile.am +1 -0
index 3c8ab40..f1c9003 100644
@@ -141,6 +141,7 @@ builtin_sources += audio/main.c \
 			audio/source.h audio/source.c \
 			audio/sink.h audio/sink.c \
 			audio/a2dp.h audio/a2dp.c \
+			audio/vdp.h audio/vdp.c \
 			audio/avdtp.h audio/avdtp.c \
 			audio/ipc.h audio/ipc.c \
 			audio/unix.h audio/unix.c \
audio/vdp.c new file +2026 -0

2,026 lines not on this page · raw message

audio/vdp.h new file +112 -0

112 lines not on this page · raw message

Signature · 1 line
1.7.6
#1 lore raw

PATCH 2/6 Implementation of video-sink for VDP

---
 Makefile.am        |    1 +
 audio/video-sink.c |  677 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 audio/video-sink.h |   44 ++++
 3 files changed, 722 insertions(+), 0 deletions(-)
 create mode 100644 audio/video-sink.c
 create mode 100644 audio/video-sink.h
Makefile.am +1 -0
index f1c9003..87b32a4 100644
@@ -142,6 +142,7 @@ builtin_sources += audio/main.c \
 			audio/sink.h audio/sink.c \
 			audio/a2dp.h audio/a2dp.c \
 			audio/vdp.h audio/vdp.c \
+			audio/video-sink.h audio/video-sink.c \
 			audio/avdtp.h audio/avdtp.c \
 			audio/ipc.h audio/ipc.c \
 			audio/unix.h audio/unix.c \
audio/video-sink.c new file +677 -0

678 lines not on this page · raw message

audio/video-sink.h new file +44 -0

45 lines not on this page · raw message

Signature · 1 line
1.7.6
#2 lore raw

Re: [PATCH BlueZ 2/6] Implementation of video-sink for VDP

Hi,

Quoted 7 lines · Prasad Bhat

+static GDBusMethodTable sink_methods[] = {
+       { "Connect",            "",     "",     sink_connect,
+                                               G_DBUS_METHOD_FLAG_ASYNC },
+       { "Disconnect",         "",     "",     sink_disconnect,
+                                               G_DBUS_METHOD_FLAG_ASYNC },
+       { "IsConnected",        "",     "b",    sink_is_connected,
+                                               G_DBUS_METHOD_FLAG_DEPRECATED },

I guess we won't need a deprecated method here.

audio/video-sink.c line 597

Quoted 9 lines

+       { "GetProperties",      "",     "a{sv}",sink_get_properties },
+       { NULL, NULL, NULL, NULL }

audio/video-sink.c new file +7 -0
+};
+
+static GDBusSignalTable sink_signals[] = {
+       { "Connected",                  "",     G_DBUS_SIGNAL_FLAG_DEPRECATED },
+       { "Disconnected",               "",     G_DBUS_SIGNAL_FLAG_DEPRECATED },
+       { "Playing",                    "",     G_DBUS_SIGNAL_FLAG_DEPRECATED },
+       { "Stopped",                    "",     G_DBUS_SIGNAL_FLAG_DEPRECATED },

And here too. Please remember to remove in other parts of the code too.

Quoted 4 lines

+       { "PropertyChanged",            "sv"    },
+       { NULL, NULL }

(quoted diff) +2 -0
+};
+
Signature · 1 line
Luiz Augusto von Dentz
#3 lore raw

PATCH 3/6 Initial video-source implementation for VDP

In reply to Prasad Bhat
---
 Makefile.am          |    1 +
 audio/video-source.c |  570 ++++++++++++++++++++++++++++++++++++++++++++++++++
 audio/video-source.h |   45 ++++
 3 files changed, 616 insertions(+), 0 deletions(-)
 create mode 100644 audio/video-source.c
 create mode 100644 audio/video-source.h
Makefile.am +1 -0
index 87b32a4..5498543 100644
@@ -143,6 +143,7 @@ builtin_sources += audio/main.c \
 			audio/a2dp.h audio/a2dp.c \
 			audio/vdp.h audio/vdp.c \
 			audio/video-sink.h audio/video-sink.c \
+			audio/video-source.h audio/video-source.c \
 			audio/avdtp.h audio/avdtp.c \
 			audio/ipc.h audio/ipc.c \
 			audio/unix.h audio/unix.c \
audio/video-source.c new file +570 -0

570 lines not on this page · raw message

audio/video-source.h new file +45 -0

45 lines not on this page · raw message

Signature · 1 line
1.7.6
#4 lore raw

Re: [PATCH BlueZ 3/6] Initial video-source implementation for VDP

Hi,

Quoted 648 lines · Prasad Bhat

---
 Makefile.am          |    1 +
 audio/video-source.c |  570 ++++++++++++++++++++++++++++++++++++++++++++++++++ audio/video-source.h |   45 ++++

 3 files changed, 616 insertions(+), 0 deletions(-)

 create mode 100644 audio/video-source.c
 create mode 100644 audio/video-source.h

Makefile.am +1 -0
index 87b32a4..5498543 100644
@@ -143,6 +143,7 @@ builtin_sources += audio/main.c \
                        audio/a2dp.h audio/a2dp.c \
                        audio/vdp.h audio/vdp.c \
                        audio/video-sink.h audio/video-sink.c \
+                       audio/video-source.h audio/video-source.c \
                        audio/avdtp.h audio/avdtp.c \
                        audio/ipc.h audio/ipc.c \
                        audio/unix.h audio/unix.c \
audio/video-source.c new file +570 -0
new file mode 100644
index 0000000..aa71de7
@@ -0,0 +1,570 @@
+/*
+ *
+ *  BlueZ - Bluetooth protocol stack for Linux
+ *
+ *  Copyright (C) 2006-2010  Nokia Corporation
+ *  Copyright (C) 2004-2010  Marcel Holtmann <[email protected]>
+ *  Copyright (C) 2009  Joao Paulo Rechi Vita
+ *  Copyright (C) 2011 Prasad Bhat <[email protected]>
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdint.h>
+#include <errno.h>
+
+#include <bluetooth/bluetooth.h>
+#include <bluetooth/sdp.h>
+
+#include <glib.h>
+#include <dbus/dbus.h>
+#include <gdbus.h>
+
+#include "log.h"
+
+#include "device.h"
+#include "avdtp.h"
+#include "media.h"
+#include "vdp.h"
+#include "error.h"
+#include "video-source.h"
+#include "dbus-common.h"
+#include "../src/adapter.h"
+#include "../src/device.h"
+
+#define STREAM_SETUP_RETRY_TIMER 2
+
+struct pending_request {
+       DBusConnection *conn;
+       DBusMessage *msg;
+       unsigned int id;
+};
+
+struct video_source {
+       struct audio_device *dev;
+       struct avdtp *session;
+       struct avdtp_stream *stream;
+       unsigned int cb_id;
+       guint retry_id;
+       avdtp_session_state_t session_state;
+       avdtp_state_t stream_state;
+       video_source_state_t state;
+       struct pending_request *connect;
+       struct pending_request *disconnect;
+       DBusConnection *conn;
+};
+
+struct video_source_state_callback {
+       video_source_state_cb cb;
+       void *user_data;
+       unsigned int id;
+};
+
+static GSList *source_callbacks = NULL;
+
+static unsigned int avdtp_callback_id = 0;
+
+static const char *state2str(video_source_state_t state)
+{
+       switch (state) {
+       case VIDEO_SOURCE_STATE_DISCONNECTED:
+               return "disconnected";
+       case VIDEO_SOURCE_STATE_CONNECTING:
+               return "connecting";
+       case VIDEO_SOURCE_STATE_CONNECTED:
+               return "connected";
+       case VIDEO_SOURCE_STATE_PLAYING:
+               return "playing";
+       default:
+               error("Invalid source state %d", state);
+               return NULL;
+       }
+}
+
+static void source_set_state(struct audio_device *dev, video_source_state_t new_state)
+{
+       struct video_source *source = dev->video_source;
+       const char *state_str;
+       video_source_state_t old_state = source->state;
+       GSList *l;
+
+       source->state = new_state;
+
+       state_str = state2str(new_state);
+       if (state_str)
+               emit_property_changed(dev->conn, dev->path,
+                                       VIDEO_SOURCE_INTERFACE, "State",
+                                       DBUS_TYPE_STRING, &state_str);
+
+       for (l = source_callbacks; l != NULL; l = l->next) {
+               struct video_source_state_callback *cb = l->data;
+               cb->cb(dev, old_state, new_state, cb->user_data);
+       }
+}
+
+static void avdtp_state_callback(struct audio_device *dev,
+                                       struct avdtp *session,
+                                       avdtp_session_state_t old_state,
+                                       avdtp_session_state_t new_state,
+                                       void *user_data)
+{
+       struct video_source *source = dev->video_source;
+
+       if (source == NULL)
+               return;
+
+       switch (new_state) {
+       case AVDTP_SESSION_STATE_DISCONNECTED:
+               source_set_state(dev, VIDEO_SOURCE_STATE_DISCONNECTED);
+               break;
+       case AVDTP_SESSION_STATE_CONNECTING:
+               source_set_state(dev, VIDEO_SOURCE_STATE_CONNECTING);
+               break;
+       case AVDTP_SESSION_STATE_CONNECTED:
+               break;
+       }
+
+       source->session_state = new_state;
+}
+
+static void pending_request_free(struct audio_device *dev,
+                                       struct pending_request *pending)
+{
+       if (pending->conn)
+               dbus_connection_unref(pending->conn);
+       if (pending->msg)
+               dbus_message_unref(pending->msg);
+       if (pending->id)
+               vdp_cancel(dev, pending->id);
+
+       g_free(pending);
+}
+
+static void stream_state_changed(struct avdtp_stream *stream,
+                                       avdtp_state_t old_state,
+                                       avdtp_state_t new_state,
+                                       struct avdtp_error *err,
+                                       void *user_data)
+{
+       struct audio_device *dev = user_data;
+       struct video_source *source = dev->video_source;
+
+       if (err)
+               return;
+
+       switch (new_state) {
+       case AVDTP_STATE_IDLE:
+               if (source->disconnect) {
+                       DBusMessage *reply;
+                       struct pending_request *p;
+
+                       p = source->disconnect;
+                       source->disconnect = NULL;
+
+                       reply = dbus_message_new_method_return(p->msg);
+                       g_dbus_send_message(p->conn, reply);
+                       pending_request_free(dev, p);
+               }
+
+               if (source->session) {
+                       avdtp_unref(source->session);
+                       source->session = NULL;
+               }
+               source->stream = NULL;
+               source->cb_id = 0;
+               break;
+       case AVDTP_STATE_OPEN:
+               source_set_state(dev, VIDEO_SOURCE_STATE_CONNECTED);
+               break;
+       case AVDTP_STATE_STREAMING:
+               source_set_state(dev, VIDEO_SOURCE_STATE_PLAYING);
+               break;
+       case AVDTP_STATE_CONFIGURED:
+       case AVDTP_STATE_CLOSING:
+       case AVDTP_STATE_ABORTING:
+       default:
+               break;
+       }
+
+       source->stream_state = new_state;
+}
+
+static void error_failed(DBusConnection *conn, DBusMessage *msg,
+                                                       const char *desc)
+{
+       DBusMessage *reply = btd_error_failed(msg, desc);
+       g_dbus_send_message(conn, reply);
+}
+
+static gboolean stream_setup_retry(gpointer user_data)
+{
+       struct video_source *source = user_data;
+       struct pending_request *pending = source->connect;
+
+       source->retry_id = 0;
+
+       if (source->stream_state >= AVDTP_STATE_OPEN) {
+               DBG("Stream successfully created, after XCASE connect:connect");
+               if (pending->msg) {
+                       DBusMessage *reply;
+                       reply = dbus_message_new_method_return(pending->msg);
+                       g_dbus_send_message(pending->conn, reply);
+               }
+       } else {
+               DBG("Stream setup failed, after XCASE connect:connect");
+               if (pending->msg)
+                       error_failed(pending->conn, pending->msg, "Stream setup failed");
+       }
+
+       source->connect = NULL;
+       pending_request_free(source->dev, pending);
+
+       return FALSE;
+}
+
+static void stream_setup_complete(struct avdtp *session, struct vdp_sep *sep,
+                                       struct avdtp_stream *stream,
+                                       struct avdtp_error *err, void *user_data)
+{
+       struct video_source *source = user_data;
+       struct pending_request *pending;
+
+       pending = source->connect;
+
+       pending->id = 0;
+
+       if (stream) {
+               DBG("Stream successfully created");
+
+               if (pending->msg) {
+                       DBusMessage *reply;
+                       reply = dbus_message_new_method_return(pending->msg);
+                       g_dbus_send_message(pending->conn, reply);
+               }
+
+               source->connect = NULL;
+               pending_request_free(source->dev, pending);
+
+               return;
+       }
+
+       avdtp_unref(source->session);
+       source->session = NULL;
+       if (avdtp_error_category(err) == AVDTP_ERRNO
+                       && avdtp_error_posix_errno(err) != EHOSTDOWN) {
+               DBG("connect:connect XCASE detected");
+               source->retry_id = g_timeout_add_seconds(STREAM_SETUP_RETRY_TIMER,
+                                                       stream_setup_retry,
+                                                       source);
+       } else {
+               if (pending->msg)
+                       error_failed(pending->conn, pending->msg, "Stream setup failed");
+               source->connect = NULL;
+               pending_request_free(source->dev, pending);
+               DBG("Stream setup failed : %s", avdtp_strerror(err));
+       }
+}
+
+static void select_complete(struct avdtp *session, struct vdp_sep *sep,
+                       GSList *caps, void *user_data)
+{
+       struct video_source *source = user_data;
+       struct pending_request *pending;
+       int id;
+
+       pending = source->connect;
+
+       pending->id = 0;
+
+       if (caps == NULL)
+               goto failed;
+
+       id = vdp_config(session, sep, stream_setup_complete, caps, source);
+       if (id == 0)
+               goto failed;
+
+       pending->id = id;
+       return;
+
+failed:
+       if (pending->msg)
+               error_failed(pending->conn, pending->msg, "Stream setup failed");
+       pending_request_free(source->dev, pending);
+       source->connect = NULL;
+       avdtp_unref(source->session);
+       source->session = NULL;
+}
+
+static void discovery_complete(struct avdtp *session, GSList *seps, struct avdtp_error *err,
+                               void *user_data)
+{
+       struct video_source *source = user_data;
+       struct pending_request *pending;
+       int id;
+
+       pending = source->connect;
+
+       if (err) {
+               avdtp_unref(source->session);
+               source->session = NULL;
+               if (avdtp_error_category(err) == AVDTP_ERRNO
+                               && avdtp_error_posix_errno(err) != EHOSTDOWN) {
+                       DBG("connect:connect XCASE detected");
+                       source->retry_id =
+                               g_timeout_add_seconds(STREAM_SETUP_RETRY_TIMER,
+                                                       stream_setup_retry,
+                                                       source);
+               } else
+                       goto failed;
+               return;
+       }
+
+       DBG("Discovery complete");
+
+       id = vdp_select_capabilities(source->session, AVDTP_SEP_TYPE_SOURCE, NULL,
+                                               select_complete, source);
+       if (id == 0)
+               goto failed;
+
+       pending->id = id;
+       return;
+
+failed:
+       if (pending->msg)
+               error_failed(pending->conn, pending->msg, "Stream setup failed");
+       pending_request_free(source->dev, pending);
+       source->connect = NULL;
+       avdtp_unref(source->session);
+       source->session = NULL;
+}
+
+gboolean video_source_setup_stream(struct video_source *source, struct avdtp *session)
+{
+       if (source->connect || source->disconnect)
+               return FALSE;
+
+       if (session && !source->session)
+               source->session = avdtp_ref(session);
+
+       if (!source->session)
+               return FALSE;
+
+       avdtp_set_auto_disconnect(source->session, FALSE);
+
+       if (avdtp_discover(source->session, discovery_complete, source) < 0)
+               return FALSE;
+
+       source->connect = g_new0(struct pending_request, 1);
+
+       return TRUE;
+}
+
+static DBusMessage *source_connect(DBusConnection *conn,
+                               DBusMessage *msg, void *data)
+{
+       struct audio_device *dev = data;
+       struct video_source *source = dev->video_source;
+       struct pending_request *pending;
+
+       if (!source->session)
+               source->session = avdtp_get(&dev->src, &dev->dst);
+
+       if (!source->session)
+               return btd_error_failed(msg, "Unable to get a session");
+
+       if (source->connect || source->disconnect)
+               return btd_error_busy(msg);
+
+       if (source->stream_state >= AVDTP_STATE_OPEN)
+               return btd_error_already_connected(msg);
+
+       if (!video_source_setup_stream(source, NULL))
+               return btd_error_failed(msg, "Failed to create a stream");
+
+       dev->auto_connect = FALSE;
+
+       pending = source->connect;
+
+       pending->conn = dbus_connection_ref(conn);
+       pending->msg = dbus_message_ref(msg);
+
+       DBG("stream creation in progress");
+
+       return NULL;
+}
+
+static DBusMessage *source_disconnect(DBusConnection *conn,
+                                       DBusMessage *msg, void *data)
+{
+       struct audio_device *device = data;
+       struct video_source *source = device->video_source;
+       struct pending_request *pending;
+       int err;
+
+       if (!source->session)
+               return btd_error_not_connected(msg);
+
+       if (source->connect || source->disconnect)
+               return btd_error_busy(msg);
+
+       if (source->stream_state < AVDTP_STATE_OPEN) {
+               DBusMessage *reply = dbus_message_new_method_return(msg);
+               if (!reply)
+                       return NULL;
+               avdtp_unref(source->session);
+               source->session = NULL;
+               return reply;
+       }
+
+       err = avdtp_close(source->session, source->stream, FALSE);
+       if (err < 0)
+               return btd_error_failed(msg, strerror(-err));
+
+       pending = g_new0(struct pending_request, 1);
+       pending->conn = dbus_connection_ref(conn);
+       pending->msg = dbus_message_ref(msg);
+       source->disconnect = pending;
+
+       return NULL;
+}
+
+static DBusMessage *source_get_properties(DBusConnection *conn,
+                                       DBusMessage *msg, void *data)
+{
+       struct audio_device *device = data;
+       struct video_source *source = device->video_source;
+       DBusMessage *reply;
+       DBusMessageIter iter;
+       DBusMessageIter dict;
+       const char *state;
+
+       reply = dbus_message_new_method_return(msg);
+       if (!reply)
+               return NULL;
+
+       dbus_message_iter_init_append(reply, &iter);
+
+       dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
+                       DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
+                       DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
+                       DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict);
+
+       /* State */
+       state = state2str(source->state);
+       if (state)
+               dict_append_entry(&dict, "State", DBUS_TYPE_STRING, &state);
+
+       dbus_message_iter_close_container(&iter, &dict);
+
+       return reply;
+}
+
+static GDBusMethodTable source_methods[] = {
+       { "Connect",            "",     "",     source_connect,
+                                               G_DBUS_METHOD_FLAG_ASYNC },
+       { "Disconnect",         "",     "",     source_disconnect,
+                                               G_DBUS_METHOD_FLAG_ASYNC },
+       { "GetProperties",      "",     "a{sv}",source_get_properties },
+       { NULL, NULL, NULL, NULL }
+};
+
+
+static GDBusSignalTable source_signals[] = {
+       { "PropertyChanged",            "sv"    },
+       { NULL, NULL }
+};
+
+static void video_source_free(struct audio_device *dev)
+{
+       struct video_source *source = dev->video_source;
+
+       if (source->cb_id)
+               avdtp_stream_remove_cb(source->session, source->stream,
+                                       source->cb_id);
+
+       if (source->session)
+               avdtp_unref(source->session);
+
+       if (source->connect)
+               pending_request_free(dev, source->connect);
+
+       if (source->disconnect)
+               pending_request_free(dev, source->disconnect);
+
+       if (source->retry_id)
+               g_source_remove(source->retry_id);
+
+       g_free(source);
+       dev->source = NULL;
+}
+
+static void path_unregister(void *data)
+{
+       struct audio_device *dev = data;
+
+       DBG("Unregistered interface %s on path %s",
+               VIDEO_SOURCE_INTERFACE, dev->path);
+
+       video_source_free(dev);
+}
+
+struct video_source *video_source_register(struct audio_device *dev)
+{
+       struct video_source *source;
+
+       if (!g_dbus_register_interface(dev->conn, dev->path,
+                                       VIDEO_SOURCE_INTERFACE,
+                                       source_methods, source_signals, NULL,
+                                       dev, path_unregister))
+               return NULL;
+
+       DBG("Registered interface %s on path %s", VIDEO_SOURCE_INTERFACE,
+                                                               dev->path);
+
+       if (avdtp_callback_id == 0)
+               avdtp_callback_id = avdtp_add_state_cb(avdtp_state_callback,
+                                                                       NULL);
+
+       source = g_new0(struct video_source, 1);
+
+       source->dev = dev;
+
+       return source;
+}
+
+gboolean video_source_new_stream(struct audio_device *dev, struct avdtp *session,
+                               struct avdtp_stream *stream)
+{
+       struct video_source *source = dev->video_source;
+
+       if (source->stream)
+               return FALSE;
+
+       if (!source->session)
+               source->session = avdtp_ref(session);
+
+       source->stream = stream;
+
+       source->cb_id = avdtp_stream_add_cb(session, stream,
+                                               stream_state_changed, dev);
+
+       return TRUE;
+}
audio/video-source.h new file +45 -1
new file mode 100644
index 0000000..97af55f
@@ -0,0 +1,45 @@
+/*
+ *
+ *  BlueZ - Bluetooth protocol stack for Linux
+ *
+ *  Copyright (C) 2006-2010  Nokia Corporation
+ *  Copyright (C) 2004-2010  Marcel Holtmann <[email protected]>
+ *  Copyright (C) 2011 Prasad Bhat <[email protected]>
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#define VIDEO_SOURCE_INTERFACE "org.bluez.VideoSource"
+
+typedef enum {
+       VIDEO_SOURCE_STATE_DISCONNECTED,
+       VIDEO_SOURCE_STATE_CONNECTING,
+       VIDEO_SOURCE_STATE_CONNECTED,
+       VIDEO_SOURCE_STATE_PLAYING,
+} video_source_state_t;
+
+typedef void (*video_source_state_cb) (struct audio_device *dev,
+                               video_source_state_t old_state,
+                               video_source_state_t new_state,
+                               void *user_data);
+struct video_source *video_source_register(struct audio_device *dev);
+void video_source_unregister(struct audio_device *dev);
+
+gboolean video_source_new_stream(struct audio_device *dev,
+                                       struct avdtp *session,
+                                       struct avdtp_stream *stream);
+gboolean video_source_setup_stream(struct video_source *source, struct avdtp *session);
--
Quoted 1 line

1.7.6

Ack, note that this does not contain any deprecated code.

Signature · 1 line
Luiz Augusto von Dentz
#5 lore raw

PATCH 4/6 The changes in media.c required for VDP.

In reply to Prasad Bhat
---
 audio/media.c |  142 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 141 insertions(+), 1 deletions(-)
audio/media.c +141 -1
index 42d8637..0aff0d4 100644
@@ -42,6 +42,7 @@
 #include "media.h"
 #include "transport.h"
 #include "a2dp.h"
+#include "vdp.h"
 #include "headset.h"
 #include "manager.h"
 
@@ -71,6 +72,7 @@ struct endpoint_request {
 
 struct media_endpoint {
 	struct a2dp_sep		*sep;
+	struct vdp_sep		*vdp_sep;
 	char			*sender;	/* Endpoint DBus bus id */
 	char			*path;		/* Endpoint object path */
 	char			*uuid;		/* Endpoint property UUID */
@@ -141,6 +143,10 @@ static void media_endpoint_remove(struct media_endpoint *endpoint)
 		return;
 	}
 
+	if (endpoint->vdp_sep) {
+		vdp_remove_sep(endpoint->vdp_sep);
+		return;
+	}
 	info("Endpoint unregistered: sender=%s path=%s", endpoint->sender,
 			endpoint->path);
 
@@ -539,6 +545,113 @@ static struct a2dp_endpoint a2dp_endpoint = {
 	.set_delay = set_delay
 };
 
+static const char *vdp_get_name(struct vdp_sep *sep, void *user_data)
+{
+	struct media_endpoint *endpoint = user_data;
+
+	return endpoint->sender;
+}
+
+static size_t vdp_get_capabilities(struct vdp_sep *sep, uint8_t **capabilities,
+							void *user_data)
+{
+	struct media_endpoint *endpoint = user_data;
+
+	*capabilities = endpoint->capabilities;
+	return endpoint->size;
+}
+
+struct vdp_config_data {
+	guint setup_id;
+	vdp_endpoint_config_t cb;
+};
+
+struct vdp_select_data {
+	guint setup_id;
+	vdp_endpoint_select_t cb;
+};
+
+static void vdp_select_cb(struct media_endpoint *endpoint, void *ret, int size,
+							void *user_data)
+{
+	struct vdp_select_data *data = user_data;
+
+	data->cb(endpoint->vdp_sep, data->setup_id, ret, size);
+}
+
+static int vdp_select_config(struct vdp_sep *sep, uint8_t *capabilities,
+				size_t length, guint setup_id,
+				vdp_endpoint_select_t cb, void *user_data)
+{
+	struct media_endpoint *endpoint = user_data;
+	struct vdp_select_data *data;
+
+	data = g_new0(struct vdp_select_data, 1);
+	data->setup_id = setup_id;
+	data->cb = cb;
+
+	if (select_configuration(endpoint, capabilities, length,
+					vdp_select_cb, data, g_free) == TRUE)
+		return 0;
+
+	g_free(data);
+	return -ENOMEM;
+}
+
+static void vdp_config_cb(struct media_endpoint *endpoint, void *ret, int size,
+							void *user_data)
+{
+	struct vdp_config_data *data = user_data;
+
+	data->cb(endpoint->vdp_sep, data->setup_id, ret ? TRUE : FALSE);
+}
+
+static int vdp_set_config(struct vdp_sep *sep, struct audio_device *dev,
+				uint8_t *configuration, size_t length,
+				guint setup_id, vdp_endpoint_config_t cb,
+				void *user_data)
+{
+	struct media_endpoint *endpoint = user_data;
+	struct vdp_config_data *data;
+
+	data = g_new0(struct vdp_config_data, 1);
+	data->setup_id = setup_id;
+	data->cb = cb;
+
+	if (set_configuration(endpoint, dev, configuration, length,
+					vdp_config_cb, data, g_free) == TRUE)
+		return 0;
+
+	g_free(data);
+	return -ENOMEM;
+}
+
+static void vdp_clear_config(struct vdp_sep *sep, void *user_data)
+{
+	struct media_endpoint *endpoint = user_data;
+
+	clear_configuration(endpoint);
+}
+
+static void vdp_set_delay(struct vdp_sep *sep, uint16_t delay, void *user_data)
+{
+	struct media_endpoint *endpoint = user_data;
+
+	if (endpoint->transport == NULL)
+		return;
+
+	media_transport_update_delay(endpoint->transport, delay);
+}
+
+static struct vdp_endpoint vdp_endpoint = {
+	.get_name = vdp_get_name,
+	.get_capabilities = vdp_get_capabilities,
+	.select_configuration = vdp_select_config,
+	.set_configuration = vdp_set_config,
+	.clear_configuration = vdp_clear_config,
+	.set_delay = vdp_set_delay
+};
+
 static void a2dp_destroy_endpoint(void *user_data)
 {
 	struct media_endpoint *endpoint = user_data;
@@ -552,6 +665,19 @@ static void a2dp_destroy_endpoint(void *user_data)
 	release_endpoint(endpoint);
 }
 
+static void vdp_destroy_endpoint(void *user_data)
+{
+	struct media_endpoint *endpoint = user_data;
+
+	if (endpoint->transport) {
+		media_transport_destroy(endpoint->transport);
+		endpoint->transport = NULL;
+	}
+
+	endpoint->sep = NULL;
+	release_endpoint(endpoint);
+}
+
 static struct media_endpoint *media_endpoint_create(struct media_adapter *adapter,
 						const char *sender,
 						const char *path,
@@ -592,7 +718,21 @@ static struct media_endpoint *media_endpoint_create(struct media_adapter *adapte
 					endpoint, a2dp_destroy_endpoint, err);
 		if (endpoint->sep == NULL)
 			goto failed;
-	} else if (strcasecmp(uuid, HFP_AG_UUID) == 0 ||
+	} else if (strcasecmp(uuid, VDP_SOURCE_UUID) == 0) {
+ 		endpoint->vdp_sep = vdp_add_sep(&adapter->src,
+					AVDTP_SEP_TYPE_SOURCE, codec,
+					delay_reporting, &vdp_endpoint,
+					endpoint, vdp_destroy_endpoint, err);
+		if (endpoint->vdp_sep == NULL)
+			goto failed;
+	} else if (strcasecmp(uuid, VDP_SINK_UUID) == 0) {
+		endpoint->vdp_sep = vdp_add_sep(&adapter->src,
+					AVDTP_SEP_TYPE_SINK, codec,
+					delay_reporting, &vdp_endpoint,
+					endpoint, vdp_destroy_endpoint, err);
+		if (endpoint->vdp_sep == NULL)
+			goto failed;
+	}else if (strcasecmp(uuid, HFP_AG_UUID) == 0 ||
 					g_strcmp0(uuid, HSP_AG_UUID) == 0) {
 		struct audio_device *dev;
 
Signature · 1 line
1.7.6
#6 lore raw

Re: [PATCH BlueZ 4/6] The changes in media.c required for VDP.

Hi,

Quoted 193 lines · Prasad Bhat

---
 audio/media.c |  142 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-

 1 files changed, 141 insertions(+), 1 deletions(-)
audio/media.c +2 -0
index 42d8637..0aff0d4 100644
@@ -42,6 +42,7 @@
  #include "media.h"
  #include "transport.h"
  #include "a2dp.h"
+#include "vdp.h"
  #include "headset.h"
  #include "manager.h"
 
@@ -71,6 +72,7 @@ struct endpoint_request {
 
  struct media_endpoint {
        struct a2dp_sep         *sep;
+       struct vdp_sep          *vdp_sep;

       char                    *sender;        /* Endpoint DBus bus id */ char                    *path;          /* Endpoint object path */ char                    *uuid;          /* Endpoint property UUID */

audio/media.c +4 -0
@@ -141,6 +143,10 @@ static void media_endpoint_remove(struct media_endpoint *endpoint)
                return;
        }
 
+       if (endpoint->vdp_sep) {
+               vdp_remove_sep(endpoint->vdp_sep);
+               return;
+       }
        info("Endpoint unregistered: sender=%s path=%s", endpoint->sender,
                        endpoint->path);
 
@@ -539,6 +545,113 @@ static struct a2dp_endpoint a2dp_endpoint = {

       .set_delay = set_delay
 };

audio/media.c +107 -0
+static const char *vdp_get_name(struct vdp_sep *sep, void *user_data)
+{
+       struct media_endpoint *endpoint = user_data;
+
+       return endpoint->sender;
+}
+
+static size_t vdp_get_capabilities(struct vdp_sep *sep, uint8_t **capabilities,
+                                                       void *user_data)
+{
+       struct media_endpoint *endpoint = user_data;
+
+       *capabilities = endpoint->capabilities;
+       return endpoint->size;
+}
+
+struct vdp_config_data {
+       guint setup_id;
+       vdp_endpoint_config_t cb;
+};
+
+struct vdp_select_data {
+       guint setup_id;
+       vdp_endpoint_select_t cb;
+};
+
+static void vdp_select_cb(struct media_endpoint *endpoint, void *ret, int size,
+                                                       void *user_data)
+{
+       struct vdp_select_data *data = user_data;
+
+       data->cb(endpoint->vdp_sep, data->setup_id, ret, size);
+}
+
+static int vdp_select_config(struct vdp_sep *sep, uint8_t *capabilities,
+                               size_t length, guint setup_id,
+                               vdp_endpoint_select_t cb, void *user_data)
+{
+       struct media_endpoint *endpoint = user_data;
+       struct vdp_select_data *data;
+
+       data = g_new0(struct vdp_select_data, 1);
+       data->setup_id = setup_id;
+       data->cb = cb;
+
+       if (select_configuration(endpoint, capabilities, length,
+                                       vdp_select_cb, data, g_free) == TRUE)
+               return 0;
+
+       g_free(data);
+       return -ENOMEM;
+}
+
+static void vdp_config_cb(struct media_endpoint *endpoint, void *ret, int size,
+                                                       void *user_data)
+{
+       struct vdp_config_data *data = user_data;
+
+       data->cb(endpoint->vdp_sep, data->setup_id, ret ? TRUE : FALSE);
+}
+
+static int vdp_set_config(struct vdp_sep *sep, struct audio_device *dev,
+                               uint8_t *configuration, size_t length,
+                               guint setup_id, vdp_endpoint_config_t cb,
+                               void *user_data)
+{
+       struct media_endpoint *endpoint = user_data;
+       struct vdp_config_data *data;
+
+       data = g_new0(struct vdp_config_data, 1);
+       data->setup_id = setup_id;
+       data->cb = cb;
+
+       if (set_configuration(endpoint, dev, configuration, length,
+                                       vdp_config_cb, data, g_free) == TRUE)
+               return 0;
+
+       g_free(data);
+       return -ENOMEM;
+}
+
+static void vdp_clear_config(struct vdp_sep *sep, void *user_data)
+{
+       struct media_endpoint *endpoint = user_data;
+
+       clear_configuration(endpoint);
+}
+
+static void vdp_set_delay(struct vdp_sep *sep, uint16_t delay, void *user_data)
+{
+       struct media_endpoint *endpoint = user_data;
+
+       if (endpoint->transport == NULL)
+               return;
+
+       media_transport_update_delay(endpoint->transport, delay);
+}
+
+static struct vdp_endpoint vdp_endpoint = {
+       .get_name = vdp_get_name,
+       .get_capabilities = vdp_get_capabilities,
+       .select_configuration = vdp_select_config,
+       .set_configuration = vdp_set_config,
+       .clear_configuration = vdp_clear_config,
+       .set_delay = vdp_set_delay
+};
+

 static void a2dp_destroy_endpoint(void *user_data) {
       struct media_endpoint *endpoint = user_data;

audio/media.c +28 -2
@@ -552,6 +665,19 @@ static void a2dp_destroy_endpoint(void *user_data)
        release_endpoint(endpoint);
  }
 
+static void vdp_destroy_endpoint(void *user_data)
+{
+       struct media_endpoint *endpoint = user_data;
+
+       if (endpoint->transport) {
+               media_transport_destroy(endpoint->transport);
+               endpoint->transport = NULL;
+       }
+
+       endpoint->sep = NULL;
+       release_endpoint(endpoint);
+}
+
  static struct media_endpoint *media_endpoint_create(struct media_adapter *adapter,
                                                const char *sender,
                                                const char *path,
@@ -592,7 +718,21 @@ static struct media_endpoint *media_endpoint_create(struct media_adapter *adapte
                                        endpoint, a2dp_destroy_endpoint, err);
                if (endpoint->sep == NULL)
                        goto failed;
-       } else if (strcasecmp(uuid, HFP_AG_UUID) == 0 ||
+       } else if (strcasecmp(uuid, VDP_SOURCE_UUID) == 0) {
+               endpoint->vdp_sep = vdp_add_sep(&adapter->src,
+                                       AVDTP_SEP_TYPE_SOURCE, codec,
+                                       delay_reporting, &vdp_endpoint,
+                                       endpoint, vdp_destroy_endpoint, err);
+               if (endpoint->vdp_sep == NULL)
+                       goto failed;
+       } else if (strcasecmp(uuid, VDP_SINK_UUID) == 0) {
+               endpoint->vdp_sep = vdp_add_sep(&adapter->src,
+                                       AVDTP_SEP_TYPE_SINK, codec,
+                                       delay_reporting, &vdp_endpoint,
+                                       endpoint, vdp_destroy_endpoint, err);
+               if (endpoint->vdp_sep == NULL)
+                       goto failed;
+       }else if (strcasecmp(uuid, HFP_AG_UUID) == 0 ||
                                        g_strcmp0(uuid, HSP_AG_UUID) == 0) {
                struct audio_device *dev;
 
--
Quoted 1 line

1.7.6

This is another reason why we want a common code to handle the seps, so a2dp_sep and vdp_sep could be merged, in fact they represent the same thing an AVDTP sep.

Signature · 1 line
Luiz Augusto von Dentz
#7 lore raw

PATCH 5/6 This adds video-sink and video-source interfaces and vdp_server_driver to audio/manager{.c, .h}

In reply to Prasad Bhat
---
 audio/manager.c |   87 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 audio/manager.h |    2 +
 2 files changed, 89 insertions(+), 0 deletions(-)
audio/manager.c +87 -0
index 6e583cf..352d91d 100644
@@ -59,10 +59,13 @@
 #include "avdtp.h"
 #include "media.h"
 #include "a2dp.h"
+#include "vdp.h"
 #include "headset.h"
 #include "gateway.h"
 #include "sink.h"
 #include "source.h"
+#include "video-sink.h"
+#include "video-source.h"
 #include "control.h"
 #include "manager.h"
 #include "sdpd.h"
@@ -119,6 +122,8 @@ static struct enabled_interfaces enabled = {
 	.socket		= TRUE,
 	.media		= FALSE,
 	.media_player	= FALSE,
+	.video_sink	= FALSE,
+	.video_source	= FALSE,
 };
 
 static struct audio_adapter *find_adapter(GSList *list,
@@ -149,6 +154,10 @@ gboolean server_is_enabled(bdaddr_t *src, uint16_t svc)
 		return enabled.sink;
 	case AUDIO_SOURCE_SVCLASS_ID:
 		return enabled.source;
+	case VIDEO_SINK_SVCLASS_ID:
+		return enabled.video_sink;
+	case VIDEO_SOURCE_SVCLASS_ID:
+		return enabled.video_source;
 	case AV_REMOTE_TARGET_SVCLASS_ID:
 	case AV_REMOTE_SVCLASS_ID:
 		return enabled.control;
@@ -214,6 +223,16 @@ static void handle_uuid(const char *uuidstr, struct audio_device *device)
 		if (device->source == NULL)
 			device->source = source_init(device);
 		break;
+	case VIDEO_SINK_SVCLASS_ID:
+		DBG("Found Video Sink");
+		if (device->video_sink == NULL)
+			device->video_sink = video_sink_register(device);
+		break;
+	case VIDEO_SOURCE_SVCLASS_ID:
+		DBG("Found Video Source");
+		if (device->video_source == NULL)	
+			device->video_source = video_source_register(device);
+		break;
 	case AV_REMOTE_SVCLASS_ID:
 	case AV_REMOTE_TARGET_SVCLASS_ID:
 		DBG("Found AV %s", uuid16 == AV_REMOTE_SVCLASS_ID ?
@@ -1035,6 +1054,45 @@ static void a2dp_server_remove(struct btd_adapter *adapter)
 	audio_adapter_unref(adp);
 }
 
+static int vdp_server_probe(struct btd_adapter *adapter)
+{
+	struct audio_adapter *adp;
+	const gchar *path = adapter_get_path(adapter);
+	bdaddr_t src;
+	int err;
+
+	DBG("path %s", path);
+
+	adp = audio_adapter_get(adapter);
+	if (!adp)
+		return -EINVAL;
+
+	adapter_get_address(adapter, &src);
+
+	err = vdp_register(connection, &src, config);
+	if (err < 0)
+		audio_adapter_unref(adp);
+
+	return err;
+}
+
+static void vdp_server_remove(struct btd_adapter *adapter)
+{
+	struct audio_adapter *adp;
+	const gchar *path = adapter_get_path(adapter);
+	bdaddr_t src;
+
+	DBG("path %s", path);
+
+	adp = find_adapter(adapters, adapter);
+	if (!adp)
+		return;
+
+	adapter_get_address(adapter, &src);
+	vdp_unregister(&src);
+	audio_adapter_unref(adp);
+}
+
 static int avrcp_server_probe(struct btd_adapter *adapter)
 {
 	struct audio_adapter *adp;
@@ -1105,6 +1163,7 @@ static struct btd_device_driver audio_driver = {
 	.name	= "audio",
 	.uuids	= BTD_UUIDS(HSP_HS_UUID, HFP_HS_UUID, HSP_AG_UUID, HFP_AG_UUID,
 			ADVANCED_AUDIO_UUID, A2DP_SOURCE_UUID, A2DP_SINK_UUID,
+			VIDEO_DISTRIBUTION_UUID, VDP_SOURCE_UUID, VDP_SINK_UUID,
 			AVRCP_TARGET_UUID, AVRCP_REMOTE_UUID),
 	.probe	= audio_probe,
 	.remove	= audio_remove,
@@ -1128,6 +1187,12 @@ static struct btd_adapter_driver a2dp_server_driver = {
 	.remove	= a2dp_server_remove,
 };
 
+static struct btd_adapter_driver vdp_server_driver = {
+	.name	= "video-vdp",
+	.probe	= vdp_server_probe,
+	.remove	= vdp_server_remove,
+};
+
 static struct btd_adapter_driver avrcp_server_driver = {
 	.name	= "audio-control",
 	.probe	= avrcp_server_probe,
@@ -1166,6 +1231,10 @@ int audio_manager_init(DBusConnection *conn, GKeyFile *conf,
 			enabled.sink = TRUE;
 		else if (g_str_equal(list[i], "Source"))
 			enabled.source = TRUE;
+		else if (g_str_equal(list[i], "VideoSink"))
+			enabled.video_sink = TRUE;
+		else if (g_str_equal(list[i], "VideoSource"))
+			enabled.video_source = TRUE;
 		else if (g_str_equal(list[i], "Control"))
 			enabled.control = TRUE;
 		else if (g_str_equal(list[i], "Socket"))
@@ -1189,6 +1258,10 @@ int audio_manager_init(DBusConnection *conn, GKeyFile *conf,
 			enabled.sink = FALSE;
 		else if (g_str_equal(list[i], "Source"))
 			enabled.source = FALSE;
+		else if (g_str_equal(list[i], "VideoSink"))
+			enabled.video_sink = FALSE;
+		else if (g_str_equal(list[i], "VideoSource"))
+			enabled.video_source = FALSE;
 		else if (g_str_equal(list[i], "Control"))
 			enabled.control = FALSE;
 		else if (g_str_equal(list[i], "Socket"))
@@ -1239,6 +1312,9 @@ proceed:
 	if (enabled.source || enabled.sink)
 		btd_register_adapter_driver(&a2dp_server_driver);
 
+	if (enabled.video_source || enabled.video_sink)
+		btd_register_adapter_driver(&vdp_server_driver);
+
 	if (enabled.control)
 		btd_register_adapter_driver(&avrcp_server_driver);
 
@@ -1278,6 +1354,9 @@ void audio_manager_exit(void)
 	if (enabled.source || enabled.sink)
 		btd_unregister_adapter_driver(&a2dp_server_driver);
 
+	if (enabled.video_source || enabled.video_sink)
+		btd_unregister_adapter_driver(&vdp_server_driver);
+
 	if (enabled.control)
 		btd_unregister_adapter_driver(&avrcp_server_driver);
 
@@ -1320,6 +1399,14 @@ struct audio_device *manager_find_device(const char *path,
 				&& !dev->source)
 			continue;
 
+		if (interface && !strcmp(VIDEO_SINK_INTERFACE, interface)
+				&& !dev->video_sink)
+			continue;
+	
+		if (interface && !strcmp(VIDEO_SOURCE_INTERFACE, interface)
+				&& !dev->video_source)
+			continue;
+
 		if (interface && !strcmp(AUDIO_CONTROL_INTERFACE, interface)
 				&& !dev->control)
 			continue;
audio/manager.h +2 -0
index cfc646c..6c61da4 100644
@@ -28,6 +28,8 @@ struct enabled_interfaces {
 	gboolean gateway;
 	gboolean sink;
 	gboolean source;
+	gboolean video_sink;
+	gboolean video_source;
 	gboolean control;
 	gboolean socket;
 	gboolean media;
Signature · 1 line
1.7.6
#8 lore raw

Re: [PATCH BlueZ 5/6] This adds video-sink and video-source interfaces and vdp_server_driver to audio/manager{.c, .h}

Hi,

Quoted 198 lines · Prasad Bhat

---
 audio/manager.c |   87 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ audio/manager.h |    2 +

 2 files changed, 89 insertions(+), 0 deletions(-)
audio/manager.c +5 -0
index 6e583cf..352d91d 100644
@@ -59,10 +59,13 @@
  #include "avdtp.h"
  #include "media.h"
  #include "a2dp.h"
+#include "vdp.h"
  #include "headset.h"
  #include "gateway.h"
  #include "sink.h"
  #include "source.h"
+#include "video-sink.h"
+#include "video-source.h"
  #include "control.h"
  #include "manager.h"
  #include "sdpd.h"
@@ -119,6 +122,8 @@ static struct enabled_interfaces enabled = {
        .socket         = TRUE,
        .media          = FALSE,
        .media_player   = FALSE,
+       .video_sink     = FALSE,
+       .video_source   = FALSE,
  };
 
  static struct audio_adapter *find_adapter(GSList *list,
@@ -149,6 +154,10 @@ gboolean server_is_enabled(bdaddr_t *src, uint16_t svc)
                return enabled.sink;

       case AUDIO_SOURCE_SVCLASS_ID:
               return enabled.source;
+       case VIDEO_SINK_SVCLASS_ID:
+               return enabled.video_sink;
+       case VIDEO_SOURCE_SVCLASS_ID:
+               return enabled.video_source;
       case AV_REMOTE_TARGET_SVCLASS_ID:
       case AV_REMOTE_SVCLASS_ID:
               return enabled.control;

audio/manager.c +10 -0
@@ -214,6 +223,16 @@ static void handle_uuid(const char *uuidstr, struct audio_device *device)
                if (device->source == NULL)
                        device->source = source_init(device);
                break;
+       case VIDEO_SINK_SVCLASS_ID:
+               DBG("Found Video Sink");
+               if (device->video_sink == NULL)
+                       device->video_sink = video_sink_register(device);
+               break;
+       case VIDEO_SOURCE_SVCLASS_ID:
+               DBG("Found Video Source");
+               if (device->video_source == NULL)
+                       device->video_source = video_source_register(device);
+               break;

       case AV_REMOTE_SVCLASS_ID:
       case AV_REMOTE_TARGET_SVCLASS_ID:
               DBG("Found AV %s", uuid16 == AV_REMOTE_SVCLASS_ID ?

audio/manager.c +68 -0
@@ -1035,6 +1054,45 @@ static void a2dp_server_remove(struct btd_adapter *adapter)
        audio_adapter_unref(adp);
  }
 
+static int vdp_server_probe(struct btd_adapter *adapter)
+{
+       struct audio_adapter *adp;
+       const gchar *path = adapter_get_path(adapter);
+       bdaddr_t src;
+       int err;
+
+       DBG("path %s", path);
+
+       adp = audio_adapter_get(adapter);
+       if (!adp)
+               return -EINVAL;
+
+       adapter_get_address(adapter, &src);
+
+       err = vdp_register(connection, &src, config);
+       if (err < 0)
+               audio_adapter_unref(adp);
+
+       return err;
+}
+
+static void vdp_server_remove(struct btd_adapter *adapter)
+{
+       struct audio_adapter *adp;
+       const gchar *path = adapter_get_path(adapter);
+       bdaddr_t src;
+
+       DBG("path %s", path);
+
+       adp = find_adapter(adapters, adapter);
+       if (!adp)
+               return;
+
+       adapter_get_address(adapter, &src);
+       vdp_unregister(&src);
+       audio_adapter_unref(adp);
+}
+
  static int avrcp_server_probe(struct btd_adapter *adapter)
  {
        struct audio_adapter *adp;
@@ -1105,6 +1163,7 @@ static struct btd_device_driver audio_driver = {
        .name   = "audio",
        .uuids  = BTD_UUIDS(HSP_HS_UUID, HFP_HS_UUID, HSP_AG_UUID, HFP_AG_UUID,
                        ADVANCED_AUDIO_UUID, A2DP_SOURCE_UUID, A2DP_SINK_UUID,
+                       VIDEO_DISTRIBUTION_UUID, VDP_SOURCE_UUID, VDP_SINK_UUID,
                        AVRCP_TARGET_UUID, AVRCP_REMOTE_UUID),
        .probe  = audio_probe,
        .remove = audio_remove,
@@ -1128,6 +1187,12 @@ static struct btd_adapter_driver a2dp_server_driver = {
        .remove = a2dp_server_remove,
  };
 
+static struct btd_adapter_driver vdp_server_driver = {
+       .name   = "video-vdp",
+       .probe  = vdp_server_probe,
+       .remove = vdp_server_remove,
+};
+
  static struct btd_adapter_driver avrcp_server_driver = {
        .name   = "audio-control",
        .probe  = avrcp_server_probe,
@@ -1166,6 +1231,10 @@ int audio_manager_init(DBusConnection *conn, GKeyFile *conf,
                        enabled.sink = TRUE;
                else if (g_str_equal(list[i], "Source"))
                        enabled.source = TRUE;
+               else if (g_str_equal(list[i], "VideoSink"))
+                       enabled.video_sink = TRUE;
+               else if (g_str_equal(list[i], "VideoSource"))
+                       enabled.video_source = TRUE;
                else if (g_str_equal(list[i], "Control"))
                        enabled.control = TRUE;
                else if (g_str_equal(list[i], "Socket"))
@@ -1189,6 +1258,10 @@ int audio_manager_init(DBusConnection *conn, GKeyFile *conf,
                        enabled.sink = FALSE;
                else if (g_str_equal(list[i], "Source"))
                        enabled.source = FALSE;
+               else if (g_str_equal(list[i], "VideoSink"))
+                       enabled.video_sink = FALSE;
+               else if (g_str_equal(list[i], "VideoSource"))
+                       enabled.video_source = FALSE;
                else if (g_str_equal(list[i], "Control"))
                        enabled.control = FALSE;
                else if (g_str_equal(list[i], "Socket"))
@@ -1239,6 +1312,9 @@ proceed:
        if (enabled.source || enabled.sink)
                btd_register_adapter_driver(&a2dp_server_driver);
 
+       if (enabled.video_source || enabled.video_sink)
+               btd_register_adapter_driver(&vdp_server_driver);
+
        if (enabled.control)
                btd_register_adapter_driver(&avrcp_server_driver);
 
@@ -1278,6 +1354,9 @@ void audio_manager_exit(void)
        if (enabled.source || enabled.sink)
                btd_unregister_adapter_driver(&a2dp_server_driver);
 
+       if (enabled.video_source || enabled.video_sink)
+               btd_unregister_adapter_driver(&vdp_server_driver);
+
        if (enabled.control)
                btd_unregister_adapter_driver(&avrcp_server_driver);
 
@@ -1320,6 +1399,14 @@ struct audio_device *manager_find_device(const char *path,
                                && !dev->source)
                        continue;
 
+               if (interface && !strcmp(VIDEO_SINK_INTERFACE, interface)
+                               && !dev->video_sink)
+                       continue;
+
+               if (interface && !strcmp(VIDEO_SOURCE_INTERFACE, interface)
+                               && !dev->video_source)
+                       continue;
+
                if (interface && !strcmp(AUDIO_CONTROL_INTERFACE, interface)
                                && !dev->control)
                        continue;
audio/manager.h +2 -1
index cfc646c..6c61da4 100644
@@ -28,6 +28,8 @@ struct enabled_interfaces {
        gboolean gateway;
        gboolean sink;
        gboolean source;
+       gboolean video_sink;
+       gboolean video_source;
        gboolean control;
        gboolean socket;
        gboolean media;
--
Quoted 1 line

1.7.6

Looks good, ack

Signature · 1 line
Luiz Augusto von Dentz
#9 lore raw

PATCH 6/6 This adds video_sink and video_source to audio_device.

In reply to Prasad Bhat
---
 audio/device.h |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
audio/device.h +7 -0
index 5117fca..661f112 100644
@@ -38,6 +38,11 @@
 #define AVRCP_REMOTE_UUID	"0000110e-0000-1000-8000-00805f9b34fb"
 #define AVRCP_TARGET_UUID	"0000110c-0000-1000-8000-00805f9b34fb"
 
+#define VIDEO_DISTRIBUTION_UUID "00001305-0000-1000-8000-00805f9b34fb"
+
+#define VDP_SOURCE_UUID	"00001303-0000-1000-8000-00805f9b34fb"
+#define VDP_SINK_UUID		"00001304-0000-1000-8000-00805f9b34fb"
+
 struct source;
 struct control;
 struct target;
@@ -62,6 +67,8 @@ struct audio_device {
 	struct source *source;
 	struct control *control;
 	struct target *target;
+	struct video_sink *video_sink;
+	struct video_source *video_source;
 
 	guint hs_preauth_id;
 
Signature · 1 line
1.7.6
#10 lore raw

Re: [PATCH BlueZ 6/6] This adds video_sink and video_source to audio_device.

Hi,

Quoted 21 lines · Prasad Bhat

---
 audio/device.h |    7 +++++++

 1 files changed, 7 insertions(+), 0 deletions(-)
audio/device.h +5 -0
index 5117fca..661f112 100644
@@ -38,6 +38,11 @@
  #define AVRCP_REMOTE_UUID      "0000110e-0000-1000-8000-00805f9b34fb"
  #define AVRCP_TARGET_UUID      "0000110c-0000-1000-8000-00805f9b34fb"
 
+#define VIDEO_DISTRIBUTION_UUID "00001305-0000-1000-8000-00805f9b34fb"
+
+#define VDP_SOURCE_UUID        "00001303-0000-1000-8000-00805f9b34fb"
+#define VDP_SINK_UUID          "00001304-0000-1000-8000-00805f9b34fb"
+
  struct source;
  struct control;
  struct target;

audio/device.h struct audio_device { · line 71

Quoted 5 lines
audio/device.h +2 -0
@@ -62,6 +67,8 @@ struct audio_device {
        struct source *source;
        struct control *control;
        struct target *target;
+       struct video_sink *video_sink;
+       struct video_source *video_source;

This looks wrong, you should merge those changes where they are necessary.

Signature · 1 line
Luiz Augusto von Dentz
#11 lore raw
In reply to Prasad Bhat

Hi

Quoted 8 lines · Prasad Bhat

---

 Makefile.am |    1 +
 audio/vdp.c | 2026 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 audio/vdp.h |  112 ++++
 3 files changed, 2139 insertions(+), 0 deletions(-)

 create mode 100644 audio/vdp.c
 create mode 100644 audio/vdp.h

This is pretty much a duplicate of a2dp.{c,h}, so it would be nice to have this in a common file e.g. sep.{c,h} as suggested last time.

Signature · 1 line
Luiz Augusto von Dentz