1. Seperate preview pipeline and encoding pipeline
[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
283 #define _MMCAMCORDER_GET_LOCK(handle)                           (_MMCAMCORDER_CAST_MTSAFE(handle).lock)
284 #define _MMCAMCORDER_LOCK(handle)                               pthread_mutex_lock(&_MMCAMCORDER_GET_LOCK(handle))
285 #define _MMCAMCORDER_TRYLOCK(handle)                            pthread_mutex_trylock(&_MMCAMCORDER_GET_LOCK(handle))
286 #define _MMCAMCORDER_UNLOCK(handle)                             pthread_mutex_unlock(&_MMCAMCORDER_GET_LOCK(handle))
287
288 #define _MMCAMCORDER_GET_COND(handle)                           (_MMCAMCORDER_CAST_MTSAFE(handle).cond)
289 #define _MMCAMCORDER_WAIT(handle)                               pthread_cond_wait(&_MMCAMCORDER_GET_COND(handle), &_MMCAMCORDER_GET_LOCK(handle))
290 #define _MMCAMCORDER_TIMED_WAIT(handle, timeval)                pthread_cond_timedwait(&_MMCAMCORDER_GET_COND(handle), &_MMCAMCORDER_GET_LOCK(handle), timeval)
291
292 #define _MMCAMCORDER_SIGNAL(handle)                             pthread_cond_signal(&_MMCAMCORDER_GET_COND(handle))
293 #define _MMCAMCORDER_BROADCAST(handle)                          pthread_cond_broadcast(&_MMCAMCORDER_GET_COND(handle))
294
295 /* for command */
296 #define _MMCAMCORDER_GET_CMD_LOCK(handle)                       (_MMCAMCORDER_CAST_MTSAFE(handle).cmd_lock)
297 #define _MMCAMCORDER_LOCK_CMD(handle)                           pthread_mutex_lock(&_MMCAMCORDER_GET_CMD_LOCK(handle))
298 #define _MMCAMCORDER_TRYLOCK_CMD(handle)                        pthread_mutex_trylock(&_MMCAMCORDER_GET_CMD_LOCK(handle))
299 #define _MMCAMCORDER_UNLOCK_CMD(handle)                         pthread_mutex_unlock(&_MMCAMCORDER_GET_CMD_LOCK(handle))
300
301 /* for ASM */
302 #define _MMCAMCORDER_GET_ASM_LOCK(handle)                       (_MMCAMCORDER_CAST_MTSAFE(handle).asm_lock)
303 #define _MMCAMCORDER_LOCK_ASM(handle)                           pthread_mutex_lock(&_MMCAMCORDER_GET_ASM_LOCK(handle))
304 #define _MMCAMCORDER_TRYLOCK_ASM(handle)                        pthread_mutex_trylock(&_MMCAMCORDER_GET_ASM_LOCK(handle))
305 #define _MMCAMCORDER_UNLOCK_ASM(handle)                         pthread_mutex_unlock(&_MMCAMCORDER_GET_ASM_LOCK(handle))
306
307 /* for state change */
308 #define _MMCAMCORDER_GET_STATE_LOCK(handle)                     (_MMCAMCORDER_CAST_MTSAFE(handle).state_lock)
309 #define _MMCAMCORDER_LOCK_STATE(handle)                         pthread_mutex_lock(&_MMCAMCORDER_GET_STATE_LOCK(handle))
310 #define _MMCAMCORDER_TRYLOCK_STATE(handle)                      pthread_mutex_trylock(&_MMCAMCORDER_GET_STATE_LOCK(handle))
311 #define _MMCAMCORDER_UNLOCK_STATE(handle)                       pthread_mutex_unlock(&_MMCAMCORDER_GET_STATE_LOCK(handle))
312
313 /* for gstreamer state change */
314 #define _MMCAMCORDER_GET_GST_STATE_LOCK(handle)                 (_MMCAMCORDER_CAST_MTSAFE(handle).gst_state_lock)
315 #define _MMCAMCORDER_LOCK_GST_STATE(handle)                     pthread_mutex_lock(&_MMCAMCORDER_GET_GST_STATE_LOCK(handle))
316 #define _MMCAMCORDER_TRYLOCK_GST_STATE(handle)                  pthread_mutex_trylock(&_MMCAMCORDER_GET_GST_STATE_LOCK(handle))
317 #define _MMCAMCORDER_UNLOCK_GST_STATE(handle)                   pthread_mutex_unlock(&_MMCAMCORDER_GET_GST_STATE_LOCK(handle))
318
319 #define _MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle)          (_MMCAMCORDER_CAST_MTSAFE(handle).gst_encode_state_lock)
320 #define _MMCAMCORDER_LOCK_GST_ENCODE_STATE(handle)              pthread_mutex_lock(&_MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle))
321 #define _MMCAMCORDER_TRYLOCK_GST_ENCODE_STATE(handle)           pthread_mutex_trylock(&_MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle))
322 #define _MMCAMCORDER_UNLOCK_GST_ENCODE_STATE(handle)            pthread_mutex_unlock(&_MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle))
323
324 /* for setting/calling callback */
325 #define _MMCAMCORDER_GET_MESSAGE_CALLBACK_LOCK(handle)      (_MMCAMCORDER_CAST_MTSAFE(handle).message_cb_lock)
326 #define _MMCAMCORDER_LOCK_MESSAGE_CALLBACK(handle)          pthread_mutex_lock(&_MMCAMCORDER_GET_MESSAGE_CALLBACK_LOCK(handle))
327 #define _MMCAMCORDER_TRYLOCK_MESSAGE_CALLBACK(handle)       pthread_mutex_trylock(&_MMCAMCORDER_GET_MESSAGE_CALLBACK_LOCK(handle))
328 #define _MMCAMCORDER_UNLOCK_MESSAGE_CALLBACK(handle)        pthread_mutex_unlock(&_MMCAMCORDER_GET_MESSAGE_CALLBACK_LOCK(handle))
329
330 #define _MMCAMCORDER_GET_VCAPTURE_CALLBACK_LOCK(handle)     (_MMCAMCORDER_CAST_MTSAFE(handle).vcapture_cb_lock)
331 #define _MMCAMCORDER_LOCK_VCAPTURE_CALLBACK(handle)         pthread_mutex_lock(&_MMCAMCORDER_GET_VCAPTURE_CALLBACK_LOCK(handle))
332 #define _MMCAMCORDER_TRYLOCK_VCAPTURE_CALLBACK(handle)      pthread_mutex_trylock(&_MMCAMCORDER_GET_VCAPTURE_CALLBACK_LOCK(handle))
333 #define _MMCAMCORDER_UNLOCK_VCAPTURE_CALLBACK(handle)       pthread_mutex_unlock(&_MMCAMCORDER_GET_VCAPTURE_CALLBACK_LOCK(handle))
334
335 #define _MMCAMCORDER_GET_VSTREAM_CALLBACK_LOCK(handle)      (_MMCAMCORDER_CAST_MTSAFE(handle).vstream_cb_lock)
336 #define _MMCAMCORDER_LOCK_VSTREAM_CALLBACK(handle)          pthread_mutex_lock(&_MMCAMCORDER_GET_VSTREAM_CALLBACK_LOCK(handle))
337 #define _MMCAMCORDER_TRYLOCK_VSTREAM_CALLBACK(handle)       pthread_mutex_trylock(&_MMCAMCORDER_GET_VSTREAM_CALLBACK_LOCK(handle))
338 #define _MMCAMCORDER_UNLOCK_VSTREAM_CALLBACK(handle)        pthread_mutex_unlock(&_MMCAMCORDER_GET_VSTREAM_CALLBACK_LOCK(handle))
339
340 #define _MMCAMCORDER_GET_ASTREAM_CALLBACK_LOCK(handle)      (_MMCAMCORDER_CAST_MTSAFE(handle).astream_cb_lock)
341 #define _MMCAMCORDER_LOCK_ASTREAM_CALLBACK(handle)          pthread_mutex_lock(&_MMCAMCORDER_GET_ASTREAM_CALLBACK_LOCK(handle))
342 #define _MMCAMCORDER_TRYLOCK_ASTREAM_CALLBACK(handle)       pthread_mutex_trylock(&_MMCAMCORDER_GET_ASTREAM_CALLBACK_LOCK(handle))
343 #define _MMCAMCORDER_UNLOCK_ASTREAM_CALLBACK(handle)        pthread_mutex_unlock(&_MMCAMCORDER_GET_ASTREAM_CALLBACK_LOCK(handle))
344
345 /**
346  * Caster of main handle (camcorder)
347  */
348 #define MMF_CAMCORDER(h) (mmf_camcorder_t *)(h)
349
350 /**
351  * Caster of subcontext
352  */
353 #define MMF_CAMCORDER_SUBCONTEXT(h) (((mmf_camcorder_t *)(h))->sub_context)
354
355 /* LOCAL CONSTANT DEFINITIONS */
356 /**
357  * Total Numbers of Attribute values.
358  * If you increase any enum of attribute values, you also have to increase this.
359  */
360 #define MM_CAMCORDER_MODE_NUM                   3       /**< Number of mode type */
361 #define MM_CAMCORDER_COLOR_TONE_NUM             30      /**< Number of color-tone modes */
362 #define MM_CAMCORDER_WHITE_BALANCE_NUM          10      /**< Number of WhiteBalance modes*/
363 #define MM_CAMCORDER_SCENE_MODE_NUM             16      /**< Number of program-modes */
364 #define MM_CAMCORDER_FOCUS_MODE_NUM             6       /**< Number of focus mode*/
365 #define MM_CAMCORDER_AUTO_FOCUS_NUM             5       /**< Total count of auto focus type*/
366 #define MM_CAMCORDER_FOCUS_STATE_NUM            4       /**< Number of focus state */
367 #define MM_CAMCORDER_ISO_NUM                    10      /**< Number of ISO */
368 #define MM_CAMCORDER_AUTO_EXPOSURE_NUM          9       /**< Number of Auto exposure type */
369 #define MM_CAMCORDER_WDR_NUM                    3       /**< Number of wide dynamic range */
370 #define MM_CAMCORDER_FLIP_NUM                   4       /**< Number of Filp mode */
371 #define MM_CAMCORDER_ROTATION_NUM               4       /**< Number of Rotation mode */
372 #define MM_CAMCORDER_AHS_NUM                    4       /**< Number of anti-handshake */
373 #define MM_CAMCORDER_VIDEO_STABILIZATION_NUM    2       /**< Number of video stabilization */
374 #define MM_CAMCORDER_HDR_CAPTURE_NUM            3       /**< Number of HDR capture mode */
375 #define MM_CAMCORDER_GEOMETRY_METHOD_NUM        5       /**< Number of geometry method */
376 #define MM_CAMCORDER_TAG_ORT_NUM                8       /**< Number of tag orientation */
377 #define MM_CAMCORDER_STROBE_MODE_NUM            8       /**< Number of strobe mode type */
378 #define MM_CAMCORDER_STROBE_CONTROL_NUM         3       /**< Number of strobe control type */
379 #define MM_CAMCORDER_DETECT_MODE_NUM            2       /**< Number of detect mode type */
380
381
382 /*=======================================================================================
383 | ENUM DEFINITIONS                                                                      |
384 ========================================================================================*/
385 /**
386  * Command for Camcorder.
387  */
388 enum {
389         /* Command for Video/Audio recording */
390         _MMCamcorder_CMD_RECORD,
391         _MMCamcorder_CMD_PAUSE,
392         _MMCamcorder_CMD_CANCEL,
393         _MMCamcorder_CMD_COMMIT,
394
395         /* Command for Image capture */
396         _MMCamcorder_CMD_CAPTURE,
397
398         /* Command for Preview(Video/Image only effective) */
399         _MMCamcorder_CMD_PREVIEW_START,
400         _MMCamcorder_CMD_PREVIEW_STOP,
401 };
402
403 /**
404  * Still-shot type
405  */
406 enum {
407         _MMCamcorder_SINGLE_SHOT,
408         _MMCamcorder_MULTI_SHOT,
409 };
410
411 /**
412  * Enumerations for manual focus direction.
413  * If focusing mode is not "MM_CAMCORDER_AF_MODE_MANUAL", this value will be ignored.
414  */
415 enum MMCamcorderMfLensDir {
416         MM_CAMCORDER_MF_LENS_DIR_FORWARD = 1,   /**< Focus direction to forward */
417         MM_CAMCORDER_MF_LENS_DIR_BACKWARD,      /**< Focus direction to backward */
418         MM_CAMCORDER_MF_LENS_DIR_NUM,           /**< Total number of the directions */
419 };
420
421 /**
422  * Camcorder Pipeline's Element name.
423  * @note index of element.
424  */
425 typedef enum {
426         _MMCAMCORDER_NONE = (-1),
427
428         /* Main Pipeline Element */
429         _MMCAMCORDER_MAIN_PIPE = 0x00,
430
431         /* Pipeline element of Video input */
432         _MMCAMCORDER_VIDEOSRC_SRC,
433         _MMCAMCORDER_VIDEOSRC_FILT,
434         _MMCAMCORDER_VIDEOSRC_CLS_QUE,
435         _MMCAMCORDER_VIDEOSRC_CLS,
436         _MMCAMCORDER_VIDEOSRC_CLS_FILT,
437         _MMCAMCORDER_VIDEOSRC_QUE,
438         _MMCAMCORDER_VIDEOSRC_DECODE,
439
440         /* Pipeline element of Video output */
441         _MMCAMCORDER_VIDEOSINK_QUE,
442         _MMCAMCORDER_VIDEOSINK_CLS,
443         _MMCAMCORDER_VIDEOSINK_SINK,
444
445         _MMCAMCORDER_PIPELINE_ELEMENT_NUM,
446 } _MMCAMCORDER_PREVIEW_PIPELINE_ELELMENT;
447
448 /**
449  * Camcorder Pipeline's Element name.
450  * @note index of element.
451  */
452 typedef enum {
453         _MMCAMCORDER_ENCODE_NONE = (-1),
454
455         /* Main Pipeline Element */
456         _MMCAMCORDER_ENCODE_MAIN_PIPE = 0x00,
457
458         /* Pipeline element of Audio input */
459         _MMCAMCORDER_AUDIOSRC_BIN,
460         _MMCAMCORDER_AUDIOSRC_SRC,
461         _MMCAMCORDER_AUDIOSRC_FILT,
462         _MMCAMCORDER_AUDIOSRC_QUE,
463         _MMCAMCORDER_AUDIOSRC_CONV,
464         _MMCAMCORDER_AUDIOSRC_VOL,
465
466         /* Pipeline element of Encodebin */
467         _MMCAMCORDER_ENCSINK_BIN,
468         _MMCAMCORDER_ENCSINK_SRC,
469         _MMCAMCORDER_ENCSINK_FILT,
470         _MMCAMCORDER_ENCSINK_ENCBIN,
471         _MMCAMCORDER_ENCSINK_AQUE,
472         _MMCAMCORDER_ENCSINK_CONV,
473         _MMCAMCORDER_ENCSINK_AENC,
474         _MMCAMCORDER_ENCSINK_AENC_QUE,
475         _MMCAMCORDER_ENCSINK_VQUE,
476         _MMCAMCORDER_ENCSINK_VCONV,
477         _MMCAMCORDER_ENCSINK_VENC,
478         _MMCAMCORDER_ENCSINK_VENC_QUE,
479         _MMCAMCORDER_ENCSINK_ITOG,
480         _MMCAMCORDER_ENCSINK_ICROP,
481         _MMCAMCORDER_ENCSINK_ISCALE,
482         _MMCAMCORDER_ENCSINK_IFILT,
483         _MMCAMCORDER_ENCSINK_IQUE,
484         _MMCAMCORDER_ENCSINK_IENC,
485         _MMCAMCORDER_ENCSINK_MUX,
486         _MMCAMCORDER_ENCSINK_SINK,
487
488         _MMCAMCORDER_ENCODE_PIPELINE_ELEMENT_NUM,
489 } _MMCAMCORDER_ENCODE_PIPELINE_ELELMENT;
490
491 typedef enum {
492         _MMCAMCORDER_TASK_THREAD_STATE_NONE,
493         _MMCAMCORDER_TASK_THREAD_STATE_SOUND_PLAY_START,
494         _MMCAMCORDER_TASK_THREAD_STATE_ENCODE_PIPE_CREATE,
495         _MMCAMCORDER_TASK_THREAD_STATE_EXIT,
496 } _MMCamcorderTaskThreadState;
497
498 /**
499  * System state change cause
500  */
501 typedef enum {
502         _MMCAMCORDER_STATE_CHANGE_NORMAL = 0,
503         _MMCAMCORDER_STATE_CHANGE_BY_ASM,
504 } _MMCamcorderStateChange;
505
506
507 /*=======================================================================================
508 | STRUCTURE DEFINITIONS                                                                 |
509 ========================================================================================*/
510 /**
511  * MMCamcorder Gstreamer Element
512  */
513 typedef struct {
514         unsigned int id;                /**< Gstreamer piplinem element name */
515         GstElement *gst;                /**< Gstreamer element */
516 } _MMCamcorderGstElement;
517
518 /**
519  * MMCamcorder information for KPI measurement
520  */
521 typedef struct {
522         int current_fps;                /**< current fps of this second */
523         int average_fps;                /**< average fps  */
524         unsigned int video_framecount;  /**< total number of video frame */
525         unsigned int last_framecount;   /**< total number of video frame in last measurement */
526         struct timeval init_video_time; /**< time when start to measure */
527         struct timeval last_video_time; /**< last measurement time */
528 } _MMCamcorderKPIMeasure;
529
530 /**
531  * MMCamcorder information for Multi-Thread Safe
532  */
533 typedef struct {
534         pthread_mutex_t lock;                   /**< Mutex (for general use) */
535         pthread_cond_t cond;                    /**< Condition (for general use) */
536         pthread_mutex_t cmd_lock;               /**< Mutex (for command) */
537         pthread_mutex_t asm_lock;               /**< Mutex (for ASM) */
538         pthread_mutex_t state_lock;             /**< Mutex (for state change) */
539         pthread_mutex_t gst_state_lock;         /**< Mutex (for gst pipeline state change) */
540         pthread_mutex_t gst_encode_state_lock;  /**< Mutex (for gst encode pipeline state change) */
541         pthread_mutex_t message_cb_lock;                /**< Mutex (for message callback) */
542         pthread_mutex_t vcapture_cb_lock;       /**< Mutex (for video capture callback) */
543         pthread_mutex_t vstream_cb_lock;                /**< Mutex (for video stream callback) */
544         pthread_mutex_t astream_cb_lock;                /**< Mutex (for audio stream callback) */
545 } _MMCamcorderMTSafe;
546
547
548 /**
549  * MMCamcorder Sub Context
550  */
551 typedef struct {
552         bool isMaxsizePausing;                  /**< Because of size limit, pipeline is paused. */
553         bool isMaxtimePausing;                  /**< Because of time limit, pipeline is paused. */
554         int element_num;                        /**< count of element */
555         int encode_element_num;                 /**< count of encode element */
556         int cam_stability_count;                /**< camsensor stability count. the count of frame will drop */
557         GstClockTime pipeline_time;             /**< current time of Gstreamer Pipeline */
558         GstClockTime pause_time;                /**< amount of time while pipeline is in PAUSE state.*/
559         GstClockTime stillshot_time;            /**< pipeline time of capturing moment*/
560         gboolean is_modified_rate;              /**< whether recording motion rate is modified or not */
561         gboolean error_occurs;                  /**< flag for error */
562         int error_code;                         /**< error code for internal gstreamer error */
563         gboolean ferror_send;                   /**< file write/seek error **/
564         guint ferror_count;                     /**< file write/seek error count **/
565         GstClockTime previous_slot_time;
566         int display_interval;                   /**< This value is set as 'GST_SECOND / display FPS' */
567         gboolean bget_eos;                      /**< Whether getting EOS */
568         gboolean bencbin_capture;               /**< Use Encodebin for capturing */
569         gboolean audio_disable;                 /**< whether audio is disabled or not when record */
570         int videosrc_rotate;                    /**< rotate of videosrc */
571
572         /* For dropping video frame when start recording */
573         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. */
574         int pass_first_vframe;                  /**< When this value is bigger than zero, MSL won't drop video frame though "drop_vframe" is bigger then zero. */
575
576         /* INI information */
577         unsigned int fourcc;                    /**< Get fourcc value of camera INI file */
578         _MMCamcorderImageInfo *info_image;      /**< extra information for image capture */
579         _MMCamcorderVideoInfo *info_video;      /**< extra information for video recording */
580         _MMCamcorderAudioInfo *info_audio;      /**< extra information for audio recording */
581
582         _MMCamcorderGstElement *element;        /**< array of preview element */
583         _MMCamcorderGstElement *encode_element; /**< array of encode element */
584         _MMCamcorderKPIMeasure kpi;             /**< information related with performance measurement */
585
586         type_element *VideosinkElement;         /**< configure data of videosink element */
587         type_element *VideoconvertElement;      /**< configure data of videoconvert element */
588         gboolean SensorEncodedCapture;          /**< whether camera sensor support encoded image capture */
589         gboolean internal_encode;               /**< whether use internal encoding function */
590 } _MMCamcorderSubContext;
591
592 /**
593   * _MMCamcorderContext
594   */
595 typedef struct mmf_camcorder {
596         /* information */
597         int type;               /**< mmcamcorder_mode_type */
598         int device_type;        /**< device type */
599         int state;              /**< state of camcorder */
600         int target_state;       /**< Target state that want to set. This is a flag that
601                                    * stands for async state changing. If this value differ from state,
602                                    * it means state is changing now asychronously. */
603
604         /* handles */
605         MMHandleType attributes;               /**< Attribute handle */
606         _MMCamcorderSubContext *sub_context;   /**< sub context */
607         mm_exif_info_t *exif_info;             /**< EXIF */
608         GList *buffer_probes;                  /**< a list of buffer probe handle */
609         GList *event_probes;                   /**< a list of event probe handle */
610         GList *signals;                        /**< a list of signal handle */
611         GList *msg_data;                       /**< a list of msg data */
612         camera_conf *conf_main;                /**< Camera configure Main structure */
613         camera_conf *conf_ctrl;                /**< Camera configure Control structure */
614         guint pipeline_cb_event_id;            /**< Event source ID of pipeline message callback */
615         guint encode_pipeline_cb_event_id;     /**< Event source ID of encode pipeline message callback */
616         guint setting_event_id;                /**< Event source ID of attributes setting to sensor */
617         SOUND_INFO snd_info;                   /**< Sound handle for multishot capture */
618
619         /* callback handlers */
620         MMMessageCallback msg_cb;                               /**< message callback */
621         void *msg_cb_param;                                     /**< message callback parameter */
622         mm_camcorder_video_stream_callback vstream_cb;          /**< Video stream callback */
623         void *vstream_cb_param;                                 /**< Video stream callback parameter */
624         mm_camcorder_audio_stream_callback astream_cb;          /**< Audio stream callback */
625         void *astream_cb_param;                                 /**< Audio stream callback parameter */
626         mm_camcorder_video_capture_callback vcapture_cb;        /**< Video capture callback */
627         void *vcapture_cb_param;                                /**< Video capture callback parameter */
628         int (*command)(MMHandleType, int);                      /**< camcorder's command */
629
630         /* etc */
631         mm_cam_attr_construct_info *cam_attrs_const_info;       /**< attribute info */
632         conf_info_table* conf_main_info_table[CONFIGURE_CATEGORY_MAIN_NUM]; /** configure info table - MAIN category */
633         conf_info_table* conf_ctrl_info_table[CONFIGURE_CATEGORY_CTRL_NUM]; /** configure info table - CONTROL category */
634         int conf_main_category_size[CONFIGURE_CATEGORY_MAIN_NUM]; /** configure info table size - MAIN category */
635         int conf_ctrl_category_size[CONFIGURE_CATEGORY_CTRL_NUM]; /** configure info table size - CONTROL category */
636         _MMCamcorderMTSafe mtsafe;                              /**< Thread safe */
637         int state_change_by_system;                             /**< MSL changes its state by itself because of system */
638         pthread_mutex_t sound_lock;                             /**< Capture sound mutex */
639         pthread_cond_t sound_cond;                              /**< Capture sound cond */
640         pthread_mutex_t restart_preview_lock;                   /**< Capture sound mutex */
641         int use_zero_copy_format;                               /**< Whether use zero copy format for camera input */
642         int support_media_packet_preview_cb;                   /**< Whether support zero copy format for camera input */
643         int shutter_sound_policy;                               /**< shutter sound policy */
644         int brightness_default;                                 /**< default value of brightness */
645         int brightness_step_denominator;                        /**< denominator of brightness bias step */
646         int support_zsl_capture;                                /**< support Zero Shutter Lag capture */
647         char *model_name;                                       /**< model name from system info */
648         char *software_version;                                 /**< software_version from system info */
649         int capture_sound_count;                                /**< count for capture sound */
650         bool stillshot_wide_resolution;                         /**<to set the capture resolution high*/
651
652         _MMCamcorderInfoConverting caminfo_convert[CAMINFO_CONVERT_NUM];        /**< converting structure of camera info */
653         _MMCamcorderEnumConvert enum_conv[ENUM_CONVERT_NUM];                    /**< enum converting list that is modified by ini info */
654
655         gboolean capture_in_recording;                          /**< Flag for capture while recording */
656
657         /* task thread */
658         pthread_t task_thread;                                  /**< thread for task */
659         pthread_mutex_t task_thread_lock;                       /**< mutex for task thread */
660         pthread_cond_t task_thread_cond;                        /**< cond for task thread */
661         _MMCamcorderTaskThreadState task_thread_state;          /**< state of task thread */
662
663         int reserved[4];                                        /**< reserved */
664 } mmf_camcorder_t;
665
666 /*=======================================================================================
667 | EXTERN GLOBAL VARIABLE                                                                |
668 ========================================================================================*/
669
670 /*=======================================================================================
671 | GLOBAL FUNCTION PROTOTYPES                                                            |
672 ========================================================================================*/
673 /**
674  *      This function creates camcorder for capturing still image and recording.
675  *
676  *      @param[out]     handle          Specifies the camcorder  handle
677  *      @param[in]      info            Preset information of camcorder
678  *      @return         This function returns zero on success, or negative value with error code.
679  *      @remarks        When this function calls successfully, camcorder  handle will be filled with a @n
680  *                      valid value and the state of  the camcorder  will become MM_CAMCORDER_STATE_NULL.@n
681  *                      Note that  it's not ready to working camcorder. @n
682  *                      You should call mmcamcorder_realize before starting camcorder.
683  *      @see            _mmcamcorder_create
684  */
685 int _mmcamcorder_create(MMHandleType *handle, MMCamPreset *info);
686
687 /**
688  *      This function destroys instance of camcorder.
689  *
690  *      @param[in]      hcamcorder      Specifies the camcorder  handle
691  *      @return         This function returns zero on success, or negative value with error code.
692  *      @see            _mmcamcorder_create
693  */
694 int _mmcamcorder_destroy(MMHandleType hcamcorder);
695
696 /**
697  *      This function allocates memory for camcorder.
698  *
699  *      @param[in]      hcamcorder      Specifies the camcorder  handle
700  *      @return         This function returns zero on success, or negative value with error code.
701  *      @remarks        This function can  be called successfully when current state is MM_CAMCORDER_STATE_NULL @n
702  *                      and  the state of the camcorder  will become MM_CAMCORDER_STATE_READY. @n
703  *                      Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
704  *      @see            _mmcamcorder_unrealize
705  *      @pre            MM_CAMCORDER_STATE_NULL
706  *      @post           MM_CAMCORDER_STATE_READY
707  */
708 int _mmcamcorder_realize(MMHandleType hcamcorder);
709
710 /**
711  *      This function free allocated memory for camcorder.
712  *
713  *      @param[in]      hcamcorder      Specifies the camcorder  handle
714  *      @return         This function returns zero on success, or negative value with error code.
715  *      @remarks        This function release all resources which are allocated for the camcorder engine.@n
716  *                      This function can  be called successfully when current state is MM_CAMCORDER_STATE_READY and  @n
717  *                      the state of the camcorder  will become MM_CAMCORDER_STATE_NULL. @n
718  *                      Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
719  *      @see            _mmcamcorder_realize
720  *      @pre            MM_CAMCORDER_STATE_READY
721  *      @post           MM_CAMCORDER_STATE_NULL
722  */
723 int _mmcamcorder_unrealize(MMHandleType hcamcorder);
724
725 /**
726  *      This function is to start previewing.
727  *
728  *      @param[in]      hcamcorder      Specifies the camcorder  handle
729  *      @return         This function returns zero on success, or negative value with error code.
730  *      @remarks        This function can  be called successfully when current state is MM_CAMCORDER_STATE_READY and  @n
731  *                      the state of the camcorder  will become MM_CAMCORDER_STATE_PREPARE. @n
732  *                      Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
733  *      @see            _mmcamcorder_stop
734  */
735 int _mmcamcorder_start(MMHandleType hcamcorder);
736
737 /**
738  *      This function is to stop previewing.
739  *
740  *      @param[in]      hcamcorder      Specifies the camcorder  handle
741  *      @return         This function returns zero on success, or negative value with error code.
742  *      @remarks        This function can  be called successfully when current state is MM_CAMCORDER_STATE_PREPARE and  @n
743  *                      the state of the camcorder  will become MM_CAMCORDER_STATE_READY.@n
744  *                      Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
745  *      @see            _mmcamcorder_start
746  */
747 int _mmcamcorder_stop(MMHandleType hcamcorder);
748
749 /**
750  *      This function to start capturing of still images.
751  *
752  *      @param[in]      hcamcorder      Specifies the camcorder  handle.
753  *      @return         This function returns zero on success, or negative value with error code.
754  *      @remarks        This function can  be called successfully when current state is MM_CAMCORDER_STATE_PREPARE and @n
755  *                      the state of the camcorder  will become MM_CAMCORDER_STATE_CAPTURING. @n
756  *                      Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
757  *      @see            _mmcamcorder_capture_stop
758  */
759 int _mmcamcorder_capture_start(MMHandleType hcamcorder);
760
761 /**
762  *      This function is to stop capturing still images.
763  *
764  *      @param[in]      hcamcorder      Specifies the camcorder  handle
765  *      @return         This function returns zero on success, or negative value with error code.
766  *      @remarks        This function can  be called successfully when current state is MM_CAMCORDER_STATE_CAPTURING and @n
767  *                      the state of the camcorder  will become MM_CAMCORDER_STATE_PREPARE. @n
768  *                      Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
769  *      @see            _mmcamcorder_capture_start
770  */
771 int _mmcamcorder_capture_stop(MMHandleType hcamcorder);
772
773 /**
774  *      This function is to start  video and audio recording.
775  *
776  *      @param[in]      hcamcorder      Specifies the camcorder  handle
777  *      @return         This function returns zero on success, or negative value with error code.
778  *      @remarks        This function can  be called successfully when current state is @n
779  *                      MM_CAMCORDER_STATE_PREPARE or MM_CAMCORDER_STATE_PAUSED and  @n
780  *                      the state of the camcorder  will become MM_CAMCORDER_STATE_RECORDING.@n
781  *                      Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
782  *      @see            _mmcamcorder_pause
783  */
784 int _mmcamcorder_record(MMHandleType hcamcorder);
785
786 /**
787  *      This function is to pause video and audio recording
788  *
789  *      @param[in]      hcamcorder      Specifies the camcorder  handle
790  *      @return         This function returns zero on success, or negative value with error code.
791  *      @remarks        This function can  be called successfully when current state is MM_CAMCORDER_STATE_RECORDING and  @n
792  *                      the  state of the camcorder  will become MM_CAMCORDER_STATE_PAUSED.@n
793  *                      Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.@n
794  *      @see            _mmcamcorder_record
795  */
796 int _mmcamcorder_pause(MMHandleType hcamcorder);
797
798 /**
799  *      This function is to stop video and audio  recording and  save results.
800  *
801  *      @param[in]      hcamcorder      Specifies the camcorder  handle
802  *      @return         This function returns zero on success, or negative value with error code.
803  *      @remarks        This function can  be called successfully when current state is @n
804  *                      MM_CAMCORDER_STATE_PAUSED or MM_CAMCORDER_STATE_RECORDING and  @n
805  *                      the state of the camcorder  will become MM_CAMCORDER_STATE_PREPARE. @n
806  *                      Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION
807  *      @see            _mmcamcorder_cancel
808  */
809 int _mmcamcorder_commit(MMHandleType hcamcorder);
810
811 /**
812  *      This function is to stop video and audio recording and do not save results.
813  *
814  *      @param[in]      hcamcorder      Specifies the camcorder  handle
815  *      @return         This function returns zero on success, or negative value with error code.
816  *      @remarks        This function can  be called successfully when current state is @n
817  *                      MM_CAMCORDER_STATE_PAUSED or MM_CAMCORDER_STATE_RECORDING and  @n
818  *                      the state of the camcorder  will become MM_CAMCORDER_STATE_PREPARE. @n
819  *                      Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
820  *      @see            _mmcamcorder_commit
821  */
822 int _mmcamcorder_cancel(MMHandleType hcamcorder);
823
824 /**
825  *      This function calls after commiting action finished asynchronously. 
826  *      In this function, remaining process , such as state change, happens.
827  *
828  *      @param[in]      hcamcorder      Specifies the camcorder  handle
829  *      @return         This function returns zero on success, or negative value with error code.
830  *      @remarks        This function can  be called successfully when current state is @n
831  *                      MM_CAMCORDER_STATE_PAUSED or MM_CAMCORDER_STATE_RECORDING and  @n
832  *                      the state of the camcorder  will become MM_CAMCORDER_STATE_PREPARE. @n
833  *                      Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
834  *      @see            _mmcamcorder_commit
835  */
836 int _mmcamcorder_commit_async_end(MMHandleType hcamcorder);
837
838 /**
839  *      This function is to set callback for receiving messages from camcorder.
840  *
841  *      @param[in]      hcamcorder      Specifies the camcorder  handle
842  *      @param[in]      callback        Specifies the function pointer of callback function
843  *      @param[in]      user_data       Specifies the user poiner for passing to callback function
844  *
845  *      @return         This function returns zero on success, or negative value with error code.
846  *      @remarks        typedef bool (*mm_message_callback) (int msg, mm_messageType *param, void *user_param);@n
847  *              @n
848  *              typedef union                           @n
849  *              {                                                       @n
850  *                      int code;                               @n
851  *                      struct                                  @n
852  *                      {                                               @n
853  *                              int total;                      @n
854  *                              int elapsed;            @n
855  *                      } time;                                 @n
856  *                      struct                                  @n
857  *                      {                                               @n
858  *                              int previous;           @n
859  *                              int current;                    @n
860  *                      } state;                                        @n
861  *              } mm_message_type;      @n
862  *                                                                      @n
863  *              If a  message value for mm_message_callback is MM_MESSAGE_STATE_CHANGED, @n
864  *              state value in mm_message_type  will be a mmcamcorder_state_type enum value;@n
865  *              @n
866  *              If  a message value for mm_message_callback is MM_MESSAGE_ERROR,  @n
867  *              the code value in mm_message_type will be a mmplayer_error_type enum value;
868  *
869  *      @see            mm_message_type,  mmcamcorder_state_type,  mmcamcorder_error_type
870  */
871 int _mmcamcorder_set_message_callback(MMHandleType hcamcorder,
872                                       MMMessageCallback callback,
873                                       void *user_data);
874
875 /**
876  *      This function is to set callback for video stream.
877  *
878  *      @param[in]      hcamcorder      Specifies the camcorder  handle
879  *      @param[in]      callback        Specifies the function pointer of callback function
880  *      @param[in]      user_data       Specifies the user poiner for passing to callback function
881  *
882  *      @return         This function returns zero on success, or negative value with error code.
883  *      @see            mmcamcorder_error_type
884  */
885 int _mmcamcorder_set_video_stream_callback(MMHandleType hcamcorder,
886                                            mm_camcorder_video_stream_callback callback,
887                                            void *user_data);
888
889 /**
890  *      This function is to set callback for audio stream.
891  *
892  *      @param[in]      hcamcorder      Specifies the camcorder handle
893  *      @param[in]      callback        Specifies the function pointer of callback function
894  *      @param[in]      user_data       Specifies the user poiner for passing to callback function
895  *
896  *      @return         This function returns zero on success, or negative value with error code.
897  *      @see            mmcamcorder_error_type
898  */
899 int _mmcamcorder_set_audio_stream_callback(MMHandleType handle,
900                                            mm_camcorder_audio_stream_callback callback,
901                                            void *user_data);
902
903 /**
904  *      This function is to set callback for video capture.
905  *
906  *      @param[in]      hcamcorder      Specifies the camcorder  handle
907  *      @param[in]      callback        Specifies the function pointer of callback function
908  *      @param[in]      user_data       Specifies the user poiner for passing to callback function
909  *
910  *      @return         This function returns zero on success, or negative value with error code.
911  *      @see            mmcamcorder_error_type
912  */
913 int _mmcamcorder_set_video_capture_callback(MMHandleType hcamcorder,
914                                             mm_camcorder_video_capture_callback callback,
915                                             void *user_data);
916
917 /**
918  *      This function returns current state of camcorder, or negative value with error code.
919  *
920  *      @param[in]      hcamcorder      Specifies the camcorder  handle.
921  *      @return         This function returns current state of camcorder, or negative value with error code.
922  *      @see            mmcamcorder_state_type
923  */
924 int _mmcamcorder_get_current_state(MMHandleType hcamcorder);
925
926 int _mmcamcorder_init_focusing(MMHandleType handle);
927 int _mmcamcorder_adjust_focus(MMHandleType handle, int direction);
928 int _mmcamcorder_adjust_manual_focus(MMHandleType handle, int direction);
929 int _mmcamcorder_adjust_auto_focus(MMHandleType handle);
930 int _mmcamcorder_stop_focusing(MMHandleType handle);
931
932 /**
933  * This function gets current state of camcorder.
934  *
935  * @param       void
936  * @return      This function returns state of current camcorder context
937  * @remarks
938  * @see         _mmcamcorder_set_state()
939  *
940  */
941 int _mmcamcorder_streamer_init(void);
942
943 /**
944  * This function gets current state of camcorder.
945  *
946  * @param       void
947  * @return      This function returns state of current camcorder context
948  * @remarks
949  * @see         _mmcamcorder_set_state()
950  *
951  */
952 int _mmcamcorder_display_init(void);
953
954 /**
955  * This function gets current state of camcorder.
956  *
957  * @param[in]   handle          Handle of camcorder context.
958  * @return      This function returns state of current camcorder context
959  * @remarks
960  * @see         _mmcamcorder_set_state()
961  *
962  */
963 int _mmcamcorder_get_state(MMHandleType handle);
964
965 /**
966  * This function sets new state of camcorder.
967  *
968  * @param[in]   handle          Handle of camcorder context.
969  * @param[in]   state           setting state value of camcorder.
970  * @return      void
971  * @remarks
972  * @see         _mmcamcorder_get_state()
973  *
974  */
975 void _mmcamcorder_set_state(MMHandleType handle, int state);
976
977 /**
978  * This function gets asynchronous status of MSL Camcroder.
979  *
980  * @param[in]   handle          Handle of camcorder context.
981  * @param[in]   target_state    setting target_state value of camcorder.
982  * @return      This function returns asynchrnous state.
983  * @remarks
984  * @see         _mmcamcorder_set_async_state()
985  *
986  */
987 int _mmcamcorder_get_async_state(MMHandleType handle);
988
989 /**
990  * This function allocates structure of subsidiary attributes.
991  *
992  * @param[in]   type            Allocation type of camcorder context.
993  * @return      This function returns structure pointer on success, NULL value on failure.
994  * @remarks
995  * @see         _mmcamcorder_dealloc_subcontext()
996  *
997  */
998 _MMCamcorderSubContext *_mmcamcorder_alloc_subcontext(int type);
999
1000 /**
1001  * This function releases structure of subsidiary attributes.
1002  *
1003  * @param[in]   sc              Handle of camcorder subcontext.
1004  * @return      void
1005  * @remarks
1006  * @see         _mmcamcorder_alloc_subcontext()
1007  *
1008  */
1009 void _mmcamcorder_dealloc_subcontext(_MMCamcorderSubContext *sc);
1010
1011 /**
1012  * This function sets command function according to the type.
1013  *
1014  * @param[in]   handle          Handle of camcorder context.
1015  * @param[in]   type            Allocation type of camcorder context.
1016  * @return      This function returns MM_ERROR_NONE on success, or other values with error code.
1017  * @remarks
1018  * @see         __mmcamcorder_video_command(), __mmcamcorder_audio_command(), __mmcamcorder_image_command()
1019  *
1020  */
1021 int _mmcamcorder_set_functions(MMHandleType handle, int type);
1022
1023 /**
1024  * This function is callback function of main pipeline.
1025  * Once this function is registered with certain pipeline using gst_bus_add_watch(),
1026  * this callback will be called every time when there is upcomming message from pipeline.
1027  * Basically, this function is used as error handling function, now.
1028  *
1029  * @param[in]   bus             pointer of buf that called this function.
1030  * @param[in]   message         callback message from pipeline.
1031  * @param[in]   data            user data.
1032  * @return      This function returns true on success, or false value with error
1033  * @remarks
1034  * @see         __mmcamcorder_create_preview_pipeline()
1035  *
1036  */
1037 gboolean _mmcamcorder_pipeline_cb_message(GstBus *bus, GstMessage *message, gpointer data);
1038
1039 /**
1040  * This function is callback function of main pipeline.
1041  * Once this function is registered with certain pipeline using gst_bus_set_sync_handler(),
1042  * this callback will be called every time when there is upcomming message from pipeline.
1043  * Basically, this function is used as sync error handling function, now.
1044  *
1045  * @param[in]   bus             pointer of buf that called this function.
1046  * @param[in]   message         callback message from pipeline.
1047  * @param[in]   data            user data.
1048  * @return      This function returns true on success, or false value with error
1049  * @remarks
1050  * @see         __mmcamcorder_create_preview_pipeline()
1051  *
1052  */
1053 GstBusSyncReply _mmcamcorder_pipeline_bus_sync_callback(GstBus *bus, GstMessage *message, gpointer data);
1054
1055 /**
1056  * This function create main pipeline according to type.
1057  *
1058  * @param[in]   handle          Handle of camcorder context.
1059  * @param[in]   type            Allocation type of camcorder context.
1060  * @return      This function returns zero on success, or negative value with error code.
1061  * @remarks
1062  * @see         _mmcamcorder_destroy_pipeline()
1063  *
1064  */
1065 int _mmcamcorder_create_pipeline(MMHandleType handle, int type);
1066
1067 /**
1068  * This function release all element of main pipeline according to type.
1069  *
1070  * @param[in]   handle          Handle of camcorder context.
1071  * @param[in]   type            Allocation type of camcorder context.
1072  * @return      void
1073  * @remarks
1074  * @see         _mmcamcorder_create_pipeline()
1075  *
1076  */
1077 void _mmcamcorder_destroy_pipeline(MMHandleType handle, int type);
1078
1079 /**
1080  * This function sets gstreamer element status.
1081  * If the gstreamer fails to set status or returns asynchronous mode,
1082  * this function waits for state changed until timeout expired.
1083  *
1084  * @param[in]   pipeline        Pointer of pipeline
1085  * @param[in]   target_state    newly setting status
1086  * @return      This function returns zero on success, or negative value with error code.
1087  * @remarks
1088  * @see
1089  *
1090  */
1091 int _mmcamcorder_gst_set_state(MMHandleType handle, GstElement *pipeline, GstState target_state);
1092
1093 /**
1094  * This function sets gstreamer element status, asynchronously.
1095  * Regardless of processing, it returns immediately.
1096  *
1097  * @param[in]   pipeline        Pointer of pipeline
1098  * @param[in]   target_state    newly setting status
1099  * @return      This function returns zero on success, or negative value with error code.
1100  * @remarks
1101  * @see
1102  *
1103  */
1104 int _mmcamcorder_gst_set_state_async(MMHandleType handle, GstElement *pipeline, GstState target_state);
1105
1106 /* For xvimagesink */
1107 GstBusSyncReply __mmcamcorder_sync_callback(GstBus *bus, GstMessage *message, gulong data);
1108
1109 /* For querying capabilities */
1110 int _mmcamcorder_read_vidsrc_info(int videodevidx, camera_conf **configure_info);
1111
1112 /* for performance check */
1113 void _mmcamcorder_video_current_framerate_init(MMHandleType handle);
1114 int _mmcamcorder_video_current_framerate(MMHandleType handle);
1115 int _mmcamcorder_video_average_framerate(MMHandleType handle);
1116
1117 #ifdef __cplusplus
1118 }
1119 #endif
1120
1121 #endif /* __MM_CAMCORDER_INTERNAL_H__ */