4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jeongmo Yang <jm80.yang@samsung.com>
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #ifndef __MM_CAMCORDER_INTERNAL_H__
23 #define __MM_CAMCORDER_INTERNAL_H__
25 /*=======================================================================================
27 ========================================================================================*/
32 #include <semaphore.h>
36 #include <mm_attrs_private.h>
37 #include <mm_message.h>
42 #include "mm_camcorder.h"
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"
61 /*=======================================================================================
63 ========================================================================================*/
64 #define _mmcam_dbg_verb(fmt, args...) debug_verbose (" "fmt"\n", ##args);
65 #define _mmcam_dbg_log(fmt, args...) debug_log (" "fmt"\n", ##args);
66 #define _mmcam_dbg_warn(fmt, args...) debug_warning (" "fmt"\n", ##args);
67 #define _mmcam_dbg_err(fmt, args...) debug_error (" "fmt"\n", ##args);
68 #define _mmcam_dbg_crit(fmt, args...) debug_critical (" "fmt"\n", ##args);
71 * Macro for checking validity and debugging
73 #define mmf_return_if_fail( expr ) \
77 _mmcam_dbg_err( "failed [%s]", #expr); \
82 * Macro for checking validity and debugging
84 #define mmf_return_val_if_fail( expr, val ) \
88 _mmcam_dbg_err("failed [%s]", #expr); \
94 * Macro for getting array size
96 #define ARRAY_SIZE(a) (sizeof((a)) / sizeof((a)[0]))
99 /* gstreamer element creation macro */
100 #define _MMCAMCORDER_PIPELINE_MAKE(sub_context, element, eid, name /*char* */, err) \
101 if (element[eid].gst != NULL) { \
102 _mmcam_dbg_err("The element(Pipeline) is existed. element_id=[%d], name=[%s]", eid, name); \
103 gst_object_unref(element[eid].gst); \
105 element[eid].id = eid; \
106 element[eid].gst = gst_pipeline_new(name); \
107 if (element[eid].gst == NULL) { \
108 _mmcam_dbg_err("Pipeline creation fail. element_id=[%d], name=[%s]", eid, name); \
109 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
110 goto pipeline_creation_error; \
112 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
115 #define _MMCAMCORDER_BIN_MAKE(sub_context, element, eid, name /*char* */, err) \
116 if (element[eid].gst != NULL) { \
117 _mmcam_dbg_err("The element(Bin) is existed. element_id=[%d], name=[%s]", eid, name); \
118 gst_object_unref(element[eid].gst); \
120 element[eid].id = eid; \
121 element[eid].gst = gst_bin_new(name); \
122 if (element[eid].gst == NULL) { \
123 _mmcam_dbg_err("Bin creation fail. element_id=[%d], name=[%s]\n", eid, name); \
124 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
125 goto pipeline_creation_error; \
127 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
130 #define _MMCAMCORDER_ELEMENT_MAKE(sub_context, element, eid, name /*char* */, nickname /*char* */, elist, err) \
131 if (element[eid].gst != NULL) { \
132 _mmcam_dbg_err("The element is existed. element_id=[%d], name=[%s]", eid, name); \
133 gst_object_unref(element[eid].gst); \
135 traceBegin(TTRACE_TAG_CAMERA, "MMCAMCORDER:ELEMENT_MAKE:%s", name); \
136 element[eid].gst = gst_element_factory_make(name, nickname); \
137 traceEnd(TTRACE_TAG_CAMERA); \
138 if (element[eid].gst == NULL) { \
139 _mmcam_dbg_err("Element creation fail. element_id=[%d], name=[%s]", eid, name); \
140 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
141 goto pipeline_creation_error; \
143 _mmcam_dbg_log("Element creation done. element_id=[%d], name=[%s]", eid, name); \
144 element[eid].id = eid; \
145 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
146 err = MM_ERROR_NONE; \
148 elist = g_list_append(elist, &(element[eid]));
150 #define _MMCAMCORDER_ELEMENT_MAKE2(sub_context, element, eid, name /*char* */, nickname /*char* */, err) \
151 if (element[eid].gst != NULL) { \
152 _mmcam_dbg_err("The element is existed. element_id=[%d], name=[%s]", eid, name); \
153 gst_object_unref(element[eid].gst); \
155 element[eid].gst = gst_element_factory_make(name, nickname); \
156 if (element[eid].gst == NULL) { \
157 _mmcam_dbg_err("Element creation fail. element_id=[%d], name=[%s]", eid, name); \
158 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
160 _mmcam_dbg_log("Element creation done. element_id=[%d], name=[%s]", eid, name); \
161 element[eid].id = eid; \
162 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
163 err = MM_ERROR_NONE; \
166 #define _MMCAMCORDER_ELEMENT_MAKE_IGNORE_ERROR(sub_context, element, eid, name /*char* */, nickname /*char* */, elist) \
167 if (element[eid].gst != NULL) { \
168 _mmcam_dbg_err("The element is existed. element_id=[%d], name=[%s]", eid, name); \
169 gst_object_unref(element[eid].gst); \
171 element[eid].gst = gst_element_factory_make(name, nickname); \
172 if (element[eid].gst == NULL) { \
173 _mmcam_dbg_err("Element creation fail. element_id=[%d], name=[%s], but keep going...", eid, name); \
175 _mmcam_dbg_log("Element creation done. element_id=[%d], name=[%s]", eid, name); \
176 element[eid].id = eid; \
177 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
178 elist = g_list_append(elist, &(element[eid])); \
181 #define _MMCAMCORDER_ENCODEBIN_ELMGET(sub_context, eid, name /*char* */, err) \
182 if (sub_context->encode_element[eid].gst != NULL) { \
183 _mmcam_dbg_err("The element is existed. element_id=[%d], name=[%s]", eid, name); \
184 gst_object_unref(sub_context->encode_element[eid].gst); \
186 sub_context->encode_element[eid].id = eid; \
187 g_object_get(G_OBJECT(sub_context->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst), name, &(sub_context->encode_element[eid].gst), NULL); \
188 if (sub_context->encode_element[eid].gst == NULL) { \
189 _mmcam_dbg_err("Encode Element get fail. element_id=[%d], name=[%s]", eid, name); \
190 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
191 goto pipeline_creation_error; \
193 gst_object_unref(sub_context->encode_element[eid].gst); \
194 g_object_weak_ref(G_OBJECT(sub_context->encode_element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
197 /* GStreamer element remove macro */
198 #define _MMCAMCORDER_ELEMENT_REMOVE(element, eid) \
199 if (element[eid].gst != NULL) { \
200 gst_object_unref(element[eid].gst); \
203 #define _MM_GST_ELEMENT_LINK_MANY gst_element_link_many
204 #define _MM_GST_ELEMENT_LINK gst_element_link
205 #define _MM_GST_ELEMENT_UNLINK gst_element_unlink
206 #define _MM_GST_PAD_LINK gst_pad_link
208 #define _MM_GST_PAD_LINK_UNREF(srcpad, sinkpad, err, if_fail_goto)\
210 GstPadLinkReturn ret = GST_PAD_LINK_OK;\
211 if (srcpad == NULL || sinkpad == NULL) {\
212 if (srcpad == NULL) {\
213 _mmcam_dbg_err("srcpad is NULL");\
215 gst_object_unref(srcpad);\
218 if (sinkpad == NULL) {\
219 _mmcam_dbg_err("sinkpad is NULL");\
221 gst_object_unref(sinkpad);\
224 err = MM_ERROR_CAMCORDER_GST_LINK;\
227 ret = _MM_GST_PAD_LINK(srcpad, sinkpad);\
228 if (ret != GST_PAD_LINK_OK) {\
229 GstObject *src_parent = gst_pad_get_parent(srcpad);\
230 GstObject *sink_parent = gst_pad_get_parent(sinkpad);\
231 char *src_name = NULL;\
232 char *sink_name = NULL;\
233 g_object_get((GObject *)src_parent, "name", &src_name, NULL);\
234 g_object_get((GObject *)sink_parent, "name", &sink_name, NULL);\
235 _mmcam_dbg_err("src[%s] - sink[%s] link failed", src_name, sink_name);\
236 gst_object_unref(src_parent); src_parent = NULL;\
237 gst_object_unref(sink_parent); sink_parent = NULL;\
239 free(src_name); src_name = NULL;\
242 free(sink_name); sink_name = NULL;\
244 gst_object_unref(srcpad); srcpad = NULL;\
245 gst_object_unref(sinkpad); sinkpad = NULL;\
246 err = MM_ERROR_CAMCORDER_GST_LINK;\
249 gst_object_unref(srcpad); srcpad = NULL;\
250 gst_object_unref(sinkpad); sinkpad = NULL;\
253 #define _MM_GST_PAD_UNLINK_UNREF( srcpad, sinkpad) \
254 if (srcpad && sinkpad) { \
255 gst_pad_unlink(srcpad, sinkpad); \
257 _mmcam_dbg_warn("some pad(srcpad:%p,sinkpad:%p) is NULL", srcpad, sinkpad); \
260 gst_object_unref(srcpad); srcpad = NULL; \
263 gst_object_unref(sinkpad); sinkpad = NULL; \
266 #define _MMCAMCORDER_STATE_SET_COUNT 3 /* checking interval */
267 #define _MMCAMCORDER_STATE_CHECK_TOTALTIME 5000000L /* total wating time for state change */
268 #define _MMCAMCORDER_STATE_CHECK_INTERVAL (50*1000) /* checking interval - 50ms*/
273 #define MAX_ERROR_MESSAGE_LEN 128
277 * Default videosink type
279 #define _MMCAMCORDER_DEFAULT_VIDEOSINK_TYPE "VideosinkElementX"
282 * Default recording motion rate
284 #define _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE 1.0
287 * Total level count of manual focus */
288 #define _MMFCAMCORDER_FOCUS_TOTAL_LEVEL 8
291 * File name length limit
293 #define _MMCamcorder_FILENAME_LEN (512)
296 * Minimum integer value
298 #define _MMCAMCORDER_MIN_INT (INT_MIN)
301 * Maximum integer value
303 #define _MMCAMCORDER_MAX_INT (INT_MAX)
306 * Minimum double value
308 #define _MMCAMCORDER_MIN_DOUBLE (DBL_MIN)
311 * Maximum integer value
313 #define _MMCAMCORDER_MAX_DOUBLE (DBL_MAX)
316 * Audio timestamp margin (msec)
318 #define _MMCAMCORDER_AUDIO_TIME_MARGIN (300)
321 * Functions related with LOCK and WAIT
323 #define _MMCAMCORDER_CAST_MTSAFE(handle) (((mmf_camcorder_t*)handle)->mtsafe)
324 #define _MMCAMCORDER_LOCK_FUNC(mutex) pthread_mutex_lock(&mutex)
325 #define _MMCAMCORDER_TRYLOCK_FUNC(mutex) (!pthread_mutex_trylock(&mutex))
326 #define _MMCAMCORDER_UNLOCK_FUNC(mutex) pthread_mutex_unlock(&mutex)
328 #define _MMCAMCORDER_GET_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).lock)
329 #define _MMCAMCORDER_LOCK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_LOCK(handle))
330 #define _MMCAMCORDER_TRYLOCK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_LOCK(handle))
331 #define _MMCAMCORDER_UNLOCK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_LOCK(handle))
333 #define _MMCAMCORDER_GET_COND(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).cond)
334 #define _MMCAMCORDER_WAIT(handle) pthread_cond_wait(&_MMCAMCORDER_GET_COND(handle), &_MMCAMCORDER_GET_LOCK(handle))
335 #define _MMCAMCORDER_TIMED_WAIT(handle, timeout) pthread_cond_timedwait(&_MMCAMCORDER_GET_COND(handle), &_MMCAMCORDER_GET_LOCK(handle), &timeout)
336 #define _MMCAMCORDER_SIGNAL(handle) pthread_cond_signal(&_MMCAMCORDER_GET_COND(handle));
337 #define _MMCAMCORDER_BROADCAST(handle) pthread_cond_broadcast(&_MMCAMCORDER_GET_COND(handle));
340 #define _MMCAMCORDER_GET_CMD_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).cmd_lock)
341 #define _MMCAMCORDER_GET_CMD_COND(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).cmd_cond)
342 #define _MMCAMCORDER_LOCK_CMD(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_CMD_LOCK(handle))
343 #define _MMCAMCORDER_TRYLOCK_CMD(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_CMD_LOCK(handle))
344 #define _MMCAMCORDER_UNLOCK_CMD(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_CMD_LOCK(handle))
345 #define _MMCAMCORDER_CMD_WAIT(handle) pthread_cond_wait(&_MMCAMCORDER_GET_CMD_COND(handle), &_MMCAMCORDER_GET_CMD_LOCK(handle))
346 #define _MMCAMCORDER_CMD_TIMED_WAIT(handle, timeout) pthread_cond_timedwait(&_MMCAMCORDER_GET_CMD_COND(handle), &_MMCAMCORDER_GET_CMD_LOCK(handle), &timeout)
347 #define _MMCAMCORDER_CMD_SIGNAL(handle) pthread_cond_signal(&_MMCAMCORDER_GET_CMD_COND(handle));
350 #define _MMCAMCORDER_GET_ASM_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).asm_lock)
351 #define _MMCAMCORDER_LOCK_ASM(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_ASM_LOCK(handle))
352 #define _MMCAMCORDER_TRYLOCK_ASM(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_ASM_LOCK(handle))
353 #define _MMCAMCORDER_UNLOCK_ASM(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_ASM_LOCK(handle))
355 /* for state change */
356 #define _MMCAMCORDER_GET_STATE_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).state_lock)
357 #define _MMCAMCORDER_LOCK_STATE(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_STATE_LOCK(handle))
358 #define _MMCAMCORDER_TRYLOCK_STATE(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_STATE_LOCK(handle))
359 #define _MMCAMCORDER_UNLOCK_STATE(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_STATE_LOCK(handle))
361 /* for gstreamer state change */
362 #define _MMCAMCORDER_GET_GST_STATE_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).gst_state_lock)
363 #define _MMCAMCORDER_LOCK_GST_STATE(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_GST_STATE_LOCK(handle))
364 #define _MMCAMCORDER_TRYLOCK_GST_STATE(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_GST_STATE_LOCK(handle))
365 #define _MMCAMCORDER_UNLOCK_GST_STATE(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_GST_STATE_LOCK(handle))
367 #define _MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).gst_encode_state_lock)
368 #define _MMCAMCORDER_LOCK_GST_ENCODE_STATE(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle))
369 #define _MMCAMCORDER_TRYLOCK_GST_ENCODE_STATE(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle))
370 #define _MMCAMCORDER_UNLOCK_GST_ENCODE_STATE(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle))
372 /* for setting/calling callback */
373 #define _MMCAMCORDER_GET_MESSAGE_CALLBACK_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).message_cb_lock)
374 #define _MMCAMCORDER_LOCK_MESSAGE_CALLBACK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_MESSAGE_CALLBACK_LOCK(handle))
375 #define _MMCAMCORDER_TRYLOCK_MESSAGE_CALLBACK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_MESSAGE_CALLBACK_LOCK(handle))
376 #define _MMCAMCORDER_UNLOCK_MESSAGE_CALLBACK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_MESSAGE_CALLBACK_LOCK(handle))
378 #define _MMCAMCORDER_GET_VCAPTURE_CALLBACK_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).vcapture_cb_lock)
379 #define _MMCAMCORDER_LOCK_VCAPTURE_CALLBACK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_VCAPTURE_CALLBACK_LOCK(handle))
380 #define _MMCAMCORDER_TRYLOCK_VCAPTURE_CALLBACK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_VCAPTURE_CALLBACK_LOCK(handle))
381 #define _MMCAMCORDER_UNLOCK_VCAPTURE_CALLBACK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_VCAPTURE_CALLBACK_LOCK(handle))
383 #define _MMCAMCORDER_GET_VSTREAM_CALLBACK_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).vstream_cb_lock)
384 #define _MMCAMCORDER_LOCK_VSTREAM_CALLBACK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_VSTREAM_CALLBACK_LOCK(handle))
385 #define _MMCAMCORDER_TRYLOCK_VSTREAM_CALLBACK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_VSTREAM_CALLBACK_LOCK(handle))
386 #define _MMCAMCORDER_UNLOCK_VSTREAM_CALLBACK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_VSTREAM_CALLBACK_LOCK(handle))
388 #define _MMCAMCORDER_GET_ASTREAM_CALLBACK_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).astream_cb_lock)
389 #define _MMCAMCORDER_LOCK_ASTREAM_CALLBACK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_ASTREAM_CALLBACK_LOCK(handle))
390 #define _MMCAMCORDER_TRYLOCK_ASTREAM_CALLBACK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_ASTREAM_CALLBACK_LOCK(handle))
391 #define _MMCAMCORDER_UNLOCK_ASTREAM_CALLBACK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_ASTREAM_CALLBACK_LOCK(handle))
394 * Caster of main handle (camcorder)
396 #define MMF_CAMCORDER(h) (mmf_camcorder_t *)(h)
399 * Caster of subcontext
401 #define MMF_CAMCORDER_SUBCONTEXT(h) (((mmf_camcorder_t *)(h))->sub_context)
403 /* LOCAL CONSTANT DEFINITIONS */
405 * Total Numbers of Attribute values.
406 * If you increase any enum of attribute values, you also have to increase this.
408 #define MM_CAMCORDER_MODE_NUM 3 /**< Number of mode type */
409 #define MM_CAMCORDER_COLOR_TONE_NUM 31 /**< Number of color-tone modes */
410 #define MM_CAMCORDER_WHITE_BALANCE_NUM 10 /**< Number of WhiteBalance modes*/
411 #define MM_CAMCORDER_SCENE_MODE_NUM 16 /**< Number of program-modes */
412 #define MM_CAMCORDER_FOCUS_MODE_NUM 6 /**< Number of focus mode*/
413 #define MM_CAMCORDER_AUTO_FOCUS_NUM 5 /**< Total count of auto focus type*/
414 #define MM_CAMCORDER_FOCUS_STATE_NUM 4 /**< Number of focus state */
415 #define MM_CAMCORDER_ISO_NUM 10 /**< Number of ISO */
416 #define MM_CAMCORDER_AUTO_EXPOSURE_NUM 9 /**< Number of Auto exposure type */
417 #define MM_CAMCORDER_WDR_NUM 3 /**< Number of wide dynamic range */
418 #define MM_CAMCORDER_FLIP_NUM 4 /**< Number of Filp mode */
419 #define MM_CAMCORDER_ROTATION_NUM 4 /**< Number of Rotation mode */
420 #define MM_CAMCORDER_AHS_NUM 4 /**< Number of anti-handshake */
421 #define MM_CAMCORDER_VIDEO_STABILIZATION_NUM 2 /**< Number of video stabilization */
422 #define MM_CAMCORDER_HDR_CAPTURE_NUM 3 /**< Number of HDR capture mode */
423 #define MM_CAMCORDER_GEOMETRY_METHOD_NUM 5 /**< Number of geometry method */
424 #define MM_CAMCORDER_TAG_ORT_NUM 8 /**< Number of tag orientation */
425 #define MM_CAMCORDER_STROBE_MODE_NUM 8 /**< Number of strobe mode type */
426 #define MM_CAMCORDER_STROBE_CONTROL_NUM 3 /**< Number of strobe control type */
427 #define MM_CAMCORDER_DETECT_MODE_NUM 2 /**< Number of detect mode type */
430 /*=======================================================================================
432 ========================================================================================*/
434 * Command for Camcorder.
437 /* Command for Video/Audio recording */
438 _MMCamcorder_CMD_RECORD,
439 _MMCamcorder_CMD_PAUSE,
440 _MMCamcorder_CMD_CANCEL,
441 _MMCamcorder_CMD_COMMIT,
443 /* Command for Image capture */
444 _MMCamcorder_CMD_CAPTURE,
446 /* Command for Preview(Video/Image only effective) */
447 _MMCamcorder_CMD_PREVIEW_START,
448 _MMCamcorder_CMD_PREVIEW_STOP,
455 _MMCamcorder_SINGLE_SHOT,
456 _MMCamcorder_MULTI_SHOT,
460 * Audio session registered type
463 _MMCamcorder_ASM_NO_NEED_REGISTER,
464 _MMCamcorder_ASM_SESSION_REGISTERED_INTERNALLY,
465 _MMCamcorder_ASM_SESSION_REGISTERED_BY_OUTSIDE,
469 * Enumerations for manual focus direction.
470 * If focusing mode is not "MM_CAMCORDER_AF_MODE_MANUAL", this value will be ignored.
472 enum MMCamcorderMfLensDir {
473 MM_CAMCORDER_MF_LENS_DIR_FORWARD = 1, /**< Focus direction to forward */
474 MM_CAMCORDER_MF_LENS_DIR_BACKWARD, /**< Focus direction to backward */
475 MM_CAMCORDER_MF_LENS_DIR_NUM, /**< Total number of the directions */
479 * Camcorder Pipeline's Element name.
480 * @note index of element.
483 _MMCAMCORDER_NONE = (-1),
485 /* Main Pipeline Element */
486 _MMCAMCORDER_MAIN_PIPE = 0x00,
488 /* Pipeline element of Video input */
489 _MMCAMCORDER_VIDEOSRC_SRC,
490 _MMCAMCORDER_VIDEOSRC_FILT,
491 _MMCAMCORDER_VIDEOSRC_CLS_QUE,
492 _MMCAMCORDER_VIDEOSRC_CLS,
493 _MMCAMCORDER_VIDEOSRC_CLS_FILT,
494 _MMCAMCORDER_VIDEOSRC_QUE,
495 _MMCAMCORDER_VIDEOSRC_DECODE,
497 /* Pipeline element of Video output */
498 _MMCAMCORDER_VIDEOSINK_QUE,
499 _MMCAMCORDER_VIDEOSINK_CLS,
500 _MMCAMCORDER_VIDEOSINK_SINK,
502 _MMCAMCORDER_PIPELINE_ELEMENT_NUM,
503 } _MMCAMCORDER_PREVIEW_PIPELINE_ELELMENT;
506 * Camcorder Pipeline's Element name.
507 * @note index of element.
510 _MMCAMCORDER_ENCODE_NONE = (-1),
512 /* Main Pipeline Element */
513 _MMCAMCORDER_ENCODE_MAIN_PIPE = 0x00,
515 /* Pipeline element of Audio input */
516 _MMCAMCORDER_AUDIOSRC_BIN,
517 _MMCAMCORDER_AUDIOSRC_SRC,
518 _MMCAMCORDER_AUDIOSRC_FILT,
519 _MMCAMCORDER_AUDIOSRC_QUE,
520 _MMCAMCORDER_AUDIOSRC_CONV,
521 _MMCAMCORDER_AUDIOSRC_VOL,
523 /* Pipeline element of Encodebin */
524 _MMCAMCORDER_ENCSINK_BIN,
525 _MMCAMCORDER_ENCSINK_SRC,
526 _MMCAMCORDER_ENCSINK_FILT,
527 _MMCAMCORDER_ENCSINK_ENCBIN,
528 _MMCAMCORDER_ENCSINK_AQUE,
529 _MMCAMCORDER_ENCSINK_CONV,
530 _MMCAMCORDER_ENCSINK_AENC,
531 _MMCAMCORDER_ENCSINK_AENC_QUE,
532 _MMCAMCORDER_ENCSINK_VQUE,
533 _MMCAMCORDER_ENCSINK_VCONV,
534 _MMCAMCORDER_ENCSINK_VENC,
535 _MMCAMCORDER_ENCSINK_VENC_QUE,
536 _MMCAMCORDER_ENCSINK_ITOG,
537 _MMCAMCORDER_ENCSINK_ICROP,
538 _MMCAMCORDER_ENCSINK_ISCALE,
539 _MMCAMCORDER_ENCSINK_IFILT,
540 _MMCAMCORDER_ENCSINK_IQUE,
541 _MMCAMCORDER_ENCSINK_IENC,
542 _MMCAMCORDER_ENCSINK_MUX,
543 _MMCAMCORDER_ENCSINK_SINK,
545 _MMCAMCORDER_ENCODE_PIPELINE_ELEMENT_NUM,
546 } _MMCAMCORDER_ENCODE_PIPELINE_ELELMENT;
549 _MMCAMCORDER_TASK_THREAD_STATE_NONE,
550 _MMCAMCORDER_TASK_THREAD_STATE_SOUND_PLAY_START,
551 _MMCAMCORDER_TASK_THREAD_STATE_SOUND_SOLO_PLAY_START,
552 _MMCAMCORDER_TASK_THREAD_STATE_ENCODE_PIPE_CREATE,
553 _MMCAMCORDER_TASK_THREAD_STATE_CHECK_CAPTURE_IN_RECORDING,
554 _MMCAMCORDER_TASK_THREAD_STATE_EXIT,
555 } _MMCamcorderTaskThreadState;
558 * System state change cause
561 _MMCAMCORDER_STATE_CHANGE_NORMAL = 0,
562 _MMCAMCORDER_STATE_CHANGE_BY_ASM,
563 } _MMCamcorderStateChange;
566 /*=======================================================================================
567 | STRUCTURE DEFINITIONS |
568 ========================================================================================*/
570 * MMCamcorder Gstreamer Element
573 unsigned int id; /**< Gstreamer piplinem element name */
574 GstElement *gst; /**< Gstreamer element */
575 } _MMCamcorderGstElement;
578 * MMCamcorder information for KPI measurement
581 int current_fps; /**< current fps of this second */
582 int average_fps; /**< average fps */
583 unsigned int video_framecount; /**< total number of video frame */
584 unsigned int last_framecount; /**< total number of video frame in last measurement */
585 struct timeval init_video_time; /**< time when start to measure */
586 struct timeval last_video_time; /**< last measurement time */
587 } _MMCamcorderKPIMeasure;
590 * MMCamcorder information for Multi-Thread Safe
593 pthread_mutex_t lock; /**< Mutex (for general use) */
594 pthread_cond_t cond; /**< Condition (for general use) */
595 pthread_mutex_t cmd_lock; /**< Mutex (for command) */
596 pthread_cond_t cmd_cond; /**< Condition (for command) */
597 pthread_mutex_t asm_lock; /**< Mutex (for ASM) */
598 pthread_mutex_t state_lock; /**< Mutex (for state change) */
599 pthread_mutex_t gst_state_lock; /**< Mutex (for gst pipeline state change) */
600 pthread_mutex_t gst_encode_state_lock; /**< Mutex (for gst encode pipeline state change) */
601 pthread_mutex_t message_cb_lock; /**< Mutex (for message callback) */
602 pthread_mutex_t vcapture_cb_lock; /**< Mutex (for video capture callback) */
603 pthread_mutex_t vstream_cb_lock; /**< Mutex (for video stream callback) */
604 pthread_mutex_t astream_cb_lock; /**< Mutex (for audio stream callback) */
605 } _MMCamcorderMTSafe;
609 * MMCamcorder Sub Context
612 bool isMaxsizePausing; /**< Because of size limit, pipeline is paused. */
613 bool isMaxtimePausing; /**< Because of time limit, pipeline is paused. */
614 int element_num; /**< count of element */
615 int encode_element_num; /**< count of encode element */
616 int cam_stability_count; /**< camsensor stability count. the count of frame will drop */
617 GstClockTime pipeline_time; /**< current time of Gstreamer Pipeline */
618 GstClockTime pause_time; /**< amount of time while pipeline is in PAUSE state.*/
619 GstClockTime stillshot_time; /**< pipeline time of capturing moment*/
620 gboolean is_modified_rate; /**< whether recording motion rate is modified or not */
621 gboolean ferror_send; /**< file write/seek error **/
622 guint ferror_count; /**< file write/seek error count **/
623 GstClockTime previous_slot_time;
624 int display_interval; /**< This value is set as 'GST_SECOND / display FPS' */
625 gboolean bget_eos; /**< Whether getting EOS */
626 gboolean bencbin_capture; /**< Use Encodebin for capturing */
627 gboolean audio_disable; /**< whether audio is disabled or not when record */
628 int videosrc_rotate; /**< rotate of videosrc */
630 /* For dropping video frame when start recording */
631 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. */
632 int pass_first_vframe; /**< When this value is bigger than zero, MSL won't drop video frame though "drop_vframe" is bigger then zero. */
634 /* INI information */
635 unsigned int fourcc; /**< Get fourcc value of camera INI file */
636 _MMCamcorderImageInfo *info_image; /**< extra information for image capture */
637 _MMCamcorderVideoInfo *info_video; /**< extra information for video recording */
638 _MMCamcorderAudioInfo *info_audio; /**< extra information for audio recording */
640 _MMCamcorderGstElement *element; /**< array of preview element */
641 _MMCamcorderGstElement *encode_element; /**< array of encode element */
642 _MMCamcorderKPIMeasure kpi; /**< information related with performance measurement */
644 type_element *VideosinkElement; /**< configure data of videosink element */
645 type_element *VideoconvertElement; /**< configure data of videoconvert element */
646 gboolean SensorEncodedCapture; /**< whether camera sensor support encoded image capture */
647 gboolean internal_encode; /**< whether use internal encoding function */
648 } _MMCamcorderSubContext;
651 * _MMCamcorderContext
653 typedef struct mmf_camcorder {
655 int type; /**< mmcamcorder_mode_type */
656 int device_type; /**< device type */
657 int state; /**< state of camcorder */
658 int target_state; /**< Target state that want to set. This is a flag that
659 * stands for async state changing. If this value differ from state,
660 * it means state is changing now asychronously. */
663 MMHandleType attributes; /**< Attribute handle */
664 _MMCamcorderSubContext *sub_context; /**< sub context */
665 mm_exif_info_t *exif_info; /**< EXIF */
666 GList *buffer_probes; /**< a list of buffer probe handle */
667 GList *event_probes; /**< a list of event probe handle */
668 GList *signals; /**< a list of signal handle */
669 GList *msg_data; /**< a list of msg data */
670 camera_conf *conf_main; /**< Camera configure Main structure */
671 camera_conf *conf_ctrl; /**< Camera configure Control structure */
672 int asm_handle; /**< Audio session manager handle */
673 guint pipeline_cb_event_id; /**< Event source ID of pipeline message callback */
674 guint encode_pipeline_cb_event_id; /**< Event source ID of encode pipeline message callback */
675 guint setting_event_id; /**< Event source ID of attributes setting to sensor */
676 SOUND_INFO snd_info; /**< Sound handle for multishot capture */
678 /* callback handlers */
679 MMMessageCallback msg_cb; /**< message callback */
680 void *msg_cb_param; /**< message callback parameter */
681 mm_camcorder_video_stream_callback vstream_cb; /**< Video stream callback */
682 void *vstream_cb_param; /**< Video stream callback parameter */
683 mm_camcorder_audio_stream_callback astream_cb; /**< Audio stream callback */
684 void *astream_cb_param; /**< Audio stream callback parameter */
685 mm_camcorder_video_capture_callback vcapture_cb; /**< Video capture callback */
686 void *vcapture_cb_param; /**< Video capture callback parameter */
687 int (*command)(MMHandleType, int); /**< camcorder's command */
688 mm_camcorder_video_frame_render_error_callback render_error_cb; /* video frame render error callback */
689 void* render_error_cb_user_param; /* video frame render error callback user parameter */
692 _MMCamcorderMTSafe mtsafe; /**< Thread safe */
693 int state_change_by_system; /**< MSL changes its state by itself because of system */
694 int asm_event_code; /**< event code of audio session manager */
695 pthread_mutex_t sound_lock; /**< Capture sound mutex */
696 pthread_cond_t sound_cond; /**< Capture sound cond */
697 pthread_mutex_t restart_preview_lock; /**< Capture sound mutex */
698 int use_zero_copy_format; /**< Whether use zero copy format for camera input */
699 int support_media_packet_preview_cb; /**< Whether support zero copy format for camera input */
700 int shutter_sound_policy; /**< shutter sound policy */
701 int brightness_default; /**< default value of brightness */
702 int brightness_step_denominator; /**< denominator of brightness bias step */
703 int support_zsl_capture; /**< support Zero Shutter Lag capture */
704 char *model_name; /**< model name from system info */
705 char *software_version; /**< software_version from system info */
706 int capture_sound_count; /**< count for capture sound */
707 int asm_register; /**< Use ASM internally */
708 int asm_event_type; /**< Event type of ASM */
709 int asm_session_type; /**< Session type of ASM */
710 int asm_session_options; /**< Session option of ASM */
711 char *root_directory; /**< Root directory for device */
712 int resolution_changed; /**< Flag for preview resolution change */
714 _MMCamcorderInfoConverting caminfo_convert[CAMINFO_CONVERT_NUM]; /**< converting structure of camera info */
715 _MMCamcorderEnumConvert enum_conv[ENUM_CONVERT_NUM]; /**< enum converting list that is modified by ini info */
717 gboolean capture_in_recording; /**< Flag for capture while recording */
719 gboolean error_occurs; /**< flag for error */
720 int error_code; /**< error code for internal gstreamer error */
723 pthread_t task_thread; /**< thread for task */
724 pthread_mutex_t task_thread_lock; /**< mutex for task thread */
725 pthread_cond_t task_thread_cond; /**< cond for task thread */
726 _MMCamcorderTaskThreadState task_thread_state; /**< state of task thread */
728 int reserved[4]; /**< reserved */
731 /*=======================================================================================
732 | EXTERN GLOBAL VARIABLE |
733 ========================================================================================*/
735 /*=======================================================================================
736 | GLOBAL FUNCTION PROTOTYPES |
737 ========================================================================================*/
739 * This function creates camcorder for capturing still image and recording.
741 * @param[out] handle Specifies the camcorder handle
742 * @param[in] info Preset information of camcorder
743 * @return This function returns zero on success, or negative value with error code.
744 * @remarks When this function calls successfully, camcorder handle will be filled with a @n
745 * valid value and the state of the camcorder will become MM_CAMCORDER_STATE_NULL.@n
746 * Note that it's not ready to working camcorder. @n
747 * You should call mmcamcorder_realize before starting camcorder.
748 * @see _mmcamcorder_create
750 int _mmcamcorder_create(MMHandleType *handle, MMCamPreset *info);
753 * This function destroys instance of camcorder.
755 * @param[in] hcamcorder Specifies the camcorder handle
756 * @return This function returns zero on success, or negative value with error code.
757 * @see _mmcamcorder_create
759 int _mmcamcorder_destroy(MMHandleType hcamcorder);
762 * This function allocates memory for camcorder.
764 * @param[in] hcamcorder Specifies the camcorder handle
765 * @return This function returns zero on success, or negative value with error code.
766 * @remarks This function can be called successfully when current state is MM_CAMCORDER_STATE_NULL @n
767 * and the state of the camcorder will become MM_CAMCORDER_STATE_READY. @n
768 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
769 * @see _mmcamcorder_unrealize
770 * @pre MM_CAMCORDER_STATE_NULL
771 * @post MM_CAMCORDER_STATE_READY
773 int _mmcamcorder_realize(MMHandleType hcamcorder);
776 * This function free allocated memory for camcorder.
778 * @param[in] hcamcorder Specifies the camcorder handle
779 * @return This function returns zero on success, or negative value with error code.
780 * @remarks This function release all resources which are allocated for the camcorder engine.@n
781 * This function can be called successfully when current state is MM_CAMCORDER_STATE_READY and @n
782 * the state of the camcorder will become MM_CAMCORDER_STATE_NULL. @n
783 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
784 * @see _mmcamcorder_realize
785 * @pre MM_CAMCORDER_STATE_READY
786 * @post MM_CAMCORDER_STATE_NULL
788 int _mmcamcorder_unrealize(MMHandleType hcamcorder);
791 * This function is to start previewing.
793 * @param[in] hcamcorder Specifies the camcorder handle
794 * @return This function returns zero on success, or negative value with error code.
795 * @remarks This function can be called successfully when current state is MM_CAMCORDER_STATE_READY and @n
796 * the state of the camcorder will become MM_CAMCORDER_STATE_PREPARE. @n
797 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
798 * @see _mmcamcorder_stop
800 int _mmcamcorder_start(MMHandleType hcamcorder);
803 * This function is to stop previewing.
805 * @param[in] hcamcorder Specifies the camcorder handle
806 * @return This function returns zero on success, or negative value with error code.
807 * @remarks This function can be called successfully when current state is MM_CAMCORDER_STATE_PREPARE and @n
808 * the state of the camcorder will become MM_CAMCORDER_STATE_READY.@n
809 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
810 * @see _mmcamcorder_start
812 int _mmcamcorder_stop(MMHandleType hcamcorder);
815 * This function to start capturing of still images.
817 * @param[in] hcamcorder Specifies the camcorder handle.
818 * @return This function returns zero on success, or negative value with error code.
819 * @remarks This function can be called successfully when current state is MM_CAMCORDER_STATE_PREPARE and @n
820 * the state of the camcorder will become MM_CAMCORDER_STATE_CAPTURING. @n
821 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
822 * @see _mmcamcorder_capture_stop
824 int _mmcamcorder_capture_start(MMHandleType hcamcorder);
827 * This function is to stop capturing still images.
829 * @param[in] hcamcorder Specifies the camcorder handle
830 * @return This function returns zero on success, or negative value with error code.
831 * @remarks This function can be called successfully when current state is MM_CAMCORDER_STATE_CAPTURING and @n
832 * the state of the camcorder will become MM_CAMCORDER_STATE_PREPARE. @n
833 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
834 * @see _mmcamcorder_capture_start
836 int _mmcamcorder_capture_stop(MMHandleType hcamcorder);
839 * This function is to start video and audio recording.
841 * @param[in] hcamcorder Specifies the camcorder handle
842 * @return This function returns zero on success, or negative value with error code.
843 * @remarks This function can be called successfully when current state is @n
844 * MM_CAMCORDER_STATE_PREPARE or MM_CAMCORDER_STATE_PAUSED and @n
845 * the state of the camcorder will become MM_CAMCORDER_STATE_RECORDING.@n
846 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
847 * @see _mmcamcorder_pause
849 int _mmcamcorder_record(MMHandleType hcamcorder);
852 * This function is to pause video and audio recording
854 * @param[in] hcamcorder Specifies the camcorder handle
855 * @return This function returns zero on success, or negative value with error code.
856 * @remarks This function can be called successfully when current state is MM_CAMCORDER_STATE_RECORDING and @n
857 * the state of the camcorder will become MM_CAMCORDER_STATE_PAUSED.@n
858 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.@n
859 * @see _mmcamcorder_record
861 int _mmcamcorder_pause(MMHandleType hcamcorder);
864 * This function is to stop video and audio recording and save results.
866 * @param[in] hcamcorder Specifies the camcorder handle
867 * @return This function returns zero on success, or negative value with error code.
868 * @remarks This function can be called successfully when current state is @n
869 * MM_CAMCORDER_STATE_PAUSED or MM_CAMCORDER_STATE_RECORDING and @n
870 * the state of the camcorder will become MM_CAMCORDER_STATE_PREPARE. @n
871 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION
872 * @see _mmcamcorder_cancel
874 int _mmcamcorder_commit(MMHandleType hcamcorder);
877 * This function is to stop video and audio recording and do not save results.
879 * @param[in] hcamcorder Specifies the camcorder handle
880 * @return This function returns zero on success, or negative value with error code.
881 * @remarks This function can be called successfully when current state is @n
882 * MM_CAMCORDER_STATE_PAUSED or MM_CAMCORDER_STATE_RECORDING and @n
883 * the state of the camcorder will become MM_CAMCORDER_STATE_PREPARE. @n
884 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
885 * @see _mmcamcorder_commit
887 int _mmcamcorder_cancel(MMHandleType hcamcorder);
890 * This function calls after commiting action finished asynchronously.
891 * In this function, remaining process , such as state change, happens.
893 * @param[in] hcamcorder Specifies the camcorder handle
894 * @return This function returns zero on success, or negative value with error code.
895 * @remarks This function can be called successfully when current state is @n
896 * MM_CAMCORDER_STATE_PAUSED or MM_CAMCORDER_STATE_RECORDING and @n
897 * the state of the camcorder will become MM_CAMCORDER_STATE_PREPARE. @n
898 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
899 * @see _mmcamcorder_commit
901 int _mmcamcorder_commit_async_end(MMHandleType hcamcorder);
904 * This function is to set callback for receiving messages from camcorder.
906 * @param[in] hcamcorder Specifies the camcorder handle
907 * @param[in] callback Specifies the function pointer of callback function
908 * @param[in] user_data Specifies the user poiner for passing to callback function
910 * @return This function returns zero on success, or negative value with error code.
911 * @remarks typedef bool (*mm_message_callback) (int msg, mm_messageType *param, void *user_param);@n
926 * } mm_message_type; @n
928 * If a message value for mm_message_callback is MM_MESSAGE_STATE_CHANGED, @n
929 * state value in mm_message_type will be a mmcamcorder_state_type enum value;@n
931 * If a message value for mm_message_callback is MM_MESSAGE_ERROR, @n
932 * the code value in mm_message_type will be a mmplayer_error_type enum value;
934 * @see mm_message_type, mmcamcorder_state_type, mmcamcorder_error_type
936 int _mmcamcorder_set_message_callback(MMHandleType hcamcorder,
937 MMMessageCallback callback,
941 * This function is to set callback for video stream.
943 * @param[in] hcamcorder Specifies the camcorder handle
944 * @param[in] callback Specifies the function pointer of callback function
945 * @param[in] user_data Specifies the user poiner for passing to callback function
947 * @return This function returns zero on success, or negative value with error code.
948 * @see mmcamcorder_error_type
950 int _mmcamcorder_set_video_stream_callback(MMHandleType hcamcorder,
951 mm_camcorder_video_stream_callback callback,
956 * This function is to set callback for video frame render error.
958 * @param[in] hcamcorder Specifies the camcorder handle
959 * @param[in] callback Specifies the function pointer of callback function
960 * @param[in] user_data Specifies the user poiner for passing to callback function
962 * @return This function returns zero on success, or negative value with error code.
963 * @see mmcamcorder_error_type
965 int _mmcamcorder_set_video_frame_render_error_callback(MMHandleType handle,
966 mm_camcorder_video_frame_render_error_callback callback,
970 * This function is to set callback for audio stream.
972 * @param[in] hcamcorder Specifies the camcorder handle
973 * @param[in] callback Specifies the function pointer of callback function
974 * @param[in] user_data Specifies the user poiner for passing to callback function
976 * @return This function returns zero on success, or negative value with error code.
977 * @see mmcamcorder_error_type
979 int _mmcamcorder_set_audio_stream_callback(MMHandleType handle,
980 mm_camcorder_audio_stream_callback callback,
984 * This function is to set callback for video capture.
986 * @param[in] hcamcorder Specifies the camcorder handle
987 * @param[in] callback Specifies the function pointer of callback function
988 * @param[in] user_data Specifies the user poiner for passing to callback function
990 * @return This function returns zero on success, or negative value with error code.
991 * @see mmcamcorder_error_type
993 int _mmcamcorder_set_video_capture_callback(MMHandleType hcamcorder,
994 mm_camcorder_video_capture_callback callback,
998 * This function returns current state of camcorder, or negative value with error code.
1000 * @param[in] hcamcorder Specifies the camcorder handle.
1001 * @return This function returns current state of camcorder, or negative value with error code.
1002 * @see mmcamcorder_state_type
1004 int _mmcamcorder_get_current_state(MMHandleType hcamcorder);
1006 int _mmcamcorder_init_focusing(MMHandleType handle);
1007 int _mmcamcorder_adjust_focus(MMHandleType handle, int direction);
1008 int _mmcamcorder_adjust_manual_focus(MMHandleType handle, int direction);
1009 int _mmcamcorder_adjust_auto_focus(MMHandleType handle);
1010 int _mmcamcorder_stop_focusing(MMHandleType handle);
1013 * This function gets current state of camcorder.
1016 * @return This function returns state of current camcorder context
1018 * @see _mmcamcorder_set_state()
1021 int _mmcamcorder_streamer_init(void);
1024 * This function gets current state of camcorder.
1027 * @return This function returns state of current camcorder context
1029 * @see _mmcamcorder_set_state()
1032 int _mmcamcorder_display_init(void);
1035 * This function gets current state of camcorder.
1037 * @param[in] handle Handle of camcorder context.
1038 * @return This function returns state of current camcorder context
1040 * @see _mmcamcorder_set_state()
1043 int _mmcamcorder_get_state(MMHandleType handle);
1046 * This function sets new state of camcorder.
1048 * @param[in] handle Handle of camcorder context.
1049 * @param[in] state setting state value of camcorder.
1052 * @see _mmcamcorder_get_state()
1055 void _mmcamcorder_set_state(MMHandleType handle, int state);
1058 * This function gets asynchronous status of MSL Camcroder.
1060 * @param[in] handle Handle of camcorder context.
1061 * @param[in] target_state setting target_state value of camcorder.
1062 * @return This function returns asynchrnous state.
1064 * @see _mmcamcorder_set_async_state()
1067 int _mmcamcorder_get_async_state(MMHandleType handle);
1070 * This function allocates structure of subsidiary attributes.
1072 * @param[in] type Allocation type of camcorder context.
1073 * @return This function returns structure pointer on success, NULL value on failure.
1075 * @see _mmcamcorder_dealloc_subcontext()
1078 _MMCamcorderSubContext *_mmcamcorder_alloc_subcontext(int type);
1081 * This function releases structure of subsidiary attributes.
1083 * @param[in] sc Handle of camcorder subcontext.
1086 * @see _mmcamcorder_alloc_subcontext()
1089 void _mmcamcorder_dealloc_subcontext(_MMCamcorderSubContext *sc);
1092 * This function sets command function according to the type.
1094 * @param[in] handle Handle of camcorder context.
1095 * @param[in] type Allocation type of camcorder context.
1096 * @return This function returns MM_ERROR_NONE on success, or other values with error code.
1098 * @see __mmcamcorder_video_command(), __mmcamcorder_audio_command(), __mmcamcorder_image_command()
1101 int _mmcamcorder_set_functions(MMHandleType handle, int type);
1104 * This function is callback function of main pipeline.
1105 * Once this function is registered with certain pipeline using gst_bus_add_watch(),
1106 * this callback will be called every time when there is upcomming message from pipeline.
1107 * Basically, this function is used as error handling function, now.
1109 * @param[in] bus pointer of buf that called this function.
1110 * @param[in] message callback message from pipeline.
1111 * @param[in] data user data.
1112 * @return This function returns true on success, or false value with error
1114 * @see __mmcamcorder_create_preview_pipeline()
1117 gboolean _mmcamcorder_pipeline_cb_message(GstBus *bus, GstMessage *message, gpointer data);
1120 * This function is callback function of main pipeline.
1121 * Once this function is registered with certain pipeline using gst_bus_set_sync_handler(),
1122 * this callback will be called every time when there is upcomming message from pipeline.
1123 * Basically, this function is used as sync error handling function, now.
1125 * @param[in] bus pointer of buf that called this function.
1126 * @param[in] message callback message from pipeline.
1127 * @param[in] data user data.
1128 * @return This function returns true on success, or false value with error
1130 * @see __mmcamcorder_create_preview_pipeline()
1133 GstBusSyncReply _mmcamcorder_pipeline_bus_sync_callback(GstBus *bus, GstMessage *message, gpointer data);
1136 * This function is callback function of main pipeline.
1137 * Once this function is registered with certain pipeline using gst_bus_set_sync_handler(),
1138 * this callback will be called every time when there is upcomming message from pipeline.
1139 * Basically, this function is used as sync error handling function, now.
1141 * @param[in] bus pointer of buf that called this function.
1142 * @param[in] message callback message from pipeline.
1143 * @param[in] data user data.
1144 * @return This function returns true on success, or false value with error
1146 * @see __mmcamcorder_create_audiop_with_encodebin()
1149 GstBusSyncReply _mmcamcorder_audio_pipeline_bus_sync_callback(GstBus *bus, GstMessage *message, gpointer data);
1153 * This function create main pipeline according to type.
1155 * @param[in] handle Handle of camcorder context.
1156 * @param[in] type Allocation type of camcorder context.
1157 * @return This function returns zero on success, or negative value with error code.
1159 * @see _mmcamcorder_destroy_pipeline()
1162 int _mmcamcorder_create_pipeline(MMHandleType handle, int type);
1165 * This function release all element of main pipeline according to type.
1167 * @param[in] handle Handle of camcorder context.
1168 * @param[in] type Allocation type of camcorder context.
1171 * @see _mmcamcorder_create_pipeline()
1174 void _mmcamcorder_destroy_pipeline(MMHandleType handle, int type);
1177 * This function sets gstreamer element status.
1178 * If the gstreamer fails to set status or returns asynchronous mode,
1179 * this function waits for state changed until timeout expired.
1181 * @param[in] pipeline Pointer of pipeline
1182 * @param[in] target_state newly setting status
1183 * @return This function returns zero on success, or negative value with error code.
1188 int _mmcamcorder_gst_set_state(MMHandleType handle, GstElement *pipeline, GstState target_state);
1191 * This function sets gstreamer element status, asynchronously.
1192 * Regardless of processing, it returns immediately.
1194 * @param[in] pipeline Pointer of pipeline
1195 * @param[in] target_state newly setting status
1196 * @return This function returns zero on success, or negative value with error code.
1201 int _mmcamcorder_gst_set_state_async(MMHandleType handle, GstElement *pipeline, GstState target_state);
1203 /* For xvimagesink */
1204 GstBusSyncReply __mmcamcorder_sync_callback(GstBus *bus, GstMessage *message, gulong data);
1206 /* For querying capabilities */
1207 int _mmcamcorder_read_vidsrc_info(int videodevidx, camera_conf **configure_info);
1209 /* for performance check */
1210 void _mmcamcorder_video_current_framerate_init(MMHandleType handle);
1211 int _mmcamcorder_video_current_framerate(MMHandleType handle);
1212 int _mmcamcorder_video_average_framerate(MMHandleType handle);
1218 #endif /* __MM_CAMCORDER_INTERNAL_H__ */