summaryrefslogtreecommitdiffstats
path: root/src/sm-helper.c
diff options
context:
space:
mode:
authorKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-03-08 12:24:46 +0900
committerKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-05-11 11:34:02 +0900
commit34e04465bd68dc92a1009c6eaebcace68aadf7c1 (patch)
tree9d9e62cf2342284e605910da62c44355b4ea5110 /src/sm-helper.c
parent08a28337118f5474b6ce73d3024dbd88d994cb93 (diff)
Improve: Add stream_open API
Add stream_open API. This means registeration of source in soundmanager. The following keys are same as High Level API's argument. audio_role ... is translated to sourceID in soundmanager endpoint_id ... is translated to sinkID and used after in soundmanager endpoint_type ... is not used in soundmanager Change-Id: Id2044b406c9e8f0a20604ce653607aed0140fe19 Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
Diffstat (limited to 'src/sm-helper.c')
-rw-r--r--src/sm-helper.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/sm-helper.c b/src/sm-helper.c
index f9e7ec3..b598faa 100644
--- a/src/sm-helper.c
+++ b/src/sm-helper.c
@@ -15,6 +15,7 @@
*/
#include "sm-helper.h"
+#include "sm-def.h"
#include <stdlib.h>
#include <string.h>
#include <limits.h>
@@ -93,6 +94,31 @@ REQ_ERROR get_value_int32(const struct afb_req request, const char *source, int3
return REQ_OK;
}
+REQ_ERROR get_sink_id(const afb_req request, const char* key, uint16_t* out_sink_id){
+ AFB_DEBUG("");
+ REQ_ERROR result = REQ_FAIL;
+ const char* requested_sink_str = afb_req_value (request, key);
+ json_object* test = afb_req_json(request);
+ AFB_DEBUG("%s", json_object_to_json_string_ext(test, JSON_C_TO_STRING_PRETTY));
+
+ if(0 == strcmp(requested_sink_str, "default")){
+ *out_sink_id = DEFAULT_SINK;
+ AFB_INFO("sinkID(endpointID) is attached as default sinkID as %d", DEFAULT_SINK);
+ result = REQ_OK;
+ }
+ else{
+ result = get_value_uint16(request, key, out_sink_id);
+ AFB_INFO("sinkID(endpointID) is %d", *out_sink_id);
+ }
+
+ if(REQ_OK != result){
+ AFB_INFO("can't parse %s, result %d", key, result);
+ afb_req_fail_f(request,"wrong-request","can't parse %s, result: %d", key, result);
+ return result;
+ }
+ return REQ_OK;
+}
+
void sm_add_object_to_json_object(struct json_object* j_obj, int count,...)
{
va_list args;