summaryrefslogtreecommitdiffstats
path: root/lib/4a-hal-utilities
diff options
context:
space:
mode:
Diffstat (limited to 'lib/4a-hal-utilities')
-rw-r--r--lib/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c108
-rw-r--r--lib/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.h1
2 files changed, 87 insertions, 22 deletions
diff --git a/lib/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c b/lib/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c
index 806387a..9e03f33 100644
--- a/lib/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c
+++ b/lib/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c
@@ -291,14 +291,66 @@ struct InternalHalMixerData *HalUtlAddStreamDataAndCreateStreamVerb(afb_api_t ap
return createdStreamData;
}
+int HalUtlRemoveStreamDataAndDeleteStreamVerbUsingMixerData(afb_api_t apiHandle,
+ struct InternalHalMixerData *toRemoveStreamData)
+{
+ int returnedErr, wrapRet;
+
+ json_object *streamRemovedEventJ;
+
+ CtlConfigT *ctrlConfig;
+
+ struct HalData *currentHalData;
+
+ if(! apiHandle || ! toRemoveStreamData)
+ return -1;
+
+ ctrlConfig = (CtlConfigT *) afb_api_get_userdata(apiHandle);
+ if(! ctrlConfig)
+ return -2;
+
+ currentHalData = (struct HalData *) getExternalData(ctrlConfig);
+ if((! currentHalData) ||
+ (! currentHalData->internalHalData) ||
+ (! currentHalData->internalHalData->streamsData) ||
+ (! currentHalData->internalHalData->streamUpdates))
+ return -3;
+
+ if(afb_api_del_verb(apiHandle, toRemoveStreamData->verb, NULL)) {
+ AFB_API_ERROR(apiHandle,"Error while deleting verb for stream : '%s'", toRemoveStreamData->verb);
+ return -4;
+ }
+
+ wrapRet = wrap_json_pack(&streamRemovedEventJ,
+ "{s:s, s:s, s:s}",
+ "action", "removed",
+ "name", toRemoveStreamData->verb,
+ "cardId", toRemoveStreamData->streamCardId);
+ if(wrapRet) {
+ AFB_API_ERROR(apiHandle,"Didn't succeed to allocate removed stream event json object");
+ return -5;
+ }
+
+ returnedErr = HalUtlRemoveSelectedMixerData(&currentHalData->internalHalData->streamsData, toRemoveStreamData);
+ if(returnedErr) {
+ AFB_API_ERROR(apiHandle,
+ "Error %i while removing data for stream",
+ returnedErr);
+ json_object_put(streamRemovedEventJ);
+ return -6;
+ }
+
+ afb_event_push(currentHalData->internalHalData->streamUpdates, streamRemovedEventJ);
+
+ return 0;
+}
+
int HalUtlRemoveStreamDataAndDeleteStreamVerb(afb_api_t apiHandle,
char *verb,
char *verbToCall,
char *streamCardId)
{
- int returnedErr = 0, wrapRet;
-
- json_object *streamRemovedEventJ;
+ int returnedErr;
CtlConfigT *ctrlConfig;
@@ -324,30 +376,42 @@ int HalUtlRemoveStreamDataAndDeleteStreamVerb(afb_api_t apiHandle,
if(! toRemoveStreamData)
return -4;
- if(afb_api_del_verb(apiHandle, verb, NULL)) {
- AFB_API_ERROR(apiHandle,"Error while deleting verb for stream : '%s'", verb);
- json_object_put(streamRemovedEventJ);
+ returnedErr = HalUtlRemoveStreamDataAndDeleteStreamVerbUsingMixerData(apiHandle,
+ toRemoveStreamData);
+ if(returnedErr) {
+ AFB_API_ERROR(apiHandle,
+ "Error %i while removing verb and data for stream : '%s'",
+ returnedErr,
+ verb);
return -5;
}
- 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 -6;
- }
+ return 0;
+}
- wrapRet = wrap_json_pack(&streamRemovedEventJ,
- "{s:s, s:s, s:s}",
- "action", "removed",
- "name", toRemoveStreamData->verb,
- "cardId", toRemoveStreamData->streamCardId);
- if(wrapRet) {
- AFB_API_ERROR(apiHandle,"Didn't succeed to allocate removed stream event json object");
- return -7;
- }
+int HalUtlRemoveAllStreamsDataAndDeleteAllStreamsVerb(afb_api_t apiHandle)
+{
+ CtlConfigT *ctrlConfig;
- afb_event_push(currentHalData->internalHalData->streamUpdates, streamRemovedEventJ);
+ struct HalData *currentHalData;
+
+ if(! apiHandle)
+ return -1;
+
+ ctrlConfig = (CtlConfigT *) afb_api_get_userdata(apiHandle);
+ if(! ctrlConfig)
+ return -2;
+
+ currentHalData = (struct HalData *) getExternalData(ctrlConfig);
+ if((! currentHalData) ||
+ (! currentHalData->internalHalData))
+ return -3;
+
+ while(currentHalData->internalHalData->streamsData) {
+ if(HalUtlRemoveStreamDataAndDeleteStreamVerbUsingMixerData(apiHandle,
+ currentHalData->internalHalData->streamsData))
+ return -4;
+ }
return 0;
} \ No newline at end of file
diff --git a/lib/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.h b/lib/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.h
index e6f0d99..3345da3 100644
--- a/lib/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.h
+++ b/lib/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.h
@@ -43,5 +43,6 @@ int HalUtlRemoveStreamDataAndDeleteStreamVerb(afb_api_t apiHandle,
char *verb,
char *verbToCall,
char *streamCardId);
+int HalUtlRemoveAllStreamsDataAndDeleteAllStreamsVerb(afb_api_t apiHandle);
#endif /* _HAL_UTILITIES_HAL_STREAMS_CREATION_INCLUDE_ */ \ No newline at end of file