2 * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "mv_surveillance.h"
19 #include "mv_surveillance_private.h"
20 #include "mv_private.h"
22 #ifdef MEDIA_VISION_SURVEILLANCE_LICENSE_PORT
24 /* Include headers of licensed surveillance module here. */
25 #include "mv_surveillance_lic.h"
29 /* Include headers of open surveillance module here. */
30 #include "mv_surveillance_open.h"
32 #endif /* MEDIA_VISION_SURVEILLANCE_LICENSE_PORT */
35 * @file mv_surveillance.c
36 * @brief This file contains the porting layer for Media Vision surveillance module.
39 static size_t __mv_surveillance_id_counter = 0;
41 int mv_surveillance_event_trigger_create(
42 const char *event_type,
43 mv_surveillance_event_trigger_h * trigger)
45 MEDIA_VISION_SUPPORT_CHECK(__mv_face_check_system_info_feature_supported());
46 MEDIA_VISION_SUPPORT_CHECK(__mv_image_check_system_info_feature_supported());
47 MEDIA_VISION_NULL_ARG_CHECK(event_type);
48 MEDIA_VISION_NULL_ARG_CHECK(trigger);
49 MEDIA_VISION_FUNCTION_ENTER();
51 mv_surveillance_event_trigger_s *handle =
52 (mv_surveillance_event_trigger_s *) malloc(
53 sizeof(mv_surveillance_event_trigger_s));
55 LOGE("[%s] malloc fail", __func__);
56 return MEDIA_VISION_ERROR_OUT_OF_MEMORY;
59 memset(handle, 0, sizeof(mv_surveillance_event_trigger_s));
62 handle->trigger_id = ++__mv_surveillance_id_counter;
63 handle->event_type = strndup(event_type, 255);
64 handle->number_of_roi_points = 0;
67 *trigger = (mv_surveillance_event_trigger_h) handle;
69 MEDIA_VISION_FUNCTION_LEAVE();
70 return MEDIA_VISION_ERROR_NONE;
73 int mv_surveillance_event_trigger_destroy(
74 mv_surveillance_event_trigger_h trigger)
76 MEDIA_VISION_SUPPORT_CHECK(__mv_face_check_system_info_feature_supported());
77 MEDIA_VISION_SUPPORT_CHECK(__mv_image_check_system_info_feature_supported());
78 MEDIA_VISION_NULL_ARG_CHECK(trigger);
79 MEDIA_VISION_FUNCTION_ENTER();
81 mv_surveillance_event_trigger_s *handle =
82 (mv_surveillance_event_trigger_s *) trigger;
83 free(handle->event_type);
85 free((mv_surveillance_event_trigger_s *) trigger);
87 MEDIA_VISION_FUNCTION_LEAVE();
88 return MEDIA_VISION_ERROR_NONE;
91 int mv_surveillance_get_event_trigger_type(
92 mv_surveillance_event_trigger_h trigger,
95 MEDIA_VISION_SUPPORT_CHECK(__mv_face_check_system_info_feature_supported());
96 MEDIA_VISION_SUPPORT_CHECK(__mv_image_check_system_info_feature_supported());
97 MEDIA_VISION_INSTANCE_CHECK(trigger);
98 MEDIA_VISION_NULL_ARG_CHECK(event_type);
99 MEDIA_VISION_FUNCTION_ENTER();
101 mv_surveillance_event_trigger_s *handle =
102 (mv_surveillance_event_trigger_s *)trigger;
103 *event_type = strndup(handle->event_type, 255);
105 MEDIA_VISION_FUNCTION_LEAVE();
106 return MEDIA_VISION_ERROR_NONE;
109 int mv_surveillance_set_event_trigger_roi(
110 mv_surveillance_event_trigger_h trigger,
111 int number_of_points,
114 MEDIA_VISION_SUPPORT_CHECK(__mv_face_check_system_info_feature_supported());
115 MEDIA_VISION_SUPPORT_CHECK(__mv_image_check_system_info_feature_supported());
116 MEDIA_VISION_INSTANCE_CHECK(trigger);
117 MEDIA_VISION_NULL_ARG_CHECK(roi);
118 MEDIA_VISION_FUNCTION_ENTER();
120 mv_surveillance_event_trigger_s *handle =
121 (mv_surveillance_event_trigger_s *)trigger;
128 handle->number_of_roi_points = number_of_points;
129 handle->roi = (mv_point_s*) malloc(sizeof(mv_point_s) * number_of_points);
131 if (NULL == handle->roi) {
132 LOGE("[%s] malloc fail", __func__);
133 return MEDIA_VISION_ERROR_OUT_OF_MEMORY;
137 for (; i < number_of_points; ++i) {
138 handle->roi[i].x = roi[i].x;
139 handle->roi[i].y = roi[i].y;
142 MEDIA_VISION_FUNCTION_LEAVE();
143 return MEDIA_VISION_ERROR_NONE;
146 int mv_surveillance_get_event_trigger_roi(
147 mv_surveillance_event_trigger_h trigger,
148 int *number_of_points,
151 MEDIA_VISION_SUPPORT_CHECK(__mv_face_check_system_info_feature_supported());
152 MEDIA_VISION_SUPPORT_CHECK(__mv_image_check_system_info_feature_supported());
153 MEDIA_VISION_INSTANCE_CHECK(trigger);
154 MEDIA_VISION_NULL_ARG_CHECK(number_of_points);
155 MEDIA_VISION_NULL_ARG_CHECK(roi);
156 MEDIA_VISION_FUNCTION_ENTER();
158 mv_surveillance_event_trigger_s *handle =
159 (mv_surveillance_event_trigger_s *) trigger;
161 *number_of_points = handle->number_of_roi_points;
162 if (0 == *number_of_points) {
163 MEDIA_VISION_FUNCTION_LEAVE();
164 return MEDIA_VISION_ERROR_NONE;
167 *roi = (mv_point_s *) malloc(
168 sizeof(mv_point_s) * handle->number_of_roi_points);
171 for (; i < handle->number_of_roi_points; ++i) {
172 (*roi)[i].x = handle->roi[i].x;
173 (*roi)[i].y = handle->roi[i].y;
176 MEDIA_VISION_FUNCTION_LEAVE();
177 return MEDIA_VISION_ERROR_NONE;
180 int mv_surveillance_subscribe_event_trigger(
181 mv_surveillance_event_trigger_h event_trigger,
183 mv_engine_config_h engine_cfg,
184 mv_surveillance_event_occurred_cb callback,
187 MEDIA_VISION_SUPPORT_CHECK(__mv_face_check_system_info_feature_supported());
188 MEDIA_VISION_SUPPORT_CHECK(__mv_image_check_system_info_feature_supported());
189 MEDIA_VISION_INSTANCE_CHECK(event_trigger);
190 MEDIA_VISION_NULL_ARG_CHECK(callback);
191 MEDIA_VISION_FUNCTION_ENTER();
193 #ifdef MEDIA_VISION_SURVEILLANCE_LICENSE_PORT
195 /* Use licensed surveillance functionality here. */
196 const int ret = mv_surveillance_subscribe_event_trigger_lic(
205 /* Use open surveillance functionality here. */
206 const int ret = mv_surveillance_subscribe_event_trigger_open(
213 #endif /* MEDIA_VISION_SURVEILLANCE_LICENSE_PORT */
215 MEDIA_VISION_FUNCTION_LEAVE();
219 int mv_surveillance_unsubscribe_event_trigger(
220 mv_surveillance_event_trigger_h event_trigger,
223 MEDIA_VISION_SUPPORT_CHECK(__mv_face_check_system_info_feature_supported());
224 MEDIA_VISION_SUPPORT_CHECK(__mv_image_check_system_info_feature_supported());
225 MEDIA_VISION_INSTANCE_CHECK(event_trigger);
226 MEDIA_VISION_FUNCTION_ENTER();
228 #ifdef MEDIA_VISION_SURVEILLANCE_LICENSE_PORT
230 /* Use licensed surveillance functionality here. */
231 const int ret = mv_surveillance_unsubscribe_event_trigger_lic(
237 /* Use open surveillance functionality here. */
238 const int ret = mv_surveillance_unsubscribe_event_trigger_open(
242 #endif /* MEDIA_VISION_SURVEILLANCE_LICENSE_PORT */
244 MEDIA_VISION_FUNCTION_LEAVE();
248 int mv_surveillance_push_source(
252 MEDIA_VISION_SUPPORT_CHECK(__mv_face_check_system_info_feature_supported());
253 MEDIA_VISION_SUPPORT_CHECK(__mv_image_check_system_info_feature_supported());
254 MEDIA_VISION_INSTANCE_CHECK(source);
255 MEDIA_VISION_FUNCTION_ENTER();
257 #ifdef MEDIA_VISION_SURVEILLANCE_LICENSE_PORT
259 /* Use licensed surveillance functionality here. */
260 const int ret = mv_surveillance_push_source_lic(source, video_stream_id);
264 /* Use open surveillance functionality here. */
265 const int ret = mv_surveillance_push_source_open(source, video_stream_id);
267 #endif /* MEDIA_VISION_SURVEILLANCE_LICENSE_PORT */
269 MEDIA_VISION_FUNCTION_LEAVE();
273 int mv_surveillance_foreach_supported_event_type(
274 mv_surveillance_event_type_cb callback,
277 MEDIA_VISION_SUPPORT_CHECK(__mv_face_check_system_info_feature_supported());
278 MEDIA_VISION_SUPPORT_CHECK(__mv_image_check_system_info_feature_supported());
279 MEDIA_VISION_NULL_ARG_CHECK(callback);
280 MEDIA_VISION_FUNCTION_ENTER();
282 #ifdef MEDIA_VISION_SURVEILLANCE_LICENSE_PORT
284 /* Use licensed surveillance functionality here. */
285 const int ret = mv_surveillance_foreach_event_type_lic(
291 /* Use open surveillance functionality here. */
292 const int ret = mv_surveillance_foreach_event_type_open(
296 #endif /* MEDIA_VISION_SURVEILLANCE_LICENSE_PORT */
298 MEDIA_VISION_FUNCTION_LEAVE();
302 int mv_surveillance_foreach_event_result_name(
303 const char *event_type,
304 mv_surveillance_event_result_name_cb callback,
307 MEDIA_VISION_SUPPORT_CHECK(__mv_face_check_system_info_feature_supported());
308 MEDIA_VISION_SUPPORT_CHECK(__mv_image_check_system_info_feature_supported());
309 MEDIA_VISION_NULL_ARG_CHECK(event_type);
310 MEDIA_VISION_NULL_ARG_CHECK(callback);
311 MEDIA_VISION_FUNCTION_ENTER();
313 #ifdef MEDIA_VISION_SURVEILLANCE_LICENSE_PORT
315 /* Use licensed surveillance functionality here. */
316 const int ret = mv_surveillance_foreach_event_result_value_name_lic(
323 /* Use open surveillance functionality here. */
324 const int ret = mv_surveillance_foreach_event_result_value_name_open(
329 #endif /* MEDIA_VISION_SURVEILLANCE_LICENSE_PORT */
331 MEDIA_VISION_FUNCTION_LEAVE();
336 int mv_surveillance_get_result_value(
337 mv_surveillance_result_h result,
338 const char *value_name,
341 MEDIA_VISION_SUPPORT_CHECK(__mv_face_check_system_info_feature_supported());
342 MEDIA_VISION_SUPPORT_CHECK(__mv_image_check_system_info_feature_supported());
343 MEDIA_VISION_INSTANCE_CHECK(result);
344 MEDIA_VISION_NULL_ARG_CHECK(value_name);
345 MEDIA_VISION_NULL_ARG_CHECK(value);
346 MEDIA_VISION_FUNCTION_ENTER();
348 #ifdef MEDIA_VISION_SURVEILLANCE_LICENSE_PORT
350 /* Use licensed surveillance functionality here. */
351 const int ret = mv_surveillance_get_result_value_lic(
358 /* Use open surveillance functionality here. */
359 const int ret = mv_surveillance_get_result_value_open(
364 #endif /* MEDIA_VISION_SURVEILLANCE_LICENSE_PORT */
366 MEDIA_VISION_FUNCTION_LEAVE();