From d03590991d2c7104e7cd4b2a18e710008b2759ab Mon Sep 17 00:00:00 2001 From: Ronan Le Martret Date: Tue, 5 Dec 2017 11:06:07 +0100 Subject: Add 4A support Add conditional compilation option to enable using the 4A high-level API to request Multimedia role access. Change-Id: I85c19e33a355f9133bdda837e9374776fc92efe9 Signed-off-by: Ronan Le Martret Signed-off-by: Scott Murray --- binding/CMakeLists.txt | 3 +++ binding/afm-mediaplayer-binding.c | 29 +++++++++++++++++++++++++++++ conf.d/cmake/config.cmake | 6 +++++- conf.d/wgt/config-4a.xml.in | 25 +++++++++++++++++++++++++ 4 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 conf.d/wgt/config-4a.xml.in diff --git a/binding/CMakeLists.txt b/binding/CMakeLists.txt index 02f2aa9..2df218b 100644 --- a/binding/CMakeLists.txt +++ b/binding/CMakeLists.txt @@ -39,3 +39,6 @@ PROJECT_TARGET_ADD(afm-mediaplayer-binding) INSTALL(TARGETS ${TARGET_NAME} LIBRARY DESTINATION ${BINDINGS_INSTALL_DIR}) + if(HAVE_4A_FRAMEWORK) + add_definitions(-DHAVE_4A_FRAMEWORK) + endif() diff --git a/binding/afm-mediaplayer-binding.c b/binding/afm-mediaplayer-binding.c index 2e3bef2..478ba0e 100644 --- a/binding/afm-mediaplayer-binding.c +++ b/binding/afm-mediaplayer-binding.c @@ -660,6 +660,35 @@ static void *gstreamer_loop_thread(void *ptr) data.fake_sink = gst_element_factory_make("fakesink", NULL); data.alsa_sink = gst_element_factory_make("alsasink", NULL); +#ifdef HAVE_4A_FRAMEWORK + json_object *jsonData = json_object_new_object(); + json_object_object_add(jsonData, "audio_role", json_object_new_string("Multimedia")); + json_object_object_add(jsonData, "endpoint_type", json_object_new_string("sink")); + ret = afb_service_call_sync("ahl-4a", "stream_open", jsonData, &response); + + if (!ret) { + json_object *valJson = NULL; + json_object *val = NULL; + gboolean ret; + ret = json_object_object_get_ex(response, "response", &valJson); + if (ret) { + ret = json_object_object_get_ex(valJson, "device_uri", &val); + if (ret) { + char* jres_pcm = json_object_get_string(val); + gchar ** res_pcm= g_strsplit (jres_pcm,":",-1); + if (res_pcm) { + g_object_set(data.alsa_sink, "device", res_pcm[1], NULL); + g_free(res_pcm); + } + } + ret = json_object_object_get_ex(valJson, "stream_id", &val); + if (ret) { + int stream_id = json_object_get_int(val); + } + } + } +#endif + g_object_set(data.playbin, "audio-sink", data.fake_sink, NULL); gst_element_set_state(data.playbin, GST_STATE_PAUSED); diff --git a/conf.d/cmake/config.cmake b/conf.d/cmake/config.cmake index e7e6143..92c7ee1 100644 --- a/conf.d/cmake/config.cmake +++ b/conf.d/cmake/config.cmake @@ -86,7 +86,11 @@ set(LD_LIBRARY_PATH ${CMAKE_INSTALL_PREFIX}/lib64 ${CMAKE_INSTALL_PREFIX}/lib) # Optional location for config.xml.in # ----------------------------------- -set(WIDGET_CONFIG_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/conf.d/wgt/config.xml.in) +if(HAVE_4A_FRAMEWORK) + set(WIDGET_CONFIG_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/conf.d/wgt/config-4a.xml.in) +else() + set(WIDGET_CONFIG_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/conf.d/wgt/config.xml.in) +endif() # Mandatory widget Mimetype specification of the main unit # -------------------------------------------------------------------------- diff --git a/conf.d/wgt/config-4a.xml.in b/conf.d/wgt/config-4a.xml.in new file mode 100644 index 0000000..a6ab311 --- /dev/null +++ b/conf.d/wgt/config-4a.xml.in @@ -0,0 +1,25 @@ + + + @PROJECT_NAME@ + + + @PROJECT_DESCRIPTION@ + @PROJECT_AUTHOR@ <@PROJECT_AUTHOR_MAIL@> + @PROJECT_LICENSE@ + + + + + + + + + + + + + + + + + -- cgit 1.2.3-korg