diff options
Diffstat (limited to '4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c')
-rw-r--r-- | 4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c | 79 |
1 files changed, 46 insertions, 33 deletions
diff --git a/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c b/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c index 3f30436..ed06b27 100644 --- a/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c +++ b/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c @@ -40,8 +40,8 @@ void HalUtlActionOnMixer(afb_req_t request, enum ActionOnMixerType actionType) afb_api_t apiHandle; CtlConfigT *ctrlConfig; - struct SpecificHalData *currentCtlHalData; - struct CtlHalMixerData *currentMixerData = NULL; + struct HalData *currentHalData; + struct InternalHalMixerData *currentMixerData = NULL; json_object *requestJson, *responseJ = NULL, *toReturnJ = NULL; @@ -55,7 +55,8 @@ void HalUtlActionOnMixer(afb_req_t request, enum ActionOnMixerType actionType) return; } - if(! (currentCtlHalData = (struct SpecificHalData *) getExternalData(ctrlConfig))) { + currentHalData = (struct HalData *) getExternalData(ctrlConfig); + if(! currentHalData) { afb_req_fail(request, "hal_controller_data", "Can't get current hal controller data"); return; } @@ -68,18 +69,19 @@ void HalUtlActionOnMixer(afb_req_t request, enum ActionOnMixerType actionType) 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; + apiToCall = currentHalData->internalHalData->mixerApiName; if(! apiToCall) { afb_req_fail(request, "mixer_api", "Can't get mixer api"); return; } - if(currentCtlHalData->status != HAL_STATUS_READY) { + if(currentHalData->status != HAL_STATUS_READY) { afb_req_fail(request, "hal_not_ready", "Seems that hal is not ready"); return; } - if(! (currentMixerData = (struct CtlHalMixerData *) afb_req_get_vcbdata(request))) { + currentMixerData = (struct InternalHalMixerData *) afb_req_get_vcbdata(request); + if(! currentMixerData) { afb_req_fail(request, "hal_call_data", "Can't get current call data"); return; } @@ -227,27 +229,32 @@ void HalUtlActionOnAllStream(afb_req_t request) * Add stream data and verb function * ******************************************************************************/ -struct CtlHalMixerData *HalUtlAddStreamDataAndCreateStreamVerb(afb_api_t apiHandle, - char *verb, - char *verbToCall, - char *streamCardId) +struct InternalHalMixerData *HalUtlAddStreamDataAndCreateStreamVerb(afb_api_t apiHandle, + char *verb, + char *verbToCall, + char *streamCardId) { json_object *streamAddedEventJ; CtlConfigT *ctrlConfig; - struct SpecificHalData *currentSpecificHalData; - struct CtlHalMixerData *createdStreamData; + struct HalData *currentHalData; + struct InternalHalMixerData *createdStreamData; if(! apiHandle || ! verb || ! verbToCall || ! streamCardId) return NULL; - if((! (ctrlConfig = (CtlConfigT *) afb_api_get_userdata(apiHandle))) || - (! (currentSpecificHalData = (struct SpecificHalData *) getExternalData(ctrlConfig))) || - (! currentSpecificHalData->ctlHalSpecificData)) + ctrlConfig = (CtlConfigT *) afb_api_get_userdata(apiHandle); + if(! ctrlConfig) return NULL; - if(! (createdStreamData = HalUtlAddMixerDataToMixerDataList(¤tSpecificHalData->ctlHalSpecificData->ctlHalStreamsData))) + currentHalData = (struct HalData *) getExternalData(ctrlConfig); + if(! currentHalData || + ! currentHalData->internalHalData) + return NULL; + + createdStreamData = HalUtlAddMixerDataToMixerDataList(¤tHalData->internalHalData->streamsData); + if(! createdStreamData) return NULL; createdStreamData->verb = strdup(verb); @@ -257,12 +264,12 @@ struct CtlHalMixerData *HalUtlAddStreamDataAndCreateStreamVerb(afb_api_t apiHand if((! createdStreamData->verb) || (! createdStreamData->verbToCall) || (! createdStreamData->streamCardId)) { - HalUtlRemoveSelectedMixerData(¤tSpecificHalData->ctlHalSpecificData->ctlHalStreamsData, createdStreamData); + HalUtlRemoveSelectedMixerData(¤tHalData->internalHalData->streamsData, createdStreamData); return NULL; } if(! (createdStreamData->event = afb_api_make_event(apiHandle, createdStreamData->verb))) { - HalUtlRemoveSelectedMixerData(¤tSpecificHalData->ctlHalSpecificData->ctlHalStreamsData, createdStreamData); + HalUtlRemoveSelectedMixerData(¤tHalData->internalHalData->streamsData, createdStreamData); return NULL; } @@ -275,7 +282,7 @@ struct CtlHalMixerData *HalUtlAddStreamDataAndCreateStreamVerb(afb_api_t apiHand 0, 0)) { AFB_API_ERROR(apiHandle,"Error while creating verb for stream : '%s'", createdStreamData->verb); - HalUtlRemoveSelectedMixerData(¤tSpecificHalData->ctlHalSpecificData->ctlHalStreamsData, createdStreamData); + HalUtlRemoveSelectedMixerData(¤tHalData->internalHalData->streamsData, createdStreamData); return NULL; } @@ -285,7 +292,7 @@ struct CtlHalMixerData *HalUtlAddStreamDataAndCreateStreamVerb(afb_api_t apiHand "name", createdStreamData->verb, "cardId", createdStreamData->streamCardId); - afb_event_push(currentSpecificHalData->ctlHalSpecificData->streamUpdates, streamAddedEventJ); + afb_event_push(currentHalData->internalHalData->streamUpdates, streamAddedEventJ); return createdStreamData; } @@ -301,23 +308,28 @@ int8_t HalUtlRemoveStreamDataAndDeleteStreamVerb(afb_api_t apiHandle, CtlConfigT *ctrlConfig; - struct SpecificHalData *currentSpecificHalData; - struct CtlHalMixerData *toRemoveStreamData; + struct HalData *currentHalData; + struct InternalHalMixerData *toRemoveStreamData; if(! apiHandle || ! verb || ! verbToCall || ! streamCardId) return -1; - if((! (ctrlConfig = (CtlConfigT *) afb_api_get_userdata(apiHandle))) || - (! (currentSpecificHalData = (struct SpecificHalData *) getExternalData(ctrlConfig))) || - (! currentSpecificHalData->ctlHalSpecificData)) + ctrlConfig = (CtlConfigT *) afb_api_get_userdata(apiHandle); + if(! ctrlConfig) return -2; - if(! (toRemoveStreamData = HalUtlSearchMixerDataByProperties(¤tSpecificHalData->ctlHalSpecificData->ctlHalStreamsData, - verb, - verbToCall, - streamCardId))) + currentHalData = (struct HalData *) getExternalData(ctrlConfig); + if(! currentHalData || + ! currentHalData->internalHalData) return -3; + toRemoveStreamData = HalUtlSearchMixerDataByProperties(¤tHalData->internalHalData->streamsData, + verb, + verbToCall, + streamCardId); + if(! toRemoveStreamData) + return -4; + wrap_json_pack(&streamRemovedEventJ, "{s:s, s:s, s:s}", "action", "removed", @@ -327,16 +339,17 @@ int8_t HalUtlRemoveStreamDataAndDeleteStreamVerb(afb_api_t apiHandle, if(afb_api_del_verb(apiHandle, verb, NULL)) { AFB_API_ERROR(apiHandle,"Error while deleting verb for stream : '%s'", verb); json_object_put(streamRemovedEventJ); - return -4; + return -5; } - if((returnedErr = HalUtlRemoveSelectedMixerData(¤tSpecificHalData->ctlHalSpecificData->ctlHalStreamsData, toRemoveStreamData))) { + returnedErr = HalUtlRemoveSelectedMixerData(¤tHalData->internalHalData->streamsData, toRemoveStreamData); + if(returnedErr) { AFB_API_ERROR(apiHandle,"Error %i while removing data for stream : '%s'", returnedErr, verb); json_object_put(streamRemovedEventJ); - return -5; + return -6; } - afb_event_push(currentSpecificHalData->ctlHalSpecificData->streamUpdates, streamRemovedEventJ); + afb_event_push(currentHalData->internalHalData->streamUpdates, streamRemovedEventJ); return 0; }
\ No newline at end of file |