Support H/W video encoder when use zero copy format
[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_VCONV,
440         _MMCAMCORDER_ENCSINK_VENC,
441         _MMCAMCORDER_ENCSINK_VENC_QUE,
442         _MMCAMCORDER_ENCSINK_ITOG,
443         _MMCAMCORDER_ENCSINK_ICROP,
444         _MMCAMCORDER_ENCSINK_ISCALE,
445         _MMCAMCORDER_ENCSINK_IFILT,
446         _MMCAMCORDER_ENCSINK_IQUE,
447         _MMCAMCORDER_ENCSINK_IENC,
448         _MMCAMCORDER_ENCSINK_MUX,
449         _MMCAMCORDER_ENCSINK_SINK,
450
451         /* Pipeline element of Stillshot output */
452         _MMCAMCORDER_STILLSHOTSINK_BIN,
453         _MMCAMCORDER_STILLSHOTSINK_QUE,
454         _MMCAMCORDER_STILLSHOTSINK_TOGGLE,
455         _MMCAMCORDER_STILLSHOTSINK_CLS,
456         _MMCAMCORDER_STILLSHOTSINK_CROP,
457         _MMCAMCORDER_STILLSHOTSINK_FILT,
458         _MMCAMCORDER_STILLSHOTSINK_SCALE,
459         _MMCAMCORDER_STILLSHOTSINK_FILT2,
460         _MMCAMCORDER_STILLSHOTSINK_ENC,
461         _MMCAMCORDER_STILLSHOTSINK_SINK,
462
463         _MMCamcorder_PIPELINE_ELEMENT_NUM,
464 } _MMCAMCORDER_PIPELINE_ELELMENT;
465
466 /**
467  * Command type for Camcorder.
468  */
469 typedef enum {
470         _MMCAMCORDER_CMD_CREATE,
471         _MMCAMCORDER_CMD_DESTROY,
472         _MMCAMCORDER_CMD_REALIZE,
473         _MMCAMCORDER_CMD_UNREALIZE,
474         _MMCAMCORDER_CMD_START,
475         _MMCAMCORDER_CMD_STOP,
476         _MMCAMCORDER_CMD_CAPTURESTART,
477         _MMCAMCORDER_CMD_CAPTURESTOP,
478         _MMCAMCORDER_CMD_RECORD,
479         _MMCAMCORDER_CMD_PAUSE,
480         _MMCAMCORDER_CMD_COMMIT,
481         _MMCAMCORDER_CMD_CANCEL,
482         _MMCAMCORDER_CMD_QUIT,
483 } _MMCamcorderCommandType;
484
485 /**
486  * System state change cause
487  */
488 typedef enum {
489         _MMCAMCORDER_STATE_CHANGE_NORMAL = 0,
490         _MMCAMCORDER_STATE_CHANGE_BY_ASM,
491 } _MMCamcorderStateChange;
492
493
494 /*=======================================================================================
495 | STRUCTURE DEFINITIONS                                                                 |
496 ========================================================================================*/
497 /**
498  * MMCamcorder Gstreamer Element
499  */
500 typedef struct {
501         unsigned int id;                /**< Gstreamer piplinem element name */
502         GstElement *gst;                /**< Gstreamer element */
503 } _MMCamcorderGstElement;
504
505 /**
506  * MMCamcorder information for KPI measurement
507  */
508 typedef struct {
509         int current_fps;                /**< current fps of this second */
510         int average_fps;                /**< average fps  */
511         unsigned int video_framecount;  /**< total number of video frame */
512         unsigned int last_framecount;   /**< total number of video frame in last measurement */
513         struct timeval init_video_time; /**< time when start to measure */
514         struct timeval last_video_time; /**< last measurement time */
515 } _MMCamcorderKPIMeasure;
516
517 /**
518  * MMCamcorder information for Multi-Thread Safe
519  */
520 typedef struct {
521         GMutex *lock;                   /**< Mutex (for general use) */
522         GCond *cond;                    /**< Condition (for general use) */
523         GMutex *cmd_lock;               /**< Mutex (for command) */
524         GMutex *state_lock;             /**< Mutex (for state change) */
525         GMutex *gst_state_lock;         /**< Mutex (for state change) */
526         GMutex *message_cb_lock;        /**< Mutex (for message callback) */
527         GMutex *vcapture_cb_lock;       /**< Mutex (for video capture callback) */
528         GMutex *vstream_cb_lock;        /**< Mutex (for video stream callback) */
529         GMutex *astream_cb_lock;        /**< Mutex (for audio stream callback) */
530 } _MMCamcorderMTSafe;
531
532 /**
533  * MMCamcorder information for command loop
534  */
535 typedef struct {
536         pthread_t pCommandThread;                                                                                       /**< Command loop handle */
537         GQueue *cmd_queue;                                                                                                      /**< Queue for Command loop */
538         sem_t sema;                                                                                                             /**< Semaphore for Command loop */
539 } _MMCamcorderCommand;
540
541 /**
542  * MMCamcorder command information
543  */
544 typedef struct {
545         MMHandleType handle;                                                                                            /**< camcorder handle */
546         _MMCamcorderCommandType type;                                                                           /**< Type of command */
547 } __MMCamcorderCmdInfo;
548
549 /**
550  * MMCamcorder Sub Context
551  */
552 typedef struct {
553         bool isMaxsizePausing;                  /**< Because of size limit, pipeline is paused. */
554         bool isMaxtimePausing;                  /**< Because of time limit, pipeline is paused. */
555         int element_num;                        /**< count of element */
556         int cam_stability_count;                /**< camsensor stability count. the count of frame will drop */
557         GstClockTime pipeline_time;             /**< current time of Gstreamer Pipeline */
558         GstClockTime pause_time;                /**< amount of time while pipeline is in PAUSE state.*/
559         GstClockTime stillshot_time;            /**< pipeline time of capturing moment*/
560         gboolean is_modified_rate;              /**< whether recording motion rate is modified or not */
561         gboolean error_occurs;                  /**< flag for error */
562         int error_code;                         /**< error code for internal gstreamer error */
563         gboolean ferror_send;                   /**< file write/seek error **/
564         guint ferror_count;                     /**< file write/seek error count **/
565         GstClockTime previous_slot_time;
566         int display_interval;                   /**< This value is set as 'GST_SECOND / display FPS' */
567         gboolean bget_eos;                      /**< Whether getting EOS */
568         gboolean bencbin_capture;               /**< Use Encodebin for capturing */
569         gboolean audio_disable;                 /**< whether audio is disabled or not when record */
570         int videosrc_rotate;                    /**< rotate of videosrc */
571
572         /* For dropping video frame when start recording */
573         int drop_vframe;                        /**< When this value is bigger than zero and pass_first_vframe is zero, MSL will drop video frame though cam_stability count is bigger then zero. */
574         int pass_first_vframe;                  /**< When this value is bigger than zero, MSL won't drop video frame though "drop_vframe" is bigger then zero. */
575
576         /* INI information */
577         unsigned int fourcc;                    /**< Get fourcc value of camera INI file */
578         _MMCamcorderImageInfo *info_image;      /**< extra information for image capture */
579         _MMCamcorderVideoInfo *info_video;      /**< extra information for video recording */
580         _MMCamcorderAudioInfo *info_audio;      /**< extra information for audio recording */
581
582         _MMCamcorderGstElement *element;        /**< array of Gstreamer element */
583         _MMCamcorderKPIMeasure kpi;             /**< information related with performance measurement */
584
585         type_element *VideosinkElement;         /**< configure data of videosink element */
586         gboolean SensorEncodedCapture;          /**< whether camera sensor support encoded image capture */
587         gboolean internal_encode;               /**< whether use internal encoding function */
588 } _MMCamcorderSubContext;
589
590 /**
591   * _MMCamcorderContext
592   */
593 typedef struct mmf_camcorder {
594         /* information */
595         int type;               /**< mmcamcorder_mode_type */
596         int state;              /**< state of camcorder */
597         int target_state;       /**< Target state that want to set. This is a flag that
598                                    * stands for async state changing. If this value differ from state,
599                                    * it means state is changing now asychronously. */
600
601         /* handles */
602         MMHandleType attributes;               /**< Attribute handle */
603         _MMCamcorderSubContext *sub_context;   /**< sub context */
604         mm_exif_info_t *exif_info;             /**< EXIF */
605         GList *buffer_probes;                  /**< a list of buffer probe handle */
606         GList *event_probes;                   /**< a list of event probe handle */
607         GList *data_probes;                    /**< a list of data probe handle */
608         GList *signals;                        /**< a list of signal handle */
609         GList *msg_data;                       /**< a list of msg data */
610         camera_conf *conf_main;                /**< Camera configure Main structure */
611         camera_conf *conf_ctrl;                /**< Camera configure Control structure */
612         int asm_handle_sh;                     /**< Audio session manager handle of share session */
613         int asm_handle_ex;                     /**< Audio session manager handle of exclusive session */
614         guint pipeline_cb_event_id;            /**< Event source ID of pipeline message callback */
615         guint setting_event_id;                /**< Event source ID of attributes setting to sensor */
616         SOUND_INFO snd_info;                   /**< Sound handle for multishot capture */
617
618         /* callback handlers */
619         MMMessageCallback msg_cb;                               /**< message callback */
620         void *msg_cb_param;                                     /**< message callback parameter */
621         mm_camcorder_video_stream_callback vstream_cb;          /**< Video stream callback */
622         void *vstream_cb_param;                                 /**< Video stream callback parameter */
623         mm_camcorder_audio_stream_callback astream_cb;          /**< Audio stream callback */
624         void *astream_cb_param;                                 /**< Audio stream callback parameter */
625         mm_camcorder_video_capture_callback vcapture_cb;        /**< Video capture callback */
626         void *vcapture_cb_param;                                /**< Video capture callback parameter */
627         int (*command)(MMHandleType, int);                      /**< camcorder's command */
628
629         /* etc */
630         _MMCamcorderMTSafe mtsafe;                              /**< Thread safe */
631         _MMCamcorderCommand cmd;                                /**< information for command loop */
632         int sync_state_change;                                  /**< Change framework state synchronously */
633         int quick_device_close;
634         int state_change_by_system;                             /**< MSL changes its state by itself because of system(ASM,MDM..) **/
635         int asm_event_code;                                     /**< event code of audio session manager */
636         pthread_mutex_t sound_lock;                             /**< Capture sound mutex */
637         pthread_cond_t sound_cond;                              /**< Capture sound cond */
638         int use_zero_copy_format;                               /**< Whether use zero copy format for camera input */
639         int shutter_sound_policy;                               /**< shutter sound policy */
640
641         _MMCamcorderInfoConverting caminfo_convert[CAMINFO_CONVERT_NUM];        /**< converting structure of camera info */
642         _MMCamcorderEnumConvert enum_conv[ENUM_CONVERT_NUM];                    /**< enum converting list that is modified by ini info */
643
644         int reserved[4];                        /**< reserved */
645 } mmf_camcorder_t;
646
647 /*=======================================================================================
648 | EXTERN GLOBAL VARIABLE                                                                |
649 ========================================================================================*/
650
651 /*=======================================================================================
652 | GLOBAL FUNCTION PROTOTYPES                                                            |
653 ========================================================================================*/
654 /**
655  *      This function creates camcorder for capturing still image and recording.
656  *
657  *      @param[out]     handle          Specifies the camcorder  handle
658  *      @param[in]      info            Preset information of camcorder
659  *      @return         This function returns zero on success, or negative value with error code.
660  *      @remarks        When this function calls successfully, camcorder  handle will be filled with a @n
661  *                      valid value and the state of  the camcorder  will become MM_CAMCORDER_STATE_NULL.@n
662  *                      Note that  it's not ready to working camcorder. @n
663  *                      You should call mmcamcorder_realize before starting camcorder.
664  *      @see            _mmcamcorder_create
665  */
666 int _mmcamcorder_create(MMHandleType *handle, MMCamPreset *info);
667
668 /**
669  *      This function destroys instance of camcorder. 
670  *
671  *      @param[in]      hcamcorder      Specifies the camcorder  handle
672  *      @return         This function returns zero on success, or negative value with error code.
673  *      @see            _mmcamcorder_create
674  */
675 int _mmcamcorder_destroy(MMHandleType hcamcorder);
676
677 /**
678  *      This function allocates memory for camcorder.
679  *
680  *      @param[in]      hcamcorder      Specifies the camcorder  handle
681  *      @return         This function returns zero on success, or negative value with error code.
682  *      @remarks        This function can  be called successfully when current state is MM_CAMCORDER_STATE_NULL @n
683  *                      and  the state of the camcorder  will become MM_CAMCORDER_STATE_READY. @n
684  *                      Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
685  *      @see            _mmcamcorder_unrealize
686  *      @pre            MM_CAMCORDER_STATE_NULL
687  *      @post           MM_CAMCORDER_STATE_READY
688  */
689 int _mmcamcorder_realize(MMHandleType hcamcorder);
690
691 /**
692  *      This function free allocated memory for camcorder.
693  *
694  *      @param[in]      hcamcorder      Specifies the camcorder  handle
695  *      @return         This function returns zero on success, or negative value with error code.
696  *      @remarks        This function release all resources which are allocated for the camcorder engine.@n
697  *                      This function can  be called successfully when current state is MM_CAMCORDER_STATE_READY and  @n
698  *                      the state of the camcorder  will become MM_CAMCORDER_STATE_NULL. @n
699  *                      Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
700  *      @see            _mmcamcorder_realize
701  *      @pre            MM_CAMCORDER_STATE_READY
702  *      @post           MM_CAMCORDER_STATE_NULL
703  */
704 int _mmcamcorder_unrealize(MMHandleType hcamcorder);
705
706 /**
707  *      This function is to start previewing.
708  *
709  *      @param[in]      hcamcorder      Specifies the camcorder  handle
710  *      @return         This function returns zero on success, or negative value with error code.
711  *      @remarks        This function can  be called successfully when current state is MM_CAMCORDER_STATE_READY and  @n
712  *                      the state of the camcorder  will become MM_CAMCORDER_STATE_PREPARE. @n
713  *                      Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
714  *      @see            _mmcamcorder_stop
715  */
716 int _mmcamcorder_start(MMHandleType hcamcorder);
717
718 /**
719  *      This function is to stop previewing.
720  *
721  *      @param[in]      hcamcorder      Specifies the camcorder  handle
722  *      @return         This function returns zero on success, or negative value with error code.
723  *      @remarks        This function can  be called successfully when current state is MM_CAMCORDER_STATE_PREPARE and  @n
724  *                      the state of the camcorder  will become MM_CAMCORDER_STATE_READY.@n
725  *                      Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
726  *      @see            _mmcamcorder_start
727  */
728 int _mmcamcorder_stop(MMHandleType hcamcorder);
729
730 /**
731  *      This function to start capturing of still images.
732  *
733  *      @param[in]      hcamcorder      Specifies the camcorder  handle.
734  *      @return         This function returns zero on success, or negative value with error code.
735  *      @remarks        This function can  be called successfully when current state is MM_CAMCORDER_STATE_PREPARE and @n
736  *                      the state of the camcorder  will become MM_CAMCORDER_STATE_CAPTURING. @n
737  *                      Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
738  *      @see            _mmcamcorder_capture_stop
739  */
740 int _mmcamcorder_capture_start(MMHandleType hcamcorder);
741
742 /**
743  *      This function is to stop capturing still images.
744  *
745  *      @param[in]      hcamcorder      Specifies the camcorder  handle
746  *      @return         This function returns zero on success, or negative value with error code.
747  *      @remarks        This function can  be called successfully when current state is MM_CAMCORDER_STATE_CAPTURING and @n
748  *                      the state of the camcorder  will become MM_CAMCORDER_STATE_PREPARE. @n
749  *                      Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
750  *      @see            _mmcamcorder_capture_start
751  */
752 int _mmcamcorder_capture_stop(MMHandleType hcamcorder);
753
754 /**
755  *      This function is to start  video and audio recording.
756  *
757  *      @param[in]      hcamcorder      Specifies the camcorder  handle
758  *      @return         This function returns zero on success, or negative value with error code.
759  *      @remarks        This function can  be called successfully when current state is @n
760  *                      MM_CAMCORDER_STATE_PREPARE or MM_CAMCORDER_STATE_PAUSED and  @n
761  *                      the state of the camcorder  will become MM_CAMCORDER_STATE_RECORDING.@n
762  *                      Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
763  *      @see            _mmcamcorder_pause
764  */
765 int _mmcamcorder_record(MMHandleType hcamcorder);
766
767 /**
768  *      This function is to pause video and audio recording
769  *
770  *      @param[in]      hcamcorder      Specifies the camcorder  handle
771  *      @return         This function returns zero on success, or negative value with error code.
772  *      @remarks        This function can  be called successfully when current state is MM_CAMCORDER_STATE_RECORDING and  @n
773  *                      the  state of the camcorder  will become MM_CAMCORDER_STATE_PAUSED.@n
774  *                      Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.@n
775  *      @see            _mmcamcorder_record
776  */
777 int _mmcamcorder_pause(MMHandleType hcamcorder);
778
779 /**
780  *      This function is to stop video and audio  recording and  save results.
781  *
782  *      @param[in]      hcamcorder      Specifies the camcorder  handle
783  *      @return         This function returns zero on success, or negative value with error code.
784  *      @remarks        This function can  be called successfully when current state is @n
785  *                      MM_CAMCORDER_STATE_PAUSED or MM_CAMCORDER_STATE_RECORDING and  @n
786  *                      the state of the camcorder  will become MM_CAMCORDER_STATE_PREPARE. @n
787  *                      Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION
788  *      @see            _mmcamcorder_cancel
789  */
790 int _mmcamcorder_commit(MMHandleType hcamcorder);
791
792 /**
793  *      This function is to stop video and audio recording and do not save results.
794  *
795  *      @param[in]      hcamcorder      Specifies the camcorder  handle
796  *      @return         This function returns zero on success, or negative value with error code.
797  *      @remarks        This function can  be called successfully when current state is @n
798  *                      MM_CAMCORDER_STATE_PAUSED or MM_CAMCORDER_STATE_RECORDING and  @n
799  *                      the state of the camcorder  will become MM_CAMCORDER_STATE_PREPARE. @n
800  *                      Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
801  *      @see            _mmcamcorder_commit
802  */
803 int _mmcamcorder_cancel(MMHandleType hcamcorder);
804
805 /**
806  *      This function calls after commiting action finished asynchronously. 
807  *      In this function, remaining process , such as state change, happens.
808  *
809  *      @param[in]      hcamcorder      Specifies the camcorder  handle
810  *      @return         This function returns zero on success, or negative value with error code.
811  *      @remarks        This function can  be called successfully when current state is @n
812  *                      MM_CAMCORDER_STATE_PAUSED or MM_CAMCORDER_STATE_RECORDING and  @n
813  *                      the state of the camcorder  will become MM_CAMCORDER_STATE_PREPARE. @n
814  *                      Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
815  *      @see            _mmcamcorder_commit
816  */
817 int _mmcamcorder_commit_async_end(MMHandleType hcamcorder);
818
819 /**
820  *      This function is to set callback for receiving messages from camcorder.
821  *
822  *      @param[in]      hcamcorder      Specifies the camcorder  handle
823  *      @param[in]      callback        Specifies the function pointer of callback function
824  *      @param[in]      user_data       Specifies the user poiner for passing to callback function
825  *
826  *      @return         This function returns zero on success, or negative value with error code.
827  *      @remarks        typedef bool (*mm_message_callback) (int msg, mm_messageType *param, void *user_param);@n
828  *              @n
829  *              typedef union                           @n
830  *              {                                                       @n
831  *                      int code;                               @n
832  *                      struct                                  @n
833  *                      {                                               @n
834  *                              int total;                      @n
835  *                              int elapsed;            @n
836  *                      } time;                                 @n
837  *                      struct                                  @n
838  *                      {                                               @n
839  *                              int previous;           @n
840  *                              int current;                    @n
841  *                      } state;                                        @n
842  *              } mm_message_type;      @n
843  *                                                                      @n
844  *              If a  message value for mm_message_callback is MM_MESSAGE_STATE_CHANGED, @n
845  *              state value in mm_message_type  will be a mmcamcorder_state_type enum value;@n
846  *              @n
847  *              If  a message value for mm_message_callback is MM_MESSAGE_ERROR,  @n
848  *              the code value in mm_message_type will be a mmplayer_error_type enum value;
849  *
850  *      @see            mm_message_type,  mmcamcorder_state_type,  mmcamcorder_error_type
851  */
852 int _mmcamcorder_set_message_callback(MMHandleType hcamcorder,
853                                       MMMessageCallback callback,
854                                       void *user_data);
855
856 /**
857  *      This function is to set callback for video stream.
858  *
859  *      @param[in]      hcamcorder      Specifies the camcorder  handle
860  *      @param[in]      callback        Specifies the function pointer of callback function
861  *      @param[in]      user_data       Specifies the user poiner for passing to callback function
862  *
863  *      @return         This function returns zero on success, or negative value with error code.
864  *      @see            mmcamcorder_error_type
865  */
866 int _mmcamcorder_set_video_stream_callback(MMHandleType hcamcorder,
867                                            mm_camcorder_video_stream_callback callback,
868                                            void *user_data);
869
870 /**
871  *      This function is to set callback for audio stream.
872  *
873  *      @param[in]      hcamcorder      Specifies the camcorder handle
874  *      @param[in]      callback        Specifies the function pointer of callback function
875  *      @param[in]      user_data       Specifies the user poiner for passing to callback function
876  *
877  *      @return         This function returns zero on success, or negative value with error code.
878  *      @see            mmcamcorder_error_type
879  */
880 int _mmcamcorder_set_audio_stream_callback(MMHandleType handle,
881                                            mm_camcorder_audio_stream_callback callback,
882                                            void *user_data);
883
884 /**
885  *      This function is to set callback for video capture.
886  *
887  *      @param[in]      hcamcorder      Specifies the camcorder  handle
888  *      @param[in]      callback        Specifies the function pointer of callback function
889  *      @param[in]      user_data       Specifies the user poiner for passing to callback function
890  *
891  *      @return         This function returns zero on success, or negative value with error code.
892  *      @see            mmcamcorder_error_type
893  */
894 int _mmcamcorder_set_video_capture_callback(MMHandleType hcamcorder,
895                                             mm_camcorder_video_capture_callback callback,
896                                             void *user_data);
897
898 /**
899  *      This function returns current state of camcorder, or negative value with error code.
900  *
901  *      @param[in]      hcamcorder      Specifies the camcorder  handle.
902  *      @return         This function returns current state of camcorder, or negative value with error code.
903  *      @see            mmcamcorder_state_type
904  */
905 int _mmcamcorder_get_current_state(MMHandleType hcamcorder);
906
907 int _mmcamcorder_init_focusing(MMHandleType handle);
908 int _mmcamcorder_adjust_focus(MMHandleType handle, int direction);
909 int _mmcamcorder_adjust_manual_focus(MMHandleType handle, int direction);
910 int _mmcamcorder_adjust_auto_focus(MMHandleType handle);
911 int _mmcamcorder_stop_focusing(MMHandleType handle);
912
913 /**
914  * This function gets current state of camcorder.
915  *
916  * @param       void
917  * @return      This function returns state of current camcorder context
918  * @remarks
919  * @see         _mmcamcorder_set_state()
920  *
921  */
922 int _mmcamcorder_streamer_init(void);
923
924 /**
925  * This function gets current state of camcorder.
926  *
927  * @param       void
928  * @return      This function returns state of current camcorder context
929  * @remarks
930  * @see         _mmcamcorder_set_state()
931  *
932  */
933 int _mmcamcorder_display_init(void);
934
935 /**
936  * This function gets current state of camcorder.
937  *
938  * @param[in]   handle          Handle of camcorder context.
939  * @return      This function returns state of current camcorder context
940  * @remarks
941  * @see         _mmcamcorder_set_state()
942  *
943  */
944 int _mmcamcorder_get_state(MMHandleType handle);
945
946 /**
947  * This function sets new state of camcorder.
948  *
949  * @param[in]   handle          Handle of camcorder context.
950  * @param[in]   state           setting state value of camcorder.
951  * @return      void
952  * @remarks
953  * @see         _mmcamcorder_get_state()
954  *
955  */
956 void _mmcamcorder_set_state(MMHandleType handle, int state);
957
958 /**
959  * This function gets asynchronous status of MSL Camcroder. 
960  *
961  * @param[in]   handle          Handle of camcorder context.
962  * @param[in]   target_state    setting target_state value of camcorder.
963  * @return      This function returns asynchrnous state.
964  * @remarks
965  * @see         _mmcamcorder_set_async_state()
966  *
967  */
968 int _mmcamcorder_get_async_state(MMHandleType handle);
969
970 /**
971  * This function sets new target state of camcorder.
972  *
973  * @param[in]   handle          Handle of camcorder context.
974  * @param[in]   target_state    setting target_state value of camcorder.
975  * @return      This function returns zero on success, or negative value with error code.
976  * @remarks
977  * @see         _mmcamcorder_get_async_state(), _mmcamcorder_set_async_cancel()
978  *
979  */
980 int _mmcamcorder_set_async_state(MMHandleType handle, int target_state);
981
982 /**
983  * This function sets new target state of camcorder.
984  *
985  * @param[in]   handle          Handle of camcorder context.
986  * @return      gboolean
987  * @remarks
988  * @see         _mmcamcorder_set_async_cancel()
989  *
990  */
991 gboolean _mmcamcorder_set_async_cancel(MMHandleType handle);
992
993 /**
994  * Check whether camcorder changes its state now.
995  *
996  * @param[in]   handle          Handle of camcorder context.
997  * @return      gboolean
998  * @remarks
999  * @see         _mmcamcorder_set_async_state(), _mmcamcorder_set_async_cancel()
1000  *
1001  */
1002 gboolean _mmcamcorder_is_state_changing(MMHandleType handle);
1003
1004 /**
1005  * This function allocates structure of subsidiary attributes.
1006  *
1007  * @param[in]   type            Allocation type of camcorder context.
1008  * @return      This function returns structure pointer on success, NULL value on failure.
1009  * @remarks
1010  * @see         _mmcamcorder_dealloc_subcontext()
1011  *
1012  */
1013 _MMCamcorderSubContext *_mmcamcorder_alloc_subcontext(int type);
1014
1015 /**
1016  * This function releases structure of subsidiary attributes.
1017  *
1018  * @param[in]   sc              Handle of camcorder subcontext.
1019  * @return      void
1020  * @remarks
1021  * @see         _mmcamcorder_alloc_subcontext()
1022  *
1023  */
1024 void _mmcamcorder_dealloc_subcontext(_MMCamcorderSubContext *sc);
1025
1026 /**
1027  * This function sets command function according to the type.
1028  *
1029  * @param[in]   handle          Handle of camcorder context.
1030  * @param[in]   type            Allocation type of camcorder context.
1031  * @return      This function returns MM_ERROR_NONE on success, or other values with error code.
1032  * @remarks
1033  * @see         __mmcamcorder_video_command(), __mmcamcorder_audio_command(), __mmcamcorder_image_command()
1034  *
1035  */
1036 int _mmcamcorder_set_functions(MMHandleType handle, int type);
1037
1038 /**
1039  * This function is callback function of main pipeline.
1040  * Once this function is registered with certain pipeline using gst_bus_add_watch(),
1041  * this callback will be called every time when there is upcomming message from pipeline.
1042  * Basically, this function is used as error handling function, now.
1043  *
1044  * @param[in]   bus             pointer of buf that called this function.
1045  * @param[in]   message         callback message from pipeline.
1046  * @param[in]   data            user data.
1047  * @return      This function returns true on success, or false value with error
1048  * @remarks
1049  * @see         __mmcamcorder_create_preview_pipeline()
1050  *
1051  */
1052 gboolean _mmcamcorder_pipeline_cb_message(GstBus *bus, GstMessage *message, gpointer data);
1053
1054 /**
1055  * This function is callback function of main pipeline.
1056  * Once this function is registered with certain pipeline using gst_bus_set_sync_handler(),
1057  * this callback will be called every time when there is upcomming message from pipeline.
1058  * Basically, this function is used as sync error handling function, now.
1059  *
1060  * @param[in]   bus             pointer of buf that called this function.
1061  * @param[in]   message         callback message from pipeline.
1062  * @param[in]   data            user data.
1063  * @return      This function returns true on success, or false value with error
1064  * @remarks
1065  * @see         __mmcamcorder_create_preview_pipeline()
1066  *
1067  */
1068 GstBusSyncReply _mmcamcorder_pipeline_bus_sync_callback(GstBus *bus, GstMessage *message, gpointer data);
1069
1070 /**
1071  * This function create main pipeline according to type.
1072  *
1073  * @param[in]   handle          Handle of camcorder context.
1074  * @param[in]   type            Allocation type of camcorder context.
1075  * @return      This function returns zero on success, or negative value with error code.
1076  * @remarks
1077  * @see         _mmcamcorder_destroy_pipeline()
1078  *
1079  */
1080 int _mmcamcorder_create_pipeline(MMHandleType handle, int type);
1081
1082 /**
1083  * This function release all element of main pipeline according to type.
1084  *
1085  * @param[in]   handle          Handle of camcorder context.
1086  * @param[in]   type            Allocation type of camcorder context.
1087  * @return      void
1088  * @remarks
1089  * @see         _mmcamcorder_create_pipeline()
1090  *
1091  */
1092 void _mmcamcorder_destroy_pipeline(MMHandleType handle, int type);
1093
1094 /**
1095  * This function sets gstreamer element status. 
1096  * If the gstreamer fails to set status or returns asynchronous mode,
1097  * this function waits for state changed until timeout expired.
1098  *
1099  * @param[in]   pipeline        Pointer of pipeline
1100  * @param[in]   target_state    newly setting status
1101  * @return      This function returns zero on success, or negative value with error code.
1102  * @remarks
1103  * @see
1104  *
1105  */
1106 int _mmcamcorder_gst_set_state(MMHandleType handle, GstElement *pipeline, GstState target_state);
1107
1108 /**
1109  * This function sets gstreamer element status, asynchronously. 
1110  * Regardless of processing, it returns immediately.
1111  *
1112  * @param[in]   pipeline        Pointer of pipeline
1113  * @param[in]   target_state    newly setting status
1114  * @return      This function returns zero on success, or negative value with error code.
1115  * @remarks
1116  * @see 
1117  *
1118  */
1119 int _mmcamcorder_gst_set_state_async(MMHandleType handle, GstElement *pipeline, GstState target_state);
1120
1121 /* For xvimagesink */
1122 GstBusSyncReply __mmcamcorder_sync_callback(GstBus *bus, GstMessage *message, gulong data);
1123
1124 /* For querying capabilities */
1125 int _mmcamcorder_read_vidsrc_info(int videodevidx, camera_conf **configure_info);
1126
1127 /* for performance check */
1128 void _mmcamcorder_video_current_framerate_init(MMHandleType handle);
1129 int _mmcamcorder_video_current_framerate(MMHandleType handle);
1130 int _mmcamcorder_video_average_framerate(MMHandleType handle);
1131
1132 /* command */
1133 void _mmcamcorder_delete_command_info(__MMCamcorderCmdInfo *cmdinfo);
1134 int _mmcamcorder_create_command_loop(MMHandleType handle);
1135 int _mmcamcorder_destroy_command_loop(MMHandleType handle);
1136 int _mmcamcorder_append_command(MMHandleType handle, __MMCamcorderCmdInfo *info);
1137 int _mmcamcorder_append_simple_command(MMHandleType handle, _MMCamcorderCommandType type);
1138 void *_mmcamcorder_command_loop_thread(void *arg);
1139
1140 #ifdef __cplusplus
1141 }
1142 #endif
1143
1144 #endif /* __MM_CAMCORDER_INTERNAL_H__ */