summaryrefslogtreecommitdiffstats
path: root/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c
diff options
context:
space:
mode:
authorJonathan Aillet <jonathan.aillet@iot.bzh>2019-01-15 11:26:54 +0100
committerJonathan Aillet <jonathan.aillet@iot.bzh>2019-01-28 15:38:43 +0100
commit5f5c1a6460b3bf342d1c3a01ae296ecb14560fb5 (patch)
tree8c91df06973df3e94f89cbb80eaca73f0ce14a53 /4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c
parente3f74a9f59c05df601aa26554612fc68901c1646 (diff)
Improve stream creation/deletion functions
Add functions to add/remove stream verb while adding/deleting stream data. Use them to create streams when mixer response is received. Change-Id: I158b04cef7f6ce4f58a9c7481b6ebad00de989e3 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.c191
1 files changed, 0 insertions, 191 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 e501e53..ec00056 100644
--- a/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c
+++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c
@@ -408,197 +408,6 @@ int HalCtlsHalMapConfig(AFB_ApiT apiHandle, CtlSectionT *section, json_object *A
* HAL controllers verbs functions *
******************************************************************************/
-void HalCtlsActionOnMixer(AFB_ReqT request, enum ActionOnMixerType actionType)
-{
- int idx, count;
-
- char *apiToCall;
-
- AFB_ApiT apiHandle;
- CtlConfigT *ctrlConfig;
-
- struct SpecificHalData *currentCtlHalData;
- struct CtlHalMixerData *currentMixerData = NULL;
-
- json_object *requestJson, *returnJ = NULL, *responseJ, *toReturnJ = NULL;
-
- apiHandle = (AFB_ApiT) AFB_ReqGetApi(request);
- if(! apiHandle) {
- AFB_ReqFail(request, "api_handle", "Can't get current hal controller api handle");
- return;
- }
-
- ctrlConfig = (CtlConfigT *) AFB_ApiGetUserData(apiHandle);
- if(! ctrlConfig) {
- AFB_ReqFail(request, "hal_controller_config", "Can't get current hal controller config");
- return;
- }
-
- currentCtlHalData = (struct SpecificHalData *) getExternalData(ctrlConfig);
- if(! currentCtlHalData) {
- AFB_ReqFail(request, "hal_controller_data", "Can't get current hal controller data");
- return;
- }
-
- requestJson = AFB_ReqJson(request);
- if(! requestJson) {
- AFB_ReqFail(request, "request_json", "Can't get request json");
- 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");
- return;
- }
-
- if(currentCtlHalData->status != HAL_STATUS_READY) {
- AFB_ReqFail(request, "hal_not_ready", "Seems that hal is not ready");
- return;
- }
-
- if(! (currentMixerData = (struct CtlHalMixerData *) AFB_ReqVCBData(request))) {
- AFB_ReqFail(request, "hal_call_data", "Can't get current call data");
- return;
- }
-
- switch(actionType) {
- case ACTION_ON_MIXER_STREAM:
- count = 1;
- break;
-
- case ACTION_ON_MIXER_PLAYBACK:
- case ACTION_ON_MIXER_CAPTURE:
- case ACTION_ON_MIXER_ALL_STREAM:
- count = (int) HalUtlGetNumberOfMixerDataInList(&currentMixerData);
- toReturnJ = json_object_new_object();
- break;
-
- default:
- AFB_ReqFail(request, "hal_call_data", "Can't get current call data");
- return;
- }
-
- for(idx = 0; idx < count; idx++) {
- 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;
- }
-
- // TBD JAI : When mixer events will be available, use them instead of generating events at calls
- if((actionType == ACTION_ON_MIXER_STREAM ||
- actionType == ACTION_ON_MIXER_ALL_STREAM) &&
- ((! currentMixerData->event) ||
- (AFB_EventPush(currentMixerData->event, json_object_get(responseJ)) < 0))) {
- AFB_ApiError(apiHandle, "Couldn't generate an event for stream %s", currentMixerData->verb);
- }
-
- 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);
-
- switch(actionType) {
- case ACTION_ON_MIXER_PLAYBACK:
- case ACTION_ON_MIXER_CAPTURE:
- case ACTION_ON_MIXER_ALL_STREAM:
- currentMixerData = currentMixerData->next;
- break;
-
- default:
- break;
- }
- }
-
- 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;
- }
-}
-
-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 CtlHalMixerData **firstMixerData, enum MixerDataType dataType)
{
json_object *mixerDataArrayJ, *currentMixerDataJ;