4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jeongmo Yang <jm80.yang@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 #ifndef __MM_CAMCORDER_INTERNAL_H__
23 #define __MM_CAMCORDER_INTERNAL_H__
25 /*=======================================================================================
27 ========================================================================================*/
31 #include <semaphore.h>
35 #include <mm_attrs_private.h>
36 #include <mm_message.h>
37 #include <mm_sound_focus.h>
39 #include <gst/video/video-format.h>
42 #include <restriction.h> /* device policy manager */
44 #include "mm_camcorder.h"
47 #ifdef _MMCAMCORDER_MURPHY_SUPPORT
48 #include "mm_camcorder_resource.h"
49 #endif /* _MMCAMCORDER_MURPHY_SUPPORT */
51 /* camcorder sub module */
52 #include "mm_camcorder_attribute.h"
53 #include "mm_camcorder_platform.h"
54 #include "mm_camcorder_stillshot.h"
55 #include "mm_camcorder_videorec.h"
56 #include "mm_camcorder_audiorec.h"
57 #include "mm_camcorder_gstcommon.h"
58 #include "mm_camcorder_exifinfo.h"
59 #include "mm_camcorder_util.h"
60 #include "mm_camcorder_configure.h"
61 #include "mm_camcorder_sound.h"
63 #ifdef _MMCAMCORDER_RM_SUPPORT
64 /* rm (resource manager)*/
66 #endif /* _MMCAMCORDER_RM_SUPPORT */
72 /*=======================================================================================
74 ========================================================================================*/
75 #define _mmcam_dbg_verb(fmt, args...) debug_verbose(" "fmt"\n", ##args);
76 #define _mmcam_dbg_log(fmt, args...) debug_log(" "fmt"\n", ##args);
77 #define _mmcam_dbg_warn(fmt, args...) debug_warning(" "fmt"\n", ##args);
78 #define _mmcam_dbg_err(fmt, args...) debug_error(" "fmt"\n", ##args);
79 #define _mmcam_dbg_crit(fmt, args...) debug_critical(" "fmt"\n", ##args);
82 * Macro for checking validity and debugging
84 #define mmf_return_if_fail(expr) \
86 _mmcam_dbg_err("failed [%s]", #expr); \
91 * Macro for checking validity and debugging
93 #define mmf_return_val_if_fail(expr, val) \
95 _mmcam_dbg_err("failed [%s]", #expr); \
102 * Macro for getting array size
104 #define ARRAY_SIZE(a) (sizeof((a)) / sizeof((a)[0]))
107 /* gstreamer element creation macro */
108 #define _MMCAMCORDER_PIPELINE_MAKE(sub_context, element, eid, name /*char* */, err) \
109 if (element[eid].gst != NULL) { \
110 _mmcam_dbg_err("The element(Pipeline) is existed. element_id=[%d], name=[%s]", eid, name); \
111 gst_object_unref(element[eid].gst); \
113 element[eid].id = eid; \
114 element[eid].gst = gst_pipeline_new(name); \
115 if (element[eid].gst == NULL) { \
116 _mmcam_dbg_err("Pipeline creation fail. element_id=[%d], name=[%s]", eid, name); \
117 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
118 goto pipeline_creation_error; \
120 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
123 #define _MMCAMCORDER_BIN_MAKE(sub_context, element, eid, name /*char* */, err) \
124 if (element[eid].gst != NULL) { \
125 _mmcam_dbg_err("The element(Bin) is existed. element_id=[%d], name=[%s]", eid, name); \
126 gst_object_unref(element[eid].gst); \
128 element[eid].id = eid; \
129 element[eid].gst = gst_bin_new(name); \
130 if (element[eid].gst == NULL) { \
131 _mmcam_dbg_err("Bin creation fail. element_id=[%d], name=[%s]\n", eid, name); \
132 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
133 goto pipeline_creation_error; \
135 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
138 #define _MMCAMCORDER_ELEMENT_MAKE(sub_context, element, eid, name /*char* */, nickname /*char* */, elist, err) \
139 if (element[eid].gst != NULL) { \
140 _mmcam_dbg_err("The element is existed. element_id=[%d], name=[%s]", eid, name); \
141 gst_object_unref(element[eid].gst); \
143 traceBegin(TTRACE_TAG_CAMERA, "MMCAMCORDER:ELEMENT_MAKE:%s", name); \
144 element[eid].gst = gst_element_factory_make(name, nickname); \
145 traceEnd(TTRACE_TAG_CAMERA); \
146 if (element[eid].gst == NULL) { \
147 _mmcam_dbg_err("Element creation fail. element_id=[%d], name=[%s]", eid, name); \
148 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
149 goto pipeline_creation_error; \
151 _mmcam_dbg_log("Element creation done. element_id=[%d], name=[%s]", eid, name); \
152 element[eid].id = eid; \
153 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
154 err = MM_ERROR_NONE; \
156 elist = g_list_append(elist, &(element[eid]));
158 #define _MMCAMCORDER_ELEMENT_MAKE2(sub_context, element, eid, name /*char* */, nickname /*char* */, err) \
159 if (element[eid].gst != NULL) { \
160 _mmcam_dbg_err("The element is existed. element_id=[%d], name=[%s]", eid, name); \
161 gst_object_unref(element[eid].gst); \
163 element[eid].gst = gst_element_factory_make(name, nickname); \
164 if (element[eid].gst == NULL) { \
165 _mmcam_dbg_err("Element creation fail. element_id=[%d], name=[%s]", eid, name); \
166 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
168 _mmcam_dbg_log("Element creation done. element_id=[%d], name=[%s]", eid, name); \
169 element[eid].id = eid; \
170 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
171 err = MM_ERROR_NONE; \
174 #define _MMCAMCORDER_ELEMENT_MAKE_IGNORE_ERROR(sub_context, element, eid, name /*char* */, nickname /*char* */, elist) \
175 if (element[eid].gst != NULL) { \
176 _mmcam_dbg_err("The element is existed. element_id=[%d], name=[%s]", eid, name); \
177 gst_object_unref(element[eid].gst); \
179 element[eid].gst = gst_element_factory_make(name, nickname); \
180 if (element[eid].gst == NULL) { \
181 _mmcam_dbg_err("Element creation fail. element_id=[%d], name=[%s], but keep going...", eid, name); \
183 _mmcam_dbg_log("Element creation done. element_id=[%d], name=[%s]", eid, name); \
184 element[eid].id = eid; \
185 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
186 elist = g_list_append(elist, &(element[eid])); \
189 #define _MMCAMCORDER_ELEMENT_ADD(sub_context, element, eid, gst_element, elist, err) \
190 if (element[eid].gst != NULL) { \
191 _mmcam_dbg_err("The element is existed. element_id=[%d]", eid); \
192 gst_object_unref(element[eid].gst); \
194 element[eid].gst = gst_element; \
195 if (element[eid].gst == NULL) { \
196 _mmcam_dbg_err("Element is NULL. element_id=[%d]", eid); \
197 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
198 goto pipeline_creation_error; \
200 _mmcam_dbg_log("Adding Element is done. element_id=[%d] %p", eid, gst_element); \
201 element[eid].id = eid; \
202 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
203 err = MM_ERROR_NONE; \
205 elist = g_list_append(elist, &(element[eid]));
207 #define _MMCAMCORDER_ENCODEBIN_ELMGET(sub_context, eid, name /*char* */, err) \
208 if (sub_context->encode_element[eid].gst != NULL) { \
209 _mmcam_dbg_err("The element is existed. element_id=[%d], name=[%s]", eid, name); \
210 gst_object_unref(sub_context->encode_element[eid].gst); \
212 sub_context->encode_element[eid].id = eid; \
213 g_object_get(G_OBJECT(sub_context->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst), name, &(sub_context->encode_element[eid].gst), NULL); \
214 if (sub_context->encode_element[eid].gst == NULL) { \
215 _mmcam_dbg_err("Encode Element get fail. element_id=[%d], name=[%s]", eid, name); \
216 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
217 goto pipeline_creation_error; \
219 gst_object_unref(sub_context->encode_element[eid].gst); \
220 g_object_weak_ref(G_OBJECT(sub_context->encode_element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
223 /* GStreamer element remove macro */
224 #define _MMCAMCORDER_ELEMENT_REMOVE(element, eid) \
225 if (element[eid].gst != NULL) { \
226 gst_object_unref(element[eid].gst); \
229 #define _MM_GST_ELEMENT_LINK_MANY gst_element_link_many
230 #define _MM_GST_ELEMENT_LINK gst_element_link
231 #define _MM_GST_ELEMENT_LINK_FILTERED gst_element_link_filtered
232 #define _MM_GST_ELEMENT_UNLINK gst_element_unlink
233 #define _MM_GST_PAD_LINK gst_pad_link
235 #define _MM_GST_PAD_LINK_UNREF(srcpad, sinkpad, err, if_fail_goto) \
237 GstPadLinkReturn ret = GST_PAD_LINK_OK; \
238 if (srcpad == NULL || sinkpad == NULL) { \
239 if (srcpad == NULL) { \
240 _mmcam_dbg_err("srcpad is NULL"); \
242 gst_object_unref(srcpad);\
245 if (sinkpad == NULL) { \
246 _mmcam_dbg_err("sinkpad is NULL"); \
248 gst_object_unref(sinkpad); \
251 err = MM_ERROR_CAMCORDER_GST_LINK; \
254 ret = _MM_GST_PAD_LINK(srcpad, sinkpad); \
255 if (ret != GST_PAD_LINK_OK) { \
256 GstObject *src_parent = gst_pad_get_parent(srcpad); \
257 GstObject *sink_parent = gst_pad_get_parent(sinkpad); \
258 char *src_name = NULL; \
259 char *sink_name = NULL; \
260 g_object_get((GObject *)src_parent, "name", &src_name, NULL); \
261 g_object_get((GObject *)sink_parent, "name", &sink_name, NULL); \
262 _mmcam_dbg_err("src[%s] - sink[%s] link failed", src_name, sink_name); \
263 gst_object_unref(src_parent); src_parent = NULL; \
264 gst_object_unref(sink_parent); sink_parent = NULL; \
266 free(src_name); src_name = NULL; \
269 free(sink_name); sink_name = NULL; \
271 gst_object_unref(srcpad); srcpad = NULL; \
272 gst_object_unref(sinkpad); sinkpad = NULL; \
273 err = MM_ERROR_CAMCORDER_GST_LINK; \
276 gst_object_unref(srcpad); srcpad = NULL; \
277 gst_object_unref(sinkpad); sinkpad = NULL; \
280 #define _MM_GST_PAD_UNLINK_UNREF(srcpad, sinkpad) \
281 if (srcpad && sinkpad) { \
282 gst_pad_unlink(srcpad, sinkpad); \
284 _mmcam_dbg_warn("some pad(srcpad:%p,sinkpad:%p) is NULL", srcpad, sinkpad); \
287 gst_object_unref(srcpad); srcpad = NULL; \
290 gst_object_unref(sinkpad); sinkpad = NULL; \
293 #define _MMCAMCORDER_STATE_SET_COUNT 3 /* checking interval */
294 #define _MMCAMCORDER_STATE_CHECK_TOTALTIME 5000000L /* total wating time for state change */
295 #define _MMCAMCORDER_STATE_CHECK_INTERVAL (50*1000) /* checking interval - 50ms*/
298 * Default videosink type
300 #define _MMCAMCORDER_DEFAULT_VIDEOSINK_TYPE "VideosinkElementOverlay"
303 * Default recording motion rate
305 #define _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE 1.0
308 * Total level count of manual focus */
309 #define _MMFCAMCORDER_FOCUS_TOTAL_LEVEL 8
312 * File name length limit
314 #define _MMCamcorder_FILENAME_LEN (512)
317 * Minimum integer value
319 #define _MMCAMCORDER_MIN_INT (INT_MIN)
322 * Maximum integer value
324 #define _MMCAMCORDER_MAX_INT (INT_MAX)
327 * Minimum double value
329 #define _MMCAMCORDER_MIN_DOUBLE (DBL_MIN)
332 * Maximum integer value
334 #define _MMCAMCORDER_MAX_DOUBLE (DBL_MAX)
337 * Audio timestamp margin (msec)
339 #define _MMCAMCORDER_AUDIO_TIME_MARGIN (300)
342 * Functions related with LOCK and WAIT
344 #define _MMCAMCORDER_CAST_MTSAFE(handle) (((mmf_camcorder_t*)handle)->mtsafe)
345 #define _MMCAMCORDER_LOCK_FUNC(mutex) g_mutex_lock(&mutex)
346 #define _MMCAMCORDER_TRYLOCK_FUNC(mutex) g_mutex_trylock(&mutex)
347 #define _MMCAMCORDER_UNLOCK_FUNC(mutex) g_mutex_unlock(&mutex)
349 #define _MMCAMCORDER_GET_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).lock)
350 #define _MMCAMCORDER_LOCK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_LOCK(handle))
351 #define _MMCAMCORDER_TRYLOCK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_LOCK(handle))
352 #define _MMCAMCORDER_UNLOCK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_LOCK(handle))
354 #define _MMCAMCORDER_GET_COND(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).cond)
355 #define _MMCAMCORDER_WAIT(handle) g_cond_wait(&_MMCAMCORDER_GET_COND(handle), &_MMCAMCORDER_GET_LOCK(handle))
356 #define _MMCAMCORDER_WAIT_UNTIL(handle, end_time) g_cond_wait_until(&_MMCAMCORDER_GET_COND(handle), &_MMCAMCORDER_GET_LOCK(handle), end_time)
357 #define _MMCAMCORDER_SIGNAL(handle) g_cond_signal(&_MMCAMCORDER_GET_COND(handle));
358 #define _MMCAMCORDER_BROADCAST(handle) g_cond_broadcast(&_MMCAMCORDER_GET_COND(handle));
361 #define _MMCAMCORDER_GET_CMD_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).cmd_lock)
362 #define _MMCAMCORDER_GET_CMD_COND(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).cmd_cond)
363 #define _MMCAMCORDER_LOCK_CMD(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_CMD_LOCK(handle))
364 #define _MMCAMCORDER_TRYLOCK_CMD(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_CMD_LOCK(handle))
365 #define _MMCAMCORDER_UNLOCK_CMD(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_CMD_LOCK(handle))
366 #define _MMCAMCORDER_CMD_WAIT(handle) g_cond_wait(&_MMCAMCORDER_GET_CMD_COND(handle), &_MMCAMCORDER_GET_CMD_LOCK(handle))
367 #define _MMCAMCORDER_CMD_WAIT_UNTIL(handle, end_time) g_cond_wait_until(&_MMCAMCORDER_GET_CMD_COND(handle), &_MMCAMCORDER_GET_CMD_LOCK(handle), end_time)
368 #define _MMCAMCORDER_CMD_SIGNAL(handle) g_cond_signal(&_MMCAMCORDER_GET_CMD_COND(handle));
371 #define _MMCAMCORDER_GET_ASM_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).asm_lock)
372 #define _MMCAMCORDER_LOCK_ASM(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_ASM_LOCK(handle))
373 #define _MMCAMCORDER_TRYLOCK_ASM(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_ASM_LOCK(handle))
374 #define _MMCAMCORDER_UNLOCK_ASM(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_ASM_LOCK(handle))
376 /* for state change */
377 #define _MMCAMCORDER_GET_STATE_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).state_lock)
378 #define _MMCAMCORDER_LOCK_STATE(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_STATE_LOCK(handle))
379 #define _MMCAMCORDER_TRYLOCK_STATE(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_STATE_LOCK(handle))
380 #define _MMCAMCORDER_UNLOCK_STATE(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_STATE_LOCK(handle))
382 /* for gstreamer state change */
383 #define _MMCAMCORDER_GET_GST_STATE_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).gst_state_lock)
384 #define _MMCAMCORDER_LOCK_GST_STATE(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_GST_STATE_LOCK(handle))
385 #define _MMCAMCORDER_TRYLOCK_GST_STATE(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_GST_STATE_LOCK(handle))
386 #define _MMCAMCORDER_UNLOCK_GST_STATE(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_GST_STATE_LOCK(handle))
388 #define _MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).gst_encode_state_lock)
389 #define _MMCAMCORDER_LOCK_GST_ENCODE_STATE(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle))
390 #define _MMCAMCORDER_TRYLOCK_GST_ENCODE_STATE(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle))
391 #define _MMCAMCORDER_UNLOCK_GST_ENCODE_STATE(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle))
393 /* for setting/calling callback */
394 #define _MMCAMCORDER_GET_MESSAGE_CALLBACK_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).message_cb_lock)
395 #define _MMCAMCORDER_LOCK_MESSAGE_CALLBACK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_MESSAGE_CALLBACK_LOCK(handle))
396 #define _MMCAMCORDER_TRYLOCK_MESSAGE_CALLBACK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_MESSAGE_CALLBACK_LOCK(handle))
397 #define _MMCAMCORDER_UNLOCK_MESSAGE_CALLBACK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_MESSAGE_CALLBACK_LOCK(handle))
399 #define _MMCAMCORDER_GET_VCAPTURE_CALLBACK_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).vcapture_cb_lock)
400 #define _MMCAMCORDER_LOCK_VCAPTURE_CALLBACK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_VCAPTURE_CALLBACK_LOCK(handle))
401 #define _MMCAMCORDER_TRYLOCK_VCAPTURE_CALLBACK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_VCAPTURE_CALLBACK_LOCK(handle))
402 #define _MMCAMCORDER_UNLOCK_VCAPTURE_CALLBACK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_VCAPTURE_CALLBACK_LOCK(handle))
404 #define _MMCAMCORDER_GET_VSTREAM_CALLBACK_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).vstream_cb_lock)
405 #define _MMCAMCORDER_LOCK_VSTREAM_CALLBACK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_VSTREAM_CALLBACK_LOCK(handle))
406 #define _MMCAMCORDER_TRYLOCK_VSTREAM_CALLBACK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_VSTREAM_CALLBACK_LOCK(handle))
407 #define _MMCAMCORDER_UNLOCK_VSTREAM_CALLBACK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_VSTREAM_CALLBACK_LOCK(handle))
409 #define _MMCAMCORDER_GET_ASTREAM_CALLBACK_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).astream_cb_lock)
410 #define _MMCAMCORDER_LOCK_ASTREAM_CALLBACK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_ASTREAM_CALLBACK_LOCK(handle))
411 #define _MMCAMCORDER_TRYLOCK_ASTREAM_CALLBACK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_ASTREAM_CALLBACK_LOCK(handle))
412 #define _MMCAMCORDER_UNLOCK_ASTREAM_CALLBACK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_ASTREAM_CALLBACK_LOCK(handle))
414 #ifdef _MMCAMCORDER_MURPHY_SUPPORT
415 /* for resource conflict */
416 #define _MMCAMCORDER_GET_RESOURCE_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).resource_lock)
417 #define _MMCAMCORDER_GET_RESOURCE_COND(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).resource_cond)
418 #define _MMCAMCORDER_LOCK_RESOURCE(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_RESOURCE_LOCK(handle))
419 #define _MMCAMCORDER_TRYLOCK_RESOURCE(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_RESOURCE_LOCK(handle))
420 #define _MMCAMCORDER_UNLOCK_RESOURCE(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_RESOURCE_LOCK(handle))
421 #define _MMCAMCORDER_RESOURCE_WAIT(handle) g_cond_wait(&_MMCAMCORDER_GET_RESOURCE_COND(handle), &_MMCAMCORDER_GET_RESOURCE_LOCK(handle))
422 #define _MMCAMCORDER_RESOURCE_WAIT_UNTIL(handle, end_time) g_cond_wait_until(&_MMCAMCORDER_GET_RESOURCE_COND(handle), &_MMCAMCORDER_GET_RESOURCE_LOCK(handle), end_time)
423 #define _MMCAMCORDER_RESOURCE_SIGNAL(handle) g_cond_signal(&_MMCAMCORDER_GET_RESOURCE_COND(handle));
424 #endif /* _MMCAMCORDER_MURPHY_SUPPORT */
427 * Caster of main handle (camcorder)
429 #define MMF_CAMCORDER(h) (mmf_camcorder_t *)(h)
432 * Caster of subcontext
434 #define MMF_CAMCORDER_SUBCONTEXT(h) (((mmf_camcorder_t *)(h))->sub_context)
436 /* LOCAL CONSTANT DEFINITIONS */
438 * Total Numbers of Attribute values.
439 * If you increase any enum of attribute values, you also have to increase this.
441 #define MM_CAMCORDER_MODE_NUM 3 /**< Number of mode type */
442 #define MM_CAMCORDER_COLOR_TONE_NUM 30 /**< Number of color-tone modes */
443 #define MM_CAMCORDER_WHITE_BALANCE_NUM 10 /**< Number of WhiteBalance modes*/
444 #define MM_CAMCORDER_SCENE_MODE_NUM 16 /**< Number of program-modes */
445 #define MM_CAMCORDER_FOCUS_MODE_NUM 6 /**< Number of focus mode*/
446 #define MM_CAMCORDER_AUTO_FOCUS_NUM 5 /**< Total count of auto focus type*/
447 #define MM_CAMCORDER_FOCUS_STATE_NUM 4 /**< Number of focus state */
448 #define MM_CAMCORDER_ISO_NUM 10 /**< Number of ISO */
449 #define MM_CAMCORDER_AUTO_EXPOSURE_NUM 9 /**< Number of Auto exposure type */
450 #define MM_CAMCORDER_WDR_NUM 3 /**< Number of wide dynamic range */
451 #define MM_CAMCORDER_FLIP_NUM 4 /**< Number of Filp mode */
452 #define MM_CAMCORDER_ROTATION_NUM 4 /**< Number of Rotation mode */
453 #define MM_CAMCORDER_AHS_NUM 4 /**< Number of anti-handshake */
454 #define MM_CAMCORDER_VIDEO_STABILIZATION_NUM 2 /**< Number of video stabilization */
455 #define MM_CAMCORDER_HDR_CAPTURE_NUM 3 /**< Number of HDR capture mode */
456 #define MM_CAMCORDER_GEOMETRY_METHOD_NUM 5 /**< Number of geometry method */
457 #define MM_CAMCORDER_TAG_ORT_NUM 8 /**< Number of tag orientation */
458 #define MM_CAMCORDER_STROBE_MODE_NUM 8 /**< Number of strobe mode type */
459 #define MM_CAMCORDER_STROBE_CONTROL_NUM 3 /**< Number of strobe control type */
460 #define MM_CAMCORDER_DETECT_MODE_NUM 2 /**< Number of detect mode type */
462 /*=======================================================================================
464 ========================================================================================*/
466 * Command for Camcorder.
469 /* Command for Video/Audio recording */
470 _MMCamcorder_CMD_RECORD,
471 _MMCamcorder_CMD_PAUSE,
472 _MMCamcorder_CMD_CANCEL,
473 _MMCamcorder_CMD_COMMIT,
475 /* Command for Image capture */
476 _MMCamcorder_CMD_CAPTURE,
478 /* Command for Preview(Video/Image only effective) */
479 _MMCamcorder_CMD_PREVIEW_START,
480 _MMCamcorder_CMD_PREVIEW_STOP,
487 _MMCamcorder_SINGLE_SHOT,
488 _MMCamcorder_MULTI_SHOT,
492 * Enumerations for manual focus direction.
493 * If focusing mode is not "MM_CAMCORDER_AF_MODE_MANUAL", this value will be ignored.
495 enum MMCamcorderMfLensDir {
496 MM_CAMCORDER_MF_LENS_DIR_FORWARD = 1, /**< Focus direction to forward */
497 MM_CAMCORDER_MF_LENS_DIR_BACKWARD, /**< Focus direction to backward */
498 MM_CAMCORDER_MF_LENS_DIR_NUM, /**< Total number of the directions */
502 * Camcorder Pipeline's Element name.
503 * @note index of element.
506 _MMCAMCORDER_NONE = (-1),
508 /* Main Pipeline Element */
509 _MMCAMCORDER_MAIN_PIPE = 0x00,
511 /* Pipeline element of Video input */
512 _MMCAMCORDER_VIDEOSRC_SRC,
513 _MMCAMCORDER_VIDEOSRC_FILT,
514 _MMCAMCORDER_VIDEOSRC_CLS_QUE,
515 _MMCAMCORDER_VIDEOSRC_CLS,
516 _MMCAMCORDER_VIDEOSRC_CLS_FILT,
517 _MMCAMCORDER_VIDEOSRC_QUE,
518 _MMCAMCORDER_VIDEOSRC_DECODE,
520 /* Pipeline element of Video output */
521 _MMCAMCORDER_VIDEOSINK_QUE,
522 _MMCAMCORDER_VIDEOSINK_CLS,
523 _MMCAMCORDER_VIDEOSINK_SINK,
525 _MMCAMCORDER_PIPELINE_ELEMENT_NUM,
526 } _MMCAMCORDER_PREVIEW_PIPELINE_ELELMENT;
529 * Camcorder Pipeline's Element name.
530 * @note index of element.
533 _MMCAMCORDER_ENCODE_NONE = (-1),
535 /* Main Pipeline Element */
536 _MMCAMCORDER_ENCODE_MAIN_PIPE = 0x00,
538 /* Pipeline element of Audio input */
539 _MMCAMCORDER_AUDIOSRC_BIN,
540 _MMCAMCORDER_AUDIOSRC_SRC,
541 _MMCAMCORDER_AUDIOSRC_FILT,
542 _MMCAMCORDER_AUDIOSRC_QUE,
543 _MMCAMCORDER_AUDIOSRC_CONV,
544 _MMCAMCORDER_AUDIOSRC_VOL,
546 /* Pipeline element of Encodebin */
547 _MMCAMCORDER_ENCSINK_BIN,
548 _MMCAMCORDER_ENCSINK_SRC,
549 _MMCAMCORDER_ENCSINK_FILT,
550 _MMCAMCORDER_ENCSINK_ENCBIN,
551 _MMCAMCORDER_ENCSINK_AQUE,
552 _MMCAMCORDER_ENCSINK_CONV,
553 _MMCAMCORDER_ENCSINK_AENC,
554 _MMCAMCORDER_ENCSINK_AENC_QUE,
555 _MMCAMCORDER_ENCSINK_VQUE,
556 _MMCAMCORDER_ENCSINK_VCONV,
557 _MMCAMCORDER_ENCSINK_VENC,
558 _MMCAMCORDER_ENCSINK_VENC_QUE,
559 _MMCAMCORDER_ENCSINK_ITOG,
560 _MMCAMCORDER_ENCSINK_ICROP,
561 _MMCAMCORDER_ENCSINK_ISCALE,
562 _MMCAMCORDER_ENCSINK_IFILT,
563 _MMCAMCORDER_ENCSINK_IQUE,
564 _MMCAMCORDER_ENCSINK_IENC,
565 _MMCAMCORDER_ENCSINK_MUX,
566 _MMCAMCORDER_ENCSINK_SINK,
568 _MMCAMCORDER_ENCODE_PIPELINE_ELEMENT_NUM,
569 } _MMCAMCORDER_ENCODE_PIPELINE_ELELMENT;
572 _MMCAMCORDER_TASK_THREAD_STATE_NONE,
573 _MMCAMCORDER_TASK_THREAD_STATE_SOUND_PLAY_START,
574 _MMCAMCORDER_TASK_THREAD_STATE_SOUND_SOLO_PLAY_START,
575 _MMCAMCORDER_TASK_THREAD_STATE_ENCODE_PIPE_CREATE,
576 _MMCAMCORDER_TASK_THREAD_STATE_CHECK_CAPTURE_IN_RECORDING,
577 _MMCAMCORDER_TASK_THREAD_STATE_EXIT,
578 } _MMCamcorderTaskThreadState;
581 * System state change cause
584 _MMCAMCORDER_STATE_CHANGE_NORMAL = 0,
585 _MMCAMCORDER_STATE_CHANGE_BY_FOCUS,
586 _MMCAMCORDER_STATE_CHANGE_BY_RM,
587 _MMCAMCORDER_STATE_CHANGE_BY_DPM
588 } _MMCamcorderStateChange;
591 /*=======================================================================================
592 | STRUCTURE DEFINITIONS |
593 ========================================================================================*/
595 * MMCamcorder Gstreamer Element
598 unsigned int id; /**< Gstreamer piplinem element name */
599 GstElement *gst; /**< Gstreamer element */
600 } _MMCamcorderGstElement;
603 * MMCamcorder information for KPI measurement
606 int current_fps; /**< current fps of this second */
607 int average_fps; /**< average fps */
608 unsigned int video_framecount; /**< total number of video frame */
609 unsigned int last_framecount; /**< total number of video frame in last measurement */
610 struct timeval init_video_time; /**< time when start to measure */
611 struct timeval last_video_time; /**< last measurement time */
612 } _MMCamcorderKPIMeasure;
615 * MMCamcorder information for Multi-Thread Safe
618 GMutex lock; /**< Mutex (for general use) */
619 GCond cond; /**< Condition (for general use) */
620 GMutex cmd_lock; /**< Mutex (for command) */
621 GCond cmd_cond; /**< Condition (for command) */
622 GMutex asm_lock; /**< Mutex (for ASM) */
623 GMutex state_lock; /**< Mutex (for state change) */
624 GMutex gst_state_lock; /**< Mutex (for gst pipeline state change) */
625 GMutex gst_encode_state_lock; /**< Mutex (for gst encode pipeline state change) */
626 GMutex message_cb_lock; /**< Mutex (for message callback) */
627 GMutex vcapture_cb_lock; /**< Mutex (for video capture callback) */
628 GMutex vstream_cb_lock; /**< Mutex (for video stream callback) */
629 GMutex astream_cb_lock; /**< Mutex (for audio stream callback) */
630 #ifdef _MMCAMCORDER_MURPHY_SUPPORT
631 GCond resource_cond; /**< Condition (for resource check) */
632 GMutex resource_lock; /**< Mutex (for resource check) */
633 #endif /* _MMCAMCORDER_MURPHY_SUPPORT */
634 } _MMCamcorderMTSafe;
637 * MMCamcorder Sub Context
640 bool isMaxsizePausing; /**< Because of size limit, pipeline is paused. */
641 bool isMaxtimePausing; /**< Because of time limit, pipeline is paused. */
642 int element_num; /**< count of element */
643 int encode_element_num; /**< count of encode element */
644 int cam_stability_count; /**< camsensor stability count. the count of frame will drop */
645 GstClockTime pipeline_time; /**< current time of Gstreamer Pipeline */
646 GstClockTime pause_time; /**< amount of time while pipeline is in PAUSE state.*/
647 GstClockTime stillshot_time; /**< pipeline time of capturing moment*/
648 gboolean is_modified_rate; /**< whether recording motion rate is modified or not */
649 gboolean ferror_send; /**< file write/seek error **/
650 guint ferror_count; /**< file write/seek error count **/
651 GstClockTime previous_slot_time;
652 int display_interval; /**< This value is set as 'GST_SECOND / display FPS' */
653 gboolean bget_eos; /**< Whether getting EOS */
654 gboolean bencbin_capture; /**< Use Encodebin for capturing */
655 gboolean audio_disable; /**< whether audio is disabled or not when record */
656 int videosrc_rotate; /**< rotate of videosrc */
658 /* For dropping video frame when start recording */
659 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. */
660 int pass_first_vframe; /**< When this value is bigger than zero, MSL won't drop video frame though "drop_vframe" is bigger then zero. */
662 /* INI information */
663 unsigned int fourcc; /**< Get fourcc value of camera INI file */
664 _MMCamcorderImageInfo *info_image; /**< extra information for image capture */
665 _MMCamcorderVideoInfo *info_video; /**< extra information for video recording */
666 _MMCamcorderAudioInfo *info_audio; /**< extra information for audio recording */
668 _MMCamcorderGstElement *element; /**< array of preview element */
669 _MMCamcorderGstElement *encode_element; /**< array of encode element */
670 _MMCamcorderKPIMeasure kpi; /**< information related with performance measurement */
672 type_element *VideosinkElement; /**< configure data of videosink element */
673 type_element *VideoconvertElement; /**< configure data of videoconvert element */
674 type_element *VideodecoderElementH264; /**< configure data of video decoder element for H.264 format */
675 gboolean SensorEncodedCapture; /**< whether camera sensor support encoded image capture */
676 gboolean internal_encode; /**< whether use internal encoding function */
677 } _MMCamcorderSubContext;
680 * _MMCamcorderContext
682 typedef struct mmf_camcorder {
684 int type; /**< mmcamcorder_mode_type */
685 int device_type; /**< device type */
686 int state; /**< state of camcorder */
687 int target_state; /**< Target state that want to set. This is a flag that
688 * stands for async state changing. If this value differ from state,
689 * it means state is changing now asychronously. */
692 MMHandleType attributes; /**< Attribute handle */
693 _MMCamcorderSubContext *sub_context; /**< sub context */
694 mm_exif_info_t *exif_info; /**< EXIF */
695 GList *buffer_probes; /**< a list of buffer probe handle */
696 GList *event_probes; /**< a list of event probe handle */
697 GList *signals; /**< a list of signal handle */
698 #ifdef _MMCAMCORDER_ENABLE_IDLE_MESSAGE_CALLBACK
699 GList *msg_data; /**< a list of msg data */
700 #endif /* _MMCAMCORDER_ENABLE_IDLE_MESSAGE_CALLBACK */
701 camera_conf *conf_main; /**< Camera configure Main structure */
702 camera_conf *conf_ctrl; /**< Camera configure Control structure */
703 #ifdef _MMCAMCORDER_RM_SUPPORT
704 int rm_handle; /**< Resource manager handle */
705 #endif /* _MMCAMCORDER_RM_SUPPORT */
706 guint pipeline_cb_event_id; /**< Event source ID of pipeline message callback */
707 guint encode_pipeline_cb_event_id; /**< Event source ID of encode pipeline message callback */
708 guint setting_event_id; /**< Event source ID of attributes setting to sensor */
709 SOUND_INFO snd_info; /**< Sound handle for multishot capture */
711 /* callback handlers */
712 MMMessageCallback msg_cb; /**< message callback */
713 void *msg_cb_param; /**< message callback parameter */
714 mm_camcorder_video_stream_callback vstream_cb; /**< Video stream callback */
715 void *vstream_cb_param; /**< Video stream callback parameter */
716 mm_camcorder_audio_stream_callback astream_cb; /**< Audio stream callback */
717 void *astream_cb_param; /**< Audio stream callback parameter */
718 mm_camcorder_video_capture_callback vcapture_cb; /**< Video capture callback */
719 void *vcapture_cb_param; /**< Video capture callback parameter */
720 int (*command)(MMHandleType, int); /**< camcorder's command */
723 mm_cam_attr_construct_info *cam_attrs_const_info; /**< attribute info */
724 conf_info_table *conf_main_info_table[CONFIGURE_CATEGORY_MAIN_NUM]; /** configure info table - MAIN category */
725 conf_info_table *conf_ctrl_info_table[CONFIGURE_CATEGORY_CTRL_NUM]; /** configure info table - CONTROL category */
726 int conf_main_category_size[CONFIGURE_CATEGORY_MAIN_NUM]; /** configure info table size - MAIN category */
727 int conf_ctrl_category_size[CONFIGURE_CATEGORY_CTRL_NUM]; /** configure info table size - CONTROL category */
728 _MMCamcorderMTSafe mtsafe; /**< Thread safe */
729 int state_change_by_system; /**< MSL changes its state by itself because of system */
730 GMutex restart_preview_lock; /**< Capture sound mutex */
731 int use_zero_copy_format; /**< Whether use zero copy format for camera input */
732 int use_videoconvert; /**< Whether use videoconvert element for display */
733 int support_media_packet_preview_cb; /**< Whether support zero copy format for camera input */
734 int shutter_sound_policy; /**< shutter sound policy */
735 int brightness_default; /**< default value of brightness */
736 int brightness_step_denominator; /**< denominator of brightness bias step */
737 int support_zsl_capture; /**< support Zero Shutter Lag capture */
738 char *model_name; /**< model name from system info */
739 char *software_version; /**< software_version from system info */
740 int capture_sound_count; /**< count for capture sound */
741 char *root_directory; /**< Root directory for device */
742 int resolution_changed; /**< Flag for preview resolution change */
743 int sound_focus_register; /**< Use sound focus internally */
744 int sound_focus_id; /**< id for sound focus */
745 int sound_focus_watch_id; /**< id for sound focus watch */
746 int interrupt_code; /**< Interrupt code */
747 int acquired_focus; /**< Current acquired focus */
748 int session_type; /**< Session type */
749 int session_flags; /**< Session flags */
750 int recreate_decoder; /**< Flag of decoder element recreation for encoded preview format */
752 _MMCamcorderInfoConverting caminfo_convert[CAMINFO_CONVERT_NUM]; /**< converting structure of camera info */
753 _MMCamcorderEnumConvert enum_conv[ENUM_CONVERT_NUM]; /**< enum converting list that is modified by ini info */
755 gboolean capture_in_recording; /**< Flag for capture while recording */
757 gboolean error_occurs; /**< flag for error */
758 int error_code; /**< error code for internal gstreamer error */
761 GThread *task_thread; /**< thread for task */
762 GMutex task_thread_lock; /**< mutex for task thread */
763 GCond task_thread_cond; /**< cond for task thread */
764 _MMCamcorderTaskThreadState task_thread_state; /**< state of task thread */
766 #ifdef _MMCAMCORDER_MURPHY_SUPPORT
767 /* resource manager for H/W resources */
768 MMCamcorderResourceManager resource_manager;
769 #endif /* _MMCAMCORDER_MURPHY_SUPPORT */
772 GDBusConnection *gdbus_conn; /**< gdbus connection */
773 _MMCamcorderGDbusCbInfo gdbus_info_sound; /**< Informations for the gbus cb of sound play */
774 _MMCamcorderGDbusCbInfo gdbus_info_solo_sound; /**< Informations for the gbus cb of solo sound play */
776 /* DPM(device policy manager) */
777 device_policy_manager_h dpm_handle; /**< DPM handle */
778 int dpm_camera_cb_id; /**< DPM camera policy changed callback id */
781 _MMCamcorderStorageInfo storage_info; /**< Storage information */
783 #ifdef _MMCAMCORDER_RM_SUPPORT
784 rm_category_request_s request_resources;
785 rm_device_return_s returned_devices;
786 #endif /* _MMCAMCORDER_RM_SUPPORT */
787 int reserved[4]; /**< reserved */
790 /*=======================================================================================
791 | EXTERN GLOBAL VARIABLE |
792 ========================================================================================*/
794 /*=======================================================================================
795 | GLOBAL FUNCTION PROTOTYPES |
796 ========================================================================================*/
798 * This function creates camcorder for capturing still image and recording.
800 * @param[out] handle Specifies the camcorder handle
801 * @param[in] info Preset information of camcorder
802 * @return This function returns zero on success, or negative value with error code.
803 * @remarks When this function calls successfully, camcorder handle will be filled with a @n
804 * valid value and the state of the camcorder will become MM_CAMCORDER_STATE_NULL.@n
805 * Note that it's not ready to working camcorder. @n
806 * You should call mmcamcorder_realize before starting camcorder.
807 * @see _mmcamcorder_create
809 int _mmcamcorder_create(MMHandleType *handle, MMCamPreset *info);
812 * This function destroys instance of camcorder.
814 * @param[in] hcamcorder Specifies the camcorder handle
815 * @return This function returns zero on success, or negative value with error code.
816 * @see _mmcamcorder_create
818 int _mmcamcorder_destroy(MMHandleType hcamcorder);
821 * This function allocates memory for camcorder.
823 * @param[in] hcamcorder Specifies the camcorder handle
824 * @return This function returns zero on success, or negative value with error code.
825 * @remarks This function can be called successfully when current state is MM_CAMCORDER_STATE_NULL @n
826 * and the state of the camcorder will become MM_CAMCORDER_STATE_READY. @n
827 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
828 * @see _mmcamcorder_unrealize
829 * @pre MM_CAMCORDER_STATE_NULL
830 * @post MM_CAMCORDER_STATE_READY
832 int _mmcamcorder_realize(MMHandleType hcamcorder);
835 * This function free allocated memory for camcorder.
837 * @param[in] hcamcorder Specifies the camcorder handle
838 * @return This function returns zero on success, or negative value with error code.
839 * @remarks This function release all resources which are allocated for the camcorder engine.@n
840 * This function can be called successfully when current state is MM_CAMCORDER_STATE_READY and @n
841 * the state of the camcorder will become MM_CAMCORDER_STATE_NULL. @n
842 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
843 * @see _mmcamcorder_realize
844 * @pre MM_CAMCORDER_STATE_READY
845 * @post MM_CAMCORDER_STATE_NULL
847 int _mmcamcorder_unrealize(MMHandleType hcamcorder);
850 * This function is to start previewing.
852 * @param[in] hcamcorder Specifies the camcorder handle
853 * @return This function returns zero on success, or negative value with error code.
854 * @remarks This function can be called successfully when current state is MM_CAMCORDER_STATE_READY and @n
855 * the state of the camcorder will become MM_CAMCORDER_STATE_PREPARE. @n
856 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
857 * @see _mmcamcorder_stop
859 int _mmcamcorder_start(MMHandleType hcamcorder);
862 * This function is to stop previewing.
864 * @param[in] hcamcorder Specifies the camcorder handle
865 * @return This function returns zero on success, or negative value with error code.
866 * @remarks This function can be called successfully when current state is MM_CAMCORDER_STATE_PREPARE and @n
867 * the state of the camcorder will become MM_CAMCORDER_STATE_READY.@n
868 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
869 * @see _mmcamcorder_start
871 int _mmcamcorder_stop(MMHandleType hcamcorder);
874 * This function to start capturing of still images.
876 * @param[in] hcamcorder Specifies the camcorder handle.
877 * @return This function returns zero on success, or negative value with error code.
878 * @remarks This function can be called successfully when current state is MM_CAMCORDER_STATE_PREPARE and @n
879 * the state of the camcorder will become MM_CAMCORDER_STATE_CAPTURING. @n
880 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
881 * @see _mmcamcorder_capture_stop
883 int _mmcamcorder_capture_start(MMHandleType hcamcorder);
886 * This function is to stop capturing still images.
888 * @param[in] hcamcorder Specifies the camcorder handle
889 * @return This function returns zero on success, or negative value with error code.
890 * @remarks This function can be called successfully when current state is MM_CAMCORDER_STATE_CAPTURING and @n
891 * the state of the camcorder will become MM_CAMCORDER_STATE_PREPARE. @n
892 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
893 * @see _mmcamcorder_capture_start
895 int _mmcamcorder_capture_stop(MMHandleType hcamcorder);
898 * This function is to start video and audio recording.
900 * @param[in] hcamcorder Specifies the camcorder handle
901 * @return This function returns zero on success, or negative value with error code.
902 * @remarks This function can be called successfully when current state is @n
903 * MM_CAMCORDER_STATE_PREPARE or MM_CAMCORDER_STATE_PAUSED and @n
904 * the state of the camcorder will become MM_CAMCORDER_STATE_RECORDING.@n
905 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
906 * @see _mmcamcorder_pause
908 int _mmcamcorder_record(MMHandleType hcamcorder);
911 * This function is to pause video and audio recording
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_RECORDING and @n
916 * the state of the camcorder will become MM_CAMCORDER_STATE_PAUSED.@n
917 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.@n
918 * @see _mmcamcorder_record
920 int _mmcamcorder_pause(MMHandleType hcamcorder);
923 * This function is to stop video and audio recording and save results.
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 @n
928 * MM_CAMCORDER_STATE_PAUSED or MM_CAMCORDER_STATE_RECORDING and @n
929 * the state of the camcorder will become MM_CAMCORDER_STATE_PREPARE. @n
930 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION
931 * @see _mmcamcorder_cancel
933 int _mmcamcorder_commit(MMHandleType hcamcorder);
936 * This function is to stop video and audio recording and do not save results.
938 * @param[in] hcamcorder Specifies the camcorder handle
939 * @return This function returns zero on success, or negative value with error code.
940 * @remarks This function can be called successfully when current state is @n
941 * MM_CAMCORDER_STATE_PAUSED or MM_CAMCORDER_STATE_RECORDING and @n
942 * the state of the camcorder will become MM_CAMCORDER_STATE_PREPARE. @n
943 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
944 * @see _mmcamcorder_commit
946 int _mmcamcorder_cancel(MMHandleType hcamcorder);
949 * This function calls after commiting action finished asynchronously.
950 * In this function, remaining process , such as state change, happens.
952 * @param[in] hcamcorder Specifies the camcorder handle
953 * @return This function returns zero on success, or negative value with error code.
954 * @remarks This function can be called successfully when current state is @n
955 * MM_CAMCORDER_STATE_PAUSED or MM_CAMCORDER_STATE_RECORDING and @n
956 * the state of the camcorder will become MM_CAMCORDER_STATE_PREPARE. @n
957 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
958 * @see _mmcamcorder_commit
960 int _mmcamcorder_commit_async_end(MMHandleType hcamcorder);
963 * This function is to set callback for receiving messages from camcorder.
965 * @param[in] hcamcorder Specifies the camcorder handle
966 * @param[in] callback Specifies the function pointer of callback function
967 * @param[in] user_data Specifies the user poiner for passing to callback function
969 * @return This function returns zero on success, or negative value with error code.
970 * @remarks typedef bool (*mm_message_callback) (int msg, mm_messageType *param, void *user_param);@n
985 * } mm_message_type; @n
987 * If a message value for mm_message_callback is MM_MESSAGE_STATE_CHANGED, @n
988 * state value in mm_message_type will be a mmcamcorder_state_type enum value;@n
990 * If a message value for mm_message_callback is MM_MESSAGE_ERROR, @n
991 * the code value in mm_message_type will be a mmplayer_error_type enum value;
993 * @see mm_message_type, mmcamcorder_state_type, mmcamcorder_error_type
995 int _mmcamcorder_set_message_callback(MMHandleType hcamcorder,
996 MMMessageCallback callback,
1000 * This function is to set callback for video stream.
1002 * @param[in] hcamcorder Specifies the camcorder handle
1003 * @param[in] callback Specifies the function pointer of callback function
1004 * @param[in] user_data Specifies the user poiner for passing to callback function
1006 * @return This function returns zero on success, or negative value with error code.
1007 * @see mmcamcorder_error_type
1009 int _mmcamcorder_set_video_stream_callback(MMHandleType hcamcorder,
1010 mm_camcorder_video_stream_callback callback,
1014 * This function is to set callback for audio stream.
1016 * @param[in] hcamcorder Specifies the camcorder handle
1017 * @param[in] callback Specifies the function pointer of callback function
1018 * @param[in] user_data Specifies the user poiner for passing to callback function
1020 * @return This function returns zero on success, or negative value with error code.
1021 * @see mmcamcorder_error_type
1023 int _mmcamcorder_set_audio_stream_callback(MMHandleType handle,
1024 mm_camcorder_audio_stream_callback callback,
1028 * This function is to set callback for video capture.
1030 * @param[in] hcamcorder Specifies the camcorder handle
1031 * @param[in] callback Specifies the function pointer of callback function
1032 * @param[in] user_data Specifies the user poiner for passing to callback function
1034 * @return This function returns zero on success, or negative value with error code.
1035 * @see mmcamcorder_error_type
1037 int _mmcamcorder_set_video_capture_callback(MMHandleType hcamcorder,
1038 mm_camcorder_video_capture_callback callback,
1042 * This function returns current state of camcorder, or negative value with error code.
1044 * @param[in] hcamcorder Specifies the camcorder handle.
1045 * @return This function returns current state of camcorder, or negative value with error code.
1046 * @see mmcamcorder_state_type
1048 int _mmcamcorder_get_current_state(MMHandleType hcamcorder);
1050 int _mmcamcorder_init_focusing(MMHandleType handle);
1051 int _mmcamcorder_adjust_focus(MMHandleType handle, int direction);
1052 int _mmcamcorder_adjust_manual_focus(MMHandleType handle, int direction);
1053 int _mmcamcorder_adjust_auto_focus(MMHandleType handle);
1054 int _mmcamcorder_stop_focusing(MMHandleType handle);
1057 * This function gets current state of camcorder.
1060 * @return This function returns state of current camcorder context
1062 * @see _mmcamcorder_set_state()
1065 int _mmcamcorder_streamer_init(void);
1068 * This function gets current state of camcorder.
1071 * @return This function returns state of current camcorder context
1073 * @see _mmcamcorder_set_state()
1076 int _mmcamcorder_display_init(void);
1079 * This function gets current state of camcorder.
1081 * @param[in] handle Handle of camcorder context.
1082 * @return This function returns state of current camcorder context
1084 * @see _mmcamcorder_set_state()
1087 int _mmcamcorder_get_state(MMHandleType handle);
1090 * This function sets new state of camcorder.
1092 * @param[in] handle Handle of camcorder context.
1093 * @param[in] state setting state value of camcorder.
1096 * @see _mmcamcorder_get_state()
1099 void _mmcamcorder_set_state(MMHandleType handle, int state);
1102 * This function gets asynchronous status of MSL Camcroder.
1104 * @param[in] handle Handle of camcorder context.
1105 * @param[in] target_state setting target_state value of camcorder.
1106 * @return This function returns asynchrnous state.
1108 * @see _mmcamcorder_set_async_state()
1111 int _mmcamcorder_get_async_state(MMHandleType handle);
1114 * This function allocates structure of subsidiary attributes.
1116 * @param[in] type Allocation type of camcorder context.
1117 * @return This function returns structure pointer on success, NULL value on failure.
1119 * @see _mmcamcorder_dealloc_subcontext()
1122 _MMCamcorderSubContext *_mmcamcorder_alloc_subcontext(int type);
1125 * This function releases structure of subsidiary attributes.
1127 * @param[in] sc Handle of camcorder subcontext.
1130 * @see _mmcamcorder_alloc_subcontext()
1133 void _mmcamcorder_dealloc_subcontext(_MMCamcorderSubContext *sc);
1136 * This function sets command function according to the type.
1138 * @param[in] handle Handle of camcorder context.
1139 * @param[in] type Allocation type of camcorder context.
1140 * @return This function returns MM_ERROR_NONE on success, or other values with error code.
1142 * @see __mmcamcorder_video_command(), __mmcamcorder_audio_command(), __mmcamcorder_image_command()
1145 int _mmcamcorder_set_functions(MMHandleType handle, int type);
1148 * This function is callback function of main pipeline.
1149 * Once this function is registered with certain pipeline using gst_bus_add_watch(),
1150 * this callback will be called every time when there is upcomming message from pipeline.
1151 * Basically, this function is used as error handling function, now.
1153 * @param[in] bus pointer of buf that called this function.
1154 * @param[in] message callback message from pipeline.
1155 * @param[in] data user data.
1156 * @return This function returns true on success, or false value with error
1158 * @see __mmcamcorder_create_preview_pipeline()
1161 gboolean _mmcamcorder_pipeline_cb_message(GstBus *bus, GstMessage *message, gpointer data);
1164 * This function is callback function of main pipeline.
1165 * Once this function is registered with certain pipeline using gst_bus_set_sync_handler(),
1166 * this callback will be called every time when there is upcomming message from pipeline.
1167 * Basically, this function is used as sync error handling function, now.
1169 * @param[in] bus pointer of buf that called this function.
1170 * @param[in] message callback message from pipeline.
1171 * @param[in] data user data.
1172 * @return This function returns true on success, or false value with error
1174 * @see __mmcamcorder_create_preview_pipeline()
1177 GstBusSyncReply _mmcamcorder_pipeline_bus_sync_callback(GstBus *bus, GstMessage *message, gpointer data);
1180 * This function is callback function of encode pipeline.
1181 * Once this function is registered with certain pipeline using gst_bus_set_sync_handler(),
1182 * this callback will be called every time when there is upcomming message from pipeline.
1183 * Basically, this function is used for EOS and error handling now.
1185 * @param[in] bus pointer of buf that called this function.
1186 * @param[in] message callback message from pipeline.
1187 * @param[in] data user data.
1188 * @return This function returns true on success, or false value with error
1190 * @see __mmcamcorder_create_recorder_pipeline()
1191 * @see __mmcamcorder_create_audiop_with_encodebin()
1194 GstBusSyncReply _mmcamcorder_encode_pipeline_bus_sync_callback(GstBus *bus, GstMessage *message, gpointer data);
1197 * This function create main pipeline according to type.
1199 * @param[in] handle Handle of camcorder context.
1200 * @param[in] type Allocation type of camcorder context.
1201 * @return This function returns zero on success, or negative value with error code.
1203 * @see _mmcamcorder_destroy_pipeline()
1206 int _mmcamcorder_create_pipeline(MMHandleType handle, int type);
1209 * This function release all element of main pipeline according to type.
1211 * @param[in] handle Handle of camcorder context.
1212 * @param[in] type Allocation type of camcorder context.
1215 * @see _mmcamcorder_create_pipeline()
1218 void _mmcamcorder_destroy_pipeline(MMHandleType handle, int type);
1221 * This function sets gstreamer element status.
1222 * If the gstreamer fails to set status or returns asynchronous mode,
1223 * this function waits for state changed until timeout expired.
1225 * @param[in] pipeline Pointer of pipeline
1226 * @param[in] target_state newly setting status
1227 * @return This function returns zero on success, or negative value with error code.
1232 int _mmcamcorder_gst_set_state(MMHandleType handle, GstElement *pipeline, GstState target_state);
1235 * This function sets gstreamer element status, asynchronously.
1236 * Regardless of processing, it returns immediately.
1238 * @param[in] pipeline Pointer of pipeline
1239 * @param[in] target_state newly setting status
1240 * @return This function returns zero on success, or negative value with error code.
1245 int _mmcamcorder_gst_set_state_async(MMHandleType handle, GstElement *pipeline, GstState target_state);
1247 /* For xvimagesink */
1248 GstBusSyncReply __mmcamcorder_sync_callback(GstBus *bus, GstMessage *message, gulong data);
1250 /* For querying capabilities */
1251 int _mmcamcorder_read_vidsrc_info(int videodevidx, camera_conf **configure_info);
1253 /* for performance check */
1254 void _mmcamcorder_video_current_framerate_init(MMHandleType handle);
1255 int _mmcamcorder_video_current_framerate(MMHandleType handle);
1256 int _mmcamcorder_video_average_framerate(MMHandleType handle);
1258 /* sound focus related function */
1259 void __mmcamcorder_force_stop(mmf_camcorder_t *hcamcorder);
1260 void _mmcamcorder_sound_focus_cb(int id, mm_sound_focus_type_e focus_type,
1261 mm_sound_focus_state_e focus_state, const char *reason_for_change,
1262 const char *additional_info, void *user_data);
1263 void _mmcamcorder_sound_focus_watch_cb(mm_sound_focus_type_e focus_type, mm_sound_focus_state_e focus_state,
1264 const char *reason_for_change, const char *additional_info, void *user_data);
1266 /* device policy manager */
1267 void _mmcamcorder_dpm_camera_policy_changed_cb(const char *name, const char *value, void *user_data);
1269 /* For hand over the server's caps information to client */
1270 int _mmcamcorder_get_video_caps(MMHandleType handle, char **caps);
1276 #endif /* __MM_CAMCORDER_INTERNAL_H__ */