cbca1865dfd588747d7badbb992b0ea3ba299c33
[platform/core/multimedia/libmm-camcorder.git] / src / include / mm_camcorder_internal.h
1 /*
2  * libmm-camcorder
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Jeongmo Yang <jm80.yang@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21
22 #ifndef __MM_CAMCORDER_INTERNAL_H__
23 #define __MM_CAMCORDER_INTERNAL_H__
24
25 /*=======================================================================================
26 | INCLUDE FILES                                                                         |
27 ========================================================================================*/
28 #include <malloc.h>
29 #include <string.h>
30 #include <unistd.h>
31 #include <semaphore.h>
32
33 #include <mm_types.h>
34 #include <mm_attrs.h>
35 #include <mm_message.h>
36 #include <vconf.h>
37 #include <gst/video/video-format.h>
38 #include <ttrace.h>
39 #include <errno.h>
40 #include <restriction.h> /* device policy manager */
41 #include <dlog.h>
42
43 #include "mm_camcorder.h"
44
45 #ifdef _MMCAMCORDER_MM_RM_SUPPORT
46 #include <mm_resource_manager.h>
47 #endif /* _MMCAMCORDER_MM_RM_SUPPORT */
48
49 /* camcorder sub module */
50 #include "mm_camcorder_attribute.h"
51 #include "mm_camcorder_platform.h"
52 #include "mm_camcorder_stillshot.h"
53 #include "mm_camcorder_videorec.h"
54 #include "mm_camcorder_audiorec.h"
55 #include "mm_camcorder_gstcommon.h"
56 #include "mm_camcorder_exifinfo.h"
57 #include "mm_camcorder_util.h"
58 #include "mm_camcorder_configure.h"
59 #include "mm_camcorder_sound.h"
60
61 #ifdef _MMCAMCORDER_RM_SUPPORT
62 /* rm (resource manager)*/
63 #include <rm_api.h>
64 #endif /* _MMCAMCORDER_RM_SUPPORT */
65
66 #ifdef _MMCAMCORDER_CAMERA_CONF_MGR_SUPPORT
67 #include "camera_conf_mgr.h"
68 #endif /*_MMCAMCORDER_CAMERA_CONF_MGR_SUPPORT */
69
70 #ifdef LOG_TAG
71 #undef LOG_TAG
72 #endif
73 #define LOG_TAG "MM_CAMCORDER"
74
75 #ifdef __cplusplus
76 extern "C" {
77 #endif
78
79 /*=======================================================================================
80 | MACRO DEFINITIONS                                                                     |
81 ========================================================================================*/
82 /**
83  *      Macro for checking validity and debugging
84  */
85 #define mmf_return_if_fail(expr) \
86         if (!(expr)) { \
87                 MMCAM_LOG_ERROR("failed [%s]", #expr); \
88                 return; \
89         }
90
91 /**
92  *      Macro for checking validity and debugging
93  */
94 #define mmf_return_val_if_fail(expr, val) \
95         if (!(expr)) { \
96                 MMCAM_LOG_ERROR("failed [%s]", #expr); \
97                 return (val); \
98         }
99
100
101 #ifndef ARRAY_SIZE
102 /**
103  *      Macro for getting array size
104  */
105 #define ARRAY_SIZE(a) (sizeof((a)) / sizeof((a)[0]))
106 #endif
107
108 /* gstreamer element creation macro */
109 #define _MMCAMCORDER_PIPELINE_MAKE(sub_context, element, eid, name /*char* */, err) \
110 do { \
111         if (element[eid].gst != NULL) { \
112                 MMCAM_LOG_ERROR("The element(Pipeline) is existed. element_id=[%d], name=[%s]", eid, name); \
113                 gst_object_unref(element[eid].gst); \
114         } \
115         element[eid].id = eid; \
116         element[eid].gst = gst_pipeline_new(name); \
117         if (element[eid].gst == NULL) { \
118                 MMCAM_LOG_ERROR("Pipeline creation fail. element_id=[%d], name=[%s]", eid, name); \
119                 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
120                 goto pipeline_creation_error; \
121         } else { \
122                 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
123         } \
124 } while (0)
125
126 #define _MMCAMCORDER_BIN_MAKE(sub_context, element, eid, name /*char* */, err) \
127 do { \
128         if (element[eid].gst != NULL) { \
129                 MMCAM_LOG_ERROR("The element(Bin) is existed. element_id=[%d], name=[%s]", eid, name); \
130                 gst_object_unref(element[eid].gst); \
131         } \
132         element[eid].id = eid; \
133         element[eid].gst = gst_bin_new(name); \
134         if (element[eid].gst == NULL) { \
135                 MMCAM_LOG_ERROR("Bin creation fail. element_id=[%d], name=[%s]\n", eid, name); \
136                 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
137                 goto pipeline_creation_error; \
138         } else { \
139                 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
140         } \
141 } while (0)
142
143 #define _MMCAMCORDER_ELEMENT_MAKE(sub_context, element, eid, name /*char* */, nickname /*char* */, elist, err) \
144 do { \
145         if (element[eid].gst != NULL) { \
146                 MMCAM_LOG_ERROR("The element is existed. element_id=[%d], name=[%s]", eid, name); \
147                 gst_object_unref(element[eid].gst); \
148         } \
149         traceBegin(TTRACE_TAG_CAMERA, "MMCAMCORDER:ELEMENT_MAKE:%s", name); \
150         element[eid].gst = gst_element_factory_make(name, nickname); \
151         traceEnd(TTRACE_TAG_CAMERA); \
152         if (element[eid].gst == NULL) { \
153                 MMCAM_LOG_ERROR("Element creation fail. element_id=[%d], name=[%s]", eid, name); \
154                 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
155                 goto pipeline_creation_error; \
156         } else { \
157                 MMCAM_LOG_INFO("Element creation done. element_id=[%d], name=[%s]", eid, name); \
158                 element[eid].id = eid; \
159                 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
160                 err = MM_ERROR_NONE; \
161         } \
162         elist = g_list_append(elist, &(element[eid])); \
163 } while (0)
164
165 #define _MMCAMCORDER_ELEMENT_MAKE2(sub_context, element, eid, name /*char* */, nickname /*char* */, err) \
166 do { \
167         if (element[eid].gst != NULL) { \
168                 MMCAM_LOG_ERROR("The element is existed. element_id=[%d], name=[%s]", eid, name); \
169                 gst_object_unref(element[eid].gst); \
170         } \
171         element[eid].gst = gst_element_factory_make(name, nickname); \
172         if (element[eid].gst == NULL) { \
173                 MMCAM_LOG_ERROR("Element creation fail. element_id=[%d], name=[%s]", eid, name); \
174                 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
175         } else { \
176                 MMCAM_LOG_INFO("Element creation done. element_id=[%d], name=[%s]", eid, name); \
177                 element[eid].id = eid; \
178                 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
179                 err = MM_ERROR_NONE; \
180         } \
181 } while (0)
182
183 #define _MMCAMCORDER_ELEMENT_MAKE_IGNORE_ERROR(sub_context, element, eid, name /*char* */, nickname /*char* */, elist) \
184 do { \
185         if (element[eid].gst != NULL) { \
186                 MMCAM_LOG_ERROR("The element is existed. element_id=[%d], name=[%s]", eid, name); \
187                 gst_object_unref(element[eid].gst); \
188         } \
189         element[eid].gst = gst_element_factory_make(name, nickname); \
190         if (element[eid].gst == NULL) { \
191                 MMCAM_LOG_ERROR("Element creation fail. element_id=[%d], name=[%s], but keep going...", eid, name); \
192         } else { \
193                 MMCAM_LOG_INFO("Element creation done. element_id=[%d], name=[%s]", eid, name); \
194                 element[eid].id = eid; \
195                 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
196                 elist = g_list_append(elist, &(element[eid])); \
197         } \
198 } while (0)
199
200 #define _MMCAMCORDER_ELEMENT_ADD(sub_context, element, eid, gst_element, elist, err) \
201 do { \
202         if (element[eid].gst != NULL) { \
203                 MMCAM_LOG_ERROR("The element is existed. element_id=[%d]", eid); \
204                 gst_object_unref(element[eid].gst); \
205         } \
206         element[eid].gst = gst_element; \
207         if (element[eid].gst == NULL) { \
208                 MMCAM_LOG_ERROR("Element is NULL. element_id=[%d]", eid); \
209                 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
210                 goto pipeline_creation_error; \
211         } else { \
212                 MMCAM_LOG_INFO("Adding Element is done. element_id=[%d] %p", eid, gst_element); \
213                 element[eid].id = eid; \
214                 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
215                 err = MM_ERROR_NONE; \
216         } \
217         elist = g_list_append(elist, &(element[eid])); \
218 } while (0)
219
220 #define _MMCAMCORDER_ENCODEBIN_ELMGET(sub_context, eid, name /*char* */, err) \
221 do { \
222         if (sub_context->encode_element[eid].gst != NULL) { \
223                 MMCAM_LOG_ERROR("The element is existed. element_id=[%d], name=[%s]", eid, name); \
224                 gst_object_unref(sub_context->encode_element[eid].gst); \
225         } \
226         sub_context->encode_element[eid].id = eid; \
227         g_object_get(G_OBJECT(sub_context->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst), name, &(sub_context->encode_element[eid].gst), NULL); \
228         if (sub_context->encode_element[eid].gst == NULL) { \
229                 MMCAM_LOG_ERROR("Encode Element get fail. element_id=[%d], name=[%s]", eid, name); \
230                 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
231                 goto pipeline_creation_error; \
232         } else{ \
233                 gst_object_unref(sub_context->encode_element[eid].gst); \
234                 g_object_weak_ref(G_OBJECT(sub_context->encode_element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
235         } \
236 } while (0)
237
238 /* GStreamer element remove macro */
239 #define _MMCAMCORDER_ELEMENT_REMOVE(element, eid) \
240         if (element[eid].gst != NULL) { \
241                 gst_object_unref(element[eid].gst); \
242         }
243
244 #define _MM_GST_ELEMENT_LINK_MANY       gst_element_link_many
245 #define _MM_GST_ELEMENT_LINK            gst_element_link
246 #define _MM_GST_ELEMENT_LINK_FILTERED   gst_element_link_filtered
247 #define _MM_GST_ELEMENT_UNLINK          gst_element_unlink
248 #define _MM_GST_PAD_LINK                gst_pad_link
249
250 #define _MM_GST_PAD_LINK_UNREF(srcpad, sinkpad, err, if_fail_goto) \
251 do { \
252         GstPadLinkReturn ret = GST_PAD_LINK_OK; \
253         if (srcpad == NULL || sinkpad == NULL) { \
254                 if (srcpad == NULL) { \
255                         MMCAM_LOG_ERROR("srcpad is NULL"); \
256                 } else { \
257                         gst_object_unref(srcpad);\
258                         srcpad = NULL; \
259                 } \
260                 if (sinkpad == NULL) { \
261                         MMCAM_LOG_ERROR("sinkpad is NULL"); \
262                 } else { \
263                         gst_object_unref(sinkpad); \
264                         sinkpad = NULL;\
265                 } \
266                 err = MM_ERROR_CAMCORDER_GST_LINK; \
267                 goto if_fail_goto; \
268         } \
269         ret = _MM_GST_PAD_LINK(srcpad, sinkpad); \
270         if (ret != GST_PAD_LINK_OK) { \
271                 GstObject *src_parent = gst_pad_get_parent(srcpad); \
272                 GstObject *sink_parent = gst_pad_get_parent(sinkpad); \
273                 char *src_name = NULL; \
274                 char *sink_name = NULL; \
275                 g_object_get((GObject *)src_parent, "name", &src_name, NULL); \
276                 g_object_get((GObject *)sink_parent, "name", &sink_name, NULL); \
277                 MMCAM_LOG_ERROR("src[%s] - sink[%s] link failed", src_name, sink_name); \
278                 gst_object_unref(src_parent); src_parent = NULL; \
279                 gst_object_unref(sink_parent); sink_parent = NULL; \
280                 if (src_name) { \
281                         free(src_name); src_name = NULL; \
282                 } \
283                 if (sink_name) { \
284                         free(sink_name); sink_name = NULL; \
285                 } \
286                 gst_object_unref(srcpad); srcpad = NULL; \
287                 gst_object_unref(sinkpad); sinkpad = NULL; \
288                 err = MM_ERROR_CAMCORDER_GST_LINK; \
289                 goto if_fail_goto;\
290         } \
291         gst_object_unref(srcpad); srcpad = NULL; \
292         gst_object_unref(sinkpad); sinkpad = NULL; \
293 } while (0)
294
295 #define _MM_GST_PAD_UNLINK_UNREF(srcpad, sinkpad) \
296 do { \
297         if (srcpad && sinkpad) { \
298                 gst_pad_unlink(srcpad, sinkpad); \
299         } else { \
300                 MMCAM_LOG_WARNING("some pad(srcpad:%p,sinkpad:%p) is NULL", srcpad, sinkpad); \
301         } \
302         if (srcpad) { \
303                 gst_object_unref(srcpad); srcpad = NULL; \
304         } \
305         if (sinkpad) { \
306                 gst_object_unref(sinkpad); sinkpad = NULL; \
307         } \
308 } while (0)
309
310 #define _MMCAMCORDER_STATE_SET_COUNT            3               /* checking interval */
311 #define _MMCAMCORDER_STATE_CHECK_TOTALTIME      5000000L        /* total waiting time for state change */
312 #define _MMCAMCORDER_STATE_CHECK_INTERVAL       (50*1000)       /* checking interval - 50ms*/
313
314 /**
315  * Default videosink type
316  */
317 #define _MMCAMCORDER_DEFAULT_VIDEOSINK_TYPE     "VideosinkElementOverlay"
318
319 /**
320  * Default recording motion rate
321  */
322 #define _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE   1.0
323
324 /**
325  * Total level count of manual focus */
326 #define _MMFCAMCORDER_FOCUS_TOTAL_LEVEL         8
327
328 /**
329  *      File name length limit
330  */
331 #define _MMCamcorder_FILENAME_LEN       (512)
332
333 /**
334  *      File name for NULL path
335  */
336 #define _MMCamcorder_FILENAME_NULL      "/dev/null"
337
338 /**
339  *      Minimum integer value
340  */
341 #define _MMCAMCORDER_MIN_INT    (INT_MIN)
342
343 /**
344  *      Maximum integer value
345  */
346 #define _MMCAMCORDER_MAX_INT    (INT_MAX)
347
348 /**
349  *      Minimum double value
350  */
351 #define _MMCAMCORDER_MIN_DOUBLE (DBL_MIN)
352
353 /**
354  *      Maximum integer value
355  */
356 #define _MMCAMCORDER_MAX_DOUBLE (DBL_MAX)
357
358 /**
359  *      Audio timestamp margin (msec)
360  */
361 #define _MMCAMCORDER_AUDIO_TIME_MARGIN (300)
362
363 /**
364  *      Functions related with LOCK and WAIT
365  */
366 #define _MMCAMCORDER_CAST_MTSAFE(handle)            (((mmf_camcorder_t*)handle)->mtsafe)
367 #define _MMCAMCORDER_LOCK_FUNC(mutex)               g_mutex_lock(&mutex)
368 #define _MMCAMCORDER_TRYLOCK_FUNC(mutex)            g_mutex_trylock(&mutex)
369 #define _MMCAMCORDER_UNLOCK_FUNC(mutex)             g_mutex_unlock(&mutex)
370
371 #define _MMCAMCORDER_GET_LOCK(handle)               (_MMCAMCORDER_CAST_MTSAFE(handle).lock)
372 #define _MMCAMCORDER_LOCK(handle)                   _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_LOCK(handle))
373 #define _MMCAMCORDER_TRYLOCK(handle)                _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_LOCK(handle))
374 #define _MMCAMCORDER_UNLOCK(handle)                 _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_LOCK(handle))
375
376 #define _MMCAMCORDER_GET_COND(handle)               (_MMCAMCORDER_CAST_MTSAFE(handle).cond)
377 #define _MMCAMCORDER_WAIT(handle)                   g_cond_wait(&_MMCAMCORDER_GET_COND(handle), &_MMCAMCORDER_GET_LOCK(handle))
378 #define _MMCAMCORDER_WAIT_UNTIL(handle, end_time)   g_cond_wait_until(&_MMCAMCORDER_GET_COND(handle), &_MMCAMCORDER_GET_LOCK(handle), end_time)
379 #define _MMCAMCORDER_SIGNAL(handle)                 g_cond_signal(&_MMCAMCORDER_GET_COND(handle));
380 #define _MMCAMCORDER_BROADCAST(handle)              g_cond_broadcast(&_MMCAMCORDER_GET_COND(handle));
381
382 /* for command */
383 #define _MMCAMCORDER_GET_CMD_LOCK(handle)           (_MMCAMCORDER_CAST_MTSAFE(handle).cmd_lock)
384 #define _MMCAMCORDER_GET_CMD_COND(handle)           (_MMCAMCORDER_CAST_MTSAFE(handle).cmd_cond)
385 #define _MMCAMCORDER_LOCK_CMD(handle)               _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_CMD_LOCK(handle))
386 #define _MMCAMCORDER_TRYLOCK_CMD(handle)            _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_CMD_LOCK(handle))
387 #define _MMCAMCORDER_UNLOCK_CMD(handle)             _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_CMD_LOCK(handle))
388 #define _MMCAMCORDER_CMD_WAIT(handle)                 g_cond_wait(&_MMCAMCORDER_GET_CMD_COND(handle), &_MMCAMCORDER_GET_CMD_LOCK(handle))
389 #define _MMCAMCORDER_CMD_WAIT_UNTIL(handle, end_time) g_cond_wait_until(&_MMCAMCORDER_GET_CMD_COND(handle), &_MMCAMCORDER_GET_CMD_LOCK(handle), end_time)
390 #define _MMCAMCORDER_CMD_SIGNAL(handle)               g_cond_signal(&_MMCAMCORDER_GET_CMD_COND(handle));
391
392 /* for interruption */
393 #define _MMCAMCORDER_GET_INTERRUPT_LOCK(handle)           (_MMCAMCORDER_CAST_MTSAFE(handle).interrupt_lock)
394 #define _MMCAMCORDER_LOCK_INTERRUPT(handle)               _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_INTERRUPT_LOCK(handle))
395 #define _MMCAMCORDER_TRYLOCK_INTERRUPT(handle)            _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_INTERRUPT_LOCK(handle))
396 #define _MMCAMCORDER_UNLOCK_INTERRUPT(handle)             _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_INTERRUPT_LOCK(handle))
397
398 /* for state change */
399 #define _MMCAMCORDER_GET_STATE_LOCK(handle)         (_MMCAMCORDER_CAST_MTSAFE(handle).state_lock)
400 #define _MMCAMCORDER_LOCK_STATE(handle)             _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_STATE_LOCK(handle))
401 #define _MMCAMCORDER_TRYLOCK_STATE(handle)          _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_STATE_LOCK(handle))
402 #define _MMCAMCORDER_UNLOCK_STATE(handle)           _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_STATE_LOCK(handle))
403
404 /* for gstreamer state change */
405 #define _MMCAMCORDER_GET_GST_STATE_LOCK(handle)     (_MMCAMCORDER_CAST_MTSAFE(handle).gst_state_lock)
406 #define _MMCAMCORDER_LOCK_GST_STATE(handle)         _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_GST_STATE_LOCK(handle))
407 #define _MMCAMCORDER_TRYLOCK_GST_STATE(handle)      _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_GST_STATE_LOCK(handle))
408 #define _MMCAMCORDER_UNLOCK_GST_STATE(handle)       _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_GST_STATE_LOCK(handle))
409
410 #define _MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle)      (_MMCAMCORDER_CAST_MTSAFE(handle).gst_encode_state_lock)
411 #define _MMCAMCORDER_LOCK_GST_ENCODE_STATE(handle)          _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle))
412 #define _MMCAMCORDER_TRYLOCK_GST_ENCODE_STATE(handle)       _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle))
413 #define _MMCAMCORDER_UNLOCK_GST_ENCODE_STATE(handle)        _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle))
414
415 /* for setting/calling callback */
416 #define _MMCAMCORDER_GET_MESSAGE_CALLBACK_LOCK(handle)      (_MMCAMCORDER_CAST_MTSAFE(handle).message_cb_lock)
417 #define _MMCAMCORDER_LOCK_MESSAGE_CALLBACK(handle)          _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_MESSAGE_CALLBACK_LOCK(handle))
418 #define _MMCAMCORDER_TRYLOCK_MESSAGE_CALLBACK(handle)       _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_MESSAGE_CALLBACK_LOCK(handle))
419 #define _MMCAMCORDER_UNLOCK_MESSAGE_CALLBACK(handle)        _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_MESSAGE_CALLBACK_LOCK(handle))
420
421 #define _MMCAMCORDER_GET_VCAPTURE_CALLBACK_LOCK(handle)     (_MMCAMCORDER_CAST_MTSAFE(handle).vcapture_cb_lock)
422 #define _MMCAMCORDER_LOCK_VCAPTURE_CALLBACK(handle)         _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_VCAPTURE_CALLBACK_LOCK(handle))
423 #define _MMCAMCORDER_TRYLOCK_VCAPTURE_CALLBACK(handle)      _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_VCAPTURE_CALLBACK_LOCK(handle))
424 #define _MMCAMCORDER_UNLOCK_VCAPTURE_CALLBACK(handle)       _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_VCAPTURE_CALLBACK_LOCK(handle))
425
426 #define _MMCAMCORDER_GET_VSTREAM_CALLBACK_LOCK(handle)      (_MMCAMCORDER_CAST_MTSAFE(handle).vstream_cb_lock)
427 #define _MMCAMCORDER_LOCK_VSTREAM_CALLBACK(handle)          _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_VSTREAM_CALLBACK_LOCK(handle))
428 #define _MMCAMCORDER_TRYLOCK_VSTREAM_CALLBACK(handle)       _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_VSTREAM_CALLBACK_LOCK(handle))
429 #define _MMCAMCORDER_UNLOCK_VSTREAM_CALLBACK(handle)        _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_VSTREAM_CALLBACK_LOCK(handle))
430
431 #define _MMCAMCORDER_GET_ASTREAM_CALLBACK_LOCK(handle)      (_MMCAMCORDER_CAST_MTSAFE(handle).astream_cb_lock)
432 #define _MMCAMCORDER_LOCK_ASTREAM_CALLBACK(handle)          _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_ASTREAM_CALLBACK_LOCK(handle))
433 #define _MMCAMCORDER_TRYLOCK_ASTREAM_CALLBACK(handle)       _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_ASTREAM_CALLBACK_LOCK(handle))
434 #define _MMCAMCORDER_UNLOCK_ASTREAM_CALLBACK(handle)        _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_ASTREAM_CALLBACK_LOCK(handle))
435
436 #define _MMCAMCORDER_GET_MSTREAM_CALLBACK_LOCK(handle)      (_MMCAMCORDER_CAST_MTSAFE(handle).mstream_cb_lock)
437 #define _MMCAMCORDER_LOCK_MSTREAM_CALLBACK(handle)          _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_MSTREAM_CALLBACK_LOCK(handle))
438 #define _MMCAMCORDER_TRYLOCK_MSTREAM_CALLBACK(handle)       _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_MSTREAM_CALLBACK_LOCK(handle))
439 #define _MMCAMCORDER_UNLOCK_MSTREAM_CALLBACK(handle)        _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_MSTREAM_CALLBACK_LOCK(handle))
440
441 #define _MMCAMCORDER_GET_VEDECISION_CALLBACK_LOCK(handle)   (_MMCAMCORDER_CAST_MTSAFE(handle).vedecision_cb_lock)
442 #define _MMCAMCORDER_LOCK_VEDECISION_CALLBACK(handle)       _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_VEDECISION_CALLBACK_LOCK(handle))
443 #define _MMCAMCORDER_TRYLOCK_VEDECISION_CALLBACK(handle)    _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_VEDECISION_CALLBACK_LOCK(handle))
444 #define _MMCAMCORDER_UNLOCK_VEDECISION_CALLBACK(handle)     _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_VEDECISION_CALLBACK_LOCK(handle))
445
446 #ifdef _MMCAMCORDER_MM_RM_SUPPORT
447 /* for resource conflict */
448 #define _MMCAMCORDER_GET_RESOURCE_LOCK(handle)              (_MMCAMCORDER_CAST_MTSAFE(handle).resource_lock)
449 #define _MMCAMCORDER_LOCK_RESOURCE(handle)                  _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_RESOURCE_LOCK(handle))
450 #define _MMCAMCORDER_UNLOCK_RESOURCE(handle)                _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_RESOURCE_LOCK(handle))
451 #endif /* _MMCAMCORDER_MM_RM_SUPPORT */
452
453 /**
454  * Caster of main handle (camcorder)
455  */
456 #define MMF_CAMCORDER(h) (mmf_camcorder_t *)(h)
457
458 /**
459  * Caster of subcontext
460  */
461 #define MMF_CAMCORDER_SUBCONTEXT(h) (((mmf_camcorder_t *)(h))->sub_context)
462
463 /* LOCAL CONSTANT DEFINITIONS */
464 /**
465  * Total Numbers of Attribute values.
466  * If you increase any enum of attribute values, you also have to increase this.
467  */
468 #define MM_CAMCORDER_MODE_NUM                   3       /**< Number of mode type */
469 #define MM_CAMCORDER_COLOR_TONE_NUM             30      /**< Number of color-tone modes */
470 #define MM_CAMCORDER_WHITE_BALANCE_NUM          10      /**< Number of WhiteBalance modes*/
471 #define MM_CAMCORDER_SCENE_MODE_NUM             16      /**< Number of program-modes */
472 #define MM_CAMCORDER_FOCUS_MODE_NUM             6       /**< Number of focus mode*/
473 #define MM_CAMCORDER_AUTO_FOCUS_NUM             5       /**< Total count of auto focus type*/
474 #define MM_CAMCORDER_FOCUS_STATE_NUM            4       /**< Number of focus state */
475 #define MM_CAMCORDER_ISO_NUM                    10      /**< Number of ISO */
476 #define MM_CAMCORDER_AUTO_EXPOSURE_NUM          9       /**< Number of Auto exposure type */
477 #define MM_CAMCORDER_WDR_NUM                    3       /**< Number of wide dynamic range */
478 #define MM_CAMCORDER_FLIP_NUM                   4       /**< Number of Flip mode */
479 #define MM_CAMCORDER_ROTATION_NUM               4       /**< Number of Rotation mode */
480 #define MM_CAMCORDER_AHS_NUM                    4       /**< Number of anti-handshake */
481 #define MM_CAMCORDER_VIDEO_STABILIZATION_NUM    2       /**< Number of video stabilization */
482 #define MM_CAMCORDER_HDR_CAPTURE_NUM            3       /**< Number of HDR capture mode */
483 #define MM_CAMCORDER_GEOMETRY_METHOD_NUM        5       /**< Number of geometry method */
484 #define MM_CAMCORDER_TAG_ORT_NUM                8       /**< Number of tag orientation */
485 #define MM_CAMCORDER_STROBE_MODE_NUM            8       /**< Number of strobe mode type */
486 #define MM_CAMCORDER_STROBE_CONTROL_NUM         3       /**< Number of strobe control type */
487 #define MM_CAMCORDER_DETECT_MODE_NUM            2       /**< Number of detect mode type */
488 #define MM_CAMCORDER_EXTRA_PREVIEW_STREAM_NUM   10      /**< Number of extra preview stream */
489
490 /*=======================================================================================
491 | ENUM DEFINITIONS                                                                      |
492 ========================================================================================*/
493 /**
494  * Command for Camcorder.
495  */
496 enum {
497         /* Command for Video/Audio recording */
498         _MMCamcorder_CMD_RECORD,
499         _MMCamcorder_CMD_PAUSE,
500         _MMCamcorder_CMD_CANCEL,
501         _MMCamcorder_CMD_COMMIT,
502
503         /* Command for Image capture */
504         _MMCamcorder_CMD_CAPTURE,
505
506         /* Command for Preview(Video/Image only effective) */
507         _MMCamcorder_CMD_PREVIEW_START,
508         _MMCamcorder_CMD_PREVIEW_STOP,
509 };
510
511 /**
512  * Still-shot type
513  */
514 enum {
515         _MMCamcorder_SINGLE_SHOT,
516         _MMCamcorder_MULTI_SHOT,
517 };
518
519 /**
520  * Enumerations for manual focus direction.
521  * If focusing mode is not "MM_CAMCORDER_AF_MODE_MANUAL", this value will be ignored.
522  */
523 enum MMCamcorderMfLensDir {
524         MM_CAMCORDER_MF_LENS_DIR_FORWARD = 1,   /**< Focus direction to forward */
525         MM_CAMCORDER_MF_LENS_DIR_BACKWARD,      /**< Focus direction to backward */
526         MM_CAMCORDER_MF_LENS_DIR_NUM,           /**< Total number of the directions */
527 };
528
529 /**
530  * Camcorder Pipeline's Element name.
531  * @note index of element.
532  */
533 typedef enum {
534         _MMCAMCORDER_NONE = (-1),
535
536         /* Main Pipeline Element */
537         _MMCAMCORDER_MAIN_PIPE = 0x00,
538
539         /* Pipeline element of Video input */
540         _MMCAMCORDER_VIDEOSRC_SRC,
541         _MMCAMCORDER_VIDEOSRC_FILT,
542         _MMCAMCORDER_VIDEOSRC_QUE,
543         _MMCAMCORDER_VIDEOSRC_DECODE,
544
545         /* Pipeline element of image capture */
546         _MMCAMCORDER_VIDEOSRC_CAP_FILT,
547         _MMCAMCORDER_VIDEOSRC_CAP_SINK,
548
549         /* Pipeline element of extra preview */
550         _MMCAMCORDER_VIDEOSRC_EXT_FILT,
551         _MMCAMCORDER_VIDEOSRC_EXT_SINK,
552
553         /* Pipeline element of Video output */
554         _MMCAMCORDER_VIDEOSINK_QUE,
555         _MMCAMCORDER_VIDEOSINK_CLS,
556         _MMCAMCORDER_VIDEOSINK_SINK,
557
558         _MMCAMCORDER_PIPELINE_ELEMENT_NUM,
559 } _MMCAMCORDER_PREVIEW_PIPELINE_ELELMENT;
560
561 /**
562  * Camcorder Pipeline's Element name.
563  * @note index of element.
564  */
565 typedef enum {
566         _MMCAMCORDER_ENCODE_NONE = (-1),
567
568         /* Main Pipeline Element */
569         _MMCAMCORDER_ENCODE_MAIN_PIPE = 0x00,
570
571         /* Pipeline element of Audio input */
572         _MMCAMCORDER_AUDIOSRC_BIN,
573         _MMCAMCORDER_AUDIOSRC_SRC,
574         _MMCAMCORDER_AUDIOSRC_FILT,
575         _MMCAMCORDER_AUDIOSRC_QUE,
576         _MMCAMCORDER_AUDIOSRC_CONV,
577         _MMCAMCORDER_AUDIOSRC_VOL,
578         _MMCAMCORDER_AUDIOSRC_RGA,      /* for replay gain analysis element */
579
580         /* Pipeline element of Encodebin */
581         _MMCAMCORDER_ENCSINK_BIN,
582         _MMCAMCORDER_ENCSINK_SRC,
583         _MMCAMCORDER_ENCSINK_FILT,
584         _MMCAMCORDER_ENCSINK_ENCBIN,
585         _MMCAMCORDER_ENCSINK_AQUE,
586         _MMCAMCORDER_ENCSINK_CONV,
587         _MMCAMCORDER_ENCSINK_AENC,
588         _MMCAMCORDER_ENCSINK_AENC_QUE,
589         _MMCAMCORDER_ENCSINK_VQUE,
590         _MMCAMCORDER_ENCSINK_VSCALE,
591         _MMCAMCORDER_ENCSINK_VSCALE_FILT,
592         _MMCAMCORDER_ENCSINK_VCONV,
593         _MMCAMCORDER_ENCSINK_VENC,
594         _MMCAMCORDER_ENCSINK_VENC_QUE,
595         _MMCAMCORDER_ENCSINK_ITOG,
596         _MMCAMCORDER_ENCSINK_ICROP,
597         _MMCAMCORDER_ENCSINK_ISCALE,
598         _MMCAMCORDER_ENCSINK_IFILT,
599         _MMCAMCORDER_ENCSINK_IQUE,
600         _MMCAMCORDER_ENCSINK_IENC,
601         _MMCAMCORDER_ENCSINK_MUX,
602         _MMCAMCORDER_ENCSINK_SINK,
603
604         _MMCAMCORDER_ENCODE_PIPELINE_ELEMENT_NUM,
605 } _MMCAMCORDER_ENCODE_PIPELINE_ELELMENT;
606
607 typedef enum {
608         _MMCAMCORDER_TASK_THREAD_STATE_NONE,
609         _MMCAMCORDER_TASK_THREAD_STATE_SOUND_PLAY_START,
610         _MMCAMCORDER_TASK_THREAD_STATE_SOUND_SOLO_PLAY_START,
611         _MMCAMCORDER_TASK_THREAD_STATE_ENCODE_PIPE_CREATE,
612         _MMCAMCORDER_TASK_THREAD_STATE_CHECK_CAPTURE_IN_RECORDING,
613         _MMCAMCORDER_TASK_THREAD_STATE_EXIT,
614 } _MMCamcorderTaskThreadState;
615
616 /**
617  * System state change cause
618  */
619 typedef enum {
620         _MMCAMCORDER_STATE_CHANGE_NORMAL = 0,
621         _MMCAMCORDER_STATE_CHANGE_BY_RM,
622         _MMCAMCORDER_STATE_CHANGE_BY_DPM,
623         _MMCAMCORDER_STATE_CHANGE_BY_STORAGE
624 } _MMCamcorderStateChange;
625
626
627 /*=======================================================================================
628 | STRUCTURE DEFINITIONS                                                                 |
629 ========================================================================================*/
630 /**
631  * MMCamcorder Gstreamer Element
632  */
633 typedef struct {
634         unsigned int id;                /**< Gstreamer pipeline element id */
635         GstElement *gst;                /**< Gstreamer element */
636 } _MMCamcorderGstElement;
637
638 /**
639  * MMCamcorder information for KPI measurement
640  */
641 typedef struct {
642         int current_fps;                /**< current fps of this second */
643         int average_fps;                /**< average fps  */
644         unsigned int video_framecount;  /**< total number of video frame */
645         unsigned int last_framecount;   /**< total number of video frame in last measurement */
646         struct timeval init_video_time; /**< time when start to measure */
647         struct timeval last_video_time; /**< last measurement time */
648 } _MMCamcorderKPIMeasure;
649
650 /**
651  * MMCamcorder information for Multi-Thread Safe
652  */
653 typedef struct {
654         GMutex lock;                    /**< Mutex (for general use) */
655         GCond cond;                     /**< Condition (for general use) */
656         GMutex cmd_lock;                /**< Mutex (for command) */
657         GCond cmd_cond;                 /**< Condition (for command) */
658         GMutex interrupt_lock;          /**< Mutex (for interruption) */
659         GMutex state_lock;              /**< Mutex (for state change) */
660         GMutex gst_state_lock;          /**< Mutex (for gst pipeline state change) */
661         GMutex gst_encode_state_lock;   /**< Mutex (for gst encode pipeline state change) */
662         GMutex message_cb_lock;         /**< Mutex (for message callback) */
663         GMutex vcapture_cb_lock;        /**< Mutex (for video capture callback) */
664         GMutex vstream_cb_lock;         /**< Mutex (for video stream callback) */
665         GMutex astream_cb_lock;         /**< Mutex (for audio stream callback) */
666         GMutex mstream_cb_lock;         /**< Mutex (for muxed stream callback) */
667         GMutex vedecision_cb_lock;      /**< Mutex (for video encode decision callback) */
668 #ifdef _MMCAMCORDER_MM_RM_SUPPORT
669         GMutex resource_lock;           /**< Mutex (for resource check) */
670 #endif /* _MMCAMCORDER_MM_RM_SUPPORT */
671 } _MMCamcorderMTSafe;
672
673 /**
674  * MMCamcorder Replay gain value
675  */
676 typedef struct {
677         gdouble track_peak;
678         gdouble track_gain;
679         gdouble album_peak;
680         gdouble album_gain;
681 } _MMCamcorderReplayGain;
682
683 /**
684  * MMCamcorder Extra preview format
685  */
686 typedef struct {
687         int pixel_format;
688         int width;
689         int height;
690         int fps;
691         int bitrate;
692         int gop_interval;
693         gboolean need_to_set_format;
694         gboolean need_to_set_bitrate;
695         gboolean need_to_set_gop_interval;
696 } _MMCamcorderExtraPreviewFormat;
697
698 /**
699  * MMCamcorder Extra preview
700  */
701 typedef struct {
702         gboolean is_supported;
703         MMCamcorderExtraPreviewMode mode;
704         _MMCamcorderExtraPreviewFormat format[MM_CAMCORDER_EXTRA_PREVIEW_STREAM_NUM];
705 } _MMCamcorderExtraPreview;
706
707 /**
708  * MMCamcorder Sub Context
709  */
710 typedef struct {
711         bool isMaxsizePausing;                  /**< Because of size limit, pipeline is paused. */
712         bool isMaxtimePausing;                  /**< Because of time limit, pipeline is paused. */
713         int element_num;                        /**< count of element */
714         int encode_element_num;                 /**< count of encode element */
715         int frame_stability_count;              /**< camsensor stability count. the count of frame will drop */
716         GstClockTime pipeline_time;             /**< current time of Gstreamer Pipeline */
717         GstClockTime pause_time;                /**< amount of time while pipeline is in PAUSE state.*/
718         GstClockTime stillshot_time;            /**< pipeline time of capturing moment*/
719         gboolean is_modified_rate;              /**< whether recording motion rate is modified or not */
720         gboolean ferror_send;                   /**< file write/seek error **/
721         guint ferror_count;                     /**< file write/seek error count **/
722         GstClockTime previous_slot_time;
723         int display_interval;                   /**< This value is set as 'GST_SECOND / display FPS' */
724         gboolean bget_eos;                      /**< Whether getting EOS */
725         gboolean audio_disable;                 /**< whether audio is disabled or not when record */
726         int videosrc_rotate;                    /**< rotate of videosrc */
727         unsigned long long muxed_stream_offset; /**< current offset for muxed stream data */
728
729         /* For dropping video frame when start recording */
730         int drop_vframe;                        /**< When this value is bigger than zero and pass_first_vframe is zero, MSL will drop video frame though cam_stability count is bigger then zero. */
731         int pass_first_vframe;                  /**< When this value is bigger than zero, MSL won't drop video frame though "drop_vframe" is bigger then zero. */
732
733         /* Replay gain */
734         _MMCamcorderReplayGain replay_gain;     /**< Replay gain for audio recording */
735
736         /* INI information */
737         unsigned int fourcc;                    /**< Get fourcc value of camera INI file */
738         _MMCamcorderImageInfo *info_image;      /**< extra information for image capture */
739         _MMCamcorderVideoInfo *info_video;      /**< extra information for video recording */
740         _MMCamcorderAudioInfo *info_audio;      /**< extra information for audio recording */
741
742         _MMCamcorderGstElement *element;        /**< array of preview element */
743         _MMCamcorderGstElement *encode_element; /**< array of encode element */
744         _MMCamcorderKPIMeasure kpi;             /**< information related with performance measurement */
745
746         type_element *VideosinkElement;         /**< configure data of videosink element */
747         type_element *VideoconvertElement;      /**< configure data of videoconvert element */
748         type_element *VideodecoderElement;      /**< configure data of video decoder element */
749         gboolean SensorEncodedCapture;          /**< whether camera sensor support encoded image capture */
750         gboolean internal_encode;               /**< whether use internal encoding function */
751 } _MMCamcorderSubContext;
752
753 /**
754   * _MMCamcorderContext
755   */
756 typedef struct mmf_camcorder {
757         /* information */
758         int type;               /**< mmcamcorder_mode_type */
759         int device_type;        /**< device type */
760         int state;              /**< state of camcorder */
761         int old_state;          /**< old state of camcorder */
762
763         /* handles */
764         MMHandleType attributes;               /**< Attribute handle */
765         _MMCamcorderSubContext *sub_context;   /**< sub context */
766         mm_exif_info_t *exif_info;             /**< EXIF */
767         GList *buffer_probes;                  /**< a list of buffer probe handle */
768         GList *event_probes;                   /**< a list of event probe handle */
769         GList *signals;                        /**< a list of signal handle */
770 #ifdef _MMCAMCORDER_ENABLE_IDLE_MESSAGE_CALLBACK
771         GList *msg_data;                       /**< a list of msg data */
772 #endif /* _MMCAMCORDER_ENABLE_IDLE_MESSAGE_CALLBACK */
773         camera_conf *conf_main;                /**< Camera configure Main structure */
774         camera_conf *conf_ctrl;                /**< Camera configure Control structure */
775 #ifdef _MMCAMCORDER_RM_SUPPORT
776         int rm_handle;                         /**< Resource manager handle */
777         rm_consumer_info rci;                  /**< Resource consumer info */
778 #endif /* _MMCAMCORDER_RM_SUPPORT */
779         SOUND_INFO snd_info;                   /**< Sound handle for multishot capture */
780
781         /* callback handlers */
782         MMMessageCallback msg_cb;                               /**< message callback */
783         void *msg_cb_param;                                     /**< message callback parameter */
784         mm_camcorder_video_stream_callback vstream_cb;          /**< Video stream callback */
785         void *vstream_cb_param;                                 /**< Video stream callback parameter */
786         mm_camcorder_audio_stream_callback astream_cb;          /**< Audio stream callback */
787         void *astream_cb_param;                                 /**< Audio stream callback parameter */
788         mm_camcorder_muxed_stream_callback mstream_cb;          /**< Muxed stream callback */
789         void *mstream_cb_param;                                 /**< Muxed stream callback parameter */
790         mm_camcorder_video_capture_callback vcapture_cb;        /**< Video capture callback */
791         void *vcapture_cb_param;                                /**< Video capture callback parameter */
792         mm_camcorder_video_encode_decision_callback vedecision_cb; /**< Video encode decision callback */
793         void *vedecision_cb_param;                                 /**< Video encode decision callback parameter */
794         int (*command)(MMHandleType, int);                      /**< camcorder's command */
795
796         /* etc */
797         mm_cam_attr_construct_info *cam_attrs_const_info;       /**< attribute info */
798         conf_info_table *conf_main_info_table[CONFIGURE_CATEGORY_MAIN_NUM]; /** configure info table - MAIN category */
799         conf_info_table *conf_ctrl_info_table[CONFIGURE_CATEGORY_CTRL_NUM]; /** configure info table - CONTROL category */
800         int conf_main_category_size[CONFIGURE_CATEGORY_MAIN_NUM]; /** configure info table size - MAIN category */
801         int conf_ctrl_category_size[CONFIGURE_CATEGORY_CTRL_NUM]; /** configure info table size - CONTROL category */
802         _MMCamcorderMTSafe mtsafe;                              /**< Thread safe */
803         int state_change_by_system;                             /**< MSL changes its state by itself because of system */
804         GMutex restart_preview_lock;                            /**< Capture sound mutex */
805         int use_zero_copy_format;                               /**< Whether use zero copy format for camera input */
806         int use_videoconvert;                                   /**< Whether use videoconvert element for display */
807         int support_media_packet_preview_cb;                    /**< Whether support zero copy format for camera input */
808         int support_user_buffer;                                /**< Whether support user allocated buffer for zero copy */
809         int capture_mode;                                       /**< Capture mode */
810         int shutter_sound_policy;                               /**< shutter sound policy */
811         int brightness_default;                                 /**< default value of brightness */
812         int brightness_step_denominator;                        /**< denominator of brightness bias step */
813         int support_zsl_capture;                                /**< support Zero Shutter Lag capture */
814         char *model_name;                                       /**< model name from system info */
815         char *software_version;                                 /**< software_version from system info */
816         int capture_sound_count;                                /**< count for capture sound */
817         char *root_directory;                                   /**< Root directory for device */
818         int resolution_changed;                                 /**< Flag for preview resolution change */
819         int interrupt_code;                                     /**< Interrupt code */
820         int recreate_decoder;                                   /**< Flag of decoder element recreation for encoded preview format */
821         gboolean is_network;                                    /**< Flag for network camera */
822         const char *network_hal_name;                           /**< Name of network camera HAL library */
823         int default_encoded_preview_bitrate;                    /**< Default bitrate for encoded preview */
824
825         _MMCamcorderInfoConverting caminfo_convert[CAMINFO_CONVERT_NUM];        /**< converting structure of camera info */
826         _MMCamcorderEnumConvert enum_conv[ENUM_CONVERT_NUM];                    /**< enum converting list that is modified by ini info */
827
828         gboolean capture_in_recording;                          /**< Flag for capture while recording */
829
830         gboolean error_occurs;                                  /**< flag for error */
831         int error_code;                                         /**< error code for internal gstreamer error */
832
833         /* task thread */
834         GThread *task_thread;                                   /**< thread for task */
835         GMutex task_thread_lock;                                /**< mutex for task thread */
836         GCond task_thread_cond;                                 /**< cond for task thread */
837         _MMCamcorderTaskThreadState task_thread_state;          /**< state of task thread */
838
839 #ifdef _MMCAMCORDER_MM_RM_SUPPORT
840         /* resource manager for H/W resources */
841         mm_resource_manager_h resource_manager;
842         mm_resource_manager_res_h camera_resource;
843         mm_resource_manager_res_h video_overlay_resource;
844         mm_resource_manager_res_h video_encoder_resource;
845         gboolean is_release_cb_calling;
846 #endif /* _MMCAMCORDER_MM_RM_SUPPORT */
847
848         /* gdbus */
849         GDBusConnection *gdbus_conn;                            /**< gdbus connection */
850         _MMCamcorderGDbusCbInfo gdbus_info_sound;               /**< Information for the gdbus cb of sound play */
851         _MMCamcorderGDbusCbInfo gdbus_info_solo_sound;          /**< Information for the gdbus cb of solo sound play */
852
853         /* DPM(device policy manager) */
854         device_policy_manager_h dpm_handle;                     /**< DPM handle */
855         int dpm_camera_cb_id;                                   /**< DPM camera policy changed callback id */
856
857         /* Storage */
858         _MMCamcorderStorageInfo storage_info;                   /**< Storage information */
859
860 #ifdef _MMCAMCORDER_RM_SUPPORT
861         rm_category_request_s request_resources;
862         rm_device_return_s returned_devices;
863 #endif /* _MMCAMCORDER_RM_SUPPORT */
864 #ifdef _MMCAMCORDER_CAMERA_CONF_MGR_SUPPORT
865         camera_conf_device_info_s conf_device_info;
866 #endif /*_MMCAMCORDER_CAMERA_CONF_MGR_SUPPORT */
867
868         /* Profiling */
869         int measure_preview_fps;                                /**< Flag for measuring fps of preview frames */
870
871         _MMCamcorderExtraPreview extra_preview;                 /**< Extra preview */
872
873         GQuark buffer_quark;                                    /**< Quark for buffer */
874
875         int reserved[4];                                        /**< reserved */
876 } mmf_camcorder_t;
877
878 /*=======================================================================================
879 | EXTERN GLOBAL VARIABLE                                                                |
880 ========================================================================================*/
881
882 /*=======================================================================================
883 | GLOBAL FUNCTION PROTOTYPES                                                            |
884 ========================================================================================*/
885 /**
886  *      This function creates camcorder for capturing still image and recording.
887  *
888  *      @param[out]     handle          Specifies the camcorder  handle
889  *      @param[in]      info            Preset information of camcorder
890  *      @return         This function returns zero on success, or negative value with error code.
891  *      @remarks        When this function calls successfully, camcorder  handle will be filled with a @n
892  *                      valid value and the state of  the camcorder  will become MM_CAMCORDER_STATE_NULL.@n
893  *                      Note that  it's not ready to working camcorder. @n
894  *                      You should call mmcamcorder_realize before starting camcorder.
895  *      @see            _mmcamcorder_create
896  */
897 int _mmcamcorder_create(MMHandleType *handle, MMCamPreset *info);
898
899 /**
900  *      This function destroys instance of camcorder.
901  *
902  *      @param[in]      hcamcorder      Specifies the camcorder  handle
903  *      @return         This function returns zero on success, or negative value with error code.
904  *      @see            _mmcamcorder_create
905  */
906 int _mmcamcorder_destroy(MMHandleType hcamcorder);
907
908 /**
909  *      This function allocates memory for camcorder.
910  *
911  *      @param[in]      hcamcorder      Specifies the camcorder  handle
912  *      @return         This function returns zero on success, or negative value with error code.
913  *      @remarks        This function can  be called successfully when current state is MM_CAMCORDER_STATE_NULL @n
914  *                      and  the state of the camcorder  will become MM_CAMCORDER_STATE_READY. @n
915  *                      Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
916  *      @see            _mmcamcorder_unrealize
917  *      @pre            MM_CAMCORDER_STATE_NULL
918  *      @post           MM_CAMCORDER_STATE_READY
919  */
920 int _mmcamcorder_realize(MMHandleType hcamcorder);
921
922 /**
923  *      This function free allocated memory for camcorder.
924  *
925  *      @param[in]      hcamcorder      Specifies the camcorder  handle
926  *      @return         This function returns zero on success, or negative value with error code.
927  *      @remarks        This function release all resources which are allocated for the camcorder engine.@n
928  *                      This function can  be called successfully when current state is MM_CAMCORDER_STATE_READY and  @n
929  *                      the state of the camcorder  will become MM_CAMCORDER_STATE_NULL. @n
930  *                      Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
931  *      @see            _mmcamcorder_realize
932  *      @pre            MM_CAMCORDER_STATE_READY
933  *      @post           MM_CAMCORDER_STATE_NULL
934  */
935 int _mmcamcorder_unrealize(MMHandleType hcamcorder);
936
937 /**
938  *      This function is to start previewing.
939  *
940  *      @param[in]      hcamcorder      Specifies the camcorder  handle
941  *      @return         This function returns zero on success, or negative value with error code.
942  *      @remarks        This function can  be called successfully when current state is MM_CAMCORDER_STATE_READY and  @n
943  *                      the state of the camcorder  will become MM_CAMCORDER_STATE_PREPARE. @n
944  *                      Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
945  *      @see            _mmcamcorder_stop
946  */
947 int _mmcamcorder_start(MMHandleType hcamcorder);
948
949 /**
950  *      This function is to stop previewing.
951  *
952  *      @param[in]      hcamcorder      Specifies the camcorder  handle
953  *      @return         This function returns zero on success, or negative value with error code.
954  *      @remarks        This function can  be called successfully when current state is MM_CAMCORDER_STATE_PREPARE and  @n
955  *                      the state of the camcorder  will become MM_CAMCORDER_STATE_READY.@n
956  *                      Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
957  *      @see            _mmcamcorder_start
958  */
959 int _mmcamcorder_stop(MMHandleType hcamcorder);
960
961 /**
962  *      This function to start capturing of still images.
963  *
964  *      @param[in]      hcamcorder      Specifies the camcorder  handle.
965  *      @return         This function returns zero on success, or negative value with error code.
966  *      @remarks        This function can  be called successfully when current state is MM_CAMCORDER_STATE_PREPARE and @n
967  *                      the state of the camcorder  will become MM_CAMCORDER_STATE_CAPTURING. @n
968  *                      Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
969  *      @see            _mmcamcorder_capture_stop
970  */
971 int _mmcamcorder_capture_start(MMHandleType hcamcorder);
972
973 /**
974  *      This function is to stop capturing still images.
975  *
976  *      @param[in]      hcamcorder      Specifies the camcorder  handle
977  *      @return         This function returns zero on success, or negative value with error code.
978  *      @remarks        This function can  be called successfully when current state is MM_CAMCORDER_STATE_CAPTURING and @n
979  *                      the state of the camcorder  will become MM_CAMCORDER_STATE_PREPARE. @n
980  *                      Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
981  *      @see            _mmcamcorder_capture_start
982  */
983 int _mmcamcorder_capture_stop(MMHandleType hcamcorder);
984
985 /**
986  *      This function is to start  video and audio recording.
987  *
988  *      @param[in]      hcamcorder      Specifies the camcorder  handle
989  *      @return         This function returns zero on success, or negative value with error code.
990  *      @remarks        This function can  be called successfully when current state is @n
991  *                      MM_CAMCORDER_STATE_PREPARE or MM_CAMCORDER_STATE_PAUSED and  @n
992  *                      the state of the camcorder  will become MM_CAMCORDER_STATE_RECORDING.@n
993  *                      Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
994  *      @see            _mmcamcorder_pause
995  */
996 int _mmcamcorder_record(MMHandleType hcamcorder);
997
998 /**
999  *      This function is to pause video and audio recording
1000  *
1001  *      @param[in]      hcamcorder      Specifies the camcorder  handle
1002  *      @return         This function returns zero on success, or negative value with error code.
1003  *      @remarks        This function can  be called successfully when current state is MM_CAMCORDER_STATE_RECORDING and  @n
1004  *                      the  state of the camcorder  will become MM_CAMCORDER_STATE_PAUSED.@n
1005  *                      Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.@n
1006  *      @see            _mmcamcorder_record
1007  */
1008 int _mmcamcorder_pause(MMHandleType hcamcorder);
1009
1010 /**
1011  *      This function is to stop video and audio  recording and  save results.
1012  *
1013  *      @param[in]      hcamcorder      Specifies the camcorder  handle
1014  *      @return         This function returns zero on success, or negative value with error code.
1015  *      @remarks        This function can  be called successfully when current state is @n
1016  *                      MM_CAMCORDER_STATE_PAUSED or MM_CAMCORDER_STATE_RECORDING and  @n
1017  *                      the state of the camcorder  will become MM_CAMCORDER_STATE_PREPARE. @n
1018  *                      Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION
1019  *      @see            _mmcamcorder_cancel
1020  */
1021 int _mmcamcorder_commit(MMHandleType hcamcorder);
1022
1023 /**
1024  *      This function is to stop video and audio recording and do not save results.
1025  *
1026  *      @param[in]      hcamcorder      Specifies the camcorder  handle
1027  *      @return         This function returns zero on success, or negative value with error code.
1028  *      @remarks        This function can  be called successfully when current state is @n
1029  *                      MM_CAMCORDER_STATE_PAUSED or MM_CAMCORDER_STATE_RECORDING and  @n
1030  *                      the state of the camcorder  will become MM_CAMCORDER_STATE_PREPARE. @n
1031  *                      Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
1032  *      @see            _mmcamcorder_commit
1033  */
1034 int _mmcamcorder_cancel(MMHandleType hcamcorder);
1035
1036 /**
1037  *      This function calls after committing action finished asynchronously.
1038  *      In this function, remaining process , such as state change, happens.
1039  *
1040  *      @param[in]      hcamcorder      Specifies the camcorder  handle
1041  *      @return         This function returns zero on success, or negative value with error code.
1042  *      @remarks        This function can  be called successfully when current state is @n
1043  *                      MM_CAMCORDER_STATE_PAUSED or MM_CAMCORDER_STATE_RECORDING and  @n
1044  *                      the state of the camcorder  will become MM_CAMCORDER_STATE_PREPARE. @n
1045  *                      Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
1046  *      @see            _mmcamcorder_commit
1047  */
1048 int _mmcamcorder_commit_async_end(MMHandleType hcamcorder);
1049
1050 /**
1051  *      This function is to set callback for receiving messages from camcorder.
1052  *
1053  *      @param[in]      hcamcorder      Specifies the camcorder  handle
1054  *      @param[in]      callback        Specifies the function pointer of callback function
1055  *      @param[in]      user_data       Specifies the user pointer for passing to callback function
1056  *
1057  *      @return         This function returns zero on success, or negative value with error code.
1058  *      @remarks        typedef bool (*mm_message_callback) (int msg, mm_messageType *param, void *user_param);@n
1059  *              @n
1060  *              typedef union                           @n
1061  *              {                                                       @n
1062  *                      int code;                               @n
1063  *                      struct                                  @n
1064  *                      {                                               @n
1065  *                              int total;                      @n
1066  *                              int elapsed;            @n
1067  *                      } time;                                 @n
1068  *                      struct                                  @n
1069  *                      {                                               @n
1070  *                              int previous;           @n
1071  *                              int current;                    @n
1072  *                      } state;                                        @n
1073  *              } mm_message_type;      @n
1074  *                                                                      @n
1075  *              If a  message value for mm_message_callback is MM_MESSAGE_STATE_CHANGED, @n
1076  *              state value in mm_message_type  will be a mmcamcorder_state_type enum value;@n
1077  *              @n
1078  *              If  a message value for mm_message_callback is MM_MESSAGE_ERROR,  @n
1079  *              the code value in mm_message_type will be a mmplayer_error_type enum value;
1080  *
1081  *      @see            mm_message_type,  mmcamcorder_state_type,  mmcamcorder_error_type
1082  */
1083 int _mmcamcorder_set_message_callback(MMHandleType hcamcorder,
1084                                       MMMessageCallback callback,
1085                                       void *user_data);
1086
1087 /**
1088  *      This function is to set callback for video stream.
1089  *
1090  *      @param[in]      hcamcorder      Specifies the camcorder  handle
1091  *      @param[in]      callback        Specifies the function pointer of callback function
1092  *      @param[in]      user_data       Specifies the user pointer for passing to callback function
1093  *
1094  *      @return         This function returns zero on success, or negative value with error code.
1095  *      @see            mmcamcorder_error_type
1096  */
1097 int _mmcamcorder_set_video_stream_callback(MMHandleType hcamcorder,
1098                                            mm_camcorder_video_stream_callback callback,
1099                                            void *user_data);
1100
1101 /**
1102  *      This function is to set callback for audio stream.
1103  *
1104  *      @param[in]      hcamcorder      Specifies the camcorder handle
1105  *      @param[in]      callback        Specifies the function pointer of callback function
1106  *      @param[in]      user_data       Specifies the user pointer for passing to callback function
1107  *
1108  *      @return         This function returns zero on success, or negative value with error code.
1109  *      @see            mmcamcorder_error_type
1110  */
1111 int _mmcamcorder_set_audio_stream_callback(MMHandleType handle,
1112                                            mm_camcorder_audio_stream_callback callback,
1113                                            void *user_data);
1114
1115 /**
1116  *      This function is to set callback for muxed stream.
1117  *
1118  *      @param[in]      hcamcorder      Specifies the camcorder handle
1119  *      @param[in]      callback        Specifies the function pointer of callback function
1120  *      @param[in]      user_data       Specifies the user pointer for passing to callback function
1121  *
1122  *      @return         This function returns zero on success, or negative value with error code.
1123  *      @see            mmcamcorder_error_type
1124  */
1125 int _mmcamcorder_set_muxed_stream_callback(MMHandleType handle,
1126                                            mm_camcorder_muxed_stream_callback callback,
1127                                            void *user_data);
1128
1129 /**
1130  *      This function is to set callback for video capture.
1131  *
1132  *      @param[in]      hcamcorder      Specifies the camcorder  handle
1133  *      @param[in]      callback        Specifies the function pointer of callback function
1134  *      @param[in]      user_data       Specifies the user pointer for passing to callback function
1135  *
1136  *      @return         This function returns zero on success, or negative value with error code.
1137  *      @see            mmcamcorder_error_type
1138  */
1139 int _mmcamcorder_set_video_capture_callback(MMHandleType hcamcorder,
1140                                             mm_camcorder_video_capture_callback callback,
1141                                             void *user_data);
1142
1143 /**
1144  *      This function is to set callback for video encode decision.
1145  *
1146  *      @param[in]      hcamcorder      Specifies the camcorder  handle
1147  *      @param[in]      callback        Specifies the function pointer of callback function
1148  *      @param[in]      user_data       Specifies the user pointer for passing to callback function
1149  *
1150  *      @return         This function returns zero on success, or negative value with error code.
1151  */
1152 int _mmcamcorder_set_video_encode_decision_callback(MMHandleType hcamcorder,
1153                                             mm_camcorder_video_encode_decision_callback callback,
1154                                             void *user_data);
1155
1156 /**
1157  *      This function returns current state of camcorder, or negative value with error code.
1158  *
1159  *      @param[in]      hcamcorder      Specifies the camcorder  handle.
1160  *      @return         This function returns current state of camcorder, or negative value with error code.
1161  *      @see            mmcamcorder_state_type
1162  */
1163 int _mmcamcorder_get_current_state(MMHandleType hcamcorder);
1164
1165 int _mmcamcorder_init_focusing(MMHandleType handle);
1166 int _mmcamcorder_adjust_focus(MMHandleType handle, int direction);
1167 int _mmcamcorder_adjust_manual_focus(MMHandleType handle, int direction);
1168 int _mmcamcorder_adjust_auto_focus(MMHandleType handle);
1169 int _mmcamcorder_stop_focusing(MMHandleType handle);
1170
1171 /**
1172  * This function gets current state of camcorder.
1173  *
1174  * @param       void
1175  * @return      This function returns state of current camcorder context
1176  * @remarks
1177  * @see         _mmcamcorder_set_state()
1178  *
1179  */
1180 int _mmcamcorder_streamer_init(void);
1181
1182 /**
1183  * This function gets current state of camcorder.
1184  *
1185  * @param       void
1186  * @return      This function returns state of current camcorder context
1187  * @remarks
1188  * @see         _mmcamcorder_set_state()
1189  *
1190  */
1191 int _mmcamcorder_display_init(void);
1192
1193 /**
1194  * This function gets current state of camcorder.
1195  *
1196  * @param[in]   handle          Handle of camcorder context.
1197  * @return      This function returns state of current camcorder context
1198  * @remarks
1199  * @see         _mmcamcorder_set_state()
1200  *
1201  */
1202 int _mmcamcorder_get_state(MMHandleType handle);
1203 int _mmcamcorder_get_state2(MMHandleType handle, int *state, int *old_state);
1204
1205 /**
1206  * This function sets new state of camcorder.
1207  *
1208  * @param[in]   handle          Handle of camcorder context.
1209  * @param[in]   state           setting state value of camcorder.
1210  * @return      void
1211  * @remarks
1212  * @see         _mmcamcorder_get_state()
1213  *
1214  */
1215 void _mmcamcorder_set_state(MMHandleType handle, int state);
1216
1217 /**
1218  * This function allocates structure of subsidiary attributes.
1219  *
1220  * @param[in]   type            Allocation type of camcorder context.
1221  * @return      This function returns structure pointer on success, NULL value on failure.
1222  * @remarks
1223  * @see         _mmcamcorder_dealloc_subcontext()
1224  *
1225  */
1226 _MMCamcorderSubContext *_mmcamcorder_alloc_subcontext(int type);
1227
1228 /**
1229  * This function releases structure of subsidiary attributes.
1230  *
1231  * @param[in]   sc              Handle of camcorder subcontext.
1232  * @return      void
1233  * @remarks
1234  * @see         _mmcamcorder_alloc_subcontext()
1235  *
1236  */
1237 void _mmcamcorder_dealloc_subcontext(_MMCamcorderSubContext *sc);
1238
1239 /**
1240  * This function sets command function according to the type.
1241  *
1242  * @param[in]   handle          Handle of camcorder context.
1243  * @param[in]   type            Allocation type of camcorder context.
1244  * @return      This function returns MM_ERROR_NONE on success, or other values with error code.
1245  * @remarks
1246  * @see         __mmcamcorder_video_command(), __mmcamcorder_audio_command(), __mmcamcorder_image_command()
1247  *
1248  */
1249 int _mmcamcorder_set_functions(MMHandleType handle, int type);
1250
1251 /**
1252  * This function is callback function of main pipeline.
1253  * Once this function is registered with certain pipeline using gst_bus_add_watch(),
1254  * this callback will be called every time when there is upcoming message from pipeline.
1255  * Basically, this function is used as error handling function, now.
1256  *
1257  * @param[in]   bus             pointer of buf that called this function.
1258  * @param[in]   message         callback message from pipeline.
1259  * @param[in]   data            user data.
1260  * @return      This function returns true on success, or false value with error
1261  * @remarks
1262  * @see         __mmcamcorder_create_preview_pipeline()
1263  *
1264  */
1265 gboolean _mmcamcorder_pipeline_cb_message(GstBus *bus, GstMessage *message, gpointer data);
1266
1267 /**
1268  * This function is callback function of main pipeline.
1269  * Once this function is registered with certain pipeline using gst_bus_set_sync_handler(),
1270  * this callback will be called every time when there is upcoming message from pipeline.
1271  * Basically, this function is used as sync error handling function, now.
1272  *
1273  * @param[in]   bus             pointer of buf that called this function.
1274  * @param[in]   message         callback message from pipeline.
1275  * @param[in]   data            user data.
1276  * @return      This function returns true on success, or false value with error
1277  * @remarks
1278  * @see         __mmcamcorder_create_preview_pipeline()
1279  *
1280  */
1281 GstBusSyncReply _mmcamcorder_pipeline_bus_sync_callback(GstBus *bus, GstMessage *message, gpointer data);
1282
1283 /**
1284  * This function is callback function of encode pipeline.
1285  * Once this function is registered with certain pipeline using gst_bus_set_sync_handler(),
1286  * this callback will be called every time when there is upcoming message from pipeline.
1287  * Basically, this function is used for EOS and error handling now.
1288  *
1289  * @param[in]   bus             pointer of buf that called this function.
1290  * @param[in]   message         callback message from pipeline.
1291  * @param[in]   data            user data.
1292  * @return      This function returns true on success, or false value with error
1293  * @remarks
1294  * @see         __mmcamcorder_create_recorder_pipeline()
1295  * @see         __mmcamcorder_create_audiop_with_encodebin()
1296  *
1297  */
1298 GstBusSyncReply _mmcamcorder_encode_pipeline_bus_sync_callback(GstBus *bus, GstMessage *message, gpointer data);
1299
1300 /**
1301  * This function create main pipeline according to type.
1302  *
1303  * @param[in]   handle          Handle of camcorder context.
1304  * @param[in]   type            Allocation type of camcorder context.
1305  * @return      This function returns zero on success, or negative value with error code.
1306  * @remarks
1307  * @see         _mmcamcorder_destroy_pipeline()
1308  *
1309  */
1310 int _mmcamcorder_create_pipeline(MMHandleType handle, int type);
1311
1312 /**
1313  * This function release all element of main pipeline according to type.
1314  *
1315  * @param[in]   handle          Handle of camcorder context.
1316  * @param[in]   type            Allocation type of camcorder context.
1317  * @return      void
1318  * @remarks
1319  * @see         _mmcamcorder_create_pipeline()
1320  *
1321  */
1322 void _mmcamcorder_destroy_pipeline(MMHandleType handle, int type);
1323
1324 /**
1325  * This function sets gstreamer element status.
1326  * If the gstreamer fails to set status or returns asynchronous mode,
1327  * this function waits for state changed until timeout expired.
1328  *
1329  * @param[in]   pipeline        Pointer of pipeline
1330  * @param[in]   target_state    newly setting status
1331  * @return      This function returns zero on success, or negative value with error code.
1332  * @remarks
1333  * @see
1334  *
1335  */
1336 int _mmcamcorder_gst_set_state(MMHandleType handle, GstElement *pipeline, GstState target_state);
1337
1338
1339 /* For xvimagesink */
1340 GstBusSyncReply __mmcamcorder_sync_callback(GstBus *bus, GstMessage *message, gulong data);
1341
1342 /* For querying capabilities */
1343 int _mmcamcorder_read_vidsrc_info(int videodevidx, camera_conf **configure_info);
1344
1345 /* for performance check */
1346 void _mmcamcorder_video_current_framerate_init(MMHandleType handle);
1347 int _mmcamcorder_video_current_framerate(MMHandleType handle);
1348 int _mmcamcorder_video_average_framerate(MMHandleType handle);
1349
1350 /* for stopping forcedly */
1351 void __mmcamcorder_force_stop(mmf_camcorder_t *hcamcorder, int state_change_by_system);
1352
1353 /* device policy manager */
1354 void _mmcamcorder_dpm_camera_policy_changed_cb(const char *name, const char *value, void *user_data);
1355
1356 /* Emit dbus signal */
1357 void _mmcamcorder_emit_signal(MMHandleType handle, const char *object_name,
1358         const char *interface_name, const char *signal_name, int value);
1359
1360 /* external storage state management */
1361 int _mmcamcorder_manage_external_storage_state(MMHandleType handle, int storage_state);
1362
1363 /* get focus level */
1364 int _mmcamcorder_get_focus_level(MMHandleType handle, int *level);
1365
1366 #ifdef __cplusplus
1367 }
1368 #endif
1369
1370 #endif /* __MM_CAMCORDER_INTERNAL_H__ */