summaryrefslogtreecommitdiffstats
path: root/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c
diff options
context:
space:
mode:
authorJonathan Aillet <jonathan.aillet@iot.bzh>2019-04-18 12:40:25 +0200
committerJonathan Aillet <jonathan.aillet@iot.bzh>2019-05-24 12:05:52 +0200
commit68138a3ec7a78ad7304d291ff92d8e5292847c4e (patch)
tree9157134d50a749c838afdf93a49c4ce17a018347 /4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c
parent196e723e79a1f5eae41cf4a8b1450df0679a4af8 (diff)
Clarify internals hal functions and files names
The purpose of this commit is to have of a more standard way to name files and functions used to generate/handle hal api (generated from hal json configuration file). It occurred to me that 'hal-controller' was not a good name because it is harder for people who don't know about the app-controller to understanded what is the purpose of these files/functions. It was renamed to 'internal-hal' because it's about hal that are all handle/load by hal-manager in opposition of external-hal that are independant binding/binder that can register themselves to hal-manager. BUG-AGL: SPEC-2329 Change-Id: I11b7efe64ec474b004a2a15ed8969b9db95d428f Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
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.c79
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(&currentSpecificHalData->ctlHalSpecificData->ctlHalStreamsData)))
+ currentHalData = (struct HalData *) getExternalData(ctrlConfig);
+ if(! currentHalData ||
+ ! currentHalData->internalHalData)
+ return NULL;
+
+ createdStreamData = HalUtlAddMixerDataToMixerDataList(&currentHalData->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(&currentSpecificHalData->ctlHalSpecificData->ctlHalStreamsData, createdStreamData);
+ HalUtlRemoveSelectedMixerData(&currentHalData->internalHalData->streamsData, createdStreamData);
return NULL;
}
if(! (createdStreamData->event = afb_api_make_event(apiHandle, createdStreamData->verb))) {
- HalUtlRemoveSelectedMixerData(&currentSpecificHalData->ctlHalSpecificData->ctlHalStreamsData, createdStreamData);
+ HalUtlRemoveSelectedMixerData(&currentHalData->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(&currentSpecificHalData->ctlHalSpecificData->ctlHalStreamsData, createdStreamData);
+ HalUtlRemoveSelectedMixerData(&currentHalData->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(&currentSpecificHalData->ctlHalSpecificData->ctlHalStreamsData,
- verb,
- verbToCall,
- streamCardId)))
+ currentHalData = (struct HalData *) getExternalData(ctrlConfig);
+ if(! currentHalData ||
+ ! currentHalData->internalHalData)
return -3;
+ toRemoveStreamData = HalUtlSearchMixerDataByProperties(&currentHalData->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(&currentSpecificHalData->ctlHalSpecificData->ctlHalStreamsData, toRemoveStreamData))) {
+ returnedErr = HalUtlRemoveSelectedMixerData(&currentHalData->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