summaryrefslogtreecommitdiffstats
path: root/4a-hal
diff options
context:
space:
mode:
authorJonathan Aillet <jonathan.aillet@iot.bzh>2018-12-17 12:34:36 +0100
committerJonathan Aillet <jonathan.aillet@iot.bzh>2018-12-20 11:10:17 +0100
commitecb03929df1b66e0d41771e49f3f810d4bcdffba (patch)
treefb976ef36fd340420e5e38267c2fb2c6fdfd5bd6 /4a-hal
parentf741fc82145c57c8dd1e483d9ab26ef2b4a92206 (diff)
Add 'halmap' controls in hal 'info' verb response
Add 'halmap' controls verbs (specified in json configuration file) in the response of verb 'info'. Bug-AGL: SPEC-1313 Change-Id: I4e7ec5c3d23fd505da1eb233c1da63708024912d Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
Diffstat (limited to '4a-hal')
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c2
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c96
2 files changed, 77 insertions, 21 deletions
diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c b/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c
index 0c2a95d..390431e 100644
--- a/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c
+++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c
@@ -61,7 +61,7 @@ static CtlSectionT ctrlSectionsDefault[] =
static AFB_ApiVerbs CtlHalApiStaticVerbs[] =
{
/* VERB'S NAME FUNCTION TO CALL SHORT DESCRIPTION */
- { .verb = "info", .callback = HalCtlsInfo, .info = "List available streams/playbacks/captures... for this api" },
+ { .verb = "info", .callback = HalCtlsInfo, .info = "List available streams/playbacks/captures/controls for this api" },
{ .verb = NULL } // Marker for end of the array
};
diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c b/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c
index b9ba537..ca3ba6b 100644
--- a/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c
+++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c
@@ -489,18 +489,26 @@ json_object *HalCtlsGetJsonArrayForMixerDataTable(AFB_ApiT apiHandle, struct Ctl
}
for(idx = 0; idx < currentMixerDataT->count; idx++) {
- if(dataType == MIXER_DATA_STREAMS) {
- wrap_json_pack(&currentMixerData,
- "{s:s s:s}",
- "name", currentMixerDataT->data[idx].verb,
- "cardId", currentMixerDataT->data[idx].streamCardId);
- }
- else {
- wrap_json_pack(&currentMixerData,
- "{s:s s:s}",
- "name", currentMixerDataT->data[idx].verb,
- "mixer-name", currentMixerDataT->data[idx].verbToCall,
- "uid", currentMixerDataT->data[idx].streamCardId ? currentMixerDataT->data[idx].streamCardId : "none");
+ switch(dataType) {
+ case MIXER_DATA_STREAMS:
+ wrap_json_pack(&currentMixerData,
+ "{s:s s:s}",
+ "name", currentMixerDataT->data[idx].verb,
+ "cardId", currentMixerDataT->data[idx].streamCardId);
+ break;
+
+ case MIXER_DATA_PLAYBACKS:
+ case MIXER_DATA_CAPTURES :
+ wrap_json_pack(&currentMixerData,
+ "{s:s s:s}",
+ "name", currentMixerDataT->data[idx].verb,
+ "mixer-name", currentMixerDataT->data[idx].verbToCall,
+ "uid", currentMixerDataT->data[idx].streamCardId ? currentMixerDataT->data[idx].streamCardId : "none");
+ break;
+
+ default:
+ json_object_put(mixerDataArray);
+ return NULL;
}
json_object_array_add(mixerDataArray, currentMixerData);
}
@@ -508,6 +516,40 @@ json_object *HalCtlsGetJsonArrayForMixerDataTable(AFB_ApiT apiHandle, struct Ctl
return mixerDataArray;
}
+json_object *HalCtlsGetJsonArrayForControls(AFB_ApiT apiHandle, struct CtlHalAlsaMapT *currentAlsaMapDataT)
+{
+ unsigned int idx;
+
+ json_object *alsaMapDataArray, *currentAlsaMapData;
+
+ if(! apiHandle) {
+ AFB_ApiError(apiHandle, "Can't get current hal controller api handle");
+ return NULL;
+ }
+
+ if(! currentAlsaMapDataT) {
+ AFB_ApiError(apiHandle, "Can't get Alsa map data table to handle");
+ return NULL;
+ }
+
+ alsaMapDataArray = json_object_new_array();
+ if(! alsaMapDataArray) {
+ AFB_ApiError(apiHandle, "Can't generate json mixer data array");
+ return NULL;
+ }
+
+ for(idx = 0; idx < currentAlsaMapDataT->ctlsCount; idx++) {
+ wrap_json_pack(&currentAlsaMapData,
+ "{s:s s:s}",
+ "name", currentAlsaMapDataT->ctls[idx].uid,
+ "info", currentAlsaMapDataT->ctls[idx].info ? currentAlsaMapDataT->ctls[idx].info : "none");
+
+ json_object_array_add(alsaMapDataArray, currentAlsaMapData);
+ }
+
+ return alsaMapDataArray;
+}
+
void HalCtlsInfo(AFB_ReqT request)
{
char *apiToCall, *returnedStatus = NULL, *returnedInfo = NULL;
@@ -517,7 +559,7 @@ void HalCtlsInfo(AFB_ReqT request)
struct SpecificHalData *currentCtlHalData;
- json_object *requestJson, *toReturnJ = NULL, *requestAnswer, *streamsArray, *playbacksArray, *capturesArray;
+ json_object *requestJson, *toReturnJ = NULL, *requestAnswer, *streamsArray, *playbacksArray, *capturesArray, *controlsArray;
apiHandle = (AFB_ApiT) AFB_ReqGetApi(request);
if(! apiHandle) {
@@ -566,25 +608,39 @@ void HalCtlsInfo(AFB_ReqT request)
return;
}
- streamsArray = HalCtlsGetJsonArrayForMixerDataTable(apiHandle, &currentCtlHalData->ctlHalSpecificData->ctlHalStreamsData, MIXER_DATA_STREAMS);
- if(! streamsArray) {
+ if(! (streamsArray = HalCtlsGetJsonArrayForMixerDataTable(apiHandle,
+ &currentCtlHalData->ctlHalSpecificData->ctlHalStreamsData,
+ MIXER_DATA_STREAMS))) {
AFB_ReqFail(request, "streams_data", "Didn't succeed to generate streams data array");
return;
}
- playbacksArray = HalCtlsGetJsonArrayForMixerDataTable(apiHandle, &currentCtlHalData->ctlHalSpecificData->ctlHalPlaybacksData, MIXER_DATA_PLAYBACKS);
- if(! playbacksArray) {
+ if(! (playbacksArray = HalCtlsGetJsonArrayForMixerDataTable(apiHandle,
+ &currentCtlHalData->ctlHalSpecificData->ctlHalPlaybacksData,
+ MIXER_DATA_PLAYBACKS))) {
AFB_ReqFail(request, "playbacks_data", "Didn't succeed to generate playbacks data array");
return;
}
- capturesArray = HalCtlsGetJsonArrayForMixerDataTable(apiHandle, &currentCtlHalData->ctlHalSpecificData->ctlHalCapturesData, MIXER_DATA_CAPTURES);
- if(! capturesArray) {
+ if(! (capturesArray = HalCtlsGetJsonArrayForMixerDataTable(apiHandle,
+ &currentCtlHalData->ctlHalSpecificData->ctlHalCapturesData,
+ MIXER_DATA_CAPTURES))) {
AFB_ReqFail(request, "captures_data", "Didn't succeed to generate captures data array");
return;
}
- wrap_json_pack(&requestAnswer, "{s:o s:o s:o}", "streams", streamsArray, "playbacks", playbacksArray, "captures", capturesArray);
+ if(! (controlsArray = HalCtlsGetJsonArrayForControls(apiHandle,
+ currentCtlHalData->ctlHalSpecificData->ctlHalAlsaMapT))) {
+ AFB_ReqFail(request, "controls_data", "Didn't succeed to generate controls data array");
+ return;
+ }
+
+ wrap_json_pack(&requestAnswer,
+ "{s:o s:o s:o s:o}",
+ "streams", streamsArray,
+ "playbacks", playbacksArray,
+ "captures", capturesArray,
+ "controls", controlsArray);
AFB_ReqSuccess(request, requestAnswer, "Requested data");
} \ No newline at end of file