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