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_message.h>
37 #include <gst/video/video-format.h>
40 #include <restriction.h> /* device policy manager */
43 #include "mm_camcorder.h"
45 #ifdef _MMCAMCORDER_MM_RM_SUPPORT
46 #include <mm_resource_manager.h>
47 #endif /* _MMCAMCORDER_MM_RM_SUPPORT */
49 /* camcorder sub module */
50 #include "mm_camcorder_attribute.h"
51 #include "mm_camcorder_platform.h"
52 #include "mm_camcorder_stillshot.h"
53 #include "mm_camcorder_videorec.h"
54 #include "mm_camcorder_audiorec.h"
55 #include "mm_camcorder_gstcommon.h"
56 #include "mm_camcorder_exifinfo.h"
57 #include "mm_camcorder_util.h"
58 #include "mm_camcorder_configure.h"
59 #include "mm_camcorder_sound.h"
61 #ifdef _MMCAMCORDER_RM_SUPPORT
62 /* rm (resource manager)*/
64 #endif /* _MMCAMCORDER_RM_SUPPORT */
66 #ifdef _MMCAMCORDER_CAMERA_CONF_MGR_SUPPORT
67 #include "camera_conf_mgr.h"
68 #endif /*_MMCAMCORDER_CAMERA_CONF_MGR_SUPPORT */
73 #define LOG_TAG "MM_CAMCORDER"
79 /*=======================================================================================
81 ========================================================================================*/
83 * Macro for checking validity and debugging
85 #define mmf_return_if_fail(expr) \
87 MMCAM_LOG_ERROR("failed [%s]", #expr); \
92 * Macro for checking validity and debugging
94 #define mmf_return_val_if_fail(expr, val) \
96 MMCAM_LOG_ERROR("failed [%s]", #expr); \
103 * Macro for getting array size
105 #define ARRAY_SIZE(a) (sizeof((a)) / sizeof((a)[0]))
108 /* gstreamer element creation macro */
109 #define _MMCAMCORDER_PIPELINE_MAKE(sub_context, element, eid, name /*char* */, err) \
111 if (element[eid].gst != NULL) { \
112 MMCAM_LOG_ERROR("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_LOG_ERROR("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); \
126 #define _MMCAMCORDER_BIN_MAKE(sub_context, element, eid, name /*char* */, err) \
128 if (element[eid].gst != NULL) { \
129 MMCAM_LOG_ERROR("The element(Bin) is existed. element_id=[%d], name=[%s]", eid, name); \
130 gst_object_unref(element[eid].gst); \
132 element[eid].id = eid; \
133 element[eid].gst = gst_bin_new(name); \
134 if (element[eid].gst == NULL) { \
135 MMCAM_LOG_ERROR("Bin creation fail. element_id=[%d], name=[%s]\n", eid, name); \
136 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
137 goto pipeline_creation_error; \
139 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
143 #define _MMCAMCORDER_ELEMENT_MAKE(sub_context, element, eid, name /*char* */, nickname /*char* */, elist, err) \
145 if (element[eid].gst != NULL) { \
146 MMCAM_LOG_ERROR("The element is existed. element_id=[%d], name=[%s]", eid, name); \
147 gst_object_unref(element[eid].gst); \
149 traceBegin(TTRACE_TAG_CAMERA, "MMCAMCORDER:ELEMENT_MAKE:%s", name); \
150 element[eid].gst = gst_element_factory_make(name, nickname); \
151 traceEnd(TTRACE_TAG_CAMERA); \
152 if (element[eid].gst == NULL) { \
153 MMCAM_LOG_ERROR("Element creation fail. element_id=[%d], name=[%s]", eid, name); \
154 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
155 goto pipeline_creation_error; \
157 MMCAM_LOG_INFO("Element creation done. element_id=[%d], name=[%s]", eid, name); \
158 element[eid].id = eid; \
159 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
160 err = MM_ERROR_NONE; \
162 elist = g_list_append(elist, &(element[eid])); \
165 #define _MMCAMCORDER_ELEMENT_MAKE2(sub_context, element, eid, name /*char* */, nickname /*char* */, err) \
167 if (element[eid].gst != NULL) { \
168 MMCAM_LOG_ERROR("The element is existed. element_id=[%d], name=[%s]", eid, name); \
169 gst_object_unref(element[eid].gst); \
171 element[eid].gst = gst_element_factory_make(name, nickname); \
172 if (element[eid].gst == NULL) { \
173 MMCAM_LOG_ERROR("Element creation fail. element_id=[%d], name=[%s]", eid, name); \
174 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
176 MMCAM_LOG_INFO("Element creation done. element_id=[%d], name=[%s]", eid, name); \
177 element[eid].id = eid; \
178 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
179 err = MM_ERROR_NONE; \
183 #define _MMCAMCORDER_ELEMENT_MAKE_IGNORE_ERROR(sub_context, element, eid, name /*char* */, nickname /*char* */, elist) \
185 if (element[eid].gst != NULL) { \
186 MMCAM_LOG_ERROR("The element is existed. element_id=[%d], name=[%s]", eid, name); \
187 gst_object_unref(element[eid].gst); \
189 element[eid].gst = gst_element_factory_make(name, nickname); \
190 if (element[eid].gst == NULL) { \
191 MMCAM_LOG_ERROR("Element creation fail. element_id=[%d], name=[%s], but keep going...", eid, name); \
193 MMCAM_LOG_INFO("Element creation done. element_id=[%d], name=[%s]", eid, name); \
194 element[eid].id = eid; \
195 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
196 elist = g_list_append(elist, &(element[eid])); \
200 #define _MMCAMCORDER_ELEMENT_ADD(sub_context, element, eid, gst_element, elist, err) \
202 if (element[eid].gst != NULL) { \
203 MMCAM_LOG_ERROR("The element is existed. element_id=[%d]", eid); \
204 gst_object_unref(element[eid].gst); \
206 element[eid].gst = gst_element; \
207 if (element[eid].gst == NULL) { \
208 MMCAM_LOG_ERROR("Element is NULL. element_id=[%d]", eid); \
209 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
210 goto pipeline_creation_error; \
212 MMCAM_LOG_INFO("Adding Element is done. element_id=[%d] %p", eid, gst_element); \
213 element[eid].id = eid; \
214 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
215 err = MM_ERROR_NONE; \
217 elist = g_list_append(elist, &(element[eid])); \
220 #define _MMCAMCORDER_ENCODEBIN_ELMGET(sub_context, eid, name /*char* */, err) \
222 if (sub_context->encode_element[eid].gst != NULL) { \
223 MMCAM_LOG_ERROR("The element is existed. element_id=[%d], name=[%s]", eid, name); \
224 gst_object_unref(sub_context->encode_element[eid].gst); \
226 sub_context->encode_element[eid].id = eid; \
227 g_object_get(G_OBJECT(sub_context->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst), name, &(sub_context->encode_element[eid].gst), NULL); \
228 if (sub_context->encode_element[eid].gst == NULL) { \
229 MMCAM_LOG_ERROR("Encode Element get fail. element_id=[%d], name=[%s]", eid, name); \
230 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
231 goto pipeline_creation_error; \
233 gst_object_unref(sub_context->encode_element[eid].gst); \
234 g_object_weak_ref(G_OBJECT(sub_context->encode_element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
238 /* GStreamer element remove macro */
239 #define _MMCAMCORDER_ELEMENT_REMOVE(element, eid) \
240 if (element[eid].gst != NULL) { \
241 gst_object_unref(element[eid].gst); \
244 #define _MM_GST_ELEMENT_LINK_MANY gst_element_link_many
245 #define _MM_GST_ELEMENT_LINK gst_element_link
246 #define _MM_GST_ELEMENT_LINK_FILTERED gst_element_link_filtered
247 #define _MM_GST_ELEMENT_UNLINK gst_element_unlink
248 #define _MM_GST_PAD_LINK gst_pad_link
250 #define _MM_GST_PAD_LINK_UNREF(srcpad, sinkpad, err, if_fail_goto) \
252 GstPadLinkReturn ret = GST_PAD_LINK_OK; \
253 if (srcpad == NULL || sinkpad == NULL) { \
254 if (srcpad == NULL) { \
255 MMCAM_LOG_ERROR("srcpad is NULL"); \
257 gst_object_unref(srcpad);\
260 if (sinkpad == NULL) { \
261 MMCAM_LOG_ERROR("sinkpad is NULL"); \
263 gst_object_unref(sinkpad); \
266 err = MM_ERROR_CAMCORDER_GST_LINK; \
269 ret = _MM_GST_PAD_LINK(srcpad, sinkpad); \
270 if (ret != GST_PAD_LINK_OK) { \
271 GstObject *src_parent = gst_pad_get_parent(srcpad); \
272 GstObject *sink_parent = gst_pad_get_parent(sinkpad); \
273 char *src_name = NULL; \
274 char *sink_name = NULL; \
275 g_object_get((GObject *)src_parent, "name", &src_name, NULL); \
276 g_object_get((GObject *)sink_parent, "name", &sink_name, NULL); \
277 MMCAM_LOG_ERROR("src[%s] - sink[%s] link failed", src_name, sink_name); \
278 gst_object_unref(src_parent); src_parent = NULL; \
279 gst_object_unref(sink_parent); sink_parent = NULL; \
281 free(src_name); src_name = NULL; \
284 free(sink_name); sink_name = NULL; \
286 gst_object_unref(srcpad); srcpad = NULL; \
287 gst_object_unref(sinkpad); sinkpad = NULL; \
288 err = MM_ERROR_CAMCORDER_GST_LINK; \
291 gst_object_unref(srcpad); srcpad = NULL; \
292 gst_object_unref(sinkpad); sinkpad = NULL; \
295 #define _MM_GST_PAD_UNLINK_UNREF(srcpad, sinkpad) \
297 if (srcpad && sinkpad) { \
298 gst_pad_unlink(srcpad, sinkpad); \
300 MMCAM_LOG_WARNING("some pad(srcpad:%p,sinkpad:%p) is NULL", srcpad, sinkpad); \
303 gst_object_unref(srcpad); srcpad = NULL; \
306 gst_object_unref(sinkpad); sinkpad = NULL; \
310 #define _MMCAMCORDER_STATE_SET_COUNT 3 /* checking interval */
311 #define _MMCAMCORDER_STATE_CHECK_TOTALTIME 5000000L /* total waiting time for state change */
312 #define _MMCAMCORDER_STATE_CHECK_INTERVAL (50*1000) /* checking interval - 50ms*/
315 * Default videosink type
317 #define _MMCAMCORDER_DEFAULT_VIDEOSINK_TYPE "VideosinkElementOverlay"
320 * Default recording motion rate
322 #define _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE 1.0
325 * Total level count of manual focus */
326 #define _MMFCAMCORDER_FOCUS_TOTAL_LEVEL 8
329 * File name length limit
331 #define _MMCamcorder_FILENAME_LEN (512)
334 * File name for NULL path
336 #define _MMCamcorder_FILENAME_NULL "/dev/null"
339 * Minimum integer value
341 #define _MMCAMCORDER_MIN_INT (INT_MIN)
344 * Maximum integer value
346 #define _MMCAMCORDER_MAX_INT (INT_MAX)
349 * Minimum double value
351 #define _MMCAMCORDER_MIN_DOUBLE (DBL_MIN)
354 * Maximum integer value
356 #define _MMCAMCORDER_MAX_DOUBLE (DBL_MAX)
359 * Audio timestamp margin (msec)
361 #define _MMCAMCORDER_AUDIO_TIME_MARGIN (300)
364 * Functions related with LOCK and WAIT
366 #define _MMCAMCORDER_CAST_MTSAFE(handle) (((mmf_camcorder_t*)handle)->mtsafe)
367 #define _MMCAMCORDER_LOCK_FUNC(mutex) g_mutex_lock(&mutex)
368 #define _MMCAMCORDER_TRYLOCK_FUNC(mutex) g_mutex_trylock(&mutex)
369 #define _MMCAMCORDER_UNLOCK_FUNC(mutex) g_mutex_unlock(&mutex)
371 #define _MMCAMCORDER_GET_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).lock)
372 #define _MMCAMCORDER_LOCK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_LOCK(handle))
373 #define _MMCAMCORDER_TRYLOCK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_LOCK(handle))
374 #define _MMCAMCORDER_UNLOCK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_LOCK(handle))
376 #define _MMCAMCORDER_GET_COND(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).cond)
377 #define _MMCAMCORDER_WAIT(handle) g_cond_wait(&_MMCAMCORDER_GET_COND(handle), &_MMCAMCORDER_GET_LOCK(handle))
378 #define _MMCAMCORDER_WAIT_UNTIL(handle, end_time) g_cond_wait_until(&_MMCAMCORDER_GET_COND(handle), &_MMCAMCORDER_GET_LOCK(handle), end_time)
379 #define _MMCAMCORDER_SIGNAL(handle) g_cond_signal(&_MMCAMCORDER_GET_COND(handle));
380 #define _MMCAMCORDER_BROADCAST(handle) g_cond_broadcast(&_MMCAMCORDER_GET_COND(handle));
383 #define _MMCAMCORDER_GET_CMD_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).cmd_lock)
384 #define _MMCAMCORDER_GET_CMD_COND(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).cmd_cond)
385 #define _MMCAMCORDER_LOCK_CMD(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_CMD_LOCK(handle))
386 #define _MMCAMCORDER_TRYLOCK_CMD(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_CMD_LOCK(handle))
387 #define _MMCAMCORDER_UNLOCK_CMD(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_CMD_LOCK(handle))
388 #define _MMCAMCORDER_CMD_WAIT(handle) g_cond_wait(&_MMCAMCORDER_GET_CMD_COND(handle), &_MMCAMCORDER_GET_CMD_LOCK(handle))
389 #define _MMCAMCORDER_CMD_WAIT_UNTIL(handle, end_time) g_cond_wait_until(&_MMCAMCORDER_GET_CMD_COND(handle), &_MMCAMCORDER_GET_CMD_LOCK(handle), end_time)
390 #define _MMCAMCORDER_CMD_SIGNAL(handle) g_cond_signal(&_MMCAMCORDER_GET_CMD_COND(handle));
392 /* for interruption */
393 #define _MMCAMCORDER_GET_INTERRUPT_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).interrupt_lock)
394 #define _MMCAMCORDER_LOCK_INTERRUPT(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_INTERRUPT_LOCK(handle))
395 #define _MMCAMCORDER_TRYLOCK_INTERRUPT(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_INTERRUPT_LOCK(handle))
396 #define _MMCAMCORDER_UNLOCK_INTERRUPT(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_INTERRUPT_LOCK(handle))
398 /* for state change */
399 #define _MMCAMCORDER_GET_STATE_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).state_lock)
400 #define _MMCAMCORDER_LOCK_STATE(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_STATE_LOCK(handle))
401 #define _MMCAMCORDER_TRYLOCK_STATE(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_STATE_LOCK(handle))
402 #define _MMCAMCORDER_UNLOCK_STATE(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_STATE_LOCK(handle))
404 /* for gstreamer state change */
405 #define _MMCAMCORDER_GET_GST_STATE_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).gst_state_lock)
406 #define _MMCAMCORDER_LOCK_GST_STATE(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_GST_STATE_LOCK(handle))
407 #define _MMCAMCORDER_TRYLOCK_GST_STATE(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_GST_STATE_LOCK(handle))
408 #define _MMCAMCORDER_UNLOCK_GST_STATE(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_GST_STATE_LOCK(handle))
410 #define _MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).gst_encode_state_lock)
411 #define _MMCAMCORDER_LOCK_GST_ENCODE_STATE(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle))
412 #define _MMCAMCORDER_TRYLOCK_GST_ENCODE_STATE(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle))
413 #define _MMCAMCORDER_UNLOCK_GST_ENCODE_STATE(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle))
415 /* for setting/calling callback */
416 #define _MMCAMCORDER_GET_MESSAGE_CALLBACK_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).message_cb_lock)
417 #define _MMCAMCORDER_LOCK_MESSAGE_CALLBACK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_MESSAGE_CALLBACK_LOCK(handle))
418 #define _MMCAMCORDER_TRYLOCK_MESSAGE_CALLBACK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_MESSAGE_CALLBACK_LOCK(handle))
419 #define _MMCAMCORDER_UNLOCK_MESSAGE_CALLBACK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_MESSAGE_CALLBACK_LOCK(handle))
421 #define _MMCAMCORDER_GET_VCAPTURE_CALLBACK_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).vcapture_cb_lock)
422 #define _MMCAMCORDER_LOCK_VCAPTURE_CALLBACK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_VCAPTURE_CALLBACK_LOCK(handle))
423 #define _MMCAMCORDER_TRYLOCK_VCAPTURE_CALLBACK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_VCAPTURE_CALLBACK_LOCK(handle))
424 #define _MMCAMCORDER_UNLOCK_VCAPTURE_CALLBACK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_VCAPTURE_CALLBACK_LOCK(handle))
426 #define _MMCAMCORDER_GET_VSTREAM_CALLBACK_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).vstream_cb_lock)
427 #define _MMCAMCORDER_LOCK_VSTREAM_CALLBACK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_VSTREAM_CALLBACK_LOCK(handle))
428 #define _MMCAMCORDER_TRYLOCK_VSTREAM_CALLBACK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_VSTREAM_CALLBACK_LOCK(handle))
429 #define _MMCAMCORDER_UNLOCK_VSTREAM_CALLBACK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_VSTREAM_CALLBACK_LOCK(handle))
431 #define _MMCAMCORDER_GET_ASTREAM_CALLBACK_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).astream_cb_lock)
432 #define _MMCAMCORDER_LOCK_ASTREAM_CALLBACK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_ASTREAM_CALLBACK_LOCK(handle))
433 #define _MMCAMCORDER_TRYLOCK_ASTREAM_CALLBACK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_ASTREAM_CALLBACK_LOCK(handle))
434 #define _MMCAMCORDER_UNLOCK_ASTREAM_CALLBACK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_ASTREAM_CALLBACK_LOCK(handle))
436 #define _MMCAMCORDER_GET_MSTREAM_CALLBACK_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).mstream_cb_lock)
437 #define _MMCAMCORDER_LOCK_MSTREAM_CALLBACK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_MSTREAM_CALLBACK_LOCK(handle))
438 #define _MMCAMCORDER_TRYLOCK_MSTREAM_CALLBACK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_MSTREAM_CALLBACK_LOCK(handle))
439 #define _MMCAMCORDER_UNLOCK_MSTREAM_CALLBACK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_MSTREAM_CALLBACK_LOCK(handle))
441 #define _MMCAMCORDER_GET_VEDECISION_CALLBACK_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).vedecision_cb_lock)
442 #define _MMCAMCORDER_LOCK_VEDECISION_CALLBACK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_VEDECISION_CALLBACK_LOCK(handle))
443 #define _MMCAMCORDER_TRYLOCK_VEDECISION_CALLBACK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_VEDECISION_CALLBACK_LOCK(handle))
444 #define _MMCAMCORDER_UNLOCK_VEDECISION_CALLBACK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_VEDECISION_CALLBACK_LOCK(handle))
446 #ifdef _MMCAMCORDER_MM_RM_SUPPORT
447 /* for resource conflict */
448 #define _MMCAMCORDER_GET_RESOURCE_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).resource_lock)
449 #define _MMCAMCORDER_LOCK_RESOURCE(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_RESOURCE_LOCK(handle))
450 #define _MMCAMCORDER_UNLOCK_RESOURCE(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_RESOURCE_LOCK(handle))
451 #endif /* _MMCAMCORDER_MM_RM_SUPPORT */
454 * Caster of main handle (camcorder)
456 #define MMF_CAMCORDER(h) (mmf_camcorder_t *)(h)
459 * Caster of subcontext
461 #define MMF_CAMCORDER_SUBCONTEXT(h) (((mmf_camcorder_t *)(h))->sub_context)
463 /* LOCAL CONSTANT DEFINITIONS */
465 * Total Numbers of Attribute values.
466 * If you increase any enum of attribute values, you also have to increase this.
468 #define MM_CAMCORDER_MODE_NUM 3 /**< Number of mode type */
469 #define MM_CAMCORDER_COLOR_TONE_NUM 30 /**< Number of color-tone modes */
470 #define MM_CAMCORDER_WHITE_BALANCE_NUM 10 /**< Number of WhiteBalance modes*/
471 #define MM_CAMCORDER_SCENE_MODE_NUM 16 /**< Number of program-modes */
472 #define MM_CAMCORDER_FOCUS_MODE_NUM 6 /**< Number of focus mode*/
473 #define MM_CAMCORDER_AUTO_FOCUS_NUM 5 /**< Total count of auto focus type*/
474 #define MM_CAMCORDER_FOCUS_STATE_NUM 4 /**< Number of focus state */
475 #define MM_CAMCORDER_ISO_NUM 10 /**< Number of ISO */
476 #define MM_CAMCORDER_AUTO_EXPOSURE_NUM 9 /**< Number of Auto exposure type */
477 #define MM_CAMCORDER_WDR_NUM 3 /**< Number of wide dynamic range */
478 #define MM_CAMCORDER_FLIP_NUM 4 /**< Number of Flip mode */
479 #define MM_CAMCORDER_ROTATION_NUM 4 /**< Number of Rotation mode */
480 #define MM_CAMCORDER_AHS_NUM 4 /**< Number of anti-handshake */
481 #define MM_CAMCORDER_VIDEO_STABILIZATION_NUM 2 /**< Number of video stabilization */
482 #define MM_CAMCORDER_HDR_CAPTURE_NUM 3 /**< Number of HDR capture mode */
483 #define MM_CAMCORDER_GEOMETRY_METHOD_NUM 5 /**< Number of geometry method */
484 #define MM_CAMCORDER_TAG_ORT_NUM 8 /**< Number of tag orientation */
485 #define MM_CAMCORDER_STROBE_MODE_NUM 8 /**< Number of strobe mode type */
486 #define MM_CAMCORDER_STROBE_CONTROL_NUM 3 /**< Number of strobe control type */
487 #define MM_CAMCORDER_DETECT_MODE_NUM 2 /**< Number of detect mode type */
488 #define MM_CAMCORDER_EXTRA_PREVIEW_STREAM_NUM 10 /**< Number of extra preview stream */
490 /*=======================================================================================
492 ========================================================================================*/
494 * Command for Camcorder.
497 /* Command for Video/Audio recording */
498 _MMCamcorder_CMD_RECORD,
499 _MMCamcorder_CMD_PAUSE,
500 _MMCamcorder_CMD_CANCEL,
501 _MMCamcorder_CMD_COMMIT,
503 /* Command for Image capture */
504 _MMCamcorder_CMD_CAPTURE,
506 /* Command for Preview(Video/Image only effective) */
507 _MMCamcorder_CMD_PREVIEW_START,
508 _MMCamcorder_CMD_PREVIEW_STOP,
515 _MMCamcorder_SINGLE_SHOT,
516 _MMCamcorder_MULTI_SHOT,
520 * Enumerations for manual focus direction.
521 * If focusing mode is not "MM_CAMCORDER_AF_MODE_MANUAL", this value will be ignored.
523 enum MMCamcorderMfLensDir {
524 MM_CAMCORDER_MF_LENS_DIR_FORWARD = 1, /**< Focus direction to forward */
525 MM_CAMCORDER_MF_LENS_DIR_BACKWARD, /**< Focus direction to backward */
526 MM_CAMCORDER_MF_LENS_DIR_NUM, /**< Total number of the directions */
530 * Camcorder Pipeline's Element name.
531 * @note index of element.
534 _MMCAMCORDER_NONE = (-1),
536 /* Main Pipeline Element */
537 _MMCAMCORDER_MAIN_PIPE = 0x00,
539 /* Pipeline element of Video input */
540 _MMCAMCORDER_VIDEOSRC_SRC,
541 _MMCAMCORDER_VIDEOSRC_FILT,
542 _MMCAMCORDER_VIDEOSRC_QUE,
543 _MMCAMCORDER_VIDEOSRC_DECODE,
545 /* Pipeline element of image capture */
546 _MMCAMCORDER_VIDEOSRC_CAP_FILT,
547 _MMCAMCORDER_VIDEOSRC_CAP_SINK,
549 /* Pipeline element of Video output */
550 _MMCAMCORDER_VIDEOSINK_QUE,
551 _MMCAMCORDER_VIDEOSINK_CLS,
552 _MMCAMCORDER_VIDEOSINK_SINK,
554 _MMCAMCORDER_PIPELINE_ELEMENT_NUM,
555 } _MMCAMCORDER_PREVIEW_PIPELINE_ELELMENT;
558 * Camcorder Pipeline's Element name.
559 * @note index of element.
562 _MMCAMCORDER_ENCODE_NONE = (-1),
564 /* Main Pipeline Element */
565 _MMCAMCORDER_ENCODE_MAIN_PIPE = 0x00,
567 /* Pipeline element of Audio input */
568 _MMCAMCORDER_AUDIOSRC_BIN,
569 _MMCAMCORDER_AUDIOSRC_SRC,
570 _MMCAMCORDER_AUDIOSRC_FILT,
571 _MMCAMCORDER_AUDIOSRC_QUE,
572 _MMCAMCORDER_AUDIOSRC_CONV,
573 _MMCAMCORDER_AUDIOSRC_VOL,
574 _MMCAMCORDER_AUDIOSRC_RGA, /* for replay gain analysis element */
576 /* Pipeline element of Encodebin */
577 _MMCAMCORDER_ENCSINK_BIN,
578 _MMCAMCORDER_ENCSINK_SRC,
579 _MMCAMCORDER_ENCSINK_FILT,
580 _MMCAMCORDER_ENCSINK_ENCBIN,
581 _MMCAMCORDER_ENCSINK_AQUE,
582 _MMCAMCORDER_ENCSINK_CONV,
583 _MMCAMCORDER_ENCSINK_AENC,
584 _MMCAMCORDER_ENCSINK_AENC_QUE,
585 _MMCAMCORDER_ENCSINK_VQUE,
586 _MMCAMCORDER_ENCSINK_VSCALE,
587 _MMCAMCORDER_ENCSINK_VSCALE_FILT,
588 _MMCAMCORDER_ENCSINK_VCONV,
589 _MMCAMCORDER_ENCSINK_VENC,
590 _MMCAMCORDER_ENCSINK_VENC_QUE,
591 _MMCAMCORDER_ENCSINK_ITOG,
592 _MMCAMCORDER_ENCSINK_ICROP,
593 _MMCAMCORDER_ENCSINK_ISCALE,
594 _MMCAMCORDER_ENCSINK_IFILT,
595 _MMCAMCORDER_ENCSINK_IQUE,
596 _MMCAMCORDER_ENCSINK_IENC,
597 _MMCAMCORDER_ENCSINK_MUX,
598 _MMCAMCORDER_ENCSINK_SINK,
600 _MMCAMCORDER_ENCODE_PIPELINE_ELEMENT_NUM,
601 } _MMCAMCORDER_ENCODE_PIPELINE_ELELMENT;
604 _MMCAMCORDER_TASK_THREAD_STATE_NONE,
605 _MMCAMCORDER_TASK_THREAD_STATE_SOUND_PLAY_START,
606 _MMCAMCORDER_TASK_THREAD_STATE_SOUND_SOLO_PLAY_START,
607 _MMCAMCORDER_TASK_THREAD_STATE_ENCODE_PIPE_CREATE,
608 _MMCAMCORDER_TASK_THREAD_STATE_CHECK_CAPTURE_IN_RECORDING,
609 _MMCAMCORDER_TASK_THREAD_STATE_EXIT,
610 } _MMCamcorderTaskThreadState;
613 * System state change cause
616 _MMCAMCORDER_STATE_CHANGE_NORMAL = 0,
617 _MMCAMCORDER_STATE_CHANGE_BY_RM,
618 _MMCAMCORDER_STATE_CHANGE_BY_DPM,
619 _MMCAMCORDER_STATE_CHANGE_BY_STORAGE
620 } _MMCamcorderStateChange;
623 /*=======================================================================================
624 | STRUCTURE DEFINITIONS |
625 ========================================================================================*/
627 * MMCamcorder Gstreamer Element
630 unsigned int id; /**< Gstreamer pipeline element id */
631 GstElement *gst; /**< Gstreamer element */
632 } _MMCamcorderGstElement;
635 * MMCamcorder information for KPI measurement
638 int current_fps; /**< current fps of this second */
639 int average_fps; /**< average fps */
640 unsigned int video_framecount; /**< total number of video frame */
641 unsigned int last_framecount; /**< total number of video frame in last measurement */
642 struct timeval init_video_time; /**< time when start to measure */
643 struct timeval last_video_time; /**< last measurement time */
644 } _MMCamcorderKPIMeasure;
647 * MMCamcorder information for Multi-Thread Safe
650 GMutex lock; /**< Mutex (for general use) */
651 GCond cond; /**< Condition (for general use) */
652 GMutex cmd_lock; /**< Mutex (for command) */
653 GCond cmd_cond; /**< Condition (for command) */
654 GMutex interrupt_lock; /**< Mutex (for interruption) */
655 GMutex state_lock; /**< Mutex (for state change) */
656 GMutex gst_state_lock; /**< Mutex (for gst pipeline state change) */
657 GMutex gst_encode_state_lock; /**< Mutex (for gst encode pipeline state change) */
658 GMutex message_cb_lock; /**< Mutex (for message callback) */
659 GMutex vcapture_cb_lock; /**< Mutex (for video capture callback) */
660 GMutex vstream_cb_lock; /**< Mutex (for video stream callback) */
661 GMutex astream_cb_lock; /**< Mutex (for audio stream callback) */
662 GMutex mstream_cb_lock; /**< Mutex (for muxed stream callback) */
663 GMutex vedecision_cb_lock; /**< Mutex (for video encode decision callback) */
664 #ifdef _MMCAMCORDER_MM_RM_SUPPORT
665 GMutex resource_lock; /**< Mutex (for resource check) */
666 #endif /* _MMCAMCORDER_MM_RM_SUPPORT */
667 } _MMCamcorderMTSafe;
670 * MMCamcorder Replay gain value
677 } _MMCamcorderReplayGain;
680 * MMCamcorder Extra preview stream format
689 gboolean need_to_set_format;
690 gboolean need_to_set_bitrate;
691 gboolean need_to_set_gop_interval;
692 } _MMCamcorderExtraPreviewStreamFormat;
695 * MMCamcorder Sub Context
698 bool isMaxsizePausing; /**< Because of size limit, pipeline is paused. */
699 bool isMaxtimePausing; /**< Because of time limit, pipeline is paused. */
700 int element_num; /**< count of element */
701 int encode_element_num; /**< count of encode element */
702 int frame_stability_count; /**< camsensor stability count. the count of frame will drop */
703 GstClockTime pipeline_time; /**< current time of Gstreamer Pipeline */
704 GstClockTime pause_time; /**< amount of time while pipeline is in PAUSE state.*/
705 GstClockTime stillshot_time; /**< pipeline time of capturing moment*/
706 gboolean is_modified_rate; /**< whether recording motion rate is modified or not */
707 gboolean ferror_send; /**< file write/seek error **/
708 guint ferror_count; /**< file write/seek error count **/
709 GstClockTime previous_slot_time;
710 int display_interval; /**< This value is set as 'GST_SECOND / display FPS' */
711 gboolean bget_eos; /**< Whether getting EOS */
712 gboolean audio_disable; /**< whether audio is disabled or not when record */
713 int videosrc_rotate; /**< rotate of videosrc */
714 unsigned long long muxed_stream_offset; /**< current offset for muxed stream data */
716 /* For dropping video frame when start recording */
717 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. */
718 int pass_first_vframe; /**< When this value is bigger than zero, MSL won't drop video frame though "drop_vframe" is bigger then zero. */
721 _MMCamcorderReplayGain replay_gain; /**< Replay gain for audio recording */
723 /* INI information */
724 unsigned int fourcc; /**< Get fourcc value of camera INI file */
725 _MMCamcorderImageInfo *info_image; /**< extra information for image capture */
726 _MMCamcorderVideoInfo *info_video; /**< extra information for video recording */
727 _MMCamcorderAudioInfo *info_audio; /**< extra information for audio recording */
729 _MMCamcorderGstElement *element; /**< array of preview element */
730 _MMCamcorderGstElement *encode_element; /**< array of encode element */
731 _MMCamcorderKPIMeasure kpi; /**< information related with performance measurement */
733 type_element *VideosinkElement; /**< configure data of videosink element */
734 type_element *VideoconvertElement; /**< configure data of videoconvert element */
735 type_element *VideodecoderElement; /**< configure data of video decoder element */
736 gboolean SensorEncodedCapture; /**< whether camera sensor support encoded image capture */
737 gboolean internal_encode; /**< whether use internal encoding function */
738 } _MMCamcorderSubContext;
741 * _MMCamcorderContext
743 typedef struct mmf_camcorder {
745 int type; /**< mmcamcorder_mode_type */
746 int device_type; /**< device type */
747 int state; /**< state of camcorder */
748 int old_state; /**< old state of camcorder */
751 MMHandleType attributes; /**< Attribute handle */
752 _MMCamcorderSubContext *sub_context; /**< sub context */
753 mm_exif_info_t *exif_info; /**< EXIF */
754 GList *buffer_probes; /**< a list of buffer probe handle */
755 GList *event_probes; /**< a list of event probe handle */
756 GList *signals; /**< a list of signal handle */
757 #ifdef _MMCAMCORDER_ENABLE_IDLE_MESSAGE_CALLBACK
758 GList *msg_data; /**< a list of msg data */
759 #endif /* _MMCAMCORDER_ENABLE_IDLE_MESSAGE_CALLBACK */
760 camera_conf *conf_main; /**< Camera configure Main structure */
761 camera_conf *conf_ctrl; /**< Camera configure Control structure */
762 #ifdef _MMCAMCORDER_RM_SUPPORT
763 int rm_handle; /**< Resource manager handle */
764 rm_consumer_info rci; /**< Resource consumer info */
765 #endif /* _MMCAMCORDER_RM_SUPPORT */
766 SOUND_INFO snd_info; /**< Sound handle for multishot capture */
768 /* callback handlers */
769 MMMessageCallback msg_cb; /**< message callback */
770 void *msg_cb_param; /**< message callback parameter */
771 mm_camcorder_video_stream_callback vstream_cb; /**< Video stream callback */
772 void *vstream_cb_param; /**< Video stream callback parameter */
773 mm_camcorder_audio_stream_callback astream_cb; /**< Audio stream callback */
774 void *astream_cb_param; /**< Audio stream callback parameter */
775 mm_camcorder_muxed_stream_callback mstream_cb; /**< Muxed stream callback */
776 void *mstream_cb_param; /**< Muxed stream callback parameter */
777 mm_camcorder_video_capture_callback vcapture_cb; /**< Video capture callback */
778 void *vcapture_cb_param; /**< Video capture callback parameter */
779 mm_camcorder_video_encode_decision_callback vedecision_cb; /**< Video encode decision callback */
780 void *vedecision_cb_param; /**< Video encode decision callback parameter */
781 int (*command)(MMHandleType, int); /**< camcorder's command */
784 mm_cam_attr_construct_info *cam_attrs_const_info; /**< attribute info */
785 conf_info_table *conf_main_info_table[CONFIGURE_CATEGORY_MAIN_NUM]; /** configure info table - MAIN category */
786 conf_info_table *conf_ctrl_info_table[CONFIGURE_CATEGORY_CTRL_NUM]; /** configure info table - CONTROL category */
787 int conf_main_category_size[CONFIGURE_CATEGORY_MAIN_NUM]; /** configure info table size - MAIN category */
788 int conf_ctrl_category_size[CONFIGURE_CATEGORY_CTRL_NUM]; /** configure info table size - CONTROL category */
789 _MMCamcorderMTSafe mtsafe; /**< Thread safe */
790 int state_change_by_system; /**< MSL changes its state by itself because of system */
791 GMutex restart_preview_lock; /**< Capture sound mutex */
792 int use_zero_copy_format; /**< Whether use zero copy format for camera input */
793 int use_videoconvert; /**< Whether use videoconvert element for display */
794 int support_media_packet_preview_cb; /**< Whether support zero copy format for camera input */
795 int support_user_buffer; /**< Whether support user allocated buffer for zero copy */
796 int capture_mode; /**< Capture mode */
797 int shutter_sound_policy; /**< shutter sound policy */
798 int brightness_default; /**< default value of brightness */
799 int brightness_step_denominator; /**< denominator of brightness bias step */
800 int support_zsl_capture; /**< support Zero Shutter Lag capture */
801 char *model_name; /**< model name from system info */
802 char *software_version; /**< software_version from system info */
803 int capture_sound_count; /**< count for capture sound */
804 char *root_directory; /**< Root directory for device */
805 int resolution_changed; /**< Flag for preview resolution change */
806 int interrupt_code; /**< Interrupt code */
807 int recreate_decoder; /**< Flag of decoder element recreation for encoded preview format */
808 gboolean is_network; /**< Flag for network camera */
809 const char *network_hal_name; /**< Name of network camera HAL library */
810 int default_encoded_preview_bitrate; /**< Default bitrate for encoded preview */
812 _MMCamcorderInfoConverting caminfo_convert[CAMINFO_CONVERT_NUM]; /**< converting structure of camera info */
813 _MMCamcorderEnumConvert enum_conv[ENUM_CONVERT_NUM]; /**< enum converting list that is modified by ini info */
815 gboolean capture_in_recording; /**< Flag for capture while recording */
817 gboolean error_occurs; /**< flag for error */
818 int error_code; /**< error code for internal gstreamer error */
821 GThread *task_thread; /**< thread for task */
822 GMutex task_thread_lock; /**< mutex for task thread */
823 GCond task_thread_cond; /**< cond for task thread */
824 _MMCamcorderTaskThreadState task_thread_state; /**< state of task thread */
826 #ifdef _MMCAMCORDER_MM_RM_SUPPORT
827 /* resource manager for H/W resources */
828 mm_resource_manager_h resource_manager;
829 mm_resource_manager_res_h camera_resource;
830 mm_resource_manager_res_h video_overlay_resource;
831 mm_resource_manager_res_h video_encoder_resource;
832 gboolean is_release_cb_calling;
833 #endif /* _MMCAMCORDER_MM_RM_SUPPORT */
836 GDBusConnection *gdbus_conn; /**< gdbus connection */
837 _MMCamcorderGDbusCbInfo gdbus_info_sound; /**< Information for the gdbus cb of sound play */
838 _MMCamcorderGDbusCbInfo gdbus_info_solo_sound; /**< Information for the gdbus cb of solo sound play */
840 /* DPM(device policy manager) */
841 device_policy_manager_h dpm_handle; /**< DPM handle */
842 int dpm_camera_cb_id; /**< DPM camera policy changed callback id */
845 _MMCamcorderStorageInfo storage_info; /**< Storage information */
847 #ifdef _MMCAMCORDER_RM_SUPPORT
848 rm_category_request_s request_resources;
849 rm_device_return_s returned_devices;
850 #endif /* _MMCAMCORDER_RM_SUPPORT */
851 #ifdef _MMCAMCORDER_CAMERA_CONF_MGR_SUPPORT
852 camera_conf_device_info_s conf_device_info;
853 #endif /*_MMCAMCORDER_CAMERA_CONF_MGR_SUPPORT */
856 int measure_preview_fps; /**< Flag for measuring fps of preview frames */
859 int support_extra_preview;
860 _MMCamcorderExtraPreviewStreamFormat extra_preview_format[MM_CAMCORDER_EXTRA_PREVIEW_STREAM_NUM];
862 GQuark buffer_quark; /**< Quark for buffer */
864 int reserved[4]; /**< reserved */
867 /*=======================================================================================
868 | EXTERN GLOBAL VARIABLE |
869 ========================================================================================*/
871 /*=======================================================================================
872 | GLOBAL FUNCTION PROTOTYPES |
873 ========================================================================================*/
875 * This function creates camcorder for capturing still image and recording.
877 * @param[out] handle Specifies the camcorder handle
878 * @param[in] info Preset information of camcorder
879 * @return This function returns zero on success, or negative value with error code.
880 * @remarks When this function calls successfully, camcorder handle will be filled with a @n
881 * valid value and the state of the camcorder will become MM_CAMCORDER_STATE_NULL.@n
882 * Note that it's not ready to working camcorder. @n
883 * You should call mmcamcorder_realize before starting camcorder.
884 * @see _mmcamcorder_create
886 int _mmcamcorder_create(MMHandleType *handle, MMCamPreset *info);
889 * This function destroys instance of camcorder.
891 * @param[in] hcamcorder Specifies the camcorder handle
892 * @return This function returns zero on success, or negative value with error code.
893 * @see _mmcamcorder_create
895 int _mmcamcorder_destroy(MMHandleType hcamcorder);
898 * This function allocates memory for camcorder.
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 MM_CAMCORDER_STATE_NULL @n
903 * and the state of the camcorder will become MM_CAMCORDER_STATE_READY. @n
904 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
905 * @see _mmcamcorder_unrealize
906 * @pre MM_CAMCORDER_STATE_NULL
907 * @post MM_CAMCORDER_STATE_READY
909 int _mmcamcorder_realize(MMHandleType hcamcorder);
912 * This function free allocated memory for camcorder.
914 * @param[in] hcamcorder Specifies the camcorder handle
915 * @return This function returns zero on success, or negative value with error code.
916 * @remarks This function release all resources which are allocated for the camcorder engine.@n
917 * This function can be called successfully when current state is MM_CAMCORDER_STATE_READY and @n
918 * the state of the camcorder will become MM_CAMCORDER_STATE_NULL. @n
919 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
920 * @see _mmcamcorder_realize
921 * @pre MM_CAMCORDER_STATE_READY
922 * @post MM_CAMCORDER_STATE_NULL
924 int _mmcamcorder_unrealize(MMHandleType hcamcorder);
927 * This function is to start previewing.
929 * @param[in] hcamcorder Specifies the camcorder handle
930 * @return This function returns zero on success, or negative value with error code.
931 * @remarks This function can be called successfully when current state is MM_CAMCORDER_STATE_READY 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_stop
936 int _mmcamcorder_start(MMHandleType hcamcorder);
939 * This function is to stop previewing.
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 MM_CAMCORDER_STATE_PREPARE and @n
944 * the state of the camcorder will become MM_CAMCORDER_STATE_READY.@n
945 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
946 * @see _mmcamcorder_start
948 int _mmcamcorder_stop(MMHandleType hcamcorder);
951 * This function to start capturing of still images.
953 * @param[in] hcamcorder Specifies the camcorder handle.
954 * @return This function returns zero on success, or negative value with error code.
955 * @remarks This function can be called successfully when current state is MM_CAMCORDER_STATE_PREPARE and @n
956 * the state of the camcorder will become MM_CAMCORDER_STATE_CAPTURING. @n
957 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
958 * @see _mmcamcorder_capture_stop
960 int _mmcamcorder_capture_start(MMHandleType hcamcorder);
963 * This function is to stop capturing still images.
965 * @param[in] hcamcorder Specifies the camcorder handle
966 * @return This function returns zero on success, or negative value with error code.
967 * @remarks This function can be called successfully when current state is MM_CAMCORDER_STATE_CAPTURING and @n
968 * the state of the camcorder will become MM_CAMCORDER_STATE_PREPARE. @n
969 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
970 * @see _mmcamcorder_capture_start
972 int _mmcamcorder_capture_stop(MMHandleType hcamcorder);
975 * This function is to start video and audio recording.
977 * @param[in] hcamcorder Specifies the camcorder handle
978 * @return This function returns zero on success, or negative value with error code.
979 * @remarks This function can be called successfully when current state is @n
980 * MM_CAMCORDER_STATE_PREPARE or MM_CAMCORDER_STATE_PAUSED and @n
981 * the state of the camcorder will become MM_CAMCORDER_STATE_RECORDING.@n
982 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
983 * @see _mmcamcorder_pause
985 int _mmcamcorder_record(MMHandleType hcamcorder);
988 * This function is to pause video and audio recording
990 * @param[in] hcamcorder Specifies the camcorder handle
991 * @return This function returns zero on success, or negative value with error code.
992 * @remarks This function can be called successfully when current state is MM_CAMCORDER_STATE_RECORDING and @n
993 * the state of the camcorder will become MM_CAMCORDER_STATE_PAUSED.@n
994 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.@n
995 * @see _mmcamcorder_record
997 int _mmcamcorder_pause(MMHandleType hcamcorder);
1000 * This function is to stop video and audio recording and save results.
1002 * @param[in] hcamcorder Specifies the camcorder handle
1003 * @return This function returns zero on success, or negative value with error code.
1004 * @remarks This function can be called successfully when current state is @n
1005 * MM_CAMCORDER_STATE_PAUSED or MM_CAMCORDER_STATE_RECORDING and @n
1006 * the state of the camcorder will become MM_CAMCORDER_STATE_PREPARE. @n
1007 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION
1008 * @see _mmcamcorder_cancel
1010 int _mmcamcorder_commit(MMHandleType hcamcorder);
1013 * This function is to stop video and audio recording and do not save results.
1015 * @param[in] hcamcorder Specifies the camcorder handle
1016 * @return This function returns zero on success, or negative value with error code.
1017 * @remarks This function can be called successfully when current state is @n
1018 * MM_CAMCORDER_STATE_PAUSED or MM_CAMCORDER_STATE_RECORDING and @n
1019 * the state of the camcorder will become MM_CAMCORDER_STATE_PREPARE. @n
1020 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
1021 * @see _mmcamcorder_commit
1023 int _mmcamcorder_cancel(MMHandleType hcamcorder);
1026 * This function calls after committing action finished asynchronously.
1027 * In this function, remaining process , such as state change, happens.
1029 * @param[in] hcamcorder Specifies the camcorder handle
1030 * @return This function returns zero on success, or negative value with error code.
1031 * @remarks This function can be called successfully when current state is @n
1032 * MM_CAMCORDER_STATE_PAUSED or MM_CAMCORDER_STATE_RECORDING and @n
1033 * the state of the camcorder will become MM_CAMCORDER_STATE_PREPARE. @n
1034 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
1035 * @see _mmcamcorder_commit
1037 int _mmcamcorder_commit_async_end(MMHandleType hcamcorder);
1040 * This function is to set callback for receiving messages from camcorder.
1042 * @param[in] hcamcorder Specifies the camcorder handle
1043 * @param[in] callback Specifies the function pointer of callback function
1044 * @param[in] user_data Specifies the user pointer for passing to callback function
1046 * @return This function returns zero on success, or negative value with error code.
1047 * @remarks typedef bool (*mm_message_callback) (int msg, mm_messageType *param, void *user_param);@n
1062 * } mm_message_type; @n
1064 * If a message value for mm_message_callback is MM_MESSAGE_STATE_CHANGED, @n
1065 * state value in mm_message_type will be a mmcamcorder_state_type enum value;@n
1067 * If a message value for mm_message_callback is MM_MESSAGE_ERROR, @n
1068 * the code value in mm_message_type will be a mmplayer_error_type enum value;
1070 * @see mm_message_type, mmcamcorder_state_type, mmcamcorder_error_type
1072 int _mmcamcorder_set_message_callback(MMHandleType hcamcorder,
1073 MMMessageCallback callback,
1077 * This function is to set callback for video stream.
1079 * @param[in] hcamcorder Specifies the camcorder handle
1080 * @param[in] callback Specifies the function pointer of callback function
1081 * @param[in] user_data Specifies the user pointer for passing to callback function
1083 * @return This function returns zero on success, or negative value with error code.
1084 * @see mmcamcorder_error_type
1086 int _mmcamcorder_set_video_stream_callback(MMHandleType hcamcorder,
1087 mm_camcorder_video_stream_callback callback,
1091 * This function is to set callback for audio stream.
1093 * @param[in] hcamcorder Specifies the camcorder handle
1094 * @param[in] callback Specifies the function pointer of callback function
1095 * @param[in] user_data Specifies the user pointer for passing to callback function
1097 * @return This function returns zero on success, or negative value with error code.
1098 * @see mmcamcorder_error_type
1100 int _mmcamcorder_set_audio_stream_callback(MMHandleType handle,
1101 mm_camcorder_audio_stream_callback callback,
1105 * This function is to set callback for muxed stream.
1107 * @param[in] hcamcorder Specifies the camcorder handle
1108 * @param[in] callback Specifies the function pointer of callback function
1109 * @param[in] user_data Specifies the user pointer for passing to callback function
1111 * @return This function returns zero on success, or negative value with error code.
1112 * @see mmcamcorder_error_type
1114 int _mmcamcorder_set_muxed_stream_callback(MMHandleType handle,
1115 mm_camcorder_muxed_stream_callback callback,
1119 * This function is to set callback for video capture.
1121 * @param[in] hcamcorder Specifies the camcorder handle
1122 * @param[in] callback Specifies the function pointer of callback function
1123 * @param[in] user_data Specifies the user pointer for passing to callback function
1125 * @return This function returns zero on success, or negative value with error code.
1126 * @see mmcamcorder_error_type
1128 int _mmcamcorder_set_video_capture_callback(MMHandleType hcamcorder,
1129 mm_camcorder_video_capture_callback callback,
1133 * This function is to set callback for video encode decision.
1135 * @param[in] hcamcorder Specifies the camcorder handle
1136 * @param[in] callback Specifies the function pointer of callback function
1137 * @param[in] user_data Specifies the user pointer for passing to callback function
1139 * @return This function returns zero on success, or negative value with error code.
1141 int _mmcamcorder_set_video_encode_decision_callback(MMHandleType hcamcorder,
1142 mm_camcorder_video_encode_decision_callback callback,
1146 * This function returns current state of camcorder, or negative value with error code.
1148 * @param[in] hcamcorder Specifies the camcorder handle.
1149 * @return This function returns current state of camcorder, or negative value with error code.
1150 * @see mmcamcorder_state_type
1152 int _mmcamcorder_get_current_state(MMHandleType hcamcorder);
1154 int _mmcamcorder_init_focusing(MMHandleType handle);
1155 int _mmcamcorder_adjust_focus(MMHandleType handle, int direction);
1156 int _mmcamcorder_adjust_manual_focus(MMHandleType handle, int direction);
1157 int _mmcamcorder_adjust_auto_focus(MMHandleType handle);
1158 int _mmcamcorder_stop_focusing(MMHandleType handle);
1161 * This function gets current state of camcorder.
1164 * @return This function returns state of current camcorder context
1166 * @see _mmcamcorder_set_state()
1169 int _mmcamcorder_streamer_init(void);
1172 * This function gets current state of camcorder.
1175 * @return This function returns state of current camcorder context
1177 * @see _mmcamcorder_set_state()
1180 int _mmcamcorder_display_init(void);
1183 * This function gets current state of camcorder.
1185 * @param[in] handle Handle of camcorder context.
1186 * @return This function returns state of current camcorder context
1188 * @see _mmcamcorder_set_state()
1191 int _mmcamcorder_get_state(MMHandleType handle);
1192 int _mmcamcorder_get_state2(MMHandleType handle, int *state, int *old_state);
1195 * This function sets new state of camcorder.
1197 * @param[in] handle Handle of camcorder context.
1198 * @param[in] state setting state value of camcorder.
1201 * @see _mmcamcorder_get_state()
1204 void _mmcamcorder_set_state(MMHandleType handle, int state);
1207 * This function allocates structure of subsidiary attributes.
1209 * @param[in] type Allocation type of camcorder context.
1210 * @return This function returns structure pointer on success, NULL value on failure.
1212 * @see _mmcamcorder_dealloc_subcontext()
1215 _MMCamcorderSubContext *_mmcamcorder_alloc_subcontext(int type);
1218 * This function releases structure of subsidiary attributes.
1220 * @param[in] sc Handle of camcorder subcontext.
1223 * @see _mmcamcorder_alloc_subcontext()
1226 void _mmcamcorder_dealloc_subcontext(_MMCamcorderSubContext *sc);
1229 * This function sets command function according to the type.
1231 * @param[in] handle Handle of camcorder context.
1232 * @param[in] type Allocation type of camcorder context.
1233 * @return This function returns MM_ERROR_NONE on success, or other values with error code.
1235 * @see __mmcamcorder_video_command(), __mmcamcorder_audio_command(), __mmcamcorder_image_command()
1238 int _mmcamcorder_set_functions(MMHandleType handle, int type);
1241 * This function is callback function of main pipeline.
1242 * Once this function is registered with certain pipeline using gst_bus_add_watch(),
1243 * this callback will be called every time when there is upcoming message from pipeline.
1244 * Basically, this function is used as error handling function, now.
1246 * @param[in] bus pointer of buf that called this function.
1247 * @param[in] message callback message from pipeline.
1248 * @param[in] data user data.
1249 * @return This function returns true on success, or false value with error
1251 * @see __mmcamcorder_create_preview_pipeline()
1254 gboolean _mmcamcorder_pipeline_cb_message(GstBus *bus, GstMessage *message, gpointer data);
1257 * This function is callback function of main pipeline.
1258 * Once this function is registered with certain pipeline using gst_bus_set_sync_handler(),
1259 * this callback will be called every time when there is upcoming message from pipeline.
1260 * Basically, this function is used as sync error handling function, now.
1262 * @param[in] bus pointer of buf that called this function.
1263 * @param[in] message callback message from pipeline.
1264 * @param[in] data user data.
1265 * @return This function returns true on success, or false value with error
1267 * @see __mmcamcorder_create_preview_pipeline()
1270 GstBusSyncReply _mmcamcorder_pipeline_bus_sync_callback(GstBus *bus, GstMessage *message, gpointer data);
1273 * This function is callback function of encode pipeline.
1274 * Once this function is registered with certain pipeline using gst_bus_set_sync_handler(),
1275 * this callback will be called every time when there is upcoming message from pipeline.
1276 * Basically, this function is used for EOS and error handling now.
1278 * @param[in] bus pointer of buf that called this function.
1279 * @param[in] message callback message from pipeline.
1280 * @param[in] data user data.
1281 * @return This function returns true on success, or false value with error
1283 * @see __mmcamcorder_create_recorder_pipeline()
1284 * @see __mmcamcorder_create_audiop_with_encodebin()
1287 GstBusSyncReply _mmcamcorder_encode_pipeline_bus_sync_callback(GstBus *bus, GstMessage *message, gpointer data);
1290 * This function create main pipeline according to type.
1292 * @param[in] handle Handle of camcorder context.
1293 * @param[in] type Allocation type of camcorder context.
1294 * @return This function returns zero on success, or negative value with error code.
1296 * @see _mmcamcorder_destroy_pipeline()
1299 int _mmcamcorder_create_pipeline(MMHandleType handle, int type);
1302 * This function release all element of main pipeline according to type.
1304 * @param[in] handle Handle of camcorder context.
1305 * @param[in] type Allocation type of camcorder context.
1308 * @see _mmcamcorder_create_pipeline()
1311 void _mmcamcorder_destroy_pipeline(MMHandleType handle, int type);
1314 * This function sets gstreamer element status.
1315 * If the gstreamer fails to set status or returns asynchronous mode,
1316 * this function waits for state changed until timeout expired.
1318 * @param[in] pipeline Pointer of pipeline
1319 * @param[in] target_state newly setting status
1320 * @return This function returns zero on success, or negative value with error code.
1325 int _mmcamcorder_gst_set_state(MMHandleType handle, GstElement *pipeline, GstState target_state);
1328 /* For xvimagesink */
1329 GstBusSyncReply __mmcamcorder_sync_callback(GstBus *bus, GstMessage *message, gulong data);
1331 /* For querying capabilities */
1332 int _mmcamcorder_read_vidsrc_info(int videodevidx, camera_conf **configure_info);
1334 /* for performance check */
1335 void _mmcamcorder_video_current_framerate_init(MMHandleType handle);
1336 int _mmcamcorder_video_current_framerate(MMHandleType handle);
1337 int _mmcamcorder_video_average_framerate(MMHandleType handle);
1339 /* for stopping forcedly */
1340 void __mmcamcorder_force_stop(mmf_camcorder_t *hcamcorder, int state_change_by_system);
1342 /* device policy manager */
1343 void _mmcamcorder_dpm_camera_policy_changed_cb(const char *name, const char *value, void *user_data);
1345 /* Emit dbus signal */
1346 void _mmcamcorder_emit_signal(MMHandleType handle, const char *object_name,
1347 const char *interface_name, const char *signal_name, int value);
1349 /* external storage state management */
1350 int _mmcamcorder_manage_external_storage_state(MMHandleType handle, int storage_state);
1352 /* get focus level */
1353 int _mmcamcorder_get_focus_level(MMHandleType handle, int *level);
1359 #endif /* __MM_CAMCORDER_INTERNAL_H__ */