summaryrefslogtreecommitdiffstats
path: root/binding/afm-mediaplayer-binding.c
diff options
context:
space:
mode:
authorRonan Le Martret <ronan.lemartret@iot.bzh>2017-12-05 11:06:07 +0100
committerScott Murray <scott.murray@konsulko.com>2017-12-20 19:24:21 -0500
commitd03590991d2c7104e7cd4b2a18e710008b2759ab (patch)
tree93f69d19982cc4ea4a3b6a317558e0b399492447 /binding/afm-mediaplayer-binding.c
parentda737e24ee735b5dbcf773997ee1f42cd4cc9888 (diff)
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 <ronan.lemartret@iot.bzh> Signed-off-by: Scott Murray <scott.murray@konsulko.com>
Diffstat (limited to 'binding/afm-mediaplayer-binding.c')
-rw-r--r--binding/afm-mediaplayer-binding.c29
1 files changed, 29 insertions, 0 deletions
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);