4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jeongmo Yang <jm80.yang@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 #ifndef __MM_CAMCORDER_INTERNAL_H__
23 #define __MM_CAMCORDER_INTERNAL_H__
25 /*=======================================================================================
27 ========================================================================================*/
31 #include <semaphore.h>
35 #include <mm_attrs_private.h>
36 #include <mm_message.h>
37 #include <mm_session.h>
38 #include <mm_session_private.h>
39 #include <mm_sound_focus.h>
41 #include <gst/video/video-format.h>
44 #include <restriction.h> /* device policy manager */
47 #include "mm_camcorder.h"
49 #ifdef _MMCAMCORDER_MURPHY_SUPPORT
50 #include "mm_camcorder_resource.h"
51 #endif /* _MMCAMCORDER_MURPHY_SUPPORT */
53 /* camcorder sub module */
54 #include "mm_camcorder_attribute.h"
55 #include "mm_camcorder_platform.h"
56 #include "mm_camcorder_stillshot.h"
57 #include "mm_camcorder_videorec.h"
58 #include "mm_camcorder_audiorec.h"
59 #include "mm_camcorder_gstcommon.h"
60 #include "mm_camcorder_exifinfo.h"
61 #include "mm_camcorder_util.h"
62 #include "mm_camcorder_configure.h"
63 #include "mm_camcorder_sound.h"
65 #ifdef _MMCAMCORDER_RM_SUPPORT
66 /* rm (resource manager)*/
68 #endif /* _MMCAMCORDER_RM_SUPPORT */
73 #define LOG_TAG "MM_CAMCORDER"
79 /*=======================================================================================
81 ========================================================================================*/
82 #define _mmcam_dbg_verb(fmt, args...) SLOGI(fmt, ##args);
83 #define _mmcam_dbg_log(fmt, args...) SLOGD(fmt, ##args);
84 #define _mmcam_dbg_warn(fmt, args...) SLOGW(fmt, ##args);
85 #define _mmcam_dbg_err(fmt, args...) SLOGE(fmt, ##args);
86 #define _mmcam_dbg_crit(fmt, args...) SLOGF(fmt, ##args);
89 * Macro for checking validity and debugging
91 #define mmf_return_if_fail(expr) \
93 _mmcam_dbg_err("failed [%s]", #expr); \
98 * Macro for checking validity and debugging
100 #define mmf_return_val_if_fail(expr, val) \
102 _mmcam_dbg_err("failed [%s]", #expr); \
109 * Macro for getting array size
111 #define ARRAY_SIZE(a) (sizeof((a)) / sizeof((a)[0]))
114 /* gstreamer element creation macro */
115 #define _MMCAMCORDER_PIPELINE_MAKE(sub_context, element, eid, name /*char* */, err) \
116 if (element[eid].gst != NULL) { \
117 _mmcam_dbg_err("The element(Pipeline) is existed. element_id=[%d], name=[%s]", eid, name); \
118 gst_object_unref(element[eid].gst); \
120 element[eid].id = eid; \
121 element[eid].gst = gst_pipeline_new(name); \
122 if (element[eid].gst == NULL) { \
123 _mmcam_dbg_err("Pipeline creation fail. element_id=[%d], name=[%s]", eid, name); \
124 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
125 goto pipeline_creation_error; \
127 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
130 #define _MMCAMCORDER_BIN_MAKE(sub_context, element, eid, name /*char* */, err) \
131 if (element[eid].gst != NULL) { \
132 _mmcam_dbg_err("The element(Bin) is existed. element_id=[%d], name=[%s]", eid, name); \
133 gst_object_unref(element[eid].gst); \
135 element[eid].id = eid; \
136 element[eid].gst = gst_bin_new(name); \
137 if (element[eid].gst == NULL) { \
138 _mmcam_dbg_err("Bin creation fail. element_id=[%d], name=[%s]\n", eid, name); \
139 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
140 goto pipeline_creation_error; \
142 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
145 #define _MMCAMCORDER_ELEMENT_MAKE(sub_context, element, eid, name /*char* */, nickname /*char* */, elist, err) \
146 if (element[eid].gst != NULL) { \
147 _mmcam_dbg_err("The element is existed. element_id=[%d], name=[%s]", eid, name); \
148 gst_object_unref(element[eid].gst); \
150 traceBegin(TTRACE_TAG_CAMERA, "MMCAMCORDER:ELEMENT_MAKE:%s", name); \
151 element[eid].gst = gst_element_factory_make(name, nickname); \
152 traceEnd(TTRACE_TAG_CAMERA); \
153 if (element[eid].gst == NULL) { \
154 _mmcam_dbg_err("Element creation fail. element_id=[%d], name=[%s]", eid, name); \
155 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
156 goto pipeline_creation_error; \
158 _mmcam_dbg_log("Element creation done. element_id=[%d], name=[%s]", eid, name); \
159 element[eid].id = eid; \
160 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
161 err = MM_ERROR_NONE; \
163 elist = g_list_append(elist, &(element[eid]));
165 #define _MMCAMCORDER_ELEMENT_MAKE2(sub_context, element, eid, name /*char* */, nickname /*char* */, err) \
166 if (element[eid].gst != NULL) { \
167 _mmcam_dbg_err("The element is existed. element_id=[%d], name=[%s]", eid, name); \
168 gst_object_unref(element[eid].gst); \
170 element[eid].gst = gst_element_factory_make(name, nickname); \
171 if (element[eid].gst == NULL) { \
172 _mmcam_dbg_err("Element creation fail. element_id=[%d], name=[%s]", eid, name); \
173 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
175 _mmcam_dbg_log("Element creation done. element_id=[%d], name=[%s]", eid, name); \
176 element[eid].id = eid; \
177 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
178 err = MM_ERROR_NONE; \
181 #define _MMCAMCORDER_ELEMENT_MAKE_IGNORE_ERROR(sub_context, element, eid, name /*char* */, nickname /*char* */, elist) \
182 if (element[eid].gst != NULL) { \
183 _mmcam_dbg_err("The element is existed. element_id=[%d], name=[%s]", eid, name); \
184 gst_object_unref(element[eid].gst); \
186 element[eid].gst = gst_element_factory_make(name, nickname); \
187 if (element[eid].gst == NULL) { \
188 _mmcam_dbg_err("Element creation fail. element_id=[%d], name=[%s], but keep going...", eid, name); \
190 _mmcam_dbg_log("Element creation done. element_id=[%d], name=[%s]", eid, name); \
191 element[eid].id = eid; \
192 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
193 elist = g_list_append(elist, &(element[eid])); \
196 #define _MMCAMCORDER_ELEMENT_ADD(sub_context, element, eid, gst_element, elist, err) \
197 if (element[eid].gst != NULL) { \
198 _mmcam_dbg_err("The element is existed. element_id=[%d]", eid); \
199 gst_object_unref(element[eid].gst); \
201 element[eid].gst = gst_element; \
202 if (element[eid].gst == NULL) { \
203 _mmcam_dbg_err("Element is NULL. element_id=[%d]", eid); \
204 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
205 goto pipeline_creation_error; \
207 _mmcam_dbg_log("Adding Element is done. element_id=[%d] %p", eid, gst_element); \
208 element[eid].id = eid; \
209 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
210 err = MM_ERROR_NONE; \
212 elist = g_list_append(elist, &(element[eid]));
214 #define _MMCAMCORDER_ENCODEBIN_ELMGET(sub_context, eid, name /*char* */, err) \
215 if (sub_context->encode_element[eid].gst != NULL) { \
216 _mmcam_dbg_err("The element is existed. element_id=[%d], name=[%s]", eid, name); \
217 gst_object_unref(sub_context->encode_element[eid].gst); \
219 sub_context->encode_element[eid].id = eid; \
220 g_object_get(G_OBJECT(sub_context->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst), name, &(sub_context->encode_element[eid].gst), NULL); \
221 if (sub_context->encode_element[eid].gst == NULL) { \
222 _mmcam_dbg_err("Encode Element get fail. element_id=[%d], name=[%s]", eid, name); \
223 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
224 goto pipeline_creation_error; \
226 gst_object_unref(sub_context->encode_element[eid].gst); \
227 g_object_weak_ref(G_OBJECT(sub_context->encode_element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
230 /* GStreamer element remove macro */
231 #define _MMCAMCORDER_ELEMENT_REMOVE(element, eid) \
232 if (element[eid].gst != NULL) { \
233 gst_object_unref(element[eid].gst); \
236 #define _MM_GST_ELEMENT_LINK_MANY gst_element_link_many
237 #define _MM_GST_ELEMENT_LINK gst_element_link
238 #define _MM_GST_ELEMENT_LINK_FILTERED gst_element_link_filtered
239 #define _MM_GST_ELEMENT_UNLINK gst_element_unlink
240 #define _MM_GST_PAD_LINK gst_pad_link
242 #define _MM_GST_PAD_LINK_UNREF(srcpad, sinkpad, err, if_fail_goto) \
244 GstPadLinkReturn ret = GST_PAD_LINK_OK; \
245 if (srcpad == NULL || sinkpad == NULL) { \
246 if (srcpad == NULL) { \
247 _mmcam_dbg_err("srcpad is NULL"); \
249 gst_object_unref(srcpad);\
252 if (sinkpad == NULL) { \
253 _mmcam_dbg_err("sinkpad is NULL"); \
255 gst_object_unref(sinkpad); \
258 err = MM_ERROR_CAMCORDER_GST_LINK; \
261 ret = _MM_GST_PAD_LINK(srcpad, sinkpad); \
262 if (ret != GST_PAD_LINK_OK) { \
263 GstObject *src_parent = gst_pad_get_parent(srcpad); \
264 GstObject *sink_parent = gst_pad_get_parent(sinkpad); \
265 char *src_name = NULL; \
266 char *sink_name = NULL; \
267 g_object_get((GObject *)src_parent, "name", &src_name, NULL); \
268 g_object_get((GObject *)sink_parent, "name", &sink_name, NULL); \
269 _mmcam_dbg_err("src[%s] - sink[%s] link failed", src_name, sink_name); \
270 gst_object_unref(src_parent); src_parent = NULL; \
271 gst_object_unref(sink_parent); sink_parent = NULL; \
273 free(src_name); src_name = NULL; \
276 free(sink_name); sink_name = NULL; \
278 gst_object_unref(srcpad); srcpad = NULL; \
279 gst_object_unref(sinkpad); sinkpad = NULL; \
280 err = MM_ERROR_CAMCORDER_GST_LINK; \
283 gst_object_unref(srcpad); srcpad = NULL; \
284 gst_object_unref(sinkpad); sinkpad = NULL; \
287 #define _MM_GST_PAD_UNLINK_UNREF(srcpad, sinkpad) \
288 if (srcpad && sinkpad) { \
289 gst_pad_unlink(srcpad, sinkpad); \
291 _mmcam_dbg_warn("some pad(srcpad:%p,sinkpad:%p) is NULL", srcpad, sinkpad); \
294 gst_object_unref(srcpad); srcpad = NULL; \
297 gst_object_unref(sinkpad); sinkpad = NULL; \
300 #define _MMCAMCORDER_STATE_SET_COUNT 3 /* checking interval */
301 #define _MMCAMCORDER_STATE_CHECK_TOTALTIME 5000000L /* total wating time for state change */
302 #define _MMCAMCORDER_STATE_CHECK_INTERVAL (50*1000) /* checking interval - 50ms*/
305 * Default videosink type
307 #define _MMCAMCORDER_DEFAULT_VIDEOSINK_TYPE "VideosinkElementOverlay"
310 * Default recording motion rate
312 #define _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE 1.0
315 * Total level count of manual focus */
316 #define _MMFCAMCORDER_FOCUS_TOTAL_LEVEL 8
319 * File name length limit
321 #define _MMCamcorder_FILENAME_LEN (512)
324 * File name for NULL path
326 #define _MMCamcorder_FILENAME_NULL "/dev/null"
329 * Minimum integer value
331 #define _MMCAMCORDER_MIN_INT (INT_MIN)
334 * Maximum integer value
336 #define _MMCAMCORDER_MAX_INT (INT_MAX)
339 * Minimum double value
341 #define _MMCAMCORDER_MIN_DOUBLE (DBL_MIN)
344 * Maximum integer value
346 #define _MMCAMCORDER_MAX_DOUBLE (DBL_MAX)
349 * Audio timestamp margin (msec)
351 #define _MMCAMCORDER_AUDIO_TIME_MARGIN (300)
354 * Functions related with LOCK and WAIT
356 #define _MMCAMCORDER_CAST_MTSAFE(handle) (((mmf_camcorder_t*)handle)->mtsafe)
357 #define _MMCAMCORDER_LOCK_FUNC(mutex) g_mutex_lock(&mutex)
358 #define _MMCAMCORDER_TRYLOCK_FUNC(mutex) g_mutex_trylock(&mutex)
359 #define _MMCAMCORDER_UNLOCK_FUNC(mutex) g_mutex_unlock(&mutex)
361 #define _MMCAMCORDER_GET_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).lock)
362 #define _MMCAMCORDER_LOCK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_LOCK(handle))
363 #define _MMCAMCORDER_TRYLOCK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_LOCK(handle))
364 #define _MMCAMCORDER_UNLOCK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_LOCK(handle))
366 #define _MMCAMCORDER_GET_COND(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).cond)
367 #define _MMCAMCORDER_WAIT(handle) g_cond_wait(&_MMCAMCORDER_GET_COND(handle), &_MMCAMCORDER_GET_LOCK(handle))
368 #define _MMCAMCORDER_WAIT_UNTIL(handle, end_time) g_cond_wait_until(&_MMCAMCORDER_GET_COND(handle), &_MMCAMCORDER_GET_LOCK(handle), end_time)
369 #define _MMCAMCORDER_SIGNAL(handle) g_cond_signal(&_MMCAMCORDER_GET_COND(handle));
370 #define _MMCAMCORDER_BROADCAST(handle) g_cond_broadcast(&_MMCAMCORDER_GET_COND(handle));
373 #define _MMCAMCORDER_GET_CMD_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).cmd_lock)
374 #define _MMCAMCORDER_GET_CMD_COND(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).cmd_cond)
375 #define _MMCAMCORDER_LOCK_CMD(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_CMD_LOCK(handle))
376 #define _MMCAMCORDER_TRYLOCK_CMD(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_CMD_LOCK(handle))
377 #define _MMCAMCORDER_UNLOCK_CMD(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_CMD_LOCK(handle))
378 #define _MMCAMCORDER_CMD_WAIT(handle) g_cond_wait(&_MMCAMCORDER_GET_CMD_COND(handle), &_MMCAMCORDER_GET_CMD_LOCK(handle))
379 #define _MMCAMCORDER_CMD_WAIT_UNTIL(handle, end_time) g_cond_wait_until(&_MMCAMCORDER_GET_CMD_COND(handle), &_MMCAMCORDER_GET_CMD_LOCK(handle), end_time)
380 #define _MMCAMCORDER_CMD_SIGNAL(handle) g_cond_signal(&_MMCAMCORDER_GET_CMD_COND(handle));
383 #define _MMCAMCORDER_GET_ASM_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).asm_lock)
384 #define _MMCAMCORDER_LOCK_ASM(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_ASM_LOCK(handle))
385 #define _MMCAMCORDER_TRYLOCK_ASM(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_ASM_LOCK(handle))
386 #define _MMCAMCORDER_UNLOCK_ASM(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_ASM_LOCK(handle))
388 /* for state change */
389 #define _MMCAMCORDER_GET_STATE_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).state_lock)
390 #define _MMCAMCORDER_LOCK_STATE(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_STATE_LOCK(handle))
391 #define _MMCAMCORDER_TRYLOCK_STATE(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_STATE_LOCK(handle))
392 #define _MMCAMCORDER_UNLOCK_STATE(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_STATE_LOCK(handle))
394 /* for gstreamer state change */
395 #define _MMCAMCORDER_GET_GST_STATE_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).gst_state_lock)
396 #define _MMCAMCORDER_LOCK_GST_STATE(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_GST_STATE_LOCK(handle))
397 #define _MMCAMCORDER_TRYLOCK_GST_STATE(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_GST_STATE_LOCK(handle))
398 #define _MMCAMCORDER_UNLOCK_GST_STATE(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_GST_STATE_LOCK(handle))
400 #define _MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).gst_encode_state_lock)
401 #define _MMCAMCORDER_LOCK_GST_ENCODE_STATE(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle))
402 #define _MMCAMCORDER_TRYLOCK_GST_ENCODE_STATE(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle))
403 #define _MMCAMCORDER_UNLOCK_GST_ENCODE_STATE(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle))
405 /* for setting/calling callback */
406 #define _MMCAMCORDER_GET_MESSAGE_CALLBACK_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).message_cb_lock)
407 #define _MMCAMCORDER_LOCK_MESSAGE_CALLBACK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_MESSAGE_CALLBACK_LOCK(handle))
408 #define _MMCAMCORDER_TRYLOCK_MESSAGE_CALLBACK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_MESSAGE_CALLBACK_LOCK(handle))
409 #define _MMCAMCORDER_UNLOCK_MESSAGE_CALLBACK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_MESSAGE_CALLBACK_LOCK(handle))
411 #define _MMCAMCORDER_GET_VCAPTURE_CALLBACK_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).vcapture_cb_lock)
412 #define _MMCAMCORDER_LOCK_VCAPTURE_CALLBACK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_VCAPTURE_CALLBACK_LOCK(handle))
413 #define _MMCAMCORDER_TRYLOCK_VCAPTURE_CALLBACK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_VCAPTURE_CALLBACK_LOCK(handle))
414 #define _MMCAMCORDER_UNLOCK_VCAPTURE_CALLBACK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_VCAPTURE_CALLBACK_LOCK(handle))
416 #define _MMCAMCORDER_GET_VSTREAM_CALLBACK_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).vstream_cb_lock)
417 #define _MMCAMCORDER_LOCK_VSTREAM_CALLBACK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_VSTREAM_CALLBACK_LOCK(handle))
418 #define _MMCAMCORDER_TRYLOCK_VSTREAM_CALLBACK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_VSTREAM_CALLBACK_LOCK(handle))
419 #define _MMCAMCORDER_UNLOCK_VSTREAM_CALLBACK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_VSTREAM_CALLBACK_LOCK(handle))
421 #define _MMCAMCORDER_GET_ASTREAM_CALLBACK_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).astream_cb_lock)
422 #define _MMCAMCORDER_LOCK_ASTREAM_CALLBACK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_ASTREAM_CALLBACK_LOCK(handle))
423 #define _MMCAMCORDER_TRYLOCK_ASTREAM_CALLBACK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_ASTREAM_CALLBACK_LOCK(handle))
424 #define _MMCAMCORDER_UNLOCK_ASTREAM_CALLBACK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_ASTREAM_CALLBACK_LOCK(handle))
426 #define _MMCAMCORDER_GET_MSTREAM_CALLBACK_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).mstream_cb_lock)
427 #define _MMCAMCORDER_LOCK_MSTREAM_CALLBACK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_MSTREAM_CALLBACK_LOCK(handle))
428 #define _MMCAMCORDER_TRYLOCK_MSTREAM_CALLBACK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_MSTREAM_CALLBACK_LOCK(handle))
429 #define _MMCAMCORDER_UNLOCK_MSTREAM_CALLBACK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_MSTREAM_CALLBACK_LOCK(handle))
431 #ifdef _MMCAMCORDER_MURPHY_SUPPORT
432 /* for resource conflict */
433 #define _MMCAMCORDER_GET_RESOURCE_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).resource_lock)
434 #define _MMCAMCORDER_GET_RESOURCE_COND(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).resource_cond)
435 #define _MMCAMCORDER_LOCK_RESOURCE(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_RESOURCE_LOCK(handle))
436 #define _MMCAMCORDER_TRYLOCK_RESOURCE(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_RESOURCE_LOCK(handle))
437 #define _MMCAMCORDER_UNLOCK_RESOURCE(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_RESOURCE_LOCK(handle))
438 #define _MMCAMCORDER_RESOURCE_WAIT(handle) g_cond_wait(&_MMCAMCORDER_GET_RESOURCE_COND(handle), &_MMCAMCORDER_GET_RESOURCE_LOCK(handle))
439 #define _MMCAMCORDER_RESOURCE_WAIT_UNTIL(handle, end_time) g_cond_wait_until(&_MMCAMCORDER_GET_RESOURCE_COND(handle), &_MMCAMCORDER_GET_RESOURCE_LOCK(handle), end_time)
440 #define _MMCAMCORDER_RESOURCE_SIGNAL(handle) g_cond_signal(&_MMCAMCORDER_GET_RESOURCE_COND(handle));
441 #endif /* _MMCAMCORDER_MURPHY_SUPPORT */
444 * Caster of main handle (camcorder)
446 #define MMF_CAMCORDER(h) (mmf_camcorder_t *)(h)
449 * Caster of subcontext
451 #define MMF_CAMCORDER_SUBCONTEXT(h) (((mmf_camcorder_t *)(h))->sub_context)
453 /* LOCAL CONSTANT DEFINITIONS */
455 * Total Numbers of Attribute values.
456 * If you increase any enum of attribute values, you also have to increase this.
458 #define MM_CAMCORDER_MODE_NUM 3 /**< Number of mode type */
459 #define MM_CAMCORDER_COLOR_TONE_NUM 30 /**< Number of color-tone modes */
460 #define MM_CAMCORDER_WHITE_BALANCE_NUM 10 /**< Number of WhiteBalance modes*/
461 #define MM_CAMCORDER_SCENE_MODE_NUM 16 /**< Number of program-modes */
462 #define MM_CAMCORDER_FOCUS_MODE_NUM 6 /**< Number of focus mode*/
463 #define MM_CAMCORDER_AUTO_FOCUS_NUM 5 /**< Total count of auto focus type*/
464 #define MM_CAMCORDER_FOCUS_STATE_NUM 4 /**< Number of focus state */
465 #define MM_CAMCORDER_ISO_NUM 10 /**< Number of ISO */
466 #define MM_CAMCORDER_AUTO_EXPOSURE_NUM 9 /**< Number of Auto exposure type */
467 #define MM_CAMCORDER_WDR_NUM 3 /**< Number of wide dynamic range */
468 #define MM_CAMCORDER_FLIP_NUM 4 /**< Number of Filp mode */
469 #define MM_CAMCORDER_ROTATION_NUM 4 /**< Number of Rotation mode */
470 #define MM_CAMCORDER_AHS_NUM 4 /**< Number of anti-handshake */
471 #define MM_CAMCORDER_VIDEO_STABILIZATION_NUM 2 /**< Number of video stabilization */
472 #define MM_CAMCORDER_HDR_CAPTURE_NUM 3 /**< Number of HDR capture mode */
473 #define MM_CAMCORDER_GEOMETRY_METHOD_NUM 5 /**< Number of geometry method */
474 #define MM_CAMCORDER_TAG_ORT_NUM 8 /**< Number of tag orientation */
475 #define MM_CAMCORDER_STROBE_MODE_NUM 8 /**< Number of strobe mode type */
476 #define MM_CAMCORDER_STROBE_CONTROL_NUM 3 /**< Number of strobe control type */
477 #define MM_CAMCORDER_DETECT_MODE_NUM 2 /**< Number of detect mode type */
479 /*=======================================================================================
481 ========================================================================================*/
483 * Command for Camcorder.
486 /* Command for Video/Audio recording */
487 _MMCamcorder_CMD_RECORD,
488 _MMCamcorder_CMD_PAUSE,
489 _MMCamcorder_CMD_CANCEL,
490 _MMCamcorder_CMD_COMMIT,
492 /* Command for Image capture */
493 _MMCamcorder_CMD_CAPTURE,
495 /* Command for Preview(Video/Image only effective) */
496 _MMCamcorder_CMD_PREVIEW_START,
497 _MMCamcorder_CMD_PREVIEW_STOP,
504 _MMCamcorder_SINGLE_SHOT,
505 _MMCamcorder_MULTI_SHOT,
509 * Enumerations for manual focus direction.
510 * If focusing mode is not "MM_CAMCORDER_AF_MODE_MANUAL", this value will be ignored.
512 enum MMCamcorderMfLensDir {
513 MM_CAMCORDER_MF_LENS_DIR_FORWARD = 1, /**< Focus direction to forward */
514 MM_CAMCORDER_MF_LENS_DIR_BACKWARD, /**< Focus direction to backward */
515 MM_CAMCORDER_MF_LENS_DIR_NUM, /**< Total number of the directions */
519 * Camcorder Pipeline's Element name.
520 * @note index of element.
523 _MMCAMCORDER_NONE = (-1),
525 /* Main Pipeline Element */
526 _MMCAMCORDER_MAIN_PIPE = 0x00,
528 /* Pipeline element of Video input */
529 _MMCAMCORDER_VIDEOSRC_SRC,
530 _MMCAMCORDER_VIDEOSRC_FILT,
531 _MMCAMCORDER_VIDEOSRC_CLS_QUE,
532 _MMCAMCORDER_VIDEOSRC_CLS,
533 _MMCAMCORDER_VIDEOSRC_CLS_FILT,
534 _MMCAMCORDER_VIDEOSRC_QUE,
535 _MMCAMCORDER_VIDEOSRC_DECODE,
537 /* Pipeline element of Video output */
538 _MMCAMCORDER_VIDEOSINK_QUE,
539 _MMCAMCORDER_VIDEOSINK_CLS,
540 _MMCAMCORDER_VIDEOSINK_SINK,
542 _MMCAMCORDER_PIPELINE_ELEMENT_NUM,
543 } _MMCAMCORDER_PREVIEW_PIPELINE_ELELMENT;
546 * Camcorder Pipeline's Element name.
547 * @note index of element.
550 _MMCAMCORDER_ENCODE_NONE = (-1),
552 /* Main Pipeline Element */
553 _MMCAMCORDER_ENCODE_MAIN_PIPE = 0x00,
555 /* Pipeline element of Audio input */
556 _MMCAMCORDER_AUDIOSRC_BIN,
557 _MMCAMCORDER_AUDIOSRC_SRC,
558 _MMCAMCORDER_AUDIOSRC_FILT,
559 _MMCAMCORDER_AUDIOSRC_QUE,
560 _MMCAMCORDER_AUDIOSRC_CONV,
561 _MMCAMCORDER_AUDIOSRC_VOL,
563 /* Pipeline element of Encodebin */
564 _MMCAMCORDER_ENCSINK_BIN,
565 _MMCAMCORDER_ENCSINK_SRC,
566 _MMCAMCORDER_ENCSINK_FILT,
567 _MMCAMCORDER_ENCSINK_ENCBIN,
568 _MMCAMCORDER_ENCSINK_AQUE,
569 _MMCAMCORDER_ENCSINK_CONV,
570 _MMCAMCORDER_ENCSINK_AENC,
571 _MMCAMCORDER_ENCSINK_AENC_QUE,
572 _MMCAMCORDER_ENCSINK_VQUE,
573 _MMCAMCORDER_ENCSINK_VCONV,
574 _MMCAMCORDER_ENCSINK_VENC,
575 _MMCAMCORDER_ENCSINK_VENC_QUE,
576 _MMCAMCORDER_ENCSINK_ITOG,
577 _MMCAMCORDER_ENCSINK_ICROP,
578 _MMCAMCORDER_ENCSINK_ISCALE,
579 _MMCAMCORDER_ENCSINK_IFILT,
580 _MMCAMCORDER_ENCSINK_IQUE,
581 _MMCAMCORDER_ENCSINK_IENC,
582 _MMCAMCORDER_ENCSINK_MUX,
583 _MMCAMCORDER_ENCSINK_SINK,
585 _MMCAMCORDER_ENCODE_PIPELINE_ELEMENT_NUM,
586 } _MMCAMCORDER_ENCODE_PIPELINE_ELELMENT;
589 _MMCAMCORDER_TASK_THREAD_STATE_NONE,
590 _MMCAMCORDER_TASK_THREAD_STATE_SOUND_PLAY_START,
591 _MMCAMCORDER_TASK_THREAD_STATE_SOUND_SOLO_PLAY_START,
592 _MMCAMCORDER_TASK_THREAD_STATE_ENCODE_PIPE_CREATE,
593 _MMCAMCORDER_TASK_THREAD_STATE_CHECK_CAPTURE_IN_RECORDING,
594 _MMCAMCORDER_TASK_THREAD_STATE_EXIT,
595 } _MMCamcorderTaskThreadState;
598 * System state change cause
601 _MMCAMCORDER_STATE_CHANGE_NORMAL = 0,
602 _MMCAMCORDER_STATE_CHANGE_BY_FOCUS,
603 _MMCAMCORDER_STATE_CHANGE_BY_RM,
604 _MMCAMCORDER_STATE_CHANGE_BY_DPM,
605 _MMCAMCORDER_STATE_CHANGE_BY_STORAGE
606 } _MMCamcorderStateChange;
609 /*=======================================================================================
610 | STRUCTURE DEFINITIONS |
611 ========================================================================================*/
613 * MMCamcorder Gstreamer Element
616 unsigned int id; /**< Gstreamer piplinem element name */
617 GstElement *gst; /**< Gstreamer element */
618 } _MMCamcorderGstElement;
621 * MMCamcorder information for KPI measurement
624 int current_fps; /**< current fps of this second */
625 int average_fps; /**< average fps */
626 unsigned int video_framecount; /**< total number of video frame */
627 unsigned int last_framecount; /**< total number of video frame in last measurement */
628 struct timeval init_video_time; /**< time when start to measure */
629 struct timeval last_video_time; /**< last measurement time */
630 } _MMCamcorderKPIMeasure;
633 * MMCamcorder information for Multi-Thread Safe
636 GMutex lock; /**< Mutex (for general use) */
637 GCond cond; /**< Condition (for general use) */
638 GMutex cmd_lock; /**< Mutex (for command) */
639 GCond cmd_cond; /**< Condition (for command) */
640 GMutex asm_lock; /**< Mutex (for ASM) */
641 GMutex state_lock; /**< Mutex (for state change) */
642 GMutex gst_state_lock; /**< Mutex (for gst pipeline state change) */
643 GMutex gst_encode_state_lock; /**< Mutex (for gst encode pipeline state change) */
644 GMutex message_cb_lock; /**< Mutex (for message callback) */
645 GMutex vcapture_cb_lock; /**< Mutex (for video capture callback) */
646 GMutex vstream_cb_lock; /**< Mutex (for video stream callback) */
647 GMutex astream_cb_lock; /**< Mutex (for audio stream callback) */
648 GMutex mstream_cb_lock; /**< Mutex (for muxed stream callback) */
649 #ifdef _MMCAMCORDER_MURPHY_SUPPORT
650 GCond resource_cond; /**< Condition (for resource check) */
651 GMutex resource_lock; /**< Mutex (for resource check) */
652 #endif /* _MMCAMCORDER_MURPHY_SUPPORT */
653 } _MMCamcorderMTSafe;
656 * MMCamcorder Sub Context
659 bool isMaxsizePausing; /**< Because of size limit, pipeline is paused. */
660 bool isMaxtimePausing; /**< Because of time limit, pipeline is paused. */
661 int element_num; /**< count of element */
662 int encode_element_num; /**< count of encode element */
663 int cam_stability_count; /**< camsensor stability count. the count of frame will drop */
664 GstClockTime pipeline_time; /**< current time of Gstreamer Pipeline */
665 GstClockTime pause_time; /**< amount of time while pipeline is in PAUSE state.*/
666 GstClockTime stillshot_time; /**< pipeline time of capturing moment*/
667 gboolean is_modified_rate; /**< whether recording motion rate is modified or not */
668 gboolean ferror_send; /**< file write/seek error **/
669 guint ferror_count; /**< file write/seek error count **/
670 GstClockTime previous_slot_time;
671 int display_interval; /**< This value is set as 'GST_SECOND / display FPS' */
672 gboolean bget_eos; /**< Whether getting EOS */
673 gboolean bencbin_capture; /**< Use Encodebin for capturing */
674 gboolean audio_disable; /**< whether audio is disabled or not when record */
675 int videosrc_rotate; /**< rotate of videosrc */
676 unsigned long long muxed_stream_offset; /**< current offset for muxed stream data */
678 /* For dropping video frame when start recording */
679 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. */
680 int pass_first_vframe; /**< When this value is bigger than zero, MSL won't drop video frame though "drop_vframe" is bigger then zero. */
682 /* INI information */
683 unsigned int fourcc; /**< Get fourcc value of camera INI file */
684 _MMCamcorderImageInfo *info_image; /**< extra information for image capture */
685 _MMCamcorderVideoInfo *info_video; /**< extra information for video recording */
686 _MMCamcorderAudioInfo *info_audio; /**< extra information for audio recording */
688 _MMCamcorderGstElement *element; /**< array of preview element */
689 _MMCamcorderGstElement *encode_element; /**< array of encode element */
690 _MMCamcorderKPIMeasure kpi; /**< information related with performance measurement */
692 type_element *VideosinkElement; /**< configure data of videosink element */
693 type_element *VideoconvertElement; /**< configure data of videoconvert element */
694 type_element *VideodecoderElementH264; /**< configure data of video decoder element for H.264 format */
695 gboolean SensorEncodedCapture; /**< whether camera sensor support encoded image capture */
696 gboolean internal_encode; /**< whether use internal encoding function */
697 } _MMCamcorderSubContext;
700 * _MMCamcorderContext
702 typedef struct mmf_camcorder {
704 int type; /**< mmcamcorder_mode_type */
705 int device_type; /**< device type */
706 int state; /**< state of camcorder */
707 int old_state; /**< old state of camcorder */
710 MMHandleType attributes; /**< Attribute handle */
711 _MMCamcorderSubContext *sub_context; /**< sub context */
712 mm_exif_info_t *exif_info; /**< EXIF */
713 GList *buffer_probes; /**< a list of buffer probe handle */
714 GList *event_probes; /**< a list of event probe handle */
715 GList *signals; /**< a list of signal handle */
716 #ifdef _MMCAMCORDER_ENABLE_IDLE_MESSAGE_CALLBACK
717 GList *msg_data; /**< a list of msg data */
718 #endif /* _MMCAMCORDER_ENABLE_IDLE_MESSAGE_CALLBACK */
719 camera_conf *conf_main; /**< Camera configure Main structure */
720 camera_conf *conf_ctrl; /**< Camera configure Control structure */
721 #ifdef _MMCAMCORDER_RM_SUPPORT
722 int rm_handle; /**< Resource manager handle */
723 #endif /* _MMCAMCORDER_RM_SUPPORT */
724 guint pipeline_cb_event_id; /**< Event source ID of pipeline message callback */
725 guint encode_pipeline_cb_event_id; /**< Event source ID of encode pipeline message callback */
726 guint setting_event_id; /**< Event source ID of attributes setting to sensor */
727 SOUND_INFO snd_info; /**< Sound handle for multishot capture */
729 /* callback handlers */
730 MMMessageCallback msg_cb; /**< message callback */
731 void *msg_cb_param; /**< message callback parameter */
732 mm_camcorder_video_stream_callback vstream_cb; /**< Video stream callback */
733 void *vstream_cb_param; /**< Video stream callback parameter */
734 mm_camcorder_audio_stream_callback astream_cb; /**< Audio stream callback */
735 void *astream_cb_param; /**< Audio stream callback parameter */
736 mm_camcorder_muxed_stream_callback mstream_cb; /**< Muxed stream callback */
737 void *mstream_cb_param; /**< Muxed stream callback parameter */
738 mm_camcorder_video_capture_callback vcapture_cb; /**< Video capture callback */
739 void *vcapture_cb_param; /**< Video capture callback parameter */
740 int (*command)(MMHandleType, int); /**< camcorder's command */
743 mm_cam_attr_construct_info *cam_attrs_const_info; /**< attribute info */
744 conf_info_table *conf_main_info_table[CONFIGURE_CATEGORY_MAIN_NUM]; /** configure info table - MAIN category */
745 conf_info_table *conf_ctrl_info_table[CONFIGURE_CATEGORY_CTRL_NUM]; /** configure info table - CONTROL category */
746 int conf_main_category_size[CONFIGURE_CATEGORY_MAIN_NUM]; /** configure info table size - MAIN category */
747 int conf_ctrl_category_size[CONFIGURE_CATEGORY_CTRL_NUM]; /** configure info table size - CONTROL category */
748 _MMCamcorderMTSafe mtsafe; /**< Thread safe */
749 int state_change_by_system; /**< MSL changes its state by itself because of system */
750 GMutex restart_preview_lock; /**< Capture sound mutex */
751 int use_zero_copy_format; /**< Whether use zero copy format for camera input */
752 int use_videoconvert; /**< Whether use videoconvert element for display */
753 int support_media_packet_preview_cb; /**< Whether support zero copy format for camera input */
754 int shutter_sound_policy; /**< shutter sound policy */
755 int brightness_default; /**< default value of brightness */
756 int brightness_step_denominator; /**< denominator of brightness bias step */
757 int support_zsl_capture; /**< support Zero Shutter Lag capture */
758 char *model_name; /**< model name from system info */
759 char *software_version; /**< software_version from system info */
760 int capture_sound_count; /**< count for capture sound */
761 char *root_directory; /**< Root directory for device */
762 int resolution_changed; /**< Flag for preview resolution change */
763 int sound_focus_register; /**< Use sound focus internally */
764 int sound_focus_id; /**< id for sound focus */
765 int sound_focus_watch_id; /**< id for sound focus watch */
766 unsigned int sound_focus_subscribe_id; /**< subscribe id for sound focus signal */
767 int interrupt_code; /**< Interrupt code */
768 int acquired_focus; /**< Current acquired focus */
769 int session_type; /**< Session type */
770 int session_flags; /**< Session flags */
771 int recreate_decoder; /**< Flag of decoder element recreation for encoded preview format */
773 _MMCamcorderInfoConverting caminfo_convert[CAMINFO_CONVERT_NUM]; /**< converting structure of camera info */
774 _MMCamcorderEnumConvert enum_conv[ENUM_CONVERT_NUM]; /**< enum converting list that is modified by ini info */
776 gboolean capture_in_recording; /**< Flag for capture while recording */
778 gboolean error_occurs; /**< flag for error */
779 int error_code; /**< error code for internal gstreamer error */
782 GThread *task_thread; /**< thread for task */
783 GMutex task_thread_lock; /**< mutex for task thread */
784 GCond task_thread_cond; /**< cond for task thread */
785 _MMCamcorderTaskThreadState task_thread_state; /**< state of task thread */
787 #ifdef _MMCAMCORDER_MURPHY_SUPPORT
788 /* resource manager for H/W resources */
789 MMCamcorderResourceManager resource_manager;
790 MMCamcorderResourceManager resource_manager_sub;
791 #endif /* _MMCAMCORDER_MURPHY_SUPPORT */
794 GDBusConnection *gdbus_conn; /**< gdbus connection */
795 _MMCamcorderGDbusCbInfo gdbus_info_sound; /**< Informations for the gbus cb of sound play */
796 _MMCamcorderGDbusCbInfo gdbus_info_solo_sound; /**< Informations for the gbus cb of solo sound play */
798 /* DPM(device policy manager) */
799 device_policy_manager_h dpm_handle; /**< DPM handle */
800 int dpm_camera_cb_id; /**< DPM camera policy changed callback id */
803 _MMCamcorderStorageInfo storage_info; /**< Storage information */
805 #ifdef _MMCAMCORDER_RM_SUPPORT
806 rm_category_request_s request_resources;
807 rm_device_return_s returned_devices;
808 #endif /* _MMCAMCORDER_RM_SUPPORT */
809 int reserved[4]; /**< reserved */
812 /*=======================================================================================
813 | EXTERN GLOBAL VARIABLE |
814 ========================================================================================*/
816 /*=======================================================================================
817 | GLOBAL FUNCTION PROTOTYPES |
818 ========================================================================================*/
820 * This function creates camcorder for capturing still image and recording.
822 * @param[out] handle Specifies the camcorder handle
823 * @param[in] info Preset information of camcorder
824 * @return This function returns zero on success, or negative value with error code.
825 * @remarks When this function calls successfully, camcorder handle will be filled with a @n
826 * valid value and the state of the camcorder will become MM_CAMCORDER_STATE_NULL.@n
827 * Note that it's not ready to working camcorder. @n
828 * You should call mmcamcorder_realize before starting camcorder.
829 * @see _mmcamcorder_create
831 int _mmcamcorder_create(MMHandleType *handle, MMCamPreset *info);
834 * This function destroys instance of camcorder.
836 * @param[in] hcamcorder Specifies the camcorder handle
837 * @return This function returns zero on success, or negative value with error code.
838 * @see _mmcamcorder_create
840 int _mmcamcorder_destroy(MMHandleType hcamcorder);
843 * This function allocates memory for camcorder.
845 * @param[in] hcamcorder Specifies the camcorder handle
846 * @return This function returns zero on success, or negative value with error code.
847 * @remarks This function can be called successfully when current state is MM_CAMCORDER_STATE_NULL @n
848 * and the state of the camcorder will become MM_CAMCORDER_STATE_READY. @n
849 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
850 * @see _mmcamcorder_unrealize
851 * @pre MM_CAMCORDER_STATE_NULL
852 * @post MM_CAMCORDER_STATE_READY
854 int _mmcamcorder_realize(MMHandleType hcamcorder);
857 * This function free allocated memory for camcorder.
859 * @param[in] hcamcorder Specifies the camcorder handle
860 * @return This function returns zero on success, or negative value with error code.
861 * @remarks This function release all resources which are allocated for the camcorder engine.@n
862 * This function can be called successfully when current state is MM_CAMCORDER_STATE_READY and @n
863 * the state of the camcorder will become MM_CAMCORDER_STATE_NULL. @n
864 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
865 * @see _mmcamcorder_realize
866 * @pre MM_CAMCORDER_STATE_READY
867 * @post MM_CAMCORDER_STATE_NULL
869 int _mmcamcorder_unrealize(MMHandleType hcamcorder);
872 * This function is to start previewing.
874 * @param[in] hcamcorder Specifies the camcorder handle
875 * @return This function returns zero on success, or negative value with error code.
876 * @remarks This function can be called successfully when current state is MM_CAMCORDER_STATE_READY and @n
877 * the state of the camcorder will become MM_CAMCORDER_STATE_PREPARE. @n
878 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
879 * @see _mmcamcorder_stop
881 int _mmcamcorder_start(MMHandleType hcamcorder);
884 * This function is to stop previewing.
886 * @param[in] hcamcorder Specifies the camcorder handle
887 * @return This function returns zero on success, or negative value with error code.
888 * @remarks This function can be called successfully when current state is MM_CAMCORDER_STATE_PREPARE and @n
889 * the state of the camcorder will become MM_CAMCORDER_STATE_READY.@n
890 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
891 * @see _mmcamcorder_start
893 int _mmcamcorder_stop(MMHandleType hcamcorder);
896 * This function to start capturing of still images.
898 * @param[in] hcamcorder Specifies the camcorder handle.
899 * @return This function returns zero on success, or negative value with error code.
900 * @remarks This function can be called successfully when current state is MM_CAMCORDER_STATE_PREPARE and @n
901 * the state of the camcorder will become MM_CAMCORDER_STATE_CAPTURING. @n
902 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
903 * @see _mmcamcorder_capture_stop
905 int _mmcamcorder_capture_start(MMHandleType hcamcorder);
908 * This function is to stop capturing still images.
910 * @param[in] hcamcorder Specifies the camcorder handle
911 * @return This function returns zero on success, or negative value with error code.
912 * @remarks This function can be called successfully when current state is MM_CAMCORDER_STATE_CAPTURING and @n
913 * the state of the camcorder will become MM_CAMCORDER_STATE_PREPARE. @n
914 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
915 * @see _mmcamcorder_capture_start
917 int _mmcamcorder_capture_stop(MMHandleType hcamcorder);
920 * This function is to start video and audio recording.
922 * @param[in] hcamcorder Specifies the camcorder handle
923 * @return This function returns zero on success, or negative value with error code.
924 * @remarks This function can be called successfully when current state is @n
925 * MM_CAMCORDER_STATE_PREPARE or MM_CAMCORDER_STATE_PAUSED and @n
926 * the state of the camcorder will become MM_CAMCORDER_STATE_RECORDING.@n
927 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
928 * @see _mmcamcorder_pause
930 int _mmcamcorder_record(MMHandleType hcamcorder);
933 * This function is to pause video and audio recording
935 * @param[in] hcamcorder Specifies the camcorder handle
936 * @return This function returns zero on success, or negative value with error code.
937 * @remarks This function can be called successfully when current state is MM_CAMCORDER_STATE_RECORDING and @n
938 * the state of the camcorder will become MM_CAMCORDER_STATE_PAUSED.@n
939 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.@n
940 * @see _mmcamcorder_record
942 int _mmcamcorder_pause(MMHandleType hcamcorder);
945 * This function is to stop video and audio recording and save results.
947 * @param[in] hcamcorder Specifies the camcorder handle
948 * @return This function returns zero on success, or negative value with error code.
949 * @remarks This function can be called successfully when current state is @n
950 * MM_CAMCORDER_STATE_PAUSED or MM_CAMCORDER_STATE_RECORDING and @n
951 * the state of the camcorder will become MM_CAMCORDER_STATE_PREPARE. @n
952 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION
953 * @see _mmcamcorder_cancel
955 int _mmcamcorder_commit(MMHandleType hcamcorder);
958 * This function is to stop video and audio recording and do not save results.
960 * @param[in] hcamcorder Specifies the camcorder handle
961 * @return This function returns zero on success, or negative value with error code.
962 * @remarks This function can be called successfully when current state is @n
963 * MM_CAMCORDER_STATE_PAUSED or MM_CAMCORDER_STATE_RECORDING and @n
964 * the state of the camcorder will become MM_CAMCORDER_STATE_PREPARE. @n
965 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
966 * @see _mmcamcorder_commit
968 int _mmcamcorder_cancel(MMHandleType hcamcorder);
971 * This function calls after commiting action finished asynchronously.
972 * In this function, remaining process , such as state change, happens.
974 * @param[in] hcamcorder Specifies the camcorder handle
975 * @return This function returns zero on success, or negative value with error code.
976 * @remarks This function can be called successfully when current state is @n
977 * MM_CAMCORDER_STATE_PAUSED or MM_CAMCORDER_STATE_RECORDING and @n
978 * the state of the camcorder will become MM_CAMCORDER_STATE_PREPARE. @n
979 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
980 * @see _mmcamcorder_commit
982 int _mmcamcorder_commit_async_end(MMHandleType hcamcorder);
985 * This function is to set callback for receiving messages from camcorder.
987 * @param[in] hcamcorder Specifies the camcorder handle
988 * @param[in] callback Specifies the function pointer of callback function
989 * @param[in] user_data Specifies the user poiner for passing to callback function
991 * @return This function returns zero on success, or negative value with error code.
992 * @remarks typedef bool (*mm_message_callback) (int msg, mm_messageType *param, void *user_param);@n
1007 * } mm_message_type; @n
1009 * If a message value for mm_message_callback is MM_MESSAGE_STATE_CHANGED, @n
1010 * state value in mm_message_type will be a mmcamcorder_state_type enum value;@n
1012 * If a message value for mm_message_callback is MM_MESSAGE_ERROR, @n
1013 * the code value in mm_message_type will be a mmplayer_error_type enum value;
1015 * @see mm_message_type, mmcamcorder_state_type, mmcamcorder_error_type
1017 int _mmcamcorder_set_message_callback(MMHandleType hcamcorder,
1018 MMMessageCallback callback,
1022 * This function is to set callback for video stream.
1024 * @param[in] hcamcorder Specifies the camcorder handle
1025 * @param[in] callback Specifies the function pointer of callback function
1026 * @param[in] user_data Specifies the user poiner for passing to callback function
1028 * @return This function returns zero on success, or negative value with error code.
1029 * @see mmcamcorder_error_type
1031 int _mmcamcorder_set_video_stream_callback(MMHandleType hcamcorder,
1032 mm_camcorder_video_stream_callback callback,
1036 * This function is to set callback for audio stream.
1038 * @param[in] hcamcorder Specifies the camcorder handle
1039 * @param[in] callback Specifies the function pointer of callback function
1040 * @param[in] user_data Specifies the user poiner for passing to callback function
1042 * @return This function returns zero on success, or negative value with error code.
1043 * @see mmcamcorder_error_type
1045 int _mmcamcorder_set_audio_stream_callback(MMHandleType handle,
1046 mm_camcorder_audio_stream_callback callback,
1050 * This function is to set callback for muxed stream.
1052 * @param[in] hcamcorder Specifies the camcorder handle
1053 * @param[in] callback Specifies the function pointer of callback function
1054 * @param[in] user_data Specifies the user poiner for passing to callback function
1056 * @return This function returns zero on success, or negative value with error code.
1057 * @see mmcamcorder_error_type
1059 int _mmcamcorder_set_muxed_stream_callback(MMHandleType handle,
1060 mm_camcorder_muxed_stream_callback callback,
1064 * This function is to set callback for video capture.
1066 * @param[in] hcamcorder Specifies the camcorder handle
1067 * @param[in] callback Specifies the function pointer of callback function
1068 * @param[in] user_data Specifies the user poiner for passing to callback function
1070 * @return This function returns zero on success, or negative value with error code.
1071 * @see mmcamcorder_error_type
1073 int _mmcamcorder_set_video_capture_callback(MMHandleType hcamcorder,
1074 mm_camcorder_video_capture_callback callback,
1078 * This function returns current state of camcorder, or negative value with error code.
1080 * @param[in] hcamcorder Specifies the camcorder handle.
1081 * @return This function returns current state of camcorder, or negative value with error code.
1082 * @see mmcamcorder_state_type
1084 int _mmcamcorder_get_current_state(MMHandleType hcamcorder);
1086 int _mmcamcorder_init_focusing(MMHandleType handle);
1087 int _mmcamcorder_adjust_focus(MMHandleType handle, int direction);
1088 int _mmcamcorder_adjust_manual_focus(MMHandleType handle, int direction);
1089 int _mmcamcorder_adjust_auto_focus(MMHandleType handle);
1090 int _mmcamcorder_stop_focusing(MMHandleType handle);
1093 * This function gets current state of camcorder.
1096 * @return This function returns state of current camcorder context
1098 * @see _mmcamcorder_set_state()
1101 int _mmcamcorder_streamer_init(void);
1104 * This function gets current state of camcorder.
1107 * @return This function returns state of current camcorder context
1109 * @see _mmcamcorder_set_state()
1112 int _mmcamcorder_display_init(void);
1115 * This function gets current state of camcorder.
1117 * @param[in] handle Handle of camcorder context.
1118 * @return This function returns state of current camcorder context
1120 * @see _mmcamcorder_set_state()
1123 int _mmcamcorder_get_state(MMHandleType handle);
1124 int _mmcamcorder_get_state2(MMHandleType handle, int *state, int *old_state);
1127 * This function sets new state of camcorder.
1129 * @param[in] handle Handle of camcorder context.
1130 * @param[in] state setting state value of camcorder.
1133 * @see _mmcamcorder_get_state()
1136 void _mmcamcorder_set_state(MMHandleType handle, int state);
1139 * This function allocates structure of subsidiary attributes.
1141 * @param[in] type Allocation type of camcorder context.
1142 * @return This function returns structure pointer on success, NULL value on failure.
1144 * @see _mmcamcorder_dealloc_subcontext()
1147 _MMCamcorderSubContext *_mmcamcorder_alloc_subcontext(int type);
1150 * This function releases structure of subsidiary attributes.
1152 * @param[in] sc Handle of camcorder subcontext.
1155 * @see _mmcamcorder_alloc_subcontext()
1158 void _mmcamcorder_dealloc_subcontext(_MMCamcorderSubContext *sc);
1161 * This function sets command function according to the type.
1163 * @param[in] handle Handle of camcorder context.
1164 * @param[in] type Allocation type of camcorder context.
1165 * @return This function returns MM_ERROR_NONE on success, or other values with error code.
1167 * @see __mmcamcorder_video_command(), __mmcamcorder_audio_command(), __mmcamcorder_image_command()
1170 int _mmcamcorder_set_functions(MMHandleType handle, int type);
1173 * This function is callback function of main pipeline.
1174 * Once this function is registered with certain pipeline using gst_bus_add_watch(),
1175 * this callback will be called every time when there is upcomming message from pipeline.
1176 * Basically, this function is used as error handling function, now.
1178 * @param[in] bus pointer of buf that called this function.
1179 * @param[in] message callback message from pipeline.
1180 * @param[in] data user data.
1181 * @return This function returns true on success, or false value with error
1183 * @see __mmcamcorder_create_preview_pipeline()
1186 gboolean _mmcamcorder_pipeline_cb_message(GstBus *bus, GstMessage *message, gpointer data);
1189 * This function is callback function of main pipeline.
1190 * Once this function is registered with certain pipeline using gst_bus_set_sync_handler(),
1191 * this callback will be called every time when there is upcomming message from pipeline.
1192 * Basically, this function is used as sync error handling function, now.
1194 * @param[in] bus pointer of buf that called this function.
1195 * @param[in] message callback message from pipeline.
1196 * @param[in] data user data.
1197 * @return This function returns true on success, or false value with error
1199 * @see __mmcamcorder_create_preview_pipeline()
1202 GstBusSyncReply _mmcamcorder_pipeline_bus_sync_callback(GstBus *bus, GstMessage *message, gpointer data);
1205 * This function is callback function of encode pipeline.
1206 * Once this function is registered with certain pipeline using gst_bus_set_sync_handler(),
1207 * this callback will be called every time when there is upcomming message from pipeline.
1208 * Basically, this function is used for EOS and error handling now.
1210 * @param[in] bus pointer of buf that called this function.
1211 * @param[in] message callback message from pipeline.
1212 * @param[in] data user data.
1213 * @return This function returns true on success, or false value with error
1215 * @see __mmcamcorder_create_recorder_pipeline()
1216 * @see __mmcamcorder_create_audiop_with_encodebin()
1219 GstBusSyncReply _mmcamcorder_encode_pipeline_bus_sync_callback(GstBus *bus, GstMessage *message, gpointer data);
1222 * This function create main pipeline according to type.
1224 * @param[in] handle Handle of camcorder context.
1225 * @param[in] type Allocation type of camcorder context.
1226 * @return This function returns zero on success, or negative value with error code.
1228 * @see _mmcamcorder_destroy_pipeline()
1231 int _mmcamcorder_create_pipeline(MMHandleType handle, int type);
1234 * This function release all element of main pipeline according to type.
1236 * @param[in] handle Handle of camcorder context.
1237 * @param[in] type Allocation type of camcorder context.
1240 * @see _mmcamcorder_create_pipeline()
1243 void _mmcamcorder_destroy_pipeline(MMHandleType handle, int type);
1246 * This function sets gstreamer element status.
1247 * If the gstreamer fails to set status or returns asynchronous mode,
1248 * this function waits for state changed until timeout expired.
1250 * @param[in] pipeline Pointer of pipeline
1251 * @param[in] target_state newly setting status
1252 * @return This function returns zero on success, or negative value with error code.
1257 int _mmcamcorder_gst_set_state(MMHandleType handle, GstElement *pipeline, GstState target_state);
1260 /* For xvimagesink */
1261 GstBusSyncReply __mmcamcorder_sync_callback(GstBus *bus, GstMessage *message, gulong data);
1263 /* For querying capabilities */
1264 int _mmcamcorder_read_vidsrc_info(int videodevidx, camera_conf **configure_info);
1266 /* for performance check */
1267 void _mmcamcorder_video_current_framerate_init(MMHandleType handle);
1268 int _mmcamcorder_video_current_framerate(MMHandleType handle);
1269 int _mmcamcorder_video_average_framerate(MMHandleType handle);
1271 /* sound focus related function */
1272 void __mmcamcorder_force_stop(mmf_camcorder_t *hcamcorder, int state_change_by_system);
1273 void _mmcamcorder_sound_focus_cb(int id, mm_sound_focus_type_e focus_type,
1274 mm_sound_focus_state_e focus_state, const char *reason_for_change,
1275 int option, const char *additional_info, void *user_data);
1276 void _mmcamcorder_sound_focus_watch_cb(int id, mm_sound_focus_type_e focus_type, mm_sound_focus_state_e focus_state,
1277 const char *reason_for_change, const char *additional_info, void *user_data);
1278 void _mmcamcorder_sound_signal_callback(mm_sound_signal_name_t signal, int value, void *user_data);
1280 /* device policy manager */
1281 void _mmcamcorder_dpm_camera_policy_changed_cb(const char *name, const char *value, void *user_data);
1283 /* Emit dbus signal */
1284 void _mmcamcorder_emit_signal(MMHandleType handle, const char *object_name,
1285 const char *interface_name, const char *signal_name, int value);
1287 /* external storage state management */
1288 int _mmcamcorder_manage_external_storage_state(MMHandleType handle, int storage_state);
1294 #endif /* __MM_CAMCORDER_INTERNAL_H__ */