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 ========================================================================================*/
31 #include <semaphore.h>
35 #include <mm_attrs_private.h>
36 #include <mm_message.h>
37 #include <mm_sound_focus.h>
39 #include <gst/video/video-format.h>
42 #include <restriction.h> /* device policy manager */
44 #include "mm_camcorder.h"
46 #include "mm_camcorder_resource.h"
48 /* camcorder sub module */
49 #include "mm_camcorder_attribute.h"
50 #include "mm_camcorder_platform.h"
51 #include "mm_camcorder_stillshot.h"
52 #include "mm_camcorder_videorec.h"
53 #include "mm_camcorder_audiorec.h"
54 #include "mm_camcorder_gstcommon.h"
55 #include "mm_camcorder_exifinfo.h"
56 #include "mm_camcorder_util.h"
57 #include "mm_camcorder_configure.h"
58 #include "mm_camcorder_sound.h"
64 /*=======================================================================================
66 ========================================================================================*/
67 #define _mmcam_dbg_verb(fmt, args...) debug_verbose (" "fmt"\n", ##args);
68 #define _mmcam_dbg_log(fmt, args...) debug_log (" "fmt"\n", ##args);
69 #define _mmcam_dbg_warn(fmt, args...) debug_warning (" "fmt"\n", ##args);
70 #define _mmcam_dbg_err(fmt, args...) debug_error (" "fmt"\n", ##args);
71 #define _mmcam_dbg_crit(fmt, args...) debug_critical (" "fmt"\n", ##args);
74 * Macro for checking validity and debugging
76 #define mmf_return_if_fail( expr ) \
80 _mmcam_dbg_err( "failed [%s]", #expr); \
85 * Macro for checking validity and debugging
87 #define mmf_return_val_if_fail( expr, val ) \
91 _mmcam_dbg_err("failed [%s]", #expr); \
97 * Macro for getting array size
99 #define ARRAY_SIZE(a) (sizeof((a)) / sizeof((a)[0]))
102 /* gstreamer element creation macro */
103 #define _MMCAMCORDER_PIPELINE_MAKE(sub_context, element, eid, name /*char* */, err) \
104 if (element[eid].gst != NULL) { \
105 _mmcam_dbg_err("The element(Pipeline) is existed. element_id=[%d], name=[%s]", eid, name); \
106 gst_object_unref(element[eid].gst); \
108 element[eid].id = eid; \
109 element[eid].gst = gst_pipeline_new(name); \
110 if (element[eid].gst == NULL) { \
111 _mmcam_dbg_err("Pipeline creation fail. element_id=[%d], name=[%s]", eid, name); \
112 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
113 goto pipeline_creation_error; \
115 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
118 #define _MMCAMCORDER_BIN_MAKE(sub_context, element, eid, name /*char* */, err) \
119 if (element[eid].gst != NULL) { \
120 _mmcam_dbg_err("The element(Bin) is existed. element_id=[%d], name=[%s]", eid, name); \
121 gst_object_unref(element[eid].gst); \
123 element[eid].id = eid; \
124 element[eid].gst = gst_bin_new(name); \
125 if (element[eid].gst == NULL) { \
126 _mmcam_dbg_err("Bin creation fail. element_id=[%d], name=[%s]\n", eid, name); \
127 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
128 goto pipeline_creation_error; \
130 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
133 #define _MMCAMCORDER_ELEMENT_MAKE(sub_context, element, eid, name /*char* */, nickname /*char* */, elist, err) \
134 if (element[eid].gst != NULL) { \
135 _mmcam_dbg_err("The element is existed. element_id=[%d], name=[%s]", eid, name); \
136 gst_object_unref(element[eid].gst); \
138 traceBegin(TTRACE_TAG_CAMERA, "MMCAMCORDER:ELEMENT_MAKE:%s", name); \
139 element[eid].gst = gst_element_factory_make(name, nickname); \
140 traceEnd(TTRACE_TAG_CAMERA); \
141 if (element[eid].gst == NULL) { \
142 _mmcam_dbg_err("Element creation fail. element_id=[%d], name=[%s]", eid, name); \
143 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
144 goto pipeline_creation_error; \
146 _mmcam_dbg_log("Element creation done. element_id=[%d], name=[%s]", eid, name); \
147 element[eid].id = eid; \
148 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
149 err = MM_ERROR_NONE; \
151 elist = g_list_append(elist, &(element[eid]));
153 #define _MMCAMCORDER_ELEMENT_MAKE2(sub_context, element, eid, name /*char* */, nickname /*char* */, err) \
154 if (element[eid].gst != NULL) { \
155 _mmcam_dbg_err("The element is existed. element_id=[%d], name=[%s]", eid, name); \
156 gst_object_unref(element[eid].gst); \
158 element[eid].gst = gst_element_factory_make(name, nickname); \
159 if (element[eid].gst == NULL) { \
160 _mmcam_dbg_err("Element creation fail. element_id=[%d], name=[%s]", eid, name); \
161 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
163 _mmcam_dbg_log("Element creation done. element_id=[%d], name=[%s]", eid, name); \
164 element[eid].id = eid; \
165 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
166 err = MM_ERROR_NONE; \
169 #define _MMCAMCORDER_ELEMENT_MAKE_IGNORE_ERROR(sub_context, element, eid, name /*char* */, nickname /*char* */, elist) \
170 if (element[eid].gst != NULL) { \
171 _mmcam_dbg_err("The element is existed. element_id=[%d], name=[%s]", eid, name); \
172 gst_object_unref(element[eid].gst); \
174 element[eid].gst = gst_element_factory_make(name, nickname); \
175 if (element[eid].gst == NULL) { \
176 _mmcam_dbg_err("Element creation fail. element_id=[%d], name=[%s], but keep going...", eid, name); \
178 _mmcam_dbg_log("Element creation done. element_id=[%d], name=[%s]", eid, name); \
179 element[eid].id = eid; \
180 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
181 elist = g_list_append(elist, &(element[eid])); \
184 #define _MMCAMCORDER_ENCODEBIN_ELMGET(sub_context, eid, name /*char* */, err) \
185 if (sub_context->encode_element[eid].gst != NULL) { \
186 _mmcam_dbg_err("The element is existed. element_id=[%d], name=[%s]", eid, name); \
187 gst_object_unref(sub_context->encode_element[eid].gst); \
189 sub_context->encode_element[eid].id = eid; \
190 g_object_get(G_OBJECT(sub_context->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst), name, &(sub_context->encode_element[eid].gst), NULL); \
191 if (sub_context->encode_element[eid].gst == NULL) { \
192 _mmcam_dbg_err("Encode Element get fail. element_id=[%d], name=[%s]", eid, name); \
193 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
194 goto pipeline_creation_error; \
196 gst_object_unref(sub_context->encode_element[eid].gst); \
197 g_object_weak_ref(G_OBJECT(sub_context->encode_element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
200 /* GStreamer element remove macro */
201 #define _MMCAMCORDER_ELEMENT_REMOVE(element, eid) \
202 if (element[eid].gst != NULL) { \
203 gst_object_unref(element[eid].gst); \
206 #define _MM_GST_ELEMENT_LINK_MANY gst_element_link_many
207 #define _MM_GST_ELEMENT_LINK gst_element_link
208 #define _MM_GST_ELEMENT_LINK_FILTERED gst_element_link_filtered
209 #define _MM_GST_ELEMENT_UNLINK gst_element_unlink
210 #define _MM_GST_PAD_LINK gst_pad_link
212 #define _MM_GST_PAD_LINK_UNREF(srcpad, sinkpad, err, if_fail_goto)\
214 GstPadLinkReturn ret = GST_PAD_LINK_OK;\
215 if (srcpad == NULL || sinkpad == NULL) {\
216 if (srcpad == NULL) {\
217 _mmcam_dbg_err("srcpad is NULL");\
219 gst_object_unref(srcpad);\
222 if (sinkpad == NULL) {\
223 _mmcam_dbg_err("sinkpad is NULL");\
225 gst_object_unref(sinkpad);\
228 err = MM_ERROR_CAMCORDER_GST_LINK;\
231 ret = _MM_GST_PAD_LINK(srcpad, sinkpad);\
232 if (ret != GST_PAD_LINK_OK) {\
233 GstObject *src_parent = gst_pad_get_parent(srcpad);\
234 GstObject *sink_parent = gst_pad_get_parent(sinkpad);\
235 char *src_name = NULL;\
236 char *sink_name = NULL;\
237 g_object_get((GObject *)src_parent, "name", &src_name, NULL);\
238 g_object_get((GObject *)sink_parent, "name", &sink_name, NULL);\
239 _mmcam_dbg_err("src[%s] - sink[%s] link failed", src_name, sink_name);\
240 gst_object_unref(src_parent); src_parent = NULL;\
241 gst_object_unref(sink_parent); sink_parent = NULL;\
243 free(src_name); src_name = NULL;\
246 free(sink_name); sink_name = NULL;\
248 gst_object_unref(srcpad); srcpad = NULL;\
249 gst_object_unref(sinkpad); sinkpad = NULL;\
250 err = MM_ERROR_CAMCORDER_GST_LINK;\
253 gst_object_unref(srcpad); srcpad = NULL;\
254 gst_object_unref(sinkpad); sinkpad = NULL;\
257 #define _MM_GST_PAD_UNLINK_UNREF( srcpad, sinkpad) \
258 if (srcpad && sinkpad) { \
259 gst_pad_unlink(srcpad, sinkpad); \
261 _mmcam_dbg_warn("some pad(srcpad:%p,sinkpad:%p) is NULL", srcpad, sinkpad); \
264 gst_object_unref(srcpad); srcpad = NULL; \
267 gst_object_unref(sinkpad); sinkpad = NULL; \
270 #define _MMCAMCORDER_STATE_SET_COUNT 3 /* checking interval */
271 #define _MMCAMCORDER_STATE_CHECK_TOTALTIME 5000000L /* total wating time for state change */
272 #define _MMCAMCORDER_STATE_CHECK_INTERVAL (50*1000) /* checking interval - 50ms*/
275 * Default videosink type
277 #define _MMCAMCORDER_DEFAULT_VIDEOSINK_TYPE "VideosinkElementOverlay"
280 * Default recording motion rate
282 #define _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE 1.0
285 * Total level count of manual focus */
286 #define _MMFCAMCORDER_FOCUS_TOTAL_LEVEL 8
289 * File name length limit
291 #define _MMCamcorder_FILENAME_LEN (512)
294 * Minimum integer value
296 #define _MMCAMCORDER_MIN_INT (INT_MIN)
299 * Maximum integer value
301 #define _MMCAMCORDER_MAX_INT (INT_MAX)
304 * Minimum double value
306 #define _MMCAMCORDER_MIN_DOUBLE (DBL_MIN)
309 * Maximum integer value
311 #define _MMCAMCORDER_MAX_DOUBLE (DBL_MAX)
314 * Audio timestamp margin (msec)
316 #define _MMCAMCORDER_AUDIO_TIME_MARGIN (300)
319 * Functions related with LOCK and WAIT
321 #define _MMCAMCORDER_CAST_MTSAFE(handle) (((mmf_camcorder_t*)handle)->mtsafe)
322 #define _MMCAMCORDER_LOCK_FUNC(mutex) g_mutex_lock(&mutex)
323 #define _MMCAMCORDER_TRYLOCK_FUNC(mutex) g_mutex_trylock(&mutex)
324 #define _MMCAMCORDER_UNLOCK_FUNC(mutex) g_mutex_unlock(&mutex)
326 #define _MMCAMCORDER_GET_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).lock)
327 #define _MMCAMCORDER_LOCK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_LOCK(handle))
328 #define _MMCAMCORDER_TRYLOCK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_LOCK(handle))
329 #define _MMCAMCORDER_UNLOCK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_LOCK(handle))
331 #define _MMCAMCORDER_GET_COND(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).cond)
332 #define _MMCAMCORDER_WAIT(handle) g_cond_wait(&_MMCAMCORDER_GET_COND(handle), &_MMCAMCORDER_GET_LOCK(handle))
333 #define _MMCAMCORDER_WAIT_UNTIL(handle, timeout) g_cond_wait_until(&_MMCAMCORDER_GET_COND(handle), &_MMCAMCORDER_GET_LOCK(handle), &end_time)
334 #define _MMCAMCORDER_SIGNAL(handle) g_cond_signal(&_MMCAMCORDER_GET_COND(handle));
335 #define _MMCAMCORDER_BROADCAST(handle) g_cond_broadcast(&_MMCAMCORDER_GET_COND(handle));
338 #define _MMCAMCORDER_GET_CMD_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).cmd_lock)
339 #define _MMCAMCORDER_LOCK_CMD(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_CMD_LOCK(handle))
340 #define _MMCAMCORDER_TRYLOCK_CMD(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_CMD_LOCK(handle))
341 #define _MMCAMCORDER_UNLOCK_CMD(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_CMD_LOCK(handle))
344 #define _MMCAMCORDER_GET_ASM_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).asm_lock)
345 #define _MMCAMCORDER_LOCK_ASM(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_ASM_LOCK(handle))
346 #define _MMCAMCORDER_TRYLOCK_ASM(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_ASM_LOCK(handle))
347 #define _MMCAMCORDER_UNLOCK_ASM(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_ASM_LOCK(handle))
349 /* for state change */
350 #define _MMCAMCORDER_GET_STATE_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).state_lock)
351 #define _MMCAMCORDER_LOCK_STATE(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_STATE_LOCK(handle))
352 #define _MMCAMCORDER_TRYLOCK_STATE(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_STATE_LOCK(handle))
353 #define _MMCAMCORDER_UNLOCK_STATE(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_STATE_LOCK(handle))
355 /* for gstreamer state change */
356 #define _MMCAMCORDER_GET_GST_STATE_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).gst_state_lock)
357 #define _MMCAMCORDER_LOCK_GST_STATE(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_GST_STATE_LOCK(handle))
358 #define _MMCAMCORDER_TRYLOCK_GST_STATE(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_GST_STATE_LOCK(handle))
359 #define _MMCAMCORDER_UNLOCK_GST_STATE(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_GST_STATE_LOCK(handle))
361 #define _MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).gst_encode_state_lock)
362 #define _MMCAMCORDER_LOCK_GST_ENCODE_STATE(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle))
363 #define _MMCAMCORDER_TRYLOCK_GST_ENCODE_STATE(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle))
364 #define _MMCAMCORDER_UNLOCK_GST_ENCODE_STATE(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle))
366 /* for setting/calling callback */
367 #define _MMCAMCORDER_GET_MESSAGE_CALLBACK_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).message_cb_lock)
368 #define _MMCAMCORDER_LOCK_MESSAGE_CALLBACK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_MESSAGE_CALLBACK_LOCK(handle))
369 #define _MMCAMCORDER_TRYLOCK_MESSAGE_CALLBACK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_MESSAGE_CALLBACK_LOCK(handle))
370 #define _MMCAMCORDER_UNLOCK_MESSAGE_CALLBACK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_MESSAGE_CALLBACK_LOCK(handle))
372 #define _MMCAMCORDER_GET_VCAPTURE_CALLBACK_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).vcapture_cb_lock)
373 #define _MMCAMCORDER_LOCK_VCAPTURE_CALLBACK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_VCAPTURE_CALLBACK_LOCK(handle))
374 #define _MMCAMCORDER_TRYLOCK_VCAPTURE_CALLBACK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_VCAPTURE_CALLBACK_LOCK(handle))
375 #define _MMCAMCORDER_UNLOCK_VCAPTURE_CALLBACK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_VCAPTURE_CALLBACK_LOCK(handle))
377 #define _MMCAMCORDER_GET_VSTREAM_CALLBACK_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).vstream_cb_lock)
378 #define _MMCAMCORDER_LOCK_VSTREAM_CALLBACK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_VSTREAM_CALLBACK_LOCK(handle))
379 #define _MMCAMCORDER_TRYLOCK_VSTREAM_CALLBACK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_VSTREAM_CALLBACK_LOCK(handle))
380 #define _MMCAMCORDER_UNLOCK_VSTREAM_CALLBACK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_VSTREAM_CALLBACK_LOCK(handle))
382 #define _MMCAMCORDER_GET_ASTREAM_CALLBACK_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).astream_cb_lock)
383 #define _MMCAMCORDER_LOCK_ASTREAM_CALLBACK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_ASTREAM_CALLBACK_LOCK(handle))
384 #define _MMCAMCORDER_TRYLOCK_ASTREAM_CALLBACK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_ASTREAM_CALLBACK_LOCK(handle))
385 #define _MMCAMCORDER_UNLOCK_ASTREAM_CALLBACK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_ASTREAM_CALLBACK_LOCK(handle))
388 * Caster of main handle (camcorder)
390 #define MMF_CAMCORDER(h) (mmf_camcorder_t *)(h)
393 * Caster of subcontext
395 #define MMF_CAMCORDER_SUBCONTEXT(h) (((mmf_camcorder_t *)(h))->sub_context)
397 /* LOCAL CONSTANT DEFINITIONS */
399 * Total Numbers of Attribute values.
400 * If you increase any enum of attribute values, you also have to increase this.
402 #define MM_CAMCORDER_MODE_NUM 3 /**< Number of mode type */
403 #define MM_CAMCORDER_COLOR_TONE_NUM 30 /**< Number of color-tone modes */
404 #define MM_CAMCORDER_WHITE_BALANCE_NUM 10 /**< Number of WhiteBalance modes*/
405 #define MM_CAMCORDER_SCENE_MODE_NUM 16 /**< Number of program-modes */
406 #define MM_CAMCORDER_FOCUS_MODE_NUM 6 /**< Number of focus mode*/
407 #define MM_CAMCORDER_AUTO_FOCUS_NUM 5 /**< Total count of auto focus type*/
408 #define MM_CAMCORDER_FOCUS_STATE_NUM 4 /**< Number of focus state */
409 #define MM_CAMCORDER_ISO_NUM 10 /**< Number of ISO */
410 #define MM_CAMCORDER_AUTO_EXPOSURE_NUM 9 /**< Number of Auto exposure type */
411 #define MM_CAMCORDER_WDR_NUM 3 /**< Number of wide dynamic range */
412 #define MM_CAMCORDER_FLIP_NUM 4 /**< Number of Filp mode */
413 #define MM_CAMCORDER_ROTATION_NUM 4 /**< Number of Rotation mode */
414 #define MM_CAMCORDER_AHS_NUM 4 /**< Number of anti-handshake */
415 #define MM_CAMCORDER_VIDEO_STABILIZATION_NUM 2 /**< Number of video stabilization */
416 #define MM_CAMCORDER_HDR_CAPTURE_NUM 3 /**< Number of HDR capture mode */
417 #define MM_CAMCORDER_GEOMETRY_METHOD_NUM 5 /**< Number of geometry method */
418 #define MM_CAMCORDER_TAG_ORT_NUM 8 /**< Number of tag orientation */
419 #define MM_CAMCORDER_STROBE_MODE_NUM 8 /**< Number of strobe mode type */
420 #define MM_CAMCORDER_STROBE_CONTROL_NUM 3 /**< Number of strobe control type */
421 #define MM_CAMCORDER_DETECT_MODE_NUM 2 /**< Number of detect mode type */
423 /*=======================================================================================
425 ========================================================================================*/
427 * Command for Camcorder.
430 /* Command for Video/Audio recording */
431 _MMCamcorder_CMD_RECORD,
432 _MMCamcorder_CMD_PAUSE,
433 _MMCamcorder_CMD_CANCEL,
434 _MMCamcorder_CMD_COMMIT,
436 /* Command for Image capture */
437 _MMCamcorder_CMD_CAPTURE,
439 /* Command for Preview(Video/Image only effective) */
440 _MMCamcorder_CMD_PREVIEW_START,
441 _MMCamcorder_CMD_PREVIEW_STOP,
448 _MMCamcorder_SINGLE_SHOT,
449 _MMCamcorder_MULTI_SHOT,
453 * Enumerations for manual focus direction.
454 * If focusing mode is not "MM_CAMCORDER_AF_MODE_MANUAL", this value will be ignored.
456 enum MMCamcorderMfLensDir {
457 MM_CAMCORDER_MF_LENS_DIR_FORWARD = 1, /**< Focus direction to forward */
458 MM_CAMCORDER_MF_LENS_DIR_BACKWARD, /**< Focus direction to backward */
459 MM_CAMCORDER_MF_LENS_DIR_NUM, /**< Total number of the directions */
463 * Camcorder Pipeline's Element name.
464 * @note index of element.
467 _MMCAMCORDER_NONE = (-1),
469 /* Main Pipeline Element */
470 _MMCAMCORDER_MAIN_PIPE = 0x00,
472 /* Pipeline element of Video input */
473 _MMCAMCORDER_VIDEOSRC_SRC,
474 _MMCAMCORDER_VIDEOSRC_FILT,
475 _MMCAMCORDER_VIDEOSRC_CLS_QUE,
476 _MMCAMCORDER_VIDEOSRC_CLS,
477 _MMCAMCORDER_VIDEOSRC_CLS_FILT,
478 _MMCAMCORDER_VIDEOSRC_QUE,
479 _MMCAMCORDER_VIDEOSRC_DECODE,
481 /* Pipeline element of Video output */
482 _MMCAMCORDER_VIDEOSINK_QUE,
483 _MMCAMCORDER_VIDEOSINK_SINK,
485 _MMCAMCORDER_PIPELINE_ELEMENT_NUM,
486 } _MMCAMCORDER_PREVIEW_PIPELINE_ELELMENT;
489 * Camcorder Pipeline's Element name.
490 * @note index of element.
493 _MMCAMCORDER_ENCODE_NONE = (-1),
495 /* Main Pipeline Element */
496 _MMCAMCORDER_ENCODE_MAIN_PIPE = 0x00,
498 /* Pipeline element of Audio input */
499 _MMCAMCORDER_AUDIOSRC_BIN,
500 _MMCAMCORDER_AUDIOSRC_SRC,
501 _MMCAMCORDER_AUDIOSRC_FILT,
502 _MMCAMCORDER_AUDIOSRC_QUE,
503 _MMCAMCORDER_AUDIOSRC_CONV,
504 _MMCAMCORDER_AUDIOSRC_VOL,
506 /* Pipeline element of Encodebin */
507 _MMCAMCORDER_ENCSINK_BIN,
508 _MMCAMCORDER_ENCSINK_SRC,
509 _MMCAMCORDER_ENCSINK_FILT,
510 _MMCAMCORDER_ENCSINK_ENCBIN,
511 _MMCAMCORDER_ENCSINK_AQUE,
512 _MMCAMCORDER_ENCSINK_CONV,
513 _MMCAMCORDER_ENCSINK_AENC,
514 _MMCAMCORDER_ENCSINK_AENC_QUE,
515 _MMCAMCORDER_ENCSINK_VQUE,
516 _MMCAMCORDER_ENCSINK_VCONV,
517 _MMCAMCORDER_ENCSINK_VENC,
518 _MMCAMCORDER_ENCSINK_VENC_QUE,
519 _MMCAMCORDER_ENCSINK_ITOG,
520 _MMCAMCORDER_ENCSINK_ICROP,
521 _MMCAMCORDER_ENCSINK_ISCALE,
522 _MMCAMCORDER_ENCSINK_IFILT,
523 _MMCAMCORDER_ENCSINK_IQUE,
524 _MMCAMCORDER_ENCSINK_IENC,
525 _MMCAMCORDER_ENCSINK_MUX,
526 _MMCAMCORDER_ENCSINK_SINK,
528 _MMCAMCORDER_ENCODE_PIPELINE_ELEMENT_NUM,
529 } _MMCAMCORDER_ENCODE_PIPELINE_ELELMENT;
532 _MMCAMCORDER_TASK_THREAD_STATE_NONE,
533 _MMCAMCORDER_TASK_THREAD_STATE_SOUND_PLAY_START,
534 _MMCAMCORDER_TASK_THREAD_STATE_SOUND_SOLO_PLAY_START,
535 _MMCAMCORDER_TASK_THREAD_STATE_ENCODE_PIPE_CREATE,
536 _MMCAMCORDER_TASK_THREAD_STATE_CHECK_CAPTURE_IN_RECORDING,
537 _MMCAMCORDER_TASK_THREAD_STATE_EXIT,
538 } _MMCamcorderTaskThreadState;
541 * System state change cause
544 _MMCAMCORDER_STATE_CHANGE_NORMAL = 0,
545 _MMCAMCORDER_STATE_CHANGE_BY_ASM,
546 _MMCAMCORDER_STATE_CHANGE_BY_RM,
547 _MMCAMCORDER_STATE_CHANGE_BY_DPM
548 } _MMCamcorderStateChange;
551 /*=======================================================================================
552 | STRUCTURE DEFINITIONS |
553 ========================================================================================*/
555 * MMCamcorder Gstreamer Element
558 unsigned int id; /**< Gstreamer piplinem element name */
559 GstElement *gst; /**< Gstreamer element */
560 } _MMCamcorderGstElement;
563 * MMCamcorder information for KPI measurement
566 int current_fps; /**< current fps of this second */
567 int average_fps; /**< average fps */
568 unsigned int video_framecount; /**< total number of video frame */
569 unsigned int last_framecount; /**< total number of video frame in last measurement */
570 struct timeval init_video_time; /**< time when start to measure */
571 struct timeval last_video_time; /**< last measurement time */
572 } _MMCamcorderKPIMeasure;
575 * MMCamcorder information for Multi-Thread Safe
578 GMutex lock; /**< Mutex (for general use) */
579 GCond cond; /**< Condition (for general use) */
580 GMutex cmd_lock; /**< Mutex (for command) */
581 GMutex asm_lock; /**< Mutex (for ASM) */
582 GMutex state_lock; /**< Mutex (for state change) */
583 GMutex gst_state_lock; /**< Mutex (for gst pipeline state change) */
584 GMutex gst_encode_state_lock; /**< Mutex (for gst encode pipeline state change) */
585 GMutex message_cb_lock; /**< Mutex (for message callback) */
586 GMutex vcapture_cb_lock; /**< Mutex (for video capture callback) */
587 GMutex vstream_cb_lock; /**< Mutex (for video stream callback) */
588 GMutex astream_cb_lock; /**< Mutex (for audio stream callback) */
589 } _MMCamcorderMTSafe;
592 * MMCamcorder Sub Context
595 bool isMaxsizePausing; /**< Because of size limit, pipeline is paused. */
596 bool isMaxtimePausing; /**< Because of time limit, pipeline is paused. */
597 int element_num; /**< count of element */
598 int encode_element_num; /**< count of encode element */
599 int cam_stability_count; /**< camsensor stability count. the count of frame will drop */
600 GstClockTime pipeline_time; /**< current time of Gstreamer Pipeline */
601 GstClockTime pause_time; /**< amount of time while pipeline is in PAUSE state.*/
602 GstClockTime stillshot_time; /**< pipeline time of capturing moment*/
603 gboolean is_modified_rate; /**< whether recording motion rate is modified or not */
604 gboolean ferror_send; /**< file write/seek error **/
605 guint ferror_count; /**< file write/seek error count **/
606 GstClockTime previous_slot_time;
607 int display_interval; /**< This value is set as 'GST_SECOND / display FPS' */
608 gboolean bget_eos; /**< Whether getting EOS */
609 gboolean bencbin_capture; /**< Use Encodebin for capturing */
610 gboolean audio_disable; /**< whether audio is disabled or not when record */
611 int videosrc_rotate; /**< rotate of videosrc */
613 /* For dropping video frame when start recording */
614 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. */
615 int pass_first_vframe; /**< When this value is bigger than zero, MSL won't drop video frame though "drop_vframe" is bigger then zero. */
617 /* INI information */
618 unsigned int fourcc; /**< Get fourcc value of camera INI file */
619 _MMCamcorderImageInfo *info_image; /**< extra information for image capture */
620 _MMCamcorderVideoInfo *info_video; /**< extra information for video recording */
621 _MMCamcorderAudioInfo *info_audio; /**< extra information for audio recording */
623 _MMCamcorderGstElement *element; /**< array of preview element */
624 _MMCamcorderGstElement *encode_element; /**< array of encode element */
625 _MMCamcorderKPIMeasure kpi; /**< information related with performance measurement */
627 type_element *VideosinkElement; /**< configure data of videosink element */
628 type_element *VideoconvertElement; /**< configure data of videoconvert element */
629 type_element *VideodecoderElementH264; /**< configure data of video decoder element for H.264 format */
630 gboolean SensorEncodedCapture; /**< whether camera sensor support encoded image capture */
631 gboolean internal_encode; /**< whether use internal encoding function */
632 } _MMCamcorderSubContext;
635 * _MMCamcorderContext
637 typedef struct mmf_camcorder {
639 int type; /**< mmcamcorder_mode_type */
640 int device_type; /**< device type */
641 int state; /**< state of camcorder */
642 int target_state; /**< Target state that want to set. This is a flag that
643 * stands for async state changing. If this value differ from state,
644 * it means state is changing now asychronously. */
647 MMHandleType attributes; /**< Attribute handle */
648 _MMCamcorderSubContext *sub_context; /**< sub context */
649 mm_exif_info_t *exif_info; /**< EXIF */
650 GList *buffer_probes; /**< a list of buffer probe handle */
651 GList *event_probes; /**< a list of event probe handle */
652 GList *signals; /**< a list of signal handle */
653 #ifdef _MMCAMCORDER_ENABLE_IDLE_MESSAGE_CALLBACK
654 GList *msg_data; /**< a list of msg data */
655 #endif /* _MMCAMCORDER_ENABLE_IDLE_MESSAGE_CALLBACK */
656 camera_conf *conf_main; /**< Camera configure Main structure */
657 camera_conf *conf_ctrl; /**< Camera configure Control structure */
658 guint pipeline_cb_event_id; /**< Event source ID of pipeline message callback */
659 guint encode_pipeline_cb_event_id; /**< Event source ID of encode pipeline message callback */
660 guint setting_event_id; /**< Event source ID of attributes setting to sensor */
661 SOUND_INFO snd_info; /**< Sound handle for multishot capture */
663 /* callback handlers */
664 MMMessageCallback msg_cb; /**< message callback */
665 void *msg_cb_param; /**< message callback parameter */
666 mm_camcorder_video_stream_callback vstream_cb; /**< Video stream callback */
667 void *vstream_cb_param; /**< Video stream callback parameter */
668 mm_camcorder_audio_stream_callback astream_cb; /**< Audio stream callback */
669 void *astream_cb_param; /**< Audio stream callback parameter */
670 mm_camcorder_video_capture_callback vcapture_cb; /**< Video capture callback */
671 void *vcapture_cb_param; /**< Video capture callback parameter */
672 int (*command)(MMHandleType, int); /**< camcorder's command */
675 mm_cam_attr_construct_info *cam_attrs_const_info; /**< attribute info */
676 conf_info_table* conf_main_info_table[CONFIGURE_CATEGORY_MAIN_NUM]; /** configure info table - MAIN category */
677 conf_info_table* conf_ctrl_info_table[CONFIGURE_CATEGORY_CTRL_NUM]; /** configure info table - CONTROL category */
678 int conf_main_category_size[CONFIGURE_CATEGORY_MAIN_NUM]; /** configure info table size - MAIN category */
679 int conf_ctrl_category_size[CONFIGURE_CATEGORY_CTRL_NUM]; /** configure info table size - CONTROL category */
680 _MMCamcorderMTSafe mtsafe; /**< Thread safe */
681 int state_change_by_system; /**< MSL changes its state by itself because of system */
682 GMutex restart_preview_lock; /**< Capture sound mutex */
683 int use_zero_copy_format; /**< Whether use zero copy format for camera input */
684 int support_media_packet_preview_cb; /**< Whether support zero copy format for camera input */
685 int shutter_sound_policy; /**< shutter sound policy */
686 int brightness_default; /**< default value of brightness */
687 int brightness_step_denominator; /**< denominator of brightness bias step */
688 int support_zsl_capture; /**< support Zero Shutter Lag capture */
689 char *model_name; /**< model name from system info */
690 char *software_version; /**< software_version from system info */
691 int capture_sound_count; /**< count for capture sound */
692 char *root_directory; /**< Root directory for device */
693 int resolution_changed; /**< Flag for preview resolution change */
694 int sound_focus_register; /**< Use sound focus internally */
695 int sound_focus_id; /**< id for sound focus */
696 int sound_focus_watch_id; /**< id for sound focus watch */
697 int interrupt_code; /**< Interrupt code */
698 int acquired_focus; /**< Current acquired focus */
699 int session_type; /**< Session type */
700 int session_flags; /**< Session flags */
701 int recreate_decoder; /**< Flag of decoder element recreation for encoded preview format */
703 _MMCamcorderInfoConverting caminfo_convert[CAMINFO_CONVERT_NUM]; /**< converting structure of camera info */
704 _MMCamcorderEnumConvert enum_conv[ENUM_CONVERT_NUM]; /**< enum converting list that is modified by ini info */
706 gboolean capture_in_recording; /**< Flag for capture while recording */
708 gboolean error_occurs; /**< flag for error */
709 int error_code; /**< error code for internal gstreamer error */
712 GThread *task_thread; /**< thread for task */
713 GMutex task_thread_lock; /**< mutex for task thread */
714 GCond task_thread_cond; /**< cond for task thread */
715 _MMCamcorderTaskThreadState task_thread_state; /**< state of task thread */
717 /* resource manager for H/W resources */
718 MMCamcorderResourceManager resource_manager;
721 GDBusConnection *gdbus_conn; /**< gdbus connection */
722 _MMCamcorderGDbusCbInfo gdbus_info_sound; /**< Informations for the gbus cb of sound play */
723 _MMCamcorderGDbusCbInfo gdbus_info_solo_sound; /**< Informations for the gbus cb of solo sound play */
725 /* DPM(device policy manager) */
726 dpm_context_h dpm_context; /**< DPM context handle */
727 dpm_restriction_policy_h dpm_policy; /**< DPM restriction policy handle */
728 int dpm_camera_cb_id; /**< DPM camera policy changed callback id */
730 int reserved[4]; /**< reserved */
733 /*=======================================================================================
734 | EXTERN GLOBAL VARIABLE |
735 ========================================================================================*/
737 /*=======================================================================================
738 | GLOBAL FUNCTION PROTOTYPES |
739 ========================================================================================*/
741 * This function creates camcorder for capturing still image and recording.
743 * @param[out] handle Specifies the camcorder handle
744 * @param[in] info Preset information of camcorder
745 * @return This function returns zero on success, or negative value with error code.
746 * @remarks When this function calls successfully, camcorder handle will be filled with a @n
747 * valid value and the state of the camcorder will become MM_CAMCORDER_STATE_NULL.@n
748 * Note that it's not ready to working camcorder. @n
749 * You should call mmcamcorder_realize before starting camcorder.
750 * @see _mmcamcorder_create
752 int _mmcamcorder_create(MMHandleType *handle, MMCamPreset *info);
755 * This function destroys instance of camcorder.
757 * @param[in] hcamcorder Specifies the camcorder handle
758 * @return This function returns zero on success, or negative value with error code.
759 * @see _mmcamcorder_create
761 int _mmcamcorder_destroy(MMHandleType hcamcorder);
764 * This function allocates memory for camcorder.
766 * @param[in] hcamcorder Specifies the camcorder handle
767 * @return This function returns zero on success, or negative value with error code.
768 * @remarks This function can be called successfully when current state is MM_CAMCORDER_STATE_NULL @n
769 * and the state of the camcorder will become MM_CAMCORDER_STATE_READY. @n
770 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
771 * @see _mmcamcorder_unrealize
772 * @pre MM_CAMCORDER_STATE_NULL
773 * @post MM_CAMCORDER_STATE_READY
775 int _mmcamcorder_realize(MMHandleType hcamcorder);
778 * This function free allocated memory for camcorder.
780 * @param[in] hcamcorder Specifies the camcorder handle
781 * @return This function returns zero on success, or negative value with error code.
782 * @remarks This function release all resources which are allocated for the camcorder engine.@n
783 * This function can be called successfully when current state is MM_CAMCORDER_STATE_READY and @n
784 * the state of the camcorder will become MM_CAMCORDER_STATE_NULL. @n
785 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
786 * @see _mmcamcorder_realize
787 * @pre MM_CAMCORDER_STATE_READY
788 * @post MM_CAMCORDER_STATE_NULL
790 int _mmcamcorder_unrealize(MMHandleType hcamcorder);
793 * This function is to start previewing.
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 MM_CAMCORDER_STATE_READY and @n
798 * the state of the camcorder will become MM_CAMCORDER_STATE_PREPARE. @n
799 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
800 * @see _mmcamcorder_stop
802 int _mmcamcorder_start(MMHandleType hcamcorder);
805 * This function is to stop previewing.
807 * @param[in] hcamcorder Specifies the camcorder handle
808 * @return This function returns zero on success, or negative value with error code.
809 * @remarks This function can be called successfully when current state is MM_CAMCORDER_STATE_PREPARE and @n
810 * the state of the camcorder will become MM_CAMCORDER_STATE_READY.@n
811 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
812 * @see _mmcamcorder_start
814 int _mmcamcorder_stop(MMHandleType hcamcorder);
817 * This function to start capturing of still images.
819 * @param[in] hcamcorder Specifies the camcorder handle.
820 * @return This function returns zero on success, or negative value with error code.
821 * @remarks This function can be called successfully when current state is MM_CAMCORDER_STATE_PREPARE and @n
822 * the state of the camcorder will become MM_CAMCORDER_STATE_CAPTURING. @n
823 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
824 * @see _mmcamcorder_capture_stop
826 int _mmcamcorder_capture_start(MMHandleType hcamcorder);
829 * This function is to stop capturing still images.
831 * @param[in] hcamcorder Specifies the camcorder handle
832 * @return This function returns zero on success, or negative value with error code.
833 * @remarks This function can be called successfully when current state is MM_CAMCORDER_STATE_CAPTURING and @n
834 * the state of the camcorder will become MM_CAMCORDER_STATE_PREPARE. @n
835 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
836 * @see _mmcamcorder_capture_start
838 int _mmcamcorder_capture_stop(MMHandleType hcamcorder);
841 * This function is to start video and audio recording.
843 * @param[in] hcamcorder Specifies the camcorder handle
844 * @return This function returns zero on success, or negative value with error code.
845 * @remarks This function can be called successfully when current state is @n
846 * MM_CAMCORDER_STATE_PREPARE or MM_CAMCORDER_STATE_PAUSED and @n
847 * the state of the camcorder will become MM_CAMCORDER_STATE_RECORDING.@n
848 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
849 * @see _mmcamcorder_pause
851 int _mmcamcorder_record(MMHandleType hcamcorder);
854 * This function is to pause video and audio recording
856 * @param[in] hcamcorder Specifies the camcorder handle
857 * @return This function returns zero on success, or negative value with error code.
858 * @remarks This function can be called successfully when current state is MM_CAMCORDER_STATE_RECORDING and @n
859 * the state of the camcorder will become MM_CAMCORDER_STATE_PAUSED.@n
860 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.@n
861 * @see _mmcamcorder_record
863 int _mmcamcorder_pause(MMHandleType hcamcorder);
866 * This function is to stop video and audio recording and save results.
868 * @param[in] hcamcorder Specifies the camcorder handle
869 * @return This function returns zero on success, or negative value with error code.
870 * @remarks This function can be called successfully when current state is @n
871 * MM_CAMCORDER_STATE_PAUSED or MM_CAMCORDER_STATE_RECORDING and @n
872 * the state of the camcorder will become MM_CAMCORDER_STATE_PREPARE. @n
873 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION
874 * @see _mmcamcorder_cancel
876 int _mmcamcorder_commit(MMHandleType hcamcorder);
879 * This function is to stop video and audio recording and do not save results.
881 * @param[in] hcamcorder Specifies the camcorder handle
882 * @return This function returns zero on success, or negative value with error code.
883 * @remarks This function can be called successfully when current state is @n
884 * MM_CAMCORDER_STATE_PAUSED or MM_CAMCORDER_STATE_RECORDING and @n
885 * the state of the camcorder will become MM_CAMCORDER_STATE_PREPARE. @n
886 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
887 * @see _mmcamcorder_commit
889 int _mmcamcorder_cancel(MMHandleType hcamcorder);
892 * This function calls after commiting action finished asynchronously.
893 * In this function, remaining process , such as state change, happens.
895 * @param[in] hcamcorder Specifies the camcorder handle
896 * @return This function returns zero on success, or negative value with error code.
897 * @remarks This function can be called successfully when current state is @n
898 * MM_CAMCORDER_STATE_PAUSED or MM_CAMCORDER_STATE_RECORDING and @n
899 * the state of the camcorder will become MM_CAMCORDER_STATE_PREPARE. @n
900 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
901 * @see _mmcamcorder_commit
903 int _mmcamcorder_commit_async_end(MMHandleType hcamcorder);
906 * This function is to set callback for receiving messages from camcorder.
908 * @param[in] hcamcorder Specifies the camcorder handle
909 * @param[in] callback Specifies the function pointer of callback function
910 * @param[in] user_data Specifies the user poiner for passing to callback function
912 * @return This function returns zero on success, or negative value with error code.
913 * @remarks typedef bool (*mm_message_callback) (int msg, mm_messageType *param, void *user_param);@n
928 * } mm_message_type; @n
930 * If a message value for mm_message_callback is MM_MESSAGE_STATE_CHANGED, @n
931 * state value in mm_message_type will be a mmcamcorder_state_type enum value;@n
933 * If a message value for mm_message_callback is MM_MESSAGE_ERROR, @n
934 * the code value in mm_message_type will be a mmplayer_error_type enum value;
936 * @see mm_message_type, mmcamcorder_state_type, mmcamcorder_error_type
938 int _mmcamcorder_set_message_callback(MMHandleType hcamcorder,
939 MMMessageCallback callback,
943 * This function is to set callback for video stream.
945 * @param[in] hcamcorder Specifies the camcorder handle
946 * @param[in] callback Specifies the function pointer of callback function
947 * @param[in] user_data Specifies the user poiner for passing to callback function
949 * @return This function returns zero on success, or negative value with error code.
950 * @see mmcamcorder_error_type
952 int _mmcamcorder_set_video_stream_callback(MMHandleType hcamcorder,
953 mm_camcorder_video_stream_callback callback,
957 * This function is to set callback for audio stream.
959 * @param[in] hcamcorder Specifies the camcorder handle
960 * @param[in] callback Specifies the function pointer of callback function
961 * @param[in] user_data Specifies the user poiner for passing to callback function
963 * @return This function returns zero on success, or negative value with error code.
964 * @see mmcamcorder_error_type
966 int _mmcamcorder_set_audio_stream_callback(MMHandleType handle,
967 mm_camcorder_audio_stream_callback callback,
971 * This function is to set callback for video capture.
973 * @param[in] hcamcorder Specifies the camcorder handle
974 * @param[in] callback Specifies the function pointer of callback function
975 * @param[in] user_data Specifies the user poiner for passing to callback function
977 * @return This function returns zero on success, or negative value with error code.
978 * @see mmcamcorder_error_type
980 int _mmcamcorder_set_video_capture_callback(MMHandleType hcamcorder,
981 mm_camcorder_video_capture_callback callback,
985 * This function returns current state of camcorder, or negative value with error code.
987 * @param[in] hcamcorder Specifies the camcorder handle.
988 * @return This function returns current state of camcorder, or negative value with error code.
989 * @see mmcamcorder_state_type
991 int _mmcamcorder_get_current_state(MMHandleType hcamcorder);
993 int _mmcamcorder_init_focusing(MMHandleType handle);
994 int _mmcamcorder_adjust_focus(MMHandleType handle, int direction);
995 int _mmcamcorder_adjust_manual_focus(MMHandleType handle, int direction);
996 int _mmcamcorder_adjust_auto_focus(MMHandleType handle);
997 int _mmcamcorder_stop_focusing(MMHandleType handle);
1000 * This function gets current state of camcorder.
1003 * @return This function returns state of current camcorder context
1005 * @see _mmcamcorder_set_state()
1008 int _mmcamcorder_streamer_init(void);
1011 * This function gets current state of camcorder.
1014 * @return This function returns state of current camcorder context
1016 * @see _mmcamcorder_set_state()
1019 int _mmcamcorder_display_init(void);
1022 * This function gets current state of camcorder.
1024 * @param[in] handle Handle of camcorder context.
1025 * @return This function returns state of current camcorder context
1027 * @see _mmcamcorder_set_state()
1030 int _mmcamcorder_get_state(MMHandleType handle);
1033 * This function sets new state of camcorder.
1035 * @param[in] handle Handle of camcorder context.
1036 * @param[in] state setting state value of camcorder.
1039 * @see _mmcamcorder_get_state()
1042 void _mmcamcorder_set_state(MMHandleType handle, int state);
1045 * This function gets asynchronous status of MSL Camcroder.
1047 * @param[in] handle Handle of camcorder context.
1048 * @param[in] target_state setting target_state value of camcorder.
1049 * @return This function returns asynchrnous state.
1051 * @see _mmcamcorder_set_async_state()
1054 int _mmcamcorder_get_async_state(MMHandleType handle);
1057 * This function allocates structure of subsidiary attributes.
1059 * @param[in] type Allocation type of camcorder context.
1060 * @return This function returns structure pointer on success, NULL value on failure.
1062 * @see _mmcamcorder_dealloc_subcontext()
1065 _MMCamcorderSubContext *_mmcamcorder_alloc_subcontext(int type);
1068 * This function releases structure of subsidiary attributes.
1070 * @param[in] sc Handle of camcorder subcontext.
1073 * @see _mmcamcorder_alloc_subcontext()
1076 void _mmcamcorder_dealloc_subcontext(_MMCamcorderSubContext *sc);
1079 * This function sets command function according to the type.
1081 * @param[in] handle Handle of camcorder context.
1082 * @param[in] type Allocation type of camcorder context.
1083 * @return This function returns MM_ERROR_NONE on success, or other values with error code.
1085 * @see __mmcamcorder_video_command(), __mmcamcorder_audio_command(), __mmcamcorder_image_command()
1088 int _mmcamcorder_set_functions(MMHandleType handle, int type);
1091 * This function is callback function of main pipeline.
1092 * Once this function is registered with certain pipeline using gst_bus_add_watch(),
1093 * this callback will be called every time when there is upcomming message from pipeline.
1094 * Basically, this function is used as error handling function, now.
1096 * @param[in] bus pointer of buf that called this function.
1097 * @param[in] message callback message from pipeline.
1098 * @param[in] data user data.
1099 * @return This function returns true on success, or false value with error
1101 * @see __mmcamcorder_create_preview_pipeline()
1104 gboolean _mmcamcorder_pipeline_cb_message(GstBus *bus, GstMessage *message, gpointer data);
1107 * This function is callback function of main pipeline.
1108 * Once this function is registered with certain pipeline using gst_bus_set_sync_handler(),
1109 * this callback will be called every time when there is upcomming message from pipeline.
1110 * Basically, this function is used as sync error handling function, now.
1112 * @param[in] bus pointer of buf that called this function.
1113 * @param[in] message callback message from pipeline.
1114 * @param[in] data user data.
1115 * @return This function returns true on success, or false value with error
1117 * @see __mmcamcorder_create_preview_pipeline()
1120 GstBusSyncReply _mmcamcorder_pipeline_bus_sync_callback(GstBus *bus, GstMessage *message, gpointer data);
1123 * This function is callback function of main pipeline.
1124 * Once this function is registered with certain pipeline using gst_bus_set_sync_handler(),
1125 * this callback will be called every time when there is upcomming message from pipeline.
1126 * Basically, this function is used as sync error handling function, now.
1128 * @param[in] bus pointer of buf that called this function.
1129 * @param[in] message callback message from pipeline.
1130 * @param[in] data user data.
1131 * @return This function returns true on success, or false value with error
1133 * @see __mmcamcorder_create_audiop_with_encodebin()
1136 GstBusSyncReply _mmcamcorder_audio_pipeline_bus_sync_callback(GstBus *bus, GstMessage *message, gpointer data);
1140 * This function create main pipeline according to type.
1142 * @param[in] handle Handle of camcorder context.
1143 * @param[in] type Allocation type of camcorder context.
1144 * @return This function returns zero on success, or negative value with error code.
1146 * @see _mmcamcorder_destroy_pipeline()
1149 int _mmcamcorder_create_pipeline(MMHandleType handle, int type);
1152 * This function release all element of main pipeline according to type.
1154 * @param[in] handle Handle of camcorder context.
1155 * @param[in] type Allocation type of camcorder context.
1158 * @see _mmcamcorder_create_pipeline()
1161 void _mmcamcorder_destroy_pipeline(MMHandleType handle, int type);
1164 * This function sets gstreamer element status.
1165 * If the gstreamer fails to set status or returns asynchronous mode,
1166 * this function waits for state changed until timeout expired.
1168 * @param[in] pipeline Pointer of pipeline
1169 * @param[in] target_state newly setting status
1170 * @return This function returns zero on success, or negative value with error code.
1175 int _mmcamcorder_gst_set_state(MMHandleType handle, GstElement *pipeline, GstState target_state);
1178 * This function sets gstreamer element status, asynchronously.
1179 * Regardless of processing, it returns immediately.
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_async(MMHandleType handle, GstElement *pipeline, GstState target_state);
1190 /* For xvimagesink */
1191 GstBusSyncReply __mmcamcorder_sync_callback(GstBus *bus, GstMessage *message, gulong data);
1193 /* For querying capabilities */
1194 int _mmcamcorder_read_vidsrc_info(int videodevidx, camera_conf **configure_info);
1196 /* for performance check */
1197 void _mmcamcorder_video_current_framerate_init(MMHandleType handle);
1198 int _mmcamcorder_video_current_framerate(MMHandleType handle);
1199 int _mmcamcorder_video_average_framerate(MMHandleType handle);
1201 /* sound focus related function */
1202 void __mmcamcorder_force_stop(mmf_camcorder_t *hcamcorder);
1203 void _mmcamcorder_sound_focus_cb(int id, mm_sound_focus_type_e focus_type,
1204 mm_sound_focus_state_e focus_state, const char *reason_for_change,
1205 const char *additional_info, void *user_data);
1206 void _mmcamcorder_sound_focus_watch_cb(mm_sound_focus_type_e focus_type, mm_sound_focus_state_e focus_state,
1207 const char *reason_for_change, const char *additional_info, void *user_data);
1209 /* device policy manager */
1210 void _mmcamcorder_dpm_camera_policy_changed_cb(const char *name, const char *value, void *user_data);
1212 /* For hand over the server's caps information to client */
1213 int _mmcamcorder_get_video_caps(MMHandleType handle, char **caps);
1219 #endif /* __MM_CAMCORDER_INTERNAL_H__ */