diff options
author | Kibum Kim <kb0929.kim@samsung.com> | 2012-01-07 00:42:22 +0900 |
---|---|---|
committer | Kibum Kim <kb0929.kim@samsung.com> | 2012-01-07 00:42:22 +0900 |
commit | 9d7310fbe194c33e3ab5bd40890022a1b3872649 (patch) | |
tree | 78a5d1f4661af100064115d77d0826ed2ead9270 | |
parent | f4360d5198f7024d048412a62d3b0a887e095c26 (diff) | |
download | camera-9d7310fbe194c33e3ab5bd40890022a1b3872649.tar.gz camera-9d7310fbe194c33e3ab5bd40890022a1b3872649.tar.bz2 camera-9d7310fbe194c33e3ab5bd40890022a1b3872649.zip |
Git init
-rwxr-xr-x | .gitignore | 26 | ||||
-rwxr-xr-x | AUTHORS | 2 | ||||
-rwxr-xr-x | CMakeLists.txt | 117 | ||||
-rwxr-xr-x | LICENSE | 206 | ||||
-rwxr-xr-x | capi-media-camera.pc.in | 15 | ||||
-rwxr-xr-x | debian/README | 0 | ||||
-rwxr-xr-x | debian/capi-media-camera-dev.install | 4 | ||||
-rwxr-xr-x | debian/capi-media-camera-dev.postinst | 1 | ||||
-rwxr-xr-x | debian/capi-media-camera.install | 1 | ||||
-rwxr-xr-x | debian/capi-media-camera.postinst | 1 | ||||
-rw-r--r-- | debian/changelog | 11 | ||||
-rwxr-xr-x | debian/compat | 1 | ||||
-rwxr-xr-x | debian/control | 22 | ||||
-rwxr-xr-x | debian/rules | 65 | ||||
-rwxr-xr-x | include/camera.h | 2366 | ||||
-rwxr-xr-x | include/camera_private.h | 69 | ||||
-rwxr-xr-x | packaging/capi-media-camera.spec | 53 | ||||
-rwxr-xr-x | src/camera.c | 1894 | ||||
-rwxr-xr-x | test/CMakeLists.txt | 21 | ||||
-rwxr-xr-x | test/multimedia_camera_test.c | 1039 |
20 files changed, 5914 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..f884ceb --- /dev/null +++ b/.gitignore @@ -0,0 +1,26 @@ +CMakeCache.txt +*/CMakeFiles/* +*.cmake +CMakeFiles* +*.a +*.so +Testing +cmake.depends +cmake.check_depends +cmake.check_cache +core +core.* +gmon.out +install_manifest.txt +*~ +.kdev_include_paths +src.kdev4 +.cproject +.project +tet_captured +tet_lock +*.pc +*-test +*-test_* +*tester.c +TC/config @@ -0,0 +1,2 @@ +Seungkeun Lee <sngn.lee@samsung.com> +Kangho Hur <kanho.hur@samsung.com> diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100755 index 0000000..6d03ef0 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,117 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) + +SET(Services + "application" + "base" + "content" + "location" + "media" + "messaging" + "network" + "social" + "telephony" + "system" + ) + +# project +SET(project_prefix "capi") +SET(prefix "/usr") +SET(version "0.0.1") +SET(maintainer "Seungkeun Lee <sngn.lee@samsung.com>, Kangho Hur<kagho.hur@samsung.com>") +SET(description "A Camera library in Tizen Native API") +SET(service "media") +SET(submodule "camera") + +# for package file +SET(dependents "dlog mm-camcorder capi-base-common") +# for deb +SET(deb_dependents "libdlog libmm-camcorder") + + + +SET(fw_name "${project_prefix}-${service}-${submodule}") + +PROJECT(${fw_name}) + +SET(CMAKE_INSTALL_PREFIX ${prefix}) +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) +SET(VERSION ${version}) + +SET(INC_DIR include) +INCLUDE_DIRECTORIES(${INC_DIR}) + +INCLUDE(FindPkgConfig) +pkg_check_modules(${fw_name} REQUIRED ${dependents}) +FOREACH(flag ${${fw_name}_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror") +SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") + +IF("${ARCH}" STREQUAL "arm") + ADD_DEFINITIONS("-DTARGET") +ENDIF("${ARCH}" STREQUAL "arm") + +ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"") +ADD_DEFINITIONS("-DTIZEN_DEBUG") + +SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib") + +aux_source_directory(src SOURCES) +ADD_LIBRARY(${fw_name} SHARED ${SOURCES}) + +TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS}) + +INSTALL(TARGETS ${fw_name} DESTINATION lib) +INSTALL( + DIRECTORY ${INC_DIR}/ DESTINATION include/${service} + FILES_MATCHING + PATTERN "*_private.h" EXCLUDE + PATTERN "${INC_DIR}/*.h" + ) + +SET(PC_NAME ${fw_name}) +SET(PC_REQUIRED ${dependents}) +SET(PC_LDFLAGS -l${fw_name}) +SET(PC_CFLAGS -I\${includedir}/${service}) + +CONFIGURE_FILE( + ${fw_name}.pc.in + ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc + @ONLY +) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION lib/pkgconfig) + +#ADD_SUBDIRECTORY(test) + +IF(UNIX) + +ADD_CUSTOM_TARGET (distclean @echo cleaning for source distribution) +ADD_CUSTOM_COMMAND( + DEPENDS clean + COMMENT "distribution clean" + COMMAND find + ARGS . + -not -name config.cmake -and \( + -name tester.c -or + -name Testing -or + -name CMakeFiles -or + -name cmake.depends -or + -name cmake.check_depends -or + -name CMakeCache.txt -or + -name cmake.check_cache -or + -name *.cmake -or + -name Makefile -or + -name core -or + -name core.* -or + -name gmon.out -or + -name install_manifest.txt -or + -name *.pc -or + -name *~ \) + | grep -v TC | xargs rm -rf + TARGET distclean + VERBATIM +) + +ENDIF(UNIX) @@ -0,0 +1,206 @@ +Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+
+
diff --git a/capi-media-camera.pc.in b/capi-media-camera.pc.in new file mode 100755 index 0000000..773d667 --- /dev/null +++ b/capi-media-camera.pc.in @@ -0,0 +1,15 @@ + +# Package Information for pkg-config + +prefix=@PREFIX@ +exec_prefix=/usr +libdir=/usr/lib +includedir=/usr/include/media + +Name: @PC_NAME@ +Description: @PACKAGE_DESCRIPTION@ +Version: @VERSION@ +Requires: @PC_REQUIRED@ +Libs: -L${libdir} @PC_LDFLAGS@ +Cflags: -I${includedir} @PC_CFLAGS@ + diff --git a/debian/README b/debian/README new file mode 100755 index 0000000..e69de29 --- /dev/null +++ b/debian/README diff --git a/debian/capi-media-camera-dev.install b/debian/capi-media-camera-dev.install new file mode 100755 index 0000000..761a28b --- /dev/null +++ b/debian/capi-media-camera-dev.install @@ -0,0 +1,4 @@ +/usr/include/* +/usr/include/*/* +/usr/lib/pkgconfig/*.pc + diff --git a/debian/capi-media-camera-dev.postinst b/debian/capi-media-camera-dev.postinst new file mode 100755 index 0000000..1a24852 --- /dev/null +++ b/debian/capi-media-camera-dev.postinst @@ -0,0 +1 @@ +#!/bin/sh diff --git a/debian/capi-media-camera.install b/debian/capi-media-camera.install new file mode 100755 index 0000000..4a755a4 --- /dev/null +++ b/debian/capi-media-camera.install @@ -0,0 +1 @@ +/usr/lib/lib*.so* diff --git a/debian/capi-media-camera.postinst b/debian/capi-media-camera.postinst new file mode 100755 index 0000000..1a24852 --- /dev/null +++ b/debian/capi-media-camera.postinst @@ -0,0 +1 @@ +#!/bin/sh diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..7b95887 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,11 @@ +capi-media-camera (0.1.0-7) unstable; urgency=low + + * Update version + + -- Seungkeun Lee <sngn.lee@samsung.com> Thu, 15 Dec 2011 12:52:02 +0900 + +capi-media-camera (0.0.1-1) unstable; urgency=low + + * Initial release. + + -- Seungkeun Lee <sngn.lee@samsung.com> Wed, 07 Dec 2011 12:42:07 +0900 diff --git a/debian/compat b/debian/compat new file mode 100755 index 0000000..7ed6ff8 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +5 diff --git a/debian/control b/debian/control new file mode 100755 index 0000000..758069a --- /dev/null +++ b/debian/control @@ -0,0 +1,22 @@ + +Source: capi-media-camera +Section: libs +Priority: extra +Maintainer: Seungkeun Lee <sngn.lee@samsung.com>, Kangho Hur<kagho.hur@samsung.com> +Build-Depends: debhelper (>= 5), libmm-camcorder-dev, libmm-common-dev, libmm-session-dev, capi-base-common-dev + +Package: capi-media-camera +Architecture: any +Depends: ${shilbs:Depends}, ${misc:Depends} +Description: A Camera library in Tizen Native API + +Package: capi-media-camera-dev +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, capi-media-camera (= ${Source-Version}), dlog-dev, capi-base-common-dev, libmm-camcorder-dev +Description: A Camera library in Tizen Native API (DEV) + +Package: capi-media-camera-dbg +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, capi-media-camera (= ${Source-Version}) +Description: A Camera library in Tizen Native API (DBG) + diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..989c066 --- /dev/null +++ b/debian/rules @@ -0,0 +1,65 @@ +#!/usr/bin/make -f + +CFLAGS = -Wall -g + +ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) + CFLAGS += -O0 +else + CFLAGS += -O2 +endif +CMAKE_ROOT_DIR ?= $(CURDIR) +CMAKE_BUILD_DIR ?= $(CURDIR)/cmake_build_tmp + +configure: configure-stamp +configure-stamp: + dh_testdir + mkdir -p $(CMAKE_BUILD_DIR) && cd $(CMAKE_BUILD_DIR) && cmake .. + touch configure-stamp + + +build: build-stamp +build-stamp: configure-stamp + dh_testdir + cd $(CMAKE_BUILD_DIR) && $(MAKE) + touch $@ + +clean: + cd $(CMAKE_ROOT_DIR) + dh_testdir + dh_testroot + rm -f build-stamp configure-stamp + rm -f + rm -rf $(CMAKE_BUILD_DIR) + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + cd $(CMAKE_BUILD_DIR) && $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install + +binary-indep: build install + +binary-arch: build install + dh_testdir + dh_testroot + dh_installchangelogs + dh_installdocs + dh_installexamples + dh_install --sourcedir=debian/tmp + dh_installman + dh_link + dh_strip --dbg-package=capi-media-camera-dbg + dh_fixperms + dh_makeshlibs + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install configure + diff --git a/include/camera.h b/include/camera.h new file mode 100755 index 0000000..c86e0f3 --- /dev/null +++ b/include/camera.h @@ -0,0 +1,2366 @@ +/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + + + +#ifndef __TIZEN_MULTIMEDIA_CAMERA_H__ +#define __TIZEN_MULTIMEDIA_CAMERA_H__ + +#include <tizen.h> + +#ifdef __cplusplus +extern "C" { +#endif + + +#define CAMERA_ERROR_CLASS TIZEN_ERROR_MULTIMEDIA_CLASS | 0x00 + + +/** + * @file camera.h + * @brief This file contains the Camera API, related structures and enumerations + */ + + +/** + * @addtogroup CAPI_MEDIA_CAMERA_MODULE + * @{ + */ + + +/** + * @brief Enumerations of the error code for Camera. + */ +typedef enum +{ + CAMERA_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ + CAMERA_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ + CAMERA_ERROR_INVALID_STATE = CAMERA_ERROR_CLASS | 0x02, /**< Invalid state */ + CAMERA_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ + CAMERA_ERROR_DEVICE = CAMERA_ERROR_CLASS | 0x04, /**< Device error */ + CAMERA_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Internal error */ + CAMERA_ERROR_SOUND_POLICY = CAMERA_ERROR_CLASS | 0x06, /**< Blocked by Audio Session Manager */ +} camera_error_e; + + +/** + * @brief Enumerations of the camera state. + */ +typedef enum +{ + CAMERA_STATE_NONE, /**< Before create */ + CAMERA_STATE_CREATED, /**< Created, but not initialized yet */ + CAMERA_STATE_PREVIEW, /**< Preview */ + CAMERA_STATE_CAPTURING, /**< While capturing */ + CAMERA_STATE_CAPTURED /**< After capturing */ +} camera_state_e; + + +/** + * @brief Enumerations of the camera device. + */ +typedef enum +{ + CAMERA_DEVICE_CAMERA0 = 0, /**< Primary camera */ + CAMERA_DEVICE_CAMERA1 /**< Secondary camera */ +} camera_device_e; + + +/** + * @brief Enumerations of the camera pixel format. + */ +typedef enum +{ + CAMERA_PIXEL_FORMAT_INVALID = -1, /**< Invalid pixel format */ + CAMERA_PIXEL_FORMAT_NV12, /**< NV12 pixel format */ + CAMERA_PIXEL_FORMAT_NV12T, /**< NV12 Tiled pixel format */ + CAMERA_PIXEL_FORMAT_NV16, /**< NV16 pixel format */ + CAMERA_PIXEL_FORMAT_NV21, /**< NV21 pixel format */ + CAMERA_PIXEL_FORMAT_YUYV, /**< YUYV(YUY2) pixel format */ + CAMERA_PIXEL_FORMAT_UYVY, /**< UYVY pixel format */ + CAMERA_PIXEL_FORMAT_422P, /**< YUV422(Y:U:V) planar pixel format */ + CAMERA_PIXEL_FORMAT_I420, /**< I420 pixel format */ + CAMERA_PIXEL_FORMAT_YV12, /**< YV12 pixel format */ + CAMERA_PIXEL_FORMAT_RGB565, /**< RGB565 pixel format */ + CAMERA_PIXEL_FORMAT_RGB888, /**< RGB888 pixel format */ + CAMERA_PIXEL_FORMAT_RGBA, /**< RGBA pixel format */ + CAMERA_PIXEL_FORMAT_ARGB, /**< ARGB pixel format */ + CAMERA_PIXEL_FORMAT_JPEG, /**< Encoded pixel format */ +} camera_pixel_format_e; + + +/** + * @brief Enumerations of the camera display type. + */ +typedef enum +{ + CAMERA_DISPLAY_TYPE_X11 = 0, /**< X surface display */ + CAMERA_DISPLAY_TYPE_EVAS = 1, /**< Evas object surface display */ + CAMERA_DISPLAY_TYPE_NONE = 3 /**< This disposes of buffers */ +} camera_display_type_e; + + +/** + * @brief The handle to the camera. + * @see recorder_create_videorecorder() + */ +typedef struct camera_s *camera_h; + + +/** + * @brief The handle to the camera display. + */ +typedef void *camera_display_h; + + +#ifndef GET_DISPLAY + +/** + * @brief Gets a display handle from x window id or evas object + */ +#define GET_DISPLAY(x) (void*)(x) + +#endif + +/** + * @} + */ + + +/** + * @addtogroup CAPI_MEDIA_CAMERA_X11_DISPLAY_MODULE + * @{ + */ + + +/** + * @brief Enumerations of the camera display rotation type. + */ +typedef enum +{ + CAMERA_DISPLAY_ROTATION_NONE, /**< No rotation of the display */ + CAMERA_DISPLAY_ROTATION_90, /**< 90 degree rotation */ + CAMERA_DISPLAY_ROTATION_180, /**< 180 degree rotation */ + CAMERA_DISPLAY_ROTATION_270, /**< 270 degree rotation */ +} camera_display_rotation_e; + +/** + * @brief Enumerations of the camera display mode. + */ +typedef enum +{ + CAMERA_DISPLAY_MODE_LETTER_BOX = 0, /**< Letter box*/ + CAMERA_DISPLAY_MODE_ORIGIN_SIZE, /**< Origin size*/ + CAMERA_DISPLAY_MODE_FULL, /**< full screen*/ + CAMERA_DISPLAY_MODE_CROPPED_FULL, /**< Cropped full screen*/ +} camera_display_mode_e; + + +/** + * @} + */ + + +/** + * @addtogroup CAPI_MEDIA_CAMERA_ATTRIBUTES_MODULE + * @{ + */ + + +/** + * @brief Enumerations of the color tone which provides an impression of looking through a tinted glass. + */ +typedef enum +{ + CAMERA_ATTR_EFFECT_NONE = 0, /**< None */ + CAMERA_ATTR_EFFECT_MONO, /**< Mono */ + CAMERA_ATTR_EFFECT_SEPIA, /**< Sepia */ + CAMERA_ATTR_EFFECT_NEGATIVE, /**< Negative */ + CAMERA_ATTR_EFFECT_BLUE, /**< Blue */ + CAMERA_ATTR_EFFECT_GREEN, /**< Green */ + CAMERA_ATTR_EFFECT_AQUA, /**< Aqua */ + CAMERA_ATTR_EFFECT_VIOLET, /**< Violet */ + CAMERA_ATTR_EFFECT_ORANGE, /**< Orange */ + CAMERA_ATTR_EFFECT_GRAY, /**< Gray */ + CAMERA_ATTR_EFFECT_RED, /**< Red */ + CAMERA_ATTR_EFFECT_ANTIQUE, /**< Antique */ + CAMERA_ATTR_EFFECT_WARM, /**< Warm */ + CAMERA_ATTR_EFFECT_PINK, /**< Pink */ + CAMERA_ATTR_EFFECT_YELLOW, /**< Yellow */ + CAMERA_ATTR_EFFECT_PURPLE, /**< Purple */ + CAMERA_ATTR_EFFECT_EMBOSS, /**< Emboss */ + CAMERA_ATTR_EFFECT_OUTLINE, /**< Outline */ + CAMERA_ATTR_EFFECT_SOLARIZATION, /**< Solarization */ + CAMERA_ATTR_EFFECT_SKETCH, /**< Sketch */ +} camera_attr_effect_mode_e; + + +/** + * @brief Enumerations of the white balance levels of the camera. + */ +typedef enum +{ + CAMERA_ATTR_WHITE_BALANCE_NONE = 0, /**< None */ + CAMERA_ATTR_WHITE_BALANCE_AUTOMATIC, /**< Automatic */ + CAMERA_ATTR_WHITE_BALANCE_DAYLIGHT, /**< Daylight */ + CAMERA_ATTR_WHITE_BALANCE_CLOUDY, /**< Cloudy */ + CAMERA_ATTR_WHITE_BALANCE_FLUORESCENT, /**< Fluorescent */ + CAMERA_ATTR_WHITE_BALANCE_INCANDESCENT, /**< Incandescent */ + CAMERA_ATTR_WHITE_BALANCE_SHADE, /**< Shade */ + CAMERA_ATTR_WHITE_BALANCE_HORIZON, /**< Horizon */ + CAMERA_ATTR_WHITE_BALANCE_FLASH, /**< Flash */ + CAMERA_ATTR_WHITE_BALANCE_CUSTOM, /**< Custom */ +} camera_attr_whitebalance_e; + + +/** + * @brief Enumerations of the scene mode. + * The mode of operation can be in daylight, night and back-light. + */ +typedef enum +{ + CAMERA_ATTR_SCENE_MODE_NORMAL = 0, /**< Normal */ + CAMERA_ATTR_SCENE_MODE_PORTRAIT, /**< Portrait */ + CAMERA_ATTR_SCENE_MODE_LANDSCAPE, /**< Landscape */ + CAMERA_ATTR_SCENE_MODE_SPORTS, /**< Sports */ + CAMERA_ATTR_SCENE_MODE_PARTY_N_INDOOR, /**< Party & indoor */ + CAMERA_ATTR_SCENE_MODE_BEACH_N_INDOOR, /**< Beach & indoor */ + CAMERA_ATTR_SCENE_MODE_SUNSET, /**< Sunset */ + CAMERA_ATTR_SCENE_MODE_DUSK_N_DAWN, /**< Dusk & dawn */ + CAMERA_ATTR_SCENE_MODE_FALL_COLOR, /**< Fall */ + CAMERA_ATTR_SCENE_MODE_NIGHT_SCENE, /**< Night scene */ + CAMERA_ATTR_SCENE_MODE_FIREWORK, /**< Firework */ + CAMERA_ATTR_SCENE_MODE_TEXT, /**< Text */ + CAMERA_ATTR_SCENE_MODE_SHOW_WINDOW, /**< Show window */ + CAMERA_ATTR_SCENE_MODE_CANDLE_LIGHT, /**< Candle light */ + CAMERA_ATTR_SCENE_MODE_BACKLIGHT, /**< Backlight */ +} camera_attr_scene_mode_e; + + +/** + * @brief Enumerations of the auto focus mode. + */ +typedef enum +{ + CAMERA_ATTR_AF_NONE = 0, /**< auto-focus is not set */ + CAMERA_ATTR_AF_NORMAL, /**< auto-focus normally */ + CAMERA_ATTR_AF_MACRO, /**< auto-focus in macro mode(close distance) */ + CAMERA_ATTR_AF_FULL, /**< auto-focus in full mode(all range scan, limited by dev spec) */ +} camera_attr_af_mode_e; + + +/** + * @brief Enumerations of the camera focus state. + */ +typedef enum +{ + CAMERA_FOCUS_STATE_RELEASED = 0, /**< Focus released.*/ + CAMERA_FOCUS_STATE_ONGOING, /**< Focus in progress*/ + CAMERA_FOCUS_STATE_FOCUSED, /**< Focus success*/ + CAMERA_FOCUS_STATE_FAILED, /**< Focus failed*/ +} camera_focus_state_e; + + +/** + * @brief Enumerations for the ISO levels of the camera. + */ +typedef enum +{ + CAMERA_ATTR_ISO_AUTO = 0, /**< ISO auto mode*/ + CAMERA_ATTR_ISO_50, /**< ISO 50*/ + CAMERA_ATTR_ISO_100, /**< ISO 100*/ + CAMERA_ATTR_ISO_200, /**< ISO 200*/ + CAMERA_ATTR_ISO_400, /**< ISO 400*/ + CAMERA_ATTR_ISO_800, /**< ISO 800*/ + CAMERA_ATTR_ISO_1600, /**< ISO 1600*/ + CAMERA_ATTR_ISO_3200, /**< ISO 3200*/ +} camera_attr_iso_e; + + +/** + * @brief Enumerations of the camera exposure modes. + */ +typedef enum +{ + CAMERA_ATTR_EXPOSURE_MODE_OFF = 0, /**< Off*/ + CAMERA_ATTR_EXPOSURE_MODE_ALL, /**< All mode*/ + CAMERA_ATTR_EXPOSURE_MODE_CENTER, /**< Center mode*/ + CAMERA_ATTR_EXPOSURE_MODE_SPOT, /**< Spot mode*/ + CAMERA_ATTR_EXPOSURE_MODE_CUSTOM, /**< Custom mode*/ +} camera_attr_exposure_mode_e; + + +/** + * @brief Enumerations for the orientation values of tag. + */ +typedef enum +{ + CAMERA_ATTR_TAG_ORIENTATION_TOP_LEFT = 1, /**< Row #0 is top, Column #0 is left */ + CAMERA_ATTR_TAG_ORIENTATION_TOP_RIGHT = 2, /**< Row #0 is top, Column #0 is right */ + CAMERA_ATTR_TAG_ORIENTATION_BOTTOM_RIGHT = 3, /**< Row #0 is bottom, Column #0 is right */ + CAMERA_ATTR_TAG_ORIENTATION_BOTTOM_LEFT = 4, /**< Row #0 is bottom, Column #0 is left */ + CAMERA_ATTR_TAG_ORIENTATION_LEFT_TOP = 5, /**< Row #0 is left, Column #0 is top */ + CAMERA_ATTR_TAG_ORIENTATION_RIGHT_TOP = 6, /**< Row #0 is right, Column #0 is top */ + CAMERA_ATTR_TAG_ORIENTATION_RIGHT_BOTTOM = 7, /**< Row #0 is right, Column #0 is bottom */ + CAMERA_ATTR_TAG_ORIENTATION_LEFT_BOTTOM = 8, /**< Row #0 is left, Column #0 is bottom */ +} camera_attr_tag_orientation_e; + + +/** + * @brief Enumerations of the flash mode. + */ +typedef enum +{ + CAMERA_ATTR_FLASH_MODE_OFF = 0, /**< Always off */ + CAMERA_ATTR_FLASH_MODE_ON, /**< Always splashes */ + CAMERA_ATTR_FLASH_MODE_AUTO, /**< Depending on intensity of light, strobe starts to flash. */ + CAMERA_ATTR_FLASH_MODE_REDEYE_REDUCTION, /**< Red eye reduction. Multiple flash before capturing. */ + CAMERA_ATTR_FLASH_MODE_SLOW_SYNC, /**< Slow sync curtain synchronization*/ + CAMERA_ATTR_FLASH_MODE_FRONT_CURTAIN, /**< Front curtain synchronization. */ + CAMERA_ATTR_FLASH_MODE_REAR_CURTAIN, /**< Rear curtain synchronization. */ + CAMERA_ATTR_FLASH_MODE_PERMANENT, /**< keep turned on until turning off */ +} camera_attr_flash_mode_e; + + +/** + * @brief Enumerations of the preview fps. + */ +typedef enum +{ + CAMERA_ATTR_FPS_AUTO = 0, /**< AUTO FPS */ + CAMERA_ATTR_FPS_8 = 8, /**< 8 FPS */ + CAMERA_ATTR_FPS_15 = 15, /**< 15 FPS */ + CAMERA_ATTR_FPS_24 = 24, /**< 24 FPS */ + CAMERA_ATTR_FPS_25 = 25, /**< 25 FPS */ + CAMERA_ATTR_FPS_30 = 30, /**< 30 FPS */ + CAMERA_ATTR_FPS_60 = 60, /**< 60 FPS */ + CAMERA_ATTR_FPS_120 = 120 /**< 120 FPS */ +} camera_attr_fps_e; + + +/** + * @} + */ + +/** + * @addtogroup CAPI_MEDIA_CAMERA_MODULE + * @{ + */ + + +/** + * @brief Called when the camera state changes. + * + * @remarks When camera is used as a recorder then this callback function won't be called. + * + * @param[in] previous The previous state of the camera + * @param[in] current The current state of the camera + * @param[in] by_policy @c true if the state is changed by sound policy, otherwise @c false + * @param[in] user_data The user data passed from the callback registration function + * @pre camera_start_preview(), camera_start_capture() or camera_stop_preview() + * will invoke this callback if you registers this callback unsing camera_set_state_changed_cb(). + * @see camera_set_state_changed_cb() + */ +typedef void (*camera_state_changed_cb)(camera_state_e previous, camera_state_e current, + bool by_policy, void *user_data); + + +/** + * @brief Called when the camera focus state changes. + * @details When the camera auto focus completes or a change to the focus state occurs, + * this callback is invoked. \n \n + * Changes of focus state are as follows: \n + * #CAMERA_FOCUS_STATE_RELEASED -> start focusing -> #CAMERA_FOCUS_STATE_ONGOING -> working -> + * #CAMERA_FOCUS_STATE_FOCUSED or #CAMERA_FOCUS_STATE_FAILED + * + * @param[in] state The current state of the auto-focus + * @param[in] user_data The user data passed from the callback registration function + * @pre camera_start_focusing() will invoke this callback if you register it using camera_set_focus_changed_cb (). + * @see camera_set_focus_changed_cb() + * @see camera_unset_focus_changed_cb() + * @see camera_start_focusing() + * @see camera_cancel_focusing() + */ +typedef void (*camera_focus_changed_cb)(camera_focus_state_e state, void *user_data); + + +/** + * @brief Called to be notified for delivering copy of new preview frame when every preview frame is displayed. + * + * @remarks This function is issued in the context of gstreamer (video sink thread) so you should not directly invoke UI update code.\n + * When camera is used as a recorder then this callback function won't be called. + * + * @param[in] stream_buffer Reference pointer to video stream data + * @param[in] buffer_size The length of stream buffer (in bytes) + * @param[in] width The part of the frame resolution, width of the scene + * @param[in] height The part of the frame resolution, height of the scene + * @param[in] format The camera pixel format, as specified + * @param[in] user_data The user data passed from the callback registration function + * @pre camera_start_preview() will invoke this callback function if you register this callback using camera_set_preview_cb(). + * @see camera_start_preview() + * @see camera_set_preview_cb() + * @see camera_unset_preview_cb() + */ +typedef void (*camera_preview_cb)(void *stream_buffer, int buffer_size, int width, int height, + camera_pixel_format_e format, void *user_data); + + +/** + * @brief Called to get information about image data taken by the camera once per frame while capturing. + * + * @remarks This function is issued in the context of gstreamer (video source thread) so you should not directly invoke UI update code. + * You must not call camera_stop_preview() within this callback. + * + * @param[in] image_buffer The reference pointer to captured data + * @param[in] buffer_size The length of stream buffer (in bytes) + * @param[in] width The width of frame resolution + * @param[in] height The height of frame resolution + * @param[in] format The camera pixel format + * @param[in] user_data The user data passed from the callback registration function + * @pre camera_start_capture() will invoke this callback function if you register this callback using camera_set_capturing_cb(). + * @see camera_set_capturing_cb() + * @see camera_unset_capturing_cb() + * @see camera_start_capture() + */ +typedef void (*camera_capturing_cb)(void *image_buffer, int buffer_size, int width, int height, + camera_pixel_format_e format, void *user_data); + + +/** + * @brief Called when the camera capturing completes. + * + * @remarks The callback is called after end of camera_capturing_cb().\n + * If you want to show the user preview after finishing capturing, an application can use camera_start_preview() after calling this callback. + * + * @param[in] user_data The user data passed from the callback registration function + * + * @pre This callback function is invoked if you register this callback using camera_set_capture_completed_cb(). + * @see camera_set_capture_completed_cb() + * @see camera_unset_capture_completed_cb() + * @see camera_capturing_cb() + */ +typedef void (*camera_capture_completed_cb)(void *user_data); + + +/** + * @brief Called when the error occurred. + * + * @remarks The callback is called when inform asynchronous operation error. + * @param[in] error The error message + * @param[in] current_state The current state of the camera + * @param[in] user_data The user data passed from the callback registration function + * + * @pre This callback function is invoked if you register this callback using camera_set_error_cb(). + * @see camera_set_error_cb() + * @see camera_unset_error_cb() + */ +typedef void (*camera_error_cb)(int error, camera_state_e current_state, void *user_data); + +/** + * @} + */ + +/** + * @addtogroup CAPI_MEDIA_CAMERA_CAPABILITY_MODULE + * @{ + */ + +/** + * @brief Called once for each supported preview resolution. + * + * @param[in] width The preview image width + * @param[in] height The preview image height + * @param[in] user_data The user data passed from the foreach function + * + * @return @c true to continue with the next iteration of the loop, \n @c false to break outsp of the loop. + * @pre camera_foreach_supported_preview_resolution() will invoke this callback. + * + * @see camera_foreach_supported_preview_resolution() + */ +typedef bool (*camera_supported_preview_resolution_cb)(int width, int height, void *user_data); + + +/** + * @brief Called once for each supported capture resolution. + * + * @param[in] width The capture resolution width + * @param[in] height The capture resolution height + * @param[in] user_data The user data passed from the foreach function + * + * @return @c true to continue with the next iteration of the loop, \n @c false to break outsp of the loop. + * @pre camera_foreach_supported_capture_resolution() will invoke this callback. + * + * @see camera_foreach_supported_capture_resolution() + */ +typedef bool (*camera_supported_capture_resolution_cb)(int width, int height, void *user_data); + + +/** + * @brief Called once for the pixel format of each supported capture format. + * + * @param[in] format The supported pixel format + * @param[in] user_data The user data passed from the foreach function + * @return @c true to continue with the next iteration of the loop, \n @c false to break outsp of the loop. + * @pre camera_foreach_supported_capture_format() will invoke this callback. + * + * @see camera_foreach_supported_capture_format() + */ +typedef bool (*camera_supported_capture_format_cb)(camera_pixel_format_e format, + void *user_data); + +/** + * @brief Called once for the pixel format of each supported preview format. + * + * @param[in] format The supported preview data format + * @param[in] user_data The user data passed from the foreach function + * @return @c true to continue with the next iteration of the loop, \n @c false to break outsp of the loop. + * @pre camera_foreach_supported_preview_format() will invoke this callback. + * + * @see camera_foreach_supported_preview_format() + */ +typedef bool (*camera_supported_preview_format_cb)(camera_pixel_format_e format, + void *user_data); + +/** + * @} + */ + +/** + * @addtogroup CAPI_MEDIA_CAMERA_MODULE + * @{ + */ + +/** + * @brief Creates a new camera handle for controlling a camera. + * + * @remarks You can create multiple handles on a context at the same time. However, + * camera cannot guarantee proper operation because of limitation of resources, such as + * camera device, audio device, and display device.\n + * a @a camera must be released with camera_destroy() by you. + * + * @param[in] device The hardware camera to access + * @param[out] camera A newly returned handle to the camera + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAMERA_ERROR_OUT_OF_MEMORY Out of memory + * @retval #CAMERA_ERROR_SOUND_POLICY Sound policy error + * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation + * @post If it succeeds the camera state will be #CAMERA_STATE_CREATED. + * + * @see camera_destroy() + */ +int camera_create(camera_device_e device, camera_h *camera); + +/** + * @brief Destroys the camera handle and releases all its resources. + * + * @param[in] camera The handle to the camera + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAMERA_ERROR_INVALID_STATE Invalid state + * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation + * + * @see camera_create() + */ +int camera_destroy(camera_h camera); + +/** + * @brief Starts capturing and drawing preview frames on the screen. + * + * @param[in] camera The handle to the camera + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAMERA_ERROR_INVALID_STATE Invalid state + * @retval #CAMERA_ERROR_SOUND_POLICY Sound policy error + * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation + * @pre The camera state should be #CAMERA_STATE_CREATED, or #CAMERA_STATE_CAPTURED.\n + * You must set display handle. \n + * If needed, modify preview fps(camera_attr_set_preview_fps()), + * preview resolution(camera_set_preview_resolution()) or preview format(camera_set_preview_format()) + * @post If it succeeds, the camera state will be #CAMERA_STATE_PREVIEW.\n + * camera_preview_cb() will be called when preview image data becomes available. + * + * @see camera_stop_preview() + * @see camera_set_display() + * @see camera_set_preview_cb() + * @see camera_foreach_supported_preview_resolution() + * @see camera_set_preview_resolution() + * @see camera_get_preview_resolution() + * @see camera_foreach_supported_preview_format() + * @see camera_set_preview_format() + * @see camera_get_preview_format() + * @see camera_attr_foreach_supported_fps() + * @see camera_attr_set_preview_fps() + * @see camera_attr_get_preview_fps() + */ +int camera_start_preview(camera_h camera); + +/** + * @brief Stops capturing and drawing preview frames. + * + * @param[in] camera The handle to the camera + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAMERA_ERROR_INVALID_STATE Invalid state + * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation + * @pre The camera state should be #CAMERA_STATE_PREVIEW. + * @post The camera state will be #CAMERA_STATE_CREATED. + * + * @see camera_start_preview() + * @see camera_unset_preview_cb() + */ +int camera_stop_preview(camera_h camera); + +/** + * @brief Starts capturing of still images. (Image mode only) + * + * @remarks This function causes the transition of camera state from #CAMERA_STATE_CAPTURING to #CAMERA_STATE_CAPTURED automatically\n + * and the corresponding callback function camera_capturing_cb() and camera_capture_completed_cb() will be invoked\n + * Captured image will be delivered through camera_capturing_cb().\n + * You will be notified by camera_capture_completed_cb() callback when camera_capturing_cb() gets completed. \n + * You should restart camera's preview with calling camera_start_preview(). + * + * @param[in] camera The handle to the camera + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAMERA_ERROR_INVALID_STATE Invalid state + * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation + * + * @pre The camera state must be #CAMERA_STATE_PREVIEW. \n + * If needed, modify capture resolution(camera_set_capture_resolution()), + * capture format(camera_set_capture_format()), or image quality(camera_attr_set_image_quality()) + * @post If it succeeds the camera state will be #CAMERA_STATE_CAPTURED. + * + * @see camera_start_preview() + * @see camera_set_capturing_cb() + * @see camera_set_capture_completed_cb() + * @see camera_foreach_supported_capture_resolution() + * @see camera_set_capture_resolution() + * @see camera_get_capture_resolution() + * @see camera_foreach_supported_capture_format() + * @see camera_set_capture_format() + * @see camera_get_capture_format() + * @see camera_attr_set_image_quality() + * @see camera_attr_get_image_quality() + */ +int camera_start_capture(camera_h camera); + +/** + * @brief Gets the state of the camera. + * + * @param[in] camera The handle to the camera + * @param[out] state The current state of camera + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_create() + * @see camera_start_preview() + * @see camera_stop_preview() + * @see camera_start_capture() + */ +int camera_get_state(camera_h camera, camera_state_e *state); + +/** + * @brief Starts camera auto-focusing, Asynchronously + * + * @param[in] camera The handle to the camera + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAMERA_ERROR_INVALID_STATE Invalid state + * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation + * @pre The camera state should be #CAMERA_STATE_PREVIEW + * @post The camera focus state will be #CAMERA_FOCUS_STATE_ONGOING. + * + * @see camera_cancel_focusing() + * @see camera_set_focus_changed_cb() + * @see camera_focus_changed_cb() + * @see camera_attr_set_af_mode() + */ +int camera_start_focusing(camera_h camera); + +/** + * @brief Stops camera auto focusing. + * + * @param[in] camera The handle to the camera + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAMERA_ERROR_INVALID_STATE Invalid state + * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation + * @pre The camera state should be #CAMERA_STATE_PREVIEW + * + * @see camera_start_focusing() + * @see camera_focus_changed_cb() + */ +int camera_cancel_focusing(camera_h camera); + +/** + * @brief Sets the display handle to show preview images + * + * @remarks This function must be called before previewing (see camera_start_preview()). + * + * @param[in] camera The handle to the camera + * @param[in] type The display type + * @param[in] display The display handle from #GET_DISPLAY() + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAMERA_ERROR_INVALID_STATE Invalid state + * @pre The camera state must be #CAMERA_STATE_CREATED + * + * @see camera_start_preview() + * @see GET_DISPLAY() + */ +int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display); + +/** + * @brief Sets the resolution of preview. + * + * @remarks This function should be called before previewing (camera_start_preview()). + * + * @param[in] camera The handle to the camera + * @param[in] width The preview width + * @param[in] height The preview height + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAMERA_ERROR_INVALID_STATE Invalid state + * @pre The camera state must be #CAMERA_STATE_CREATED + * + * @see camera_start_preview() + * @see camera_get_preview_resolution() + * @see camera_foreach_supported_preview_resolution() + */ +int camera_set_preview_resolution(camera_h camera, int width, int height); + +/** + * @brief Gets the resolution of preview. + * + * @param[in] camera The handle to the camera + * @param[out] width The preview width + * @param[out] height The preview height + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_set_preview_resolution() + * @see camera_foreach_supported_preview_resolution() + */ +int camera_get_preview_resolution(camera_h camera, int *width, int *height); + +/** + * @} + */ + +/** + * @addtogroup CAPI_MEDIA_CAMERA_CAPABILITY_MODULE + * @{ + */ + +/** + * @brief Retrieves all supported camera preview resolutions by invoking callback function once for each supported camera preview resolution. + * + * @param[in] camera The handle to the camera + * @param[in] callback The callback function to invoke + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * @post This function invokes camera_supported_preview_resolution_cb() repeatly to retrieve each supported preview resolution. + * + * @see camera_set_preview_resolution() + * @see camera_get_preview_resolution() + * @see camera_supported_preview_resolution_cb() + */ +int camera_foreach_supported_preview_resolution(camera_h camera, + camera_supported_preview_resolution_cb callback, void *user_data); + +/** + * @} + */ + +/** + * @addtogroup CAPI_MEDIA_CAMERA_MODULE + * @{ + */ + + +/** + * @brief Sets the display rotation. + * @ingroup CAPI_MEDIA_CAMERA_X11_DISPLAY_MODULE + * + * + * @remarks This function should be called before previewing (see camera_start_preview())\n + * This function is valid only for #CAMERA_DISPLAY_TYPE_X11 + * + * @param[in] camera The handle to the camera + * @param[in] rotation The display rotation + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAMERA_ERROR_INVALID_STATE Invalid state + * @retval #CAMERA_ERROR_INVALID_OPERATION Display type is not X11 + * + * @see camera_start_preview() + * @see camera_get_x11_display_rotation() + */ +int camera_set_x11_display_rotation(camera_h camera, camera_display_rotation_e rotation); + +/** + * @brief Gets the display rotation. + * @ingroup CAPI_MEDIA_CAMERA_X11_DISPLAY_MODULE + * + * @remarks This function is valid only for #CAMERA_DISPLAY_TYPE_X11. + * + * @param[in] camera The handle to the camera + * @param[out] rotation The display rotation + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_set_x11_display_rotation() + */ +int camera_get_x11_display_rotation(camera_h camera, camera_display_rotation_e *rotation); + +/** + * @brief Sets the visible property for X11 display. + * @ingroup CAPI_MEDIA_CAMERA_X11_DISPLAY_MODULE + * + * @remarks This function is valid only for #CAMERA_DISPLAY_TYPE_X11. + * @param[in] camera The handle to the camera + * @param[in] visible The display visibility property + * + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_is_x11_display_visible() + */ +int camera_set_x11_display_visible(camera_h camera, bool visible); + +/** + * @brief Gets the visible property of X11 display. + * @ingroup CAPI_MEDIA_CAMERA_X11_DISPLAY_MODULE + * + * @remarks This function is valid only for #CAMERA_DISPLAY_TYPE_X11 + * @param[in] camera The handle to the camera + * @param[out] visible @c true if camera display is visible, otherwise @c false + * + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_set_x11_display_visible() + */ +int camera_is_x11_display_visible(camera_h camera, bool *visible); + + +/** + * @brief Sets the X11 display aspect ratio. + * @ingroup CAPI_MEDIA_CAMERA_X11_DISPLAY_MODULE + * + * @remarks This function is valid only for #CAMERA_DISPLAY_TYPE_X11 + * @param[in] camera The handle to the camera + * @param[in] ratio The display apect ratio + * + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_get_x11_display_mode() + */ +int camera_set_x11_display_mode(camera_h camera , camera_display_mode_e mode); + + +/** + * @brief Gets the X11 display aspect ratio. + * @ingroup CAPI_MEDIA_CAMERA_X11_DISPLAY_MODULE + * + * @remarks This function is valid only for #CAMERA_DISPLAY_TYPE_X11. + * @param[in] camera The handle to the camera + * @param[out] ratio The display apect ratio + * + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_set_x11_display_mode() + */ +int camera_get_x11_display_mode(camera_h camera, camera_display_mode_e *mode); + + +/** + * @brief Sets the resolution of capture image. + * + * @param[in] camera The handle to the camera + * @param[in] width The capture width + * @param[in] height The capture height + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAMERA_ERROR_INVALID_STATE Invalid state + * @pre The camera state must be #CAMERA_STATE_CREATED or #CAMERA_STATE_PREVIEW. + * + * @see camera_start_capture() + * @see camera_get_capture_resolution() + * @see camera_foreach_supported_capture_resolution() + */ +int camera_set_capture_resolution(camera_h camera, int width, int height); + + +/** + * @brief Gets the resolution of capture image. + * + * + * @param[in] camera The handle to the camera + * @param[out] width The capture width + * @param[out] height The capture height + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_set_capture_resolution() + * @see camera_foreach_supported_capture_resolution() + */ +int camera_get_capture_resolution(camera_h camera, int *width, int *height); + +/** + * @} + */ + +/** + * @addtogroup CAPI_MEDIA_CAMERA_CAPABILITY_MODULE + * @{ + */ + +/** + * @brief Retrieves all supported camera capture resolutions by invoking the callback function once for each supported camera capture resolution. + * + * @param[in] camera The handle to the camera + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * @post This function invokes camera_supported_capture_resolution_cb() repeatly to retrieve each supported capture resolution. + * + * @see camera_set_capture_resolution() + * @see camera_get_capture_resolution() + * @see camera_supported_capture_resolution_cb() + */ +int camera_foreach_supported_capture_resolution(camera_h camera, + camera_supported_capture_resolution_cb callback, void *user_data); + +/** + * @} + */ + +/** + * @addtogroup CAPI_MEDIA_CAMERA_MODULE + * @{ + */ + + +/** + * @brief Sets the format of an image to capture. + * + * @remarks This function should be called before capturing (see camera_start_capture()). + * + * @param[in] camera The handle to the camera + * @param[out] format The format of capture image + * + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAMERA_ERROR_INVALID_STATE Invalid state + * + * @pre The camera state must be CAMERA_STATE_CREATED or CAMERA_STATE_PREVIEW. + * + * @see camera_start_capture() + * @see camera_get_capture_format() + * @see camera_foreach_supported_capture_format() + */ +int camera_set_capture_format(camera_h camera, camera_pixel_format_e format); + +/** + * @brief Gets the format of capture image to capture. + * + * @param[in] camera The handle to the camera + * @param[out] format The format of capture image + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_set_capture_format() + * @see camera_foreach_supported_capture_format() + */ +int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format); + +/** + * @} + */ + +/** + * @addtogroup CAPI_MEDIA_CAMERA_CAPABILITY_MODULE + * @{ + */ + +/** + * @brief Retrieves all supported camera capture formats by invoking callback function once for each supported camera capture format. + * + * + * @param[in] camera The handle to the camera + * @param[in] callback The callback function to invoke + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * @post This function invokes camera_supported_capture_format_cb() repeatdly to retrieve each supported capture format. + * + * @see camera_set_capture_format() + * @see camera_get_capture_format() + * @see camera_supported_capture_format_cb() + */ +int camera_foreach_supported_capture_format(camera_h camera, + camera_supported_capture_format_cb callback, void *user_data); + +/** + * @} + */ + +/** + * @addtogroup CAPI_MEDIA_CAMERA_MODULE + * @{ + */ + +/** + * @brief Sets the preview data format. + * + * + * @remarks This function should be called before previewing (see camera_start_preview()). + * + * @param[in] camera The handle to the camera + * @param[out] format The preview data format + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAMERA_ERROR_INVALID_STATE Invalid state + * @pre The camera state must be CAMERA_STATE_CREATED + * + * @see camera_start_preview() + * @see camera_get_preview_format() + * @see camera_foreach_supported_preview_format() + */ +int camera_set_preview_format(camera_h camera, camera_pixel_format_e format); + +/** + * @brief Gets the format of preview stream. + * + * @param[in] camera The handle to the camera + * @param[out] format The preview data format + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_set_preview_format() + * @see camera_foreach_supported_preview_format() + */ +int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format); + +/** + * @} + */ + +/** + * @addtogroup CAPI_MEDIA_CAMERA_CAPABILITY_MODULE + * @{ + */ + +/** + * @brief Retrieves all supported camera preview formats by invoking callback function once for each supported camera preview format. + * + * @param[in] camera The handle to the camera + * @param[in] callback The callback function to invoke + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * @post This function invokes camera_supported_preview_format_cb() repeatly to retrieve each supported preview format. + * + * @see camera_set_preview_format() + * @see camera_get_preview_format() + * @see camera_supported_preview_format_cb() + */ +int camera_foreach_supported_preview_format(camera_h camera, + camera_supported_preview_format_cb callback, void *user_data); + +/** + * @} + */ + +/** + * @addtogroup CAPI_MEDIA_CAMERA_MODULE + * @{ + */ + +/** + * @brief Registers a callback function to be called once per frame when previewing. + * + * @remarks This callback does not work in video recorder mode.\n + * This function should be called before previewing (see camera_start_preview())\n + * registered callback is called on internal thread of camera.\n + * You can retrieve video frame using registered callback. + * The callback function holds the same buffer that will be drawn on the display device. + * So if you change the buffer, it will be displayed on the device. + * + * @param[in] camera The handle to the camera + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * @pre The camera state should be #CAMERA_STATE_CREATED. + * + * @see camera_start_preview() + * @see camera_unset_preview_cb() + * @see camera_preview_cb() + */ +int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data); + +/** + * @brief Unregisters the callback function. + * + * @param[in] camera The handle to the camera + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_set_preview_cb() + */ +int camera_unset_preview_cb(camera_h camera); + +/** + * @brief Registers a callback function to be called when capturing. + * + * @remarks registered callback is called on internal thread of camera so you should not directly invoke UI update code in callback. + * You will be notified when sending a message finisheds and check whether is succeeds using this function.\n + * This function should be called before capturing (see camera_start_capture()). + * + * @param[in] camera The handle to the camera + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAMERA_ERROR_INVALID_STATE Invalid state + * + * @see camera_start_capture() + * @see camera_unset_capturing_cb() + * @see camera_capturing_cb() + */ +int camera_set_capturing_cb(camera_h camera, camera_capturing_cb callback, void *user_data); + +/** + * @brief Unregisters the callback function. + * + * @param[in] camera The handle to the camera + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_set_capturing_cb() + */ +int camera_unset_capturing_cb(camera_h camera); + +/** + * @brief Registers a callback function to be called when camera state changes. + * + * @param[in] camera The handle to the camera + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * @post This function will invoke camera_state_changed_cb() when camera state changes. + * + * @see camera_unset_state_changed_cb() + * @see camera_state_changed_cb() + */ +int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, + void *user_data); + +/** + * @brief Unregisters the callback function. + * + * @param[in] camera The handle to the camera + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_set_state_changed_cb() + */ +int camera_unset_state_changed_cb(camera_h camera); + +/** + * @brief Registers a callback function to be called when auto-focus state changes. + * + * @param[in] camera The handle to the camera + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * @post This function will invoke camera_focus_changed_cb() when auto-focus state changes. + * + * @see camera_start_focusing() + * @see camera_cancel_focusing() + * @see camera_unset_focus_changed_cb() + * @see camera_focus_changed_cb() + */ +int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, + void *user_data); + + +/** + * @brief Unregisters the callback function. + * + * @param[in] camera The handle to the camera + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_set_focus_changed_cb() + */ +int camera_unset_focus_changed_cb(camera_h camera); + + +/** + * @brief Registers a callback function to be called when capture completes. + * + * @param[in] camera The handle to the camera + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * @post This function makes camera_capture_completed_cb() called when capturing completes. + * + * @see camera_start_capture() + * @see camera_unset_capture_completed_cb() + * @see camera_capture_completed_cb() + */ +int camera_set_capture_completed_cb(camera_h camera, camera_capture_completed_cb callback, + void *user_data); + + +/** + * @brief Unregisters the callback function. + * + * @param[in] camera The handle to the camera + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_set_capture_completed_cb() + */ +int camera_unset_capture_completed_cb(camera_h camera); + + +/** + * @brief Registers a callback function to be called when an asynchronous operation error occurred. + * + * @param[in] camera The handle to the camera + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * @post This function will invoke camera_error_cb() when an asynchronous operation error occur. + * + * @see camera_unset_error_cb() + * @see camera_error_cb() + */ +int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data); + + +/** + * @brief Unregisters the callback function. + * + * @param[in] camera The handle to the camera + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_set_error_cb() + */ +int camera_unset_error_cb(camera_h camera); + +/** + * @} + */ + +/** + * @addtogroup CAPI_MEDIA_CAMERA_CAPABILITY_MODULE + * @{ + */ + +/** + * @brief Called to get each supported auto-focus mode. + * + * @param[in] mode The supported auto-focus mode + * @param[in] user_data The user data passed from the foreach function + * @return @c true to continue with the next iteration of the loop, \n @c false to break outsp of the loop. + * @pre camera_attr_foreach_supported_af_mode() will invoke this callback. + * @see camera_attr_foreach_supported_af_mode() + */ +typedef bool (*camera_attr_supported_af_mode_cb)(camera_attr_af_mode_e mode, void *user_data); + +/** + * @brief Called to get each supported exposure mode. + * + * @param[in] mode The supported exposure mode + * @param[in] user_data The user data passed from the foreach function + * @return @c true to continue with the next iteration of the loop, \n @c false to break outsp of the loop. + * @pre camera_attr_foreach_supported_exposure_mode() will invoke this callback. + * @see camera_attr_foreach_supported_exposure_mode() + * @see #camera_attr_exposure_mode_e + */ +typedef bool (*camera_attr_supported_exposure_mode_cb)(camera_attr_exposure_mode_e mode, + void *user_data); + +/** + * @brief Called to get each supported ISO mode. + * + * @param[in] iso The supported iso mode + * @param[in] user_data The user data passed from the foreach function + * @return @c true to continue with the next iteration of the loop, \n @c false to break outsp of the loop. + * @pre camera_attr_foreach_supported_iso() will invoke this callback. + * @see camera_attr_foreach_supported_iso() + */ +typedef bool (*camera_attr_supported_iso_cb)(camera_attr_iso_e iso, void *user_data); + +/** + * @brief Called to get each supported white balance. + * + * @param[in] wb The supported white balance mode + * @param[in] user_data The user data passed from the foreach function + * @return @c true to continue with the next iteration of the loop, \n @c false to break outsp of the loop. + * @pre camera_attr_foreach_supported_whitebalance() will invoke this callback. + * @see camera_attr_foreach_supported_whitebalance() + * @see #camera_attr_whitebalance_e + */ +typedef bool (*camera_attr_supported_whitebalance_cb)(camera_attr_whitebalance_e wb, + void *user_data); + +/** + * @brief Called to get each supported effect mode. + * + * @param[in] effect The supported effect mode + * @param[in] user_data The user data passed from the foreach function + * @return @c true to continue with the next iteration of the loop, \n @c false to break outsp of the loop. + * @pre camera_attr_foreach_supported_effect() will invoke this callback. + * @see camera_attr_foreach_supported_effect() + */ +typedef bool (*camera_attr_supported_effect_cb)(camera_attr_effect_mode_e effect, + void *user_data); + +/** + * @brief Called to get each supported scene mode. + * + * @param[in] mode The supported scene mode + * @param[in] user_data The user data passed from the foreach function + * @return @c true to continue with the next iteration of the loop, \n @c false to break outsp of the loop. + * @pre camera_attr_foreach_supported_scene_mode() will invoke this callback. + * @see camera_attr_foreach_supported_scene_mode() + * @see #camera_attr_scene_mode_e + */ +typedef bool (*camera_attr_supported_scene_mode_cb)(camera_attr_scene_mode_e mode, + void *user_data); + +/** + * @brief Called to get each supported flash mode. + * + * @param[in] mode The supported flash mode + * @param[in] user_data The user data passed from the foreach function + * @return @c true to continue with the next iteration of the loop, \n @c false to break outsp of the loop. + * @pre camera_attr_foreach_supported_flash_mode() will invoke this callback. + * @see camera_attr_foreach_supported_flash_mode() + */ +typedef bool (*camera_attr_supported_flash_mode_cb)(camera_attr_flash_mode_e mode, + void *user_data); + +/** + * @brief Called to get each supported FPS mode. + * + * @param[in] mode The supported FPS mode + * @param[in] user_data The user data passed from the foreach function + * @return @c true to continue with the next iteration of the loop, \n @c false to break outsp of the loop. + * @pre camera_attr_foreach_supported_fps() will invoke this callback. + * @see camera_attr_foreach_supported_fps() + */ +typedef bool (*camera_attr_supported_fps_cb)(camera_attr_fps_e fps, void *user_data); + +/** + * @} + */ + +/** + * @addtogroup CAPI_MEDIA_CAMERA_ATTRIBUTES_MODULE + * @{ + */ + +/** + * @brief Sets the preview frame rate. + * + * @remarks This function should be called before previewing (see camera_start_preview()). + * + * @param[in] camera The handle to the camera + * @param[in] fps The frame rate + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAMERA_ERROR_INVALID_STATE Invalid state + * + * @see camera_start_preview() + * @see camera_attr_get_preview_fps() + * @see camera_attr_foreach_supported_fps() + */ +int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps); + +/** + * @brief Gets the frames per second of a preview video stream. + * + * @param[in] camera The handle to the camera + * @param[out] fps The frames per second of preview video stream + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_attr_set_preview_fps() + * @see camera_attr_foreach_supported_fps() + */ +int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps); + +/** + * @} + */ + +/** + * @addtogroup CAPI_MEDIA_CAMERA_CAPABILITY_MODULE + * @{ + */ + +/** + * @brief Retrieves all supported FPS modes by invoking callback function once for each supported FPS mode. + * + * @param[in] camera The handle to the camera + * @param[in] callback The callback function to invoke + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * @post This function invokes camera_attr_supported_fps_cb() repeatly to get each supported FPS mode. + * + * @see camera_attr_set_preview_fps() + * @see camera_attr_get_preview_fps() + * @see camera_attr_supported_fps_cb() + */ +int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb callback, + void *user_data); + +/** + * @} + */ + +/** + * @addtogroup CAPI_MEDIA_CAMERA_ATTRIBUTES_MODULE + * @{ + */ + +/** + * @brief Sets the image quality. + * + * @details The range for image quality is 1 to 100. If @a quality is out of range, #CAMERA_ERROR_INVALID_PARAMETER error occurred. + * + * @param[in] camera The handle to the camera + * @param[in] quality The quality of image (1 ~ 100) + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAMERA_ERROR_INVALID_STATE Invalid state + * @pre The camera state must be #CAMERA_STATE_CREATED, #CAMERA_STATE_PREVIEW. + * + * @see camera_start_preview() + * @see camera_attr_get_image_quality() + */ +int camera_attr_set_image_quality(camera_h camera, int quality); + +/** + * @brief Gets the quality of capturing a still image. + * + * @param[in] camera The handle to the camera + * @param[out] quality The quality of image(1 ~ 100) + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_attr_set_image_quality() + */ +int camera_attr_get_image_quality(camera_h camera, int *quality); + +/** + * @brief Sets the zoom level. + * @details The range for zoom level is getting from camera_attr_get_zoom_range(). If @a zoom is out of range, #CAMERA_ERROR_INVALID_PARAMETER error occurred. + * + * @param[in] camera The handle to the camera + * @param[in] zoom The zoom level + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_attr_get_zoom() + * @see camera_attr_get_zoom_range() + */ +int camera_attr_set_zoom(camera_h camera, int zoom); + +/** + * @brief Gets the zoom level. + * + * @param[in] camera The handle to the camera + * @param[out] zoom The zoom level + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_attr_set_zoom() + * @see camera_attr_get_zoom_range() + */ +int camera_attr_get_zoom(camera_h camera, int *zoom); + +/** + * @brief Gets the available zoom level. + * + * @param[in] camera The handle to the camera + * @param[out] min The minimum zoom level + * @param[out] max The maximum zoom level + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_attr_set_zoom() + * @see camera_attr_get_zoom() + */ +int camera_attr_get_zoom_range(camera_h camera , int *min , int *max); + + +/** + * @brief Sets the auto focus mode. + * + * @param[in] camera The handle to the camera + * @param[in] mode The auto focus mode + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_attr_get_af_mode() + * @see camera_attr_foreach_supported_af_mode() + * @see #camera_attr_af_mode_e + */ +int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode); + +/** + * @brief Gets the auto focus mode. + * + * @param[in] camera The handle to the camera + * @param[out] mode Auto focus mode + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_attr_foreach_supported_af_mode() + * @see camera_attr_set_af_mode() + * @see #camera_attr_af_mode_e + */ +int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode); + +/** + * @} + */ + +/** + * @addtogroup CAPI_MEDIA_CAMERA_CAPABILITY_MODULE + * @{ + */ + +/** + * @brief Retrieves all supported auto focus modes by invoking callback function once for each supported auto focus mode. + * + * @param[in] camera The handle to the camera + * @param[in] callback The callback function to invoke + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * @post This function invokes camera_attr_supported_af_mode_cb() to get all supported auto focus modes. + * + * @see camera_attr_set_af_mode() + * @see camera_attr_get_af_mode() + * @see camera_attr_supported_af_mode_cb() + */ +int camera_attr_foreach_supported_af_mode(camera_h camera, + camera_attr_supported_af_mode_cb callback, void *user_data); + +/** + * @} + */ + +/** + * @addtogroup CAPI_MEDIA_CAMERA_ATTRIBUTES_MODULE + * @{ + */ + +/** + * @brief Sets the exposure mode. + * + * @param[in] camera The handle to the camera + * @param[in] mode The exposure mode + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_attr_get_exposure_mode() + * @see camera_attr_foreach_supported_exposure_mode() + */ +int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode); + +/** + * @brief Gets the exposure mode. + * + * @param[in] camera The handle to the camera + * @param[out] mode Exposure mode + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_attr_set_exposure_mode() + * @see camera_attr_foreach_supported_exposure_mode() + */ +int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode); + +/** + * @} + */ + +/** + * @addtogroup CAPI_MEDIA_CAMERA_CAPABILITY_MODULE + * @{ + */ + +/** + * @brief Retrieves all supported exposure modes by invoking callback function once for each supported exposure mode. + * + * @param[in] camera The handle to the camera + * @param[in] callback The callback function to invoke + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * @post This function invokes camera_attr_supported_exposure_mode_cb() to get all supported exposure modes. + * + * @see camera_attr_set_exposure_mode() + * @see camera_attr_get_exposure_mode() + * @see camera_attr_supported_exposure_mode_cb() + */ +int camera_attr_foreach_supported_exposure_mode(camera_h camera, + camera_attr_supported_exposure_mode_cb callback, void *user_data); + +/** + * @} + */ + +/** + * @addtogroup CAPI_MEDIA_CAMERA_ATTRIBUTES_MODULE + * @{ + */ + +/** + * @brief Sets the exposure value. + * + * @param[in] camera The handle to the camera + * @param[in] value The exposure value + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_attr_get_exposure() + */ +int camera_attr_set_exposure(camera_h camera, int value); + +/** + * @brief Gets the exposure value. + * + * @param[in] camera The handle to the camera + * @param[out] value Exposure value + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_attr_set_exposure() + */ +int camera_attr_get_exposure(camera_h camera, int *value); + +/** + * @brief Gets the available exposure value. + * + * @param[in] camera The handle to the camera + * @param[out] min The minimum exposure value + * @param[out] max The maximum exposure value + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_attr_set_exposure() + */ +int camera_attr_get_exposure_range(camera_h camera, int *min, int *max); + +/** + * @brief Sets the ISO level. + * + * @param[in] camera The handle to the camera + * @param[in] iso The ISO Level + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_attr_get_iso() + * @see camera_attr_foreach_supported_iso() + */ +int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso); + +/** + * @brief Gets the ISO level. + * + * @param[in] camera The handle to the camera + * @param[out] iso ISO Level + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_attr_set_iso() + * @see camera_attr_foreach_supported_iso() + */ +int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso); + +/** + * @} + */ + +/** + * @addtogroup CAPI_MEDIA_CAMERA_CAPABILITY_MODULE + * @{ + */ + +/** + * @brief Retrieves all supported ISO levels by invoking callback function once for each supported ISO level. + * + * @param[in] camera The handle to the camera + * @param[in] callback The callback function to invoke + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * @post This function invokes camera_attr_supported_iso_cb() to get all supported ISO levels. + * + * @see camera_attr_set_iso() + * @see camera_attr_get_iso() + * @see camera_attr_supported_iso_cb() + */ +int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb callback, + void *user_data); + +/** + * @} + */ + +/** + * @addtogroup CAPI_MEDIA_CAMERA_ATTRIBUTES_MODULE + * @{ + */ + + +/** + * @brief Sets the brightness level. + * + * + * @param[in] camera The handle to the camera + * @param[in] level The brightness level + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_attr_get_brightness() + * @see camera_attr_get_brightness_range() + */ +int camera_attr_set_brightness(camera_h camera, int level); + +/** + * @brief Gets the brightness level. + * + * @param[in] camera The handle to the camera + * @param[out] level The brightness level + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_attr_set_brightness() + * @see camera_attr_get_brightness_range() + */ +int camera_attr_get_brightness(camera_h camera, int *level); + +/** + * @brief Gets the available brightness level. + * + * @param[in] camera The handle to the camera + * @param[out] min The minimum brightness level + * @param[out] max The maximum brightness level + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_attr_set_brightness() + * @see camera_attr_get_brightness() + */ +int camera_attr_get_brightness_range(camera_h camera, int *min, int *max); + +/** + * @brief Sets the contrast level. + * + * @param[in] camera The handle to the camera + * @param[in] level The contrast level + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_attr_get_contrast() + * @see camera_attr_get_contrast_range() + */ +int camera_attr_set_contrast(camera_h camera, int level); + + +/** + * @brief Gets the contrast level. + * + * @param[in] camera The handle to the camera + * @param[out] level The contrast level + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_attr_set_contrast() + * @see camera_attr_get_contrast_range() + */ +int camera_attr_get_contrast(camera_h camera, int *level); + +/** + * @brief Gets the available contrast level. + * + * @param[in] camera The handle to the camera + * @param[out] min The minimum contrast level + * @param[out] max The maximum contrast level + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_attr_set_contrast() + * @see camera_attr_get_contrast() + */ +int camera_attr_get_contrast_range(camera_h camera, int *min , int *max); + +/** + * @brief Sets the white balance mode. + * + * @param[in] camera The handle to the camera + * @param[in] whitebalance The white balance mode + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_attr_foreach_supported_whitebalance() + * @see camera_attr_get_whitebalance() + */ +int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e whitebalance); + + +/** + * @brief Gets the white balance mode. + * + * @param[in] camera The handle to the camera + * @param[out] whitebalance The white balance mode + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_attr_foreach_supported_whitebalance() + * @see camera_attr_set_whitebalance() + */ +int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *whitebalance); + +/** + * @} + */ + +/** + * @addtogroup CAPI_MEDIA_CAMERA_CAPABILITY_MODULE + * @{ + */ + +/** + * @brief Retrieves all supported white balances by invoking callback function once for each supported white balance. + * + * @param[in] camera The handle to the camera + * @param[in] callback The callback function to invoke + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * @post This function invokes camera_attr_supported_whitebalance_cb() to get all supported white balances. + * + * @see camera_attr_set_whitebalance() + * @see camera_attr_get_whitebalance() + * @see camera_attr_supported_whitebalance_cb() + */ +int camera_attr_foreach_supported_whitebalance(camera_h camera, + camera_attr_supported_whitebalance_cb callback, void *user_data); + +/** + * @} + */ + +/** + * @addtogroup CAPI_MEDIA_CAMERA_ATTRIBUTES_MODULE + * @{ + */ + +/** + * @brief Sets the camera effect mode. + * + * @param[in] camera The handle to the camera + * @param[in] effect The camera effect mode + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_attr_foreach_supported_effect() + * @see camera_attr_get_effect() + */ +int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect); + + +/** + * @brief Gets the camera effect mode. + * + * @param[in] camera The handle to the camera + * @param[out] effect The camera effect mode + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_attr_foreach_supported_effect() + * @see camera_attr_set_effect() + */ +int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect); + +/** + * @} + */ + +/** + * @addtogroup CAPI_MEDIA_CAMERA_CAPABILITY_MODULE + * @{ + */ + +/** + * @brief Retrieves all supported effect modes by invoking callback function once for each supported effect mode. + * + * @param[in] camera The handle to the camera + * @param[in] callback The callback function to invoke + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * @post This function invokes camera_attr_supported_effect_cb() to get all supported effect modes. + * + * @see camera_attr_set_effect() + * @see camera_attr_get_effect() + * @see camera_attr_supported_effect_cb() + */ +int camera_attr_foreach_supported_effect(camera_h camera, + camera_attr_supported_effect_cb callback, void *user_data); + +/** + * @} + */ + +/** + * @addtogroup CAPI_MEDIA_CAMERA_ATTRIBUTES_MODULE + * @{ + */ + +/** + * @brief Sets the scene mode. + * + * @param[in] camera The handle to the camera + * @param[in] mode The scene mode + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_attr_foreach_supported_scene_mode() + * @see camera_attr_get_scene_mode() + */ +int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode); + +/** + * @brief Gets the scene mode. + * + * @param[in] camera The handle to the camera + * @param[out] mode The scene mode + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_attr_foreach_supported_scene_mode() + * @see camera_attr_set_scene_mode() + */ +int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode); + +/** + * @} + */ + +/** + * @addtogroup CAPI_MEDIA_CAMERA_CAPABILITY_MODULE + * @{ + */ + +/** + * @brief Retrieves all supported scene modes by invoking callback function once for each supported scene mode. + * + * @param[in] camera The handle to the camera + * @param[in] callback The callback function to invoke + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * @post This function invokes camera_attr_supported_scene_mode_cb() to get all supported scene modes. + * + * @see camera_attr_set_scene_mode() + * @see camera_attr_get_scene_mode() + * @see camera_attr_supported_scene_mode_cb() + */ +int camera_attr_foreach_supported_scene_mode(camera_h camera, + camera_attr_supported_scene_mode_cb callback, void *user_data); + +/** + * @} + */ + +/** + * @addtogroup CAPI_MEDIA_CAMERA_ATTRIBUTES_MODULE + * @{ + */ + +/** + * @brief Enables to write EXIF(Exchangeable image file format) tags in a JPEG file. + * + * @param[in] camera The handle to the camera + * @param[in] enable @c true to enable write EXIF tags in a JPEG file, otherwise @c false + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_attr_is_enabled_tag() + */ +int camera_attr_enable_tag(camera_h camera, bool enable); + +/** + * @brief Gets the value that indicates whether to write EXIF(Exchangeable image file format) tags in a JPEG file is enabled. + * + * @param[in] camera The handle to the camera + * @param[out] enabled @c true if camera information is enabled, otherwise @c false + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_attr_enable_tag() + */ +int camera_attr_is_enabled_tag(camera_h camera, bool *enabled); + +/** + * @brief Sets a camera image description in EXIF(Exchangeable image file format) tag. + * + * @param[in] camera The handle to the camera + * @param[in] description The string with description + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_attr_get_tag_image_description() + */ +int camera_attr_set_tag_image_description(camera_h camera, const char *description); + +/** + * @brief Gets the camera image description in EXIF(Exchangeable image file format) tag. + * + * @remarks @a description must be released with free() by you. + * + * @param[in] camera The handle to the camera + * @param[out] description A pointer to a string + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_attr_set_tag_image_description() + */ +int camera_attr_get_tag_image_description(camera_h camera, char **description); + +/** + * @brief Sets the camera orientation in EXIF(Exchangeable image file format) tag. + * + * @param[in] camera The handle to the camera + * @param[in] orientation The information of the camera orientation + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_attr_get_tag_orientation() + */ +int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation); + +/** + * @brief Gets the camera orientation in EXIF(Exchangeable image file format) tag. + * + * @param[in] camera The handle to the camera + * @param[out] orientation The information of the camera orientation + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_attr_set_tag_orientation() + */ +int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation); + +/** + * @brief Sets the software information in EXIF(Exchangeable image file format) tag. + * + * @param[in] camera The handle to the camera + * @param[in] software The software information tag + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_attr_get_tag_software() + */ +int camera_attr_set_tag_software(camera_h camera, const char *software); + +/** + * @brief Gets the software information in EXIF(Exchangeable image file format) tag. + * + * @remarks @a software must be released with free() by you. + * + * @param[in] camera The handle to the camera + * @param[out] software A pointer to a string + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_attr_set_tag_software() + */ +int camera_attr_get_tag_software(camera_h camera, char **software); + +/** + * @brief Sets the GPS latitude data in EXIF(Exchangeable image file format) tag. + * + * @param[in] camera The handle to the camera + * @param[in] latitude Latitude data + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_attr_get_tag_latitude() + */ +int camera_attr_set_tag_latitude(camera_h camera, double latitude); + +/** + * @brief Gets the GPS latitude data in EXIF(Exchangeable image file format) tag. + * + * @param[in] camera The handle to the camera + * @param[out] latitude The latitude data + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_attr_set_tag_latitude() + */ +int camera_attr_get_tag_latitude(camera_h camera, double *latitude); + +/** + * @brief Sets the GPS longitude data in EXIF(Exchangeable image file format) tag. + * + * @param[in] camera The handle to the camera + * @param[in] longitude The longitude data + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_attr_get_tag_longitude() + */ +int camera_attr_set_tag_longitude(camera_h camera, double longitude); + +/** + * @brief Gets the GPS longitude data in EXIF(Exchangeable image file format) tag. + * + * @param[in] camera The handle to the camera + * @param[out] longitude The longitude data + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_attr_set_tag_longitude() + */ +int camera_attr_get_tag_longitude(camera_h camera, double *longitude); + +/** + * @brief Sets the GPS altitude data in EXIF(Exchangeable image file format) tag. + * + * @param[in] camera The handle to the camera + * @param[in] altitude The altitude data + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_attr_get_tag_altitude() + */ +int camera_attr_set_tag_altitude(camera_h camera, double altitude); + +/** + * @brief Gets the GPS altitude data in EXIF(Exchangeable image file format) tag. + * + * @param[in] camera The handle to the camera + * @param[out] altitude The altitude data + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_attr_set_tag_altitude() + */ +int camera_attr_get_tag_altitude(camera_h camera, double *altitude); + +/** + * @brief Sets the camera flash mode. + * + * @param[in] camera The handle to the camera + * @param[in] mode The flash mode + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_attr_foreach_supported_flash_mode() + * @see camera_attr_get_flash_mode() + */ +int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode); + +/** + * @brief Gets the camera flash mode. + * + * @param[in] camera The handle to the camera + * @param[out] mode The flash mode + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_attr_foreach_supported_flash_mode() + * @see camera_attr_set_flash_mode() + */ +int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode); + +/** + * @} + */ + +/** + * @addtogroup CAPI_MEDIA_CAMERA_CAPABILITY_MODULE + * @{ + */ + +/** + * @brief Retrieves all supported flash modes by invoking callback funcion once for each supported flash mode. + * + * @param[in] camera The handle to the camera + * @param[in] callback The callback function to invoke + * @param[in] user_data The user data passed to the callback registration function + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * @post This function invokes camera_attr_supported_flash_mode_cb() to get all supported flash modes. + * + * @see camera_attr_set_flash_mode() + * @see camera_attr_get_flash_mode() + * @see camera_attr_supported_flash_mode_cb() + */ +int camera_attr_foreach_supported_flash_mode(camera_h camera, + camera_attr_supported_flash_mode_cb callback, void *user_data); + +/** + * @} + */ + +/** + * @addtogroup CAPI_MEDIA_CAMERA_ATTRIBUTES_MODULE + * @{ + */ + +/** + * @brief Gets the camera lens orientation angle. + * + * @param[in] camera The handle to the camera + * @param[out] angle The orientation angle + * @return 0 on success, otherwise a negative error value. + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see camera_set_x11_display_rotation() + */ +int camera_attr_get_lens_orientation(camera_h camera, int *angle); + + +/** + * @} + */ +#ifdef __cplusplus +} +#endif + +#endif /* __TIZEN_MULTIMEDIA_CAMERA_H__ */ + diff --git a/include/camera_private.h b/include/camera_private.h new file mode 100755 index 0000000..9018385 --- /dev/null +++ b/include/camera_private.h @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + + + + + +#ifndef __TIZEN_MULTIMEDIA_CAMERA_PRIVATE_H__ +#define __TIZEN_MULTIMEDIA_CAMERA_PRIVATE_H__ +#include <camera.h> +#include <mm_camcorder.h> + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + _CAMERA_EVENT_TYPE_STATE_CHANGE, + _CAMERA_EVENT_TYPE_FOCUS_CHANGE, + _CAMERA_EVENT_TYPE_CAPTURE_COMPLETE, + _CAMERA_EVENT_TYPE_PREVIEW, + _CAMERA_EVENT_TYPE_CAPTURE, + _CAMERA_EVENT_TYPE_ERROR, + _CAMERA_EVENT_TYPE_NUM +}_camera_event_e; + +typedef struct _camera_s{ + MMHandleType mm_handle; + + void* user_cb[_CAMERA_EVENT_TYPE_NUM]; + void* user_data[_CAMERA_EVENT_TYPE_NUM]; + void* display_handle; + camera_display_type_e display_type; + int state; + +} camera_s; + +typedef enum { + CAMERA_MODE_IMAGE = MM_CAMCORDER_MODE_IMAGE, /**< Still image capture mode */ + CAMERA_MODE_VIDEO = MM_CAMCORDER_MODE_VIDEO /**< Video recording mode */ +} camera_mode_e; + + + + +gboolean mm_videostream_callback(MMCamcorderVideoStreamDataType * stream, void *user_data); +gboolean mm_capture_callback(MMCamcorderCaptureDataType *frame, MMCamcorderCaptureDataType *thumbnail, void *user_data); + +int mm_message_callback(int message, void *param, void *user_data); + +#ifdef __cplusplus +} +#endif + +#endif //__TIZEN_MULTIMEDIA_CAMERA_PRIVATE_H__ + diff --git a/packaging/capi-media-camera.spec b/packaging/capi-media-camera.spec new file mode 100755 index 0000000..62e4082 --- /dev/null +++ b/packaging/capi-media-camera.spec @@ -0,0 +1,53 @@ +Name: capi-media-camera +Summary: A Camera library in Tizen Native API +Version: 0.0.1 +Release: 1 +Group: TO_BE/FILLED_IN +License: TO BE FILLED IN +Source0: %{name}-%{version}.tar.gz +BuildRequires: cmake +BuildRequires: pkgconfig(dlog) +BuildRequires: pkgconfig(mm-camcorder) +BuildRequires: pkgconfig(capi-base-common) +Requires(post): /sbin/ldconfig +Requires(postun): /sbin/ldconfig + +%description + + +%package devel +Summary: A Camera library in Tizen Native API (Development) +Group: TO_BE/FILLED_IN +Requires: %{name} = %{version}-%{release} + +%description devel + + + +%prep +%setup -q + + +%build +cmake . -DCMAKE_INSTALL_PREFIX=/usr + + +make %{?jobs:-j%jobs} + +%install +rm -rf %{buildroot} +%make_install + +%post -p /sbin/ldconfig + +%postun -p /sbin/ldconfig + + +%files +%{_libdir}/libcapi-media-camera.so + +%files devel +%{_includedir}/media/camera.h +%{_libdir}/pkgconfig/*.pc + + diff --git a/src/camera.c b/src/camera.c new file mode 100755 index 0000000..db1217b --- /dev/null +++ b/src/camera.c @@ -0,0 +1,1894 @@ +/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <mm.h> +#include <mm_camcorder.h> +#include <mm_types.h> +#include <math.h> +#include <camera.h> +#include <camera_private.h> +#include <glib.h> +#include <dlog.h> + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "TIZEN_N_CAMERA" + +int _convert_camera_error_code(const char* func, int code){ + int ret = CAMERA_ERROR_NONE; + char *errorstr = NULL; + switch(code) + { + case MM_ERROR_NONE: + ret = CAMERA_ERROR_NONE; + errorstr = "ERROR_NONE"; + break; + case MM_ERROR_CAMCORDER_INVALID_ARGUMENT : + case MM_ERROR_COMMON_INVALID_ATTRTYPE : + case MM_ERROR_COMMON_INVALID_PERMISSION : + case MM_ERROR_COMMON_OUT_OF_ARRAY : + case MM_ERROR_COMMON_OUT_OF_RANGE : + case MM_ERROR_COMMON_ATTR_NOT_EXIST : + ret = CAMERA_ERROR_INVALID_PARAMETER; + errorstr = "INVALID_PARAMETER"; + break; + case MM_ERROR_CAMCORDER_NOT_INITIALIZED : + case MM_ERROR_CAMCORDER_INVALID_STATE : + ret = CAMERA_ERROR_INVALID_STATE; + errorstr = "INVALID_STATE"; + break; + + case MM_ERROR_CAMCORDER_DEVICE : + case MM_ERROR_CAMCORDER_DEVICE_NOT_FOUND : + case MM_ERROR_CAMCORDER_DEVICE_BUSY : + case MM_ERROR_CAMCORDER_DEVICE_OPEN : + case MM_ERROR_CAMCORDER_DEVICE_IO : + case MM_ERROR_CAMCORDER_DEVICE_TIMEOUT : + case MM_ERROR_CAMCORDER_DEVICE_REG_TROUBLE : + case MM_ERROR_CAMCORDER_DEVICE_WRONG_JPEG : + case MM_ERROR_CAMCORDER_DEVICE_LACK_BUFFER : + ret = CAMERA_ERROR_DEVICE; + errorstr = "ERROR_DEVICE"; + break; + + case MM_ERROR_CAMCORDER_GST_CORE : + case MM_ERROR_CAMCORDER_GST_LIBRARY : + case MM_ERROR_CAMCORDER_GST_RESOURCE : + case MM_ERROR_CAMCORDER_GST_STREAM : + case MM_ERROR_CAMCORDER_GST_STATECHANGE : + case MM_ERROR_CAMCORDER_GST_NEGOTIATION : + case MM_ERROR_CAMCORDER_GST_LINK : + case MM_ERROR_CAMCORDER_GST_FLOW_ERROR : + case MM_ERROR_CAMCORDER_ENCODER : + case MM_ERROR_CAMCORDER_ENCODER_BUFFER : + case MM_ERROR_CAMCORDER_ENCODER_WRONG_TYPE : + case MM_ERROR_CAMCORDER_ENCODER_WORKING : + case MM_ERROR_CAMCORDER_INTERNAL : + case MM_ERROR_CAMCORDER_NOT_SUPPORTED : + case MM_ERROR_CAMCORDER_RESPONSE_TIMEOUT : + case MM_ERROR_CAMCORDER_CMD_IS_RUNNING : + case MM_ERROR_CAMCORDER_DSP_FAIL : + case MM_ERROR_CAMCORDER_AUDIO_EMPTY : + case MM_ERROR_CAMCORDER_CREATE_CONFIGURE : + case MM_ERROR_CAMCORDER_FILE_SIZE_OVER : + case MM_ERROR_CAMCORDER_DISPLAY_DEVICE_OFF : + case MM_ERROR_CAMCORDER_INVALID_CONDITION : + ret = CAMERA_ERROR_INVALID_OPERATION; + errorstr = "INVALID_OPERATION"; + break; + + + case MM_ERROR_CAMCORDER_RESOURCE_CREATION : + case MM_ERROR_COMMON_OUT_OF_MEMORY: + ret = CAMERA_ERROR_OUT_OF_MEMORY; + errorstr = "OUT_OF_MEMORY"; + break; + + case MM_ERROR_POLICY_BLOCKED: + ret = CAMERA_ERROR_SOUND_POLICY; + errorstr = "ERROR_SOUND_POLICY"; + break; + + default: + ret = CAMERA_ERROR_INVALID_OPERATION; + errorstr = "INVALID_OPERATION"; + + } + + LOGE( "[%s] %s(0x%08x) : core frameworks error code(0x%08x)",func, errorstr, ret, code); + + return ret; +} + + +gboolean mm_videostream_callback(MMCamcorderVideoStreamDataType * stream, void *user_data){ + + if( user_data == NULL || stream == NULL) + return 0; + + camera_s * handle = (camera_s*)user_data; + if( handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW] ) + ((camera_preview_cb)handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW])(stream->data, stream->length, stream->width, stream->height, stream->format, handle->user_data[_CAMERA_EVENT_TYPE_PREVIEW]); + return 1; +} +gboolean mm_capture_callback(MMCamcorderCaptureDataType *frame, MMCamcorderCaptureDataType *thumbnail, void *user_data){ + if( user_data == NULL || frame == NULL) + return 0; + + camera_s * handle = (camera_s*)user_data; + if( handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] ) + ((camera_capturing_cb)handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE])(frame->data, frame->length, frame->width, frame->height, frame->format, handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE]); + + return 1; +} + +camera_state_e _camera_state_convert(MMCamcorderStateType mm_state) +{ + camera_state_e state = CAMERA_STATE_NONE; + + switch( mm_state ){ + case MM_CAMCORDER_STATE_NONE: + state = CAMERA_STATE_NONE; + break; + case MM_CAMCORDER_STATE_NULL: + state = CAMERA_STATE_CREATED; + break; + case MM_CAMCORDER_STATE_READY: + state = CAMERA_STATE_CREATED; + break; + case MM_CAMCORDER_STATE_PREPARE: + state = CAMERA_STATE_PREVIEW; + break; + case MM_CAMCORDER_STATE_CAPTURING: + state = CAMERA_STATE_CAPTURING; + break; + case MM_CAMCORDER_STATE_RECORDING: + state = CAMERA_STATE_PREVIEW; + break; + case MM_CAMCORDER_STATE_PAUSED: + state = CAMERA_STATE_PREVIEW; + break; + default: + state = CAMERA_STATE_NONE; + break; + } + + return state; + +} + + +int mm_message_callback(int message, void *param, void *user_data){ + if( user_data == NULL || param == NULL ) + return 0; + + + camera_s * handle = (camera_s*)user_data; + MMMessageParamType *m = (MMMessageParamType*)param; + camera_state_e previous_state; + + + switch(message){ + case MM_MESSAGE_CAMCORDER_STATE_CHANGED: + case MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_ASM: + if( m->state.previous < MM_CAMCORDER_STATE_NONE || m->state.previous > MM_CAMCORDER_STATE_PAUSED || m->state.code != 0 ){ + LOGI( "Invalid state changed message"); + break; + } + + previous_state = handle->state; + handle->state = _camera_state_convert(m->state.current ); + + if( previous_state != handle->state && handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE] ){ + ((camera_state_changed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE])(previous_state, handle->state, message == MM_MESSAGE_CAMCORDER_STATE_CHANGED ? 0 : 1 , handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE]); + } + + // should change intermediate state MM_CAMCORDER_STATE_READY is not valid in capi , change to NULL state + if( message == MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_ASM ){ + if( m->state.previous == MM_CAMCORDER_STATE_PREPARE && m->state.current == MM_CAMCORDER_STATE_READY ){ + mm_camcorder_unrealize(handle->mm_handle); + } + } + + break; + case MM_MESSAGE_CAMCORDER_FOCUS_CHANGED : + if( handle->user_cb[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] ){ + ((camera_focus_changed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_FOCUS_CHANGE])( m->code, handle->user_data[_CAMERA_EVENT_TYPE_FOCUS_CHANGE]); + } + break; + case MM_MESSAGE_CAMCORDER_CAPTURED: + { + MMCamRecordingReport *report = (MMCamRecordingReport *)m ->data; + int mode; + mm_camcorder_get_attributes(handle->mm_handle ,NULL,MMCAM_MODE, &mode, NULL); + if( mode == MM_CAMCORDER_MODE_IMAGE){ + //pseudo state change + previous_state = handle->state ; + handle->state = CAMERA_STATE_CAPTURED; + if( previous_state != handle->state && handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE] ){ + ((camera_state_changed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE])(previous_state, handle->state, 0 , handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE]); + } + + if( handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] ){ + ((camera_capture_completed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE])(handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE]); + } + }else{ + if( report != NULL && report->recording_filename ){ + free(report->recording_filename ); + report->recording_filename = NULL; + } + if( report ){ + free(report); + report = NULL; + } + } + break; + } + case MM_MESSAGE_CAMCORDER_ERROR: + { + int errorcode = m->code; + errorcode = _convert_camera_error_code("NOTIFY", errorcode); + if( handle->user_cb[_CAMERA_EVENT_TYPE_ERROR] ) + ((camera_error_cb)handle->user_cb[_CAMERA_EVENT_TYPE_ERROR])(errorcode, handle->state , handle->user_data[_CAMERA_EVENT_TYPE_ERROR]); + + break; + } + + + } + + return 1; +} + +int camera_create( camera_device_e device, camera_h* camera){ + + if( camera == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + + int ret; + MMCamPreset info; + int preview_format; + int rotation; + + if( device == CAMERA_DEVICE_CAMERA1 ) + info.videodev_type= MM_VIDEO_DEVICE_CAMERA1; + else + info.videodev_type= MM_VIDEO_DEVICE_CAMERA0; + + camera_s* handle = (camera_s*)malloc( sizeof(camera_s) ); + if(handle==NULL){ + LOGE("[%s] malloc fail",__func__); + return CAMERA_ERROR_OUT_OF_MEMORY; + } + memset(handle, 0 , sizeof(camera_s)); + + ret = mm_camcorder_create(&handle->mm_handle, &info); + if( ret != MM_ERROR_NONE){ + free(handle); + return _convert_camera_error_code(__func__,ret); + } + + preview_format = MM_PIXEL_FORMAT_YUYV; + rotation = MM_DISPLAY_ROTATION_NONE; + ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, MMCAM_RECOMMEND_PREVIEW_FORMAT_FOR_CAPTURE, &preview_format, MMCAM_RECOMMEND_DISPLAY_ROTATION, &rotation, NULL); + + + char *error; + ret = mm_camcorder_set_attributes(handle->mm_handle, &error, + MMCAM_MODE , MM_CAMCORDER_MODE_IMAGE, + MMCAM_CAMERA_FORMAT, preview_format, + MMCAM_IMAGE_ENCODER , MM_IMAGE_CODEC_JPEG, + MMCAM_CAPTURE_FORMAT, MM_PIXEL_FORMAT_ENCODED , + MMCAM_DISPLAY_SURFACE, MM_DISPLAY_SURFACE_NULL, + MMCAM_DISPLAY_ROTATION, rotation, + MMCAM_CAPTURE_COUNT, 1, + (void*)NULL); + + handle->display_type = CAMERA_DISPLAY_TYPE_NONE; + + if( ret != MM_ERROR_NONE){ + LOGE("[%s] mm_camcorder_set_attributes fail(%x, %s)",__func__, ret, error); + mm_camcorder_destroy(handle->mm_handle); + free(error); + free(handle); + return _convert_camera_error_code(__func__, ret); + } + + handle->state = CAMERA_STATE_CREATED; + mm_camcorder_set_message_callback(handle->mm_handle, mm_message_callback, (void*)handle); + + + if( ret == MM_ERROR_NONE) + *camera = (camera_h)handle; + + return _convert_camera_error_code(__func__, ret); + +} + + int camera_destroy(camera_h camera){ + if( camera == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + int ret; + camera_s *handle = (camera_s*)camera; + + ret = mm_camcorder_destroy(handle->mm_handle); + + if( ret == MM_ERROR_NONE) + free(handle); + + return _convert_camera_error_code(__func__, ret); + +} + +int camera_start_preview(camera_h camera){ + if( camera == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + + int ret; + camera_s *handle = (camera_s*)camera; + + if( handle->state == CAMERA_STATE_CAPTURED ) + { + ret = mm_camcorder_capture_stop(handle->mm_handle); + return _convert_camera_error_code(__func__, ret); + } + + + + //for receving MM_MESSAGE_CAMCORDER_CAPTURED evnet must be seted capture callback + mm_camcorder_set_video_capture_callback( handle->mm_handle, (mm_camcorder_video_capture_callback)mm_capture_callback, (void*)handle); + + if( handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW] ) + mm_camcorder_set_video_stream_callback( handle->mm_handle, (mm_camcorder_video_stream_callback)mm_videostream_callback, (void*)handle); + else + mm_camcorder_set_video_stream_callback( handle->mm_handle, (mm_camcorder_video_stream_callback)NULL, (void*)NULL); + + MMCamcorderStateType state ; + mm_camcorder_get_state(handle->mm_handle, &state); + if( state != MM_CAMCORDER_STATE_READY){ + ret = mm_camcorder_realize(handle->mm_handle); + if( ret != MM_ERROR_NONE ) + return _convert_camera_error_code(__func__, ret); + } + + ret = mm_camcorder_start(handle->mm_handle); + + //start fail. + if( ret != MM_ERROR_NONE && state != MM_CAMCORDER_STATE_READY){ + mm_camcorder_unrealize(handle->mm_handle); + } + + return _convert_camera_error_code(__func__, ret); +} + +int camera_stop_preview(camera_h camera){ + if( camera == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + + int ret; + camera_s *handle = (camera_s*)camera; + MMCamcorderStateType state ; + mm_camcorder_get_state(handle->mm_handle, &state); + + if( state == MM_CAMCORDER_STATE_PREPARE ){ + ret = mm_camcorder_stop(handle->mm_handle); + if( ret != MM_ERROR_NONE) + return _convert_camera_error_code(__func__, ret); + } + + ret = mm_camcorder_unrealize(handle->mm_handle); + return _convert_camera_error_code(__func__, ret); +} + +int camera_start_capture(camera_h camera){ + if( camera == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + return mm_camcorder_capture_start(((camera_s*)camera)->mm_handle); +} + + +int camera_get_state(camera_h camera, camera_state_e * state){ + if( camera == NULL || state == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + camera_s *handle = (camera_s*)camera; + camera_state_e capi_state; + MMCamcorderStateType mmstate ; + mm_camcorder_get_state(handle->mm_handle, &mmstate); + + capi_state = _camera_state_convert(mmstate); + + if( handle->state == CAMERA_STATE_CAPTURED && mmstate == MM_CAMCORDER_STATE_CAPTURING ) + capi_state = CAMERA_STATE_CAPTURED; + + *state = capi_state; + + return CAMERA_ERROR_NONE; + +} + +int camera_start_focusing( camera_h camera ){ + if( camera == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + return _convert_camera_error_code(__func__, mm_camcorder_start_focusing(((camera_s*)camera)->mm_handle)); +} +int camera_cancel_focusing( camera_h camera ){ + if( camera == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + return _convert_camera_error_code(__func__, mm_camcorder_stop_focusing(((camera_s*)camera)->mm_handle)); +} +int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display){ + if( camera == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + int ret; + camera_s * handle = (camera_s*)camera; + handle->display_handle = display; + handle->display_type = type; + ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, + MMCAM_DISPLAY_DEVICE, MM_DISPLAY_DEVICE_MAINLCD, + MMCAM_DISPLAY_SURFACE ,type, + MMCAM_DISPLAY_HANDLE , type == CAMERA_DISPLAY_TYPE_X11 ? &handle->display_handle : display , sizeof(display) , + NULL); + return _convert_camera_error_code(__func__, ret); +} + +int camera_set_preview_resolution(camera_h camera, int width, int height){ + if( camera == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + int ret; + camera_s * handle = (camera_s*)camera; + ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_WIDTH , width ,MMCAM_CAMERA_HEIGHT ,height, NULL); + return _convert_camera_error_code(__func__, ret); + +} +int camera_set_x11_display_rotation(camera_h camera, camera_display_rotation_e rotation){ + if( camera == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + if( rotation < CAMERA_DISPLAY_ROTATION_NONE || rotation > CAMERA_DISPLAY_ROTATION_270 ) + return CAMERA_ERROR_INVALID_PARAMETER; + + int ret; + camera_s * handle = (camera_s*)camera; + + ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_DISPLAY_ROTATION , rotation, NULL); + return _convert_camera_error_code(__func__, ret); +} + +int camera_set_capture_resolution(camera_h camera, int width, int height){ + if( camera == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + int ret; + camera_s * handle = (camera_s*)camera; + ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAPTURE_WIDTH, width ,MMCAM_CAPTURE_HEIGHT , height, NULL); + return _convert_camera_error_code(__func__, ret); +} + +int camera_set_capture_format(camera_h camera, camera_pixel_format_e format){ + if( camera == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + int ret; + camera_s * handle = (camera_s*)camera; + ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAPTURE_FORMAT, format , NULL); + return _convert_camera_error_code(__func__, ret); +} + +int camera_set_preview_format(camera_h camera, camera_pixel_format_e format){ + if( camera == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + int ret; + camera_s * handle = (camera_s*)camera; + ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FORMAT, format , NULL); + return _convert_camera_error_code(__func__, ret); +} + +int camera_get_preview_resolution(camera_h camera, int *width, int *height){ + if( camera == NULL || width == NULL || height == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + int ret; + camera_s * handle = (camera_s*)camera; + ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_WIDTH , width,MMCAM_CAMERA_HEIGHT, height, NULL); + return _convert_camera_error_code(__func__, ret); + +} + +int camera_get_x11_display_rotation( camera_h camera, camera_display_rotation_e *rotation){ + if( camera == NULL || rotation == NULL ){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + int ret; + camera_s * handle = (camera_s*)camera; + + ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_DISPLAY_ROTATION , rotation, NULL); + return _convert_camera_error_code(__func__, ret); +} + +int camera_set_x11_display_visible(camera_h camera, bool visible){ + if( camera == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + int ret; + camera_s * handle = (camera_s*)camera; + + ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_DISPLAY_VISIBLE , visible, NULL); + return _convert_camera_error_code(__func__, ret); +} + +int camera_is_x11_display_visible(camera_h camera, bool* visible){ + if( camera == NULL || visible == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + int ret; + int result; + camera_s * handle = (camera_s*)camera; + + ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_DISPLAY_VISIBLE , &result, NULL); + if( ret == 0) + *visible = result; + return _convert_camera_error_code(__func__, ret); +} + +int camera_set_x11_display_mode( camera_h camera , camera_display_mode_e ratio){ + if( camera == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + if( ratio < CAMERA_DISPLAY_MODE_LETTER_BOX || ratio > CAMERA_DISPLAY_MODE_CROPPED_FULL ) + return CAMERA_ERROR_INVALID_PARAMETER; + + int ret; + camera_s * handle = (camera_s*)camera; + + ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_DISPLAY_GEOMETRY_METHOD , ratio, NULL); + return _convert_camera_error_code(__func__, ret); +} + +int camera_get_x11_display_mode( camera_h camera , camera_display_mode_e* ratio){ + if( camera == NULL || ratio == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + int ret; + camera_s * handle = (camera_s*)camera; + + ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_DISPLAY_GEOMETRY_METHOD , ratio, NULL); + return _convert_camera_error_code(__func__, ret); +} + + +int camera_get_capture_resolution(camera_h camera, int *width, int *height){ + if( camera == NULL || width== NULL || height == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + int ret; + camera_s * handle = (camera_s*)camera; + ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAPTURE_WIDTH, width ,MMCAM_CAPTURE_HEIGHT , height, NULL); + return _convert_camera_error_code(__func__, ret); +} + +int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format){ + if( camera == NULL || format == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + int ret; + camera_s * handle = (camera_s*)camera; + ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAPTURE_FORMAT, format , NULL); + return _convert_camera_error_code(__func__, ret); +} + +int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format){ + if( camera == NULL || format == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + int ret; + camera_s * handle = (camera_s*)camera; + ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FORMAT, format , NULL); + return _convert_camera_error_code(__func__, ret); +} + +int camera_set_preview_cb( camera_h camera, camera_preview_cb callback, void* user_data ){ + if( camera == NULL || callback == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + camera_s * handle = (camera_s*)camera; + handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW] = (void*)callback; + handle->user_data[_CAMERA_EVENT_TYPE_PREVIEW] = (void*)user_data; + return CAMERA_ERROR_NONE; +} +int camera_unset_preview_cb( camera_h camera){ + if( camera == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + camera_s * handle = (camera_s*)camera; + handle->user_cb[_CAMERA_EVENT_TYPE_PREVIEW] = (void*)NULL; + handle->user_data[_CAMERA_EVENT_TYPE_PREVIEW] = (void*)NULL; + return CAMERA_ERROR_NONE; +} +int camera_set_capturing_cb( camera_h camera, camera_capturing_cb callback, void* user_data ){ + + if( camera == NULL || callback == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + camera_s * handle = (camera_s*)camera; + handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] = (void*)callback; + handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE] = (void*)user_data; + return CAMERA_ERROR_NONE; +} +int camera_unset_capturing_cb( camera_h camera){ + if( camera == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + camera_s * handle = (camera_s*)camera; + handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE] = (void*)NULL; + handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE] = (void*)NULL; + return CAMERA_ERROR_NONE; +} +int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void* user_data){ + if( camera == NULL || callback == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + camera_s * handle = (camera_s*)camera; + handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void*)callback; + handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void*)user_data; + return CAMERA_ERROR_NONE; +} +int camera_unset_state_changed_cb(camera_h camera){ + if( camera == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + camera_s * handle = (camera_s*)camera; + handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void*)NULL; + handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void*)NULL; + return CAMERA_ERROR_NONE; +} + +int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void* user_data){ + if( camera == NULL || callback == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + camera_s * handle = (camera_s*)camera; + handle->user_cb[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void*)callback; + handle->user_data[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void*)user_data; + return CAMERA_ERROR_NONE; +} +int camera_unset_focus_changed_cb(camera_h camera){ + if( camera == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + camera_s * handle = (camera_s*)camera; + handle->user_cb[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void*)NULL; + handle->user_data[_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void*)NULL; + return CAMERA_ERROR_NONE; +} + +int camera_set_capture_completed_cb(camera_h camera, camera_capture_completed_cb callback, void* user_data){ + + if( camera == NULL || callback == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + camera_s * handle = (camera_s*)camera; + handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void*)callback; + handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void*)user_data; + return CAMERA_ERROR_NONE; +} + +int camera_unset_capture_completed_cb(camera_h camera){ + + if( camera == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + camera_s * handle = (camera_s*)camera; + handle->user_cb[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void*)NULL; + handle->user_data[_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = (void*)NULL; + return CAMERA_ERROR_NONE; +} + +int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data){ + if( camera == NULL || callback == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + camera_s * handle = (camera_s*)camera; + handle->user_cb[_CAMERA_EVENT_TYPE_ERROR] = (void*)callback; + handle->user_data[_CAMERA_EVENT_TYPE_ERROR] = (void*)user_data; + return CAMERA_ERROR_NONE; +} + +int camera_unset_error_cb(camera_h camera){ + if( camera == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + camera_s * handle = (camera_s*)camera; + handle->user_cb[_CAMERA_EVENT_TYPE_ERROR] = (void*)NULL; + handle->user_data[_CAMERA_EVENT_TYPE_ERROR] = (void*)NULL; + return CAMERA_ERROR_NONE; +} + +int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb , void *user_data){ + if( camera == NULL || foreach_cb == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + int ret; + camera_s * handle = (camera_s*)camera; + MMCamAttrsInfo preview_width; + MMCamAttrsInfo preview_height; + ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_WIDTH , &preview_width); + ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_HEIGHT , &preview_height); + + if( ret != CAMERA_ERROR_NONE ) + return _convert_camera_error_code(__func__, ret); + + int i; + for( i=0 ; i < preview_width.int_array.count ; i++) + { + if ( foreach_cb(preview_width.int_array.array[i], preview_height.int_array.array[i],user_data) < 0 ) + break; + } + return CAMERA_ERROR_NONE; + +} +int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb , void *user_data){ + if( camera == NULL || foreach_cb == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + int ret; + camera_s * handle = (camera_s*)camera; + MMCamAttrsInfo capture_width; + MMCamAttrsInfo capture_height; + ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAPTURE_WIDTH , &capture_width); + ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAPTURE_HEIGHT , &capture_height); + + if( ret != CAMERA_ERROR_NONE ) + return _convert_camera_error_code(__func__, ret); + + int i; + for( i=0 ; i < capture_width.int_array.count ; i++) + { + if ( !foreach_cb(capture_width.int_array.array[i], capture_height.int_array.array[i],user_data) ) + break; + } + return CAMERA_ERROR_NONE; +} + +int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb , void *user_data){ + if( camera == NULL || foreach_cb == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + int ret; + camera_s * handle = (camera_s*)camera; + MMCamAttrsInfo format; + ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAPTURE_FORMAT , &format); + + if( ret != CAMERA_ERROR_NONE ) + return _convert_camera_error_code(__func__, ret); + + int i; + for( i=0 ; i < format.int_array.count ; i++) + { + if ( !foreach_cb(format.int_array.array[i], user_data) ) + break; + } + return CAMERA_ERROR_NONE; + +} + + +int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb , void *user_data){ + if( camera == NULL || foreach_cb == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + int ret; + camera_s * handle = (camera_s*)camera; + MMCamAttrsInfo format; + ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FORMAT , &format); + + if( ret != CAMERA_ERROR_NONE ) + return _convert_camera_error_code(__func__, ret); + + int i; + for( i=0 ; i < format.int_array.count ; i++) + { + if ( !foreach_cb(format.int_array.array[i], user_data) ) + break; + } + return CAMERA_ERROR_NONE; + +} + + +int camera_attr_get_lens_orientation(camera_h camera, int *angle) { + if( camera == NULL || angle == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + int ret; + camera_s * handle = (camera_s*)camera; + int rotation; + ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_RECOMMEND_DISPLAY_ROTATION, &rotation , NULL); + + switch( rotation ) { + case MM_DISPLAY_ROTATION_NONE: + *angle = 0; + break; + case MM_DISPLAY_ROTATION_90: + *angle = 270; + break; + case MM_DISPLAY_ROTATION_180: + *angle = 180; + break; + case MM_DISPLAY_ROTATION_270: + *angle = 90; + break; + } + + return _convert_camera_error_code(__func__, ret); +} + + + +int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps){ + if( camera == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + int ret; + camera_s * handle = (camera_s*)camera; + + if( fps == CAMERA_ATTR_FPS_AUTO ) + ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FPS_AUTO , 1, MMCAM_CAMERA_FPS, CAMERA_ATTR_FPS_60 , NULL); + else + ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FPS_AUTO , 0, MMCAM_CAMERA_FPS , fps, NULL); + + return _convert_camera_error_code(__func__, ret); + +} + + +int camera_attr_set_image_quality(camera_h camera, int quality){ + + if( camera == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + int ret; + camera_s * handle = (camera_s*)camera; + ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_IMAGE_ENCODER_QUALITY , quality, NULL); + return _convert_camera_error_code(__func__, ret); + +} +int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps){ + if( camera == NULL || fps == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + int ret; + int mm_fps; + int is_auto; + camera_s * handle = (camera_s*)camera; + + ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FPS , &mm_fps, MMCAM_CAMERA_FPS_AUTO , &is_auto, NULL); + if( is_auto ) + *fps = CAMERA_ATTR_FPS_AUTO; + else + *fps = mm_fps; + + return _convert_camera_error_code(__func__, ret); + +} +int camera_attr_get_image_quality(camera_h camera, int *quality){ + if( camera == NULL || quality == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + int ret; + camera_s * handle = (camera_s*)camera; + ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_IMAGE_ENCODER_QUALITY , quality, NULL); + return _convert_camera_error_code(__func__, ret); + +} + + +int camera_attr_set_zoom(camera_h camera, int zoom){ + if( camera == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + int ret; + camera_s * handle = (camera_s*)camera; + ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_DIGITAL_ZOOM , zoom, NULL); + return _convert_camera_error_code(__func__, ret); + +} +int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode){ + if( camera == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + int ret = CAMERA_ERROR_INVALID_PARAMETER; + camera_s * handle = (camera_s*)camera; + + switch(mode){ + case CAMERA_ATTR_AF_NONE: + ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FOCUS_MODE , MM_CAMCORDER_FOCUS_MODE_NONE , + MMCAM_CAMERA_AF_SCAN_RANGE , MM_CAMCORDER_AUTO_FOCUS_NORMAL , NULL); + break; + case CAMERA_ATTR_AF_NORMAL: + ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FOCUS_MODE , MM_CAMCORDER_FOCUS_MODE_AUTO , + MMCAM_CAMERA_AF_SCAN_RANGE , MM_CAMCORDER_AUTO_FOCUS_NORMAL , NULL); + break; + case CAMERA_ATTR_AF_MACRO: + ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FOCUS_MODE , MM_CAMCORDER_FOCUS_MODE_AUTO , + MMCAM_CAMERA_AF_SCAN_RANGE , MM_CAMCORDER_AUTO_FOCUS_MACRO , NULL); + break; + case CAMERA_ATTR_AF_FULL: + ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FOCUS_MODE , MM_CAMCORDER_FOCUS_MODE_AUTO , + MMCAM_CAMERA_AF_SCAN_RANGE , MM_CAMCORDER_AUTO_FOCUS_FULL , NULL); + break; + + default: + return ret; + } + + return _convert_camera_error_code(__func__, ret); +} + +int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode){ + if( camera == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + int maptable[] = {MM_CAMCORDER_AUTO_EXPOSURE_OFF, //CAMCORDER_EXPOSURE_MODE_OFF + MM_CAMCORDER_AUTO_EXPOSURE_ALL, //CAMCORDER_EXPOSURE_MODE_ALL + MM_CAMCORDER_AUTO_EXPOSURE_CENTER_1, //CAMCORDER_EXPOSURE_MODE_CENTER + MM_CAMCORDER_AUTO_EXPOSURE_SPOT_1, //CAMCORDER_EXPOSURE_MODE_SPOT + MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_1,//CAMCORDER_EXPOSURE_MODE_CUSTOM + }; + + int ret; + camera_s * handle = (camera_s*)camera; + ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_EXPOSURE_MODE , maptable[abs(mode%5)], NULL); + return _convert_camera_error_code(__func__, ret); + +} + +int camera_attr_set_exposure(camera_h camera, int value){ + if( camera == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + int ret; + + camera_s * handle = (camera_s*)camera; + ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_EXPOSURE_VALUE , value, NULL); + return _convert_camera_error_code(__func__, ret); + +} + +int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso){ + if( camera == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + int ret; + camera_s * handle = (camera_s*)camera; + ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_ISO , iso, NULL); + return _convert_camera_error_code(__func__, ret); +} +int camera_attr_set_brightness(camera_h camera, int level){ + if( camera == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + int ret; + + camera_s * handle = (camera_s*)camera; + ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_FILTER_BRIGHTNESS , level, NULL); + return _convert_camera_error_code(__func__, ret); + +} + +int camera_attr_set_contrast(camera_h camera, int level){ + if( camera == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + int ret; + + camera_s * handle = (camera_s*)camera; + ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_FILTER_CONTRAST , level, NULL); + + return _convert_camera_error_code(__func__, ret); + +} +int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb){ + if( camera == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + int ret; + camera_s * handle = (camera_s*)camera; + ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_FILTER_WB , wb, NULL); + return _convert_camera_error_code(__func__, ret); + +} + +int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect){ + if( camera == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + int maptable[] = { + MM_CAMCORDER_COLOR_TONE_NONE, // CAMCORDER_EFFECT_NONE = 0, /**< None */ + MM_CAMCORDER_COLOR_TONE_MONO, //CAMCORDER_EFFECT_MONO, /**< Mono */ + MM_CAMCORDER_COLOR_TONE_SEPIA, //CAMCORDER_EFFECT_SEPIA, /**< Sepia */ + MM_CAMCORDER_COLOR_TONE_NEGATIVE, //CAMCORDER_EFFECT_NEGATIVE, /**< Negative */ + MM_CAMCORDER_COLOR_TONE_BLUE, //CAMCORDER_EFFECT_BLUE, /**< Blue */ + MM_CAMCORDER_COLOR_TONE_GREEN, //CAMCORDER_EFFECT_GREEN, /**< Green */ + MM_CAMCORDER_COLOR_TONE_AQUA, //CAMCORDER_EFFECT_AQUA, /**< Aqua */ + MM_CAMCORDER_COLOR_TONE_VIOLET, //CAMCORDER_EFFECT_VIOLET, /**< Violet */ + MM_CAMCORDER_COLOR_TONE_ORANGE, //CAMCORDER_EFFECT_ORANGE, /**< Orange */ + MM_CAMCORDER_COLOR_TONE_GRAY, //CAMCORDER_EFFECT_GRAY, /**< Gray */ + MM_CAMCORDER_COLOR_TONE_RED, //CAMCORDER_EFFECT_RED, /**< Red */ + MM_CAMCORDER_COLOR_TONE_ANTIQUE, //CAMCORDER_EFFECT_ANTIQUE, /**< Antique */ + MM_CAMCORDER_COLOR_TONE_WARM, //CAMCORDER_EFFECT_WARM, /**< Warm */ + MM_CAMCORDER_COLOR_TONE_PINK, //CAMCORDER_EFFECT_PINK, /**< Pink */ + MM_CAMCORDER_COLOR_TONE_YELLOW, //CAMCORDER_EFFECT_YELLOW, /**< Yellow */ + MM_CAMCORDER_COLOR_TONE_PURPLE, //CAMCORDER_EFFECT_PURPLE, /**< Purple */ + MM_CAMCORDER_COLOR_TONE_EMBOSS, //CAMCORDER_EFFECT_EMBOSS, /**< Emboss */ + MM_CAMCORDER_COLOR_TONE_OUTLINE, //CAMCORDER_EFFECT_OUTLINE, /**< Outline */ + MM_CAMCORDER_COLOR_TONE_SOLARIZATION_1, //CAMCORDER_EFFECT_SOLARIZATION, /**< Solarization1 */ + MM_CAMCORDER_COLOR_TONE_SKETCH_1, //CAMCORDER_EFFECT_SKETCH, /**< Sketch1 */ + }; + int ret; + camera_s * handle = (camera_s*)camera; + ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_FILTER_COLOR_TONE , maptable[abs(effect%20)], NULL); + return _convert_camera_error_code(__func__, ret); +} +int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode){ + if( camera == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + int ret; + camera_s * handle = (camera_s*)camera; + ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_FILTER_SCENE_MODE , mode, NULL); + return _convert_camera_error_code(__func__, ret); + +} + + +int camera_attr_enable_tag(camera_h camera, bool enable){ + if( camera == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + int ret; + camera_s * handle = (camera_s*)camera; + ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_TAG_ENABLE , enable, NULL); + return _convert_camera_error_code(__func__, ret); + +} + +int camera_attr_set_tag_image_description(camera_h camera, const char *description){ + if( camera == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + int ret; + camera_s * handle = (camera_s*)camera; + ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_TAG_IMAGE_DESCRIPTION , description, strlen(description), NULL); + return _convert_camera_error_code(__func__, ret); + +} + +int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation){ + if( camera == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + int ret; + camera_s * handle = (camera_s*)camera; + ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_TAG_ORIENTATION , orientation, NULL); + return _convert_camera_error_code(__func__, ret); + +} + +int camera_attr_set_tag_software(camera_h camera, const char *software){ + if( camera == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + int ret; + camera_s * handle = (camera_s*)camera; + ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_TAG_SOFTWARE , software, strlen(software), NULL); + return _convert_camera_error_code(__func__, ret); + +} + +int camera_attr_set_tag_latitude(camera_h camera, double latitude){ + if( camera == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + int ret; + camera_s * handle = (camera_s*)camera; + ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_TAG_LATITUDE , latitude, NULL); + return _convert_camera_error_code(__func__, ret); + +} + +int camera_attr_set_tag_longitude(camera_h camera, double longtitude){ + if( camera == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + int ret; + camera_s * handle = (camera_s*)camera; + ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_TAG_LONGITUDE , longtitude, NULL); + return _convert_camera_error_code(__func__, ret); + +} + +int camera_attr_set_tag_altitude(camera_h camera, double altitude){ + if( camera == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + int ret; + camera_s * handle = (camera_s*)camera; + ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_TAG_ALTITUDE , altitude, NULL); + return _convert_camera_error_code(__func__, ret); + +} +int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode){ + if( camera == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + int ret; + camera_s * handle = (camera_s*)camera; + ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_STROBE_MODE , mode, NULL); + return _convert_camera_error_code(__func__, ret); +} + + +int camera_attr_get_zoom(camera_h camera, int *zoom){ + if( camera == NULL || zoom == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + int ret; + camera_s * handle = (camera_s*)camera; + ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_DIGITAL_ZOOM , zoom, NULL); + return _convert_camera_error_code(__func__, ret); + +} + +int camera_attr_get_zoom_range(camera_h camera , int *min , int *max){ + if( camera == NULL || min == NULL || max == NULL ){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + int ret; + camera_s * handle = (camera_s*)camera; + MMCamAttrsInfo ainfo; + ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_DIGITAL_ZOOM, &ainfo); + if( min ) + *min = ainfo.int_range.min; + if( max ) + *max = ainfo.int_range.max; + + return _convert_camera_error_code(__func__, ret); +} + + +int camera_attr_get_af_mode( camera_h camera, camera_attr_af_mode_e *mode){ + if( camera == NULL || mode == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + int ret; + int focus_mode; + int af_range; + int detect_mode; + camera_s * handle = (camera_s*)camera; + ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_FOCUS_MODE , &focus_mode, MMCAM_CAMERA_AF_SCAN_RANGE , &af_range, MMCAM_DETECT_MODE , &detect_mode, NULL); + if( ret == CAMERA_ERROR_NONE){ + switch( focus_mode ){ + case MM_CAMCORDER_FOCUS_MODE_NONE : + case MM_CAMCORDER_FOCUS_MODE_PAN : + case MM_CAMCORDER_FOCUS_MODE_MANUAL : + *mode = CAMERA_ATTR_AF_NONE; + break; + case MM_CAMCORDER_FOCUS_MODE_AUTO: + switch ( af_range ){ + case MM_CAMCORDER_AUTO_FOCUS_NONE : + *mode = CAMERA_ATTR_AF_NONE; + break; + case MM_CAMCORDER_AUTO_FOCUS_NORMAL: + *mode = CAMERA_ATTR_AF_NORMAL; + + break; + case MM_CAMCORDER_AUTO_FOCUS_MACRO: + *mode = CAMERA_ATTR_AF_MACRO; + break; + case MM_CAMCORDER_AUTO_FOCUS_FULL: + *mode = CAMERA_ATTR_AF_FULL; + break; + } + break; + case MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO: + *mode = CAMERA_ATTR_AF_NORMAL; + break; + } + + } + return _convert_camera_error_code(__func__, ret); +} + +int camera_attr_get_exposure_mode( camera_h camera, camera_attr_exposure_mode_e *mode){ + if( camera == NULL|| mode == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + int maptable[] = { + CAMERA_ATTR_EXPOSURE_MODE_OFF, //MM_CAMCORDER_AUTO_EXPOSURE_OFF + CAMERA_ATTR_EXPOSURE_MODE_ALL, //MM_CAMCORDER_AUTO_EXPOSURE_ALL + CAMERA_ATTR_EXPOSURE_MODE_CENTER, //MM_CAMCORDER_AUTO_EXPOSURE_CENTER_1 + CAMERA_ATTR_EXPOSURE_MODE_CENTER, //MM_CAMCORDER_AUTO_EXPOSURE_CENTER_2 + CAMERA_ATTR_EXPOSURE_MODE_CENTER, //MM_CAMCORDER_AUTO_EXPOSURE_CENTER_3 + CAMERA_ATTR_EXPOSURE_MODE_SPOT, //MM_CAMCORDER_AUTO_EXPOSURE_SPOT_1 + CAMERA_ATTR_EXPOSURE_MODE_SPOT, //MM_CAMCORDER_AUTO_EXPOSURE_SPOT_2 + CAMERA_ATTR_EXPOSURE_MODE_CUSTOM,//MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_1 + CAMERA_ATTR_EXPOSURE_MODE_CUSTOM //MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_2 + }; + int ret; + int exposure_mode; + camera_s * handle = (camera_s*)camera; + ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_EXPOSURE_MODE , &exposure_mode, NULL); + if( ret == CAMERA_ERROR_NONE ){ + *mode = maptable[abs(exposure_mode%9)]; + } + return _convert_camera_error_code(__func__, ret); + +} + +int camera_attr_get_exposure(camera_h camera, int *value){ + if( camera == NULL || value == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + int ret; + camera_s * handle = (camera_s*)camera; + ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_EXPOSURE_VALUE , value, NULL); + return _convert_camera_error_code(__func__, ret); +} + + +int camera_attr_get_exposure_range(camera_h camera, int *min, int *max){ + if( camera == NULL || min == NULL || max == NULL ){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + int ret; + camera_s * handle = (camera_s*)camera; + MMCamAttrsInfo ainfo; + ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_EXPOSURE_VALUE, &ainfo); + if( min ) + *min = ainfo.int_range.min; + if( max ) + *max = ainfo.int_range.max; + + return _convert_camera_error_code(__func__, ret); +} + + +int camera_attr_get_iso( camera_h camera, camera_attr_iso_e *iso){ + if( camera == NULL || iso == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + int ret; + camera_s * handle = (camera_s*)camera; + ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_CAMERA_ISO , iso, NULL); + return _convert_camera_error_code(__func__, ret); + +} + +int camera_attr_get_brightness(camera_h camera, int *level){ + if( camera == NULL || level == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + int ret; + camera_s * handle = (camera_s*)camera; + ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_FILTER_BRIGHTNESS , level, NULL); + return _convert_camera_error_code(__func__, ret); + +} + +int camera_attr_get_brightness_range(camera_h camera, int *min, int *max){ + if( camera == NULL || min == NULL || max == NULL ){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + int ret; + camera_s * handle = (camera_s*)camera; + MMCamAttrsInfo ainfo; + ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_BRIGHTNESS, &ainfo); + if( min ) + *min = ainfo.int_range.min; + if( max ) + *max = ainfo.int_range.max; + + return _convert_camera_error_code(__func__, ret); +} + + +int camera_attr_get_contrast(camera_h camera, int *level){ + if( camera == NULL || level == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + + int ret; + camera_s * handle = (camera_s*)camera; + ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_FILTER_CONTRAST , level, NULL); + return _convert_camera_error_code(__func__, ret); +} + +int camera_attr_get_contrast_range(camera_h camera, int *min , int *max){ + if( camera == NULL || min == NULL || max == NULL ){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + int ret; + camera_s * handle = (camera_s*)camera; + MMCamAttrsInfo ainfo; + ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_CONTRAST, &ainfo); + if( min ) + *min = ainfo.int_range.min; + if( max ) + *max = ainfo.int_range.max; + + return _convert_camera_error_code(__func__, ret); +} + + +int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb){ + if( camera == NULL || wb == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + int ret; + camera_s * handle = (camera_s*)camera; + ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_FILTER_WB , wb, NULL); + return _convert_camera_error_code(__func__, ret); + +} + +int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect){ + + if( camera == NULL || effect == NULL ){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + int ret; + camera_s * handle = (camera_s*)camera; + int tone; + ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_FILTER_COLOR_TONE , &tone, NULL); + + if( ret != CAMERA_ERROR_NONE ) + return _convert_camera_error_code(__func__, ret); + + switch(tone){ + case MM_CAMCORDER_COLOR_TONE_NONE: + case MM_CAMCORDER_COLOR_TONE_MONO: + case MM_CAMCORDER_COLOR_TONE_SEPIA: + case MM_CAMCORDER_COLOR_TONE_NEGATIVE: + case MM_CAMCORDER_COLOR_TONE_BLUE: + case MM_CAMCORDER_COLOR_TONE_GREEN: + case MM_CAMCORDER_COLOR_TONE_AQUA: + case MM_CAMCORDER_COLOR_TONE_VIOLET: + case MM_CAMCORDER_COLOR_TONE_ORANGE: + case MM_CAMCORDER_COLOR_TONE_GRAY: + case MM_CAMCORDER_COLOR_TONE_RED: + case MM_CAMCORDER_COLOR_TONE_ANTIQUE: + case MM_CAMCORDER_COLOR_TONE_WARM: + case MM_CAMCORDER_COLOR_TONE_PINK: + case MM_CAMCORDER_COLOR_TONE_YELLOW: + case MM_CAMCORDER_COLOR_TONE_PURPLE: + case MM_CAMCORDER_COLOR_TONE_EMBOSS: + case MM_CAMCORDER_COLOR_TONE_OUTLINE: + case MM_CAMCORDER_COLOR_TONE_SOLARIZATION_1: + *effect = tone; + break; + case MM_CAMCORDER_COLOR_TONE_SOLARIZATION_2: + case MM_CAMCORDER_COLOR_TONE_SOLARIZATION_3: + case MM_CAMCORDER_COLOR_TONE_SOLARIZATION_4: + *effect = CAMERA_ATTR_EFFECT_SOLARIZATION; + break; + case MM_CAMCORDER_COLOR_TONE_SKETCH_1: + case MM_CAMCORDER_COLOR_TONE_SKETCH_2: + case MM_CAMCORDER_COLOR_TONE_SKETCH_3: + case MM_CAMCORDER_COLOR_TONE_SKETCH_4: + *effect = CAMERA_ATTR_EFFECT_SKETCH; + break; + } + + return _convert_camera_error_code(__func__, ret); +} + +int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode){ + + if( camera == NULL || mode == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + int ret; + camera_s * handle = (camera_s*)camera; + ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_FILTER_SCENE_MODE , mode, NULL); + return _convert_camera_error_code(__func__, ret); + +} + + +int camera_attr_is_enabled_tag(camera_h camera, bool *enable){ + if( camera == NULL || enable == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + int ret; + camera_s * handle = (camera_s*)camera; + + ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_TAG_ENABLE , enable, NULL); + + return _convert_camera_error_code(__func__, ret); + +} + +int camera_attr_get_tag_image_description(camera_h camera, char **description){ + if( camera == NULL || description == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + int ret; + camera_s * handle = (camera_s*)camera; + char *ndescription = NULL; + int desc_size; + ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_TAG_IMAGE_DESCRIPTION , &ndescription, &desc_size, NULL); + if( ret == CAMERA_ERROR_NONE ){ + if( ndescription != NULL ) + *description = strdup(ndescription); + else + *description = strdup(""); + } + + return _convert_camera_error_code(__func__, ret); + +} + +int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation){ + + if( camera == NULL || orientation == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + int ret; + camera_s * handle = (camera_s*)camera; + ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_TAG_ORIENTATION , orientation, NULL); + return _convert_camera_error_code(__func__, ret); + +} +int camera_attr_get_tag_software(camera_h camera, char **software){ + if( camera == NULL || software == NULL ){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + int ret; + camera_s * handle = (camera_s*)camera; + char *soft; + int soft_size; + ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_TAG_SOFTWARE , &soft, &soft_size, NULL); + if( ret == CAMERA_ERROR_NONE ){ + if( soft != NULL ) + *software = strdup(soft); + else + *software = strdup(""); + } + + return _convert_camera_error_code(__func__, ret); + +} + +int camera_attr_get_tag_latitude(camera_h camera, double *latitude){ + if( camera == NULL || latitude == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + int ret; + camera_s * handle = (camera_s*)camera; + ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_TAG_LATITUDE , latitude, NULL); + return _convert_camera_error_code(__func__, ret); + +} + +int camera_attr_get_tag_longitude(camera_h camera, double *longtitude){ + if( camera == NULL || longtitude == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + int ret; + camera_s * handle = (camera_s*)camera; + ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_TAG_LONGITUDE , longtitude, NULL); + return _convert_camera_error_code(__func__, ret); +} + +int camera_attr_get_tag_altitude(camera_h camera, double *altitude){ + if( camera == NULL || altitude == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + int ret; + camera_s * handle = (camera_s*)camera; + ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_TAG_ALTITUDE , altitude, NULL); + return _convert_camera_error_code(__func__, ret); +} +int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode){ + if( camera == NULL || mode == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + int ret; + camera_s * handle = (camera_s*)camera; + ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_STROBE_MODE , mode, NULL); + return _convert_camera_error_code(__func__, ret); +} + +int camera_attr_foreach_supported_af_mode( camera_h camera, camera_attr_supported_af_mode_cb foreach_cb , void *user_data){ + if( camera == NULL || foreach_cb == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + + int ret; + int i; + camera_s * handle = (camera_s*)camera; + MMCamAttrsInfo af_range; + MMCamAttrsInfo focus_mode; + + ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_AF_SCAN_RANGE , &af_range); + ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FOCUS_MODE , &focus_mode); + + if( ret != CAMERA_ERROR_NONE ) + return _convert_camera_error_code(__func__, ret); + + for( i=0 ; i < af_range.int_array.count ; i++) + { + if ( !foreach_cb(af_range.int_array.array[i],user_data) ) + goto ENDCALLBACK; + } + + + ENDCALLBACK: + + return CAMERA_ERROR_NONE; + +} + +int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb , void *user_data){ + if( camera == NULL || foreach_cb == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + int maptable[] = { + CAMERA_ATTR_EXPOSURE_MODE_OFF, //MM_CAMCORDER_AUTO_EXPOSURE_OFF + CAMERA_ATTR_EXPOSURE_MODE_ALL, //MM_CAMCORDER_AUTO_EXPOSURE_ALL + CAMERA_ATTR_EXPOSURE_MODE_CENTER, //MM_CAMCORDER_AUTO_EXPOSURE_CENTER_1 + -1, //MM_CAMCORDER_AUTO_EXPOSURE_CENTER_2 + -1, //MM_CAMCORDER_AUTO_EXPOSURE_CENTER_3 + CAMERA_ATTR_EXPOSURE_MODE_SPOT, //MM_CAMCORDER_AUTO_EXPOSURE_SPOT_1 + -1, //MM_CAMCORDER_AUTO_EXPOSURE_SPOT_2 + CAMERA_ATTR_EXPOSURE_MODE_CUSTOM,//MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_1 + -1//MM_CAMCORDER_AUTO_EXPOSURE_CUSTOM_2 + }; + int ret; + camera_s * handle = (camera_s*)camera; + MMCamAttrsInfo info; + ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_EXPOSURE_MODE , &info); + if( ret != CAMERA_ERROR_NONE ) + return _convert_camera_error_code(__func__, ret); + + int i; + for( i=0 ; i < info.int_array.count ; i++) + { + if( maptable[info.int_array.array[i]] != -1){ + if ( !foreach_cb(maptable[info.int_array.array[i]],user_data) ) + break; + } + } + return CAMERA_ERROR_NONE; + +} +int camera_attr_foreach_supported_iso( camera_h camera, camera_attr_supported_iso_cb foreach_cb , void *user_data){ + if( camera == NULL || foreach_cb == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + int ret; + camera_s * handle = (camera_s*)camera; + MMCamAttrsInfo info; + ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_ISO , &info); + if( ret != CAMERA_ERROR_NONE ) + return _convert_camera_error_code(__func__, ret); + + int i; + for( i=0 ; i < info.int_array.count ; i++) + { + if ( !foreach_cb(info.int_array.array[i],user_data) ) + break; + } + return CAMERA_ERROR_NONE; + +} + +int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb , void *user_data){ + if( camera == NULL || foreach_cb == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + int ret; + camera_s * handle = (camera_s*)camera; + MMCamAttrsInfo info; + ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_WB , &info); + if( ret != CAMERA_ERROR_NONE ) + return _convert_camera_error_code(__func__, ret); + + int i; + for( i=0 ; i < info.int_array.count ; i++) + { + if ( !foreach_cb(info.int_array.array[i],user_data) ) + break; + } + return CAMERA_ERROR_NONE; + +} +int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb , void *user_data){ + if( camera == NULL || foreach_cb == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + int maptable[] = { + CAMERA_ATTR_EFFECT_NONE, //MM_CAMCORDER_COLOR_TONE_NONE + CAMERA_ATTR_EFFECT_MONO, //MM_CAMCORDER_COLOR_TONE_MONO, + CAMERA_ATTR_EFFECT_SEPIA, //MM_CAMCORDER_COLOR_TONE_SEPIA, /**< Sepia */ + CAMERA_ATTR_EFFECT_NEGATIVE, //MM_CAMCORDER_COLOR_TONE_NEGATIVE, //, /**< Negative */ + CAMERA_ATTR_EFFECT_BLUE, //MM_CAMCORDER_COLOR_TONE_BLUE, /**< Blue */ + CAMERA_ATTR_EFFECT_GREEN, //MM_CAMCORDER_COLOR_TONE_GREEN, /**< Green */ + CAMERA_ATTR_EFFECT_AQUA, //MM_CAMCORDER_COLOR_TONE_AQUA, /**< Aqua */ + CAMERA_ATTR_EFFECT_VIOLET, //MM_CAMCORDER_COLOR_TONE_VIOLET, /**< Violet */ + CAMERA_ATTR_EFFECT_ORANGE, //MM_CAMCORDER_COLOR_TONE_ORANGE, //, /**< Orange */ + CAMERA_ATTR_EFFECT_GRAY, //MM_CAMCORDER_COLOR_TONE_GRAY, //, /**< Gray */ + CAMERA_ATTR_EFFECT_RED, //MM_CAMCORDER_COLOR_TONE_RED, //, /**< Red */ + CAMERA_ATTR_EFFECT_ANTIQUE, //MM_CAMCORDER_COLOR_TONE_ANTIQUE /**< Antique */ + CAMERA_ATTR_EFFECT_WARM, //MM_CAMCORDER_COLOR_TONE_WARM, //, /**< Warm */ + CAMERA_ATTR_EFFECT_PINK, //MM_CAMCORDER_COLOR_TONE_PINK, /**< Pink */ + CAMERA_ATTR_EFFECT_YELLOW, //MM_CAMCORDER_COLOR_TONE_YELLOW, /**< Yellow */ + CAMERA_ATTR_EFFECT_PURPLE, //MM_CAMCORDER_COLOR_TONE_PURPLE, /**< Purple */ + CAMERA_ATTR_EFFECT_EMBOSS, //MM_CAMCORDER_COLOR_TONE_EMBOSS,, /**< Emboss */ + CAMERA_ATTR_EFFECT_OUTLINE, //MM_CAMCORDER_COLOR_TONE_OUTLINE, //, /**< Outline */ + CAMERA_ATTR_EFFECT_SOLARIZATION, //MM_CAMCORDER_COLOR_TONE_SOLARIZATION_1, //, /**< Solarization1 */ + -1, //MM_CAMCORDER_COLOR_TONE_SOLARIZATION_2 + -1 , //MM_CAMCORDER_COLOR_TONE_SOLARIZATION_3 + -1, //MM_CAMCORDER_COLOR_TONE_SOLARIZATION_4 + CAMERA_ATTR_EFFECT_SKETCH , // MM_CAMCORDER_COLOR_TONE_SKETCH_1,/**< Sketch1 */ + -1, //MM_CAMCORDER_COLOR_TONE_SKETCH_2 + -1, //MM_CAMCORDER_COLOR_TONE_SKETCH_3 + -1 //MM_CAMCORDER_COLOR_TONE_SKETCH_4 + }; + + int ret; + camera_s * handle = (camera_s*)camera; + MMCamAttrsInfo info; + ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_COLOR_TONE , &info); + if( ret != CAMERA_ERROR_NONE ) + return _convert_camera_error_code(__func__, ret); + + int i; + for( i=0 ; i < info.int_array.count ; i++) + { + if( maptable[info.int_array.array[i]] != -1){ + if ( !foreach_cb(maptable[info.int_array.array[i]],user_data) ) + break; + } + } + return CAMERA_ERROR_NONE; + +} +int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb , void *user_data){ + if( camera == NULL || foreach_cb == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + int ret; + camera_s * handle = (camera_s*)camera; + MMCamAttrsInfo info; + ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILTER_SCENE_MODE , &info); + if( ret != CAMERA_ERROR_NONE ) + return _convert_camera_error_code(__func__, ret); + + int i; + for( i=0 ; i < info.int_array.count ; i++) + { + if ( !foreach_cb(info.int_array.array[i],user_data) ) + break; + } + return CAMERA_ERROR_NONE; + +} + +int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb , void *user_data){ + if( camera == NULL || foreach_cb == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + int ret; + camera_s * handle = (camera_s*)camera; + MMCamAttrsInfo info; + ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_STROBE_MODE , &info); + if( ret != CAMERA_ERROR_NONE ) + return _convert_camera_error_code(__func__, ret); + + int i; + for( i=0 ; i < info.int_array.count ; i++) + { + if ( !foreach_cb(info.int_array.array[i],user_data) ) + break; + } + return CAMERA_ERROR_NONE; + +} +int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb , void *user_data){ + if( camera == NULL || foreach_cb == NULL){ + LOGE( "[%s] INVALID_PARAMETER(0x%08x)",__func__,CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + int ret; + camera_s * handle = (camera_s*)camera; + MMCamAttrsInfo info; + ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_CAMERA_FPS , &info); + if( ret != CAMERA_ERROR_NONE ) + return _convert_camera_error_code(__func__, ret); + + int i; + //if (foreach_cb(CAMERA_ATTR_FPS_AUTO, user_data) < 0 ) + // return CAMERA_ERROR_NONE; + for( i=0 ; i < info.int_array.count ; i++) + { + if ( !foreach_cb(info.int_array.array[i],user_data) ) + break; + } + return CAMERA_ERROR_NONE; + + +} + + + diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100755 index 0000000..421664d --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,21 @@ +SET(fw_test "${fw_name}-test") + +INCLUDE(FindPkgConfig) +pkg_check_modules(${fw_test} REQUIRED mm-camcorder appcore-efl elementary evas ecore edje ecore-x) +FOREACH(flag ${${fw_test}_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") + MESSAGE(${flag}) +ENDFOREACH() + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall") + +#ADD_EXECUTABLE("system-sensor" system-sensor.c) +#TARGET_LINK_LIBRARIES("system-sensor" ${fw_name} ${${fw_test}_LDFLAGS}) + +aux_source_directory(. sources) +FOREACH(src ${sources}) + GET_FILENAME_COMPONENT(src_name ${src} NAME_WE) + MESSAGE("${src_name}") + ADD_EXECUTABLE(${src_name} ${src}) + TARGET_LINK_LIBRARIES(${src_name} ${fw_name} ${${fw_test}_LDFLAGS}) +ENDFOREACH() diff --git a/test/multimedia_camera_test.c b/test/multimedia_camera_test.c new file mode 100755 index 0000000..7bf3baf --- /dev/null +++ b/test/multimedia_camera_test.c @@ -0,0 +1,1039 @@ +/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + + +#include <Elementary.h> +#include <glib.h> +#include <Ecore.h> +#include <Ecore_X.h> + +#include <stdio.h> +#include <camera.h> + +#include <assert.h> +#include <pthread.h> + +typedef struct{ + Evas_Object* win; + +}appdata; + + +Evas_Object* mEvasWindow; +Ecore_X_Window preview_win; +Evas_Object* img; + +void state_cb(camera_state_e previous , camera_state_e current , int by_asm, const void *user_data){ + char *state_table[] ={ + "CAMERA_STATE_NONE", /**< camera is not created yet */ + "CAMERA_STATE_CREATED", /**< camera is created, but not initialized yet */ + "CAMERA_STATE_PREVIEW", /**< camera is prepared to capture (Preview) */ + "CAMERA_STATE_CAPTURING", /**< While capturing*/ + "CAMERA_STATE_CAPTURED", /**< camera is now recording */ + "CAMERA_STATE_NUM", /**< Number of camera states */ + }; + printf("%s\n", state_table[current]); +} + + +void capturing_cb(void *image_buffer, int buffer_size, int width, int height, camera_pixel_format_e format, void *user_data) +{ + char * filepath = (char*)user_data; + FILE* f = fopen(filepath, "w+"); + bool ret; + if(f!=NULL && image_buffer !=NULL) + { + fwrite(image_buffer,1, buffer_size, f); + printf("capture(%s) %dx%d, buffer_size=%d\n", filepath, width, height, buffer_size); + ret = TRUE; + } + else + { + ret = FALSE; + } + fclose(f); + +} + +int capture_complete(void *user_data){ + camera_h cam = (camera_h)user_data; + + printf("capture_complete!!\n"); + + camera_start_preview(cam); + + return 1; +} + +int stillshot_test(){ + camera_h camera; + camera_create(CAMERA_DEVICE_CAMERA1, &camera); + camera_attr_set_image_quality(camera, 100); + camera_set_capturing_cb(camera, capturing_cb, "/mnt/nfs/test.jpg"); + camera_set_display(camera,CAMERA_DISPLAY_TYPE_X11, GET_DISPLAY(preview_win)); + camera_set_x11_display_rotation(camera, CAMERA_DISPLAY_ROTATION_270); + camera_attr_set_tag_orientation(camera,6); + //camera_attr_set_tag_orientation(camera,CAMERA_ATTR_TAG_ORT_0R_VT_0C_VR); + //camera_attr_enable_tag(camera, true); + camera_set_capture_format(camera, CAMERA_PIXEL_FORMAT_JPEG); + + camera_start_preview(camera); + camera_start_focusing(camera); + + sleep(1); + camera_start_capture(camera); + sleep(1); + camera_start_preview(camera); + camera_stop_preview(camera); + camera_destroy(camera); + return 0; +} + +bool g_preview_fps_pass; +bool _preview_fps_cb(camera_attr_fps_e fps, void *user_data){ + int ret; + camera_attr_fps_e get_fps; + camera_h camera = (camera_h) user_data; + ret = camera_attr_set_preview_fps(camera, fps); + printf("-set preview fps %d\tret=%x\n", fps, ret); + ret = camera_attr_get_preview_fps(camera, &get_fps); + printf("-get preview fps %d\tret=%x", get_fps, ret); + + if(get_fps == fps) + printf("\t\t\tpass\n"); + else{ + printf("\t\t\tfail\n"); + g_preview_fps_pass = false; + return false; + } + return true; +} + + +int preview_fps_test(camera_h camera) +{ + g_preview_fps_pass = true; + printf("------------- PREVIEW FPS TEST -------------\n"); + camera_attr_foreach_supported_fps(camera, _preview_fps_cb,(void*)camera); + printf("--------------------------------------------\n"); + if( g_preview_fps_pass ){ + printf("PREVIEW FPS TEST PASS\n\n"); + return 0; + }else{ + printf("PREVIEW FPS TEST FAIL\n\n"); + return -1; + } +} + +int image_quality_test(camera_h camera){ + int ret1; + int ret2; + int i; + printf("------------- IMAGE QUALITY TEST -------------\n"); + for( i =-10; i <= 110 ; i+=10){ + int quality; + ret1 = camera_attr_set_image_quality(camera,i); + printf("-set image quality %d\tret=%x\n",i,ret1); + ret2 = camera_attr_get_image_quality(camera,&quality); + printf("-get image quality %d\tret=%x",quality,ret2); + + if( i >=0 && i <= 100){ + if( quality == i ){ + printf("\t\t\tpass\n"); + }else + { + printf("\t\t\tfail\n"); + return -1; + } + }else{ //out of bound error + if( ret1 == 0){ + printf("\t\t\tfail\n"); + return -1; + }else{ + printf("\t\t\tpass\n"); + } + } + + } + printf("--------------------------------------------\n"); + printf("IMAGE QUALITY TEST PASS\n\n"); + + return 0; +} + +int zoom_test(camera_h camera){ + int ret1 ; + int ret2 ; + int i; + printf("------------- ZOOM TEST -------------\n"); + + for( i = 0 ; i <= 40 ; i+=5 ){ + int zoom; + ret1 = camera_attr_set_zoom(camera, i); + printf("-set zoom %d\tret=%x\n",i, ret1); + ret2 = camera_attr_get_zoom(camera,&zoom); + printf("-get zoom %d\tret=%x",zoom, ret2); + + if( i >=10 && i <= 30 ){ + if( i == zoom ) + printf("\t\t\tpass\n"); + else{ + printf("\t\t\tfail\n"); + return -1; + } + }else{ + if( ret1 == 0 ){ + printf("\t\t\tfail\n"); + return -1; + }else{ + printf("\t\t\tpass\n"); + } + } + } + printf("--------------------------------------------\n"); + printf("ZOOM TEST PASS\n\n"); + + camera_attr_set_zoom(camera, 10); + return 0; +} + +bool g_af_test_pass ; +bool _af_mode_test_cb(camera_attr_af_mode_e mode, void *user_data){ + camera_h camera = (camera_h) user_data; + int ret; + camera_attr_af_mode_e get_mode; + ret= camera_attr_set_af_mode(camera, mode); + printf("-set af mode %d\tret=%x\n", mode, ret); + ret= camera_attr_get_af_mode(camera, &get_mode); + printf("-get af mode %d\tret=%x", get_mode, ret); + if( mode != get_mode ){ + printf("\t\t\tFAIL\n"); + g_af_test_pass= false; + return false; + }else + printf("\t\t\tPASS\n"); + return true; +} + +int af_mode_test(camera_h camera){ + g_af_test_pass = true; + camera_attr_foreach_supported_af_mode(camera, _af_mode_test_cb, camera); + return g_af_test_pass ? 0 : -1; +} + +bool g_exposure_mode_pass; +bool _exposure_mode_test_cb(camera_attr_exposure_mode_e mode, void *user_data){ + camera_h camera = (camera_h) user_data; + int ret; + camera_attr_exposure_mode_e get_mode; + + ret = camera_attr_set_exposure_mode(camera, mode); + printf("-set exposure mode %d\tret=%x\n", mode,ret); + ret = camera_attr_get_exposure_mode(camera,&get_mode); + printf("-get exposure mode %d\tret=%x\n", get_mode,ret); + if( get_mode != mode ){ + g_exposure_mode_pass = false; + return false; + } + return true; +} + +int exposure_mode_test(camera_h camera){ + g_exposure_mode_pass = true; + camera_attr_foreach_supported_exposure_mode(camera,_exposure_mode_test_cb, camera); + camera_attr_set_exposure_mode(camera, CAMERA_ATTR_EXPOSURE_MODE_ALL); + + return g_exposure_mode_pass ? 0 : -1; +} + +int exposure_test(camera_h camera){ + int i; + int ret1, ret2; + int default_value; + ret1 = camera_attr_get_exposure(camera, &default_value ); + for( i = 0; i < 13 ; i++ ){ + int value; + ret1 = camera_attr_set_exposure(camera, i ); + printf("-set exposure %d\tret=%x\n",i,ret1); + ret2 = camera_attr_get_exposure(camera, &value); + printf("-get exposure %d\tret=%x\n",value,ret2); + if( i >= 1 && i <= 7 ){ + if( value != i) + return -1; + }else{ // out of bound error + if( ret1 == 0 ) + return -1; + } + } + ret1 = camera_attr_set_exposure(camera, default_value ); + return 0; +} + +bool g_iso_test_pass ; +bool _iso_test_cb(camera_attr_iso_e iso, void *user_data){ + camera_h camera = (camera_h) user_data; + int ret; + camera_attr_iso_e get_iso; + ret = camera_attr_set_iso(camera, iso); + printf("-set iso %d\tret=%x\n", iso, ret); + ret = camera_attr_get_iso(camera,&get_iso); + printf("-get iso %d\tret=%x\n", get_iso, ret); + if( get_iso != iso ){ + g_iso_test_pass = false; + return false; + } + return true; +} + +int iso_test(camera_h camera){ + g_iso_test_pass = true; + camera_attr_foreach_supported_iso(camera,_iso_test_cb, camera); + return g_iso_test_pass ? 0 : -1; +} + +int brightness_test(camera_h camera){ + int i; + int ret1,ret2; + int default_value; + ret1 = camera_attr_get_brightness(camera, &default_value ); + for( i = 0; i < 13 ; i++ ){ + int value; + ret1 = camera_attr_set_brightness(camera, i ); + printf("-set brightness %d\tret=%x\n",i,ret1); + ret2 = camera_attr_get_brightness(camera, &value); + printf("-get brightness %d\tret=%x\n",value,ret2); + + if( i >= 1 && i <= 7 ){ + if( value != i) + return -1; + }else{ // out of bound error + if( ret1 == 0 ) + return -1; + } + + } + ret1 = camera_attr_set_brightness(camera, default_value ); + return 0; + +} + +int contrast_test(camera_h camera){ + int i; + int ret1,ret2; + int default_value; + ret1 = camera_attr_get_contrast (camera, &default_value ); + for( i = 0; i < 13 ; i++ ){ + int value; + ret1 = camera_attr_set_contrast (camera, i ); + printf("-set contrast %d\tret=%x\n",i,ret1); + ret2 = camera_attr_get_contrast (camera, &value); + printf("-get contrast %d\tret=%x\n",value,ret2); + + if( i >= 1 && i <= 7 ){ + if( value != i) + return -1; + }else{ // out of bound error + if( ret1 == 0 ) + return -1; + } + } + ret1 = camera_attr_set_contrast (camera, default_value ); + return 0; +} + +bool _whitebalance_test_cb(camera_attr_whitebalance_e wb, void *user_data){ + camera_h camera = (camera_h) user_data; + int ret; + ret = camera_attr_set_whitebalance(camera, wb); + printf("-set whitebalance %d\tret=%x\n", wb,ret); + ret = camera_attr_get_whitebalance(camera,&wb); + printf("-get whitebalance %d\tret=%x\n", wb,ret); + return true; +} + + +int whitebalance_test(camera_h camera){ + camera_attr_foreach_supported_whitebalance(camera, _whitebalance_test_cb ,camera); + return 0; +} + +bool _effect_test_cb(camera_attr_effect_mode_e effect, void *user_data){ + camera_h camera = (camera_h) user_data; + int ret; + ret = camera_attr_set_effect(camera, effect); + printf("-set effect %d\tret=%x\n", effect,ret); + ret = camera_attr_get_effect(camera,&effect); + printf("-get effect %d\tret=%x\n", effect,ret); + return true; +} + + +int effect_test(camera_h camera){ + camera_attr_foreach_supported_effect(camera, _effect_test_cb, camera); + return 0; +} + + +bool _scene_mode_test_cb (camera_attr_scene_mode_e mode, void *user_data){ + camera_h camera = (camera_h) user_data; + int ret; + ret = camera_attr_set_scene_mode(camera, mode); + printf("-set scene %d\tret=%x\n", mode,ret); + ret = camera_attr_get_scene_mode(camera,&mode); + printf("-get scene %d\tret=%x\n", mode,ret); + return true; +} + +int scene_mode_test(camera_h camera){ + camera_attr_foreach_supported_scene_mode(camera, _scene_mode_test_cb, camera); + return 0; +} + +int tag_enable_test(camera_h camera){ + int ret; + bool enable; + ret = camera_attr_enable_tag(camera, true); + printf("-set enable tag true\tret=%x\n",ret); + ret = camera_attr_is_enabled_tag(camera, &enable); + printf("-get enable tag %d\tret=%x\n",enable, ret); + return 0; +} + +int tag_orientation_test(camera_h camera){ + int ret; + camera_attr_tag_orientation_e orientation; + + ret = camera_attr_set_tag_orientation(camera, 1); + printf("-set tag orientation %d\tret=%x\n",1 ,ret); + ret= camera_attr_get_tag_orientation(camera, &orientation); + printf("-get tag orientation %d\tret=%x\n",orientation,ret); + + + ret |= camera_attr_set_tag_orientation(camera, 2 ); + printf("-set tag orientation %d\tret=%x\n",2 ,ret); + ret |= camera_attr_get_tag_orientation(camera, &orientation); + printf("-get tag orientation %d\tret=%x\n",orientation,ret); + + ret |= camera_attr_set_tag_orientation(camera, 3 ); + printf("-set tag orientation %d\tret=%x\n",3 ,ret); + ret |= camera_attr_get_tag_orientation(camera, &orientation); + printf("-get tag orientation %d\tret=%x\n",orientation,ret); + + ret |= camera_attr_set_tag_orientation(camera, 4 ); + printf("-set tag orientation %d\tret=%x\n",4 ,ret); + ret |= camera_attr_get_tag_orientation(camera, &orientation); + printf("-get tag orientation %d\tret=%x\n",orientation,ret); + + ret |= camera_attr_set_tag_orientation(camera, 5 ); + printf("-set tag orientation %d\tret=%x\n",5 ,ret); + ret |= camera_attr_get_tag_orientation(camera, &orientation); + printf("-get tag orientation %d\tret=%x\n",orientation,ret); + + ret |= camera_attr_set_tag_orientation(camera, 6 ); + printf("-set tag orientation %d\tret=%x\n",6 ,ret); + ret |= camera_attr_get_tag_orientation(camera, &orientation); + printf("-get tag orientation %d\tret=%x\n",orientation,ret); + + ret |= camera_attr_set_tag_orientation(camera, 7 ); + printf("-set tag orientation %d\tret=%x\n",7 ,ret); + ret |= camera_attr_get_tag_orientation(camera, &orientation); + printf("-get tag orientation %d\tret=%x\n",orientation,ret); + + ret |= camera_attr_set_tag_orientation(camera, 8 ); + printf("-set tag orientation %d\tret=%x\n",8 ,ret); + ret |= camera_attr_get_tag_orientation(camera, &orientation); + printf("-get tag orientation %d\tret=%x\n",orientation,ret); + + return ret == 0 ? 0 : -1; + +} + +int tag_image_description_test(camera_h camera){ + char *description; + int ret; + ret = camera_attr_set_tag_image_description(camera, "hello capi"); + printf("-set tag image description \"hello capi\"\tret=%x\n", ret); + ret = camera_attr_get_tag_image_description(camera, &description); + printf("-get tag image description \"%s\"\tret=%x\n", description, ret); + free(description); + ret = camera_attr_set_tag_image_description(camera, "12345678901234567890"); + printf("-set tag image description \"12345678901234567890\"\tret=%x\n", ret); + ret = camera_attr_get_tag_image_description(camera, &description); + printf("-get tag image description \"%s\"\tret=%x\n", description, ret); + free(description); + return 0; +} + +int tag_software_test(camera_h camera){ + char *buffer; + int ret; + ret = camera_attr_set_tag_software(camera, "hello capi"); + printf("-set tag software \"hello capi\"\tret=%x\n", ret); + ret = camera_attr_get_tag_software(camera, &buffer); + printf("-get tag software \"%s\"\tret=%x\n", buffer, ret); + free(buffer); + + ret = camera_attr_set_tag_software(camera, "12345678901234567890"); + printf("-set tag software \"12345678901234567890\"\tret=%x\n", ret); + ret = camera_attr_get_tag_software(camera, &buffer); + printf("-get tag software \"%s\"\tret=%x\n", buffer, ret); + free(buffer); + return 0; +} + + +bool _flash_mode_test_cb(camera_attr_flash_mode_e mode, void *user_data){ + camera_h camera = (camera_h) user_data; + int ret; + ret = camera_attr_set_flash_mode(camera, mode); + printf("-set flash mode %d\tret=%x\n", mode,ret); + ret = camera_attr_get_flash_mode(camera,&mode); + printf("-get flash mode %d\tret=%x\n", mode,ret); + return true; +} + + +int flash_mode_test(camera_h camera){ + camera_attr_foreach_supported_flash_mode(camera, _flash_mode_test_cb,camera); + return 0; +} + +int gps_test(camera_h camera){ + double value; + int ret; + ret = camera_attr_set_tag_longitude(camera, 1.12); + printf("-set tag longitude 1.12\tret=%x\n",ret); + ret = camera_attr_get_tag_longitude(camera, &value); + printf("-get tag longitude %g\tret=%x\n",value, ret); + + ret = camera_attr_set_tag_latitude(camera, 1.13); + printf("-set tag latitude 1.13\tret=%x\n", ret); + ret = camera_attr_get_tag_latitude(camera, &value); + printf("-get tag latitude %g\tret=%x\n",value, ret); + + ret = camera_attr_set_tag_altitude(camera, 1.15); + printf("-set tag altitude 1.15\tret=%x\n",ret); + ret = camera_attr_get_tag_altitude(camera, &value); + printf("-get tag altitude %g\tret=%x\n",value, ret); + + return 0; +} +int camera_attribute_test(){ + int ret; + camera_h camera ; + camera_create(CAMERA_DEVICE_CAMERA0 , &camera); + camera_set_display(camera,CAMERA_DISPLAY_TYPE_X11, GET_DISPLAY(preview_win)); + camera_set_x11_display_rotation(camera, CAMERA_DISPLAY_ROTATION_270); + printf("-----------------------create camera-----------------------------\n"); + + preview_fps_test(camera); + image_quality_test(camera); + + camera_start_preview(camera); + printf("--------------------------preview-started-----------------------------------\n"); + + ret = zoom_test(camera); + ret += af_mode_test(camera); + ret += exposure_mode_test(camera); + ret += exposure_test(camera); + ret += iso_test(camera); + ret += brightness_test(camera); + ret += contrast_test(camera); + ret += whitebalance_test(camera); + ret += effect_test(camera); + ret += scene_mode_test(camera); + ret += tag_enable_test(camera); + ret += tag_orientation_test(camera); + ret += tag_image_description_test(camera); + ret += tag_software_test(camera); + ret += flash_mode_test(camera); + ret += gps_test(camera); + + camera_stop_preview(camera); + camera_destroy(camera); + return ret; +} + + +typedef struct { + camera_h camera; + camera_pixel_format_e in_format; + bool iscalled; + bool result; +} camera_preview_test_s; + + void _camera_preview_test_cb(void *stream_buffer, int buffer_size, int width, int height, camera_pixel_format_e format, void *user_data){ + camera_preview_test_s * data = (camera_preview_test_s*)user_data; + data->iscalled = true; + if( format == data->in_format ) + data->result = true; + +} + +bool _preview_format_test_cb(camera_pixel_format_e format, void *user_data){ + int *table = (int*)user_data; + table[format] = 1; + return true; +} + + +int camera_preview_test(){ + int ret; + camera_h camera ; + int i; + camera_preview_test_s preview_test_data; + int enable_preview_format[CAMERA_PIXEL_FORMAT_JPEG+1] = {0,}; + + + camera_create(CAMERA_DEVICE_CAMERA0 , &camera); + camera_set_display(camera,CAMERA_DISPLAY_TYPE_X11, GET_DISPLAY(preview_win)); + camera_set_x11_display_rotation(camera, CAMERA_DISPLAY_ROTATION_270); + camera_set_preview_cb(camera, _camera_preview_test_cb , &preview_test_data); + + ret = camera_foreach_supported_preview_format(camera, _preview_format_test_cb,enable_preview_format); + + printf("-----------------------PREVIEW FORMAT TEST-----------------------------\n"); + + for(i =0; i<= CAMERA_PIXEL_FORMAT_JPEG ; i++){ + if( enable_preview_format[i] ){ + preview_test_data.in_format = i; + preview_test_data.camera = camera; + preview_test_data.iscalled = false; + preview_test_data.result = false; + camera_set_preview_format(camera, i); + printf("-------------PREVIEW FORMAT %d TEST--------------------\n", i); + camera_start_preview(camera); + sleep(1); + camera_stop_preview(camera); + if( preview_test_data.iscalled && preview_test_data.result ){ + printf("PASS\n"); + }else{ + printf("FAIL\n"); + camera_destroy(camera); + return -1; + } + + } + } + + camera_destroy(camera); + return 0; + + +} + + +typedef struct{ + bool iscalled; + bool ispreviewed; + bool iscapturing; + bool iscaptured; + camera_state_e state; +} state_change_data; + +void _state_change_test_cb(camera_state_e previous , camera_state_e current , bool by_asm, void *user_data){ + state_change_data * data = (state_change_data*)user_data; + data->iscalled = true; + if( current == CAMERA_STATE_PREVIEW ) + data->ispreviewed = true; + if( current == CAMERA_STATE_CAPTURED ) + data->iscaptured = true; + if( current == CAMERA_STATE_CAPTURING ) + data->iscapturing = true; + data->state = current; +} + +void _capture_test_cb(void *image_buffer, int buffer_size, int width, int height, camera_pixel_format_e format, void *user_data){ +} + + +int camera_state_change_test(){ + camera_h camera ; + state_change_data data; + bool ispass = true; + + camera_create(CAMERA_DEVICE_CAMERA0 , &camera); + camera_set_display(camera,CAMERA_DISPLAY_TYPE_X11, GET_DISPLAY(preview_win)); + camera_set_x11_display_rotation(camera, CAMERA_DISPLAY_ROTATION_270); + camera_set_state_changed_cb(camera, _state_change_test_cb, &data); + camera_set_capturing_cb(camera,_capture_test_cb, NULL); + + + printf("------------------- PREVIEW STATE Change test------------------\n"); + data.iscalled = false; + data.state = 0; + camera_start_preview(camera); + sleep(1); + if( data.iscalled && data.state == CAMERA_STATE_PREVIEW ) + printf("PASS\n"); + else{ + printf("FAIL\n"); + ispass = false; + } + + + printf("------------------- CREATED STATE Change test------------------\n"); + + data.iscalled = false; + data.state = 0; + camera_stop_preview(camera); + sleep(1); + if( data.iscalled && data.state == CAMERA_STATE_CREATED) + printf("PASS\n"); + else{ + printf("FAIL\n"); + ispass = false; + } + + + printf("------------------- CAPTURED STATE Change test------------------\n"); + + camera_start_preview(camera); + sleep(1); + data.iscalled = false; + data.state = 0; + data.iscaptured = false; + data.ispreviewed= false; + data.iscapturing = false; + camera_start_capture(camera); + sleep(3); + if( data.iscalled && data.iscaptured && data.iscapturing && data.state == CAMERA_STATE_CAPTURED) + printf("PASS\n"); + else{ + printf("FAIL\n"); + ispass = false; + } + + camera_start_preview(camera); + camera_stop_preview(camera); + camera_destroy(camera); + return ispass ? 0: -1; + +} + +void _capture_test2_cb(void *image_buffer, int buffer_size, int width, int height, camera_pixel_format_e format, void *user_data){ + int *iscalled = (int*)user_data; + *iscalled = 1; +} + +int capture_test(){ + camera_h camera ; + int iscalled; + camera_state_e state ; + bool ispass = true; + int timeout = 10; + + printf("---------------------CAPTURE Test -----------------\n"); + + camera_create(CAMERA_DEVICE_CAMERA0 , &camera); + camera_set_display(camera,CAMERA_DISPLAY_TYPE_X11, GET_DISPLAY(preview_win)); + camera_set_x11_display_rotation(camera, CAMERA_DISPLAY_ROTATION_270); + camera_set_capturing_cb(camera,_capture_test2_cb, &iscalled); + camera_start_preview(camera); + iscalled = 0; + camera_start_capture(camera); + + while( camera_get_state(camera, &state ) == 0 && state != CAMERA_STATE_CAPTURED && timeout-- > 0 ) + sleep(1); + + if( iscalled == 1 ) + printf("PASS\n"); + else{ + printf("FAIL\n"); + ispass = false; + } + + + camera_start_preview(camera); + camera_stop_preview(camera); + camera_destroy(camera); + return ispass ? 0: -1; + +} + + +typedef struct{ + int width[100]; + int height[100]; + int count; +} resolution_stack; + + +bool capture_resolution_test_cb(int width, int height, void *user_data){ + resolution_stack *data = (resolution_stack*)user_data; + data->width[data->count] = width; + data->height[data->count] = height; + data->count++; + + printf("%dx%d\n",width, height); + + return true; +} + +typedef struct{ + int expected_width; + int expected_height; + bool ispass; +}preview_test_data; +void _capture_test3_cb(void *image_buffer, int buffer_size, int width, int height, camera_pixel_format_e format, void *user_data){ + preview_test_data *data = (preview_test_data*)user_data; + if( data->expected_height == height && data->expected_width == width ) + data->ispass = true; +} + + +int capture_resolution_test(){ + camera_h camera ; + resolution_stack resolution_list; + int i; + camera_state_e state ; + int ret = 0; + + camera_create(CAMERA_DEVICE_CAMERA0 , &camera); + camera_set_display(camera,CAMERA_DISPLAY_TYPE_X11, GET_DISPLAY(preview_win)); + camera_set_x11_display_rotation(camera, CAMERA_DISPLAY_ROTATION_270); + resolution_list.count = 0; + camera_foreach_supported_capture_resolution(camera, capture_resolution_test_cb, &resolution_list); + //camera_set_state_changed_cb(camera, state_cb, NULL); + + printf("-----------------CAPTURE RESOLUTION TEST---------------------\n"); + + for(i =0 ; i < resolution_list.count ; i++){ + preview_test_data data; + data.ispass = false; + data.expected_width = resolution_list.width[i]; + data.expected_height = resolution_list.height[i]; + int timeout = 10; + + printf("-----------------CAPTURE RESOLUTION (%dx%d)---------------------\n",data.expected_width ,data.expected_height); + + printf("resolution set test %x\n", (unsigned int)camera_set_capture_resolution(camera,data.expected_width ,data.expected_height)); + + camera_set_capturing_cb(camera, _capture_test3_cb , &data); + camera_start_preview(camera); + + camera_start_capture(camera); + + while( camera_get_state(camera, &state ) == 0 && state != CAMERA_STATE_CAPTURED && timeout-- > 0){ + sleep(1); + } + + camera_start_preview(camera); + camera_stop_preview(camera); + if( !data.ispass ){ + ret += -1; + printf("FAIL\n"); + }else{ + printf("PASS\n"); + } + } + + return ret; +} + +bool preview_resolution_cb(int width, int height, void *user_data) +{ + printf("%dx%d\n", width, height); + return true; +} + + +void preview_test(){ + camera_h camera ; + camera_create(CAMERA_DEVICE_CAMERA0, &camera); + camera_set_display(camera, CAMERA_DISPLAY_TYPE_EVAS,img); + //camera_foreach_supported_preview_resolution(camera,preview_resolution_cb, NULL); + camera_start_preview(camera); +} + + +void rotation_test(){ + camera_h camera; + int ret; + ret = camera_create(CAMERA_DEVICE_CAMERA0, &camera); + printf("camera_create %d\n", ret); + camera_set_display(camera, CAMERA_DISPLAY_TYPE_X11 , GET_DISPLAY(preview_win)); + camera_set_x11_display_rotation(camera, CAMERA_DISPLAY_ROTATION_NONE); + camera_start_preview(camera); + sleep(3); + printf("180\n"); + camera_set_x11_display_rotation(camera, CAMERA_DISPLAY_ROTATION_180); + + sleep(3); + printf("270\n"); + camera_set_x11_display_rotation(camera, CAMERA_DISPLAY_ROTATION_270); + + sleep(3); + printf("90\n"); + camera_set_x11_display_rotation(camera, CAMERA_DISPLAY_ROTATION_90); + + sleep(10); + camera_stop_preview(camera); + camera_destroy(camera); + +} + + +void _focus_changed_cb2(camera_focus_state_e state, void *user_data){ + char* table[] = { "CAMERA_FOCUS_STATE_RELEASED", "CAMERA_FOCUS_STATE_ONGOING" , "CAMERA_FOCUS_STATE_FOCUSED","CAMERA_FOCUS_STATE_FAILED" }; + + + printf("focus state %s\n", table[state]); +} + + +void focus_test(){ + camera_h camera; + int ret; + ret = camera_create(CAMERA_DEVICE_CAMERA0, &camera); + printf("camera_create %d\n", ret); + camera_set_display(camera, CAMERA_DISPLAY_TYPE_X11 , GET_DISPLAY(preview_win)); + camera_set_x11_display_rotation(camera, CAMERA_DISPLAY_ROTATION_270); + camera_set_focus_changed_cb(camera, _focus_changed_cb2, NULL); + camera_start_preview(camera); + + sleep(3); + printf("start focusing\n"); + camera_start_focusing(camera); + + sleep(3); + printf("start focusing2\n"); + camera_start_focusing(camera); + sleep(3); + + printf("start focusing3\n"); + camera_start_focusing(camera); + printf("cancel focusing\n"); + camera_cancel_focusing(camera); + + sleep(3); + camera_stop_preview(camera); + camera_destroy(camera); + + + +} + + +void camera_lens_rotation_test(){ + camera_h camera; + camera_create(CAMERA_DEVICE_CAMERA0, &camera); + camera_set_display(camera, CAMERA_DISPLAY_TYPE_X11, GET_DISPLAY(preview_win)); + int angle; + camera_attr_get_lens_orientation(camera, &angle); + printf("angle =%d\n",angle); + camera_start_preview(camera); + + sleep(20); + camera_stop_preview(camera); + camera_destroy(camera); + + + camera_create(CAMERA_DEVICE_CAMERA1, &camera); + camera_set_display(camera, CAMERA_DISPLAY_TYPE_X11, GET_DISPLAY(preview_win)); + + camera_attr_get_lens_orientation(camera, &angle); + printf("angle =%d\n",angle); + camera_start_preview(camera); + + sleep(20); + camera_stop_preview(camera); + camera_destroy(camera); + + +} + +void contrast_test2(){ + camera_h camera; + camera_create(CAMERA_DEVICE_CAMERA0, &camera); + camera_attr_set_contrast(camera, 1); +} + +int camera_test(){ + + int ret=0; + ret = camera_attribute_test(); + ret += camera_preview_test(); + ret += camera_state_change_test(); + ret += capture_test(); + ret += capture_resolution_test(); + ret += stillshot_test(); + camera_lens_rotation_test(); + + contrast_test2(); + + + return ret; +} + + + +void* test_main(void *arg){ + int ret = 0; + + ret = camera_test(); + //focus_test(); + if( ret == 0 ) + printf("--------------CAMERA TEST ALL PASS--------------------------\n"); + else + printf("--------------CAMERA TEST FAIL %d--------------------------\n", -ret); + + + return 0; + +} + +int main(int argc, char ** argv) +{ + int w,h; + elm_init(argc, argv); + + + + mEvasWindow = elm_win_add(NULL, "VIDEO OVERLAY", ELM_WIN_BASIC); + elm_win_title_set(mEvasWindow, "video oeverlay window"); + elm_win_borderless_set(mEvasWindow, EINA_TRUE); + ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h); + evas_object_resize(mEvasWindow, w, h); + elm_win_indicator_state_set(mEvasWindow, EINA_TRUE); + + //elm_win_rotation_set(mEvasWindow, 270); + //elm_win_fullscreen_set(mEvasWindow, 1); + preview_win = elm_win_xwindow_get(mEvasWindow); + + evas_object_show(mEvasWindow); + + img = evas_object_image_add(evas_object_evas_get(mEvasWindow)); + evas_object_resize(mEvasWindow, w, h); + + evas_object_image_fill_set(img, 0, 0, w, h); + + evas_object_show(img); + + pthread_t gloop_thread; + + pthread_create(&gloop_thread, NULL, test_main, NULL); + + //ecore_timer_add(0.01, video_window_update, NULL); + + + elm_run(); + elm_shutdown(); + + + return 0; +} + |