vision : add event handler of MMI_VISION_EVENT_DROP for following provider mode change 41/277141/1
authordyamy-lee <dyamy.lee@samsung.com>
Mon, 25 Oct 2021 02:35:15 +0000 (11:35 +0900)
committerdyamy-lee <dyamy.lee@samsung.com>
Fri, 1 Jul 2022 05:49:44 +0000 (14:49 +0900)
Change-Id: I503b577e4f91bf8f5c447081938a2188951b690e

src/modules/modality_vision/vision.c

index af98742b3a2e2b35b68c7aa31bf84ca04b635b01..622e76077ea5d64e3b742c292daf6d0a924b7c65 100644 (file)
@@ -33,6 +33,7 @@
 
 #include "image_helper.h"
 #include "mv_video_helper.h"
+#include "mmi-vision-provider.h"
 
 #define DEFAULT_VIDEO_PATH "/usr/share/mmi-provider/test_video_2.mp4"
 #define DEFAULT_IMAGE_PATH "/usr/share/mmi-provider/sample_no.jpg"
@@ -85,6 +86,7 @@ mv_engine_config_h _engine_cfg = NULL;
 mv_inference_h _infer = NULL;
 static Ecore_Event_Handler *_event_handlers;
 static Ecore_Event_Handler *_exit_event_handlers;
+static Ecore_Event_Handler *_drop_event_handlers;
 static bool _is_destroyed;
 
 void _send_vision_event_cb(void *data)
@@ -116,6 +118,11 @@ void _image_classified_cb(mv_source_h source, const int number_of_classes,
        }
        LOGI("Max Confidence idx = %d, It's result is %s, type(state) = %d\n", max_confidence_idx, names[max_confidence_idx], indices[max_confidence_idx]);
 
+       if(_provider_mode != MODALITY_PROVIDER_MODE_PROPAGATE_EVENT)
+       {
+               LOGD("No Propagate Event\n");
+               return;
+       }
        mmi_provider_event_vision *ev = calloc(1, sizeof(mmi_provider_event_vision));
        if(!ev)
        {
@@ -238,6 +245,7 @@ void _vision_finish_cb(void *user_data)
 
        if(_is_destroyed)
        {
+               LOGD("callback vision finish, it is already destroyed");
                return;
        }
 
@@ -262,7 +270,9 @@ void _vision_finish_cb(void *user_data)
        LOGD("end of destroy");
 
        ecore_event_handler_del(_exit_event_handlers);
+       ecore_event_handler_del(_drop_event_handlers);
        _exit_event_handlers = NULL;
+       _drop_event_handlers = NULL;
 
        //Todo. for test
        ecore_event_add(MMI_VISION_EVENT_FINISH, NULL, NULL, NULL);
@@ -417,6 +427,7 @@ int infer_task_with_video(const char *path_to_video, mv_inference_h infer, int t
        }
 
        _exit_event_handlers = ecore_event_handler_prepend(ECORE_EVENT_SIGNAL_EXIT, _vision_exit_cb, reader);
+       _drop_event_handlers = ecore_event_handler_add(MMI_VISION_EVENT_DROP, _vision_exit_cb, reader);
 
        err = mv_video_reader_start(reader);
        if (MEDIA_VISION_ERROR_NONE != err) {