aboutsummaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c321
-rw-r--r--4a-hal-utilities/4a-hal-utilities-hal-streams-handler.h51
-rw-r--r--4a-hal-utilities/CMakeLists.txt1
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c191
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-cb.h12
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.c55
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.h8
7 files changed, 388 insertions, 251 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
new file mode 100644
index 0000000..4dbe35c
--- /dev/null
+++ b/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c
@@ -0,0 +1,321 @@
+/*
+ * Copyright (C) 2019 "IoT.bzh"
+ * Author Jonathan Aillet <jonathan.aillet@iot.bzh>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define _GNU_SOURCE
+
+#include <stdio.h>
+#include <json-c/json.h>
+
+#include <afb-definitions.h>
+
+#include <ctl-config.h>
+
+#include "4a-hal-utilities-data.h"
+#include "4a-hal-utilities-appfw-responses-handler.h"
+#include "4a-hal-utilities-hal-streams-handler.h"
+
+/*******************************************************************************
+ * Actions to be call when a stream verb is called *
+ ******************************************************************************/
+
+void HalUtlActionOnMixer(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 HalUtlActionOnStream(AFB_ReqT request)
+{
+ HalUtlActionOnMixer(request, ACTION_ON_MIXER_STREAM);
+}
+
+void HalUtlActionOnPlayback(AFB_ReqT request)
+{
+ HalUtlActionOnMixer(request, ACTION_ON_MIXER_PLAYBACK);
+}
+
+void HalUtlActionOnCapture(AFB_ReqT request)
+{
+ HalUtlActionOnMixer(request, ACTION_ON_MIXER_CAPTURE);
+}
+
+void HalUtlActionOnAllStream(AFB_ReqT request)
+{
+ HalUtlActionOnMixer(request, ACTION_ON_MIXER_ALL_STREAM);
+}
+
+/*******************************************************************************
+ * Add stream data and verb function *
+ ******************************************************************************/
+
+struct CtlHalMixerData *HalUtlAddStreamDataAndCreateStreamVerb(AFB_ApiT apiHandle,
+ char *verb,
+ char *verbToCall,
+ char *streamCardId)
+{
+ CtlConfigT *ctrlConfig;
+
+ struct SpecificHalData *currentSpecificHalData;
+ struct CtlHalMixerData *createdStreamData;
+
+ if(! apiHandle || ! verb || ! verbToCall || ! streamCardId)
+ return NULL;
+
+ if((! (ctrlConfig = (CtlConfigT *) AFB_ApiGetUserData(apiHandle))) ||
+ (! (currentSpecificHalData = (struct SpecificHalData *) getExternalData(ctrlConfig))) ||
+ (! currentSpecificHalData->ctlHalSpecificData))
+ return NULL;
+
+ if(! (createdStreamData = HalUtlAddMixerDataToMixerDataList(&currentSpecificHalData->ctlHalSpecificData->ctlHalStreamsData)))
+ return NULL;
+
+ createdStreamData->verb = strdup(verb);
+ createdStreamData->verbToCall = strdup(verbToCall);
+ createdStreamData->streamCardId = strdup(streamCardId);
+
+ if((! createdStreamData->verb) ||
+ (! createdStreamData->verbToCall) ||
+ (! createdStreamData->streamCardId)) {
+ HalUtlRemoveSelectedMixerData(&currentSpecificHalData->ctlHalSpecificData->ctlHalStreamsData, createdStreamData);
+ return NULL;
+ }
+
+ createdStreamData->event = AFB_EventMake(apiHandle, createdStreamData->verb);
+ if(! AFB_EventIsValid(createdStreamData->event)) {
+ HalUtlRemoveSelectedMixerData(&currentSpecificHalData->ctlHalSpecificData->ctlHalStreamsData, createdStreamData);
+ return NULL;
+ }
+
+ if(AFB_ApiAddVerb(apiHandle,
+ createdStreamData->verb,
+ "Stream action transferred to mixer",
+ HalUtlActionOnStream,
+ (void *) createdStreamData,
+ NULL,
+ 0,
+ 0)) {
+ AFB_ApiError(apiHandle,"Error while creating verb for stream : '%s'", createdStreamData->verb);
+ HalUtlRemoveSelectedMixerData(&currentSpecificHalData->ctlHalSpecificData->ctlHalStreamsData, createdStreamData);
+ return NULL;
+ }
+
+ return createdStreamData;
+}
+
+int8_t HalUtlRemoveStreamDataAndDeleteStreamVerb(AFB_ApiT apiHandle,
+ char *verb,
+ char *verbToCall,
+ char *streamCardId)
+{
+ int8_t returnedErr = 0;
+
+ CtlConfigT *ctrlConfig;
+
+ struct SpecificHalData *currentSpecificHalData;
+ struct CtlHalMixerData *toRemoveStreamData;
+
+ if(! apiHandle || ! verb || ! verbToCall || ! streamCardId)
+ return -1;
+
+ if((! (ctrlConfig = (CtlConfigT *) AFB_ApiGetUserData(apiHandle))) ||
+ (! (currentSpecificHalData = (struct SpecificHalData *) getExternalData(ctrlConfig))) ||
+ (! currentSpecificHalData->ctlHalSpecificData))
+ return -2;
+
+ if(! (toRemoveStreamData = HalUtlSearchMixerDataByProperties(&currentSpecificHalData->ctlHalSpecificData->ctlHalStreamsData,
+ verb,
+ verbToCall,
+ streamCardId)))
+ return -3;
+
+ if(afb_api_del_verb(apiHandle, verb, NULL)) {
+ AFB_ApiError(apiHandle,"Error while deleting verb for stream : '%s'", verb);
+ return -4;
+ }
+
+ if((returnedErr = HalUtlRemoveSelectedMixerData(&currentSpecificHalData->ctlHalSpecificData->ctlHalStreamsData, toRemoveStreamData))) {
+ AFB_ApiError(apiHandle,"Error %i while removing data for stream : '%s'", returnedErr, verb);
+ return -5;
+ }
+
+ return 0;
+} \ No newline at end of file
diff --git a/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.h b/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.h
new file mode 100644
index 0000000..b77006d
--- /dev/null
+++ b/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.h
@@ -0,0 +1,51 @@
+/*
+* Copyright (C) 2019 "IoT.bzh"
+* Author Jonathan Aillet <jonathan.aillet@iot.bzh>
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef _HAL_UTILITIES_HAL_STREAMS_CREATION_INCLUDE_
+#define _HAL_UTILITIES_HAL_STREAMS_CREATION_INCLUDE_
+
+#include <stdio.h>
+
+#include <afb-definitions.h>
+
+#include <ctl-config.h>
+
+// Enum for the type of action on mixer
+enum ActionOnMixerType {
+ ACTION_ON_MIXER_STREAM = 1,
+ ACTION_ON_MIXER_PLAYBACK = 2,
+ ACTION_ON_MIXER_CAPTURE = 3,
+ ACTION_ON_MIXER_ALL_STREAM = 4
+};
+
+// Actions to be call when a stream verb is called
+void HalUtlActionOnStream(AFB_ReqT request);
+void HalUtlActionOnPlayback(AFB_ReqT request);
+void HalUtlActionOnCapture(AFB_ReqT request);
+void HalUtlActionOnAllStream(AFB_ReqT request);
+
+// Add/Remove stream data and verb functions
+struct CtlHalMixerData *HalUtlAddStreamDataAndCreateStreamVerb(AFB_ApiT apiHandle,
+ char *verb,
+ char *verbToCall,
+ char *streamCardId);
+int8_t HalUtlRemoveStreamDataAndDeleteStreamVerb(AFB_ApiT apiHandle,
+ char *verb,
+ char *verbToCall,
+ char *streamCardId);
+
+#endif /* _HAL_UTILITIES_HAL_STREAMS_CREATION_INCLUDE_ */ \ No newline at end of file
diff --git a/4a-hal-utilities/CMakeLists.txt b/4a-hal-utilities/CMakeLists.txt
index a45cb2c..f5c8eca 100644
--- a/4a-hal-utilities/CMakeLists.txt
+++ b/4a-hal-utilities/CMakeLists.txt
@@ -25,6 +25,7 @@ PROJECT_TARGET_ADD(4a-hal-utilities)
4a-hal-utilities-alsa-data.c
4a-hal-utilities-appfw-responses-handler.c
4a-hal-utilities-data.c
+ 4a-hal-utilities-hal-streams-handler.c
4a-hal-utilities-verbs-loader.c)
# Library dependencies (include updates automatically)
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;
diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.h b/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.h
index d9b4411..a90c19a 100644
--- a/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.h
+++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.h
@@ -24,14 +24,6 @@
#include <ctl-config.h>
-// Enum for the type of action on mixer
-enum ActionOnMixerType {
- ACTION_ON_MIXER_STREAM = 1,
- ACTION_ON_MIXER_PLAYBACK = 2,
- ACTION_ON_MIXER_CAPTURE = 3,
- ACTION_ON_MIXER_ALL_STREAM = 4
-};
-
// Enum for the type of subscription/subscription
enum SubscribeUnsubscribeType {
SUBSCRIPTION = 1,
@@ -46,10 +38,6 @@ int HalCtlsHalMixerConfig(AFB_ApiT apiHandle, CtlSectionT *section, json_object
int HalCtlsHalMapConfig(AFB_ApiT apiHandle, CtlSectionT *section, json_object *StreamControlsJ);
// HAL controllers verbs functions
-void HalCtlsActionOnStream(AFB_ReqT request);
-void HalCtlsActionOnPlayback(AFB_ReqT request);
-void HalCtlsActionOnCapture(AFB_ReqT request);
-void HalCtlsActionOnAllStream(AFB_ReqT request);
void HalCtlsInfo(AFB_ReqT request);
void HalCtlsSubscribe(AFB_ReqT request);
void HalCtlsUnsubscribe(AFB_ReqT request);
diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.c b/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.c
index 72f62dd..da05498 100644
--- a/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.c
+++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.c
@@ -26,6 +26,8 @@
#include "4a-hal-utilities-appfw-responses-handler.h"
#include "4a-hal-utilities-data.h"
+
+#include "4a-hal-utilities-hal-streams-handler.h"
#include "4a-hal-utilities-verbs-loader.h"
#include "../4a-hal-manager/4a-hal-manager.h"
@@ -91,47 +93,14 @@ int HalCtlsHandleMixerData(AFB_ApiT apiHandle, struct CtlHalMixerData **firstMix
if(verbStart == size)
verbStart = 0;
- if(! (currentMixerData = HalUtlAddMixerDataToMixerDataList(firstMixerData))) {
- AFB_ApiError(apiHandle, "Error while adding a stream to stream list");
- err += (int) MIXER_ERROR_STREAM_NOT_ADDED_TO_STREAM_LIST;
- break;
- }
-
- currentMixerData->verb = strdup(&currentDataVerbName[verbStart]);
- currentMixerData->verbToCall = strdup(currentDataVerbName);
- currentMixerData->streamCardId = strdup(currentStreamCardId);
-
- if((! currentMixerData->verb) ||
- (! currentMixerData->verbToCall) ||
- (! currentMixerData->streamCardId)) {
- HalUtlRemoveSelectedMixerData(firstMixerData, currentMixerData);
- err += (int) MIXER_ERROR_STREAM_ALLOCATION_FAILED;
- break;
- }
-
- if(AFB_ApiAddVerb(apiHandle,
- currentMixerData->verb,
- "Stream action transferred to mixer",
- HalCtlsActionOnStream,
- (void *) currentMixerData,
- NULL,
- 0,
- 0)) {
+ if(! HalUtlAddStreamDataAndCreateStreamVerb(apiHandle,
+ &currentDataVerbName[verbStart],
+ currentDataVerbName,
+ currentStreamCardId)) {
AFB_ApiError(apiHandle,
- "Error while creating verbs for stream : '%s'",
- currentMixerData->verb);
- HalUtlRemoveSelectedMixerData(firstMixerData, currentMixerData);
- err += (int) MIXER_ERROR_STREAM_VERB_NOT_CREATED;
- break;
- }
-
- currentMixerData->event = AFB_EventMake(apiHandle, currentMixerData->verb);
- if(! AFB_EventIsValid(currentMixerData->event)) {
- AFB_ApiError(apiHandle,
- "Error while creating event for stream %s",
- currentMixerData->verb);
- HalUtlRemoveSelectedMixerData(firstMixerData, currentMixerData);
- err += (int) MIXER_ERROR_STREAM_EVENT_NOT_CREATED;
+ "Error while adding stream '%s'",
+ currentDataVerbName);
+ err += (int) MIXER_ERROR_STREAM_NOT_ADDED;
}
break;
@@ -160,7 +129,7 @@ int HalCtlsHandleMixerData(AFB_ApiT apiHandle, struct CtlHalMixerData **firstMix
if(AFB_ApiAddVerb(apiHandle,
HAL_PLAYBACK_ID,
"Playback action transferred to mixer",
- HalCtlsActionOnPlayback,
+ HalUtlActionOnPlayback,
(void *) *firstMixerData,
NULL,
0,
@@ -174,7 +143,7 @@ int HalCtlsHandleMixerData(AFB_ApiT apiHandle, struct CtlHalMixerData **firstMix
if(AFB_ApiAddVerb(apiHandle,
HAL_CAPTURE_ID,
"Capture action transferred to mixer",
- HalCtlsActionOnCapture,
+ HalUtlActionOnCapture,
(void *) *firstMixerData,
NULL,
0,
@@ -218,7 +187,7 @@ int HalCtlsHandleMixerAttachResponse(AFB_ApiT apiHandle, struct CtlHalSpecificDa
else if(AFB_ApiAddVerb(apiHandle,
HAL_ALL_STREAMS_VERB,
"Send a stream action on all streams",
- HalCtlsActionOnAllStream,
+ HalUtlActionOnAllStream,
(void *) currentHalSpecificData->ctlHalStreamsData,
NULL,
0,
diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.h b/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.h
index 7856bb7..db42001 100644
--- a/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.h
+++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.h
@@ -22,7 +22,7 @@
#include <wrap-json.h>
-#include "afb-helpers-utils.h"
+#include <afb-helpers-utils.h>
#include "4a-hal-utilities-data.h"
@@ -52,10 +52,8 @@ enum MixerStatus {
MIXER_ERROR_ALL_STREAMS_VERB_NOT_CREATED =-6,
MIXER_ERROR_DATA_NAME_UNAVAILABLE=-10,
MIXER_ERROR_DATA_CARDID_UNAVAILABLE=-100,
- MIXER_ERROR_STREAM_NOT_ADDED_TO_STREAM_LIST =-1000,
- MIXER_ERROR_STREAM_ALLOCATION_FAILED =-10000,
- MIXER_ERROR_STREAM_EVENT_NOT_CREATED =-100000,
- MIXER_ERROR_STREAM_VERB_NOT_CREATED =-1000000
+ MIXER_ERROR_STREAM_NOT_ADDED =-1000,
+ MIXER_ERROR_STREAM_ALLOCATION_FAILED =-10000
};
// HAL controllers handle mixer calls functions