From: Jinkun Jang Date: Tue, 12 Mar 2013 16:46:05 +0000 (+0900) Subject: Tizen 2.1 base X-Git-Tag: 2.1b_release~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c1d9843bfe8e2937a4925fb698129778c5eb3080;p=platform%2Fcore%2Fapi%2Fplayer.git Tizen 2.1 base --- diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..68b49ae --- /dev/null +++ b/AUTHORS @@ -0,0 +1,2 @@ +Kangho Hur +Seungkeun Lee diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..f467f01 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,98 @@ + +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +SET(fw_name "capi-media-player") + +PROJECT(${fw_name}) + +SET(CMAKE_INSTALL_PREFIX /usr) +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) + +SET(INC_DIR include) +INCLUDE_DIRECTORIES(${INC_DIR}) + +SET(dependents "dlog mm-player capi-base-common capi-media-sound-manager mm-ta") +SET(pc_dependents "capi-base-common capi-media-sound-manager") + +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 "-I./include ${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror -DGST_EXT_TIME_ANALYSIS") +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}) + +SET_TARGET_PROPERTIES(${fw_name} + PROPERTIES + VERSION ${FULLVER} + SOVERSION ${MAJORVER} + CLEAN_DIRECT_OUTPUT 1 +) + +INSTALL(TARGETS ${fw_name} DESTINATION lib) +INSTALL( + DIRECTORY ${INC_DIR}/ DESTINATION include/media + FILES_MATCHING + PATTERN "*_private.h" EXCLUDE + PATTERN "${INC_DIR}/*.h" + ) + +SET(PC_NAME ${fw_name}) +SET(PC_REQUIRED ${pc_dependents}) +SET(PC_LDFLAGS -l${fw_name}) +SET(PC_CFLAGS -I\${includedir}/media) + +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) + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..bbe9d02 --- /dev/null +++ b/LICENSE @@ -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/NOTICE b/NOTICE new file mode 100644 index 0000000..ccdad52 --- /dev/null +++ b/NOTICE @@ -0,0 +1,3 @@ +Copyright (c) Samsung Electronics Co., Ltd. All rights reserved. +Except as noted, this software is licensed under Apache License, Version 2. +Please, see the LICENSE file for Apache License terms and conditions. diff --git a/capi-media-player.manifest b/capi-media-player.manifest new file mode 100755 index 0000000..a76fdba --- /dev/null +++ b/capi-media-player.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/capi-media-player.pc.in b/capi-media-player.pc.in new file mode 100644 index 0000000..5d02f8d --- /dev/null +++ b/capi-media-player.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} + diff --git a/include/player.h b/include/player.h new file mode 100644 index 0000000..419a746 --- /dev/null +++ b/include/player.h @@ -0,0 +1,1830 @@ +/* +* 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_MEDIA_PLAYER_H__ +#define __TIZEN_MEDIA_PLAYER_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define PLAYER_ERROR_CLASS TIZEN_ERROR_MULTIMEDIA_CLASS | 0x20 + +/** + * @file player.h + * @brief This file contains the media player API. + */ + +/** + * @addtogroup CAPI_MEDIA_PLAYER_MODULE + * @{ + */ + +/** + * @brief Media player handle type. + */ +typedef struct player_s *player_h; + +/** + * @brief Enumerations of media player state + */ +typedef enum +{ + PLAYER_STATE_NONE, /**< Player is not created */ + PLAYER_STATE_IDLE, /**< Player is created, but not prepared */ + PLAYER_STATE_READY, /**< Player is ready to play media */ + PLAYER_STATE_PLAYING, /**< Player is playing media */ + PLAYER_STATE_PAUSED, /**< Player is paused while playing media */ +} player_state_e; + + + +/** + * @brief Error codes for media player + */ +typedef enum +{ + PLAYER_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ + PLAYER_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ + PLAYER_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ + PLAYER_ERROR_NO_SUCH_FILE = TIZEN_ERROR_NO_SUCH_FILE, /**< No such file or directory */ + PLAYER_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid operation */ + PLAYER_ERROR_FILE_NO_SPACE_ON_DEVICE = TIZEN_ERROR_FILE_NO_SPACE_ON_DEVICE, /**< No space left on device */ + PLAYER_ERROR_SEEK_FAILED = PLAYER_ERROR_CLASS | 0x01 , /**< Seek operation failure */ + PLAYER_ERROR_INVALID_STATE = PLAYER_ERROR_CLASS | 0x02 , /**< Invalid state */ + PLAYER_ERROR_NOT_SUPPORTED_FILE = PLAYER_ERROR_CLASS | 0x03 , /**< Not supported file format */ + PLAYER_ERROR_INVALID_URI = PLAYER_ERROR_CLASS | 0x04 , /**< Invalid URI */ + PLAYER_ERROR_SOUND_POLICY = PLAYER_ERROR_CLASS | 0x05 , /**< Sound policy error */ + PLAYER_ERROR_CONNECTION_FAILED = PLAYER_ERROR_CLASS | 0x06, /**< Streaming connection failed */ + PLAYER_ERROR_VIDEO_CAPTURE_FAILED = PLAYER_ERROR_CLASS | 0x07 /**< Video capture failure */ +} player_error_e; + +/** + * @brief Enumerations of player interrupted type + */ +typedef enum +{ + PLAYER_INTERRUPTED_COMPLETED = 0, /**< Interrupt completed*/ + PLAYER_INTERRUPTED_BY_MEDIA, /**< Interrupted by non-resumable media application*/ + PLAYER_INTERRUPTED_BY_CALL, /**< Interrupted by incoming call*/ + PLAYER_INTERRUPTED_BY_EARJACK_UNPLUG, /**< Interrupted by unplugging headphone*/ + PLAYER_INTERRUPTED_BY_RESOURCE_CONFLICT, /**< Interrupted by resource conflict*/ + PLAYER_INTERRUPTED_BY_ALARM, /**< Interrupted by alarm*/ + PLAYER_INTERRUPTED_BY_EMERGENCY, /**< Interrupted by emergency*/ + PLAYER_INTERRUPTED_BY_RESUMABLE_MEDIA, /**< Interrupted by resumable media application*/ +} player_interrupted_code_e; + +/** + * @brief Enumerations of progressive download message type + */ +typedef enum +{ + PLAYER_PD_STARTED = 0, /**< Progressive download is started */ + PLAYER_PD_COMPLETED, /**< Progressive download is completed */ +} player_pd_message_type_e; + +/** + * @brief + * Enumerations of display type + */ +typedef enum +{ + PLAYER_DISPLAY_TYPE_X11 = 0, /**< X surface display */ + PLAYER_DISPLAY_TYPE_EVAS = 1, /**< Evas image object surface display */ +} player_display_type_e; + +/** + * @brief Enumerations of audio latency mode + */ +typedef enum{ + AUDIO_LATENCY_MODE_LOW = 0, /**< Low audio latency mode*/ + AUDIO_LATENCY_MODE_MID, /**< Middle audio latency mode*/ + AUDIO_LATENCY_MODE_HIGH, /**< High audio latency mode*/ +} audio_latency_mode_e; + +/** + * @brief Player display handle + * + */ +typedef void* player_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_PLAYER_X11_DISPLAY_MODULE + * @{ + */ + +/** + * @brief Enumerations of x surface display rotation type. + */ +typedef enum +{ + PLAYER_DISPLAY_ROTATION_NONE, /**< Display is not rotated */ + PLAYER_DISPLAY_ROTATION_90, /**< Display is rotated 90 degrees */ + PLAYER_DISPLAY_ROTATION_180, /**< Display is rotated 180 degrees */ + PLAYER_DISPLAY_ROTATION_270, /**< Display is rotated 270 degrees */ +} player_display_rotation_e; + +/** + * @brief Enumerations of x surface display aspect ratio + */ +typedef enum +{ + PLAYER_DISPLAY_MODE_LETTER_BOX = 0, /**< Letter box*/ + PLAYER_DISPLAY_MODE_ORIGIN_SIZE, /**< Origin size*/ + PLAYER_DISPLAY_MODE_FULL_SCREEN, /**< full-screen*/ + PLAYER_DISPLAY_MODE_CROPPED_FULL, /**< Cropped full-screen*/ + PLAYER_DISPLAY_MODE_ORIGIN_OR_LETTER, /**< Origin size (if surface size is larger than video size(width/height)) or Letter box (if video size(width/height) is larger than surface size)*/ +} player_display_mode_e; + + +/** + * @} + */ + +/** + * @addtogroup CAPI_MEDIA_PLAYER_STREAM_INFO_MODULE + * @{ + */ + +/** + * @brief Enumerations of media stream content information + */ +typedef enum +{ + PLAYER_CONTENT_INFO_ALBUM, /**< Album */ + PLAYER_CONTENT_INFO_ARTIST, /**< Artist */ + PLAYER_CONTENT_INFO_AUTHOR, /**< Author */ + PLAYER_CONTENT_INFO_GENRE, /**< Genre */ + PLAYER_CONTENT_INFO_TITLE, /**< Title */ + PLAYER_CONTENT_INFO_YEAR, /**< Year */ +} player_content_info_e; + +/** + * @brief Enumerations of media stream content information + */ +typedef enum +{ + PLAYER_TRACK_TYPE_AUDIO, /**< Audio Track */ + PLAYER_TRACK_TYPE_VIDEO, /**< Video Track */ + PLAYER_TRACK_TYPE_TEXT, /**< Text Track */ +} player_track_type_e; +/** + * @} + */ + +/** + * @addtogroup CAPI_MEDIA_PLAYER_AUDIO_EFFECT_MODULE + * @{ + */ + +/** + * @brief Enumerations of audio effect + */ +typedef enum{ + AUDIO_EFFECT_3D = 1, /**< 3D effect */ + AUDIO_EFFECT_BASS, /**< Bass effect */ + AUDIO_EFFECT_ROOM, /**< Room effect */ + AUDIO_EFFECT_REVERB, /**< Reverberation effect */ + AUDIO_EFFECT_CLARITY, /**< Clarity effect */ +} audio_effect_e; + +/** + * @brief Enumerations of preset audio effect + */ +typedef enum{ + AUDIO_EFFECT_PRESET_AUTO = 0, /**< Auto */ + AUDIO_EFFECT_PRESET_NONE, /**< None */ + AUDIO_EFFECT_PRESET_POP, /**< POP */ + AUDIO_EFFECT_PRESET_ROCK, /**< Rock */ + AUDIO_EFFECT_PRESET_DANCE, /**< Dance */ + AUDIO_EFFECT_PRESET_JAZZ, /**< Jazz */ + AUDIO_EFFECT_PRESET_CLASSIC, /**< Classic */ + AUDIO_EFFECT_PRESET_VOCAL, /**< Vocal */ + AUDIO_EFFECT_PRESET_BASS_BOOST, /**< Bass boost */ + AUDIO_EFFECT_PRESET_TREBLE_BOOST, /**< Treble boost */ + AUDIO_EFFECT_PRESET_MTHEATER, /**< Theater */ + AUDIO_EFFECT_PRESET_EXTERNALIZATION,/**< Externalization */ + AUDIO_EFFECT_PRESET_CAFE, /**< Cafe */ + AUDIO_EFFECT_PRESET_CONCERT_HALL, /**< Concert Hall */ + AUDIO_EFFECT_PRESET_VOICE, /**< Voice */ + AUDIO_EFFECT_PRESET_MOVIE, /**< Movie */ + AUDIO_EFFECT_PRESET_VIRTUAL_5_1, /**< Virtual 5.1 */ + AUDIO_EFFECT_PRESET_HIPHOP, /**< HipHop */ + AUDIO_EFFECT_PRESET_RNB, /**< R&B */ + AUDIO_EFFECT_PRESET_FLAT, /**< Flat */ +} audio_effect_preset_e; + +/** + * @brief Called once for each supported audio effect. + * @param[in] effect The audio effect + * @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 player_audio_effect_foreach_supported_effect() will invoke this callback. + * @see player_audio_effect_foreach_supported_effect() + */ +typedef bool (*player_audio_effect_supported_effect_cb)(audio_effect_e effect, void *user_data); + +/** + * @brief Called once for each supported preset audio effect. + * @param[in] preset The preset audio effect + * @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 player_audio_effect_foreach_supported_preset() will invoke this callback. + * @see player_audio_effect_foreach_supported_preset() + */ +typedef bool (*player_audio_effect_supported_preset_cb)(audio_effect_preset_e preset, void *user_data); + +/** + * @} + */ + +/** + * @addtogroup CAPI_MEDIA_PLAYER_X11_DISPLAY_MODULE + * @{ + */ + +/** + * @internal + * @brief Called when the media player needs updated xid. + * @remarks If current display type is not #PLAYER_DISPLAY_TYPE_X11, no operation is performed. + * @param[in] user_data The user data passed from the callback registration function + * @pre It will be invoked when player needs updated xid if you register this callback using player_set_x11_display_pixmap() + * @return The updated xid + * @see player_set_x11_display_pixmap() + */ +typedef unsigned int (*player_x11_pixmap_updated_cb)(void *user_data); + +/** + * @internal + * @brief Called when the media player needs to inform rendering error. + * @remarks If current display type is not #PLAYER_DISPLAY_TYPE_X11, no operation is performed. + * @param[in] pixmap_id The pixmap_id where the rendering error is occurred + * @param[in] user_data The user data passed from the callback registration function + * @see player_set_x11_display_pixmap_error_cb() + */ +typedef void (*player_x11_pixmap_error_cb)(unsigned int *pixmap_id, void *user_data); + +/** + * @} + */ + + +/** + * @addtogroup CAPI_MEDIA_PLAYER_MODULE + * @{ + */ + +/** + * @brief Called when the media player is prepared. + * @details It will be invoked when player has reached the begin of stream + * @param[in] user_data The user data passed from the callback registration function + * @pre player_prepare_async() will cause this callback + * @post The player state will be #PLAYER_STATE_READY + * @see player_prepare_async() + */ +typedef void (*player_prepared_cb)(void *user_data); + +/** + * @brief Called when the media player is completed. + * @details It will be invoked when player has reached to the end of the stream. + * @param[in] user_data The user data passed from the callback registration function + * @pre It will be invoked when playback completed if you register this callback using player_set_completed_cb() + * @see player_set_completed_cb() + * @see player_unset_completed_cb() + */ +typedef void (*player_completed_cb)(void *user_data); + +/** + * @brief Called when the seek operation is completed. + * @param[in] user_data The user data passed from the callback registration function + * @see player_set_position() + * @see player_set_position_ratio() + */ +typedef void (*player_seek_completed_cb)(void *user_data); + +/** + * @brief Called when the media player is interrupted. + * @param[in] error_code The interrupted error code + * @param[in] user_data The user data passed from the callback registration function + * @see player_set_interrupted_cb() + * @see player_unset_interrupted_cb() + */ +typedef void (*player_interrupted_cb)(player_interrupted_code_e code, void *user_data); + +/** + * @brief Called when the media player occured error. + * @param[in] error_code Error code + * @param[in] user_data The user data passed from the callback registration function + * @see player_set_error_cb() + * @see player_unset_error_cb() + * @see #player_error_e + */ +typedef void (*player_error_cb)(int error_code, void *user_data); + +/** + * @brief Called when the buffering percentage of media playback is updated. + * @details If the buffer is full, it will return 100%. + * @param[in] percent The percentage of buffering completed (0~100) + * @param[in] user_data The user data passed from the callback registration function + * @see player_set_buffering_cb() + * @see player_unset_buffering_cb() + */ +typedef void (*player_buffering_cb)(int percent, void *user_data); + + +/** + * @brief Called when the subtitle is updated. + * @param[in] duration The duration of subtitle updated + * @param[in] text The text of subtitle updated + * @param[in] user_data The user data passed from the callback registration function + * @see player_set_subtitle_updated_cb() + * @see player_unset_subtitle_updated_cb() + */ +typedef void (*player_subtitle_updated_cb)(unsigned long duration, char *text, void *user_data); + +/** + * @brief Called when the progressive download is started or completed. + * @param[in] type The message type of progressive download + * @param[in] user_data The user data passed from the callback registration function + * @see player_set_progressive_download_path() + */ +typedef void (*player_pd_message_cb)(player_pd_message_type_e type, void *user_data); + +/** + * @brief Called when the video is captured. + * @remarks The color space format of the captured image is #IMAGE_UTIL_COLORSPACE_RGB888. + * @param[in] data The captured image buffer + * @param[in] width The width of captured image + * @param[in] height The height of captured image + * @param[in] size The size of captured image + * @param[in] user_data The user data passed from the callback registration function + * @see player_capture_video() + */ +typedef void (*player_video_captured_cb)(unsigned char *data, int width, int height, unsigned int size, void *user_data); + +/** + * @brief Called when the video frame is decoded. + * @remarks The color space format of the captured image is #IMAGE_UTIL_COLORSPACE_RGB888. + * @param[in] data The decoded video frame data + * @param[in] width The width of video frame + * @param[in] height The height of video frame + * @param[in] size The size of video frame + * @param[in] user_data The user data passed from the callback registration function + * @see player_set_video_frame_decoded_cb() + * @see player_unset_video_frame_decoded_cb() + */ +typedef void (*player_video_frame_decoded_cb)(unsigned char *data, int width, int height, unsigned int size, void *user_data); + +/** + * @brief Called when the audio frame is decoded. + * @param[in] data The decoded audio frame data + * @param[in] size The size of audio frame + * @param[in] user_data The user data passed from the callback registration function + * @see player_set_audio_frame_decoded_cb() + * @see player_unset_audio_frame_decoded_cb() + */ +typedef void (*player_audio_frame_decoded_cb)(unsigned char *data, unsigned int size, void *user_data); + +/** + * @brief Creates a player handle for playing multimedia content. + * @remarks @a player must be released player_destroy() by you. + * @remarks + * Although you can create multiple player handles at the same time, + * the player cannot guarantee proper operation because of limited resources, such as + * audio or display device. + * + * @param[out] player A new handle to media player + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_OUT_OF_MEMORY Out of memory + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @post The player state will be #PLAYER_STATE_IDLE. + * @see player_destroy() + */ +int player_create(player_h *player); + + +/** + * @brief Destroys the media player handle and releases all its resources. + * + * @remarks To completely shutdown player operation, call this function with a valid player handle from any player state. + * + * @param[in] player The handle to media player to be destroyed + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @pre The player state should be #PLAYER_STATE_IDLE + * @post The player state will be #PLAYER_STATE_NONE. + * @see player_create() + */ +int player_destroy(player_h player); + +/** + * @brief Prepares the media player for playback. + * @param[in] player The handle to media player + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_URI Invalid URI + * @retval #PLAYER_ERROR_NO_SUCH_FILE File not found + * @retval #PLAYER_ERROR_NOT_SUPPORTED_FILE Not supported file + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state should be #PLAYER_STATE_IDLE by player_create() or player_unprepare(). After that, call player_set_uri() to load the media content you want to play. + * @post The player state will be #PLAYER_STATE_READY. + * @see player_prepare_async() + * @see player_unprepare() + * @see player_set_uri() + */ +int player_prepare(player_h player); + +/** + * @brief Prepares the media player for playback, asynchronously. + * @param[in] player The handle to media player + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_URI Invalid URI + * @retval #PLAYER_ERROR_NO_SUCH_FILE File not found + * @retval #PLAYER_ERROR_NOT_SUPPORTED_FILE Not supported file + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state should be #PLAYER_STATE_IDLE by player_create() or player_unprepare().. After that, call player_set_uri() to load the media content you want to play.. + * @post It invokes player_prepared_cb() when playback is prepare. + * @see player_prepare() + * @see player_prepared_cb() + * @see player_unprepare() + * @see player_set_uri() + */ +int player_prepare_async (player_h player, player_prepared_cb callback, void* user_data); + +/** + * @brief Reset the media player. + * @details + * The most recently used media is reset and no longer associated with the player. + * Playback is no longer possible. If you want to use the player again, you will have to set the data URI and call + * player_prepare() again. + * @param[in] player The handle to media player + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state should be #PLAYER_STATE_READY by player_prepare() or player_stop(). + * @post The player state will be #PLAYER_STATE_IDLE. + * @see player_prepare() + */ +int player_unprepare(player_h player); + +/** + * @brief Sets the data source (file-path, http or rtsp URI) to use. + * + * @details + * Associates media contents, referred to by the URI, with the player. + * If the function call is successful, subsequent calls to player_prepare() and player_start() will start playing the media. + * + * @remarks + * If you use http or rtsp, URI should start with "http://" or "rtsp://". The default protocol is "file://". + * If you provide an invalid URI, you won't receive an error message until you call player_start(). + * + * @param[in] player The handle to media player + * @param[in] uri Specifies the content location, such as the file path, the URI of the http or rtsp stream you want to play + * + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state should be #PLAYER_STATE_IDLE by player_create() or player_unprepare(). + * @see player_set_memory_buffer() + */ +int player_set_uri(player_h player, const char * uri); + +/** + * @brief Sets memory as the data source. + * + * @details + * Associates media content, cached in memory, with the player. Unlike the case of player_set_uri(), the media resides in memory. + * If the function call is successful, subsequent calls to player_prepare() and player_start() will start playing the media. + * + * @remarks + * If you provide an invalid data, you won't receive an error message until you call player_start(). + * + * + * @param[in] player The handle to media player + * @param[in] data The memory pointer of media data + * @param[in] size The size of media data + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state should be #PLAYER_STATE_IDLE by player_create() or player_unprepare(). + * @see player_set_uri() + */ +int player_set_memory_buffer(player_h player, const void * data, int size); + +/** + * @brief Gets the player's current state. + * @param[in] player The handle to media player + * @param[out] state The current state of the player + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @see #player_state_e + */ +int player_get_state(player_h player, player_state_e *state); + + +/** + * @brief Sets the player's volume. + * + * @details + * The range of @a left and @c right is from 0 to 1.0, inclusive (1.0 = 100%). Default value is 1.0. + * Setting this volume adjusts the player volume, not the system volume. + * To change system volume, use the @ref CAPI_MEDIA_SOUND_MANAGER_MODULE API. + * + * @param[in] player The handle to media player + * @param[in] left Left volume scalar + * @param[in] right Right volume scalar + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @see player_get_volume() + */ +int player_set_volume(player_h player, float left, float right); + + +/** + * @brief Gets the player's current volume factor. + * + * @details The range of @a left and @a right is from 0 to 1.0, inclusive (1.0 = 100%). This function gets the player volume, not the system volume. + * To get the system volume, use the @ref CAPI_MEDIA_SOUND_MANAGER_MODULE API. + * + * @param[in] player The handle to media player + * @param[out] left The current left volume scalar + * @param[out] right The current right volume scalar + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @see player_set_volume() + */ +int player_get_volume(player_h player, float *left, float *right); + +/** + * @brief Sets the player's sound type. + * + * @remarks + * The default sound type of player is #SOUND_TYPE_MEDIA. + * To get current sound type, use the sound_manager_get_current_sound_type(). + * + * @param[in] player The handle to media player + * @param[in] type The sound type + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @see sound_manager_get_current_sound_type() + */ +int player_set_sound_type(player_h player, sound_type_e type); + +/** + * @brief Set the latency mode of audio. + * + * @remarks + * The default audio latency mode of player is #AUDIO_LATENCY_MODE_MID. + * To get current audio latency mode, use player_get_audio_latency_mode(). + * + * @param[in] player The handle to media player. + * @param[in] latency_mode The latency mode to be applyed to audio. + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful. + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter. + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation. + * @see #audio_latency_mode_e. + * @see player_get_audio_latency_mode(). + */ +int player_set_audio_latency_mode(player_h player, audio_latency_mode_e latency_mode); + +/** + * @brief Get current latency mode of audio. + * @param[in] player The handle to media player. + * @param[out] latency_mode The latency mode to get from audio. + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful. + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter. + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation. + * @see #audio_latency_mode_e. + * @see player_set_audio_latency_mode(). + */ +int player_get_audio_latency_mode(player_h player, audio_latency_mode_e *latency_mode); + +/** + * @brief Starts or resumes playback. + * + * @details Plays current media content, or resumes play if paused. + * + * @param[in] player The handle to media player + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @retval #PLAYER_ERROR_CONNECTION_FAILED Network connection failed + * @retval #PLAYER_ERROR_SOUND_POLICY Sound policy error + * @pre Call player_prepare() before calling this function. + * @pre The player state must be #PLAYER_STATE_READY by player_prepare() or #PLAYER_STATE_PAUSED by player_pause(). + * @post The player state will be #PLAYER_STATE_PLAYING. + * @post It invokes player_completed_cb() when playback completes, if you set a callback with player_set_completed_cb(). + * @post It invokes player_pd_message_cb() when progressive download starts or completes, if you set a download path with player_set_progressive_download_path() and a callback with player_set_progressive_download_message_cb(). + * @see player_prepare() + * @see player_prepare_async() + * @see player_stop() + * @see player_pause() + * @see player_set_completed_cb() + * @see player_completed_cb() + * @see player_set_progressive_download_path() + * @see player_set_progressive_download_message_cb() + * @see player_pd_message_cb() + */ +int player_start(player_h player); + + +/** + * @brief Stops playing media content. + * @param[in] player The handle to media player + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid state + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @retval #PLAYER_ERROR_SOUND_POLICY Sound policy error + * @pre The player state must be either #PLAYER_STATE_PLAYING by player_start() or #PLAYER_STATE_PAUSED by player_pause(). + * @post The player state will be #PLAYER_STATE_READY. + * @post The downloading will be aborted if you use progressive download. + * @see player_start() + * @see player_pause() + */ +int player_stop(player_h player); + +/** + * @brief Pauses the player. + * + * @remarks Playback can be resumed with player_start(). + * + * @param[in] player The handle to media player + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid state + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @retval #PLAYER_ERROR_SOUND_POLICY Sound policy error + * @pre The player state must be #PLAYER_STATE_PLAYING. + * @post The player state will be #PLAYER_STATE_READY. + * @see player_start() + */ +int player_pause(player_h player); + +/** + * @brief Sets the seek position for playback, asynchronously. + * @param[in] player The handle to media player + * @param[in] millisecond The position in milliseconds from the start to seek to + * @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 #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_SEEK_FAILED Seek operation failure + * @pre The player state must be one of these: #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + * @post It invokes player_seek_completed_cb() when seek operation completes, if you set a callback. + * @see player_get_position() + * @see player_get_position_ratio() + * @see player_set_position_ratio() + */ +int player_set_position(player_h player, int millisecond, player_seek_completed_cb callback, void *user_data); + + +/** + * @brief Sets the playback position specified by percent of media content played, asynchronously. + * @param[in] player The handle to media player + * @param[in] percent The position in percentage from the start to seek to. \n The position is relative to content. (length, 0 = beginning, 100 = end) + * @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 #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_SEEK_FAILED Seek operation failure + * @pre The player state must be one of these: #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + * @post It invokes player_seek_completed_cb() when seek operation completes, if you set a callback. + * @see player_get_position() + * @see player_get_position_ratio() + * @see player_set_position() + */ +int player_set_position_ratio(player_h player, int percent, player_seek_completed_cb callback, void *user_data); + +/** + * @brief Gets current position in milliseconds. + * @param[in] player The handle to media player + * @param[out] millisecond The current position in milliseconds + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_SEEK_FAILED Seek operation failure + * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + * @see player_get_position_ratio() + * @see player_set_position() + * @see player_set_position_ratio() + */ + +int player_get_position(player_h player, int *millisecond); + +/** + * @brief Gets the playback position specified by percent of media content played. + * @param[in] player The handle to media player + * @param[out] percent The current position in percentage [0, 100] + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_SEEK_FAILED Seek operation failure + * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + * @see player_get_position() + * @see player_set_position() + * @see player_set_position_ratio() + */ +int player_get_position_ratio(player_h player, int *percent); + +/** + * @brief Sets the player's mute status. + * + * @details If the mute status is @c true, no sounds will be played. If @c false, sounds will be played at the previously set volume level. Until this function is called, by default the player is not muted. + * + * @param[in] player The handle to media player + * @param[in] muted New mute status: (@c true = mute, @c false = not muted) + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + * @see player_is_muted() + */ +int player_set_mute(player_h player, bool muted); + +/** + * @brief Gets the player's mute status. + * + * @details If the mute status is @c true, no sounds are played. If @c false, sounds are played at previously set volume level. + * + * @param[in] player The handle to media player + * @param[out] muted The current mute status: (@c true = mute, @c false = not muted) + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + * @see player_set_mute() + */ +int player_is_muted(player_h player, bool *muted); + +/** + * @brief Sets the player's looping status. + * + * @details If the looping status is @c true, playback will automatically restart upon finishing. If @c false, it won't. The default value is false. + * + * @param[in] player The handle to media player + * @param[in] looping New looping status: (@c true = looping, @c false = non-looping ) + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + * @see player_is_looping() + */ +int player_set_looping(player_h player, bool looping); + + +/** + * @brief Gets the player's looping status. + * + * @details If the looping status is @c true, playback will automatically restart upon finishing. If @c false, it won't. + * + * @param[in] player The handle to media player + * @param[out] looping The looping status: (@c true = looping, @c false = non-looping ) + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + * @see player_set_looping() + */ +int player_is_looping(player_h player, bool *looping); + +/** + * @brief Gets the total running time of the associated media. + * @remarks The media source is associated with the player, using either player_set_uri() or player_set_memory_buffer(). + * @remarks The playback type should be local playback or http streaming playback. + * @param[in] player The handle to media player + * @param[out] duration The duration is in milliseconds + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of: #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + * @see player_get_position() + * @see player_set_uri() + * @see player_set_memory_buffer() + */ +int player_get_duration(player_h player, int *duration); + +/** + * @brief Sets the video display. + * @remaks To get @a display to set, use #GET_DISPLAY(). + * @remaks To use multiple surface display mode, use player_set_display() again with different display type. + * @param[in] player The handle to media player + * @param[in] type The display type + * @param[in] display The handle to display + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + */ +int player_set_display(player_h player, player_display_type_e type, player_display_h display); + +/** + * @brief Gets the availability of display mode change + * @remark The result can be changed by display setting. + * @param[in] player The handle to media player + * @param[out] changeable The cuurent availability of display mode change (@c true = changeable, @c false = non-changeable ) + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @see player_set_display_mode() + */ +int player_is_display_mode_changeable(player_h player, bool* changeable); + +/** + * @brief Sets a video display mode + * @remarks If no display is not set, no operation is performed. + * @param[in] player The handle to media player + * @param[in] mode The display mode + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_STATE Invalid state + * @pre The player should be supported display mode changing. (player_is_display_mode_changeable()) + * @see player_get_display_mode() + */ +int player_set_display_mode(player_h player, player_display_mode_e mode); + +/** + * @brief Gets the video display mode + * @remarks If no display is not set, no operation is performed. + * @param[in] player The handle to media player + * @param[out] mode The current display mode + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @see player_set_display_mode() + */ +int player_get_display_mode(player_h player, player_display_mode_e *mode); + +/** + * @brief Sets the playback rate + * @details The default value is 1.0. + * @remarks #PLAYER_ERROR_INVALID_OPERATION occured if streaming playbak. + * @remarks No operation is performed, if @a rate is 0. + * @remarks The sound is muted, when playback rate is under 0.0 and over 2.0. + * @param[in] player The handle to media player + * @param[in] rate The playback rate (-5.0x ~ 5.0x) + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be #PLAYER_STATE_PLAYING by player_start(). + */ +int player_set_playback_rate(player_h player, float rate); + +/** + * @} + */ + +/** + * @addtogroup CAPI_MEDIA_PLAYER_X11_DISPLAY_MODULE + * @{ + */ + +/** + * @brief Sets the rotation settings of the x surface video display + * @details Use this function to change the video orientation to portrait mode. + * @remarks If current display type is not #PLAYER_DISPLAY_TYPE_X11, no operation is performed. + * @param[in] player The handle to media player + * @param[in] rotation The rotation of display + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_STATE Invalid state + * @see player_get_x11_display_rotation() + */ +int player_set_x11_display_rotation(player_h player, player_display_rotation_e rotation); + +/** + * @brief Gets a rotation of the x surface video display + * @remarks If current display type is not #PLAYER_DISPLAY_TYPE_X11, no operation is performed. + * @param[in] player The handle to media player + * @param[out] rotation The current rotation of display + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @see player_set_x11_display_rotation() + */ +int player_get_x11_display_rotation( player_h player, player_display_rotation_e *rotation); + +/** + * @brief Sets the visibility of the x surface video display + * @remarks If current display type is not #PLAYER_DISPLAY_TYPE_X11, no operation is performed. + * @param[in] player The handle to media player + * @param[in] rotation The visibility of display (@c true = visible, @c false = non-visible ) + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_STATE Invalid state + * @see player_is_x11_display_visible() + */ +int player_set_x11_display_visible(player_h player, bool visible); + +/** + * @brief Gets a visibility of the x surface video display + * @remarks If current display type is not #PLAYER_DISPLAY_TYPE_X11, no operation is performed. + * @param[in] player The handle to media player + * @param[out] visible The current visibility of display (@c true = visible, @c false = non-visible ) + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @see player_set_x11_display_visible() + */ +int player_is_x11_display_visible(player_h player, bool* visible); + +/** + * @brief Sets the zoom level of the x surface video display + * @remarks If current display type is not #PLAYER_DISPLAY_TYPE_X11, no operation is performed. + * @param[in] player The handle to media player + * @param[in] level The level of zoom [1~9] + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_STATE Invalid state + * @see player_get_x11_display_zoom() + */ +int player_set_x11_display_zoom(player_h player, int level); + +/** + * @brief Gets a zoom level of the x surface video display + * @remarks If current display type is not #PLAYER_DISPLAY_TYPE_X11, no operation is performed. + * @param[in] player The handle to media player + * @param[out] level The level of zoom [1~9] + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @see player_set_x11_display_zoom() + */ +int player_get_x11_display_zoom( player_h player, int *level); + +/** + * @internal + * @brief Registers a callback function to be invoked when player need updated xid. + * @param[in] player The handle to media player + * @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 #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @pre The player state must be either #PLAYER_STATE_IDLE by player_create() or #PLAYER_STATE_READY by player_prepare(). + * @post player_set_x11_display_pixmap() will be invoked + * @see player_set_x11_display_pixmap() + */ +int player_set_x11_display_pixmap (player_h player, player_x11_pixmap_updated_cb callback, void *user_data); + +/** + * @internal + * @brief Registers a callback function to be invoked when failure of rendering video frame happen. + * @param[in] player The handle to media player + * @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 #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_STATE Invalid state + * @pre The player state must be either #PLAYER_STATE_IDLE by player_create() or #PLAYER_STATE_READY by player_prepare(). + * @post player_set_x11_display_pixmap_error_cb() will be invoked + * @see player_set_x11_display_pixmap_error_cb() + */ +int player_set_x11_display_pixmap_error_cb (player_h player, player_x11_pixmap_error_cb callback, void *user_data); + +/** + * @} + */ + +/** + * @addtogroup CAPI_MEDIA_PLAYER_EVAS_DISPLAY_MODULE + * @{ + */ + +/** + * @brief Sets the evas surface video display scaling status. + * @remarks If current display type is not #PLAYER_DISPLAY_TYPE_EVAS, no operation is performed. + * @remarks If the scaling status is @c false, player_is_display_mode_changeable() always return @a false. + * @param[in] player The handle to media player + * @param[in] enable New evas surface video display scaling status: (@c true = scaling, @c false = not scaled) + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + */ +int player_enable_evas_display_scaling(player_h player, bool enable); + +/** + * @} + */ + +/** + * @addtogroup CAPI_MEDIA_PLAYER_STREAM_INFO_MODULE + * @{ + */ + + /** + * @brief Get the media content information + * @remarks @a value must be released with @c free() by you + * @remarks The playback type should be local playback or http streaming playback. + * @param[in] player The handle to media player + * @param[in] key The key attribute name to get + * @param[out] value The value of the key attribute. It can be empty string if there is no content information. + * @return 0 on success, otherwise a negative error value + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_OUT_OF_MEMORY Not enough memory is available + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of: #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + */ +int player_get_content_info(player_h player, player_content_info_e key, char ** value); + +/** + * @brief Gets the audio and video codec information + * @remarks @a audio_codec and @a video_codec must be released with @c free() by you + * @remarks The playback type should be local playback or http streaming playback. + * @param[in] player The handle to media player + * @param[out] audio_codec The name of audio codec. It can be @c NULL if there is no audio codec. + * @param[out] video_codec The name of video codec. It can be @c NULL if there is no video codec. + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of: #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + */ +int player_get_codec_info(player_h player, char **audio_codec, char **video_codec); + +/** + * @brief Gets the audio stream information + * @remarks The playback type should be local playback or http streaming playback. + * @param[in] player The handle to media player + * @param[out] sample_rate The audio sample rate [Hz]. It can be invalid value if there is no audio stream information. + * @param[out] channel The audio channel (1: mono, 2: stereo). It can be invalid value if there is no audio stream information. + * @param[out] bit_rate The audio bit rate [Hz]. It can be invalid value if there is no audio stream information. + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of: #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + */ +int player_get_audio_stream_info(player_h player, int *sample_rate, int *channel, int *bit_rate); + +/** + * @brief Gets the video stream information + * @remarks The playback type should be local playback or http streaming playback. + * @param[in] player The handle to media player + * @param[out] fps The frame per second of video. It can be 0 if there is no video stream information. + * @param[out] bit_rate The video bit rate [Hz]. It can be invalid value if there is no video stream information. + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of: #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + */ +int player_get_video_stream_info(player_h player, int *fps, int *bit_rate); + +/** + * @brief Gets the video display's height and width. + * @remarks The playback type should be local playback or http streaming playback. + * @param[in] player The handle to media player + * @param[out] width The width of video. It can be invalid value if there is no video, no display was set. + * @param[out] height The height of video. It can be invalid value if there is no video, no display was set. + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of: #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + */ +int player_get_video_size(player_h player, int *width, int *height); + +/** + * @brief Gets the album art in media resource + * @remarks Do not release @a album_art. It will be released by framework when player destroys. + * @param[in] player The handle to media player + * @param [out] artwork encoded artwork image + * @param [out] size encoded artwork size + * @return 0 on success, otherwise a negative error value + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of: #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + */ +int player_get_album_art(player_h player, void **album_art, int *size); + +/** + * @brief Gets the track count + * @param[in] player The handle to media player + * @param [in] type The track type + * @param [out] count The count of track + * @return 0 on success, otherwise a negative error value + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of: #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + */ +int player_get_track_count(player_h player, player_track_type_e type, int *count); + +/** + * @} + */ + + +/** + * @addtogroup CAPI_MEDIA_PLAYER_AUDIO_EFFECT_MODULE + * @{ + */ + +/** + * @brief Sets an audio effect value. + * @param[in] player The handle to media player + * @param[in] effect The audio effect type + * @param[in] value The value of given effect type + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + * @see player_audio_effect_get_value() + * @see player_audio_effect_clear() + * @see player_audio_effect_get_value_range() + */ +int player_audio_effect_set_value(player_h player, audio_effect_e effect, int value); + +/** + * @brief Gets an audio effect value. + * @param[in] player The handle to media player + * @param[in] effect The audio effect type + * @param[out] value The value of given effect type + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + * @see player_audio_effect_set_value() + */ +int player_audio_effect_get_value(player_h player, audio_effect_e effect, int *value); + +/** + * @brief Clears audio effect. + * @param[in] player The handle to media player + * @param[in] effect The audio effect type + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + * @see player_audio_effect_set_value() + */ +int player_audio_effect_clear(player_h player, audio_effect_e effect); + +/** + * @brief Gets the range of audio effect value. + * @param[in] player The handle to media player + * @param[in] effect The audio effect type + * @param[out] min The minumum value to be set + * @param[out] max The maximum value to be set + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + * @see player_audio_effect_set_value() + */ +int player_audio_effect_get_value_range(player_h player, audio_effect_e effect, int* min, int* max); + +/** + * @brief Checks whether the given effect is avaliable or not. + * @param[in] player The handle to media player + * @param[in] effect The audio effect to be checked + * @param[out] available @c true if the specified audio effect is available, else @c false + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + */ +int player_audio_effect_is_available(player_h player, audio_effect_e effect, bool *available); + +/** + * @brief Retrieves all supported audio effects by invoking callback function once for each supported audio effect. + * @param[in] player The handle to media player + * @param[in] callback The callback function to invoke + * @param[in] user_data The user data to be passed to the callback function + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + * @post This function invokes player_audio_effect_supported_effect_cb() repeatly to retrieve each supported audio effect. + * @see player_audio_effect_set_value() + * @see player_audio_effect_get_value() + * @see player_audio_effect_foreach_supported_effect() + */ +int player_audio_effect_foreach_supported_effect(player_h player, player_audio_effect_supported_effect_cb callback, void *user_data); + +/** + * @brief Sets an preset audio effect. + * @remarks Audio effects or equalizer which is set be ignored. + * @param[in] player The handle to media player + * @param[in] preset The preset audio effect + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + * @see player_audio_effect_preset_is_available() + * @see player_audio_effect_foreach_supported_preset() + */ +int player_audio_effect_set_preset(player_h player, audio_effect_preset_e preset); + +/** + * @brief Checks whether the given preset is avaliable or not. + * @param[in] player The handle to media player + * @param[in] preset The preset to be checked + * @param[out] available @c true if the specified preset is available, else @c false + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + */ +int player_audio_effect_preset_is_available(player_h player, audio_effect_preset_e preset, bool *available); + +/** + * @brief Retrieves all supported presets by invoking callback function once for each supported preset audio effect. + * @param[in] player The handle to media player + * @param[in] callback The callback function to invoke + * @param[in] user_data The user data to be passed to the callback function + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + * @post This function invokes player_audio_effect_supported_preset_cb() repeatly to retrieve each supported preset audio effect. + * @see player_audio_effect_set_preset() + * @see player_audio_effect_supported_preset_cb() + */ +int player_audio_effect_foreach_supported_preset(player_h player, player_audio_effect_supported_preset_cb callback, void *user_data); + +/** + * @brief Gets the bands number of equalizer. + * @param[in] player The handle to media player + * @param[out] count The number of equalizer bands + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + * @see player_audio_effect_set_equalizer_band_level() + * @see player_audio_effect_set_equalizer_all_bands() + */ +int player_audio_effect_get_equalizer_bands_count (player_h player, int *count); + +/** + * @brief Sets the all bands of equalizer. + * @param[in] player The handle to media player + * @param[in] band_levels The list of band level to be set + * @param[in] length The length of the band level + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + * @see player_audio_effect_get_equalizer_bands_count() + * @see player_audio_effect_get_equalizer_level_range() + * @see player_audio_effect_set_equalizer_band_level() + */ +int player_audio_effect_set_equalizer_all_bands(player_h player, int *band_levels, int length); + +/** + * @brief Sets the gain set for the given equalizer band. + * @param[in] player The handle to media player + * @param[in] index The index of qualizer band to be set + * @param[in] level New gain in decibel that will be set to the given band.[dB] + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + * @see player_audio_effect_get_equalizer_bands_count() + * @see player_audio_effect_get_equalizer_level_range() + * @see player_audio_effect_get_equalizer_band_level() + * @see player_audio_effect_set_equalizer_all_bands() + */ +int player_audio_effect_set_equalizer_band_level(player_h player, int index, int level); + +/** + * @brief Gets the gain set for the given equalizer band. + * @param[in] player The handle to media player + * @param[in] index The index of qualizer band which is requested + * @param[out] level The gain in decibel of the given band [dB] + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + * @see player_audio_effect_set_equalizer_band_level() + */ +int player_audio_effect_get_equalizer_band_level(player_h player, int index, int *level); + +/** + * @brief Gets the valid band level range of equalizer. + * @param[in] player The handle to media player + * @param[out] min The minumum value to be set [dB] + * @param[out] max The maximum value to be set [dB] + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + * @see player_audio_effect_set_equalizer_band_level() + * @see player_audio_effect_set_equalizer_all_bands() + */ +int player_audio_effect_get_equalizer_level_range(player_h player, int* min, int* max); + +/** + * @brief Gets the band frequency of equalizer. + * @param[in] player The handle to media player + * @param[in] index The index of qualizer band which is requested + * @param[out] frequency The frequency of the given band [dB] + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + */ +int player_audio_effect_get_equalizer_band_frequency(player_h player, int index, int *frequency); + +/** + * @brief Gets the band frequency range of equalizer. + * @param[in] player The handle to media player + * @param[in] index The index of qualizer band which is requested + * @param[out] range The frequency range of the given band [dB] + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + */ +int player_audio_effect_get_equalizer_band_frequency_range(player_h player, int index, int *range); + +/** + * @brief Clears the equalizer effect. + * @param[in] player The handle to media player + * @param[in] effect The audio effect type + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + * @see player_audio_effect_set_equalizer_band_level() + * @see player_audio_effect_set_equalizer_all_bands() + */ +int player_audio_effect_equalizer_clear(player_h player); + +/** + * @brief Checks whether the custom equilizer effect is avaliable or not. + * @param[in] player The handle to media player + * @param[out] available @c true if the specified audio effect is available, else @c false + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + * @see player_audio_effect_set_equalizer_band_level() + * @see player_audio_effect_set_equalizer_all_bands() + */ +int player_audio_effect_equalizer_is_available(player_h player, bool *available); + +/** + * @} + */ + +/** + * @addtogroup CAPI_MEDIA_PLAYER_MODULE + * @{ + */ + +/** + * @brief Sets a subtitle path. + * @remarks Only MicroDVD/SubViewer(*.sub), SAMI(*.smi), and SubRip(*.srt) subtitle formats are supported. + * @param[in] player The handle to media player + * @param[in] path The absolute path of the subtitle file + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state should be #PLAYER_STATE_IDLE by player_create() or player_unprepare(). + */ +int player_set_subtitle_path(player_h player,const char *path); + +/** + * @brief Sets the seek position for subtitle. + * @remarks Only MicroDVD/SubViewer(*.sub), SAMI(*.smi), and SubRip(*.srt) subtitle formats are supported. + * @param[in] player The handle to media player + * @param[in] millisecond The position in milliseconds from the start to seek to + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The subtitle must be set by player_set_subtitle_path(). + * @pre The player state must be one of: #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + */ +int player_set_subtitle_position(player_h player, int millisecond); + +/** + * @brief Sets a path to download, progressively. + * @remarks Progressive download will be started when you invoke player_start(). + * @param[in] player The handle to media player + * @param[in] path The absolute path to download + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state should be #PLAYER_STATE_IDLE by player_create() or player_unprepare(). + * @see player_set_progressive_download_message_cb() + * @see player_unset_progressive_download_message_cb() + */ +int player_set_progressive_download_path(player_h player, const char *path); + +/** + * @brief Gets the staus of progressive download. + * @param[in] player The handle to media player + * @param[out] current The current download position (bytes) + * @param[out] total_size The total size of file (bytes) + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The progressive download path must be set by player_set_progressive_download_path(). + * @pre The player state must be either #PLAYER_STATE_PLAYING by player_start() or #PLAYER_STATE_PAUSED by player_pause(). + */ +int player_get_progressive_download_status(player_h player, unsigned long *current, unsigned long *total_size); + +/** + * @brief Captures the video frame, asynchronously. + * @param[in] player The handle to media player + * @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 #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be #PLAYER_STATE_PLAYING by player_start() or #PLAYER_STATE_PAUSED by player_pause(). + * @post It invokes player_video_captured_cb() when capture completes, if you set a callback. + * @see player_video_captured_cb() + */ +int player_capture_video(player_h player, player_video_captured_cb callback, void *user_data); + +/** + * @brief Sets the cookie for streaming playback. + * @param[in] player The handle to media player + * @param[in] cookie The cookie to set + * @param[in] size The size of cookie + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state should be #PLAYER_STATE_IDLE by player_create() or player_unprepare(). + * @see player_set_streaming_user_agent() + */ +int player_set_streaming_cookie(player_h player, const char *cookie, int size); + +/** + * @brief Sets the user agent for streaming playback. + * @param[in] player The handle to media player + * @param[in] user_agent The user agent to set + * @param[in] size The size of user agent + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state should be #PLAYER_STATE_IDLE by player_create() or player_unprepare(). + * @see player_set_streaming_cookie() + */ +int player_set_streaming_user_agent(player_h player, const char *user_agent, int size); + +/** + * @brief Gets the download progress for streaming playback. + * @param[in] player The handle to media player + * @param[out] start The starting position in percent [0, 100] + * @param[out] current The current position in percent [0, 100] + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be either #PLAYER_STATE_PLAYING by player_start() or #PLAYER_STATE_PAUSED by player_pause(). + */ +int player_get_streaming_download_progress(player_h player, int *start, int *current); + +/** + * @brief Registers a callback function to be invoked when the playback finishes. + * @param[in] player The handle to media player + * @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 #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @post player_completed_cb() will be invoked + * @see player_unset_completed_cb() + * @see player_completed_cb() + * @see player_start() + */ +int player_set_completed_cb(player_h player, player_completed_cb callback, void *user_data); + +/** + * @brief Unregisters the callback function. + * @param[in] player The handle to media player + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @see player_set_completed_cb() + */ +int player_unset_completed_cb(player_h player); + +/** + * @brief Registers a callback function to be invoked when the playback is interrupted or interrupt completed. + * @param[in] player The handle to media player + * @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 #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @post player_interrupted_cb() will be invoked + * @see player_unset_interrupted_cb() + * @see #player_interrupted_code_e + * @see player_interrupted_cb() + */ +int player_set_interrupted_cb(player_h player, player_interrupted_cb callback, void *user_data); + +/** + * @brief Unregisters the callback function. + * @param[in] player The handle to media player + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @see player_set_interrupted_cb() + */ +int player_unset_interrupted_cb(player_h player); + +/** + * @brief Registers a callback function to be invoked when error occured. + * @param[in] player The handle to media player + * @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 #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @post player_error_cb() will be invoked + * @see player_unset_error_cb() + * @see player_error_cb() + */ +int player_set_error_cb(player_h player, player_error_cb callback, void *user_data); + +/** + * @brief Unregisters the callback function. + * + * @param[in] player The handle to media player + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @see player_set_error_cb() + */ +int player_unset_error_cb(player_h player); + +/** + * @brief Registers a callback function to be invoked when there is a change in the buffering status of a media stream. + * @remarks The media resource should be streamed over the network. + * @param[in] player The handle to media player + * @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 #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @post player_buffering_cb() will be invoked + * @see player_unset_buffering_cb() + * @see player_set_uri() + * @see player_buffering_cb() + */ +int player_set_buffering_cb(player_h player, player_buffering_cb callback, void *user_data); + +/** + * @brief Unregisters the callback function. + * @param[in] player The handle to media player + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @see player_set_buffering_cb() + */ +int player_unset_buffering_cb(player_h player); + +/** + * @brief Registers a callback function to be invoked when progressive download is starts or completes. + * @param[in] player The handle to media player + * @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 #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @pre The path to download must be set by player_set_progressive_download_path(). + * @post player_pd_message_cb() will be invoked + * @see player_unset_progressive_download_message_cb() + * @see player_set_progressive_download_path() + */ +int player_set_progressive_download_message_cb(player_h player, player_pd_message_cb callback, void *user_data); + +/** + * @brief Unregisters the callback function. + * @param[in] player The handle to media player + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @see player_set_progressive_download_message_cb() + */ +int player_unset_progressive_download_message_cb(player_h player); + +/** + * @brief Registers a callback function to be invoked when subtitle updates. + * @param[in] player The handle to media player + * @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 #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @pre The subtitle must be set by player_set_subtitle_path(). + * @post player_subtitle_updated_cb() will be invoked + * @see player_unset_subtitle_updated_cb() + * @see player_subtitle_updated_cb() + * @see player_set_subtitle_path() + */ +int player_set_subtitle_updated_cb(player_h player, player_subtitle_updated_cb callback, void *user_data); + +/** + * @brief Unregisters the callback function. + * @param[in] player The handle to media player + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @see player_set_subtitle_updated_cb() + */ +int player_unset_subtitle_updated_cb(player_h player); + +/** + * @brief Registers a callback function to be invoked when video frame is decoded. + * @param[in] player The handle to media player + * @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 #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @pre The player state must be #PLAYER_STATE_IDLE by player_create() or player_unprepare(). + * @post player_video_frame_decoded_cb() will be invoked + * @see player_unset_video_frame_decoded_cb() + * @see player_video_frame_decoded_cb() + */ +int player_set_video_frame_decoded_cb(player_h player, player_video_frame_decoded_cb callback, void *user_data); + +/** + * @brief Unregisters the callback function. + * @param[in] player The handle to media player + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @see player_set_video_frame_decoded_cb() + */ +int player_unset_video_frame_decoded_cb(player_h player); + +/** + * @brief Registers a callback function to be invoked when audio frame is decoded. + * @param[in] player The handle to media player + * @param[in] start The start position to decode. + * @param[in] end The end position to decode. + * @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 #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @pre The player state must be #PLAYER_STATE_IDLE by player_create() or player_unprepare(). + * @post player_audio_frame_decoded_cb() will be invoked + * @see player_unset_audio_frame_decoded_cb() + * @see player_audio_frame_decoded_cb() + */ +int player_set_audio_frame_decoded_cb(player_h player, int start, int end ,player_audio_frame_decoded_cb callback, void *user_data); + +/** + * @brief Unregisters the callback function. + * @param[in] player The handle to media player + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @see player_set_audio_frame_decoded_cb() + */ +int player_unset_audio_frame_decoded_cb(player_h player); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __TIZEN_MEDIA_PLAYER_H__ */ diff --git a/include/player_private.h b/include/player_private.h new file mode 100644 index 0000000..4eea27a --- /dev/null +++ b/include/player_private.h @@ -0,0 +1,64 @@ +/* +* 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_MEDIA_PLAYER_PRIVATE_H__ +#define __TIZEN_MEDIA_PLAYER_PRIVATE_H__ +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + _PLAYER_EVENT_TYPE_PREPARE, + _PLAYER_EVENT_TYPE_COMPLETE, + _PLAYER_EVENT_TYPE_INTERRUPT, + _PLAYER_EVENT_TYPE_ERROR, + _PLAYER_EVENT_TYPE_BUFFERING, + _PLAYER_EVENT_TYPE_SUBTITLE, + _PLAYER_EVENT_TYPE_CAPTURE, + _PLAYER_EVENT_TYPE_SEEK, + _PLAYER_EVENT_TYPE_VIDEO_FRAME, + _PLAYER_EVENT_TYPE_AUDIO_FRAME, + _PLAYER_EVENT_TYPE_VIDEO_FRAME_RENDER_ERROR, + _PLAYER_EVENT_TYPE_PD, + _PLAYER_SUPPORTED_AUDIO_EFFECT_TYPE, + _PLAYER_SUPPORTED_AUDIO_EFFECT_PRESET, + _PLAYER_EVENT_TYPE_NUM +}_player_event_e; + +typedef struct _player_s{ + MMHandleType mm_handle; + const void* user_cb[_PLAYER_EVENT_TYPE_NUM]; + void* user_data[_PLAYER_EVENT_TYPE_NUM]; + void* display_handle; + player_display_type_e display_type; + int state; + bool is_set_pixmap_cb; + bool is_stopped; + bool is_display_visible; + bool is_progressive_download; +} player_s; + +#ifdef __cplusplus +} +#endif + +#endif //__TIZEN_MEDIA_PLAYER_PRIVATE_H__ + + + diff --git a/packaging/capi-media-player.spec b/packaging/capi-media-player.spec new file mode 100644 index 0000000..de5f55e --- /dev/null +++ b/packaging/capi-media-player.spec @@ -0,0 +1,59 @@ +Name: capi-media-player +Summary: A Media Player library in Tizen Native API +Version: 0.1.0 +Release: 51 +Group: TO_BE/FILLED_IN +License: TO BE FILLED IN +Source0: %{name}-%{version}.tar.gz +BuildRequires: cmake +BuildRequires: pkgconfig(dlog) +BuildRequires: pkgconfig(mm-player) +BuildRequires: pkgconfig(capi-base-common) +BuildRequires: pkgconfig(capi-media-sound-manager) +BuildRequires: pkgconfig(mm-ta) +Requires(post): /sbin/ldconfig +Requires(postun): /sbin/ldconfig + +%description + + +%package devel +Summary: A Media Player library in Tizen Native API (Development) +Group: TO_BE/FILLED_IN +Requires: %{name} = %{version}-%{release} + +%description devel + +%prep +%setup -q + + +%build +MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` +cmake . -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER} + + +make %{?jobs:-j%jobs} + +%install +rm -rf %{buildroot} +mkdir -p %{buildroot}/usr/share/license +cp LICENSE %{buildroot}/usr/share/license/%{name} +%make_install + +%post -p /sbin/ldconfig + +%postun -p /sbin/ldconfig + + +%files +%manifest capi-media-player.manifest +%{_libdir}/libcapi-media-player.so.* +%{_datadir}/license/%{name} + +%files devel +%{_includedir}/media/*.h +%{_libdir}/pkgconfig/*.pc +%{_libdir}/libcapi-media-player.so + + diff --git a/src/player.c b/src/player.c new file mode 100644 index 0000000..9d270af --- /dev/null +++ b/src/player.c @@ -0,0 +1,2320 @@ +/* +* 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "TIZEN_N_PLAYER" + +/* +* Internal Macros +*/ + +#define PLAYER_CHECK_CONDITION(condition,error,msg) \ + if(condition) {} else \ + { LOGE("[%s] %s(0x%08x)",__FUNCTION__, msg,error); return error;}; \ + + +#define PLAYER_INSTANCE_CHECK(player) \ + PLAYER_CHECK_CONDITION(player != NULL, PLAYER_ERROR_INVALID_PARAMETER,"PLAYER_ERROR_INVALID_PARAMETER") + +#define PLAYER_STATE_CHECK(player,expected_state) \ + PLAYER_CHECK_CONDITION(player->state == expected_state,PLAYER_ERROR_INVALID_STATE,"PLAYER_ERROR_INVALID_STATE") + +#define PLAYER_NULL_ARG_CHECK(arg) \ + PLAYER_CHECK_CONDITION(arg != NULL,PLAYER_ERROR_INVALID_PARAMETER,"PLAYER_ERROR_INVALID_PARAMETER") + +/* +* Internal Implementation +*/ +static int __convert_error_code(int code, char* func_name) +{ + int ret = PLAYER_ERROR_INVALID_OPERATION; + char* msg="PLAYER_ERROR_INVALID_OPERATION"; + switch(code) + { + case MM_ERROR_NONE: + ret = PLAYER_ERROR_NONE; + msg = "PLAYER_ERROR_NONE"; + break; + case MM_ERROR_PLAYER_CODEC_NOT_FOUND: + case MM_ERROR_PLAYER_AUDIO_CODEC_NOT_FOUND: + case MM_ERROR_PLAYER_VIDEO_CODEC_NOT_FOUND: + case MM_ERROR_PLAYER_STREAMING_UNSUPPORTED_AUDIO: + case MM_ERROR_PLAYER_STREAMING_UNSUPPORTED_VIDEO: + case MM_ERROR_PLAYER_STREAMING_UNSUPPORTED_MEDIA_TYPE: + case MM_ERROR_PLAYER_NOT_SUPPORTED_FORMAT: + ret = PLAYER_ERROR_NOT_SUPPORTED_FILE; + msg = "PLAYER_ERROR_NOT_SUPPORTED_FILE"; + break; + case MM_ERROR_PLAYER_INVALID_STATE: + case MM_ERROR_PLAYER_NOT_INITIALIZED: + ret = PLAYER_ERROR_INVALID_STATE; + msg = "PLAYER_ERROR_INVALID_STATE"; + break; + case MM_ERROR_PLAYER_INTERNAL: + case MM_ERROR_PLAYER_INVALID_STREAM: + case MM_ERROR_PLAYER_STREAMING_FAIL: + case MM_ERROR_PLAYER_NO_OP: + case MM_ERROR_NOT_SUPPORT_API: + ret = PLAYER_ERROR_INVALID_OPERATION; + msg = "PLAYER_ERROR_INVALID_OPERATION"; + break; + case MM_ERROR_PLAYER_SOUND_EFFECT_INVALID_STATUS: + case MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER: + ret = PLAYER_ERROR_INVALID_OPERATION; + msg = "PLAYER_ERROR_INVALID_OPERATION (NOT SUPPORTED AUDIO EFFECT)"; + break; + case MM_ERROR_PLAYER_NO_FREE_SPACE: + ret = PLAYER_ERROR_FILE_NO_SPACE_ON_DEVICE; + msg = "PLAYER_ERROR_FILE_NO_SPACE_ON_DEVICE"; + break; + case MM_ERROR_PLAYER_FILE_NOT_FOUND: + ret = PLAYER_ERROR_NO_SUCH_FILE; + msg = "PLAYER_ERROR_NO_SUCH_FILE"; + break; + case MM_ERROR_PLAYER_SEEK: + ret = PLAYER_ERROR_SEEK_FAILED; + msg = "PLAYER_ERROR_SEEK_FAILED"; + break; + case MM_ERROR_PLAYER_INVALID_URI: + case MM_ERROR_PLAYER_STREAMING_INVALID_URL: + ret = PLAYER_ERROR_INVALID_URI; + msg = "PLAYER_ERROR_INVALID_URI"; + break; + case MM_ERROR_PLAYER_STREAMING_CONNECTION_FAIL: + case MM_ERROR_PLAYER_STREAMING_DNS_FAIL : + case MM_ERROR_PLAYER_STREAMING_SERVER_DISCONNECTED: + case MM_ERROR_PLAYER_STREAMING_INVALID_PROTOCOL: + case MM_ERROR_PLAYER_STREAMING_UNEXPECTED_MSG: + case MM_ERROR_PLAYER_STREAMING_OUT_OF_MEMORIES: + case MM_ERROR_PLAYER_STREAMING_RTSP_TIMEOUT: + case MM_ERROR_PLAYER_STREAMING_BAD_REQUEST: + case MM_ERROR_PLAYER_STREAMING_NOT_AUTHORIZED: + case MM_ERROR_PLAYER_STREAMING_PAYMENT_REQUIRED: + case MM_ERROR_PLAYER_STREAMING_FORBIDDEN: + case MM_ERROR_PLAYER_STREAMING_CONTENT_NOT_FOUND: + case MM_ERROR_PLAYER_STREAMING_METHOD_NOT_ALLOWED: + case MM_ERROR_PLAYER_STREAMING_NOT_ACCEPTABLE: + case MM_ERROR_PLAYER_STREAMING_PROXY_AUTHENTICATION_REQUIRED: + case MM_ERROR_PLAYER_STREAMING_SERVER_TIMEOUT: + case MM_ERROR_PLAYER_STREAMING_GONE: + case MM_ERROR_PLAYER_STREAMING_LENGTH_REQUIRED: + case MM_ERROR_PLAYER_STREAMING_PRECONDITION_FAILED: + case MM_ERROR_PLAYER_STREAMING_REQUEST_ENTITY_TOO_LARGE: + case MM_ERROR_PLAYER_STREAMING_REQUEST_URI_TOO_LARGE: + case MM_ERROR_PLAYER_STREAMING_PARAMETER_NOT_UNDERSTOOD: + case MM_ERROR_PLAYER_STREAMING_CONFERENCE_NOT_FOUND: + case MM_ERROR_PLAYER_STREAMING_NOT_ENOUGH_BANDWIDTH: + case MM_ERROR_PLAYER_STREAMING_NO_SESSION_ID: + case MM_ERROR_PLAYER_STREAMING_METHOD_NOT_VALID_IN_THIS_STATE: + case MM_ERROR_PLAYER_STREAMING_HEADER_FIELD_NOT_VALID_FOR_SOURCE: + case MM_ERROR_PLAYER_STREAMING_INVALID_RANGE: + case MM_ERROR_PLAYER_STREAMING_PARAMETER_IS_READONLY: + case MM_ERROR_PLAYER_STREAMING_AGGREGATE_OP_NOT_ALLOWED: + case MM_ERROR_PLAYER_STREAMING_ONLY_AGGREGATE_OP_ALLOWED: + case MM_ERROR_PLAYER_STREAMING_BAD_TRANSPORT: + case MM_ERROR_PLAYER_STREAMING_DESTINATION_UNREACHABLE: + case MM_ERROR_PLAYER_STREAMING_INTERNAL_SERVER_ERROR: + case MM_ERROR_PLAYER_STREAMING_NOT_IMPLEMENTED: + case MM_ERROR_PLAYER_STREAMING_BAD_GATEWAY: + case MM_ERROR_PLAYER_STREAMING_SERVICE_UNAVAILABLE: + case MM_ERROR_PLAYER_STREAMING_GATEWAY_TIME_OUT: + case MM_ERROR_PLAYER_STREAMING_OPTION_NOT_SUPPORTED: + ret = PLAYER_ERROR_CONNECTION_FAILED; + msg = "PLAYER_ERROR_CONNECTION_FAILED"; + break; + case MM_ERROR_POLICY_BLOCKED: + case MM_ERROR_POLICY_INTERRUPTED: + case MM_ERROR_POLICY_INTERNAL: + case MM_ERROR_POLICY_DUPLICATED: + ret = PLAYER_ERROR_SOUND_POLICY; + msg = "PLAYER_ERROR_SOUND_POLICY"; + break; + } + LOGE("[%s] %s(0x%08x) : core fw error(0x%x)",func_name,msg, ret, code); + return ret; +} + +static player_interrupted_code_e __convert_interrupted_code(int code) +{ + player_interrupted_code_e ret = PLAYER_INTERRUPTED_BY_RESOURCE_CONFLICT; + switch(code) + { + case MM_MSG_CODE_INTERRUPTED_BY_ALARM_END: + case MM_MSG_CODE_INTERRUPTED_BY_EMERGENCY_END: + ret = PLAYER_INTERRUPTED_COMPLETED; + break; + case MM_MSG_CODE_INTERRUPTED_BY_MEDIA: + case MM_MSG_CODE_INTERRUPTED_BY_OTHER_PLAYER_APP: + ret = PLAYER_INTERRUPTED_BY_MEDIA; + break; + case MM_MSG_CODE_INTERRUPTED_BY_CALL_START: + ret = PLAYER_INTERRUPTED_BY_CALL; + break; + case MM_MSG_CODE_INTERRUPTED_BY_EARJACK_UNPLUG: + ret = PLAYER_INTERRUPTED_BY_EARJACK_UNPLUG; + break; + case MM_MSG_CODE_INTERRUPTED_BY_ALARM_START: + ret = PLAYER_INTERRUPTED_BY_ALARM; + break; + case MM_MSG_CODE_INTERRUPTED_BY_EMERGENCY_START: + ret = PLAYER_INTERRUPTED_BY_EMERGENCY; + break; + case MM_MSG_CODE_INTERRUPTED_BY_RESUMABLE_MEDIA: + ret = PLAYER_INTERRUPTED_BY_RESUMABLE_MEDIA; + break; + case MM_MSG_CODE_INTERRUPTED_BY_RESOURCE_CONFLICT: + default : + ret = PLAYER_INTERRUPTED_BY_RESOURCE_CONFLICT; + break; + } + return ret; +} + +static player_state_e __convert_player_state(MMPlayerStateType state) +{ + if(state == MM_PLAYER_STATE_NONE) + return PLAYER_STATE_NONE; + else + return state +1; +} + +static bool __player_state_validate(player_s * handle, player_state_e threshold) +{ + if (handle->state < threshold) + return FALSE; + return TRUE; +} + +static int __set_callback(_player_event_e type, player_h player, void* callback, void *user_data) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(callback); + player_s * handle = (player_s *) player; + handle->user_cb[type] = callback; + handle->user_data[type] = user_data; + LOGI("[%s] Event type : %d ",__FUNCTION__, type); + return PLAYER_ERROR_NONE; +} + +static int __unset_callback(_player_event_e type, player_h player) +{ + PLAYER_INSTANCE_CHECK(player); + player_s * handle = (player_s *) player; + handle->user_cb[type] = NULL; + handle->user_data[type] = NULL; + LOGI("[%s] Event type : %d ",__FUNCTION__, type); + return PLAYER_ERROR_NONE; +} + +static int __msg_callback(int message, void *param, void *user_data) +{ + player_s * handle = (player_s*)user_data; + MMMessageParamType *msg = (MMMessageParamType*)param; + LOGI("[%s] Start : Got message type : 0x%x" ,__FUNCTION__, message); + player_error_e err_code = PLAYER_ERROR_NONE; + switch(message) + { + case MM_MESSAGE_ERROR: //0x01 + err_code = __convert_error_code(msg->code,(char*)__FUNCTION__); + break; + case MM_MESSAGE_STATE_CHANGED: //0x03 + LOGE("STATE CHANGED INTERNALLY - from : %d, to : %d (CAPI State : %d)", msg->state.previous, msg->state.current, handle->state); + if ((handle->is_progressive_download && msg->state.previous == MM_PLAYER_STATE_NULL && msg->state.current == MM_PLAYER_STATE_READY) || + (msg->state.previous == MM_PLAYER_STATE_READY && msg->state.current == MM_PLAYER_STATE_PAUSED)) + { + if(handle->user_cb[_PLAYER_EVENT_TYPE_PREPARE]) // asyc && prepared cb has been set + { + LOGE("[%s] Prepared! [current state : %d]", __FUNCTION__, handle->state); + handle->state = PLAYER_STATE_READY; + ((player_prepared_cb)handle->user_cb[_PLAYER_EVENT_TYPE_PREPARE])(handle->user_data[_PLAYER_EVENT_TYPE_PREPARE]); + handle->user_cb[_PLAYER_EVENT_TYPE_PREPARE] = NULL; + handle->user_data[_PLAYER_EVENT_TYPE_PREPARE] = NULL; + } + } + break; + case MM_MESSAGE_READY_TO_RESUME: //0x05 + if( handle->user_cb[_PLAYER_EVENT_TYPE_INTERRUPT] ) + { + ((player_interrupted_cb)handle->user_cb[_PLAYER_EVENT_TYPE_INTERRUPT])(PLAYER_INTERRUPTED_COMPLETED,handle->user_data[_PLAYER_EVENT_TYPE_INTERRUPT]); + } + break; + case MM_MESSAGE_BEGIN_OF_STREAM: //0x104 + MMTA_ACUM_ITEM_END("[CAPI] player_start ~ BOS", 0); + LOGE("[%s] Ready to streaming information (BOS) [current state : %d]", __FUNCTION__, handle->state); + break; + case MM_MESSAGE_END_OF_STREAM://0x105 + if( handle->user_cb[_PLAYER_EVENT_TYPE_COMPLETE] ) + { + ((player_completed_cb)handle->user_cb[_PLAYER_EVENT_TYPE_COMPLETE])(handle->user_data[_PLAYER_EVENT_TYPE_COMPLETE]); + } + break; + case MM_MESSAGE_BUFFERING: //0x103 + if( handle->user_cb[_PLAYER_EVENT_TYPE_BUFFERING] ) + { + ((player_buffering_cb)handle->user_cb[_PLAYER_EVENT_TYPE_BUFFERING])(msg->connection.buffering,handle->user_data[_PLAYER_EVENT_TYPE_BUFFERING]); + } + break; + case MM_MESSAGE_STATE_INTERRUPTED: //0x04 + if( handle->user_cb[_PLAYER_EVENT_TYPE_INTERRUPT] ) + { + handle->state = __convert_player_state(msg->state.current); + ((player_interrupted_cb)handle->user_cb[_PLAYER_EVENT_TYPE_INTERRUPT])(__convert_interrupted_code(msg->code),handle->user_data[_PLAYER_EVENT_TYPE_INTERRUPT]); + } + break; + case MM_MESSAGE_CONNECTION_TIMEOUT: //0x102 + LOGE("[%s] PLAYER_ERROR_CONNECTION_FAILED (0x%08x) : CONNECTION_TIMEOUT" ,__FUNCTION__, PLAYER_ERROR_CONNECTION_FAILED); + err_code = PLAYER_ERROR_CONNECTION_FAILED; + break; + case MM_MESSAGE_UPDATE_SUBTITLE: //0x109 + if( handle->user_cb[_PLAYER_EVENT_TYPE_SUBTITLE] ) + { + ((player_subtitle_updated_cb)handle->user_cb[_PLAYER_EVENT_TYPE_SUBTITLE])(msg->subtitle.duration, (char*)msg->data,handle->user_data[_PLAYER_EVENT_TYPE_SUBTITLE]); + } + break; + case MM_MESSAGE_VIDEO_NOT_CAPTURED: //0x113 + LOGE("[%s] PLAYER_ERROR_VIDEO_CAPTURE_FAILED (0x%08x)",__FUNCTION__, PLAYER_ERROR_VIDEO_CAPTURE_FAILED); + if( handle->user_cb[_PLAYER_EVENT_TYPE_ERROR] ) + { + ((player_error_cb)handle->user_cb[_PLAYER_EVENT_TYPE_ERROR])(PLAYER_ERROR_VIDEO_CAPTURE_FAILED,handle->user_data[_PLAYER_EVENT_TYPE_ERROR]); + } + break; + case MM_MESSAGE_VIDEO_CAPTURED: //0x110 + if( handle->user_cb[_PLAYER_EVENT_TYPE_CAPTURE] ) + { + int w; + int h; + int ret = mm_player_get_attribute(handle->mm_handle, NULL,MM_PLAYER_VIDEO_WIDTH ,&w, MM_PLAYER_VIDEO_HEIGHT, &h, (char*)NULL); + if(ret != MM_ERROR_NONE && handle->user_cb[_PLAYER_EVENT_TYPE_ERROR] ) + { + LOGE("[%s] PLAYER_ERROR_VIDEO_CAPTURE_FAILED (0x%08x) : Failed to get video size on video captured (0x%x)" ,__FUNCTION__, PLAYER_ERROR_VIDEO_CAPTURE_FAILED, ret); + err_code=PLAYER_ERROR_VIDEO_CAPTURE_FAILED; + } + else + { + MMPlayerVideoCapture* capture = (MMPlayerVideoCapture *)msg->data; + ((player_video_captured_cb)handle->user_cb[_PLAYER_EVENT_TYPE_CAPTURE])(capture->data, w, h, capture->size, handle->user_data[_PLAYER_EVENT_TYPE_CAPTURE]); + + if (capture->data) + { + g_free(capture->data); + capture->data = NULL; + } + } + handle->user_cb[_PLAYER_EVENT_TYPE_CAPTURE] = NULL; + handle->user_data[_PLAYER_EVENT_TYPE_CAPTURE] = NULL; + } + break; + case MM_MESSAGE_FILE_NOT_SUPPORTED: //0x10f + LOGE("[%s] PLAYER_ERROR_NOT_SUPPORTED_FILE (0x%08x) : FILE_NOT_SUPPORTED" ,__FUNCTION__, PLAYER_ERROR_NOT_SUPPORTED_FILE); + err_code = PLAYER_ERROR_NOT_SUPPORTED_FILE; + break; + case MM_MESSAGE_FILE_NOT_FOUND: //0x110 + LOGE("[%s] PLAYER_ERROR_NOT_SUPPORTED_FILE (0x%08x) : FILE_NOT_FOUND" ,__FUNCTION__, PLAYER_ERROR_NOT_SUPPORTED_FILE); + err_code = PLAYER_ERROR_NOT_SUPPORTED_FILE; + break; + case MM_MESSAGE_DRM_NOT_AUTHORIZED: //0x111 + LOGE("[%s] PLAYER_ERROR_NOT_SUPPORTED_FILE (0x%08x) : DRM_NOT_AUTHORIZED" ,__FUNCTION__, PLAYER_ERROR_NOT_SUPPORTED_FILE); + err_code = PLAYER_ERROR_NOT_SUPPORTED_FILE; + break; + case MM_MESSAGE_SEEK_COMPLETED: //0x114 + if (handle->display_type != ((int)MM_DISPLAY_SURFACE_NULL) && handle->state == PLAYER_STATE_READY) + { + if(handle->is_display_visible) + { + int ret = MM_ERROR_NONE; + ret = mm_player_set_attribute(handle->mm_handle, NULL,"display_visible" , 1, (char*)NULL); + if(ret != MM_ERROR_NONE) + { + LOGW("[%s] Failed to set display visible (0x%x)" ,__FUNCTION__, ret); + } + + } + } + if( handle->user_cb[_PLAYER_EVENT_TYPE_SEEK]) + { + ((player_seek_completed_cb)handle->user_cb[_PLAYER_EVENT_TYPE_SEEK])(handle->user_data[_PLAYER_EVENT_TYPE_SEEK]); + handle->user_cb[_PLAYER_EVENT_TYPE_SEEK] = NULL; + handle->user_data[_PLAYER_EVENT_TYPE_SEEK] = NULL; + } + break; + case MM_MESSAGE_UNKNOWN: //0x00 + case MM_MESSAGE_WARNING: //0x02 + case MM_MESSAGE_CONNECTING: //0x100 + case MM_MESSAGE_CONNECTED: //0x101 + case MM_MESSAGE_BLUETOOTH_ON: //0x106 + case MM_MESSAGE_BLUETOOTH_OFF: //0x107 + case MM_MESSAGE_RESUMED_BY_REW: //0x108 + case MM_MESSAGE_RTP_SENDER_REPORT: //0x10a + case MM_MESSAGE_RTP_RECEIVER_REPORT: //0x10b + case MM_MESSAGE_RTP_SESSION_STATUS: //0x10c + case MM_MESSAGE_SENDER_STATE: //0x10d + case MM_MESSAGE_RECEIVER_STATE: //0x10e + default: + break; + } + + if(err_code != PLAYER_ERROR_NONE && handle->user_cb[_PLAYER_EVENT_TYPE_ERROR]) + { + ((player_error_cb)handle->user_cb[_PLAYER_EVENT_TYPE_ERROR])(err_code,handle->user_data[_PLAYER_EVENT_TYPE_ERROR]); + } + LOGE("[%s] End", __FUNCTION__); + return 1; +} + +static bool __video_stream_callback(void *stream, int stream_size, void *user_data, int width, int height) +{ + player_s * handle = (player_s*)user_data; + if( handle->user_cb[_PLAYER_EVENT_TYPE_VIDEO_FRAME]) + { + if(handle->state==PLAYER_STATE_PLAYING) + ((player_video_frame_decoded_cb)handle->user_cb[_PLAYER_EVENT_TYPE_VIDEO_FRAME])((unsigned char *)stream, width, height, stream_size, handle->user_data[_PLAYER_EVENT_TYPE_VIDEO_FRAME]); + else + LOGE("[%s] Skip stream - current state : %d", __FUNCTION__,handle->state); + } + return TRUE; +} + +static bool __audio_stream_callback(void *stream, int stream_size, void *user_data) +{ + player_s * handle = (player_s*)user_data; + if( handle->user_cb[_PLAYER_EVENT_TYPE_AUDIO_FRAME] ) + { + if(handle->state==PLAYER_STATE_PLAYING) + ((player_audio_frame_decoded_cb)handle->user_cb[_PLAYER_EVENT_TYPE_AUDIO_FRAME])((unsigned char *)stream, stream_size, handle->user_data[_PLAYER_EVENT_TYPE_AUDIO_FRAME]); + else + LOGE("[%s] Skip stream - current state : %d", __FUNCTION__,handle->state); + } + return TRUE; +} + +static bool __video_frame_render_error_callback(void *param, void *user_data) +{ + player_s * handle = (player_s*)user_data; + if( handle->user_cb[_PLAYER_EVENT_TYPE_VIDEO_FRAME_RENDER_ERROR]) + { + ((player_x11_pixmap_error_cb)handle->user_cb[_PLAYER_EVENT_TYPE_VIDEO_FRAME_RENDER_ERROR])((unsigned int *)param, handle->user_data[_PLAYER_EVENT_TYPE_VIDEO_FRAME_RENDER_ERROR]); + } + return TRUE; +} + +static int __pd_message_callback(int message, void *param, void *user_data) +{ + player_s * handle = (player_s*)user_data; + player_pd_message_type_e type; + switch(message) + { + case MM_MESSAGE_PD_DOWNLOADER_START: + type = PLAYER_PD_STARTED; + break; + case MM_MESSAGE_PD_DOWNLOADER_END: + type = PLAYER_PD_COMPLETED; + break; + default: + return 0; + } + + if( handle->user_cb[_PLAYER_EVENT_TYPE_PD] ) + { + ((player_pd_message_cb)handle->user_cb[_PLAYER_EVENT_TYPE_PD])(type, handle->user_data[_PLAYER_EVENT_TYPE_PD]); + } + return 0; +} + +static bool __supported_audio_effect_type (int filter, int type, void *user_data) +{ + player_s * handle = (player_s*)user_data; + if(filter != MM_AUDIO_EFFECT_TYPE_CUSTOM || type == MM_AUDIO_EFFECT_CUSTOM_EQ) + { + LOGI("[%s] Skip invalid filter: %d or type : %d",__FUNCTION__, filter, type); + return TRUE; + } + + if( handle->user_cb[_PLAYER_SUPPORTED_AUDIO_EFFECT_TYPE] ) + { + return ((player_audio_effect_supported_effect_cb)handle->user_cb[_PLAYER_SUPPORTED_AUDIO_EFFECT_TYPE])(type, handle->user_data[_PLAYER_SUPPORTED_AUDIO_EFFECT_TYPE]); + } + return FALSE; +} + +static bool __supported_audio_effect_preset (int filter, int type, void *user_data) +{ + player_s * handle = (player_s*)user_data; + if(filter != MM_AUDIO_EFFECT_TYPE_PRESET) + { + LOGI("[%s] Skip invalid filter: %d or type : %d",__FUNCTION__, filter, type); + return TRUE; + } + + if( handle->user_cb[_PLAYER_SUPPORTED_AUDIO_EFFECT_PRESET] ) + { + return ((player_audio_effect_supported_effect_cb)handle->user_cb[_PLAYER_SUPPORTED_AUDIO_EFFECT_PRESET])(type, handle->user_data[_PLAYER_SUPPORTED_AUDIO_EFFECT_PRESET]); + } + return FALSE; +} + + +/* +* Public Implementation +*/ + +int player_create (player_h *player) +{ + LOGE("[%s] Start", __FUNCTION__); + PLAYER_INSTANCE_CHECK(player); + MMTA_INIT(); + MMTA_ACUM_ITEM_BEGIN("[CAPI] player_create", 0); + player_s * handle; + handle = (player_s*)malloc( sizeof(player_s)); + if (handle != NULL) + memset(handle, 0 , sizeof(player_s)); + else + { + LOGE("[%s] PLAYER_ERROR_OUT_OF_MEMORY(0x%08x)" ,__FUNCTION__,PLAYER_ERROR_OUT_OF_MEMORY); + return PLAYER_ERROR_OUT_OF_MEMORY; + } + int ret = mm_player_create(&handle->mm_handle); + MMTA_ACUM_ITEM_END("[CAPI] player_create", 0); + if( ret != MM_ERROR_NONE) + { + LOGE("[%s] PLAYER_ERROR_INVALID_OPERATION(0x%08x)" ,__FUNCTION__,PLAYER_ERROR_INVALID_OPERATION); + handle->state = PLAYER_STATE_NONE; + free(handle); + handle=NULL; + return PLAYER_ERROR_INVALID_OPERATION; + } + else + { + *player = (player_h)handle; + handle->state = PLAYER_STATE_IDLE; + handle->display_type = MM_DISPLAY_SURFACE_NULL; // means DISPLAY_TYPE_NONE(3) + handle->is_stopped=false; + handle->is_display_visible=true; + LOGE("[%s] End", __FUNCTION__); + return PLAYER_ERROR_NONE; + } +} + + +int player_destroy (player_h player) +{ + LOGE("[%s] Start", __FUNCTION__); + PLAYER_INSTANCE_CHECK(player); + player_s * handle = (player_s *) player; + MMTA_ACUM_ITEM_SHOW_RESULT_TO(MMTA_SHOW_FILE); + + if (mm_player_destroy(handle->mm_handle)!= MM_ERROR_NONE) + { + LOGE("[%s] PLAYER_ERROR_INVALID_OPERATION(0x%08x)" ,__FUNCTION__,PLAYER_ERROR_INVALID_OPERATION); + return PLAYER_ERROR_INVALID_OPERATION; + } + else + { + handle->state = PLAYER_STATE_NONE; + free(handle); + handle= NULL; + LOGE("[%s] End", __FUNCTION__); + return PLAYER_ERROR_NONE; + } +} + +int player_prepare_async (player_h player, player_prepared_cb callback, void* user_data) +{ + LOGE("[%s] Start", __FUNCTION__); + PLAYER_INSTANCE_CHECK(player); + player_s * handle = (player_s *) player; + PLAYER_STATE_CHECK(handle,PLAYER_STATE_IDLE); + + if(handle->user_cb[_PLAYER_EVENT_TYPE_PREPARE]) + { + LOGE("[%s] PLAYER_ERROR_INVALID_OPERATION (0x%08x) : preparing... we can't do any more " ,__FUNCTION__, PLAYER_ERROR_INVALID_OPERATION); + return PLAYER_ERROR_INVALID_OPERATION; + } + else + { + LOGI("[%s] Event type : %d ",__FUNCTION__, _PLAYER_EVENT_TYPE_PREPARE); + handle->user_cb[_PLAYER_EVENT_TYPE_PREPARE] = callback; + handle->user_data[_PLAYER_EVENT_TYPE_PREPARE] = user_data; + } + + int ret; + ret = mm_player_set_message_callback(handle->mm_handle, __msg_callback, (void*)handle); + if(ret != MM_ERROR_NONE) + { + LOGW("[%s] Failed to set message callback function (0x%x)" ,__FUNCTION__, ret); + } + + if (handle->display_type==((int)MM_DISPLAY_SURFACE_NULL)) + { + ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_surface_type", MM_DISPLAY_SURFACE_NULL, (char*)NULL); + if(ret != MM_ERROR_NONE) + { + LOGW("[%s] Failed to set display surface type 'MM_DISPLAY_SURFACE_NULL' (0x%x)" ,__FUNCTION__, ret); + } + } + else + { + ret = mm_player_set_attribute(handle->mm_handle, NULL,"display_visible", 0, (char*)NULL); + if(ret != MM_ERROR_NONE) + { + LOGW("[%s] Failed to set display visible (0x%x)" ,__FUNCTION__, ret); + } + } + + ret = mm_player_set_attribute(handle->mm_handle, NULL, "profile_prepare_async", 1, (char*)NULL); + if(ret != MM_ERROR_NONE) + { + LOGE("[%s] Failed to set profile_async_start '1' (0x%x)" ,__FUNCTION__, ret); + } + ret = mm_player_realize(handle->mm_handle); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + + if (!handle->is_progressive_download) + ret = mm_player_pause(handle->mm_handle); + + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + LOGE("[%s] End", __FUNCTION__); + return PLAYER_ERROR_NONE; + } +} + +int player_prepare (player_h player) +{ + LOGE("[%s] Start", __FUNCTION__); + PLAYER_INSTANCE_CHECK(player); + MMTA_ACUM_ITEM_BEGIN("[CAPI] player_prepare", 0); + player_s * handle = (player_s *) player; + PLAYER_STATE_CHECK(handle,PLAYER_STATE_IDLE); + + int ret; + ret = mm_player_set_message_callback(handle->mm_handle, __msg_callback, (void*)handle); + if(ret != MM_ERROR_NONE) + { + LOGW("[%s] Failed to set message callback function (0x%x)" ,__FUNCTION__, ret); + } + + if (handle->display_type==((int)MM_DISPLAY_SURFACE_NULL)) + { + ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_surface_type", MM_DISPLAY_SURFACE_NULL, (char*)NULL); + if(ret != MM_ERROR_NONE) + { + LOGW("[%s] Failed to set display surface type 'MM_DISPLAY_SURFACE_NULL' (0x%x)" ,__FUNCTION__, ret); + } + } + else + { + ret = mm_player_set_attribute(handle->mm_handle, NULL,"display_visible" , 0, (char*)NULL); + if(ret != MM_ERROR_NONE) + { + LOGW("[%s] Failed to set display visible (0x%x)" ,__FUNCTION__, ret); + } + } + + ret = mm_player_realize(handle->mm_handle); + if(ret != MM_ERROR_NONE) + { + LOGE("[%s] Failed to realize - 0x%x", __FUNCTION__,ret); + return __convert_error_code(ret,(char*)__FUNCTION__); + } + + if (!handle->is_progressive_download) + ret = mm_player_pause(handle->mm_handle); + + MMTA_ACUM_ITEM_END("[CAPI] player_prepare", 0); + if(ret != MM_ERROR_NONE) + { + LOGE("[%s] Failed to pause - 0x%x", __FUNCTION__,ret); + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + handle->state = PLAYER_STATE_READY; + LOGE("[%s] End", __FUNCTION__); + return PLAYER_ERROR_NONE; + } +} + +int player_unprepare (player_h player) +{ + LOGE("[%s] Start", __FUNCTION__); + PLAYER_INSTANCE_CHECK(player); + player_s * handle = (player_s *) player; + if (!__player_state_validate(handle, PLAYER_STATE_READY)) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d" ,__FUNCTION__,PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + + int ret = mm_player_unrealize(handle->mm_handle); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + handle->state = PLAYER_STATE_IDLE; + handle->display_type = MM_DISPLAY_SURFACE_NULL; // means DISPLAY_TYPE_NONE(3) + handle->is_set_pixmap_cb = false; + handle->is_stopped=false; + handle->is_display_visible=true; + handle->is_progressive_download=false; + LOGE("[%s] End", __FUNCTION__); + return PLAYER_ERROR_NONE; + } +} + +int player_set_uri (player_h player, const char *uri) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(uri); + player_s * handle = (player_s *) player; + PLAYER_STATE_CHECK(handle,PLAYER_STATE_IDLE); + + int uri_length = strlen(uri); + int ret = mm_player_set_attribute(handle->mm_handle, NULL,MM_PLAYER_CONTENT_URI , uri, uri_length, (char*)NULL); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + return PLAYER_ERROR_NONE; +} + +int player_set_memory_buffer (player_h player, const void *data, int size) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(data); + PLAYER_CHECK_CONDITION(size>=0,PLAYER_ERROR_INVALID_PARAMETER,"PLAYER_ERROR_INVALID_PARAMETER" ); + player_s * handle = (player_s *) player; + PLAYER_STATE_CHECK(handle,PLAYER_STATE_IDLE); + + char uri[PATH_MAX] ; + + snprintf(uri, sizeof(uri),"mem:///ext=%s,size=%d","", size); + int ret = mm_player_set_attribute(handle->mm_handle, NULL,MM_PLAYER_CONTENT_URI, uri, strlen(uri), MM_PLAYER_MEMORY_SRC, data,size,(char*)NULL); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + return PLAYER_ERROR_NONE; +} + +int player_get_state (player_h player, player_state_e *state) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(state); + player_s * handle = (player_s *) player; + *state = handle->state; + MMPlayerStateType currentStat = MM_PLAYER_STATE_NULL; + mm_player_get_state(handle->mm_handle, ¤tStat); + LOGE("[%s] State : %d (FW state : %d)", __FUNCTION__,handle->state, currentStat); + return PLAYER_ERROR_NONE; +} + +int player_set_volume (player_h player, float left, float right) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_CHECK_CONDITION(left>=0 && left <= 1.0 ,PLAYER_ERROR_INVALID_PARAMETER,"PLAYER_ERROR_INVALID_PARAMETER" ); + PLAYER_CHECK_CONDITION(right>=0 && right <= 1.0 ,PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER" ); + player_s * handle = (player_s *) player; + MMPlayerVolumeType vol; + vol.level[MM_VOLUME_CHANNEL_LEFT] = left; + vol.level[MM_VOLUME_CHANNEL_RIGHT] = right; + int ret = mm_player_set_volume(handle->mm_handle,&vol); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + return PLAYER_ERROR_NONE; + } +} + +int player_get_volume (player_h player, float *left, float *right) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(left); + PLAYER_NULL_ARG_CHECK(right); + player_s * handle = (player_s *) player; + MMPlayerVolumeType vol; + int ret = mm_player_get_volume(handle->mm_handle,&vol); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + *left = vol.level[MM_VOLUME_CHANNEL_LEFT]; + *right = vol.level[MM_VOLUME_CHANNEL_RIGHT]; + return PLAYER_ERROR_NONE; + } +} + +int player_set_sound_type(player_h player, sound_type_e type) +{ + PLAYER_INSTANCE_CHECK(player); + player_s * handle = (player_s *) player; + + int ret = mm_player_set_attribute(handle->mm_handle, NULL,"sound_volume_type" , type, (char*)NULL); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + return PLAYER_ERROR_NONE; +} + +int player_set_audio_latency_mode(player_h player, audio_latency_mode_e latency_mode) +{ + PLAYER_INSTANCE_CHECK(player); + player_s * handle = (player_s *) player; + + int ret = mm_player_set_attribute(handle->mm_handle, NULL,"audio_latency_mode" , latency_mode, (char*)NULL); + if(ret != MM_ERROR_NONE) + return __convert_error_code(ret,(char*)__FUNCTION__); + else + return PLAYER_ERROR_NONE; +} + +int player_get_audio_latency_mode(player_h player, audio_latency_mode_e *latency_mode) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(latency_mode); + player_s * handle = (player_s *) player; + + int ret = mm_player_get_attribute(handle->mm_handle, NULL,"audio_latency_mode" , latency_mode, (char*)NULL); + if(ret != MM_ERROR_NONE) + return __convert_error_code(ret,(char*)__FUNCTION__); + else + return PLAYER_ERROR_NONE; +} + +int player_start (player_h player) +{ + LOGE("[%s] Start", __FUNCTION__); + PLAYER_INSTANCE_CHECK(player); + MMTA_ACUM_ITEM_BEGIN("[CAPI] player_start only", 0); + MMTA_ACUM_ITEM_BEGIN("[CAPI] player_start ~ BOS", 0); + player_s * handle = (player_s *) player; + int ret; + if ( handle->state ==PLAYER_STATE_READY || handle->state ==PLAYER_STATE_PAUSED) + { + if(handle->display_type == PLAYER_DISPLAY_TYPE_X11 || handle->display_type == PLAYER_DISPLAY_TYPE_EVAS) + { + if(handle->is_display_visible) + { + ret = mm_player_set_attribute(handle->mm_handle, NULL,"display_visible" , 1, (char*)NULL); + LOGE("[%s] show video display : %d",__FUNCTION__, ret); + } + } + + if(handle->is_stopped) + { + if (handle->is_progressive_download) + { + LOGE("[%s] PLAYER_ERROR_INVALID_OPERATION(0x%08x)" ,__FUNCTION__,PLAYER_ERROR_INVALID_OPERATION); + return PLAYER_ERROR_INVALID_OPERATION; + } + + ret = mm_player_start(handle->mm_handle); + LOGE("[%s] stop -> start() ",__FUNCTION__); + } + else + { + if (handle->is_progressive_download && handle->state ==PLAYER_STATE_READY) + ret = mm_player_start(handle->mm_handle); + else + ret = mm_player_resume(handle->mm_handle); + } + } + else + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d" ,__FUNCTION__,PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + handle->is_stopped = FALSE; + handle->state = PLAYER_STATE_PLAYING; + LOGE("[%s] End", __FUNCTION__); + return PLAYER_ERROR_NONE; + } +} + +int player_stop (player_h player) +{ + LOGE("[%s] Start", __FUNCTION__); + PLAYER_INSTANCE_CHECK(player); + player_s * handle = (player_s *) player; + if (handle->state == PLAYER_STATE_PLAYING || handle->state == PLAYER_STATE_PAUSED) + { + int ret = mm_player_stop(handle->mm_handle); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + handle->state = PLAYER_STATE_READY; + handle->is_stopped = TRUE; + LOGE("[%s] End", __FUNCTION__); + return PLAYER_ERROR_NONE; + } + } + else + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d" ,__FUNCTION__,PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } +} + +int player_pause (player_h player) +{ + LOGE("[%s] Start", __FUNCTION__); + PLAYER_INSTANCE_CHECK(player); + player_s * handle = (player_s *) player; + PLAYER_STATE_CHECK(handle,PLAYER_STATE_PLAYING); + + int ret = mm_player_pause(handle->mm_handle); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + handle->state = PLAYER_STATE_PAUSED; + LOGE("[%s] End", __FUNCTION__); + return PLAYER_ERROR_NONE; + } +} + +int player_set_position (player_h player, int millisecond, player_seek_completed_cb callback, void *user_data) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_CHECK_CONDITION(millisecond>=0 ,PLAYER_ERROR_INVALID_PARAMETER ,"PLAYER_ERROR_INVALID_PARAMETER" ); + + player_s * handle = (player_s *) player; + if(handle->user_cb[_PLAYER_EVENT_TYPE_SEEK]) + { + LOGE("[%s] PLAYER_ERROR_SEEK_FAILED (0x%08x) : seeking... we can't do any more " ,__FUNCTION__, PLAYER_ERROR_SEEK_FAILED); + return PLAYER_ERROR_SEEK_FAILED; + } + else + { + LOGI("[%s] Event type : %d ",__FUNCTION__, _PLAYER_EVENT_TYPE_SEEK); + handle->user_cb[_PLAYER_EVENT_TYPE_SEEK] = callback; + handle->user_data[_PLAYER_EVENT_TYPE_SEEK] = user_data; + } + + int ret = mm_player_set_position(handle->mm_handle, MM_PLAYER_POS_FORMAT_TIME, millisecond); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + return PLAYER_ERROR_NONE; + } +} + +int player_set_position_ratio (player_h player, int percent, player_seek_completed_cb callback, void *user_data) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_CHECK_CONDITION(percent>=0 && percent <= 100 ,PLAYER_ERROR_INVALID_PARAMETER ,"PLAYER_ERROR_INVALID_PARAMETER" ); + + player_s * handle = (player_s *) player; + if(handle->user_cb[_PLAYER_EVENT_TYPE_SEEK]) + { + LOGE("[%s] PLAYER_ERROR_SEEK_FAILED (0x%08x) : seeking... we can't do any more " ,__FUNCTION__, PLAYER_ERROR_SEEK_FAILED); + return PLAYER_ERROR_SEEK_FAILED; + } + else + { + LOGI("[%s] Event type : %d ",__FUNCTION__, _PLAYER_EVENT_TYPE_SEEK); + handle->user_cb[_PLAYER_EVENT_TYPE_SEEK] = callback; + handle->user_data[_PLAYER_EVENT_TYPE_SEEK] = user_data; + } + + int ret = mm_player_set_position(handle->mm_handle, MM_PLAYER_POS_FORMAT_PERCENT , percent); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + return PLAYER_ERROR_NONE; + } +} + + +int player_get_position (player_h player, int *millisecond) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(millisecond); + player_s * handle = (player_s *) player; + if (!__player_state_validate(handle, PLAYER_STATE_READY)) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d" ,__FUNCTION__,PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + int pos; + int ret = mm_player_get_position(handle->mm_handle, MM_PLAYER_POS_FORMAT_TIME , &pos); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + *millisecond = pos; + return PLAYER_ERROR_NONE; + } +} + +int player_get_position_ratio (player_h player,int *percent) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(percent); + player_s * handle = (player_s *) player; + if (!__player_state_validate(handle, PLAYER_STATE_READY)) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d" ,__FUNCTION__,PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + int pos; + int ret = mm_player_get_position(handle->mm_handle, MM_PLAYER_POS_FORMAT_PERCENT, &pos); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + *percent=pos; + return PLAYER_ERROR_NONE; + } +} + +int player_set_mute (player_h player, bool muted) +{ + PLAYER_INSTANCE_CHECK(player); + player_s * handle = (player_s *) player; + + int ret = mm_player_set_mute(handle->mm_handle, muted); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + return PLAYER_ERROR_NONE; + } +} + +int player_is_muted (player_h player, bool *muted) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(muted); + player_s * handle = (player_s *) player; + + int _mute; + int ret = mm_player_get_mute(handle->mm_handle, &_mute); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + if(_mute) + { + *muted = TRUE; + } + else + { + *muted = FALSE; + } + return PLAYER_ERROR_NONE; + } +} + +int player_set_looping (player_h player, bool looping) +{ + PLAYER_INSTANCE_CHECK(player); + player_s * handle = (player_s *) player; + if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d" ,__FUNCTION__,PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + + int value = 0; + if(looping==TRUE) + { + value = -1; + } + int ret = mm_player_set_attribute(handle->mm_handle, NULL,MM_PLAYER_PLAYBACK_COUNT , value, (char*)NULL); + + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + return PLAYER_ERROR_NONE; + } +} + +int player_is_looping (player_h player, bool *looping) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(looping); + player_s * handle = (player_s *) player; + if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d" ,__FUNCTION__,PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + int count; + int ret = mm_player_get_attribute(handle->mm_handle, NULL,MM_PLAYER_PLAYBACK_COUNT , &count, (char*)NULL); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + if(count==-1) + { + *looping = TRUE; + } + else + { + *looping = FALSE; + } + return PLAYER_ERROR_NONE; + } +} + +int player_get_duration (player_h player, int *duration) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(duration); + player_s * handle = (player_s *) player; + if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d" ,__FUNCTION__,PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + int _duration; + int ret = mm_player_get_attribute(handle->mm_handle, NULL,MM_PLAYER_CONTENT_DURATION, &_duration, (char*)NULL); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + *duration = _duration; + LOGE("[%s] duration : %d",__FUNCTION__,_duration); + return PLAYER_ERROR_NONE; + } +} + +int player_set_display(player_h player, player_display_type_e type, player_display_h display) +{ + PLAYER_INSTANCE_CHECK(player); + player_s * handle = (player_s *) player; + + int ret; + if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d" ,__FUNCTION__,PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + + if (handle->is_set_pixmap_cb) + { + if (handle->state < PLAYER_STATE_READY) + { + /* just set below and go to "changing surface case" */ + handle->is_set_pixmap_cb = false; + } + else + { + LOGE("[%s] pixmap callback was set, try it again after calling player_unprepare()" ,__FUNCTION__,PLAYER_ERROR_INVALID_OPERATION); + LOGE("[%s] PLAYER_ERROR_INVALID_OPERATION(0x%08x)" ,__FUNCTION__,PLAYER_ERROR_INVALID_OPERATION); + return PLAYER_ERROR_INVALID_OPERATION; + } + } + + void* temp; + if (handle->display_type == (int)MM_DISPLAY_SURFACE_NULL || type == handle->display_type) // first time or same type + { + temp = handle->display_handle; + handle->display_handle = display; + ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_surface_type", type, "display_overlay" , type == PLAYER_DISPLAY_TYPE_X11 ? &handle->display_handle : display, sizeof(display), (char*)NULL); + if (ret != MM_ERROR_NONE) + { + handle->display_handle = temp; + LOGE("[%s] Failed to display surface change :%d",__FUNCTION__,ret); + } + else + { + handle->display_type = type; + LOGE("[%s] video display has been changed- type :%d, addr : 0x%x",__FUNCTION__,handle->display_type, handle->display_handle); + } + LOGE("[%s] video display has been updated - type :%d",__FUNCTION__,type); + } + else //changing surface case + { + temp = handle->display_handle; + handle->display_handle = display; + + ret = mm_player_change_videosink(handle->mm_handle, type, type == PLAYER_DISPLAY_TYPE_X11 ? &handle->display_handle : display); + if (ret != MM_ERROR_NONE) + { + handle->display_handle = temp; + if(ret == MM_ERROR_NOT_SUPPORT_API) + { + LOGE("[%s] change video sink is not available.",__FUNCTION__); + ret = PLAYER_ERROR_NONE; + } + else + { + LOGE("[%s] Failed to display surface change :%d",__FUNCTION__,ret); + } + } + else + { + handle->display_type = type; + LOGE("[%s] video display has been changed- type :%d, addr : 0x%x",__FUNCTION__,handle->display_type, handle->display_handle); + } + } + + if(ret != MM_ERROR_NONE) + { + handle->display_type = MM_DISPLAY_SURFACE_NULL; + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + LOGE("[%s] End",__FUNCTION__); + return PLAYER_ERROR_NONE; + } +} + +int player_is_display_mode_changeable(player_h player, bool* changeable) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(changeable); + player_s * handle = (player_s *) player; + switch(handle->display_type) + { + case PLAYER_DISPLAY_TYPE_X11: + *changeable = TRUE; + break; + case PLAYER_DISPLAY_TYPE_EVAS: + { + char *sink_name = NULL; + int length; + int scaling; + int ret = mm_player_get_attribute(handle->mm_handle, NULL,"display_evas_surface_sink" ,&sink_name, &length, "display_evas_do_scaling", &scaling, (char*)NULL); + if(ret != MM_ERROR_NONE) + *changeable = FALSE; + if (!strncmp(sink_name,"evaspixmapsink",length) && scaling==1) + { + *changeable = TRUE; + } + break; + } + default: + *changeable = FALSE; + break; + } + return PLAYER_ERROR_NONE; +} + +int player_set_display_mode(player_h player, player_display_mode_e mode) +{ + PLAYER_INSTANCE_CHECK(player); + player_s * handle = (player_s *) player; + + int ret = mm_player_set_attribute(handle->mm_handle, NULL,"display_method" , mode, (char*)NULL); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + return PLAYER_ERROR_NONE; +} + +int player_get_display_mode(player_h player, player_display_mode_e *mode) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(mode); + player_s * handle = (player_s *) player; + int ret = mm_player_get_attribute(handle->mm_handle, NULL,"display_method" ,mode, (char*)NULL); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + return PLAYER_ERROR_NONE; + } +} + +int player_set_playback_rate(player_h player, float rate) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_CHECK_CONDITION(rate>=-5.0 && rate <= 5.0 ,PLAYER_ERROR_INVALID_PARAMETER,"PLAYER_ERROR_INVALID_PARAMETER" ); + player_s * handle = (player_s *) player; + PLAYER_STATE_CHECK(handle,PLAYER_STATE_PLAYING); + + int ret = mm_player_set_play_speed(handle->mm_handle, rate); + + switch (ret) + { + case MM_ERROR_NONE: + case MM_ERROR_PLAYER_NO_OP: + ret = PLAYER_ERROR_NONE; + break; + case MM_ERROR_NOT_SUPPORT_API: + case MM_ERROR_PLAYER_SEEK: + LOGE("[%s] PLAYER_ERROR_INVALID_OPERATION(0x%08x) : seek error",__FUNCTION__, PLAYER_ERROR_INVALID_OPERATION); + ret = PLAYER_ERROR_INVALID_OPERATION; + break; + default: + return __convert_error_code(ret,(char*)__FUNCTION__); + } + return ret; +} + + +int player_set_x11_display_rotation(player_h player, player_display_rotation_e rotation) +{ + PLAYER_INSTANCE_CHECK(player); + player_s * handle = (player_s *) player; + + int ret = mm_player_set_attribute(handle->mm_handle, NULL,MM_PLAYER_VIDEO_ROTATION , rotation, (char*)NULL); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + return PLAYER_ERROR_NONE; +} + +int player_get_x11_display_rotation( player_h player, player_display_rotation_e *rotation) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(rotation); + player_s * handle = (player_s *) player; + int ret = mm_player_get_attribute(handle->mm_handle, NULL,MM_PLAYER_VIDEO_ROTATION ,rotation, (char*)NULL); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + return PLAYER_ERROR_NONE; + } +} + +int player_set_x11_display_visible(player_h player, bool visible) +{ + PLAYER_INSTANCE_CHECK(player); + player_s * handle = (player_s *) player; + + int value = 0; + if(visible==TRUE) + { + value = 1; + } + + int ret = mm_player_set_attribute(handle->mm_handle, NULL,"display_visible" , value, (char*)NULL); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + handle->is_display_visible = visible; + return PLAYER_ERROR_NONE; + } +} + +int player_is_x11_display_visible(player_h player, bool* visible) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(visible); + player_s * handle = (player_s *) player; + int count; + int ret = mm_player_get_attribute(handle->mm_handle, NULL,"display_visible" ,&count, (char*)NULL); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + if(count==0) + { + *visible = FALSE; + } + else + { + *visible = TRUE; + } + + return PLAYER_ERROR_NONE; + } +} + +int player_set_x11_display_zoom(player_h player, int level) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_CHECK_CONDITION(level>0 && level < 10 ,PLAYER_ERROR_INVALID_PARAMETER,"PLAYER_ERROR_INVALID_PARAMETER" ); + + player_s * handle = (player_s *) player; + int ret = mm_player_set_attribute(handle->mm_handle, NULL,"display_zoom" , level, (char*)NULL); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + return PLAYER_ERROR_NONE; +} + +int player_get_x11_display_zoom( player_h player, int *level) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(level); + player_s * handle = (player_s *) player; + int _level; + int ret = mm_player_get_attribute(handle->mm_handle, NULL,"display_zoom" , &_level, (char*)NULL); + if(ret != MM_ERROR_NONE) + { + *level=-1; + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + *level = _level; + return PLAYER_ERROR_NONE; + } +} + +int player_set_x11_display_pixmap (player_h player, player_x11_pixmap_updated_cb callback, void *user_data) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(callback); + player_s * handle = (player_s *) player; + + if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d" ,__FUNCTION__,PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + + if (!handle->is_set_pixmap_cb && handle->display_type != ((int)MM_DISPLAY_SURFACE_NULL)) + { + LOGE("[%s] player_set_display() was set, try it again after calling player_unprepare()" ,__FUNCTION__,PLAYER_ERROR_INVALID_OPERATION); + LOGE("[%s] PLAYER_ERROR_INVALID_OPERATION(0x%08x)" ,__FUNCTION__,PLAYER_ERROR_INVALID_OPERATION); + return PLAYER_ERROR_INVALID_OPERATION; + } + + int ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_surface_type", MM_DISPLAY_SURFACE_X_EXT, "display_overlay" , callback , sizeof(callback), "display_overlay_user_data", user_data, sizeof(user_data), (char*)NULL); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + handle->is_set_pixmap_cb = true; + handle->display_type = MM_DISPLAY_SURFACE_X; + handle->display_handle = callback; + LOGE("[%s] video display has been changed- type :%d, pixmap_callback addr : 0x%x",__FUNCTION__,handle->display_type, handle->display_handle); + return PLAYER_ERROR_NONE; + } + +} + +int player_set_x11_display_pixmap_error_cb (player_h player, player_x11_pixmap_error_cb callback, void *user_data) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(callback); + player_s * handle = (player_s *) player; + + if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d" ,__FUNCTION__,PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + + int ret = mm_player_set_video_frame_render_error_callback(handle->mm_handle, __video_frame_render_error_callback, (void*)handle); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + LOGE("[%s] set pixmap_error_cb(0x%08x) and user_data(0x%8x)" ,__FUNCTION__, callback, user_data); + handle->user_cb[_PLAYER_EVENT_TYPE_VIDEO_FRAME_RENDER_ERROR] = callback; + handle->user_data[_PLAYER_EVENT_TYPE_VIDEO_FRAME_RENDER_ERROR] = user_data; + LOGI("[%s] Event type : %d ",__FUNCTION__, _PLAYER_EVENT_TYPE_VIDEO_FRAME_RENDER_ERROR); + return PLAYER_ERROR_NONE; + } +} + +int player_enable_evas_display_scaling(player_h player, bool enable) +{ + PLAYER_INSTANCE_CHECK(player); + player_s * handle = (player_s *) player; + + int scaling = enable?1:0; + int ret = mm_player_set_attribute(handle->mm_handle, NULL,"display_evas_do_scaling" , scaling, (char*)NULL); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + return PLAYER_ERROR_NONE; +} + +int player_get_content_info(player_h player, player_content_info_e key, char ** value) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(value); + player_s * handle = (player_s *) player; + if (!__player_state_validate(handle, PLAYER_STATE_READY)) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d" ,__FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + + char* attr=NULL; + char* val=NULL; + int val_len=0; + + switch(key) + { + case PLAYER_CONTENT_INFO_ALBUM: + attr = MM_PLAYER_TAG_ALBUM; + break; + case PLAYER_CONTENT_INFO_ARTIST: + attr = MM_PLAYER_TAG_ARTIST; + break; + case PLAYER_CONTENT_INFO_AUTHOR: + attr = MM_PLAYER_TAG_AUTHOUR; + break; + case PLAYER_CONTENT_INFO_GENRE: + attr = MM_PLAYER_TAG_GENRE; + break; + case PLAYER_CONTENT_INFO_TITLE: + attr = MM_PLAYER_TAG_TITLE; + break; + case PLAYER_CONTENT_INFO_YEAR: + attr = MM_PLAYER_TAG_DATE; + break; + default: + attr=NULL; + } + + int ret = mm_player_get_attribute(handle->mm_handle, NULL,attr ,&val, &val_len, (char*)NULL); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + *value = NULL; + if(val!=NULL) + *value = strndup(val,val_len); + else + *value = strndup("",0); + + if (*value == NULL) + { + LOGE("[%s] PLAYER_ERROR_OUT_OF_MEMORY(0x%08x) : fail to strdup ", __FUNCTION__,PLAYER_ERROR_OUT_OF_MEMORY); + return PLAYER_ERROR_OUT_OF_MEMORY; + } + return PLAYER_ERROR_NONE; + } +} + +int player_get_codec_info(player_h player, char **audio_codec, char **video_codec) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(audio_codec); + PLAYER_NULL_ARG_CHECK(video_codec); + player_s * handle = (player_s *) player; + if (!__player_state_validate(handle, PLAYER_STATE_READY)) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d" ,__FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + + char* audio=NULL; + int audio_len=0; + char* video=NULL; + int video_len=0; + + int ret = mm_player_get_attribute(handle->mm_handle, NULL,MM_PLAYER_AUDIO_CODEC,&audio,&audio_len,MM_PLAYER_VIDEO_CODEC,&video,&video_len,(char*)NULL); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + *audio_codec = NULL; + if(audio!=NULL) + *audio_codec = strndup(audio,audio_len); + else + *audio_codec = strndup("",0); + + *video_codec = NULL; + if(video!=NULL) + *video_codec = strndup(video,video_len); + else + *video_codec = strndup("",0); + + return PLAYER_ERROR_NONE; + } +} + +int player_get_audio_stream_info(player_h player, int *sample_rate, int *channel, int *bit_rate) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(sample_rate); + PLAYER_NULL_ARG_CHECK(channel); + PLAYER_NULL_ARG_CHECK(bit_rate); + player_s * handle = (player_s *) player; + if (!__player_state_validate(handle, PLAYER_STATE_READY)) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d" ,__FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + int ret = mm_player_get_attribute(handle->mm_handle, NULL,MM_PLAYER_AUDIO_SAMPLERATE,sample_rate,MM_PLAYER_AUDIO_CHANNEL,channel,MM_PLAYER_AUDIO_BITRATE,bit_rate,(char*)NULL); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + return PLAYER_ERROR_NONE; +} + +int player_get_video_stream_info(player_h player, int *fps, int *bit_rate) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(fps); + PLAYER_NULL_ARG_CHECK(bit_rate); + player_s * handle = (player_s *) player; + if (!__player_state_validate(handle, PLAYER_STATE_READY)) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d" ,__FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + int ret = mm_player_get_attribute(handle->mm_handle, NULL,"content_video_fps",fps,"content_video_bitrate",bit_rate,(char*)NULL); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + return PLAYER_ERROR_NONE; +} + +int player_get_video_size (player_h player, int *width, int *height) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(width); + PLAYER_NULL_ARG_CHECK(height); + player_s * handle = (player_s *) player; + if (!__player_state_validate(handle, PLAYER_STATE_READY)) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d" ,__FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + int w; + int h; + int ret = mm_player_get_attribute(handle->mm_handle, NULL,MM_PLAYER_VIDEO_WIDTH ,&w, MM_PLAYER_VIDEO_HEIGHT, &h, (char*)NULL); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + *width = w; + *height = h; + LOGE("[%s] width : %d, height : %d",__FUNCTION__,w, h); + return PLAYER_ERROR_NONE; + } +} + +int player_get_album_art(player_h player, void **album_art, int *size) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(size); + player_s * handle = (player_s *) player; + if (!__player_state_validate(handle, PLAYER_STATE_READY)) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d" ,__FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + + int ret = mm_player_get_attribute(handle->mm_handle, NULL,"tag_album_cover",album_art,size,(char*)NULL); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + return PLAYER_ERROR_NONE; +} + +int player_get_track_count(player_h player, player_track_type_e type, int *count) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(count); + player_s * handle = (player_s *) player; + if (!__player_state_validate(handle, PLAYER_STATE_READY)) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d" ,__FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + int ret = mm_player_get_track_count(handle->mm_handle, type, count); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + return PLAYER_ERROR_NONE; +} + +int player_audio_effect_set_value(player_h player, audio_effect_e effect, int value) +{ + PLAYER_INSTANCE_CHECK(player); + player_s * handle = (player_s *) player; + int ret = mm_player_audio_effect_custom_set_level(handle->mm_handle,effect,0,value); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + ret = mm_player_audio_effect_custom_apply(handle->mm_handle); + return (ret==MM_ERROR_NONE)?PLAYER_ERROR_NONE:__convert_error_code(ret,(char*)__FUNCTION__); + } +} + +int player_audio_effect_get_value(player_h player, audio_effect_e effect, int *value) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(value); + player_s * handle = (player_s *) player; + int ret = mm_player_audio_effect_custom_get_level(handle->mm_handle,effect,0,value); + if(ret != MM_ERROR_NONE) + return __convert_error_code(ret,(char*)__FUNCTION__); + else + return PLAYER_ERROR_NONE; +} + +int player_audio_effect_clear(player_h player, audio_effect_e effect) +{ + PLAYER_INSTANCE_CHECK(player); + player_s * handle = (player_s *) player; + int ret = mm_player_audio_effect_custom_clear_ext_all(handle->mm_handle); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + ret = mm_player_audio_effect_custom_apply(handle->mm_handle); + return (ret==MM_ERROR_NONE)?PLAYER_ERROR_NONE:__convert_error_code(ret,(char*)__FUNCTION__); + } +} + +int player_audio_effect_get_value_range(player_h player, audio_effect_e effect, int* min, int* max) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(min); + PLAYER_NULL_ARG_CHECK(max); + player_s * handle = (player_s *) player; + int ret = mm_player_audio_effect_custom_get_level_range(handle->mm_handle, effect, min, max); + if(ret != MM_ERROR_NONE) + return __convert_error_code(ret,(char*)__FUNCTION__); + else + return PLAYER_ERROR_NONE; +} + +int player_audio_effect_is_available(player_h player, audio_effect_e effect, bool *available) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(available); + player_s * handle = (player_s *) player; + int ret = mm_player_is_supported_custom_effect_type(handle->mm_handle, effect); + if(ret != MM_ERROR_NONE) + *available = FALSE; + else + *available = TRUE; + return PLAYER_ERROR_NONE; +} + +int player_audio_effect_foreach_supported_effect(player_h player, player_audio_effect_supported_effect_cb callback, void *user_data) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(callback); + player_s * handle = (player_s *) player; + + LOGI("[%s] Event type : %d ",__FUNCTION__, _PLAYER_SUPPORTED_AUDIO_EFFECT_TYPE); + handle->user_cb[_PLAYER_SUPPORTED_AUDIO_EFFECT_TYPE] = callback; + handle->user_data[_PLAYER_SUPPORTED_AUDIO_EFFECT_TYPE] = user_data; + int ret = mm_player_get_foreach_present_supported_effect_type(handle->mm_handle, MM_AUDIO_EFFECT_TYPE_CUSTOM, __supported_audio_effect_type, (void*)handle); + if(ret != MM_ERROR_NONE) + return __convert_error_code(ret,(char*)__FUNCTION__); + else + return PLAYER_ERROR_NONE; +} + +int player_audio_effect_set_preset(player_h player, audio_effect_preset_e preset) +{ + PLAYER_INSTANCE_CHECK(player); + player_s * handle = (player_s *) player; + int ret = mm_player_audio_effect_preset_apply(handle->mm_handle, preset); + if(ret != MM_ERROR_NONE) + return __convert_error_code(ret,(char*)__FUNCTION__); + else + return PLAYER_ERROR_NONE; +} + +int player_audio_effect_preset_is_available(player_h player, audio_effect_preset_e preset, bool *available) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(available); + player_s * handle = (player_s *) player; + int ret = mm_player_is_supported_preset_effect_type(handle->mm_handle, preset); + if(ret != MM_ERROR_NONE) + *available = FALSE; + else + *available = TRUE; + return PLAYER_ERROR_NONE; +} + +int player_audio_effect_foreach_supported_preset(player_h player, player_audio_effect_supported_preset_cb callback, void *user_data) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(callback); + player_s * handle = (player_s *) player; + + LOGI("[%s] Event type : %d ",__FUNCTION__, _PLAYER_SUPPORTED_AUDIO_EFFECT_PRESET); + handle->user_cb[_PLAYER_SUPPORTED_AUDIO_EFFECT_PRESET] = callback; + handle->user_data[_PLAYER_SUPPORTED_AUDIO_EFFECT_PRESET] = user_data; + int ret = mm_player_get_foreach_present_supported_effect_type(handle->mm_handle, MM_AUDIO_EFFECT_TYPE_PRESET, __supported_audio_effect_preset, (void*)handle); + if(ret != MM_ERROR_NONE) + return __convert_error_code(ret,(char*)__FUNCTION__); + else + return PLAYER_ERROR_NONE; +} + +int player_audio_effect_get_equalizer_bands_count (player_h player, int *count) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(count); + player_s * handle = (player_s *) player; + int ret = mm_player_audio_effect_custom_get_eq_bands_number(handle->mm_handle, count); + if(ret != MM_ERROR_NONE) + return __convert_error_code(ret,(char*)__FUNCTION__); + else + return PLAYER_ERROR_NONE; +} + +int player_audio_effect_set_equalizer_all_bands(player_h player, int *band_levels, int length) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(band_levels); + player_s * handle = (player_s *) player; + int ret = mm_player_audio_effect_custom_set_level_eq_from_list(handle->mm_handle, band_levels, length); + if(ret != MM_ERROR_NONE) + return __convert_error_code(ret,(char*)__FUNCTION__); + else + return PLAYER_ERROR_NONE; +} + +int player_audio_effect_set_equalizer_band_level(player_h player, int index, int level) +{ + PLAYER_INSTANCE_CHECK(player); + player_s * handle = (player_s *) player; + int ret = mm_player_audio_effect_custom_set_level(handle->mm_handle,MM_AUDIO_EFFECT_CUSTOM_EQ, index, level); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + ret = mm_player_audio_effect_custom_apply(handle->mm_handle); + return (ret==MM_ERROR_NONE)?PLAYER_ERROR_NONE:__convert_error_code(ret,(char*)__FUNCTION__); + } +} + +int player_audio_effect_get_equalizer_band_level(player_h player, int index, int *level) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(level); + player_s * handle = (player_s *) player; + int ret = mm_player_audio_effect_custom_get_level(handle->mm_handle,MM_AUDIO_EFFECT_CUSTOM_EQ, index, level); + if(ret != MM_ERROR_NONE) + return __convert_error_code(ret,(char*)__FUNCTION__); + else + return PLAYER_ERROR_NONE; +} + +int player_audio_effect_get_equalizer_level_range(player_h player, int* min, int* max) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(min); + PLAYER_NULL_ARG_CHECK(max); + player_s * handle = (player_s *) player; + int ret = mm_player_audio_effect_custom_get_level_range(handle->mm_handle, MM_AUDIO_EFFECT_CUSTOM_EQ, min, max); + if(ret != MM_ERROR_NONE) + return __convert_error_code(ret,(char*)__FUNCTION__); + else + return PLAYER_ERROR_NONE; +} + +int player_audio_effect_get_equalizer_band_frequency(player_h player, int index, int *frequency) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(frequency); + player_s * handle = (player_s *) player; + int ret = mm_player_audio_effect_custom_get_eq_bands_freq(handle->mm_handle, index, frequency); + if(ret != MM_ERROR_NONE) + return __convert_error_code(ret,(char*)__FUNCTION__); + else + return PLAYER_ERROR_NONE; +} + +int player_audio_effect_get_equalizer_band_frequency_range(player_h player, int index, int *range) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(range); + player_s * handle = (player_s *) player; + int ret = mm_player_audio_effect_custom_get_eq_bands_width(handle->mm_handle, index, range); + if(ret != MM_ERROR_NONE) + return __convert_error_code(ret,(char*)__FUNCTION__); + else + return PLAYER_ERROR_NONE; +} + +int player_audio_effect_equalizer_clear(player_h player) +{ + PLAYER_INSTANCE_CHECK(player); + player_s * handle = (player_s *) player; + int ret = mm_player_audio_effect_custom_clear_eq_all(handle->mm_handle); + if(ret != MM_ERROR_NONE) + return __convert_error_code(ret,(char*)__FUNCTION__); + else + return PLAYER_ERROR_NONE; +} + +int player_audio_effect_equalizer_is_available(player_h player, bool *available) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(available); + player_s * handle = (player_s *) player; + int ret = mm_player_is_supported_custom_effect_type(handle->mm_handle, MM_AUDIO_EFFECT_CUSTOM_EQ); + if(ret != MM_ERROR_NONE) + *available = FALSE; + else + *available = TRUE; + return PLAYER_ERROR_NONE; +} + +int player_set_subtitle_path(player_h player,const char* path) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(path); + player_s * handle = (player_s *) player; + PLAYER_STATE_CHECK(handle,PLAYER_STATE_IDLE); + + int ret = mm_player_set_attribute(handle->mm_handle, NULL,"subtitle_uri" , path, strlen(path),"subtitle_silent", 0, (char*)NULL); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + return PLAYER_ERROR_NONE; +} + +int player_set_subtitle_position(player_h player, int millisecond) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_CHECK_CONDITION(millisecond>=0 ,PLAYER_ERROR_INVALID_PARAMETER ,"PLAYER_ERROR_INVALID_PARAMETER" ); + player_s * handle = (player_s *) player; + if (!__player_state_validate(handle, PLAYER_STATE_PLAYING)) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d" ,__FUNCTION__,PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + + int ret = mm_player_adjust_subtitle_position(handle->mm_handle, MM_PLAYER_POS_FORMAT_TIME, millisecond); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + return PLAYER_ERROR_NONE; +} + +int player_set_progressive_download_path(player_h player, const char *path) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(path); + player_s * handle = (player_s *) player; + PLAYER_STATE_CHECK(handle,PLAYER_STATE_IDLE); + + int ret = mm_player_set_attribute(handle->mm_handle, NULL,"pd_mode", MM_PLAYER_PD_MODE_URI, "pd_location", path, strlen(path), (char*)NULL); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + handle->is_progressive_download = 1; + return PLAYER_ERROR_NONE; + } +} + +int player_get_progressive_download_status(player_h player, unsigned long *current, unsigned long *total_size) +{ + + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(current); + PLAYER_NULL_ARG_CHECK(total_size); + player_s * handle = (player_s *) player; + if (handle->state != PLAYER_STATE_PLAYING && handle->state != PLAYER_STATE_PAUSED) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d" ,__FUNCTION__,PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + guint64 _current; + guint64 _total; + int ret = mm_player_get_pd_status(handle->mm_handle, &_current, &_total); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + *current = _current; + *total_size = _total; + return PLAYER_ERROR_NONE; + } +} + +int player_capture_video(player_h player, player_video_captured_cb callback, void *user_data) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(callback); + + player_s * handle = (player_s *) player; + if(handle->user_cb[_PLAYER_EVENT_TYPE_CAPTURE]) + { + LOGE("[%s] PLAYER_ERROR_VIDEO_CAPTURE_FAILED (0x%08x) : capturing... we can't do any more " ,__FUNCTION__, PLAYER_ERROR_VIDEO_CAPTURE_FAILED); + return PLAYER_ERROR_VIDEO_CAPTURE_FAILED; + } + else + { + LOGI("[%s] Event type : %d ",__FUNCTION__, _PLAYER_EVENT_TYPE_CAPTURE); + handle->user_cb[_PLAYER_EVENT_TYPE_CAPTURE] = callback; + handle->user_data[_PLAYER_EVENT_TYPE_CAPTURE] = user_data; + } + + if(handle->state == PLAYER_STATE_PAUSED || handle->state == PLAYER_STATE_PLAYING ) + { + int ret = mm_player_do_video_capture(handle->mm_handle); + if(ret==MM_ERROR_PLAYER_NO_OP) + { + handle->user_cb[_PLAYER_EVENT_TYPE_CAPTURE] = NULL; + handle->user_data[_PLAYER_EVENT_TYPE_CAPTURE] = NULL; + LOGE("[%s] PLAYER_ERROR_INVALID_OPERATION (0x%08x) : video display must be set : %d" ,__FUNCTION__, PLAYER_ERROR_INVALID_OPERATION, handle->display_type); + return PLAYER_ERROR_INVALID_OPERATION; + } + if(ret != MM_ERROR_NONE) + { + handle->user_cb[_PLAYER_EVENT_TYPE_CAPTURE] = NULL; + handle->user_data[_PLAYER_EVENT_TYPE_CAPTURE] = NULL; + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + return PLAYER_ERROR_NONE; + } + else + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d" ,__FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state); + handle->user_cb[_PLAYER_EVENT_TYPE_CAPTURE] = NULL; + handle->user_data[_PLAYER_EVENT_TYPE_CAPTURE] = NULL; + return PLAYER_ERROR_INVALID_STATE; + } +} + +int player_set_streaming_cookie(player_h player, const char *cookie, int size) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(cookie); + PLAYER_CHECK_CONDITION(size>=0,PLAYER_ERROR_INVALID_PARAMETER,"PLAYER_ERROR_INVALID_PARAMETER" ); + player_s * handle = (player_s *) player; + PLAYER_STATE_CHECK(handle,PLAYER_STATE_IDLE); + + int ret = mm_player_set_attribute(handle->mm_handle, NULL,"streaming_cookie", cookie, size, (char*)NULL); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + return PLAYER_ERROR_NONE; +} + +int player_set_streaming_user_agent(player_h player, const char *user_agent, int size) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(user_agent); + PLAYER_CHECK_CONDITION(size>=0,PLAYER_ERROR_INVALID_PARAMETER,"PLAYER_ERROR_INVALID_PARAMETER" ); + player_s * handle = (player_s *) player; + PLAYER_STATE_CHECK(handle,PLAYER_STATE_IDLE); + + int ret = mm_player_set_attribute(handle->mm_handle, NULL,"streaming_user_agent", user_agent, size, (char*)NULL); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + return PLAYER_ERROR_NONE; +} + +int player_get_streaming_download_progress(player_h player, int *start, int *current) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(start); + PLAYER_NULL_ARG_CHECK(current); + player_s * handle = (player_s *) player; + if (handle->state != PLAYER_STATE_PLAYING && handle->state != PLAYER_STATE_PAUSED) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d" ,__FUNCTION__,PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + int _current; + int _start; + int ret = mm_player_get_buffer_position(handle->mm_handle,MM_PLAYER_POS_FORMAT_PERCENT,&_start,&_current); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + *start = _start; + *current = _current; + return PLAYER_ERROR_NONE; + } +} + +int player_set_completed_cb (player_h player, player_completed_cb callback, void *user_data) +{ + return __set_callback(_PLAYER_EVENT_TYPE_COMPLETE,player,callback,user_data); +} + +int player_unset_completed_cb (player_h player) +{ + return __unset_callback(_PLAYER_EVENT_TYPE_COMPLETE,player); +} + +int player_set_interrupted_cb (player_h player, player_interrupted_cb callback, void *user_data) +{ + return __set_callback(_PLAYER_EVENT_TYPE_INTERRUPT,player,callback,user_data); +} + +int player_unset_interrupted_cb (player_h player) +{ + return __unset_callback(_PLAYER_EVENT_TYPE_INTERRUPT,player); +} + +int player_set_error_cb (player_h player, player_error_cb callback, void *user_data) +{ + return __set_callback(_PLAYER_EVENT_TYPE_ERROR,player,callback,user_data); +} + +int player_unset_error_cb (player_h player) +{ + return __unset_callback(_PLAYER_EVENT_TYPE_ERROR,player); +} + +int player_set_buffering_cb (player_h player, player_buffering_cb callback, void *user_data) +{ + return __set_callback(_PLAYER_EVENT_TYPE_BUFFERING,player,callback,user_data); +} + +int player_unset_buffering_cb (player_h player) +{ + return __unset_callback(_PLAYER_EVENT_TYPE_BUFFERING,player); +} + +int player_set_subtitle_updated_cb(player_h player, player_subtitle_updated_cb callback, void* user_data ) +{ + return __set_callback(_PLAYER_EVENT_TYPE_SUBTITLE,player,callback,user_data); +} + +int player_unset_subtitle_updated_cb (player_h player) +{ + return __unset_callback(_PLAYER_EVENT_TYPE_SUBTITLE,player); +} + +int player_set_video_frame_decoded_cb(player_h player, player_video_frame_decoded_cb callback, void *user_data) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(callback); + player_s * handle = (player_s *) player; + if (handle->state != PLAYER_STATE_IDLE ) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d" ,__FUNCTION__,PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + + int ret = mm_player_set_video_stream_callback(handle->mm_handle, __video_stream_callback, (void*)handle); + if(ret != MM_ERROR_NONE) + return __convert_error_code(ret,(char*)__FUNCTION__); + + handle->user_cb[_PLAYER_EVENT_TYPE_VIDEO_FRAME] = callback; + handle->user_data[_PLAYER_EVENT_TYPE_VIDEO_FRAME] = user_data; + LOGI("[%s] Event type : %d ",__FUNCTION__, _PLAYER_EVENT_TYPE_VIDEO_FRAME); + return PLAYER_ERROR_NONE; +} + +int player_unset_video_frame_decoded_cb(player_h player) +{ + PLAYER_INSTANCE_CHECK(player); + player_s * handle = (player_s *) player; + handle->user_cb[_PLAYER_EVENT_TYPE_VIDEO_FRAME] = NULL; + handle->user_data[_PLAYER_EVENT_TYPE_VIDEO_FRAME] = NULL; + LOGI("[%s] Event type : %d ",__FUNCTION__, _PLAYER_EVENT_TYPE_VIDEO_FRAME); + int ret = mm_player_set_video_stream_callback(handle->mm_handle, NULL, NULL); + if(ret != MM_ERROR_NONE) + return __convert_error_code(ret,(char*)__FUNCTION__); + else + return PLAYER_ERROR_NONE; +} + +int player_set_audio_frame_decoded_cb(player_h player, int start, int end, player_audio_frame_decoded_cb callback, void *user_data) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(callback); + PLAYER_CHECK_CONDITION(start>=0 ,PLAYER_ERROR_INVALID_PARAMETER,"PLAYER_ERROR_INVALID_PARAMETER" ); + PLAYER_CHECK_CONDITION(end>=start ,PLAYER_ERROR_INVALID_PARAMETER,"PLAYER_ERROR_INVALID_PARAMETER" ); + player_s * handle = (player_s *) player; + if (handle->state != PLAYER_STATE_IDLE) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d" ,__FUNCTION__,PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + + int ret = mm_player_set_attribute(handle->mm_handle, NULL, "pcm_extraction",TRUE, "pcm_extraction_start_msec", start, "pcm_extraction_end_msec", end, NULL); + if(ret != MM_ERROR_NONE) + return __convert_error_code(ret,(char*)__FUNCTION__); + + ret = mm_player_set_audio_stream_callback(handle->mm_handle, __audio_stream_callback, (void*)handle); + if(ret != MM_ERROR_NONE) + return __convert_error_code(ret,(char*)__FUNCTION__); + + handle->user_cb[_PLAYER_EVENT_TYPE_AUDIO_FRAME] = callback; + handle->user_data[_PLAYER_EVENT_TYPE_AUDIO_FRAME] = user_data; + LOGI("[%s] Event type : %d ",__FUNCTION__, _PLAYER_EVENT_TYPE_AUDIO_FRAME); + return PLAYER_ERROR_NONE; +} + +int player_unset_audio_frame_decoded_cb(player_h player) +{ + PLAYER_INSTANCE_CHECK(player); + player_s * handle = (player_s *) player; + + handle->user_cb[_PLAYER_EVENT_TYPE_AUDIO_FRAME] = NULL; + handle->user_data[_PLAYER_EVENT_TYPE_AUDIO_FRAME] = NULL; + LOGI("[%s] Event type : %d ",__FUNCTION__, _PLAYER_EVENT_TYPE_AUDIO_FRAME); + + int ret = mm_player_set_attribute(handle->mm_handle, NULL, "pcm_extraction",FALSE, NULL); + if(ret != MM_ERROR_NONE) + return __convert_error_code(ret,(char*)__FUNCTION__); + + ret = mm_player_set_audio_buffer_callback(handle->mm_handle, NULL, NULL); + if(ret != MM_ERROR_NONE) + return __convert_error_code(ret,(char*)__FUNCTION__); + else + return PLAYER_ERROR_NONE; +} + +int player_set_progressive_download_message_cb(player_h player, player_pd_message_cb callback, void *user_data) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(callback); + player_s * handle = (player_s *) player; + if (handle->state != PLAYER_STATE_IDLE && handle->state != PLAYER_STATE_READY) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d" ,__FUNCTION__,PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + + int ret = mm_player_set_pd_message_callback(handle->mm_handle, __pd_message_callback, (void*)handle); + if(ret != MM_ERROR_NONE) + return __convert_error_code(ret,(char*)__FUNCTION__); + + handle->user_cb[_PLAYER_EVENT_TYPE_PD] = callback; + handle->user_data[_PLAYER_EVENT_TYPE_PD] = user_data; + LOGI("[%s] Event type : %d ",__FUNCTION__, _PLAYER_EVENT_TYPE_PD); + return PLAYER_ERROR_NONE; +} + +int player_unset_progressive_download_message_cb(player_h player) +{ + PLAYER_INSTANCE_CHECK(player); + player_s * handle = (player_s *) player; + + handle->user_cb[_PLAYER_EVENT_TYPE_PD] = NULL; + handle->user_data[_PLAYER_EVENT_TYPE_PD] = NULL; + LOGI("[%s] Event type : %d ",__FUNCTION__, _PLAYER_EVENT_TYPE_PD); + + int ret = mm_player_set_pd_message_callback(handle->mm_handle, NULL, NULL); + if(ret != MM_ERROR_NONE) + return __convert_error_code(ret,(char*)__FUNCTION__); + else + return PLAYER_ERROR_NONE; +} diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..461b088 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,22 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +SET(fw_test "${fw_name}-test") + +INCLUDE_DIRECTORIES(../include) +link_directories(${CMAKE_SOURCE_DIR}/../) + +INCLUDE(FindPkgConfig) +pkg_check_modules(${fw_test} REQUIRED mm-player appcore-efl elementary ecore evas ecore-x capi-media-sound-manager) +FOREACH(flag ${${fw_test}_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") + +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} capi-media-player ${${fw_test}_LDFLAGS}) +ENDFOREACH() + diff --git a/test/player_test.c b/test/player_test.c new file mode 100644 index 0000000..218d045 --- /dev/null +++ b/test/player_test.c @@ -0,0 +1,947 @@ +/* +* 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 +#include +#include +#include +#include +#include +#include + +#define PACKAGE "player_test" +#define MAX_STRING_LEN 2048 +#define MMTS_SAMPLELIST_INI_DEFAULT_PATH "/opt/etc/mmts_filelist.ini" +#define INI_SAMPLE_LIST_MAX 9 +char g_uri[MAX_STRING_LEN]; +char g_subtitle_uri[MAX_STRING_LEN]; + +enum +{ + CURRENT_STATUS_MAINMENU, + CURRENT_STATUS_FILENAME, + CURRENT_STATUS_VOLUME, + CURRENT_STATUS_MUTE, + CURRENT_STATUS_POSITION_TIME, + CURRENT_STATUS_POSITION_PERCENT, + CURRENT_STATUS_LOOPING, + CURRENT_STATUS_DISPLAY_MODE, + CURRENT_STATUS_DISPLAY_ROTATION, + CURRENT_STATUS_DISPLAY_VISIBLE, + CURRENT_STATUS_SUBTITLE_FILENAME +}; + +struct appdata +{ + Evas *evas; + Ecore_Evas *ee; + Evas_Object *win; + + Evas_Object *layout_main; /* layout widget based on EDJ */ + Ecore_X_Window xid; + /* add more variables here */ +}; + +static void win_del(void *data, Evas_Object *obj, void *event) +{ + elm_exit(); +} + +static Evas_Object* create_win(const char *name) +{ + Evas_Object *eo; + int w, h; + + printf ("[%s][%d] name=%s\n", __func__, __LINE__, name); + + eo = elm_win_add(NULL, name, ELM_WIN_BASIC); + if (eo) { + elm_win_title_set(eo, name); + elm_win_borderless_set(eo, EINA_TRUE); + evas_object_smart_callback_add(eo, "delete,request",win_del, NULL); + ecore_x_window_size_get(ecore_x_window_root_first_get(),&w, &h); + evas_object_resize(eo, w, h); + } + + return eo; +} + +static int app_create(void *data) +{ + struct appdata *ad = data; + Evas_Object *win; + /* create window */ + win = create_win(PACKAGE); + if (win == NULL) + return -1; + ad->win = win; + evas_object_show(win); + return 0; +} + +static int app_terminate(void *data) +{ + struct appdata *ad = data; + + if (ad->win) + evas_object_del(ad->win); + + return 0; +} + +struct appcore_ops ops = { + .create = app_create, + .terminate = app_terminate, +}; + +struct appdata ad; +static player_h g_player = 0; +int g_menu_state = CURRENT_STATUS_MAINMENU; +char g_file_list[9][256]; +gboolean quit_pushing; + +static void prepared_cb(void *user_data) +{ + g_print("[Player_Test] prepared_cb!!!!\n"); +} + +static void progress_down_cb(player_pd_message_type_e type, void *user_data) +{ + g_print("[Player_Test] progress_down_cb!!!! type : %d\n", type); +} + +static void paused_cb(void *user_data) +{ + g_print("[Player_Test] paused_cb!!!!\n"); +} + +static void started_cb(void *user_data) +{ + g_print("[Player_Test] started_cb!!!!\n"); +} + +static void buffering_cb(int percent, void *user_data) +{ + g_print("[Player_Test] buffering_cb!!!! percent : %d\n", percent); +} + +static void seek_completed_cb(void *user_data) +{ + g_print("[Player_Test] seek_completed_cb!!! \n"); +} + +static void completed_cb(void *user_data) +{ + g_print("[Player_Test] completed_cb!!!!\n"); +} + +static void audio_frame_decoded_cb(unsigned char *data, unsigned int size, void *user_data) +{ + int pos=0; + player_get_position(g_player, &pos); + g_print("[Player_Test] audio_frame_decoded_cb [size: %d] --- current pos : %d!!!!\n", size, pos); +} + +void video_frame_decoded_cb(unsigned char *data, int width, int height, unsigned int size, void *user_data) +{ + int pos=0; + player_get_position(g_player, &pos); + g_print("[Player_Test] video_frame_decoded_cb!!!! width: %d, height : %d, size :%d ---- current pos: %d \n",width, height,size,pos); +} + +static void subtitle_updated_cb(unsigned long duration, char *text, void *user_data) +{ + g_print("[Player_Test] subtitle_updated_cb!!!! [%ld] %s\n",duration, text); +} + +static void video_captured_cb(unsigned char *data, int width, int height,unsigned int size, void *user_data) +{ + g_print("[Player_Test] video_captured_cb!!!! width: %d, height : %d, size : %d \n",width, height,size); +} + +static void input_filename(char *filename) +{ + int len = strlen(filename); + + if ( len < 0 || len > MAX_STRING_LEN ) + return; + if(g_player!=NULL) + { + player_unprepare(g_player); + player_destroy(g_player); + } + g_player = 0; + + if ( player_create(&g_player) != PLAYER_ERROR_NONE ) + { + g_print("player create is failed\n"); + } + + strncpy (g_uri, filename,len); + +#if 0 //ned(APPSRC_TEST) + gchar uri[100]; + gchar *ext; + gsize file_size; + GMappedFile *file; + GError *error = NULL; + guint8* g_media_mem = NULL; + + ext = filename; + + file = g_mapped_file_new (ext, FALSE, &error); + file_size = g_mapped_file_get_length (file); + g_media_mem = (guint8 *) g_mapped_file_get_contents (file); + + g_sprintf(uri, "mem://ext=%s,size=%d", ext ? ext : "", file_size); + g_print("[uri] = %s\n", uri); + + mm_player_set_attribute(g_player, + &g_err_name, + "profile_uri", uri, strlen(uri), + "profile_user_param", g_media_mem, file_size + NULL); +#else + //player_set_uri(g_player, filename); +#endif /* APPSRC_TEST */ + + int ret; + player_state_e state; + ret = player_get_state(g_player, &state); + g_print("1. After player_create() - Current State : %d \n", state); +} + +static void _player_prepare() +{ + int ret = FALSE; + int slen = strlen(g_subtitle_uri); + + if ( slen > 0 && slen < MAX_STRING_LEN ) + { + g_print("0. set subtile path() (size : %d) - %s \n", slen, g_subtitle_uri); + player_set_subtitle_path(g_player,g_subtitle_uri); + player_set_subtitle_updated_cb(g_player, subtitle_updated_cb, (void*)g_player); + } + player_set_display(g_player,PLAYER_DISPLAY_TYPE_X11,GET_DISPLAY(ad.xid)); + + player_set_buffering_cb(g_player, buffering_cb, (void*)g_player); + player_set_completed_cb(g_player, completed_cb, (void*)g_player); + + player_set_uri(g_player, g_uri); + + ret = player_prepare(g_player); + //ret = player_prepare_async(g_player,prepared_cb, (void*) g_player); + if ( ret != PLAYER_ERROR_NONE ) + { + g_print("prepare is failed (errno = %d) \n", ret); + } + player_state_e state; + ret = player_get_state(g_player, &state); + g_print("After player_prepare() - Current State : %d \n", state); +} + +static void _player_unprepare() +{ + int ret = FALSE; + ret = player_unprepare(g_player); + if ( ret != PLAYER_ERROR_NONE ) + { + g_print("unprepare is failed (errno = %d) \n", ret); + } + memset(g_subtitle_uri, 0 , sizeof(g_subtitle_uri)); + player_state_e state; + ret = player_get_state(g_player, &state); + g_print(" After player_unprepare() - Current State : %d \n", state); +} + +static void _player_play() +{ + int bRet = FALSE; + bRet = player_start(g_player); +} + +static void _player_stop() +{ + int bRet = FALSE; + bRet = player_stop(g_player); +} + +static void _player_resume() +{ + int bRet = FALSE; + bRet = player_start(g_player); +} + +static void _player_pause() +{ + int bRet = FALSE; + bRet = player_pause(g_player); +} + +static void _player_state() +{ + player_state_e state; + player_get_state(g_player, &state); + g_print(" ==> [Player_Test] Current Player State : %d\n", state); +} + +static void _player_set_progressive_download() +{ + player_set_progressive_download_path(g_player, "/opt/test.pd"); + player_set_progressive_download_message_cb(g_player, progress_down_cb, (void*)g_player); +} + +static void set_volume(float volume) +{ + if ( player_set_volume(g_player, volume, volume) != PLAYER_ERROR_NONE ) + { + g_print("failed to set volume\n"); + } +} + +static void get_volume(float* left, float* right) +{ + player_get_volume(g_player, left, right); + g_print(" ==> [Player_Test] volume - left : %f, right : %f\n", *left, *right); +} + +static void set_mute(bool mute) +{ + if ( player_set_mute(g_player, mute) != PLAYER_ERROR_NONE ) + { + g_print("failed to set_mute\n"); + } +} + +static void get_mute(bool *mute) +{ + player_is_muted(g_player, mute); + g_print(" ==> [Player_Test] mute = %d\n", *mute); +} + +static void get_position() +{ + int position = 0; + int percent = 0; + int ret; + ret = player_get_position(g_player, &position); + g_print(" ==> [Player_Test] player_get_position() return : %d\n",ret); + ret = player_get_position_ratio(g_player, &percent); + g_print(" ==> [Player_Test] player_get_position_ratio() return : %d\n",ret); + g_print(" ==> [Player_Test] Pos: [%d ] msec\n", position); + g_print(" ==> [Player_Test] Pos: [%d] percent\n", percent); +} + +static void set_position(int position) +{ + if ( player_set_position(g_player, position, seek_completed_cb, g_player) != PLAYER_ERROR_NONE ) + { + g_print("failed to set position\n"); + } +} + +static void set_position_ratio(int percent) +{ + if ( player_set_position_ratio(g_player, percent, seek_completed_cb, g_player) != PLAYER_ERROR_NONE ) + { + g_print("failed to set position ratio\n"); + } +} + +static void get_duration() +{ + int duration = 0; + int ret; + ret = player_get_duration(g_player, &duration); + g_print(" ==> [Player_Test] player_get_duration() return : %d\n",ret); + g_print(" ==> [Player_Test] Duration: [%d ] msec\n",duration); +} + +static void get_stream_info() +{ + int w = 0; + int h = 0; + char *value = NULL; + player_get_content_info(g_player, PLAYER_CONTENT_INFO_ALBUM, &value); + g_print(" ==> [Player_Test] PLAYER_CONTENT_INFO_ALBUM: [%s ] \n",value); + player_get_content_info(g_player, PLAYER_CONTENT_INFO_ARTIST, &value); + g_print(" ==> [Player_Test] PLAYER_CONTENT_INFO_ARTIST: [%s ] \n",value); + player_get_content_info(g_player, PLAYER_CONTENT_INFO_AUTHOR, &value); + g_print(" ==> [Player_Test] PLAYER_CONTENT_INFO_AUTHOR: [%s ] \n",value); + player_get_content_info(g_player, PLAYER_CONTENT_INFO_GENRE, &value); + g_print(" ==> [Player_Test] PLAYER_CONTENT_INFO_GENRE: [%s ] \n",value); + player_get_content_info(g_player, PLAYER_CONTENT_INFO_TITLE, &value); + g_print(" ==> [Player_Test] PLAYER_CONTENT_INFO_TITLE: [%s ] \n",value); + void *album; + int size; + player_get_album_art(g_player, &album, &size); + g_print(" ==> [Player_Test] Album art : [ data : 0x%x, size : %d ]\n",album, size); + if(value!=NULL) + { + free(value); + value = NULL; + } + + int sample_rate; + int channel; + int bit_rate; + player_get_audio_stream_info(g_player, &sample_rate, &channel, &bit_rate); + g_print(" ==> [Player_Test] Sample Rate: [%d ] , Channel: [%d ] , Bit Rate: [%d ] \n",sample_rate,channel,bit_rate); + + char *audio_codec = NULL; + char *video_codec = NULL; + player_get_codec_info(g_player, &audio_codec, &video_codec); + if(audio_codec!=NULL) + { + g_print(" ==> [Player_Test] Audio Codec: [%s ] \n",audio_codec); + free(audio_codec); + audio_codec = NULL; + } + if(video_codec!=NULL) + { + g_print(" ==> [Player_Test] Video Codec: [%s ] \n",video_codec); + free(video_codec); + video_codec = NULL; + } + player_get_video_size(g_player, &w, &h); + g_print(" ==> [Player_Test] Width: [%d ] , Height: [%d ] \n",w,h); +} + +static void set_looping(bool looping) +{ + if ( player_set_looping(g_player, looping) != PLAYER_ERROR_NONE ) + { + g_print("failed to set_looping\n"); + } +} + +static void get_looping(bool *looping) +{ + player_is_looping(g_player, looping); + g_print(" ==> [Player_Test] looping = %d\n", *looping); +} + +static void set_display_mode(int mode) +{ + if ( player_set_display_mode(g_player, mode) != PLAYER_ERROR_NONE ) + { + g_print("failed to player_set_display_mode\n"); + } +} + +static void get_display_mode() +{ + player_display_mode_e mode; + player_get_display_mode(g_player, &mode); + g_print(" ==> [Player_Test] Display mode: [%d ] \n",mode); +} + +static void set_display_rotation(int rotation) +{ + if ( player_set_x11_display_rotation(g_player, rotation) != PLAYER_ERROR_NONE ) + { + g_print("failed to set_display_rotation\n"); + } +} + +static void get_display_rotation() +{ + player_display_rotation_e rotation = 0; + player_get_x11_display_rotation(g_player, &rotation); + g_print(" ==> [Player_Test] X11 Display rotation: [%d ] \n",rotation); +} + + +static void set_display_visible(bool visible) +{ + if ( player_set_x11_display_visible(g_player, visible) != PLAYER_ERROR_NONE ) + { + g_print("failed to player_set_x11_display_visible\n"); + } +} + +static void get_display_visible(bool *visible) +{ + player_is_x11_display_visible(g_player, visible); + g_print(" ==> [Player_Test] X11 Display Visible = %d\n", *visible); +} + +static void input_subtitle_filename(char *subtitle_filename) +{ + int len = strlen(subtitle_filename); + + if ( len < 1 || len > MAX_STRING_LEN ) + return; + + strncpy (g_subtitle_uri, subtitle_filename,len); + g_print("subtitle uri is set to %s\n", g_subtitle_uri); +} + +static void capture_video() +{ + if( player_capture_video(g_player,video_captured_cb,NULL)!=PLAYER_ERROR_NONE) + { + g_print("failed to player_capture_video\n"); + } +} + +static void decoding_audio() +{ + int ret; + ret =player_set_audio_frame_decoded_cb(g_player, 0,0,audio_frame_decoded_cb, (void*)g_player); + if ( ret != PLAYER_ERROR_NONE ) + { + g_print("player_set_audio_frame_decoded_cb is failed (errno = %d) \n", ret); + } +} + +static void decoding_video() +{ + int ret; + ret =player_set_video_frame_decoded_cb(g_player, video_frame_decoded_cb, (void*)g_player); + if ( ret != PLAYER_ERROR_NONE ) + { + g_print("player_set_video_frame_decoded_cb is failed (errno = %d) \n", ret); + } +} + +void quit_program() +{ + player_unprepare(g_player); + player_destroy(g_player); + g_player = 0; + elm_exit(); +} + +void play_with_ini(char *file_path) +{ + input_filename(file_path); + _player_play(); +} + +void _interpret_main_menu(char *cmd) +{ + int len = strlen(cmd); + if ( len == 1 ) + { + if (strncmp(cmd, "a", 1) == 0) + { + g_menu_state = CURRENT_STATUS_FILENAME; + } + else if (strncmp(cmd, "1", 1) == 0) + { + play_with_ini(g_file_list[0]); + } + else if (strncmp(cmd, "2", 1) == 0) + { + play_with_ini(g_file_list[1]); + } + else if (strncmp(cmd, "3", 1) == 0) + { + play_with_ini(g_file_list[2]); + } + else if (strncmp(cmd, "4", 1) == 0) + { + play_with_ini(g_file_list[3]); + } + else if (strncmp(cmd, "5", 1) == 0) + { + play_with_ini(g_file_list[4]); + } + else if (strncmp(cmd, "6", 1) == 0) + { + play_with_ini(g_file_list[5]); + } + else if (strncmp(cmd, "7", 1) == 0) + { + play_with_ini(g_file_list[6]); + } + else if (strncmp(cmd, "8", 1) == 0) + { + play_with_ini(g_file_list[7]); + } + else if (strncmp(cmd, "9", 1) == 0) + { + play_with_ini(g_file_list[8]); + } + else if (strncmp(cmd, "b", 1) == 0) + { + _player_play(); + } + else if (strncmp(cmd, "c", 1) == 0) + { + _player_stop(); + } + else if (strncmp(cmd, "d", 1) == 0) + { + _player_resume(); + } + else if (strncmp(cmd, "e", 1) == 0) + { + _player_pause(); + } + else if (strncmp(cmd, "S", 1) == 0) + { + _player_state(); + } + else if (strncmp(cmd, "f", 1) == 0) + { + g_menu_state = CURRENT_STATUS_VOLUME; + } + else if (strncmp(cmd, "g", 1) == 0) + { + float left; + float right; + get_volume(&left, &right); + } + else if (strncmp(cmd, "h", 1) == 0 ) + { + g_menu_state = CURRENT_STATUS_MUTE; + } + else if (strncmp(cmd, "i", 1) == 0 ) + { + bool mute; + get_mute(&mute); + } + else if (strncmp(cmd, "j", 1) == 0 ) + { + g_menu_state = CURRENT_STATUS_POSITION_TIME; + } + else if (strncmp(cmd, "k", 1) == 0 ) + { + g_menu_state = CURRENT_STATUS_POSITION_PERCENT; + } + else if (strncmp(cmd, "l", 1) == 0 ) + { + get_position(); + } + else if (strncmp(cmd, "m", 1) == 0 ) + { + get_duration(); + } + else if (strncmp(cmd, "n", 1) == 0 ) + { + get_stream_info(); + } + else if (strncmp(cmd, "o", 1) == 0 ) + { + g_menu_state = CURRENT_STATUS_LOOPING; + } + else if (strncmp(cmd, "p", 1) == 0 ) + { + bool looping; + get_looping(&looping); + } + else if (strncmp(cmd, "r", 1) == 0 ) + { + g_menu_state = CURRENT_STATUS_DISPLAY_MODE; + } + else if (strncmp(cmd, "s", 1) == 0 ) + { + get_display_mode(); + } + else if (strncmp(cmd, "t", 1) == 0 ) + { + g_menu_state = CURRENT_STATUS_DISPLAY_ROTATION; + } + else if (strncmp(cmd, "u", 1) == 0 ) + { + get_display_rotation(); + } + else if (strncmp(cmd, "v", 1) == 0 ) + { + g_menu_state = CURRENT_STATUS_DISPLAY_VISIBLE; + } + else if (strncmp(cmd, "w", 1) == 0 ) + { + bool visible; + get_display_visible(&visible); + } + else if (strncmp(cmd, "A", 1) == 0 ) + { + g_menu_state=CURRENT_STATUS_SUBTITLE_FILENAME; + } + else if (strncmp(cmd, "C", 1) == 0 ) + { + capture_video(); + } + else if (strncmp(cmd, "D", 1) == 0 ) + { + decoding_audio(); + } + else if (strncmp(cmd, "E", 1) == 0 ) + { + decoding_video(); + } + else if (strncmp(cmd, "q", 1) == 0) + { + quit_pushing = TRUE; + quit_program(); + } + else + { + g_print("unknown menu \n"); + } + } + else if(len == 2) + { + if (strncmp(cmd, "pr", 2) == 0) + { + _player_prepare(); + } + else if (strncmp(cmd, "un", 2) == 0) + { + _player_unprepare(); + } + else if (strncmp(cmd, "sp", 2) == 0) + { + _player_set_progressive_download(); + } + else + { + g_print("unknown menu \n"); + } + } + else + { + g_print("unknown menu \n"); + } +} + +void display_sub_basic() +{ + int idx; + g_print("\n"); + g_print("=========================================================================================\n"); + g_print(" Player Test (press q to quit) \n"); + g_print("-----------------------------------------------------------------------------------------\n"); + g_print("*. Sample List in [%s]\n", MMTS_SAMPLELIST_INI_DEFAULT_PATH); + + for( idx = 1; idx <= INI_SAMPLE_LIST_MAX ; idx++ ) + { + if (strlen (g_file_list[idx-1]) > 0) + g_print("%d. Play [%s]\n", idx, g_file_list[idx-1]); + } + g_print("-----------------------------------------------------------------------------------------\n"); + g_print("[playback] a. Create\t"); + g_print("pr. Prepare \t"); + g_print("b. Play \t"); + g_print("c. Stop \t"); + g_print("d. Resume\t"); + g_print("e. Pause \t"); + g_print("un. Unprepare \n"); + g_print("[State] S. Player State \n"); + g_print("[ volume ] f. Set Volume\t"); + g_print("g. Get Volume\n"); + g_print("[ mute ] h. Set Mute\t"); + g_print("i. Get Mute\n"); + g_print("[position] j. Set Position (T)\t"); + g_print("k. Set Position (%%)\t"); + g_print("l. Get Position\n"); + g_print("[duration] m. Get Duration\n"); + g_print("[Stream Info] n. Get stream info (Video Size, codec, audio stream info, and tag info)\n"); + g_print("[Looping] o. Set Looping\t"); + g_print("p. Get Looping\n"); + g_print("[x display] r. Set display mode\t"); + g_print("s. Get display mode\t"); + g_print("t. Set display Rotation\t"); + g_print("u. Get display Rotation\n"); + g_print("[x display] v. Set display visible\t"); + g_print("w. Get display visible\n"); + g_print("[subtitle] A. Set subtitle path\n"); + g_print("[Video Capture] C. Capture \n"); + g_print("[Audio Frame Decode] D. Decoding Audio Frame E. Decoding Video Frame \n"); + g_print("[etc] sp. Set Progressive Download\n"); + g_print("\n"); + g_print("=========================================================================================\n"); +} + +static void displaymenu() +{ + if (g_menu_state == CURRENT_STATUS_MAINMENU) + { + display_sub_basic(); + } + else if (g_menu_state == CURRENT_STATUS_FILENAME) + { + g_print("*** input mediapath.\n"); + } + else if (g_menu_state == CURRENT_STATUS_VOLUME) + { + g_print("*** input volume value.(0~1.0)\n"); + } + else if (g_menu_state == CURRENT_STATUS_MUTE) + { + g_print("*** input mute value.(0: Not Mute, 1: Mute) \n"); + } + else if (g_menu_state == CURRENT_STATUS_POSITION_TIME) + { + g_print("*** input position value(msec)\n"); + } + else if (g_menu_state == CURRENT_STATUS_POSITION_PERCENT) + { + g_print("*** input position percent(%%)\n"); + } + else if (g_menu_state == CURRENT_STATUS_LOOPING) + { + g_print("*** input looping value.(0: Not Looping, 1: Looping) \n"); + } + else if (g_menu_state == CURRENT_STATUS_DISPLAY_MODE) + { + g_print("*** input display mode value.(0: LETTER BOX, 1: ORIGIN SIZE, 2: FULL_SCREEN, 3: CROPPED_FULL) \n"); + } + else if (g_menu_state == CURRENT_STATUS_DISPLAY_ROTATION) + { + g_print("*** input display rotation value.(0: NONE, 1: 90, 2: 180, 3: 270, 4:F LIP_HORZ, 5: FLIP_VERT ) \n"); + } + else if (g_menu_state == CURRENT_STATUS_DISPLAY_VISIBLE) + { + g_print("*** input display visible value.(0: HIDE, 1: SHOW) \n"); + } + else if (g_menu_state == CURRENT_STATUS_SUBTITLE_FILENAME) + { + g_print(" *** input subtitle file path.\n"); + } + else + { + g_print("*** unknown status.\n"); + quit_program(); + } + g_print(" >>> "); +} + +gboolean timeout_menu_display(void* data) +{ + displaymenu(); + return FALSE; +} + +gboolean timeout_quit_program(void* data) +{ + quit_program(); + return FALSE; +} + +void reset_menu_state(void) +{ + g_menu_state = CURRENT_STATUS_MAINMENU; +} + +static void interpret (char *cmd) +{ + switch (g_menu_state) + { + case CURRENT_STATUS_MAINMENU: + { + _interpret_main_menu(cmd); + } + break; + case CURRENT_STATUS_FILENAME: + { + input_filename(cmd); + reset_menu_state(); + } + break; + case CURRENT_STATUS_VOLUME: + { + float level = atof(cmd); + set_volume(level); + reset_menu_state(); + } + break; + case CURRENT_STATUS_MUTE: + { + int mute = atoi(cmd); + set_mute(mute); + reset_menu_state(); + } + break; + case CURRENT_STATUS_POSITION_TIME: + { + long position = atol(cmd); + set_position(position); + reset_menu_state(); + } + break; + case CURRENT_STATUS_POSITION_PERCENT: + { + long percent = atol(cmd); + set_position_ratio(percent); + reset_menu_state(); + } + break; + case CURRENT_STATUS_LOOPING: + { + int looping = atoi(cmd); + set_looping(looping); + reset_menu_state(); + } + break; + case CURRENT_STATUS_DISPLAY_MODE: + { + int mode = atoi(cmd); + set_display_mode(mode); + reset_menu_state(); + } + break; + case CURRENT_STATUS_DISPLAY_ROTATION: + { + int rotation = atoi(cmd); + set_display_rotation(rotation); + reset_menu_state(); + } + break; + case CURRENT_STATUS_DISPLAY_VISIBLE: + { + int visible = atoi(cmd); + set_display_visible(visible); + reset_menu_state(); + } + break; + case CURRENT_STATUS_SUBTITLE_FILENAME: + { + input_subtitle_filename(cmd); + reset_menu_state(); + } + break; + } + g_timeout_add(100, timeout_menu_display, 0); +} + +gboolean input (GIOChannel *channel) +{ + char buf[MAX_STRING_LEN + 3]; + gsize read; + + g_io_channel_read(channel, buf, MAX_STRING_LEN, &read); + buf[read] = '\0'; + g_strstrip(buf); + interpret (buf); + return TRUE; +} + +int main(int argc, char *argv[]) +{ + GIOChannel *stdin_channel; + stdin_channel = g_io_channel_unix_new(0); + g_io_add_watch(stdin_channel, G_IO_IN, (GIOFunc)input, NULL); + displaymenu(); + memset(&ad, 0x0, sizeof(struct appdata)); + ops.data = &ad; + + return appcore_efl_main(PACKAGE, &argc, &argv, &ops); +} +