summaryrefslogtreecommitdiffstats
path: root/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c
diff options
context:
space:
mode:
authorJonathan Aillet <jonathan.aillet@iot.bzh>2018-12-17 19:41:41 +0100
committerJonathan Aillet <jonathan.aillet@iot.bzh>2018-12-20 11:10:17 +0100
commita48048548e85244a66e830523ebcbeb7f709ad60 (patch)
tree36193cfe797df0967e551cc8adc18a18fe96ae03 /4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c
parentecb03929df1b66e0d41771e49f3f810d4bcdffba (diff)
Rework calls to mixer streams
When using 'playback'/'capture' verbs, call all associated controls. When at least one stream has been created by the mixer, a verb called 'all-streams' is added to transfer a request to all the streams. Bug-AGL: SPEC-1313 Change-Id: Ie574e2ef0dcae8abbd45523b49093ec2ed1413cf Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
Diffstat (limited to '4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c')
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c166
1 files changed, 137 insertions, 29 deletions
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 ca3ba6b..9e25c61 100644
--- a/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c
+++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c
@@ -385,17 +385,20 @@ int HalCtlsHalMapConfig(AFB_ApiT apiHandle, CtlSectionT *section, json_object *A
* HAL controllers verbs functions *
******************************************************************************/
-void HalCtlsActionOnCall(AFB_ReqT request)
+void HalCtlsActionOnMixer(AFB_ReqT request, enum ActionOnMixerType actionType)
{
+ int idx, count;
+
char *apiToCall;
AFB_ApiT apiHandle;
CtlConfigT *ctrlConfig;
struct SpecificHalData *currentCtlHalData;
- struct CtlHalMixerData *currentMixerData;
+ struct CtlHalMixerData *currentMixerData = NULL;
+ struct CtlHalMixerDataT *currentMixerDataT = NULL;
- json_object *requestJson, *returnJ = NULL, *toReturnJ;
+ json_object *requestJson, *returnJ = NULL, *responseJ, *toReturnJ = NULL;
apiHandle = (AFB_ApiT) AFB_ReqGetApi(request);
if(! apiHandle) {
@@ -409,12 +412,6 @@ void HalCtlsActionOnCall(AFB_ReqT request)
return;
}
- currentMixerData = (struct CtlHalMixerData *) AFB_ReqVCBData(request);
- if(! currentMixerData) {
- AFB_ReqFail(request, "hal_call_data", "Can't get current call data");
- return;
- }
-
currentCtlHalData = (struct SpecificHalData *) getExternalData(ctrlConfig);
if(! currentCtlHalData) {
AFB_ReqFail(request, "hal_controller_data", "Can't get current hal controller data");
@@ -427,6 +424,9 @@ void HalCtlsActionOnCall(AFB_ReqT request)
return;
}
+ if(json_object_is_type(requestJson, json_type_object) && json_object_get_object(requestJson)->count > 0)
+ json_object_object_add(requestJson, "verbose", json_object_new_boolean(1));
+
apiToCall = currentCtlHalData->ctlHalSpecificData->mixerApiName;
if(! apiToCall) {
AFB_ReqFail(request, "mixer_api", "Can't get mixer api");
@@ -438,32 +438,140 @@ void HalCtlsActionOnCall(AFB_ReqT request)
return;
}
- if(json_object_is_type(requestJson, json_type_object) && json_object_get_object(requestJson)->count > 0)
- json_object_object_add(requestJson, "verbose", json_object_new_boolean(1));
+ switch(actionType) {
+ case ACTION_ON_MIXER_STREAM:
+ currentMixerData = (struct CtlHalMixerData *) AFB_ReqVCBData(request);
+ if(! currentMixerData) {
+ AFB_ReqFail(request, "hal_call_data", "Can't get current call data");
+ return;
+ }
+ count = 1;
+ break;
- // TBD JAI : handle the case of there is multiple 'playbacks' or 'captures' entries (call them all)
+ case ACTION_ON_MIXER_PLAYBACK:
+ case ACTION_ON_MIXER_CAPTURE:
+ case ACTION_ON_MIXER_ALL_STREAM:
+ currentMixerDataT = (struct CtlHalMixerDataT *) AFB_ReqVCBData(request);
+ if(! currentMixerDataT) {
+ AFB_ReqFail(request, "hal_call_data", "Can't get current call data");
+ return;
+ }
+ count = currentMixerDataT->count;
+ toReturnJ = json_object_new_object();
+ break;
- if(AFB_ServiceSync(apiHandle, apiToCall, currentMixerData->verbToCall, json_object_get(requestJson), &returnJ)) {
- HalUtlHandleAppFwCallErrorInRequest(request, apiToCall, currentMixerData->verbToCall, returnJ, "call_action");
+ default:
+ AFB_ReqFail(request, "hal_call_data", "Can't get current call data");
+ return;
}
- else if(wrap_json_unpack(returnJ, "{s:o}", "response", &toReturnJ)) {
- AFB_ReqSuccessF(request,
- json_object_get(returnJ),
- "Seems that %s call to api %s succeed, but no response was found : '%s'",
- currentMixerData->verbToCall,
- apiToCall,
- json_object_get_string(returnJ));
+
+ for(idx = 0; idx < count; idx++) {
+ switch(actionType) {
+ case ACTION_ON_MIXER_PLAYBACK:
+ case ACTION_ON_MIXER_CAPTURE:
+ case ACTION_ON_MIXER_ALL_STREAM:
+ currentMixerData = &currentMixerDataT->data[idx];
+ break;
+
+ default:
+ break;
+ }
+
+ if(AFB_ServiceSync(apiHandle,
+ apiToCall,
+ currentMixerData->verbToCall,
+ json_object_get(requestJson),
+ &returnJ)) {
+ HalUtlHandleAppFwCallErrorInRequest(request, apiToCall, currentMixerData->verbToCall, returnJ, "call_action");
+ json_object_put(returnJ);
+ if(toReturnJ)
+ json_object_put(toReturnJ);
+ return;
+ }
+
+ if(wrap_json_unpack(returnJ, "{s:o}", "response", &responseJ)) {
+ AFB_ReqFailF(request,
+ "Seems that %s call to api %s succeed, but no response was found in : '%s'",
+ currentMixerData->verbToCall,
+ apiToCall,
+ json_object_get_string(returnJ));
+ json_object_put(returnJ);
+ if(toReturnJ)
+ json_object_put(toReturnJ);
+ return;
+ }
+
+ switch(actionType) {
+ case ACTION_ON_MIXER_STREAM:
+ toReturnJ = json_object_get(responseJ);
+ break;
+
+ case ACTION_ON_MIXER_PLAYBACK:
+ case ACTION_ON_MIXER_CAPTURE:
+ json_object_object_add(toReturnJ, currentMixerData->verbToCall, json_object_get(responseJ));
+ break;
+
+ case ACTION_ON_MIXER_ALL_STREAM:
+ json_object_object_add(toReturnJ, currentMixerData->verb, json_object_get(responseJ));
+ break;
+
+ default:
+ break;
+ }
+
+ json_object_put(returnJ);
}
- else {
- AFB_ReqSuccessF(request,
- json_object_get(toReturnJ),
- "Action %s correctly transferred to %s without any error raised",
- currentMixerData->verbToCall,
- apiToCall);
+
+ switch(actionType) {
+ case ACTION_ON_MIXER_STREAM:
+ AFB_ReqSuccessF(request,
+ toReturnJ,
+ "Action %s correctly transferred to %s without any error raised",
+ currentMixerData->verbToCall,
+ apiToCall);
+ break;
+
+ case ACTION_ON_MIXER_PLAYBACK:
+ AFB_ReqSuccess(request,
+ toReturnJ,
+ "Actions correctly transferred to all playbacks without any error raised");
+ break;
+
+ case ACTION_ON_MIXER_CAPTURE:
+ AFB_ReqSuccess(request,
+ toReturnJ,
+ "Actions correctly transferred to all captures without any error raised");
+ break;
+
+ case ACTION_ON_MIXER_ALL_STREAM:
+ AFB_ReqSuccess(request,
+ toReturnJ,
+ "Actions correctly transferred to all streams without any error raised");
+ break;
+
+ default:
+ break;
}
+}
- if(returnJ)
- json_object_put(returnJ);
+void HalCtlsActionOnStream(AFB_ReqT request)
+{
+ HalCtlsActionOnMixer(request, ACTION_ON_MIXER_STREAM);
+}
+
+void HalCtlsActionOnPlayback(AFB_ReqT request)
+{
+ HalCtlsActionOnMixer(request, ACTION_ON_MIXER_PLAYBACK);
+}
+
+void HalCtlsActionOnCapture(AFB_ReqT request)
+{
+ HalCtlsActionOnMixer(request, ACTION_ON_MIXER_CAPTURE);
+}
+
+void HalCtlsActionOnAllStream(AFB_ReqT request)
+{
+ HalCtlsActionOnMixer(request, ACTION_ON_MIXER_ALL_STREAM);
}
json_object *HalCtlsGetJsonArrayForMixerDataTable(AFB_ApiT apiHandle, struct CtlHalMixerDataT *currentMixerDataT, enum MixerDataType dataType)