Initial AVDTP for Android
Subsystems (2)
Luiz Augusto von Dentz
maintainerv2 cover Initial AVDTP for Android
From: Luiz Augusto von Dentz <[email protected]>
The code is based on the current implementation available in profiles/audio/avdtp.{c,h} but it is transport agnostic and does not contain any external dependency except glib for IO handling.
Both the signaling and the transport connection has to be handled by the upper layer, that is why it is not modified in place to avoid breaking current implemention until this work is considered stable.
Two new function are added:
- avdtp_new: Creates AVDTP session and attach signaling transport
- avdtp_stream_set_transport: Set stream transport
Both receives a fd as parameter so in future it should be possible to replace the IO handling.
This set also includes a initial test set based on the current AVDTP test specification, once merged more tests will be added as well, then the intent is to make this used by audio plugin.
Note: It is possible to track back to the original code by doing:
git log --follow or git blame -C -C.
v2: Add a separate commit to copy existing AVDTP files
Luiz Augusto von Dentz (20):
android: Add copy of current AVDTP implemention
android/AVDTP: Strip dependencies
unit/AVDTP: Add /TP/SIG/SMG/BV-05-C test
unit/AVDTP: Add /TP/SIG/SMG/BV-06-C test
unit/AVDTP: Add /TP/SIG/SMG/BV-07-C test
unit/AVDTP: Add /TP/SIG/SMG/BV-08-C test
unit/AVDTP: Add /TP/SIG/SMG/BV-09-C test
unit/AVDTP: Add /TP/SIG/SMG/BV-10-C test
unit/AVDTP: Add /TP/SIG/SMG/BV-11-C test
unit/AVDTP: Add /TP/SIG/SMG/BV-12-C test
unit/AVDTP: Add /TP/SIG/SMG/BV-15-C test
unit/AVDTP: Add /TP/SIG/SMG/BV-16-C test
unit/AVDTP: Add /TP/SIG/SMG/BV-17-C test
unit/AVDTP: Add /TP/SIG/SMG/BV-18-C test
unit/AVDTP: Add /TP/SIG/SMG/BV-19-C test
unit/AVDTP: Add /TP/SIG/SMG/BV-20-C test
unit/AVDTP: Add /TP/SIG/SMG/BV-21-C test
unit/AVDTP: Add /TP/SIG/SMG/BV-22-C test
unit/AVDTP: Add /TP/SIG/SMG/BV-23-C test
unit/AVDTP: Add /TP/SIG/SMG/BV-24-C test
Makefile.am | 8 + android/Makefile.am | 1 + android/a2dp.c | 23 + android/avdtp.c | 3256 +++++++++++++++++++++++++++++++++++++++++++++++++++ android/avdtp.h | 275 +++++ unit/test-avdtp.c | 612 ++++++++++ 6 files changed, 4175 insertions(+) create mode 100644 android/avdtp.c create mode 100644 android/avdtp.h create mode 100644 unit/test-avdtp.c
Signature · 1 line
1.8.3.1
Luiz Augusto von Dentz
maintainerPATCH v2 2/20 android/AVDTP: Strip dependencies
From: Luiz Augusto von Dentz <[email protected]>
This strips AVDTP code of any dependency of core and btio to make it transport agnostic.
--- android/Android.mk | 1 + android/Makefile.am | 1 + android/a2dp.c | 23 ++ android/avdtp.c | 757 +++++----------------------------------------------- android/avdtp.h | 28 +- 5 files changed, 102 insertions(+), 708 deletions(-)
android/Android.mk +1 -0
@@ -25,6 +25,7 @@ LOCAL_SRC_FILES := \ hidhost.c \ socket.c \ ipc.c ipc.h \ + avdtp.c \ a2dp.c \ pan.c \ ../src/log.c \
android/Makefile.am +1 -0
@@ -19,6 +19,7 @@ android_bluetoothd_SOURCES = android/main.c \ android/bluetooth.h android/bluetooth.c \ android/hidhost.h android/hidhost.c \ android/ipc.h android/ipc.c \ + android/avdtp.h android/avdtp.c \ android/a2dp.h android/a2dp.c \ android/socket.h android/socket.c \ android/pan.h android/pan.c \
android/a2dp.c +23 -0
@@ -43,6 +43,7 @@#include "ipc.h" #include "utils.h" #include "bluetooth.h" +#include "avdtp.h" #define L2CAP_PSM_AVDTP 0x19#define SVC_HINT_CAPTURING 0x08
@@ -58,6 +59,7 @@ struct a2dp_device {uint8_t state;GIOChannel *io;guint watch; +struct avdtp *session; };static int device_cmp (gconstpointer s,gconstpointer user_data)
@@ -70,6 +72,9 @@ static int device_cmp(gconstpointer s, gconstpointer user_data)static void a2dp_device_free (struct a2dp_device *dev) { +if (dev->session) +avdtp_unref (dev->session); +if (dev->watch >0 )g_source_remove (dev->watch);
@@ -129,6 +134,9 @@ static void signaling_connect_cb(GIOChannel *chan, GError *err, gpointer user_data) {struct a2dp_device *dev = user_data; +uint16_t imtu, omtu; +GError *gerr =NULL ; +int fd;if (err) {bt_a2dp_notify_state (dev,HAL_A2DP_STATE_DISCONNECTED );
@@ -136,6 +144,21 @@ static void signaling_connect_cb(GIOChannel *chan, GError *err,return ; } +bt_io_get (chan, &gerr, +BT_IO_OPT_IMTU , &imtu, +BT_IO_OPT_OMTU , &omtu, +BT_IO_OPT_INVALID ); +if (gerr) { +bt_a2dp_notify_state (dev,HAL_A2DP_STATE_DISCONNECTED ); +error ("%s" , gerr->message); +g_error_free (gerr); +return ; + } + +/* FIXME: Add proper version */ + fd =g_io_channel_unix_get_fd (chan); + dev->session =avdtp_new (fd, imtu, omtu,0x0100 ); + dev->watch =g_io_add_watch (dev->io,G_IO_HUP |G_IO_ERR |G_IO_NVAL , watch_cb, dev);
android/avdtp.c +73 -684
1,081 lines not on this page · raw message
android/avdtp.h +4 -24
@@ -22,12 +22,6 @@* */ -typedef enum { -AVDTP_SESSION_STATE_DISCONNECTED , -AVDTP_SESSION_STATE_CONNECTING , -AVDTP_SESSION_STATE_CONNECTED -}avdtp_session_state_t ; -struct avdtp ;struct avdtp_stream ;struct avdtp_local_sep ;
@@ -116,12 +110,6 @@ struct avdtp_media_codec_capability {#error "Unknown byte order"#endif -typedef void (*avdtp_session_state_cb ) (struct btd_device *dev, -struct avdtp *session, -avdtp_session_state_t old_state, -avdtp_session_state_t new_state, -void *user_data); - typedef void (*avdtp_stream_state_cb) (struct avdtp_stream *stream, avdtp_state_t old_state, avdtp_state_t new_state,
@@ -213,7 +201,7 @@ struct avdtp_sep_ind {typedef void (*avdtp_discover_cb_t ) (struct avdtp *session,GSList *seps,struct avdtp_error *err,void *user_data); -struct avdtp *avdtp_get (struct btd_device *device); +struct avdtp *avdtp_new (int fd,size_t imtu,size_t omtu,uint16_t version);void avdtp_unref (struct avdtp *session);struct avdtp *avdtp_ref (struct avdtp *session);
@@ -235,6 +223,8 @@ gboolean avdtp_stream_remove_cb(struct avdtp *session,struct avdtp_stream *stream, unsigned int id); +gboolean avdtp_stream_set_transport (struct avdtp_stream *stream,int fd, +size_t imtu,size_t omtu);gboolean avdtp_stream_get_transport (struct avdtp_stream *stream,int *sock,uint16_t *imtu,uint16_t *omtu,GSList **caps);
@@ -245,11 +235,6 @@ gboolean avdtp_stream_has_capabilities(struct avdtp_stream *stream,struct avdtp_remote_sep *avdtp_stream_get_remote_sep (struct avdtp_stream *stream); -unsigned int avdtp_add_state_cb (struct btd_device *dev, -avdtp_session_state_cb cb,void *user_data); - -gboolean avdtp_remove_state_cb (unsigned int id); - int avdtp_set_configuration(struct avdtp *session, struct avdtp_remote_sep *rsep, struct avdtp_local_sep *lsep,
@@ -268,9 +253,7 @@ int avdtp_abort(struct avdtp *session, struct avdtp_stream *stream);int avdtp_delay_report (struct avdtp *session,struct avdtp_stream *stream,uint16_t delay); -struct avdtp_local_sep *avdtp_register_sep(struct btd_adapter *adapter, - uint8_t type, - uint8_t media_type, +struct avdtp_local_sep *avdtp_register_sep(uint8_t type, uint8_t media_type, uint8_t codec_type, gboolean delay_reporting, struct avdtp_sep_ind *ind,
@@ -290,6 +273,3 @@ const char *avdtp_strerror(struct avdtp_error *err);uint8_t avdtp_error_category (struct avdtp_error *err);int avdtp_error_error_code (struct avdtp_error *err);int avdtp_error_posix_errno (struct avdtp_error *err); - -struct btd_adapter *avdtp_get_adapter (struct avdtp *session); -struct btd_device *avdtp_get_device (struct avdtp *session);
Signature · 1 line
1.8.3.1
Luiz Augusto von Dentz
maintainerPATCH v2 3/20 unit/AVDTP: Add /TP/SIG/SMG/BV-05-C test
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
Verify that the IUT (INT) is able to issue a valid stream discover command and report the replied SEPs and media types.
--- Makefile.am | 8 ++ unit/test-avdtp.c | 234 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 unit/test-avdtp.c
Makefile.am +8 -0
@@ -249,6 +249,14 @@ unit_test_sdp_SOURCES = unit/test-sdp.c \ src/sdpd-service.c src/sdpd-request.c unit_test_sdp_LDADD = lib/libbluetooth-internal.la @GLIB_LIBS@ +unit_tests += unit/test-avdtp + +unit_test_avdtp_SOURCES = unit/test-avdtp.c \ + src/shared/util.h src/shared/util.c \ + src/log.h src/log.c \ + android/avdtp.c android/avdtp.h +unit_test_avdtp_LDADD = @GLIB_LIBS@ + unit_tests += unit/test-gdbus-client unit_test_gdbus_client_SOURCES = unit/test-gdbus-client.c
unit/test-avdtp.c new file +234 -0
234 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Luiz Augusto von Dentz
maintainerPATCH v2 4/20 unit/AVDTP: Add /TP/SIG/SMG/BV-06-C test
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
Verify that the IUT (ACP) reports the reception of a valid stream discover command and replies the returned list of SEPs and media types.
--- unit/test-avdtp.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
unit/test-avdtp.c +19 -0
@@ -195,6 +195,22 @@ static void execute_context(struct context *context)g_free (context); } +static void test_server (gconstpointer data) +{ +const struct test_data *test = data; +struct context *context =create_context (); + + context->pdu_list = test->pdu_list; +avdtp_register_sep (AVDTP_SEP_TYPE_SOURCE ,AVDTP_MEDIA_TYPE_AUDIO ,0x00 , + TRUE,NULL ,NULL ,NULL ); + +g_idle_add (send_pdu, context); + +execute_context (context); + +g_free (test->pdu_list); +} +static void discover_cb (struct avdtp *session,GSList *seps,struct avdtp_error *err,void *user_data) {
@@ -229,6 +245,9 @@ int main(int argc, char *argv[])*/ define_test ("/TP/SIG/SMG/BV-05-C" , test_discover,raw_pdu (0x00 ,0x01 )); +define_test ("/TP/SIG/SMG/BV-06-C" , test_server, +raw_pdu (0x00 ,0x01 ), +raw_pdu (0x02 ,0x01 ,0x04 ,0x00 ));return g_test_run (); }
Signature · 1 line
1.8.3.1
Luiz Augusto von Dentz
maintainerPATCH v2 5/20 unit/AVDTP: Add /TP/SIG/SMG/BV-07-C test
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
Verify that the IUT (INT) is able to issue a valid query for remote SEP capabilities and reports the replied ones.
--- unit/test-avdtp.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-)
unit/test-avdtp.c +21 -2
@@ -198,11 +198,12 @@ static void execute_context(struct context *context)static void test_server (gconstpointer data) {const struct test_data *test = data; -struct context *context =create_context (); +struct context *context =create_context (0x0100 ); context->pdu_list = test->pdu_list; +avdtp_register_sep (AVDTP_SEP_TYPE_SOURCE ,AVDTP_MEDIA_TYPE_AUDIO ,0x00 , - TRUE,NULL ,NULL ,NULL ); + TRUE,NULL ,NULL ,NULL );g_idle_add (send_pdu, context);
@@ -230,6 +231,20 @@ static void test_discover(gconstpointer data)g_free (test->pdu_list); } +static void test_get_capabilities (gconstpointer data) +{ +const struct test_data *test = data; +struct context *context =create_context (0x0100 ); + + context->pdu_list = test->pdu_list; + +avdtp_discover (context->session, discover_cb,NULL ); + +execute_context (context); + +g_free (test->pdu_list); +} +int main (int argc,char *argv[]) {g_test_init (&argc, &argv,NULL );
@@ -248,6 +263,10 @@ int main(int argc, char *argv[])define_test ("/TP/SIG/SMG/BV-06-C" , test_server,raw_pdu (0x00 ,0x01 ),raw_pdu (0x02 ,0x01 ,0x04 ,0x00 )); +define_test ("/TP/SIG/SMG/BV-07-C" , test_get_capabilities, +raw_pdu (0x10 ,0x01 ), +raw_pdu (0x12 ,0x01 ,0x04 ,0x00 ), +raw_pdu (0x20 ,0x02 ,0x04 ));return g_test_run (); }
Signature · 1 line
1.8.3.1
Luiz Augusto von Dentz
maintainerPATCH v2 6/20 unit/AVDTP: Add /TP/SIG/SMG/BV-08-C test
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
Verify that the IUT (ACP) reports the reception of a valid query for remote SEP capabilities and replies the returned capabilities.
--- unit/test-avdtp.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-)
unit/test-avdtp.c +46 -2
@@ -195,26 +195,64 @@ static void execute_context(struct context *context)g_free (context); } +static gboolean sep_getcap_ind (struct avdtp *session, +struct avdtp_local_sep *sep, +gboolean get_all,GSList **caps, +uint8_t *err,void *user_data) +{ +struct avdtp_service_capability *media_transport, *media_codec; +struct avdtp_media_codec_capability *codec_caps; +uint8_t cap[4 ] = {0xff ,0xff ,2 ,64 }; + + *caps =NULL ; + + media_transport =avdtp_service_cap_new (AVDTP_MEDIA_TRANSPORT , +NULL ,0 ); + + *caps =g_slist_append (*caps, media_transport); + + codec_caps =g_malloc0 (sizeof (*codec_caps) +sizeof (cap)); + codec_caps->media_type =AVDTP_MEDIA_TYPE_AUDIO ; + codec_caps->media_codec_type =0x00 ; +memcpy (codec_caps->data, cap,sizeof (cap)); + + media_codec =avdtp_service_cap_new (AVDTP_MEDIA_CODEC , codec_caps, +sizeof (*codec_caps) +sizeof (cap)); + + *caps =g_slist_append (*caps, media_codec); +g_free (codec_caps); + +return TRUE; +} + +static struct avdtp_sep_ind sep_ind = { + .get_capability = sep_getcap_ind, +}; +static void test_server (gconstpointer data) {const struct test_data *test = data;struct context *context =create_context (0x0100 ); +struct avdtp_local_sep *sep; context->pdu_list = test->pdu_list; -avdtp_register_sep (AVDTP_SEP_TYPE_SOURCE ,AVDTP_MEDIA_TYPE_AUDIO ,0x00 , - TRUE,NULL ,NULL ,NULL ); + sep =avdtp_register_sep (AVDTP_SEP_TYPE_SOURCE ,AVDTP_MEDIA_TYPE_AUDIO , +0x00 , TRUE, &sep_ind,NULL ,NULL );g_idle_add (send_pdu, context);execute_context (context); +avdtp_unregister_sep (sep); +g_free (test->pdu_list); }static void discover_cb (struct avdtp *session,GSList *seps,struct avdtp_error *err,void *user_data) { + }static void test_discover (gconstpointer data)
@@ -267,6 +305,12 @@ int main(int argc, char *argv[])raw_pdu (0x10 ,0x01 ),raw_pdu (0x12 ,0x01 ,0x04 ,0x00 ), raw_pdu(0x20, 0x02, 0x04)); +define_test ("/TP/SIG/SMG/BV-08-C" , test_server, +raw_pdu (0x00 ,0x01 ), +raw_pdu (0x02 ,0x01 ,0x04 ,0x00 ), +raw_pdu (0x10 ,0x02 ,0x04 ), +raw_pdu (0x12 ,0x02 ,0x01 ,0x00 ,0x07 ,0x06 ,0x00 ,0x00 , +0xff ,0xff ,0x02 ,0x40 ));return g_test_run (); }
Signature · 1 line
1.8.3.1
Luiz Augusto von Dentz
maintainerPATCH v2 7/20 unit/AVDTP: Add /TP/SIG/SMG/BV-09-C test
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
Verify that the IUT (INT) is able to issue a valid set configuration command for remote SEP and reports the replied confirmation.
--- unit/test-avdtp.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+)
unit/test-avdtp.c +68 -0
@@ -71,6 +71,7 @@ struct test_data {struct context {GMainLoop *main_loop;struct avdtp *session; +struct avdtp_local_sep *sep;guint source;int fd;int mtu;
@@ -252,7 +253,45 @@ static void test_server(gconstpointer data)static void discover_cb (struct avdtp *session,GSList *seps,struct avdtp_error *err,void *user_data) { +struct context *context = user_data; +struct avdtp_stream *stream; +struct avdtp_remote_sep *rsep; +struct avdtp_service_capability *media_transport, *media_codec; +struct avdtp_media_codec_capability *cap; +GSList *caps; +uint8_t data[4 ] = {0x21 ,0x02 ,2 ,32 }; +int ret; + +if (!context) +return ; + +g_assert (err ==NULL ); + g_assert_cmpint(g_slist_length(seps), !=, 0); + + rsep =avdtp_find_remote_sep (session, context->sep); +g_assert (rsep !=NULL ); + + media_transport =avdtp_service_cap_new (AVDTP_MEDIA_TRANSPORT , +NULL ,0 ); + + caps =g_slist_append (NULL , media_transport); + + cap =g_malloc0 (sizeof (*cap) +sizeof (data)); + cap->media_type =AVDTP_MEDIA_TYPE_AUDIO ; + cap->media_codec_type =0x00 ; +memcpy (cap->data, data,sizeof (data)); + media_codec =avdtp_service_cap_new (AVDTP_MEDIA_CODEC , cap, +sizeof (*cap) +sizeof (data)); + + caps =g_slist_append (caps, media_codec); +g_free (cap); + + ret =avdtp_set_configuration (session, rsep, context->sep, caps, + &stream); + g_assert_cmpint(ret, ==, 0); + +g_slist_free_full (caps, g_free); }static void test_discover (gconstpointer data)
@@ -283,6 +322,27 @@ static void test_get_capabilities(gconstpointer data)g_free (test->pdu_list); } +static void test_set_configuration (gconstpointer data) +{ +const struct test_data *test = data; +struct context *context =create_context (0x0100 ); +struct avdtp_local_sep *sep; + + context->pdu_list = test->pdu_list; + + sep =avdtp_register_sep (AVDTP_SEP_TYPE_SINK ,AVDTP_MEDIA_TYPE_AUDIO , +0x00 , FALSE,NULL ,NULL ,NULL ); + context->sep = sep; + +avdtp_discover (context->session, discover_cb, context); + +execute_context (context); + +avdtp_unregister_sep (sep); + +g_free (test->pdu_list); +} +int main (int argc,char *argv[]) {g_test_init (&argc, &argv,NULL );
@@ -311,6 +371,14 @@ int main(int argc, char *argv[])raw_pdu (0x10 ,0x02 ,0x04 ),raw_pdu (0x12 ,0x02 ,0x01 ,0x00 ,0x07 ,0x06 ,0x00 ,0x00 , 0xff, 0xff, 0x02, 0x40)); +define_test ("/TP/SIG/SMG/BV-09-C" , test_set_configuration, +raw_pdu (0x30 ,0x01 ), +raw_pdu (0x32 ,0x01 ,0x04 ,0x00 ), +raw_pdu (0x40 ,0x02 ,0x04 ), +raw_pdu (0x42 ,0x02 ,0x01 ,0x00 ,0x07 ,0x06 ,0x00 ,0x00 , +0xff ,0xff ,0x02 ,0x40 ), +raw_pdu (0x50 ,0x03 ,0x04 ,0x04 ,0x01 ,0x00 ,0x07 ,0x06 , +0x00 ,0x00 ,0x21 ,0x02 ,0x02 ,0x20 ));return g_test_run (); }
Signature · 1 line
1.8.3.1
Luiz Augusto von Dentz
maintainerPATCH v2 8/20 unit/AVDTP: Add /TP/SIG/SMG/BV-10-C test
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
Verify that the IUT (ACP) reports the reception of a valid set configuration command for remote SEP, and configures the SEP as requested and replies the returned confirmation.
--- unit/test-avdtp.c | 9 +++++++++ 1 file changed, 9 insertions(+)
unit/test-avdtp.c +9 -0
@@ -379,6 +379,15 @@ int main(int argc, char *argv[]) 0xff, 0xff, 0x02, 0x40),raw_pdu (0x50 ,0x03 ,0x04 ,0x04 ,0x01 ,0x00 ,0x07 ,0x06 , 0x00, 0x00, 0x21, 0x02, 0x02, 0x20)); +define_test ("/TP/SIG/SMG/BV-10-C" , test_server, +raw_pdu (0x00 ,0x01 ), +raw_pdu (0x02 ,0x01 ,0x04 ,0x00 ), +raw_pdu (0x10 ,0x02 ,0x04 ), +raw_pdu (0x12 ,0x02 ,0x01 ,0x00 ,0x07 ,0x06 ,0x00 ,0x00 , +0xff ,0xff ,0x02 ,0x40 ), +raw_pdu (0x20 ,0x03 ,0x04 ,0x04 ,0x01 ,0x00 ,0x07 ,0x06 , +0x00 ,0x00 ,0x21 ,0x02 ,0x02 ,0x20 ), +raw_pdu (0x22 ,0x03 ));return g_test_run (); }
Signature · 1 line
1.8.3.1
Luiz Augusto von Dentz
maintainerPATCH v2 9/20 unit/AVDTP: Add /TP/SIG/SMG/BV-11-C test
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
Verify that the IUT (INT) is able to issue a valid get configuration command for remote SEP and report the replied configuration.
--- unit/test-avdtp.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+)
unit/test-avdtp.c +47 -0
@@ -230,6 +230,22 @@ static struct avdtp_sep_ind sep_ind = { .get_capability = sep_getcap_ind, }; +static void sep_setconf_cfm (struct avdtp *session,struct avdtp_local_sep *sep, +struct avdtp_stream *stream, +struct avdtp_error *err,void *user_data) +{ +int ret; + +g_assert (err ==NULL ); + + ret =avdtp_get_configuration (session, stream); + g_assert_cmpint(ret, ==, 0); +} + +static struct avdtp_sep_cfm sep_cfm = { + .set_configuration = sep_setconf_cfm, +}; +static void test_server (gconstpointer data) {const struct test_data *test = data;
@@ -343,6 +359,27 @@ static void test_set_configuration(gconstpointer data)g_free (test->pdu_list); } +static void test_get_configuration (gconstpointer data) +{ +const struct test_data *test = data; +struct context *context =create_context (0x0100 ); +struct avdtp_local_sep *sep; + + context->pdu_list = test->pdu_list; + + sep =avdtp_register_sep (AVDTP_SEP_TYPE_SINK ,AVDTP_MEDIA_TYPE_AUDIO , +0x00 , FALSE, &sep_ind, &sep_cfm,NULL ); + context->sep = sep; + +avdtp_discover (context->session, discover_cb, context); + +execute_context (context); + +avdtp_unregister_sep (sep); + +g_free (test->pdu_list); +} +int main (int argc,char *argv[]) {g_test_init (&argc, &argv,NULL );
@@ -388,6 +425,16 @@ int main(int argc, char *argv[])raw_pdu (0x20 ,0x03 ,0x04 ,0x04 ,0x01 ,0x00 ,0x07 ,0x06 ,0x00 ,0x00 ,0x21 ,0x02 ,0x02 ,0x20 ), raw_pdu(0x22, 0x03)); +define_test ("/TP/SIG/SMG/BV-11-C" , test_get_configuration, +raw_pdu (0x60 ,0x01 ), +raw_pdu (0x62 ,0x01 ,0x04 ,0x00 ), +raw_pdu (0x70 ,0x02 ,0x04 ), +raw_pdu (0x72 ,0x02 ,0x01 ,0x00 ,0x07 ,0x06 ,0x00 ,0x00 , +0xff ,0xff ,0x02 ,0x40 ), +raw_pdu (0x80 ,0x03 ,0x04 ,0x04 ,0x01 ,0x00 ,0x07 ,0x06 , +0x00 ,0x00 ,0x21 ,0x02 ,0x02 ,0x20 ), +raw_pdu (0x82 ,0x03 ), +raw_pdu (0x90 ,0x04 ,0x04 ));return g_test_run (); }
Signature · 1 line
1.8.3.1
Luiz Augusto von Dentz
maintainerPATCH v2 10/20 unit/AVDTP: Add /TP/SIG/SMG/BV-12-C test
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
Verify that the IUT (ACP) reports the reception of a valid get configuration command for remote SEP and replies the returned configuration.
--- unit/test-avdtp.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
unit/test-avdtp.c +14 -1
@@ -368,7 +368,8 @@ static void test_get_configuration(gconstpointer data) context->pdu_list = test->pdu_list; sep =avdtp_register_sep (AVDTP_SEP_TYPE_SINK ,AVDTP_MEDIA_TYPE_AUDIO , -0x00 , FALSE, &sep_ind, &sep_cfm,NULL ); +0x00 , FALSE,NULL , &sep_cfm, + context); context->sep = sep;avdtp_discover (context->session, discover_cb, context);
@@ -435,6 +436,18 @@ int main(int argc, char *argv[]) 0x00, 0x00, 0x21, 0x02, 0x02, 0x20),raw_pdu (0x82 ,0x03 ), raw_pdu(0x90, 0x04, 0x04)); +define_test ("/TP/SIG/SMG/BV-12-C" , test_server, +raw_pdu (0x00 ,0x01 ), +raw_pdu (0x02 ,0x01 ,0x04 ,0x00 ), +raw_pdu (0x10 ,0x02 ,0x04 ), +raw_pdu (0x12 ,0x02 ,0x01 ,0x00 ,0x07 ,0x06 ,0x00 ,0x00 , +0xff ,0xff ,0x02 ,0x40 ), +raw_pdu (0x20 ,0x03 ,0x04 ,0x04 ,0x01 ,0x00 ,0x07 ,0x06 , +0x00 ,0x00 ,0x21 ,0x02 ,0x02 ,0x20 ), +raw_pdu (0x22 ,0x03 ), +raw_pdu (0x30 ,0x04 ,0x04 ), +raw_pdu (0x32 ,0x04 ,0x01 ,0x00 ,0x07 ,0x06 ,0x00 ,0x00 , +0x21 ,0x02 ,0x02 ,0x20 ));return g_test_run (); }
Signature · 1 line
1.8.3.1
Luiz Augusto von Dentz
maintainerPATCH v2 11/20 unit/AVDTP: Add /TP/SIG/SMG/BV-15-C test
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
Verify that the IUT (INT) is able to establish a stream connection to a previously configured remote SEP by establishing one L2CAP channel (AVDTP_OPEN_CMD), and reports the related confirmation.
--- unit/test-avdtp.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-)
unit/test-avdtp.c +54 -2
@@ -40,7 +40,7 @@struct test_pdu {bool valid; -const void *data; +const uint8_t *data;size_t size; };
@@ -234,11 +234,31 @@ static void sep_setconf_cfm(struct avdtp *session, struct avdtp_local_sep *sep,struct avdtp_stream *stream, struct avdtp_error *err, void *user_data) { + struct context *context = user_data; +const struct test_pdu *pdu;int ret;g_assert (err ==NULL ); - ret =avdtp_get_configuration (session, stream); +if (!context) +return ; + + pdu = &context->pdu_list[context->pdu_offset]; + +if (pdu->size <2 ) +return ; + +switch (pdu->data[1 ]) { +case 0x04 : + ret =avdtp_get_configuration (session, stream); +break ; +case 0x06 : + ret =avdtp_open (session, stream); +break ; +default : +g_assert_not_reached (); + } + g_assert_cmpint(ret, ==, 0); }
@@ -381,6 +401,28 @@ static void test_get_configuration(gconstpointer data)g_free (test->pdu_list); } +static void test_open (gconstpointer data) +{ +const struct test_data *test = data; +struct context *context =create_context (0x0100 ); +struct avdtp_local_sep *sep; + + context->pdu_list = test->pdu_list; + + sep =avdtp_register_sep (AVDTP_SEP_TYPE_SINK ,AVDTP_MEDIA_TYPE_AUDIO , +0x00 , FALSE,NULL , &sep_cfm, + context); + context->sep = sep; + +avdtp_discover (context->session, discover_cb, context); + +execute_context (context); + +avdtp_unregister_sep (sep); + +g_free (test->pdu_list); +} +int main (int argc,char *argv[]) {g_test_init (&argc, &argv,NULL );
@@ -448,6 +490,16 @@ int main(int argc, char *argv[])raw_pdu (0x30 ,0x04 ,0x04 ),raw_pdu (0x32 ,0x04 ,0x01 ,0x00 ,0x07 ,0x06 ,0x00 ,0x00 , 0x21, 0x02, 0x02, 0x20)); +define_test ("/TP/SIG/SMG/BV-15-C" , test_open, +raw_pdu (0xa0 ,0x01 ), +raw_pdu (0xa2 ,0x01 ,0x04 ,0x00 ), +raw_pdu (0xb0 ,0x02 ,0x04 ), +raw_pdu (0xb2 ,0x02 ,0x01 ,0x00 ,0x07 ,0x06 ,0x00 ,0x00 , +0xff ,0xff ,0x02 ,0x40 ), +raw_pdu (0xc0 ,0x03 ,0x04 ,0x04 ,0x01 ,0x00 ,0x07 ,0x06 , +0x00 ,0x00 ,0x21 ,0x02 ,0x02 ,0x20 ), +raw_pdu (0xc2 ,0x03 ), +raw_pdu (0xd0 ,0x06 ,0x04 ));return g_test_run (); }
Signature · 1 line
1.8.3.1
Luiz Augusto von Dentz
maintainerPATCH v2 12/20 unit/AVDTP: Add /TP/SIG/SMG/BV-16-C test
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
Verify that the IUT (ACP) reports the reception of valid AVDTP_OPEN_CMD for transport sessions associated to a SEP and replies the returned confirmation.
--- unit/test-avdtp.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
unit/test-avdtp.c +11 -0
@@ -500,6 +500,17 @@ int main(int argc, char *argv[]) 0x00, 0x00, 0x21, 0x02, 0x02, 0x20),raw_pdu (0xc2 ,0x03 ), raw_pdu(0xd0, 0x06, 0x04)); +define_test ("/TP/SIG/SMG/BV-16-C" , test_server, +raw_pdu (0x00 ,0x01 ), +raw_pdu (0x02 ,0x01 ,0x04 ,0x00 ), +raw_pdu (0x10 ,0x02 ,0x04 ), +raw_pdu (0x12 ,0x02 ,0x01 ,0x00 ,0x07 ,0x06 ,0x00 ,0x00 , +0xff ,0xff ,0x02 ,0x40 ), +raw_pdu (0x20 ,0x03 ,0x04 ,0x04 ,0x01 ,0x00 ,0x07 ,0x06 , +0x00 ,0x00 ,0x21 ,0x02 ,0x02 ,0x20 ), +raw_pdu (0x22 ,0x03 ), +raw_pdu (0x30 ,0x06 ,0x04 ), +raw_pdu (0x32 ,0x06 ));return g_test_run (); }
Signature · 1 line
1.8.3.1
Luiz Augusto von Dentz
maintainerPATCH v2 13/20 unit/AVDTP: Add /TP/SIG/SMG/BV-17-C test
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
Verify that the IUT (INT) is able to start a streaming procedure after the stream establishment is complete, by issuing the AVDTP_START_CMD, reporting the replied confirmation and streaming packets.
--- unit/test-avdtp.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+)
unit/test-avdtp.c +54 -0
@@ -30,6 +30,7 @@#include <stdbool.h> #include <inttypes.h> #include <string.h> +#include <fcntl.h> #include <sys/socket.h> #include <glib.h>
@@ -262,8 +263,27 @@ static void sep_setconf_cfm(struct avdtp *session, struct avdtp_local_sep *sep, g_assert_cmpint(ret, ==, 0); } +static void sep_open_cfm (struct avdtp *session,struct avdtp_local_sep *sep, +struct avdtp_stream *stream,struct avdtp_error *err, +void *user_data) +{ +int ret; + +g_assert (err ==NULL ); + + ret =open ("/dev/null" ,O_RDWR ,0 ); +if (ret <0 ) +g_assert_not_reached (); + +avdtp_stream_set_transport (stream, ret,672 ,672 ); + + ret =avdtp_start (session, stream); + g_assert_cmpint(ret, ==, 0); +} +static struct avdtp_sep_cfm sep_cfm = { .set_configuration = sep_setconf_cfm, + .open = sep_open_cfm, };static void test_server (gconstpointer data)
@@ -423,6 +443,28 @@ static void test_open(gconstpointer data)g_free (test->pdu_list); } +static void test_start (gconstpointer data) +{ +const struct test_data *test = data; +struct context *context =create_context (0x0100 ); +struct avdtp_local_sep *sep; + + context->pdu_list = test->pdu_list; + + sep =avdtp_register_sep (AVDTP_SEP_TYPE_SINK ,AVDTP_MEDIA_TYPE_AUDIO , +0x00 , FALSE,NULL , &sep_cfm, + context); + context->sep = sep; + +avdtp_discover (context->session, discover_cb, context); + +execute_context (context); + +avdtp_unregister_sep (sep); + +g_free (test->pdu_list); +} +int main (int argc,char *argv[]) {g_test_init (&argc, &argv,NULL );
@@ -511,6 +553,18 @@ int main(int argc, char *argv[])raw_pdu (0x22 ,0x03 ),raw_pdu (0x30 ,0x06 ,0x04 ), raw_pdu(0x32, 0x06)); +define_test ("/TP/SIG/SMG/BV-17-C" , test_start, +raw_pdu (0xe0 ,0x01 ), +raw_pdu (0xe2 ,0x01 ,0x04 ,0x00 ), +raw_pdu (0xf0 ,0x02 ,0x04 ), +raw_pdu (0xf2 ,0x02 ,0x01 ,0x00 ,0x07 ,0x06 ,0x00 ,0x00 , +0xff ,0xff ,0x02 ,0x40 ), +raw_pdu (0x00 ,0x03 ,0x04 ,0x04 ,0x01 ,0x00 ,0x07 ,0x06 , +0x00 ,0x00 ,0x21 ,0x02 ,0x02 ,0x20 ), +raw_pdu (0x02 ,0x03 ), +raw_pdu (0x10 ,0x06 ,0x04 ), +raw_pdu (0x12 ,0x06 ), +raw_pdu (0x20 ,0x07 ,0x04 ));return g_test_run (); }
Signature · 1 line
1.8.3.1
Luiz Augusto von Dentz
maintainerPATCH v2 14/20 unit/AVDTP: Add /TP/SIG/SMG/BV-18-C test
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
To verify that the IUT (ACP) reports the reception of valid AVDTP_START_CMD and replies the returned confirmation.
--- unit/test-avdtp.c | 138 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 76 insertions(+), 62 deletions(-)
unit/test-avdtp.c +76 -62
@@ -46,6 +46,7 @@ struct test_pdu { };struct test_data { +char *test_name;struct test_pdu *pdu_list; };
@@ -64,20 +65,23 @@ struct test_data { args, { }, { } \ }; \static struct test_data data; \ + data.test_name =g_strdup (name); \ data.pdu_list =g_malloc (sizeof (pdus)); \memcpy (data.pdu_list, pdus,sizeof (pdus)); \ -g_test_add_data_func (name, &data, function); \ +g_test_add_data_func_full (name, &data, function, test_free); \ }while (0 ) struct context {GMainLoop *main_loop;struct avdtp *session;struct avdtp_local_sep *sep; +struct avdtp_stream *stream;guint source;int fd;int mtu; +gboolean pending_open;unsigned int pdu_offset; -const struct test_pdu *pdu_list; +const struct test_data *data; };static void test_debug (const char *str,void *user_data)
@@ -87,6 +91,14 @@ static void test_debug(const char *str, void *user_data)g_print ("%s%s\n" , prefix, str); } +static void test_free (void *user_data) +{ +struct test_data *data = user_data; + +g_free (data->test_name); +g_free (data->pdu_list); +} +static void context_quit (struct context *context) {g_main_loop_quit (context->main_loop);
@@ -98,7 +110,7 @@ static gboolean send_pdu(gpointer user_data)const struct test_pdu *pdu;ssize_t len; - pdu = &context->pdu_list[context->pdu_offset++]; + pdu = &context->data->pdu_list[context->pdu_offset++]; len =write (context->fd, pdu->data, pdu->size);
@@ -112,7 +124,7 @@ static gboolean send_pdu(gpointer user_data)static void context_process (struct context *context) { -if (!context->pdu_list[context->pdu_offset].valid) { +if (!context->data->pdu_list[context->pdu_offset].valid) {context_quit (context);return ; }
@@ -120,6 +132,17 @@ static void context_process(struct context *context)g_idle_add (send_pdu, context); } +static gboolean transport_open (struct avdtp_stream *stream) +{ +int fd; + + fd =open ("/dev/null" ,O_RDWR ,0 ); +if (fd <0 ) +g_assert_not_reached (); + +return avdtp_stream_set_transport (stream, fd,672 ,672 ); +} +static gboolean test_handler (GIOChannel *channel,GIOCondition cond,gpointer user_data) {
@@ -129,7 +152,7 @@ static gboolean test_handler(GIOChannel *channel, GIOCondition cond,ssize_t len;int fd; - pdu = &context->pdu_list[context->pdu_offset++]; + pdu = &context->data->pdu_list[context->pdu_offset++];if (cond & (G_IO_NVAL |G_IO_ERR |G_IO_HUP ))return FALSE;
@@ -147,12 +170,17 @@ static gboolean test_handler(GIOChannel *channel, GIOCondition cond,g_assert (memcmp (buf, pdu->data, pdu->size) ==0 ); +if (context->pending_open) { + context->pending_open = FALSE; +g_assert (transport_open (context->stream)); + } +context_process (context);return TRUE; } -static struct context *create_context (uint16_t version) +static struct context *create_context (uint16_t version,gconstpointer data) { struct context *context = g_new0(struct context, 1);GIOChannel *channel;
@@ -181,6 +209,7 @@ static struct context *create_context(uint16_t version)g_io_channel_unref (channel); context->fd = sv[1 ]; + context->data = data;return context; }
@@ -227,8 +256,21 @@ static gboolean sep_getcap_ind(struct avdtp *session,return TRUE; } +static gboolean sep_open_ind (struct avdtp *session,struct avdtp_local_sep *sep, +struct avdtp_stream *stream,uint8_t *err, +void *user_data) +{ +struct context *context = user_data; + + context->pending_open = TRUE; + context->stream = stream; + +return TRUE; +} +static struct avdtp_sep_ind sep_ind = { .get_capability = sep_getcap_ind, + .open = sep_open_ind, }; static void sep_setconf_cfm(struct avdtp *session, struct avdtp_local_sep *sep,
@@ -244,21 +286,19 @@ static void sep_setconf_cfm(struct avdtp *session, struct avdtp_local_sep *sep,if (!context)return ; - pdu = &context->pdu_list[context->pdu_offset]; + pdu = &context->data->pdu_list[context->pdu_offset];if (pdu->size <2 )return ; -switch (pdu->data[1 ]) { -case 0x04 : +if (g_str_equal (context->data->test_name,"/TP/SIG/SMG/BV-11-C" )) ret =avdtp_get_configuration (session, stream); -break ; -case 0x06 : +else if (g_str_equal (context->data->test_name,"/TP/SIG/SMG/BV-15-C" )) ret =avdtp_open (session, stream); -break ; -default : +else if (g_str_equal (context->data->test_name,"/TP/SIG/SMG/BV-17-C" )) + ret =avdtp_open (session, stream); +else g_assert_not_reached (); - } g_assert_cmpint(ret, ==, 0); }
@@ -271,11 +311,7 @@ static void sep_open_cfm(struct avdtp *session, struct avdtp_local_sep *sep,g_assert (err ==NULL ); - ret =open ("/dev/null" ,O_RDWR ,0 ); -if (ret <0 ) -g_assert_not_reached (); - -avdtp_stream_set_transport (stream, ret,672 ,672 ); +g_assert (transport_open (stream)); ret =avdtp_start (session, stream); g_assert_cmpint(ret, ==, 0);
@@ -288,22 +324,17 @@ static struct avdtp_sep_cfm sep_cfm = {static void test_server (gconstpointer data) { -const struct test_data *test = data; -struct context *context =create_context (0x0100 ); +struct context *context =create_context (0x0100 , data);struct avdtp_local_sep *sep; - context->pdu_list = test->pdu_list; - sep =avdtp_register_sep (AVDTP_SEP_TYPE_SOURCE ,AVDTP_MEDIA_TYPE_AUDIO , -0x00 , TRUE, &sep_ind,NULL ,NULL ); +0x00 , TRUE, &sep_ind,NULL , context);g_idle_add (send_pdu, context);execute_context (context);avdtp_unregister_sep (sep); - -g_free (test->pdu_list); } static void discover_cb(struct avdtp *session, GSList *seps,
@@ -352,40 +383,27 @@ static void discover_cb(struct avdtp *session, GSList *seps,static void test_discover (gconstpointer data) { -const struct test_data *test = data; -struct context *context =create_context (0x0100 ); - - context->pdu_list = test->pdu_list; +struct context *context =create_context (0x0100 , data);avdtp_discover (context->session, discover_cb,NULL );execute_context (context); - -g_free (test->pdu_list); }static void test_get_capabilities (gconstpointer data) { -const struct test_data *test = data; -struct context *context =create_context (0x0100 ); - - context->pdu_list = test->pdu_list; +struct context *context =create_context (0x0100 , data);avdtp_discover (context->session, discover_cb,NULL );execute_context (context); - -g_free (test->pdu_list); }static void test_set_configuration (gconstpointer data) { -const struct test_data *test = data; -struct context *context =create_context (0x0100 ); +struct context *context =create_context (0x0100 , data);struct avdtp_local_sep *sep; - context->pdu_list = test->pdu_list; - sep =avdtp_register_sep (AVDTP_SEP_TYPE_SINK ,AVDTP_MEDIA_TYPE_AUDIO ,0x00 , FALSE,NULL ,NULL ,NULL ); context->sep = sep;
@@ -395,18 +413,13 @@ static void test_set_configuration(gconstpointer data)execute_context (context);avdtp_unregister_sep (sep); - -g_free (test->pdu_list); }static void test_get_configuration (gconstpointer data) { -const struct test_data *test = data; -struct context *context =create_context (0x0100 ); +struct context *context =create_context (0x0100 , data);struct avdtp_local_sep *sep; - context->pdu_list = test->pdu_list; - sep =avdtp_register_sep (AVDTP_SEP_TYPE_SINK ,AVDTP_MEDIA_TYPE_AUDIO ,0x00 , FALSE,NULL , &sep_cfm, context);
@@ -417,18 +430,13 @@ static void test_get_configuration(gconstpointer data)execute_context (context);avdtp_unregister_sep (sep); - -g_free (test->pdu_list); }static void test_open (gconstpointer data) { -const struct test_data *test = data; -struct context *context =create_context (0x0100 ); +struct context *context =create_context (0x0100 , data);struct avdtp_local_sep *sep; - context->pdu_list = test->pdu_list; - sep =avdtp_register_sep (AVDTP_SEP_TYPE_SINK ,AVDTP_MEDIA_TYPE_AUDIO ,0x00 , FALSE,NULL , &sep_cfm, context);
@@ -439,18 +447,13 @@ static void test_open(gconstpointer data)execute_context (context);avdtp_unregister_sep (sep); - -g_free (test->pdu_list); }static void test_start (gconstpointer data) { -const struct test_data *test = data; -struct context *context =create_context (0x0100 ); +struct context *context =create_context (0x0100 , data);struct avdtp_local_sep *sep; - context->pdu_list = test->pdu_list; - sep =avdtp_register_sep (AVDTP_SEP_TYPE_SINK ,AVDTP_MEDIA_TYPE_AUDIO ,0x00 , FALSE,NULL , &sep_cfm, context);
@@ -461,8 +464,6 @@ static void test_start(gconstpointer data)execute_context (context);avdtp_unregister_sep (sep); - -g_free (test->pdu_list); }int main (int argc,char *argv[])
@@ -565,6 +566,19 @@ int main(int argc, char *argv[])raw_pdu (0x10 ,0x06 ,0x04 ),raw_pdu (0x12 ,0x06 ), raw_pdu(0x20, 0x07, 0x04)); +define_test ("/TP/SIG/SMG/BV-18-C" , test_server, +raw_pdu (0x00 ,0x01 ), +raw_pdu (0x02 ,0x01 ,0x04 ,0x00 ), +raw_pdu (0x10 ,0x02 ,0x04 ), +raw_pdu (0x12 ,0x02 ,0x01 ,0x00 ,0x07 ,0x06 ,0x00 ,0x00 , +0xff ,0xff ,0x02 ,0x40 ), +raw_pdu (0x20 ,0x03 ,0x04 ,0x04 ,0x01 ,0x00 ,0x07 ,0x06 , +0x00 ,0x00 ,0x21 ,0x02 ,0x02 ,0x20 ), +raw_pdu (0x22 ,0x03 ), +raw_pdu (0x30 ,0x06 ,0x04 ), +raw_pdu (0x32 ,0x06 ), +raw_pdu (0x40 ,0x07 ,0x04 ), +raw_pdu (0x42 ,0x07 ));return g_test_run (); }
Signature · 1 line
1.8.3.1
Luiz Augusto von Dentz
maintainerPATCH v2 15/20 unit/AVDTP: Add /TP/SIG/SMG/BV-19-C test
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
Verify that the IUT (INT) is able to initiate the release of a streaming procedure after the streaming procedure has been started, by issuing the AVDTP_CLOSE_CMD, releasing all the resources associated to the SEP after reception of the replied confirmation and reporting the closing.
--- unit/test-avdtp.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 5 deletions(-)
unit/test-avdtp.c +46 -5
@@ -293,12 +293,8 @@ static void sep_setconf_cfm(struct avdtp *session, struct avdtp_local_sep *sep,if (g_str_equal (context->data->test_name,"/TP/SIG/SMG/BV-11-C" )) ret =avdtp_get_configuration (session, stream); -else if (g_str_equal (context->data->test_name,"/TP/SIG/SMG/BV-15-C" )) - ret =avdtp_open (session, stream); -else if (g_str_equal (context->data->test_name,"/TP/SIG/SMG/BV-17-C" )) - ret =avdtp_open (session, stream);else -g_assert_not_reached (); + ret =avdtp_open (session, stream); g_assert_cmpint(ret, ==, 0); }
@@ -317,9 +313,23 @@ static void sep_open_cfm(struct avdtp *session, struct avdtp_local_sep *sep, g_assert_cmpint(ret, ==, 0); } +static void sep_start_cfm (struct avdtp *session,struct avdtp_local_sep *sep, +struct avdtp_stream *stream,struct avdtp_error *err, +void *user_data) +{ +int ret; + +g_assert (err ==NULL ); + + ret =avdtp_close (session, stream, FALSE); + + g_assert_cmpint(ret, ==, 0); +} +static struct avdtp_sep_cfm sep_cfm = { .set_configuration = sep_setconf_cfm, .open = sep_open_cfm, + .start = sep_start_cfm, };static void test_server (gconstpointer data)
@@ -466,6 +476,23 @@ static void test_start(gconstpointer data)avdtp_unregister_sep (sep); } +static void test_close (gconstpointer data) +{ +struct context *context =create_context (0x0100 , data); +struct avdtp_local_sep *sep; + + sep =avdtp_register_sep (AVDTP_SEP_TYPE_SINK ,AVDTP_MEDIA_TYPE_AUDIO , +0x00 , FALSE,NULL , &sep_cfm, + context); + context->sep = sep; + +avdtp_discover (context->session, discover_cb, context); + +execute_context (context); + +avdtp_unregister_sep (sep); +} +int main (int argc,char *argv[]) {g_test_init (&argc, &argv,NULL );
@@ -579,6 +606,20 @@ int main(int argc, char *argv[])raw_pdu (0x32 ,0x06 ),raw_pdu (0x40 ,0x07 ,0x04 ), raw_pdu(0x42, 0x07)); +define_test ("/TP/SIG/SMG/BV-19-C" , test_close, +raw_pdu (0x30 ,0x01 ), +raw_pdu (0x32 ,0x01 ,0x04 ,0x00 ), +raw_pdu (0x40 ,0x02 ,0x04 ), +raw_pdu (0x42 ,0x02 ,0x01 ,0x00 ,0x07 ,0x06 ,0x00 ,0x00 , +0xff ,0xff ,0x02 ,0x40 ), +raw_pdu (0x50 ,0x03 ,0x04 ,0x04 ,0x01 ,0x00 ,0x07 ,0x06 , +0x00 ,0x00 ,0x21 ,0x02 ,0x02 ,0x20 ), +raw_pdu (0x52 ,0x03 ), +raw_pdu (0x60 ,0x06 ,0x04 ), +raw_pdu (0x62 ,0x06 ), +raw_pdu (0x70 ,0x07 ,0x04 ), +raw_pdu (0x72 ,0x07 ), +raw_pdu (0x80 ,0x08 ,0x04 ));return g_test_run (); }
Signature · 1 line
1.8.3.1
Luiz Augusto von Dentz
maintainerPATCH v2 16/20 unit/AVDTP: Add /TP/SIG/SMG/BV-20-C test
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
Verify that the IUT (ACP) is able to accept an AVDTP_CLOSE_CMD after the streaming procedure has been started, by releasing all the resources associated to the SEP, reporting of the closing and replying the returned confirmation.
--- unit/test-avdtp.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
unit/test-avdtp.c +15 -0
@@ -620,6 +620,21 @@ int main(int argc, char *argv[])raw_pdu (0x70 ,0x07 ,0x04 ),raw_pdu (0x72 ,0x07 ), raw_pdu(0x80, 0x08, 0x04)); +define_test ("/TP/SIG/SMG/BV-20-C" , test_server, +raw_pdu (0x00 ,0x01 ), +raw_pdu (0x02 ,0x01 ,0x04 ,0x00 ), +raw_pdu (0x10 ,0x02 ,0x04 ), +raw_pdu (0x12 ,0x02 ,0x01 ,0x00 ,0x07 ,0x06 ,0x00 ,0x00 , +0xff ,0xff ,0x02 ,0x40 ), +raw_pdu (0x20 ,0x03 ,0x04 ,0x04 ,0x01 ,0x00 ,0x07 ,0x06 , +0x00 ,0x00 ,0x21 ,0x02 ,0x02 ,0x20 ), +raw_pdu (0x22 ,0x03 ), +raw_pdu (0x30 ,0x06 ,0x04 ), +raw_pdu (0x32 ,0x06 ), +raw_pdu (0x40 ,0x07 ,0x04 ), +raw_pdu (0x42 ,0x07 ), +raw_pdu (0x50 ,0x08 ,0x04 ), +raw_pdu (0x52 ,0x08 ));return g_test_run (); }
Signature · 1 line
1.8.3.1
Luiz Augusto von Dentz
maintainerPATCH v2 17/20 unit/AVDTP: Add /TP/SIG/SMG/BV-21-C test
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
Verify that the IUT (INT) is able to initiate the suspension of a streaming procedure, after the streaming procedure has been started, by issuing the AVDTP_SUSPEND_CMD.
--- unit/test-avdtp.c | 124 +++++++++++++----------------------------------------- 1 file changed, 29 insertions(+), 95 deletions(-)
unit/test-avdtp.c +29 -95
@@ -317,11 +317,15 @@ static void sep_start_cfm(struct avdtp *session, struct avdtp_local_sep *sep, struct avdtp_stream *stream, struct avdtp_error *err, void *user_data) { + struct context *context = user_data;int ret;g_assert (err ==NULL ); - ret =avdtp_close (session, stream, FALSE); +if (g_str_equal (context->data->test_name,"/TP/SIG/SMG/BV-19-C" )) + ret =avdtp_close (session, stream, FALSE); +else + ret =avdtp_suspend (session, stream); g_assert_cmpint(ret, ==, 0); }
@@ -359,7 +363,8 @@ static void discover_cb(struct avdtp *session, GSList *seps,uint8_t data[4 ] = {0x21 ,0x02 ,2 ,32 };int ret; -if (!context) +if (g_str_equal (context->data->test_name,"/TP/SIG/SMG/BV-05-C" ) || +g_str_equal (context->data->test_name,"/TP/SIG/SMG/BV-07-C" ))return ;g_assert (err ==NULL );
@@ -391,92 +396,7 @@ static void discover_cb(struct avdtp *session, GSList *seps,g_slist_free_full (caps, g_free); } -static void test_discover (gconstpointer data) -{ -struct context *context =create_context (0x0100 , data); - -avdtp_discover (context->session, discover_cb,NULL ); - -execute_context (context); -} - -static void test_get_capabilities (gconstpointer data) -{ -struct context *context =create_context (0x0100 , data); - -avdtp_discover (context->session, discover_cb,NULL ); - -execute_context (context); -} - -static void test_set_configuration (gconstpointer data) -{ -struct context *context =create_context (0x0100 , data); -struct avdtp_local_sep *sep; - - sep =avdtp_register_sep (AVDTP_SEP_TYPE_SINK ,AVDTP_MEDIA_TYPE_AUDIO , -0x00 , FALSE,NULL ,NULL ,NULL ); - context->sep = sep; - -avdtp_discover (context->session, discover_cb, context); - -execute_context (context); - -avdtp_unregister_sep (sep); -} - -static void test_get_configuration (gconstpointer data) -{ -struct context *context =create_context (0x0100 , data); -struct avdtp_local_sep *sep; - - sep =avdtp_register_sep (AVDTP_SEP_TYPE_SINK ,AVDTP_MEDIA_TYPE_AUDIO , -0x00 , FALSE,NULL , &sep_cfm, - context); - context->sep = sep; - -avdtp_discover (context->session, discover_cb, context); - -execute_context (context); - -avdtp_unregister_sep (sep); -} - -static void test_open (gconstpointer data) -{ -struct context *context =create_context (0x0100 , data); -struct avdtp_local_sep *sep; - - sep =avdtp_register_sep (AVDTP_SEP_TYPE_SINK ,AVDTP_MEDIA_TYPE_AUDIO , -0x00 , FALSE,NULL , &sep_cfm, - context); - context->sep = sep; - -avdtp_discover (context->session, discover_cb, context); - -execute_context (context); - -avdtp_unregister_sep (sep); -} - -static void test_start (gconstpointer data) -{ -struct context *context =create_context (0x0100 , data); -struct avdtp_local_sep *sep; - - sep =avdtp_register_sep (AVDTP_SEP_TYPE_SINK ,AVDTP_MEDIA_TYPE_AUDIO , -0x00 , FALSE,NULL , &sep_cfm, - context); - context->sep = sep; - -avdtp_discover (context->session, discover_cb, context); - -execute_context (context); - -avdtp_unregister_sep (sep); -} - -static void test_close (gconstpointer data) +static void test_client (gconstpointer data) {struct context *context =create_context (0x0100 , data);struct avdtp_local_sep *sep;
@@ -506,12 +426,12 @@ int main(int argc, char *argv[])* To verify that the following procedures are implemented according to * their specification in AVDTP. */ -define_test ("/TP/SIG/SMG/BV-05-C" , test_discover, +define_test ("/TP/SIG/SMG/BV-05-C" , test_client,raw_pdu (0x00 ,0x01 ));define_test ("/TP/SIG/SMG/BV-06-C" , test_server,raw_pdu (0x00 ,0x01 ),raw_pdu (0x02 ,0x01 ,0x04 ,0x00 )); -define_test ("/TP/SIG/SMG/BV-07-C" , test_get_capabilities, +define_test ("/TP/SIG/SMG/BV-07-C" , test_client,raw_pdu (0x10 ,0x01 ),raw_pdu (0x12 ,0x01 ,0x04 ,0x00 ),raw_pdu (0x20 ,0x02 ,0x04 ));
@@ -521,7 +441,7 @@ int main(int argc, char *argv[])raw_pdu (0x10 ,0x02 ,0x04 ),raw_pdu (0x12 ,0x02 ,0x01 ,0x00 ,0x07 ,0x06 ,0x00 ,0x00 , 0xff, 0xff, 0x02, 0x40)); - define_test("/TP/SIG/SMG/BV-09-C", test_set_configuration, + define_test("/TP/SIG/SMG/BV-09-C", test_client, raw_pdu(0x30, 0x01), raw_pdu(0x32, 0x01, 0x04, 0x00), raw_pdu(0x40, 0x02, 0x04),
@@ -538,7 +458,7 @@ int main(int argc, char *argv[])raw_pdu (0x20 ,0x03 ,0x04 ,0x04 ,0x01 ,0x00 ,0x07 ,0x06 ,0x00 ,0x00 ,0x21 ,0x02 ,0x02 ,0x20 ), raw_pdu(0x22, 0x03)); - define_test("/TP/SIG/SMG/BV-11-C", test_get_configuration, + define_test("/TP/SIG/SMG/BV-11-C", test_client, raw_pdu(0x60, 0x01), raw_pdu(0x62, 0x01, 0x04, 0x00), raw_pdu(0x70, 0x02, 0x04),
@@ -560,7 +480,7 @@ int main(int argc, char *argv[])raw_pdu (0x30 ,0x04 ,0x04 ),raw_pdu (0x32 ,0x04 ,0x01 ,0x00 ,0x07 ,0x06 ,0x00 ,0x00 , 0x21, 0x02, 0x02, 0x20)); - define_test("/TP/SIG/SMG/BV-15-C", test_open, + define_test("/TP/SIG/SMG/BV-15-C", test_client, raw_pdu(0xa0, 0x01), raw_pdu(0xa2, 0x01, 0x04, 0x00), raw_pdu(0xb0, 0x02, 0x04),
@@ -581,7 +501,7 @@ int main(int argc, char *argv[])raw_pdu (0x22 ,0x03 ),raw_pdu (0x30 ,0x06 ,0x04 ), raw_pdu(0x32, 0x06)); - define_test("/TP/SIG/SMG/BV-17-C", test_start, + define_test("/TP/SIG/SMG/BV-17-C", test_client, raw_pdu(0xe0, 0x01), raw_pdu(0xe2, 0x01, 0x04, 0x00), raw_pdu(0xf0, 0x02, 0x04),
@@ -606,7 +526,7 @@ int main(int argc, char *argv[])raw_pdu (0x32 ,0x06 ),raw_pdu (0x40 ,0x07 ,0x04 ), raw_pdu(0x42, 0x07)); - define_test("/TP/SIG/SMG/BV-19-C", test_close, + define_test("/TP/SIG/SMG/BV-19-C", test_client, raw_pdu(0x30, 0x01), raw_pdu(0x32, 0x01, 0x04, 0x00), raw_pdu(0x40, 0x02, 0x04),
@@ -635,6 +555,20 @@ int main(int argc, char *argv[])raw_pdu (0x42 ,0x07 ),raw_pdu (0x50 ,0x08 ,0x04 ), raw_pdu(0x52, 0x08)); +define_test ("/TP/SIG/SMG/BV-21-C" , test_client, +raw_pdu (0x90 ,0x01 ), +raw_pdu (0x92 ,0x01 ,0x04 ,0x00 ), +raw_pdu (0xa0 ,0x02 ,0x04 ), +raw_pdu (0xa2 ,0x02 ,0x01 ,0x00 ,0x07 ,0x06 ,0x00 ,0x00 , +0xff ,0xff ,0x02 ,0x40 ), +raw_pdu (0xb0 ,0x03 ,0x04 ,0x04 ,0x01 ,0x00 ,0x07 ,0x06 , +0x00 ,0x00 ,0x21 ,0x02 ,0x02 ,0x20 ), +raw_pdu (0xb2 ,0x03 ), +raw_pdu (0xc0 ,0x06 ,0x04 ), +raw_pdu (0xc2 ,0x06 ), +raw_pdu (0xd0 ,0x07 ,0x04 ), +raw_pdu (0xd2 ,0x07 ), +raw_pdu (0xe0 ,0x09 ,0x04 ));return g_test_run (); }
Signature · 1 line
1.8.3.1
Luiz Augusto von Dentz
maintainerPATCH v2 18/20 unit/AVDTP: Add /TP/SIG/SMG/BV-22-C test
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
Verify that the IUT (ACP) is able to accept an AVDTP_SUSPEND_CMD, after the streaming procedure has been started, by reporting the suspension and replying the returned confirmation.
--- unit/test-avdtp.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
unit/test-avdtp.c +15 -0
@@ -569,6 +569,21 @@ int main(int argc, char *argv[])raw_pdu (0xd0 ,0x07 ,0x04 ),raw_pdu (0xd2 ,0x07 ), raw_pdu(0xe0, 0x09, 0x04)); +define_test ("/TP/SIG/SMG/BV-22-C" , test_server, +raw_pdu (0x00 ,0x01 ), +raw_pdu (0x02 ,0x01 ,0x04 ,0x00 ), +raw_pdu (0x10 ,0x02 ,0x04 ), +raw_pdu (0x12 ,0x02 ,0x01 ,0x00 ,0x07 ,0x06 ,0x00 ,0x00 , +0xff ,0xff ,0x02 ,0x40 ), +raw_pdu (0x20 ,0x03 ,0x04 ,0x04 ,0x01 ,0x00 ,0x07 ,0x06 , +0x00 ,0x00 ,0x21 ,0x02 ,0x02 ,0x20 ), +raw_pdu (0x22 ,0x03 ), +raw_pdu (0x30 ,0x06 ,0x04 ), +raw_pdu (0x32 ,0x06 ), +raw_pdu (0x40 ,0x07 ,0x04 ), +raw_pdu (0x42 ,0x07 ), +raw_pdu (0x50 ,0x09 ,0x04 ), +raw_pdu (0x52 ,0x09 ));return g_test_run (); }
Signature · 1 line
1.8.3.1
Luiz Augusto von Dentz
maintainerPATCH v2 19/20 unit/AVDTP: Add /TP/SIG/SMG/BV-23-C test
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
Verify that the IUT (INT) is able to abort a stream by issuing the AVDTP_ABORT and reporting the replied confirmation.
--- unit/test-avdtp.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
unit/test-avdtp.c +12 -0
@@ -293,6 +293,8 @@ static void sep_setconf_cfm(struct avdtp *session, struct avdtp_local_sep *sep,if (g_str_equal (context->data->test_name,"/TP/SIG/SMG/BV-11-C" )) ret =avdtp_get_configuration (session, stream); +if (g_str_equal (context->data->test_name,"/TP/SIG/SMG/BV-23-C" )) + ret =avdtp_abort (session, stream);else ret =avdtp_open (session, stream);
@@ -584,6 +586,16 @@ int main(int argc, char *argv[])raw_pdu (0x42 ,0x07 ),raw_pdu (0x50 ,0x09 ,0x04 ), raw_pdu(0x52, 0x09)); +define_test ("/TP/SIG/SMG/BV-23-C" , test_client, +raw_pdu (0xf0 ,0x01 ), +raw_pdu (0xf2 ,0x01 ,0x04 ,0x00 ), +raw_pdu (0x00 ,0x02 ,0x04 ), +raw_pdu (0x02 ,0x02 ,0x01 ,0x00 ,0x07 ,0x06 ,0x00 ,0x00 , +0xff ,0xff ,0x02 ,0x40 ), +raw_pdu (0x10 ,0x03 ,0x04 ,0x04 ,0x01 ,0x00 ,0x07 ,0x06 , +0x00 ,0x00 ,0x21 ,0x02 ,0x02 ,0x20 ), +raw_pdu (0x12 ,0x03 ), +raw_pdu (0x20 ,0x0a ,0x04 ));return g_test_run (); }
Signature · 1 line
1.8.3.1
Luiz Augusto von Dentz
maintainerPATCH v2 20/20 unit/AVDTP: Add /TP/SIG/SMG/BV-24-C test
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
Verify that the IUT (ACP) is able to accept a command to abort a stream.
--- unit/test-avdtp.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
unit/test-avdtp.c +11 -0
@@ -596,6 +596,17 @@ int main(int argc, char *argv[]) 0x00, 0x00, 0x21, 0x02, 0x02, 0x20),raw_pdu (0x12 ,0x03 ), raw_pdu(0x20, 0x0a, 0x04)); +define_test ("/TP/SIG/SMG/BV-24-C" , test_server, +raw_pdu (0x00 ,0x01 ), +raw_pdu (0x02 ,0x01 ,0x04 ,0x00 ), +raw_pdu (0x10 ,0x02 ,0x04 ), +raw_pdu (0x12 ,0x02 ,0x01 ,0x00 ,0x07 ,0x06 ,0x00 ,0x00 , +0xff ,0xff ,0x02 ,0x40 ), +raw_pdu (0x20 ,0x03 ,0x04 ,0x04 ,0x01 ,0x00 ,0x07 ,0x06 , +0x00 ,0x00 ,0x21 ,0x02 ,0x02 ,0x20 ), +raw_pdu (0x22 ,0x03 ), +raw_pdu (0x30 ,0x0a ,0x04 ), +raw_pdu (0x32 ,0x0a ));return g_test_run (); }
Signature · 1 line
1.8.3.1
Luiz Augusto von Dentz
maintainerHi,
Quoted 60 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
The code is based on the current implementation available in profiles/audio/avdtp.{c,h} but it is transport agnostic and does not contain any external dependency except glib for IO handling.
Both the signaling and the transport connection has to be handled by the upper layer, that is why it is not modified in place to avoid breaking current implemention until this work is considered stable.
Two new function are added:
-
avdtp_new: Creates AVDTP session and attach signaling transport
-avdtp_stream_set_transport: Set stream transportBoth receives a fd as parameter so in future it should be possible to replace the IO handling.
This set also includes a initial test set based on the current AVDTP test specification, once merged more tests will be added as well, then the intent is to make this used by audio plugin.
Note: It is possible to track back to the original code by doing:
git log --follow or git blame -C -C.v2: Add a separate commit to copy existing AVDTP files
Luiz Augusto von Dentz (20):
android: Add copy of current AVDTP implemention
android/AVDTP: Strip dependencies
unit/AVDTP: Add /TP/SIG/SMG/BV-05-C test
unit/AVDTP: Add /TP/SIG/SMG/BV-06-C test
unit/AVDTP: Add /TP/SIG/SMG/BV-07-C test
unit/AVDTP: Add /TP/SIG/SMG/BV-08-C test
unit/AVDTP: Add /TP/SIG/SMG/BV-09-C test
unit/AVDTP: Add /TP/SIG/SMG/BV-10-C test
unit/AVDTP: Add /TP/SIG/SMG/BV-11-C test
unit/AVDTP: Add /TP/SIG/SMG/BV-12-C test
unit/AVDTP: Add /TP/SIG/SMG/BV-15-C test
unit/AVDTP: Add /TP/SIG/SMG/BV-16-C test
unit/AVDTP: Add /TP/SIG/SMG/BV-17-C test
unit/AVDTP: Add /TP/SIG/SMG/BV-18-C test
unit/AVDTP: Add /TP/SIG/SMG/BV-19-C test
unit/AVDTP: Add /TP/SIG/SMG/BV-20-C test
unit/AVDTP: Add /TP/SIG/SMG/BV-21-C test
unit/AVDTP: Add /TP/SIG/SMG/BV-22-C test
unit/AVDTP: Add /TP/SIG/SMG/BV-23-C test
unit/AVDTP: Add /TP/SIG/SMG/BV-24-C testMakefile.am | 8 + android/Makefile.am | 1 + android/a2dp.c | 23 + android/avdtp.c | 3256 +++++++++++++++++++++++++++++++++++++++++++++++++++ android/avdtp.h | 275 +++++ unit/test-avdtp.c | 612 ++++++++++ 6 files changed, 4175 insertions(+) create mode 100644 android/avdtp.c create mode 100644 android/avdtp.h create mode 100644 unit/test-avdtp.c
Quoted 2 lines
--
1.8.3.1
This set is now upstream.
Signature · 1 line
Luiz Augusto von Dentz