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 /* ==============================================================================
24 ===============================================================================*/
30 #include "mm_camcorder.h"
31 #include "mm_camcorder_internal.h"
34 /*===============================================================================
35 | FUNCTION DEFINITIONS |
36 ===============================================================================*/
37 /*-------------------------------------------------------------------------------
38 | GLOBAL FUNCTION DEFINITIONS: |
39 -------------------------------------------------------------------------------*/
40 int mm_camcorder_create(MMHandleType *camcorder, MMCamPreset *info)
42 int error = MM_ERROR_NONE;
44 mmf_return_val_if_fail((void *)camcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
45 mmf_return_val_if_fail((void *)info, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
49 traceBegin(TTRACE_TAG_CAMERA, "MMCAMCORDER:CREATE");
51 error = _mmcamcorder_create(camcorder, info);
53 traceEnd(TTRACE_TAG_CAMERA);
55 MMCAM_LOG_ERROR("END");
61 int mm_camcorder_destroy(MMHandleType camcorder)
63 int error = MM_ERROR_NONE;
65 mmf_return_val_if_fail((void *)camcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
69 traceBegin(TTRACE_TAG_CAMERA, "MMCAMCORDER:DESTROY");
71 error = _mmcamcorder_destroy(camcorder);
73 traceEnd(TTRACE_TAG_CAMERA);
75 MMCAM_LOG_ERROR("END!!!");
81 int mm_camcorder_realize(MMHandleType camcorder)
83 int error = MM_ERROR_NONE;
85 mmf_return_val_if_fail((void *)camcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
89 _MMCAMCORDER_LOCK_INTERRUPT(camcorder);
91 traceBegin(TTRACE_TAG_CAMERA, "MMCAMCORDER:REALIZE");
93 error = _mmcamcorder_realize(camcorder);
95 traceEnd(TTRACE_TAG_CAMERA);
97 _MMCAMCORDER_UNLOCK_INTERRUPT(camcorder);
99 MMCAM_LOG_ERROR("END");
105 int mm_camcorder_unrealize(MMHandleType camcorder)
107 int error = MM_ERROR_NONE;
109 mmf_return_val_if_fail((void *)camcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
113 _MMCAMCORDER_LOCK_INTERRUPT(camcorder);
115 traceBegin(TTRACE_TAG_CAMERA, "MMCAMCORDER:UNREALIZE");
117 error = _mmcamcorder_unrealize(camcorder);
119 traceEnd(TTRACE_TAG_CAMERA);
121 _MMCAMCORDER_UNLOCK_INTERRUPT(camcorder);
123 MMCAM_LOG_ERROR("END");
129 int mm_camcorder_start(MMHandleType camcorder)
131 int error = MM_ERROR_NONE;
133 mmf_return_val_if_fail((void *)camcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
137 _MMCAMCORDER_LOCK_INTERRUPT(camcorder);
139 traceBegin(TTRACE_TAG_CAMERA, "MMCAMCORDER:START");
141 error = _mmcamcorder_start(camcorder);
143 traceEnd(TTRACE_TAG_CAMERA);
145 _MMCAMCORDER_UNLOCK_INTERRUPT(camcorder);
147 MMCAM_LOG_ERROR("END");
153 int mm_camcorder_stop(MMHandleType camcorder)
155 int error = MM_ERROR_NONE;
157 mmf_return_val_if_fail((void *)camcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
161 _MMCAMCORDER_LOCK_INTERRUPT(camcorder);
163 traceBegin(TTRACE_TAG_CAMERA, "MMCAMCORDER:STOP");
165 error = _mmcamcorder_stop(camcorder);
167 traceEnd(TTRACE_TAG_CAMERA);
169 _MMCAMCORDER_UNLOCK_INTERRUPT(camcorder);
171 MMCAM_LOG_ERROR("END");
177 int mm_camcorder_capture_start(MMHandleType camcorder)
179 int error = MM_ERROR_NONE;
181 mmf_return_val_if_fail((void *)camcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
185 _MMCAMCORDER_LOCK_INTERRUPT(camcorder);
187 error = _mmcamcorder_capture_start(camcorder);
189 _MMCAMCORDER_UNLOCK_INTERRUPT(camcorder);
191 MMCAM_LOG_ERROR("END");
197 int mm_camcorder_capture_stop(MMHandleType camcorder)
199 int error = MM_ERROR_NONE;
201 mmf_return_val_if_fail((void *)camcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
205 _MMCAMCORDER_LOCK_INTERRUPT(camcorder);
207 error = _mmcamcorder_capture_stop(camcorder);
209 _MMCAMCORDER_UNLOCK_INTERRUPT(camcorder);
211 MMCAM_LOG_ERROR("END");
217 int mm_camcorder_record(MMHandleType camcorder)
219 int error = MM_ERROR_NONE;
221 mmf_return_val_if_fail((void*)camcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
225 _MMCAMCORDER_LOCK_INTERRUPT(camcorder);
227 error = _mmcamcorder_record(camcorder);
229 _MMCAMCORDER_UNLOCK_INTERRUPT(camcorder);
231 MMCAM_LOG_ERROR("END");
237 int mm_camcorder_pause(MMHandleType camcorder)
239 int error = MM_ERROR_NONE;
241 mmf_return_val_if_fail((void *)camcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
245 _MMCAMCORDER_LOCK_INTERRUPT(camcorder);
247 error = _mmcamcorder_pause(camcorder);
249 _MMCAMCORDER_UNLOCK_INTERRUPT(camcorder);
251 MMCAM_LOG_ERROR("END");
257 int mm_camcorder_commit(MMHandleType camcorder)
259 int error = MM_ERROR_NONE;
261 mmf_return_val_if_fail((void *)camcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
265 _MMCAMCORDER_LOCK_INTERRUPT(camcorder);
267 error = _mmcamcorder_commit(camcorder);
269 _MMCAMCORDER_UNLOCK_INTERRUPT(camcorder);
271 MMCAM_LOG_ERROR("END");
277 int mm_camcorder_cancel(MMHandleType camcorder)
279 int error = MM_ERROR_NONE;
281 mmf_return_val_if_fail((void *)camcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
285 _MMCAMCORDER_LOCK_INTERRUPT(camcorder);
287 error = _mmcamcorder_cancel(camcorder);
289 _MMCAMCORDER_UNLOCK_INTERRUPT(camcorder);
291 MMCAM_LOG_ERROR("END");
297 int mm_camcorder_set_message_callback(MMHandleType camcorder, MMMessageCallback callback, void *user_data)
299 mmf_return_val_if_fail((void *)camcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
301 return _mmcamcorder_set_message_callback(camcorder, callback, user_data);
305 int mm_camcorder_set_video_stream_callback(MMHandleType camcorder, mm_camcorder_video_stream_callback callback, void* user_data)
307 mmf_return_val_if_fail((void *)camcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
309 return _mmcamcorder_set_video_stream_callback(camcorder, callback, user_data);
313 int mm_camcorder_set_audio_stream_callback(MMHandleType camcorder, mm_camcorder_audio_stream_callback callback, void* user_data)
315 mmf_return_val_if_fail((void *)camcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
317 return _mmcamcorder_set_audio_stream_callback(camcorder, callback, user_data);
321 int mm_camcorder_set_muxed_stream_callback(MMHandleType camcorder, mm_camcorder_muxed_stream_callback callback, void *user_data)
323 mmf_return_val_if_fail((void *)camcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
325 return _mmcamcorder_set_muxed_stream_callback(camcorder, callback, user_data);
329 int mm_camcorder_set_video_capture_callback(MMHandleType camcorder, mm_camcorder_video_capture_callback callback, void* user_data)
331 mmf_return_val_if_fail((void *)camcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
333 return _mmcamcorder_set_video_capture_callback(camcorder, callback, user_data);
337 int mm_camcorder_set_video_encode_decision_callback(MMHandleType camcorder, mm_camcorder_video_encode_decision_callback callback, void* user_data)
339 mmf_return_val_if_fail((void *)camcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
341 return _mmcamcorder_set_video_encode_decision_callback(camcorder, callback, user_data);
345 int mm_camcorder_get_state(MMHandleType camcorder, MMCamcorderStateType *state)
347 int ret = MM_ERROR_NONE;
350 MMCAM_LOG_WARNING("Empty handle.");
351 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
354 *state = _mmcamcorder_get_state(camcorder);
360 int mm_camcorder_get_state2(MMHandleType camcorder, MMCamcorderStateType *state, MMCamcorderStateType *old_state)
363 MMCAM_LOG_WARNING("Empty handle.");
364 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
367 return _mmcamcorder_get_state2(camcorder, (int *)state, (int *)old_state);
371 int mm_camcorder_get_attributes(MMHandleType camcorder, char **err_attr_name, const char *attribute_name, ...)
374 int ret = MM_ERROR_NONE;
376 mmf_return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
378 va_start(var_args, attribute_name);
379 ret = _mmcamcorder_get_attributes(camcorder, err_attr_name, attribute_name, var_args);
386 int mm_camcorder_set_attributes(MMHandleType camcorder, char **err_attr_name, const char *attribute_name, ...)
389 int ret = MM_ERROR_NONE;
391 mmf_return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
393 va_start(var_args, attribute_name);
394 ret = _mmcamcorder_set_attributes(camcorder, err_attr_name, attribute_name, var_args);
401 int mm_camcorder_get_attribute_info(MMHandleType camcorder, const char *attribute_name, MMCamAttrsInfo *info)
403 return _mmcamcorder_get_attribute_info(camcorder, attribute_name, info);
406 int mm_camcorder_get_fps_list_by_resolution(MMHandleType camcorder, int width, int height, MMCamAttrsInfo *fps_info)
408 return _mmcamcorder_get_fps_array_by_resolution(camcorder, width, height, fps_info);
412 int mm_camcorder_init_focusing(MMHandleType camcorder)
414 int error = MM_ERROR_NONE;
416 mmf_return_val_if_fail((void *)camcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
418 error = _mmcamcorder_init_focusing(camcorder);
424 int mm_camcorder_start_focusing(MMHandleType camcorder)
426 int error = MM_ERROR_NONE;
428 mmf_return_val_if_fail((void *)camcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
430 /* TODO : Add direction parameter */
432 error = _mmcamcorder_adjust_focus(camcorder, MM_CAMCORDER_MF_LENS_DIR_FORWARD);
438 int mm_camcorder_stop_focusing(MMHandleType camcorder)
440 int error = MM_ERROR_NONE;
442 mmf_return_val_if_fail((void *)camcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
444 error = _mmcamcorder_stop_focusing(camcorder);
449 void mm_camcorder_emit_signal(MMHandleType camcorder, const char *object_name,
450 const char *interface_name, const char *signal_name, int value)
452 mmf_return_if_fail((void *)camcorder);
454 _mmcamcorder_emit_signal(camcorder, object_name, interface_name, signal_name, value);
459 int mm_camcorder_check_codec_fileformat_compatibility(const char *codec_type, int codec, int file_format)
461 mmf_return_val_if_fail(codec_type, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
463 return _mmcamcorder_check_codec_fileformat_compatibility(codec_type, codec, file_format);
466 int mm_camcorder_manage_external_storage_state(MMHandleType camcorder, int storage_state)
468 mmf_return_val_if_fail((void *)camcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
470 return _mmcamcorder_manage_external_storage_state(camcorder, storage_state);
473 int mm_camcorder_get_log_level(void)
475 return _mmcamcorder_get_log_level();
478 int mm_camcorder_set_extra_preview_device_type(MMHandleType camcorder, int stream_id, int device_type)
480 return _mmcamcorder_set_extra_preview_device_type(camcorder, stream_id, device_type);
483 int mm_camcorder_set_extra_preview_stream_format(MMHandleType camcorder, int stream_id, int pixel_format, int width, int height, int fps)
485 return _mmcamcorder_set_extra_preview_stream_format(camcorder, stream_id, pixel_format, width, height, fps);
488 int mm_camcorder_get_extra_preview_stream_format(MMHandleType camcorder, int stream_id, int *pixel_format, int *width, int *height, int *fps)
490 return _mmcamcorder_get_extra_preview_stream_format(camcorder, stream_id, pixel_format, width, height, fps);
493 int mm_camcorder_set_extra_preview_bitrate(MMHandleType camcorder, int stream_id, int bitrate)
495 return _mmcamcorder_set_extra_preview_bitrate(camcorder, stream_id, bitrate);
498 int mm_camcorder_get_extra_preview_bitrate(MMHandleType camcorder, int stream_id, int *bitrate)
500 return _mmcamcorder_get_extra_preview_bitrate(camcorder, stream_id, bitrate);
503 int mm_camcorder_set_extra_preview_gop_interval(MMHandleType camcorder, int stream_id, int interval)
505 return _mmcamcorder_set_extra_preview_gop_interval(camcorder, stream_id, interval);
508 int mm_camcorder_get_extra_preview_gop_interval(MMHandleType camcorder, int stream_id, int *interval)
510 return _mmcamcorder_get_extra_preview_gop_interval(camcorder, stream_id, interval);