summaryrefslogtreecommitdiffstats
path: root/lib/4a-hal-utilities/4a-hal-utilities-data.c
diff options
context:
space:
mode:
authorJonathan Aillet <jonathan.aillet@iot.bzh>2019-06-06 14:56:03 +0200
committerJonathan Aillet <jonathan.aillet@iot.bzh>2019-06-06 14:56:03 +0200
commit82cde4494319b55b51a6c42e037003b8241c02be (patch)
tree602dd5384b2d5b977392453b6163527c045129be /lib/4a-hal-utilities/4a-hal-utilities-data.c
parent391fcec50ea79d4f487258532e1df6007f3942c7 (diff)
Move functions used to generate json
Move functions used to generate hal information json into there corresponding files in hal-utilities. BUG-AGL: SPEC-2329 Change-Id: Id518e7f732ef393bbf98f3b3a32edf01ec81f70c Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
Diffstat (limited to 'lib/4a-hal-utilities/4a-hal-utilities-data.c')
-rw-r--r--lib/4a-hal-utilities/4a-hal-utilities-data.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/lib/4a-hal-utilities/4a-hal-utilities-data.c b/lib/4a-hal-utilities/4a-hal-utilities-data.c
index 3918db4..b1401a9 100644
--- a/lib/4a-hal-utilities/4a-hal-utilities-data.c
+++ b/lib/4a-hal-utilities/4a-hal-utilities-data.c
@@ -348,6 +348,68 @@ struct InternalHalMixerData *HalUtlSearchMixerDataByProperties(struct InternalHa
return NULL;
}
+json_object *HalUtlGetJsonArrayForSpecificMixerData(afb_api_t apiHandle, struct InternalHalMixerData *mixerData)
+{
+ int wrapRet;
+
+ json_object *currentMixerDataJ;
+
+ if(! apiHandle) {
+ AFB_API_ERROR(apiHandle, "Api handle is not valid");
+ return NULL;
+ }
+
+ if(! mixerData) {
+ AFB_API_ERROR(apiHandle, "Mixer data to use to generate json object are empty");
+ return NULL;
+ }
+
+ wrapRet = wrap_json_pack(&currentMixerDataJ,
+ "{s:s s:s}",
+ "name", mixerData->verb,
+ "cardId", mixerData->streamCardId);
+ if(wrapRet) {
+ AFB_API_ERROR(apiHandle, "Didn't succeed to allocate current mixer json object");
+ return NULL;
+ }
+
+ return currentMixerDataJ;
+}
+
+json_object *HalUtlGetJsonArrayForAllMixersData(afb_api_t apiHandle, struct InternalHalMixerData **mixerDataList)
+{
+ json_object *mixerDataArrayJ, *currentMixerDataJ;
+
+ struct InternalHalMixerData *currentMixerData;
+
+ if(! apiHandle) {
+ AFB_API_ERROR(apiHandle, "Api handle is not valid");
+ return NULL;
+ }
+
+ mixerDataArrayJ = json_object_new_array();
+ if(! mixerDataArrayJ) {
+ AFB_API_ERROR(apiHandle, "Didn't succeed to allocate requested mixer data json array");
+ return NULL;
+ }
+
+ currentMixerData = *mixerDataList;
+ while(currentMixerData) {
+ currentMixerDataJ = HalUtlGetJsonArrayForSpecificMixerData(apiHandle, currentMixerData);
+ if(! currentMixerDataJ) {
+ AFB_API_ERROR(apiHandle, "Didn't succeed to generate current mixer data json object");
+ json_object_put(mixerDataArrayJ);
+ return NULL;
+ }
+
+ json_object_array_add(mixerDataArrayJ, currentMixerDataJ);
+
+ currentMixerData = currentMixerData->next;
+ }
+
+ return mixerDataArrayJ;
+}
+
/*******************************************************************************
* Hal data handling functions *
******************************************************************************/