summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Aillet <jonathan.aillet@iot.bzh>2018-05-26 19:45:45 +0200
committerJonathan Aillet <jonathan.aillet@iot.bzh>2018-10-08 15:51:00 +0200
commitfba2f9632ccc6c9c6f7a810eb6bd4b0bf2e6799f (patch)
tree2eb7bd45f427f3f5690cb206762588d078860749
parentbb13f7376e40119d08bb4c2b6a291f49a3432e59 (diff)
Add 'init-mixer' verb to hal controller
Add creation of 4a-softmixer mixer as hal controller verb called 'init-mixer'. This verb sends json mixer configration to mixer api. Add a forgotten cast. Change-Id: Id4ca6b68caf21c74fb6b17b953d8db2f2db0c04b Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c3
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c59
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-cb.h3
3 files changed, 64 insertions, 1 deletions
diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c b/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c
index 0b6a919..c215f50 100644
--- a/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c
+++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c
@@ -59,6 +59,7 @@ static struct HalUtlApiVerb CtlHalDynApiStaticVerbs[] =
{
/* VERB'S NAME FUNCTION TO CALL SHORT DESCRIPTION */
{ .verb = "list", .callback = HalCtlsListVerbs, .info = "List available verbs for this api"},
+ { .verb = "init-mixer", .callback = HalCtlsInitMixer, .info = "Init Hal with 4a-softmixer"},
{ .verb = NULL } // Marker for end of the array
};
@@ -83,7 +84,7 @@ static int HalCtlsInitOneApi(afb_dynapi *apiHandle)
if(! ctrlConfig)
return -2;
- currentCtlHalData = ctrlConfig->external;
+ currentCtlHalData = (struct SpecificHalData *) ctrlConfig->external;
if(! currentCtlHalData)
return -3;
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 c05059d..d74abf0 100644
--- a/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c
+++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c
@@ -130,4 +130,63 @@ void HalCtlsListVerbs(afb_request *request)
AFB_REQUEST_WARNING(request, "JAI :%s not implemented yet", __func__);
afb_request_success(request, json_object_new_boolean(false), NULL);
+}
+
+void HalCtlsInitMixer(afb_request *request)
+{
+ char *apiToCall;
+
+ afb_dynapi *apiHandle;
+ CtlConfigT *ctrlConfig;
+
+ struct SpecificHalData *currentCtlHalData;
+
+ json_object *returnJ, *toReturnJ;
+
+ apiHandle = (afb_dynapi *) afb_request_get_dynapi(request);
+ if(! apiHandle) {
+ afb_request_fail(request, "api_handle", "Can't get hal manager api handle");
+ return;
+ }
+
+ ctrlConfig = (CtlConfigT *) afb_dynapi_get_userdata(apiHandle);
+ if(! ctrlConfig) {
+ afb_request_fail(request, "hal_controller_config", "Can't get current hal controller config");
+ return;
+ }
+
+ currentCtlHalData = ctrlConfig->external;
+ if(! currentCtlHalData) {
+ afb_request_fail(request, "hal_controller_data", "Can't get current hal controller data");
+ return;
+ }
+
+ apiToCall = currentCtlHalData->ctlHalSpecificData->mixerApiName;
+ if(! apiToCall) {
+ afb_request_fail(request, "mixer_api", "Can't get mixer api");
+ return;
+ }
+
+ // TODO JAI: test hal status (card is detected)
+
+ if(afb_dynapi_call_sync(apiHandle, apiToCall, "mixer_new", json_object_get(currentCtlHalData->ctlHalSpecificData->halMixerJ), &returnJ)) {
+ afb_request_fail_f(request,
+ "mixer_new_call",
+ "Seems that mix_new call to api %s didn't end well",
+ apiToCall);
+ }
+ else if(json_object_object_get_ex(returnJ, "response", &toReturnJ)) {
+ // TODO JAI : get streams cardId from mixer response
+
+ afb_request_success_f(request,
+ toReturnJ,
+ "Seems that mix_new call to api %s succeed",
+ apiToCall);
+ }
+ else {
+ afb_request_fail_f(request,
+ "invalid_response",
+ "Seems that mix_new call to api %s succeed, but response is not valid",
+ apiToCall);
+ }
} \ No newline at end of file
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 765001e..472b643 100644
--- a/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.h
+++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.h
@@ -25,11 +25,14 @@
#include <ctl-config.h>
+#define ACTION_API_NAME "4a-softmixer"
+
// HAL controllers sections parsing functions
int HalCtlsHalMixerConfig(afb_dynapi *apiHandle, CtlSectionT *section, json_object *MixerJ);
// HAL controllers verbs functions
void HalCtlsActionOnStream(afb_request *request);
void HalCtlsListVerbs(afb_request *request);
+void HalCtlsInitMixer(afb_request *request);
#endif /* _HALMGR_CB_INCLUDE_ */ \ No newline at end of file