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_session.h>
38 #include <mm_session_private.h>
39 #include <mm_sound_focus.h>
41 #include <gst/video/video-format.h>
44 #include <restriction.h> /* device policy manager */
47 #include "mm_camcorder.h"
49 #ifdef _MMCAMCORDER_MM_RM_SUPPORT
50 #include <mm_resource_manager.h>
51 #endif /* _MMCAMCORDER_MM_RM_SUPPORT */
53 /* camcorder sub module */
54 #include "mm_camcorder_attribute.h"
55 #include "mm_camcorder_platform.h"
56 #include "mm_camcorder_stillshot.h"
57 #include "mm_camcorder_videorec.h"
58 #include "mm_camcorder_audiorec.h"
59 #include "mm_camcorder_gstcommon.h"
60 #include "mm_camcorder_exifinfo.h"
61 #include "mm_camcorder_util.h"
62 #include "mm_camcorder_configure.h"
63 #include "mm_camcorder_sound.h"
65 #ifdef _MMCAMCORDER_RM_SUPPORT
66 /* rm (resource manager)*/
68 #endif /* _MMCAMCORDER_RM_SUPPORT */
73 #define LOG_TAG "MM_CAMCORDER"
79 /*=======================================================================================
81 ========================================================================================*/
82 #define _mmcam_dbg_verb(fmt, args...) SLOGI(fmt, ##args);
83 #define _mmcam_dbg_log(fmt, args...) SLOGD(fmt, ##args);
84 #define _mmcam_dbg_warn(fmt, args...) SLOGW(fmt, ##args);
85 #define _mmcam_dbg_err(fmt, args...) SLOGE(fmt, ##args);
86 #define _mmcam_dbg_crit(fmt, args...) SLOGF(fmt, ##args);
89 * Macro for checking validity and debugging
91 #define mmf_return_if_fail(expr) \
93 _mmcam_dbg_err("failed [%s]", #expr); \
98 * Macro for checking validity and debugging
100 #define mmf_return_val_if_fail(expr, val) \
102 _mmcam_dbg_err("failed [%s]", #expr); \
109 * Macro for getting array size
111 #define ARRAY_SIZE(a) (sizeof((a)) / sizeof((a)[0]))
114 /* gstreamer element creation macro */
115 #define _MMCAMCORDER_PIPELINE_MAKE(sub_context, element, eid, name /*char* */, err) \
117 if (element[eid].gst != NULL) { \
118 _mmcam_dbg_err("The element(Pipeline) is existed. element_id=[%d], name=[%s]", eid, name); \
119 gst_object_unref(element[eid].gst); \
121 element[eid].id = eid; \
122 element[eid].gst = gst_pipeline_new(name); \
123 if (element[eid].gst == NULL) { \
124 _mmcam_dbg_err("Pipeline creation fail. element_id=[%d], name=[%s]", eid, name); \
125 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
126 goto pipeline_creation_error; \
128 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
132 #define _MMCAMCORDER_BIN_MAKE(sub_context, element, eid, name /*char* */, err) \
134 if (element[eid].gst != NULL) { \
135 _mmcam_dbg_err("The element(Bin) is existed. element_id=[%d], name=[%s]", eid, name); \
136 gst_object_unref(element[eid].gst); \
138 element[eid].id = eid; \
139 element[eid].gst = gst_bin_new(name); \
140 if (element[eid].gst == NULL) { \
141 _mmcam_dbg_err("Bin creation fail. element_id=[%d], name=[%s]\n", eid, name); \
142 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
143 goto pipeline_creation_error; \
145 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
149 #define _MMCAMCORDER_ELEMENT_MAKE(sub_context, element, eid, name /*char* */, nickname /*char* */, elist, 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 traceBegin(TTRACE_TAG_CAMERA, "MMCAMCORDER:ELEMENT_MAKE:%s", name); \
156 element[eid].gst = gst_element_factory_make(name, nickname); \
157 traceEnd(TTRACE_TAG_CAMERA); \
158 if (element[eid].gst == NULL) { \
159 _mmcam_dbg_err("Element creation fail. element_id=[%d], name=[%s]", eid, name); \
160 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
161 goto pipeline_creation_error; \
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; \
168 elist = g_list_append(elist, &(element[eid])); \
171 #define _MMCAMCORDER_ELEMENT_MAKE2(sub_context, element, eid, name /*char* */, nickname /*char* */, err) \
173 if (element[eid].gst != NULL) { \
174 _mmcam_dbg_err("The element is existed. element_id=[%d], name=[%s]", eid, name); \
175 gst_object_unref(element[eid].gst); \
177 element[eid].gst = gst_element_factory_make(name, nickname); \
178 if (element[eid].gst == NULL) { \
179 _mmcam_dbg_err("Element creation fail. element_id=[%d], name=[%s]", eid, name); \
180 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
182 _mmcam_dbg_log("Element creation done. element_id=[%d], name=[%s]", eid, name); \
183 element[eid].id = eid; \
184 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
185 err = MM_ERROR_NONE; \
189 #define _MMCAMCORDER_ELEMENT_MAKE_IGNORE_ERROR(sub_context, element, eid, name /*char* */, nickname /*char* */, elist) \
191 if (element[eid].gst != NULL) { \
192 _mmcam_dbg_err("The element is existed. element_id=[%d], name=[%s]", eid, name); \
193 gst_object_unref(element[eid].gst); \
195 element[eid].gst = gst_element_factory_make(name, nickname); \
196 if (element[eid].gst == NULL) { \
197 _mmcam_dbg_err("Element creation fail. element_id=[%d], name=[%s], but keep going...", eid, name); \
199 _mmcam_dbg_log("Element creation done. element_id=[%d], name=[%s]", eid, name); \
200 element[eid].id = eid; \
201 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
202 elist = g_list_append(elist, &(element[eid])); \
206 #define _MMCAMCORDER_ELEMENT_ADD(sub_context, element, eid, gst_element, elist, err) \
208 if (element[eid].gst != NULL) { \
209 _mmcam_dbg_err("The element is existed. element_id=[%d]", eid); \
210 gst_object_unref(element[eid].gst); \
212 element[eid].gst = gst_element; \
213 if (element[eid].gst == NULL) { \
214 _mmcam_dbg_err("Element is NULL. element_id=[%d]", eid); \
215 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
216 goto pipeline_creation_error; \
218 _mmcam_dbg_log("Adding Element is done. element_id=[%d] %p", eid, gst_element); \
219 element[eid].id = eid; \
220 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
221 err = MM_ERROR_NONE; \
223 elist = g_list_append(elist, &(element[eid])); \
226 #define _MMCAMCORDER_ENCODEBIN_ELMGET(sub_context, eid, name /*char* */, err) \
228 if (sub_context->encode_element[eid].gst != NULL) { \
229 _mmcam_dbg_err("The element is existed. element_id=[%d], name=[%s]", eid, name); \
230 gst_object_unref(sub_context->encode_element[eid].gst); \
232 sub_context->encode_element[eid].id = eid; \
233 g_object_get(G_OBJECT(sub_context->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst), name, &(sub_context->encode_element[eid].gst), NULL); \
234 if (sub_context->encode_element[eid].gst == NULL) { \
235 _mmcam_dbg_err("Encode Element get fail. element_id=[%d], name=[%s]", eid, name); \
236 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
237 goto pipeline_creation_error; \
239 gst_object_unref(sub_context->encode_element[eid].gst); \
240 g_object_weak_ref(G_OBJECT(sub_context->encode_element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
244 /* GStreamer element remove macro */
245 #define _MMCAMCORDER_ELEMENT_REMOVE(element, eid) \
246 if (element[eid].gst != NULL) { \
247 gst_object_unref(element[eid].gst); \
250 #define _MM_GST_ELEMENT_LINK_MANY gst_element_link_many
251 #define _MM_GST_ELEMENT_LINK gst_element_link
252 #define _MM_GST_ELEMENT_LINK_FILTERED gst_element_link_filtered
253 #define _MM_GST_ELEMENT_UNLINK gst_element_unlink
254 #define _MM_GST_PAD_LINK gst_pad_link
256 #define _MM_GST_PAD_LINK_UNREF(srcpad, sinkpad, err, if_fail_goto) \
258 GstPadLinkReturn ret = GST_PAD_LINK_OK; \
259 if (srcpad == NULL || sinkpad == NULL) { \
260 if (srcpad == NULL) { \
261 _mmcam_dbg_err("srcpad is NULL"); \
263 gst_object_unref(srcpad);\
266 if (sinkpad == NULL) { \
267 _mmcam_dbg_err("sinkpad is NULL"); \
269 gst_object_unref(sinkpad); \
272 err = MM_ERROR_CAMCORDER_GST_LINK; \
275 ret = _MM_GST_PAD_LINK(srcpad, sinkpad); \
276 if (ret != GST_PAD_LINK_OK) { \
277 GstObject *src_parent = gst_pad_get_parent(srcpad); \
278 GstObject *sink_parent = gst_pad_get_parent(sinkpad); \
279 char *src_name = NULL; \
280 char *sink_name = NULL; \
281 g_object_get((GObject *)src_parent, "name", &src_name, NULL); \
282 g_object_get((GObject *)sink_parent, "name", &sink_name, NULL); \
283 _mmcam_dbg_err("src[%s] - sink[%s] link failed", src_name, sink_name); \
284 gst_object_unref(src_parent); src_parent = NULL; \
285 gst_object_unref(sink_parent); sink_parent = NULL; \
287 free(src_name); src_name = NULL; \
290 free(sink_name); sink_name = NULL; \
292 gst_object_unref(srcpad); srcpad = NULL; \
293 gst_object_unref(sinkpad); sinkpad = NULL; \
294 err = MM_ERROR_CAMCORDER_GST_LINK; \
297 gst_object_unref(srcpad); srcpad = NULL; \
298 gst_object_unref(sinkpad); sinkpad = NULL; \
301 #define _MM_GST_PAD_UNLINK_UNREF(srcpad, sinkpad) \
303 if (srcpad && sinkpad) { \
304 gst_pad_unlink(srcpad, sinkpad); \
306 _mmcam_dbg_warn("some pad(srcpad:%p,sinkpad:%p) is NULL", srcpad, sinkpad); \
309 gst_object_unref(srcpad); srcpad = NULL; \
312 gst_object_unref(sinkpad); sinkpad = NULL; \
316 #define _MMCAMCORDER_STATE_SET_COUNT 3 /* checking interval */
317 #define _MMCAMCORDER_STATE_CHECK_TOTALTIME 5000000L /* total wating time for state change */
318 #define _MMCAMCORDER_STATE_CHECK_INTERVAL (50*1000) /* checking interval - 50ms*/
321 * Default videosink type
323 #define _MMCAMCORDER_DEFAULT_VIDEOSINK_TYPE "VideosinkElementOverlay"
326 * Default recording motion rate
328 #define _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE 1.0
331 * Total level count of manual focus */
332 #define _MMFCAMCORDER_FOCUS_TOTAL_LEVEL 8
335 * File name length limit
337 #define _MMCamcorder_FILENAME_LEN (512)
340 * File name for NULL path
342 #define _MMCamcorder_FILENAME_NULL "/dev/null"
345 * Minimum integer value
347 #define _MMCAMCORDER_MIN_INT (INT_MIN)
350 * Maximum integer value
352 #define _MMCAMCORDER_MAX_INT (INT_MAX)
355 * Minimum double value
357 #define _MMCAMCORDER_MIN_DOUBLE (DBL_MIN)
360 * Maximum integer value
362 #define _MMCAMCORDER_MAX_DOUBLE (DBL_MAX)
365 * Audio timestamp margin (msec)
367 #define _MMCAMCORDER_AUDIO_TIME_MARGIN (300)
370 * Functions related with LOCK and WAIT
372 #define _MMCAMCORDER_CAST_MTSAFE(handle) (((mmf_camcorder_t*)handle)->mtsafe)
373 #define _MMCAMCORDER_LOCK_FUNC(mutex) g_mutex_lock(&mutex)
374 #define _MMCAMCORDER_TRYLOCK_FUNC(mutex) g_mutex_trylock(&mutex)
375 #define _MMCAMCORDER_UNLOCK_FUNC(mutex) g_mutex_unlock(&mutex)
377 #define _MMCAMCORDER_GET_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).lock)
378 #define _MMCAMCORDER_LOCK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_LOCK(handle))
379 #define _MMCAMCORDER_TRYLOCK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_LOCK(handle))
380 #define _MMCAMCORDER_UNLOCK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_LOCK(handle))
382 #define _MMCAMCORDER_GET_COND(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).cond)
383 #define _MMCAMCORDER_WAIT(handle) g_cond_wait(&_MMCAMCORDER_GET_COND(handle), &_MMCAMCORDER_GET_LOCK(handle))
384 #define _MMCAMCORDER_WAIT_UNTIL(handle, end_time) g_cond_wait_until(&_MMCAMCORDER_GET_COND(handle), &_MMCAMCORDER_GET_LOCK(handle), end_time)
385 #define _MMCAMCORDER_SIGNAL(handle) g_cond_signal(&_MMCAMCORDER_GET_COND(handle));
386 #define _MMCAMCORDER_BROADCAST(handle) g_cond_broadcast(&_MMCAMCORDER_GET_COND(handle));
389 #define _MMCAMCORDER_GET_CMD_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).cmd_lock)
390 #define _MMCAMCORDER_GET_CMD_COND(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).cmd_cond)
391 #define _MMCAMCORDER_LOCK_CMD(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_CMD_LOCK(handle))
392 #define _MMCAMCORDER_TRYLOCK_CMD(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_CMD_LOCK(handle))
393 #define _MMCAMCORDER_UNLOCK_CMD(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_CMD_LOCK(handle))
394 #define _MMCAMCORDER_CMD_WAIT(handle) g_cond_wait(&_MMCAMCORDER_GET_CMD_COND(handle), &_MMCAMCORDER_GET_CMD_LOCK(handle))
395 #define _MMCAMCORDER_CMD_WAIT_UNTIL(handle, end_time) g_cond_wait_until(&_MMCAMCORDER_GET_CMD_COND(handle), &_MMCAMCORDER_GET_CMD_LOCK(handle), end_time)
396 #define _MMCAMCORDER_CMD_SIGNAL(handle) g_cond_signal(&_MMCAMCORDER_GET_CMD_COND(handle));
399 #define _MMCAMCORDER_GET_ASM_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).asm_lock)
400 #define _MMCAMCORDER_LOCK_ASM(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_ASM_LOCK(handle))
401 #define _MMCAMCORDER_TRYLOCK_ASM(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_ASM_LOCK(handle))
402 #define _MMCAMCORDER_UNLOCK_ASM(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_ASM_LOCK(handle))
404 /* for state change */
405 #define _MMCAMCORDER_GET_STATE_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).state_lock)
406 #define _MMCAMCORDER_LOCK_STATE(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_STATE_LOCK(handle))
407 #define _MMCAMCORDER_TRYLOCK_STATE(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_STATE_LOCK(handle))
408 #define _MMCAMCORDER_UNLOCK_STATE(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_STATE_LOCK(handle))
410 /* for gstreamer state change */
411 #define _MMCAMCORDER_GET_GST_STATE_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).gst_state_lock)
412 #define _MMCAMCORDER_LOCK_GST_STATE(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_GST_STATE_LOCK(handle))
413 #define _MMCAMCORDER_TRYLOCK_GST_STATE(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_GST_STATE_LOCK(handle))
414 #define _MMCAMCORDER_UNLOCK_GST_STATE(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_GST_STATE_LOCK(handle))
416 #define _MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).gst_encode_state_lock)
417 #define _MMCAMCORDER_LOCK_GST_ENCODE_STATE(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle))
418 #define _MMCAMCORDER_TRYLOCK_GST_ENCODE_STATE(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle))
419 #define _MMCAMCORDER_UNLOCK_GST_ENCODE_STATE(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle))
421 /* for setting/calling callback */
422 #define _MMCAMCORDER_GET_MESSAGE_CALLBACK_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).message_cb_lock)
423 #define _MMCAMCORDER_LOCK_MESSAGE_CALLBACK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_MESSAGE_CALLBACK_LOCK(handle))
424 #define _MMCAMCORDER_TRYLOCK_MESSAGE_CALLBACK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_MESSAGE_CALLBACK_LOCK(handle))
425 #define _MMCAMCORDER_UNLOCK_MESSAGE_CALLBACK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_MESSAGE_CALLBACK_LOCK(handle))
427 #define _MMCAMCORDER_GET_VCAPTURE_CALLBACK_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).vcapture_cb_lock)
428 #define _MMCAMCORDER_LOCK_VCAPTURE_CALLBACK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_VCAPTURE_CALLBACK_LOCK(handle))
429 #define _MMCAMCORDER_TRYLOCK_VCAPTURE_CALLBACK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_VCAPTURE_CALLBACK_LOCK(handle))
430 #define _MMCAMCORDER_UNLOCK_VCAPTURE_CALLBACK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_VCAPTURE_CALLBACK_LOCK(handle))
432 #define _MMCAMCORDER_GET_VSTREAM_CALLBACK_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).vstream_cb_lock)
433 #define _MMCAMCORDER_LOCK_VSTREAM_CALLBACK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_VSTREAM_CALLBACK_LOCK(handle))
434 #define _MMCAMCORDER_TRYLOCK_VSTREAM_CALLBACK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_VSTREAM_CALLBACK_LOCK(handle))
435 #define _MMCAMCORDER_UNLOCK_VSTREAM_CALLBACK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_VSTREAM_CALLBACK_LOCK(handle))
437 #define _MMCAMCORDER_GET_ASTREAM_CALLBACK_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).astream_cb_lock)
438 #define _MMCAMCORDER_LOCK_ASTREAM_CALLBACK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_ASTREAM_CALLBACK_LOCK(handle))
439 #define _MMCAMCORDER_TRYLOCK_ASTREAM_CALLBACK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_ASTREAM_CALLBACK_LOCK(handle))
440 #define _MMCAMCORDER_UNLOCK_ASTREAM_CALLBACK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_ASTREAM_CALLBACK_LOCK(handle))
442 #define _MMCAMCORDER_GET_MSTREAM_CALLBACK_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).mstream_cb_lock)
443 #define _MMCAMCORDER_LOCK_MSTREAM_CALLBACK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_MSTREAM_CALLBACK_LOCK(handle))
444 #define _MMCAMCORDER_TRYLOCK_MSTREAM_CALLBACK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_MSTREAM_CALLBACK_LOCK(handle))
445 #define _MMCAMCORDER_UNLOCK_MSTREAM_CALLBACK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_MSTREAM_CALLBACK_LOCK(handle))
447 #ifdef _MMCAMCORDER_MM_RM_SUPPORT
448 /* for resource conflict */
449 #define _MMCAMCORDER_GET_RESOURCE_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).resource_lock)
450 #define _MMCAMCORDER_LOCK_RESOURCE(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_RESOURCE_LOCK(handle))
451 #define _MMCAMCORDER_UNLOCK_RESOURCE(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_RESOURCE_LOCK(handle))
452 #endif /* _MMCAMCORDER_MM_RM_SUPPORT */
455 * Caster of main handle (camcorder)
457 #define MMF_CAMCORDER(h) (mmf_camcorder_t *)(h)
460 * Caster of subcontext
462 #define MMF_CAMCORDER_SUBCONTEXT(h) (((mmf_camcorder_t *)(h))->sub_context)
464 /* LOCAL CONSTANT DEFINITIONS */
466 * Total Numbers of Attribute values.
467 * If you increase any enum of attribute values, you also have to increase this.
469 #define MM_CAMCORDER_MODE_NUM 3 /**< Number of mode type */
470 #define MM_CAMCORDER_COLOR_TONE_NUM 30 /**< Number of color-tone modes */
471 #define MM_CAMCORDER_WHITE_BALANCE_NUM 10 /**< Number of WhiteBalance modes*/
472 #define MM_CAMCORDER_SCENE_MODE_NUM 16 /**< Number of program-modes */
473 #define MM_CAMCORDER_FOCUS_MODE_NUM 6 /**< Number of focus mode*/
474 #define MM_CAMCORDER_AUTO_FOCUS_NUM 5 /**< Total count of auto focus type*/
475 #define MM_CAMCORDER_FOCUS_STATE_NUM 4 /**< Number of focus state */
476 #define MM_CAMCORDER_ISO_NUM 10 /**< Number of ISO */
477 #define MM_CAMCORDER_AUTO_EXPOSURE_NUM 9 /**< Number of Auto exposure type */
478 #define MM_CAMCORDER_WDR_NUM 3 /**< Number of wide dynamic range */
479 #define MM_CAMCORDER_FLIP_NUM 4 /**< Number of Filp mode */
480 #define MM_CAMCORDER_ROTATION_NUM 4 /**< Number of Rotation mode */
481 #define MM_CAMCORDER_AHS_NUM 4 /**< Number of anti-handshake */
482 #define MM_CAMCORDER_VIDEO_STABILIZATION_NUM 2 /**< Number of video stabilization */
483 #define MM_CAMCORDER_HDR_CAPTURE_NUM 3 /**< Number of HDR capture mode */
484 #define MM_CAMCORDER_GEOMETRY_METHOD_NUM 5 /**< Number of geometry method */
485 #define MM_CAMCORDER_TAG_ORT_NUM 8 /**< Number of tag orientation */
486 #define MM_CAMCORDER_STROBE_MODE_NUM 8 /**< Number of strobe mode type */
487 #define MM_CAMCORDER_STROBE_CONTROL_NUM 3 /**< Number of strobe control type */
488 #define MM_CAMCORDER_DETECT_MODE_NUM 2 /**< Number of detect mode type */
490 /*=======================================================================================
492 ========================================================================================*/
494 * Command for Camcorder.
497 /* Command for Video/Audio recording */
498 _MMCamcorder_CMD_RECORD,
499 _MMCamcorder_CMD_PAUSE,
500 _MMCamcorder_CMD_CANCEL,
501 _MMCamcorder_CMD_COMMIT,
503 /* Command for Image capture */
504 _MMCamcorder_CMD_CAPTURE,
506 /* Command for Preview(Video/Image only effective) */
507 _MMCamcorder_CMD_PREVIEW_START,
508 _MMCamcorder_CMD_PREVIEW_STOP,
515 _MMCamcorder_SINGLE_SHOT,
516 _MMCamcorder_MULTI_SHOT,
520 * Enumerations for manual focus direction.
521 * If focusing mode is not "MM_CAMCORDER_AF_MODE_MANUAL", this value will be ignored.
523 enum MMCamcorderMfLensDir {
524 MM_CAMCORDER_MF_LENS_DIR_FORWARD = 1, /**< Focus direction to forward */
525 MM_CAMCORDER_MF_LENS_DIR_BACKWARD, /**< Focus direction to backward */
526 MM_CAMCORDER_MF_LENS_DIR_NUM, /**< Total number of the directions */
530 * Camcorder Pipeline's Element name.
531 * @note index of element.
534 _MMCAMCORDER_NONE = (-1),
536 /* Main Pipeline Element */
537 _MMCAMCORDER_MAIN_PIPE = 0x00,
539 /* Pipeline element of Video input */
540 _MMCAMCORDER_VIDEOSRC_SRC,
541 _MMCAMCORDER_VIDEOSRC_FILT,
542 _MMCAMCORDER_VIDEOSRC_CLS_QUE,
543 _MMCAMCORDER_VIDEOSRC_CLS,
544 _MMCAMCORDER_VIDEOSRC_CLS_FILT,
545 _MMCAMCORDER_VIDEOSRC_QUE,
546 _MMCAMCORDER_VIDEOSRC_DECODE,
548 /* Pipeline element of Video output */
549 _MMCAMCORDER_VIDEOSINK_QUE,
550 _MMCAMCORDER_VIDEOSINK_CLS,
551 _MMCAMCORDER_VIDEOSINK_SINK,
553 _MMCAMCORDER_PIPELINE_ELEMENT_NUM,
554 } _MMCAMCORDER_PREVIEW_PIPELINE_ELELMENT;
557 * Camcorder Pipeline's Element name.
558 * @note index of element.
561 _MMCAMCORDER_ENCODE_NONE = (-1),
563 /* Main Pipeline Element */
564 _MMCAMCORDER_ENCODE_MAIN_PIPE = 0x00,
566 /* Pipeline element of Audio input */
567 _MMCAMCORDER_AUDIOSRC_BIN,
568 _MMCAMCORDER_AUDIOSRC_SRC,
569 _MMCAMCORDER_AUDIOSRC_FILT,
570 _MMCAMCORDER_AUDIOSRC_QUE,
571 _MMCAMCORDER_AUDIOSRC_CONV,
572 _MMCAMCORDER_AUDIOSRC_VOL,
573 _MMCAMCORDER_AUDIOSRC_RGA, /* for replay gain analysis element */
575 /* Pipeline element of Encodebin */
576 _MMCAMCORDER_ENCSINK_BIN,
577 _MMCAMCORDER_ENCSINK_SRC,
578 _MMCAMCORDER_ENCSINK_FILT,
579 _MMCAMCORDER_ENCSINK_ENCBIN,
580 _MMCAMCORDER_ENCSINK_AQUE,
581 _MMCAMCORDER_ENCSINK_CONV,
582 _MMCAMCORDER_ENCSINK_AENC,
583 _MMCAMCORDER_ENCSINK_AENC_QUE,
584 _MMCAMCORDER_ENCSINK_VQUE,
585 _MMCAMCORDER_ENCSINK_VCONV,
586 _MMCAMCORDER_ENCSINK_VENC,
587 _MMCAMCORDER_ENCSINK_VENC_QUE,
588 _MMCAMCORDER_ENCSINK_ITOG,
589 _MMCAMCORDER_ENCSINK_ICROP,
590 _MMCAMCORDER_ENCSINK_ISCALE,
591 _MMCAMCORDER_ENCSINK_IFILT,
592 _MMCAMCORDER_ENCSINK_IQUE,
593 _MMCAMCORDER_ENCSINK_IENC,
594 _MMCAMCORDER_ENCSINK_MUX,
595 _MMCAMCORDER_ENCSINK_SINK,
597 _MMCAMCORDER_ENCODE_PIPELINE_ELEMENT_NUM,
598 } _MMCAMCORDER_ENCODE_PIPELINE_ELELMENT;
601 _MMCAMCORDER_TASK_THREAD_STATE_NONE,
602 _MMCAMCORDER_TASK_THREAD_STATE_SOUND_PLAY_START,
603 _MMCAMCORDER_TASK_THREAD_STATE_SOUND_SOLO_PLAY_START,
604 _MMCAMCORDER_TASK_THREAD_STATE_ENCODE_PIPE_CREATE,
605 _MMCAMCORDER_TASK_THREAD_STATE_CHECK_CAPTURE_IN_RECORDING,
606 _MMCAMCORDER_TASK_THREAD_STATE_EXIT,
607 } _MMCamcorderTaskThreadState;
610 * System state change cause
613 _MMCAMCORDER_STATE_CHANGE_NORMAL = 0,
614 _MMCAMCORDER_STATE_CHANGE_BY_FOCUS,
615 _MMCAMCORDER_STATE_CHANGE_BY_RM,
616 _MMCAMCORDER_STATE_CHANGE_BY_DPM,
617 _MMCAMCORDER_STATE_CHANGE_BY_STORAGE
618 } _MMCamcorderStateChange;
621 /*=======================================================================================
622 | STRUCTURE DEFINITIONS |
623 ========================================================================================*/
625 * MMCamcorder Gstreamer Element
628 unsigned int id; /**< Gstreamer piplinem element name */
629 GstElement *gst; /**< Gstreamer element */
630 } _MMCamcorderGstElement;
633 * MMCamcorder information for KPI measurement
636 int current_fps; /**< current fps of this second */
637 int average_fps; /**< average fps */
638 unsigned int video_framecount; /**< total number of video frame */
639 unsigned int last_framecount; /**< total number of video frame in last measurement */
640 struct timeval init_video_time; /**< time when start to measure */
641 struct timeval last_video_time; /**< last measurement time */
642 } _MMCamcorderKPIMeasure;
645 * MMCamcorder information for Multi-Thread Safe
648 GMutex lock; /**< Mutex (for general use) */
649 GCond cond; /**< Condition (for general use) */
650 GMutex cmd_lock; /**< Mutex (for command) */
651 GCond cmd_cond; /**< Condition (for command) */
652 GMutex asm_lock; /**< Mutex (for ASM) */
653 GMutex state_lock; /**< Mutex (for state change) */
654 GMutex gst_state_lock; /**< Mutex (for gst pipeline state change) */
655 GMutex gst_encode_state_lock; /**< Mutex (for gst encode pipeline state change) */
656 GMutex message_cb_lock; /**< Mutex (for message callback) */
657 GMutex vcapture_cb_lock; /**< Mutex (for video capture callback) */
658 GMutex vstream_cb_lock; /**< Mutex (for video stream callback) */
659 GMutex astream_cb_lock; /**< Mutex (for audio stream callback) */
660 GMutex mstream_cb_lock; /**< Mutex (for muxed stream callback) */
661 #ifdef _MMCAMCORDER_MM_RM_SUPPORT
662 GMutex resource_lock; /**< Mutex (for resource check) */
663 #endif /* _MMCAMCORDER_MM_RM_SUPPORT */
664 } _MMCamcorderMTSafe;
667 * MMCamcorder Replay gain value
674 } _MMCamcorderReplayGain;
677 * MMCamcorder Sub Context
680 bool isMaxsizePausing; /**< Because of size limit, pipeline is paused. */
681 bool isMaxtimePausing; /**< Because of time limit, pipeline is paused. */
682 int element_num; /**< count of element */
683 int encode_element_num; /**< count of encode element */
684 int cam_stability_count; /**< camsensor stability count. the count of frame will drop */
685 GstClockTime pipeline_time; /**< current time of Gstreamer Pipeline */
686 GstClockTime pause_time; /**< amount of time while pipeline is in PAUSE state.*/
687 GstClockTime stillshot_time; /**< pipeline time of capturing moment*/
688 gboolean is_modified_rate; /**< whether recording motion rate is modified or not */
689 gboolean ferror_send; /**< file write/seek error **/
690 guint ferror_count; /**< file write/seek error count **/
691 GstClockTime previous_slot_time;
692 int display_interval; /**< This value is set as 'GST_SECOND / display FPS' */
693 gboolean bget_eos; /**< Whether getting EOS */
694 gboolean bencbin_capture; /**< Use Encodebin for capturing */
695 gboolean audio_disable; /**< whether audio is disabled or not when record */
696 int videosrc_rotate; /**< rotate of videosrc */
697 unsigned long long muxed_stream_offset; /**< current offset for muxed stream data */
699 /* For dropping video frame when start recording */
700 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. */
701 int pass_first_vframe; /**< When this value is bigger than zero, MSL won't drop video frame though "drop_vframe" is bigger then zero. */
704 _MMCamcorderReplayGain replay_gain; /**< Replay gain for audio recording */
706 /* INI information */
707 unsigned int fourcc; /**< Get fourcc value of camera INI file */
708 _MMCamcorderImageInfo *info_image; /**< extra information for image capture */
709 _MMCamcorderVideoInfo *info_video; /**< extra information for video recording */
710 _MMCamcorderAudioInfo *info_audio; /**< extra information for audio recording */
712 _MMCamcorderGstElement *element; /**< array of preview element */
713 _MMCamcorderGstElement *encode_element; /**< array of encode element */
714 _MMCamcorderKPIMeasure kpi; /**< information related with performance measurement */
716 type_element *VideosinkElement; /**< configure data of videosink element */
717 type_element *VideoconvertElement; /**< configure data of videoconvert element */
718 type_element *VideodecoderElementH264; /**< configure data of video decoder element for H.264 format */
719 gboolean SensorEncodedCapture; /**< whether camera sensor support encoded image capture */
720 gboolean internal_encode; /**< whether use internal encoding function */
721 } _MMCamcorderSubContext;
724 * _MMCamcorderContext
726 typedef struct mmf_camcorder {
728 int type; /**< mmcamcorder_mode_type */
729 int device_type; /**< device type */
730 int state; /**< state of camcorder */
731 int old_state; /**< old state of camcorder */
734 MMHandleType attributes; /**< Attribute handle */
735 _MMCamcorderSubContext *sub_context; /**< sub context */
736 mm_exif_info_t *exif_info; /**< EXIF */
737 GList *buffer_probes; /**< a list of buffer probe handle */
738 GList *event_probes; /**< a list of event probe handle */
739 GList *signals; /**< a list of signal handle */
740 #ifdef _MMCAMCORDER_ENABLE_IDLE_MESSAGE_CALLBACK
741 GList *msg_data; /**< a list of msg data */
742 #endif /* _MMCAMCORDER_ENABLE_IDLE_MESSAGE_CALLBACK */
743 camera_conf *conf_main; /**< Camera configure Main structure */
744 camera_conf *conf_ctrl; /**< Camera configure Control structure */
745 #ifdef _MMCAMCORDER_RM_SUPPORT
746 int rm_handle; /**< Resource manager handle */
747 #endif /* _MMCAMCORDER_RM_SUPPORT */
748 guint pipeline_cb_event_id; /**< Event source ID of pipeline message callback */
749 guint encode_pipeline_cb_event_id; /**< Event source ID of encode pipeline message callback */
750 guint setting_event_id; /**< Event source ID of attributes setting to sensor */
751 SOUND_INFO snd_info; /**< Sound handle for multishot capture */
753 /* callback handlers */
754 MMMessageCallback msg_cb; /**< message callback */
755 void *msg_cb_param; /**< message callback parameter */
756 mm_camcorder_video_stream_callback vstream_cb; /**< Video stream callback */
757 void *vstream_cb_param; /**< Video stream callback parameter */
758 mm_camcorder_audio_stream_callback astream_cb; /**< Audio stream callback */
759 void *astream_cb_param; /**< Audio stream callback parameter */
760 mm_camcorder_muxed_stream_callback mstream_cb; /**< Muxed stream callback */
761 void *mstream_cb_param; /**< Muxed stream callback parameter */
762 mm_camcorder_video_capture_callback vcapture_cb; /**< Video capture callback */
763 void *vcapture_cb_param; /**< Video capture callback parameter */
764 int (*command)(MMHandleType, int); /**< camcorder's command */
767 mm_cam_attr_construct_info *cam_attrs_const_info; /**< attribute info */
768 conf_info_table *conf_main_info_table[CONFIGURE_CATEGORY_MAIN_NUM]; /** configure info table - MAIN category */
769 conf_info_table *conf_ctrl_info_table[CONFIGURE_CATEGORY_CTRL_NUM]; /** configure info table - CONTROL category */
770 int conf_main_category_size[CONFIGURE_CATEGORY_MAIN_NUM]; /** configure info table size - MAIN category */
771 int conf_ctrl_category_size[CONFIGURE_CATEGORY_CTRL_NUM]; /** configure info table size - CONTROL category */
772 _MMCamcorderMTSafe mtsafe; /**< Thread safe */
773 int state_change_by_system; /**< MSL changes its state by itself because of system */
774 GMutex restart_preview_lock; /**< Capture sound mutex */
775 int use_zero_copy_format; /**< Whether use zero copy format for camera input */
776 int use_videoconvert; /**< Whether use videoconvert element for display */
777 int support_media_packet_preview_cb; /**< Whether support zero copy format for camera input */
778 int shutter_sound_policy; /**< shutter sound policy */
779 int brightness_default; /**< default value of brightness */
780 int brightness_step_denominator; /**< denominator of brightness bias step */
781 int support_zsl_capture; /**< support Zero Shutter Lag capture */
782 char *model_name; /**< model name from system info */
783 char *software_version; /**< software_version from system info */
784 int capture_sound_count; /**< count for capture sound */
785 char *root_directory; /**< Root directory for device */
786 int resolution_changed; /**< Flag for preview resolution change */
787 int sound_focus_register; /**< Use sound focus internally */
788 int sound_focus_id; /**< id for sound focus */
789 int sound_focus_watch_id; /**< id for sound focus watch */
790 unsigned int sound_focus_subscribe_id; /**< subscribe id for sound focus signal */
791 int interrupt_code; /**< Interrupt code */
792 int acquired_focus; /**< Current acquired focus */
793 int session_type; /**< Session type */
794 int session_flags; /**< Session flags */
795 int recreate_decoder; /**< Flag of decoder element recreation for encoded preview format */
797 _MMCamcorderInfoConverting caminfo_convert[CAMINFO_CONVERT_NUM]; /**< converting structure of camera info */
798 _MMCamcorderEnumConvert enum_conv[ENUM_CONVERT_NUM]; /**< enum converting list that is modified by ini info */
800 gboolean capture_in_recording; /**< Flag for capture while recording */
802 gboolean error_occurs; /**< flag for error */
803 int error_code; /**< error code for internal gstreamer error */
806 GThread *task_thread; /**< thread for task */
807 GMutex task_thread_lock; /**< mutex for task thread */
808 GCond task_thread_cond; /**< cond for task thread */
809 _MMCamcorderTaskThreadState task_thread_state; /**< state of task thread */
811 #ifdef _MMCAMCORDER_MM_RM_SUPPORT
812 /* resource manager for H/W resources */
813 mm_resource_manager_h resource_manager;
814 mm_resource_manager_res_h camera_resource;
815 mm_resource_manager_res_h video_overlay_resource;
816 mm_resource_manager_res_h video_encoder_resource;
817 gboolean is_release_cb_calling;
818 #endif /* _MMCAMCORDER_MM_RM_SUPPORT */
821 GDBusConnection *gdbus_conn; /**< gdbus connection */
822 _MMCamcorderGDbusCbInfo gdbus_info_sound; /**< Informations for the gbus cb of sound play */
823 _MMCamcorderGDbusCbInfo gdbus_info_solo_sound; /**< Informations for the gbus cb of solo sound play */
825 /* DPM(device policy manager) */
826 device_policy_manager_h dpm_handle; /**< DPM handle */
827 int dpm_camera_cb_id; /**< DPM camera policy changed callback id */
830 _MMCamcorderStorageInfo storage_info; /**< Storage information */
832 #ifdef _MMCAMCORDER_RM_SUPPORT
833 rm_category_request_s request_resources;
834 rm_device_return_s returned_devices;
835 #endif /* _MMCAMCORDER_RM_SUPPORT */
836 int reserved[4]; /**< reserved */
839 /*=======================================================================================
840 | EXTERN GLOBAL VARIABLE |
841 ========================================================================================*/
843 /*=======================================================================================
844 | GLOBAL FUNCTION PROTOTYPES |
845 ========================================================================================*/
847 * This function creates camcorder for capturing still image and recording.
849 * @param[out] handle Specifies the camcorder handle
850 * @param[in] info Preset information of camcorder
851 * @return This function returns zero on success, or negative value with error code.
852 * @remarks When this function calls successfully, camcorder handle will be filled with a @n
853 * valid value and the state of the camcorder will become MM_CAMCORDER_STATE_NULL.@n
854 * Note that it's not ready to working camcorder. @n
855 * You should call mmcamcorder_realize before starting camcorder.
856 * @see _mmcamcorder_create
858 int _mmcamcorder_create(MMHandleType *handle, MMCamPreset *info);
861 * This function destroys instance of camcorder.
863 * @param[in] hcamcorder Specifies the camcorder handle
864 * @return This function returns zero on success, or negative value with error code.
865 * @see _mmcamcorder_create
867 int _mmcamcorder_destroy(MMHandleType hcamcorder);
870 * This function allocates memory for camcorder.
872 * @param[in] hcamcorder Specifies the camcorder handle
873 * @return This function returns zero on success, or negative value with error code.
874 * @remarks This function can be called successfully when current state is MM_CAMCORDER_STATE_NULL @n
875 * and the state of the camcorder will become MM_CAMCORDER_STATE_READY. @n
876 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
877 * @see _mmcamcorder_unrealize
878 * @pre MM_CAMCORDER_STATE_NULL
879 * @post MM_CAMCORDER_STATE_READY
881 int _mmcamcorder_realize(MMHandleType hcamcorder);
884 * This function free allocated memory for camcorder.
886 * @param[in] hcamcorder Specifies the camcorder handle
887 * @return This function returns zero on success, or negative value with error code.
888 * @remarks This function release all resources which are allocated for the camcorder engine.@n
889 * This function can be called successfully when current state is MM_CAMCORDER_STATE_READY and @n
890 * the state of the camcorder will become MM_CAMCORDER_STATE_NULL. @n
891 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
892 * @see _mmcamcorder_realize
893 * @pre MM_CAMCORDER_STATE_READY
894 * @post MM_CAMCORDER_STATE_NULL
896 int _mmcamcorder_unrealize(MMHandleType hcamcorder);
899 * This function is to start previewing.
901 * @param[in] hcamcorder Specifies the camcorder handle
902 * @return This function returns zero on success, or negative value with error code.
903 * @remarks This function can be called successfully when current state is MM_CAMCORDER_STATE_READY and @n
904 * the state of the camcorder will become MM_CAMCORDER_STATE_PREPARE. @n
905 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
906 * @see _mmcamcorder_stop
908 int _mmcamcorder_start(MMHandleType hcamcorder);
911 * This function is to stop previewing.
913 * @param[in] hcamcorder Specifies the camcorder handle
914 * @return This function returns zero on success, or negative value with error code.
915 * @remarks This function can be called successfully when current state is MM_CAMCORDER_STATE_PREPARE and @n
916 * the state of the camcorder will become MM_CAMCORDER_STATE_READY.@n
917 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
918 * @see _mmcamcorder_start
920 int _mmcamcorder_stop(MMHandleType hcamcorder);
923 * This function to start capturing of still images.
925 * @param[in] hcamcorder Specifies the camcorder handle.
926 * @return This function returns zero on success, or negative value with error code.
927 * @remarks This function can be called successfully when current state is MM_CAMCORDER_STATE_PREPARE and @n
928 * the state of the camcorder will become MM_CAMCORDER_STATE_CAPTURING. @n
929 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
930 * @see _mmcamcorder_capture_stop
932 int _mmcamcorder_capture_start(MMHandleType hcamcorder);
935 * This function is to stop capturing still images.
937 * @param[in] hcamcorder Specifies the camcorder handle
938 * @return This function returns zero on success, or negative value with error code.
939 * @remarks This function can be called successfully when current state is MM_CAMCORDER_STATE_CAPTURING and @n
940 * the state of the camcorder will become MM_CAMCORDER_STATE_PREPARE. @n
941 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
942 * @see _mmcamcorder_capture_start
944 int _mmcamcorder_capture_stop(MMHandleType hcamcorder);
947 * This function is to start video and audio recording.
949 * @param[in] hcamcorder Specifies the camcorder handle
950 * @return This function returns zero on success, or negative value with error code.
951 * @remarks This function can be called successfully when current state is @n
952 * MM_CAMCORDER_STATE_PREPARE or MM_CAMCORDER_STATE_PAUSED and @n
953 * the state of the camcorder will become MM_CAMCORDER_STATE_RECORDING.@n
954 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
955 * @see _mmcamcorder_pause
957 int _mmcamcorder_record(MMHandleType hcamcorder);
960 * This function is to pause video and audio recording
962 * @param[in] hcamcorder Specifies the camcorder handle
963 * @return This function returns zero on success, or negative value with error code.
964 * @remarks This function can be called successfully when current state is MM_CAMCORDER_STATE_RECORDING and @n
965 * the state of the camcorder will become MM_CAMCORDER_STATE_PAUSED.@n
966 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.@n
967 * @see _mmcamcorder_record
969 int _mmcamcorder_pause(MMHandleType hcamcorder);
972 * This function is to stop video and audio recording and save results.
974 * @param[in] hcamcorder Specifies the camcorder handle
975 * @return This function returns zero on success, or negative value with error code.
976 * @remarks This function can be called successfully when current state is @n
977 * MM_CAMCORDER_STATE_PAUSED or MM_CAMCORDER_STATE_RECORDING and @n
978 * the state of the camcorder will become MM_CAMCORDER_STATE_PREPARE. @n
979 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION
980 * @see _mmcamcorder_cancel
982 int _mmcamcorder_commit(MMHandleType hcamcorder);
985 * This function is to stop video and audio recording and do not save results.
987 * @param[in] hcamcorder Specifies the camcorder handle
988 * @return This function returns zero on success, or negative value with error code.
989 * @remarks This function can be called successfully when current state is @n
990 * MM_CAMCORDER_STATE_PAUSED or MM_CAMCORDER_STATE_RECORDING and @n
991 * the state of the camcorder will become MM_CAMCORDER_STATE_PREPARE. @n
992 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
993 * @see _mmcamcorder_commit
995 int _mmcamcorder_cancel(MMHandleType hcamcorder);
998 * This function calls after commiting action finished asynchronously.
999 * In this function, remaining process , such as state change, happens.
1001 * @param[in] hcamcorder Specifies the camcorder handle
1002 * @return This function returns zero on success, or negative value with error code.
1003 * @remarks This function can be called successfully when current state is @n
1004 * MM_CAMCORDER_STATE_PAUSED or MM_CAMCORDER_STATE_RECORDING and @n
1005 * the state of the camcorder will become MM_CAMCORDER_STATE_PREPARE. @n
1006 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
1007 * @see _mmcamcorder_commit
1009 int _mmcamcorder_commit_async_end(MMHandleType hcamcorder);
1012 * This function is to set callback for receiving messages from camcorder.
1014 * @param[in] hcamcorder Specifies the camcorder handle
1015 * @param[in] callback Specifies the function pointer of callback function
1016 * @param[in] user_data Specifies the user poiner for passing to callback function
1018 * @return This function returns zero on success, or negative value with error code.
1019 * @remarks typedef bool (*mm_message_callback) (int msg, mm_messageType *param, void *user_param);@n
1034 * } mm_message_type; @n
1036 * If a message value for mm_message_callback is MM_MESSAGE_STATE_CHANGED, @n
1037 * state value in mm_message_type will be a mmcamcorder_state_type enum value;@n
1039 * If a message value for mm_message_callback is MM_MESSAGE_ERROR, @n
1040 * the code value in mm_message_type will be a mmplayer_error_type enum value;
1042 * @see mm_message_type, mmcamcorder_state_type, mmcamcorder_error_type
1044 int _mmcamcorder_set_message_callback(MMHandleType hcamcorder,
1045 MMMessageCallback callback,
1049 * This function is to set callback for video stream.
1051 * @param[in] hcamcorder Specifies the camcorder handle
1052 * @param[in] callback Specifies the function pointer of callback function
1053 * @param[in] user_data Specifies the user poiner for passing to callback function
1055 * @return This function returns zero on success, or negative value with error code.
1056 * @see mmcamcorder_error_type
1058 int _mmcamcorder_set_video_stream_callback(MMHandleType hcamcorder,
1059 mm_camcorder_video_stream_callback callback,
1063 * This function is to set callback for audio stream.
1065 * @param[in] hcamcorder Specifies the camcorder handle
1066 * @param[in] callback Specifies the function pointer of callback function
1067 * @param[in] user_data Specifies the user poiner for passing to callback function
1069 * @return This function returns zero on success, or negative value with error code.
1070 * @see mmcamcorder_error_type
1072 int _mmcamcorder_set_audio_stream_callback(MMHandleType handle,
1073 mm_camcorder_audio_stream_callback callback,
1077 * This function is to set callback for muxed stream.
1079 * @param[in] hcamcorder Specifies the camcorder handle
1080 * @param[in] callback Specifies the function pointer of callback function
1081 * @param[in] user_data Specifies the user poiner for passing to callback function
1083 * @return This function returns zero on success, or negative value with error code.
1084 * @see mmcamcorder_error_type
1086 int _mmcamcorder_set_muxed_stream_callback(MMHandleType handle,
1087 mm_camcorder_muxed_stream_callback callback,
1091 * This function is to set callback for video capture.
1093 * @param[in] hcamcorder Specifies the camcorder handle
1094 * @param[in] callback Specifies the function pointer of callback function
1095 * @param[in] user_data Specifies the user poiner for passing to callback function
1097 * @return This function returns zero on success, or negative value with error code.
1098 * @see mmcamcorder_error_type
1100 int _mmcamcorder_set_video_capture_callback(MMHandleType hcamcorder,
1101 mm_camcorder_video_capture_callback callback,
1105 * This function returns current state of camcorder, or negative value with error code.
1107 * @param[in] hcamcorder Specifies the camcorder handle.
1108 * @return This function returns current state of camcorder, or negative value with error code.
1109 * @see mmcamcorder_state_type
1111 int _mmcamcorder_get_current_state(MMHandleType hcamcorder);
1113 int _mmcamcorder_init_focusing(MMHandleType handle);
1114 int _mmcamcorder_adjust_focus(MMHandleType handle, int direction);
1115 int _mmcamcorder_adjust_manual_focus(MMHandleType handle, int direction);
1116 int _mmcamcorder_adjust_auto_focus(MMHandleType handle);
1117 int _mmcamcorder_stop_focusing(MMHandleType handle);
1120 * This function gets current state of camcorder.
1123 * @return This function returns state of current camcorder context
1125 * @see _mmcamcorder_set_state()
1128 int _mmcamcorder_streamer_init(void);
1131 * This function gets current state of camcorder.
1134 * @return This function returns state of current camcorder context
1136 * @see _mmcamcorder_set_state()
1139 int _mmcamcorder_display_init(void);
1142 * This function gets current state of camcorder.
1144 * @param[in] handle Handle of camcorder context.
1145 * @return This function returns state of current camcorder context
1147 * @see _mmcamcorder_set_state()
1150 int _mmcamcorder_get_state(MMHandleType handle);
1151 int _mmcamcorder_get_state2(MMHandleType handle, int *state, int *old_state);
1154 * This function sets new state of camcorder.
1156 * @param[in] handle Handle of camcorder context.
1157 * @param[in] state setting state value of camcorder.
1160 * @see _mmcamcorder_get_state()
1163 void _mmcamcorder_set_state(MMHandleType handle, int state);
1166 * This function allocates structure of subsidiary attributes.
1168 * @param[in] type Allocation type of camcorder context.
1169 * @return This function returns structure pointer on success, NULL value on failure.
1171 * @see _mmcamcorder_dealloc_subcontext()
1174 _MMCamcorderSubContext *_mmcamcorder_alloc_subcontext(int type);
1177 * This function releases structure of subsidiary attributes.
1179 * @param[in] sc Handle of camcorder subcontext.
1182 * @see _mmcamcorder_alloc_subcontext()
1185 void _mmcamcorder_dealloc_subcontext(_MMCamcorderSubContext *sc);
1188 * This function sets command function according to the type.
1190 * @param[in] handle Handle of camcorder context.
1191 * @param[in] type Allocation type of camcorder context.
1192 * @return This function returns MM_ERROR_NONE on success, or other values with error code.
1194 * @see __mmcamcorder_video_command(), __mmcamcorder_audio_command(), __mmcamcorder_image_command()
1197 int _mmcamcorder_set_functions(MMHandleType handle, int type);
1200 * This function is callback function of main pipeline.
1201 * Once this function is registered with certain pipeline using gst_bus_add_watch(),
1202 * this callback will be called every time when there is upcomming message from pipeline.
1203 * Basically, this function is used as error handling function, now.
1205 * @param[in] bus pointer of buf that called this function.
1206 * @param[in] message callback message from pipeline.
1207 * @param[in] data user data.
1208 * @return This function returns true on success, or false value with error
1210 * @see __mmcamcorder_create_preview_pipeline()
1213 gboolean _mmcamcorder_pipeline_cb_message(GstBus *bus, GstMessage *message, gpointer data);
1216 * This function is callback function of main pipeline.
1217 * Once this function is registered with certain pipeline using gst_bus_set_sync_handler(),
1218 * this callback will be called every time when there is upcomming message from pipeline.
1219 * Basically, this function is used as sync error handling function, now.
1221 * @param[in] bus pointer of buf that called this function.
1222 * @param[in] message callback message from pipeline.
1223 * @param[in] data user data.
1224 * @return This function returns true on success, or false value with error
1226 * @see __mmcamcorder_create_preview_pipeline()
1229 GstBusSyncReply _mmcamcorder_pipeline_bus_sync_callback(GstBus *bus, GstMessage *message, gpointer data);
1232 * This function is callback function of encode pipeline.
1233 * Once this function is registered with certain pipeline using gst_bus_set_sync_handler(),
1234 * this callback will be called every time when there is upcomming message from pipeline.
1235 * Basically, this function is used for EOS and error handling now.
1237 * @param[in] bus pointer of buf that called this function.
1238 * @param[in] message callback message from pipeline.
1239 * @param[in] data user data.
1240 * @return This function returns true on success, or false value with error
1242 * @see __mmcamcorder_create_recorder_pipeline()
1243 * @see __mmcamcorder_create_audiop_with_encodebin()
1246 GstBusSyncReply _mmcamcorder_encode_pipeline_bus_sync_callback(GstBus *bus, GstMessage *message, gpointer data);
1249 * This function create main pipeline according to type.
1251 * @param[in] handle Handle of camcorder context.
1252 * @param[in] type Allocation type of camcorder context.
1253 * @return This function returns zero on success, or negative value with error code.
1255 * @see _mmcamcorder_destroy_pipeline()
1258 int _mmcamcorder_create_pipeline(MMHandleType handle, int type);
1261 * This function release all element of main pipeline according to type.
1263 * @param[in] handle Handle of camcorder context.
1264 * @param[in] type Allocation type of camcorder context.
1267 * @see _mmcamcorder_create_pipeline()
1270 void _mmcamcorder_destroy_pipeline(MMHandleType handle, int type);
1273 * This function sets gstreamer element status.
1274 * If the gstreamer fails to set status or returns asynchronous mode,
1275 * this function waits for state changed until timeout expired.
1277 * @param[in] pipeline Pointer of pipeline
1278 * @param[in] target_state newly setting status
1279 * @return This function returns zero on success, or negative value with error code.
1284 int _mmcamcorder_gst_set_state(MMHandleType handle, GstElement *pipeline, GstState target_state);
1287 /* For xvimagesink */
1288 GstBusSyncReply __mmcamcorder_sync_callback(GstBus *bus, GstMessage *message, gulong data);
1290 /* For querying capabilities */
1291 int _mmcamcorder_read_vidsrc_info(int videodevidx, camera_conf **configure_info);
1293 /* for performance check */
1294 void _mmcamcorder_video_current_framerate_init(MMHandleType handle);
1295 int _mmcamcorder_video_current_framerate(MMHandleType handle);
1296 int _mmcamcorder_video_average_framerate(MMHandleType handle);
1298 /* sound focus related function */
1299 void __mmcamcorder_force_stop(mmf_camcorder_t *hcamcorder, int state_change_by_system);
1300 void _mmcamcorder_sound_focus_cb(int id, mm_sound_focus_type_e focus_type,
1301 mm_sound_focus_state_e focus_state, const char *reason_for_change,
1302 int option, const char *additional_info, void *user_data);
1303 void _mmcamcorder_sound_focus_watch_cb(int id, mm_sound_focus_type_e focus_type, mm_sound_focus_state_e focus_state,
1304 const char *reason_for_change, const char *additional_info, void *user_data);
1305 void _mmcamcorder_sound_signal_callback(mm_sound_signal_name_t signal, int value, void *user_data);
1307 /* device policy manager */
1308 void _mmcamcorder_dpm_camera_policy_changed_cb(const char *name, const char *value, void *user_data);
1310 /* Emit dbus signal */
1311 void _mmcamcorder_emit_signal(MMHandleType handle, const char *object_name,
1312 const char *interface_name, const char *signal_name, int value);
1314 /* external storage state management */
1315 int _mmcamcorder_manage_external_storage_state(MMHandleType handle, int storage_state);
1321 #endif /* __MM_CAMCORDER_INTERNAL_H__ */