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 */
46 #include "mm_camcorder.h"
49 #ifdef _MMCAMCORDER_MURPHY_SUPPORT
50 #include "mm_camcorder_resource.h"
51 #endif /* _MMCAMCORDER_MURPHY_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 */
74 /*=======================================================================================
76 ========================================================================================*/
77 #define _mmcam_dbg_verb(fmt, args...) debug_verbose(" "fmt"\n", ##args);
78 #define _mmcam_dbg_log(fmt, args...) debug_log(" "fmt"\n", ##args);
79 #define _mmcam_dbg_warn(fmt, args...) debug_warning(" "fmt"\n", ##args);
80 #define _mmcam_dbg_err(fmt, args...) debug_error(" "fmt"\n", ##args);
81 #define _mmcam_dbg_crit(fmt, args...) debug_critical(" "fmt"\n", ##args);
84 * Macro for checking validity and debugging
86 #define mmf_return_if_fail(expr) \
88 _mmcam_dbg_err("failed [%s]", #expr); \
93 * Macro for checking validity and debugging
95 #define mmf_return_val_if_fail(expr, val) \
97 _mmcam_dbg_err("failed [%s]", #expr); \
104 * Macro for getting array size
106 #define ARRAY_SIZE(a) (sizeof((a)) / sizeof((a)[0]))
109 /* gstreamer element creation macro */
110 #define _MMCAMCORDER_PIPELINE_MAKE(sub_context, element, eid, name /*char* */, err) \
111 if (element[eid].gst != NULL) { \
112 _mmcam_dbg_err("The element(Pipeline) is existed. element_id=[%d], name=[%s]", eid, name); \
113 gst_object_unref(element[eid].gst); \
115 element[eid].id = eid; \
116 element[eid].gst = gst_pipeline_new(name); \
117 if (element[eid].gst == NULL) { \
118 _mmcam_dbg_err("Pipeline creation fail. element_id=[%d], name=[%s]", eid, name); \
119 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
120 goto pipeline_creation_error; \
122 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
125 #define _MMCAMCORDER_BIN_MAKE(sub_context, element, eid, name /*char* */, err) \
126 if (element[eid].gst != NULL) { \
127 _mmcam_dbg_err("The element(Bin) is existed. element_id=[%d], name=[%s]", eid, name); \
128 gst_object_unref(element[eid].gst); \
130 element[eid].id = eid; \
131 element[eid].gst = gst_bin_new(name); \
132 if (element[eid].gst == NULL) { \
133 _mmcam_dbg_err("Bin creation fail. element_id=[%d], name=[%s]\n", eid, name); \
134 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
135 goto pipeline_creation_error; \
137 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
140 #define _MMCAMCORDER_ELEMENT_MAKE(sub_context, element, eid, name /*char* */, nickname /*char* */, elist, err) \
141 if (element[eid].gst != NULL) { \
142 _mmcam_dbg_err("The element is existed. element_id=[%d], name=[%s]", eid, name); \
143 gst_object_unref(element[eid].gst); \
145 traceBegin(TTRACE_TAG_CAMERA, "MMCAMCORDER:ELEMENT_MAKE:%s", name); \
146 element[eid].gst = gst_element_factory_make(name, nickname); \
147 traceEnd(TTRACE_TAG_CAMERA); \
148 if (element[eid].gst == NULL) { \
149 _mmcam_dbg_err("Element creation fail. element_id=[%d], name=[%s]", eid, name); \
150 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
151 goto pipeline_creation_error; \
153 _mmcam_dbg_log("Element creation done. element_id=[%d], name=[%s]", eid, name); \
154 element[eid].id = eid; \
155 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
156 err = MM_ERROR_NONE; \
158 elist = g_list_append(elist, &(element[eid]));
160 #define _MMCAMCORDER_ELEMENT_MAKE2(sub_context, element, eid, name /*char* */, nickname /*char* */, err) \
161 if (element[eid].gst != NULL) { \
162 _mmcam_dbg_err("The element is existed. element_id=[%d], name=[%s]", eid, name); \
163 gst_object_unref(element[eid].gst); \
165 element[eid].gst = gst_element_factory_make(name, nickname); \
166 if (element[eid].gst == NULL) { \
167 _mmcam_dbg_err("Element creation fail. element_id=[%d], name=[%s]", eid, name); \
168 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
170 _mmcam_dbg_log("Element creation done. element_id=[%d], name=[%s]", eid, name); \
171 element[eid].id = eid; \
172 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
173 err = MM_ERROR_NONE; \
176 #define _MMCAMCORDER_ELEMENT_MAKE_IGNORE_ERROR(sub_context, element, eid, name /*char* */, nickname /*char* */, elist) \
177 if (element[eid].gst != NULL) { \
178 _mmcam_dbg_err("The element is existed. element_id=[%d], name=[%s]", eid, name); \
179 gst_object_unref(element[eid].gst); \
181 element[eid].gst = gst_element_factory_make(name, nickname); \
182 if (element[eid].gst == NULL) { \
183 _mmcam_dbg_err("Element creation fail. element_id=[%d], name=[%s], but keep going...", eid, name); \
185 _mmcam_dbg_log("Element creation done. element_id=[%d], name=[%s]", eid, name); \
186 element[eid].id = eid; \
187 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
188 elist = g_list_append(elist, &(element[eid])); \
191 #define _MMCAMCORDER_ELEMENT_ADD(sub_context, element, eid, gst_element, elist, err) \
192 if (element[eid].gst != NULL) { \
193 _mmcam_dbg_err("The element is existed. element_id=[%d]", eid); \
194 gst_object_unref(element[eid].gst); \
196 element[eid].gst = gst_element; \
197 if (element[eid].gst == NULL) { \
198 _mmcam_dbg_err("Element is NULL. element_id=[%d]", eid); \
199 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
200 goto pipeline_creation_error; \
202 _mmcam_dbg_log("Adding Element is done. element_id=[%d] %p", eid, gst_element); \
203 element[eid].id = eid; \
204 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
205 err = MM_ERROR_NONE; \
207 elist = g_list_append(elist, &(element[eid]));
209 #define _MMCAMCORDER_ENCODEBIN_ELMGET(sub_context, eid, name /*char* */, err) \
210 if (sub_context->encode_element[eid].gst != NULL) { \
211 _mmcam_dbg_err("The element is existed. element_id=[%d], name=[%s]", eid, name); \
212 gst_object_unref(sub_context->encode_element[eid].gst); \
214 sub_context->encode_element[eid].id = eid; \
215 g_object_get(G_OBJECT(sub_context->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst), name, &(sub_context->encode_element[eid].gst), NULL); \
216 if (sub_context->encode_element[eid].gst == NULL) { \
217 _mmcam_dbg_err("Encode Element get fail. element_id=[%d], name=[%s]", eid, name); \
218 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
219 goto pipeline_creation_error; \
221 gst_object_unref(sub_context->encode_element[eid].gst); \
222 g_object_weak_ref(G_OBJECT(sub_context->encode_element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
225 /* GStreamer element remove macro */
226 #define _MMCAMCORDER_ELEMENT_REMOVE(element, eid) \
227 if (element[eid].gst != NULL) { \
228 gst_object_unref(element[eid].gst); \
231 #define _MM_GST_ELEMENT_LINK_MANY gst_element_link_many
232 #define _MM_GST_ELEMENT_LINK gst_element_link
233 #define _MM_GST_ELEMENT_LINK_FILTERED gst_element_link_filtered
234 #define _MM_GST_ELEMENT_UNLINK gst_element_unlink
235 #define _MM_GST_PAD_LINK gst_pad_link
237 #define _MM_GST_PAD_LINK_UNREF(srcpad, sinkpad, err, if_fail_goto) \
239 GstPadLinkReturn ret = GST_PAD_LINK_OK; \
240 if (srcpad == NULL || sinkpad == NULL) { \
241 if (srcpad == NULL) { \
242 _mmcam_dbg_err("srcpad is NULL"); \
244 gst_object_unref(srcpad);\
247 if (sinkpad == NULL) { \
248 _mmcam_dbg_err("sinkpad is NULL"); \
250 gst_object_unref(sinkpad); \
253 err = MM_ERROR_CAMCORDER_GST_LINK; \
256 ret = _MM_GST_PAD_LINK(srcpad, sinkpad); \
257 if (ret != GST_PAD_LINK_OK) { \
258 GstObject *src_parent = gst_pad_get_parent(srcpad); \
259 GstObject *sink_parent = gst_pad_get_parent(sinkpad); \
260 char *src_name = NULL; \
261 char *sink_name = NULL; \
262 g_object_get((GObject *)src_parent, "name", &src_name, NULL); \
263 g_object_get((GObject *)sink_parent, "name", &sink_name, NULL); \
264 _mmcam_dbg_err("src[%s] - sink[%s] link failed", src_name, sink_name); \
265 gst_object_unref(src_parent); src_parent = NULL; \
266 gst_object_unref(sink_parent); sink_parent = NULL; \
268 free(src_name); src_name = NULL; \
271 free(sink_name); sink_name = NULL; \
273 gst_object_unref(srcpad); srcpad = NULL; \
274 gst_object_unref(sinkpad); sinkpad = NULL; \
275 err = MM_ERROR_CAMCORDER_GST_LINK; \
278 gst_object_unref(srcpad); srcpad = NULL; \
279 gst_object_unref(sinkpad); sinkpad = NULL; \
282 #define _MM_GST_PAD_UNLINK_UNREF(srcpad, sinkpad) \
283 if (srcpad && sinkpad) { \
284 gst_pad_unlink(srcpad, sinkpad); \
286 _mmcam_dbg_warn("some pad(srcpad:%p,sinkpad:%p) is NULL", srcpad, sinkpad); \
289 gst_object_unref(srcpad); srcpad = NULL; \
292 gst_object_unref(sinkpad); sinkpad = NULL; \
295 #define _MMCAMCORDER_STATE_SET_COUNT 3 /* checking interval */
296 #define _MMCAMCORDER_STATE_CHECK_TOTALTIME 5000000L /* total wating time for state change */
297 #define _MMCAMCORDER_STATE_CHECK_INTERVAL (50*1000) /* checking interval - 50ms*/
300 * Default videosink type
302 #define _MMCAMCORDER_DEFAULT_VIDEOSINK_TYPE "VideosinkElementOverlay"
305 * Default recording motion rate
307 #define _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE 1.0
310 * Total level count of manual focus */
311 #define _MMFCAMCORDER_FOCUS_TOTAL_LEVEL 8
314 * File name length limit
316 #define _MMCamcorder_FILENAME_LEN (512)
319 * Minimum integer value
321 #define _MMCAMCORDER_MIN_INT (INT_MIN)
324 * Maximum integer value
326 #define _MMCAMCORDER_MAX_INT (INT_MAX)
329 * Minimum double value
331 #define _MMCAMCORDER_MIN_DOUBLE (DBL_MIN)
334 * Maximum integer value
336 #define _MMCAMCORDER_MAX_DOUBLE (DBL_MAX)
339 * Audio timestamp margin (msec)
341 #define _MMCAMCORDER_AUDIO_TIME_MARGIN (300)
344 * Functions related with LOCK and WAIT
346 #define _MMCAMCORDER_CAST_MTSAFE(handle) (((mmf_camcorder_t*)handle)->mtsafe)
347 #define _MMCAMCORDER_LOCK_FUNC(mutex) g_mutex_lock(&mutex)
348 #define _MMCAMCORDER_TRYLOCK_FUNC(mutex) g_mutex_trylock(&mutex)
349 #define _MMCAMCORDER_UNLOCK_FUNC(mutex) g_mutex_unlock(&mutex)
351 #define _MMCAMCORDER_GET_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).lock)
352 #define _MMCAMCORDER_LOCK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_LOCK(handle))
353 #define _MMCAMCORDER_TRYLOCK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_LOCK(handle))
354 #define _MMCAMCORDER_UNLOCK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_LOCK(handle))
356 #define _MMCAMCORDER_GET_COND(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).cond)
357 #define _MMCAMCORDER_WAIT(handle) g_cond_wait(&_MMCAMCORDER_GET_COND(handle), &_MMCAMCORDER_GET_LOCK(handle))
358 #define _MMCAMCORDER_WAIT_UNTIL(handle, end_time) g_cond_wait_until(&_MMCAMCORDER_GET_COND(handle), &_MMCAMCORDER_GET_LOCK(handle), end_time)
359 #define _MMCAMCORDER_SIGNAL(handle) g_cond_signal(&_MMCAMCORDER_GET_COND(handle));
360 #define _MMCAMCORDER_BROADCAST(handle) g_cond_broadcast(&_MMCAMCORDER_GET_COND(handle));
363 #define _MMCAMCORDER_GET_CMD_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).cmd_lock)
364 #define _MMCAMCORDER_GET_CMD_COND(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).cmd_cond)
365 #define _MMCAMCORDER_LOCK_CMD(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_CMD_LOCK(handle))
366 #define _MMCAMCORDER_TRYLOCK_CMD(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_CMD_LOCK(handle))
367 #define _MMCAMCORDER_UNLOCK_CMD(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_CMD_LOCK(handle))
368 #define _MMCAMCORDER_CMD_WAIT(handle) g_cond_wait(&_MMCAMCORDER_GET_CMD_COND(handle), &_MMCAMCORDER_GET_CMD_LOCK(handle))
369 #define _MMCAMCORDER_CMD_WAIT_UNTIL(handle, end_time) g_cond_wait_until(&_MMCAMCORDER_GET_CMD_COND(handle), &_MMCAMCORDER_GET_CMD_LOCK(handle), end_time)
370 #define _MMCAMCORDER_CMD_SIGNAL(handle) g_cond_signal(&_MMCAMCORDER_GET_CMD_COND(handle));
373 #define _MMCAMCORDER_GET_ASM_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).asm_lock)
374 #define _MMCAMCORDER_LOCK_ASM(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_ASM_LOCK(handle))
375 #define _MMCAMCORDER_TRYLOCK_ASM(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_ASM_LOCK(handle))
376 #define _MMCAMCORDER_UNLOCK_ASM(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_ASM_LOCK(handle))
378 /* for state change */
379 #define _MMCAMCORDER_GET_STATE_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).state_lock)
380 #define _MMCAMCORDER_LOCK_STATE(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_STATE_LOCK(handle))
381 #define _MMCAMCORDER_TRYLOCK_STATE(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_STATE_LOCK(handle))
382 #define _MMCAMCORDER_UNLOCK_STATE(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_STATE_LOCK(handle))
384 /* for gstreamer state change */
385 #define _MMCAMCORDER_GET_GST_STATE_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).gst_state_lock)
386 #define _MMCAMCORDER_LOCK_GST_STATE(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_GST_STATE_LOCK(handle))
387 #define _MMCAMCORDER_TRYLOCK_GST_STATE(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_GST_STATE_LOCK(handle))
388 #define _MMCAMCORDER_UNLOCK_GST_STATE(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_GST_STATE_LOCK(handle))
390 #define _MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).gst_encode_state_lock)
391 #define _MMCAMCORDER_LOCK_GST_ENCODE_STATE(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle))
392 #define _MMCAMCORDER_TRYLOCK_GST_ENCODE_STATE(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle))
393 #define _MMCAMCORDER_UNLOCK_GST_ENCODE_STATE(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle))
395 /* for setting/calling callback */
396 #define _MMCAMCORDER_GET_MESSAGE_CALLBACK_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).message_cb_lock)
397 #define _MMCAMCORDER_LOCK_MESSAGE_CALLBACK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_MESSAGE_CALLBACK_LOCK(handle))
398 #define _MMCAMCORDER_TRYLOCK_MESSAGE_CALLBACK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_MESSAGE_CALLBACK_LOCK(handle))
399 #define _MMCAMCORDER_UNLOCK_MESSAGE_CALLBACK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_MESSAGE_CALLBACK_LOCK(handle))
401 #define _MMCAMCORDER_GET_VCAPTURE_CALLBACK_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).vcapture_cb_lock)
402 #define _MMCAMCORDER_LOCK_VCAPTURE_CALLBACK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_VCAPTURE_CALLBACK_LOCK(handle))
403 #define _MMCAMCORDER_TRYLOCK_VCAPTURE_CALLBACK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_VCAPTURE_CALLBACK_LOCK(handle))
404 #define _MMCAMCORDER_UNLOCK_VCAPTURE_CALLBACK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_VCAPTURE_CALLBACK_LOCK(handle))
406 #define _MMCAMCORDER_GET_VSTREAM_CALLBACK_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).vstream_cb_lock)
407 #define _MMCAMCORDER_LOCK_VSTREAM_CALLBACK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_VSTREAM_CALLBACK_LOCK(handle))
408 #define _MMCAMCORDER_TRYLOCK_VSTREAM_CALLBACK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_VSTREAM_CALLBACK_LOCK(handle))
409 #define _MMCAMCORDER_UNLOCK_VSTREAM_CALLBACK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_VSTREAM_CALLBACK_LOCK(handle))
411 #define _MMCAMCORDER_GET_ASTREAM_CALLBACK_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).astream_cb_lock)
412 #define _MMCAMCORDER_LOCK_ASTREAM_CALLBACK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_ASTREAM_CALLBACK_LOCK(handle))
413 #define _MMCAMCORDER_TRYLOCK_ASTREAM_CALLBACK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_ASTREAM_CALLBACK_LOCK(handle))
414 #define _MMCAMCORDER_UNLOCK_ASTREAM_CALLBACK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_ASTREAM_CALLBACK_LOCK(handle))
416 #ifdef _MMCAMCORDER_MURPHY_SUPPORT
417 /* for resource conflict */
418 #define _MMCAMCORDER_GET_RESOURCE_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).resource_lock)
419 #define _MMCAMCORDER_GET_RESOURCE_COND(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).resource_cond)
420 #define _MMCAMCORDER_LOCK_RESOURCE(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_RESOURCE_LOCK(handle))
421 #define _MMCAMCORDER_TRYLOCK_RESOURCE(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_RESOURCE_LOCK(handle))
422 #define _MMCAMCORDER_UNLOCK_RESOURCE(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_RESOURCE_LOCK(handle))
423 #define _MMCAMCORDER_RESOURCE_WAIT(handle) g_cond_wait(&_MMCAMCORDER_GET_RESOURCE_COND(handle), &_MMCAMCORDER_GET_RESOURCE_LOCK(handle))
424 #define _MMCAMCORDER_RESOURCE_WAIT_UNTIL(handle, end_time) g_cond_wait_until(&_MMCAMCORDER_GET_RESOURCE_COND(handle), &_MMCAMCORDER_GET_RESOURCE_LOCK(handle), end_time)
425 #define _MMCAMCORDER_RESOURCE_SIGNAL(handle) g_cond_signal(&_MMCAMCORDER_GET_RESOURCE_COND(handle));
426 #endif /* _MMCAMCORDER_MURPHY_SUPPORT */
429 * Caster of main handle (camcorder)
431 #define MMF_CAMCORDER(h) (mmf_camcorder_t *)(h)
434 * Caster of subcontext
436 #define MMF_CAMCORDER_SUBCONTEXT(h) (((mmf_camcorder_t *)(h))->sub_context)
438 /* LOCAL CONSTANT DEFINITIONS */
440 * Total Numbers of Attribute values.
441 * If you increase any enum of attribute values, you also have to increase this.
443 #define MM_CAMCORDER_MODE_NUM 3 /**< Number of mode type */
444 #define MM_CAMCORDER_COLOR_TONE_NUM 30 /**< Number of color-tone modes */
445 #define MM_CAMCORDER_WHITE_BALANCE_NUM 10 /**< Number of WhiteBalance modes*/
446 #define MM_CAMCORDER_SCENE_MODE_NUM 16 /**< Number of program-modes */
447 #define MM_CAMCORDER_FOCUS_MODE_NUM 6 /**< Number of focus mode*/
448 #define MM_CAMCORDER_AUTO_FOCUS_NUM 5 /**< Total count of auto focus type*/
449 #define MM_CAMCORDER_FOCUS_STATE_NUM 4 /**< Number of focus state */
450 #define MM_CAMCORDER_ISO_NUM 10 /**< Number of ISO */
451 #define MM_CAMCORDER_AUTO_EXPOSURE_NUM 9 /**< Number of Auto exposure type */
452 #define MM_CAMCORDER_WDR_NUM 3 /**< Number of wide dynamic range */
453 #define MM_CAMCORDER_FLIP_NUM 4 /**< Number of Filp mode */
454 #define MM_CAMCORDER_ROTATION_NUM 4 /**< Number of Rotation mode */
455 #define MM_CAMCORDER_AHS_NUM 4 /**< Number of anti-handshake */
456 #define MM_CAMCORDER_VIDEO_STABILIZATION_NUM 2 /**< Number of video stabilization */
457 #define MM_CAMCORDER_HDR_CAPTURE_NUM 3 /**< Number of HDR capture mode */
458 #define MM_CAMCORDER_GEOMETRY_METHOD_NUM 5 /**< Number of geometry method */
459 #define MM_CAMCORDER_TAG_ORT_NUM 8 /**< Number of tag orientation */
460 #define MM_CAMCORDER_STROBE_MODE_NUM 8 /**< Number of strobe mode type */
461 #define MM_CAMCORDER_STROBE_CONTROL_NUM 3 /**< Number of strobe control type */
462 #define MM_CAMCORDER_DETECT_MODE_NUM 2 /**< Number of detect mode type */
464 /*=======================================================================================
466 ========================================================================================*/
468 * Command for Camcorder.
471 /* Command for Video/Audio recording */
472 _MMCamcorder_CMD_RECORD,
473 _MMCamcorder_CMD_PAUSE,
474 _MMCamcorder_CMD_CANCEL,
475 _MMCamcorder_CMD_COMMIT,
477 /* Command for Image capture */
478 _MMCamcorder_CMD_CAPTURE,
480 /* Command for Preview(Video/Image only effective) */
481 _MMCamcorder_CMD_PREVIEW_START,
482 _MMCamcorder_CMD_PREVIEW_STOP,
489 _MMCamcorder_SINGLE_SHOT,
490 _MMCamcorder_MULTI_SHOT,
494 * Enumerations for manual focus direction.
495 * If focusing mode is not "MM_CAMCORDER_AF_MODE_MANUAL", this value will be ignored.
497 enum MMCamcorderMfLensDir {
498 MM_CAMCORDER_MF_LENS_DIR_FORWARD = 1, /**< Focus direction to forward */
499 MM_CAMCORDER_MF_LENS_DIR_BACKWARD, /**< Focus direction to backward */
500 MM_CAMCORDER_MF_LENS_DIR_NUM, /**< Total number of the directions */
504 * Camcorder Pipeline's Element name.
505 * @note index of element.
508 _MMCAMCORDER_NONE = (-1),
510 /* Main Pipeline Element */
511 _MMCAMCORDER_MAIN_PIPE = 0x00,
513 /* Pipeline element of Video input */
514 _MMCAMCORDER_VIDEOSRC_SRC,
515 _MMCAMCORDER_VIDEOSRC_FILT,
516 _MMCAMCORDER_VIDEOSRC_CLS_QUE,
517 _MMCAMCORDER_VIDEOSRC_CLS,
518 _MMCAMCORDER_VIDEOSRC_CLS_FILT,
519 _MMCAMCORDER_VIDEOSRC_QUE,
520 _MMCAMCORDER_VIDEOSRC_DECODE,
522 /* Pipeline element of Video output */
523 _MMCAMCORDER_VIDEOSINK_QUE,
524 _MMCAMCORDER_VIDEOSINK_CLS,
525 _MMCAMCORDER_VIDEOSINK_SINK,
527 _MMCAMCORDER_PIPELINE_ELEMENT_NUM,
528 } _MMCAMCORDER_PREVIEW_PIPELINE_ELELMENT;
531 * Camcorder Pipeline's Element name.
532 * @note index of element.
535 _MMCAMCORDER_ENCODE_NONE = (-1),
537 /* Main Pipeline Element */
538 _MMCAMCORDER_ENCODE_MAIN_PIPE = 0x00,
540 /* Pipeline element of Audio input */
541 _MMCAMCORDER_AUDIOSRC_BIN,
542 _MMCAMCORDER_AUDIOSRC_SRC,
543 _MMCAMCORDER_AUDIOSRC_FILT,
544 _MMCAMCORDER_AUDIOSRC_QUE,
545 _MMCAMCORDER_AUDIOSRC_CONV,
546 _MMCAMCORDER_AUDIOSRC_VOL,
548 /* Pipeline element of Encodebin */
549 _MMCAMCORDER_ENCSINK_BIN,
550 _MMCAMCORDER_ENCSINK_SRC,
551 _MMCAMCORDER_ENCSINK_FILT,
552 _MMCAMCORDER_ENCSINK_ENCBIN,
553 _MMCAMCORDER_ENCSINK_AQUE,
554 _MMCAMCORDER_ENCSINK_CONV,
555 _MMCAMCORDER_ENCSINK_AENC,
556 _MMCAMCORDER_ENCSINK_AENC_QUE,
557 _MMCAMCORDER_ENCSINK_VQUE,
558 _MMCAMCORDER_ENCSINK_VCONV,
559 _MMCAMCORDER_ENCSINK_VENC,
560 _MMCAMCORDER_ENCSINK_VENC_QUE,
561 _MMCAMCORDER_ENCSINK_ITOG,
562 _MMCAMCORDER_ENCSINK_ICROP,
563 _MMCAMCORDER_ENCSINK_ISCALE,
564 _MMCAMCORDER_ENCSINK_IFILT,
565 _MMCAMCORDER_ENCSINK_IQUE,
566 _MMCAMCORDER_ENCSINK_IENC,
567 _MMCAMCORDER_ENCSINK_MUX,
568 _MMCAMCORDER_ENCSINK_SINK,
570 _MMCAMCORDER_ENCODE_PIPELINE_ELEMENT_NUM,
571 } _MMCAMCORDER_ENCODE_PIPELINE_ELELMENT;
574 _MMCAMCORDER_TASK_THREAD_STATE_NONE,
575 _MMCAMCORDER_TASK_THREAD_STATE_SOUND_PLAY_START,
576 _MMCAMCORDER_TASK_THREAD_STATE_SOUND_SOLO_PLAY_START,
577 _MMCAMCORDER_TASK_THREAD_STATE_ENCODE_PIPE_CREATE,
578 _MMCAMCORDER_TASK_THREAD_STATE_CHECK_CAPTURE_IN_RECORDING,
579 _MMCAMCORDER_TASK_THREAD_STATE_EXIT,
580 } _MMCamcorderTaskThreadState;
583 * System state change cause
586 _MMCAMCORDER_STATE_CHANGE_NORMAL = 0,
587 _MMCAMCORDER_STATE_CHANGE_BY_FOCUS,
588 _MMCAMCORDER_STATE_CHANGE_BY_RM,
589 _MMCAMCORDER_STATE_CHANGE_BY_DPM
590 } _MMCamcorderStateChange;
593 /*=======================================================================================
594 | STRUCTURE DEFINITIONS |
595 ========================================================================================*/
597 * MMCamcorder Gstreamer Element
600 unsigned int id; /**< Gstreamer piplinem element name */
601 GstElement *gst; /**< Gstreamer element */
602 } _MMCamcorderGstElement;
605 * MMCamcorder information for KPI measurement
608 int current_fps; /**< current fps of this second */
609 int average_fps; /**< average fps */
610 unsigned int video_framecount; /**< total number of video frame */
611 unsigned int last_framecount; /**< total number of video frame in last measurement */
612 struct timeval init_video_time; /**< time when start to measure */
613 struct timeval last_video_time; /**< last measurement time */
614 } _MMCamcorderKPIMeasure;
617 * MMCamcorder information for Multi-Thread Safe
620 GMutex lock; /**< Mutex (for general use) */
621 GCond cond; /**< Condition (for general use) */
622 GMutex cmd_lock; /**< Mutex (for command) */
623 GCond cmd_cond; /**< Condition (for command) */
624 GMutex asm_lock; /**< Mutex (for ASM) */
625 GMutex state_lock; /**< Mutex (for state change) */
626 GMutex gst_state_lock; /**< Mutex (for gst pipeline state change) */
627 GMutex gst_encode_state_lock; /**< Mutex (for gst encode pipeline state change) */
628 GMutex message_cb_lock; /**< Mutex (for message callback) */
629 GMutex vcapture_cb_lock; /**< Mutex (for video capture callback) */
630 GMutex vstream_cb_lock; /**< Mutex (for video stream callback) */
631 GMutex astream_cb_lock; /**< Mutex (for audio stream callback) */
632 #ifdef _MMCAMCORDER_MURPHY_SUPPORT
633 GCond resource_cond; /**< Condition (for resource check) */
634 GMutex resource_lock; /**< Mutex (for resource check) */
635 #endif /* _MMCAMCORDER_MURPHY_SUPPORT */
636 } _MMCamcorderMTSafe;
639 * MMCamcorder Sub Context
642 bool isMaxsizePausing; /**< Because of size limit, pipeline is paused. */
643 bool isMaxtimePausing; /**< Because of time limit, pipeline is paused. */
644 int element_num; /**< count of element */
645 int encode_element_num; /**< count of encode element */
646 int cam_stability_count; /**< camsensor stability count. the count of frame will drop */
647 GstClockTime pipeline_time; /**< current time of Gstreamer Pipeline */
648 GstClockTime pause_time; /**< amount of time while pipeline is in PAUSE state.*/
649 GstClockTime stillshot_time; /**< pipeline time of capturing moment*/
650 gboolean is_modified_rate; /**< whether recording motion rate is modified or not */
651 gboolean ferror_send; /**< file write/seek error **/
652 guint ferror_count; /**< file write/seek error count **/
653 GstClockTime previous_slot_time;
654 int display_interval; /**< This value is set as 'GST_SECOND / display FPS' */
655 gboolean bget_eos; /**< Whether getting EOS */
656 gboolean bencbin_capture; /**< Use Encodebin for capturing */
657 gboolean audio_disable; /**< whether audio is disabled or not when record */
658 int videosrc_rotate; /**< rotate of videosrc */
660 /* For dropping video frame when start recording */
661 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. */
662 int pass_first_vframe; /**< When this value is bigger than zero, MSL won't drop video frame though "drop_vframe" is bigger then zero. */
664 /* INI information */
665 unsigned int fourcc; /**< Get fourcc value of camera INI file */
666 _MMCamcorderImageInfo *info_image; /**< extra information for image capture */
667 _MMCamcorderVideoInfo *info_video; /**< extra information for video recording */
668 _MMCamcorderAudioInfo *info_audio; /**< extra information for audio recording */
670 _MMCamcorderGstElement *element; /**< array of preview element */
671 _MMCamcorderGstElement *encode_element; /**< array of encode element */
672 _MMCamcorderKPIMeasure kpi; /**< information related with performance measurement */
674 type_element *VideosinkElement; /**< configure data of videosink element */
675 type_element *VideoconvertElement; /**< configure data of videoconvert element */
676 type_element *VideodecoderElementH264; /**< configure data of video decoder element for H.264 format */
677 gboolean SensorEncodedCapture; /**< whether camera sensor support encoded image capture */
678 gboolean internal_encode; /**< whether use internal encoding function */
679 } _MMCamcorderSubContext;
682 * _MMCamcorderContext
684 typedef struct mmf_camcorder {
686 int type; /**< mmcamcorder_mode_type */
687 int device_type; /**< device type */
688 int state; /**< state of camcorder */
689 int target_state; /**< Target state that want to set. This is a flag that
690 * stands for async state changing. If this value differ from state,
691 * it means state is changing now asychronously. */
694 MMHandleType attributes; /**< Attribute handle */
695 _MMCamcorderSubContext *sub_context; /**< sub context */
696 mm_exif_info_t *exif_info; /**< EXIF */
697 GList *buffer_probes; /**< a list of buffer probe handle */
698 GList *event_probes; /**< a list of event probe handle */
699 GList *signals; /**< a list of signal handle */
700 #ifdef _MMCAMCORDER_ENABLE_IDLE_MESSAGE_CALLBACK
701 GList *msg_data; /**< a list of msg data */
702 #endif /* _MMCAMCORDER_ENABLE_IDLE_MESSAGE_CALLBACK */
703 camera_conf *conf_main; /**< Camera configure Main structure */
704 camera_conf *conf_ctrl; /**< Camera configure Control structure */
705 #ifdef _MMCAMCORDER_RM_SUPPORT
706 int rm_handle; /**< Resource manager handle */
707 #endif /* _MMCAMCORDER_RM_SUPPORT */
708 guint pipeline_cb_event_id; /**< Event source ID of pipeline message callback */
709 guint encode_pipeline_cb_event_id; /**< Event source ID of encode pipeline message callback */
710 guint setting_event_id; /**< Event source ID of attributes setting to sensor */
711 SOUND_INFO snd_info; /**< Sound handle for multishot capture */
713 /* callback handlers */
714 MMMessageCallback msg_cb; /**< message callback */
715 void *msg_cb_param; /**< message callback parameter */
716 mm_camcorder_video_stream_callback vstream_cb; /**< Video stream callback */
717 void *vstream_cb_param; /**< Video stream callback parameter */
718 mm_camcorder_audio_stream_callback astream_cb; /**< Audio stream callback */
719 void *astream_cb_param; /**< Audio stream callback parameter */
720 mm_camcorder_video_capture_callback vcapture_cb; /**< Video capture callback */
721 void *vcapture_cb_param; /**< Video capture callback parameter */
722 int (*command)(MMHandleType, int); /**< camcorder's command */
725 mm_cam_attr_construct_info *cam_attrs_const_info; /**< attribute info */
726 conf_info_table *conf_main_info_table[CONFIGURE_CATEGORY_MAIN_NUM]; /** configure info table - MAIN category */
727 conf_info_table *conf_ctrl_info_table[CONFIGURE_CATEGORY_CTRL_NUM]; /** configure info table - CONTROL category */
728 int conf_main_category_size[CONFIGURE_CATEGORY_MAIN_NUM]; /** configure info table size - MAIN category */
729 int conf_ctrl_category_size[CONFIGURE_CATEGORY_CTRL_NUM]; /** configure info table size - CONTROL category */
730 _MMCamcorderMTSafe mtsafe; /**< Thread safe */
731 int state_change_by_system; /**< MSL changes its state by itself because of system */
732 GMutex restart_preview_lock; /**< Capture sound mutex */
733 int use_zero_copy_format; /**< Whether use zero copy format for camera input */
734 int use_videoconvert; /**< Whether use videoconvert element for display */
735 int support_media_packet_preview_cb; /**< Whether support zero copy format for camera input */
736 int shutter_sound_policy; /**< shutter sound policy */
737 int brightness_default; /**< default value of brightness */
738 int brightness_step_denominator; /**< denominator of brightness bias step */
739 int support_zsl_capture; /**< support Zero Shutter Lag capture */
740 char *model_name; /**< model name from system info */
741 char *software_version; /**< software_version from system info */
742 int capture_sound_count; /**< count for capture sound */
743 char *root_directory; /**< Root directory for device */
744 int resolution_changed; /**< Flag for preview resolution change */
745 int sound_focus_register; /**< Use sound focus internally */
746 int sound_focus_id; /**< id for sound focus */
747 int sound_focus_watch_id; /**< id for sound focus watch */
748 unsigned int sound_focus_subscribe_id; /**< subscribe id for sound focus signal */
749 int interrupt_code; /**< Interrupt code */
750 int acquired_focus; /**< Current acquired focus */
751 int session_type; /**< Session type */
752 int session_flags; /**< Session flags */
753 int recreate_decoder; /**< Flag of decoder element recreation for encoded preview format */
755 _MMCamcorderInfoConverting caminfo_convert[CAMINFO_CONVERT_NUM]; /**< converting structure of camera info */
756 _MMCamcorderEnumConvert enum_conv[ENUM_CONVERT_NUM]; /**< enum converting list that is modified by ini info */
758 gboolean capture_in_recording; /**< Flag for capture while recording */
760 gboolean error_occurs; /**< flag for error */
761 int error_code; /**< error code for internal gstreamer error */
764 GThread *task_thread; /**< thread for task */
765 GMutex task_thread_lock; /**< mutex for task thread */
766 GCond task_thread_cond; /**< cond for task thread */
767 _MMCamcorderTaskThreadState task_thread_state; /**< state of task thread */
769 #ifdef _MMCAMCORDER_MURPHY_SUPPORT
770 /* resource manager for H/W resources */
771 MMCamcorderResourceManager resource_manager;
772 #endif /* _MMCAMCORDER_MURPHY_SUPPORT */
775 GDBusConnection *gdbus_conn; /**< gdbus connection */
776 _MMCamcorderGDbusCbInfo gdbus_info_sound; /**< Informations for the gbus cb of sound play */
777 _MMCamcorderGDbusCbInfo gdbus_info_solo_sound; /**< Informations for the gbus cb of solo sound play */
779 /* DPM(device policy manager) */
780 device_policy_manager_h dpm_handle; /**< DPM handle */
781 int dpm_camera_cb_id; /**< DPM camera policy changed callback id */
784 _MMCamcorderStorageInfo storage_info; /**< Storage information */
786 #ifdef _MMCAMCORDER_RM_SUPPORT
787 rm_category_request_s request_resources;
788 rm_device_return_s returned_devices;
789 #endif /* _MMCAMCORDER_RM_SUPPORT */
790 int reserved[4]; /**< reserved */
793 /*=======================================================================================
794 | EXTERN GLOBAL VARIABLE |
795 ========================================================================================*/
797 /*=======================================================================================
798 | GLOBAL FUNCTION PROTOTYPES |
799 ========================================================================================*/
801 * This function creates camcorder for capturing still image and recording.
803 * @param[out] handle Specifies the camcorder handle
804 * @param[in] info Preset information of camcorder
805 * @return This function returns zero on success, or negative value with error code.
806 * @remarks When this function calls successfully, camcorder handle will be filled with a @n
807 * valid value and the state of the camcorder will become MM_CAMCORDER_STATE_NULL.@n
808 * Note that it's not ready to working camcorder. @n
809 * You should call mmcamcorder_realize before starting camcorder.
810 * @see _mmcamcorder_create
812 int _mmcamcorder_create(MMHandleType *handle, MMCamPreset *info);
815 * This function destroys instance of camcorder.
817 * @param[in] hcamcorder Specifies the camcorder handle
818 * @return This function returns zero on success, or negative value with error code.
819 * @see _mmcamcorder_create
821 int _mmcamcorder_destroy(MMHandleType hcamcorder);
824 * This function allocates memory for camcorder.
826 * @param[in] hcamcorder Specifies the camcorder handle
827 * @return This function returns zero on success, or negative value with error code.
828 * @remarks This function can be called successfully when current state is MM_CAMCORDER_STATE_NULL @n
829 * and the state of the camcorder will become MM_CAMCORDER_STATE_READY. @n
830 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
831 * @see _mmcamcorder_unrealize
832 * @pre MM_CAMCORDER_STATE_NULL
833 * @post MM_CAMCORDER_STATE_READY
835 int _mmcamcorder_realize(MMHandleType hcamcorder);
838 * This function free allocated memory for camcorder.
840 * @param[in] hcamcorder Specifies the camcorder handle
841 * @return This function returns zero on success, or negative value with error code.
842 * @remarks This function release all resources which are allocated for the camcorder engine.@n
843 * This function can be called successfully when current state is MM_CAMCORDER_STATE_READY and @n
844 * the state of the camcorder will become MM_CAMCORDER_STATE_NULL. @n
845 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
846 * @see _mmcamcorder_realize
847 * @pre MM_CAMCORDER_STATE_READY
848 * @post MM_CAMCORDER_STATE_NULL
850 int _mmcamcorder_unrealize(MMHandleType hcamcorder);
853 * This function is to start previewing.
855 * @param[in] hcamcorder Specifies the camcorder handle
856 * @return This function returns zero on success, or negative value with error code.
857 * @remarks This function can be called successfully when current state is MM_CAMCORDER_STATE_READY and @n
858 * the state of the camcorder will become MM_CAMCORDER_STATE_PREPARE. @n
859 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
860 * @see _mmcamcorder_stop
862 int _mmcamcorder_start(MMHandleType hcamcorder);
865 * This function is to stop previewing.
867 * @param[in] hcamcorder Specifies the camcorder handle
868 * @return This function returns zero on success, or negative value with error code.
869 * @remarks This function can be called successfully when current state is MM_CAMCORDER_STATE_PREPARE and @n
870 * the state of the camcorder will become MM_CAMCORDER_STATE_READY.@n
871 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
872 * @see _mmcamcorder_start
874 int _mmcamcorder_stop(MMHandleType hcamcorder);
877 * This function to start capturing of still images.
879 * @param[in] hcamcorder Specifies the camcorder handle.
880 * @return This function returns zero on success, or negative value with error code.
881 * @remarks This function can be called successfully when current state is MM_CAMCORDER_STATE_PREPARE and @n
882 * the state of the camcorder will become MM_CAMCORDER_STATE_CAPTURING. @n
883 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
884 * @see _mmcamcorder_capture_stop
886 int _mmcamcorder_capture_start(MMHandleType hcamcorder);
889 * This function is to stop capturing still images.
891 * @param[in] hcamcorder Specifies the camcorder handle
892 * @return This function returns zero on success, or negative value with error code.
893 * @remarks This function can be called successfully when current state is MM_CAMCORDER_STATE_CAPTURING and @n
894 * the state of the camcorder will become MM_CAMCORDER_STATE_PREPARE. @n
895 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
896 * @see _mmcamcorder_capture_start
898 int _mmcamcorder_capture_stop(MMHandleType hcamcorder);
901 * This function is to start video and audio recording.
903 * @param[in] hcamcorder Specifies the camcorder handle
904 * @return This function returns zero on success, or negative value with error code.
905 * @remarks This function can be called successfully when current state is @n
906 * MM_CAMCORDER_STATE_PREPARE or MM_CAMCORDER_STATE_PAUSED and @n
907 * the state of the camcorder will become MM_CAMCORDER_STATE_RECORDING.@n
908 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
909 * @see _mmcamcorder_pause
911 int _mmcamcorder_record(MMHandleType hcamcorder);
914 * This function is to pause video and audio recording
916 * @param[in] hcamcorder Specifies the camcorder handle
917 * @return This function returns zero on success, or negative value with error code.
918 * @remarks This function can be called successfully when current state is MM_CAMCORDER_STATE_RECORDING and @n
919 * the state of the camcorder will become MM_CAMCORDER_STATE_PAUSED.@n
920 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.@n
921 * @see _mmcamcorder_record
923 int _mmcamcorder_pause(MMHandleType hcamcorder);
926 * This function is to stop video and audio recording and save results.
928 * @param[in] hcamcorder Specifies the camcorder handle
929 * @return This function returns zero on success, or negative value with error code.
930 * @remarks This function can be called successfully when current state is @n
931 * MM_CAMCORDER_STATE_PAUSED or MM_CAMCORDER_STATE_RECORDING and @n
932 * the state of the camcorder will become MM_CAMCORDER_STATE_PREPARE. @n
933 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION
934 * @see _mmcamcorder_cancel
936 int _mmcamcorder_commit(MMHandleType hcamcorder);
939 * This function is to stop video and audio recording and do not save results.
941 * @param[in] hcamcorder Specifies the camcorder handle
942 * @return This function returns zero on success, or negative value with error code.
943 * @remarks This function can be called successfully when current state is @n
944 * MM_CAMCORDER_STATE_PAUSED or MM_CAMCORDER_STATE_RECORDING and @n
945 * the state of the camcorder will become MM_CAMCORDER_STATE_PREPARE. @n
946 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
947 * @see _mmcamcorder_commit
949 int _mmcamcorder_cancel(MMHandleType hcamcorder);
952 * This function calls after commiting action finished asynchronously.
953 * In this function, remaining process , such as state change, happens.
955 * @param[in] hcamcorder Specifies the camcorder handle
956 * @return This function returns zero on success, or negative value with error code.
957 * @remarks This function can be called successfully when current state is @n
958 * MM_CAMCORDER_STATE_PAUSED or MM_CAMCORDER_STATE_RECORDING and @n
959 * the state of the camcorder will become MM_CAMCORDER_STATE_PREPARE. @n
960 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
961 * @see _mmcamcorder_commit
963 int _mmcamcorder_commit_async_end(MMHandleType hcamcorder);
966 * This function is to set callback for receiving messages from camcorder.
968 * @param[in] hcamcorder Specifies the camcorder handle
969 * @param[in] callback Specifies the function pointer of callback function
970 * @param[in] user_data Specifies the user poiner for passing to callback function
972 * @return This function returns zero on success, or negative value with error code.
973 * @remarks typedef bool (*mm_message_callback) (int msg, mm_messageType *param, void *user_param);@n
988 * } mm_message_type; @n
990 * If a message value for mm_message_callback is MM_MESSAGE_STATE_CHANGED, @n
991 * state value in mm_message_type will be a mmcamcorder_state_type enum value;@n
993 * If a message value for mm_message_callback is MM_MESSAGE_ERROR, @n
994 * the code value in mm_message_type will be a mmplayer_error_type enum value;
996 * @see mm_message_type, mmcamcorder_state_type, mmcamcorder_error_type
998 int _mmcamcorder_set_message_callback(MMHandleType hcamcorder,
999 MMMessageCallback callback,
1003 * This function is to set callback for video stream.
1005 * @param[in] hcamcorder Specifies the camcorder handle
1006 * @param[in] callback Specifies the function pointer of callback function
1007 * @param[in] user_data Specifies the user poiner for passing to callback function
1009 * @return This function returns zero on success, or negative value with error code.
1010 * @see mmcamcorder_error_type
1012 int _mmcamcorder_set_video_stream_callback(MMHandleType hcamcorder,
1013 mm_camcorder_video_stream_callback callback,
1017 * This function is to set callback for audio stream.
1019 * @param[in] hcamcorder Specifies the camcorder handle
1020 * @param[in] callback Specifies the function pointer of callback function
1021 * @param[in] user_data Specifies the user poiner for passing to callback function
1023 * @return This function returns zero on success, or negative value with error code.
1024 * @see mmcamcorder_error_type
1026 int _mmcamcorder_set_audio_stream_callback(MMHandleType handle,
1027 mm_camcorder_audio_stream_callback callback,
1031 * This function is to set callback for video capture.
1033 * @param[in] hcamcorder Specifies the camcorder handle
1034 * @param[in] callback Specifies the function pointer of callback function
1035 * @param[in] user_data Specifies the user poiner for passing to callback function
1037 * @return This function returns zero on success, or negative value with error code.
1038 * @see mmcamcorder_error_type
1040 int _mmcamcorder_set_video_capture_callback(MMHandleType hcamcorder,
1041 mm_camcorder_video_capture_callback callback,
1045 * This function returns current state of camcorder, or negative value with error code.
1047 * @param[in] hcamcorder Specifies the camcorder handle.
1048 * @return This function returns current state of camcorder, or negative value with error code.
1049 * @see mmcamcorder_state_type
1051 int _mmcamcorder_get_current_state(MMHandleType hcamcorder);
1053 int _mmcamcorder_init_focusing(MMHandleType handle);
1054 int _mmcamcorder_adjust_focus(MMHandleType handle, int direction);
1055 int _mmcamcorder_adjust_manual_focus(MMHandleType handle, int direction);
1056 int _mmcamcorder_adjust_auto_focus(MMHandleType handle);
1057 int _mmcamcorder_stop_focusing(MMHandleType handle);
1060 * This function gets current state of camcorder.
1063 * @return This function returns state of current camcorder context
1065 * @see _mmcamcorder_set_state()
1068 int _mmcamcorder_streamer_init(void);
1071 * This function gets current state of camcorder.
1074 * @return This function returns state of current camcorder context
1076 * @see _mmcamcorder_set_state()
1079 int _mmcamcorder_display_init(void);
1082 * This function gets current state of camcorder.
1084 * @param[in] handle Handle of camcorder context.
1085 * @return This function returns state of current camcorder context
1087 * @see _mmcamcorder_set_state()
1090 int _mmcamcorder_get_state(MMHandleType handle);
1093 * This function sets new state of camcorder.
1095 * @param[in] handle Handle of camcorder context.
1096 * @param[in] state setting state value of camcorder.
1099 * @see _mmcamcorder_get_state()
1102 void _mmcamcorder_set_state(MMHandleType handle, int state);
1105 * This function gets asynchronous status of MSL Camcroder.
1107 * @param[in] handle Handle of camcorder context.
1108 * @param[in] target_state setting target_state value of camcorder.
1109 * @return This function returns asynchrnous state.
1111 * @see _mmcamcorder_set_async_state()
1114 int _mmcamcorder_get_async_state(MMHandleType handle);
1117 * This function allocates structure of subsidiary attributes.
1119 * @param[in] type Allocation type of camcorder context.
1120 * @return This function returns structure pointer on success, NULL value on failure.
1122 * @see _mmcamcorder_dealloc_subcontext()
1125 _MMCamcorderSubContext *_mmcamcorder_alloc_subcontext(int type);
1128 * This function releases structure of subsidiary attributes.
1130 * @param[in] sc Handle of camcorder subcontext.
1133 * @see _mmcamcorder_alloc_subcontext()
1136 void _mmcamcorder_dealloc_subcontext(_MMCamcorderSubContext *sc);
1139 * This function sets command function according to the type.
1141 * @param[in] handle Handle of camcorder context.
1142 * @param[in] type Allocation type of camcorder context.
1143 * @return This function returns MM_ERROR_NONE on success, or other values with error code.
1145 * @see __mmcamcorder_video_command(), __mmcamcorder_audio_command(), __mmcamcorder_image_command()
1148 int _mmcamcorder_set_functions(MMHandleType handle, int type);
1151 * This function is callback function of main pipeline.
1152 * Once this function is registered with certain pipeline using gst_bus_add_watch(),
1153 * this callback will be called every time when there is upcomming message from pipeline.
1154 * Basically, this function is used as error handling function, now.
1156 * @param[in] bus pointer of buf that called this function.
1157 * @param[in] message callback message from pipeline.
1158 * @param[in] data user data.
1159 * @return This function returns true on success, or false value with error
1161 * @see __mmcamcorder_create_preview_pipeline()
1164 gboolean _mmcamcorder_pipeline_cb_message(GstBus *bus, GstMessage *message, gpointer data);
1167 * This function is callback function of main pipeline.
1168 * Once this function is registered with certain pipeline using gst_bus_set_sync_handler(),
1169 * this callback will be called every time when there is upcomming message from pipeline.
1170 * Basically, this function is used as sync error handling function, now.
1172 * @param[in] bus pointer of buf that called this function.
1173 * @param[in] message callback message from pipeline.
1174 * @param[in] data user data.
1175 * @return This function returns true on success, or false value with error
1177 * @see __mmcamcorder_create_preview_pipeline()
1180 GstBusSyncReply _mmcamcorder_pipeline_bus_sync_callback(GstBus *bus, GstMessage *message, gpointer data);
1183 * This function is callback function of encode pipeline.
1184 * Once this function is registered with certain pipeline using gst_bus_set_sync_handler(),
1185 * this callback will be called every time when there is upcomming message from pipeline.
1186 * Basically, this function is used for EOS and error handling now.
1188 * @param[in] bus pointer of buf that called this function.
1189 * @param[in] message callback message from pipeline.
1190 * @param[in] data user data.
1191 * @return This function returns true on success, or false value with error
1193 * @see __mmcamcorder_create_recorder_pipeline()
1194 * @see __mmcamcorder_create_audiop_with_encodebin()
1197 GstBusSyncReply _mmcamcorder_encode_pipeline_bus_sync_callback(GstBus *bus, GstMessage *message, gpointer data);
1200 * This function create main pipeline according to type.
1202 * @param[in] handle Handle of camcorder context.
1203 * @param[in] type Allocation type of camcorder context.
1204 * @return This function returns zero on success, or negative value with error code.
1206 * @see _mmcamcorder_destroy_pipeline()
1209 int _mmcamcorder_create_pipeline(MMHandleType handle, int type);
1212 * This function release all element of main pipeline according to type.
1214 * @param[in] handle Handle of camcorder context.
1215 * @param[in] type Allocation type of camcorder context.
1218 * @see _mmcamcorder_create_pipeline()
1221 void _mmcamcorder_destroy_pipeline(MMHandleType handle, int type);
1224 * This function sets gstreamer element status.
1225 * If the gstreamer fails to set status or returns asynchronous mode,
1226 * this function waits for state changed until timeout expired.
1228 * @param[in] pipeline Pointer of pipeline
1229 * @param[in] target_state newly setting status
1230 * @return This function returns zero on success, or negative value with error code.
1235 int _mmcamcorder_gst_set_state(MMHandleType handle, GstElement *pipeline, GstState target_state);
1238 * This function sets gstreamer element status, asynchronously.
1239 * Regardless of processing, it returns immediately.
1241 * @param[in] pipeline Pointer of pipeline
1242 * @param[in] target_state newly setting status
1243 * @return This function returns zero on success, or negative value with error code.
1248 int _mmcamcorder_gst_set_state_async(MMHandleType handle, GstElement *pipeline, GstState target_state);
1250 /* For xvimagesink */
1251 GstBusSyncReply __mmcamcorder_sync_callback(GstBus *bus, GstMessage *message, gulong data);
1253 /* For querying capabilities */
1254 int _mmcamcorder_read_vidsrc_info(int videodevidx, camera_conf **configure_info);
1256 /* for performance check */
1257 void _mmcamcorder_video_current_framerate_init(MMHandleType handle);
1258 int _mmcamcorder_video_current_framerate(MMHandleType handle);
1259 int _mmcamcorder_video_average_framerate(MMHandleType handle);
1261 /* sound focus related function */
1262 void __mmcamcorder_force_stop(mmf_camcorder_t *hcamcorder);
1263 void _mmcamcorder_sound_focus_cb(int id, mm_sound_focus_type_e focus_type,
1264 mm_sound_focus_state_e focus_state, const char *reason_for_change,
1265 int option, const char *additional_info, void *user_data);
1266 void _mmcamcorder_sound_focus_watch_cb(int id, mm_sound_focus_type_e focus_type, mm_sound_focus_state_e focus_state,
1267 const char *reason_for_change, const char *additional_info, void *user_data);
1268 void _mmcamcorder_sound_signal_callback(mm_sound_signal_name_t signal, int value, void *user_data);
1270 /* device policy manager */
1271 void _mmcamcorder_dpm_camera_policy_changed_cb(const char *name, const char *value, void *user_data);
1273 /* For hand over the server's caps information to client */
1274 int _mmcamcorder_get_video_caps(MMHandleType handle, char **caps);
1280 #endif /* __MM_CAMCORDER_INTERNAL_H__ */