1. Remove build warnings
[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 <pthread.h>
32 #include <semaphore.h>
33
34 #include <mm_types.h>
35 #include <mm_attrs.h>
36 #include <mm_attrs_private.h>
37 #include <mm_message.h>
38 #include <sndfile.h>
39 #include <vconf.h>
40 #include <gst/video/video-format.h>
41
42 #include "mm_camcorder.h"
43 #include "mm_debug.h"
44
45 /* camcorder sub module */
46 #include "mm_camcorder_attribute.h"
47 #include "mm_camcorder_platform.h"
48 #include "mm_camcorder_stillshot.h"
49 #include "mm_camcorder_videorec.h"
50 #include "mm_camcorder_audiorec.h"
51 #include "mm_camcorder_gstcommon.h"
52 #include "mm_camcorder_exifinfo.h"
53 #include "mm_camcorder_util.h"
54 #include "mm_camcorder_configure.h"
55 #include "mm_camcorder_sound.h"
56
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
60
61 /*=======================================================================================
62 | MACRO DEFINITIONS                                                                     |
63 ========================================================================================*/
64 #define _mmcam_dbg_verb(fmt, args...)  debug_verbose (" "fmt"\n", ##args);
65 #define _mmcam_dbg_log(fmt, args...)   debug_log (" "fmt"\n", ##args);
66 #define _mmcam_dbg_warn(fmt, args...)  debug_warning (" "fmt"\n", ##args);
67 #define _mmcam_dbg_err(fmt, args...)   debug_error (" "fmt"\n", ##args);
68 #define _mmcam_dbg_crit(fmt, args...)  debug_critical (" "fmt"\n", ##args);
69
70 /**
71  *      Macro for checking validity and debugging
72  */
73 #define mmf_return_if_fail( expr )      \
74         if( expr ){}                                    \
75         else                                            \
76         {                                                       \
77                 _mmcam_dbg_err( "failed [%s]", #expr);  \
78                 return;                                         \
79         };
80
81 /**
82  *      Macro for checking validity and debugging
83  */
84 #define mmf_return_val_if_fail( expr, val )     \
85         if( expr ){}                                    \
86         else                                            \
87         {                                                       \
88                 _mmcam_dbg_err("failed [%s]", #expr);   \
89                 return( val );                                          \
90         };
91
92 #ifndef ARRAY_SIZE
93 /**
94  *      Macro for getting array size
95  */
96 #define ARRAY_SIZE(a) (sizeof((a)) / sizeof((a)[0]))
97 #endif
98
99 /* gstreamer element creation macro */
100 #define _MMCAMCORDER_PIPELINE_MAKE(sub_context, element, eid, name /*char* */, err) \
101         if (element[eid].gst != NULL) { \
102                 _mmcam_dbg_err("The element(Pipeline) is existed. element_id=[%d], name=[%s]", eid, name); \
103                 gst_object_unref(element[eid].gst); \
104         } \
105         element[eid].id = eid; \
106         element[eid].gst = gst_pipeline_new(name); \
107         if (element[eid].gst == NULL) { \
108                 _mmcam_dbg_err("Pipeline creation fail. element_id=[%d], name=[%s]", eid, name); \
109                 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
110                 goto pipeline_creation_error; \
111         } else { \
112                 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
113         }
114
115 #define _MMCAMCORDER_BIN_MAKE(sub_context, element, eid, name /*char* */, err) \
116         if (element[eid].gst != NULL) { \
117                 _mmcam_dbg_err("The element(Bin) is existed. element_id=[%d], name=[%s]", eid, name); \
118                 gst_object_unref(element[eid].gst); \
119         } \
120         element[eid].id = eid; \
121         element[eid].gst = gst_bin_new(name); \
122         if (element[eid].gst == NULL) { \
123                 _mmcam_dbg_err("Bin creation fail. element_id=[%d], name=[%s]\n", eid, name); \
124                 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
125                 goto pipeline_creation_error; \
126         } else { \
127                 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
128         }
129
130 #define _MMCAMCORDER_ELEMENT_MAKE(sub_context, element, eid, name /*char* */, nickname /*char* */, elist, err) \
131         if (element[eid].gst != NULL) { \
132                 _mmcam_dbg_err("The element is existed. element_id=[%d], name=[%s]", eid, name); \
133                 gst_object_unref(element[eid].gst); \
134         } \
135         element[eid].gst = gst_element_factory_make(name, nickname); \
136         if (element[eid].gst == NULL) { \
137                 _mmcam_dbg_err("Element creation fail. element_id=[%d], name=[%s]", eid, name); \
138                 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
139                 goto pipeline_creation_error; \
140         } else { \
141                 _mmcam_dbg_log("Element creation done. element_id=[%d], name=[%s]", eid, name); \
142                 element[eid].id = eid; \
143                 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
144                 err = MM_ERROR_NONE; \
145         } \
146         elist = g_list_append(elist, &(element[eid]));
147
148 #define _MMCAMCORDER_ELEMENT_MAKE_IGNORE_ERROR(sub_context, element, eid, name /*char* */, nickname /*char* */, elist) \
149         if (element[eid].gst != NULL) { \
150                 _mmcam_dbg_err("The element is existed. element_id=[%d], name=[%s]", eid, name); \
151                 gst_object_unref(element[eid].gst); \
152         } \
153         element[eid].gst = gst_element_factory_make(name, nickname); \
154         if (element[eid].gst == NULL) { \
155                 _mmcam_dbg_err("Element creation fail. element_id=[%d], name=[%s], but keep going...", eid, name); \
156         } else { \
157                 _mmcam_dbg_log("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                 elist = g_list_append(elist, &(element[eid])); \
161         }
162
163 #define _MMCAMCORDER_ENCODEBIN_ELMGET(sub_context, eid, name /*char* */, err) \
164         if (sub_context->encode_element[eid].gst != NULL) { \
165                 _mmcam_dbg_err("The element is existed. element_id=[%d], name=[%s]", eid, name); \
166                 gst_object_unref(sub_context->encode_element[eid].gst); \
167         } \
168         sub_context->encode_element[eid].id = eid; \
169         g_object_get(G_OBJECT(sub_context->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst), name, &(sub_context->encode_element[eid].gst), NULL); \
170         if (sub_context->encode_element[eid].gst == NULL) { \
171                 _mmcam_dbg_err("Encode Element get fail. element_id=[%d], name=[%s]", eid, name); \
172                 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
173                 goto pipeline_creation_error; \
174         } else{ \
175                 gst_object_unref(sub_context->encode_element[eid].gst); \
176                 g_object_weak_ref(G_OBJECT(sub_context->encode_element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
177         }
178
179 /* GStreamer element remove macro */
180 #define _MMCAMCORDER_ELEMENT_REMOVE(element, eid) \
181         if (element[eid].gst != NULL) { \
182                 gst_object_unref(element[eid].gst); \
183         }
184
185 #define _MM_GST_ELEMENT_LINK_MANY       gst_element_link_many
186 #define _MM_GST_ELEMENT_LINK            gst_element_link
187 #define _MM_GST_PAD_LINK                gst_pad_link
188
189 #define _MM_GST_PAD_LINK_UNREF(srcpad, sinkpad, err, if_fail_goto)\
190 {\
191         GstPadLinkReturn ret = _MM_GST_PAD_LINK(srcpad, sinkpad);\
192         if (ret != GST_PAD_LINK_OK) {\
193                 GstObject *src_parent = gst_pad_get_parent(srcpad);\
194                 GstObject *sink_parent = gst_pad_get_parent(sinkpad);\
195                 char *src_name = NULL;\
196                 char *sink_name = NULL;\
197                 g_object_get((GObject *)src_parent, "name", &src_name, NULL);\
198                 g_object_get((GObject *)sink_parent, "name", &sink_name, NULL);\
199                 _mmcam_dbg_err("src[%s] - sink[%s] link failed", src_name, sink_name);\
200                 gst_object_unref(src_parent); src_parent = NULL;\
201                 gst_object_unref(sink_parent); sink_parent = NULL;\
202                 if (src_name) {\
203                         free(src_name); src_name = NULL;\
204                 }\
205                 if (sink_name) {\
206                         free(sink_name); sink_name = NULL;\
207                 }\
208                 gst_object_unref(srcpad); srcpad = NULL;\
209                 gst_object_unref(sinkpad); sinkpad = NULL;\
210                 err = MM_ERROR_CAMCORDER_GST_LINK;\
211                 goto if_fail_goto;\
212         }\
213         gst_object_unref(srcpad); srcpad = NULL;\
214         gst_object_unref(sinkpad); sinkpad = NULL;\
215 }
216
217 #define _MM_GST_PAD_UNLINK_UNREF( srcpad, sinkpad) \
218         if (srcpad && sinkpad) { \
219                 gst_pad_unlink(srcpad, sinkpad); \
220         } else { \
221                 _mmcam_dbg_warn("some pad(srcpad:%p,sinkpad:%p) is NULL", srcpad, sinkpad); \
222         } \
223         if (srcpad) { \
224                 gst_object_unref(srcpad); srcpad = NULL; \
225         } \
226         if (sinkpad) { \
227                 gst_object_unref(sinkpad); sinkpad = NULL; \
228         }
229
230 #define _MMCAMCORDER_STATE_SET_COUNT            3               /* checking interval */
231 #define _MMCAMCORDER_STATE_CHECK_TOTALTIME      5000000L        /* total wating time for state change */
232 #define _MMCAMCORDER_STATE_CHECK_INTERVAL       5000            /* checking interval */
233
234 /**
235  * Default videosink type
236  */
237 #define _MMCAMCORDER_DEFAULT_VIDEOSINK_TYPE     "VideosinkElementX"
238
239 /**
240  * Default recording motion rate
241  */
242 #define _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE   1.0
243
244 /**
245  * Total level count of manual focus */
246 #define _MMFCAMCORDER_FOCUS_TOTAL_LEVEL         8
247
248 /**
249  *      File name length limit
250  */
251 #define _MMCamcorder_FILENAME_LEN       (512)
252
253 /**
254  *      Minimum integer value
255  */
256 #define _MMCAMCORDER_MIN_INT    (INT_MIN)
257
258 /**
259  *      Maximum integer value
260  */
261 #define _MMCAMCORDER_MAX_INT    (INT_MAX)
262
263 /**
264  *      Minimum double value
265  */
266 #define _MMCAMCORDER_MIN_DOUBLE (DBL_MIN)
267
268 /**
269  *      Maximum integer value
270  */
271 #define _MMCAMCORDER_MAX_DOUBLE (DBL_MAX)
272
273 /**
274  *      Audio timestamp margin (msec)
275  */
276 #define _MMCAMCORDER_AUDIO_TIME_MARGIN (300)
277
278 /**
279  *      Functions related with LOCK and WAIT
280  */
281 #define _MMCAMCORDER_CAST_MTSAFE(handle)                        (((mmf_camcorder_t*)handle)->mtsafe)
282 #define _MMCAMCORDER_LOCK_FUNC(mutex)                           pthread_mutex_lock(&mutex)
283 #define _MMCAMCORDER_TRYLOCK_FUNC(mutex)                        (!pthread_mutex_trylock(&mutex))
284 #define _MMCAMCORDER_UNLOCK_FUNC(mutex)                         pthread_mutex_unlock(&mutex)
285
286 #define _MMCAMCORDER_GET_LOCK(handle)                           (_MMCAMCORDER_CAST_MTSAFE(handle).lock)
287 #define _MMCAMCORDER_LOCK(handle)                               _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_LOCK(handle))
288 #define _MMCAMCORDER_TRYLOCK(handle)                            _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_LOCK(handle))
289 #define _MMCAMCORDER_UNLOCK(handle)                             _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_LOCK(handle))
290
291 /* for command */
292 #define _MMCAMCORDER_GET_CMD_LOCK(handle)                       (_MMCAMCORDER_CAST_MTSAFE(handle).cmd_lock)
293 #define _MMCAMCORDER_LOCK_CMD(handle)                           _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_CMD_LOCK(handle))
294 #define _MMCAMCORDER_TRYLOCK_CMD(handle)                        _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_CMD_LOCK(handle))
295 #define _MMCAMCORDER_UNLOCK_CMD(handle)                         _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_CMD_LOCK(handle))
296
297 /* for ASM */
298 #define _MMCAMCORDER_GET_ASM_LOCK(handle)                       (_MMCAMCORDER_CAST_MTSAFE(handle).asm_lock)
299 #define _MMCAMCORDER_LOCK_ASM(handle)                           _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_ASM_LOCK(handle))
300 #define _MMCAMCORDER_TRYLOCK_ASM(handle)                        _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_ASM_LOCK(handle))
301 #define _MMCAMCORDER_UNLOCK_ASM(handle)                         _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_ASM_LOCK(handle))
302
303 /* for state change */
304 #define _MMCAMCORDER_GET_STATE_LOCK(handle)                     (_MMCAMCORDER_CAST_MTSAFE(handle).state_lock)
305 #define _MMCAMCORDER_LOCK_STATE(handle)                         _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_STATE_LOCK(handle))
306 #define _MMCAMCORDER_TRYLOCK_STATE(handle)                      _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_STATE_LOCK(handle))
307 #define _MMCAMCORDER_UNLOCK_STATE(handle)                       _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_STATE_LOCK(handle))
308
309 /* for gstreamer state change */
310 #define _MMCAMCORDER_GET_GST_STATE_LOCK(handle)                 (_MMCAMCORDER_CAST_MTSAFE(handle).gst_state_lock)
311 #define _MMCAMCORDER_LOCK_GST_STATE(handle)                     _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_GST_STATE_LOCK(handle))
312 #define _MMCAMCORDER_TRYLOCK_GST_STATE(handle)                  _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_GST_STATE_LOCK(handle))
313 #define _MMCAMCORDER_UNLOCK_GST_STATE(handle)                   _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_GST_STATE_LOCK(handle))
314
315 #define _MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle)          (_MMCAMCORDER_CAST_MTSAFE(handle).gst_encode_state_lock)
316 #define _MMCAMCORDER_LOCK_GST_ENCODE_STATE(handle)              _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle))
317 #define _MMCAMCORDER_TRYLOCK_GST_ENCODE_STATE(handle)           _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle))
318 #define _MMCAMCORDER_UNLOCK_GST_ENCODE_STATE(handle)            _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle))
319
320 /* for setting/calling callback */
321 #define _MMCAMCORDER_GET_MESSAGE_CALLBACK_LOCK(handle)      (_MMCAMCORDER_CAST_MTSAFE(handle).message_cb_lock)
322 #define _MMCAMCORDER_LOCK_MESSAGE_CALLBACK(handle)          _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_MESSAGE_CALLBACK_LOCK(handle))
323 #define _MMCAMCORDER_TRYLOCK_MESSAGE_CALLBACK(handle)       _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_MESSAGE_CALLBACK_LOCK(handle))
324 #define _MMCAMCORDER_UNLOCK_MESSAGE_CALLBACK(handle)        _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_MESSAGE_CALLBACK_LOCK(handle))
325
326 #define _MMCAMCORDER_GET_VCAPTURE_CALLBACK_LOCK(handle)     (_MMCAMCORDER_CAST_MTSAFE(handle).vcapture_cb_lock)
327 #define _MMCAMCORDER_LOCK_VCAPTURE_CALLBACK(handle)         _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_VCAPTURE_CALLBACK_LOCK(handle))
328 #define _MMCAMCORDER_TRYLOCK_VCAPTURE_CALLBACK(handle)      _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_VCAPTURE_CALLBACK_LOCK(handle))
329 #define _MMCAMCORDER_UNLOCK_VCAPTURE_CALLBACK(handle)       _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_VCAPTURE_CALLBACK_LOCK(handle))
330
331 #define _MMCAMCORDER_GET_VSTREAM_CALLBACK_LOCK(handle)      (_MMCAMCORDER_CAST_MTSAFE(handle).vstream_cb_lock)
332 #define _MMCAMCORDER_LOCK_VSTREAM_CALLBACK(handle)          _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_VSTREAM_CALLBACK_LOCK(handle))
333 #define _MMCAMCORDER_TRYLOCK_VSTREAM_CALLBACK(handle)       _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_VSTREAM_CALLBACK_LOCK(handle))
334 #define _MMCAMCORDER_UNLOCK_VSTREAM_CALLBACK(handle)        _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_VSTREAM_CALLBACK_LOCK(handle))
335
336 #define _MMCAMCORDER_GET_ASTREAM_CALLBACK_LOCK(handle)      (_MMCAMCORDER_CAST_MTSAFE(handle).astream_cb_lock)
337 #define _MMCAMCORDER_LOCK_ASTREAM_CALLBACK(handle)          _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_ASTREAM_CALLBACK_LOCK(handle))
338 #define _MMCAMCORDER_TRYLOCK_ASTREAM_CALLBACK(handle)       _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_ASTREAM_CALLBACK_LOCK(handle))
339 #define _MMCAMCORDER_UNLOCK_ASTREAM_CALLBACK(handle)        _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_ASTREAM_CALLBACK_LOCK(handle))
340
341 /**
342  * Caster of main handle (camcorder)
343  */
344 #define MMF_CAMCORDER(h) (mmf_camcorder_t *)(h)
345
346 /**
347  * Caster of subcontext
348  */
349 #define MMF_CAMCORDER_SUBCONTEXT(h) (((mmf_camcorder_t *)(h))->sub_context)
350
351 /* LOCAL CONSTANT DEFINITIONS */
352 /**
353  * Total Numbers of Attribute values.
354  * If you increase any enum of attribute values, you also have to increase this.
355  */
356 #define MM_CAMCORDER_MODE_NUM                   3       /**< Number of mode type */
357 #define MM_CAMCORDER_COLOR_TONE_NUM             30      /**< Number of color-tone modes */
358 #define MM_CAMCORDER_WHITE_BALANCE_NUM          10      /**< Number of WhiteBalance modes*/
359 #define MM_CAMCORDER_SCENE_MODE_NUM             16      /**< Number of program-modes */
360 #define MM_CAMCORDER_FOCUS_MODE_NUM             6       /**< Number of focus mode*/
361 #define MM_CAMCORDER_AUTO_FOCUS_NUM             5       /**< Total count of auto focus type*/
362 #define MM_CAMCORDER_FOCUS_STATE_NUM            4       /**< Number of focus state */
363 #define MM_CAMCORDER_ISO_NUM                    10      /**< Number of ISO */
364 #define MM_CAMCORDER_AUTO_EXPOSURE_NUM          9       /**< Number of Auto exposure type */
365 #define MM_CAMCORDER_WDR_NUM                    3       /**< Number of wide dynamic range */
366 #define MM_CAMCORDER_FLIP_NUM                   4       /**< Number of Filp mode */
367 #define MM_CAMCORDER_ROTATION_NUM               4       /**< Number of Rotation mode */
368 #define MM_CAMCORDER_AHS_NUM                    4       /**< Number of anti-handshake */
369 #define MM_CAMCORDER_VIDEO_STABILIZATION_NUM    2       /**< Number of video stabilization */
370 #define MM_CAMCORDER_HDR_CAPTURE_NUM            3       /**< Number of HDR capture mode */
371 #define MM_CAMCORDER_GEOMETRY_METHOD_NUM        5       /**< Number of geometry method */
372 #define MM_CAMCORDER_TAG_ORT_NUM                8       /**< Number of tag orientation */
373 #define MM_CAMCORDER_STROBE_MODE_NUM            8       /**< Number of strobe mode type */
374 #define MM_CAMCORDER_STROBE_CONTROL_NUM         3       /**< Number of strobe control type */
375 #define MM_CAMCORDER_DETECT_MODE_NUM            2       /**< Number of detect mode type */
376
377
378 /*=======================================================================================
379 | ENUM DEFINITIONS                                                                      |
380 ========================================================================================*/
381 /**
382  * Command for Camcorder.
383  */
384 enum {
385         /* Command for Video/Audio recording */
386         _MMCamcorder_CMD_RECORD,
387         _MMCamcorder_CMD_PAUSE,
388         _MMCamcorder_CMD_CANCEL,
389         _MMCamcorder_CMD_COMMIT,
390
391         /* Command for Image capture */
392         _MMCamcorder_CMD_CAPTURE,
393
394         /* Command for Preview(Video/Image only effective) */
395         _MMCamcorder_CMD_PREVIEW_START,
396         _MMCamcorder_CMD_PREVIEW_STOP,
397 };
398
399 /**
400  * Still-shot type
401  */
402 enum {
403         _MMCamcorder_SINGLE_SHOT,
404         _MMCamcorder_MULTI_SHOT,
405 };
406
407 /**
408  * Enumerations for manual focus direction.
409  * If focusing mode is not "MM_CAMCORDER_AF_MODE_MANUAL", this value will be ignored.
410  */
411 enum MMCamcorderMfLensDir {
412         MM_CAMCORDER_MF_LENS_DIR_FORWARD = 1,   /**< Focus direction to forward */
413         MM_CAMCORDER_MF_LENS_DIR_BACKWARD,      /**< Focus direction to backward */
414         MM_CAMCORDER_MF_LENS_DIR_NUM,           /**< Total number of the directions */
415 };
416
417 /**
418  * Camcorder Pipeline's Element name.
419  * @note index of element.
420  */
421 typedef enum {
422         _MMCAMCORDER_NONE = (-1),
423
424         /* Main Pipeline Element */
425         _MMCAMCORDER_MAIN_PIPE = 0x00,
426
427         /* Pipeline element of Video input */
428         _MMCAMCORDER_VIDEOSRC_SRC,
429         _MMCAMCORDER_VIDEOSRC_FILT,
430         _MMCAMCORDER_VIDEOSRC_CLS_QUE,
431         _MMCAMCORDER_VIDEOSRC_CLS,
432         _MMCAMCORDER_VIDEOSRC_CLS_FILT,
433         _MMCAMCORDER_VIDEOSRC_QUE,
434         _MMCAMCORDER_VIDEOSRC_DECODE,
435
436         /* Pipeline element of Video output */
437         _MMCAMCORDER_VIDEOSINK_QUE,
438         _MMCAMCORDER_VIDEOSINK_CLS,
439         _MMCAMCORDER_VIDEOSINK_SINK,
440
441         _MMCAMCORDER_PIPELINE_ELEMENT_NUM,
442 } _MMCAMCORDER_PREVIEW_PIPELINE_ELELMENT;
443
444 /**
445  * Camcorder Pipeline's Element name.
446  * @note index of element.
447  */
448 typedef enum {
449         _MMCAMCORDER_ENCODE_NONE = (-1),
450
451         /* Main Pipeline Element */
452         _MMCAMCORDER_ENCODE_MAIN_PIPE = 0x00,
453
454         /* Pipeline element of Audio input */
455         _MMCAMCORDER_AUDIOSRC_BIN,
456         _MMCAMCORDER_AUDIOSRC_SRC,
457         _MMCAMCORDER_AUDIOSRC_FILT,
458         _MMCAMCORDER_AUDIOSRC_QUE,
459         _MMCAMCORDER_AUDIOSRC_CONV,
460         _MMCAMCORDER_AUDIOSRC_VOL,
461
462         /* Pipeline element of Encodebin */
463         _MMCAMCORDER_ENCSINK_BIN,
464         _MMCAMCORDER_ENCSINK_SRC,
465         _MMCAMCORDER_ENCSINK_FILT,
466         _MMCAMCORDER_ENCSINK_ENCBIN,
467         _MMCAMCORDER_ENCSINK_AQUE,
468         _MMCAMCORDER_ENCSINK_CONV,
469         _MMCAMCORDER_ENCSINK_AENC,
470         _MMCAMCORDER_ENCSINK_AENC_QUE,
471         _MMCAMCORDER_ENCSINK_VQUE,
472         _MMCAMCORDER_ENCSINK_VCONV,
473         _MMCAMCORDER_ENCSINK_VENC,
474         _MMCAMCORDER_ENCSINK_VENC_QUE,
475         _MMCAMCORDER_ENCSINK_ITOG,
476         _MMCAMCORDER_ENCSINK_ICROP,
477         _MMCAMCORDER_ENCSINK_ISCALE,
478         _MMCAMCORDER_ENCSINK_IFILT,
479         _MMCAMCORDER_ENCSINK_IQUE,
480         _MMCAMCORDER_ENCSINK_IENC,
481         _MMCAMCORDER_ENCSINK_MUX,
482         _MMCAMCORDER_ENCSINK_SINK,
483
484         _MMCAMCORDER_ENCODE_PIPELINE_ELEMENT_NUM,
485 } _MMCAMCORDER_ENCODE_PIPELINE_ELELMENT;
486
487 typedef enum {
488         _MMCAMCORDER_TASK_THREAD_STATE_NONE,
489         _MMCAMCORDER_TASK_THREAD_STATE_SOUND_PLAY_START,
490         _MMCAMCORDER_TASK_THREAD_STATE_ENCODE_PIPE_CREATE,
491         _MMCAMCORDER_TASK_THREAD_STATE_EXIT,
492 } _MMCamcorderTaskThreadState;
493
494 /**
495  * System state change cause
496  */
497 typedef enum {
498         _MMCAMCORDER_STATE_CHANGE_NORMAL = 0,
499         _MMCAMCORDER_STATE_CHANGE_BY_ASM,
500 } _MMCamcorderStateChange;
501
502
503 /*=======================================================================================
504 | STRUCTURE DEFINITIONS                                                                 |
505 ========================================================================================*/
506 /**
507  * MMCamcorder Gstreamer Element
508  */
509 typedef struct {
510         unsigned int id;                /**< Gstreamer piplinem element name */
511         GstElement *gst;                /**< Gstreamer element */
512 } _MMCamcorderGstElement;
513
514 /**
515  * MMCamcorder information for KPI measurement
516  */
517 typedef struct {
518         int current_fps;                /**< current fps of this second */
519         int average_fps;                /**< average fps  */
520         unsigned int video_framecount;  /**< total number of video frame */
521         unsigned int last_framecount;   /**< total number of video frame in last measurement */
522         struct timeval init_video_time; /**< time when start to measure */
523         struct timeval last_video_time; /**< last measurement time */
524 } _MMCamcorderKPIMeasure;
525
526 /**
527  * MMCamcorder information for Multi-Thread Safe
528  */
529 typedef struct {
530         pthread_mutex_t lock;                   /**< Mutex (for general use) */
531         pthread_mutex_t cmd_lock;               /**< Mutex (for command) */
532         pthread_mutex_t asm_lock;               /**< Mutex (for ASM) */
533         pthread_mutex_t state_lock;             /**< Mutex (for state change) */
534         pthread_mutex_t gst_state_lock;         /**< Mutex (for gst pipeline state change) */
535         pthread_mutex_t gst_encode_state_lock;  /**< Mutex (for gst encode pipeline state change) */
536         pthread_mutex_t message_cb_lock;                /**< Mutex (for message callback) */
537         pthread_mutex_t vcapture_cb_lock;       /**< Mutex (for video capture callback) */
538         pthread_mutex_t vstream_cb_lock;                /**< Mutex (for video stream callback) */
539         pthread_mutex_t astream_cb_lock;                /**< Mutex (for audio stream callback) */
540 } _MMCamcorderMTSafe;
541
542
543 /**
544  * MMCamcorder Sub Context
545  */
546 typedef struct {
547         bool isMaxsizePausing;                  /**< Because of size limit, pipeline is paused. */
548         bool isMaxtimePausing;                  /**< Because of time limit, pipeline is paused. */
549         int element_num;                        /**< count of element */
550         int encode_element_num;                 /**< count of encode element */
551         int cam_stability_count;                /**< camsensor stability count. the count of frame will drop */
552         GstClockTime pipeline_time;             /**< current time of Gstreamer Pipeline */
553         GstClockTime pause_time;                /**< amount of time while pipeline is in PAUSE state.*/
554         GstClockTime stillshot_time;            /**< pipeline time of capturing moment*/
555         gboolean is_modified_rate;              /**< whether recording motion rate is modified or not */
556         gboolean error_occurs;                  /**< flag for error */
557         int error_code;                         /**< error code for internal gstreamer error */
558         gboolean ferror_send;                   /**< file write/seek error **/
559         guint ferror_count;                     /**< file write/seek error count **/
560         GstClockTime previous_slot_time;
561         int display_interval;                   /**< This value is set as 'GST_SECOND / display FPS' */
562         gboolean bget_eos;                      /**< Whether getting EOS */
563         gboolean bencbin_capture;               /**< Use Encodebin for capturing */
564         gboolean audio_disable;                 /**< whether audio is disabled or not when record */
565         int videosrc_rotate;                    /**< rotate of videosrc */
566
567         /* For dropping video frame when start recording */
568         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. */
569         int pass_first_vframe;                  /**< When this value is bigger than zero, MSL won't drop video frame though "drop_vframe" is bigger then zero. */
570
571         /* INI information */
572         unsigned int fourcc;                    /**< Get fourcc value of camera INI file */
573         _MMCamcorderImageInfo *info_image;      /**< extra information for image capture */
574         _MMCamcorderVideoInfo *info_video;      /**< extra information for video recording */
575         _MMCamcorderAudioInfo *info_audio;      /**< extra information for audio recording */
576
577         _MMCamcorderGstElement *element;        /**< array of preview element */
578         _MMCamcorderGstElement *encode_element; /**< array of encode element */
579         _MMCamcorderKPIMeasure kpi;             /**< information related with performance measurement */
580
581         type_element *VideosinkElement;         /**< configure data of videosink element */
582         type_element *VideoconvertElement;      /**< configure data of videoconvert element */
583         gboolean SensorEncodedCapture;          /**< whether camera sensor support encoded image capture */
584         gboolean internal_encode;               /**< whether use internal encoding function */
585 } _MMCamcorderSubContext;
586
587 /**
588   * _MMCamcorderContext
589   */
590 typedef struct mmf_camcorder {
591         /* information */
592         int type;               /**< mmcamcorder_mode_type */
593         int device_type;        /**< device type */
594         int state;              /**< state of camcorder */
595         int target_state;       /**< Target state that want to set. This is a flag that
596                                    * stands for async state changing. If this value differ from state,
597                                    * it means state is changing now asychronously. */
598
599         /* handles */
600         MMHandleType attributes;               /**< Attribute handle */
601         _MMCamcorderSubContext *sub_context;   /**< sub context */
602         mm_exif_info_t *exif_info;             /**< EXIF */
603         GList *buffer_probes;                  /**< a list of buffer probe handle */
604         GList *event_probes;                   /**< a list of event probe handle */
605         GList *signals;                        /**< a list of signal handle */
606         GList *msg_data;                       /**< a list of msg data */
607         camera_conf *conf_main;                /**< Camera configure Main structure */
608         camera_conf *conf_ctrl;                /**< Camera configure Control structure */
609         guint pipeline_cb_event_id;            /**< Event source ID of pipeline message callback */
610         guint encode_pipeline_cb_event_id;     /**< Event source ID of encode pipeline message callback */
611         guint setting_event_id;                /**< Event source ID of attributes setting to sensor */
612         SOUND_INFO snd_info;                   /**< Sound handle for multishot capture */
613
614         /* callback handlers */
615         MMMessageCallback msg_cb;                               /**< message callback */
616         void *msg_cb_param;                                     /**< message callback parameter */
617         mm_camcorder_video_stream_callback vstream_cb;          /**< Video stream callback */
618         void *vstream_cb_param;                                 /**< Video stream callback parameter */
619         mm_camcorder_audio_stream_callback astream_cb;          /**< Audio stream callback */
620         void *astream_cb_param;                                 /**< Audio stream callback parameter */
621         mm_camcorder_video_capture_callback vcapture_cb;        /**< Video capture callback */
622         void *vcapture_cb_param;                                /**< Video capture callback parameter */
623         int (*command)(MMHandleType, int);                      /**< camcorder's command */
624
625         /* etc */
626         mm_cam_attr_construct_info *cam_attrs_const_info;       /**< attribute info */
627         conf_info_table* conf_main_info_table[CONFIGURE_CATEGORY_MAIN_NUM]; /** configure info table - MAIN category */
628         conf_info_table* conf_ctrl_info_table[CONFIGURE_CATEGORY_CTRL_NUM]; /** configure info table - CONTROL category */
629         int conf_main_category_size[CONFIGURE_CATEGORY_MAIN_NUM]; /** configure info table size - MAIN category */
630         int conf_ctrl_category_size[CONFIGURE_CATEGORY_CTRL_NUM]; /** configure info table size - CONTROL category */
631         _MMCamcorderMTSafe mtsafe;                              /**< Thread safe */
632         int state_change_by_system;                             /**< MSL changes its state by itself because of system */
633         pthread_mutex_t sound_lock;                             /**< Capture sound mutex */
634         pthread_cond_t sound_cond;                              /**< Capture sound cond */
635         pthread_mutex_t restart_preview_lock;                   /**< Capture sound mutex */
636         int use_zero_copy_format;                               /**< Whether use zero copy format for camera input */
637         int support_media_packet_preview_cb;                   /**< Whether support zero copy format for camera input */
638         int shutter_sound_policy;                               /**< shutter sound policy */
639         int brightness_default;                                 /**< default value of brightness */
640         int brightness_step_denominator;                        /**< denominator of brightness bias step */
641         int support_zsl_capture;                                /**< support Zero Shutter Lag capture */
642         char *model_name;                                       /**< model name from system info */
643         char *software_version;                                 /**< software_version from system info */
644         int capture_sound_count;                                /**< count for capture sound */
645
646         _MMCamcorderInfoConverting caminfo_convert[CAMINFO_CONVERT_NUM];        /**< converting structure of camera info */
647         _MMCamcorderEnumConvert enum_conv[ENUM_CONVERT_NUM];                    /**< enum converting list that is modified by ini info */
648
649         gboolean capture_in_recording;                          /**< Flag for capture while recording */
650
651         /* task thread */
652         pthread_t task_thread;                                  /**< thread for task */
653         pthread_mutex_t task_thread_lock;                       /**< mutex for task thread */
654         pthread_cond_t task_thread_cond;                        /**< cond for task thread */
655         _MMCamcorderTaskThreadState task_thread_state;          /**< state of task thread */
656
657         int reserved[4];                                        /**< reserved */
658 } mmf_camcorder_t;
659
660 /*=======================================================================================
661 | EXTERN GLOBAL VARIABLE                                                                |
662 ========================================================================================*/
663
664 /*=======================================================================================
665 | GLOBAL FUNCTION PROTOTYPES                                                            |
666 ========================================================================================*/
667 /**
668  *      This function creates camcorder for capturing still image and recording.
669  *
670  *      @param[out]     handle          Specifies the camcorder  handle
671  *      @param[in]      info            Preset information of camcorder
672  *      @return         This function returns zero on success, or negative value with error code.
673  *      @remarks        When this function calls successfully, camcorder  handle will be filled with a @n
674  *                      valid value and the state of  the camcorder  will become MM_CAMCORDER_STATE_NULL.@n
675  *                      Note that  it's not ready to working camcorder. @n
676  *                      You should call mmcamcorder_realize before starting camcorder.
677  *      @see            _mmcamcorder_create
678  */
679 int _mmcamcorder_create(MMHandleType *handle, MMCamPreset *info);
680
681 /**
682  *      This function destroys instance of camcorder.
683  *
684  *      @param[in]      hcamcorder      Specifies the camcorder  handle
685  *      @return         This function returns zero on success, or negative value with error code.
686  *      @see            _mmcamcorder_create
687  */
688 int _mmcamcorder_destroy(MMHandleType hcamcorder);
689
690 /**
691  *      This function allocates memory for camcorder.
692  *
693  *      @param[in]      hcamcorder      Specifies the camcorder  handle
694  *      @return         This function returns zero on success, or negative value with error code.
695  *      @remarks        This function can  be called successfully when current state is MM_CAMCORDER_STATE_NULL @n
696  *                      and  the state of the camcorder  will become MM_CAMCORDER_STATE_READY. @n
697  *                      Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
698  *      @see            _mmcamcorder_unrealize
699  *      @pre            MM_CAMCORDER_STATE_NULL
700  *      @post           MM_CAMCORDER_STATE_READY
701  */
702 int _mmcamcorder_realize(MMHandleType hcamcorder);
703
704 /**
705  *      This function free allocated memory for camcorder.
706  *
707  *      @param[in]      hcamcorder      Specifies the camcorder  handle
708  *      @return         This function returns zero on success, or negative value with error code.
709  *      @remarks        This function release all resources which are allocated for the camcorder engine.@n
710  *                      This function can  be called successfully when current state is MM_CAMCORDER_STATE_READY and  @n
711  *                      the state of the camcorder  will become MM_CAMCORDER_STATE_NULL. @n
712  *                      Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
713  *      @see            _mmcamcorder_realize
714  *      @pre            MM_CAMCORDER_STATE_READY
715  *      @post           MM_CAMCORDER_STATE_NULL
716  */
717 int _mmcamcorder_unrealize(MMHandleType hcamcorder);
718
719 /**
720  *      This function is to start previewing.
721  *
722  *      @param[in]      hcamcorder      Specifies the camcorder  handle
723  *      @return         This function returns zero on success, or negative value with error code.
724  *      @remarks        This function can  be called successfully when current state is MM_CAMCORDER_STATE_READY and  @n
725  *                      the state of the camcorder  will become MM_CAMCORDER_STATE_PREPARE. @n
726  *                      Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
727  *      @see            _mmcamcorder_stop
728  */
729 int _mmcamcorder_start(MMHandleType hcamcorder);
730
731 /**
732  *      This function is to stop previewing.
733  *
734  *      @param[in]      hcamcorder      Specifies the camcorder  handle
735  *      @return         This function returns zero on success, or negative value with error code.
736  *      @remarks        This function can  be called successfully when current state is MM_CAMCORDER_STATE_PREPARE and  @n
737  *                      the state of the camcorder  will become MM_CAMCORDER_STATE_READY.@n
738  *                      Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
739  *      @see            _mmcamcorder_start
740  */
741 int _mmcamcorder_stop(MMHandleType hcamcorder);
742
743 /**
744  *      This function to start capturing of still images.
745  *
746  *      @param[in]      hcamcorder      Specifies the camcorder  handle.
747  *      @return         This function returns zero on success, or negative value with error code.
748  *      @remarks        This function can  be called successfully when current state is MM_CAMCORDER_STATE_PREPARE and @n
749  *                      the state of the camcorder  will become MM_CAMCORDER_STATE_CAPTURING. @n
750  *                      Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
751  *      @see            _mmcamcorder_capture_stop
752  */
753 int _mmcamcorder_capture_start(MMHandleType hcamcorder);
754
755 /**
756  *      This function is to stop capturing still images.
757  *
758  *      @param[in]      hcamcorder      Specifies the camcorder  handle
759  *      @return         This function returns zero on success, or negative value with error code.
760  *      @remarks        This function can  be called successfully when current state is MM_CAMCORDER_STATE_CAPTURING and @n
761  *                      the state of the camcorder  will become MM_CAMCORDER_STATE_PREPARE. @n
762  *                      Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
763  *      @see            _mmcamcorder_capture_start
764  */
765 int _mmcamcorder_capture_stop(MMHandleType hcamcorder);
766
767 /**
768  *      This function is to start  video and audio recording.
769  *
770  *      @param[in]      hcamcorder      Specifies the camcorder  handle
771  *      @return         This function returns zero on success, or negative value with error code.
772  *      @remarks        This function can  be called successfully when current state is @n
773  *                      MM_CAMCORDER_STATE_PREPARE or MM_CAMCORDER_STATE_PAUSED and  @n
774  *                      the state of the camcorder  will become MM_CAMCORDER_STATE_RECORDING.@n
775  *                      Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
776  *      @see            _mmcamcorder_pause
777  */
778 int _mmcamcorder_record(MMHandleType hcamcorder);
779
780 /**
781  *      This function is to pause video and audio recording
782  *
783  *      @param[in]      hcamcorder      Specifies the camcorder  handle
784  *      @return         This function returns zero on success, or negative value with error code.
785  *      @remarks        This function can  be called successfully when current state is MM_CAMCORDER_STATE_RECORDING and  @n
786  *                      the  state of the camcorder  will become MM_CAMCORDER_STATE_PAUSED.@n
787  *                      Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.@n
788  *      @see            _mmcamcorder_record
789  */
790 int _mmcamcorder_pause(MMHandleType hcamcorder);
791
792 /**
793  *      This function is to stop video and audio  recording and  save results.
794  *
795  *      @param[in]      hcamcorder      Specifies the camcorder  handle
796  *      @return         This function returns zero on success, or negative value with error code.
797  *      @remarks        This function can  be called successfully when current state is @n
798  *                      MM_CAMCORDER_STATE_PAUSED or MM_CAMCORDER_STATE_RECORDING and  @n
799  *                      the state of the camcorder  will become MM_CAMCORDER_STATE_PREPARE. @n
800  *                      Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION
801  *      @see            _mmcamcorder_cancel
802  */
803 int _mmcamcorder_commit(MMHandleType hcamcorder);
804
805 /**
806  *      This function is to stop video and audio recording and do not save results.
807  *
808  *      @param[in]      hcamcorder      Specifies the camcorder  handle
809  *      @return         This function returns zero on success, or negative value with error code.
810  *      @remarks        This function can  be called successfully when current state is @n
811  *                      MM_CAMCORDER_STATE_PAUSED or MM_CAMCORDER_STATE_RECORDING and  @n
812  *                      the state of the camcorder  will become MM_CAMCORDER_STATE_PREPARE. @n
813  *                      Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
814  *      @see            _mmcamcorder_commit
815  */
816 int _mmcamcorder_cancel(MMHandleType hcamcorder);
817
818 /**
819  *      This function calls after commiting action finished asynchronously. 
820  *      In this function, remaining process , such as state change, happens.
821  *
822  *      @param[in]      hcamcorder      Specifies the camcorder  handle
823  *      @return         This function returns zero on success, or negative value with error code.
824  *      @remarks        This function can  be called successfully when current state is @n
825  *                      MM_CAMCORDER_STATE_PAUSED or MM_CAMCORDER_STATE_RECORDING and  @n
826  *                      the state of the camcorder  will become MM_CAMCORDER_STATE_PREPARE. @n
827  *                      Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
828  *      @see            _mmcamcorder_commit
829  */
830 int _mmcamcorder_commit_async_end(MMHandleType hcamcorder);
831
832 /**
833  *      This function is to set callback for receiving messages from camcorder.
834  *
835  *      @param[in]      hcamcorder      Specifies the camcorder  handle
836  *      @param[in]      callback        Specifies the function pointer of callback function
837  *      @param[in]      user_data       Specifies the user poiner for passing to callback function
838  *
839  *      @return         This function returns zero on success, or negative value with error code.
840  *      @remarks        typedef bool (*mm_message_callback) (int msg, mm_messageType *param, void *user_param);@n
841  *              @n
842  *              typedef union                           @n
843  *              {                                                       @n
844  *                      int code;                               @n
845  *                      struct                                  @n
846  *                      {                                               @n
847  *                              int total;                      @n
848  *                              int elapsed;            @n
849  *                      } time;                                 @n
850  *                      struct                                  @n
851  *                      {                                               @n
852  *                              int previous;           @n
853  *                              int current;                    @n
854  *                      } state;                                        @n
855  *              } mm_message_type;      @n
856  *                                                                      @n
857  *              If a  message value for mm_message_callback is MM_MESSAGE_STATE_CHANGED, @n
858  *              state value in mm_message_type  will be a mmcamcorder_state_type enum value;@n
859  *              @n
860  *              If  a message value for mm_message_callback is MM_MESSAGE_ERROR,  @n
861  *              the code value in mm_message_type will be a mmplayer_error_type enum value;
862  *
863  *      @see            mm_message_type,  mmcamcorder_state_type,  mmcamcorder_error_type
864  */
865 int _mmcamcorder_set_message_callback(MMHandleType hcamcorder,
866                                       MMMessageCallback callback,
867                                       void *user_data);
868
869 /**
870  *      This function is to set callback for video stream.
871  *
872  *      @param[in]      hcamcorder      Specifies the camcorder  handle
873  *      @param[in]      callback        Specifies the function pointer of callback function
874  *      @param[in]      user_data       Specifies the user poiner for passing to callback function
875  *
876  *      @return         This function returns zero on success, or negative value with error code.
877  *      @see            mmcamcorder_error_type
878  */
879 int _mmcamcorder_set_video_stream_callback(MMHandleType hcamcorder,
880                                            mm_camcorder_video_stream_callback callback,
881                                            void *user_data);
882
883 /**
884  *      This function is to set callback for audio stream.
885  *
886  *      @param[in]      hcamcorder      Specifies the camcorder handle
887  *      @param[in]      callback        Specifies the function pointer of callback function
888  *      @param[in]      user_data       Specifies the user poiner for passing to callback function
889  *
890  *      @return         This function returns zero on success, or negative value with error code.
891  *      @see            mmcamcorder_error_type
892  */
893 int _mmcamcorder_set_audio_stream_callback(MMHandleType handle,
894                                            mm_camcorder_audio_stream_callback callback,
895                                            void *user_data);
896
897 /**
898  *      This function is to set callback for video capture.
899  *
900  *      @param[in]      hcamcorder      Specifies the camcorder  handle
901  *      @param[in]      callback        Specifies the function pointer of callback function
902  *      @param[in]      user_data       Specifies the user poiner for passing to callback function
903  *
904  *      @return         This function returns zero on success, or negative value with error code.
905  *      @see            mmcamcorder_error_type
906  */
907 int _mmcamcorder_set_video_capture_callback(MMHandleType hcamcorder,
908                                             mm_camcorder_video_capture_callback callback,
909                                             void *user_data);
910
911 /**
912  *      This function returns current state of camcorder, or negative value with error code.
913  *
914  *      @param[in]      hcamcorder      Specifies the camcorder  handle.
915  *      @return         This function returns current state of camcorder, or negative value with error code.
916  *      @see            mmcamcorder_state_type
917  */
918 int _mmcamcorder_get_current_state(MMHandleType hcamcorder);
919
920 int _mmcamcorder_init_focusing(MMHandleType handle);
921 int _mmcamcorder_adjust_focus(MMHandleType handle, int direction);
922 int _mmcamcorder_adjust_manual_focus(MMHandleType handle, int direction);
923 int _mmcamcorder_adjust_auto_focus(MMHandleType handle);
924 int _mmcamcorder_stop_focusing(MMHandleType handle);
925
926 /**
927  * This function gets current state of camcorder.
928  *
929  * @param       void
930  * @return      This function returns state of current camcorder context
931  * @remarks
932  * @see         _mmcamcorder_set_state()
933  *
934  */
935 int _mmcamcorder_streamer_init(void);
936
937 /**
938  * This function gets current state of camcorder.
939  *
940  * @param       void
941  * @return      This function returns state of current camcorder context
942  * @remarks
943  * @see         _mmcamcorder_set_state()
944  *
945  */
946 int _mmcamcorder_display_init(void);
947
948 /**
949  * This function gets current state of camcorder.
950  *
951  * @param[in]   handle          Handle of camcorder context.
952  * @return      This function returns state of current camcorder context
953  * @remarks
954  * @see         _mmcamcorder_set_state()
955  *
956  */
957 int _mmcamcorder_get_state(MMHandleType handle);
958
959 /**
960  * This function sets new state of camcorder.
961  *
962  * @param[in]   handle          Handle of camcorder context.
963  * @param[in]   state           setting state value of camcorder.
964  * @return      void
965  * @remarks
966  * @see         _mmcamcorder_get_state()
967  *
968  */
969 void _mmcamcorder_set_state(MMHandleType handle, int state);
970
971 /**
972  * This function gets asynchronous status of MSL Camcroder.
973  *
974  * @param[in]   handle          Handle of camcorder context.
975  * @param[in]   target_state    setting target_state value of camcorder.
976  * @return      This function returns asynchrnous state.
977  * @remarks
978  * @see         _mmcamcorder_set_async_state()
979  *
980  */
981 int _mmcamcorder_get_async_state(MMHandleType handle);
982
983 /**
984  * This function allocates structure of subsidiary attributes.
985  *
986  * @param[in]   type            Allocation type of camcorder context.
987  * @return      This function returns structure pointer on success, NULL value on failure.
988  * @remarks
989  * @see         _mmcamcorder_dealloc_subcontext()
990  *
991  */
992 _MMCamcorderSubContext *_mmcamcorder_alloc_subcontext(int type);
993
994 /**
995  * This function releases structure of subsidiary attributes.
996  *
997  * @param[in]   sc              Handle of camcorder subcontext.
998  * @return      void
999  * @remarks
1000  * @see         _mmcamcorder_alloc_subcontext()
1001  *
1002  */
1003 void _mmcamcorder_dealloc_subcontext(_MMCamcorderSubContext *sc);
1004
1005 /**
1006  * This function sets command function according to the type.
1007  *
1008  * @param[in]   handle          Handle of camcorder context.
1009  * @param[in]   type            Allocation type of camcorder context.
1010  * @return      This function returns MM_ERROR_NONE on success, or other values with error code.
1011  * @remarks
1012  * @see         __mmcamcorder_video_command(), __mmcamcorder_audio_command(), __mmcamcorder_image_command()
1013  *
1014  */
1015 int _mmcamcorder_set_functions(MMHandleType handle, int type);
1016
1017 /**
1018  * This function is callback function of main pipeline.
1019  * Once this function is registered with certain pipeline using gst_bus_add_watch(),
1020  * this callback will be called every time when there is upcomming message from pipeline.
1021  * Basically, this function is used as error handling function, now.
1022  *
1023  * @param[in]   bus             pointer of buf that called this function.
1024  * @param[in]   message         callback message from pipeline.
1025  * @param[in]   data            user data.
1026  * @return      This function returns true on success, or false value with error
1027  * @remarks
1028  * @see         __mmcamcorder_create_preview_pipeline()
1029  *
1030  */
1031 gboolean _mmcamcorder_pipeline_cb_message(GstBus *bus, GstMessage *message, gpointer data);
1032
1033 /**
1034  * This function is callback function of main pipeline.
1035  * Once this function is registered with certain pipeline using gst_bus_set_sync_handler(),
1036  * this callback will be called every time when there is upcomming message from pipeline.
1037  * Basically, this function is used as sync error handling function, now.
1038  *
1039  * @param[in]   bus             pointer of buf that called this function.
1040  * @param[in]   message         callback message from pipeline.
1041  * @param[in]   data            user data.
1042  * @return      This function returns true on success, or false value with error
1043  * @remarks
1044  * @see         __mmcamcorder_create_preview_pipeline()
1045  *
1046  */
1047 GstBusSyncReply _mmcamcorder_pipeline_bus_sync_callback(GstBus *bus, GstMessage *message, gpointer data);
1048
1049 /**
1050  * This function create main pipeline according to type.
1051  *
1052  * @param[in]   handle          Handle of camcorder context.
1053  * @param[in]   type            Allocation type of camcorder context.
1054  * @return      This function returns zero on success, or negative value with error code.
1055  * @remarks
1056  * @see         _mmcamcorder_destroy_pipeline()
1057  *
1058  */
1059 int _mmcamcorder_create_pipeline(MMHandleType handle, int type);
1060
1061 /**
1062  * This function release all element of main pipeline according to type.
1063  *
1064  * @param[in]   handle          Handle of camcorder context.
1065  * @param[in]   type            Allocation type of camcorder context.
1066  * @return      void
1067  * @remarks
1068  * @see         _mmcamcorder_create_pipeline()
1069  *
1070  */
1071 void _mmcamcorder_destroy_pipeline(MMHandleType handle, int type);
1072
1073 /**
1074  * This function sets gstreamer element status.
1075  * If the gstreamer fails to set status or returns asynchronous mode,
1076  * this function waits for state changed until timeout expired.
1077  *
1078  * @param[in]   pipeline        Pointer of pipeline
1079  * @param[in]   target_state    newly setting status
1080  * @return      This function returns zero on success, or negative value with error code.
1081  * @remarks
1082  * @see
1083  *
1084  */
1085 int _mmcamcorder_gst_set_state(MMHandleType handle, GstElement *pipeline, GstState target_state);
1086
1087 /**
1088  * This function sets gstreamer element status, asynchronously.
1089  * Regardless of processing, it returns immediately.
1090  *
1091  * @param[in]   pipeline        Pointer of pipeline
1092  * @param[in]   target_state    newly setting status
1093  * @return      This function returns zero on success, or negative value with error code.
1094  * @remarks
1095  * @see
1096  *
1097  */
1098 int _mmcamcorder_gst_set_state_async(MMHandleType handle, GstElement *pipeline, GstState target_state);
1099
1100 /* For xvimagesink */
1101 GstBusSyncReply __mmcamcorder_sync_callback(GstBus *bus, GstMessage *message, gulong data);
1102
1103 /* For querying capabilities */
1104 int _mmcamcorder_read_vidsrc_info(int videodevidx, camera_conf **configure_info);
1105
1106 /* for performance check */
1107 void _mmcamcorder_video_current_framerate_init(MMHandleType handle);
1108 int _mmcamcorder_video_current_framerate(MMHandleType handle);
1109 int _mmcamcorder_video_average_framerate(MMHandleType handle);
1110
1111 #ifdef __cplusplus
1112 }
1113 #endif
1114
1115 #endif /* __MM_CAMCORDER_INTERNAL_H__ */