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 ========================================================================================*/
82 #define _mmcam_dbg_verb(fmt, args...) SLOGI(fmt, ##args);
83 #define _mmcam_dbg_log(fmt, args...) SLOGD(fmt, ##args);
84 #define _mmcam_dbg_warn(fmt, args...) SLOGW(fmt, ##args);
85 #define _mmcam_dbg_err(fmt, args...) SLOGE(fmt, ##args);
86 #define _mmcam_dbg_crit(fmt, args...) SLOGF(fmt, ##args);
89 * Macro for checking validity and debugging
91 #define mmf_return_if_fail(expr) \
93 _mmcam_dbg_err("failed [%s]", #expr); \
98 * Macro for checking validity and debugging
100 #define mmf_return_val_if_fail(expr, val) \
102 _mmcam_dbg_err("failed [%s]", #expr); \
109 * Macro for getting array size
111 #define ARRAY_SIZE(a) (sizeof((a)) / sizeof((a)[0]))
114 /* gstreamer element creation macro */
115 #define _MMCAMCORDER_PIPELINE_MAKE(sub_context, element, eid, name /*char* */, err) \
117 if (element[eid].gst != NULL) { \
118 _mmcam_dbg_err("The element(Pipeline) is existed. element_id=[%d], name=[%s]", eid, name); \
119 gst_object_unref(element[eid].gst); \
121 element[eid].id = eid; \
122 element[eid].gst = gst_pipeline_new(name); \
123 if (element[eid].gst == NULL) { \
124 _mmcam_dbg_err("Pipeline creation fail. element_id=[%d], name=[%s]", eid, name); \
125 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
126 goto pipeline_creation_error; \
128 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
132 #define _MMCAMCORDER_BIN_MAKE(sub_context, element, eid, name /*char* */, err) \
134 if (element[eid].gst != NULL) { \
135 _mmcam_dbg_err("The element(Bin) is existed. element_id=[%d], name=[%s]", eid, name); \
136 gst_object_unref(element[eid].gst); \
138 element[eid].id = eid; \
139 element[eid].gst = gst_bin_new(name); \
140 if (element[eid].gst == NULL) { \
141 _mmcam_dbg_err("Bin creation fail. element_id=[%d], name=[%s]\n", eid, name); \
142 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
143 goto pipeline_creation_error; \
145 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
149 #define _MMCAMCORDER_ELEMENT_MAKE(sub_context, element, eid, name /*char* */, nickname /*char* */, elist, err) \
151 if (element[eid].gst != NULL) { \
152 _mmcam_dbg_err("The element is existed. element_id=[%d], name=[%s]", eid, name); \
153 gst_object_unref(element[eid].gst); \
155 traceBegin(TTRACE_TAG_CAMERA, "MMCAMCORDER:ELEMENT_MAKE:%s", name); \
156 element[eid].gst = gst_element_factory_make(name, nickname); \
157 traceEnd(TTRACE_TAG_CAMERA); \
158 if (element[eid].gst == NULL) { \
159 _mmcam_dbg_err("Element creation fail. element_id=[%d], name=[%s]", eid, name); \
160 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
161 goto pipeline_creation_error; \
163 _mmcam_dbg_log("Element creation done. element_id=[%d], name=[%s]", eid, name); \
164 element[eid].id = eid; \
165 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
166 err = MM_ERROR_NONE; \
168 elist = g_list_append(elist, &(element[eid])); \
171 #define _MMCAMCORDER_ELEMENT_MAKE2(sub_context, element, eid, name /*char* */, nickname /*char* */, err) \
173 if (element[eid].gst != NULL) { \
174 _mmcam_dbg_err("The element is existed. element_id=[%d], name=[%s]", eid, name); \
175 gst_object_unref(element[eid].gst); \
177 element[eid].gst = gst_element_factory_make(name, nickname); \
178 if (element[eid].gst == NULL) { \
179 _mmcam_dbg_err("Element creation fail. element_id=[%d], name=[%s]", eid, name); \
180 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
182 _mmcam_dbg_log("Element creation done. element_id=[%d], name=[%s]", eid, name); \
183 element[eid].id = eid; \
184 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
185 err = MM_ERROR_NONE; \
189 #define _MMCAMCORDER_ELEMENT_MAKE_IGNORE_ERROR(sub_context, element, eid, name /*char* */, nickname /*char* */, elist) \
191 if (element[eid].gst != NULL) { \
192 _mmcam_dbg_err("The element is existed. element_id=[%d], name=[%s]", eid, name); \
193 gst_object_unref(element[eid].gst); \
195 element[eid].gst = gst_element_factory_make(name, nickname); \
196 if (element[eid].gst == NULL) { \
197 _mmcam_dbg_err("Element creation fail. element_id=[%d], name=[%s], but keep going...", eid, name); \
199 _mmcam_dbg_log("Element creation done. element_id=[%d], name=[%s]", eid, name); \
200 element[eid].id = eid; \
201 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
202 elist = g_list_append(elist, &(element[eid])); \
206 #define _MMCAMCORDER_ELEMENT_ADD(sub_context, element, eid, gst_element, elist, err) \
208 if (element[eid].gst != NULL) { \
209 _mmcam_dbg_err("The element is existed. element_id=[%d]", eid); \
210 gst_object_unref(element[eid].gst); \
212 element[eid].gst = gst_element; \
213 if (element[eid].gst == NULL) { \
214 _mmcam_dbg_err("Element is NULL. element_id=[%d]", eid); \
215 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
216 goto pipeline_creation_error; \
218 _mmcam_dbg_log("Adding Element is done. element_id=[%d] %p", eid, gst_element); \
219 element[eid].id = eid; \
220 g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
221 err = MM_ERROR_NONE; \
223 elist = g_list_append(elist, &(element[eid])); \
226 #define _MMCAMCORDER_ENCODEBIN_ELMGET(sub_context, eid, name /*char* */, err) \
228 if (sub_context->encode_element[eid].gst != NULL) { \
229 _mmcam_dbg_err("The element is existed. element_id=[%d], name=[%s]", eid, name); \
230 gst_object_unref(sub_context->encode_element[eid].gst); \
232 sub_context->encode_element[eid].id = eid; \
233 g_object_get(G_OBJECT(sub_context->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst), name, &(sub_context->encode_element[eid].gst), NULL); \
234 if (sub_context->encode_element[eid].gst == NULL) { \
235 _mmcam_dbg_err("Encode Element get fail. element_id=[%d], name=[%s]", eid, name); \
236 err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \
237 goto pipeline_creation_error; \
239 gst_object_unref(sub_context->encode_element[eid].gst); \
240 g_object_weak_ref(G_OBJECT(sub_context->encode_element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
244 /* GStreamer element remove macro */
245 #define _MMCAMCORDER_ELEMENT_REMOVE(element, eid) \
246 if (element[eid].gst != NULL) { \
247 gst_object_unref(element[eid].gst); \
250 #define _MM_GST_ELEMENT_LINK_MANY gst_element_link_many
251 #define _MM_GST_ELEMENT_LINK gst_element_link
252 #define _MM_GST_ELEMENT_LINK_FILTERED gst_element_link_filtered
253 #define _MM_GST_ELEMENT_UNLINK gst_element_unlink
254 #define _MM_GST_PAD_LINK gst_pad_link
256 #define _MM_GST_PAD_LINK_UNREF(srcpad, sinkpad, err, if_fail_goto) \
258 GstPadLinkReturn ret = GST_PAD_LINK_OK; \
259 if (srcpad == NULL || sinkpad == NULL) { \
260 if (srcpad == NULL) { \
261 _mmcam_dbg_err("srcpad is NULL"); \
263 gst_object_unref(srcpad);\
266 if (sinkpad == NULL) { \
267 _mmcam_dbg_err("sinkpad is NULL"); \
269 gst_object_unref(sinkpad); \
272 err = MM_ERROR_CAMCORDER_GST_LINK; \
275 ret = _MM_GST_PAD_LINK(srcpad, sinkpad); \
276 if (ret != GST_PAD_LINK_OK) { \
277 GstObject *src_parent = gst_pad_get_parent(srcpad); \
278 GstObject *sink_parent = gst_pad_get_parent(sinkpad); \
279 char *src_name = NULL; \
280 char *sink_name = NULL; \
281 g_object_get((GObject *)src_parent, "name", &src_name, NULL); \
282 g_object_get((GObject *)sink_parent, "name", &sink_name, NULL); \
283 _mmcam_dbg_err("src[%s] - sink[%s] link failed", src_name, sink_name); \
284 gst_object_unref(src_parent); src_parent = NULL; \
285 gst_object_unref(sink_parent); sink_parent = NULL; \
287 free(src_name); src_name = NULL; \
290 free(sink_name); sink_name = NULL; \
292 gst_object_unref(srcpad); srcpad = NULL; \
293 gst_object_unref(sinkpad); sinkpad = NULL; \
294 err = MM_ERROR_CAMCORDER_GST_LINK; \
297 gst_object_unref(srcpad); srcpad = NULL; \
298 gst_object_unref(sinkpad); sinkpad = NULL; \
301 #define _MM_GST_PAD_UNLINK_UNREF(srcpad, sinkpad) \
303 if (srcpad && sinkpad) { \
304 gst_pad_unlink(srcpad, sinkpad); \
306 _mmcam_dbg_warn("some pad(srcpad:%p,sinkpad:%p) is NULL", srcpad, sinkpad); \
309 gst_object_unref(srcpad); srcpad = NULL; \
312 gst_object_unref(sinkpad); sinkpad = NULL; \
316 #define _MMCAMCORDER_STATE_SET_COUNT 3 /* checking interval */
317 #define _MMCAMCORDER_STATE_CHECK_TOTALTIME 5000000L /* total wating time for state change */
318 #define _MMCAMCORDER_STATE_CHECK_INTERVAL (50*1000) /* checking interval - 50ms*/
321 * Default videosink type
323 #define _MMCAMCORDER_DEFAULT_VIDEOSINK_TYPE "VideosinkElementOverlay"
326 * Default recording motion rate
328 #define _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE 1.0
331 * Total level count of manual focus */
332 #define _MMFCAMCORDER_FOCUS_TOTAL_LEVEL 8
335 * File name length limit
337 #define _MMCamcorder_FILENAME_LEN (512)
340 * File name for NULL path
342 #define _MMCamcorder_FILENAME_NULL "/dev/null"
345 * Minimum integer value
347 #define _MMCAMCORDER_MIN_INT (INT_MIN)
350 * Maximum integer value
352 #define _MMCAMCORDER_MAX_INT (INT_MAX)
355 * Minimum double value
357 #define _MMCAMCORDER_MIN_DOUBLE (DBL_MIN)
360 * Maximum integer value
362 #define _MMCAMCORDER_MAX_DOUBLE (DBL_MAX)
365 * Audio timestamp margin (msec)
367 #define _MMCAMCORDER_AUDIO_TIME_MARGIN (300)
370 * Functions related with LOCK and WAIT
372 #define _MMCAMCORDER_CAST_MTSAFE(handle) (((mmf_camcorder_t*)handle)->mtsafe)
373 #define _MMCAMCORDER_LOCK_FUNC(mutex) g_mutex_lock(&mutex)
374 #define _MMCAMCORDER_TRYLOCK_FUNC(mutex) g_mutex_trylock(&mutex)
375 #define _MMCAMCORDER_UNLOCK_FUNC(mutex) g_mutex_unlock(&mutex)
377 #define _MMCAMCORDER_GET_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).lock)
378 #define _MMCAMCORDER_LOCK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_LOCK(handle))
379 #define _MMCAMCORDER_TRYLOCK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_LOCK(handle))
380 #define _MMCAMCORDER_UNLOCK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_LOCK(handle))
382 #define _MMCAMCORDER_GET_COND(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).cond)
383 #define _MMCAMCORDER_WAIT(handle) g_cond_wait(&_MMCAMCORDER_GET_COND(handle), &_MMCAMCORDER_GET_LOCK(handle))
384 #define _MMCAMCORDER_WAIT_UNTIL(handle, end_time) g_cond_wait_until(&_MMCAMCORDER_GET_COND(handle), &_MMCAMCORDER_GET_LOCK(handle), end_time)
385 #define _MMCAMCORDER_SIGNAL(handle) g_cond_signal(&_MMCAMCORDER_GET_COND(handle));
386 #define _MMCAMCORDER_BROADCAST(handle) g_cond_broadcast(&_MMCAMCORDER_GET_COND(handle));
389 #define _MMCAMCORDER_GET_CMD_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).cmd_lock)
390 #define _MMCAMCORDER_GET_CMD_COND(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).cmd_cond)
391 #define _MMCAMCORDER_LOCK_CMD(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_CMD_LOCK(handle))
392 #define _MMCAMCORDER_TRYLOCK_CMD(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_CMD_LOCK(handle))
393 #define _MMCAMCORDER_UNLOCK_CMD(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_CMD_LOCK(handle))
394 #define _MMCAMCORDER_CMD_WAIT(handle) g_cond_wait(&_MMCAMCORDER_GET_CMD_COND(handle), &_MMCAMCORDER_GET_CMD_LOCK(handle))
395 #define _MMCAMCORDER_CMD_WAIT_UNTIL(handle, end_time) g_cond_wait_until(&_MMCAMCORDER_GET_CMD_COND(handle), &_MMCAMCORDER_GET_CMD_LOCK(handle), end_time)
396 #define _MMCAMCORDER_CMD_SIGNAL(handle) g_cond_signal(&_MMCAMCORDER_GET_CMD_COND(handle));
398 /* for interruption */
399 #define _MMCAMCORDER_GET_INTERRUPT_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).interrupt_lock)
400 #define _MMCAMCORDER_LOCK_INTERRUPT(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_INTERRUPT_LOCK(handle))
401 #define _MMCAMCORDER_TRYLOCK_INTERRUPT(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_INTERRUPT_LOCK(handle))
402 #define _MMCAMCORDER_UNLOCK_INTERRUPT(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_INTERRUPT_LOCK(handle))
404 /* for state change */
405 #define _MMCAMCORDER_GET_STATE_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).state_lock)
406 #define _MMCAMCORDER_LOCK_STATE(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_STATE_LOCK(handle))
407 #define _MMCAMCORDER_TRYLOCK_STATE(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_STATE_LOCK(handle))
408 #define _MMCAMCORDER_UNLOCK_STATE(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_STATE_LOCK(handle))
410 /* for gstreamer state change */
411 #define _MMCAMCORDER_GET_GST_STATE_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).gst_state_lock)
412 #define _MMCAMCORDER_LOCK_GST_STATE(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_GST_STATE_LOCK(handle))
413 #define _MMCAMCORDER_TRYLOCK_GST_STATE(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_GST_STATE_LOCK(handle))
414 #define _MMCAMCORDER_UNLOCK_GST_STATE(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_GST_STATE_LOCK(handle))
416 #define _MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).gst_encode_state_lock)
417 #define _MMCAMCORDER_LOCK_GST_ENCODE_STATE(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle))
418 #define _MMCAMCORDER_TRYLOCK_GST_ENCODE_STATE(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle))
419 #define _MMCAMCORDER_UNLOCK_GST_ENCODE_STATE(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle))
421 /* for setting/calling callback */
422 #define _MMCAMCORDER_GET_MESSAGE_CALLBACK_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).message_cb_lock)
423 #define _MMCAMCORDER_LOCK_MESSAGE_CALLBACK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_MESSAGE_CALLBACK_LOCK(handle))
424 #define _MMCAMCORDER_TRYLOCK_MESSAGE_CALLBACK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_MESSAGE_CALLBACK_LOCK(handle))
425 #define _MMCAMCORDER_UNLOCK_MESSAGE_CALLBACK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_MESSAGE_CALLBACK_LOCK(handle))
427 #define _MMCAMCORDER_GET_VCAPTURE_CALLBACK_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).vcapture_cb_lock)
428 #define _MMCAMCORDER_LOCK_VCAPTURE_CALLBACK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_VCAPTURE_CALLBACK_LOCK(handle))
429 #define _MMCAMCORDER_TRYLOCK_VCAPTURE_CALLBACK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_VCAPTURE_CALLBACK_LOCK(handle))
430 #define _MMCAMCORDER_UNLOCK_VCAPTURE_CALLBACK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_VCAPTURE_CALLBACK_LOCK(handle))
432 #define _MMCAMCORDER_GET_VSTREAM_CALLBACK_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).vstream_cb_lock)
433 #define _MMCAMCORDER_LOCK_VSTREAM_CALLBACK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_VSTREAM_CALLBACK_LOCK(handle))
434 #define _MMCAMCORDER_TRYLOCK_VSTREAM_CALLBACK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_VSTREAM_CALLBACK_LOCK(handle))
435 #define _MMCAMCORDER_UNLOCK_VSTREAM_CALLBACK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_VSTREAM_CALLBACK_LOCK(handle))
437 #define _MMCAMCORDER_GET_ASTREAM_CALLBACK_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).astream_cb_lock)
438 #define _MMCAMCORDER_LOCK_ASTREAM_CALLBACK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_ASTREAM_CALLBACK_LOCK(handle))
439 #define _MMCAMCORDER_TRYLOCK_ASTREAM_CALLBACK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_ASTREAM_CALLBACK_LOCK(handle))
440 #define _MMCAMCORDER_UNLOCK_ASTREAM_CALLBACK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_ASTREAM_CALLBACK_LOCK(handle))
442 #define _MMCAMCORDER_GET_MSTREAM_CALLBACK_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).mstream_cb_lock)
443 #define _MMCAMCORDER_LOCK_MSTREAM_CALLBACK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_MSTREAM_CALLBACK_LOCK(handle))
444 #define _MMCAMCORDER_TRYLOCK_MSTREAM_CALLBACK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_MSTREAM_CALLBACK_LOCK(handle))
445 #define _MMCAMCORDER_UNLOCK_MSTREAM_CALLBACK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_MSTREAM_CALLBACK_LOCK(handle))
447 #define _MMCAMCORDER_GET_VEDECISION_CALLBACK_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).vedecision_cb_lock)
448 #define _MMCAMCORDER_LOCK_VEDECISION_CALLBACK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_VEDECISION_CALLBACK_LOCK(handle))
449 #define _MMCAMCORDER_TRYLOCK_VEDECISION_CALLBACK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_VEDECISION_CALLBACK_LOCK(handle))
450 #define _MMCAMCORDER_UNLOCK_VEDECISION_CALLBACK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_VEDECISION_CALLBACK_LOCK(handle))
452 #ifdef _MMCAMCORDER_MM_RM_SUPPORT
453 /* for resource conflict */
454 #define _MMCAMCORDER_GET_RESOURCE_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).resource_lock)
455 #define _MMCAMCORDER_LOCK_RESOURCE(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_RESOURCE_LOCK(handle))
456 #define _MMCAMCORDER_UNLOCK_RESOURCE(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_RESOURCE_LOCK(handle))
457 #endif /* _MMCAMCORDER_MM_RM_SUPPORT */
460 * Caster of main handle (camcorder)
462 #define MMF_CAMCORDER(h) (mmf_camcorder_t *)(h)
465 * Caster of subcontext
467 #define MMF_CAMCORDER_SUBCONTEXT(h) (((mmf_camcorder_t *)(h))->sub_context)
469 /* LOCAL CONSTANT DEFINITIONS */
471 * Total Numbers of Attribute values.
472 * If you increase any enum of attribute values, you also have to increase this.
474 #define MM_CAMCORDER_MODE_NUM 3 /**< Number of mode type */
475 #define MM_CAMCORDER_COLOR_TONE_NUM 30 /**< Number of color-tone modes */
476 #define MM_CAMCORDER_WHITE_BALANCE_NUM 10 /**< Number of WhiteBalance modes*/
477 #define MM_CAMCORDER_SCENE_MODE_NUM 16 /**< Number of program-modes */
478 #define MM_CAMCORDER_FOCUS_MODE_NUM 6 /**< Number of focus mode*/
479 #define MM_CAMCORDER_AUTO_FOCUS_NUM 5 /**< Total count of auto focus type*/
480 #define MM_CAMCORDER_FOCUS_STATE_NUM 4 /**< Number of focus state */
481 #define MM_CAMCORDER_ISO_NUM 10 /**< Number of ISO */
482 #define MM_CAMCORDER_AUTO_EXPOSURE_NUM 9 /**< Number of Auto exposure type */
483 #define MM_CAMCORDER_WDR_NUM 3 /**< Number of wide dynamic range */
484 #define MM_CAMCORDER_FLIP_NUM 4 /**< Number of Filp mode */
485 #define MM_CAMCORDER_ROTATION_NUM 4 /**< Number of Rotation mode */
486 #define MM_CAMCORDER_AHS_NUM 4 /**< Number of anti-handshake */
487 #define MM_CAMCORDER_VIDEO_STABILIZATION_NUM 2 /**< Number of video stabilization */
488 #define MM_CAMCORDER_HDR_CAPTURE_NUM 3 /**< Number of HDR capture mode */
489 #define MM_CAMCORDER_GEOMETRY_METHOD_NUM 5 /**< Number of geometry method */
490 #define MM_CAMCORDER_TAG_ORT_NUM 8 /**< Number of tag orientation */
491 #define MM_CAMCORDER_STROBE_MODE_NUM 8 /**< Number of strobe mode type */
492 #define MM_CAMCORDER_STROBE_CONTROL_NUM 3 /**< Number of strobe control type */
493 #define MM_CAMCORDER_DETECT_MODE_NUM 2 /**< Number of detect mode type */
495 /*=======================================================================================
497 ========================================================================================*/
499 * Command for Camcorder.
502 /* Command for Video/Audio recording */
503 _MMCamcorder_CMD_RECORD,
504 _MMCamcorder_CMD_PAUSE,
505 _MMCamcorder_CMD_CANCEL,
506 _MMCamcorder_CMD_COMMIT,
508 /* Command for Image capture */
509 _MMCamcorder_CMD_CAPTURE,
511 /* Command for Preview(Video/Image only effective) */
512 _MMCamcorder_CMD_PREVIEW_START,
513 _MMCamcorder_CMD_PREVIEW_STOP,
520 _MMCamcorder_SINGLE_SHOT,
521 _MMCamcorder_MULTI_SHOT,
525 * Enumerations for manual focus direction.
526 * If focusing mode is not "MM_CAMCORDER_AF_MODE_MANUAL", this value will be ignored.
528 enum MMCamcorderMfLensDir {
529 MM_CAMCORDER_MF_LENS_DIR_FORWARD = 1, /**< Focus direction to forward */
530 MM_CAMCORDER_MF_LENS_DIR_BACKWARD, /**< Focus direction to backward */
531 MM_CAMCORDER_MF_LENS_DIR_NUM, /**< Total number of the directions */
535 * Camcorder Pipeline's Element name.
536 * @note index of element.
539 _MMCAMCORDER_NONE = (-1),
541 /* Main Pipeline Element */
542 _MMCAMCORDER_MAIN_PIPE = 0x00,
544 /* Pipeline element of Video input */
545 _MMCAMCORDER_VIDEOSRC_SRC,
546 _MMCAMCORDER_VIDEOSRC_FILT,
547 _MMCAMCORDER_VIDEOSRC_CLS_QUE,
548 _MMCAMCORDER_VIDEOSRC_CLS,
549 _MMCAMCORDER_VIDEOSRC_CLS_FILT,
550 _MMCAMCORDER_VIDEOSRC_QUE,
551 _MMCAMCORDER_VIDEOSRC_DECODE,
553 /* Pipeline element of Video output */
554 _MMCAMCORDER_VIDEOSINK_QUE,
555 _MMCAMCORDER_VIDEOSINK_CLS,
556 _MMCAMCORDER_VIDEOSINK_SINK,
558 _MMCAMCORDER_PIPELINE_ELEMENT_NUM,
559 } _MMCAMCORDER_PREVIEW_PIPELINE_ELELMENT;
562 * Camcorder Pipeline's Element name.
563 * @note index of element.
566 _MMCAMCORDER_ENCODE_NONE = (-1),
568 /* Main Pipeline Element */
569 _MMCAMCORDER_ENCODE_MAIN_PIPE = 0x00,
571 /* Pipeline element of Audio input */
572 _MMCAMCORDER_AUDIOSRC_BIN,
573 _MMCAMCORDER_AUDIOSRC_SRC,
574 _MMCAMCORDER_AUDIOSRC_FILT,
575 _MMCAMCORDER_AUDIOSRC_QUE,
576 _MMCAMCORDER_AUDIOSRC_CONV,
577 _MMCAMCORDER_AUDIOSRC_VOL,
578 _MMCAMCORDER_AUDIOSRC_RGA, /* for replay gain analysis element */
580 /* Pipeline element of Encodebin */
581 _MMCAMCORDER_ENCSINK_BIN,
582 _MMCAMCORDER_ENCSINK_SRC,
583 _MMCAMCORDER_ENCSINK_FILT,
584 _MMCAMCORDER_ENCSINK_ENCBIN,
585 _MMCAMCORDER_ENCSINK_AQUE,
586 _MMCAMCORDER_ENCSINK_CONV,
587 _MMCAMCORDER_ENCSINK_AENC,
588 _MMCAMCORDER_ENCSINK_AENC_QUE,
589 _MMCAMCORDER_ENCSINK_VQUE,
590 _MMCAMCORDER_ENCSINK_VSCALE,
591 _MMCAMCORDER_ENCSINK_VSCALE_FILT,
592 _MMCAMCORDER_ENCSINK_VCONV,
593 _MMCAMCORDER_ENCSINK_VENC,
594 _MMCAMCORDER_ENCSINK_VENC_QUE,
595 _MMCAMCORDER_ENCSINK_ITOG,
596 _MMCAMCORDER_ENCSINK_ICROP,
597 _MMCAMCORDER_ENCSINK_ISCALE,
598 _MMCAMCORDER_ENCSINK_IFILT,
599 _MMCAMCORDER_ENCSINK_IQUE,
600 _MMCAMCORDER_ENCSINK_IENC,
601 _MMCAMCORDER_ENCSINK_MUX,
602 _MMCAMCORDER_ENCSINK_SINK,
604 _MMCAMCORDER_ENCODE_PIPELINE_ELEMENT_NUM,
605 } _MMCAMCORDER_ENCODE_PIPELINE_ELELMENT;
608 _MMCAMCORDER_TASK_THREAD_STATE_NONE,
609 _MMCAMCORDER_TASK_THREAD_STATE_SOUND_PLAY_START,
610 _MMCAMCORDER_TASK_THREAD_STATE_SOUND_SOLO_PLAY_START,
611 _MMCAMCORDER_TASK_THREAD_STATE_ENCODE_PIPE_CREATE,
612 _MMCAMCORDER_TASK_THREAD_STATE_CHECK_CAPTURE_IN_RECORDING,
613 _MMCAMCORDER_TASK_THREAD_STATE_EXIT,
614 } _MMCamcorderTaskThreadState;
617 * System state change cause
620 _MMCAMCORDER_STATE_CHANGE_NORMAL = 0,
621 _MMCAMCORDER_STATE_CHANGE_BY_RM,
622 _MMCAMCORDER_STATE_CHANGE_BY_DPM,
623 _MMCAMCORDER_STATE_CHANGE_BY_STORAGE
624 } _MMCamcorderStateChange;
627 /*=======================================================================================
628 | STRUCTURE DEFINITIONS |
629 ========================================================================================*/
631 * MMCamcorder Gstreamer Element
634 unsigned int id; /**< Gstreamer piplinem element name */
635 GstElement *gst; /**< Gstreamer element */
636 } _MMCamcorderGstElement;
639 * MMCamcorder information for KPI measurement
642 int current_fps; /**< current fps of this second */
643 int average_fps; /**< average fps */
644 unsigned int video_framecount; /**< total number of video frame */
645 unsigned int last_framecount; /**< total number of video frame in last measurement */
646 struct timeval init_video_time; /**< time when start to measure */
647 struct timeval last_video_time; /**< last measurement time */
648 } _MMCamcorderKPIMeasure;
651 * MMCamcorder information for Multi-Thread Safe
654 GMutex lock; /**< Mutex (for general use) */
655 GCond cond; /**< Condition (for general use) */
656 GMutex cmd_lock; /**< Mutex (for command) */
657 GCond cmd_cond; /**< Condition (for command) */
658 GMutex interrupt_lock; /**< Mutex (for interruption) */
659 GMutex state_lock; /**< Mutex (for state change) */
660 GMutex gst_state_lock; /**< Mutex (for gst pipeline state change) */
661 GMutex gst_encode_state_lock; /**< Mutex (for gst encode pipeline state change) */
662 GMutex message_cb_lock; /**< Mutex (for message callback) */
663 GMutex vcapture_cb_lock; /**< Mutex (for video capture callback) */
664 GMutex vstream_cb_lock; /**< Mutex (for video stream callback) */
665 GMutex astream_cb_lock; /**< Mutex (for audio stream callback) */
666 GMutex mstream_cb_lock; /**< Mutex (for muxed stream callback) */
667 GMutex vedecision_cb_lock; /**< Mutex (for video encode decision callback) */
668 #ifdef _MMCAMCORDER_MM_RM_SUPPORT
669 GMutex resource_lock; /**< Mutex (for resource check) */
670 #endif /* _MMCAMCORDER_MM_RM_SUPPORT */
671 } _MMCamcorderMTSafe;
674 * MMCamcorder Replay gain value
681 } _MMCamcorderReplayGain;
684 * MMCamcorder Sub Context
687 bool isMaxsizePausing; /**< Because of size limit, pipeline is paused. */
688 bool isMaxtimePausing; /**< Because of time limit, pipeline is paused. */
689 int element_num; /**< count of element */
690 int encode_element_num; /**< count of encode element */
691 int frame_stability_count; /**< camsensor stability count. the count of frame will drop */
692 GstClockTime pipeline_time; /**< current time of Gstreamer Pipeline */
693 GstClockTime pause_time; /**< amount of time while pipeline is in PAUSE state.*/
694 GstClockTime stillshot_time; /**< pipeline time of capturing moment*/
695 gboolean is_modified_rate; /**< whether recording motion rate is modified or not */
696 gboolean ferror_send; /**< file write/seek error **/
697 guint ferror_count; /**< file write/seek error count **/
698 GstClockTime previous_slot_time;
699 int display_interval; /**< This value is set as 'GST_SECOND / display FPS' */
700 gboolean bget_eos; /**< Whether getting EOS */
701 gboolean bencbin_capture; /**< Use Encodebin for capturing */
702 gboolean audio_disable; /**< whether audio is disabled or not when record */
703 int videosrc_rotate; /**< rotate of videosrc */
704 unsigned long long muxed_stream_offset; /**< current offset for muxed stream data */
706 /* For dropping video frame when start recording */
707 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. */
708 int pass_first_vframe; /**< When this value is bigger than zero, MSL won't drop video frame though "drop_vframe" is bigger then zero. */
711 _MMCamcorderReplayGain replay_gain; /**< Replay gain for audio recording */
713 /* INI information */
714 unsigned int fourcc; /**< Get fourcc value of camera INI file */
715 _MMCamcorderImageInfo *info_image; /**< extra information for image capture */
716 _MMCamcorderVideoInfo *info_video; /**< extra information for video recording */
717 _MMCamcorderAudioInfo *info_audio; /**< extra information for audio recording */
719 _MMCamcorderGstElement *element; /**< array of preview element */
720 _MMCamcorderGstElement *encode_element; /**< array of encode element */
721 _MMCamcorderKPIMeasure kpi; /**< information related with performance measurement */
723 type_element *VideosinkElement; /**< configure data of videosink element */
724 type_element *VideoconvertElement; /**< configure data of videoconvert element */
725 type_element *VideodecoderElementH264; /**< configure data of video decoder element for H.264 format */
726 gboolean SensorEncodedCapture; /**< whether camera sensor support encoded image capture */
727 gboolean internal_encode; /**< whether use internal encoding function */
728 } _MMCamcorderSubContext;
731 * _MMCamcorderContext
733 typedef struct mmf_camcorder {
735 int type; /**< mmcamcorder_mode_type */
736 int device_type; /**< device type */
737 int state; /**< state of camcorder */
738 int old_state; /**< old state of camcorder */
741 MMHandleType attributes; /**< Attribute handle */
742 _MMCamcorderSubContext *sub_context; /**< sub context */
743 mm_exif_info_t *exif_info; /**< EXIF */
744 GList *buffer_probes; /**< a list of buffer probe handle */
745 GList *event_probes; /**< a list of event probe handle */
746 GList *signals; /**< a list of signal handle */
747 #ifdef _MMCAMCORDER_ENABLE_IDLE_MESSAGE_CALLBACK
748 GList *msg_data; /**< a list of msg data */
749 #endif /* _MMCAMCORDER_ENABLE_IDLE_MESSAGE_CALLBACK */
750 camera_conf *conf_main; /**< Camera configure Main structure */
751 camera_conf *conf_ctrl; /**< Camera configure Control structure */
752 #ifdef _MMCAMCORDER_RM_SUPPORT
753 int rm_handle; /**< Resource manager handle */
754 #endif /* _MMCAMCORDER_RM_SUPPORT */
755 guint pipeline_cb_event_id; /**< Event source ID of pipeline message callback */
756 guint encode_pipeline_cb_event_id; /**< Event source ID of encode pipeline message callback */
757 guint setting_event_id; /**< Event source ID of attributes setting to sensor */
758 SOUND_INFO snd_info; /**< Sound handle for multishot capture */
760 /* callback handlers */
761 MMMessageCallback msg_cb; /**< message callback */
762 void *msg_cb_param; /**< message callback parameter */
763 mm_camcorder_video_stream_callback vstream_cb; /**< Video stream callback */
764 void *vstream_cb_param; /**< Video stream callback parameter */
765 mm_camcorder_audio_stream_callback astream_cb; /**< Audio stream callback */
766 void *astream_cb_param; /**< Audio stream callback parameter */
767 mm_camcorder_muxed_stream_callback mstream_cb; /**< Muxed stream callback */
768 void *mstream_cb_param; /**< Muxed stream callback parameter */
769 mm_camcorder_video_capture_callback vcapture_cb; /**< Video capture callback */
770 void *vcapture_cb_param; /**< Video capture callback parameter */
771 mm_camcorder_video_encode_decision_callback vedecision_cb; /**< Video encode decision callback */
772 void *vedecision_cb_param; /**< Video encode decision callback parameter */
773 int (*command)(MMHandleType, int); /**< camcorder's command */
776 mm_cam_attr_construct_info *cam_attrs_const_info; /**< attribute info */
777 conf_info_table *conf_main_info_table[CONFIGURE_CATEGORY_MAIN_NUM]; /** configure info table - MAIN category */
778 conf_info_table *conf_ctrl_info_table[CONFIGURE_CATEGORY_CTRL_NUM]; /** configure info table - CONTROL category */
779 int conf_main_category_size[CONFIGURE_CATEGORY_MAIN_NUM]; /** configure info table size - MAIN category */
780 int conf_ctrl_category_size[CONFIGURE_CATEGORY_CTRL_NUM]; /** configure info table size - CONTROL category */
781 _MMCamcorderMTSafe mtsafe; /**< Thread safe */
782 int state_change_by_system; /**< MSL changes its state by itself because of system */
783 GMutex restart_preview_lock; /**< Capture sound mutex */
784 int use_zero_copy_format; /**< Whether use zero copy format for camera input */
785 int use_videoconvert; /**< Whether use videoconvert element for display */
786 int support_media_packet_preview_cb; /**< Whether support zero copy format for camera input */
787 int support_user_buffer; /**< Whether support user allocated buffer for zero copy */
788 int shutter_sound_policy; /**< shutter sound policy */
789 int brightness_default; /**< default value of brightness */
790 int brightness_step_denominator; /**< denominator of brightness bias step */
791 int support_zsl_capture; /**< support Zero Shutter Lag capture */
792 char *model_name; /**< model name from system info */
793 char *software_version; /**< software_version from system info */
794 int capture_sound_count; /**< count for capture sound */
795 char *root_directory; /**< Root directory for device */
796 int resolution_changed; /**< Flag for preview resolution change */
797 int interrupt_code; /**< Interrupt code */
798 int recreate_decoder; /**< Flag of decoder element recreation for encoded preview format */
800 _MMCamcorderInfoConverting caminfo_convert[CAMINFO_CONVERT_NUM]; /**< converting structure of camera info */
801 _MMCamcorderEnumConvert enum_conv[ENUM_CONVERT_NUM]; /**< enum converting list that is modified by ini info */
803 gboolean capture_in_recording; /**< Flag for capture while recording */
805 gboolean error_occurs; /**< flag for error */
806 int error_code; /**< error code for internal gstreamer error */
809 GThread *task_thread; /**< thread for task */
810 GMutex task_thread_lock; /**< mutex for task thread */
811 GCond task_thread_cond; /**< cond for task thread */
812 _MMCamcorderTaskThreadState task_thread_state; /**< state of task thread */
814 #ifdef _MMCAMCORDER_MM_RM_SUPPORT
815 /* resource manager for H/W resources */
816 mm_resource_manager_h resource_manager;
817 mm_resource_manager_res_h camera_resource;
818 mm_resource_manager_res_h video_overlay_resource;
819 mm_resource_manager_res_h video_encoder_resource;
820 gboolean is_release_cb_calling;
821 #endif /* _MMCAMCORDER_MM_RM_SUPPORT */
824 GDBusConnection *gdbus_conn; /**< gdbus connection */
825 _MMCamcorderGDbusCbInfo gdbus_info_sound; /**< Informations for the gbus cb of sound play */
826 _MMCamcorderGDbusCbInfo gdbus_info_solo_sound; /**< Informations for the gbus cb of solo sound play */
828 /* DPM(device policy manager) */
829 device_policy_manager_h dpm_handle; /**< DPM handle */
830 int dpm_camera_cb_id; /**< DPM camera policy changed callback id */
833 _MMCamcorderStorageInfo storage_info; /**< Storage information */
835 #ifdef _MMCAMCORDER_RM_SUPPORT
836 rm_category_request_s request_resources;
837 rm_device_return_s returned_devices;
838 #endif /* _MMCAMCORDER_RM_SUPPORT */
839 #ifdef _MMCAMCORDER_CAMERA_CONF_MGR_SUPPORT
840 camera_conf_device_info_s conf_device_info;
841 #endif /*_MMCAMCORDER_CAMERA_CONF_MGR_SUPPORT */
842 int reserved[4]; /**< reserved */
845 /*=======================================================================================
846 | EXTERN GLOBAL VARIABLE |
847 ========================================================================================*/
849 /*=======================================================================================
850 | GLOBAL FUNCTION PROTOTYPES |
851 ========================================================================================*/
853 * This function creates camcorder for capturing still image and recording.
855 * @param[out] handle Specifies the camcorder handle
856 * @param[in] info Preset information of camcorder
857 * @return This function returns zero on success, or negative value with error code.
858 * @remarks When this function calls successfully, camcorder handle will be filled with a @n
859 * valid value and the state of the camcorder will become MM_CAMCORDER_STATE_NULL.@n
860 * Note that it's not ready to working camcorder. @n
861 * You should call mmcamcorder_realize before starting camcorder.
862 * @see _mmcamcorder_create
864 int _mmcamcorder_create(MMHandleType *handle, MMCamPreset *info);
867 * This function destroys instance of camcorder.
869 * @param[in] hcamcorder Specifies the camcorder handle
870 * @return This function returns zero on success, or negative value with error code.
871 * @see _mmcamcorder_create
873 int _mmcamcorder_destroy(MMHandleType hcamcorder);
876 * This function allocates memory for camcorder.
878 * @param[in] hcamcorder Specifies the camcorder handle
879 * @return This function returns zero on success, or negative value with error code.
880 * @remarks This function can be called successfully when current state is MM_CAMCORDER_STATE_NULL @n
881 * and the state of the camcorder will become MM_CAMCORDER_STATE_READY. @n
882 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
883 * @see _mmcamcorder_unrealize
884 * @pre MM_CAMCORDER_STATE_NULL
885 * @post MM_CAMCORDER_STATE_READY
887 int _mmcamcorder_realize(MMHandleType hcamcorder);
890 * This function free allocated memory for camcorder.
892 * @param[in] hcamcorder Specifies the camcorder handle
893 * @return This function returns zero on success, or negative value with error code.
894 * @remarks This function release all resources which are allocated for the camcorder engine.@n
895 * This function can be called successfully when current state is MM_CAMCORDER_STATE_READY and @n
896 * the state of the camcorder will become MM_CAMCORDER_STATE_NULL. @n
897 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
898 * @see _mmcamcorder_realize
899 * @pre MM_CAMCORDER_STATE_READY
900 * @post MM_CAMCORDER_STATE_NULL
902 int _mmcamcorder_unrealize(MMHandleType hcamcorder);
905 * This function is to start previewing.
907 * @param[in] hcamcorder Specifies the camcorder handle
908 * @return This function returns zero on success, or negative value with error code.
909 * @remarks This function can be called successfully when current state is MM_CAMCORDER_STATE_READY and @n
910 * the state of the camcorder will become MM_CAMCORDER_STATE_PREPARE. @n
911 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
912 * @see _mmcamcorder_stop
914 int _mmcamcorder_start(MMHandleType hcamcorder);
917 * This function is to stop previewing.
919 * @param[in] hcamcorder Specifies the camcorder handle
920 * @return This function returns zero on success, or negative value with error code.
921 * @remarks This function can be called successfully when current state is MM_CAMCORDER_STATE_PREPARE and @n
922 * the state of the camcorder will become MM_CAMCORDER_STATE_READY.@n
923 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
924 * @see _mmcamcorder_start
926 int _mmcamcorder_stop(MMHandleType hcamcorder);
929 * This function to start capturing of still images.
931 * @param[in] hcamcorder Specifies the camcorder handle.
932 * @return This function returns zero on success, or negative value with error code.
933 * @remarks This function can be called successfully when current state is MM_CAMCORDER_STATE_PREPARE and @n
934 * the state of the camcorder will become MM_CAMCORDER_STATE_CAPTURING. @n
935 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
936 * @see _mmcamcorder_capture_stop
938 int _mmcamcorder_capture_start(MMHandleType hcamcorder);
941 * This function is to stop capturing still images.
943 * @param[in] hcamcorder Specifies the camcorder handle
944 * @return This function returns zero on success, or negative value with error code.
945 * @remarks This function can be called successfully when current state is MM_CAMCORDER_STATE_CAPTURING and @n
946 * the state of the camcorder will become MM_CAMCORDER_STATE_PREPARE. @n
947 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
948 * @see _mmcamcorder_capture_start
950 int _mmcamcorder_capture_stop(MMHandleType hcamcorder);
953 * This function is to start video and audio recording.
955 * @param[in] hcamcorder Specifies the camcorder handle
956 * @return This function returns zero on success, or negative value with error code.
957 * @remarks This function can be called successfully when current state is @n
958 * MM_CAMCORDER_STATE_PREPARE or MM_CAMCORDER_STATE_PAUSED and @n
959 * the state of the camcorder will become MM_CAMCORDER_STATE_RECORDING.@n
960 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
961 * @see _mmcamcorder_pause
963 int _mmcamcorder_record(MMHandleType hcamcorder);
966 * This function is to pause video and audio recording
968 * @param[in] hcamcorder Specifies the camcorder handle
969 * @return This function returns zero on success, or negative value with error code.
970 * @remarks This function can be called successfully when current state is MM_CAMCORDER_STATE_RECORDING and @n
971 * the state of the camcorder will become MM_CAMCORDER_STATE_PAUSED.@n
972 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.@n
973 * @see _mmcamcorder_record
975 int _mmcamcorder_pause(MMHandleType hcamcorder);
978 * This function is to stop video and audio recording and save results.
980 * @param[in] hcamcorder Specifies the camcorder handle
981 * @return This function returns zero on success, or negative value with error code.
982 * @remarks This function can be called successfully when current state is @n
983 * MM_CAMCORDER_STATE_PAUSED or MM_CAMCORDER_STATE_RECORDING and @n
984 * the state of the camcorder will become MM_CAMCORDER_STATE_PREPARE. @n
985 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION
986 * @see _mmcamcorder_cancel
988 int _mmcamcorder_commit(MMHandleType hcamcorder);
991 * This function is to stop video and audio recording and do not save results.
993 * @param[in] hcamcorder Specifies the camcorder handle
994 * @return This function returns zero on success, or negative value with error code.
995 * @remarks This function can be called successfully when current state is @n
996 * MM_CAMCORDER_STATE_PAUSED or MM_CAMCORDER_STATE_RECORDING and @n
997 * the state of the camcorder will become MM_CAMCORDER_STATE_PREPARE. @n
998 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
999 * @see _mmcamcorder_commit
1001 int _mmcamcorder_cancel(MMHandleType hcamcorder);
1004 * This function calls after commiting action finished asynchronously.
1005 * In this function, remaining process , such as state change, happens.
1007 * @param[in] hcamcorder Specifies the camcorder handle
1008 * @return This function returns zero on success, or negative value with error code.
1009 * @remarks This function can be called successfully when current state is @n
1010 * MM_CAMCORDER_STATE_PAUSED or MM_CAMCORDER_STATE_RECORDING and @n
1011 * the state of the camcorder will become MM_CAMCORDER_STATE_PREPARE. @n
1012 * Otherwise, this function will return MM_ERROR_CAMCORDER_INVALID_CONDITION.
1013 * @see _mmcamcorder_commit
1015 int _mmcamcorder_commit_async_end(MMHandleType hcamcorder);
1018 * This function is to set callback for receiving messages from camcorder.
1020 * @param[in] hcamcorder Specifies the camcorder handle
1021 * @param[in] callback Specifies the function pointer of callback function
1022 * @param[in] user_data Specifies the user poiner for passing to callback function
1024 * @return This function returns zero on success, or negative value with error code.
1025 * @remarks typedef bool (*mm_message_callback) (int msg, mm_messageType *param, void *user_param);@n
1040 * } mm_message_type; @n
1042 * If a message value for mm_message_callback is MM_MESSAGE_STATE_CHANGED, @n
1043 * state value in mm_message_type will be a mmcamcorder_state_type enum value;@n
1045 * If a message value for mm_message_callback is MM_MESSAGE_ERROR, @n
1046 * the code value in mm_message_type will be a mmplayer_error_type enum value;
1048 * @see mm_message_type, mmcamcorder_state_type, mmcamcorder_error_type
1050 int _mmcamcorder_set_message_callback(MMHandleType hcamcorder,
1051 MMMessageCallback callback,
1055 * This function is to set callback for video stream.
1057 * @param[in] hcamcorder Specifies the camcorder handle
1058 * @param[in] callback Specifies the function pointer of callback function
1059 * @param[in] user_data Specifies the user poiner for passing to callback function
1061 * @return This function returns zero on success, or negative value with error code.
1062 * @see mmcamcorder_error_type
1064 int _mmcamcorder_set_video_stream_callback(MMHandleType hcamcorder,
1065 mm_camcorder_video_stream_callback callback,
1069 * This function is to set callback for audio stream.
1071 * @param[in] hcamcorder Specifies the camcorder handle
1072 * @param[in] callback Specifies the function pointer of callback function
1073 * @param[in] user_data Specifies the user poiner for passing to callback function
1075 * @return This function returns zero on success, or negative value with error code.
1076 * @see mmcamcorder_error_type
1078 int _mmcamcorder_set_audio_stream_callback(MMHandleType handle,
1079 mm_camcorder_audio_stream_callback callback,
1083 * This function is to set callback for muxed stream.
1085 * @param[in] hcamcorder Specifies the camcorder handle
1086 * @param[in] callback Specifies the function pointer of callback function
1087 * @param[in] user_data Specifies the user poiner for passing to callback function
1089 * @return This function returns zero on success, or negative value with error code.
1090 * @see mmcamcorder_error_type
1092 int _mmcamcorder_set_muxed_stream_callback(MMHandleType handle,
1093 mm_camcorder_muxed_stream_callback callback,
1097 * This function is to set callback for video capture.
1099 * @param[in] hcamcorder Specifies the camcorder handle
1100 * @param[in] callback Specifies the function pointer of callback function
1101 * @param[in] user_data Specifies the user poiner for passing to callback function
1103 * @return This function returns zero on success, or negative value with error code.
1104 * @see mmcamcorder_error_type
1106 int _mmcamcorder_set_video_capture_callback(MMHandleType hcamcorder,
1107 mm_camcorder_video_capture_callback callback,
1111 * This function is to set callback for video encode decision.
1113 * @param[in] hcamcorder Specifies the camcorder handle
1114 * @param[in] callback Specifies the function pointer of callback function
1115 * @param[in] user_data Specifies the user poiner for passing to callback function
1117 * @return This function returns zero on success, or negative value with error code.
1119 int _mmcamcorder_set_video_encode_decision_callback(MMHandleType hcamcorder,
1120 mm_camcorder_video_encode_decision_callback callback,
1124 * This function returns current state of camcorder, or negative value with error code.
1126 * @param[in] hcamcorder Specifies the camcorder handle.
1127 * @return This function returns current state of camcorder, or negative value with error code.
1128 * @see mmcamcorder_state_type
1130 int _mmcamcorder_get_current_state(MMHandleType hcamcorder);
1132 int _mmcamcorder_init_focusing(MMHandleType handle);
1133 int _mmcamcorder_adjust_focus(MMHandleType handle, int direction);
1134 int _mmcamcorder_adjust_manual_focus(MMHandleType handle, int direction);
1135 int _mmcamcorder_adjust_auto_focus(MMHandleType handle);
1136 int _mmcamcorder_stop_focusing(MMHandleType handle);
1139 * This function gets current state of camcorder.
1142 * @return This function returns state of current camcorder context
1144 * @see _mmcamcorder_set_state()
1147 int _mmcamcorder_streamer_init(void);
1150 * This function gets current state of camcorder.
1153 * @return This function returns state of current camcorder context
1155 * @see _mmcamcorder_set_state()
1158 int _mmcamcorder_display_init(void);
1161 * This function gets current state of camcorder.
1163 * @param[in] handle Handle of camcorder context.
1164 * @return This function returns state of current camcorder context
1166 * @see _mmcamcorder_set_state()
1169 int _mmcamcorder_get_state(MMHandleType handle);
1170 int _mmcamcorder_get_state2(MMHandleType handle, int *state, int *old_state);
1173 * This function sets new state of camcorder.
1175 * @param[in] handle Handle of camcorder context.
1176 * @param[in] state setting state value of camcorder.
1179 * @see _mmcamcorder_get_state()
1182 void _mmcamcorder_set_state(MMHandleType handle, int state);
1185 * This function allocates structure of subsidiary attributes.
1187 * @param[in] type Allocation type of camcorder context.
1188 * @return This function returns structure pointer on success, NULL value on failure.
1190 * @see _mmcamcorder_dealloc_subcontext()
1193 _MMCamcorderSubContext *_mmcamcorder_alloc_subcontext(int type);
1196 * This function releases structure of subsidiary attributes.
1198 * @param[in] sc Handle of camcorder subcontext.
1201 * @see _mmcamcorder_alloc_subcontext()
1204 void _mmcamcorder_dealloc_subcontext(_MMCamcorderSubContext *sc);
1207 * This function sets command function according to the type.
1209 * @param[in] handle Handle of camcorder context.
1210 * @param[in] type Allocation type of camcorder context.
1211 * @return This function returns MM_ERROR_NONE on success, or other values with error code.
1213 * @see __mmcamcorder_video_command(), __mmcamcorder_audio_command(), __mmcamcorder_image_command()
1216 int _mmcamcorder_set_functions(MMHandleType handle, int type);
1219 * This function is callback function of main pipeline.
1220 * Once this function is registered with certain pipeline using gst_bus_add_watch(),
1221 * this callback will be called every time when there is upcomming message from pipeline.
1222 * Basically, this function is used as error handling function, now.
1224 * @param[in] bus pointer of buf that called this function.
1225 * @param[in] message callback message from pipeline.
1226 * @param[in] data user data.
1227 * @return This function returns true on success, or false value with error
1229 * @see __mmcamcorder_create_preview_pipeline()
1232 gboolean _mmcamcorder_pipeline_cb_message(GstBus *bus, GstMessage *message, gpointer data);
1235 * This function is callback function of main pipeline.
1236 * Once this function is registered with certain pipeline using gst_bus_set_sync_handler(),
1237 * this callback will be called every time when there is upcomming message from pipeline.
1238 * Basically, this function is used as sync error handling function, now.
1240 * @param[in] bus pointer of buf that called this function.
1241 * @param[in] message callback message from pipeline.
1242 * @param[in] data user data.
1243 * @return This function returns true on success, or false value with error
1245 * @see __mmcamcorder_create_preview_pipeline()
1248 GstBusSyncReply _mmcamcorder_pipeline_bus_sync_callback(GstBus *bus, GstMessage *message, gpointer data);
1251 * This function is callback function of encode pipeline.
1252 * Once this function is registered with certain pipeline using gst_bus_set_sync_handler(),
1253 * this callback will be called every time when there is upcomming message from pipeline.
1254 * Basically, this function is used for EOS and error handling now.
1256 * @param[in] bus pointer of buf that called this function.
1257 * @param[in] message callback message from pipeline.
1258 * @param[in] data user data.
1259 * @return This function returns true on success, or false value with error
1261 * @see __mmcamcorder_create_recorder_pipeline()
1262 * @see __mmcamcorder_create_audiop_with_encodebin()
1265 GstBusSyncReply _mmcamcorder_encode_pipeline_bus_sync_callback(GstBus *bus, GstMessage *message, gpointer data);
1268 * This function create main pipeline according to type.
1270 * @param[in] handle Handle of camcorder context.
1271 * @param[in] type Allocation type of camcorder context.
1272 * @return This function returns zero on success, or negative value with error code.
1274 * @see _mmcamcorder_destroy_pipeline()
1277 int _mmcamcorder_create_pipeline(MMHandleType handle, int type);
1280 * This function release all element of main pipeline according to type.
1282 * @param[in] handle Handle of camcorder context.
1283 * @param[in] type Allocation type of camcorder context.
1286 * @see _mmcamcorder_create_pipeline()
1289 void _mmcamcorder_destroy_pipeline(MMHandleType handle, int type);
1292 * This function sets gstreamer element status.
1293 * If the gstreamer fails to set status or returns asynchronous mode,
1294 * this function waits for state changed until timeout expired.
1296 * @param[in] pipeline Pointer of pipeline
1297 * @param[in] target_state newly setting status
1298 * @return This function returns zero on success, or negative value with error code.
1303 int _mmcamcorder_gst_set_state(MMHandleType handle, GstElement *pipeline, GstState target_state);
1306 /* For xvimagesink */
1307 GstBusSyncReply __mmcamcorder_sync_callback(GstBus *bus, GstMessage *message, gulong data);
1309 /* For querying capabilities */
1310 int _mmcamcorder_read_vidsrc_info(int videodevidx, camera_conf **configure_info);
1312 /* for performance check */
1313 void _mmcamcorder_video_current_framerate_init(MMHandleType handle);
1314 int _mmcamcorder_video_current_framerate(MMHandleType handle);
1315 int _mmcamcorder_video_average_framerate(MMHandleType handle);
1317 /* for stopping forcedly */
1318 void __mmcamcorder_force_stop(mmf_camcorder_t *hcamcorder, int state_change_by_system);
1320 /* device policy manager */
1321 void _mmcamcorder_dpm_camera_policy_changed_cb(const char *name, const char *value, void *user_data);
1323 /* Emit dbus signal */
1324 void _mmcamcorder_emit_signal(MMHandleType handle, const char *object_name,
1325 const char *interface_name, const char *signal_name, int value);
1327 /* external storage state management */
1328 int _mmcamcorder_manage_external_storage_state(MMHandleType handle, int storage_state);
1334 #endif /* __MM_CAMCORDER_INTERNAL_H__ */