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