-JongHyuk Choi <jhchoi.choi@samsung.com>
+Heechul Jeon <heechul.jeon@samsung.com>
-
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-SET(fw_name "muse-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 glib-2.0 libtbm mused legacy-capi-media-player mm-common tizen-extension-client evas")
-
-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./${INC_DIR} ${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror -Wno-error=deprecated-declarations")
-SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+# project
+SET(description "A Player module for muse server")
+SET(service "mmsvc")
+SET(submodule "player")
+SET(fw_name "${service}-${submodule}")
-IF("${ARCH}" STREQUAL "arm")
- ADD_DEFINITIONS("-DTARGET")
-ENDIF("${ARCH}" STREQUAL "arm")
-
-ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
-ADD_DEFINITIONS("-DTIZEN_DEBUG")
-IF (TIZEN_MOBILE)
-ADD_DEFINITIONS("-DTIZEN_MOBILE")
-ENDIF(TIZEN_MOBILE)
-IF(WAYLAND_SUPPORT)
- ADD_DEFINITIONS("-DHAVE_WAYLAND")
-ENDIF(WAYLAND_SUPPORT)
-IF(X11_SUPPORT)
- ADD_DEFINITIONS("-DHAVE_X11")
-ENDIF(X11_SUPPORT)
-
-SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${LIB_INSTALL_DIR}")
-
-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
-)
+PROJECT(${fw_name})
-INSTALL(TARGETS ${fw_name} DESTINATION ${LIB_INSTALL_DIR})
-INSTALL(
- DIRECTORY ${INC_DIR}/ DESTINATION include/media
- FILES_MATCHING
- PATTERN "*_private.h" EXCLUDE
- PATTERN "${INC_DIR}/*.h"
- )
+SET(pc_dependents "libtbm capi-media-tool capi-base-common capi-media-sound-manager")
SET(PC_NAME ${fw_name})
SET(PC_REQUIRED ${pc_dependents})
-SET(PC_LDFLAGS -l${fw_name})
-SET(PC_CFLAGS -I\${includedir}/media)
+SET(PC_LDFLAGS -lmuse-player)
CONFIGURE_FILE(
${fw_name}.pc.in
)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
-ADD_SUBDIRECTORY(client)
+ADD_SUBDIRECTORY(legacy)
+ADD_SUBDIRECTORY(muse)
IF(UNIX)
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.
+Please, see the LICENSE.APLv2 file for Apache License terms and conditions.
+++ /dev/null
-<manifest>
- <request>
- <domain name="_" />
- </request>
- <assign>
- <filesystem path="/usr/bin/player_test" label="_" exec_label="none" />
- </assign>
-</manifest>
+++ /dev/null
-JongHyuk Choi <jhchoi.choi@samsung.com>
+++ /dev/null
-
-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 elementary evas libtbm mm-common mm-playerclient capi-base-common capi-media-tool eom tizen-extension-client")
-SET(pc_dependents "libtbm capi-media-tool capi-base-common capi-media-sound-manager legacy-capi-media-player")
-
-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")
-IF (TIZEN_MOBILE)
-ADD_DEFINITIONS("-DTIZEN_MOBILE")
-ENDIF(TIZEN_MOBILE)
-IF(WAYLAND_SUPPORT)
- ADD_DEFINITIONS("-DHAVE_WAYLAND")
-ENDIF(WAYLAND_SUPPORT)
-IF(X11_SUPPORT)
- ADD_DEFINITIONS("-DHAVE_X11")
-ENDIF(X11_SUPPORT)
-
-SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${LIB_INSTALL_DIR}")
-
-
-aux_source_directory(src CLI_SOURCES)
-ADD_LIBRARY(${fw_name} SHARED ${CLI_SOURCES})
-
-TARGET_LINK_LIBRARIES(${fw_name} mused ${${fw_name}_LDFLAGS})
-
-SET_TARGET_PROPERTIES(${fw_name}
- PROPERTIES
- VERSION ${FULLVER}
- SOVERSION ${MAJORVER}
- CLEAN_DIRECT_OUTPUT 1
-)
-
-INSTALL(TARGETS ${fw_name} DESTINATION ${LIB_INSTALL_DIR})
-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_INSTALL_DIR}/pkgconfig)
-
-ADD_SUBDIRECTORY(test)
-
+++ /dev/null
-Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
-\r
- Apache License\r
- Version 2.0, January 2004\r
- http://www.apache.org/licenses/\r
-\r
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\r
-\r
- 1. Definitions.\r
-\r
- "License" shall mean the terms and conditions for use, reproduction,\r
- and distribution as defined by Sections 1 through 9 of this document.\r
-\r
- "Licensor" shall mean the copyright owner or entity authorized by\r
- the copyright owner that is granting the License.\r
-\r
- "Legal Entity" shall mean the union of the acting entity and all\r
- other entities that control, are controlled by, or are under common\r
- control with that entity. For the purposes of this definition,\r
- "control" means (i) the power, direct or indirect, to cause the\r
- direction or management of such entity, whether by contract or\r
- otherwise, or (ii) ownership of fifty percent (50%) or more of the\r
- outstanding shares, or (iii) beneficial ownership of such entity.\r
-\r
- "You" (or "Your") shall mean an individual or Legal Entity\r
- exercising permissions granted by this License.\r
-\r
- "Source" form shall mean the preferred form for making modifications,\r
- including but not limited to software source code, documentation\r
- source, and configuration files.\r
-\r
- "Object" form shall mean any form resulting from mechanical\r
- transformation or translation of a Source form, including but\r
- not limited to compiled object code, generated documentation,\r
- and conversions to other media types.\r
-\r
- "Work" shall mean the work of authorship, whether in Source or\r
- Object form, made available under the License, as indicated by a\r
- copyright notice that is included in or attached to the work\r
- (an example is provided in the Appendix below).\r
-\r
- "Derivative Works" shall mean any work, whether in Source or Object\r
- form, that is based on (or derived from) the Work and for which the\r
- editorial revisions, annotations, elaborations, or other modifications\r
- represent, as a whole, an original work of authorship. For the purposes\r
- of this License, Derivative Works shall not include works that remain\r
- separable from, or merely link (or bind by name) to the interfaces of,\r
- the Work and Derivative Works thereof.\r
-\r
- "Contribution" shall mean any work of authorship, including\r
- the original version of the Work and any modifications or additions\r
- to that Work or Derivative Works thereof, that is intentionally\r
- submitted to Licensor for inclusion in the Work by the copyright owner\r
- or by an individual or Legal Entity authorized to submit on behalf of\r
- the copyright owner. For the purposes of this definition, "submitted"\r
- means any form of electronic, verbal, or written communication sent\r
- to the Licensor or its representatives, including but not limited to\r
- communication on electronic mailing lists, source code control systems,\r
- and issue tracking systems that are managed by, or on behalf of, the\r
- Licensor for the purpose of discussing and improving the Work, but\r
- excluding communication that is conspicuously marked or otherwise\r
- designated in writing by the copyright owner as "Not a Contribution."\r
-\r
- "Contributor" shall mean Licensor and any individual or Legal Entity\r
- on behalf of whom a Contribution has been received by Licensor and\r
- subsequently incorporated within the Work.\r
-\r
- 2. Grant of Copyright License. Subject to the terms and conditions of\r
- this License, each Contributor hereby grants to You a perpetual,\r
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
- copyright license to reproduce, prepare Derivative Works of,\r
- publicly display, publicly perform, sublicense, and distribute the\r
- Work and such Derivative Works in Source or Object form.\r
-\r
- 3. Grant of Patent License. Subject to the terms and conditions of\r
- this License, each Contributor hereby grants to You a perpetual,\r
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
- (except as stated in this section) patent license to make, have made,\r
- use, offer to sell, sell, import, and otherwise transfer the Work,\r
- where such license applies only to those patent claims licensable\r
- by such Contributor that are necessarily infringed by their\r
- Contribution(s) alone or by combination of their Contribution(s)\r
- with the Work to which such Contribution(s) was submitted. If You\r
- institute patent litigation against any entity (including a\r
- cross-claim or counterclaim in a lawsuit) alleging that the Work\r
- or a Contribution incorporated within the Work constitutes direct\r
- or contributory patent infringement, then any patent licenses\r
- granted to You under this License for that Work shall terminate\r
- as of the date such litigation is filed.\r
-\r
- 4. Redistribution. You may reproduce and distribute copies of the\r
- Work or Derivative Works thereof in any medium, with or without\r
- modifications, and in Source or Object form, provided that You\r
- meet the following conditions:\r
-\r
- (a) You must give any other recipients of the Work or\r
- Derivative Works a copy of this License; and\r
-\r
- (b) You must cause any modified files to carry prominent notices\r
- stating that You changed the files; and\r
-\r
- (c) You must retain, in the Source form of any Derivative Works\r
- that You distribute, all copyright, patent, trademark, and\r
- attribution notices from the Source form of the Work,\r
- excluding those notices that do not pertain to any part of\r
- the Derivative Works; and\r
-\r
- (d) If the Work includes a "NOTICE" text file as part of its\r
- distribution, then any Derivative Works that You distribute must\r
- include a readable copy of the attribution notices contained\r
- within such NOTICE file, excluding those notices that do not\r
- pertain to any part of the Derivative Works, in at least one\r
- of the following places: within a NOTICE text file distributed\r
- as part of the Derivative Works; within the Source form or\r
- documentation, if provided along with the Derivative Works; or,\r
- within a display generated by the Derivative Works, if and\r
- wherever such third-party notices normally appear. The contents\r
- of the NOTICE file are for informational purposes only and\r
- do not modify the License. You may add Your own attribution\r
- notices within Derivative Works that You distribute, alongside\r
- or as an addendum to the NOTICE text from the Work, provided\r
- that such additional attribution notices cannot be construed\r
- as modifying the License.\r
-\r
- You may add Your own copyright statement to Your modifications and\r
- may provide additional or different license terms and conditions\r
- for use, reproduction, or distribution of Your modifications, or\r
- for any such Derivative Works as a whole, provided Your use,\r
- reproduction, and distribution of the Work otherwise complies with\r
- the conditions stated in this License.\r
-\r
- 5. Submission of Contributions. Unless You explicitly state otherwise,\r
- any Contribution intentionally submitted for inclusion in the Work\r
- by You to the Licensor shall be under the terms and conditions of\r
- this License, without any additional terms or conditions.\r
- Notwithstanding the above, nothing herein shall supersede or modify\r
- the terms of any separate license agreement you may have executed\r
- with Licensor regarding such Contributions.\r
-\r
- 6. Trademarks. This License does not grant permission to use the trade\r
- names, trademarks, service marks, or product names of the Licensor,\r
- except as required for reasonable and customary use in describing the\r
- origin of the Work and reproducing the content of the NOTICE file.\r
-\r
- 7. Disclaimer of Warranty. Unless required by applicable law or\r
- agreed to in writing, Licensor provides the Work (and each\r
- Contributor provides its Contributions) on an "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\r
- implied, including, without limitation, any warranties or conditions\r
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\r
- PARTICULAR PURPOSE. You are solely responsible for determining the\r
- appropriateness of using or redistributing the Work and assume any\r
- risks associated with Your exercise of permissions under this License.\r
-\r
- 8. Limitation of Liability. In no event and under no legal theory,\r
- whether in tort (including negligence), contract, or otherwise,\r
- unless required by applicable law (such as deliberate and grossly\r
- negligent acts) or agreed to in writing, shall any Contributor be\r
- liable to You for damages, including any direct, indirect, special,\r
- incidental, or consequential damages of any character arising as a\r
- result of this License or out of the use or inability to use the\r
- Work (including but not limited to damages for loss of goodwill,\r
- work stoppage, computer failure or malfunction, or any and all\r
- other commercial damages or losses), even if such Contributor\r
- has been advised of the possibility of such damages.\r
-\r
- 9. Accepting Warranty or Additional Liability. While redistributing\r
- the Work or Derivative Works thereof, You may choose to offer,\r
- and charge a fee for, acceptance of support, warranty, indemnity,\r
- or other liability obligations and/or rights consistent with this\r
- License. However, in accepting such obligations, You may act only\r
- on Your own behalf and on Your sole responsibility, not on behalf\r
- of any other Contributor, and only if You agree to indemnify,\r
- defend, and hold each Contributor harmless for any liability\r
- incurred by, or claims asserted against, such Contributor by reason\r
- of your accepting any such warranty or additional liability.\r
-\r
- END OF TERMS AND CONDITIONS\r
-\r
- APPENDIX: How to apply the Apache License to your work.\r
-\r
- To apply the Apache License to your work, attach the following\r
- boilerplate notice, with the fields enclosed by brackets "[]"\r
- replaced with your own identifying information. (Don't include\r
- the brackets!) The text should be enclosed in the appropriate\r
- comment syntax for the file format. We also recommend that a\r
- file or class name and description of purpose be included on the\r
- same "printed page" as the copyright notice for easier\r
- identification within third-party archives.\r
-\r
- Copyright [yyyy] [name of copyright owner]\r
-\r
- Licensed under the Apache License, Version 2.0 (the "License");\r
- you may not use this file except in compliance with the License.\r
- You may obtain a copy of the License at\r
-\r
- http://www.apache.org/licenses/LICENSE-2.0\r
-\r
- Unless required by applicable law or agreed to in writing, software\r
- distributed under the License is distributed on an "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- See the License for the specific language governing permissions and\r
- limitations under the License.\r
-\r
-\r
-\r
+++ /dev/null
-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.
+++ /dev/null
-
-# 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}
-
+++ /dev/null
-/*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include "glib.h"
-#include "tbm_bufmgr.h"
-#include "tbm_surface.h"
-#include "tbm_surface_internal.h"
-#include "Evas.h"
-#include "Elementary.h"
-#include "Ecore.h"
-#ifdef HAVE_WAYLAND
-#include "Ecore_Wayland.h"
-#endif
-#include "muse_core.h"
-#include "muse_core_msg_json.h"
-#include "muse_core_module.h"
-#include "muse_core_ipc.h"
-#include "player2_private.h"
-#include "player_msg_private.h"
-#include "player_internal.h"
-#include "sound_manager_internal.h"
-#include "mm_error.h"
-#include "mm_player.h"
-#include "mm_player_mused.h"
-#include "dlog.h"
-
-typedef struct {
- int int_data;
- char *buf;
- callback_cb_info_s *cb_info;
-} _player_cb_data;
-
-typedef struct {
- intptr_t remote_pkt;
- callback_cb_info_s *cb_info;
-} _media_pkt_fin_data;
-
-/*
- Global varialbe
-*/
-
-/*
-* Internal Implementation
-*/
-static int _player_deinit_memory_buffer(player_cli_s *pc);
-
-int _player_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
-{
- int ret = 0;
- tbm_surface_h tsurf = NULL;
- muse_player_api_e api = MUSE_PLAYER_API_MEDIA_PACKET_FINALIZE_CB;
- _media_pkt_fin_data *fin_data = (_media_pkt_fin_data *)user_data;
- intptr_t packet;
- char *sndMsg;
-
- if (pkt == NULL || user_data == NULL) {
- LOGE("invalid parameter buffer %p, user_data %p", pkt, user_data);
- return MEDIA_PACKET_FINALIZE;
- }
-
- ret = media_packet_get_tbm_surface(pkt, &tsurf);
- if (ret != MEDIA_PACKET_ERROR_NONE) {
- LOGE("media_packet_get_tbm_surface failed 0x%x", ret);
- return MEDIA_PACKET_FINALIZE;
- }
-
- if (tsurf) {
- tbm_surface_destroy(tsurf);
- tsurf = NULL;
- }
-
- packet = fin_data->remote_pkt;
- sndMsg = muse_core_msg_json_factory_new(api, MUSE_TYPE_POINTER, "packet", packet, 0);
- muse_core_ipc_send_msg(fin_data->cb_info->fd, sndMsg);
- muse_core_msg_json_factory_free(sndMsg);
-
- g_free(fin_data);
-
- return MEDIA_PACKET_FINALIZE;
-}
-
-static int __player_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:
- case MM_ERROR_PLAYER_AUDIO_CODEC_NOT_FOUND:
- case MM_ERROR_PLAYER_VIDEO_CODEC_NOT_FOUND:
- ret = PLAYER_ERROR_NONE;
- msg = "PLAYER_ERROR_NONE";
- break;
- case MM_ERROR_INVALID_ARGUMENT:
- ret = PLAYER_ERROR_INVALID_PARAMETER;
- msg = "PLAYER_ERROR_INVALID_PARAMETER";
- break;
- case MM_ERROR_PLAYER_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:
- ret = PLAYER_ERROR_INVALID_OPERATION;
- msg = "PLAYER_ERROR_INVALID_OPERATION";
- break;
- case MM_ERROR_PLAYER_SOUND_EFFECT_INVALID_STATUS:
- case MM_ERROR_NOT_SUPPORT_API:
- case MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER:
- ret = PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE;
- msg = "PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE";
- 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;
- case MM_ERROR_PLAYER_DRM_EXPIRED:
- ret = PLAYER_ERROR_DRM_EXPIRED;
- msg = "PLAYER_ERROR_DRM_EXPIRED";
- break;
- case MM_ERROR_PLAYER_DRM_NOT_AUTHORIZED:
- case MM_ERROR_PLAYER_DRM_NO_LICENSE:
- ret = PLAYER_ERROR_DRM_NO_LICENSE;
- msg = "PLAYER_ERROR_DRM_NO_LICENSE";
- break;
- case MM_ERROR_PLAYER_DRM_FUTURE_USE:
- ret = PLAYER_ERROR_DRM_FUTURE_USE;
- msg = "PLAYER_ERROR_DRM_FUTURE_USE";
- break;
- case MM_ERROR_PLAYER_DRM_OUTPUT_PROTECTION:
- ret = PLAYER_ERROR_DRM_NOT_PERMITTED;
- msg = "PLAYER_ERROR_DRM_NOT_PERMITTED";
- break;
- case MM_ERROR_PLAYER_RESOURCE_LIMIT:
- ret = PLAYER_ERROR_RESOURCE_LIMIT;
- msg = "PLAYER_ERROR_RESOURCE_LIMIT";
- break;
- case MM_ERROR_PLAYER_PERMISSION_DENIED:
- ret = PLAYER_ERROR_PERMISSION_DENIED;
- msg = "PLAYER_ERROR_PERMISSION_DENIED";
- }
- LOGE("[%s] %s(0x%08x) : core fw error(0x%x)", func_name, msg, ret, code);
- return ret;
-}
-
-static void *_get_mem(player_cli_s *player, int size)
-{
- player_data_s *mem = g_new(player_data_s, sizeof(player_data_s));
- if (mem) {
- mem->data = g_new(void, size);
- mem->next = player->head;
- player->head = mem;
- return mem->data;
- }
- return NULL;
-}
-
-static void _del_mem(player_cli_s *player)
-{
- player_data_s *mem;
- while (player->head) {
- mem = player->head->next;
- g_free(player->head->data);
- g_free(player->head);
- player->head = mem;
- }
-}
-
-static int player_recv_msg(callback_cb_info_s *cb_info, int len)
-{
- int recvLen;
- msg_buff_s *buff = &cb_info->buff;
- char *new;
-
- if (len && buff->bufLen - MUSE_MSG_MAX_LENGTH <= len) {
- LOGD("realloc Buffer %d -> %d, Msg Length %d", buff->bufLen, buff->bufLen + MUSE_MSG_MAX_LENGTH, len);
- buff->bufLen += MUSE_MSG_MAX_LENGTH;
- new = g_renew(char, buff->recvMsg, buff->bufLen);
- if (new && new != buff->recvMsg)
- buff->recvMsg = new;
- }
-
- recvLen = muse_core_ipc_recv_msg(cb_info->fd, buff->recvMsg + len);
- len += recvLen;
-
- return len;
-}
-
-static void set_null_user_cb(callback_cb_info_s *cb_info, _player_event_e event)
-{
- if (cb_info && event < _PLAYER_EVENT_TYPE_NUM) {
- cb_info->user_cb[event] = NULL;
- cb_info->user_data[event] = NULL;
- }
-}
-
-static void set_null_user_cb_lock(callback_cb_info_s *cb_info, _player_event_e event)
-{
- bool lock = g_thread_self() != cb_info->event_queue.thread;
-
- if (lock)
- g_mutex_lock(&cb_info->event_queue.mutex);
-
- set_null_user_cb(cb_info, event);
-
- if (lock)
- g_mutex_unlock(&cb_info->event_queue.mutex);
-}
-
-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);
- int ret = PLAYER_ERROR_NONE;
- player_cli_s *pc = (player_cli_s *)player;
- muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
- int set = 1;
-
- LOGI("Event type : %d ", type);
- player_msg_set_callback(api, pc, ret, type, set);
-
- if (ret == PLAYER_ERROR_NONE) {
- pc->cb_info->user_cb[type] = callback;
- pc->cb_info->user_data[type] = user_data;
- }
- return ret;
-}
-
-static int __unset_callback(_player_event_e type, player_h player)
-{
- PLAYER_INSTANCE_CHECK(player);
- int ret = PLAYER_ERROR_NONE;
- player_cli_s *pc = (player_cli_s *)player;
- muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
- int set = 0;
-
- LOGI("Event type : %d ", type);
-
- PLAYER_NULL_ARG_CHECK(CALLBACK_INFO(pc));
- set_null_user_cb_lock(CALLBACK_INFO(pc), type);
-
- player_msg_set_callback(api, pc, ret, type, set);
- ret = PLAYER_ERROR_NONE;
-
- return ret;
-}
-
-static void __prepare_cb_handler(callback_cb_info_s *cb_info, char *recvMsg)
-{
- _player_event_e ev = _PLAYER_EVENT_TYPE_PREPARE;
-
- ((player_prepared_cb)cb_info->user_cb[ev])(cb_info->user_data[ev]);
-
- set_null_user_cb(cb_info, ev);
-}
-
-static void __complete_cb_handler(callback_cb_info_s *cb_info, char *recvMsg)
-{
- _player_event_e ev = _PLAYER_EVENT_TYPE_COMPLETE;
- ((player_completed_cb)cb_info->user_cb[ev])(cb_info->user_data[ev]);
-}
-
-static void __interrupt_cb_handler(callback_cb_info_s *cb_info, char *recvMsg)
-{
- int code;
- _player_event_e ev = _PLAYER_EVENT_TYPE_INTERRUPT;
-
- if (player_msg_get(code, recvMsg))
- ((player_interrupted_cb)cb_info->user_cb[ev])(code, cb_info->user_data[ev]);
-}
-
-static void __error_cb_handler(callback_cb_info_s *cb_info, char *recvMsg)
-{
- int code;
- _player_event_e ev = _PLAYER_EVENT_TYPE_ERROR;
-
- if (player_msg_get(code, recvMsg))
- ((player_error_cb)cb_info->user_cb[ev])(code, cb_info->user_data[ev]);
-}
-
-static void __buffering_cb_handler(callback_cb_info_s *cb_info, char *recvMsg)
-{
- int percent;
- _player_event_e ev = _PLAYER_EVENT_TYPE_BUFFERING;
-
- if (player_msg_get(percent, recvMsg))
- ((player_buffering_cb)cb_info->user_cb[ev])(percent, cb_info->user_data[ev]);
-}
-
-static void __subtitle_cb_handler(callback_cb_info_s *cb_info, char *recvMsg)
-{
- int duration = 0;
- char text[MUSE_URI_MAX_LENGTH];
- _player_event_e ev = _PLAYER_EVENT_TYPE_SUBTITLE;
-
- if (player_msg_get(duration, recvMsg)
- && player_msg_get_string(text, recvMsg)) {
- ((player_subtitle_updated_cb)cb_info->user_cb[ev])(duration, text, cb_info->user_data[ev]);
- }
-}
-
-static void __capture_cb_handler(callback_cb_info_s *cb_info, char *recvMsg)
-{
- unsigned char *data = NULL;
- int width = 0;
- int height = 0;
- unsigned int size = 0;
- tbm_bo bo;
- tbm_bo_handle thandle;
- tbm_key key;
-
- if (player_msg_get(width, recvMsg) && player_msg_get(height, recvMsg)
- && player_msg_get(size, recvMsg)) {
- if (!player_msg_get(key, recvMsg))
- goto capture_event_exit1;
-
- bo = tbm_bo_import(cb_info->bufmgr, key);
- if (bo == NULL) {
- LOGE("TBM get error : bo is NULL");
- goto capture_event_exit1;
- }
- thandle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_WRITE | TBM_OPTION_READ);
- if (thandle.ptr == NULL) {
- LOGE("TBM get error : handle pointer is NULL");
- goto capture_event_exit2;
- }
- data = g_new(unsigned char, size);
- if (data) {
- memcpy(data, thandle.ptr, size);
- ((player_video_captured_cb)cb_info->user_cb[_PLAYER_EVENT_TYPE_CAPTURE])(data, width, height, size, cb_info->user_data[_PLAYER_EVENT_TYPE_CAPTURE]);
- g_free(data);
- } else
- LOGE("g_new failure");
-
- /* mark to read */
- *((char *)thandle.ptr + size) = 0;
-
- tbm_bo_unmap(bo);
-capture_event_exit2:
- tbm_bo_unref(bo);
- }
-capture_event_exit1:
- set_null_user_cb(cb_info, _PLAYER_EVENT_TYPE_CAPTURE);
-}
-
-static void __seek_cb_handler(callback_cb_info_s *cb_info, char *recvMsg)
-{
- _player_event_e ev = _PLAYER_EVENT_TYPE_SEEK;
-
- ((player_seek_completed_cb)cb_info->user_cb[ev])(cb_info->user_data[ev]);
-
- set_null_user_cb(cb_info, ev);
-}
-
-static void __media_packet_video_frame_cb_handler(callback_cb_info_s *cb_info, char *recvMsg)
-{
- tbm_bo bo[4] = { NULL, };
- tbm_key key[4] = { 0, };
- tbm_surface_info_s sinfo;
- char *surface_info = (char *)&sinfo;
- media_packet_h pkt = NULL;
- tbm_surface_h tsurf = NULL;
- int bo_num = 0;
- media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
- bool make_pkt_fmt = false;
- int ret;
- _media_pkt_fin_data *fin_data;
- intptr_t packet;
- uint64_t pts = 0;
- int i;
-
- player_msg_get(key[0], recvMsg);
- player_msg_get(key[1], recvMsg);
- player_msg_get(key[2], recvMsg);
- player_msg_get(key[3], recvMsg);
- player_msg_get_type(packet, recvMsg, POINTER);
- player_msg_get(mimetype, recvMsg);
- player_msg_get_type(pts, recvMsg, INT64);
- player_msg_get_array(surface_info, recvMsg);
-
- LOGD("width %d, height %d", sinfo.width, sinfo.height);
-
- for (i = 0; i < 4; i++) {
- if (key[i]) {
- bo_num++;
- bo[i] = tbm_bo_import(cb_info->bufmgr, key[i]);
- }
- }
-
- tsurf = tbm_surface_internal_create_with_bos(&sinfo, bo, bo_num);
- if (tsurf) {
- /* check media packet format */
- if (cb_info->pkt_fmt) {
- int pkt_fmt_width = 0;
- int pkt_fmt_height = 0;
- media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
-
- media_format_get_video_info(cb_info->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
- if (pkt_fmt_mimetype != mimetype || pkt_fmt_width != sinfo.width || pkt_fmt_height != sinfo.height) {
- LOGW("different format. current 0x%x, %dx%d, new 0x%x, %dx%d", pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height, mimetype, sinfo.width, sinfo.height);
- media_format_unref(cb_info->pkt_fmt);
- cb_info->pkt_fmt = NULL;
- make_pkt_fmt = true;
- }
- } else {
- make_pkt_fmt = true;
- }
- /* create packet format */
- if (make_pkt_fmt) {
- LOGI("make new pkt_fmt - mimetype 0x%x, %dx%d", mimetype, sinfo.width, sinfo.height);
- ret = media_format_create(&cb_info->pkt_fmt);
- if (ret == MEDIA_FORMAT_ERROR_NONE) {
- ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
- ret |= media_format_set_video_width(cb_info->pkt_fmt, sinfo.width);
- ret |= media_format_set_video_height(cb_info->pkt_fmt, sinfo.height);
- LOGI("media_format_set_video_mime,width,height ret : 0x%x", ret);
- } else {
- LOGE("media_format_create failed");
- }
- }
-
- fin_data = g_new(_media_pkt_fin_data, 1);
- fin_data->remote_pkt = packet;
- fin_data->cb_info = cb_info;
- ret = media_packet_create_from_tbm_surface(cb_info->pkt_fmt, tsurf, (media_packet_finalize_cb)_player_media_packet_finalize, (void *)fin_data, &pkt);
- if (ret != MEDIA_PACKET_ERROR_NONE) {
- LOGE("media_packet_create_from_tbm_surface failed");
- tbm_surface_destroy(tsurf);
- tsurf = NULL;
- }
- }
- if (pkt) {
- if (pts != 0) {
- ret = media_packet_set_pts(pkt, (uint64_t)pts);
- if (ret != MEDIA_PACKET_ERROR_NONE)
- LOGE("media_packet_set_pts failed");
- }
- /* call media packet callback */
- ((player_media_packet_video_decoded_cb)cb_info->user_cb[_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME])(pkt, cb_info->user_data[_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME]);
- }
- for (i = 0; i < bo_num; i++) {
- if (bo[i])
- tbm_bo_unref(bo[i]);
- }
-}
-
-static void __audio_frame_cb_handler(callback_cb_info_s *cb_info, char *recvMsg)
-{
- unsigned char *data = NULL;
- unsigned int size = 0;
- tbm_bo bo;
- tbm_bo_handle thandle;
- tbm_key key;
- player_audio_raw_data_s audio;
- void *audio_frame = &audio;
-
- if (player_msg_get_array(audio_frame, recvMsg) && player_msg_get(size, recvMsg)) {
- if (!player_msg_get(key, recvMsg))
- return;
-
- bo = tbm_bo_import(cb_info->bufmgr, key);
- if (bo == NULL) {
- LOGE("TBM get error : bo is NULL");
- return;
- }
- thandle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_WRITE | TBM_OPTION_READ);
- if (thandle.ptr == NULL) {
- LOGE("TBM get error : handle pointer is NULL");
- tbm_bo_unref(bo);
- return;
- }
- data = g_new(unsigned char, size);
- if (data) {
- memcpy(data, thandle.ptr, size);
- audio.data = data;
- audio.size = size;
- LOGD("user callback data %p, size %d", audio.data, audio.size);
- ((player_audio_pcm_extraction_cb)cb_info->user_cb[_PLAYER_EVENT_TYPE_AUDIO_FRAME])(&audio, cb_info->user_data[_PLAYER_EVENT_TYPE_AUDIO_FRAME]);
- g_free(data);
- } else
- LOGE("g_new failure");
-
- /* mark to read */
- *((char *)thandle.ptr + size) = 0;
- LOGD("Fin");
-
- tbm_bo_unmap(bo);
- tbm_bo_unref(bo);
- }
-}
-
-static void __video_frame_render_error_cb_handler(callback_cb_info_s *cb_info, char *recvMsg)
-{
-}
-
-static void __pd_cb_handler(callback_cb_info_s *cb_info, char *recvMsg)
-{
- int type;
- _player_event_e ev = _PLAYER_EVENT_TYPE_PD;
-
- if (player_msg_get(type, recvMsg))
- ((player_pd_message_cb)cb_info->user_cb[ev])(type, cb_info->user_data[ev]);
-}
-
-static void __supported_audio_effect_cb_handler(callback_cb_info_s *cb_info, char *recvMsg)
-{
-}
-
-static void __supported_audio_effect_freset_cb_handler(callback_cb_info_s *cb_info, char *recvMsg)
-{
-}
-
-static void __missed_plugin_cb_handler(callback_cb_info_s *cb_info, char *recvMsg)
-{
-}
-
-static void __media_stream_video_buffer_cb_handler(callback_cb_info_s *cb_info, char *recvMsg)
-{
- /* player_media_stream_buffer_status_e status; */
- int status;
-
- if (player_msg_get(status, recvMsg)) {
- ((player_media_stream_buffer_status_cb)
- cb_info->user_cb[_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS])((player_media_stream_buffer_status_e)status, cb_info->user_data[_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS]);
- }
-}
-
-static void __media_stream_audio_buffer_cb_handler(callback_cb_info_s *cb_info, char *recvMsg)
-{
- /* player_media_stream_buffer_status_e status; */
- int status;
-
- if (player_msg_get(status, recvMsg)) {
- ((player_media_stream_buffer_status_cb)
- cb_info->user_cb[_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS])
- ((player_media_stream_buffer_status_e)status, cb_info->user_data[_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS]);
- }
-
-}
-
-static void __media_stream_video_buffer_cb_handler_ex(callback_cb_info_s *cb_info, char *recvMsg)
-{
- /* player_media_stream_buffer_status_e status; */
- int status;
- unsigned long long bytes;
-
- if (player_msg_get(status, recvMsg) && player_msg_get_type(bytes, recvMsg, INT64)) {
- ((player_media_stream_buffer_status_cb_ex)
- cb_info->user_cb[_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO])
- ((player_media_stream_buffer_status_e)status, bytes, cb_info->user_data[_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO]);
- }
-}
-
-static void __media_stream_audio_buffer_cb_handler_ex(callback_cb_info_s *cb_info, char *recvMsg)
-{
- /* player_media_stream_buffer_status_e status; */
- int status;
- unsigned long long bytes;
-
- if (player_msg_get(status, recvMsg) && player_msg_get_type(bytes, recvMsg, INT64)) {
- ((player_media_stream_buffer_status_cb_ex)
- cb_info->user_cb[_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO])
- ((player_media_stream_buffer_status_e)status, bytes, cb_info->user_data[_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO]);
- }
-
-}
-
-static void __media_stream_video_seek_cb_handler(callback_cb_info_s *cb_info, char *recvMsg)
-{
- unsigned long long offset;
-
- if (player_msg_get_type(offset, recvMsg, INT64)) {
- ((player_media_stream_seek_cb)
- cb_info->user_cb[_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK])
- (offset, cb_info->user_data[_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK]);
- }
-}
-
-static void __media_stream_audio_seek_cb_handler(callback_cb_info_s *cb_info, char *recvMsg)
-{
- unsigned long long offset;
-
- if (player_msg_get_type(offset, recvMsg, INT64)) {
- ((player_media_stream_seek_cb)
- cb_info->user_cb[_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK])
- (offset, cb_info->user_data[_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK]);
- }
-}
-
-static void __video_stream_changed_cb_handler(callback_cb_info_s *cb_info, char *recvMsg)
-{
- int width;
- int height;
- int fps;
- int bit_rate;
- if (player_msg_get(width, recvMsg)
- && player_msg_get(height, recvMsg)
- && player_msg_get(fps, recvMsg)
- && player_msg_get(bit_rate, recvMsg)) {
- ((player_video_stream_changed_cb)cb_info->user_cb[_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED])
- (width, height, fps, bit_rate, cb_info->user_data[_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED]);
- }
-}
-
-static void (*_user_callbacks[_PLAYER_EVENT_TYPE_NUM])(callback_cb_info_s *cb_info, char *recvMsg) = {
- __prepare_cb_handler, /*_PLAYER_EVENT_TYPE_PREPARE*/
- __complete_cb_handler, /*_PLAYER_EVENT_TYPE_COMPLETE*/
- __interrupt_cb_handler, /*_PLAYER_EVENT_TYPE_INTERRUPT*/
- __error_cb_handler, /*_PLAYER_EVENT_TYPE_ERROR*/
- __buffering_cb_handler, /*_PLAYER_EVENT_TYPE_BUFFERING*/
- __subtitle_cb_handler, /*_PLAYER_EVENT_TYPE_SUBTITLE*/
- __capture_cb_handler, /*_PLAYER_EVENT_TYPE_CAPTURE*/
- __seek_cb_handler, /*_PLAYER_EVENT_TYPE_SEEK*/
- __media_packet_video_frame_cb_handler, /*_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME*/
- __audio_frame_cb_handler, /*_PLAYER_EVENT_TYPE_AUDIO_FRAME*/
- __video_frame_render_error_cb_handler, /*_PLAYER_EVENT_TYPE_VIDEO_FRAME_RENDER_ERROR*/
- __pd_cb_handler, /*_PLAYER_EVENT_TYPE_PD*/
- __supported_audio_effect_cb_handler, /*_PLAYER_EVENT_TYPE_SUPPORTED_AUDIO_EFFECT*/
- __supported_audio_effect_freset_cb_handler, /*_PLAYER_EVENT_TYPE_SUPPORTED_AUDIO_EFFECT_PRESET*/
- __missed_plugin_cb_handler, /*_PLAYER_EVENT_TYPE_MISSED_PLUGIN*/
-#ifdef _PLAYER_FOR_PRODUCT
- NULL, /*_PLAYER_EVENT_TYPE_IMAGE_BUFFER*/
- NULL, /*_PLAYER_EVENT_TYPE_SELECTED_SUBTITLE_LANGUAGE*/
-#endif
- __media_stream_video_buffer_cb_handler, /*_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS*/
- __media_stream_audio_buffer_cb_handler, /*_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS*/
- __media_stream_video_buffer_cb_handler_ex, /*_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO*/
- __media_stream_audio_buffer_cb_handler_ex, /*_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO*/
- __media_stream_video_seek_cb_handler, /*_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK*/
- __media_stream_audio_seek_cb_handler, /*_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK*/
- NULL, /*_PLAYER_EVENT_TYPE_AUDIO_STREAM_CHANGED*/
- __video_stream_changed_cb_handler, /*_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED*/
-};
-
-static void _player_event_job_function(_player_cb_data *data)
-{
- _player_event_e ev = data->int_data;
- if (data->cb_info->user_cb[ev])
- _user_callbacks[ev] (data->cb_info, data->buf);
- else
- LOGW("user callback is unset. type : %d", ev);
-
- g_free(data->buf);
- g_free(data);
-}
-
-static void *_player_event_queue_loop(void *param)
-{
- if (!param) {
- LOGE("NULL parameter");
- return NULL;
- }
- callback_cb_info_s *cb_info = param;
- player_event_queue *ev = &cb_info->event_queue;
- _player_cb_data *event_data;
-
- g_mutex_lock(&ev->mutex);
- while (ev->running) {
- g_mutex_lock(&ev->qlock);
- if (g_queue_is_empty(ev->queue)) {
- g_mutex_unlock(&ev->qlock);
- g_cond_wait(&ev->cond, &ev->mutex);
- if (!ev->running)
- break;
- } else
- g_mutex_unlock(&ev->qlock);
-
- while (1) {
- g_mutex_lock(&ev->qlock);
- event_data = (_player_cb_data *)g_queue_pop_head(ev->queue);
- g_mutex_unlock(&ev->qlock);
- if (event_data)
- _player_event_job_function(event_data);
- else
- break;
- }
- }
- g_mutex_unlock(&ev->mutex);
- LOGI("Exit event loop");
- return NULL;
-}
-
-static gboolean _player_event_queue_new(callback_cb_info_s *cb_info)
-{
- g_return_val_if_fail(cb_info, FALSE);
- player_event_queue *ev = &cb_info->event_queue;
-
- ev->queue = g_queue_new();
- g_return_val_if_fail(ev->queue, FALSE);
- g_mutex_init(&ev->qlock);
-
- g_mutex_init(&ev->mutex);
- g_cond_init(&ev->cond);
- ev->running = TRUE;
- ev->thread = g_thread_new("cb_event_thread", _player_event_queue_loop, (gpointer)cb_info);
- g_return_val_if_fail(ev->thread, FALSE);
- LOGI("event queue thread %p", ev->thread);
-
- return TRUE;
-
-}
-
-static void _player_event_queue_destroy(callback_cb_info_s *cb_info)
-{
- g_return_if_fail(cb_info);
- player_event_queue *ev = &cb_info->event_queue;
- _player_cb_data *event_data;
-
- LOGI("event queue thread %p", ev->thread);
-
- g_mutex_lock(&ev->mutex);
- ev->running = FALSE;
- g_cond_broadcast(&ev->cond);
- g_mutex_unlock(&ev->mutex);
-
- g_thread_join(ev->thread);
- g_thread_unref(ev->thread);
-
- while (!g_queue_is_empty(ev->queue)) {
- event_data = (_player_cb_data *)g_queue_pop_head(ev->queue);
- if (event_data) {
- g_free(event_data->buf);
- g_free(event_data);
- }
- }
- g_queue_free(ev->queue);
- g_mutex_clear(&ev->qlock);
- g_mutex_clear(&ev->mutex);
- g_cond_clear(&ev->cond);
-
-}
-
-static void _player_event_queue_add(player_event_queue *ev, _player_cb_data *data)
-{
- if (ev->running) {
- g_mutex_lock(&ev->qlock);
- g_queue_push_tail(ev->queue, (gpointer)data);
- g_mutex_unlock(&ev->qlock);
- g_cond_signal(&ev->cond);
- }
-}
-
-static void _user_callback_handler(callback_cb_info_s *cb_info, _player_event_e event, char *buffer)
-{
- LOGD("get event %d", event);
-
- if (event < _PLAYER_EVENT_TYPE_NUM) {
- if (cb_info->user_cb[event] && _user_callbacks[event]) {
- _player_cb_data *data = NULL;
- data = g_new(_player_cb_data, 1);
- if (!data) {
- LOGE("fail to alloc mem");
- return;
- }
- data->int_data = (int)event;
- data->cb_info = cb_info;
- data->buf = buffer;
- _player_event_queue_add(&cb_info->event_queue, data);
- }
- }
-}
-
-static void _add_ret_msg(muse_player_api_e api, callback_cb_info_s *cb_info, int offset, int parse_len)
-{
- ret_msg_s *msg = NULL;
- ret_msg_s *last = cb_info->buff.retMsgHead;
-
- msg = g_new(ret_msg_s, 1);
- if (msg) {
- msg->api = api;
- msg->msg = strndup(cb_info->buff.recvMsg + offset, parse_len);
- msg->next = NULL;
- if (last == NULL)
- cb_info->buff.retMsgHead = msg;
- else {
- while (last->next)
- last = last->next;
- last->next = msg;
- }
- } else
- LOGE("g_new failure");
-}
-
-static ret_msg_s *_get_ret_msg(muse_player_api_e api, callback_cb_info_s *cb_info)
-{
- ret_msg_s *msg = cb_info->buff.retMsgHead;
- ret_msg_s *prev = NULL;
- while (msg) {
- if (msg->api == api) {
- if (!prev)
- cb_info->buff.retMsgHead = msg->next;
- else
- prev->next = msg->next;
- return msg;
- }
- prev = msg;
- msg = msg->next;
- }
- return NULL;
-}
-
-static void _notify_disconnected(callback_cb_info_s *cb_info)
-{
- int code = PLAYER_ERROR_SERVICE_DISCONNECTED;
- _player_event_e ev = _PLAYER_EVENT_TYPE_ERROR;
- if (!cb_info || !cb_info->user_cb[ev])
- return;
- ((player_error_cb) cb_info->user_cb[ev]) (code, cb_info->user_data[ev]);
-}
-
-static void *client_cb_handler(gpointer data)
-{
- int api;
- int len = 0;
- int parse_len = 0;
- int offset = 0;
- callback_cb_info_s *cb_info = data;
- char *recvMsg = cb_info->buff.recvMsg;
- muse_core_msg_parse_err_e err;
-
- while (g_atomic_int_get(&cb_info->running)) {
- len = 0;
- err = MUSE_MSG_PARSE_ERROR_NONE;
- do {
- len = player_recv_msg(cb_info, len);
- if (len <= 0)
- break;
- recvMsg[len] = '\0';
- parse_len = len;
- offset = 0;
- while (offset < len) {
- api = MUSE_PLAYER_API_MAX;
- if (player_msg_get_error_e(api, recvMsg + offset, parse_len, err)) {
- if (api < MUSE_PLAYER_API_MAX) {
- g_mutex_lock(&cb_info->player_mutex);
- cb_info->buff.recved++;
- _add_ret_msg(api, cb_info, offset, parse_len);
- g_cond_signal(&cb_info->player_cond[api]);
- g_mutex_unlock(&cb_info->player_mutex);
- if (api == MUSE_PLAYER_API_DESTROY)
- g_atomic_int_set(&cb_info->running, 0);
- } else if (api == MUSE_PLAYER_CB_EVENT) {
- int event;
- char *buffer;
- g_mutex_lock(&cb_info->player_mutex);
- buffer = strndup(recvMsg + offset, parse_len);
- g_mutex_unlock(&cb_info->player_mutex);
- if (player_msg_get(event, buffer))
- _user_callback_handler(cb_info, event, buffer);
- }
- }
- if (parse_len == 0)
- break;
- offset += parse_len;
- parse_len = len - parse_len;
- }
- } while (err == MUSE_MSG_PARSE_ERROR_CONTINUE);
- if (len <= 0)
- break;
- }
- if (g_atomic_int_get(&cb_info->running))
- _notify_disconnected(cb_info);
- LOGD("client cb exit");
-
- return NULL;
-}
-
-static callback_cb_info_s *callback_new(gint sockfd)
-{
- callback_cb_info_s *cb_info;
- msg_buff_s *buff;
- int i;
-
- g_return_val_if_fail(sockfd > 0, NULL);
-
- cb_info = g_new(callback_cb_info_s, 1);
- memset(cb_info, 0, sizeof(callback_cb_info_s));
-
- g_mutex_init(&cb_info->player_mutex);
- for (i = 0; i < MUSE_PLAYER_API_MAX; i++)
- g_cond_init(&cb_info->player_cond[i]);
-
- buff = &cb_info->buff;
- buff->recvMsg = g_new(char, MUSE_MSG_MAX_LENGTH + 1);
- buff->bufLen = MUSE_MSG_MAX_LENGTH + 1;
- buff->recved = 0;
- buff->retMsgHead = NULL;
-
- g_atomic_int_set(&cb_info->running, 1);
- cb_info->fd = sockfd;
- cb_info->thread = g_thread_new("callback_thread", client_cb_handler, (gpointer)cb_info);
-
- return cb_info;
-}
-
-static void callback_destroy(callback_cb_info_s *cb_info)
-{
- int i;
- g_return_if_fail(cb_info);
-
- muse_core_connection_close(cb_info->fd);
- muse_core_connection_close(cb_info->data_fd);
-
- g_thread_join(cb_info->thread);
- g_thread_unref(cb_info->thread);
-
- LOGI("%p Callback destroyed", cb_info->thread);
-
- g_mutex_clear(&cb_info->player_mutex);
- for (i = 0; i < MUSE_PLAYER_API_MAX; i++)
- g_cond_clear(&cb_info->player_cond[i]);
-
- g_free(cb_info->buff.recvMsg);
- g_free(cb_info);
-}
-
-int _get_api_timeout(player_cli_s *pc, muse_player_api_e api)
-{
- int timeout = 0;
-
- switch (api) {
- case MUSE_PLAYER_API_PREPARE:
- case MUSE_PLAYER_API_PREPARE_ASYNC:
- case MUSE_PLAYER_API_UNPREPARE:
- case MUSE_PLAYER_API_START:
- case MUSE_PLAYER_API_STOP:
- case MUSE_PLAYER_API_PAUSE:
- timeout += SERVER_TIMEOUT(pc);
- break;
- default:
- /* check prepare async is done */
- if (pc && CALLBACK_INFO(pc) && CALLBACK_INFO(pc)->user_cb[_PLAYER_EVENT_TYPE_PREPARE])
- timeout += SERVER_TIMEOUT(pc);
- break;
- }
- timeout += CALLBACK_TIME_OUT;
- return timeout;
-}
-
-int wait_for_cb_return(muse_player_api_e api, callback_cb_info_s *cb_info, char **ret_buf, int time_out)
-{
- int ret = PLAYER_ERROR_NONE;
- gint64 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
- msg_buff_s *buff = &cb_info->buff;
- ret_msg_s *msg = NULL;
-
- g_mutex_lock(&cb_info->player_mutex);
-
- msg = _get_ret_msg(api, cb_info);
- if (!buff->recved || !msg) {
- if (!g_cond_wait_until(&cb_info->player_cond[api], &cb_info->player_mutex, end_time)) {
- LOGW("api %d return msg does not received %ds", api, time_out);
- g_mutex_unlock(&cb_info->player_mutex);
- return PLAYER_ERROR_INVALID_OPERATION;
- }
- }
- if (!msg)
- msg = _get_ret_msg(api, cb_info);
- if (msg) {
- *ret_buf = msg->msg;
- g_free(msg);
- if (!player_msg_get(ret, *ret_buf))
- ret = PLAYER_ERROR_INVALID_OPERATION;
- } else {
- LOGE("api %d return msg is not exist", api);
- ret = PLAYER_ERROR_INVALID_OPERATION;
- }
- buff->recved--;
-
- g_mutex_unlock(&cb_info->player_mutex);
-
- return ret;
-}
-
-/*
-* Public Implementation
-*/
-
-int player_create(player_h *player)
-{
- PLAYER_INSTANCE_CHECK(player);
-
- int ret = PLAYER_ERROR_NONE;
- int sock_fd = -1;
- int pid = getpid();
-
- muse_player_api_e api = MUSE_PLAYER_API_CREATE;
- muse_core_api_module_e module = MUSE_PLAYER;
- player_cli_s *pc = NULL;
- char *ret_buf = NULL;
-
- LOGD("ENTER");
-
- sock_fd = muse_core_client_new();
- if (sock_fd < 0) {
- LOGE("connection failure %d", errno);
- ret = PLAYER_ERROR_INVALID_OPERATION;
- goto ErrorExit;
- }
- player_msg_create_handle(api, sock_fd, INT, module, INT, pid);
-
- pc = g_new0(player_cli_s, 1);
- if (pc == NULL) {
- ret = PLAYER_ERROR_OUT_OF_MEMORY;
- goto ErrorExit;
- }
-
- pc->cb_info = callback_new(sock_fd);
- if (!pc->cb_info) {
- LOGE("fail to create callback");
- ret = PLAYER_ERROR_INVALID_OPERATION;
- goto ErrorExit;
- }
- if (!_player_event_queue_new(pc->cb_info)) {
- LOGE("fail to create event queue");
- ret = PLAYER_ERROR_INVALID_OPERATION;
- goto ErrorExit;
- }
-
- ret = wait_for_cb_return(api, pc->cb_info, &ret_buf, CALLBACK_TIME_OUT);
- if (ret == PLAYER_ERROR_NONE) {
- intptr_t module_addr;
- *player = (player_h)pc;
- if (player_msg_get_type(module_addr, ret_buf, POINTER)) {
- pc->cb_info->data_fd = muse_core_client_new_data_ch();
- muse_core_send_client_addr(module_addr, pc->cb_info->data_fd);
- LOGD("Data channel fd %d, muse module addr %p", pc->cb_info->data_fd, module_addr);
- }
- } else
- goto ErrorExit;
-
- pc->cb_info->bufmgr = tbm_bufmgr_init(-1);
-
- g_free(ret_buf);
- return ret;
-
-ErrorExit:
- if (pc && pc->cb_info) {
- if (pc->cb_info->event_queue.running)
- _player_event_queue_destroy(pc->cb_info);
- callback_destroy(pc->cb_info);
- pc->cb_info = NULL;
- }
- g_free(pc);
- g_free(ret_buf);
- LOGD("ret value : %d", ret);
- return ret;
-}
-
-int player_destroy(player_h player)
-{
- PLAYER_INSTANCE_CHECK(player);
-
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_DESTROY;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
-
- LOGD("ENTER");
-
- player_msg_send(api, pc, ret_buf, ret);
-
- if(player_unset_evas_object_cb(player) != MM_ERROR_NONE)
- LOGW("fail to unset evas object callback");
-
- if (CALLBACK_INFO(pc)) {
- _player_event_queue_destroy(CALLBACK_INFO(pc));
- tbm_bufmgr_deinit(TBM_BUFMGR(pc));
-
- callback_destroy(CALLBACK_INFO(pc));
- }
-
- g_free(pc);
- pc = NULL;
-
- g_free(ret_buf);
- return ret;
-}
-
-int player_prepare_async(player_h player, player_prepared_cb callback, void *user_data)
-{
- PLAYER_INSTANCE_CHECK(player);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_PREPARE_ASYNC;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
-
- LOGD("ENTER");
-
- if (pc->cb_info->user_cb[_PLAYER_EVENT_TYPE_PREPARE]) {
- LOGE("PLAYER_ERROR_INVALID_OPERATION (0x%08x) : preparing...", PLAYER_ERROR_INVALID_OPERATION);
- return PLAYER_ERROR_INVALID_OPERATION;
- } else {
- pc->cb_info->user_cb[_PLAYER_EVENT_TYPE_PREPARE] = callback;
- pc->cb_info->user_data[_PLAYER_EVENT_TYPE_PREPARE] = user_data;
- }
- player_msg_send(api, pc, ret_buf, ret);
-
- g_free(ret_buf);
- return ret;
-}
-
-int player_prepare(player_h player)
-{
- PLAYER_INSTANCE_CHECK(player);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_PREPARE;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
-
- LOGD("ENTER");
-
- player_msg_send(api, pc, ret_buf, ret);
-
- g_free(ret_buf);
- return ret;
-}
-
-int player_unprepare(player_h player)
-{
- PLAYER_INSTANCE_CHECK(player);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_UNPREPARE;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
-
- LOGD("ENTER");
-
- if (!CALLBACK_INFO(pc))
- return PLAYER_ERROR_INVALID_STATE;
-
- player_msg_send(api, pc, ret_buf, ret);
- if (ret == PLAYER_ERROR_NONE) {
- set_null_user_cb_lock(pc->cb_info, _PLAYER_EVENT_TYPE_SEEK);
- set_null_user_cb_lock(pc->cb_info, _PLAYER_EVENT_TYPE_PREPARE);
- _del_mem(pc);
- _player_deinit_memory_buffer(pc);
- }
-
- g_free(ret_buf);
- return ret;
-}
-
-int player_set_uri(player_h player, const char *uri)
-{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(uri);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_SET_URI;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
-
- LOGD("ENTER");
-
- player_msg_send1(api, pc, ret_buf, ret, STRING, uri);
-
- g_free(ret_buf);
- return ret;
-}
-
-int player_set_memory_buffer(player_h player, const void *data, int size)
-{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(data);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_SET_MEMORY_BUFFER;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
- tbm_bo bo;
- tbm_bo_handle thandle;
- tbm_key key;
-
- if (SERVER_TBM_BO(pc)) {
- LOGE("Already set the memory buffer. unprepare please");
- return PLAYER_ERROR_INVALID_OPERATION;
- }
-
- bo = tbm_bo_alloc(pc->cb_info->bufmgr, size, TBM_BO_DEFAULT);
- if (bo == NULL) {
- LOGE("TBM get error : bo is NULL");
- return PLAYER_ERROR_INVALID_OPERATION;
- }
- thandle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_WRITE);
- if (thandle.ptr == NULL) {
- LOGE("TBM get error : handle pointer is NULL");
- ret = PLAYER_ERROR_INVALID_OPERATION;
- goto set_memory_exit;
- }
- memcpy(thandle.ptr, data, size);
- tbm_bo_unmap(bo);
-
- key = tbm_bo_export(bo);
- if (key == 0) {
- LOGE("TBM get error : key is 0");
- ret = PLAYER_ERROR_INVALID_OPERATION;
- goto set_memory_exit;
- }
-
- player_msg_send2(api, pc, ret_buf, ret, INT, key, INT, size);
-
- set_memory_exit:
- tbm_bo_unref(bo);
-
- if (ret == PLAYER_ERROR_NONE) {
- intptr_t bo_addr = 0;
- if (player_msg_get_type(bo_addr, ret_buf, POINTER))
- SERVER_TBM_BO(pc) = (intptr_t)bo_addr;
- }
-
- g_free(ret_buf);
- return ret;
-}
-
-static int _player_deinit_memory_buffer(player_cli_s *pc)
-{
- PLAYER_INSTANCE_CHECK(pc);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_DEINIT_MEMORY_BUFFER;
- intptr_t bo_addr = SERVER_TBM_BO(pc);
-
- if (!bo_addr)
- return ret;
-
- player_msg_send1_async(api, pc, POINTER, bo_addr);
- SERVER_TBM_BO(pc) = 0;
-
- return ret;
-}
-
-int player_get_state(player_h player, player_state_e *pstate)
-{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(pstate);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_GET_STATE;
- player_cli_s *pc = (player_cli_s *)player;
- int state;
- char *ret_buf = NULL;
-
- LOGD("ENTER");
-
- player_msg_send(api, pc, ret_buf, ret);
-
- if (ret == PLAYER_ERROR_NONE) {
- player_msg_get(state, ret_buf);
- *pstate = state;
- }
-
- g_free(ret_buf);
- return ret;
-}
-
-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");
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_SET_VOLUME;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
-
- LOGD("ENTER");
-
- player_msg_send2(api, pc, ret_buf, ret, DOUBLE, right, DOUBLE, left);
- g_free(ret_buf);
- return ret;
-}
-
-int player_get_volume(player_h player, float *pleft, float *pright)
-{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(pleft);
- PLAYER_NULL_ARG_CHECK(pright);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_GET_VOLUME;
- player_cli_s *pc = (player_cli_s *)player;
- double left = -1;
- double right = -1;
- char *ret_buf = NULL;
-
- LOGD("ENTER");
-
- player_msg_send(api, pc, ret_buf, ret);
-
- if (ret == PLAYER_ERROR_NONE) {
- player_msg_get_type(left, ret_buf, DOUBLE);
- player_msg_get_type(right, ret_buf, DOUBLE);
- *pleft = (float)left;
- *pright = (float)right;
- }
-
- g_free(ret_buf);
- return ret;
-}
-
-int player_set_sound_type(player_h player, sound_type_e type)
-{
- PLAYER_INSTANCE_CHECK(player);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_SET_SOUND_TYPE;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
-
- LOGD("ENTER");
-
- player_msg_send1(api, pc, ret_buf, ret, INT, type);
- g_free(ret_buf);
- return ret;
-}
-
-int player_set_audio_policy_info(player_h player, sound_stream_info_h stream_info)
-{
- PLAYER_INSTANCE_CHECK(player);
-
- muse_player_api_e api = MUSE_PLAYER_API_SET_AUDIO_POLICY_INFO;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
-
- LOGD("ENTER");
-
- bool is_available = false;
-
- /* check if stream_info is valid */
- int ret = __player_convert_error_code(
- sound_manager_is_available_stream_information(
- stream_info, NATIVE_API_PLAYER, &is_available), (char *)__FUNCTION__);
-
- if (ret == PLAYER_ERROR_NONE) {
- if (is_available == false)
- ret = PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE;
- else {
- char *stream_type = NULL;
- int stream_index = 0;
- ret = sound_manager_get_type_from_stream_information(stream_info, &stream_type);
- ret = sound_manager_get_index_from_stream_information(stream_info, &stream_index);
- if (ret == SOUND_MANAGER_ERROR_NONE)
- player_msg_send2(api, pc, ret_buf, ret, STRING, stream_type, INT, stream_index);
- else
- ret = PLAYER_ERROR_INVALID_OPERATION;
- }
- }
-
- g_free(ret_buf);
- return ret;
-
-}
-
-int player_set_audio_latency_mode(player_h player, audio_latency_mode_e latency_mode)
-{
- PLAYER_INSTANCE_CHECK(player);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_SET_AUDIO_LATENCY_MODE;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
-
- LOGD("ENTER");
-
- player_msg_send1(api, pc, ret_buf, ret, INT, latency_mode);
- g_free(ret_buf);
- return ret;
-}
-
-int player_get_audio_latency_mode(player_h player, audio_latency_mode_e *platency_mode)
-{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(platency_mode);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_GET_AUDIO_LATENCY_MODE;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
- int latency_mode = -1;
-
- LOGD("ENTER");
-
- player_msg_send(api, pc, ret_buf, ret);
-
- if (ret == PLAYER_ERROR_NONE) {
- player_msg_get(latency_mode, ret_buf);
- *platency_mode = latency_mode;
- }
-
- g_free(ret_buf);
- return ret;
-
-}
-
-int player_start(player_h player)
-{
- PLAYER_INSTANCE_CHECK(player);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_START;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
-
- LOGD("ENTER");
-
- player_msg_send(api, pc, ret_buf, ret);
-
- g_free(ret_buf);
- return ret;
-}
-
-int player_stop(player_h player)
-{
- PLAYER_INSTANCE_CHECK(player);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_STOP;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
-
- LOGD("ENTER");
-
- player_msg_send(api, pc, ret_buf, ret);
- if (ret == PLAYER_ERROR_NONE)
- set_null_user_cb_lock(pc->cb_info, _PLAYER_EVENT_TYPE_SEEK);
-
- g_free(ret_buf);
- return ret;
-}
-
-int player_pause(player_h player)
-{
- PLAYER_INSTANCE_CHECK(player);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_PAUSE;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
-
- LOGD("ENTER");
-
- player_msg_send(api, pc, ret_buf, ret);
- g_free(ret_buf);
- return ret;
-}
-
-int player_set_play_position(player_h player, int millisecond, bool accurate, 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");
-
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_SET_PLAY_POSITION;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
- int pos = millisecond;
-
- LOGD("ENTER");
-
- if (pc->cb_info->user_cb[_PLAYER_EVENT_TYPE_SEEK]) {
- LOGE("PLAYER_ERROR_SEEK_FAILED (0x%08x) : seeking...", PLAYER_ERROR_SEEK_FAILED);
- return PLAYER_ERROR_SEEK_FAILED;
- } else {
- LOGI("Event type : %d, pos : %d ", _PLAYER_EVENT_TYPE_SEEK, millisecond);
- pc->cb_info->user_cb[_PLAYER_EVENT_TYPE_SEEK] = callback;
- pc->cb_info->user_data[_PLAYER_EVENT_TYPE_SEEK] = user_data;
- }
-
- player_msg_send2(api, pc, ret_buf, ret, INT, pos, INT, accurate);
-
- if (ret != PLAYER_ERROR_NONE)
- set_null_user_cb(pc->cb_info, _PLAYER_EVENT_TYPE_SEEK);
-
- g_free(ret_buf);
- return ret;
-
-}
-
-int player_get_play_position(player_h player, int *millisecond)
-{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(millisecond);
-
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_GET_PLAY_POSITION;
- player_cli_s *pc = (player_cli_s *)player;
- int pos;
- char *ret_buf = NULL;
-
- LOGD("ENTER");
-
- player_msg_send(api, pc, ret_buf, ret);
-
- if (ret == PLAYER_ERROR_NONE) {
- player_msg_get(pos, ret_buf);
- *millisecond = pos;
- }
-
- g_free(ret_buf);
- return ret;
-}
-
-int player_set_mute(player_h player, bool muted)
-{
- PLAYER_INSTANCE_CHECK(player);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_SET_MUTE;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
- int mute = (int)muted;
-
- LOGD("ENTER");
-
- player_msg_send1(api, pc, ret_buf, ret, INT, mute);
- g_free(ret_buf);
- return ret;
-}
-
-int player_is_muted(player_h player, bool * muted)
-{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(muted);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_IS_MUTED;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
- int mute = -1;
-
- LOGD("ENTER");
-
- player_msg_send(api, pc, ret_buf, ret);
- if (ret == PLAYER_ERROR_NONE) {
- player_msg_get(mute, ret_buf);
- *muted = (bool) mute;
- }
-
- g_free(ret_buf);
- return ret;
-}
-
-int player_set_looping(player_h player, bool looping)
-{
- PLAYER_INSTANCE_CHECK(player);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_SET_LOOPING;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
-
- LOGD("ENTER");
-
- player_msg_send1(api, pc, ret_buf, ret, INT, looping);
- g_free(ret_buf);
- return ret;
-}
-
-int player_is_looping(player_h player, bool *plooping)
-{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(plooping);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_IS_LOOPING;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
- int looping = 0;
-
- LOGD("ENTER");
-
- player_msg_send(api, pc, ret_buf, ret);
- if (ret == PLAYER_ERROR_NONE) {
- player_msg_get(looping, ret_buf);
- *plooping = looping;
- }
- g_free(ret_buf);
- return ret;
-}
-
-int player_get_duration(player_h player, int *pduration)
-{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(pduration);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_GET_DURATION;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
- int duration = 0;
-
- LOGD("ENTER");
-
- player_msg_send(api, pc, ret_buf, ret);
- if (ret == PLAYER_ERROR_NONE) {
- player_msg_get(duration, ret_buf);
- *pduration = duration;
- }
-
- g_free(ret_buf);
- return ret;
-}
-
-int player_set_display(player_h player, player_display_type_e type, player_display_h display)
-{
- PLAYER_INSTANCE_CHECK(player);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_SET_DISPLAY;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
- Evas_Object *obj = NULL;
- const char *object_type = NULL;
-#ifdef HAVE_WAYLAND
- wl_win_msg_type wl_win;
- char *wl_win_msg = (char *)&wl_win;
- unsigned int wl_surface_id;
- struct wl_surface *wl_surface;
- struct wl_display *wl_display;
- Ecore_Wl_Window *wl_window = NULL;
-#else
- unsigned int xhandle = 0;
-#endif
-
- LOGD("ENTER");
-
- if (type != PLAYER_DISPLAY_TYPE_NONE) {
- obj = (Evas_Object *)display;
- if (!obj)
- return PLAYER_ERROR_INVALID_PARAMETER;
-
- object_type = evas_object_type_get(obj);
- if (object_type) {
- if (type == PLAYER_DISPLAY_TYPE_OVERLAY && !strcmp(object_type, "elm_win")) {
-#ifdef HAVE_WAYLAND
- /* wayland overlay surface */
- LOGI("Wayland overlay surface type");
- wl_win.type = type;
-
- evas_object_geometry_get(obj, &wl_win.wl_window_x, &wl_win.wl_window_y, &wl_win.wl_window_width, &wl_win.wl_window_height);
-
- if(player_set_evas_object_cb(player, obj) != MM_ERROR_NONE){
- LOGW("fail to set evas object callback");
- }
-
- wl_window = elm_win_wl_window_get(obj);
- wl_surface = (struct wl_surface *) ecore_wl_window_surface_get(wl_window);
-
- /* get wl_display */
- wl_display = (struct wl_display *) ecore_wl_display_get();
-
- if (!pc->wlclient) {
- ret = _wlclient_create(&pc->wlclient);
- if ( ret != MM_ERROR_NONE) {
- LOGE("Wayland client create failure");
- return ret;
- }
- }
- if (wl_surface && wl_display){
- LOGD ("surface = %p, wl_display = %p", wl_surface, wl_display);
- wl_surface_id = _wlclient_get_wl_window_wl_surface_id (pc->wlclient, wl_surface, wl_display);
- LOGD ("wl_surface_id = %d", wl_surface_id);
- wl_win.wl_surface_id = wl_surface_id;
- LOGD ("wl_win.wl_surface_id = %d", wl_win.wl_surface_id);
- }
- if (pc->wlclient) {
- g_free(pc->wlclient);
- pc->wlclient = NULL;
- }
-#else
- /* x window overlay surface */
- LOGI("overlay surface type");
- xhandle = elm_win_xwindow_get(obj);
-#endif
- }
-#ifdef TIZEN_MOBILE
- else if (type == PLAYER_DISPLAY_TYPE_EVAS && !strcmp(object_type, "image")) {
- /* evas object surface */
- LOGI("evas surface type");
- wl_win.type = type;
-
- evas_object_geometry_get(obj, &wl_win.wl_window_x, &wl_win.wl_window_y,
- &wl_win.wl_window_width, &wl_win.wl_window_height);
- }
-#endif
- else
- return PLAYER_ERROR_INVALID_PARAMETER;
- } else
- return PLAYER_ERROR_INVALID_PARAMETER;
- }
-#ifdef HAVE_WAYLAND
- else { /* PLAYER_DISPLAY_TYPE_NONE */
- LOGI("Wayland surface type is NONE");
- wl_win.type = type;
- wl_win.wl_window_x = 0;
- wl_win.wl_window_y = 0;
- wl_win.wl_window_width = 0;
- wl_win.wl_window_height = 0;
- }
- player_msg_send_array(api, pc, ret_buf, ret, wl_win_msg, sizeof(wl_win_msg_type), sizeof(char));
-#else
- player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, xhandle);
-#endif
-
- g_free(ret_buf);
- return ret;
-}
-
-int player_set_display_mode(player_h player, player_display_mode_e mode)
-{
- PLAYER_INSTANCE_CHECK(player);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_SET_DISPLAY_MODE;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
-
- LOGD("ENTER");
- player_msg_send1(api, pc, ret_buf, ret, INT, mode);
- g_free(ret_buf);
- return ret;
-}
-
-int player_get_display_mode(player_h player, player_display_mode_e *pmode)
-{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(pmode);
- int ret = PLAYER_ERROR_NONE;
- player_cli_s *pc = (player_cli_s *)player;
- int mode = -1;
-
- LOGD("ENTER");
-
- ret = mm_player_get_attribute(INT_HANDLE(pc), NULL, "display_method", &mode, NULL);
- if (ret != MM_ERROR_NONE)
- return __player_convert_error_code(ret, (char *)__FUNCTION__);
-
- *pmode = mode;
- return ret;
-}
-
-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");
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_SET_PLAYBACK_RATE;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
-
- LOGD("ENTER");
-
- player_msg_send1(api, pc, ret_buf, ret, DOUBLE, rate);
- g_free(ret_buf);
- return ret;
-}
-
-int player_set_display_rotation(player_h player, player_display_rotation_e rotation)
-{
- PLAYER_INSTANCE_CHECK(player);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_SET_DISPLAY_ROTATION;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
-
- LOGD("ENTER");
- player_msg_send1(api, pc, ret_buf, ret, INT, rotation);
- g_free(ret_buf);
- return ret;
-}
-
-int player_get_display_rotation(player_h player, player_display_rotation_e *protation)
-{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(protation);
- int ret = PLAYER_ERROR_NONE;
- player_cli_s *pc = (player_cli_s *)player;
- int rotation = -1;
-
- LOGD("ENTER");
-
- ret = mm_player_get_attribute(INT_HANDLE(pc), NULL, "display_rotation", &rotation, NULL);
- if (ret != MM_ERROR_NONE)
- return __player_convert_error_code(ret, (char *)__FUNCTION__);
-
- *protation = rotation;
-
- return ret;
-}
-
-int player_set_display_visible(player_h player, bool visible)
-{
- PLAYER_INSTANCE_CHECK(player);
- int ret = PLAYER_ERROR_NONE;
-#if 0
- player_cli_s *pc = (player_cli_s *)player;
- int value = 0;
-
- LOGD("ENTER");
- if (visible == TRUE)
- value = 1;
- ret = mm_player_set_attribute(INT_HANDLE(pc), NULL, "display_visible", value, NULL);
- if (ret != MM_ERROR_NONE)
- return __player_convert_error_code(ret, (char *)__FUNCTION__);
-#endif
- return ret;
-}
-
-int player_is_display_visible(player_h player, bool *pvisible)
-{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(pvisible);
- int ret = PLAYER_ERROR_NONE;
- player_cli_s *pc = (player_cli_s *)player;
- int value = 0;
-
- LOGD("ENTER");
-
- ret = mm_player_get_attribute(INT_HANDLE(pc), NULL, "display_visible", &value, NULL);
- if (ret != MM_ERROR_NONE)
- return __player_convert_error_code(ret, (char *)__FUNCTION__);
- else {
- if (value)
- *pvisible = TRUE;
- else
- *pvisible = FALSE;
- }
- return ret;
-}
-
-int player_get_content_info(player_h player, player_content_info_e key, char **pvalue)
-{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(pvalue);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_GET_CONTENT_INFO;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
- char value[MUSE_MSG_MAX_LENGTH] = {0, };
-
- LOGD("ENTER");
-
- player_msg_send1(api, pc, ret_buf, ret, INT, key);
- if (ret == PLAYER_ERROR_NONE) {
- player_msg_get_string(value, ret_buf);
- *pvalue = strndup(value, MUSE_MSG_MAX_LENGTH);
- }
- g_free(ret_buf);
- return ret;
-}
-
-int player_get_codec_info(player_h player, char **paudio_codec, char **pvideo_codec)
-{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(paudio_codec);
- PLAYER_NULL_ARG_CHECK(pvideo_codec);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_GET_CODEC_INFO;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
- char video_codec[MUSE_MSG_MAX_LENGTH] = {0, };
- char audio_codec[MUSE_MSG_MAX_LENGTH] = {0, };
-
- LOGD("ENTER");
-
- player_msg_send(api, pc, ret_buf, ret);
- if (ret == PLAYER_ERROR_NONE) {
- player_msg_get_string(video_codec, ret_buf);
- player_msg_get_string(audio_codec, ret_buf);
- *pvideo_codec = strndup(video_codec, MUSE_MSG_MAX_LENGTH);
- *paudio_codec = strndup(audio_codec, MUSE_MSG_MAX_LENGTH);
- }
- g_free(ret_buf);
- return ret;
-}
-
-int player_get_audio_stream_info(player_h player, int *psample_rate, int *pchannel, int *pbit_rate)
-{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(psample_rate);
- PLAYER_NULL_ARG_CHECK(pchannel);
- PLAYER_NULL_ARG_CHECK(pbit_rate);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_GET_AUDIO_STREAM_INFO;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
- int sample_rate = 0;
- int channel = 0;
- int bit_rate = 0;
-
- LOGD("ENTER");
-
- player_msg_send(api, pc, ret_buf, ret);
- if (ret == PLAYER_ERROR_NONE) {
- player_msg_get(sample_rate, ret_buf);
- player_msg_get(channel, ret_buf);
- player_msg_get(bit_rate, ret_buf);
- *psample_rate = sample_rate;
- *pchannel = channel;
- *pbit_rate = bit_rate;
- }
- g_free(ret_buf);
- return ret;
-}
-
-int player_get_video_stream_info(player_h player, int *pfps, int *pbit_rate)
-{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(pfps);
- PLAYER_NULL_ARG_CHECK(pbit_rate);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_GET_VIDEO_STREAM_INFO;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
- int fps = 0;
- int bit_rate = 0;
-
- LOGD("ENTER");
-
- player_msg_send(api, pc, ret_buf, ret);
- if (ret == PLAYER_ERROR_NONE) {
- player_msg_get(fps, ret_buf);
- player_msg_get(bit_rate, ret_buf);
- *pfps = fps;
- *pbit_rate = bit_rate;
- }
- g_free(ret_buf);
- return ret;
-}
-
-int player_get_video_size(player_h player, int *pwidth, int *pheight)
-{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(pwidth);
- PLAYER_NULL_ARG_CHECK(pheight);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_GET_VIDEO_SIZE;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
- int width = 0;
- int height = 0;
-
- LOGD("ENTER");
-
- player_msg_send(api, pc, ret_buf, ret);
- if (ret == PLAYER_ERROR_NONE) {
- player_msg_get(width, ret_buf);
- player_msg_get(height, ret_buf);
- *pwidth = width;
- *pheight = height;
- }
- g_free(ret_buf);
- return ret;
-}
-
-int player_get_album_art(player_h player, void **palbum_art, int *psize)
-{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(palbum_art);
- PLAYER_NULL_ARG_CHECK(psize);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_GET_ALBUM_ART;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
- char *album_art;
- int size = 0;
-
- LOGD("ENTER");
-
- player_msg_send(api, pc, ret_buf, ret);
- if (ret == PLAYER_ERROR_NONE) {
- player_msg_get(size, ret_buf);
- if (size > 0) {
- album_art = _get_mem(pc, size);
- player_msg_get_array(album_art, ret_buf);
- *palbum_art = album_art;
- } else
- *palbum_art = NULL;
-
- *psize = size;
- }
- g_free(ret_buf);
- return ret;
-}
-
-int player_audio_effect_get_equalizer_bands_count(player_h player, int *pcount)
-{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(pcount);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_BANDS_COUNT;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
- int count;
-
- LOGD("ENTER");
-
- player_msg_send(api, pc, ret_buf, ret);
- if (ret == PLAYER_ERROR_NONE) {
- player_msg_get(count, ret_buf);
- *pcount = count;
- }
- g_free(ret_buf);
- return ret;
-}
-
-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);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_SET_EQUALIZER_ALL_BANDS;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
-
- LOGD("ENTER");
-
- player_msg_send_array(api, pc, ret_buf, ret, band_levels, length, sizeof(int));
-
- g_free(ret_buf);
- return ret;
-
-}
-
-int player_audio_effect_set_equalizer_band_level(player_h player, int index, int level)
-{
- PLAYER_INSTANCE_CHECK(player);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_SET_EQUALIZER_BAND_LEVEL;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
-
- LOGD("ENTER");
-
- player_msg_send2(api, pc, ret_buf, ret, INT, index, INT, level);
-
- g_free(ret_buf);
- return ret;
-}
-
-int player_audio_effect_get_equalizer_band_level(player_h player, int index, int *plevel)
-{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(plevel);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_BAND_LEVEL;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
- int level;
-
- LOGD("ENTER");
-
- player_msg_send1(api, pc, ret_buf, ret, INT, index);
- if (ret == PLAYER_ERROR_NONE) {
- player_msg_get(level, ret_buf);
- *plevel = level;
- }
- g_free(ret_buf);
- return ret;
-}
-
-int player_audio_effect_get_equalizer_level_range(player_h player, int *pmin, int *pmax)
-{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(pmin);
- PLAYER_NULL_ARG_CHECK(pmax);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_LEVEL_RANGE;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
- int min, max;
-
- LOGD("ENTER");
-
- player_msg_send(api, pc, ret_buf, ret);
- if (ret == PLAYER_ERROR_NONE) {
- player_msg_get(min, ret_buf);
- player_msg_get(max, ret_buf);
- *pmin = min;
- *pmax = max;
- }
- g_free(ret_buf);
- return ret;
-}
-
-int player_audio_effect_get_equalizer_band_frequency(player_h player, int index, int *pfrequency)
-{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(pfrequency);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_BAND_FREQUENCY;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
- int frequency;
-
- LOGD("ENTER");
-
- player_msg_send1(api, pc, ret_buf, ret, INT, index);
- if (ret == PLAYER_ERROR_NONE) {
- player_msg_get(frequency, ret_buf);
- *pfrequency = frequency;
- }
- g_free(ret_buf);
- return ret;
-}
-
-int player_audio_effect_get_equalizer_band_frequency_range(player_h player, int index, int *prange)
-{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(prange);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_BAND_FREQUENCY_RANGE;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
- int range;
-
- LOGD("ENTER");
-
- player_msg_send1(api, pc, ret_buf, ret, INT, index);
- if (ret == PLAYER_ERROR_NONE) {
- player_msg_get(range, ret_buf);
- *prange = range;
- }
- g_free(ret_buf);
- return ret;
-}
-
-int player_audio_effect_equalizer_clear(player_h player)
-{
- PLAYER_INSTANCE_CHECK(player);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_EQUALIZER_CLEAR;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
-
- LOGD("ENTER");
-
- player_msg_send(api, pc, ret_buf, ret);
- g_free(ret_buf);
- return ret;
-}
-
-int player_audio_effect_equalizer_is_available(player_h player, bool * pavailable)
-{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(pavailable);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_EQUALIZER_IS_AVAILABLE;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
- int available;
-
- LOGD("ENTER");
-
- player_msg_send(api, pc, ret_buf, ret);
- if (ret == PLAYER_ERROR_NONE) {
- player_msg_get(available, ret_buf);
- *pavailable = available;
- }
- g_free(ret_buf);
- return ret;
-}
-
-int player_set_subtitle_path(player_h player, const char *path)
-{
- PLAYER_INSTANCE_CHECK(player);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_SET_SUBTITLE_PATH;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
-
- LOGD("ENTER");
-
- player_msg_send1(api, pc, ret_buf, ret, STRING, path);
- g_free(ret_buf);
- return ret;
-}
-
-int player_set_subtitle_position_offset(player_h player, int millisecond)
-{
- PLAYER_INSTANCE_CHECK(player);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_SET_SUBTITLE_POSITION_OFFSET;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
-
- LOGD("ENTER");
-
- player_msg_send1(api, pc, ret_buf, ret, INT, millisecond);
-
- g_free(ret_buf);
- return ret;
-}
-
-int player_set_progressive_download_path(player_h player, const char *path)
-{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(path);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_SET_PROGRESSIVE_DOWNLOAD_PATH;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
-
- LOGD("ENTER");
-
- player_msg_send1(api, pc, ret_buf, ret, STRING, path);
- g_free(ret_buf);
- return ret;
-}
-
-int player_get_progressive_download_status(player_h player, unsigned long *pcurrent, unsigned long *ptotal_size)
-{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(pcurrent);
- PLAYER_NULL_ARG_CHECK(ptotal_size);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_GET_PROGRESSIVE_DOWNLOAD_STATUS;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
- unsigned long current, total_size;
-
- LOGD("ENTER");
-
- player_msg_send(api, pc, ret_buf, ret);
- if (ret == PLAYER_ERROR_NONE) {
- player_msg_get_type(current, ret_buf, POINTER);
- player_msg_get_type(total_size, ret_buf, POINTER);
- *pcurrent = current;
- *ptotal_size = total_size;
- }
- g_free(ret_buf);
- return ret;
-
-}
-
-int player_capture_video(player_h player, player_video_captured_cb callback, void *user_data)
-{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(callback);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_CAPTURE_VIDEO;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
-
- LOGD("ENTER");
- if (pc->cb_info->user_cb[_PLAYER_EVENT_TYPE_CAPTURE]) {
- LOGE("PLAYER_ERROR_VIDEO_CAPTURE_FAILED (0x%08x) : capturing...", PLAYER_ERROR_VIDEO_CAPTURE_FAILED);
- return PLAYER_ERROR_VIDEO_CAPTURE_FAILED;
- } else {
- LOGI("Event type : %d ", _PLAYER_EVENT_TYPE_CAPTURE);
- pc->cb_info->user_cb[_PLAYER_EVENT_TYPE_CAPTURE] = callback;
- pc->cb_info->user_data[_PLAYER_EVENT_TYPE_CAPTURE] = user_data;
- }
-
- player_msg_send(api, pc, ret_buf, ret);
-
- if (ret != PLAYER_ERROR_NONE)
- set_null_user_cb(pc->cb_info, _PLAYER_EVENT_TYPE_CAPTURE);
-
- g_free(ret_buf);
- return ret;
-}
-
-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");
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_SET_STREAMING_COOKIE;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
-
- LOGD("ENTER");
-
- player_msg_send2(api, pc, ret_buf, ret, STRING, cookie, INT, size);
- g_free(ret_buf);
- return ret;
-}
-
-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");
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_SET_STREAMING_COOKIE;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
-
- LOGD("ENTER");
-
- player_msg_send2(api, pc, ret_buf, ret, STRING, user_agent, INT, size);
- g_free(ret_buf);
- return ret;
-}
-
-int player_get_streaming_download_progress(player_h player, int *pstart, int *pcurrent)
-{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(pstart);
- PLAYER_NULL_ARG_CHECK(pcurrent);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_GET_STREAMING_DOWNLOAD_PROGRESS;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
- int start, current;
-
- LOGD("ENTER");
-
- player_msg_send(api, pc, ret_buf, ret);
- if (ret == PLAYER_ERROR_NONE) {
- player_msg_get(start, ret_buf);
- player_msg_get(current, ret_buf);
- *pstart = start;
- *pcurrent = current;
- }
- g_free(ret_buf);
- return ret;
-
-}
-
-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_progressive_download_message_cb(player_h player, player_pd_message_cb callback, void *user_data)
-{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(callback);
- int ret = PLAYER_ERROR_NONE;
- player_cli_s *pc = (player_cli_s *)player;
- muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
- char *ret_buf = NULL;
- _player_event_e type = _PLAYER_EVENT_TYPE_PD;
- int set = 1;
-
- LOGD("ENTER");
-
- player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, set);
-
- if (ret == PLAYER_ERROR_NONE) {
- pc->cb_info->user_cb[type] = callback;
- pc->cb_info->user_data[type] = user_data;
- LOGI("Event type : %d ", type);
- }
-
- g_free(ret_buf);
- return ret;
-}
-
-int player_unset_progressive_download_message_cb(player_h player)
-{
- PLAYER_INSTANCE_CHECK(player);
- int ret = PLAYER_ERROR_NONE;
- player_cli_s *pc = (player_cli_s *)player;
- muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
- char *ret_buf = NULL;
- _player_event_e type = _PLAYER_EVENT_TYPE_PD;
- int set = 0;
-
- LOGD("ENTER");
-
- set_null_user_cb_lock(pc->cb_info, type);
-
- player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, set);
-
- g_free(ret_buf);
- return ret;
-
-}
-
-int player_set_media_packet_video_frame_decoded_cb(player_h player, player_media_packet_video_decoded_cb callback, void *user_data)
-{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(callback);
- int ret = PLAYER_ERROR_NONE;
- player_cli_s *pc = (player_cli_s *)player;
- muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
- char *ret_buf = NULL;
- _player_event_e type = _PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME;
- int set = 1;
-
- LOGD("ENTER");
-
- player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, set);
-
- if (ret == PLAYER_ERROR_NONE) {
- pc->cb_info->user_cb[_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME] = callback;
- pc->cb_info->user_data[_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME] = user_data;
- LOGI("Event type : %d ", _PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME);
- }
-
- g_free(ret_buf);
- return ret;
-}
-
-int player_unset_media_packet_video_frame_decoded_cb(player_h player)
-{
- PLAYER_INSTANCE_CHECK(player);
- int ret = PLAYER_ERROR_NONE;
- player_cli_s *pc = (player_cli_s *)player;
- muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
- char *ret_buf = NULL;
- _player_event_e type = _PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME;
- int set = 0;
-
- LOGD("ENTER");
-
- set_null_user_cb_lock(pc->cb_info, type);
-
- player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, set);
-
- g_free(ret_buf);
- return ret;
-}
-
-int player_set_video_stream_changed_cb(player_h player, player_video_stream_changed_cb callback, void *user_data)
-{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(callback);
- int ret = PLAYER_ERROR_NONE;
- player_cli_s *pc = (player_cli_s *)player;
- muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
- char *ret_buf = NULL;
- _player_event_e type = _PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED;
- int set = 1;
-
- LOGD("ENTER");
-
- player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, set);
-
- if (ret == PLAYER_ERROR_NONE) {
- pc->cb_info->user_cb[type] = callback;
- pc->cb_info->user_data[type] = user_data;
- LOGI("Event type : %d ", type);
- }
-
- g_free(ret_buf);
- return ret;
-}
-
-int player_unset_video_stream_changed_cb(player_h player)
-{
- PLAYER_INSTANCE_CHECK(player);
- int ret = PLAYER_ERROR_NONE;
- player_cli_s *pc = (player_cli_s *)player;
- muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
- char *ret_buf = NULL;
- _player_event_e type = _PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED;
- int set = 0;
-
- LOGD("ENTER");
-
- set_null_user_cb_lock(pc->cb_info, type);
-
- player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, set);
-
- g_free(ret_buf);
- return ret;
-}
-
-int player_set_media_stream_buffer_status_cb(player_h player, player_stream_type_e stream_type, player_media_stream_buffer_status_cb callback, void *user_data)
-{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(callback);
- int ret = PLAYER_ERROR_NONE;
- player_cli_s *pc = (player_cli_s *)player;
- muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
- char *ret_buf = NULL;
- _player_event_e type;
- int set = 1;
-
- LOGD("ENTER");
-
- if (stream_type == PLAYER_STREAM_TYPE_VIDEO)
- type = _PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS;
- else if (stream_type == PLAYER_STREAM_TYPE_AUDIO)
- type = _PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS;
- else {
- LOGE("PLAYER_ERROR_INVALID_PARAMETER(type : %d)", stream_type);
- return PLAYER_ERROR_INVALID_PARAMETER;
- }
-
- player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, set);
-
- if (ret == PLAYER_ERROR_NONE) {
- pc->cb_info->user_cb[type] = callback;
- pc->cb_info->user_data[type] = user_data;
- LOGI("Event type : %d ", type);
- }
-
- g_free(ret_buf);
- return ret;
-}
-
-int player_unset_media_stream_buffer_status_cb(player_h player, player_stream_type_e stream_type)
-{
- PLAYER_INSTANCE_CHECK(player);
- int ret = PLAYER_ERROR_NONE;
- player_cli_s *pc = (player_cli_s *)player;
- muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
- char *ret_buf = NULL;
- _player_event_e type;
- int set = 0;
-
- LOGD("ENTER");
-
- if (stream_type == PLAYER_STREAM_TYPE_VIDEO)
- type = _PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS;
- else if (stream_type == PLAYER_STREAM_TYPE_AUDIO)
- type = _PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS;
- else {
- LOGE("PLAYER_ERROR_INVALID_PARAMETER(type : %d)", stream_type);
- return PLAYER_ERROR_INVALID_PARAMETER;
- }
-
- set_null_user_cb_lock(pc->cb_info, type);
-
- player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, set);
-
- g_free(ret_buf);
- return ret;
-}
-
-int player_set_media_stream_seek_cb(player_h player, player_stream_type_e stream_type, player_media_stream_seek_cb callback, void *user_data)
-{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(callback);
- int ret = PLAYER_ERROR_NONE;
- player_cli_s *pc = (player_cli_s *)player;
- muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
- char *ret_buf = NULL;
- _player_event_e type;
- int set = 1;
-
- LOGD("ENTER");
-
- if (stream_type == PLAYER_STREAM_TYPE_VIDEO)
- type = _PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK;
- else if (stream_type == PLAYER_STREAM_TYPE_AUDIO)
- type = _PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK;
- else {
- LOGE("PLAYER_ERROR_INVALID_PARAMETER(type : %d)", stream_type);
- return PLAYER_ERROR_INVALID_PARAMETER;
- }
-
- player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, set);
-
- if (ret == PLAYER_ERROR_NONE) {
- pc->cb_info->user_cb[type] = callback;
- pc->cb_info->user_data[type] = user_data;
- LOGI("Event type : %d ", type);
- }
-
- g_free(ret_buf);
- return ret;
-}
-
-int player_unset_media_stream_seek_cb(player_h player, player_stream_type_e stream_type)
-{
- PLAYER_INSTANCE_CHECK(player);
- int ret = PLAYER_ERROR_NONE;
- player_cli_s *pc = (player_cli_s *)player;
- muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
- char *ret_buf = NULL;
- _player_event_e type;
- int set = 0;
-
- LOGD("ENTER");
-
- if (stream_type == PLAYER_STREAM_TYPE_VIDEO)
- type = _PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK;
- else if (stream_type == PLAYER_STREAM_TYPE_AUDIO)
- type = _PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK;
- else {
- LOGE("PLAYER_ERROR_INVALID_PARAMETER(type : %d)", stream_type);
- return PLAYER_ERROR_INVALID_PARAMETER;
- }
-
- set_null_user_cb_lock(pc->cb_info, type);
-
- player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, set);
-
- g_free(ret_buf);
- return ret;
-}
-
-/* TODO Implement raw data socket channel */
-int player_push_media_stream(player_h player, media_packet_h packet)
-{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(packet);
- int ret = PLAYER_ERROR_NONE;
- player_cli_s *pc = (player_cli_s *)player;
- muse_player_api_e api = MUSE_PLAYER_API_PUSH_MEDIA_STREAM;
- char *ret_buf = NULL;
- player_push_media_msg_type push_media;
- char *push_media_msg = (char *)&push_media;
- int msg_size = sizeof(player_push_media_msg_type);
-#ifdef __UN_USED
- tbm_bo bo = NULL;
- tbm_bo_handle thandle;
- int buf_size;
-#endif
- char *buf;
- media_format_h format;
- bool is_video;
- bool is_audio;
-
- LOGD("ENTER");
-
- media_packet_get_buffer_data_ptr(packet, (void **)&buf);
- media_packet_get_buffer_size(packet, &push_media.size);
- media_packet_get_pts(packet, &push_media.pts);
- media_packet_get_format(packet, &format);
- media_packet_get_flags(packet, &push_media.flags);
-
- push_media.buf_type = PUSH_MEDIA_BUF_TYPE_RAW;
-
- media_packet_is_video(packet, &is_video);
- media_packet_is_audio(packet, &is_audio);
- if (is_video)
- media_format_get_video_info(format, &push_media.mimetype, NULL, NULL, NULL, NULL);
- else if (is_audio)
- media_format_get_audio_info(format, &push_media.mimetype, NULL, NULL, NULL, NULL);
-
-#ifdef __UN_USED
- if (push_media.buf_type == PUSH_MEDIA_BUF_TYPE_TBM) {
- bo = tbm_bo_alloc(pc->cb_info->bufmgr, push_media.size, TBM_BO_DEFAULT);
- if (bo == NULL) {
- LOGE("TBM get error : bo is NULL");
- return PLAYER_ERROR_INVALID_OPERATION;
- }
- thandle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_WRITE);
- if (thandle.ptr == NULL) {
- LOGE("TBM get error : handle pointer is NULL");
- ret = PLAYER_ERROR_INVALID_OPERATION;
- goto push_media_error;
- }
- memcpy(thandle.ptr, buf, push_media.size);
- tbm_bo_unmap(bo);
-
- push_media.key = tbm_bo_export(bo);
- if (push_media.key == 0) {
- LOGE("TBM get error : key is 0");
- ret = PLAYER_ERROR_INVALID_OPERATION;
- goto push_media_error;
- }
-
- player_msg_send_array(api, pc, ret_buf, ret, push_media_msg, msg_size, sizeof(char));
- } else if (push_media.buf_type == PUSH_MEDIA_BUF_TYPE_MSG) {
- buf_size = (int)push_media.size;
- player_msg_send_array2(api, pc, ret_buf, ret, push_media_msg, msg_size, sizeof(char), buf, buf_size, sizeof(char));
- } else
-#endif
- if (push_media.buf_type == PUSH_MEDIA_BUF_TYPE_RAW) {
- muse_core_ipc_push_data(pc->cb_info->data_fd, buf, push_media.size, push_media.pts);
- player_msg_send_array(api, pc, ret_buf, ret, push_media_msg, msg_size, sizeof(char));
- }
-
- LOGD("ret_buf %s", ret_buf);
-
-#ifdef __UN_USED
-push_media_error:
- if (push_media.buf_type == PUSH_MEDIA_BUF_TYPE_TBM)
- tbm_bo_unref(bo);
-#endif
-
- g_free(ret_buf);
- return ret;
-}
-
-int player_set_media_stream_info(player_h player, player_stream_type_e type, media_format_h format)
-{
- PLAYER_INSTANCE_CHECK(player);
- g_return_val_if_fail(format, PLAYER_ERROR_INVALID_OPERATION);
- int ret = PLAYER_ERROR_NONE;
- player_cli_s *pc = (player_cli_s *)player;
- muse_player_api_e api = MUSE_PLAYER_API_SET_MEDIA_STREAM_INFO;
- char *ret_buf = NULL;
- media_format_mimetype_e mimetype;
- int width;
- int height;
- int avg_bps;
- int max_bps;
- int channel;
- int samplerate;
- int bit;
-
- LOGD("ENTER");
-
- media_format_ref(format);
- if (type == PLAYER_STREAM_TYPE_VIDEO) {
- media_format_get_video_info(format, &mimetype, &width, &height, &avg_bps, &max_bps);
- player_msg_send6(api, pc, ret_buf, ret, INT, type, INT, mimetype, INT, width, INT, height, INT, avg_bps, INT, max_bps);
- } else if (type == PLAYER_STREAM_TYPE_AUDIO) {
- media_format_get_audio_info(format, &mimetype, &channel, &samplerate, &bit, &avg_bps);
- player_msg_send6(api, pc, ret_buf, ret, INT, type, INT, mimetype, INT, channel, INT, samplerate, INT, avg_bps, INT, bit);
- }
- media_format_unref(format);
-
- g_free(ret_buf);
- return ret;
-}
-
-int player_set_media_stream_buffer_max_size(player_h player, player_stream_type_e type, unsigned long long max_size)
-{
- int ret = PLAYER_ERROR_NONE;
- PLAYER_INSTANCE_CHECK(player);
- player_cli_s *pc = (player_cli_s *)player;
- muse_player_api_e api = MUSE_PLAYER_API_SET_MEDIA_STREAM_BUFFER_MAX_SIZE;
- char *ret_buf = NULL;
-
- LOGD("ENTER");
-
- player_msg_send2(api, pc, ret_buf, ret, INT, type, INT64, max_size);
-
- g_free(ret_buf);
- return ret;
-}
-
-int player_get_media_stream_buffer_max_size(player_h player, player_stream_type_e type, unsigned long long *pmax_size)
-{
- int ret = PLAYER_ERROR_NONE;
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(pmax_size);
- player_cli_s *pc = (player_cli_s *)player;
- muse_player_api_e api = MUSE_PLAYER_API_GET_MEDIA_STREAM_BUFFER_MAX_SIZE;
- char *ret_buf = NULL;
- unsigned long long max_size;
-
- LOGD("ENTER");
-
- player_msg_send1(api, pc, ret_buf, ret, INT, type);
- if (ret == PLAYER_ERROR_NONE) {
- player_msg_get_type(max_size, ret_buf, INT64);
- *pmax_size = max_size;
- }
- g_free(ret_buf);
- return ret;
-}
-
-int player_set_media_stream_buffer_min_threshold(player_h player, player_stream_type_e type, unsigned int percent)
-{
- int ret = PLAYER_ERROR_NONE;
- PLAYER_INSTANCE_CHECK(player);
- player_cli_s *pc = (player_cli_s *)player;
- muse_player_api_e api = MUSE_PLAYER_API_SET_MEDIA_STREAM_BUFFER_MIN_THRESHOLD;
- char *ret_buf = NULL;
-
- LOGD("ENTER");
-
- player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, percent);
-
- g_free(ret_buf);
- return ret;
-}
-
-int player_get_media_stream_buffer_min_threshold(player_h player, player_stream_type_e type, unsigned int *ppercent)
-{
- int ret = PLAYER_ERROR_NONE;
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(ppercent);
- player_cli_s *pc = (player_cli_s *)player;
- muse_player_api_e api = MUSE_PLAYER_API_GET_MEDIA_STREAM_BUFFER_MIN_THRESHOLD;
- char *ret_buf = NULL;
- uint percent;
-
- LOGD("ENTER");
-
- player_msg_send1(api, pc, ret_buf, ret, INT, type);
- if (ret == PLAYER_ERROR_NONE) {
- player_msg_get(percent, ret_buf);
- *ppercent = percent;
- }
-
- g_free(ret_buf);
- return ret;
-}
-
-int player_get_track_count(player_h player, player_stream_type_e type, int *pcount)
-{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(pcount);
- int ret = PLAYER_ERROR_NONE;
- player_cli_s *pc = (player_cli_s *)player;
- muse_player_api_e api = MUSE_PLAYER_API_GET_TRACK_COUNT;
- char *ret_buf = NULL;
- int count;
-
- LOGD("ENTER");
-
- player_msg_send1(api, pc, ret_buf, ret, INT, type);
- if (ret == PLAYER_ERROR_NONE) {
- player_msg_get(count, ret_buf);
- *pcount = count;
- }
-
- g_free(ret_buf);
- return ret;
-}
-
-int player_get_current_track(player_h player, player_stream_type_e type, int *pindex)
-{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(pindex);
- int ret = PLAYER_ERROR_NONE;
- player_cli_s *pc = (player_cli_s *)player;
- muse_player_api_e api = MUSE_PLAYER_API_GET_CURRENT_TRACK;
- char *ret_buf = NULL;
- int index;
-
- LOGD("ENTER");
-
- player_msg_send1(api, pc, ret_buf, ret, INT, type);
- if (ret == PLAYER_ERROR_NONE) {
- player_msg_get(index, ret_buf);
- *pindex = index;
- }
-
- g_free(ret_buf);
- return ret;
-}
-
-int player_select_track(player_h player, player_stream_type_e type, int index)
-{
- PLAYER_INSTANCE_CHECK(player);
- int ret = PLAYER_ERROR_NONE;
- player_cli_s *pc = (player_cli_s *)player;
- muse_player_api_e api = MUSE_PLAYER_API_SELECT_TRACK;
- char *ret_buf = NULL;
-
- LOGD("ENTER");
-
- player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, index);
-
- g_free(ret_buf);
- return ret;
-}
-
-int player_get_track_language_code(player_h player, player_stream_type_e type, int index, char **pcode)
-{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(pcode);
- int ret = PLAYER_ERROR_NONE;
- player_cli_s *pc = (player_cli_s *)player;
- muse_player_api_e api = MUSE_PLAYER_API_GET_TRACK_LANGUAGE_CODE;
- char *ret_buf = NULL;
- char code[MUSE_MSG_MAX_LENGTH] = {0, };
- const int code_len = 2;
-
- LOGD("ENTER");
-
- player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, index);
- if (ret == PLAYER_ERROR_NONE) {
- if (player_msg_get_string(code, ret_buf))
- *pcode = strndup(code, code_len);
- }
-
- g_free(ret_buf);
- return ret;
-}
+++ /dev/null
-/*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <glib.h>
-#include <muse_core.h>
-#include <muse_core_msg_json.h>
-#include <muse_core_ipc.h>
-#include <mm_error.h>
-#include <dlog.h>
-#include <Evas.h>
-#include "player2_private.h"
-#include "player_msg_private.h"
-#include "player_internal.h"
-
-int player_set_pcm_extraction_mode(player_h player, bool sync, player_audio_pcm_extraction_cb callback, void *user_data)
-{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(callback);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_SET_PCM_EXTRACTION_MODE;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
- _player_event_e event = _PLAYER_EVENT_TYPE_AUDIO_FRAME;
-
- LOGD("ENTER");
-
- player_msg_send1(api, pc, ret_buf, ret, INT, sync);
-
- if (ret == PLAYER_ERROR_NONE) {
- pc->cb_info->user_cb[event] = callback;
- pc->cb_info->user_data[event] = user_data;
- LOGI("Event type : %d ", event);
- }
-
- g_free(ret_buf);
- return ret;
-}
-
-int player_set_pcm_spec(player_h player, const char *format, int samplerate, int channel)
-{
- PLAYER_INSTANCE_CHECK(player);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_SET_PCM_SPEC;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
-
- LOGD("ENTER");
-
- player_msg_send3(api, pc, ret_buf, ret, STRING, format, INT, samplerate, INT, channel);
-
- g_free(ret_buf);
- return ret;
-}
-
-int player_set_streaming_playback_rate(player_h player, float rate)
-{
- PLAYER_INSTANCE_CHECK(player);
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_SET_STREAMING_PLAYBACK_RATE;
- player_cli_s *pc = (player_cli_s *)player;
- char *ret_buf = NULL;
-
- LOGD("ENTER");
-
- player_msg_send1(api, pc, ret_buf, ret, DOUBLE, rate);
- g_free(ret_buf);
- return ret;
-}
-
-int player_set_media_stream_buffer_status_cb_ex(player_h player, player_stream_type_e stream_type, player_media_stream_buffer_status_cb_ex callback, void *user_data)
-{
- PLAYER_INSTANCE_CHECK(player);
- PLAYER_NULL_ARG_CHECK(callback);
- int ret = PLAYER_ERROR_NONE;
- player_cli_s *pc = (player_cli_s *)player;
- muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
- char *ret_buf = NULL;
- _player_event_e type;
- int set = 1;
-
- LOGD("ENTER");
-
- if (stream_type == PLAYER_STREAM_TYPE_VIDEO)
- type = _PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO;
- else if (stream_type == PLAYER_STREAM_TYPE_AUDIO)
- type = _PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO;
- else {
- LOGE("PLAYER_ERROR_INVALID_PARAMETER(type : %d)", stream_type);
- return PLAYER_ERROR_INVALID_PARAMETER;
- }
-
- player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, set);
-
- if (ret == PLAYER_ERROR_NONE) {
- pc->cb_info->user_cb[type] = callback;
- pc->cb_info->user_data[type] = user_data;
- LOGI("Event type : %d ", type);
- }
-
- g_free(ret_buf);
- return ret;
-}
-
-static void set_null_user_cb(callback_cb_info_s *cb_info, _player_event_e event)
-{
- if (cb_info && event < _PLAYER_EVENT_TYPE_NUM) {
- cb_info->user_cb[event] = NULL;
- cb_info->user_data[event] = NULL;
- }
-}
-
-static void set_null_user_cb_lock(callback_cb_info_s *cb_info, _player_event_e event)
-{
- bool lock = g_thread_self() != cb_info->event_queue.thread;
-
- if (lock)
- g_mutex_lock(&cb_info->event_queue.mutex);
-
- set_null_user_cb(cb_info, event);
-
- if (lock)
- g_mutex_unlock(&cb_info->event_queue.mutex);
-}
-
-int player_unset_media_stream_buffer_status_cb_ex(player_h player, player_stream_type_e stream_type)
-{
- PLAYER_INSTANCE_CHECK(player);
- int ret = PLAYER_ERROR_NONE;
- player_cli_s *pc = (player_cli_s *)player;
- muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
- char *ret_buf = NULL;
- _player_event_e type;
- int set = 0;
-
- LOGD("ENTER");
-
- if (stream_type == PLAYER_STREAM_TYPE_VIDEO)
- type = _PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO;
- else if (stream_type == PLAYER_STREAM_TYPE_AUDIO)
- type = _PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO;
- else {
- LOGE("PLAYER_ERROR_INVALID_PARAMETER(type : %d)", stream_type);
- return PLAYER_ERROR_INVALID_PARAMETER;
- }
-
- set_null_user_cb_lock(pc->cb_info, type);
-
- player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, set);
-
- g_free(ret_buf);
- return ret;
-}
-
-static void __evas_resize_cb (void *data, Evas *e, Evas_Object *eo, void *event_info)
-{
-
- player_cli_s *pc = (player_cli_s *)data;
- wl_win_msg_type wl_win;
- char *wl_win_msg = (char *)&wl_win;
- char *ret_buf = NULL;
- muse_player_api_e api = MUSE_PLAYER_API_RESIZE_VIDEO_RENDER_RECT;
- int ret = PLAYER_ERROR_NONE;
- LOGD("ret =%d",ret);
-
- evas_object_geometry_get(eo, &wl_win.wl_window_x, &wl_win.wl_window_y, &wl_win.wl_window_width, &wl_win.wl_window_height);
- LOGD("get window rectangle: x(%d) y(%d) width(%d) height(%d)",
- wl_win.wl_window_x, wl_win.wl_window_y, wl_win.wl_window_width, wl_win.wl_window_height);
-
- wl_win.type = 0; /*init but not use */
- wl_win.wl_surface_id = 0; /*init but not use */
-
- player_msg_send_array(api, pc, ret_buf, ret, wl_win_msg, sizeof(wl_win_msg_type), sizeof(char));
-
- g_free(ret_buf);
- return;
-
-}
-
-static void __evas_del_cb (void *data, Evas *e, Evas_Object *eo, void *event_info)
-{
-
- player_cli_s *pc = (player_cli_s *)data;
-
- evas_object_event_callback_del (eo, EVAS_CALLBACK_RESIZE, __evas_resize_cb);
- evas_object_event_callback_del (eo, EVAS_CALLBACK_DEL, __evas_del_cb);
-
- LOGD("evas callback del %p", eo);
- pc->have_evas_callback = FALSE;
-
- return;
-}
-
-int player_set_evas_object_cb(player_h player, Evas_Object * eo)
-{
-
- PLAYER_INSTANCE_CHECK(player);
- return_val_if_fail(eo != NULL, MM_ERROR_INVALID_ARGUMENT);
-
- player_cli_s *pc = (player_cli_s *)player;
-
- if(pc->have_evas_callback && pc->eo == eo) {
- LOGW("evas object had callback already %p", pc->eo);
- return MM_ERROR_UNKNOWN;
- }
- pc->eo = eo;
- evas_object_event_callback_add (eo, EVAS_CALLBACK_RESIZE, __evas_resize_cb, player);
- evas_object_event_callback_add (eo, EVAS_CALLBACK_DEL, __evas_del_cb, player);
- LOGD("evas callback add %p", pc->eo);
- pc->have_evas_callback = TRUE;
-
- return MM_ERROR_NONE;
-}
-
-int player_unset_evas_object_cb(player_h player)
-{
- PLAYER_INSTANCE_CHECK(player);
- player_cli_s *pc = (player_cli_s *)player;
- return_val_if_fail(pc->eo != NULL, MM_ERROR_INVALID_ARGUMENT);
-
- evas_object_event_callback_del (pc->eo, EVAS_CALLBACK_RESIZE, __evas_resize_cb);
- evas_object_event_callback_del (pc->eo, EVAS_CALLBACK_DEL, __evas_del_cb);
- LOGD("evas callback del %p", pc->eo);
- pc->eo = NULL;
- pc->have_evas_callback = FALSE;
-
- return MM_ERROR_NONE;
-}
+++ /dev/null
-/*
-* 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 <glib.h>
-#include <string.h>
-#include <dlog.h>
-#include <mm_error.h>
-#include <wayland-client.h>
-#include <tizen-extension-client-protocol.h>
-
-#include "player2_wayland.h"
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-#define LOG_TAG "TIZEN_N_PLAYER"
-
-
-
-#define goto_if_fail(expr,label) \
-{ \
- if (!(expr)) { \
- debug_error(" failed [%s]\n", #expr); \
- goto label; \
- } \
-}
-
-void handle_resource_id(void *data, struct tizen_resource *tizen_resource, uint32_t id)
-{
- unsigned int *wl_surface_id = data;
-
- *wl_surface_id = id;
-
- LOGD("[CLIENT] got parent_id(%d) from server\n", id);
-}
-
-static const struct tizen_resource_listener tz_resource_listener =
-{
- handle_resource_id,
-};
-
-static void
-handle_global(void *data, struct wl_registry *registry,
- uint32_t name, const char *interface, uint32_t version)
-{
- return_if_fail (data != NULL);
- wl_client *wlclient = data;
-
- if (strcmp(interface, "tizen_surface") == 0)
- {
- LOGD("binding tizen_surface");
- wlclient->tz_surface = wl_registry_bind(registry, name, &tizen_surface_interface, version);
- return_if_fail (wlclient->tz_surface != NULL);
- }
-}
-
-static const struct wl_registry_listener registry_listener =
-{
- handle_global,
-};
-
-int _wlclient_create (wl_client ** wlclient)
-{
- wl_client *ptr = NULL;
-
- ptr = g_malloc0 (sizeof (wl_client));
- if (!ptr) {
- LOGE ("Cannot allocate memory for wlclient\n");
- goto ERROR;
- } else {
- *wlclient = ptr;
- LOGD ("Success create wlclient(%p)", *wlclient);
- }
- return MM_ERROR_NONE;
-
-ERROR:
- *wlclient = NULL;
- return MM_ERROR_PLAYER_NO_FREE_SPACE;
-}
-
-
-int _wlclient_get_wl_window_wl_surface_id (wl_client * wlclient, struct wl_surface *surface, struct wl_display *display)
-{
- goto_if_fail (wlclient != NULL, failed);
- goto_if_fail (surface != NULL, failed);
- goto_if_fail (display != NULL, failed);
-
- unsigned int wl_surface_id = 0;
-
- wlclient->display = display;
- goto_if_fail (wlclient->display != NULL, failed);
-
- wlclient->registry = wl_display_get_registry(wlclient->display);
- goto_if_fail (wlclient->registry != NULL, failed);
-
- wl_registry_add_listener(wlclient->registry, ®istry_listener, wlclient);
- wl_display_dispatch(wlclient->display);
- wl_display_roundtrip(wlclient->display);
-
- /* check global objects */
- goto_if_fail (wlclient->tz_surface != NULL, failed);
-
- /* Get wl_surface_id which is unique in a entire systemw. */
- wlclient->tz_resource = tizen_surface_get_tizen_resource(wlclient->tz_surface, surface);
- goto_if_fail (wlclient->tz_resource != NULL, failed);
-
- tizen_resource_add_listener(wlclient->tz_resource, &tz_resource_listener, &wl_surface_id);
- wl_display_roundtrip(wlclient->display);
- goto_if_fail (wl_surface_id > 0, failed);
-
- _wlclient_finalize(wlclient);
-
- return wl_surface_id;
-
-failed:
- LOGE ("Failed to get wl_surface_id");
-
- return 0;
-}
-
-void _wlclient_finalize (wl_client * wlclient)
-{
- LOGD ("start finalize wlclient");
- return_if_fail (wlclient != NULL)
-
- if (wlclient->tz_surface)
- tizen_surface_destroy(wlclient->tz_surface);
-
- if (wlclient->tz_resource)
- tizen_resource_destroy(wlclient->tz_resource);
-
- /* destroy registry */
- if (wlclient->registry)
- wl_registry_destroy(wlclient->registry);
- return;
-}
-
+++ /dev/null
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-SET(client_test "${fw_name}-test")
-
-INCLUDE_DIRECTORIES(../include)
-link_directories(${CMAKE_SOURCE_DIR}/../)
-
-IF(X11_SUPPORT)
- SET(WIN_PKG "ecore-x")
-ENDIF(X11_SUPPORT)
-IF(WAYLAND_SUPPORT)
- SET(WIN_PKG "${WIN_PKG} ecore-wayland")
-ENDIF(WAYLAND_SUPPORT)
-INCLUDE(FindPkgConfig)
-pkg_check_modules(${client_test} REQUIRED appcore-efl elementary ecore evas capi-media-sound-manager ${WIN_PKG})
-FOREACH(flag ${${client_test}_CFLAGS})
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -pie")
-
-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 ${${client_test}_LDFLAGS})
-ENDFOREACH()
-
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <Elementary.h>
-#include <tbm_surface.h>
-#include <dlog.h>
-#include <player.h>
-#include <player_internal.h>
-#include <glib.h>
-#include <appcore-efl.h>
-#ifdef HAVE_WAYLAND
-#include <Ecore.h>
-#include <Ecore_Wayland.h>
-#endif
-
-#define KEY_END "XF86Stop"
-
-#define ES_DEFAULT_DIR_PATH "/home/owner/content/"
-#define ES_DEFAULT_H264_VIDEO_PATH ES_DEFAULT_DIR_PATH"Simpsons.h264"
-#define ES_DEFAULT_VIDEO_FORMAT_TYPE MEDIA_FORMAT_H264_SP
-#define ES_DEFAULT_VIDEO_FORMAT_WIDTH 1280
-#define ES_DEFAULT_VIDEO_FORMAT_HEIGHT 544
-#define ES_DEFAULT_VIDEO_PTS_OFFSET 20000000
-#define ES_DEFAULT_NUMBER_OF_FEED 2000
-
-unsigned char sps[100];
-unsigned char pps[100];
-unsigned char tmp_buf[1000000];
-static int sps_len, pps_len;
-
-#ifdef PACKAGE
-#undef PACKAGE
-#endif
-#define PACKAGE "player_es_push_test"
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-#define LOG_TAG "PLAYER_TEST"
-
-static int app_create(void *data);
-static int app_reset(bundle *b, void *data);
-static int app_resume(void *data);
-static int app_pause(void *data);
-static int app_terminate(void *data);
-
-struct appcore_ops ops = {
- .create = app_create,
- .terminate = app_terminate,
- .pause = app_pause,
- .resume = app_resume,
- .reset = app_reset,
-};
-
-typedef struct appdata {
- Evas_Object *win;
- Evas_Object *rect;
- player_h player_handle;
- media_packet_h video_pkt;
- media_format_h video_fmt;
- FILE *file_src;
- pthread_t feeding_thread_id;
-} appdata_s;
-
-static void win_delete_request_cb(void *data, Evas_Object *obj, void *event_info)
-{
- elm_exit();
-}
-
-static Eina_Bool keydown_cb(void *data, int type, void *event)
-{
- /* appdata_s *ad = data; */
- Ecore_Event_Key *ev = event;
-
- LOGD("start");
-
- if (!strcmp(ev->keyname, KEY_END)) {
- /* Let window go to hide state. */
- /* elm_win_lower(ad->win); */
- LOGD("elm exit");
- elm_exit();
-
- return ECORE_CALLBACK_DONE;
- }
-
- LOGD("done");
-
- return ECORE_CALLBACK_PASS_ON;
-}
-
-static void win_del(void *data, Evas_Object *obj, void *event)
-{
- elm_exit();
-}
-
-static Evas_Object *create_win(const char *name)
-{
- Evas_Object *eo = NULL;
- int w = 0;
- int h = 0;
-
- 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);
- elm_win_screen_size_get(eo, NULL, NULL, &w, &h);
- g_print("window size :%d,%d", w, h);
- evas_object_resize(eo, w, h);
- elm_win_autodel_set(eo, EINA_TRUE);
-#ifdef HAVE_WAYLAND
- elm_win_alpha_set(eo, EINA_TRUE);
-#endif
- }
- return eo;
-}
-
-static Evas_Object *create_render_rect(Evas_Object *pParent)
-{
- if (!pParent)
- return NULL;
-
- Evas *pEvas = evas_object_evas_get(pParent);
- Evas_Object *pObj = evas_object_rectangle_add(pEvas);
- if (pObj == NULL)
- return NULL;
-
- evas_object_size_hint_weight_set(pObj, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_color_set(pObj, 0, 0, 0, 0);
- evas_object_render_op_set(pObj, EVAS_RENDER_COPY);
- evas_object_show(pObj);
- elm_win_resize_object_add(pParent, pObj);
-
- return pObj;
-}
-
-static void create_base_gui(appdata_s *ad)
-{
- /* Enable GLES Backened */
- elm_config_preferred_engine_set("3d");
-
- /* Window */
- /* elm_win_util_standard_add(PACKAGE, PACKAGE); */
- ad->win = create_win(PACKAGE);
- ad->rect = create_render_rect(ad->win);
- /* This is not supported in 3.0
- elm_win_wm_desktop_layout_support_set(ad->win, EINA_TRUE); */
- elm_win_autodel_set(ad->win, EINA_TRUE);
- evas_object_smart_callback_add(ad->win, "delete,request", win_delete_request_cb, ad);
-
- /* Show window after base gui is set up */
- elm_win_activate(ad->win);
- evas_object_show(ad->win);
-}
-
-static int app_create(void *data)
-{
- /* Hook to take necessary actions before main event loop starts
- Initialize UI resources and application's data
- If this function returns true, the main loop of application starts
- If this function returns false, the application is terminated */
- appdata_s *ad = data;
-
- LOGD("start");
-
- create_base_gui(ad);
- ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, keydown_cb, NULL);
-
- /* open test file */
- ad->file_src = fopen(ES_DEFAULT_H264_VIDEO_PATH, "r");
-
- LOGD("done");
-
- return 0;
-}
-
-static int app_pause(void *data)
-{
- /* Take necessary actions when application becomes invisible. */
- appdata_s *ad = (appdata_s *)data;
- int ret = PLAYER_ERROR_NONE;
-
- LOGD("start");
-
- if (ad == NULL) {
- LOGE("appdata is NULL");
- return -1;
- }
-
- if (ad->player_handle == NULL) {
- g_print("player_handle is NULL");
- return -1;
- }
-
- if (ad->feeding_thread_id) {
- pthread_join(ad->feeding_thread_id, NULL);
- ad->feeding_thread_id = 0;
- }
-
- player_unset_media_stream_buffer_status_cb_ex(ad->player_handle, PLAYER_STREAM_TYPE_VIDEO);
- player_unset_media_stream_buffer_status_cb_ex(ad->player_handle, PLAYER_STREAM_TYPE_AUDIO);
- player_unset_media_stream_seek_cb(ad->player_handle, PLAYER_STREAM_TYPE_VIDEO);
- player_unset_media_stream_seek_cb(ad->player_handle, PLAYER_STREAM_TYPE_AUDIO);
-
- ret = player_unprepare(ad->player_handle);
- if (ret != PLAYER_ERROR_NONE) {
- g_print("player_unprepare failed : 0x%x", ret);
- return false;
- }
-
- /* unref media format */
- if (ad->video_fmt)
- media_format_unref(ad->video_fmt);
-
- fclose(ad->file_src);
-
- /* destroy player handle */
- ret = player_destroy(ad->player_handle);
- if (ret != PLAYER_ERROR_NONE) {
- g_print("player_destroy failed : 0x%x", ret);
- return false;
- }
-
- ad->player_handle = NULL;
-
- LOGD("done");
-
- return 0;
-}
-
-static int app_resume(void *data)
-{
- LOGD("start");
-
- LOGD("done");
-
- return 0;
-}
-
-static void _player_prepared_cb(void *user_data)
-{
- int ret = PLAYER_ERROR_NONE;
- appdata_s *ad = (appdata_s *)user_data;
-
- LOGD("prepared");
-
- ret = player_start(ad->player_handle);
- if (ret != PLAYER_ERROR_NONE)
- LOGE("player start failed : 0x%x", ret);
-
- LOGD("done");
-}
-
-int bytestream2nalunit(FILE * fd, unsigned char *nal)
-{
- int nal_length = 0;
- size_t result;
- int read_size = 1;
- unsigned char buffer[1000000];
- unsigned char val, zero_count, i;
- int nal_unit_type = 0;
- int init;
-
- zero_count = 0;
- if (feof(fd))
- return -1;
-
- result = fread(buffer, 1, read_size, fd);
-
- if (result != read_size)
- return -1;
-
- val = buffer[0];
- while (!val) {
- if ((zero_count == 2 || zero_count == 3) && val == 1)
- break;
- zero_count++;
- result = fread(buffer, 1, read_size, fd);
-
- if (result != read_size)
- break;
- val = buffer[0];
- }
- nal[nal_length++] = 0;
- nal[nal_length++] = 0;
- nal[nal_length++] = 0;
- nal[nal_length++] = 1;
- zero_count = 0;
- init = 1;
- while (1) {
- if (feof(fd))
- return -1;
-
- result = fread(buffer, 1, read_size, fd);
- if (result != read_size) {
- if (init == 1)
- return -1;
- break;
- }
- val = buffer[0];
-
- if (init) {
- nal_unit_type = val & 0xf;
- init = 0;
- }
- if (!val) {
- zero_count++;
- } else {
- if ((zero_count == 2 || zero_count == 3 || zero_count == 4) && (val == 1)) {
- break;
- } else {
- for (i = 0; i < zero_count; i++)
- nal[nal_length++] = 0;
- nal[nal_length++] = val;
- zero_count = 0;
- }
- }
- }
-
- fseek(fd, -(zero_count + 1), SEEK_CUR);
-
- if (nal_unit_type == 0x7) {
- sps_len = nal_length;
- memcpy(sps, nal, nal_length);
- return 0;
- } else if (nal_unit_type == 0x8) {
- pps_len = nal_length;
- memcpy(pps, nal, nal_length);
- return 0;
- } else if (nal_unit_type == 0x5) {
- memcpy(tmp_buf, nal, nal_length);
- memcpy(nal, sps, sps_len);
- memcpy(nal + sps_len, pps, pps_len);
- memcpy(nal + sps_len + pps_len, tmp_buf, nal_length);
- nal_length += sps_len + pps_len;
- }
-
- return nal_length;
-}
-
-static void feed_eos_data(appdata_s *appdata)
-{
- appdata_s *ad = appdata;
-
- LOGD("push EOS");
-
- if (media_packet_create(ad->video_fmt, NULL, NULL, &ad->video_pkt) != MEDIA_PACKET_ERROR_NONE) {
- LOGE("media_packet_create_alloc failed\n");
- return;
- }
-
- media_packet_set_flags(ad->video_pkt, MEDIA_PACKET_END_OF_STREAM);
- if (player_push_media_stream(ad->player_handle, ad->video_pkt) != PLAYER_ERROR_NONE)
- LOGE("fail to push media packet\n");
-
- media_packet_destroy(ad->video_pkt);
- ad->video_pkt = NULL;
-
- return;
-}
-
-static bool feed_video_data(appdata_s *appdata)
-{
- bool ret = FALSE;
- int read = 0;
- static guint64 pts = 0L;
- void *buf_data_ptr = NULL;
- appdata_s *ad = appdata;
-
- if (media_packet_create_alloc(ad->video_fmt, NULL, NULL, &ad->video_pkt) != MEDIA_PACKET_ERROR_NONE) {
- LOGE("media_packet_create_alloc failed\n");
- return FALSE;
- }
-
- if (media_packet_get_buffer_data_ptr(ad->video_pkt, &buf_data_ptr) != MEDIA_PACKET_ERROR_NONE) {
- LOGE("media_packet_get_buffer_data_ptr failed\n");
- goto ERROR;
- }
-
- if (media_packet_set_pts(ad->video_pkt, (uint64_t)pts) != MEDIA_PACKET_ERROR_NONE) {
- LOGE("media_packet_set_pts failed\n");
- goto ERROR;
- }
-
- /* NOTE: In case of H.264 video, stream format for feeding is NAL unit.
- * And, SPS(0x67) and PPS(0x68) should be located before IDR.(0x65).
- */
- read = bytestream2nalunit(ad->file_src, buf_data_ptr);
- LOGD("real length = %d\n", read);
- if (read == 0) {
- LOGE("input file read failed\n");
- ret = TRUE;
- goto ERROR;
- } else if (read < 0) {
- LOGD("push EOS");
- media_packet_destroy(ad->video_pkt);
- ad->video_pkt = NULL;
-
- if (media_packet_create(ad->video_fmt, NULL, NULL, &ad->video_pkt) != MEDIA_PACKET_ERROR_NONE) {
- LOGE("media_packet_create failed\n");
- goto ERROR;
- }
- media_packet_set_flags(ad->video_pkt, MEDIA_PACKET_END_OF_STREAM);
- if (player_push_media_stream(ad->player_handle, ad->video_pkt) != PLAYER_ERROR_NONE)
- LOGE("fail to push media packet\n");
- goto ERROR;
- }
-
- if (media_packet_set_buffer_size(ad->video_pkt, (uint64_t)read) != MEDIA_PACKET_ERROR_NONE) {
- LOGE("media_packet_set_buffer_size failed\n");
- goto ERROR;
- }
-
- /* push media packet */
- player_push_media_stream(ad->player_handle, ad->video_pkt);
- pts += ES_DEFAULT_VIDEO_PTS_OFFSET;
- ret = TRUE;
-
-ERROR:
- /* destroy media packet after use */
- media_packet_destroy(ad->video_pkt);
- ad->video_pkt = NULL;
- return ret;
-}
-
-static void feed_video_data_thread_func(void *data)
-{
- appdata_s *ad = (appdata_s *)data;
-
- while (TRUE) {
- static int frame_count = 0;
- if (frame_count < ES_DEFAULT_NUMBER_OF_FEED) {
- if (!feed_video_data(ad))
- break;
- frame_count++;
- } else {
- feed_eos_data(ad);
- break;
- }
- }
-}
-
-void _video_buffer_status_cb_ex(player_media_stream_buffer_status_e status, unsigned long long bytes, void *user_data)
-{
- if (status == PLAYER_MEDIA_STREAM_BUFFER_UNDERRUN) {
- LOGE("video buffer is underrun state, current level byte = %llu", bytes);
- }
- else if (status == PLAYER_MEDIA_STREAM_BUFFER_OVERFLOW) {
- LOGE("video buffer is overrun state, current level byte = %llu", bytes);
- }
-}
-
-void _audio_buffer_status_cb_ex(player_media_stream_buffer_status_e status, unsigned long long bytes, void *user_data)
-{
- if (status == PLAYER_MEDIA_STREAM_BUFFER_UNDERRUN) {
- LOGE("audio buffer is underrun state, current level byte = %llu", bytes);
- }
- else if (status == PLAYER_MEDIA_STREAM_BUFFER_OVERFLOW) {
- LOGE("audio buffer is overrun state, current level byte = %llu", bytes);
- }
-}
-
-void _video_seek_data_cb(unsigned long long offset, void *user_data)
-{
- LOGE("seek offset of video is %llu", offset);
-}
-
-void _audio_seek_data_cb(unsigned long long offset, void *user_data)
-{
- LOGE("seek offset of audio is %llu", offset);
-}
-
-static int app_reset(bundle *b, void *data)
-{
- /* Take necessary actions when application becomes visible. */
- appdata_s *ad = (appdata_s *)data;
- int ret = PLAYER_ERROR_NONE;
-
- LOGD("start");
-
- if (ad == NULL) {
- LOGE("appdata is NULL");
- return -1;
- }
-
- ret = player_create(&ad->player_handle);
- if (ret != PLAYER_ERROR_NONE) {
- LOGE("player_create failed : 0x%x", ret);
- return -1;
- }
-
- ret = player_set_display(ad->player_handle, PLAYER_DISPLAY_TYPE_OVERLAY, GET_DISPLAY(ad->win));
- if (ret != PLAYER_ERROR_NONE) {
- LOGE("player_set_display failed : 0x%x", ret);
- goto FAILED;
- }
-
- /* get media format format */
- ret = media_format_create(&ad->video_fmt);
- if (ret != MEDIA_FORMAT_ERROR_NONE) {
- LOGE("media_format_create : 0x%x", ret);
- goto FAILED;
- }
-
- /* set video format */
- media_format_set_video_mime(ad->video_fmt, ES_DEFAULT_VIDEO_FORMAT_TYPE);
- media_format_set_video_width(ad->video_fmt, ES_DEFAULT_VIDEO_FORMAT_WIDTH);
- media_format_set_video_height(ad->video_fmt, ES_DEFAULT_VIDEO_FORMAT_HEIGHT);
-
- player_set_media_stream_buffer_max_size(ad->player_handle, PLAYER_STREAM_TYPE_VIDEO, (unsigned long long)3*1024*1024);
- player_set_media_stream_buffer_min_threshold(ad->player_handle, PLAYER_STREAM_TYPE_VIDEO, 50);
-
- ret = player_set_media_stream_buffer_status_cb_ex(ad->player_handle, PLAYER_STREAM_TYPE_VIDEO, _video_buffer_status_cb_ex, (void *)ad);
- if (ret != PLAYER_ERROR_NONE) {
- LOGE("player set video buffer status cb failed : 0x%x", ret);
- goto FAILED;
- }
- ret = player_set_media_stream_buffer_status_cb_ex(ad->player_handle, PLAYER_STREAM_TYPE_AUDIO, _audio_buffer_status_cb_ex, (void *)ad);
- if (ret != PLAYER_ERROR_NONE) {
- LOGE("player set audio buffer status cb failed : 0x%x", ret);
- goto FAILED;
- }
-
- ret = player_set_media_stream_seek_cb(ad->player_handle, PLAYER_STREAM_TYPE_VIDEO, _video_seek_data_cb, (void *)ad);
- if (ret != PLAYER_ERROR_NONE) {
- LOGE("player set seek data cb for video failed : 0x%x", ret);
- goto FAILED;
- }
- ret = player_set_media_stream_seek_cb(ad->player_handle, PLAYER_STREAM_TYPE_AUDIO, _audio_seek_data_cb, (void *)ad);
- if (ret != PLAYER_ERROR_NONE) {
- LOGE("player set seek data cb for audio failed : 0x%x", ret);
- goto FAILED;
- }
-
- /* send media packet to player */
- player_set_media_stream_info(ad->player_handle, PLAYER_STREAM_TYPE_VIDEO, ad->video_fmt);
-
- ret = player_prepare_async(ad->player_handle, _player_prepared_cb, (void *)ad);
- if (ret != PLAYER_ERROR_NONE) {
- LOGE("player prepare failed : 0x%x", ret);
- goto FAILED;
- }
-
- pthread_create(&ad->feeding_thread_id, NULL, (void *)feed_video_data_thread_func, (void *)ad);
-
- LOGD("done");
-
- return 0;
-
-FAILED:
- if (ad->player_handle) {
- player_destroy(ad->player_handle);
- ad->player_handle = NULL;
- }
-
- return -1;
-}
-
-static int app_terminate(void *data)
-{
- /* Release all resources. */
- appdata_s *ad = (appdata_s *)data;
-
- LOGD("start");
-
- if (ad == NULL) {
- LOGE("appdata is NULL");
- return -1;
- }
-
- app_pause(data);
-
- LOGD("done");
-
- return 0;
-}
-
-int main(int argc, char *argv[])
-{
- int ret = 0;
- static appdata_s ad = {0, };
-
- LOGD("start");
-
- memset(&ad, 0x0, sizeof(appdata_s));
-
- LOGD("call appcore_efl_main");
-
- ops.data = &ad;
-
- ret = appcore_efl_main(PACKAGE, &argc, &argv, &ops);
-
- LOGD("appcore_efl_main() ret = 0x%x", ret);
-
- return ret;
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <Elementary.h>
-#include <tbm_surface.h>
-#include <dlog.h>
-#include <player.h>
-#include <glib.h>
-#include <appcore-efl.h>
-
-#define KEY_END "XF86Stop"
-#define MEDIA_FILE_PATH "/home/owner/content/Color.mp4"
-#ifdef PACKAGE
-#undef PACKAGE
-#endif
-#define PACKAGE "player_test"
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-#define LOG_TAG "PLAYER_TEST"
-
-static int app_create(void *data);
-static int app_reset(bundle *b, void *data);
-static int app_resume(void *data);
-static int app_pause(void *data);
-static int app_terminate(void *data);
-
-struct appcore_ops ops = {
- .create = app_create,
- .terminate = app_terminate,
- .pause = app_pause,
- .resume = app_resume,
- .reset = app_reset,
-};
-
-typedef struct appdata {
- Evas_Object *win;
- Evas_Object *img;
- media_packet_h packet;
- Ecore_Pipe *pipe;
- player_h player_handle;
- GList *packet_list;
- GMutex buffer_lock;
- int w, h;
-} appdata_s;
-
-static void win_delete_request_cb(void *data, Evas_Object *obj, void *event_info)
-{
- elm_exit();
-}
-
-static Eina_Bool keydown_cb(void *data, int type, void *event)
-{
- /* appdata_s *ad = data; */
- Ecore_Event_Key *ev = event;
-
- LOGD("start");
-
- if (!strcmp(ev->keyname, KEY_END)) {
- /* Let window go to hide state. */
- /* elm_win_lower(ad->win); */
- LOGD("elm exit");
- elm_exit();
-
- return ECORE_CALLBACK_DONE;
- }
-
- LOGD("done");
-
- return ECORE_CALLBACK_PASS_ON;
-}
-
-static void create_base_gui(appdata_s *ad)
-{
- /* Enable GLES Backened */
- elm_config_preferred_engine_set("3d");
-
- /* Window */
- ad->win = elm_win_util_standard_add(PACKAGE, PACKAGE);
- /* This is not supported in 3.0
- elm_win_wm_desktop_layout_support_set(ad->win, EINA_TRUE); */
- elm_win_autodel_set(ad->win, EINA_TRUE);
-#if 0
- if (elm_win_wm_rotation_supported_get(ad->win)) {
- int rots[4] = { 0, 90, 180, 270 };
- elm_win_wm_rotation_available_rotations_set(ad->win, (const int *)(&rots), 4);
- }
-#endif
- evas_object_smart_callback_add(ad->win, "delete,request", win_delete_request_cb, ad);
-
- Evas *e = evas_object_evas_get(ad->win);
-
- elm_win_screen_size_get(ad->win, NULL, NULL, &ad->w, &ad->h);
- LOGD("surface size (%d x %d)\n", ad->w, ad->h);
-
- /* Image Object */
- ad->img = evas_object_image_filled_add(e);
- evas_object_image_size_set(ad->img, ad->w, ad->h);
- evas_object_size_hint_weight_set(ad->img, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_show(ad->img);
-
- elm_win_resize_object_add(ad->win, ad->img);
-
- /* Show window after base gui is set up */
- evas_object_show(ad->win);
-}
-
-static void _media_packet_video_decoded_cb(media_packet_h packet, void *user_data)
-{
- /* This callback function would be called on different thread */
- appdata_s *ad = user_data;
-
- if (ad == NULL) {
- LOGE("appdata is NULL");
- return;
- }
-
- g_mutex_lock(&ad->buffer_lock);
-
- if (ad->pipe == NULL) {
- media_packet_destroy(packet);
- LOGW("release media packet immediately");
- g_mutex_unlock(&ad->buffer_lock);
- return;
- }
-
- /* add packet list */
- ad->packet_list = g_list_prepend(ad->packet_list, (gpointer)packet);
-
- LOGD("packet %p", packet);
-
- /* Send packet to main thread */
- ecore_pipe_write(ad->pipe, &packet, sizeof(media_packet_h));
-
- g_mutex_unlock(&ad->buffer_lock);
-
- return;
-}
-
-static void pipe_cb(void *data, void *buf, unsigned int len)
-{
- /* Now, we get a player surface to be set here. */
- appdata_s *ad = data;
- tbm_surface_h surface;
-#ifdef _CAN_USE_NATIVE_SURFACE_TBM
- Evas_Native_Surface surf;
-#endif
- tbm_surface_info_s suf_info;
- uint32_t plane_idx;
- int ret;
- GList *last_item = NULL;
-
- LOGD("start");
-
- g_mutex_lock(&ad->buffer_lock);
-
- /* Destroy previous packet */
- if (ad->packet) {
- ret = media_packet_destroy(ad->packet);
- if (ret != MEDIA_PACKET_ERROR_NONE)
- LOGE("Failed to destroy media packet. ret (%d)", ret);
- ad->packet = NULL;
- }
-
- /* remove packet from list */
- last_item = g_list_last(ad->packet_list);
- if (last_item) {
- /* Get new packet */
- ad->packet = (media_packet_h)last_item->data;;
- ad->packet_list = g_list_remove(ad->packet_list, ad->packet);
- LOGD("ad->packet %p", ad->packet);
- }
-
- if (ad->packet == NULL) {
- LOGW("NULL packet");
- g_mutex_unlock(&ad->buffer_lock);
- return;
- }
-
- ret = media_packet_get_tbm_surface(ad->packet, &surface);
- if (ret != MEDIA_PACKET_ERROR_NONE) {
- LOGE("Failed to get surface from media packet. ret(0x%x)", ret);
-
- media_packet_destroy(ad->packet);
- ad->packet = NULL;
-
- g_mutex_unlock(&ad->buffer_lock);
-
- return;
- }
-
- LOGD("surface %p", surface);
-
- g_mutex_unlock(&ad->buffer_lock);
-
-#ifdef _CAN_USE_NATIVE_SURFACE_TBM
- /* Set tbm surface to image native surface */
- memset(&surf, 0x0, sizeof(surf));
- surf.version = EVAS_NATIVE_SURFACE_VERSION;
- surf.type = EVAS_NATIVE_SURFACE_TBM;
- surf.data.tizen.buffer = surface;
- surf.data.tizen.rot = 270;
- evas_object_image_native_surface_set(ad->img, &surf);
-
- /* Set dirty image region to be redrawn */
- evas_object_image_data_update_add(ad->img, 0, 0, ad->w, ad->h);
-#else
- unsigned char *ptr = NULL;
- unsigned char *buf_data = NULL;
- media_format_h format = NULL;
- media_format_mimetype_e mimetype;
-
- media_packet_get_format(ad->packet, &format);
- media_format_get_video_info(format, &mimetype, NULL, NULL, NULL, NULL);
-
- if (mimetype == MEDIA_FORMAT_I420 || mimetype == MEDIA_FORMAT_NV12 || mimetype == MEDIA_FORMAT_NV12T) {
-
- tbm_surface_get_info(surface, &suf_info);
- buf_data = (unsigned char *)g_malloc0(suf_info.size);
- if (!buf_data) {
- LOGE("no free space");
- return;
- }
- ptr = buf_data;
-
- for (plane_idx = 0; plane_idx < suf_info.num_planes; plane_idx++) {
- memcpy(ptr, suf_info.planes[plane_idx].ptr, suf_info.planes[plane_idx].size);
- ptr += suf_info.planes[plane_idx].size;
- }
- /* dump buf data here, if needed */
- g_free(buf_data);
- }
-#endif
-
- LOGD("done");
-
- return;
-}
-
-static int app_create(void *data)
-{
- /* Hook to take necessary actions before main event loop starts
- Initialize UI resources and application's data
- If this function returns true, the main loop of application starts
- If this function returns false, the application is terminated */
- appdata_s *ad = data;
-
- LOGD("start");
-
- create_base_gui(ad);
- ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, keydown_cb, NULL);
-
- g_mutex_init(&ad->buffer_lock);
-
- LOGD("done");
-
- return 0;
-}
-
-static int app_pause(void *data)
-{
- /* Take necessary actions when application becomes invisible. */
- appdata_s *ad = (appdata_s *)data;
- GList *list = NULL;
- media_packet_h packet = NULL;
- int ret = PLAYER_ERROR_NONE;
-
- LOGD("start");
-
- if (ad == NULL) {
- LOGE("appdata is NULL");
- return -1;
- }
-
- if (ad->player_handle == NULL) {
- g_print("player_handle is NULL");
- return -1;
- }
-
- /* stop render last set frame */
- evas_object_image_native_surface_set(ad->img, NULL);
-
- g_mutex_lock(&ad->buffer_lock);
-
- /* remove ecore pipe */
- ecore_pipe_del(ad->pipe);
- ad->pipe = NULL;
-
- /* remove packet list */
- list = ad->packet_list;
- while (list) {
- packet = list->data;
- list = g_list_next(list);
-
- if (!packet) {
- LOGW("packet is NULL");
- } else {
- LOGD("destroy packet %p", packet);
- media_packet_destroy(packet);
- packet = NULL;
- ad->packet_list = g_list_remove(ad->packet_list, packet);
- }
- }
-
- if (ad->packet_list) {
- g_list_free(ad->packet_list);
- ad->packet_list = NULL;
- }
-
- /* Destroy previous packet */
- if (ad->packet) {
- LOGD("destroy packet %p", ad->packet);
- ret = media_packet_destroy(ad->packet);
- if (ret != MEDIA_PACKET_ERROR_NONE)
- LOGE("Failed to destroy media packet. ret (%d)", ret);
- ad->packet = NULL;
- }
-
- g_mutex_unlock(&ad->buffer_lock);
-
- ret = player_unset_media_packet_video_frame_decoded_cb(ad->player_handle);
- if (ret != PLAYER_ERROR_NONE) {
- g_print("player_unset_media_packet_video_frame_decoded_cb failed : 0x%x", ret);
- return false;
- }
-
- ret = player_unprepare(ad->player_handle);
- if (ret != PLAYER_ERROR_NONE) {
- g_print("player_unprepare failed : 0x%x", ret);
- return false;
- }
-
- ret = player_destroy(ad->player_handle);
- if (ret != PLAYER_ERROR_NONE) {
- g_print("player_destroy failed : 0x%x", ret);
- return false;
- }
-
- ad->player_handle = NULL;
-
- LOGD("done");
-
- return 0;
-}
-
-static int app_resume(void *data)
-{
- LOGD("start");
-
- LOGD("done");
-
- return 0;
-}
-
-static int app_reset(bundle *b, void *data)
-{
- /* Take necessary actions when application becomes visible. */
- appdata_s *ad = (appdata_s *)data;
- int ret = PLAYER_ERROR_NONE;
-
- LOGD("start");
-
- if (ad == NULL) {
- LOGE("appdata is NULL");
- return -1;
- }
-
- /* create ecore pipe */
- ad->pipe = ecore_pipe_add(pipe_cb, ad);
-
- ret = player_create(&ad->player_handle);
- if (ret != PLAYER_ERROR_NONE) {
- LOGE("player_create failed : 0x%x", ret);
- return -1;
- }
-
- ret = player_set_media_packet_video_frame_decoded_cb(ad->player_handle, _media_packet_video_decoded_cb, ad);
- if (ret != PLAYER_ERROR_NONE) {
- LOGE("player_set_media_packet_video_frame_decoded_cb failed : 0x%x", ret);
- goto FAILED;
- }
-
- ret = player_set_display(ad->player_handle, PLAYER_DISPLAY_TYPE_NONE, NULL);
- if (ret != PLAYER_ERROR_NONE) {
- LOGE("player_set_display failed : 0x%x", ret);
- goto FAILED;
- }
-
- ret = player_set_uri(ad->player_handle, MEDIA_FILE_PATH);
- if (ret != PLAYER_ERROR_NONE) {
- LOGE("player_set_uri failed : 0x%x", ret);
- goto FAILED;
- }
-
- ret = player_prepare(ad->player_handle);
- if (ret != PLAYER_ERROR_NONE) {
- LOGE("player prepare failed : 0x%x", ret);
- goto FAILED;
- }
-
- ret = player_start(ad->player_handle);
- if (ret != PLAYER_ERROR_NONE) {
- LOGE("player start failed : 0x%x", ret);
- goto FAILED;
- }
-
- LOGD("done");
-
- return 0;
-
-FAILED:
- if (ad->player_handle) {
- player_destroy(ad->player_handle);
- ad->player_handle = NULL;
- }
-
- return -1;
-
-}
-
-static int app_terminate(void *data)
-{
- /* Release all resources. */
- appdata_s *ad = (appdata_s *)data;
-
- LOGD("start");
-
- if (ad == NULL) {
- LOGE("appdata is NULL");
- return -1;
- }
-
- app_pause(data);
-
- g_mutex_clear(&ad->buffer_lock);
-
- LOGD("done");
-
- return 0;
-}
-
-int main(int argc, char *argv[])
-{
- int ret = 0;
- static appdata_s ad = {0, };
-
- LOGD("start");
-
- memset(&ad, 0x0, sizeof(appdata_s));
-
- LOGD("call appcore_efl_main");
-
- ops.data = &ad;
-
- ret = appcore_efl_main(PACKAGE, &argc, &argv, &ops);
-
- LOGD("appcore_efl_main() ret = 0x%x", ret);
-
- return ret;
-}
+++ /dev/null
-/*
-* 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 <player.h>
-#include <player_internal.h>
-#include <sound_manager.h>
-#include <pthread.h>
-#include <glib.h>
-#include <dlfcn.h>
-#include <appcore-efl.h>
-#include <Elementary.h>
-#ifdef HAVE_X11
-#include <Ecore_X.h>
-#endif
-#ifdef HAVE_WAYLAND
-#include <Ecore.h>
-#include <Ecore_Wayland.h>
-#endif
-#ifdef _ACTIVATE_EOM_
-#include <eom.h>
-#endif
-#define PACKAGE "player_test"
-#define MAX_STRING_LEN 2048
-#define MMTS_SAMPLELIST_INI_DEFAULT_PATH "/opt/etc/mmts_filelist.ini"
-#define PLAYER_TEST_DUMP_PATH_PREFIX "/home/owner/content/dump_pcm_"
-#define INI_SAMPLE_LIST_MAX 9
-#define DEFAULT_HTTP_TIMEOUT -1
-
-static gboolean g_memory_playback = FALSE;
-static char g_uri[MAX_STRING_LEN];
-static char g_subtitle_uri[MAX_STRING_LEN];
-static FILE *g_pcm_fd;
-
-static gboolean is_es_push_mode = FALSE;
-static pthread_t g_feed_video_thread_id = 0;
-static bool g_thread_end = FALSE;
-static media_packet_h g_audio_pkt = NULL;
-static media_format_h g_audio_fmt = NULL;
-
-static media_packet_h g_video_pkt = NULL;
-static media_format_h g_video_fmt = NULL;
-
-static int _save(unsigned char *src, int length);
-
-#define DUMP_OUTBUF 1
-#if DUMP_OUTBUF
-FILE *fp_out1 = NULL;
-FILE *fp_out2 = NULL;
-#endif
-
-enum {
- CURRENT_STATUS_MAINMENU,
- CURRENT_STATUS_HANDLE_NUM,
- CURRENT_STATUS_FILENAME,
- CURRENT_STATUS_VOLUME,
- CURRENT_STATUS_SOUND_TYPE,
- CURRENT_STATUS_SOUND_STREAM_INFO,
- CURRENT_STATUS_MUTE,
- CURRENT_STATUS_POSITION_TIME,
- CURRENT_STATUS_LOOPING,
- CURRENT_STATUS_DISPLAY_SURFACE_CHANGE,
- CURRENT_STATUS_DISPLAY_MODE,
- CURRENT_STATUS_DISPLAY_ROTATION,
- CURRENT_STATUS_DISPLAY_VISIBLE,
- CURRENT_STATUS_DISPLAY_ROI_MODE,
- CURRENT_STATUS_DISPLAY_DST_ROI,
- CURRENT_STATUS_DISPLAY_SRC_CROP,
- CURRENT_STATUS_SUBTITLE_FILENAME,
- CURRENT_STATUS_AUDIO_EQUALIZER,
- CURRENT_STATUS_PLAYBACK_RATE,
- CURRENT_STATUS_STREAMING_PLAYBACK_RATE,
- CURRENT_STATUS_SWITCH_SUBTITLE,
-};
-
-#define MAX_HANDLE 20
-
-/* for video display */
-static Evas_Object *g_xid;
-#ifdef _ACTIVATE_EOM_
-static Evas_Object *g_external_xid;
-#endif
-static Evas_Object *selected_xid;
-static Evas_Object *g_eo[MAX_HANDLE] = {0, };
-
-static int g_current_surface_type = PLAYER_DISPLAY_TYPE_OVERLAY;
-
-typedef struct {
- Evas_Object *win;
- Evas_Object *layout_main; /* layout widget based on EDJ */
-#ifdef HAVE_X11
- Ecore_X_Window xid;
-#elif HAVE_WAYLAND
- unsigned int xid;
-#endif
- /* add more variables here */
-#ifdef _ACTIVATE_EOM_
- int hdmi_output_id;
-#endif
-} appdata;
-
-static appdata ad;
-static player_h g_player[MAX_HANDLE] = {0, };
-
-int g_handle_num = 1;
-int g_menu_state = CURRENT_STATUS_MAINMENU;
-char g_file_list[9][256];
-gboolean quit_pushing;
-sound_stream_info_h g_stream_info_h = NULL;
-
-static void win_del(void *data, Evas_Object *obj, void *event)
-{
- elm_exit();
-}
-
-static Evas_Object *create_win(const char *name)
-{
- Evas_Object *eo = NULL;
- int w = 0;
- int h = 0;
-
- g_print("[%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);
- elm_win_screen_size_get(eo, NULL, NULL, &w, &h);
- g_print("window size :%d,%d", w, h);
- evas_object_resize(eo, w, h);
- elm_win_autodel_set(eo, EINA_TRUE);
-#ifdef HAVE_WAYLAND
- elm_win_alpha_set(eo, EINA_TRUE);
-#endif
- }
- return eo;
-}
-
-static Evas_Object *create_image_object(Evas_Object *eo_parent)
-{
- if (!eo_parent)
- return NULL;
-
- Evas *evas = evas_object_evas_get(eo_parent);
- Evas_Object *eo = NULL;
-
- eo = evas_object_image_add(evas);
-
- return eo;
-}
-
-void create_render_rect_and_bg(Evas_Object *win)
-{
- if (!win) {
- g_print("no win");
- return;
- }
- Evas_Object *bg, *rect;
-
- bg = elm_bg_add(win);
- elm_win_resize_object_add(win, bg);
- evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_show(bg);
-
- rect = evas_object_rectangle_add(evas_object_evas_get(win));
- if (!rect) {
- g_print("no rect");
- return;
- }
- evas_object_color_set(rect, 0, 0, 0, 0);
- evas_object_render_op_set(rect, EVAS_RENDER_COPY);
-
- elm_win_resize_object_add(win, rect);
- evas_object_size_hint_weight_set(rect, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_show(rect);
- evas_object_show(win);
-}
-#ifdef _ACTIVATE_EOM_
-int eom_get_output_id(const char *output_name)
-{
- eom_output_id *output_ids = NULL;
- eom_output_id output_id = 0;
- eom_output_type_e output_type = EOM_OUTPUT_TYPE_UNKNOWN;
- int id_cnt = 0;
- int i;
-
- /* get output_ids */
- output_ids = eom_get_eom_output_ids(&id_cnt);
- if (id_cnt == 0) {
- g_print("[eom] no external outuputs supported\n");
- return 0;
- }
-
- /* find output ids interested */
- for (i = 0; i < id_cnt; i++) {
- eom_get_output_type(output_ids[i], &output_type);
- if (!strncmp(output_name, "HDMI", 4)) {
- if (output_type == EOM_OUTPUT_TYPE_HDMIA || output_type == EOM_OUTPUT_TYPE_HDMIB) {
- output_id = output_ids[i];
- break;
- }
- } else if (!strncmp(output_name, "Virtual", 4)) {
- if (output_type == EOM_OUTPUT_TYPE_VIRTUAL) {
- output_id = output_ids[i];
- break;
- }
- }
- }
-
- if (output_ids)
- free(output_ids);
-
- return output_id;
-}
-
-static void eom_notify_cb_output_add(eom_output_id output_id, void *user_data)
-{
- appdata *info = (appdata *)user_data;
-
- if (info->hdmi_output_id != output_id) {
- g_print("[eom] OUTPUT ADDED. SKIP. my output ID is %d\n", info->hdmi_output_id);
- return;
- }
- g_print("[eom] output(%d) connected\n", output_id);
- /* it is for external window */
- if (!g_external_xid) {
- g_external_xid = elm_win_add(NULL, "External", ELM_WIN_BASIC);
- if (eom_set_output_window(info->hdmi_output_id, g_external_xid) == EOM_ERROR_NONE) {
- create_render_rect_and_bg(g_external_xid);
- g_print("[eom] create external window\n");
- } else {
- evas_object_del(g_external_xid);
- g_external_xid = NULL;
- g_print("[eom] create external window fail\n");
- }
- }
-}
-
-static void eom_notify_cb_output_remove(eom_output_id output_id, void *user_data)
-{
- appdata *info = (appdata *)user_data;
- player_state_e state;
-
- if (info->hdmi_output_id != output_id) {
- g_print("[eom] OUTPUT REMOVED. SKIP. my output ID is %d\n", info->hdmi_output_id);
- return;
- }
- g_print("[eom] output(%d) disconnected\n", output_id);
-
- if (selected_xid == g_external_xid && g_player[0]) {
- player_get_state(g_player[0], &state);
- if (state >= PLAYER_STATE_READY) {
- if (!g_xid) {
- g_xid = create_win(PACKAGE);
- if (g_xid == NULL)
- return;
- g_print("create xid %p\n", g_xid);
- create_render_rect_and_bg(g_xid);
- elm_win_activate(g_xid);
- evas_object_show(g_xid);
- }
- player_set_display(g_player[0], PLAYER_DISPLAY_TYPE_OVERLAY, GET_DISPLAY(g_xid));
- }
- }
-
- /* it is for external window */
- if (g_external_xid) {
- evas_object_del(g_external_xid);
- g_external_xid = NULL;
- }
- selected_xid = g_xid;
-}
-
-static void eom_notify_cb_mode_changed(eom_output_id output_id, void *user_data)
-{
- appdata *info = (appdata *)user_data;
- eom_output_mode_e mode = EOM_OUTPUT_MODE_NONE;
-
- if (info->hdmi_output_id != output_id) {
- g_print("[eom] MODE CHANGED. SKIP. my output ID is %d\n", info->hdmi_output_id);
- return;
- }
-
- eom_get_output_mode(output_id, &mode);
- g_print("[eom] output(%d) mode changed(%d)\n", output_id, mode);
-}
-
-static void eom_notify_cb_attribute_changed(eom_output_id output_id, void *user_data)
-{
- appdata *info = (appdata *)user_data;
-
- eom_output_attribute_e attribute = EOM_OUTPUT_ATTRIBUTE_NONE;
- eom_output_attribute_state_e state = EOM_OUTPUT_ATTRIBUTE_STATE_NONE;
-
- if (info->hdmi_output_id != output_id) {
- g_print("[eom] ATTR CHANGED. SKIP. my output ID is %d\n", info->hdmi_output_id);
- return;
- }
-
- eom_get_output_attribute(output_id, &attribute);
- eom_get_output_attribute_state(output_id, &state);
-
- g_print("[eom] output(%d) attribute changed(%d, %d)\n", output_id, attribute, state);
- if (state == EOM_OUTPUT_ATTRIBUTE_STATE_ACTIVE) {
- g_print("[eom] active\n");
- if (!g_external_xid) {
- g_external_xid = elm_win_add(NULL, "External", ELM_WIN_BASIC);
- if (eom_set_output_window(info->hdmi_output_id, g_external_xid) == EOM_ERROR_NONE) {
- create_render_rect_and_bg(g_external_xid);
- g_print("[eom] create external window\n");
- } else {
- evas_object_del(g_external_xid);
- g_external_xid = NULL;
- g_print("[eom] create external window fail\n");
- }
- }
- selected_xid = g_external_xid;
- /* play video on external window */
- if (g_player[0])
- player_set_display(g_player[0], PLAYER_DISPLAY_TYPE_OVERLAY, GET_DISPLAY(selected_xid));
- } else if (state == EOM_OUTPUT_ATTRIBUTE_STATE_INACTIVE) {
- g_print("[eom] inactive\n");
- if (!g_xid) {
- g_xid = create_win(PACKAGE);
- if (g_xid == NULL)
- return;
- g_print("create xid %p\n", g_xid);
- create_render_rect_and_bg(g_xid);
- elm_win_activate(g_xid);
- evas_object_show(g_xid);
- }
- selected_xid = g_xid;
- if (g_player[0])
- player_set_display(g_player[0], PLAYER_DISPLAY_TYPE_OVERLAY, GET_DISPLAY(selected_xid));
-
- if (g_external_xid) {
- evas_object_del(g_external_xid);
- g_external_xid = NULL;
- }
- } else if (state == EOM_OUTPUT_ATTRIBUTE_STATE_LOST) {
- g_print("[eom] lost\n");
- if (!g_xid) {
- g_xid = create_win(PACKAGE);
- if (g_xid == NULL)
- return;
- g_print("create xid %p\n", g_xid);
- create_render_rect_and_bg(g_xid);
- elm_win_activate(g_xid);
- evas_object_show(g_xid);
- }
- selected_xid = g_xid;
-
- if (g_player[0])
- player_set_display(g_player[0], PLAYER_DISPLAY_TYPE_OVERLAY, GET_DISPLAY(selected_xid));
-
- if (g_external_xid) {
- evas_object_del(g_external_xid);
- g_external_xid = NULL;
- }
-
- eom_unset_output_added_cb(eom_notify_cb_output_add);
- eom_unset_output_removed_cb(eom_notify_cb_output_remove);
- eom_unset_mode_changed_cb(eom_notify_cb_mode_changed);
- eom_unset_attribute_changed_cb(eom_notify_cb_attribute_changed);
-
- eom_deinit();
- }
-}
-#endif
-static int app_create(void *data)
-{
- appdata *ad = data;
- Evas_Object *win = NULL;
-#ifdef _ACTIVATE_EOM_
- eom_output_mode_e output_mode = EOM_OUTPUT_MODE_NONE;
-#endif
- /* use gl backend */
- elm_config_preferred_engine_set("3d");
-
- /* create window */
- win = create_win(PACKAGE);
- if (win == NULL)
- return -1;
- ad->win = win;
- g_xid = win;
- selected_xid = g_xid;
- create_render_rect_and_bg(ad->win);
- /* Create evas image object for EVAS surface */
- g_eo[0] = create_image_object(ad->win);
- evas_object_image_size_set(g_eo[0], 500, 500);
- evas_object_image_fill_set(g_eo[0], 0, 0, 500, 500);
- evas_object_resize(g_eo[0], 500, 500);
-
- elm_win_activate(win);
- evas_object_show(win);
-#ifdef _ACTIVATE_EOM_
- /* check external device */
- eom_init();
- ad->hdmi_output_id = eom_get_output_id("HDMI");
- if (ad->hdmi_output_id == 0) {
- g_print("[eom] error : HDMI output id is NULL.\n");
- return 0;
- }
-
- g_print("eom_set_output_attribute EOM_OUTPUT_ATTRIBUTE_NORMAL(id:%d)\n", ad->hdmi_output_id);
- if (eom_set_output_attribute(ad->hdmi_output_id, EOM_OUTPUT_ATTRIBUTE_NORMAL) != EOM_ERROR_NONE) {
- g_print("attribute set fail. cannot use external output\n");
- eom_deinit();
- }
-
- eom_get_output_mode(ad->hdmi_output_id, &output_mode);
- if (output_mode != EOM_OUTPUT_MODE_NONE) {
- g_external_xid = elm_win_add(NULL, "External", ELM_WIN_BASIC);
- if (eom_set_output_window(ad->hdmi_output_id, g_external_xid) == EOM_ERROR_NONE) {
- create_render_rect_and_bg(g_external_xid);
- g_print("[eom] create external window\n");
- } else {
- evas_object_del(g_external_xid);
- g_external_xid = NULL;
- g_print("[eom] create external window fail\n");
- }
- selected_xid = g_external_xid;
- }
-
- /* set callback for detecting external device */
- eom_set_output_added_cb(eom_notify_cb_output_add, ad);
- eom_set_output_removed_cb(eom_notify_cb_output_remove, ad);
- eom_set_mode_changed_cb(eom_notify_cb_mode_changed, ad);
- eom_set_attribute_changed_cb(eom_notify_cb_attribute_changed, ad);
-#endif
- return 0;
-}
-
-static int app_terminate(void *data)
-{
- appdata *ad = data;
- int i = 0;
-
- for (i = 0; i < MAX_HANDLE; i++) {
- if (g_eo[i]) {
- evas_object_del(g_eo[i]);
- g_eo[i] = NULL;
- }
- }
- if (g_xid) {
- evas_object_del(g_xid);
- g_xid = NULL;
- }
-#ifdef _ACTIVATE_EOM_
- if (g_external_xid) {
- evas_object_del(g_external_xid);
- g_external_xid = NULL;
- }
-#endif
- ad->win = NULL;
- selected_xid = NULL;
-#ifdef _ACTIVATE_EOM_
- eom_unset_output_added_cb(eom_notify_cb_output_add);
- eom_unset_output_removed_cb(eom_notify_cb_output_remove);
- eom_unset_mode_changed_cb(eom_notify_cb_mode_changed);
- eom_unset_attribute_changed_cb(eom_notify_cb_attribute_changed);
-
- eom_deinit();
-#endif
- return 0;
-}
-
-struct appcore_ops ops = {
- .create = app_create,
- .terminate = app_terminate,
-};
-
-static void prepared_cb(void *user_data)
-{
- g_print("[Player_Test] prepared_cb!!!!\n");
-}
-
-static void _audio_frame_decoded_cb_ex(player_audio_raw_data_s *audio_raw_frame, void *user_data)
-{
- player_audio_raw_data_s *audio_raw = audio_raw_frame;
-
- if (!audio_raw)
- return;
-
- g_print("[Player_Test] decoded_cb_ex! channel: %d channel_mask: %" G_GUINT64_FORMAT "\n", audio_raw->channel, audio_raw->channel_mask);
-
-#ifdef DUMP_OUTBUF
- if (audio_raw->channel_mask == 1 && fp_out1)
- fwrite((guint8 *)audio_raw->data, 1, audio_raw->size, fp_out1);
- else if (audio_raw->channel_mask == 2 && fp_out2)
- fwrite((guint8 *)audio_raw->data, 1, audio_raw->size, fp_out2);
-#endif
-}
-
-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 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 error_cb(int code, void *user_data)
-{
- g_print("[Player_Test] error_cb!!!! code : %d\n", code);
-}
-
-static void interrupted_cb(player_interrupted_code_e code, void *user_data)
-{
- g_print("[Player_Test] interrupted_cb!!!! code : %d\n", code);
-}
-
-#if 0
-static void audio_frame_decoded_cb(unsigned char *data, unsigned int size, void *user_data)
-{
- int pos = 0;
-
- if (data && g_pcm_fd)
- fwrite(data, 1, size, g_pcm_fd);
- player_get_play_position(g_player[0], &pos);
- g_print("[Player_Test] audio_frame_decoded_cb [size: %d] --- current pos : %d!!!!\n", size, pos);
-}
-#endif
-
-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);
- _save(data, size);
-}
-
-static int _save(unsigned char *src, int length)
-{
- /* unlink(CAPTUERD_IMAGE_SAVE_PATH); */
- FILE *fp;
- char filename[256] = {0, };
- static int WRITE_COUNT = 0;
- /* gchar *filename = CAPTUERD_IMAGE_SAVE_PATH; */
- snprintf(filename, 256, "IMAGE_client%d", WRITE_COUNT);
- WRITE_COUNT++;
- fp = fopen(filename, "w+");
- if (fp == NULL) {
- g_print("file open error!!\n");
- return FALSE;
- } else {
- g_print("open success\n");
- if (fwrite(src, 1, length, fp) < 1) {
- g_print("file write error!!\n");
- fclose(fp);
- return FALSE;
- }
- g_print("write success(%s)\n", filename);
- fclose(fp);
- }
-
- return TRUE;
-}
-
-static void reset_display()
-{
- int i = 0;
-
- /* delete evas window, if it is */
- for (i = 0; i < MAX_HANDLE; i++) {
- if (g_eo[i]) {
- evas_object_del(g_eo[i]);
- g_eo[i] = NULL;
- }
- }
-}
-
-static void input_filename(char *filename)
-{
- int len = strlen(filename);
- int i = 0;
-
- if (len < 0 || len > MAX_STRING_LEN - 1)
- return;
-
- for (i = 0; i < g_handle_num; i++) {
- if (g_player[i] != NULL) {
- player_unprepare(g_player[i]);
- player_destroy(g_player[i]);
- }
- g_player[i] = 0;
-
- if (player_create(&g_player[i]) != PLAYER_ERROR_NONE)
- g_print("player create is failed\n");
- }
-
- strncpy(g_uri, filename, len);
- g_uri[len] = '\0';
-
-#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[0], &g_err_name, "profile_uri", uri, strlen(uri), "profile_user_param", g_media_mem, file_size NULL);
-#else
- /* player_set_uri(g_player[0], filename); */
-#endif
- /* APPSRC_TEST */
-
- int ret;
- player_state_e state;
- for (i = 0; i < g_handle_num; i++) {
- ret = player_get_state(g_player[i], &state);
- g_print("player_get_state returned [%d]\n", ret);
- g_print("1. After player_create() - Current State : %d \n", state);
- }
-}
-
-/* use this API instead of player_set_uri */
-static void player_set_memory_buffer_test()
-{
- GMappedFile *file;
- gsize file_size;
- guint8 *g_media_mem = NULL;
-
- file = g_mapped_file_new(g_uri, FALSE, NULL);
- file_size = g_mapped_file_get_length(file);
- g_media_mem = (guint8 *)g_mapped_file_get_contents(file);
-
- int ret = player_set_memory_buffer(g_player[0], (void *)g_media_mem, file_size);
- g_print("player_set_memory_buffer ret : %d\n", ret);
-}
-
-int video_packet_count = 0;
-
-static void buffer_need_video_data_cb(unsigned int size, void *user_data)
-{
- int real_read_len = 0;
- char fname[128];
- char fptsname[128];
- static guint64 pts = 0L;
-
- FILE *fp = NULL;
- guint8 *buff_ptr = NULL;
- void *src = NULL;
-
- memset(fname, 0, 128);
- memset(fptsname, 0, 128);
-
- video_packet_count++;
-
- if (video_packet_count > 1000) {
- g_print("EOS.\n");
-
- /* player_submit_packet(g_player[0], NULL, 0, 0, 1); */
- player_push_media_stream(g_player[0], NULL);
- g_thread_end = TRUE;
- }
-
- /* snprintf(fname, 128, "/opt/storage/usb/test/packet/packet_%d.dat", video_packet_count); */
- /* snprintf(fptsname, 128, "/opt/storage/usb/test/packet/gstpts_%d.dat", video_packet_count); */
- snprintf(fname, 128, "/home/developer/test/packet/packet_%d.dat", video_packet_count);
- snprintf(fptsname, 128, "/home/developer/test/packet/gstpts_%d.dat", video_packet_count);
-
- fp = fopen(fptsname, "rb");
- if (fp) {
- int pts_len = 0;
- pts_len = fread(&pts, 1, sizeof(guint64), fp);
- if (pts_len != sizeof(guint64))
- g_print("Warning, pts value can be wrong.\n");
- fclose(fp);
- fp = NULL;
- }
-
- fp = fopen(fname, "rb");
- if (fp) {
- buff_ptr = (guint8 *)g_malloc0(1048576);
- if (!buff_ptr) {
- g_print("no free space\n");
- fclose(fp);
- fp = NULL;
- return;
- }
- real_read_len = fread(buff_ptr, 1, size, fp);
- fclose(fp);
- fp = NULL;
- }
- g_print("video need data - data size : %d, pts : %" G_GUINT64_FORMAT "\n", real_read_len, pts);
-#if 0
- player_submit_packet(g_player[0], buff_ptr, real_read_len, (pts / 1000000), 1);
-#else
- /* create media packet */
- if (g_video_pkt) {
- media_packet_destroy(g_video_pkt);
- g_video_pkt = NULL;
- }
-
- media_packet_create_alloc(g_video_fmt, NULL, NULL, &g_video_pkt);
-
- g_print("packet = %p, src = %p\n", g_video_pkt, src);
-
- if (media_packet_get_buffer_data_ptr(g_video_pkt, &src) != MEDIA_PACKET_ERROR_NONE)
- goto EXIT;
-
- if (media_packet_set_pts(g_video_pkt, (uint64_t)pts) != MEDIA_PACKET_ERROR_NONE)
- goto EXIT;
-
- if (media_packet_set_buffer_size(g_video_pkt, (uint64_t)real_read_len) != MEDIA_PACKET_ERROR_NONE)
- goto EXIT;
-
- memcpy(src, buff_ptr, real_read_len);
-
- /* then, push it */
- player_push_media_stream(g_player[0], g_video_pkt);
-#endif
-
-EXIT:
- if (buff_ptr) {
- g_free(buff_ptr);
- buff_ptr = NULL;
- }
-}
-
-int audio_packet_count = 0;
-static void buffer_need_audio_data_cb(unsigned int size, void *user_data)
-{
- int real_read_len = 0;
- char fname[128];
- FILE *fp = NULL;
- guint8 *buff_ptr = NULL;
- void *src = NULL;
-
- memset(fname, 0, 128);
- audio_packet_count++;
-
- if (audio_packet_count > 1000) {
- g_print("EOS.\n");
- /* player_submit_packet(g_player[0], NULL, 0, 0, 0); */
- player_push_media_stream(g_player[0], NULL);
- g_thread_end = TRUE;
- }
-
- /* snprintf(fname, 128, "/opt/storage/usb/test/audio_packet/packet_%d.dat", audio_packet_count); */
- snprintf(fname, 128, "/home/developer/test/audio_packet/packet_%d.dat", audio_packet_count);
-
- static guint64 audio_pts = 0;
- guint64 audio_dur = 21333333;
-
- fp = fopen(fname, "rb");
- if (fp) {
- buff_ptr = (guint8 *)g_malloc0(1048576);
- if (!buff_ptr) {
- g_print("no free space\n");
- fclose(fp);
- fp = NULL;
- return;
- }
- real_read_len = fread(buff_ptr, 1, size, fp);
- fclose(fp);
- fp = NULL;
-
- g_print("\t audio need data - data size : %d, pts : %" G_GUINT64_FORMAT "\n", real_read_len, audio_pts);
- }
-#if 0
- player_submit_packet(g_player[0], buff_ptr, real_read_len, (audio_pts / 1000000), 0);
-#else
- /* create media packet */
- if (g_audio_pkt) {
- media_packet_destroy(g_audio_pkt);
- g_audio_pkt = NULL;
- }
- media_packet_create_alloc(g_audio_fmt, NULL, NULL, &g_audio_pkt);
-
- g_print("packet = %p, src = %p\n", g_audio_pkt, src);
-
- if (media_packet_get_buffer_data_ptr(g_audio_pkt, &src) != MEDIA_PACKET_ERROR_NONE)
- goto EXIT;
-
- if (media_packet_set_pts(g_audio_pkt, (uint64_t)audio_pts) != MEDIA_PACKET_ERROR_NONE)
- goto EXIT;
-
- if (media_packet_set_buffer_size(g_audio_pkt, (uint64_t)real_read_len) != MEDIA_PACKET_ERROR_NONE)
- goto EXIT;
-
- memcpy(src, buff_ptr, real_read_len);
-
- /* then, push it */
- player_push_media_stream(g_player[0], g_audio_pkt);
-#endif
-
- audio_pts += audio_dur;
-EXIT:
- if (buff_ptr) {
- g_free(buff_ptr);
- buff_ptr = NULL;
- }
-}
-
-static void set_content_info(bool is_push_mode)
-{
- /* testcode for es buff src case, please input url as es_buff://123 or es_buff://push_mode */
- /* unsigned char codec_data[45] = {0x0,0x0,0x1,0xb0,0x1,0x0,0x0,0x1,0xb5,0x89,0x13,0x0,0x0,0x1,0x0,0x0,0x0,0x1,0x20,0x0,0xc4,0x8d,0x88,0x5d,0xad,0x14,0x4,0x22,0x14,0x43,0x0,0x0,0x1,0xb2,0x4c,0x61,0x76,0x63,0x35,0x31,0x2e,0x34,0x30,0x2e,0x34}; */
-
- /* create media format */
- media_format_create(&g_audio_fmt);
- media_format_create(&g_video_fmt);
-
- /* Video */
- /* configure media format for video and set to player */
- media_format_set_video_mime(g_video_fmt, MEDIA_FORMAT_MPEG4_SP);
- media_format_set_video_width(g_video_fmt, 640);
- media_format_set_video_height(g_video_fmt, 272);
- /* player_set_media_stream_info(g_player[0], PLAYER_STREAM_TYPE_VIDEO, g_video_fmt); */
-
- /* Audio--aac--StarWars.mp4 */
- media_format_set_audio_mime(g_audio_fmt, MEDIA_FORMAT_AAC);
- media_format_set_audio_channel(g_audio_fmt, 2);
- media_format_set_audio_samplerate(g_audio_fmt, 48000);
- /* player_set_media_stream_info(g_player[0], PLAYER_STREAM_TYPE_AUDIO, g_audio_fmt); */
-#if 0
- /* video_info->mime = g_strdup("video/mpeg"); */ /* CODEC_ID_MPEG4VIDEO */
- video_info->width = 640;
- video_info->height = 272;
- video_info->version = 4;
- video_info->framerate_den = 100;
- video_info->framerate_num = 2997;
-
- video_info->extradata_size = 45;
- video_info->codec_extradata = codec_data;
- player_set_video_stream_info(g_player[0], video_info);
-
- /* audio--aac--StarWars.mp4 */
- /* audio_info->mime = g_strdup("audio/mpeg"); */
- /* audio_info->version = 2; */
- /* audio_info->user_info = 0; */ /* raw */
-#endif
-
-#ifdef _ES_PULL_
- if (!is_push_mode) {
- player_set_buffer_need_video_data_cb(g_player[0], buffer_need_video_data_cb, (void *)g_player[0]);
- player_set_buffer_need_audio_data_cb(g_player[0], buffer_need_audio_data_cb, (void *)g_player[0]);
- }
-#endif
-}
-
-static void feed_video_data_thread_func(void *data)
-{
- while (!g_thread_end) {
- buffer_need_video_data_cb(1048576, NULL);
- buffer_need_audio_data_cb(1048576, NULL);
- }
-}
-
-static void _player_prepare(bool async)
-{
- 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[0], g_subtitle_uri);
- player_set_subtitle_updated_cb(g_player[0], subtitle_updated_cb, (void *)g_player[0]);
- }
- if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
- player_set_display(g_player[0], g_current_surface_type, GET_DISPLAY(selected_xid));
- player_set_buffering_cb(g_player[0], buffering_cb, (void *)g_player[0]);
- player_set_completed_cb(g_player[0], completed_cb, (void *)g_player[0]);
- player_set_interrupted_cb(g_player[0], interrupted_cb, (void *)g_player[0]);
- player_set_error_cb(g_player[0], error_cb, (void *)g_player[0]);
- if (g_memory_playback)
- player_set_memory_buffer_test();
- else
- player_set_uri(g_player[0], g_uri);
- } else {
- int i = 0;
- for (i = 0; i < g_handle_num; i++) {
- player_set_display(g_player[i], g_current_surface_type, g_eo[i]);
- player_set_buffering_cb(g_player[i], buffering_cb, (void *)g_player[i]);
- player_set_completed_cb(g_player[i], completed_cb, (void *)g_player[i]);
- player_set_interrupted_cb(g_player[i], interrupted_cb, (void *)g_player[i]);
- player_set_error_cb(g_player[i], error_cb, (void *)g_player[i]);
- if (g_memory_playback)
- player_set_memory_buffer_test();
- else
- player_set_uri(g_player[i], g_uri);
- }
- }
-
- if (strstr(g_uri, "es_buff://")) {
- is_es_push_mode = FALSE;
- video_packet_count = 0;
- audio_packet_count = 0;
-
- if (strstr(g_uri, "es_buff://push_mode")) {
- set_content_info(TRUE);
- async = TRUE;
- is_es_push_mode = TRUE;
-#ifdef _ES_PULL_
- } else {
- set_content_info(FALSE);
-#endif
- }
- }
-
- if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
- if (async)
- ret = player_prepare_async(g_player[0], prepared_cb, (void *)g_player[0]);
- else
- ret = player_prepare(g_player[0]);
- } else {
- int i = 0;
- for (i = 0; i < g_handle_num; i++) {
- if (async)
- ret = player_prepare_async(g_player[i], prepared_cb, (void *)g_player[i]);
- else
- ret = player_prepare(g_player[i]);
- }
- }
-
- if (ret != PLAYER_ERROR_NONE)
- g_print("prepare is failed (errno = %d) \n", ret);
-
- player_state_e state;
- if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
- ret = player_get_state(g_player[0], &state);
- g_print("After player_prepare() - Current State : %d \n", state);
- } else {
- int i = 0;
- for (i = 0; i < g_handle_num; i++) {
- ret = player_get_state(g_player[i], &state);
- g_print("After player_prepare() - Current State : %d \n", state);
- }
- }
-
- if (is_es_push_mode)
- pthread_create(&g_feed_video_thread_id, NULL, (void *)feed_video_data_thread_func, NULL);
-
-}
-
-static void _player_unprepare()
-{
- int ret = FALSE;
- int i = 0;
- if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
- ret = player_unprepare(g_player[0]);
- if (ret != PLAYER_ERROR_NONE)
- g_print("unprepare is failed (errno = %d) \n", ret);
-
- ret = player_unset_subtitle_updated_cb(g_player[0]);
- g_print("player_unset_subtitle_updated_cb ret %d\n", ret);
-
- ret = player_unset_buffering_cb(g_player[0]);
- g_print("player_unset_buffering_cb ret %d\n", ret);
-
- ret = player_unset_completed_cb(g_player[0]);
- g_print("player_unset_completed_cb ret %d\n", ret);
-
- ret = player_unset_interrupted_cb(g_player[0]);
- g_print("player_unset_interrupted_cb ret %d\n", ret);
-
- ret = player_unset_error_cb(g_player[0]);
- g_print("player_unset_error_cb ret %d\n", ret);
- } else {
- for (i = 0; i < g_handle_num; i++) {
- if (g_player[i] != NULL) {
- ret = player_unprepare(g_player[i]);
- if (ret != PLAYER_ERROR_NONE)
- g_print("unprepare is failed (errno = %d) \n", ret);
-
- ret = player_unset_subtitle_updated_cb(g_player[i]);
- g_print("player_unset_subtitle_updated_cb [%d] ret %d\n", i, ret);
-
- ret = player_unset_buffering_cb(g_player[i]);
- g_print("player_unset_buffering_cb [%d] ret %d\n", i, ret);
-
- ret = player_unset_completed_cb(g_player[i]);
- g_print("player_unset_completed_cb [%d] ret %d\n", i, ret);
-
- ret = player_unset_interrupted_cb(g_player[i]);
- g_print("player_unset_interrupted_cb [%d] ret %d\n", i, ret);
-
- ret = player_unset_error_cb(g_player[i]);
- g_print("player_unset_error_cb [%d] ret %d\n", i, ret);
- }
- }
- }
- /* attention! surface(evas) -> unprepare -> surface(evas) : evas object will disappear. */
- reset_display();
- memset(g_subtitle_uri, 0, sizeof(g_subtitle_uri));
- player_state_e state;
- if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
- ret = player_get_state(g_player[0], &state);
- g_print(" After player_unprepare() - Current State : %d \n", state);
- } else {
- for (i = 0; i < g_handle_num; i++) {
- ret = player_get_state(g_player[i], &state);
- g_print(" After player_unprepare() - Current State : %d \n", state);
- }
- }
-}
-
-static void _player_destroy()
-{
- int i = 0;
-
- if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
- player_unprepare(g_player[0]);
- for (i = 0; i < g_handle_num; i++) {
- player_destroy(g_player[i]);
- g_player[i] = 0;
- }
- } else {
- for (i = 0; i < g_handle_num; i++) {
- if (g_player[i] != NULL) {
- player_unprepare(g_player[i]);
- player_destroy(g_player[i]);
- g_player[i] = 0;
- }
- }
- }
-
- if (g_stream_info_h) {
- sound_manager_destroy_stream_information(g_stream_info_h);
- g_stream_info_h = NULL;
- }
-
- if (g_video_pkt)
- media_packet_destroy(g_video_pkt);
-
- if (g_audio_pkt)
- media_packet_destroy(g_audio_pkt);
-
-#if DUMP_OUTBUF
- if (fp_out1)
- fclose(fp_out1);
- if (fp_out2)
- fclose(fp_out2);
-#endif
-
-}
-
-static void _player_play()
-{
- int bRet = FALSE;
- int i = 0;
- if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
-#ifdef _ACTIVATE_EOM_
- /* for checking external display.... */
- player_set_display(g_player[0], g_current_surface_type, GET_DISPLAY(selected_xid));
-#endif
- bRet = player_start(g_player[0]);
- g_print("player_start returned [%d]", bRet);
- } else {
- for (i = 0; i < g_handle_num; i++) {
- bRet = player_start(g_player[i]);
- g_print("player_start returned [%d]", bRet);
- }
- }
-}
-
-static void _player_stop()
-{
- int bRet = FALSE;
- int i = 0;
- if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
- bRet = player_stop(g_player[0]);
- g_print("player_stop returned [%d]", bRet);
- } else {
- for (i = 0; i < g_handle_num; i++) {
- bRet = player_stop(g_player[i]);
- g_print("player_stop returned [%d]", bRet);
- }
- }
-
- g_thread_end = TRUE;
- if (g_feed_video_thread_id) {
- pthread_join(g_feed_video_thread_id, NULL);
- g_feed_video_thread_id = 0;
- }
-
-}
-
-static void _player_resume()
-{
- int bRet = FALSE;
- int i = 0;
- if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
-#ifdef _ACTIVATE_EOM_
- /* for checking external display.... */
- player_set_display(g_player[0], PLAYER_DISPLAY_TYPE_OVERLAY, GET_DISPLAY(selected_xid));
-#endif
- bRet = player_start(g_player[0]);
- g_print("player_start returned [%d]", bRet);
- } else {
- for (i = 0; i < g_handle_num; i++) {
- bRet = player_start(g_player[i]);
- g_print("player_start returned [%d]", bRet);
- }
- }
-}
-
-static void _player_pause()
-{
- int bRet = FALSE;
- int i = 0;
- if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
- bRet = player_pause(g_player[0]);
- g_print("player_pause returned [%d]", bRet);
- } else {
- for (i = 0; i < g_handle_num; i++) {
- bRet = player_pause(g_player[i]);
- g_print("player_pause returned [%d]", bRet);
- }
- }
-}
-
-static void _player_state()
-{
- player_state_e state;
- player_get_state(g_player[0], &state);
- g_print(" ==> [Player_Test] Current Player State : %d\n", state);
-}
-
-static void _player_set_progressive_download()
-{
- player_set_progressive_download_path(g_player[0], "/home/owner/test.pd");
- player_set_progressive_download_message_cb(g_player[0], progress_down_cb, (void *)g_player[0]);
-}
-
-static void _player_get_progressive_download_status()
-{
- int bRet;
- unsigned long curr, total;
- bRet = player_get_progressive_download_status(g_player[0], &curr, &total);
- g_print("player_get_progressive_download_status return[%d] ==> [Player_Test] progressive download status : %lu/%lu\n", bRet, curr, total);
-}
-
-static void set_volume(float volume)
-{
- if (player_set_volume(g_player[0], 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[0], 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[0], mute) != PLAYER_ERROR_NONE)
- g_print("failed to set_mute\n");
-}
-
-static void get_mute(bool * mute)
-{
- player_is_muted(g_player[0], mute);
- g_print(" ==> [Player_Test] mute = %d\n", *mute);
-}
-
-static void set_sound_type(sound_type_e type)
-{
- if (player_set_sound_type(g_player[0], type) != PLAYER_ERROR_NONE)
- g_print("failed to set sound type(%d)\n", type);
- else
- g_print("set sound type(%d) success", type);
-}
-
-void focus_callback(sound_stream_info_h stream_info, sound_stream_focus_change_reason_e reason_for_change, const char *additional_info, void *user_data)
-{
- g_print("FOCUS callback is called, reason_for_change(%d), additional_info(%s), userdata(%p)", reason_for_change, additional_info, user_data);
- return;
-}
-
-static void set_sound_stream_info(int type)
-{
- if (g_stream_info_h) {
- g_print("stream information is already set, please destory handle and try again\n");
- return;
- }
- if (sound_manager_create_stream_information(type, focus_callback, g_player[0], &g_stream_info_h)) {
- g_print("failed to create stream_information()\n");
- return;
- }
- if (player_set_audio_policy_info(g_player[0], g_stream_info_h) != PLAYER_ERROR_NONE)
- g_print("failed to set sound stream information(%p)\n", g_stream_info_h);
- else
- g_print("set stream information(%p) success", g_stream_info_h);
-}
-
-static void get_position()
-{
- int position = 0;
- int ret;
- ret = player_get_play_position(g_player[0], &position);
- g_print(" ==> [Player_Test] player_get_play_position()%d return : %d\n", ret, position);
-}
-
-static void set_position(int position)
-{
- if (player_set_play_position(g_player[0], position, TRUE, seek_completed_cb, g_player[0]) != PLAYER_ERROR_NONE)
- g_print("failed to set position\n");
-}
-
-static void set_playback_rate(float rate, bool streaming)
-{
- if (streaming) {
- if (player_set_streaming_playback_rate(g_player[0], rate) != PLAYER_ERROR_NONE)
- g_print("failed to set streaming playback rate\n");
- } else {
- if (player_set_playback_rate(g_player[0], rate) != PLAYER_ERROR_NONE)
- g_print("failed to set playback rate\n");
- }
-}
-
-static void get_duration()
-{
- int duration = 0;
- int ret;
- ret = player_get_duration(g_player[0], &duration);
- g_print(" ==> [Player_Test] player_get_duration() return : %d\n", ret);
- g_print(" ==> [Player_Test] Duration: [%d ] msec\n", duration);
-}
-
-static void audio_frame_decoded_cb_ex()
-{
- int ret;
-
-#if DUMP_OUTBUF
- fp_out1 = fopen("/home/owner/content/out1.pcm", "wb");
- fp_out2 = fopen("/home/owner/content/out2.pcm", "wb");
- if (!fp_out1 || !fp_out2) {
- g_print("File open error\n");
- return;
- }
-#endif
-
- ret = player_set_pcm_extraction_mode(g_player[0], false, _audio_frame_decoded_cb_ex, &ret);
- g_print(" ==> [Player_Test] player_set_audio_frame_decoded_cb_ex return: %d\n", ret);
-}
-
-static void set_pcm_spec()
-{
- int ret = 0;
-
- ret = player_set_pcm_spec(g_player[0], "F32LE", 44100, 2);
- g_print("[Player_Test] set_pcm_spec return: %d\n", ret);
-}
-
-static void get_stream_info()
-{
- int w = 0;
- int h = 0;
-
- char *value = NULL;
- player_get_content_info(g_player[0], PLAYER_CONTENT_INFO_ALBUM, &value);
- g_print(" ==> [Player_Test] PLAYER_CONTENT_INFO_ALBUM: [%s ] \n", value);
- player_get_content_info(g_player[0], PLAYER_CONTENT_INFO_ARTIST, &value);
- g_print(" ==> [Player_Test] PLAYER_CONTENT_INFO_ARTIST: [%s ] \n", value);
- player_get_content_info(g_player[0], PLAYER_CONTENT_INFO_AUTHOR, &value);
- g_print(" ==> [Player_Test] PLAYER_CONTENT_INFO_AUTHOR: [%s ] \n", value);
- player_get_content_info(g_player[0], PLAYER_CONTENT_INFO_GENRE, &value);
- g_print(" ==> [Player_Test] PLAYER_CONTENT_INFO_GENRE: [%s ] \n", value);
- player_get_content_info(g_player[0], 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[0], &album, &size);
- g_print(" ==> [Player_Test] Album art : [ data : %p, size : %d ]\n", (unsigned int *)album, size);
- if (value != NULL) {
- free(value);
- value = NULL;
- }
-
- int sample_rate;
- int channel;
- int bit_rate;
- int fps, v_bit_rate;
- player_get_audio_stream_info(g_player[0], &sample_rate, &channel, &bit_rate);
- g_print(" ==> [Player_Test] Sample Rate: [%d ] , Channel: [%d ] , Bit Rate: [%d ] \n", sample_rate, channel, bit_rate);
-
- player_get_video_stream_info(g_player[0], &fps, &v_bit_rate);
- g_print(" ==> [Player_Test] fps: [%d ] , Bit Rate: [%d ] \n", fps, v_bit_rate);
-
- char *audio_codec = NULL;
- char *video_codec = NULL;
- player_get_codec_info(g_player[0], &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[0], &w, &h);
- g_print(" ==> [Player_Test] Width: [%d ] , Height: [%d ] \n", w, h);
-}
-
-static void set_looping(bool looping)
-{
- if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
- if (player_set_looping(g_player[0], looping) != PLAYER_ERROR_NONE)
- g_print("failed to set_looping\n");
- } else {
- int i = 0;
- for (i = 0; i < g_handle_num; i++) {
- if (player_set_looping(g_player[i], looping) != PLAYER_ERROR_NONE)
- g_print("failed to set_looping\n");
- }
- }
-}
-
-static void get_looping(bool *looping)
-{
- player_is_looping(g_player[0], looping);
- g_print(" ==> [Player_Test] looping = %d\n", *looping);
-}
-
-static void change_surface(int option)
-{
- player_display_type_e surface_type = 0;
- int ret = PLAYER_ERROR_NONE;
-#ifdef _ACTIVATE_EOM_
- int hdmi_output_id;
- eom_output_mode_e output_mode;
-#endif
- switch (option) {
- case 0:
- /* X surface */
- surface_type = PLAYER_DISPLAY_TYPE_OVERLAY;
- g_print("change surface type to X\n");
- break;
-#ifdef TIZEN_MOBILE
- case 1:
- /* EVAS surface */
- surface_type = PLAYER_DISPLAY_TYPE_EVAS;
- g_print("change surface type to EVAS\n");
- break;
-#endif
- case 2:
- g_print("change surface type to NONE\n");
- player_set_display(g_player[0], PLAYER_DISPLAY_TYPE_NONE, NULL);
- break;
- default:
- g_print("invalid surface type\n");
- return;
- }
-
- if (surface_type == g_current_surface_type) {
- g_print("same with the previous surface type(%d)\n", g_current_surface_type);
- return;
- } else {
- player_state_e player_state = PLAYER_STATE_NONE;
- ret = player_get_state(g_player[0], &player_state);
- if (ret)
- g_print("failed to player_get_state(), ret(0x%x)\n", ret);
-
- reset_display();
-
- if (surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
-#ifdef _ACTIVATE_EOM_
- hdmi_output_id = eom_get_output_id("HDMI");
- if (hdmi_output_id == 0)
- g_print("[eom] error : HDMI output id is NULL.\n");
-
- eom_get_output_mode(hdmi_output_id, &output_mode);
- if (output_mode == EOM_OUTPUT_MODE_NONE) {
-#endif
- if (!g_xid) {
- g_xid = create_win(PACKAGE);
- if (g_xid == NULL)
- return;
- g_print("create xid %p\n", g_xid);
- create_render_rect_and_bg(g_xid);
- elm_win_activate(g_xid);
- evas_object_show(g_xid);
- g_xid = selected_xid;
- }
-#ifdef _ACTIVATE_EOM_
- } else {
- /* for external */
- }
-#endif
- ret = player_set_display(g_player[0], surface_type, GET_DISPLAY(selected_xid));
- } else {
- if (!g_xid) {
- g_xid = create_win(PACKAGE);
- if (g_xid == NULL)
- return;
- g_print("create xid %p\n", g_xid);
- create_render_rect_and_bg(g_xid);
- elm_win_activate(g_xid);
- evas_object_show(g_xid);
- }
- int i = 0;
- for (i = 0; i < g_handle_num; i++) {
- /* Create evas image object for EVAS surface */
- if (!g_eo[i]) {
- g_eo[i] = create_image_object(g_xid);
- g_print("create eo[%d] %p\n", i, g_eo[i]);
- evas_object_image_size_set(g_eo[i], 500, 500);
- evas_object_image_fill_set(g_eo[i], 0, 0, 500, 500);
- evas_object_resize(g_eo[i], 500, 500);
- evas_object_move(g_eo[i], i * 20, i * 20);
- }
- ret = player_set_display(g_player[i], surface_type, g_eo[i]);
-
- }
- }
- if (ret) {
- g_print("failed to set display, surface_type(%d)\n", surface_type);
- return;
- }
- g_current_surface_type = surface_type;
- }
- return;
-}
-
-static void set_display_mode(int mode)
-{
- if (player_set_display_mode(g_player[0], 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[0], &mode);
- g_print(" ==> [Player_Test] Display mode: [%d ] \n", mode);
-}
-
-static void set_display_rotation(int rotation)
-{
- if (player_set_display_rotation(g_player[0], 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_display_rotation(g_player[0], &rotation);
- g_print(" ==> [Player_Test] X11 Display rotation: [%d ] \n", rotation);
-}
-
-static void set_display_visible(bool visible)
-{
- if (player_set_display_visible(g_player[0], visible) != PLAYER_ERROR_NONE)
- g_print("failed to player_set_x11_display_visible\n");
-}
-
-static void get_display_visible(bool *visible)
-{
- player_is_display_visible(g_player[0], visible);
- g_print(" ==> [Player_Test] X11 Display Visible = %d\n", *visible);
-}
-
-static void set_display_dst_roi(int x, int y, int w, int h)
-{
-#if 0
- if (player_set_x11_display_dst_roi(g_player[0], x, y, w, h) != PLAYER_ERROR_NONE)
- g_print("failed to player_set_x11_display_dst_roi\n");
- else
- g_print(" ==> [Player_Test] set X11 Display DST ROI (x:%d, y:%d, w:%d, h:%d)\n", x, y, w, h);
-#endif
-}
-
-static void get_display_dst_roi()
-{
-#if 0
- int x = 0;
- int y = 0;
- int w = 0;
- int h = 0;
-
- if (player_get_x11_display_dst_roi(g_player[0], &x, &y, &w, &h) != PLAYER_ERROR_NONE)
- g_print("failed to player_get_x11_display_dst_roi\n");
- else
- g_print(" ==> [Player_Test] got X11 Display DST ROI (x:%d, y:%d, w:%d, h:%d)\n", x, y, w, h);
-#endif
-}
-
-static void set_display_roi_mode(int mode)
-{
-#if 0
- if (player_set_x11_display_roi_mode(g_player[0], (player_display_roi_mode_e) mode) != PLAYER_ERROR_NONE)
- g_print("failed to player_set_x11_display_roi_mode\n");
- else
- g_print(" ==> [Player_Test] set X11 Display ROI mode (%d)\n", mode);
-#endif
-}
-
-static void get_display_roi_mode()
-{
-#if 0
- player_display_roi_mode_e mode;
- if (player_get_x11_display_roi_mode(g_player[0], &mode) != PLAYER_ERROR_NONE)
- g_print("failed to player_get_x11_display_roi_mode\n");
- else
- g_print(" ==> [Player_Test] got X11 Display ROI mode (%d)\n", mode);
-#endif
-}
-
-static void set_display_src_crop(int x, int y, int w, int h)
-{
-#if 0
- if (player_set_x11_display_src_crop(g_player[0], x, y, w, h) != PLAYER_ERROR_NONE)
- g_print("failed to player_set_x11_display_src_crop\n");
- else
- g_print(" ==> [Player_Test] set X11 Display SRC CROP (x:%d, y:%d, w:%d, h:%d)\n", x, y, w, h);
-#endif
-}
-
-static void get_display_src_crop()
-{
-#if 0
- int x = 0;
- int y = 0;
- int w = 0;
- int h = 0;
-
- if (player_get_x11_display_src_crop(g_player[0], &x, &y, &w, &h) != PLAYER_ERROR_NONE)
- g_print("failed to player_get_x11_display_src_crop\n");
- else
- g_print(" ==> [Player_Test] got X11 Display SRC CROP (x:%d, y:%d, w:%d, h:%d)\n", x, y, w, h);
-#endif
-}
-
-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);
- player_set_subtitle_path(g_player[0], g_subtitle_uri);
-}
-
-static void switch_subtitle(int index)
-{
- char *lang_code = NULL;
- if (player_select_track(g_player[0], PLAYER_STREAM_TYPE_TEXT, index) != PLAYER_ERROR_NONE)
- g_print("player_select_track failed\n");
-
- if (player_get_track_language_code(g_player[0], PLAYER_STREAM_TYPE_TEXT, index, &lang_code) == PLAYER_ERROR_NONE) {
- g_print("selected track code %s\n", lang_code);
- free(lang_code);
- }
-}
-
-static void capture_video()
-{
- if (player_capture_video(g_player[0], video_captured_cb, NULL) != PLAYER_ERROR_NONE)
- g_print("failed to player_capture_video\n");
-}
-
-static void decoding_audio()
-{
-#if 0
- int ret;
- char *suffix, *dump_path;
- GDateTime *time = g_date_time_new_now_local();
-
- suffix = g_date_time_format(time, "%Y%m%d_%H%M%S.pcm");
- dump_path = g_strjoin(NULL, PLAYER_TEST_DUMP_PATH_PREFIX, suffix, NULL);
- g_pcm_fd = fopen(dump_path, "w+");
- g_free(dump_path);
- g_free(suffix);
- g_date_time_unref(time);
- if (!g_pcm_fd)
- g_print("Can not create debug dump file");
-
- ret = player_set_audio_frame_decoded_cb(g_player[0], 0, 0, audio_frame_decoded_cb, (void *)g_player[0]);
- if (ret != PLAYER_ERROR_NONE)
- g_print("player_set_audio_frame_decoded_cb is failed (errno = %d) \n", ret);
-#endif
-}
-
-static void set_audio_eq(int value)
-{
- bool available = FALSE;
- int index, min, max;
-
- if (value) {
- if (player_audio_effect_equalizer_is_available(g_player[0], &available) != PLAYER_ERROR_NONE)
- g_print("failed to player_audio_effect_equalizer_is_available\n");
-
- if (available) {
- if ((player_audio_effect_get_equalizer_bands_count(g_player[0], &index) != PLAYER_ERROR_NONE) ||
- (player_audio_effect_get_equalizer_level_range(g_player[0], &min, &max) != PLAYER_ERROR_NONE) ||
- (player_audio_effect_set_equalizer_band_level(g_player[0], index / 2, max) != PLAYER_ERROR_NONE))
- g_print("failed to player_audio_effect_set_equalizer_band_level index %d, level %d\n", index / 2, max);
- }
- }
-
- else {
- if (player_audio_effect_equalizer_clear(g_player[0]) != PLAYER_ERROR_NONE)
- g_print("failed to player_audio_effect_equalizer_clear\n");
- }
-
-}
-
-static void get_audio_eq()
-{
- int index, min, max, value;
- player_audio_effect_get_equalizer_bands_count(g_player[0], &index);
- g_print(" ==> [Player_Test] eq bands count: [%d] \n", index);
- player_audio_effect_get_equalizer_level_range(g_player[0], &min, &max);
- g_print(" ==> [Player_Test] eq bands range: [%d~%d] \n", min, max);
- player_audio_effect_get_equalizer_band_level(g_player[0], index / 2, &value);
- g_print(" ==> [Player_Test] eq bands level: [%d] \n", value);
- player_audio_effect_get_equalizer_band_frequency(g_player[0], 0, &value);
- g_print(" ==> [Player_Test] eq bands frequency: [%d] \n", value);
- player_audio_effect_get_equalizer_band_frequency_range(g_player[0], 0, &value);
- g_print(" ==> [Player_Test] eq bands frequency range: [%d] \n", value);
-}
-
-void quit_program()
-{
- int i = 0;
-
- if (g_pcm_fd)
- fclose(g_pcm_fd);
-
- for (i = 0; i < g_handle_num; i++) {
- if (g_player[i] != NULL) {
- player_unprepare(g_player[i]);
- player_destroy(g_player[i]);
- g_player[i] = 0;
- }
- }
- elm_exit();
-
- if (g_audio_fmt)
- media_format_unref(g_audio_fmt);
-
- if (g_video_fmt)
- media_format_unref(g_video_fmt);
-}
-
-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, "z", 1) == 0) {
- g_menu_state = CURRENT_STATUS_SOUND_TYPE;
- } else if (strncmp(cmd, "k", 1) == 0) {
- g_menu_state = CURRENT_STATUS_SOUND_STREAM_INFO;
- } 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, "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, "x", 1) == 0) {
- g_menu_state = CURRENT_STATUS_DISPLAY_DST_ROI;
- } else if (strncmp(cmd, "y", 1) == 0) {
- get_display_dst_roi();
- } else if (strncmp(cmd, "M", 1) == 0) {
- g_menu_state = CURRENT_STATUS_DISPLAY_ROI_MODE;
- } else if (strncmp(cmd, "N", 1) == 0) {
- get_display_roi_mode();
- } else if (strncmp(cmd, "F", 1) == 0) {
- g_menu_state = CURRENT_STATUS_DISPLAY_SRC_CROP;
- } else if (strncmp(cmd, "G", 1) == 0) {
- get_display_src_crop();
- } 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, "q", 1) == 0) {
- quit_pushing = TRUE;
- quit_program();
- } else if (strncmp(cmd, "E", 1) == 0) {
- g_menu_state = CURRENT_STATUS_AUDIO_EQUALIZER;
- } else if (strncmp(cmd, "H", 1) == 0) {
- get_audio_eq();
- } else {
- g_print("unknown menu \n");
- }
- } else if (len == 2) {
- if (strncmp(cmd, "pr", 2) == 0) {
- /* sync */
- _player_prepare(FALSE);
- } else if (strncmp(cmd, "pa", 2) == 0) {
- /* async */
- _player_prepare(TRUE);
- } else if (strncmp(cmd, "un", 2) == 0) {
- _player_unprepare();
- } else if (strncmp(cmd, "dt", 2) == 0) {
- _player_destroy();
- } else if (strncmp(cmd, "sp", 2) == 0) {
- _player_set_progressive_download();
- } else if (strncmp(cmd, "gp", 2) == 0) {
- _player_get_progressive_download_status();
- } else if (strncmp(cmd, "mp", 2) == 0) {
- g_memory_playback = (g_memory_playback ? FALSE : TRUE);
- g_print("memory playback = %d\n", g_memory_playback);
- } else if (strncmp(cmd, "ds", 2) == 0) {
- g_menu_state = CURRENT_STATUS_DISPLAY_SURFACE_CHANGE;
- } else if (strncmp(cmd, "nb", 2) == 0) {
- g_menu_state = CURRENT_STATUS_HANDLE_NUM;
- } else if (strncmp(cmd, "tr", 2) == 0) {
- g_menu_state = CURRENT_STATUS_PLAYBACK_RATE;
- } else if (strncmp(cmd, "ss", 2) == 0) {
- g_menu_state = CURRENT_STATUS_SWITCH_SUBTITLE;
- } else if (strncmp(cmd, "X3", 2) == 0) {
- audio_frame_decoded_cb_ex();
- } else if (strncmp(cmd, "X4", 2) == 0) {
- set_pcm_spec();
- } else {
- g_print("unknown menu \n");
- }
- } else {
- if (strncmp(cmd, "trs", 3) == 0)
- g_menu_state = CURRENT_STATUS_STREAMING_PLAYBACK_RATE;
- 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] \t", MMTS_SAMPLELIST_INI_DEFAULT_PATH);
- g_print("nb. num. of handles \n");
- 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("pa. Prepare async \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 \t");
- g_print("dt. Destroy \n");
- g_print("[State] S. Player State \n");
- g_print("[ volume ] f. Set Volume\t");
- g_print("g. Get Volume\t");
- g_print("z. Set Sound type\t");
- g_print("k. Set Sound Stream Info.\t");
- g_print("[ mute ] h. Set Mute\t");
- g_print("i. Get Mute\n");
- g_print("[audio eq] E. Set Audio EQ\t");
- g_print("H. Get Audio EQ\n");
- g_print("[position] j. Set Position \t");
- g_print("l. Get Position\n");
- g_print("[trick] tr. set playback rate\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("[display] v. Set display visible\t");
- g_print("w. Get display visible\n");
- g_print("[display] ds. Change display surface type\n");
- g_print("[x display] r. Set display mode\t");
- g_print("s. Get display mode\n");
- g_print("[x display] t. Set display Rotation\t");
- g_print("[Track] tl. Get Track language info(single only)\n");
- g_print("[subtitle] A. Set(or change) subtitle path\n");
- g_print("[subtitle] ss. Select(or change) subtitle track\n");
- g_print("[Video Capture] C. Capture \n");
- g_print("[etc] sp. Set Progressive Download\t");
- g_print("gp. Get Progressive Download status\n");
- g_print("mp. memory playback\n");
- g_print("[audio_frame_decoded_cb_ex] X3. (input) set audio_frame_decoded_cb_ex callback \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_HANDLE_NUM) {
- g_print("*** input number of handles.(recommended only for EVAS surface)\n");
- } 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_SOUND_TYPE) {
- g_print("*** input sound type.(0:SYSTEM 1:NOTIFICATION 2:ALARM 3:RINGTONE 4:MEDIA 5:CALL 6:VOIP 7:FIXED)\n");
- } else if (g_menu_state == CURRENT_STATUS_SOUND_STREAM_INFO) {
- g_print("*** input sound stream type.(0:MEDIA 1:SYSTEM 2:ALARM 3:NOTIFICATION 4:RINGTONE 5:CALL 6:VOIP)\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_LOOPING) {
- g_print("*** input looping value.(0: Not Looping, 1: Looping) \n");
- } else if (g_menu_state == CURRENT_STATUS_DISPLAY_SURFACE_CHANGE) {
- g_print("*** input display surface type.(0: X surface, 1: EVAS surface) \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, 4: ORIGIN_OR_LETTER, 5: ROI) \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_DISPLAY_ROI_MODE) {
- g_print("*** input display roi mode.(0: FULL_SCREEN, 1: LETTER BOX)\n");
- } else if (g_menu_state == CURRENT_STATUS_DISPLAY_DST_ROI) {
- g_print("*** input display roi value sequentially.(x, y, w, h)\n");
- } else if (g_menu_state == CURRENT_STATUS_DISPLAY_SRC_CROP) {
- g_print("*** input display source crop value sequentially.(x, y, w, h)\n");
- } else if (g_menu_state == CURRENT_STATUS_SUBTITLE_FILENAME) {
- g_print(" *** input subtitle file path.\n");
- } else if (g_menu_state == CURRENT_STATUS_AUDIO_EQUALIZER) {
- g_print(" *** input audio eq value.(0: UNSET, 1: SET) \n");
- } else if (g_menu_state == CURRENT_STATUS_PLAYBACK_RATE || g_menu_state == CURRENT_STATUS_STREAMING_PLAYBACK_RATE) {
- g_print(" *** input playback rate.(-5.0 ~ 5.0)\n");
- } else if (g_menu_state == CURRENT_STATUS_SWITCH_SUBTITLE) {
- int count = 0, cur_index = 0;
- int ret = 0;
-
- ret = player_get_track_count(g_player[0], PLAYER_STREAM_TYPE_TEXT, &count);
- if (ret != PLAYER_ERROR_NONE)
- g_print("player_get_track_count fail!!!!\n");
- else if (count) {
- g_print("Total subtitle tracks = %d \n", count);
- player_get_current_track(g_player[0], PLAYER_STREAM_TYPE_TEXT, &cur_index);
- g_print("Current index = %d \n", cur_index);
- g_print(" *** input correct index 0 to %d\n:", (count - 1));
- } else
- g_print("no track\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_HANDLE_NUM:
- {
- int num_handle = atoi(cmd);
- if (0 >= num_handle || num_handle > MAX_HANDLE)
- g_print("not supported this number for handles(%d)\n", num_handle);
- else
- g_handle_num = num_handle;
-
- reset_menu_state();
- }
- 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_SOUND_TYPE:
- {
- int type = atoi(cmd);
- set_sound_type(type);
- reset_menu_state();
- }
- break;
- case CURRENT_STATUS_SOUND_STREAM_INFO:
- {
- int type = atoi(cmd);
- set_sound_stream_info(type);
- 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_LOOPING:
- {
- int looping = atoi(cmd);
- set_looping(looping);
- reset_menu_state();
- }
- break;
- case CURRENT_STATUS_DISPLAY_SURFACE_CHANGE:
- {
- int type = atoi(cmd);
- change_surface(type);
- 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_DISPLAY_DST_ROI:
- {
- int value = atoi(cmd);
- static int roi_x = 0;
- static int roi_y = 0;
- static int roi_w = 0;
- static int roi_h = 0;
- static int cnt = 0;
- switch (cnt) {
- case 0:
- roi_x = value;
- cnt++;
- break;
- case 1:
- roi_y = value;
- cnt++;
- break;
- case 2:
- roi_w = value;
- cnt++;
- break;
- case 3:
- cnt = 0;
- roi_h = value;
- set_display_dst_roi(roi_x, roi_y, roi_w, roi_h);
- roi_x = roi_y = roi_w = roi_h = 0;
- reset_menu_state();
- break;
- default:
- break;
- }
- }
- break;
- case CURRENT_STATUS_DISPLAY_SRC_CROP:
- {
- int value = atoi(cmd);
- static int crop_x = 0;
- static int crop_y = 0;
- static int crop_w = 0;
- static int crop_h = 0;
- static int crop_cnt = 0;
- switch (crop_cnt) {
- case 0:
- crop_x = value;
- crop_cnt++;
- break;
- case 1:
- crop_y = value;
- crop_cnt++;
- break;
- case 2:
- crop_w = value;
- crop_cnt++;
- break;
- case 3:
- crop_cnt = 0;
- crop_h = value;
- set_display_src_crop(crop_x, crop_y, crop_w, crop_h);
- crop_x = crop_y = crop_w = crop_h = 0;
- reset_menu_state();
- break;
- default:
- break;
- }
- }
- break;
- case CURRENT_STATUS_DISPLAY_ROI_MODE:
- {
- int value = atoi(cmd);
- set_display_roi_mode(value);
- reset_menu_state();
- }
- break;
- case CURRENT_STATUS_SUBTITLE_FILENAME:
- {
- input_subtitle_filename(cmd);
- reset_menu_state();
- }
- break;
- case CURRENT_STATUS_AUDIO_EQUALIZER:
- {
- int value = atoi(cmd);
- set_audio_eq(value);
- reset_menu_state();
- }
- break;
- case CURRENT_STATUS_PLAYBACK_RATE:
- {
- float rate = atof(cmd);
- set_playback_rate(rate, FALSE);
- reset_menu_state();
- }
- break;
- case CURRENT_STATUS_STREAMING_PLAYBACK_RATE:
- {
- float rate = atof(cmd);
- set_playback_rate(rate, TRUE);
- reset_menu_state();
- }
- break;
- case CURRENT_STATUS_SWITCH_SUBTITLE:
- {
- int index = atoi(cmd);
- switch_subtitle(index);
- reset_menu_state();
- }
- break;
- }
- g_timeout_add(100, timeout_menu_display, 0);
-}
-
-gboolean input(GIOChannel *channel)
-{
- gchar buf[MAX_STRING_LEN];
- gsize read;
- GError *error = NULL;
-
- g_io_channel_read_chars(channel, buf, MAX_STRING_LEN, &read, &error);
- 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_channel_set_flags(stdin_channel, G_IO_FLAG_NONBLOCK, NULL);
- g_io_add_watch(stdin_channel, G_IO_IN, (GIOFunc)input, NULL);
-
- displaymenu();
- memset(&ad, 0x0, sizeof(appdata));
- ops.data = &ad;
-
- return appcore_efl_main(PACKAGE, &argc, &argv, &ops);
-}
+++ /dev/null
-/*
-* 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_2_H__
-#define __TIZEN_MEDIA_PLAYER_2_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* __TIZEN_MEDIA_PLAYER_2_H__ */
+++ /dev/null
-/*
-* 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_2_PRIVATE_H__
-#define __TIZEN_MEDIA_PLAYER_2_PRIVATE_H__
-#include <tbm_bufmgr.h>
-#include <Evas.h>
-#include "player.h"
-#include "mm_types.h"
-#include "muse_core.h"
-#include "muse_core_ipc.h"
-#include "player2_wayland.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-#define LOG_TAG "TIZEN_N_PLAYER"
-
-#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")
-
-#define PLAYER_RANGE_ARG_CHECK(arg, min, max) \
- PLAYER_CHECK_CONDITION(arg <= max,PLAYER_ERROR_INVALID_PARAMETER,"PLAYER_ERROR_INVALID_PARAMETER") \
- PLAYER_CHECK_CONDITION(arg >= min,PLAYER_ERROR_INVALID_PARAMETER,"PLAYER_ERROR_INVALID_PARAMETER")
-
-#define MUSE_PLAYER_HEAD_GAP(api) ((api)/(1000)+(1))*(1000)
-
-typedef enum {
- MUSE_PLAYER_API_CREATE = API_CREATE,
- MUSE_PLAYER_API_DESTROY = API_DESTROY,
- MUSE_PLAYER_API_PREPARE,
- MUSE_PLAYER_API_PREPARE_ASYNC,
- MUSE_PLAYER_API_UNPREPARE,
- MUSE_PLAYER_API_SET_URI,
- MUSE_PLAYER_API_START,
- MUSE_PLAYER_API_STOP,
- MUSE_PLAYER_API_PAUSE,
- MUSE_PLAYER_API_SET_MEMORY_BUFFER,
- MUSE_PLAYER_API_DEINIT_MEMORY_BUFFER,
- MUSE_PLAYER_API_GET_STATE,
- MUSE_PLAYER_API_SET_VOLUME,
- MUSE_PLAYER_API_GET_VOLUME,
- MUSE_PLAYER_API_SET_SOUND_TYPE,
- MUSE_PLAYER_API_SET_AUDIO_POLICY_INFO,
- MUSE_PLAYER_API_SET_AUDIO_LATENCY_MODE,
- MUSE_PLAYER_API_GET_AUDIO_LATENCY_MODE,
- MUSE_PLAYER_API_SET_PLAY_POSITION,
- MUSE_PLAYER_API_GET_PLAY_POSITION,
- MUSE_PLAYER_API_SET_MUTE,
- MUSE_PLAYER_API_IS_MUTED,
- MUSE_PLAYER_API_SET_LOOPING,
- MUSE_PLAYER_API_IS_LOOPING,
- MUSE_PLAYER_API_GET_DURATION,
- MUSE_PLAYER_API_SET_DISPLAY,
- MUSE_PLAYER_API_SET_DISPLAY_MODE,
- MUSE_PLAYER_API_GET_DISPLAY_MODE,
- MUSE_PLAYER_API_SET_PLAYBACK_RATE,
- MUSE_PLAYER_API_SET_DISPLAY_ROTATION,
- MUSE_PLAYER_API_GET_DISPLAY_ROTATION,
- MUSE_PLAYER_API_SET_DISPLAY_VISIBLE,
- MUSE_PLAYER_API_IS_DISPLAY_VISIBLE,
- MUSE_PLAYER_API_RESIZE_VIDEO_RENDER_RECT,
- MUSE_PLAYER_API_GET_CONTENT_INFO,
- MUSE_PLAYER_API_GET_CODEC_INFO,
- MUSE_PLAYER_API_GET_AUDIO_STREAM_INFO,
- MUSE_PLAYER_API_GET_VIDEO_STREAM_INFO,
- MUSE_PLAYER_API_GET_VIDEO_SIZE,
- MUSE_PLAYER_API_GET_ALBUM_ART,
- MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_BANDS_COUNT,
- MUSE_PLAYER_API_AUDIO_EFFECT_SET_EQUALIZER_ALL_BANDS,
- MUSE_PLAYER_API_AUDIO_EFFECT_SET_EQUALIZER_BAND_LEVEL,
- MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_BAND_LEVEL,
- MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_LEVEL_RANGE,
- MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_BAND_FREQUENCY,
- MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_BAND_FREQUENCY_RANGE,
- MUSE_PLAYER_API_AUDIO_EFFECT_EQUALIZER_CLEAR,
- MUSE_PLAYER_API_AUDIO_EFFECT_EQUALIZER_IS_AVAILABLE,
- MUSE_PLAYER_API_SET_PROGRESSIVE_DOWNLOAD_PATH,
- MUSE_PLAYER_API_GET_PROGRESSIVE_DOWNLOAD_STATUS,
- MUSE_PLAYER_API_CAPTURE_VIDEO,
- MUSE_PLAYER_API_SET_STREAMING_COOKIE,
- MUSE_PLAYER_API_SET_STREAMING_USER_AGENT,
- MUSE_PLAYER_API_GET_STREAMING_DOWNLOAD_PROGRESS,
- MUSE_PLAYER_API_SET_SUBTITLE_PATH,
- MUSE_PLAYER_API_SET_SUBTITLE_POSITION_OFFSET,
- MUSE_PLAYER_API_PUSH_MEDIA_STREAM,
- MUSE_PLAYER_API_SET_MEDIA_STREAM_INFO,
- MUSE_PLAYER_API_SET_CALLBACK,
- MUSE_PLAYER_API_MEDIA_PACKET_FINALIZE_CB,
- MUSE_PLAYER_API_SET_MEDIA_STREAM_BUFFER_MAX_SIZE,
- MUSE_PLAYER_API_GET_MEDIA_STREAM_BUFFER_MAX_SIZE,
- MUSE_PLAYER_API_SET_MEDIA_STREAM_BUFFER_MIN_THRESHOLD,
- MUSE_PLAYER_API_GET_MEDIA_STREAM_BUFFER_MIN_THRESHOLD,
- MUSE_PLAYER_API_GET_TRACK_COUNT,
- MUSE_PLAYER_API_GET_CURRENT_TRACK,
- MUSE_PLAYER_API_SELECT_TRACK,
- MUSE_PLAYER_API_GET_TRACK_LANGUAGE_CODE,
- MUSE_PLAYER_API_SET_PCM_EXTRACTION_MODE,
- MUSE_PLAYER_API_SET_PCM_SPEC,
- MUSE_PLAYER_API_SET_STREAMING_PLAYBACK_RATE,
- MUSE_PLAYER_API_MAX
-} muse_player_api_e;
-
-typedef enum {
- MUSE_PLAYER_CB_EVENT = MUSE_PLAYER_HEAD_GAP(MUSE_PLAYER_API_MAX),
- MUSE_PLAYER_CB_MAX
-} muse_player_cb_e;
-
-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_MEDIA_PACKET_VIDEO_FRAME,
- _PLAYER_EVENT_TYPE_AUDIO_FRAME,
- _PLAYER_EVENT_TYPE_VIDEO_FRAME_RENDER_ERROR,
- _PLAYER_EVENT_TYPE_PD,
- _PLAYER_EVENT_TYPE_SUPPORTED_AUDIO_EFFECT,
- _PLAYER_EVENT_TYPE_SUPPORTED_AUDIO_EFFECT_PRESET,
- _PLAYER_EVENT_TYPE_MISSED_PLUGIN,
-#ifdef _PLAYER_FOR_PRODUCT
- _PLAYER_EVENT_TYPE_IMAGE_BUFFER,
- _PLAYER_EVENT_TYPE_SELECTED_SUBTITLE_LANGUAGE,
-#endif
- _PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS,
- _PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS,
- _PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO,
- _PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO,
- _PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK,
- _PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK,
- _PLAYER_EVENT_TYPE_AUDIO_STREAM_CHANGED,
- _PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED,
- _PLAYER_EVENT_TYPE_VIDEO_BIN_CREATED,
- _PLAYER_EVENT_TYPE_NUM
-} _player_event_e;
-
-#ifndef USE_ECORE_FUNCTIONS
-typedef enum {
- PLAYER_MESSAGE_NONE,
- PLAYER_MESSAGE_PREPARED,
- PLAYER_MESSAGE_ERROR,
- PLAYER_MESSAGE_SEEK_DONE,
- PLAYER_MESSAGE_EOS,
- PLAYER_MESSAGE_LOOP_EXIT,
- PLAYER_MESSAGE_MAX
-} _player_message_e;
-#endif
-
-typedef struct _player_s {
- MMHandleType mm_handle;
- const void* user_cb[_PLAYER_EVENT_TYPE_NUM];
- void* user_data[_PLAYER_EVENT_TYPE_NUM];
-#ifdef HAVE_WAYLAND
- void* wl_display;
-#endif
- 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;
- pthread_t prepare_async_thread;
-#ifdef USE_ECORE_FUNCTIONS
- GHashTable *ecore_jobs;
-#else
- pthread_t message_thread;
- GQueue *message_queue;
- GMutex message_queue_lock;
- GCond message_queue_cond;
- int current_message;
-#endif
- player_error_e error_code;
- bool is_doing_jobs;
- media_format_h pkt_fmt;
-} player_s;
-
-typedef struct _ret_msg_s{
- gint api;
- gchar *msg;
- struct _ret_msg_s *next;
-} ret_msg_s;
-
-typedef struct {
- gint bufLen;
- gchar *recvMsg;
- gint recved;
- ret_msg_s *retMsgHead;
-} msg_buff_s;
-
-typedef struct _player_data{
- void *data;
- struct _player_data *next;
-} player_data_s;
-
-typedef struct {
- GThread *thread;
- GQueue *queue;
- GMutex qlock;
- GMutex mutex;
- GCond cond;
- gboolean running;
-} player_event_queue;
-
-typedef struct _callback_cb_info {
- GThread *thread;
- gint running;
- gint fd;
- gint data_fd;
- gpointer user_cb[_PLAYER_EVENT_TYPE_NUM];
- gpointer user_data[_PLAYER_EVENT_TYPE_NUM];
- GMutex player_mutex;
- GCond player_cond[MUSE_PLAYER_API_MAX];
- msg_buff_s buff;
- player_event_queue event_queue;
- media_format_h pkt_fmt;
- MMHandleType local_handle;
- tbm_bufmgr bufmgr;
-} callback_cb_info_s;
-
-typedef struct {
- intptr_t bo;
- gboolean is_streaming;
- gint timeout;
-} server_info_s;
-
-typedef struct _player_cli_s{
- callback_cb_info_s *cb_info;
- player_data_s *head;
- server_info_s server;
- wl_client *wlclient;
- Evas_Object * eo;
- gboolean have_evas_callback;
-} player_cli_s;
-
-/* Internal handle */
-#define INT_HANDLE(h) ((h)->cb_info->local_handle)
-
-/* player callback infomatnio */
-#define CALLBACK_INFO(h) ((h)->cb_info)
-/* MSG Channel socket fd */
-#define MSG_FD(h) (CALLBACK_INFO(h)->fd)
-/* Data Channel socket fd */
-#define DATA_FD(h) (CALLBACK_INFO(h)->data_fd)
-/* TBM buffer manager */
-#define TBM_BUFMGR(h) (CALLBACK_INFO(h)->bufmgr)
-
-/* server tbm bo */
-#define SERVER_TBM_BO(h) ((h)->server.bo)
-/* content type is streaming */
-#define IS_STREAMING_CONTENT(h) ((h)->server.is_streaming)
-/* server state change timeout */
-#define SERVER_TIMEOUT(h) ((h)->server.timeout)
-
-int _get_api_timeout(player_cli_s *pc, muse_player_api_e api);
-int wait_for_cb_return(muse_player_api_e api, callback_cb_info_s *cb_info, char **ret_buf, int time_out);
-int player_sound_register(player_h player, int pid);
-int player_is_streaming(player_h player, bool *is_streaming);
-int player_set_evas_object_cb(player_h player, Evas_Object * eo);
-int player_unset_evas_object_cb(player_h player);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //__TIZEN_MEDIA_PLAYER_2_PRIVATE_H__
+++ /dev/null
-/*
-* 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_2_WLCLIENT_H__
-#define __TIZEN_MEDIA_PLAYER_2_WLCLIENT_H__
-#include <stdio.h>
-#include <tbm_bufmgr.h>
-#include <tizen-extension-client-protocol.h>
-#include <wayland-client.h>
-#include "mm_types.h"
-#include "mm_debug.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-typedef struct
-{
- struct wl_display *display;
- struct wl_registry *registry;
- struct tizen_surface *tz_surface;
- struct tizen_resource *tz_resource;
-} wl_client;
-int _wlclient_create (wl_client ** wlclient);
-int _wlclient_get_wl_window_wl_surface_id (wl_client * wlclient, struct wl_surface *surface, struct wl_display *display);
-void _wlclient_finalize (wl_client * wlclient);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __TIZEN_MEDIA_PLAYER_2_WLCLIENT_H__ */
+++ /dev/null
-/*
-* 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 __PLAYER_MSG_PRIVATE_H__
-#define __PLAYER_MSG_PRIVATE_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <muse_core_msg_json.h>
-#include <media_format.h>
-#include <tbm_bufmgr.h>
-#include <player2_private.h>
-
-#define CALLBACK_TIME_OUT 5
-
-typedef int32_t INT;
-typedef int64_t INT64;
-typedef intptr_t POINTER;
-typedef double DOUBLE;
-typedef const char* STRING;
-
-typedef enum {
- PUSH_MEDIA_BUF_TYPE_TBM,
- PUSH_MEDIA_BUF_TYPE_MSG,
- PUSH_MEDIA_BUF_TYPE_RAW
-} push_media_buf_type_e;
-
-typedef struct _player_push_media_msg_type{
- push_media_buf_type_e buf_type;
- uint64_t size;
- uint64_t pts;
- media_format_mimetype_e mimetype;
- media_buffer_flags_e flags;
- tbm_key key;
-}player_push_media_msg_type;
-
-typedef struct {
- int type;
- unsigned int wl_surface_id;
- int wl_window_x;
- int wl_window_y;
- int wl_window_width;
- int wl_window_height;
-}wl_win_msg_type;
-
-/**
- * @brief Get value from Message.
- * @remarks Does NOT guarantee thread safe.
- * @param[out] param the name of param is key, must be local variable. never be pointer.
- * @param[in] buf string of message buffer. has key and value
- */
-#define player_msg_get(param, buf) \
- muse_core_msg_json_deserialize(#param, buf, NULL, ¶m, NULL, MUSE_TYPE_ANY)
-
-/**
- * @brief Get value from Message.
- * @remarks Does NOT guarantee thread safe.
- * @param[out] param the name of param is key, must be local variable. never be pointer.
- * @param[in] buf string of message buffer. has key and value
- * @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
- */
-#define player_msg_get_type(param, buf, type) \
- muse_core_msg_json_deserialize(#param, buf, NULL, ¶m, NULL, MUSE_TYPE_##type)
-
-/**
- * @brief Get value from Message.
- * @remarks Does NOT guarantee thread safe.
- * @param[out] param the name of param is key, must be local pointer variable.
- * @param[in] buf string of message buffer. has key and value
- */
-#define player_msg_get_string(param, buf) \
- muse_core_msg_json_deserialize(#param, buf, NULL, param, NULL, MUSE_TYPE_ANY)
-
-/**
- * @brief Get value from Message.
- * @remarks Does NOT guarantee thread safe.
- * @param[out] param the name of param is key, must be local pointer variable.
- * @param[in] buf string of message buffer. has key and value
- */
-#define player_msg_get_array(param, buf) \
- muse_core_msg_json_deserialize(#param, buf, NULL, param, NULL, MUSE_TYPE_ANY)
-
-/**
- * @brief Get value from Message.
- * @remarks Does NOT guarantee thread safe.
- * @param[out] param the name of param is key, must be local variable. never be pointer.
- * @param[in] buf string of message buffer. has key and value
- * @param[in/out] len size of buffer. After retrun len is set parsed length.
- * @param[out] e the error number.
- */
-#define player_msg_get_error_e(param, buf, len, e) \
- muse_core_msg_json_deserialize(#param, buf, &len, ¶m, &e, MUSE_TYPE_INT)
-
-/**
- * @brief Create and send message. Wait for server result.
- * @remarks Does NOT guarantee thread safe.
- * @param[in] api The enum of module API.
- * @param[in] player The handle of capi media player.
- * @param[out] retbuf The buffer of return message. Must be char pointer.
- * @param[out] ret The return value from server.
- */
-#define player_msg_send(api, player, retbuf, ret) \
- do{ \
- char *__sndMsg__; \
- int __len__; \
- int __fd__; \
- int __timeout__ = _get_api_timeout(player, api); \
- if(CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
- else {ret = PLAYER_ERROR_INVALID_STATE;break;} \
- __sndMsg__ = muse_core_msg_json_factory_new(api, \
- 0); \
- __len__ = muse_core_ipc_send_msg(__fd__, __sndMsg__); \
- if (__len__ <= 0) { \
- LOGE("sending message failed"); \
- ret = PLAYER_ERROR_INVALID_OPERATION; \
- } else \
- ret = wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, __timeout__); \
- muse_core_msg_json_factory_free(__sndMsg__); \
- }while(0)
-
-/**
- * @brief Create and send message. Wait for server result.
- * @remarks Does NOT guarantee thread safe.
- * @param[in] api The enum of module API.
- * @param[in] player The handle of capi media player.
- * @param[out] retbuf The buffer of return message. Must be char pointer.Must free after use.
- * @param[out] ret The return value from server.
- * @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
- * @param[in] param the name of param is key, must be local variable. never be pointer.
- */
-#define player_msg_send1(api, player, retbuf, ret, type, param) \
- do{ \
- char *__sndMsg__; \
- int __len__; \
- int __fd__; \
- int __timeout__ = _get_api_timeout(player, api); \
- type __value__ = (type)param; \
- if(CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
- else {ret = PLAYER_ERROR_INVALID_STATE;break;} \
- __sndMsg__ = muse_core_msg_json_factory_new(api, \
- MUSE_TYPE_##type, #param, __value__, \
- 0); \
- __len__ = muse_core_ipc_send_msg(__fd__, __sndMsg__); \
- if (__len__ <= 0) { \
- LOGE("sending message failed"); \
- ret = PLAYER_ERROR_INVALID_OPERATION; \
- } else \
- ret = wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, __timeout__); \
- muse_core_msg_json_factory_free(__sndMsg__); \
- }while(0)
-
-/**
- * @brief Create and send message. Wait for server result.
- * @remarks Does NOT guarantee thread safe.
- * @param[in] api The enum of module API.
- * @param[in] player The handle of capi media player.
- * @param[out] retbuf The buffer of return message. Must be char pointer.Must free after use.
- * @param[out] ret The return value from server.
- * @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
- * @param[in] param# the name of param is key, must be local variable. never be pointer.
- */
-#define player_msg_send2(api, player, retbuf, ret, type1, param1, type2, param2) \
- do{ \
- char *__sndMsg__; \
- int __len__; \
- int __fd__; \
- int __timeout__ = _get_api_timeout(player, api); \
- type1 __value1__ = (type1)param1; \
- type2 __value2__ = (type2)param2; \
- if(CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
- else {ret = PLAYER_ERROR_INVALID_STATE;break;} \
- __sndMsg__ = muse_core_msg_json_factory_new(api, \
- MUSE_TYPE_##type1, #param1, __value1__, \
- MUSE_TYPE_##type2, #param2, __value2__, \
- 0); \
- __len__ = muse_core_ipc_send_msg(__fd__, __sndMsg__); \
- if (__len__ <= 0) { \
- LOGE("sending message failed"); \
- ret = PLAYER_ERROR_INVALID_OPERATION; \
- } else \
- ret = wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, __timeout__); \
- muse_core_msg_json_factory_free(__sndMsg__); \
- }while(0)
-
-/**
- * @brief Create and send message. Wait for server result.
- * @remarks Does NOT guarantee thread safe.
- * @param[in] api The enum of module API.
- * @param[in] player The handle of capi media player.
- * @param[out] retbuf The buffer of return message. Must be char pointer.Must free after use.
- * @param[out] ret The return value from server.
- * @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
- * @param[in] param# the name of param is key, must be local variable. never be pointer.
- */
-#define player_msg_send3(api, player, retbuf, ret, type1, param1, type2, param2, type3, param3) \
- do{ \
- char *__sndMsg__; \
- int __len__; \
- int __fd__; \
- int __timeout__ = _get_api_timeout(player, api); \
- type1 __value1__ = (type1)param1; \
- type2 __value2__ = (type2)param2; \
- type3 __value3__ = (type3)param3; \
- if(CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
- else {ret = PLAYER_ERROR_INVALID_STATE;break;} \
- __sndMsg__ = muse_core_msg_json_factory_new(api, \
- MUSE_TYPE_##type1, #param1, __value1__, \
- MUSE_TYPE_##type2, #param2, __value2__, \
- MUSE_TYPE_##type3, #param3, __value3__, \
- 0); \
- __len__ = muse_core_ipc_send_msg(__fd__, __sndMsg__); \
- if (__len__ <= 0) { \
- LOGE("sending message failed"); \
- ret = PLAYER_ERROR_INVALID_OPERATION; \
- } else \
- ret = wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, __timeout__); \
- muse_core_msg_json_factory_free(__sndMsg__); \
- }while(0)
-
-/**
- * @brief Create and send message. Wait for server result.
- * @remarks Does NOT guarantee thread safe.
- * @param[in] api The enum of module API.
- * @param[in] player The handle of capi media player.
- * @param[out] retbuf The buffer of return message. Must be char pointer.Must free after use.
- * @param[out] ret The return value from server.
- * @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
- * @param[in] param# the name of param is key, must be local variable. never be pointer.
- */
-#define player_msg_send6(api, player, retbuf, ret, type1, param1, type2, param2, type3, param3, type4, param4, type5, param5, type6, param6) \
- do{ \
- char *__sndMsg__; \
- int __len__; \
- int __fd__; \
- int __timeout__ = _get_api_timeout(player, api); \
- type1 __value1__ = (type1)param1; \
- type2 __value2__ = (type2)param2; \
- type3 __value3__ = (type3)param3; \
- type4 __value4__ = (type4)param4; \
- type5 __value5__ = (type5)param5; \
- type6 __value6__ = (type6)param6; \
- if(CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
- else {ret = PLAYER_ERROR_INVALID_STATE;break;} \
- __sndMsg__ = muse_core_msg_json_factory_new(api, \
- MUSE_TYPE_##type1, #param1, __value1__, \
- MUSE_TYPE_##type2, #param2, __value2__, \
- MUSE_TYPE_##type3, #param3, __value3__, \
- MUSE_TYPE_##type4, #param4, __value4__, \
- MUSE_TYPE_##type5, #param5, __value5__, \
- MUSE_TYPE_##type6, #param6, __value6__, \
- 0); \
- __len__ = muse_core_ipc_send_msg(__fd__, __sndMsg__); \
- if (__len__ <= 0) { \
- LOGE("sending message failed"); \
- ret = PLAYER_ERROR_INVALID_OPERATION; \
- } else \
- ret = wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, __timeout__); \
- muse_core_msg_json_factory_free(__sndMsg__); \
- }while(0)
-
-/**
- * @brief Create and send message. Wait for server result.
- * @remarks Does NOT guarantee thread safe.
- * @param[in] api The enum of module API.
- * @param[in] player The handle of capi media player.
- * @param[out] retbuf The buffer of return message. Must be char pointer.Must free after use.
- * @param[out] ret The return value from server.
- * @param[in] param the name of param is key, must be local array/pointer variable.
- * @param[in] length The size of array.
- * @param[in] datum_size The size of a array's datum.
- */
-#define player_msg_send_array(api, player, retbuf, ret, param, length, datum_size) \
- do{ \
- char *__sndMsg__; \
- int __len__; \
- int __fd__; \
- int __timeout__ = _get_api_timeout(player, api); \
- int *__value__ = (int *)param; \
- if(CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
- else {ret = PLAYER_ERROR_INVALID_STATE;break;} \
- __sndMsg__ = muse_core_msg_json_factory_new(api, \
- MUSE_TYPE_INT, #length, length, \
- MUSE_TYPE_ARRAY, #param, \
- datum_size == sizeof(int)? length : \
- length / sizeof(int) + (length % sizeof(int)?1:0), \
- __value__, \
- 0); \
- __len__ = muse_core_ipc_send_msg(__fd__, __sndMsg__); \
- if (__len__ <= 0) { \
- LOGE("sending message failed"); \
- ret = PLAYER_ERROR_INVALID_OPERATION; \
- } else \
- ret = wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, __timeout__); \
- muse_core_msg_json_factory_free(__sndMsg__); \
- }while(0)
-
-/**
- * @brief Create and send message. Wait for server result.
- * @remarks Does NOT guarantee thread safe.
- * @param[in] api The enum of module API.
- * @param[in] player The handle of capi media player.
- * @param[out] retbuf The buffer of return message. Must be char pointer.Must free after use.
- * @param[out] ret The return value from server.
- * @param[in] param# the name of param is key, must be local array/pointer variable.
- * @param[in] length# The size of array.
- * @param[in] datum_size# The size of a array's datum.
- */
-#define player_msg_send_array2(api, player, retbuf, ret, param1, length1, datum_size1, param2, length2, datum_size2) \
- do{ \
- char *__sndMsg__; \
- int __len__; \
- int __fd__; \
- int __timeout__ = _get_api_timeout(player, api); \
- int *__value1__ = (int *)param1; \
- int *__value2__ = (int *)param2; \
- if(CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
- else {ret = PLAYER_ERROR_INVALID_STATE;break;} \
- __sndMsg__ = muse_core_msg_json_factory_new(api, \
- MUSE_TYPE_INT, #length1, length1, \
- MUSE_TYPE_ARRAY, #param1, \
- datum_size1 == sizeof(int)? length1 : \
- length1 / sizeof(int) + (length1 % sizeof(int)?1:0), \
- __value1__, \
- MUSE_TYPE_INT, #length2, length2, \
- MUSE_TYPE_ARRAY, #param2, \
- datum_size2 == sizeof(int)? length2 : \
- length2 / sizeof(int) + (length2 % sizeof(int)?1:0), \
- __value2__, \
- 0); \
- __len__ = muse_core_ipc_send_msg(__fd__, __sndMsg__); \
- if (__len__ <= 0) { \
- LOGE("sending message failed"); \
- ret = PLAYER_ERROR_INVALID_OPERATION; \
- } else \
- ret = wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, __timeout__); \
- muse_core_msg_json_factory_free(__sndMsg__); \
- }while(0)
-
-
-/**
- * @brief Create and send message. Does not wait server result.
- * @remarks Does NOT guarantee thread safe.
- * @param[in] api The enum of module API.
- * @param[in] player The handle of capi media player.
- * @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
- * @param[in] param the name of param is key, must be local variable. never be pointer.
- */
-#define player_msg_send1_async(api, player, type, param) \
- do{ \
- char *__sndMsg__; \
- int __len__; \
- int __fd__; \
- type __value__ = (type)param; \
- if(CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
- else {ret = PLAYER_ERROR_INVALID_STATE;break;} \
- __sndMsg__ = muse_core_msg_json_factory_new(api, \
- MUSE_TYPE_##type, #param, __value__, \
- 0); \
- __len__ = muse_core_ipc_send_msg(__fd__, __sndMsg__); \
- muse_core_msg_json_factory_free(__sndMsg__); \
- if (__len__ <= 0) { \
- LOGE("sending message failed"); \
- return PLAYER_ERROR_INVALID_OPERATION; \
- } \
- }while(0)
-
-/**
- * @brief Create and send message. Does not wait server result.
- * @remarks Does NOT guarantee thread safe.
- * @param[in] api The enum of module API.
- * @param[in] player The server side handle of media player.
- * @param[in] fd socket fd
- * @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
- * @param[in] param the name of param is key, must be local variable. never be pointer.
- */
-#define player_msg_create_handle(api, fd, type1, param1, type2, param2) \
- do{ \
- char *__sndMsg__; \
- int __len__; \
- type1 __value1__ = (type1)param1; \
- type2 __value2__ = (type2)param2; \
- __sndMsg__ = muse_core_msg_json_factory_new(api, \
- MUSE_TYPE_##type1, #param1, __value1__, \
- MUSE_TYPE_##type2, #param2, __value2__, \
- 0); \
- __len__ = muse_core_ipc_send_msg(fd, __sndMsg__); \
- muse_core_msg_json_factory_free(__sndMsg__); \
- if (__len__ <= 0) { \
- LOGE("sending message failed"); \
- return PLAYER_ERROR_INVALID_OPERATION; \
- } \
- }while(0)
-
-
-/**
- * @brief Create and send message for callback. Does not wait server result.
- * @remarks Does NOT guarantee thread safe.
- * @param[in] api The enum of module API.
- * @param[in] player The handle of capi media player.
- * @param[out] ret set ERROR when fail to send msg.
- * @param[in] event_type type of event (_player_event_e).
- * @param[in] set 1 is set the user callback, 0 is unset the user callback.
- */
-#define player_msg_set_callback(api, player, ret, event_type, set) \
- do{ \
- char *__sndMsg__; \
- int __len__; \
- int __fd__; \
- int __value1__ = (int)event_type; \
- int __value2__ = (int)set; \
- if(CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
- else {ret = PLAYER_ERROR_INVALID_STATE;break;} \
- __sndMsg__ = muse_core_msg_json_factory_new(api, \
- MUSE_TYPE_INT, #event_type, __value1__, \
- MUSE_TYPE_INT, #set, __value2__, \
- 0); \
- __len__ = muse_core_ipc_send_msg(__fd__, __sndMsg__); \
- muse_core_msg_json_factory_free(__sndMsg__); \
- if (__len__ <= 0) { \
- LOGE("sending message failed"); \
- ret = PLAYER_ERROR_INVALID_OPERATION; \
- } \
- }while(0)
-
-/**
- * @brief Create and send return message.
- * @remarks Does NOT guarantee thread safe.
- * @param[in] api The enum of module API.
- * @param[in] ret Thre result of API.
- * @param[in] module mused module information
- */
-#define player_msg_return(api, ret, module) \
- do{ \
- char *__sndMsg__; \
- int __len__; \
- __sndMsg__ = muse_core_msg_json_factory_new(api, \
- MUSE_TYPE_INT, MUSE_PARAM_RETURN, ret, \
- 0); \
- __len__ = muse_core_ipc_send_msg(muse_core_client_get_msg_fd(module), __sndMsg__); \
- if (__len__ <= 0) { \
- LOGE("sending message failed"); \
- ret = PLAYER_ERROR_INVALID_OPERATION; \
- } \
- muse_core_msg_json_factory_free(__sndMsg__); \
- }while(0)
-
-/**
- * @brief Create and send return message.
- * @remarks Does NOT guarantee thread safe.
- * @param[in] api The enum of module API.
- * @param[in] ret Thre result of API.
- * @param[in] module mused module information
- * @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
- * @param[in] param the name of param is key, must be local variable. never be pointer.
- */
-#define player_msg_return1(api, ret, module, type, param) \
- do{ \
- char *__sndMsg__; \
- int __len__; \
- type __value__ = (type)param; \
- __sndMsg__ = muse_core_msg_json_factory_new(api, \
- MUSE_TYPE_INT, MUSE_PARAM_RETURN, ret, \
- MUSE_TYPE_##type, #param, __value__, \
- 0); \
- __len__ = muse_core_ipc_send_msg(muse_core_client_get_msg_fd(module), __sndMsg__); \
- if (__len__ <= 0) { \
- LOGE("sending message failed"); \
- ret = PLAYER_ERROR_INVALID_OPERATION; \
- } \
- muse_core_msg_json_factory_free(__sndMsg__); \
- }while(0)
-
-/**
- * @brief Create and send return message.
- * @remarks Does NOT guarantee thread safe.
- * @param[in] api The enum of module API.
- * @param[in] ret Thre result of API.
- * @param[in] module mused module information
- * @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
- * @param[in] param# the name of param is key, must be local variable. never be pointer.
- */
-#define player_msg_return2(api, ret, module, type1, param1, type2, param2) \
- do{ \
- char *__sndMsg__; \
- int __len__; \
- type1 __value1__ = (type1)param1; \
- type2 __value2__ = (type2)param2; \
- __sndMsg__ = muse_core_msg_json_factory_new(api, \
- MUSE_TYPE_INT, MUSE_PARAM_RETURN, ret, \
- MUSE_TYPE_##type1, #param1, __value1__, \
- MUSE_TYPE_##type2, #param2, __value2__, \
- 0); \
- __len__ = muse_core_ipc_send_msg(muse_core_client_get_msg_fd(module), __sndMsg__); \
- if (__len__ <= 0) { \
- LOGE("sending message failed"); \
- ret = PLAYER_ERROR_INVALID_OPERATION; \
- } \
- muse_core_msg_json_factory_free(__sndMsg__); \
- }while(0)
-
-/**
- * @brief Create and send return message.
- * @remarks Does NOT guarantee thread safe.
- * @param[in] api The enum of module API.
- * @param[in] ret Thre result of API.
- * @param[in] module mused module information
- * @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
- * @param[in] param# the name of param is key, must be local variable. never be pointer.
- */
-#define player_msg_return3(api, ret, module, type1, param1, type2, param2, type3, param3) \
- do{ \
- char *__sndMsg__; \
- int __len__; \
- type1 __value1__ = (type1)param1; \
- type2 __value2__ = (type2)param2; \
- type3 __value3__ = (type3)param3; \
- __sndMsg__ = muse_core_msg_json_factory_new(api, \
- MUSE_TYPE_INT, MUSE_PARAM_RETURN, ret, \
- MUSE_TYPE_##type1, #param1, __value1__, \
- MUSE_TYPE_##type2, #param2, __value2__, \
- MUSE_TYPE_##type3, #param3, __value3__, \
- 0); \
- __len__ = muse_core_ipc_send_msg(muse_core_client_get_msg_fd(module), __sndMsg__); \
- if (__len__ <= 0) { \
- LOGE("sending message failed"); \
- ret = PLAYER_ERROR_INVALID_OPERATION; \
- } \
- muse_core_msg_json_factory_free(__sndMsg__); \
- }while(0)
-
-/**
- * @brief Create and send return message.
- * @remarks Does NOT guarantee thread safe.
- * @param[in] api The enum of module API.
- * @param[in] ret Thre result of API.
- * @param[in] module mused module information
- * @param[in] param the name of param is key, must be local array/pointer variable.
- * @param[in] length The size of array.
- * @param[in] datum_size The size of a array's datum.
- */
-#define player_msg_return_array(api, ret, module, param, length, datum_size) \
- do{ \
- char *__sndMsg__; \
- int __len__; \
- int *__value__ = (int *)param; \
- __sndMsg__ = muse_core_msg_json_factory_new(api, \
- MUSE_TYPE_INT, MUSE_PARAM_RETURN, ret, \
- MUSE_TYPE_INT, #length, length, \
- MUSE_TYPE_ARRAY, #param, \
- datum_size == sizeof(int)? length : \
- length / sizeof(int) + (length % sizeof(int)?1:0), \
- __value__, \
- 0); \
- __len__ = muse_core_ipc_send_msg(muse_core_client_get_msg_fd(module), __sndMsg__); \
- if (__len__ <= 0) { \
- LOGE("sending message failed"); \
- ret = PLAYER_ERROR_INVALID_OPERATION; \
- } \
- muse_core_msg_json_factory_free(__sndMsg__); \
- }while(0)
-
-/**
- * @brief Create and send return message.
- * @remarks Does NOT guarantee thread safe.
- * @param[in] api The enum of module API.
- * @param[in] event The event number.
- * @param[in] module mused module information
- */
-#define player_msg_event(api, event, module) \
- do{ \
- char *__sndMsg__; \
- __sndMsg__ = muse_core_msg_json_factory_new(api, \
- MUSE_TYPE_INT, MUSE_PARAM_EVENT, event, \
- 0); \
- muse_core_ipc_send_msg(muse_core_client_get_msg_fd(module), __sndMsg__); \
- muse_core_msg_json_factory_free(__sndMsg__); \
- }while(0)
-
-/**
- * @brief Create and send return message.
- * @remarks Does NOT guarantee thread safe.
- * @param[in] api The enum of module API.
- * @param[in] event The event number.
- * @param[in] module mused module information
- * @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
- * @param[in] param the name of param is key, must be local variable. never be pointer.
- */
-#define player_msg_event1(api, event, module, type, param) \
- do{ \
- char *__sndMsg__; \
- type __value__ = (type)param; \
- __sndMsg__ = muse_core_msg_json_factory_new(api, \
- MUSE_TYPE_INT, MUSE_PARAM_EVENT, event, \
- MUSE_TYPE_##type, #param, __value__, \
- 0); \
- muse_core_ipc_send_msg(muse_core_client_get_msg_fd(module), __sndMsg__); \
- muse_core_msg_json_factory_free(__sndMsg__); \
- }while(0)
-
-/**
- * @brief Create and send return message.
- * @remarks Does NOT guarantee thread safe.
- * @param[in] api The enum of module API.
- * @param[in] event The event number.
- * @param[in] module mused module information
- * @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
- * @param[in] param# the name of param is key, must be local variable. never be pointer.
- */
-#define player_msg_event2(api, event, module, type1, param1, type2, param2) \
- do{ \
- char *__sndMsg__; \
- type1 __value1__ = (type1)param1; \
- type2 __value2__ = (type2)param2; \
- __sndMsg__ = muse_core_msg_json_factory_new(api, \
- MUSE_TYPE_INT, MUSE_PARAM_EVENT, event, \
- MUSE_TYPE_##type1, #param1, __value1__, \
- MUSE_TYPE_##type2, #param2, __value2__, \
- 0); \
- muse_core_ipc_send_msg(muse_core_client_get_msg_fd(module), __sndMsg__); \
- muse_core_msg_json_factory_free(__sndMsg__); \
- }while(0)
-
-/**
- * @brief Create and send return message.
- * @remarks Does NOT guarantee thread safe.
- * @param[in] api The enum of module API.
- * @param[in] event The event number.
- * @param[in] module mused module information
- * @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
- * @param[in] param# the name of param is key, must be local variable. never be pointer.
- */
-#define player_msg_event3(api, event, module, type1, param1, type2, param2, type3, param3) \
- do{ \
- char *__sndMsg__; \
- type1 __value1__ = (type1)param1; \
- type2 __value2__ = (type2)param2; \
- type3 __value3__ = (type3)param3; \
- __sndMsg__ = muse_core_msg_json_factory_new(api, \
- MUSE_TYPE_INT, MUSE_PARAM_EVENT, event, \
- MUSE_TYPE_##type1, #param1, __value1__, \
- MUSE_TYPE_##type2, #param2, __value2__, \
- MUSE_TYPE_##type3, #param3, __value3__, \
- 0); \
- muse_core_ipc_send_msg(muse_core_client_get_msg_fd(module), __sndMsg__); \
- muse_core_msg_json_factory_free(__sndMsg__); \
- }while(0)
-
-/**
- * @brief Create and send return message.
- * @remarks Does NOT guarantee thread safe.
- * @param[in] api The enum of module API.
- * @param[in] event The event number.
- * @param[in] module mused module information
- * @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
- * @param[in] param# the name of param is key, must be local variable. never be pointer.
- */
-#define player_msg_event4(api, event, module, type1, param1, type2, param2, type3, param3, type4, param4) \
- do{ \
- char *__sndMsg__; \
- type1 __value1__ = (type1)param1; \
- type2 __value2__ = (type2)param2; \
- type3 __value3__ = (type3)param3; \
- type4 __value4__ = (type4)param4; \
- __sndMsg__ = muse_core_msg_json_factory_new(api, \
- MUSE_TYPE_INT, MUSE_PARAM_EVENT, event, \
- MUSE_TYPE_##type1, #param1, __value1__, \
- MUSE_TYPE_##type2, #param2, __value2__, \
- MUSE_TYPE_##type3, #param3, __value3__, \
- MUSE_TYPE_##type4, #param4, __value4__, \
- 0); \
- muse_core_ipc_send_msg(muse_core_client_get_msg_fd(module), __sndMsg__); \
- muse_core_msg_json_factory_free(__sndMsg__); \
- }while(0)
-
-/**
- * @brief Create and send return message.
- * @remarks Does NOT guarantee thread safe.
- * @param[in] api The enum of module API.
- * @param[in] event The event number.
- * @param[in] module mused module information
- * @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
- * @param[in] param# the name of param is key, must be local variable. never be pointer.
- * @param[in] arr_param the name of param is key, must be local pointer/array variable.
- * @param[in] length The size of array.
- * @param[in] datum_size The size of a array's datum.
- */
-#define player_msg_event2_array(api, event, module, type1, param1, type2, param2, arr_param, length, datum_size) \
- do{ \
- char *__sndMsg__; \
- type1 __value1__ = (type1)param1; \
- type2 __value2__ = (type2)param2; \
- int *__arr_value__ = (int *)arr_param; \
- __sndMsg__ = muse_core_msg_json_factory_new(api, \
- MUSE_TYPE_INT, MUSE_PARAM_EVENT, event, \
- MUSE_TYPE_##type1, #param1, __value1__, \
- MUSE_TYPE_##type2, #param2, __value2__, \
- MUSE_TYPE_INT, #length, length, \
- MUSE_TYPE_ARRAY, #arr_param, \
- datum_size == sizeof(int)? length : \
- length / sizeof(int) + (length % sizeof(int)?1:0), \
- __arr_value__, \
- 0); \
- muse_core_ipc_send_msg(muse_core_client_get_msg_fd(module), __sndMsg__); \
- muse_core_msg_json_factory_free(__sndMsg__); \
- }while(0)
-
-/**
- * @brief Create and send return message.
- * @remarks Does NOT guarantee thread safe.
- * @param[in] api The enum of module API.
- * @param[in] event The event number.
- * @param[in] module mused module information
- * @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
- * @param[in] param# the name of param is key, must be local variable. never be pointer.
- * @param[in] arr_param the name of param is key, must be local array/pointer variable.
- * @param[in] length The size of array.
- * @param[in] datum_size The size of a array's datum.
- */
-#define player_msg_event6_array(api, event, module, type1, param1, type2, param2, type3, param3, type4, param4, type5, param5, type6, param6, arr_param, length, datum_size) \
- do{ \
- char *__sndMsg__; \
- type1 __value1__ = (type1)param1; \
- type2 __value2__ = (type2)param2; \
- type3 __value3__ = (type3)param3; \
- type4 __value4__ = (type4)param4; \
- type5 __value5__ = (type5)param5; \
- type6 __value6__ = (type6)param6; \
- int *__arr_value__ = (int *)arr_param; \
- __sndMsg__ = muse_core_msg_json_factory_new(api, \
- MUSE_TYPE_INT, MUSE_PARAM_EVENT, event, \
- MUSE_TYPE_##type1, #param1, __value1__, \
- MUSE_TYPE_##type2, #param2, __value2__, \
- MUSE_TYPE_##type3, #param3, __value3__, \
- MUSE_TYPE_##type4, #param4, __value4__, \
- MUSE_TYPE_##type5, #param5, __value5__, \
- MUSE_TYPE_##type6, #param6, __value6__, \
- MUSE_TYPE_INT, #length, length, \
- MUSE_TYPE_ARRAY, #arr_param, \
- datum_size == sizeof(int)? length : \
- length / sizeof(int) + (length % sizeof(int)?1:0), \
- __arr_value__, \
- 0); \
- muse_core_ipc_send_msg(muse_core_client_get_msg_fd(module), __sndMsg__); \
- muse_core_msg_json_factory_free(__sndMsg__); \
- }while(0)
-
-/**
- * @brief Create and send return message.
- * @remarks Does NOT guarantee thread safe.
- * @param[in] api The enum of module API.
- * @param[in] event The event number.
- * @param[in] module mused module information
- * @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
- * @param[in] param# the name of param is key, must be local variable. never be pointer.
- * @param[in] arr_param the name of param is key, must be local array/pointer variable.
- * @param[in] length The size of array.
- * @param[in] datum_size The size of a array's datum.
- */
-#define player_msg_event7_array(api, event, module, type1, param1, type2, param2, type3, param3, type4, param4, type5, param5, type6, param6, type7, param7, arr_param, length, datum_size) \
- do{ \
- char *__sndMsg__; \
- type1 __value1__ = (type1)param1; \
- type2 __value2__ = (type2)param2; \
- type3 __value3__ = (type3)param3; \
- type4 __value4__ = (type4)param4; \
- type5 __value5__ = (type5)param5; \
- type6 __value6__ = (type6)param6; \
- type7 __value7__ = (type7)param7; \
- int *__arr_value__ = (int *)arr_param; \
- __sndMsg__ = muse_core_msg_json_factory_new(api, \
- MUSE_TYPE_INT, MUSE_PARAM_EVENT, event, \
- MUSE_TYPE_##type1, #param1, __value1__, \
- MUSE_TYPE_##type2, #param2, __value2__, \
- MUSE_TYPE_##type3, #param3, __value3__, \
- MUSE_TYPE_##type4, #param4, __value4__, \
- MUSE_TYPE_##type5, #param5, __value5__, \
- MUSE_TYPE_##type6, #param6, __value6__, \
- MUSE_TYPE_##type7, #param7, __value7__, \
- MUSE_TYPE_INT, #length, length, \
- MUSE_TYPE_ARRAY, #arr_param, \
- datum_size == sizeof(int)? length : \
- length / sizeof(int) + (length % sizeof(int)?1:0), \
- __arr_value__, \
- 0); \
- muse_core_ipc_send_msg(muse_core_client_get_msg_fd(module), __sndMsg__); \
- muse_core_msg_json_factory_free(__sndMsg__); \
- }while(0)
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /*__PLAYER_MSG_PRIVATE_H__*/
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+SET(service "legacy")
+SET(submodule "player")
+
+# for package file
+SET(dependents "dlog mm-player capi-base-common capi-media-tool libtbm evas ecore elementary capi-system-info")
+
+SET(fw_name "${service}-${submodule}")
+
+PROJECT(${fw_name})
+
+SET(CMAKE_INSTALL_PREFIX /usr)
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+
+SET(INC_DIR include)
+INCLUDE_DIRECTORIES(${INC_DIR})
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${fw_name} REQUIRED ${dependents})
+FOREACH(flag ${${fw_name}_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror -Wno-deprecated -Wno-deprecated-declarations")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+
+IF("${ARCH}" STREQUAL "arm")
+ ADD_DEFINITIONS("-DTARGET")
+ENDIF("${ARCH}" STREQUAL "arm")
+
+IF(WAYLAND_SUPPORT)
+ ADD_DEFINITIONS("-DHAVE_WAYLAND")
+ENDIF(WAYLAND_SUPPORT)
+IF(X11_SUPPORT)
+ ADD_DEFINITIONS("-DHAVE_X11")
+ENDIF(X11_SUPPORT)
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+ADD_DEFINITIONS("-DTIZEN_DEBUG")
+
+IF (TIZEN_MOBILE)
+ADD_DEFINITIONS("-DTIZEN_MOBILE")
+ENDIF(TIZEN_MOBILE)
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${LIB_INSTALL_DIR}")
+
+aux_source_directory(src LEGACY_SOURCES)
+ADD_LIBRARY(${fw_name} SHARED ${LEGACY_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_DIR})
+INSTALL(
+ DIRECTORY ${INC_DIR}/ DESTINATION include/media
+ FILES_MATCHING
+ PATTERN "*_private.h" EXCLUDE
+ PATTERN "${INC_DIR}/*.h"
+ )
+
+ADD_SUBDIRECTORY(test)
--- /dev/null
+/*
+* 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_LEGACY_PLAYER_H__
+#define __TIZEN_MEDIA_LEGACY_PLAYER_H__
+
+#include <tizen.h>
+#include <sound_manager.h>
+#include <media_packet.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define PLAYER_ERROR_CLASS TIZEN_ERROR_PLAYER | 0x20
+
+/* This is for custom defined player error. */
+#define PLAYER_CUSTOM_ERROR_CLASS TIZEN_ERROR_PLAYER | 0x1000
+
+/**
+ * @file legacy_player.h
+ * @brief This file contains the media player API.
+ */
+
+/**
+ * @addtogroup CAPI_MEDIA_PLAYER_MODULE
+ * @{
+ */
+
+/**
+ * @brief The media player's type handle.
+ * @since_tizen 2.3
+ */
+typedef struct player_s *player_h;
+
+/**
+ * @brief Enumeration for media player state.
+ * @since_tizen 2.3
+ */
+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 Enumeration for media player's error codes.
+ * @since_tizen 2.3
+ */
+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 the device */
+ PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported */
+ 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, /**< File format not supported */
+ 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 failed */
+ PLAYER_ERROR_DRM_EXPIRED = PLAYER_ERROR_CLASS | 0x08, /**< Expired license */
+ PLAYER_ERROR_DRM_NO_LICENSE = PLAYER_ERROR_CLASS | 0x09, /**< No license */
+ PLAYER_ERROR_DRM_FUTURE_USE = PLAYER_ERROR_CLASS | 0x0a, /**< License for future use */
+ PLAYER_ERROR_DRM_NOT_PERMITTED = PLAYER_ERROR_CLASS | 0x0b, /**< Format not permitted */
+ PLAYER_ERROR_RESOURCE_LIMIT = PLAYER_ERROR_CLASS | 0x0c, /**< Resource limit */
+ PLAYER_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
+ PLAYER_ERROR_SERVICE_DISCONNECTED = PLAYER_ERROR_CLASS | 0x0d, /**< Socket connection lost (Since 3.0) */
+ PLAYER_ERROR_BUFFER_SPACE = TIZEN_ERROR_BUFFER_SPACE, /**< No buffer space available (Since 3.0)*/
+
+} player_error_e;
+
+/**
+ * @brief Enumeration for media player's interruption type.
+ * @since_tizen 2.3
+ */
+typedef enum {
+ PLAYER_INTERRUPTED_COMPLETED = 0, /**< Interrupt completed (Deprecated since 3.0)*/
+ PLAYER_INTERRUPTED_BY_MEDIA, /**< Interrupted by a non-resumable media application (Deprecated since 3.0)*/
+ PLAYER_INTERRUPTED_BY_CALL, /**< Interrupted by an incoming call (Deprecated since 3.0)*/
+ PLAYER_INTERRUPTED_BY_EARJACK_UNPLUG, /**< Interrupted by unplugging headphones (Deprecated since 3.0)*/
+ PLAYER_INTERRUPTED_BY_RESOURCE_CONFLICT, /**< Interrupted by a resource conflict */
+ PLAYER_INTERRUPTED_BY_ALARM, /**< Interrupted by an alarm (Deprecated since 3.0)*/
+ PLAYER_INTERRUPTED_BY_EMERGENCY, /**< Interrupted by an emergency (Deprecated since 3.0)*/
+ PLAYER_INTERRUPTED_BY_NOTIFICATION, /**< Interrupted by a notification (Deprecated since 3.0)*/
+} player_interrupted_code_e;
+
+/**
+ * @brief Enumeration for progressive download message type.
+ * @since_tizen 2.3
+ */
+typedef enum {
+ PLAYER_PD_STARTED = 0, /**< Progressive download is started */
+ PLAYER_PD_COMPLETED, /**< Progressive download is completed */
+} player_pd_message_type_e;
+
+/**
+ * @brief Enumeration for display type.
+ * @since_tizen 2.3
+ */
+typedef enum {
+ PLAYER_DISPLAY_TYPE_OVERLAY = 0, /**< Overlay surface display */
+ PLAYER_DISPLAY_TYPE_EVAS, /**< Evas image object surface display */
+ PLAYER_DISPLAY_TYPE_NONE, /**< This disposes off buffers */
+} player_display_type_e;
+
+/**
+ * @brief Enumeration for audio latency mode.
+ * @since_tizen 2.3
+ */
+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 Enumeration for stream type.
+ * @since_tizen 2.4
+ */
+typedef enum {
+ PLAYER_STREAM_TYPE_DEFAULT, /**< Container type */
+ PLAYER_STREAM_TYPE_AUDIO, /**< Audio element stream type */
+ PLAYER_STREAM_TYPE_VIDEO, /**< Video element stream type */
+ PLAYER_STREAM_TYPE_TEXT, /**< Text type */
+} player_stream_type_e;
+
+/**
+ * @brief Enumeration of media stream buffer status
+ * @since_tizen 2.4
+ */
+typedef enum {
+ PLAYER_MEDIA_STREAM_BUFFER_UNDERRUN,
+ PLAYER_MEDIA_STREAM_BUFFER_OVERFLOW,
+} player_media_stream_buffer_status_e;
+
+/**
+ * @brief The player display handle.
+ * @since_tizen 2.3
+ */
+typedef void* player_display_h;
+
+#ifndef GET_DISPLAY
+/**
+ * @brief Definition for a display handle from evas object.
+ * @since_tizen 2.3
+ */
+#define GET_DISPLAY(x) (void*)(x)
+#endif
+
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup CAPI_MEDIA_PLAYER_DISPLAY_MODULE
+ * @{
+ */
+
+/**
+ * @brief Enumeration for display rotation type.
+ * @since_tizen 2.3
+ */
+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 Enumeration for display mode.
+ * @since_tizen 2.3
+ */
+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_DST_ROI, /**< Dst ROI mode (Deprecated since [3.0]).*/
+} player_display_mode_e;
+
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup CAPI_MEDIA_PLAYER_STREAM_INFO_MODULE
+ * @{
+ */
+
+/**
+ * @brief Enumeration for media stream content information.
+ * @since_tizen 2.3
+ */
+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;
+
+/**
+ * @}
+ */
+
+
+/**
+ * @addtogroup CAPI_MEDIA_PLAYER_SUBTITLE_MODULE
+ * @{
+ */
+
+/**
+ * @brief Called when the subtitle is updated.
+ * @since_tizen 2.3
+ * @param[in] duration The duration of the updated subtitle
+ * @param[in] text The text of the updated subtitle
+ * @param[in] user_data The user data passed from the callback registration function
+ * @see legacy_player_set_subtitle_updated_cb()
+ * @see legacy_player_unset_subtitle_updated_cb()
+ */
+typedef void (*player_subtitle_updated_cb)(unsigned long duration, char *text, void *user_data);
+
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup CAPI_MEDIA_PLAYER_MODULE
+ * @{
+ */
+
+/**
+ * @brief Called when the media player is prepared.
+ * @since_tizen 2.3
+ * @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 legacy_player_prepare_async() will cause this callback.
+ * @post The player state will be #PLAYER_STATE_READY.
+ * @see legacy_player_prepare_async()
+ */
+typedef void (*player_prepared_cb)(void *user_data);
+
+/**
+ * @brief Called when the media player is completed.
+ * @since_tizen 2.3
+ * @details It will be invoked when player has reached the end of the stream.
+ * @param[in] user_data The user data passed from the callback registration function
+ * @pre It will be invoked when the playback is completed if you register this callback using legacy_player_set_completed_cb().
+ * @see legacy_player_set_completed_cb()
+ * @see legacy_player_unset_completed_cb()
+ */
+typedef void (*player_completed_cb)(void *user_data);
+
+/**
+ * @brief Called when the seek operation is completed.
+ * @since_tizen 2.3
+ * @param[in] user_data The user data passed from the callback registration function
+ * @see legacy_player_set_play_position()
+ */
+typedef void (*player_seek_completed_cb)(void *user_data);
+
+/**
+ * @brief Called when the media player is interrupted.
+ * @since_tizen 2.3
+ * @param[in] error_code The interrupted error code
+ * @param[in] user_data The user data passed from the callback registration function
+ * @see legacy_player_set_interrupted_cb()
+ * @see legacy_player_unset_interrupted_cb()
+ */
+typedef void (*player_interrupted_cb)(player_interrupted_code_e code, void *user_data);
+
+/**
+ * @brief Called when an error occurs in the media player.
+ * @details Following error codes can be delivered.
+ * #PLAYER_ERROR_INVALID_OPERATION
+ * #PLAYER_ERROR_INVALID_STATE
+ * #PLAYER_ERROR_INVALID_URI
+ * #PLAYER_ERROR_CONNECTION_FAILED
+ * #PLAYER_ERROR_DRM_NOT_PERMITTED
+ * #PLAYER_ERROR_FILE_NO_SPACE_ON_DEVICE
+ * #PLAYER_ERROR_NOT_SUPPORTED_FILE
+ * #PLAYER_ERROR_SEEK_FAILED
+ * #PLAYER_ERROR_SERVICE_DISCONNECTED
+ * @since_tizen 2.3
+ * @param[in] error_code The error code
+ * @param[in] user_data The user data passed from the callback registration function
+ * @see legacy_player_set_error_cb()
+ * @see legacy_player_unset_error_cb()
+ */
+typedef void (*player_error_cb)(int error_code, void *user_data);
+
+/**
+ * @brief Called when the buffering percentage of the media playback is updated.
+ * @since_tizen 2.3
+ * @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 legacy_player_set_buffering_cb()
+ * @see legacy_player_unset_buffering_cb()
+ */
+typedef void (*player_buffering_cb)(int percent, void *user_data);
+
+/**
+ * @brief Called when progressive download is started or completed.
+ * @since_tizen 2.3
+ * @param[in] type The message type for progressive download
+ * @param[in] user_data The user data passed from the callback registration function
+ * @see legacy_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.
+ * @since_tizen 2.3
+ * @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 the captured image
+ * @param[in] height The height of the captured image
+ * @param[in] size The size of the captured image
+ * @param[in] user_data The user data passed from the callback registration function
+ * @see legacy_player_capture_video()
+ */
+typedef void (*player_video_captured_cb)(unsigned char *data, int width, int height, unsigned int size, void *user_data);
+
+/**
+ * @brief Called to register for notifications about delivering media packet when every video frame is decoded.
+ * @since_tizen 2.3
+ *
+ * @remarks This function is issued in the context of gstreamer so the UI update code should not be directly invoked.\n
+ * the packet should be released by media_packet_destroy() after use. \n
+ * Otherwises, decoder can't work more because it can't have enough buffer to fill decoded frame.
+ *
+ * @param[in] pkt Reference pointer to the media packet
+ * @param[in] user_data The user data passed from the callback registration function
+ */
+typedef void (*player_media_packet_video_decoded_cb)(media_packet_h pkt, void *user_data);
+
+/**
+ * @brief Called when the buffer level drops below the threshold of max size or no free space in buffer.
+ * @since_tizen 2.4
+ * @remarks This API is used for media stream playback only.
+ * @param[in] user_data The user data passed from the callback registration function
+ * @see legacy_player_set_media_stream_buffer_status_cb()
+ * @see legacy_player_set_media_stream_buffer_max_size()
+ * @see legacy_player_set_media_stream_buffer_min_threshold()
+ */
+typedef void (*player_media_stream_buffer_status_cb) (player_media_stream_buffer_status_e status, void *user_data);
+
+/**
+ * @brief Called to notify the next push-buffer offset when seeking is occurred.
+ * @since_tizen 2.4
+ * @remarks This API is used for media stream playback only.
+ * @details The next push-buffer should produce buffers from the new offset.
+ * @param[in] offset The new byte position to seek
+ * @param[in] user_data The user data passed from the callback registration function
+ */
+typedef void (*player_media_stream_seek_cb) (unsigned long long offset, void *user_data);
+
+/**
+ * @brief Called to notify the video stream changed.
+ * @since_tizen 2.4
+ * @details The video stream changing is detected just before rendering operation.
+ * @param[in] width The width of the captured image
+ * @param[in] height The height of the captured image
+ * @param[in] fps The frame per second of the video \n
+ It can be @c 0 if there is no video stream information.
+ * @param[in] bit_rate The video bit rate [Hz] \n
+ * It can be an invalid value if there is no video stream information.
+ * @param[in] user_data The user data passed from the callback registration function
+ * @see legacy_player_set_video_stream_changed_cb()
+ */
+typedef void (*player_video_stream_changed_cb) (int width, int height, int fps, int bit_rate, void *user_data);
+
+/**
+ * @brief Creates a player handle for playing multimedia content.
+ * @since_tizen 2.3
+ * @remarks You must release @a player by using legacy_player_destroy().\n
+ * 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 the 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 legacy_player_destroy()
+ */
+int legacy_player_create(player_h *player);
+
+/**
+ * @brief Destroys the media player handle and releases all its resources.
+ * @since_tizen 2.3
+ * @remarks To completely shutdown player operation, call this function with a valid player handle from any player state.
+ * @param[in] player The handle to the media player to be destroyed
+ * @return @c 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 set to #PLAYER_STATE_IDLE.
+ * @post The player state will be #PLAYER_STATE_NONE.
+ * @see legacy_player_create()
+ */
+int legacy_player_destroy(player_h player);
+
+/**
+ * @brief Prepares the media player for playback.
+ * @since_tizen 2.3
+ * @remarks The mediastorage privilege(http://tizen.org/privilege/mediastorage) should be added if any video/audio files are used to play located in the internal storage.
+ * @remarks The externalstorage privilege(http://tizen.org/privilege/externalstorage) should be added if any video/audio files are used to play located in the external storage.
+ * @remarks The internet privilege(http://tizen.org/privilege/internet) should be added if any URLs are used to play from network.
+ * @param[in] player The handle to the media player
+ * @return @c 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 File not supported
+ * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state
+ * @retval #PLAYER_ERROR_PERMISSION_DENIED Permission denied
+ * @pre The player state must be set to #PLAYER_STATE_IDLE by calling legacy_player_create() or legacy_player_unprepare(). After that, call legacy_player_set_uri() to load the media content you want to play.
+ * @post The player state will be #PLAYER_STATE_READY.
+ * @see legacy_player_prepare_async()
+ * @see legacy_player_unprepare()
+ * @see legacy_player_set_uri()
+ */
+int legacy_player_prepare(player_h player);
+
+/**
+ * @brief Prepares the media player for playback, asynchronously.
+ * @since_tizen 2.3
+ * @remarks The mediastorage privilege(http://tizen.org/privilege/mediastorage) should be added if any video/audio files are used to play located in the internal storage.
+ * @remarks The externalstorage privilege(http://tizen.org/privilege/externalstorage) should be added if any video/audio files are used to play located in the external storage.
+ * @remarks The internet privilege(http://tizen.org/privilege/internet) should be added if any URLs are used to play from network.
+ * @param[in] player The handle to the 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 @c 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 File not supported
+ * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state
+ * @retval #PLAYER_ERROR_PERMISSION_DENIED Permission denied
+ * @pre The player state must be set to #PLAYER_STATE_IDLE by calling legacy_player_create() or legacy_player_unprepare(). After that, call legacy_player_set_uri() to load the media content you want to play.
+ * @post It invokes legacy_player_prepared_cb() when playback is prepared.
+ * @see legacy_player_prepare()
+ * @see legacy_player_prepared_cb()
+ * @see legacy_player_unprepare()
+ * @see legacy_player_set_uri()
+ */
+int legacy_player_prepare_async (player_h player, player_prepared_cb callback, void* user_data);
+
+/**
+ * @brief Resets 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
+ * legacy_player_prepare() again.
+ * @since_tizen 2.3
+ * @param[in] player The handle to the media player
+ * @return @c 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 higher than #PLAYER_STATE_IDLE.
+ * @post The player state will be #PLAYER_STATE_IDLE.
+ * @see legacy_player_prepare()
+ */
+int legacy_player_unprepare(player_h player);
+
+/**
+ * @brief Sets the data source (file-path, HTTP or RSTP URI) to use.
+ *
+ * @details Associates media contents, referred to by the URI, with the player.
+ * If the function call is successful, subsequent calls to legacy_player_prepare() and legacy_player_start() will start playing the media.
+ * @since_tizen 2.3
+ * @remarks If you use HTTP or RSTP, 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 legacy_player_start().
+ *
+ * @param[in] player The handle to the media player
+ * @param[in] uri The content location, such as the file path, the URI of the HTTP or RSTP stream you want to play
+ *
+ * @return @c 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 set to #PLAYER_STATE_IDLE by calling legacy_player_create() or legacy_player_unprepare().
+ * @see legacy_player_set_memory_buffer()
+ */
+int legacy_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 legacy_player_set_uri(), the media resides in memory.
+ * If the function call is successful, subsequent calls to legacy_player_prepare() and legacy_player_start() will start playing the media.
+ * @since_tizen 2.3
+ * @remarks If you provide an invalid data, you won't receive an error message until you call legacy_player_start().
+ *
+ * @param[in] player The handle to the media player
+ * @param[in] data The memory pointer of media data
+ * @param[in] size The size of media data
+ * @return @c 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 set to #PLAYER_STATE_IDLE by calling legacy_player_create() or legacy_player_unprepare().
+ * @see legacy_player_set_uri()
+ */
+int legacy_player_set_memory_buffer(player_h player, const void * data, int size);
+
+/**
+ * @brief Gets the player's current state.
+ * @since_tizen 2.3
+ * @param[in] player The handle to the media player
+ * @param[out] state The current state of the player
+ * @return @c 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 legacy_player_get_state(player_h player, player_state_e *state);
+
+/**
+ * @brief Sets the player's volume.
+ * @since_tizen 2.3
+ * @details Setting this volume adjusts the player's instance volume, not the system volume.
+ * The valid range is from 0 to 1.0, inclusive (1.0 = 100%). Default value is 1.0.
+ * To change system volume, use the @ref CAPI_MEDIA_SOUND_MANAGER_MODULE API.
+ * Finally, it does not support to set other value into each channel currently.
+ *
+ * @param[in] player The handle to the media player
+ * @param[in] left The left volume scalar
+ * @param[in] right The right volume scalar
+ * @return @c 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 legacy_player_get_volume()
+ */
+int legacy_player_set_volume(player_h player, float left, float right);
+
+/**
+ * @brief Gets the player's current volume factor.
+ * @since_tizen 2.3
+ * @details The range of @a left and @a right is from @c 0 to @c 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 the media player
+ * @param[out] left The current left volume scalar
+ * @param[out] right The current right volume scalar
+ * @return @c 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 legacy_player_set_volume()
+ */
+int legacy_player_get_volume(player_h player, float *left, float *right);
+
+/**
+ * @deprecated Deprecated since 3.0. Use legacy_player_set_audio_policy_info() instead.
+ * @brief Sets the player's volume type.
+ * @since_tizen 2.3
+ * @remarks The default sound type of the player is #SOUND_TYPE_MEDIA.
+ * To get the current sound type, use sound_manager_get_current_sound_type().
+ * @remarks If stream_info already exists by calling sound_manager_create_stream_info(),
+ * It will return error since 3.0.
+ *
+ * @param[in] player The handle to the media player
+ * @param[in] type The sound type
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #PLAYER_ERROR_NONE Successful
+ * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #PLAYER_ERROR_SOUND_POLICY Sound policy error
+ * @pre The player state must be set to #PLAYER_STATE_IDLE by calling legacy_player_create().
+ * @see sound_manager_get_current_sound_type()
+ */
+int legacy_player_set_sound_type(player_h player, sound_type_e type);
+
+/**
+ * @brief Sets the player's sound manager stream information.
+ * @since_tizen 3.0
+ * @remarks You can set sound stream information including audio routing and volume type.
+ * For more details, please refer to sound_manager.h
+ *
+ * @param[in] player The handle to the media player
+ * @param[in] stream_info The sound manager info type
+ * @return @c 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_FEATURE_NOT_SUPPORTED_ON_DEVICE Unsupported feature
+ * @pre The player state must be set to #PLAYER_STATE_IDLE by calling legacy_player_create().
+ * @see #sound_stream_info_h
+ * @see sound_manager_create_stream_information()
+ * @see sound_manager_destroy_stream_information()
+ */
+int legacy_player_set_audio_policy_info(player_h player, sound_stream_info_h stream_info);
+
+/**
+ * @brief Sets the audio latency mode.
+ * @since_tizen 2.3
+ * @remarks The default audio latency mode of the player is #AUDIO_LATENCY_MODE_MID.
+ * To get the current audio latency mode, use legacy_player_get_audio_latency_mode().
+ * If it's high mode, audio output interval can be increased so, it can keep more audio data to play.
+ * But, state transition like pause or resume can be more slower than default(mid) mode.
+ *
+ * @param[in] player The handle to the media player
+ * @param[in] latency_mode The latency mode to be applied to the audio
+ * @return @c 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 legacy_player_get_audio_latency_mode()
+ */
+int legacy_player_set_audio_latency_mode(player_h player, audio_latency_mode_e latency_mode);
+
+/**
+ * @brief Gets the current audio latency mode.
+ * @since_tizen 2.3
+ * @param[in] player The handle to the media player
+ * @param[out] latency_mode The latency mode to get from the audio
+ * @return @c 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 legacy_player_set_audio_latency_mode()
+ */
+int legacy_player_get_audio_latency_mode(player_h player, audio_latency_mode_e *latency_mode);
+
+/**
+ * @brief Starts or resumes playback.
+ * @since_tizen 2.3
+ * @remarks Sound can be mixed with other sounds if you don't control the stream focus in sound-manager module since 3.0.\n
+ * You can refer to @ref CAPI_MEDIA_SUOND_MANAGER_MODULE.
+ * @details Plays current media content, or resumes play if paused.
+ *
+ * @param[in] player The handle to the media player
+ * @return @c 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 legacy_player_prepare() must be called before calling this function.
+ * @pre The player state must be set to #PLAYER_STATE_READY by calling legacy_player_prepare() or set to #PLAYER_STATE_PAUSED by calling legacy_player_pause().
+ * @post The player state will be #PLAYER_STATE_PLAYING.
+ * @post It invokes legacy_player_completed_cb() when playback completes, if you set a callback with legacy_player_set_completed_cb().
+ * @post It invokes legacy_player_pd_message_cb() when progressive download starts or completes, if you set a download path with legacy_player_set_progressive_download_path() and a callback with legacy_player_set_progressive_download_message_cb().
+ * @see legacy_player_prepare()
+ * @see legacy_player_prepare_async()
+ * @see legacy_player_stop()
+ * @see legacy_player_pause()
+ * @see legacy_player_set_completed_cb()
+ * @see legacy_player_completed_cb()
+ * @see legacy_player_set_progressive_download_path()
+ * @see legacy_player_set_progressive_download_message_cb()
+ * @see legacy_player_pd_message_cb()
+ */
+int legacy_player_start(player_h player);
+
+/**
+ * @brief Stops playing media content.
+ * @since_tizen 2.3
+ * @param[in] player The handle to the media player
+ * @return @c 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 set to #PLAYER_STATE_PLAYING by calling legacy_player_start() or set to #PLAYER_STATE_PAUSED by calling legacy_player_pause().
+ * @post The player state will be #PLAYER_STATE_READY.
+ * @post The downloading will be aborted if you use progressive download.
+ * @see legacy_player_start()
+ * @see legacy_player_pause()
+ */
+int legacy_player_stop(player_h player);
+
+/**
+ * @brief Pauses the player.
+ * @since_tizen 2.3
+ * @remarks You can resume playback using legacy_player_start().
+ *
+ * @param[in] player The handle to the media player
+ * @return @c 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 set to #PLAYER_STATE_PLAYING.
+ * @post The player state will be #PLAYER_STATE_READY.
+ * @see legacy_player_start()
+ */
+int legacy_player_pause(player_h player);
+
+/**
+ * @brief Sets the seek position for playback, asynchronously.
+ * @since_tizen 2.3
+ * @param[in] player The handle to the media player
+ * @param[in] millisecond The position in milliseconds from the start to the seek point
+ * @param[in] accurate If @c true the selected position is returned, but this might be considerably slow,
+ * otherwise @c false
+ * @param[in] callback The callback function to register
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return @c 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 legacy_player_seek_completed_cb() when seek operation completes, if you set a callback.
+ * @see legacy_player_get_play_position()
+ */
+int legacy_player_set_play_position(player_h player, int millisecond, bool accurate, player_seek_completed_cb callback, void *user_data);
+
+/**
+ * @brief Gets the current position in milliseconds.
+ * @since_tizen 2.3
+ * @param[in] player The handle to the media player
+ * @param[out] millisecond The current position in milliseconds
+ * @return @c 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 legacy_player_set_play_position()
+ */
+int legacy_player_get_play_position(player_h player, int *millisecond);
+
+/**
+ * @brief Sets the player's mute status.
+ * @since_tizen 2.3
+ * @details If the mute status is @c true, no sounds are played.
+ * If it is @c false, sounds are 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 the media player
+ * @param[in] muted The new mute status: (@c true = mute, @c false = not muted)
+ * @return @c 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 legacy_player_is_muted()
+ */
+int legacy_player_set_mute(player_h player, bool muted);
+
+/**
+ * @brief Gets the player's mute status.
+ * @since_tizen 2.3
+ * @details If the mute status is @c true, no sounds are played.
+ * If it is @c false, sounds are played at the previously set volume level.
+ *
+ * @param[in] player The handle to the media player
+ * @param[out] muted The current mute status: (@c true = mute, @c false = not muted)
+ * @return @c 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 legacy_player_set_mute()
+ */
+int legacy_player_is_muted(player_h player, bool *muted);
+
+/**
+ * @brief Sets the player's looping status.
+ * @since_tizen 2.3
+ * @details If the looping status is @c true, playback automatically restarts upon finishing.
+ * If it is @c false, it won't. The default value is @c false.
+ *
+ * @param[in] player The handle to the media player
+ * @param[in] looping The new looping status: (@c true = looping, @c false = non-looping )
+ * @return @c 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 legacy_player_is_looping()
+ */
+int legacy_player_set_looping(player_h player, bool looping);
+
+/**
+ * @brief Gets the player's looping status.
+ * @since_tizen 2.3
+ * @details If the looping status is @c true, playback automatically restarts upon finishing.
+ * If it is @c false, it won't.
+ *
+ * @param[in] player The handle to the media player
+ * @param[out] looping The looping status: (@c true = looping, @c false = non-looping )
+ * @return @c 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 legacy_player_set_looping()
+ */
+int legacy_player_is_looping(player_h player, bool *looping);
+
+/**
+ * @brief Sets the video display.
+ * @since_tizen 2.3
+ * @remarks To get @a display to set, use #GET_DISPLAY().
+ * @remarks To use the multiple surface display mode, use legacy_player_set_display() again with a different display type.
+ * @remarks We are not supporting changing display between different types. \n
+ * If you want to change display handle after calling legacy_player_prepare(), you must use the same display type as what you set before.
+ * @param[in] player The handle to the media player
+ * @param[in] type The display type
+ * @param[in] display The handle to display
+ * @return @c 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 legacy_player_set_display_rotation
+ */
+int legacy_player_set_display(player_h player, player_display_type_e type, player_display_h display);
+
+/**
+ * @brief Registers a media packet video callback function to be called once per frame.
+ * @since_tizen 2.3
+ * @remarks This function should be called before preparing. \n
+ * A registered callback is called on the internal thread of the player. \n
+ * A video frame can be retrieved using a registered callback as a media packet.\n
+ * The callback function holds the same buffer that will be drawn on the display device.\n
+ * So if you change the media packet in a registerd callback, it will be displayed on the device\n
+ * and the media packet is available until it's destroyed by media_packet_destroy().
+ * @param[in] player The handle to the media player
+ * @param[in] callback The callback function to be registered
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return @c 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's state should be #PLAYER_STATE_IDLE. And, #PLAYER_DISPLAY_TYPE_NONE should be set by calling legacy_player_set_display().
+ * @see legacy_player_unset_media_packet_video_frame_decoded_cb
+ */
+int legacy_player_set_media_packet_video_frame_decoded_cb(player_h player, player_media_packet_video_decoded_cb callback, void *user_data);
+
+/**
+ * @brief Unregisters the callback function.
+ * @since_tizen 2.3
+ * @param[in] player The handle to the media player
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #PLAYER_ERROR_NONE Successful
+ * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre The player's state should be #PLAYER_STATE_READY or #PLAYER_STATE_IDLE
+ * @see legacy_player_set_media_packet_video_frame_decoded_cb()
+ */
+int legacy_player_unset_media_packet_video_frame_decoded_cb(player_h player);
+
+/**
+ * @brief Pushes elementary stream to decode audio or video
+ * @since_tizen 2.4
+ * @remarks legacy_player_set_media_stream_info() should be called before using this API.
+ * @remarks The available buffer size can be set by calling legacy_player_set_media_stream_buffer_max_size() API.
+ * If there is no available buffer space, this api will return error since 3.0.
+ * @param[in] player The handle to media player
+ * @param[in] packet The media packet to decode
+ * @return @c 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
+ * @retval #PLAYER_ERROR_NOT_SUPPORTED_FILE File not supported
+ * @retval #PLAYER_ERROR_BUFFER_SPACE No buffer space available (since 3.0)
+ * @pre The player state must be set to #PLAYER_STATE_IDLE at least.
+ * @see legacy_player_set_media_stream_info()
+ * @see legacy_player_set_media_stream_buffer_max_size()
+ */
+int legacy_player_push_media_stream(player_h player, media_packet_h packet);
+
+/**
+ * @brief Sets contents information for media stream
+ * @since_tizen 2.4
+ * @remarks AV format should be set before pushing elementary stream with legacy_player_push_media_stream().
+ * @remarks AAC can be supported.
+ * @remarks H.264 can be supported.
+ * @remarks This API should be called before calling the legacy_player_prepare() or legacy_player_prepare_async() \n
+ to reflect the media information when pipeline is created.
+ * @param[in] player The handle to media player
+ * @param[in] type The type of target stream
+ * @param[in] format The media format to set audio information
+ * @return @c 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 state must be set to #PLAYER_STATE_IDLE by calling legacy_player_create() or legacy_player_unprepare().
+ * @see legacy_player_push_media_stream()
+ */
+int legacy_player_set_media_stream_info(player_h player, player_stream_type_e type, media_format_h format);
+
+/**
+ * @brief Registers a callback function to be invoked when buffer underrun or overflow is occurred.
+ * @since_tizen 2.4
+ * @remarks This API is used for media stream playback only.
+ * @param[in] player The handle to the media player
+ * @param[in] type The type of target stream
+ * @param[in] callback The buffer status callback function to register
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #PLAYER_ERROR_NONE Successful
+ * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state
+ * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre The player state must be set to #PLAYER_STATE_IDLE by calling legacy_player_create() or legacy_player_unprepare().
+ * @post legacy_player_media_stream_buffer_status_cb() will be invoked.
+ * @see legacy_player_unset_media_stream_buffer_status_cb()
+ * @see legacy_player_media_stream_buffer_status_cb()
+ */
+int legacy_player_set_media_stream_buffer_status_cb(player_h player, player_stream_type_e type, player_media_stream_buffer_status_cb callback, void *user_data);
+
+/**
+ * @brief Unregisters the buffer status callback function.
+ * @since_tizen 2.4
+ * @remarks This API is used for media stream playback only.
+ * @param[in] player The handle to the media player
+ * @param[in] type The type of target stream
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #PLAYER_ERROR_NONE Successful
+ * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state
+ * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see legacy_player_set_media_stream_buffer_status_cb()
+ */
+int legacy_player_unset_media_stream_buffer_status_cb(player_h player, player_stream_type_e type);
+
+/**
+ * @brief Registers a callback function to be invoked when seeking is occurred.
+ * @since_tizen 2.4
+ * @remarks This API is used for media stream playback only.
+ * @param[in] player The handle to the media player
+ * @param[in] type The type of target stream
+ * @param[in] callback The callback function to register
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #PLAYER_ERROR_NONE Successful
+ * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state
+ * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre The player state must be set to #PLAYER_STATE_IDLE by calling legacy_player_create() or legacy_player_unprepare().
+ * @post legacy_player_media_stream_seek_cb() will be invoked.
+ * @see legacy_player_unset_media_stream_seek_cb()
+ * @see legacy_player_media_stream_seek_cb()
+ */
+int legacy_player_set_media_stream_seek_cb(player_h player, player_stream_type_e type, player_media_stream_seek_cb callback, void *user_data);
+
+/**
+ * @brief Unregisters the seek callback function.
+ * @since_tizen 2.4
+ * @param[in] player The handle to the media player
+ * @param[in] type The type of target stream
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #PLAYER_ERROR_NONE Successful
+ * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state
+ * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see legacy_player_set_media_stream_seek_cb()
+ */
+int legacy_player_unset_media_stream_seek_cb(player_h player, player_stream_type_e type);
+
+/**
+ * @brief Sets the max size bytes of buffer.
+ * @since_tizen 2.4
+ * @remarks This API is used for media stream playback only.
+ * @remarks If the buffer level over the max size, legacy_player_media_stream_buffer_status_cb() will be invoked with overflow status.
+ * @param[in] player The handle to the media player
+ * @param[in] type The type of target stream
+ * @param[in] max_size The max bytes of buffer, it has to be bigger than zero. (default: 200000)
+ * @return @c 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. (since 3.0)
+ * @see legacy_player_get_media_stream_buffer_max_size()
+ * @see legacy_player_media_stream_buffer_status_cb()
+ */
+int legacy_player_set_media_stream_buffer_max_size(player_h player, player_stream_type_e type, unsigned long long max_size);
+
+/**
+ * @brief Gets the max size bytes of buffer.
+ * @since_tizen 2.4
+ * @remarks This API is used for media stream playback only.
+ * @remarks If the buffer level over the max size, legacy_player_media_stream_buffer_status_cb() will be invoked with overflow status.
+ * @param[in] player The handle to the media player
+ * @param[in] type The type of target stream
+ * @param[out] max_size The max bytes of buffer
+ * @return @c 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 legacy_player_set_media_stream_buffer_max_size()
+ * @see legacy_player_media_stream_buffer_status_cb()
+ */
+int legacy_player_get_media_stream_buffer_max_size(player_h player, player_stream_type_e type, unsigned long long *max_size);
+
+/**
+ * @brief Sets the buffer threshold percent of buffer.
+ * @since_tizen 2.4
+ * @remarks This API is used for media stream playback only.
+ * @remarks If the buffer level drops below the percent value, legacy_player_media_stream_buffer_status_cb() will be invoked with underrun status.
+ * @param[in] player The handle to the media player
+ * @param[in] type The type of target stream
+ * @param[in] percent The minimum threshold(0~100) of buffer (default: 0)
+ * @return @c 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. (since 3.0)
+ * @see legacy_player_get_media_stream_buffer_min_threshold()
+ * @see legacy_player_media_stream_buffer_status_cb()
+ */
+int legacy_player_set_media_stream_buffer_min_threshold(player_h player, player_stream_type_e type, unsigned int percent);
+
+/**
+ * @brief Gets the buffer threshold percent of buffer.
+ * @since_tizen 2.4
+ * @remarks This API is used for media stream playback only.
+ * @remarks If the buffer level drops below the percent value, legacy_player_media_stream_buffer_status_cb() will be invoked with underrun status.
+ * @param[in] player The handle to the media player
+ * @param[in] type The type of target stream
+ * @param[out] percent The minimum threshold(0~100) of buffer
+ * @return @c 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 legacy_player_set_media_stream_buffer_min_threshold()
+ * @see legacy_player_media_stream_buffer_status_cb()
+ */
+int legacy_player_get_media_stream_buffer_min_threshold(player_h player, player_stream_type_e type, unsigned int *percent);
+
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup CAPI_MEDIA_PLAYER_DISPLAY_MODULE
+ * @{
+ */
+
+/**
+ * @brief Sets the video display mode.
+ * @since_tizen 2.3
+ * @remarks If no display is set, no operation is performed.
+ * @param[in] player The handle to the media player
+ * @param[in] mode The display mode
+ * @return @c 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 support display mode changes.
+ * @see legacy_player_get_display_mode()
+ */
+int legacy_player_set_display_mode(player_h player, player_display_mode_e mode);
+
+/**
+ * @brief Gets the video display mode.
+ * @since_tizen 2.3
+ * @remarks If no display is set, no operation is performed.
+ * @param[in] player The handle to the media player
+ * @param[out] mode The current display mode
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #PLAYER_ERROR_NONE Successful
+ * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see legacy_player_set_display_mode()
+ */
+int legacy_player_get_display_mode(player_h player, player_display_mode_e *mode);
+
+/**
+ * @brief Sets the visibility of the x surface video display
+ * @since_tizen 2.3
+ * @param[in] player The handle to the media player
+ * @param[in] visible The visibility of the display (@c true = visible, @c false = non-visible )
+ * @return @c 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 legacy_player_is_display_visible()
+ */
+int legacy_player_set_display_visible(player_h player, bool visible);
+
+/**
+ * @brief Gets the visibility of the x surface video display.
+ * @since_tizen 2.3
+ * @param[in] player The handle to the media player
+ * @param[out] visible The current visibility of the display (@c true = visible, @c false = non-visible )
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #PLAYER_ERROR_NONE Successful
+ * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see legacy_player_set_display_visible()
+ */
+int legacy_player_is_display_visible(player_h player, bool* visible);
+
+/**
+ * @brief Sets the rotation settings of the video surface display.
+ * @since_tizen 2.3
+ * @details Use this function to change the video orientation to portrait mode.
+ * @param[in] player The handle to the media player
+ * @param[in] rotation The rotation of the display
+ * @return @c 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
+ * @retval #PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE Unsupported feature
+ * @see legacy_player_set_display
+ * @see legacy_player_get_display_rotation()
+ */
+int legacy_player_set_display_rotation(player_h player, player_display_rotation_e rotation);
+
+/**
+ * @brief Gets the rotation of the video surface display.
+ * @since_tizen 2.3
+ * @param[in] player The handle to the media player
+ * @param[out] rotation The current rotation of the display
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #PLAYER_ERROR_NONE Successful
+ * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see legacy_player_set_display_rotation()
+ */
+int legacy_player_get_display_rotation( player_h player, player_display_rotation_e *rotation);
+
+/**
+ * @}
+ */
+
+
+/**
+ * @addtogroup CAPI_MEDIA_PLAYER_STREAM_INFO_MODULE
+ * @{
+ */
+
+ /**
+ * @brief Gets the media content information.
+ * @since_tizen 2.3
+ * @remarks You must release @a value using @c free().
+ * @remarks The playback type should be local playback or HTTP streaming playback.
+ * @param[in] player The handle to the media player
+ * @param[in] key The key attribute name to get
+ * @param[out] value The value of the key attribute \n
+ * It can be an empty string if there is no content information.
+ * @return @c 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 these: #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING or #PLAYER_STATE_PAUSED.
+ */
+int legacy_player_get_content_info(player_h player, player_content_info_e key, char ** value);
+
+/**
+ * @brief Gets the audio and video codec information.
+ * @since_tizen 2.3
+ * @remarks You must release @a audio_codec and @a video_codec using free().
+ * @remarks The playback type should be local playback or HTTP streaming playback.
+ * @param[in] player The handle to the media player
+ * @param[out] audio_codec The name of the audio codec \n
+ * It can be @c NULL if there is no audio codec.
+ * @param[out] video_codec The name of the video codec \n
+ * It can be @c NULL if there is no video codec.
+ * @return @c 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_READY, #PLAYER_STATE_PLAYING or #PLAYER_STATE_PAUSED.
+ */
+int legacy_player_get_codec_info(player_h player, char **audio_codec, char **video_codec);
+
+/**
+ * @brief Gets the audio stream information.
+ * @since_tizen 2.3
+ * @remarks The playback type should be local playback or HTTP streaming playback.
+ * @param[in] player The handle to the media player
+ * @param[out] sample_rate The audio sample rate [Hz] \n
+ * Value can be invalid if there is no audio stream information.
+ * @param[out] channel The audio channel (1: mono, 2: stereo) \n
+ * Value can be invalid if there is no audio stream information.
+ * @param[out] bit_rate The audio bit rate [Hz] \n
+ * Value can be invalid if there is no audio stream information.
+ * @return @c 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_READY, #PLAYER_STATE_PLAYING or #PLAYER_STATE_PAUSED.
+ */
+int legacy_player_get_audio_stream_info(player_h player, int *sample_rate, int *channel, int *bit_rate);
+
+/**
+ * @brief Gets the video stream information.
+ * @since_tizen 2.3
+ * @remarks The playback type should be local playback or HTTP streaming playback.
+ * @param[in] player The handle to the media player
+ * @param[out] fps The frame per second of the video \n
+ * It can be @c 0 if there is no video stream information.
+ * @param[out] bit_rate The video bit rate [Hz] \n
+ * It can be an invalid value if there is no video stream information.
+ * @return @c 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_READY, #PLAYER_STATE_PLAYING or #PLAYER_STATE_PAUSED.
+ */
+int legacy_player_get_video_stream_info(player_h player, int *fps, int *bit_rate);
+
+/**
+ * @brief Gets the video display's height and width.
+ * @since_tizen 2.3
+ * @remarks The playback type should be local playback or HTTP streaming playback.
+ * @param[in] player The handle to the media player
+ * @param[out] width The width of the video \n
+ * Value can be invalid if there is no video or no display is set.
+ * @param[out] height The height of the video \n
+ * Value can be invalid value if there is no video or no display is set.
+ * @return @c 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_READY, #PLAYER_STATE_PLAYING or #PLAYER_STATE_PAUSED.
+ */
+int legacy_player_get_video_size(player_h player, int *width, int *height);
+
+/**
+ * @brief Gets the album art in the media resource.
+ * @since_tizen 2.3
+ * @remarks You must not release @a album_art. It will be released by framework when the player is destroyed.
+ * @param[in] player The handle to the media player
+ * @param[out] album_art The encoded artwork image
+ * @param[out] size The encoded artwork size
+ * @return @c 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_READY, #PLAYER_STATE_PLAYING or #PLAYER_STATE_PAUSED.
+ */
+int legacy_player_get_album_art(player_h player, void **album_art, int *size);
+
+/**
+ * @brief Gets the total running time of the associated media.
+ * @since_tizen 2.3
+ * @remarks The media source is associated with the player, using either legacy_player_set_uri() or legacy_player_set_memory_buffer().
+ * @remarks The playback type should be local playback or HTTP streaming playback.
+ * @param[in] player The handle to the media player
+ * @param[out] duration The duration in milliseconds
+ * @return @c 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_READY, #PLAYER_STATE_PLAYING or #PLAYER_STATE_PAUSED.
+ * @see legacy_player_set_uri()
+ * @see legacy_player_set_memory_buffer()
+ */
+int legacy_player_get_duration(player_h player, int *duration);
+
+/**
+ * @}
+ */
+
+
+/**
+ * @addtogroup CAPI_MEDIA_PLAYER_AUDIO_EFFECT_MODULE
+ * @{
+ */
+
+/**
+ * @brief Gets the number of equalizer bands.
+ * @since_tizen 2.3
+ * @param[in] player The handle to the media player
+ * @param[out] count The number of equalizer bands
+ * @return @c 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 legacy_player_audio_effect_set_equalizer_band_level()
+ * @see legacy_player_audio_effect_set_equalizer_all_bands()
+ */
+int legacy_player_audio_effect_get_equalizer_bands_count (player_h player, int *count);
+
+/**
+ * @brief Sets the gain set for the given equalizer band.
+ * @since_tizen 2.3
+ * @param[in] player The handle to the media player
+ * @param[in] index The index of the equalizer band to be set
+ * @param[in] level The new gain in decibel that is set to the given band [dB]
+ * @return @c 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 legacy_player_audio_effect_get_equalizer_bands_count()
+ * @see legacy_player_audio_effect_get_equalizer_level_range()
+ * @see legacy_player_audio_effect_get_equalizer_band_level()
+ * @see legacy_player_audio_effect_set_equalizer_all_bands()
+ */
+int legacy_player_audio_effect_set_equalizer_band_level(player_h player, int index, int level);
+
+/**
+ * @brief Gets the gain set for the given equalizer band.
+ * @since_tizen 2.3
+ * @param[in] player The handle to the media player
+ * @param[in] index The index of the requested equalizer band
+ * @param[out] level The gain in decibel of the given band [dB]
+ * @return @c 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 legacy_player_audio_effect_set_equalizer_band_level()
+ */
+int legacy_player_audio_effect_get_equalizer_band_level(player_h player, int index, int *level);
+
+/**
+ * @brief Sets all bands of the equalizer.
+ * @since_tizen 2.3
+ * @param[in] player The handle to the media player
+ * @param[in] band_levels The list of band levels to be set
+ * @param[in] length The length of the band level
+ * @return @c 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 legacy_player_audio_effect_get_equalizer_bands_count()
+ * @see legacy_player_audio_effect_get_equalizer_level_range()
+ * @see legacy_player_audio_effect_set_equalizer_band_level()
+ */
+int legacy_player_audio_effect_set_equalizer_all_bands(player_h player, int *band_levels, int length);
+
+/**
+ * @brief Gets the valid band level range of the equalizer.
+ * @since_tizen 2.3
+ * @param[in] player The handle to the media player
+ * @param[out] min The minimum value to be set [dB]
+ * @param[out] max The maximum value to be set [dB]
+ * @return @c 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 legacy_player_audio_effect_set_equalizer_band_level()
+ * @see legacy_player_audio_effect_set_equalizer_all_bands()
+ */
+int legacy_player_audio_effect_get_equalizer_level_range(player_h player, int* min, int* max);
+
+/**
+ * @brief Gets the band frequency of the equalizer.
+ * @since_tizen 2.3
+ * @param[in] player The handle to the media player
+ * @param[in] index The index of the requested equalizer band
+ * @param[out] frequency The frequency of the given band [dB]
+ * @return @c 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 legacy_player_audio_effect_get_equalizer_band_frequency(player_h player, int index, int *frequency);
+
+/**
+ * @brief Gets the band frequency range of the equalizer.
+ * @since_tizen 2.3
+ * @param[in] player The handle to the media player
+ * @param[in] index The index of the requested equalizer band
+ * @param[out] range The frequency range of the given band [dB]
+ * @return @c 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 legacy_player_audio_effect_get_equalizer_band_frequency_range(player_h player, int index, int *range);
+
+/**
+ * @brief Clears the equalizer effect.
+ * @since_tizen 2.3
+ * @param[in] player The handle to the media player
+ * @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 legacy_player_audio_effect_set_equalizer_band_level()
+ * @see legacy_player_audio_effect_set_equalizer_all_bands()
+ */
+int legacy_player_audio_effect_equalizer_clear(player_h player);
+
+/**
+ * @brief Checks whether the custom equalizer effect is available.
+ * @since_tizen 2.3
+ * @param[in] player The handle to the media player
+ * @param[out] available If @c true the specified audio effect is available,
+ * otherwise @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 legacy_player_audio_effect_set_equalizer_band_level()
+ * @see legacy_player_audio_effect_set_equalizer_all_bands()
+ */
+int legacy_player_audio_effect_equalizer_is_available(player_h player, bool *available);
+
+/**
+ * @}
+ */
+
+
+/**
+ * @addtogroup CAPI_MEDIA_PLAYER_MODULE
+ * @{
+ */
+
+/**
+ * @brief Captures the video frame, asynchronously.
+ * @since_tizen 2.3
+ * @param[in] player The handle to the 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 @c 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
+ * Video type should be set using legacy_player_set_display() otherwises, audio stream is only processed even though video file is set.
+ * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state
+ * @pre The player state must be set to #PLAYER_STATE_PLAYING by calling legacy_player_start() or set to #PLAYER_STATE_PAUSED by calling legacy_player_pause().
+ * @post It invokes legacy_player_video_captured_cb() when capture completes, if you set a callback.
+ * @see legacy_player_video_captured_cb()
+ */
+int legacy_player_capture_video(player_h player, player_video_captured_cb callback, void *user_data);
+
+/**
+ * @brief Sets the cookie for streaming playback.
+ * @since_tizen 2.3
+ * @param[in] player The handle to the media player
+ * @param[in] cookie The cookie to set
+ * @param[in] size The size of the cookie
+ * @return @c 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 set to #PLAYER_STATE_IDLE by calling legacy_player_create() or legacy_player_unprepare().
+ * @see legacy_player_set_streaming_user_agent()
+ */
+int legacy_player_set_streaming_cookie(player_h player, const char *cookie, int size);
+
+/**
+ * @brief Sets the streaming user agent for playback.
+ * @since_tizen 2.3
+ * @param[in] player The handle to the media player
+ * @param[in] user_agent The user agent to set
+ * @param[in] size The size of the user agent
+ * @return @c 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 set to #PLAYER_STATE_IDLE by calling legacy_player_create() or legacy_player_unprepare().
+ * @see legacy_player_set_streaming_cookie()
+ */
+int legacy_player_set_streaming_user_agent(player_h player, const char *user_agent, int size);
+
+/**
+ * @brief Gets the download progress for streaming playback.
+ * @since_tizen 2.3
+ * @param[in] player The handle to the media player
+ * @param[out] start The starting position in percentage [0, 100]
+ * @param[out] current The current position in percentage [0, 100]
+ * @return @c 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 set to #PLAYER_STATE_PLAYING by calling legacy_player_start() or set to #PLAYER_STATE_PAUSED by calling legacy_player_pause().
+ */
+int legacy_player_get_streaming_download_progress(player_h player, int *start, int *current);
+
+/**
+ * @brief Registers a callback function to be invoked when the playback is finished.
+ * @since_tizen 2.3
+ * @param[in] player The handle to the 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 @c 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 legacy_player_completed_cb() will be invoked.
+ * @see legacy_player_unset_completed_cb()
+ * @see legacy_player_completed_cb()
+ * @see legacy_player_start()
+ */
+int legacy_player_set_completed_cb(player_h player, player_completed_cb callback, void *user_data);
+
+/**
+ * @brief Unregisters the callback function.
+ * @since_tizen 2.3
+ * @param[in] player The handle to the media player
+ * @return @c 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 legacy_player_set_completed_cb()
+ */
+int legacy_player_unset_completed_cb(player_h player);
+
+/**
+ * @brief Registers a callback function to be invoked when the playback is interrupted or the interrupt is completed.
+ * @since_tizen 2.3
+ * @param[in] player The handle to the 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 @c 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 legacy_player_unset_interrupted_cb()
+ * @see #player_interrupted_code_e
+ * @see legacy_player_interrupted_cb()
+ */
+int legacy_player_set_interrupted_cb(player_h player, player_interrupted_cb callback, void *user_data);
+
+/**
+ * @brief Unregisters the callback function.
+ * @since_tizen 2.3
+ * @param[in] player The handle to the media player
+ * @return @c 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 legacy_player_set_interrupted_cb()
+ */
+int legacy_player_unset_interrupted_cb(player_h player);
+
+/**
+ * @brief Registers a callback function to be invoked when an error occurs.
+ * @since_tizen 2.3
+ * @param[in] player The handle to the 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 @c 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 legacy_player_error_cb() will be invoked.
+ * @see legacy_player_unset_error_cb()
+ * @see legacy_player_error_cb()
+ */
+int legacy_player_set_error_cb(player_h player, player_error_cb callback, void *user_data);
+
+/**
+ * @brief Unregisters the callback function.
+ * @since_tizen 2.3
+ * @param[in] player The handle to the media player
+ * @return @c 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 legacy_player_set_error_cb()
+ */
+int legacy_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.
+ * @since_tizen 2.3
+ * @remarks The media resource should be streamed over the network.
+ * @param[in] player The handle to the 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 @c 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_FEATURE_NOT_SUPPORTED_ON_DEVICE Unsupported feature
+ * @post legacy_player_buffering_cb() will be invoked.
+ * @see legacy_player_unset_buffering_cb()
+ * @see legacy_player_set_uri()
+ * @see legacy_player_buffering_cb()
+ */
+int legacy_player_set_buffering_cb(player_h player, player_buffering_cb callback, void *user_data);
+
+/**
+ * @brief Unregisters the callback function.
+ * @since_tizen 2.3
+ * @param[in] player The handle to the media player
+ * @return @c 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 legacy_player_set_buffering_cb()
+ */
+int legacy_player_unset_buffering_cb(player_h player);
+
+/**
+ * @brief Sets a path to download, progressively.
+ * @since_tizen 2.3
+ * @remarks Progressive download will be started when you invoke legacy_player_start().
+ * @param[in] player The handle to the media player
+ * @param[in] path The absolute path to download
+ * @return @c 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_FEATURE_NOT_SUPPORTED_ON_DEVICE Unsupported feature
+ * @pre The player state must be set to #PLAYER_STATE_IDLE by calling legacy_player_create() or legacy_player_unprepare().
+ * @see legacy_player_set_progressive_download_message_cb()
+ * @see legacy_player_unset_progressive_download_message_cb()
+ */
+int legacy_player_set_progressive_download_path(player_h player, const char *path);
+
+/**
+ * @brief Gets the status of progressive download.
+ * @since_tizen 2.3
+ * @param[in] player The handle to the media player
+ * @param[out] current The current download position (bytes)
+ * @param[out] total_size The total size of the file (bytes)
+ * @return @c 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 calling legacy_player_set_progressive_download_path().
+ * @pre The player state must be set to #PLAYER_STATE_PLAYING by calling legacy_player_start() or set to #PLAYER_STATE_PAUSED by calling legacy_player_pause().
+ */
+int legacy_player_get_progressive_download_status(player_h player, unsigned long *current, unsigned long *total_size);
+
+/**
+ * @brief Registers a callback function to be invoked when progressive download is started or completed.
+ * @since_tizen 2.3
+ * @param[in] player The handle to the 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 @c 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_FEATURE_NOT_SUPPORTED_ON_DEVICE Unsupported feature
+ * @pre The path to download must be set by calling legacy_player_set_progressive_download_path().
+ * @post legacy_player_pd_message_cb() will be invoked.
+ * @see legacy_player_unset_progressive_download_message_cb()
+ * @see legacy_player_set_progressive_download_path()
+ */
+int legacy_player_set_progressive_download_message_cb(player_h player, player_pd_message_cb callback, void *user_data);
+
+/**
+ * @brief Unregisters the callback function.
+ * @since_tizen 2.3
+ * @param[in] player The handle to the media player
+ * @return @c 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 legacy_player_set_progressive_download_message_cb()
+ */
+int legacy_player_unset_progressive_download_message_cb(player_h player);
+
+/**
+ * @brief Sets the playback rate.
+ * @since_tizen 2.3
+ * @details The default value is @c 1.0.
+ * @remarks #PLAYER_ERROR_INVALID_OPERATION occurs when streaming playback.
+ * @remarks No operation is performed, if @a rate is @c 0.
+ * @remarks The sound is muted, when playback rate is under @c 0.0 and over @c 2.0.
+ * @param[in] player The handle to the media player
+ * @param[in] rate The playback rate (-5.0x ~ 5.0x)
+ * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state
+ * @pre The player state must be set to #PLAYER_STATE_PLAYING by calling legacy_player_start().
+ * @pre The player state must be set to #PLAYER_STATE_READY by calling legacy_player_prepare() or set to #PLAYER_STATE_PLAYING by calling legacy_player_start() or set to #PLAYER_STATE_PAUSED by calling legacy_player_pause().
+ */
+int legacy_player_set_playback_rate(player_h player, float rate);
+
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup CAPI_MEDIA_PLAYER_SUBTITLE_MODULE
+ * @{
+ */
+
+/**
+ * @brief Sets a subtitle path.
+ * @since_tizen 2.3
+ * @remarks Only MicroDVD/SubViewer(*.sub), SAMI(*.smi), and SubRip(*.srt) subtitle formats are supported.
+ * @param[in] player The handle to the media player
+ * @param[in] path The absolute path of the subtitle file, it can be @c NULL in the #PLAYER_STATE_IDLE state.
+ * @return @c 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.
+ * @pre The path value can be @c NULL for reset when the player state is set to #PLAYER_STATE_IDLE by calling legacy_player_create() or legacy_player_unprepare().
+ */
+int legacy_player_set_subtitle_path(player_h player,const char *path);
+
+/**
+ * @brief Registers a callback function to be invoked when a subtitle updates.
+ * @since_tizen 2.3
+ * @param[in] player The handle to the 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 @c 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 calling legacy_player_set_subtitle_path().
+ * @post legacy_player_subtitle_updated_cb() will be invoked.
+ * @see legacy_player_unset_subtitle_updated_cb()
+ * @see legacy_player_subtitle_updated_cb()
+ * @see legacy_player_set_subtitle_path()
+ */
+int legacy_player_set_subtitle_updated_cb(player_h player, player_subtitle_updated_cb callback, void *user_data);
+
+/**
+ * @brief Unregisters the callback function.
+ * @since_tizen 2.3
+ * @param[in] player The handle to the media player
+ * @return @c 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 legacy_player_set_subtitle_updated_cb()
+ */
+int legacy_player_unset_subtitle_updated_cb(player_h player);
+
+/**
+ * @brief Sets the seek position for the subtitle.
+ * @since_tizen 2.3.1
+ * @remarks Only MicroDVD/SubViewer(*.sub), SAMI(*.smi), and SubRip(*.srt) subtitle formats are supported.
+ * @param[in] player The handle to the media player
+ * @param[in] millisecond The position in milliseconds from the start to the seek point
+ * @return @c 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 calling legacy_player_set_subtitle_path().
+ * @pre The player state must be one of these: #PLAYER_STATE_PLAYING or #PLAYER_STATE_PAUSED.
+ */
+int legacy_player_set_subtitle_position_offset(player_h player, int millisecond);
+
+/**
+ * @brief Registers a callback function to be invoked when video stream is changed.
+ * @since_tizen 2.4
+ * @remarks The stream changing is detected just before rendering operation.
+ * @param[in] player The handle to the media player
+ * @param[in] callback The stream changed callback function to register
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #PLAYER_ERROR_NONE Successful
+ * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state
+ * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre The player state must be set to #PLAYER_STATE_IDLE by calling legacy_player_create() or legacy_player_unprepare().
+ * @post legacy_player_video_stream_changed_cb() will be invoked.
+ * @see legacy_player_unset_video_stream_changed_cb()
+ * @see legacy_player_video_stream_changed_cb()
+ */
+int legacy_player_set_video_stream_changed_cb (player_h player, player_video_stream_changed_cb callback, void *user_data);
+
+/**
+ * @brief Unregisters the video stream changed callback function.
+ * @since_tizen 2.4
+ * @param[in] player The handle to the media player
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #PLAYER_ERROR_NONE Successful
+ * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state
+ * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see legacy_player_set_video_stream_changed_cb()
+ */
+int legacy_player_unset_video_stream_changed_cb (player_h player);
+
+/**
+ * @brief Gets current track index.
+ * @since_tizen 2.4
+ * @details Index starts from 0.
+ * @remarks PLAYER_STREAM_TYPE_VIDEO is not supported.
+ * @param[in] player The handle to the media player
+ * @param[in] type The type of target stream
+ * @param[out] index The index of track
+ * @return @c 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_NOT_SUPPORTD Not supported
+ * @pre The player state must be one of these: #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED
+ */
+int legacy_player_get_current_track(player_h player, player_stream_type_e type, int *index);
+
+/**
+ * @brief Gets language code of a track.
+ * @since_tizen 2.4
+ * @remarks @a code must be released with @c free() by caller
+ * @remarks PLAYER_STREAM_TYPE_VIDEO is not supported.
+ * @param[in] player The handle to the media player
+ * @param[in] type The type of target stream
+ * @param[in] index The index of track
+ * @param[out] code A language code in ISO 639-1. "und" will be returned if the language is undefined.
+ * @return @c 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_NOT_SUPPORTD Not supported
+ * @pre The player state must be one of these: #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED
+ */
+int legacy_player_get_track_language_code(player_h player, player_stream_type_e type, int index, char **code);
+
+/**
+ * @brief Gets the track count.
+ * @since_tizen 2.4
+ * @remarks PLAYER_STREAM_TYPE_VIDEO is not supported.
+ * @param[in] player The handle to the media player
+ * @param[in] type The type of target stream
+ * @param[out] count The number of track
+ * @return @c 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_NOT_SUPPORTD Not supported
+ * @pre The player state must be one of these: #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED
+ */
+int legacy_player_get_track_count(player_h player, player_stream_type_e type, int *count);
+
+/**
+ * @brief Selects a track to play.
+ * @since_tizen 2.4
+ * @remarks PLAYER_STREAM_TYPE_VIDEO is not supported.
+ * @param[in] player The handle to the media player
+ * @param[in] type The type of target stream
+ * @param[in] index The index of track
+ * @return @c 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_NOT_SUPPORTD Not supported
+ * @pre The player state must be one of these: #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED
+ * @see legacy_player_get_current_track()
+ */
+int legacy_player_select_track(player_h player, player_stream_type_e type, int index);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_MEDIA_LEGACY_PLAYER_H__ */
+
--- /dev/null
+/*
+* 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_LEGACY_PLAYER_INTERNAL_H__
+#define __TIZEN_MEDIA_LEGACY_PLAYER_INTERNAL_H__
+#include <mm_player.h>
+#include "legacy_player.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file legacy_player_internal.h
+ */
+
+/**
+ * @addtogroup CAPI_MEDIA_PLAYER_MODULE
+ * @{
+ */
+
+/**
+ * @brief This file contains the media player API for custom features.
+ * @since_tizen 2.4
+ */
+typedef struct {
+ void *data; /**< PCM data */
+ int size; /**< Data Size */
+ int channel; /**< Channel */
+ int rate; /**< Samplerate */
+ int depth; /**< Depth */
+ bool little_endian; /**< Endianness */
+ guint64 channel_mask; /**< channel_mask */
+} player_audio_raw_data_s;
+
+/**
+ * @brief Called when the audio frame is decoded.
+ * @since_tizen 2.4
+ * @param[in] audio_raw_frame The decoded audio frame data type
+ * @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_pcm_extraction_cb)(player_audio_raw_data_s *audio_raw_frame, void *user_data);
+
+/**
+ * @brief Called when the buffer level drops below the min size or exceeds the max size.
+ * @since_tizen 3.0
+ * @remarks This API is used for media stream playback only.
+ * @param[in] status The buffer status
+ * @param[in] bytes The current buffer level bytes
+ * @param[in] user_data The user data passed from the callback registration function
+ * @see legacy_player_set_media_stream_buffer_status_cb_ex()
+ * @see legacy_player_set_media_stream_buffer_max_size()
+ * @see legacy_player_set_media_stream_buffer_min_threshold()
+ */
+typedef void (*player_media_stream_buffer_status_cb_ex) (player_media_stream_buffer_status_e status, unsigned long long bytes, void *user_data);
+
+/**
+ * @brief Registers a callback function to be invoked when audio frame is decoded. Audio only contents is possible. If included video, error happens.
+ * @since_tizen 2.4
+ * @param[in] player The handle to the media player
+ * @param[in] sync Sync on the clock
+ * @param[in] format Audio format of output pcm
+ * @param[in] callback The callback function to register
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return @c 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_NOT_SUPPORTD Not supported
+ * @pre The player state must be #PLAYER_STATE_IDLE by legacy_player_create() or legacy_player_unprepare().
+ * @post player_audio_pcm_extraction_cb() will be invoked.
+ */
+int legacy_player_set_pcm_extraction_mode(player_h player, bool sync, player_audio_pcm_extraction_cb callback, void *user_data);
+
+/**
+ * @brief Set pcm mode spec. Samplerate, channel is needed.
+ * @since_tizen 2.4
+ * @param[in] player The handle to the media player
+ * @param[in] samplerate Samplerate
+ * @param[in] channel Channel
+ * @return @c 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_NOT_SUPPORTD Not supported
+ * @pre The player state must be #PLAYER_STATE_IDLE by legacy_player_create() or legacy_player_unprepare().
+ * @see legacy_player_set_pcm_extraction_mode()
+ */
+int legacy_player_set_pcm_spec(player_h player, const char *format, int samplerate, int channel);
+
+/**
+ * @brief Sets the playback rate include streaming mode.
+ * @since_tizen 3.0
+ * @details The default value is @c 1.0.
+ * @remarks No operation is performed, if @a rate is @c 0.
+ * @remarks The sound is muted, when playback rate is under @c 0.0 and over @c 2.0.
+ * @param[in] player The handle to the media player
+ * @param[in] rate The playback rate
+ * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state
+ * @pre The player state must be set to #PLAYER_STATE_PLAYING by calling legacy_player_start().
+ * @pre The player state must be set to #PLAYER_STATE_READY by calling legacy_player_prepare() or set to #PLAYER_STATE_PLAYING by calling legacy_player_start() or set to #PLAYER_STATE_PAUSED by calling legacy_player_pause().
+ */
+int legacy_player_set_streaming_playback_rate(player_h player, float rate);
+
+/**
+ * @brief Registers a callback function to be invoked when buffer underrun or overflow is occurred.
+ * @since_tizen 3.0
+ * @remarks This API is used for media stream playback only.
+ * @param[in] player The handle to the media player
+ * @param[in] type The type of target stream
+ * @param[in] callback The buffer status callback function to register
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #PLAYER_ERROR_NONE Successful
+ * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state
+ * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre The player state must be set to #PLAYER_STATE_IDLE by calling legacy_player_create() or legacy_player_unprepare().
+ * @post player_media_stream_buffer_status_cb_ex() will be invoked.
+ * @see legacy_player_unset_media_stream_buffer_status_cb_ex()
+ * @see player_media_stream_buffer_status_cb_ex()
+ */
+int legacy_player_set_media_stream_buffer_status_cb_ex(player_h player, player_stream_type_e type, player_media_stream_buffer_status_cb_ex callback, void *user_data);
+
+/**
+ * @brief Unregisters the buffer status callback function.
+ * @since_tizen 3.0
+ * @remarks This API is used for media stream playback only.
+ * @param[in] player The handle to the media player
+ * @param[in] type The type of target stream
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #PLAYER_ERROR_NONE Successful
+ * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state
+ * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see legacy_player_set_media_stream_buffer_status_cb()
+ */
+int legacy_player_unset_media_stream_buffer_status_cb_ex(player_h player, player_stream_type_e type);
+
+/**
+ * @}
+ */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //__TIZEN_MEDIA_LEGACY_PLAYER_INTERNAL_H__
+
+
--- /dev/null
+/*
+* 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_LEGACY_PLAYER_PRIVATE_H__
+#define __TIZEN_MEDIA_LEGACY_PLAYER_PRIVATE_H__
+#include <mm_types.h>
+#include <system_info.h>
+#include "legacy_player.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "TIZEN_N_PLAYER"
+//#define USE_ECORE_FUNCTIONS
+
+#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")
+
+#define PLAYER_RANGE_ARG_CHECK(arg, min, max) \
+ PLAYER_CHECK_CONDITION(arg <= max,PLAYER_ERROR_INVALID_PARAMETER,"PLAYER_ERROR_INVALID_PARAMETER") \
+ PLAYER_CHECK_CONDITION(arg >= min,PLAYER_ERROR_INVALID_PARAMETER,"PLAYER_ERROR_INVALID_PARAMETER")
+
+#ifdef TIZEN_TTRACE
+#include <ttrace.h>
+#define PLAYER_TRACE_BEGIN(NAME) traceBegin(TTRACE_TAG_VIDEO, NAME)
+#define PLAYER_TRACE_END() traceEnd(TTRACE_TAG_VIDEO)
+#define PLAYER_TRACE_ASYNC_BEGIN(NAME, COOKIE) traceAsyncBegin (TTRACE_TAG_VIDEO, COOKIE, NAME);
+#define PLAYER_TRACE_ASYNC_END(NAME, COOKIE) traceAsyncEnd(TTRACE_TAG_VIDEO, COOKIE, NAME);
+#else
+#define PLAYER_TRACE_BEGIN(NAME)
+#define PLAYER_TRACE_END()
+#define PLAYER_TRACE_ASYNC_BEGIN(NAME, KEY)
+#define PLAYER_TRACE_ASYNC_END(NAME, KEY)
+#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_MEDIA_PACKET_VIDEO_FRAME,
+ _PLAYER_EVENT_TYPE_AUDIO_FRAME,
+ _PLAYER_EVENT_TYPE_VIDEO_FRAME_RENDER_ERROR,
+ _PLAYER_EVENT_TYPE_PD,
+ _PLAYER_EVENT_TYPE_SUPPORTED_AUDIO_EFFECT,
+ _PLAYER_EVENT_TYPE_SUPPORTED_AUDIO_EFFECT_PRESET,
+ _PLAYER_EVENT_TYPE_MISSED_PLUGIN,
+#ifdef _PLAYER_FOR_PRODUCT
+ _PLAYER_EVENT_TYPE_IMAGE_BUFFER,
+ _PLAYER_EVENT_TYPE_SELECTED_SUBTITLE_LANGUAGE,
+#endif
+ _PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS,
+ _PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS,
+ _PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO,
+ _PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO,
+ _PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK,
+ _PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK,
+ _PLAYER_EVENT_TYPE_AUDIO_STREAM_CHANGED,
+ _PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED,
+ _PLAYER_EVENT_TYPE_NUM
+}_player_event_e;
+
+#ifndef USE_ECORE_FUNCTIONS
+typedef enum {
+ PLAYER_MESSAGE_NONE,
+ PLAYER_MESSAGE_PREPARED,
+ PLAYER_MESSAGE_ERROR,
+ PLAYER_MESSAGE_SEEK_DONE,
+ PLAYER_MESSAGE_EOS,
+ PLAYER_MESSAGE_LOOP_EXIT,
+ PLAYER_MESSAGE_MAX
+}_player_message_e;
+#endif
+
+typedef struct _player_s{
+ MMHandleType mm_handle;
+ const void* user_cb[_PLAYER_EVENT_TYPE_NUM];
+ void* user_data[_PLAYER_EVENT_TYPE_NUM];
+#ifdef HAVE_WAYLAND
+ void* wl_display;
+#endif
+ 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;
+ pthread_t prepare_async_thread;
+#ifdef USE_ECORE_FUNCTIONS
+ GHashTable *ecore_jobs;
+#else
+ pthread_t message_thread;
+ GQueue *message_queue;
+ GMutex message_queue_lock;
+ GCond message_queue_cond;
+ int current_message;
+#endif
+ player_error_e error_code;
+ bool is_doing_jobs;
+ media_format_h pkt_fmt;
+} player_s;
+
+int __player_convert_error_code(int code, char* func_name);
+bool __player_state_validate(player_s * handle, player_state_e threshold);
+
+/*
+* define for lagacy API for mused
+*/
+#ifdef HAVE_WAYLAND
+int legacy_player_set_display_wl_for_mused(player_h player, player_display_type_e type, unsigned int wl_surface_id, int x, int y, int w, int h);
+int legacy_player_resize_video_render_rect(player_h player, int x, int y, int w, int h);
+#else
+int legacy_player_set_display_for_mused(player_h player, player_display_type_e type, unsigned int xhandle);
+#endif
+int legacy_player_set_audio_policy_info_for_mused(player_h player, char *stream_type, int stream_index);
+int legacy_player_sound_register(player_h player, int pid);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //__TIZEN_MEDIA_LEGACY_PLAYER_PRIVATE_H__
+
+
+
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <mm.h>
+#include <mm_player.h>
+#include <mm_player_audioeffect.h>
+#include <mm_player_internal.h>
+#include <mm_types.h>
+#include <sound_manager.h>
+#include <sound_manager_internal.h>
+#include <dlog.h>
+#include <Evas.h>
+#include <Ecore.h>
+#include <Elementary.h>
+#include <Ecore.h>
+#ifdef HAVE_WAYLAND
+#include <Ecore_Wayland.h>
+#endif
+#include <tbm_bufmgr.h>
+#include <tbm_surface_internal.h>
+#include <mm_sound.h>
+
+#include "legacy_player.h"
+#include "legacy_player_private.h"
+
+#define __JOB_KEY_PREPARED "prepared"
+#define __JOB_KEY_ERROR "error"
+#define __JOB_KEY_SEEK_DONE "seek_done"
+#define __JOB_KEY_EOS "eos"
+
+#define __RELEASEIF_PREPARE_THREAD(thread_id) \
+ do { \
+ if (thread_id) { \
+ pthread_join(thread_id, NULL); \
+ thread_id = 0; \
+ LOGI("prepare thread released\n"); \
+ } \
+ } while (0)
+
+#ifndef USE_ECORE_FUNCTIONS
+#define __RELEASEIF_MESSAGE_THREAD(thread_id) \
+ do { \
+ if (thread_id) { \
+ pthread_join(thread_id, NULL); \
+ thread_id = 0; \
+ LOGI("message thread released\n"); \
+ } \
+ } while (0)
+#endif
+
+#ifdef USE_ECORE_FUNCTIONS
+#define __DELETE_ECORE_ITEM(ecore_job) \
+ do { \
+ if (ecore_job) { \
+ ecore_job_del(ecore_job); \
+ ecore_job = NULL; \
+ } \
+ } while (0)
+
+#define __ADD_ECORE_JOB(handle, key, job_callback) \
+ do { \
+ Ecore_Job *job = NULL; \
+ job = ecore_job_add(job_callback, (void *)handle); \
+ LOGI("adding %s job - %p\n", key, job); \
+ g_hash_table_insert(handle->ecore_jobs, g_strdup(key), job); \
+ } while (0)
+
+#define __REMOVE_ECORE_JOB(handle, job_key) \
+ do { \
+ LOGI("%s done so, remove\n", job_key); \
+ g_hash_table_remove(handle->ecore_jobs, job_key); \
+ handle->is_doing_jobs = FALSE; \
+ } while (0)
+#else
+#define __GET_MESSAGE(handle) \
+ do { \
+ if (handle && handle->message_queue) { \
+ g_mutex_lock(&handle->message_queue_lock); \
+ if (g_queue_is_empty(handle->message_queue)) { \
+ g_cond_wait(&handle->message_queue_cond, &handle->message_queue_lock); \
+ } \
+ handle->current_message = (int)(intptr_t)g_queue_pop_head(handle->message_queue); \
+ g_mutex_unlock(&handle->message_queue_lock); \
+ LOGI("Retrived message [%d] from queue", handle->current_message); \
+ } else { \
+ LOGI("Failed to retrive message from queue"); \
+ handle->current_message = PLAYER_MESSAGE_NONE; \
+ } \
+ } while (0)
+
+#define __ADD_MESSAGE(handle, message) \
+ do { \
+ if (handle && handle->message_queue) { \
+ g_mutex_lock(&handle->message_queue_lock); \
+ if (message == PLAYER_MESSAGE_LOOP_EXIT) \
+ g_queue_clear(handle->message_queue); \
+ g_queue_push_tail(handle->message_queue, (gpointer)message); \
+ g_cond_signal(&handle->message_queue_cond); \
+ g_mutex_unlock(&handle->message_queue_lock); \
+ LOGI("Adding message [%d] to queue", message); \
+ } else { \
+ LOGI("Failed to add message [%d] to queue", message); \
+ } \
+ } while (0)
+#endif
+
+/*
+* Internal Implementation
+*/
+int __player_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:
+ case MM_ERROR_PLAYER_AUDIO_CODEC_NOT_FOUND:
+ case MM_ERROR_PLAYER_VIDEO_CODEC_NOT_FOUND:
+ ret = PLAYER_ERROR_NONE;
+ msg = "PLAYER_ERROR_NONE";
+ break;
+ case MM_ERROR_INVALID_ARGUMENT:
+ ret = PLAYER_ERROR_INVALID_PARAMETER;
+ msg = "PLAYER_ERROR_INVALID_PARAMETER";
+ break;
+ case MM_ERROR_PLAYER_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:
+ ret = PLAYER_ERROR_INVALID_OPERATION;
+ msg = "PLAYER_ERROR_INVALID_OPERATION";
+ break;
+ case MM_ERROR_PLAYER_SOUND_EFFECT_INVALID_STATUS:
+ case MM_ERROR_NOT_SUPPORT_API:
+ case MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER:
+ ret = PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE;
+ msg = "PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE";
+ 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;
+ case MM_ERROR_PLAYER_DRM_EXPIRED:
+ ret = PLAYER_ERROR_DRM_EXPIRED;
+ msg = "PLAYER_ERROR_DRM_EXPIRED";
+ break;
+ case MM_ERROR_PLAYER_DRM_NOT_AUTHORIZED:
+ case MM_ERROR_PLAYER_DRM_NO_LICENSE:
+ ret = PLAYER_ERROR_DRM_NO_LICENSE;
+ msg = "PLAYER_ERROR_DRM_NO_LICENSE";
+ break;
+ case MM_ERROR_PLAYER_DRM_FUTURE_USE:
+ ret = PLAYER_ERROR_DRM_FUTURE_USE;
+ msg = "PLAYER_ERROR_DRM_FUTURE_USE";
+ break;
+ case MM_ERROR_PLAYER_DRM_OUTPUT_PROTECTION:
+ ret = PLAYER_ERROR_DRM_NOT_PERMITTED;
+ msg = "PLAYER_ERROR_DRM_NOT_PERMITTED";
+ break;
+ case MM_ERROR_PLAYER_RESOURCE_LIMIT:
+ ret = PLAYER_ERROR_RESOURCE_LIMIT;
+ msg = "PLAYER_ERROR_RESOURCE_LIMIT";
+ break;
+ case MM_ERROR_PLAYER_PERMISSION_DENIED:
+ ret = PLAYER_ERROR_PERMISSION_DENIED;
+ msg = "PLAYER_ERROR_PERMISSION_DENIED";
+ break;
+ case MM_ERROR_PLAYER_BUFFER_SPACE:
+ ret = PLAYER_ERROR_BUFFER_SPACE;
+ msg = "PLAYER_ERROR_BUFFER_SPACE";
+ break;
+ default:
+ break;
+ }
+ LOGE("[%s] %s(0x%08x) : core fw error(0x%x)", func_name, msg, ret, code);
+ return ret;
+}
+
+int _player_get_tbm_surface_format(int in_format, uint32_t *out_format)
+{
+ if (in_format <= MM_PIXEL_FORMAT_INVALID || in_format >= MM_PIXEL_FORMAT_NUM || out_format == NULL) {
+ LOGE("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
+ return PLAYER_ERROR_INVALID_PARAMETER;
+ }
+
+ switch (in_format) {
+ case MM_PIXEL_FORMAT_NV12:
+ case MM_PIXEL_FORMAT_NV12T:
+ *out_format = TBM_FORMAT_NV12;
+ break;
+ case MM_PIXEL_FORMAT_NV16:
+ *out_format = TBM_FORMAT_NV16;
+ break;
+ case MM_PIXEL_FORMAT_NV21:
+ *out_format = TBM_FORMAT_NV21;
+ break;
+ case MM_PIXEL_FORMAT_YUYV:
+ *out_format = TBM_FORMAT_YUYV;
+ break;
+ case MM_PIXEL_FORMAT_UYVY:
+ case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
+ *out_format = TBM_FORMAT_UYVY;
+ break;
+ case MM_PIXEL_FORMAT_422P:
+ *out_format = TBM_FORMAT_YUV422;
+ break;
+ case MM_PIXEL_FORMAT_I420:
+ *out_format = TBM_FORMAT_YUV420;
+ break;
+ case MM_PIXEL_FORMAT_YV12:
+ *out_format = TBM_FORMAT_YVU420;
+ break;
+ case MM_PIXEL_FORMAT_RGB565:
+ *out_format = TBM_FORMAT_RGB565;
+ break;
+ case MM_PIXEL_FORMAT_RGB888:
+ *out_format = TBM_FORMAT_RGB888;
+ break;
+ case MM_PIXEL_FORMAT_RGBA:
+ *out_format = TBM_FORMAT_RGBA8888;
+ break;
+ case MM_PIXEL_FORMAT_ARGB:
+ *out_format = TBM_FORMAT_ARGB8888;
+ break;
+ default:
+ LOGE("invalid in_format %d", in_format);
+ return PLAYER_ERROR_INVALID_PARAMETER;
+ }
+
+ return PLAYER_ERROR_NONE;
+}
+
+int _player_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
+{
+ if (in_format <= MM_PIXEL_FORMAT_INVALID || in_format >= MM_PIXEL_FORMAT_NUM || mimetype == NULL) {
+ LOGE("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
+ return PLAYER_ERROR_INVALID_PARAMETER;
+ }
+
+ switch (in_format) {
+ case MM_PIXEL_FORMAT_NV12:
+ case MM_PIXEL_FORMAT_NV12T:
+ *mimetype = MEDIA_FORMAT_NV12;
+ break;
+ case MM_PIXEL_FORMAT_NV16:
+ *mimetype = MEDIA_FORMAT_NV16;
+ break;
+ case MM_PIXEL_FORMAT_NV21:
+ *mimetype = MEDIA_FORMAT_NV21;
+ break;
+ case MM_PIXEL_FORMAT_YUYV:
+ *mimetype = MEDIA_FORMAT_YUYV;
+ break;
+ case MM_PIXEL_FORMAT_UYVY:
+ case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
+ *mimetype = MEDIA_FORMAT_UYVY;
+ break;
+ case MM_PIXEL_FORMAT_422P:
+ *mimetype = MEDIA_FORMAT_422P;
+ break;
+ case MM_PIXEL_FORMAT_I420:
+ *mimetype = MEDIA_FORMAT_I420;
+ break;
+ case MM_PIXEL_FORMAT_YV12:
+ *mimetype = MEDIA_FORMAT_YV12;
+ break;
+ case MM_PIXEL_FORMAT_RGB565:
+ *mimetype = MEDIA_FORMAT_RGB565;
+ break;
+ case MM_PIXEL_FORMAT_RGB888:
+ *mimetype = MEDIA_FORMAT_RGB888;
+ break;
+ case MM_PIXEL_FORMAT_RGBA:
+ *mimetype = MEDIA_FORMAT_RGBA;
+ break;
+ case MM_PIXEL_FORMAT_ARGB:
+ *mimetype = MEDIA_FORMAT_ARGB;
+ break;
+ default:
+ LOGE("invalid in_format %d", in_format);
+ return PLAYER_ERROR_INVALID_PARAMETER;
+ }
+
+ return PLAYER_ERROR_NONE;
+}
+
+int _player_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
+{
+ int ret = 0;
+ void *internal_buffer = NULL;
+ tbm_surface_h tsurf = NULL;
+
+ if (pkt == NULL || user_data == NULL) {
+ LOGE("invalid parameter buffer %p, user_data %p", pkt, user_data);
+ return MEDIA_PACKET_FINALIZE;
+ }
+
+ ret = media_packet_get_extra(pkt, &internal_buffer);
+ if (ret != MEDIA_PACKET_ERROR_NONE) {
+ LOGE("media_packet_get_extra failed 0x%x", ret);
+ return MEDIA_PACKET_FINALIZE;
+ }
+
+ /* LOGD("pointer gst buffer %p, ret 0x%x", internal_buffer, ret); */
+ mm_player_media_packet_video_stream_internal_buffer_unref(internal_buffer);
+
+ ret = media_packet_get_tbm_surface(pkt, &tsurf);
+ if (ret != MEDIA_PACKET_ERROR_NONE) {
+ LOGE("media_packet_get_tbm_surface failed 0x%x", ret);
+ return MEDIA_PACKET_FINALIZE;
+ }
+
+ if (tsurf) {
+ tbm_surface_destroy(tsurf);
+ tsurf = NULL;
+ }
+
+ return MEDIA_PACKET_FINALIZE;
+}
+
+static bool _player_network_availability_check()
+{
+#define _FEATURE_NAME_WIFI "http://tizen.org/feature/network.wifi"
+#define _FEATURE_NAME_TELEPHONY "http://tizen.org/feature/network.telephony"
+#define _FEATURE_NAME_ETHERNET "http://tizen.org/feature/network.ethernet"
+ bool enabled = FALSE;
+ bool supported = FALSE;
+
+ if (SYSTEM_INFO_ERROR_NONE == system_info_get_platform_bool(_FEATURE_NAME_WIFI, &enabled)) {
+ LOGI("wifi status = %d", enabled);
+ if (enabled)
+ supported = TRUE;
+ } else {
+ LOGE("SYSTEM_INFO_ERROR");
+ }
+
+ if (SYSTEM_INFO_ERROR_NONE == system_info_get_platform_bool(_FEATURE_NAME_TELEPHONY, &enabled)) {
+ LOGI("telephony status = %d", enabled);
+ if (enabled)
+ supported = TRUE;
+ } else {
+ LOGE("SYSTEM_INFO_ERROR");
+ }
+
+ if (SYSTEM_INFO_ERROR_NONE == system_info_get_platform_bool(_FEATURE_NAME_ETHERNET, &enabled)) {
+ LOGI("ethernet status = %d", enabled);
+ if (enabled)
+ supported = TRUE;
+ } else {
+ LOGE("SYSTEM_INFO_ERROR");
+ }
+
+ if (!supported)
+ return FALSE;
+
+ return TRUE;
+}
+
+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_CALL_END:
+ case MM_MSG_CODE_INTERRUPTED_BY_ALARM_END:
+ case MM_MSG_CODE_INTERRUPTED_BY_EMERGENCY_END:
+ case MM_MSG_CODE_INTERRUPTED_BY_NOTIFICATION_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_NOTIFICATION_START:
+ ret = PLAYER_INTERRUPTED_BY_NOTIFICATION;
+ break;
+ case MM_MSG_CODE_INTERRUPTED_BY_EMERGENCY_START:
+ ret = PLAYER_INTERRUPTED_BY_EMERGENCY;
+ break;
+ case MM_MSG_CODE_INTERRUPTED_BY_RESOURCE_CONFLICT:
+ default:
+ ret = PLAYER_INTERRUPTED_BY_RESOURCE_CONFLICT;
+ break;
+ }
+ LOGE("[%s] interrupted code(%d) => ret(%d)", __FUNCTION__, code, ret);
+ 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;
+}
+
+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);
+ if (_PLAYER_EVENT_TYPE_BUFFERING == type) {
+ if (!_player_network_availability_check())
+ return PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE;
+ }
+
+ 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;
+}
+
+#ifdef USE_ECORE_FUNCTIONS
+static void __job_prepared_cb(void *user_data)
+{
+ player_s *handle = (player_s *)user_data;
+ LOGI("Start");
+ handle->is_doing_jobs = TRUE;
+ 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;
+ __REMOVE_ECORE_JOB(handle, __JOB_KEY_PREPARED);
+ LOGI("End");
+}
+
+static void __job_error_cb(void *user_data)
+{
+ player_s *handle = (player_s *)user_data;
+ LOGI("Start");
+ handle->is_doing_jobs = TRUE;
+ ((player_error_cb)handle->user_cb[_PLAYER_EVENT_TYPE_ERROR])(handle->error_code, handle->user_data[_PLAYER_EVENT_TYPE_ERROR]);
+ __REMOVE_ECORE_JOB(handle, __JOB_KEY_ERROR);
+ LOGI("End");
+}
+
+static void __job_seek_done_cb(void *user_data)
+{
+ player_s *handle = (player_s *)user_data;
+ LOGI("Start");
+ handle->is_doing_jobs = TRUE;
+ ((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;
+ __REMOVE_ECORE_JOB(handle, __JOB_KEY_SEEK_DONE);
+ LOGI("End");
+}
+
+static void __job_eos_cb(void *user_data)
+{
+ player_s *handle = (player_s *)user_data;
+ LOGI("Start");
+ handle->is_doing_jobs = TRUE;
+ ((player_completed_cb)handle->user_cb[_PLAYER_EVENT_TYPE_COMPLETE])(handle->user_data[_PLAYER_EVENT_TYPE_COMPLETE]);
+ __REMOVE_ECORE_JOB(handle, __JOB_KEY_EOS);
+ LOGI("End");
+}
+#else
+static void __message_cb_loop(void *data)
+{
+ bool running = TRUE;
+ player_s *handle = (player_s *)data;
+ if (!handle) {
+ LOGE("null handle in __message_cb_loop");
+ return;
+ }
+ do {
+ __GET_MESSAGE(handle);
+ switch (handle->current_message) {
+ case PLAYER_MESSAGE_NONE:
+ {
+ LOGW("PLAYER_MESSAGE_NONE");
+ running = FALSE;
+ }
+ break;
+ case PLAYER_MESSAGE_PREPARED:
+ {
+ LOGW("PLAYER_MESSAGE_PREPARED");
+ if (handle->user_cb[_PLAYER_EVENT_TYPE_PREPARE]) {
+ handle->is_doing_jobs = TRUE;
+ 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;
+ handle->is_doing_jobs = FALSE;
+ } else {
+ LOGE("null handle in PLAYER_MESSAGE_PREPARED");
+ }
+ }
+ break;
+ case PLAYER_MESSAGE_ERROR:
+ {
+ LOGW("PLAYER_MESSAGE_ERROR");
+ if (handle->user_cb[_PLAYER_EVENT_TYPE_ERROR]) {
+ handle->is_doing_jobs = TRUE;
+ ((player_error_cb)handle->user_cb[_PLAYER_EVENT_TYPE_ERROR])(handle->error_code, handle->user_data[_PLAYER_EVENT_TYPE_ERROR]);
+ handle->is_doing_jobs = FALSE;
+ } else {
+ LOGE("null handle in PLAYER_MESSAGE_ERROR");
+ }
+ }
+ break;
+ case PLAYER_MESSAGE_SEEK_DONE:
+ {
+ LOGW("PLAYER_MESSAGE_SEEK_DONE");
+ if (handle->user_cb[_PLAYER_EVENT_TYPE_SEEK]) {
+ handle->is_doing_jobs = TRUE;
+ ((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;
+ handle->is_doing_jobs = FALSE;
+ } else {
+ LOGE("null handle in PLAYER_MESSAGE_SEEK_DONE");
+ }
+ }
+ break;
+ case PLAYER_MESSAGE_EOS:
+ {
+ LOGW("PLAYER_MESSAGE_EOS");
+ if (handle->user_cb[_PLAYER_EVENT_TYPE_COMPLETE]) {
+ handle->is_doing_jobs = TRUE;
+ ((player_completed_cb)handle->user_cb[_PLAYER_EVENT_TYPE_COMPLETE])(handle->user_data[_PLAYER_EVENT_TYPE_COMPLETE]);
+ handle->is_doing_jobs = FALSE;
+ } else {
+ LOGE("null handle in PLAYER_MESSAGE_EOS");
+ }
+ }
+ break;
+ case PLAYER_MESSAGE_LOOP_EXIT:
+ {
+ LOGW("PLAYER_MESSAGE_LOOP_EXIT");
+ running = FALSE;
+ }
+ break;
+ case PLAYER_MESSAGE_MAX:
+ {
+ LOGW("PLAYER_MESSAGE_MAX");
+ running = FALSE;
+ }
+ break;
+ default:
+ break;
+ }
+ } while (running);
+ return;
+}
+#endif
+
+static int __msg_callback(int message, void *param, void *user_data)
+{
+ player_s *handle = (player_s *)user_data;
+ MMMessageParamType *msg = (MMMessageParamType *)param;
+ LOGW("[%s] Got message type : 0x%x", __FUNCTION__, message);
+ player_error_e err_code = PLAYER_ERROR_NONE;
+ switch (message) {
+ case MM_MESSAGE_ERROR: /* 0x01 */
+ err_code = __player_convert_error_code(msg->code, (char *)__FUNCTION__);
+ break;
+ case MM_MESSAGE_STATE_CHANGED: /* 0x03 */
+ LOGI("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 */
+ LOGI("[%s] Prepared! [current state : %d]", __FUNCTION__, handle->state);
+ PLAYER_TRACE_ASYNC_END("MM:PLAYER:PREPARE_ASYNC", *(int *)handle);
+#ifdef USE_ECORE_FUNCTIONS
+ __ADD_ECORE_JOB(handle, __JOB_KEY_PREPARED, __job_prepared_cb);
+#else
+ __ADD_MESSAGE(handle, PLAYER_MESSAGE_PREPARED);
+#endif
+ }
+ }
+ 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 */
+ LOGI("[%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]) {
+#ifdef USE_ECORE_FUNCTIONS
+ __ADD_ECORE_JOB(handle, __JOB_KEY_EOS, __job_eos_cb);
+#else
+ __ADD_MESSAGE(handle, PLAYER_MESSAGE_EOS);
+#endif
+ }
+ 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);
+ if (handle->state == PLAYER_STATE_READY)
+ handle->is_stopped = TRUE;
+ ((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 */
+ LOGI("[%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 */
+ LOGI("[%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;
+
+ switch (msg->captured_frame.orientation) {
+ case 0:
+ case 180:
+ {
+ /* use video resolution from above */
+ }
+ break;
+ case 90:
+ case 270:
+ {
+ /* use calculated size during rotation */
+ w = msg->captured_frame.width;
+ h = msg->captured_frame.height;
+ }
+ break;
+ default:
+ break;
+ }
+
+ LOGI("[%s] captured image width : %d height : %d", __FUNCTION__, w, h);
+
+ /* call application callback */
+ ((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 */
+ LOGI("[%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 */
+ LOGI("[%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_SEEK_COMPLETED: /* 0x114 */
+ if (handle->display_type != PLAYER_DISPLAY_TYPE_NONE && handle->state == PLAYER_STATE_READY) {
+ if (handle->is_display_visible)
+ mm_player_set_attribute(handle->mm_handle, NULL, "display_visible", 1, (char *)NULL);
+ }
+ if (handle->user_cb[_PLAYER_EVENT_TYPE_SEEK]) {
+#ifdef USE_ECORE_FUNCTIONS
+ __ADD_ECORE_JOB(handle, __JOB_KEY_SEEK_DONE, __job_seek_done_cb);
+#else
+ __ADD_MESSAGE(handle, PLAYER_MESSAGE_SEEK_DONE);
+#endif
+ }
+ 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_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]) {
+ handle->error_code = err_code;
+#ifdef USE_ECORE_FUNCTIONS
+ __ADD_ECORE_JOB(handle, __JOB_KEY_ERROR, __job_error_cb);
+#else
+ __ADD_MESSAGE(handle, PLAYER_MESSAGE_ERROR);
+#endif
+ }
+ LOGW("[%s] End", __FUNCTION__);
+ return 1;
+}
+
+static bool __video_stream_callback(void *stream, void *user_data)
+{
+ player_s *handle = (player_s *)user_data;
+ MMPlayerVideoStreamDataType *video_stream = (MMPlayerVideoStreamDataType *)stream;
+
+ if (handle->user_cb[_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME]) {
+ /* media packet and zero-copy */
+ media_packet_h pkt = NULL;
+ tbm_surface_h tsurf = NULL;
+ uint32_t bo_format = 0;
+ int i;
+ int bo_num;
+ int ret = 0;
+ media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
+ bool make_pkt_fmt = false;
+
+ /* create tbm surface */
+ for (i = 0, bo_num = 0; i < BUFFER_MAX_PLANE_NUM; i++) {
+ if (video_stream->bo[i])
+ bo_num++;
+ }
+
+ /* get tbm surface format */
+ ret = _player_get_tbm_surface_format(video_stream->format, &bo_format);
+ ret |= _player_get_media_packet_mimetype(video_stream->format, &mimetype);
+
+ if (bo_num > 0 && ret == PLAYER_ERROR_NONE) {
+ tbm_surface_info_s info;
+ memset(&info, 0, sizeof(tbm_surface_info_s));
+ info.width = video_stream->width;
+ info.height = video_stream->height;
+ info.format = bo_format;
+ info.bpp = tbm_surface_internal_get_bpp(bo_format);
+ info.num_planes = tbm_surface_internal_get_num_planes(bo_format);
+ info.size = 0;
+ for (i = 0; i < info.num_planes; i++) {
+ info.planes[i].stride = video_stream->stride[i];
+ info.planes[i].size = video_stream->stride[i] * video_stream->elevation[i];
+ if (i < bo_num)
+ info.planes[i].offset = 0;
+ else
+ info.planes[i].offset = info.planes[i - 1].offset + info.planes[i - 1].size;
+ info.size += info.planes[i].size;
+ }
+ tsurf = tbm_surface_internal_create_with_bos(&info, (tbm_bo *)video_stream->bo, bo_num);
+ /*LOGD("tbm surface %p", tsurf); */
+ } else if (bo_num == 0) {
+ int plane_idx = 0;
+ tbm_surface_info_s tsuri;
+ unsigned char *ptr = video_stream->data[0];
+ unsigned char *ptr2 = video_stream->data[1];
+
+ if (!ptr)
+ return TRUE;
+ if (!ptr2 && video_stream->format == MM_PIXEL_FORMAT_NV12T)
+ return TRUE;
+
+ tsurf = tbm_surface_create(video_stream->width, video_stream->height, bo_format);
+ if (tsurf) {
+ /* map surface to set data */
+ if (tbm_surface_map(tsurf, TBM_SURF_OPTION_READ | TBM_SURF_OPTION_WRITE, &tsuri)) {
+ LOGE("tbm_surface_map failed");
+ return TRUE;
+ }
+
+ if (video_stream->format == MM_PIXEL_FORMAT_NV12T) {
+ memcpy(tsuri.planes[0].ptr, ptr, tsuri.planes[0].size);
+ memcpy(tsuri.planes[1].ptr, ptr2, tsuri.planes[1].size);
+ } else {
+ for (plane_idx = 0; plane_idx < tsuri.num_planes; plane_idx++) {
+ memcpy(tsuri.planes[plane_idx].ptr, ptr, tsuri.planes[plane_idx].size);
+ ptr += tsuri.planes[plane_idx].size;
+ }
+ }
+ } else {
+ LOGW("tbm_surface_create failed");
+ }
+ }
+
+ if (tsurf) {
+ /* check media packet format */
+ if (handle->pkt_fmt) {
+ int pkt_fmt_width = 0;
+ int pkt_fmt_height = 0;
+ media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
+
+ media_format_get_video_info(handle->pkt_fmt, &pkt_fmt_mimetype,
+ &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
+ if (pkt_fmt_mimetype != mimetype ||
+ pkt_fmt_width != video_stream->width ||
+ pkt_fmt_height != video_stream->height) {
+ LOGW("different format. current 0x%x, %dx%d, new 0x%x, %dx%d",
+ pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height, mimetype,
+ video_stream->width, video_stream->height);
+ media_format_unref(handle->pkt_fmt);
+ handle->pkt_fmt = NULL;
+ make_pkt_fmt = true;
+ }
+ } else {
+ make_pkt_fmt = true;
+ }
+
+ /* create packet format */
+ if (make_pkt_fmt) {
+ LOGW("make new pkt_fmt - mimetype 0x%x, %dx%d", mimetype, video_stream->width, video_stream->height);
+ ret = media_format_create(&handle->pkt_fmt);
+ if (ret == MEDIA_FORMAT_ERROR_NONE) {
+ ret = media_format_set_video_mime(handle->pkt_fmt, mimetype);
+ ret |= media_format_set_video_width(handle->pkt_fmt, video_stream->width);
+ ret |= media_format_set_video_height(handle->pkt_fmt, video_stream->height);
+ LOGW("media_format_set_video_mime,width,height ret : 0x%x", ret);
+ } else {
+ LOGW("media_format_create failed");
+ }
+ }
+
+ /* create media packet */
+ ret = media_packet_create_from_tbm_surface(handle->pkt_fmt, tsurf, (media_packet_finalize_cb)_player_media_packet_finalize, (void *)handle, &pkt);
+ if (ret != MEDIA_PACKET_ERROR_NONE) {
+ LOGE("media_packet_create_from_tbm_surface failed");
+
+ tbm_surface_destroy(tsurf);
+ tsurf = NULL;
+ }
+ } else {
+ LOGE("failed to create tbm surface %dx%d, format %d, bo_num %d",
+ video_stream->width, video_stream->height, video_stream->format, bo_num);
+ }
+
+ if (pkt) {
+ /* LOGD("media packet %p, internal buffer %p", pkt, stream->internal_buffer); */
+ if (video_stream->timestamp) {
+ ret = media_packet_set_pts(pkt, (uint64_t)video_stream->timestamp * 1000000);
+ if (ret != MEDIA_PACKET_ERROR_NONE) {
+ LOGE("media_packet_set_pts failed");
+
+ media_packet_destroy(pkt);
+ pkt = NULL;
+ }
+ } else {
+ LOGD("media packet %p, didn't have video-stream timestamp", pkt);
+ }
+
+ /* set internal buffer */
+ if (video_stream->internal_buffer)
+ ret = media_packet_set_extra(pkt, video_stream->internal_buffer);
+
+ if (ret != MEDIA_PACKET_ERROR_NONE) {
+ LOGE("media_packet_set_extra failed");
+
+ media_packet_destroy(pkt);
+ pkt = NULL;
+ } else {
+ mm_player_media_packet_video_stream_internal_buffer_ref(video_stream->internal_buffer);
+
+ /* call media packet callback */
+ ((player_media_packet_video_decoded_cb)handle->user_cb[_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME])(pkt, handle->user_data[_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME]);
+
+ if (bo_num == 0)
+ tbm_surface_unmap(tsurf);
+ }
+ }
+ }
+ 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;
+}
+
+#ifdef USE_ECORE_FUNCTIONS
+static void __job_key_to_remove(gpointer key)
+{
+ LOGI("%s", key);
+ g_free(key);
+}
+
+static void __job_value_to_destroy(gpointer value)
+{
+ Ecore_Job *job = (Ecore_Job *) value;
+ LOGI("%p", job);
+ __DELETE_ECORE_ITEM(job);
+}
+#endif
+
+static MMDisplaySurfaceType __player_convet_display_type(player_display_type_e type)
+{
+ switch (type) {
+ case PLAYER_DISPLAY_TYPE_OVERLAY:
+ return MM_DISPLAY_SURFACE_OVERLAY;
+#ifdef TIZEN_MOBILE
+ case PLAYER_DISPLAY_TYPE_EVAS:
+ return MM_DISPLAY_SURFACE_EVAS;
+#endif
+ case PLAYER_DISPLAY_TYPE_NONE:
+ return MM_DISPLAY_SURFACE_NULL;
+ default:
+ return MM_DISPLAY_SURFACE_NULL;
+ }
+}
+
+/*
+* Public Implementation
+*/
+
+int legacy_player_create(player_h *player)
+{
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_TRACE_BEGIN("MM:PLAYER:CREATE");
+ 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);
+ 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 = PLAYER_DISPLAY_TYPE_NONE;
+ handle->is_stopped = false;
+ handle->is_display_visible = true;
+#ifdef USE_ECORE_FUNCTIONS
+ handle->ecore_jobs = g_hash_table_new_full(g_str_hash, g_str_equal, __job_key_to_remove, __job_value_to_destroy);
+#else
+ handle->message_queue = g_queue_new();
+ g_mutex_init(&handle->message_queue_lock);
+ g_cond_init(&handle->message_queue_cond);
+ ret = pthread_create(&handle->message_thread, NULL, (void *)__message_cb_loop, (void *)handle);
+ if (ret != 0) {
+ LOGE("[%s] failed to create message thread ret = %d", __FUNCTION__, ret);
+ return PLAYER_ERROR_OUT_OF_MEMORY;
+ }
+#endif
+ LOGI("[%s] new handle : %p", __FUNCTION__, *player);
+ PLAYER_TRACE_END();
+ return PLAYER_ERROR_NONE;
+ }
+}
+
+int legacy_player_destroy(player_h player)
+{
+ LOGI("[%s] Start, handle to destroy : %p", __FUNCTION__, player);
+ PLAYER_TRACE_BEGIN("MM:PLAYER:DESTROY");
+ PLAYER_INSTANCE_CHECK(player);
+ player_s *handle = (player_s *)player;
+ if (handle->is_doing_jobs) {
+ LOGE("jobs not completed. can't do destroy");
+ return PLAYER_ERROR_INVALID_OPERATION;
+ }
+#ifdef USE_ECORE_FUNCTIONS
+ g_hash_table_remove_all(handle->ecore_jobs);
+ g_hash_table_unref(handle->ecore_jobs);
+ handle->ecore_jobs = NULL;
+#else
+ __ADD_MESSAGE(handle, PLAYER_MESSAGE_LOOP_EXIT);
+#endif
+ __RELEASEIF_PREPARE_THREAD(handle->prepare_async_thread);
+
+#ifndef USE_ECORE_FUNCTIONS
+ __RELEASEIF_MESSAGE_THREAD(handle->message_thread);
+#endif
+
+ int ret = mm_player_destroy(handle->mm_handle);
+
+ if (handle->pkt_fmt) {
+ media_format_unref(handle->pkt_fmt);
+ handle->pkt_fmt = NULL;
+ }
+
+ LOGI("[%s] Done mm_player_destroy", __FUNCTION__);
+
+ if (ret != 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;
+#ifndef USE_ECORE_FUNCTIONS
+ if (handle->message_queue) {
+ g_queue_free(handle->message_queue);
+ handle->message_queue = NULL;
+ }
+
+ g_cond_broadcast(&handle->message_queue_cond);
+ g_mutex_clear(&handle->message_queue_lock);
+ g_cond_clear(&handle->message_queue_cond);
+#endif
+ free(handle);
+ handle = NULL;
+ LOGI("[%s] End", __FUNCTION__);
+ PLAYER_TRACE_END();
+ return PLAYER_ERROR_NONE;
+ }
+}
+
+static void *__prepare_async_thread_func(void *data)
+{
+ player_s *handle = data;
+ int ret = MM_ERROR_NONE;
+ LOGI("[%s]", __FUNCTION__);
+
+ ret = mm_player_pause(handle->mm_handle);
+ if (ret != MM_ERROR_NONE) {
+ LOGE("[%s] Failed to pause - core fw error(0x%x)", __FUNCTION__, ret);
+ /*MM_MESSAGE_ERROR will not be posted as legacy_player_prepare(sync API) works with return value
+ of mm_player_pause So in case of async API we post the error message to application from here */
+ MMMessageParamType msg_param;
+ msg_param.code = ret;
+ __msg_callback(MM_MESSAGE_ERROR, (void *)&msg_param, (void *)handle);
+
+ ret = mm_player_unrealize(handle->mm_handle);
+ if (ret != MM_ERROR_NONE)
+ LOGE("[%s] Failed to unrealize - 0x%x", __FUNCTION__, ret);
+ }
+ LOGI("[%s], done", __FUNCTION__);
+ return NULL;
+}
+
+int legacy_player_prepare_async(player_h player, player_prepared_cb callback, void *user_data)
+{
+ LOGI("[%s] Start", __FUNCTION__);
+ PLAYER_INSTANCE_CHECK(player);
+ player_s *handle = (player_s *)player;
+ PLAYER_TRACE_ASYNC_BEGIN("MM:PLAYER:PREPARE_ASYNC", *(int *)handle);
+ PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
+
+ int ret;
+ int visible;
+ int value;
+
+ 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;
+ }
+
+ 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 == PLAYER_DISPLAY_TYPE_NONE) {
+ 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_get_attribute(handle->mm_handle, NULL, "display_visible", &visible, (char *)NULL);
+ if (ret != MM_ERROR_NONE)
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+
+ if (!visible)
+ value = FALSE;
+ else
+ value = TRUE;
+
+ ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_visible", value, (char *)NULL);
+ if (ret != MM_ERROR_NONE)
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+ }
+
+ ret = mm_player_realize(handle->mm_handle);
+ if (ret != MM_ERROR_NONE) {
+ LOGE("[%s] Failed to realize - 0x%x", __FUNCTION__, ret);
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+ }
+
+ if (!handle->is_progressive_download) {
+ ret = pthread_create(&handle->prepare_async_thread, NULL, (void *)__prepare_async_thread_func, (void *)handle);
+
+ if (ret != 0) {
+ LOGE("[%s] failed to create thread ret = %d", __FUNCTION__, ret);
+ return PLAYER_ERROR_OUT_OF_MEMORY;
+ }
+ }
+
+ LOGI("[%s] End", __FUNCTION__);
+ return PLAYER_ERROR_NONE;
+}
+
+int legacy_player_prepare(player_h player)
+{
+ LOGI("[%s] Start", __FUNCTION__);
+ PLAYER_TRACE_BEGIN("MM:PLAYER:PREPARE");
+ PLAYER_INSTANCE_CHECK(player);
+ player_s *handle = (player_s *)player;
+ PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
+
+ int ret;
+ int visible;
+ int value;
+ 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 == PLAYER_DISPLAY_TYPE_NONE) {
+ 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_get_attribute(handle->mm_handle, NULL, "display_visible", &visible, (char *)NULL);
+ if (ret != MM_ERROR_NONE)
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+
+ if (!visible)
+ value = FALSE;
+ else
+ value = TRUE;
+
+ mm_player_set_attribute(handle->mm_handle, NULL, "display_visible", value, (char *)NULL);
+
+ if (ret != MM_ERROR_NONE)
+ LOGW("[%s] Failed to set display display_visible '0' (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 __player_convert_error_code(ret, (char *)__FUNCTION__);
+ }
+
+ if (!handle->is_progressive_download)
+ ret = mm_player_pause(handle->mm_handle);
+
+ if (ret != MM_ERROR_NONE) {
+ int uret;
+ uret = mm_player_unrealize(handle->mm_handle);
+ if (uret != MM_ERROR_NONE)
+ LOGE("[%s] Failed to unrealize - 0x%x", __FUNCTION__, uret);
+
+ LOGE("[%s] Failed to pause - 0x%x", __FUNCTION__, ret);
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+ } else {
+ handle->state = PLAYER_STATE_READY;
+ LOGI("[%s] End", __FUNCTION__);
+ PLAYER_TRACE_END();
+ return PLAYER_ERROR_NONE;
+ }
+}
+
+int legacy_player_unprepare(player_h player)
+{
+ LOGI("[%s] Start", __FUNCTION__);
+ PLAYER_TRACE_BEGIN("MM:PLAYER:UNPREPARE");
+ 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;
+ }
+
+ __RELEASEIF_PREPARE_THREAD(handle->prepare_async_thread);
+
+ int ret = mm_player_unrealize(handle->mm_handle);
+
+ if (ret != MM_ERROR_NONE) {
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+ } else {
+ if (handle->user_cb[_PLAYER_EVENT_TYPE_SEEK]) {
+ handle->user_cb[_PLAYER_EVENT_TYPE_SEEK] = NULL;
+ handle->user_data[_PLAYER_EVENT_TYPE_SEEK] = NULL;
+ }
+
+ if (handle->user_cb[_PLAYER_EVENT_TYPE_PREPARE]) {
+ handle->user_cb[_PLAYER_EVENT_TYPE_PREPARE] = NULL;
+ handle->user_data[_PLAYER_EVENT_TYPE_PREPARE] = NULL;
+ }
+
+ handle->state = PLAYER_STATE_IDLE;
+ handle->display_type = PLAYER_DISPLAY_TYPE_NONE;
+ handle->is_set_pixmap_cb = false;
+ handle->is_stopped = false;
+ handle->is_display_visible = true;
+ handle->is_progressive_download = false;
+ LOGI("[%s] End", __FUNCTION__);
+ PLAYER_TRACE_END();
+ return PLAYER_ERROR_NONE;
+ }
+}
+
+int legacy_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 ret = mm_player_set_uri(handle->mm_handle, uri);
+
+ if (ret != MM_ERROR_NONE)
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+ else
+ return PLAYER_ERROR_NONE;
+}
+
+int legacy_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 __player_convert_error_code(ret, (char *)__FUNCTION__);
+ else
+ return PLAYER_ERROR_NONE;
+}
+
+int legacy_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);
+ /* LOGI("[%s] State : %d (FW state : %d)", __FUNCTION__,handle->state, currentStat); */
+ return PLAYER_ERROR_NONE;
+}
+
+int legacy_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 __player_convert_error_code(ret, (char *)__FUNCTION__);
+ else
+ return PLAYER_ERROR_NONE;
+}
+
+int legacy_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 __player_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 legacy_player_set_sound_type(player_h player, sound_type_e type)
+{
+ PLAYER_INSTANCE_CHECK(player);
+ player_s *handle = (player_s *)player;
+
+ PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
+
+ int sig_value = 0;
+ char *stream_type = NULL;
+ int stream_index = -1;
+
+ /* check if focus is released */
+ mm_sound_get_signal_value(MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS, &sig_value);
+ if(sig_value)
+ return PLAYER_ERROR_SOUND_POLICY;
+
+ /* convert volume_type to stream_type */
+ switch(type) {
+ case SOUND_TYPE_SYSTEM:
+ stream_type = "system";
+ break;
+ case SOUND_TYPE_NOTIFICATION:
+ stream_type = "notification";
+ break;
+ case SOUND_TYPE_ALARM:
+ stream_type = "alarm";
+ break;
+ case SOUND_TYPE_RINGTONE:
+ stream_type = "ringtone-voip";
+ break;
+ case SOUND_TYPE_MEDIA:
+ case SOUND_TYPE_CALL:
+ stream_type = "media";
+ break;
+ case SOUND_TYPE_VOIP:
+ stream_type = "voip";
+ break;
+ case SOUND_TYPE_VOICE:
+ stream_type = "voice-information";
+ break;
+ default:
+ LOGW("check the value[%d].\n", type);
+ return PLAYER_ERROR_INVALID_PARAMETER;
+ }
+ LOGI("[%s] sound type = %s", __FUNCTION__, stream_type);
+
+ int ret = mm_player_set_attribute(handle->mm_handle, NULL, "sound_stream_type", stream_type, strlen(stream_type), "sound_stream_index", stream_index, (char *)NULL);
+ if (ret != MM_ERROR_NONE)
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+ else
+ return PLAYER_ERROR_NONE;
+}
+
+int legacy_player_set_audio_policy_info(player_h player, sound_stream_info_h stream_info)
+{
+ PLAYER_INSTANCE_CHECK(player);
+ player_s *handle = (player_s *)player;
+ PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
+
+ bool is_available = false;
+
+ /* check if stream_info is valid */
+ int ret = sound_manager_is_available_stream_information(stream_info, NATIVE_API_PLAYER, &is_available);
+
+ if (ret != MM_ERROR_NONE) {
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+ } else {
+ if (is_available == false)
+ ret = MM_ERROR_NOT_SUPPORT_API;
+ else {
+ char *stream_type = NULL;
+ int stream_index = 0;
+ ret = sound_manager_get_type_from_stream_information(stream_info, &stream_type);
+ ret = sound_manager_get_index_from_stream_information(stream_info, &stream_index);
+ if (ret == SOUND_MANAGER_ERROR_NONE)
+ ret = mm_player_set_attribute(handle->mm_handle, NULL, "sound_stream_type", stream_type, strlen(stream_type), "sound_stream_index", stream_index, (char *)NULL);
+ else
+ ret = MM_ERROR_PLAYER_INTERNAL;
+ }
+ }
+
+ if (ret != MM_ERROR_NONE)
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+ else
+ return PLAYER_ERROR_NONE;
+}
+
+int legacy_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, "sound_latency_mode", latency_mode, (char *)NULL);
+ if (ret != MM_ERROR_NONE)
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+ else
+ return PLAYER_ERROR_NONE;
+}
+
+int legacy_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, "sound_latency_mode", latency_mode, (char *)NULL);
+ if (ret != MM_ERROR_NONE)
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+ else
+ return PLAYER_ERROR_NONE;
+}
+
+int legacy_player_start(player_h player)
+{
+ LOGI("[%s] Start", __FUNCTION__);
+ PLAYER_INSTANCE_CHECK(player);
+ 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_OVERLAY
+#ifdef TIZEN_MOBILE
+ || handle->display_type == PLAYER_DISPLAY_TYPE_EVAS
+#endif
+ ) {
+ if (handle->is_display_visible)
+ ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_visible", 1, (char *)NULL);
+ }
+
+ 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);
+ LOGI("[%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 __player_convert_error_code(ret, (char *)__FUNCTION__);
+ } else {
+ handle->is_stopped = FALSE;
+ handle->state = PLAYER_STATE_PLAYING;
+ LOGI("[%s] End", __FUNCTION__);
+ return PLAYER_ERROR_NONE;
+ }
+}
+
+int legacy_player_stop(player_h player)
+{
+ LOGI("[%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 (handle->display_type == PLAYER_DISPLAY_TYPE_OVERLAY
+#ifdef TIZEN_MOBILE
+ || handle->display_type == PLAYER_DISPLAY_TYPE_EVAS
+#endif
+ ) {
+ ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_visible", 0, (char *)NULL);
+ }
+
+ if (ret != MM_ERROR_NONE) {
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+ } else {
+ if (handle->user_cb[_PLAYER_EVENT_TYPE_SEEK]) {
+ handle->user_cb[_PLAYER_EVENT_TYPE_SEEK] = NULL;
+ handle->user_data[_PLAYER_EVENT_TYPE_SEEK] = NULL;
+ }
+
+ handle->state = PLAYER_STATE_READY;
+ handle->is_stopped = TRUE;
+ LOGI("[%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 legacy_player_pause(player_h player)
+{
+ LOGI("[%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 __player_convert_error_code(ret, (char *)__FUNCTION__);
+ } else {
+ handle->state = PLAYER_STATE_PAUSED;
+ LOGI("[%s] End", __FUNCTION__);
+ return PLAYER_ERROR_NONE;
+ }
+}
+
+int legacy_player_set_play_position(player_h player, int millisecond, bool accurate, 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 (!__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;
+ }
+
+ 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, pos : %d ", __FUNCTION__, _PLAYER_EVENT_TYPE_SEEK, millisecond);
+ handle->user_cb[_PLAYER_EVENT_TYPE_SEEK] = callback;
+ handle->user_data[_PLAYER_EVENT_TYPE_SEEK] = user_data;
+ }
+ int accurated = accurate ? 1 : 0;
+ int ret = mm_player_set_attribute(handle->mm_handle, NULL, "accurate_seek", accurated, (char *)NULL);
+ if (ret != MM_ERROR_NONE)
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+
+ ret = mm_player_set_position(handle->mm_handle, MM_PLAYER_POS_FORMAT_TIME, millisecond);
+ if (ret != MM_ERROR_NONE) {
+ handle->user_cb[_PLAYER_EVENT_TYPE_SEEK] = NULL;
+ handle->user_data[_PLAYER_EVENT_TYPE_SEEK] = NULL;
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+ } else {
+ return PLAYER_ERROR_NONE;
+ }
+}
+
+int legacy_player_get_play_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;
+ }
+ unsigned long pos;
+ int ret = mm_player_get_position(handle->mm_handle, MM_PLAYER_POS_FORMAT_TIME, &pos);
+ if (ret != MM_ERROR_NONE) {
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+ } else {
+ *millisecond = (int)pos;
+ return PLAYER_ERROR_NONE;
+ }
+}
+
+int legacy_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 __player_convert_error_code(ret, (char *)__FUNCTION__);
+ else
+ return PLAYER_ERROR_NONE;
+}
+
+int legacy_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 __player_convert_error_code(ret, (char *)__FUNCTION__);
+ } else {
+ if (_mute)
+ *muted = TRUE;
+ else
+ *muted = FALSE;
+ return PLAYER_ERROR_NONE;
+ }
+}
+
+int legacy_player_set_looping(player_h player, bool looping)
+{
+ PLAYER_INSTANCE_CHECK(player);
+ player_s *handle = (player_s *)player;
+
+ 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 __player_convert_error_code(ret, (char *)__FUNCTION__);
+ else
+ return PLAYER_ERROR_NONE;
+}
+
+int legacy_player_is_looping(player_h player, bool *looping)
+{
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(looping);
+ player_s *handle = (player_s *)player;
+ 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 __player_convert_error_code(ret, (char *)__FUNCTION__);
+ } else {
+ if (count == -1)
+ *looping = TRUE;
+ else
+ *looping = FALSE;
+
+ return PLAYER_ERROR_NONE;
+ }
+}
+
+int legacy_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_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 _duration;
+ int ret = mm_player_get_attribute(handle->mm_handle, NULL, MM_PLAYER_CONTENT_DURATION, &_duration, (char *)NULL);
+ if (ret != MM_ERROR_NONE) {
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+ } else {
+ *duration = _duration;
+ /* LOGI("[%s] duration : %d",__FUNCTION__,_duration); */
+ return PLAYER_ERROR_NONE;
+ }
+}
+
+int legacy_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;
+ Evas_Object *obj = NULL;
+ const char *object_type = NULL;
+ void *set_handle = NULL;
+#ifdef HAVE_WAYLAND
+ void *set_wl_display = NULL;
+ Ecore_Wl_Window *wl_window = NULL;
+ int wl_window_x = 0;
+ int wl_window_y = 0;
+ int wl_window_width = 0;
+ int wl_window_height = 0;
+#endif
+ int ret;
+
+ if (type != PLAYER_DISPLAY_TYPE_NONE && display == NULL) {
+ LOGE("display type[%d] is not NONE, but display handle is NULL", type);
+ return PLAYER_ERROR_INVALID_PARAMETER;
+ }
+
+ 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 legacy_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 = NULL;
+ if (type == PLAYER_DISPLAY_TYPE_NONE) {
+ /* NULL surface */
+ handle->display_handle = 0;
+ handle->display_type = PLAYER_DISPLAY_TYPE_NONE;
+ set_handle = NULL;
+ } else {
+ /* get handle from overlay or evas surface */
+ obj = (Evas_Object *) display;
+ object_type = evas_object_type_get(obj);
+ if (object_type) {
+ temp = handle->display_handle;
+ if (type == PLAYER_DISPLAY_TYPE_OVERLAY && !strcmp(object_type, "elm_win")) {
+#ifdef HAVE_WAYLAND
+ /* wayland overlay surface */
+ LOGI("Wayland overlay surface type");
+
+ evas_object_geometry_get(obj, &wl_window_x, &wl_window_y, &wl_window_width, &wl_window_height);
+ LOGI("get window rectangle: x(%d) y(%d) width(%d) height(%d)", wl_window_x, wl_window_y, wl_window_width, wl_window_height);
+
+ wl_window = elm_win_wl_window_get(obj);
+
+ /* get wl_surface */
+ handle->display_handle = (void *)ecore_wl_window_surface_get(wl_window);
+ set_handle = handle->display_handle;
+
+ /* get wl_display */
+ handle->wl_display = (void *)ecore_wl_display_get();
+ set_wl_display = handle->wl_display;
+#else
+ /* HAVE_X11 */
+ /* x window overlay surface */
+ LOGI("X overlay surface type");
+ handle->display_handle = (void *)(uintptr_t)elm_win_xwindow_get(obj);
+ set_handle = &(handle->display_handle);
+#endif
+ }
+#ifdef TIZEN_MOBILE
+ else if (type == PLAYER_DISPLAY_TYPE_EVAS && !strcmp(object_type, "image")) {
+ /* evas object surface */
+ LOGI("evas surface type");
+ handle->display_handle = display;
+ set_handle = display;
+ }
+#endif
+ else {
+ LOGE("invalid surface type");
+ return PLAYER_ERROR_INVALID_PARAMETER;
+ }
+ } else {
+ LOGE("falied to get evas object type from %p", obj);
+ return PLAYER_ERROR_INVALID_PARAMETER;
+ }
+ }
+
+ /* set display handle */
+ if (handle->display_type == PLAYER_DISPLAY_TYPE_NONE || type == handle->display_type) {
+ /* first time or same type */
+ ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_surface_type", __player_convet_display_type(type),
+#ifdef HAVE_WAYLAND
+ "wl_display", set_wl_display, sizeof(void *),
+#endif
+ "display_overlay", set_handle, sizeof(player_display_h), (char *)NULL);
+
+ if (ret != MM_ERROR_NONE) {
+ handle->display_handle = temp;
+ LOGE("[%s] Failed to display surface change :%d", __FUNCTION__, ret);
+ } else {
+ if (type != PLAYER_DISPLAY_TYPE_NONE) {
+ handle->display_type = type;
+ LOGI("[%s] video display has been changed- type :%d, addr : 0x%x", __FUNCTION__, handle->display_type, handle->display_handle);
+ } else
+ LOGI("NULL surface");
+ }
+#ifdef HAVE_WAYLAND
+ ret = mm_player_set_attribute(handle->mm_handle, NULL, "wl_window_render_x", wl_window_x, "wl_window_render_y", wl_window_y, "wl_window_render_width", wl_window_width, "wl_window_render_height", wl_window_height, (char *)NULL);
+
+ if (ret != MM_ERROR_NONE) {
+ handle->display_handle = temp;
+ LOGE("[%s] Failed to set wl_window render rectangle :%d", __FUNCTION__, ret);
+ }
+#endif
+ } else {
+ /* changing surface case */
+ if (handle->state >= PLAYER_STATE_READY) {
+ LOGE("[%s] it is not available to change display surface from %d to %d", __FUNCTION__, handle->display_type, type);
+ return PLAYER_ERROR_INVALID_OPERATION;
+ }
+ ret = mm_player_change_videosink(handle->mm_handle, __player_convet_display_type(type), set_handle);
+ 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;
+ LOGI("[%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 = PLAYER_DISPLAY_TYPE_NONE;
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+ } else {
+ return PLAYER_ERROR_NONE;
+ }
+}
+
+int legacy_player_set_display_mode(player_h player, player_display_mode_e mode)
+{
+ PLAYER_INSTANCE_CHECK(player);
+ player_s *handle = (player_s *)player;
+ LOGI("[%s] mode:%d", __FUNCTION__, mode);
+
+ int ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_method", mode, (char *)NULL);
+ if (ret != MM_ERROR_NONE)
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+ else
+ return PLAYER_ERROR_NONE;
+}
+
+int legacy_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 __player_convert_error_code(ret, (char *)__FUNCTION__);
+ else
+ return PLAYER_ERROR_NONE;
+}
+
+int legacy_player_set_playback_rate(player_h player, float rate)
+{
+ LOGI("[%s] rate : %0.1f", __FUNCTION__, 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;
+
+ 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_set_play_speed(handle->mm_handle, rate, FALSE);
+
+ 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 __player_convert_error_code(ret, (char *)__FUNCTION__);
+ }
+ return ret;
+}
+
+int legacy_player_set_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 __player_convert_error_code(ret, (char *)__FUNCTION__);
+ else
+ return PLAYER_ERROR_NONE;
+}
+
+int legacy_player_get_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 __player_convert_error_code(ret, (char *)__FUNCTION__);
+ else
+ return PLAYER_ERROR_NONE;
+}
+
+int legacy_player_set_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 __player_convert_error_code(ret, (char *)__FUNCTION__);
+ } else {
+ handle->is_display_visible = visible;
+ return PLAYER_ERROR_NONE;
+ }
+}
+
+int legacy_player_is_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 __player_convert_error_code(ret, (char *)__FUNCTION__);
+ } else {
+ if (count == 0)
+ *visible = FALSE;
+ else
+ *visible = TRUE;
+
+ return PLAYER_ERROR_NONE;
+ }
+}
+
+int legacy_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 __player_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 legacy_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 __player_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 legacy_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 __player_convert_error_code(ret, (char *)__FUNCTION__);
+
+ return PLAYER_ERROR_NONE;
+}
+
+int legacy_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 __player_convert_error_code(ret, (char *)__FUNCTION__);
+
+ return PLAYER_ERROR_NONE;
+}
+
+int legacy_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 __player_convert_error_code(ret, (char *)__FUNCTION__);
+ } else {
+ *width = w;
+ *height = h;
+ LOGI("[%s] width : %d, height : %d", __FUNCTION__, w, h);
+ return PLAYER_ERROR_NONE;
+ }
+}
+
+int legacy_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 __player_convert_error_code(ret, (char *)__FUNCTION__);
+
+ return PLAYER_ERROR_NONE;
+}
+
+int legacy_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 __player_convert_error_code(ret, (char *)__FUNCTION__);
+ else
+ return PLAYER_ERROR_NONE;
+}
+
+int legacy_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 __player_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 : __player_convert_error_code(ret, (char *)__FUNCTION__);
+ }
+}
+
+int legacy_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 __player_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 : __player_convert_error_code(ret, (char *)__FUNCTION__);
+ }
+}
+
+int legacy_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 __player_convert_error_code(ret, (char *)__FUNCTION__);
+ else
+ return PLAYER_ERROR_NONE;
+}
+
+int legacy_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 __player_convert_error_code(ret, (char *)__FUNCTION__);
+ else
+ return PLAYER_ERROR_NONE;
+}
+
+int legacy_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 __player_convert_error_code(ret, (char *)__FUNCTION__);
+ else
+ return PLAYER_ERROR_NONE;
+}
+
+int legacy_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 __player_convert_error_code(ret, (char *)__FUNCTION__);
+ else
+ return PLAYER_ERROR_NONE;
+}
+
+int legacy_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 __player_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 : __player_convert_error_code(ret, (char *)__FUNCTION__);
+ }
+}
+
+int legacy_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 legacy_player_set_subtitle_path(player_h player, const char *path)
+{
+ PLAYER_INSTANCE_CHECK(player);
+ player_s *handle = (player_s *)player;
+
+ if ((path == NULL) && (handle->state != PLAYER_STATE_IDLE))
+ return PLAYER_ERROR_INVALID_PARAMETER;
+
+ int ret = mm_player_set_external_subtitle_path(handle->mm_handle, path);
+ if (ret != MM_ERROR_NONE)
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+ else
+ return PLAYER_ERROR_NONE;
+}
+
+int legacy_player_set_subtitle_position_offset(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 __player_convert_error_code(ret, (char *)__FUNCTION__);
+ else
+ return PLAYER_ERROR_NONE;
+}
+
+int legacy_player_set_progressive_download_path(player_h player, const char *path)
+{
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(path);
+ if (!_player_network_availability_check())
+ return PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE;
+
+ 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 __player_convert_error_code(ret, (char *)__FUNCTION__);
+ } else {
+ handle->is_progressive_download = 1;
+ return PLAYER_ERROR_NONE;
+ }
+}
+
+int legacy_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 __player_convert_error_code(ret, (char *)__FUNCTION__);
+ } else {
+ *current = _current;
+ *total_size = _total;
+ return PLAYER_ERROR_NONE;
+ }
+}
+
+int legacy_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_READY) {
+ 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 __player_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 legacy_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 __player_convert_error_code(ret, (char *)__FUNCTION__);
+ else
+ return PLAYER_ERROR_NONE;
+}
+
+int legacy_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 __player_convert_error_code(ret, (char *)__FUNCTION__);
+ else
+ return PLAYER_ERROR_NONE;
+}
+
+int legacy_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;
+ }
+ unsigned long _current = 0;
+ unsigned long _start = 0;
+ int ret = mm_player_get_buffer_position(handle->mm_handle, MM_PLAYER_POS_FORMAT_PERCENT, &_start, &_current);
+ if (ret != MM_ERROR_NONE) {
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+ } else {
+ *start = (int)_start;
+ *current = (int)_current;
+ return PLAYER_ERROR_NONE;
+ }
+}
+
+int legacy_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 legacy_player_unset_completed_cb(player_h player)
+{
+ return __unset_callback(_PLAYER_EVENT_TYPE_COMPLETE, player);
+}
+
+int legacy_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 legacy_player_unset_interrupted_cb(player_h player)
+{
+ return __unset_callback(_PLAYER_EVENT_TYPE_INTERRUPT, player);
+}
+
+int legacy_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 legacy_player_unset_error_cb(player_h player)
+{
+ return __unset_callback(_PLAYER_EVENT_TYPE_ERROR, player);
+}
+
+int legacy_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 legacy_player_unset_buffering_cb(player_h player)
+{
+ return __unset_callback(_PLAYER_EVENT_TYPE_BUFFERING, player);
+}
+
+int legacy_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 legacy_player_unset_subtitle_updated_cb(player_h player)
+{
+ return __unset_callback(_PLAYER_EVENT_TYPE_SUBTITLE, player);
+}
+
+int legacy_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);
+ if (!_player_network_availability_check())
+ return PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE;
+
+ 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 __player_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 legacy_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 __player_convert_error_code(ret, (char *)__FUNCTION__);
+ else
+ return PLAYER_ERROR_NONE;
+}
+
+int legacy_player_set_media_packet_video_frame_decoded_cb(player_h player, player_media_packet_video_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;
+ }
+
+ mm_player_enable_media_packet_video_stream(handle->mm_handle, TRUE);
+
+ int ret = mm_player_set_video_stream_callback(handle->mm_handle, __video_stream_callback, (void *)handle);
+ if (ret != MM_ERROR_NONE)
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+
+ handle->user_cb[_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME] = callback;
+ handle->user_data[_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME] = user_data;
+ LOGI("Event type : %d ", _PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME);
+
+ return PLAYER_ERROR_NONE;
+}
+
+int legacy_player_unset_media_packet_video_frame_decoded_cb(player_h player)
+{
+ PLAYER_INSTANCE_CHECK(player);
+ player_s *handle = (player_s *)player;
+ handle->user_cb[_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME] = NULL;
+ handle->user_data[_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME] = NULL;
+ LOGI("Event type : %d ", _PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME);
+
+ int ret = mm_player_set_video_stream_callback(handle->mm_handle, NULL, NULL);
+ if (ret != MM_ERROR_NONE)
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+ else
+ return PLAYER_ERROR_NONE;
+}
+
+static bool __video_stream_changed_callback(void *user_data)
+{
+ player_s *handle = (player_s *)user_data;
+ _player_event_e event_type = _PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED;
+
+ LOGE("[%s] event type %d", __FUNCTION__, event_type);
+
+ if (handle->user_cb[event_type]) {
+ int width = 0, height = 0, fps = 0, bit_rate = 0;
+ int ret = mm_player_get_attribute(handle->mm_handle, NULL,
+ MM_PLAYER_VIDEO_WIDTH, &width,
+ MM_PLAYER_VIDEO_HEIGHT, &height,
+ "content_video_fps", &fps,
+ "content_video_bitrate", &bit_rate, (char *)NULL);
+
+ if (ret != MM_ERROR_NONE) {
+ LOGE("[%s] get attr is failed", __FUNCTION__);
+ return FALSE;
+ }
+
+ ((player_video_stream_changed_cb)handle->user_cb[event_type])(width, height, fps, bit_rate, handle->user_data[event_type]);
+ } else {
+ LOGE("[%s] video stream changed cb was not set.", __FUNCTION__);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+int legacy_player_set_video_stream_changed_cb(player_h player, player_video_stream_changed_cb callback, void *user_data)
+{
+ int ret;
+ 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;
+ }
+
+ ret = mm_player_set_video_stream_changed_callback(handle->mm_handle, (mm_player_stream_changed_callback)__video_stream_changed_callback, (void *)handle);
+
+ if (ret != MM_ERROR_NONE)
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+
+ return __set_callback(_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED, player, callback, user_data);
+}
+
+int legacy_player_unset_video_stream_changed_cb(player_h player)
+{
+ int ret;
+ PLAYER_INSTANCE_CHECK(player);
+ player_s *handle = (player_s *)player;
+
+ __unset_callback(_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED, player);
+
+ ret = mm_player_set_video_stream_changed_callback(handle->mm_handle, NULL, NULL);
+ if (ret != MM_ERROR_NONE)
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+ else
+ return PLAYER_ERROR_NONE;
+}
+
+static bool __media_stream_buffer_status_callback(player_stream_type_e type, player_media_stream_buffer_status_e status, unsigned long long bytes, void *user_data)
+{
+ player_s *handle = (player_s *)user_data;
+ _player_event_e event_type;
+
+ if (type == PLAYER_STREAM_TYPE_AUDIO)
+ event_type = _PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS;
+ else if (type == PLAYER_STREAM_TYPE_VIDEO)
+ event_type = _PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS;
+ else
+ return FALSE;
+
+ LOGE("[%s] event type %d", __FUNCTION__, event_type);
+
+ if (handle->user_cb[event_type]) {
+ ((player_media_stream_buffer_status_cb)handle->user_cb[event_type])(status, handle->user_data[event_type]);
+ } else {
+ LOGE("[%s][type:%d] buffer status cb was not set.", __FUNCTION__, type);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static bool __media_stream_seek_data_callback(player_stream_type_e type, unsigned long long offset, void *user_data)
+{
+ player_s *handle = (player_s *)user_data;
+ _player_event_e event_type;
+
+ if (type == PLAYER_STREAM_TYPE_AUDIO)
+ event_type = _PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK;
+ else if (type == PLAYER_STREAM_TYPE_VIDEO)
+ event_type = _PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK;
+ else
+ return FALSE;
+
+ LOGE("[%s] event type %d", __FUNCTION__, event_type);
+
+ if (handle->user_cb[event_type]) {
+ ((player_media_stream_seek_cb)handle->user_cb[event_type])(offset, handle->user_data[event_type]);
+ } else {
+ LOGE("[%s][type:%d] seek cb was not set.", __FUNCTION__, type);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+int legacy_player_set_media_stream_buffer_status_cb(player_h player, player_stream_type_e type, player_media_stream_buffer_status_cb callback, void *user_data)
+{
+ int ret;
+ 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;
+ }
+ /* the type can be expaned with default and text. */
+ if ((type != PLAYER_STREAM_TYPE_VIDEO) && (type != PLAYER_STREAM_TYPE_AUDIO)) {
+ LOGE("[%s] PLAYER_ERROR_INVALID_PARAMETER(type : %d)", __FUNCTION__, type);
+ return PLAYER_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = mm_player_set_media_stream_buffer_status_callback(handle->mm_handle, type, (mm_player_media_stream_buffer_status_callback)__media_stream_buffer_status_callback, (void *)handle);
+
+ if (ret != MM_ERROR_NONE)
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+
+ if (type == PLAYER_STREAM_TYPE_VIDEO)
+ return __set_callback(_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS, player, callback, user_data);
+ else
+ return __set_callback(_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS, player, callback, user_data);
+}
+
+int legacy_player_unset_media_stream_buffer_status_cb(player_h player, player_stream_type_e type)
+{
+ int ret;
+ PLAYER_INSTANCE_CHECK(player);
+ player_s *handle = (player_s *)player;
+
+ if (type == PLAYER_STREAM_TYPE_VIDEO)
+ __unset_callback(_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS, player);
+ else if (type == PLAYER_STREAM_TYPE_AUDIO)
+ __unset_callback(_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS, player);
+ else
+ return PLAYER_ERROR_INVALID_PARAMETER;
+
+ ret = mm_player_set_media_stream_buffer_status_callback(handle->mm_handle, type, NULL, NULL);
+ if (ret != MM_ERROR_NONE)
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+ else
+ return PLAYER_ERROR_NONE;
+}
+
+int legacy_player_set_media_stream_seek_cb(player_h player, player_stream_type_e type, player_media_stream_seek_cb callback, void *user_data)
+{
+ int ret;
+ 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;
+ }
+ /* the type can be expaned with default and text. */
+ if ((type != PLAYER_STREAM_TYPE_VIDEO) && (type != PLAYER_STREAM_TYPE_AUDIO)) {
+ LOGE("[%s] PLAYER_ERROR_INVALID_PARAMETER(type : %d)", __FUNCTION__, type);
+ return PLAYER_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = mm_player_set_media_stream_seek_data_callback(handle->mm_handle, type, (mm_player_media_stream_seek_data_callback)__media_stream_seek_data_callback, (void *)handle);
+
+ if (ret != MM_ERROR_NONE)
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+
+ if (type == PLAYER_STREAM_TYPE_VIDEO)
+ return __set_callback(_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK, player, callback, user_data);
+ else
+ return __set_callback(_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK, player, callback, user_data);
+}
+
+int legacy_player_unset_media_stream_seek_cb(player_h player, player_stream_type_e type)
+{
+ int ret;
+ PLAYER_INSTANCE_CHECK(player);
+ player_s *handle = (player_s *)player;
+
+ if (type == PLAYER_STREAM_TYPE_VIDEO)
+ __unset_callback(_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK, player);
+ else if (type == PLAYER_STREAM_TYPE_AUDIO)
+ __unset_callback(_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK, player);
+ else
+ return PLAYER_ERROR_INVALID_PARAMETER;
+
+ ret = mm_player_set_media_stream_seek_data_callback(handle->mm_handle, type, NULL, NULL);
+ if (ret != MM_ERROR_NONE)
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+ else
+ return PLAYER_ERROR_NONE;
+}
+
+int legacy_player_push_media_stream(player_h player, media_packet_h packet)
+{
+ PLAYER_INSTANCE_CHECK(player);
+ player_s *handle = (player_s *)player;
+
+ PLAYER_CHECK_CONDITION(handle->error_code == PLAYER_ERROR_NONE, PLAYER_ERROR_NOT_SUPPORTED_FILE, "can't support this format");
+
+ int ret = mm_player_submit_packet(handle->mm_handle, packet);
+
+ if (ret != MM_ERROR_NONE)
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+ else
+ return PLAYER_ERROR_NONE;
+}
+
+int legacy_player_set_media_stream_info(player_h player, player_stream_type_e type, media_format_h format)
+{
+ int ret;
+ PLAYER_INSTANCE_CHECK(player);
+ player_s *handle = (player_s *)player;
+ PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
+
+ if (type == PLAYER_STREAM_TYPE_VIDEO)
+ ret = mm_player_set_video_info(handle->mm_handle, format);
+ else if (type == PLAYER_STREAM_TYPE_AUDIO)
+ ret = mm_player_set_audio_info(handle->mm_handle, format);
+ else
+ return PLAYER_ERROR_INVALID_PARAMETER;
+
+ if (ret != MM_ERROR_NONE)
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+ else
+ return PLAYER_ERROR_NONE;
+
+ return PLAYER_ERROR_NONE;
+}
+
+int legacy_player_set_media_stream_buffer_max_size(player_h player, player_stream_type_e type, unsigned long long max_size)
+{
+ int ret;
+ 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;
+ }
+
+ ret = mm_player_set_media_stream_buffer_max_size(handle->mm_handle, type, max_size);
+
+ if (ret != MM_ERROR_NONE)
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+ else
+ return PLAYER_ERROR_NONE;
+}
+
+int legacy_player_get_media_stream_buffer_max_size(player_h player, player_stream_type_e type, unsigned long long *max_size)
+{
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(max_size);
+ player_s *handle = (player_s *)player;
+
+ unsigned long long _max_size;
+ int ret = mm_player_get_media_stream_buffer_max_size(handle->mm_handle, type, &_max_size);
+ if (ret != MM_ERROR_NONE) {
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+ } else {
+ *max_size = _max_size;
+ return PLAYER_ERROR_NONE;
+ }
+}
+
+int legacy_player_set_media_stream_buffer_min_threshold(player_h player, player_stream_type_e type, unsigned int percent)
+{
+ int ret;
+ 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;
+ }
+
+ ret = mm_player_set_media_stream_buffer_min_percent(handle->mm_handle, type, percent);
+
+ if (ret != MM_ERROR_NONE)
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+ else
+ return PLAYER_ERROR_NONE;
+}
+
+int legacy_player_get_media_stream_buffer_min_threshold(player_h player, player_stream_type_e type, unsigned int *percent)
+{
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(percent);
+ player_s *handle = (player_s *)player;
+
+ unsigned int _value;
+ int ret = mm_player_get_media_stream_buffer_min_percent(handle->mm_handle, type, &_value);
+ if (ret != MM_ERROR_NONE) {
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+ } else {
+ *percent = _value;
+ return PLAYER_ERROR_NONE;
+ }
+}
+
+int legacy_player_get_track_count(player_h player, player_stream_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;
+ }
+
+ MMPlayerTrackType track_type = 0;
+ switch (type) {
+ case PLAYER_STREAM_TYPE_AUDIO:
+ track_type = MM_PLAYER_TRACK_TYPE_AUDIO;
+ break;
+ case PLAYER_STREAM_TYPE_TEXT:
+ track_type = MM_PLAYER_TRACK_TYPE_TEXT;
+ break;
+ default:
+ LOGE("invalid stream type %d", type);
+ return PLAYER_ERROR_INVALID_PARAMETER;
+ }
+
+ int ret = mm_player_get_track_count(handle->mm_handle, track_type, count);
+ if (ret != MM_ERROR_NONE)
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+
+ return PLAYER_ERROR_NONE;
+}
+
+int legacy_player_get_current_track(player_h player, player_stream_type_e type, int *index)
+{
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(index);
+ 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;
+ }
+
+ MMPlayerTrackType track_type = 0;
+ switch (type) {
+ case PLAYER_STREAM_TYPE_AUDIO:
+ track_type = MM_PLAYER_TRACK_TYPE_AUDIO;
+ break;
+ case PLAYER_STREAM_TYPE_TEXT:
+ track_type = MM_PLAYER_TRACK_TYPE_TEXT;
+ break;
+ default:
+ LOGE("invalid stream type %d", type);
+ return PLAYER_ERROR_INVALID_PARAMETER;
+ }
+
+ int ret = mm_player_get_current_track(handle->mm_handle, track_type, index);
+ if (ret != MM_ERROR_NONE)
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+
+ return PLAYER_ERROR_NONE;
+}
+
+int legacy_player_select_track(player_h player, player_stream_type_e type, int index)
+{
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_CHECK_CONDITION(index >= 0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
+ 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;
+ }
+
+ MMPlayerTrackType track_type = 0;
+ switch (type) {
+ case PLAYER_STREAM_TYPE_AUDIO:
+ track_type = MM_PLAYER_TRACK_TYPE_AUDIO;
+ break;
+ case PLAYER_STREAM_TYPE_TEXT:
+ track_type = MM_PLAYER_TRACK_TYPE_TEXT;
+ break;
+ default:
+ LOGE("invalid stream type %d", type);
+ return PLAYER_ERROR_INVALID_PARAMETER;
+ }
+
+ int ret = mm_player_select_track(handle->mm_handle, track_type, index);
+ if (ret != MM_ERROR_NONE)
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+
+ return PLAYER_ERROR_NONE;
+}
+
+int legacy_player_get_track_language_code(player_h player, player_stream_type_e type, int index, char **code)
+{
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(code);
+ 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 *language_code = NULL;
+ MMPlayerTrackType track_type = 0;
+ switch (type) {
+ case PLAYER_STREAM_TYPE_AUDIO:
+ track_type = MM_PLAYER_TRACK_TYPE_AUDIO;
+ break;
+ case PLAYER_STREAM_TYPE_VIDEO:
+ track_type = MM_PLAYER_TRACK_TYPE_VIDEO;
+ break;
+ case PLAYER_STREAM_TYPE_TEXT:
+ track_type = MM_PLAYER_TRACK_TYPE_TEXT;
+ break;
+ default:
+ LOGE("invalid stream type %d", type);
+ return PLAYER_ERROR_INVALID_PARAMETER;
+ }
+
+ int ret = mm_player_get_track_language_code(handle->mm_handle, track_type, index, &language_code);
+ if (ret != MM_ERROR_NONE) {
+ if (language_code != NULL)
+ free(language_code);
+
+ language_code = NULL;
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+ } else {
+ int code_len = 0;
+ *code = NULL;
+ if (language_code != NULL && strncmp(language_code, "und", 3)) {
+ code_len = 2;
+ *code = strndup(language_code, code_len);
+ } else {
+ code_len = 3;
+ *code = strndup("und", code_len);
+ }
+
+ if (language_code)
+ free(language_code);
+
+ language_code = NULL;
+ return PLAYER_ERROR_NONE;
+ }
+}
+
+static MMDisplaySurfaceType __player_mused_convet_display_type(player_display_type_e type)
+{
+ switch (type) {
+ case PLAYER_DISPLAY_TYPE_OVERLAY:
+ return PLAYER_DISPLAY_TYPE_OVERLAY;
+#ifdef TIZEN_MOBILE
+ case PLAYER_DISPLAY_TYPE_EVAS:
+ return MM_DISPLAY_SURFACE_REMOTE;
+#endif
+ case PLAYER_DISPLAY_TYPE_NONE:
+ return MM_DISPLAY_SURFACE_NULL;
+ default:
+ return MM_DISPLAY_SURFACE_NULL;
+ }
+}
+
+#ifdef HAVE_WAYLAND
+int legacy_player_resize_video_render_rect(player_h player, int x, int y, int w, int h)
+{
+ PLAYER_INSTANCE_CHECK(player);
+ player_s *handle = (player_s *)player;
+ int ret;
+
+ LOGD("<Enter>");
+
+ ret = mm_player_set_attribute(handle->mm_handle, NULL, "wl_window_render_x", x, "wl_window_render_y", y, "wl_window_render_width", w, "wl_window_render_height", h, (char *)NULL);
+
+ if (ret != MM_ERROR_NONE) {
+ handle->display_type = PLAYER_DISPLAY_TYPE_NONE;
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+ } else {
+ return PLAYER_ERROR_NONE;
+ }
+}
+
+int legacy_player_set_display_wl_for_mused(player_h player, player_display_type_e type, unsigned int wl_surface_id, int x, int y, int w, int h)
+{
+ PLAYER_INSTANCE_CHECK(player);
+ player_s *handle = (player_s *)player;
+ void *set_handle = NULL;
+ MMDisplaySurfaceType mmType = __player_mused_convet_display_type(type);
+ MMDisplaySurfaceType mmClientType = MM_DISPLAY_SURFACE_NULL;
+ MMPlayerPipelineType mmPipelineType = MM_PLAYER_PIPELINE_SERVER;
+
+ 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 legacy_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 = NULL;
+ if (type == PLAYER_DISPLAY_TYPE_NONE) {
+ /* NULL surface */
+ handle->display_handle = 0;
+ handle->display_type = type;
+ set_handle = NULL;
+ } else {
+ /* get handle from overlay or evas surface */
+ temp = handle->display_handle;
+ if (type == PLAYER_DISPLAY_TYPE_OVERLAY) {
+ LOGI("Wayland overlay surface type");
+ LOGI("wl_surface_id %d", wl_surface_id);
+ handle->display_handle = (void *)(uintptr_t)wl_surface_id;
+ set_handle = &(handle->display_handle);
+ mmClientType = MM_DISPLAY_SURFACE_OVERLAY;
+#ifdef TIZEN_MOBILE
+ } else if (type == PLAYER_DISPLAY_TYPE_EVAS) {
+ LOGI("Evas surface type");
+ set_handle = &(handle->display_handle);
+ mmClientType = MM_DISPLAY_SURFACE_EVAS;
+#endif
+ } else {
+ LOGE("invalid surface type");
+ return PLAYER_ERROR_INVALID_PARAMETER;
+ }
+ }
+
+ /* set display handle */
+ if (handle->display_type == PLAYER_DISPLAY_TYPE_NONE || type == handle->display_type) {
+ /* first time or same type */
+ LOGW("first time or same type");
+ ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_surface_type", mmType, "display_surface_client_type", mmClientType, "display_overlay", set_handle, sizeof(wl_surface_id), "pipeline_type", mmPipelineType, NULL);
+
+ if (ret != MM_ERROR_NONE) {
+ handle->display_handle = temp;
+ LOGE("[%s] Failed to display surface change :%d", __FUNCTION__, ret);
+ } else {
+ if (type != PLAYER_DISPLAY_TYPE_NONE) {
+ handle->display_type = type;
+ LOGI("[%s] video display has been changed- type :%d, addr : 0x%x", __FUNCTION__, handle->display_type, handle->display_handle);
+ } else
+ LOGI("NULL surface");
+ }
+ LOGI("get window rectangle: x(%d) y(%d) width(%d) height(%d)", x, y, w, h);
+ ret = mm_player_set_attribute(handle->mm_handle, NULL, "wl_window_render_x", x, "wl_window_render_y", y, "wl_window_render_width", w, "wl_window_render_height", h, (char *)NULL);
+
+ if (ret != MM_ERROR_NONE) {
+ handle->display_handle = temp;
+ LOGE("[%s] Failed to set wl_window render rectangle :%d", __FUNCTION__, ret);
+ }
+ } else {
+ /* changing surface case */
+ ret = mm_player_change_videosink(handle->mm_handle, mmType, set_handle);
+ 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;
+ LOGI("[%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 = PLAYER_DISPLAY_TYPE_NONE;
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+ } else {
+ return PLAYER_ERROR_NONE;
+ }
+}
+
+#else
+
+int legacy_player_set_display_for_mused(player_h player, player_display_type_e type, unsigned int xhandle)
+{
+ PLAYER_INSTANCE_CHECK(player);
+ player_s *handle = (player_s *)player;
+ void *set_handle = NULL;
+ MMDisplaySurfaceType mmType = __player_mused_convet_display_type(type);
+
+ 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 legacy_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 = NULL;
+ if (type == PLAYER_DISPLAY_TYPE_NONE) {
+ /* NULL surface */
+ handle->display_handle = 0;
+ handle->display_type = PLAYER_DISPLAY_TYPE_NONE;
+ set_handle = NULL;
+ } else {
+ /* get handle from overlay or evas surface */
+ temp = handle->display_handle;
+ if (type == PLAYER_DISPLAY_TYPE_OVERLAY/* && !strcmp(object_type, "elm_win") */) {
+ /* x window overlay surface */
+ LOGI("overlay surface type");
+ handle->display_handle = (void *)(uintptr_t)xhandle;
+ set_handle = &(handle->display_handle);
+ } else {
+ LOGE("invalid surface type");
+ return PLAYER_ERROR_INVALID_PARAMETER;
+ }
+ }
+
+ /* set display handle */
+ if (handle->display_type == PLAYER_DISPLAY_TYPE_NONE || type == handle->display_type) {
+ /* first time or same type */
+ ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_surface_type", mmType, "display_overlay", set_handle, sizeof(xhandle), NULL);
+
+ if (ret != MM_ERROR_NONE) {
+ handle->display_handle = temp;
+ LOGE("[%s] Failed to display surface change :%d", __FUNCTION__, ret);
+ } else {
+ if (type != PLAYER_DISPLAY_TYPE_NONE) {
+ handle->display_type = type;
+ LOGI("[%s] video display has been changed- type :%d, addr : 0x%x", __FUNCTION__, handle->display_type, handle->display_handle);
+ } else
+ LOGI("NULL surface");
+ }
+ } else {
+ /* changing surface case */
+ ret = mm_player_change_videosink(handle->mm_handle, mmType, set_handle);
+ 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;
+ LOGI("[%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 = PLAYER_DISPLAY_TYPE_NONE;
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+ } else {
+ return PLAYER_ERROR_NONE;
+ }
+}
+#endif
+
+int legacy_player_set_audio_policy_info_for_mused(player_h player, char *stream_type, int stream_index)
+{
+ PLAYER_INSTANCE_CHECK(player);
+ player_s *handle = (player_s *)player;
+ int ret;
+
+ PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
+
+ ret = mm_player_set_attribute(handle->mm_handle, NULL, "sound_stream_type", stream_type, strlen(stream_type), "sound_stream_index", stream_index, NULL);
+
+ if (ret != MM_ERROR_NONE)
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+ else
+ return PLAYER_ERROR_NONE;
+}
+
+int legacy_player_sound_register(player_h player, int pid)
+{
+ PLAYER_INSTANCE_CHECK(player);
+ player_s *handle = (player_s *)player;
+ int ret;
+
+ PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
+
+ ret = mm_player_sound_register(handle->mm_handle, pid);
+ if (ret != MM_ERROR_NONE)
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+
+ return PLAYER_ERROR_NONE;
+}
+
+
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dlog.h>
+
+#include <mm.h>
+#include <mm_player.h>
+#include <mm_player_internal.h>
+#include <mm_types.h>
+#include "legacy_player.h"
+#include "legacy_player_internal.h"
+#include "legacy_player_private.h"
+
+/*
+* Internal Macros
+*/
+#define PLAYER_SET_CALLBACK(event_type, handle, callback, user_data) \
+do { \
+ PLAYER_INSTANCE_CHECK(handle); \
+ PLAYER_NULL_ARG_CHECK(callback); \
+ handle->user_cb[event_type] = callback; \
+ handle->user_data[event_type] = user_data; \
+ LOGI("[%s] Event type : %d ", __FUNCTION__, event_type); \
+} while (0) \
+
+bool __audio_stream_callback_ex(MMPlayerAudioStreamDataType *stream, void *user_data)
+{
+ player_s *handle = (player_s *)user_data;
+
+ 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 TRUE;
+ }
+
+ if (handle->user_cb[_PLAYER_EVENT_TYPE_AUDIO_FRAME])
+ ((player_audio_pcm_extraction_cb)handle->user_cb[_PLAYER_EVENT_TYPE_AUDIO_FRAME])((player_audio_raw_data_s *)stream, handle->user_data[_PLAYER_EVENT_TYPE_AUDIO_FRAME]);
+ return TRUE;
+}
+
+int legacy_player_set_pcm_extraction_mode(player_h player, bool sync, player_audio_pcm_extraction_cb callback, void *user_data)
+{
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(callback);
+ player_s *handle = (player_s *)player;
+ int ret = MM_ERROR_NONE;
+
+ PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
+
+ ret = mm_player_set_attribute(handle->mm_handle, NULL, "pcm_extraction", TRUE, "pcm_extraction_start_msec", 0, "pcm_extraction_end_msec", 0, NULL);
+ if (ret != MM_ERROR_NONE)
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+
+ ret = mm_player_set_audio_stream_callback_ex(handle->mm_handle, sync, __audio_stream_callback_ex, (void *)handle);
+ if (ret != MM_ERROR_NONE)
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+
+ PLAYER_SET_CALLBACK(_PLAYER_EVENT_TYPE_AUDIO_FRAME, handle, callback, user_data);
+ return PLAYER_ERROR_NONE;
+}
+
+int legacy_player_set_pcm_spec(player_h player, const char *format, int samplerate, int channel)
+{
+ PLAYER_INSTANCE_CHECK(player);
+
+ player_s *handle = (player_s *)player;
+ int ret = MM_ERROR_NONE;
+
+ LOGE("[%s] legacy_player_set_pcm_spec %s %d %d", __FUNCTION__, format, samplerate, channel);
+ ret = mm_player_set_attribute(handle->mm_handle, NULL, "pcm_audioformat", format, strlen(format), NULL);
+ if (ret != MM_ERROR_NONE)
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+
+ ret = mm_player_set_pcm_spec(handle->mm_handle, samplerate, channel);
+ if (ret != MM_ERROR_NONE)
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+
+ return PLAYER_ERROR_NONE;
+}
+
+int legacy_player_set_streaming_playback_rate(player_h player, float rate)
+{
+ LOGI("[%s] rate : %0.1f", __FUNCTION__, rate);
+ 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_set_play_speed(handle->mm_handle, rate, TRUE);
+
+ 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 __player_convert_error_code(ret, (char *)__FUNCTION__);
+ }
+ return ret;
+}
+
+static bool __media_stream_buffer_status_callback_ex(player_stream_type_e type, player_media_stream_buffer_status_e status, unsigned long long bytes, void *user_data)
+{
+ player_s *handle = (player_s *)user_data;
+ _player_event_e event_type;
+
+ if (type == PLAYER_STREAM_TYPE_AUDIO)
+ event_type = _PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO;
+ else if (type == PLAYER_STREAM_TYPE_VIDEO)
+ event_type = _PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO;
+ else
+ return FALSE;
+
+ LOGE("[%s] event type %d, status %d, bytes %llu", __FUNCTION__, event_type, status, bytes);
+
+ if (handle->user_cb[event_type]) {
+ ((player_media_stream_buffer_status_cb_ex)handle->user_cb[event_type])(status, bytes, handle->user_data[event_type]);
+ } else {
+ LOGE("[%s][type:%d] buffer status cb was not set.", __FUNCTION__, type);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+int legacy_player_set_media_stream_buffer_status_cb_ex(player_h player, player_stream_type_e type, player_media_stream_buffer_status_cb_ex callback, void *user_data)
+{
+ int ret;
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(callback);
+ player_s *handle = (player_s *)player;
+ _player_event_e event_type;
+
+ 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;
+ }
+ /* the type can be expaned with default and text. */
+ if ((type != PLAYER_STREAM_TYPE_VIDEO) && (type != PLAYER_STREAM_TYPE_AUDIO)) {
+ LOGE("[%s] PLAYER_ERROR_INVALID_PARAMETER(type : %d)", __FUNCTION__, type);
+ return PLAYER_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = mm_player_set_media_stream_buffer_status_callback(handle->mm_handle, type, (mm_player_media_stream_buffer_status_callback)__media_stream_buffer_status_callback_ex, (void *)handle);
+
+ if (ret != MM_ERROR_NONE)
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+
+ if (type == PLAYER_STREAM_TYPE_VIDEO)
+ event_type = _PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO;
+ else
+ event_type = _PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO;
+
+ LOGI("[%s] Event type : %d ", __FUNCTION__, type);
+
+ handle->user_cb[event_type] = callback;
+ handle->user_data[event_type] = user_data;
+
+ return PLAYER_ERROR_NONE;
+}
+
+int legacy_player_unset_media_stream_buffer_status_cb_ex(player_h player, player_stream_type_e type)
+{
+ int ret;
+ PLAYER_INSTANCE_CHECK(player);
+ player_s *handle = (player_s *)player;
+ _player_event_e event_type;
+
+ if (type == PLAYER_STREAM_TYPE_VIDEO)
+ event_type = _PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO;
+ else if (type == PLAYER_STREAM_TYPE_AUDIO)
+ event_type = _PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO;
+ else
+ return PLAYER_ERROR_INVALID_PARAMETER;
+
+ handle->user_cb[event_type] = NULL;
+ handle->user_data[event_type] = NULL;
+
+ LOGI("[%s] Event type : %d ", __FUNCTION__, type);
+
+ ret = mm_player_set_media_stream_buffer_status_callback(handle->mm_handle, type, NULL, NULL);
+ if (ret != MM_ERROR_NONE)
+ return __player_convert_error_code(ret, (char *)__FUNCTION__);
+ else
+ return PLAYER_ERROR_NONE;
+}
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+SET(fw_test "${fw_name}-test")
+
+INCLUDE_DIRECTORIES(../include/)
+link_directories(${CMAKE_SOURCE_DIR}/../)
+
+IF(X11_SUPPORT)
+ SET(WIN_PKG "ecore-x")
+ENDIF(X11_SUPPORT)
+IF(WAYLAND_SUPPORT)
+ SET(WIN_PKG "${WIN_PKG} ecore-wayland")
+ENDIF(WAYLAND_SUPPORT)
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${fw_test} REQUIRED libtbm mm-player appcore-efl elementary ecore evas capi-media-sound-manager ${WIN_PKG})
+
+
+FOREACH(flag ${${fw_test}_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wno-deprecated-declarations")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib/gstreamer-1.0")
+
+IF(WAYLAND_SUPPORT)
+ ADD_DEFINITIONS("-DHAVE_WAYLAND")
+ENDIF(WAYLAND_SUPPORT)
+
+IF(X11_SUPPORT)
+ ADD_DEFINITIONS("-DHAVE_X11")
+ENDIF(X11_SUPPORT)
+
+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} legacy-player ${${fw_test}_LDFLAGS})
+ INSTALL(TARGETS ${src_name} DESTINATION bin)
+ENDFOREACH()
+
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <Elementary.h>
+#include <tbm_surface.h>
+#include <dlog.h>
+#include <legacy_player.h>
+#include <legacy_player_internal.h>
+#include <glib.h>
+#include <appcore-efl.h>
+#ifdef HAVE_WAYLAND
+#include <Ecore.h>
+#include <Ecore_Wayland.h>
+#endif
+
+#define KEY_END "XF86Stop"
+
+#define ES_DEFAULT_DIR_PATH "/home/owner/content/"
+#define ES_DEFAULT_H264_VIDEO_PATH ES_DEFAULT_DIR_PATH"Simpsons.h264"
+#define ES_DEFAULT_VIDEO_FORMAT_TYPE MEDIA_FORMAT_H264_SP
+#define ES_DEFAULT_VIDEO_FORMAT_WIDTH 1280
+#define ES_DEFAULT_VIDEO_FORMAT_HEIGHT 544
+#define ES_DEFAULT_VIDEO_PTS_OFFSET 20000000
+#define ES_DEFAULT_NUMBER_OF_FEED 2000
+
+unsigned char sps[100];
+unsigned char pps[100];
+unsigned char tmp_buf[1000000];
+static int sps_len, pps_len;
+
+#ifdef PACKAGE
+#undef PACKAGE
+#endif
+#define PACKAGE "player_es_push_test"
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "PLAYER_TEST"
+
+static int app_create(void *data);
+static int app_reset(bundle *b, void *data);
+static int app_resume(void *data);
+static int app_pause(void *data);
+static int app_terminate(void *data);
+
+struct appcore_ops ops = {
+ .create = app_create,
+ .terminate = app_terminate,
+ .pause = app_pause,
+ .resume = app_resume,
+ .reset = app_reset,
+};
+
+typedef struct appdata {
+ Evas_Object *win;
+ Evas_Object *rect;
+ player_h player_handle;
+ media_packet_h video_pkt;
+ media_format_h video_fmt;
+ FILE *file_src;
+ pthread_t feeding_thread_id;
+} appdata_s;
+
+static void win_delete_request_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ elm_exit();
+}
+
+static Eina_Bool keydown_cb(void *data, int type, void *event)
+{
+ /* appdata_s *ad = data; */
+ Ecore_Event_Key *ev = event;
+
+ LOGD("start");
+
+ if (!strcmp(ev->keyname, KEY_END)) {
+ /* Let window go to hide state. */
+ /* elm_win_lower(ad->win); */
+ LOGD("elm exit");
+ elm_exit();
+
+ return ECORE_CALLBACK_DONE;
+ }
+
+ LOGD("done");
+
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+static void win_del(void *data, Evas_Object *obj, void *event)
+{
+ elm_exit();
+}
+
+static Evas_Object *create_win(const char *name)
+{
+ Evas_Object *eo = NULL;
+ int w = 0;
+ int h = 0;
+
+ 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);
+ elm_win_screen_size_get(eo, NULL, NULL, &w, &h);
+ g_print("window size :%d,%d", w, h);
+ evas_object_resize(eo, w, h);
+ elm_win_autodel_set(eo, EINA_TRUE);
+#ifdef HAVE_WAYLAND
+ elm_win_alpha_set(eo, EINA_TRUE);
+#endif
+ }
+ return eo;
+}
+
+static Evas_Object *create_render_rect(Evas_Object *pParent)
+{
+ if (!pParent)
+ return NULL;
+
+ Evas *pEvas = evas_object_evas_get(pParent);
+ Evas_Object *pObj = evas_object_rectangle_add(pEvas);
+ if (pObj == NULL)
+ return NULL;
+
+ evas_object_size_hint_weight_set(pObj, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_color_set(pObj, 0, 0, 0, 0);
+ evas_object_render_op_set(pObj, EVAS_RENDER_COPY);
+ evas_object_show(pObj);
+ elm_win_resize_object_add(pParent, pObj);
+
+ return pObj;
+}
+
+static void create_base_gui(appdata_s *ad)
+{
+ /* Enable GLES Backened */
+ elm_config_preferred_engine_set("3d");
+
+ /* Window */
+ ad->win = create_win(PACKAGE); /* elm_win_util_standard_add(PACKAGE, PACKAGE); */
+ ad->rect = create_render_rect(ad->win);
+ /* This is not supported in 3.0
+ elm_win_wm_desktop_layout_support_set(ad->win, EINA_TRUE); */
+ elm_win_autodel_set(ad->win, EINA_TRUE);
+ evas_object_smart_callback_add(ad->win, "delete,request", win_delete_request_cb, ad);
+
+ /* Show window after base gui is set up */
+ elm_win_activate(ad->win);
+ evas_object_show(ad->win);
+}
+
+static int app_create(void *data)
+{
+ /* Hook to take necessary actions before main event loop starts
+ Initialize UI resources and application's data
+ If this function returns true, the main loop of application starts
+ If this function returns false, the application is terminated */
+ appdata_s *ad = data;
+
+ LOGD("start");
+
+ create_base_gui(ad);
+ ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, keydown_cb, NULL);
+
+ /* open test file */
+ ad->file_src = fopen(ES_DEFAULT_H264_VIDEO_PATH, "r");
+
+ LOGD("done");
+
+ return 0;
+}
+
+static int app_pause(void *data)
+{
+ /* Take necessary actions when application becomes invisible. */
+ appdata_s *ad = (appdata_s *)data;
+ int ret = PLAYER_ERROR_NONE;
+
+ LOGD("start");
+
+ if (ad == NULL) {
+ LOGE("appdata is NULL");
+ return -1;
+ }
+
+ if (ad->player_handle == NULL) {
+ LOGE("player_handle is NULL");
+ return -1;
+ }
+
+ if (ad->feeding_thread_id) {
+ pthread_join(ad->feeding_thread_id, NULL);
+ ad->feeding_thread_id = 0;
+ }
+
+ legacy_player_unset_media_stream_buffer_status_cb_ex(ad->player_handle, PLAYER_STREAM_TYPE_VIDEO);
+ legacy_player_unset_media_stream_buffer_status_cb_ex(ad->player_handle, PLAYER_STREAM_TYPE_AUDIO);
+ legacy_player_unset_media_stream_seek_cb(ad->player_handle, PLAYER_STREAM_TYPE_VIDEO);
+ legacy_player_unset_media_stream_seek_cb(ad->player_handle, PLAYER_STREAM_TYPE_AUDIO);
+
+ ret = legacy_player_unprepare(ad->player_handle);
+ if (ret != PLAYER_ERROR_NONE) {
+ LOGE("legacy_player_unprepare failed : 0x%x", ret);
+ return false;
+ }
+
+ /* unref media format */
+ if (ad->video_fmt)
+ media_format_unref(ad->video_fmt);
+
+ fclose(ad->file_src);
+
+ /* destroy player handle */
+ ret = legacy_player_destroy(ad->player_handle);
+ if (ret != PLAYER_ERROR_NONE) {
+ LOGE("legacy_player_destroy failed : 0x%x", ret);
+ return false;
+ }
+
+ ad->player_handle = NULL;
+
+ LOGD("done");
+
+ return 0;
+}
+
+static int app_resume(void *data)
+{
+ LOGD("start");
+
+ LOGD("done");
+
+ return 0;
+}
+
+static void _player_prepared_cb(void *user_data)
+{
+ int ret = PLAYER_ERROR_NONE;
+ appdata_s *ad = (appdata_s *)user_data;
+
+ LOGD("prepared");
+
+ ret = legacy_player_start(ad->player_handle);
+ if (ret != PLAYER_ERROR_NONE)
+ LOGE("player start failed : 0x%x", ret);
+
+ LOGD("done");
+}
+
+int bytestream2nalunit(FILE *fd, unsigned char *nal)
+{
+ int nal_length = 0;
+ size_t result;
+ int read_size = 1;
+ unsigned char buffer[1000000];
+ unsigned char val, zero_count, i;
+ int nal_unit_type = 0;
+ int init;
+
+ zero_count = 0;
+ if (feof(fd))
+ return -1;
+
+ result = fread(buffer, 1, read_size, fd);
+
+ if (result != read_size)
+ return -1;
+
+ val = buffer[0];
+ while (!val) {
+ if ((zero_count == 2 || zero_count == 3) && val == 1)
+ break;
+
+ zero_count++;
+ result = fread(buffer, 1, read_size, fd);
+
+ if (result != read_size)
+ break;
+
+ val = buffer[0];
+ }
+ nal[nal_length++] = 0;
+ nal[nal_length++] = 0;
+ nal[nal_length++] = 0;
+ nal[nal_length++] = 1;
+ zero_count = 0;
+ init = 1;
+ while (1) {
+ if (feof(fd))
+ return -1;
+
+ result = fread(buffer, 1, read_size, fd);
+ if (result != read_size) {
+ if (init == 1)
+ return -1;
+ break;
+ }
+ val = buffer[0];
+
+ if (init) {
+ nal_unit_type = val & 0xf;
+ init = 0;
+ }
+ if (!val) {
+ zero_count++;
+ } else {
+ if ((zero_count == 2 || zero_count == 3 || zero_count == 4) && (val == 1)) {
+ break;
+ } else {
+ for (i = 0; i < zero_count; i++)
+ nal[nal_length++] = 0;
+
+ nal[nal_length++] = val;
+ zero_count = 0;
+ }
+ }
+ }
+
+ fseek(fd, -(zero_count + 1), SEEK_CUR);
+
+ if (nal_unit_type == 0x7) {
+ sps_len = nal_length;
+ memcpy(sps, nal, nal_length);
+ return 0;
+ } else if (nal_unit_type == 0x8) {
+ pps_len = nal_length;
+ memcpy(pps, nal, nal_length);
+ return 0;
+ } else if (nal_unit_type == 0x5) {
+ memcpy(tmp_buf, nal, nal_length);
+ memcpy(nal, sps, sps_len);
+ memcpy(nal + sps_len, pps, pps_len);
+ memcpy(nal + sps_len + pps_len, tmp_buf, nal_length);
+ nal_length += sps_len + pps_len;
+ }
+
+ return nal_length;
+}
+
+static void feed_eos_data(appdata_s *appdata)
+{
+ appdata_s *ad = appdata;
+
+ LOGD("push EOS");
+
+ if (media_packet_create_alloc(ad->video_fmt, NULL, NULL, &ad->video_pkt) != MEDIA_PACKET_ERROR_NONE) {
+ LOGE("media_packet_create_alloc failed\n");
+ return;
+ }
+
+ if (media_packet_set_buffer_size(ad->video_pkt, (uint64_t)0) != MEDIA_PACKET_ERROR_NONE) {
+ LOGE("media_packet_set_buffer_size failed\n");
+ return;
+ }
+
+ media_packet_set_flags(ad->video_pkt, MEDIA_PACKET_END_OF_STREAM);
+ if (legacy_player_push_media_stream(ad->player_handle, ad->video_pkt) != PLAYER_ERROR_NONE)
+ LOGE("fail to push media packet\n");
+
+ media_packet_destroy(ad->video_pkt);
+ ad->video_pkt = NULL;
+
+ return;
+}
+
+static bool feed_video_data(appdata_s *appdata)
+{
+ bool ret = FALSE;
+ int read = 0;
+ static guint64 pts = 0L;
+ void *buf_data_ptr = NULL;
+ appdata_s *ad = appdata;
+
+ if (media_packet_create_alloc(ad->video_fmt, NULL, NULL, &ad->video_pkt) != MEDIA_PACKET_ERROR_NONE) {
+ LOGE("media_packet_create_alloc failed\n");
+ return FALSE;
+ }
+
+ if (media_packet_get_buffer_data_ptr(ad->video_pkt, &buf_data_ptr) != MEDIA_PACKET_ERROR_NONE) {
+ LOGE("media_packet_get_buffer_data_ptr failed\n");
+ goto ERROR;
+ }
+
+ if (media_packet_set_pts(ad->video_pkt, (uint64_t)pts) != MEDIA_PACKET_ERROR_NONE) {
+ LOGE("media_packet_set_pts failed\n");
+ goto ERROR;
+ }
+
+ /* NOTE: In case of H.264 video, stream format for feeding is NAL unit.
+ * And, SPS(0x67) and PPS(0x68) should be located before IDR.(0x65).
+ */
+ read = bytestream2nalunit(ad->file_src, buf_data_ptr);
+ LOGD("real length = %d\n", read);
+ if (read == 0) {
+ LOGE("input file read failed\n");
+ ret = TRUE;
+ goto ERROR;
+ } else if (read < 0) {
+ LOGD("push EOS");
+ media_packet_set_buffer_size(ad->video_pkt, (uint64_t)0);
+ media_packet_set_flags(ad->video_pkt, MEDIA_PACKET_END_OF_STREAM);
+ if (legacy_player_push_media_stream(ad->player_handle, ad->video_pkt) != PLAYER_ERROR_NONE)
+ LOGE("fail to push media packet\n");
+ goto ERROR;
+ }
+
+ if (media_packet_set_buffer_size(ad->video_pkt, (uint64_t)read) != MEDIA_PACKET_ERROR_NONE) {
+ LOGE("media_packet_set_buffer_size failed\n");
+ goto ERROR;
+ }
+
+ /* push media packet */
+ legacy_player_push_media_stream(ad->player_handle, ad->video_pkt);
+ pts += ES_DEFAULT_VIDEO_PTS_OFFSET;
+ ret = TRUE;
+
+ERROR:
+ /* destroy media packet after use */
+ media_packet_destroy(ad->video_pkt);
+ ad->video_pkt = NULL;
+ return ret;
+}
+
+static void feed_video_data_thread_func(void *data)
+{
+ appdata_s *ad = (appdata_s *)data;
+
+ while (TRUE) {
+ static int frame_count = 0;
+
+ if (frame_count < ES_DEFAULT_NUMBER_OF_FEED) {
+ if (!feed_video_data(ad))
+ break;
+ frame_count++;
+ } else {
+ feed_eos_data(ad);
+ break;
+ }
+ }
+}
+
+void _video_buffer_status_cb_ex(player_media_stream_buffer_status_e status, unsigned long long bytes, void *user_data)
+{
+ if (status == PLAYER_MEDIA_STREAM_BUFFER_UNDERRUN) {
+ LOGE("video buffer is underrun state, current level byte = %llu", bytes);
+ }
+ else if (status == PLAYER_MEDIA_STREAM_BUFFER_OVERFLOW) {
+ LOGE("video buffer is overrun state, current level byte = %llu", bytes);
+ }
+}
+
+void _audio_buffer_status_cb_ex(player_media_stream_buffer_status_e status, unsigned long long bytes, void *user_data)
+{
+ if (status == PLAYER_MEDIA_STREAM_BUFFER_UNDERRUN) {
+ LOGE("audio buffer is underrun state, current level byte = %llu", bytes);
+ }
+ else if (status == PLAYER_MEDIA_STREAM_BUFFER_OVERFLOW) {
+ LOGE("audio buffer is overrun state, current level byte = %llu", bytes);
+ }
+}
+
+void _video_seek_data_cb(unsigned long long offset, void *user_data)
+{
+ LOGE("seek offset of video is %llu", offset);
+}
+
+void _audio_seek_data_cb(unsigned long long offset, void *user_data)
+{
+ LOGE("seek offset of audio is %llu", offset);
+}
+
+static int app_reset(bundle *b, void *data)
+{
+ /* Take necessary actions when application becomes visible. */
+ appdata_s *ad = (appdata_s *)data;
+ int ret = PLAYER_ERROR_NONE;
+
+ LOGD("start");
+
+ if (ad == NULL) {
+ LOGE("appdata is NULL");
+ return -1;
+ }
+
+ ret = legacy_player_create(&ad->player_handle);
+ if (ret != PLAYER_ERROR_NONE) {
+ LOGE("legacy_player_create failed : 0x%x", ret);
+ return -1;
+ }
+
+ ret = legacy_player_set_display(ad->player_handle, PLAYER_DISPLAY_TYPE_OVERLAY, GET_DISPLAY(ad->win));
+ if (ret != PLAYER_ERROR_NONE) {
+ LOGE("legacy_player_set_display failed : 0x%x", ret);
+ goto FAILED;
+ }
+
+ /* get media format format */
+ ret = media_format_create(&ad->video_fmt);
+ if (ret != MEDIA_FORMAT_ERROR_NONE) {
+ LOGE("media_format_create : 0x%x", ret);
+ goto FAILED;
+ }
+
+ /* set video format */
+ media_format_set_video_mime(ad->video_fmt, ES_DEFAULT_VIDEO_FORMAT_TYPE);
+ media_format_set_video_width(ad->video_fmt, ES_DEFAULT_VIDEO_FORMAT_WIDTH);
+ media_format_set_video_height(ad->video_fmt, ES_DEFAULT_VIDEO_FORMAT_HEIGHT);
+
+ legacy_player_set_media_stream_buffer_max_size(ad->player_handle, PLAYER_STREAM_TYPE_VIDEO, (unsigned long long)3*1024*1024);
+ legacy_player_set_media_stream_buffer_min_threshold(ad->player_handle, PLAYER_STREAM_TYPE_VIDEO, 50);
+
+ ret = legacy_player_set_media_stream_buffer_status_cb_ex(ad->player_handle, PLAYER_STREAM_TYPE_VIDEO, _video_buffer_status_cb_ex, (void *)ad);
+ if (ret != PLAYER_ERROR_NONE) {
+ LOGE("player set video buffer status cb failed : 0x%x", ret);
+ goto FAILED;
+ }
+ ret = legacy_player_set_media_stream_buffer_status_cb_ex(ad->player_handle, PLAYER_STREAM_TYPE_AUDIO, _audio_buffer_status_cb_ex, (void *)ad);
+ if (ret != PLAYER_ERROR_NONE) {
+ LOGE("player set audio buffer status cb failed : 0x%x", ret);
+ goto FAILED;
+ }
+
+ ret = legacy_player_set_media_stream_seek_cb(ad->player_handle, PLAYER_STREAM_TYPE_VIDEO, _video_seek_data_cb, (void *)ad);
+ if (ret != PLAYER_ERROR_NONE) {
+ LOGE("player set seek data cb for video failed : 0x%x", ret);
+ goto FAILED;
+ }
+ ret = legacy_player_set_media_stream_seek_cb(ad->player_handle, PLAYER_STREAM_TYPE_AUDIO, _audio_seek_data_cb, (void *)ad);
+ if (ret != PLAYER_ERROR_NONE) {
+ LOGE("player set seek data cb for audio failed : 0x%x", ret);
+ goto FAILED;
+ }
+
+ /* send media packet to player */
+ legacy_player_set_media_stream_info(ad->player_handle, PLAYER_STREAM_TYPE_VIDEO, ad->video_fmt);
+
+ ret = legacy_player_prepare_async(ad->player_handle, _player_prepared_cb, (void *)ad);
+ if (ret != PLAYER_ERROR_NONE) {
+ LOGE("player prepare failed : 0x%x", ret);
+ goto FAILED;
+ }
+
+ pthread_create(&ad->feeding_thread_id, NULL, (void *)feed_video_data_thread_func, (void *)ad);
+
+ LOGD("done");
+
+ return 0;
+
+FAILED:
+ if (ad->player_handle) {
+ legacy_player_destroy(ad->player_handle);
+ ad->player_handle = NULL;
+ }
+
+ return -1;
+}
+
+static int app_terminate(void *data)
+{
+ /* Release all resources. */
+ appdata_s *ad = (appdata_s *)data;
+
+ LOGD("start");
+
+ if (ad == NULL) {
+ LOGE("appdata is NULL");
+ return -1;
+ }
+
+ app_pause(data);
+
+ LOGD("done");
+
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+ int ret = 0;
+ static appdata_s ad = {0, };
+
+ LOGD("start");
+
+ memset(&ad, 0x0, sizeof(appdata_s));
+
+ LOGD("call appcore_efl_main");
+
+ ops.data = &ad;
+
+ ret = appcore_efl_main(PACKAGE, &argc, &argv, &ops);
+
+ LOGD("appcore_efl_main() ret = 0x%x", ret);
+
+ return ret;
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <Elementary.h>
+#include <tbm_surface.h>
+#include <dlog.h>
+#include <legacy_player.h>
+#include <glib.h>
+#include <appcore-efl.h>
+
+#define KEY_END "XF86Stop"
+#define MEDIA_FILE_PATH "/home/owner/content/Color.mp4"
+#ifdef PACKAGE
+#undef PACKAGE
+#endif
+#define PACKAGE "player_test"
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "PLAYER_TEST"
+
+static int app_create(void *data);
+static int app_reset(bundle *b, void *data);
+static int app_resume(void *data);
+static int app_pause(void *data);
+static int app_terminate(void *data);
+
+struct appcore_ops ops = {
+ .create = app_create,
+ .terminate = app_terminate,
+ .pause = app_pause,
+ .resume = app_resume,
+ .reset = app_reset,
+};
+
+typedef struct appdata {
+ Evas_Object *win;
+ Evas_Object *img;
+ media_packet_h packet;
+ Ecore_Pipe *pipe;
+ player_h player_handle;
+ GList *packet_list;
+ GMutex buffer_lock;
+ int w, h;
+} appdata_s;
+
+static void win_delete_request_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ elm_exit();
+}
+
+static Eina_Bool keydown_cb(void *data, int type, void *event)
+{
+ /* appdata_s *ad = data; */
+ Ecore_Event_Key *ev = event;
+
+ LOGD("start");
+
+ if (!strcmp(ev->keyname, KEY_END)) {
+ /* Let window go to hide state. */
+ /* elm_win_lower(ad->win); */
+ LOGD("elm exit");
+ elm_exit();
+
+ return ECORE_CALLBACK_DONE;
+ }
+
+ LOGD("done");
+
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+static void create_base_gui(appdata_s *ad)
+{
+ /* Enable GLES Backened */
+ elm_config_preferred_engine_set("3d");
+
+ /* Window */
+ ad->win = elm_win_util_standard_add(PACKAGE, PACKAGE);
+ /* This is not supported in 3.0
+ elm_win_wm_desktop_layout_support_set(ad->win, EINA_TRUE); */
+ elm_win_autodel_set(ad->win, EINA_TRUE);
+#if 0
+ if (elm_win_wm_rotation_supported_get(ad->win)) {
+ int rots[4] = { 0, 90, 180, 270 };
+ elm_win_wm_rotation_available_rotations_set(ad->win, (const int *)(&rots), 4);
+ }
+#endif
+ evas_object_smart_callback_add(ad->win, "delete,request", win_delete_request_cb, ad);
+
+ Evas *e = evas_object_evas_get(ad->win);
+
+ elm_win_screen_size_get(ad->win, NULL, NULL, &ad->w, &ad->h);
+ LOGD("surface size (%d x %d)\n", ad->w, ad->h);
+
+ /* Image Object */
+ ad->img = evas_object_image_filled_add(e);
+ evas_object_image_size_set(ad->img, ad->w, ad->h);
+ evas_object_size_hint_weight_set(ad->img, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_show(ad->img);
+
+ elm_win_resize_object_add(ad->win, ad->img);
+
+ /* Show window after base gui is set up */
+ evas_object_show(ad->win);
+}
+
+static void _media_packet_video_decoded_cb(media_packet_h packet, void *user_data)
+{
+ /* This callback function would be called on different thread */
+ appdata_s *ad = user_data;
+
+ if (ad == NULL) {
+ LOGE("appdata is NULL");
+ return;
+ }
+
+ g_mutex_lock(&ad->buffer_lock);
+
+ if (ad->pipe == NULL) {
+ media_packet_destroy(packet);
+ LOGW("release media packet immediately");
+ return;
+ }
+
+ /* add packet list */
+ ad->packet_list = g_list_prepend(ad->packet_list, (gpointer)packet);
+
+ LOGD("packet %p", packet);
+
+ /* Send packet to main thread */
+ ecore_pipe_write(ad->pipe, &packet, sizeof(media_packet_h));
+
+ g_mutex_unlock(&ad->buffer_lock);
+
+ return;
+}
+
+static void pipe_cb(void *data, void *buf, unsigned int len)
+{
+ /* Now, we get a player surface to be set here. */
+ appdata_s *ad = data;
+ tbm_surface_h surface;
+#if _CAN_USE_NATIVE_SURFACE_TBM
+ Evas_Native_Surface surf;
+#endif
+ tbm_surface_info_s suf_info;
+ uint32_t plane_idx;
+ int ret;
+ GList *last_item = NULL;
+
+ LOGD("start");
+
+ g_mutex_lock(&ad->buffer_lock);
+
+ /* Destroy previous packet */
+ if (ad->packet) {
+ ret = media_packet_destroy(ad->packet);
+ if (ret != MEDIA_PACKET_ERROR_NONE)
+ LOGE("Failed to destroy media packet. ret (%d)", ret);
+ ad->packet = NULL;
+ }
+
+ /* remove packet from list */
+ last_item = g_list_last(ad->packet_list);
+ if (last_item) {
+ /* Get new packet */
+ ad->packet = (media_packet_h)last_item->data;;
+ ad->packet_list = g_list_remove(ad->packet_list, ad->packet);
+ LOGD("ad->packet %p", ad->packet);
+ }
+
+ if (ad->packet == NULL) {
+ LOGW("NULL packet");
+ g_mutex_unlock(&ad->buffer_lock);
+ return;
+ }
+
+ ret = media_packet_get_tbm_surface(ad->packet, &surface);
+ if (ret != MEDIA_PACKET_ERROR_NONE) {
+ LOGE("Failed to get surface from media packet. ret(0x%x)", ret);
+
+ media_packet_destroy(ad->packet);
+ ad->packet = NULL;
+
+ g_mutex_unlock(&ad->buffer_lock);
+
+ return;
+ }
+
+ LOGD("surface %p", surface);
+
+ g_mutex_unlock(&ad->buffer_lock);
+
+#if _CAN_USE_NATIVE_SURFACE_TBM
+ /* Set tbm surface to image native surface */
+ memset(&surf, 0x0, sizeof(surf));
+ surf.version = EVAS_NATIVE_SURFACE_VERSION;
+ surf.type = EVAS_NATIVE_SURFACE_TBM;
+ surf.data.tizen.buffer = surface;
+ surf.data.tizen.rot = 270;
+ evas_object_image_native_surface_set(ad->img, &surf);
+
+ /* Set dirty image region to be redrawn */
+ evas_object_image_data_update_add(ad->img, 0, 0, ad->w, ad->h);
+#else
+ unsigned char *ptr = NULL;
+ unsigned char *buf_data = NULL;
+ media_format_h format = NULL;
+ media_format_mimetype_e mimetype;
+
+ media_packet_get_format(ad->packet, &format);
+ media_format_get_video_info(format, &mimetype, NULL, NULL, NULL, NULL);
+
+ if (mimetype == MEDIA_FORMAT_I420 || mimetype == MEDIA_FORMAT_NV12 || mimetype == MEDIA_FORMAT_NV12T) {
+
+ tbm_surface_get_info(surface, &suf_info);
+ buf_data = (unsigned char *)g_malloc0(suf_info.size);
+ if (!buf_data) {
+ LOGE("no free space");
+ return;
+ }
+ ptr = buf_data;
+
+ for (plane_idx = 0; plane_idx < suf_info.num_planes; plane_idx++) {
+ memcpy(ptr, suf_info.planes[plane_idx].ptr, suf_info.planes[plane_idx].size);
+ ptr += suf_info.planes[plane_idx].size;
+ }
+ /* dump buf data here, if needed */
+ g_free(buf_data);
+ }
+#endif
+
+ LOGD("done");
+
+ return;
+}
+
+static int app_create(void *data)
+{
+ /* Hook to take necessary actions before main event loop starts
+ Initialize UI resources and application's data
+ If this function returns true, the main loop of application starts
+ If this function returns false, the application is terminated */
+ appdata_s *ad = data;
+
+ LOGD("start");
+
+ create_base_gui(ad);
+ ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, keydown_cb, NULL);
+
+ g_mutex_init(&ad->buffer_lock);
+
+ LOGD("done");
+
+ return 0;
+}
+
+static int app_pause(void *data)
+{
+ /* Take necessary actions when application becomes invisible. */
+ appdata_s *ad = (appdata_s *)data;
+ GList *list = NULL;
+ media_packet_h packet = NULL;
+ int ret = PLAYER_ERROR_NONE;
+
+ LOGD("start");
+
+ if (ad == NULL) {
+ LOGE("appdata is NULL");
+ return -1;
+ }
+
+ if (ad->player_handle == NULL) {
+ printf("player_handle is NULL");
+ return -1;
+ }
+
+ /* stop render last set frame */
+ evas_object_image_native_surface_set(ad->img, NULL);
+
+ g_mutex_lock(&ad->buffer_lock);
+
+ /* remove ecore pipe */
+ ecore_pipe_del(ad->pipe);
+ ad->pipe = NULL;
+
+ /* remove packet list */
+ list = ad->packet_list;
+ while (list) {
+ packet = list->data;
+ list = g_list_next(list);
+
+ if (!packet) {
+ LOGW("packet is NULL");
+ } else {
+ LOGD("destroy packet %p", packet);
+ media_packet_destroy(packet);
+ packet = NULL;
+ ad->packet_list = g_list_remove(ad->packet_list, packet);
+ }
+ }
+
+ if (ad->packet_list) {
+ g_list_free(ad->packet_list);
+ ad->packet_list = NULL;
+ }
+
+ /* Destroy previous packet */
+ if (ad->packet) {
+ LOGD("destroy packet %p", ad->packet);
+ ret = media_packet_destroy(ad->packet);
+ if (ret != MEDIA_PACKET_ERROR_NONE)
+ LOGE("Failed to destroy media packet. ret (%d)", ret);
+ ad->packet = NULL;
+ }
+
+ g_mutex_unlock(&ad->buffer_lock);
+
+ ret = legacy_player_unprepare(ad->player_handle);
+ if (ret != PLAYER_ERROR_NONE) {
+ printf("legacy_player_unprepare failed : 0x%x", ret);
+ return false;
+ }
+
+ ret = legacy_player_destroy(ad->player_handle);
+ if (ret != PLAYER_ERROR_NONE) {
+ printf("legacy_player_destroy failed : 0x%x", ret);
+ return false;
+ }
+
+ ad->player_handle = NULL;
+
+ LOGD("done");
+
+ return 0;
+}
+
+static int app_resume(void *data)
+{
+ LOGD("start");
+
+ LOGD("done");
+
+ return 0;
+}
+
+static int app_reset(bundle *b, void *data)
+{
+ /* Take necessary actions when application becomes visible. */
+ appdata_s *ad = (appdata_s *)data;
+ int ret = PLAYER_ERROR_NONE;
+
+ LOGD("start");
+
+ if (ad == NULL) {
+ LOGE("appdata is NULL");
+ return -1;
+ }
+
+ /* create ecore pipe */
+ ad->pipe = ecore_pipe_add(pipe_cb, ad);
+
+ ret = legacy_player_create(&ad->player_handle);
+ if (ret != PLAYER_ERROR_NONE) {
+ LOGE("legacy_player_create failed : 0x%x", ret);
+ return -1;
+ }
+
+ ret = legacy_player_set_media_packet_video_frame_decoded_cb(ad->player_handle, _media_packet_video_decoded_cb, ad);
+ if (ret != PLAYER_ERROR_NONE) {
+ LOGE("legacy_player_set_media_packet_video_frame_decoded_cb failed : 0x%x", ret);
+ goto FAILED;
+ }
+
+ ret = legacy_player_set_display(ad->player_handle, PLAYER_DISPLAY_TYPE_NONE, NULL);
+ if (ret != PLAYER_ERROR_NONE) {
+ LOGE("legacy_player_set_display failed : 0x%x", ret);
+ goto FAILED;
+ }
+
+ ret = legacy_player_set_uri(ad->player_handle, MEDIA_FILE_PATH);
+ if (ret != PLAYER_ERROR_NONE) {
+ LOGE("legacy_player_set_uri failed : 0x%x", ret);
+ goto FAILED;
+ }
+
+ ret = legacy_player_prepare(ad->player_handle);
+ if (ret != PLAYER_ERROR_NONE) {
+ LOGE("player prepare failed : 0x%x", ret);
+ goto FAILED;
+ }
+
+ ret = legacy_player_start(ad->player_handle);
+ if (ret != PLAYER_ERROR_NONE) {
+ LOGE("player start failed : 0x%x", ret);
+ goto FAILED;
+ }
+
+ LOGD("done");
+
+ return 0;
+
+FAILED:
+ if (ad->player_handle) {
+ legacy_player_destroy(ad->player_handle);
+ ad->player_handle = NULL;
+ }
+
+ return -1;
+
+}
+
+static int app_terminate(void *data)
+{
+ /* Release all resources. */
+ appdata_s *ad = (appdata_s *)data;
+
+ LOGD("start");
+
+ if (ad == NULL) {
+ LOGE("appdata is NULL");
+ return -1;
+ }
+
+ app_pause(data);
+
+ g_mutex_clear(&ad->buffer_lock);
+
+ LOGD("done");
+
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+ int ret = 0;
+ static appdata_s ad = {0, };
+
+ LOGD("start");
+
+ memset(&ad, 0x0, sizeof(appdata_s));
+
+ LOGD("call appcore_efl_main");
+
+ ops.data = &ad;
+
+ ret = appcore_efl_main(PACKAGE, &argc, &argv, &ops);
+
+ LOGD("appcore_efl_main() ret = 0x%x", ret);
+
+ return ret;
+}
--- /dev/null
+/*
+* 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 <legacy_player.h>
+#include <legacy_player_internal.h>
+#include <sound_manager.h>
+#include <pthread.h>
+#include <glib.h>
+#include <dlfcn.h>
+#include <appcore-efl.h>
+#include <Elementary.h>
+#ifdef HAVE_X11
+#include <Ecore_X.h>
+#endif
+#ifdef HAVE_WAYLAND
+#include <Ecore.h>
+#include <Ecore_Wayland.h>
+#endif
+#define PACKAGE "player_test"
+#define MAX_STRING_LEN 2048
+#define MMTS_SAMPLELIST_INI_DEFAULT_PATH "/opt/etc/mmts_filelist.ini"
+#define PLAYER_TEST_DUMP_PATH_PREFIX "/home/owner/content/dump_pcm_"
+#define INI_SAMPLE_LIST_MAX 9
+#define DEFAULT_HTTP_TIMEOUT -1
+
+static gboolean g_memory_playback = FALSE;
+static char g_uri[MAX_STRING_LEN];
+static char g_subtitle_uri[MAX_STRING_LEN];
+static FILE *g_pcm_fd;
+
+static gboolean is_es_push_mode = FALSE;
+static pthread_t g_feed_video_thread_id = 0;
+static bool g_thread_end = FALSE;
+static media_packet_h g_audio_pkt = NULL;
+static media_format_h g_audio_fmt = NULL;
+
+static media_packet_h g_video_pkt = NULL;
+static media_format_h g_video_fmt = NULL;
+
+/* #define DUMP_OUTBUF 1 */
+#if DUMP_OUTBUF
+FILE *fp_out1 = NULL;
+FILE *fp_out2 = NULL;
+#endif
+
+enum {
+ CURRENT_STATUS_MAINMENU,
+ CURRENT_STATUS_HANDLE_NUM,
+ CURRENT_STATUS_FILENAME,
+ CURRENT_STATUS_VOLUME,
+ CURRENT_STATUS_SOUND_TYPE,
+ CURRENT_STATUS_SOUND_STREAM_INFO,
+ CURRENT_STATUS_MUTE,
+ CURRENT_STATUS_POSITION_TIME,
+ CURRENT_STATUS_LOOPING,
+ CURRENT_STATUS_DISPLAY_SURFACE_CHANGE,
+ CURRENT_STATUS_DISPLAY_MODE,
+ CURRENT_STATUS_DISPLAY_ROTATION,
+ CURRENT_STATUS_DISPLAY_VISIBLE,
+ CURRENT_STATUS_DISPLAY_ROI_MODE,
+ CURRENT_STATUS_DISPLAY_DST_ROI,
+ CURRENT_STATUS_DISPLAY_SRC_CROP,
+ CURRENT_STATUS_SUBTITLE_FILENAME,
+ CURRENT_STATUS_AUDIO_EQUALIZER,
+ CURRENT_STATUS_PLAYBACK_RATE,
+ CURRENT_STATUS_SWITCH_SUBTITLE,
+};
+
+#define MAX_HANDLE 20
+
+/* for video display */
+Evas_Object *g_xid;
+Evas_Object *g_eo_win;
+Evas_Object *g_eo[MAX_HANDLE] = {0, };
+
+int g_current_surface_type = PLAYER_DISPLAY_TYPE_OVERLAY;
+
+struct appdata {
+
+ Evas_Object *win;
+ Evas_Object *bg;
+ Evas_Object *rect;
+#ifdef HAVE_X11
+ Ecore_X_Window xid;
+#elif HAVE_WAYLAND
+ unsigned int xid;
+#endif
+ Evas_Object *layout_main; /* layout widget based on EDJ */
+ /* add more variables here */
+};
+
+static Evas_Object *create_bg(Evas_Object * pParent)
+{
+ if (!pParent)
+ return NULL;
+
+ Evas_Object *pObj = NULL;
+
+ pObj = elm_bg_add(pParent);
+ evas_object_size_hint_weight_set(pObj, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_win_resize_object_add(pParent, pObj);
+ evas_object_color_set(pObj, 0, 0, 0, 0);
+ evas_object_show(pObj);
+ return pObj;
+}
+
+static void win_del(void *data, Evas_Object * obj, void *event)
+{
+ elm_exit();
+}
+
+static Evas_Object *create_win(const char *name)
+{
+ Evas_Object *eo = NULL;
+ int w = 0;
+ int h = 0;
+
+ g_print("[%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);
+ elm_win_screen_size_get(eo, NULL, NULL, &w, &h);
+ g_print("window size :%d,%d", w, h);
+ evas_object_resize(eo, w, h);
+ elm_win_autodel_set(eo, EINA_TRUE);
+#ifdef HAVE_WAYLAND
+ elm_win_alpha_set(eo, EINA_TRUE);
+#endif
+ }
+ return eo;
+}
+
+static Evas_Object *create_image_object(Evas_Object * eo_parent)
+{
+ if (!eo_parent)
+ return NULL;
+
+ Evas *evas = evas_object_evas_get(eo_parent);
+ Evas_Object *eo = NULL;
+
+ eo = evas_object_image_add(evas);
+
+ return eo;
+}
+
+static Evas_Object *create_render_rect(Evas_Object * pParent)
+{
+ if (!pParent)
+ return NULL;
+
+ Evas *pEvas = evas_object_evas_get(pParent);
+ Evas_Object *pObj = evas_object_rectangle_add(pEvas);
+ if (pObj == NULL)
+ return NULL;
+
+ evas_object_size_hint_weight_set(pObj, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_color_set(pObj, 0, 0, 0, 0);
+ evas_object_render_op_set(pObj, EVAS_RENDER_COPY);
+ evas_object_show(pObj);
+ elm_win_resize_object_add(pParent, pObj);
+
+ return pObj;
+}
+
+static int app_create(void *data)
+{
+ struct appdata *ad = data;
+ Evas_Object *win = NULL;
+
+ /* use gl backend */
+ elm_config_preferred_engine_set("3d");
+
+ /* create window */
+ win = create_win(PACKAGE);
+ if (win == NULL)
+ return -1;
+ ad->win = win;
+ g_eo_win = win;
+ ad->bg = create_bg(ad->win);
+ ad->rect = create_render_rect(ad->win);
+ g_xid = ad->win;
+ /* Create evas image object for EVAS surface */
+ g_eo[0] = create_image_object(ad->win);
+ evas_object_image_size_set(g_eo[0], 500, 500);
+ evas_object_image_fill_set(g_eo[0], 0, 0, 500, 500);
+ evas_object_resize(g_eo[0], 500, 500);
+
+ elm_win_activate(win);
+ evas_object_show(win);
+
+ return 0;
+}
+
+static int app_terminate(void *data)
+{
+ struct appdata *ad = data;
+ int i = 0;
+
+ for (i = 0; i < MAX_HANDLE; i++) {
+ if (g_eo[i]) {
+ evas_object_del(g_eo[i]);
+ g_eo[i] = NULL;
+ }
+ }
+ if (g_eo_win) {
+ evas_object_del(g_eo_win);
+ g_eo_win = NULL;
+ }
+ ad->win = NULL;
+ return 0;
+}
+
+struct appcore_ops ops = {
+ .create = app_create,
+ .terminate = app_terminate,
+};
+
+struct appdata ad;
+static player_h g_player[MAX_HANDLE] = {0, };
+
+int g_handle_num = 1;
+int g_menu_state = CURRENT_STATUS_MAINMENU;
+char g_file_list[9][256];
+gboolean quit_pushing;
+sound_stream_info_h g_stream_info_h = NULL;
+
+static void prepared_cb(void *user_data)
+{
+ g_print("[Player_Test] prepared_cb!!!!\n");
+}
+
+static void _audio_frame_decoded_cb_ex(player_audio_raw_data_s *audio_raw_frame, void *user_data)
+{
+ player_audio_raw_data_s *audio_raw = audio_raw_frame;
+
+ if (!audio_raw)
+ return;
+
+ g_print("[Player_Test] decoded_cb_ex! channel: %d channel_mask: %" G_GUINT64_FORMAT "\n", audio_raw->channel, audio_raw->channel_mask);
+
+#ifdef DUMP_OUTBUF
+ if (audio_raw->channel_mask == 1)
+ fwrite((guint8 *) audio_raw->data, 1, audio_raw->size, fp_out1);
+ else if (audio_raw->channel_mask == 2)
+ fwrite((guint8 *) audio_raw->data, 1, audio_raw->size, fp_out2);
+#endif
+}
+
+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 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 error_cb(int code, void *user_data)
+{
+ g_print("[Player_Test] error_cb!!!! code : %d\n", code);
+}
+
+static void interrupted_cb(player_interrupted_code_e code, void *user_data)
+{
+ g_print("[Player_Test] interrupted_cb!!!! code : %d\n", code);
+}
+
+#if 0
+static void audio_frame_decoded_cb(unsigned char *data, unsigned int size, void *user_data)
+{
+ int pos = 0;
+
+ if (data && g_pcm_fd)
+ fwrite(data, 1, size, g_pcm_fd);
+
+ legacy_player_get_play_position(g_player[0], &pos);
+ g_print("[Player_Test] audio_frame_decoded_cb [size: %d] --- current pos : %d!!!!\n", size, pos);
+}
+#endif
+
+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);
+}
+
+int _save(unsigned char *src, int length)
+{
+ /* unlink(CAPTUERD_IMAGE_SAVE_PATH); */
+ FILE *fp;
+ char filename[256] = {0, };
+ static int WRITE_COUNT = 0;
+
+ /* gchar *filename = CAPTUERD_IMAGE_SAVE_PATH; */
+ snprintf(filename, 256, "ALBUM_ART_IMAGE_%d", WRITE_COUNT);
+ WRITE_COUNT++;
+ fp = fopen(filename, "w+");
+ if (fp == NULL) {
+ g_print("file open error!!\n");
+ return FALSE;
+ } else {
+ g_print("open success\n");
+ if (fwrite(src, 1, length, fp) < 1) {
+ g_print("file write error!!\n");
+ fclose(fp);
+ return FALSE;
+ }
+ g_print("write success(%s)\n", filename);
+ fclose(fp);
+ }
+
+ return TRUE;
+}
+
+static void reset_display()
+{
+ int i = 0;
+
+ /* delete evas window, if it is */
+ for (i = 0; i < MAX_HANDLE; i++) {
+ if (g_eo[i]) {
+ evas_object_del(g_eo[i]);
+ g_eo[i] = NULL;
+ }
+ }
+
+}
+
+static void input_filename(char *filename)
+{
+ int len = strlen(filename);
+ int i = 0;
+
+ if (len < 0 || len > MAX_STRING_LEN)
+ return;
+
+ for (i = 0; i < g_handle_num; i++) {
+ if (g_player[i] != NULL) {
+ legacy_player_unprepare(g_player[i]);
+ legacy_player_destroy(g_player[i]);
+ }
+ g_player[i] = 0;
+
+ if (legacy_player_create(&g_player[i]) != PLAYER_ERROR_NONE)
+ g_print("legacy_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[0], &g_err_name, "profile_uri", uri, strlen(uri), "profile_user_param", g_media_mem, file_size NULL);
+#else
+ /* legacy_player_set_uri(g_player[0], filename); */
+#endif
+ /* APPSRC_TEST */
+ int ret;
+ player_state_e state;
+ for (i = 0; i < g_handle_num; i++) {
+ ret = legacy_player_get_state(g_player[i], &state);
+ g_print("legacy_player_get_state returned [%d]", ret);
+ g_print("1. After legacy_player_create() - Current State : %d \n", state);
+ }
+}
+
+/* use this API instead of legacy_player_set_uri */
+static void player_set_memory_buffer_test()
+{
+ GMappedFile *file;
+ gsize file_size;
+ guint8 *g_media_mem = NULL;
+
+ file = g_mapped_file_new(g_uri, FALSE, NULL);
+ file_size = g_mapped_file_get_length(file);
+ g_media_mem = (guint8 *) g_mapped_file_get_contents(file);
+
+ int ret = legacy_player_set_memory_buffer(g_player[0], (void *)g_media_mem, file_size);
+ g_print("legacy_player_set_memory_buffer ret : %d\n", ret);
+}
+
+int video_packet_count = 0;
+
+static void buffer_need_video_data_cb(unsigned int size, void *user_data)
+{
+ int real_read_len = 0;
+ char fname[128];
+ char fptsname[128];
+ static guint64 pts = 0L;
+
+ FILE *fp = NULL;
+ guint8 *buff_ptr = NULL;
+ void *src = NULL;
+
+ memset(fname, 0, 128);
+ memset(fptsname, 0, 128);
+
+ video_packet_count++;
+
+ if (video_packet_count > 1000) {
+ g_print("EOS.\n");
+ /* player_submit_packet(g_player[0], NULL, 0, 0, 1); */
+ legacy_player_push_media_stream(g_player[0], NULL);
+ g_thread_end = TRUE;
+ }
+ /* snprintf(fname, 128, "/opt/storage/usb/test/packet/packet_%d.dat", video_packet_count); */
+ /* snprintf(fptsname, 128, "/opt/storage/usb/test/packet/gstpts_%d.dat", video_packet_count); */
+ snprintf(fname, 128, "/home/developer/test/packet/packet_%d.dat", video_packet_count);
+ snprintf(fptsname, 128, "/home/developer/test/packet/gstpts_%d.dat", video_packet_count);
+
+ fp = fopen(fptsname, "rb");
+ if (fp) {
+ int pts_len = 0;
+ pts_len = fread(&pts, 1, sizeof(guint64), fp);
+ if (pts_len != sizeof(guint64))
+ g_print("Warning, pts value can be wrong.\n");
+
+ fclose(fp);
+ fp = NULL;
+ }
+
+ fp = fopen(fname, "rb");
+ if (fp) {
+ buff_ptr = (guint8 *) g_malloc0(1048576);
+ if (!buff_ptr) {
+ g_print("no free space\n");
+ fclose(fp);
+ fp = NULL;
+ return;
+ }
+
+ real_read_len = fread(buff_ptr, 1, size, fp);
+ fclose(fp);
+ fp = NULL;
+ }
+ g_print("video need data - data size : %d, pts : %" G_GUINT64_FORMAT "\n", real_read_len, pts);
+#if 0
+ player_submit_packet(g_player[0], buff_ptr, real_read_len, (pts / 1000000), 1);
+#else
+ /* create media packet */
+ if (g_video_pkt) {
+ media_packet_destroy(g_video_pkt);
+ g_video_pkt = NULL;
+ }
+
+ media_packet_create_alloc(g_video_fmt, NULL, NULL, &g_video_pkt);
+
+ g_print("packet = %p, src = %p\n", g_video_pkt, src);
+
+ if (media_packet_get_buffer_data_ptr(g_video_pkt, &src) != MEDIA_PACKET_ERROR_NONE)
+ goto EXIT;
+
+ if (media_packet_set_pts(g_video_pkt, (uint64_t)pts) != MEDIA_PACKET_ERROR_NONE)
+ goto EXIT;
+
+ if (media_packet_set_buffer_size(g_video_pkt, (uint64_t) real_read_len) != MEDIA_PACKET_ERROR_NONE)
+ goto EXIT;
+
+ memcpy(src, buff_ptr, real_read_len);
+
+ /* then, push it */
+ legacy_player_push_media_stream(g_player[0], g_video_pkt);
+#endif
+
+EXIT:
+ if (buff_ptr) {
+ g_free(buff_ptr);
+ buff_ptr = NULL;
+ }
+}
+
+int audio_packet_count = 0;
+static void buffer_need_audio_data_cb(unsigned int size, void *user_data)
+{
+ int real_read_len = 0;
+ char fname[128];
+ FILE *fp = NULL;
+ guint8 *buff_ptr = NULL;
+ void *src = NULL;
+
+ memset(fname, 0, 128);
+ audio_packet_count++;
+
+ if (audio_packet_count > 1000) {
+ g_print("EOS.\n");
+ /* player_submit_packet(g_player[0], NULL, 0, 0, 0); */
+ legacy_player_push_media_stream(g_player[0], NULL);
+ g_thread_end = TRUE;
+ }
+ /* snprintf(fname, 128, "/opt/storage/usb/test/audio_packet/packet_%d.dat", audio_packet_count); */
+ snprintf(fname, 128, "/home/developer/test/audio_packet/packet_%d.dat", audio_packet_count);
+
+ static guint64 audio_pts = 0;
+ guint64 audio_dur = 21333333;
+
+ fp = fopen(fname, "rb");
+ if (fp) {
+ buff_ptr = (guint8 *) g_malloc0(1048576);
+ if (!buff_ptr) {
+ g_print("no free space\n");
+ fclose(fp);
+ fp = NULL;
+ return;
+ }
+
+ real_read_len = fread(buff_ptr, 1, size, fp);
+ fclose(fp);
+ fp = NULL;
+
+ g_print("\t audio need data - data size : %d, pts : %" G_GUINT64_FORMAT "\n", real_read_len, audio_pts);
+ }
+#if 0
+ player_submit_packet(g_player[0], buff_ptr, real_read_len, (audio_pts / 1000000), 0);
+#else
+ /* create media packet */
+ if (g_audio_pkt) {
+ media_packet_destroy(g_audio_pkt);
+ g_audio_pkt = NULL;
+ }
+ media_packet_create_alloc(g_audio_fmt, NULL, NULL, &g_audio_pkt);
+
+ g_print("packet = %p, src = %p\n", g_audio_pkt, src);
+
+ if (media_packet_get_buffer_data_ptr(g_audio_pkt, &src) != MEDIA_PACKET_ERROR_NONE)
+ goto EXIT;
+
+ if (media_packet_set_pts(g_audio_pkt, (uint64_t)audio_pts) != MEDIA_PACKET_ERROR_NONE)
+ goto EXIT;
+
+ if (media_packet_set_buffer_size(g_audio_pkt, (uint64_t) real_read_len) != MEDIA_PACKET_ERROR_NONE)
+ goto EXIT;
+
+ memcpy(src, buff_ptr, real_read_len);
+
+ /* then, push it */
+ legacy_player_push_media_stream(g_player[0], g_audio_pkt);
+#endif
+
+ audio_pts += audio_dur;
+
+EXIT:
+ if (buff_ptr) {
+ g_free(buff_ptr);
+ buff_ptr = NULL;
+ }
+}
+
+static void set_content_info(bool is_push_mode)
+{
+ /* testcode for es buff src case, please input url as es_buff://123 or es_buff://push_mode */
+ /* unsigned char codec_data[45] = {0x0,0x0,0x1,0xb0,0x1,0x0,0x0,0x1,0xb5,0x89,0x13,0x0,0x0,0x1,0x0,0x0,0x0,0x1,0x20,0x0,0xc4,0x8d,0x88,0x5d,0xad,0x14,0x4,0x22,0x14,0x43,0x0,0x0,0x1,0xb2,0x4c,0x61,0x76,0x63,0x35,0x31,0x2e,0x34,0x30,0x2e,0x34}; */
+
+ /* create media format */
+ media_format_create(&g_audio_fmt);
+ media_format_create(&g_video_fmt);
+
+ /* Video */
+ /* configure media format for video and set to player */
+ media_format_set_video_mime(g_video_fmt, MEDIA_FORMAT_MPEG4_SP);
+ media_format_set_video_width(g_video_fmt, 640);
+ media_format_set_video_height(g_video_fmt, 272);
+ /* legacy_player_set_media_stream_info(g_player[0], PLAYER_STREAM_TYPE_VIDEO, g_video_fmt); */
+
+ /* Audio--aac--StarWars.mp4 */
+ media_format_set_audio_mime(g_audio_fmt, MEDIA_FORMAT_AAC);
+ media_format_set_audio_channel(g_audio_fmt, 2);
+ media_format_set_audio_samplerate(g_audio_fmt, 48000);
+ /* legacy_player_set_media_stream_info(g_player[0], PLAYER_STREAM_TYPE_AUDIO, g_audio_fmt); */
+#if 0
+ /* video_info->mime = g_strdup("video/mpeg"); */ /* CODEC_ID_MPEG4VIDEO */
+ video_info->width = 640;
+ video_info->height = 272;
+ video_info->version = 4;
+ video_info->framerate_den = 100;
+ video_info->framerate_num = 2997;
+
+ video_info->extradata_size = 45;
+ video_info->codec_extradata = codec_data;
+ player_set_video_stream_info(g_player[0], video_info);
+
+ /* audio--aac--StarWars.mp4 */
+ /* audio_info->mime = g_strdup("audio/mpeg"); */
+ /* audio_info->version = 2; */
+ /* audio_info->user_info = 0;*/ /* raw */
+#endif
+
+#ifdef _ES_PULL_
+ if (!is_push_mode) {
+ player_set_buffer_need_video_data_cb(g_player[0], buffer_need_video_data_cb, (void *)g_player[0]);
+ player_set_buffer_need_audio_data_cb(g_player[0], buffer_need_audio_data_cb, (void *)g_player[0]);
+ }
+#endif
+}
+
+static void feed_video_data_thread_func(void *data)
+{
+ while (!g_thread_end) {
+ buffer_need_video_data_cb(1048576, NULL);
+ buffer_need_audio_data_cb(1048576, NULL);
+ }
+}
+
+static void _player_prepare(bool async)
+{
+ 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);
+ legacy_player_set_subtitle_path(g_player[0], g_subtitle_uri);
+ legacy_player_set_subtitle_updated_cb(g_player[0], subtitle_updated_cb, (void *)g_player[0]);
+ }
+ if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
+ legacy_player_set_display(g_player[0], g_current_surface_type, GET_DISPLAY(g_xid));
+ legacy_player_set_buffering_cb(g_player[0], buffering_cb, (void *)g_player[0]);
+ legacy_player_set_completed_cb(g_player[0], completed_cb, (void *)g_player[0]);
+ legacy_player_set_interrupted_cb(g_player[0], interrupted_cb, (void *)g_player[0]);
+ legacy_player_set_error_cb(g_player[0], error_cb, (void *)g_player[0]);
+ if (g_memory_playback)
+ player_set_memory_buffer_test();
+ else
+ legacy_player_set_uri(g_player[0], g_uri);
+ } else {
+ int i = 0;
+ for (i = 0; i < g_handle_num; i++) {
+ legacy_player_set_display(g_player[i], g_current_surface_type, g_eo[i]);
+ legacy_player_set_buffering_cb(g_player[i], buffering_cb, (void *)g_player[i]);
+ legacy_player_set_completed_cb(g_player[i], completed_cb, (void *)g_player[i]);
+ legacy_player_set_interrupted_cb(g_player[i], interrupted_cb, (void *)g_player[i]);
+ legacy_player_set_error_cb(g_player[i], error_cb, (void *)g_player[i]);
+ if (g_memory_playback)
+ player_set_memory_buffer_test();
+ else
+ legacy_player_set_uri(g_player[i], g_uri);
+ }
+ }
+
+ if (strstr(g_uri, "es_buff://")) {
+ is_es_push_mode = FALSE;
+ video_packet_count = 0;
+ audio_packet_count = 0;
+
+ if (strstr(g_uri, "es_buff://push_mode")) {
+ set_content_info(TRUE);
+ async = TRUE;
+ is_es_push_mode = TRUE;
+ }
+#ifdef _ES_PULL_
+ else
+ set_content_info(FALSE);
+#endif
+ }
+
+ if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
+ if (async)
+ ret = legacy_player_prepare_async(g_player[0], prepared_cb, (void *)g_player[0]);
+ else
+ ret = legacy_player_prepare(g_player[0]);
+ } else {
+ int i = 0;
+ for (i = 0; i < g_handle_num; i++) {
+ if (async)
+ ret = legacy_player_prepare_async(g_player[i], prepared_cb, (void *)g_player[i]);
+ else
+ ret = legacy_player_prepare(g_player[i]);
+ }
+ }
+
+ if (ret != PLAYER_ERROR_NONE)
+ g_print("prepare is failed (errno = %d) \n", ret);
+
+ player_state_e state;
+ if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
+ ret = legacy_player_get_state(g_player[0], &state);
+ g_print("After legacy_player_prepare() - Current State : %d \n", state);
+ } else {
+ int i = 0;
+ for (i = 0; i < g_handle_num; i++) {
+ ret = legacy_player_get_state(g_player[i], &state);
+ g_print("After legacy_player_prepare() - Current State : %d \n", state);
+ }
+ }
+
+ if (is_es_push_mode)
+ pthread_create(&g_feed_video_thread_id, NULL, (void *)feed_video_data_thread_func, NULL);
+}
+
+static void _player_unprepare()
+{
+ int ret = FALSE;
+ int i = 0;
+ if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
+ ret = legacy_player_unprepare(g_player[0]);
+ if (ret != PLAYER_ERROR_NONE)
+ g_print("unprepare is failed (errno = %d) \n", ret);
+ ret = legacy_player_unset_subtitle_updated_cb(g_player[0]);
+ g_print("legacy_player_unset_subtitle_updated_cb ret %d\n", ret);
+
+ ret = legacy_player_unset_buffering_cb(g_player[0]);
+ g_print("legacy_player_unset_buffering_cb ret %d\n", ret);
+
+ ret = legacy_player_unset_completed_cb(g_player[0]);
+ g_print("legacy_player_unset_completed_cb ret %d\n", ret);
+
+ ret = legacy_player_unset_interrupted_cb(g_player[0]);
+ g_print("legacy_player_unset_interrupted_cb ret %d\n", ret);
+
+ ret = legacy_player_unset_error_cb(g_player[0]);
+ g_print("legacy_player_unset_error_cb ret %d\n", ret);
+ } else {
+ for (i = 0; i < g_handle_num; i++) {
+ if (g_player[i] != NULL) {
+ ret = legacy_player_unprepare(g_player[i]);
+ if (ret != PLAYER_ERROR_NONE)
+ g_print("unprepare is failed (errno = %d) \n", ret);
+
+ ret = legacy_player_unset_subtitle_updated_cb(g_player[i]);
+ g_print("legacy_player_unset_subtitle_updated_cb [%d] ret %d\n", i, ret);
+
+ ret = legacy_player_unset_buffering_cb(g_player[i]);
+ g_print("legacy_player_unset_buffering_cb [%d] ret %d\n", i, ret);
+
+ ret = legacy_player_unset_completed_cb(g_player[i]);
+ g_print("legacy_player_unset_completed_cb [%d] ret %d\n", i, ret);
+
+ ret = legacy_player_unset_interrupted_cb(g_player[i]);
+ g_print("legacy_player_unset_interrupted_cb [%d] ret %d\n", i, ret);
+
+ ret = legacy_player_unset_error_cb(g_player[i]);
+ g_print("legacy_player_unset_error_cb [%d] ret %d\n", i, ret);
+ }
+ }
+ }
+ reset_display();
+ memset(g_subtitle_uri, 0, sizeof(g_subtitle_uri));
+ player_state_e state;
+ if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
+ ret = legacy_player_get_state(g_player[0], &state);
+ g_print(" After player_unprepare() - Current State : %d \n", state);
+ } else {
+ for (i = 0; i < g_handle_num; i++) {
+ ret = legacy_player_get_state(g_player[i], &state);
+ g_print(" After legacy_player_unprepare() - Current State : %d \n", state);
+ }
+ }
+}
+
+static void _player_destroy()
+{
+ int i = 0;
+
+ if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
+ legacy_player_unprepare(g_player[0]);
+ for (i = 0; i < g_handle_num; i++) {
+ legacy_player_destroy(g_player[i]);
+ g_player[i] = 0;
+ }
+ } else {
+ for (i = 0; i < g_handle_num; i++) {
+ if (g_player[i] != NULL) {
+ legacy_player_unprepare(g_player[i]);
+ legacy_player_destroy(g_player[i]);
+ g_player[i] = 0;
+ }
+ }
+ }
+
+ if (g_stream_info_h) {
+ sound_manager_destroy_stream_information(g_stream_info_h);
+ g_stream_info_h = NULL;
+ }
+
+ if (g_video_pkt)
+ media_packet_destroy(g_video_pkt);
+
+ if (g_audio_pkt)
+ media_packet_destroy(g_audio_pkt);
+
+#if DUMP_OUTBUF
+ if (fp_out1)
+ fclose(fp_out1);
+ if (fp_out2)
+ fclose(fp_out2);
+#endif
+
+}
+
+static void _player_play()
+{
+ int bRet = FALSE;
+ int i = 0;
+ if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
+ bRet = legacy_player_start(g_player[0]);
+ g_print("legacy_player_start returned [%d]", bRet);
+ } else {
+ for (i = 0; i < g_handle_num; i++) {
+ bRet = legacy_player_start(g_player[i]);
+ g_print("legacy_player_start returned [%d]", bRet);
+ }
+ }
+}
+
+static void _player_stop()
+{
+ int bRet = FALSE;
+ int i = 0;
+ if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
+ bRet = legacy_player_stop(g_player[0]);
+ g_print("legacy_player_stop returned [%d]", bRet);
+ } else {
+ for (i = 0; i < g_handle_num; i++) {
+ bRet = legacy_player_stop(g_player[i]);
+ g_print("legacy_player_stop returned [%d]", bRet);
+ }
+ }
+
+ g_thread_end = TRUE;
+ if (g_feed_video_thread_id) {
+ pthread_join(g_feed_video_thread_id, NULL);
+ g_feed_video_thread_id = 0;
+ }
+
+}
+
+static void _player_resume()
+{
+ int bRet = FALSE;
+ int i = 0;
+ if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
+ bRet = legacy_player_start(g_player[0]);
+ g_print("legacy_player_start returned [%d]", bRet);
+ } else {
+ for (i = 0; i < g_handle_num; i++) {
+ bRet = legacy_player_start(g_player[i]);
+ g_print("legacy_player_start returned [%d]", bRet);
+ }
+ }
+}
+
+static void _player_pause()
+{
+ int bRet = FALSE;
+ int i = 0;
+ if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
+ bRet = legacy_player_pause(g_player[0]);
+ g_print("legacy_player_pause returned [%d]", bRet);
+ } else {
+ for (i = 0; i < g_handle_num; i++) {
+ bRet = legacy_player_pause(g_player[i]);
+ g_print("legacy_player_pause returned [%d]", bRet);
+ }
+ }
+}
+
+static void _player_state()
+{
+ player_state_e state;
+ legacy_player_get_state(g_player[0], &state);
+ g_print(" ==> [Player_Test] Current Player State : %d\n", state);
+}
+
+static void _player_set_progressive_download()
+{
+ legacy_player_set_progressive_download_path(g_player[0], "/home/owner/test.pd");
+ legacy_player_set_progressive_download_message_cb(g_player[0], progress_down_cb, (void *)g_player[0]);
+}
+
+static void set_volume(float volume)
+{
+ if (legacy_player_set_volume(g_player[0], volume, volume) != PLAYER_ERROR_NONE)
+ g_print("failed to set volume\n");
+}
+
+static void get_volume(float *left, float *right)
+{
+ legacy_player_get_volume(g_player[0], left, right);
+ g_print(" ==> [Player_Test] volume - left : %f, right : %f\n", *left, *right);
+}
+
+static void set_mute(bool mute)
+{
+ if (legacy_player_set_mute(g_player[0], mute) != PLAYER_ERROR_NONE)
+ g_print("failed to set_mute\n");
+}
+
+static void get_mute(bool * mute)
+{
+ legacy_player_is_muted(g_player[0], mute);
+ g_print(" ==> [Player_Test] mute = %d\n", *mute);
+}
+
+static void set_sound_type(sound_type_e type)
+{
+ if (legacy_player_set_sound_type(g_player[0], type) != PLAYER_ERROR_NONE)
+ g_print("failed to set sound type(%d)\n", type);
+ else
+ g_print("set sound type(%d) success", type);
+}
+
+void focus_callback(sound_stream_info_h stream_info, sound_stream_focus_change_reason_e reason_for_change, const char *additional_info, void *user_data)
+{
+ g_print("FOCUS callback is called, reason_for_change(%d), additional_info(%s), userdata(%p)", reason_for_change, additional_info, user_data);
+ return;
+}
+
+static void set_sound_stream_info(int type)
+{
+ if (g_stream_info_h) {
+ g_print("stream information is already set, please destory handle and try again\n");
+ return;
+ }
+ if (sound_manager_create_stream_information(type, focus_callback, g_player[0], &g_stream_info_h)) {
+ g_print("failed to create stream_information()\n");
+ return;
+ }
+ if (legacy_player_set_audio_policy_info(g_player[0], g_stream_info_h) != PLAYER_ERROR_NONE)
+ g_print("failed to set sound stream information(%p)\n", g_stream_info_h);
+ else
+ g_print("set stream information(%p) success", g_stream_info_h);
+}
+
+static void get_position()
+{
+ int position = 0;
+ int ret;
+ ret = legacy_player_get_play_position(g_player[0], &position);
+ g_print(" ==> [Player_Test] legacy_player_get_play_position()%d return : %d\n", ret, position);
+}
+
+static void set_position(int position)
+{
+ if (legacy_player_set_play_position(g_player[0], position, TRUE, seek_completed_cb, g_player[0]) != PLAYER_ERROR_NONE)
+ g_print("failed to set position\n");
+}
+
+static void set_playback_rate(float rate)
+{
+ if (legacy_player_set_playback_rate(g_player[0], rate) != PLAYER_ERROR_NONE)
+ g_print("failed to set playback rate\n");
+}
+
+static void get_duration()
+{
+ int duration = 0;
+ int ret;
+ ret = legacy_player_get_duration(g_player[0], &duration);
+ g_print(" ==> [Player_Test] legacy_player_get_duration() return : %d\n", ret);
+ g_print(" ==> [Player_Test] Duration: [%d ] msec\n", duration);
+}
+
+static int get_download_progress()
+{
+ int ret;
+ int start=0, current=0;
+ ret = legacy_player_get_streaming_download_progress(g_player[0], &start, ¤t);
+ g_print(" ==> [Player_Test] download progress: [%d ~ %d]\n", start, current);
+ return ret;
+}
+static void audio_frame_decoded_cb_ex()
+{
+ int ret;
+
+#if DUMP_OUTBUF
+ fp_out1 = fopen("/home/owner/content/out1.pcm", "wb");
+ fp_out2 = fopen("/home/owner/content/out2.pcm", "wb");
+ if (!fp_out1 || !fp_out2) {
+ g_print("File open error\n");
+ return;
+ }
+#endif
+
+ ret = legacy_player_set_pcm_extraction_mode(g_player[0], false, _audio_frame_decoded_cb_ex, &ret);
+ g_print(" ==> [Player_Test] player_set_audio_frame_decoded_cb_ex return: %d\n", ret);
+}
+
+static void set_pcm_spec()
+{
+ int ret;
+
+ ret = legacy_player_set_pcm_spec(g_player[0], "F32LE", 44100, 2);
+ g_print("[Player_Test] set_pcm_spec return: %d\n", ret);
+}
+
+static void get_stream_info()
+{
+ int w = 0;
+ int h = 0;
+
+ char *value = NULL;
+ legacy_player_get_content_info(g_player[0], PLAYER_CONTENT_INFO_ALBUM, &value);
+ g_print(" ==> [Player_Test] PLAYER_CONTENT_INFO_ALBUM: [%s ] \n", value);
+ legacy_player_get_content_info(g_player[0], PLAYER_CONTENT_INFO_ARTIST, &value);
+ g_print(" ==> [Player_Test] PLAYER_CONTENT_INFO_ARTIST: [%s ] \n", value);
+ legacy_player_get_content_info(g_player[0], PLAYER_CONTENT_INFO_AUTHOR, &value);
+ g_print(" ==> [Player_Test] PLAYER_CONTENT_INFO_AUTHOR: [%s ] \n", value);
+ legacy_player_get_content_info(g_player[0], PLAYER_CONTENT_INFO_GENRE, &value);
+ g_print(" ==> [Player_Test] PLAYER_CONTENT_INFO_GENRE: [%s ] \n", value);
+ legacy_player_get_content_info(g_player[0], PLAYER_CONTENT_INFO_TITLE, &value);
+ g_print(" ==> [Player_Test] PLAYER_CONTENT_INFO_TITLE: [%s ] \n", value);
+ void *album;
+ int size;
+ legacy_player_get_album_art(g_player[0], &album, &size);
+ g_print(" ==> [Player_Test] Album art : [ data : %p, size : %d ]\n", (unsigned int *)album, size);
+ if (value != NULL) {
+ free(value);
+ value = NULL;
+ }
+
+ int sample_rate;
+ int channel;
+ int bit_rate;
+ int fps, v_bit_rate;
+ legacy_player_get_audio_stream_info(g_player[0], &sample_rate, &channel, &bit_rate);
+ g_print(" ==> [Player_Test] Sample Rate: [%d ] , Channel: [%d ] , Bit Rate: [%d ] \n", sample_rate, channel, bit_rate);
+
+ legacy_player_get_video_stream_info(g_player[0], &fps, &v_bit_rate);
+ g_print(" ==> [Player_Test] fps: [%d ] , Bit Rate: [%d ] \n", fps, v_bit_rate);
+
+ char *audio_codec = NULL;
+ char *video_codec = NULL;
+ legacy_player_get_codec_info(g_player[0], &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;
+ }
+ legacy_player_get_video_size(g_player[0], &w, &h);
+ g_print(" ==> [Player_Test] Width: [%d ] , Height: [%d ] \n", w, h);
+}
+
+static void set_looping(bool looping)
+{
+ if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
+ if (legacy_player_set_looping(g_player[0], looping) != PLAYER_ERROR_NONE)
+ g_print("failed to set_looping\n");
+ } else {
+ int i = 0;
+ for (i = 0; i < g_handle_num; i++) {
+ if (legacy_player_set_looping(g_player[i], looping) != PLAYER_ERROR_NONE)
+ g_print("failed to set_looping\n");
+ }
+ }
+}
+
+static void get_looping(bool * looping)
+{
+ legacy_player_is_looping(g_player[0], looping);
+ g_print(" ==> [Player_Test] looping = %d\n", *looping);
+}
+
+static void change_surface(int option)
+{
+ player_display_type_e surface_type = 0;
+ int ret = PLAYER_ERROR_NONE;
+
+ switch (option) {
+ case 0:
+ /* X surface */
+ surface_type = PLAYER_DISPLAY_TYPE_OVERLAY;
+ g_print("change surface type to X\n");
+ break;
+#ifdef TIZEN_MOBILE
+ case 1:
+ /* EVAS surface */
+ surface_type = PLAYER_DISPLAY_TYPE_EVAS;
+ g_print("change surface type to EVAS\n");
+ break;
+#endif
+ case 2:
+ g_print("change surface type to NONE\n");
+ legacy_player_set_display(g_player[0], PLAYER_DISPLAY_TYPE_NONE, NULL);
+ break;
+ default:
+ g_print("invalid surface type\n");
+ return;
+ }
+
+ if (surface_type == g_current_surface_type) {
+ g_print("same with the previous surface type(%d)\n", g_current_surface_type);
+ return;
+ } else {
+ player_state_e player_state = PLAYER_STATE_NONE;
+ ret = legacy_player_get_state(g_player[0], &player_state);
+ if (ret)
+ g_print("failed to player_get_state(), ret(0x%x)\n", ret);
+
+ /* state check */
+ if (player_state == PLAYER_STATE_NONE || player_state == PLAYER_STATE_IDLE) {
+ reset_display();
+
+ if (surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
+ g_xid = g_eo_win;
+ ret = legacy_player_set_display(g_player[0], surface_type, GET_DISPLAY(g_xid));
+ } else {
+ int i = 0;
+ for (i = 0; i < g_handle_num; i++) {
+ /* Create evas image object for EVAS surface */
+ if (!g_eo[i]) {
+ g_eo[i] = create_image_object(g_eo_win);
+ evas_object_image_size_set(g_eo[i], 500, 500);
+ evas_object_image_fill_set(g_eo[i], 0, 0, 500, 500);
+ evas_object_resize(g_eo[i], 500, 500);
+ evas_object_move(g_eo[i], i * 20, i * 20);
+ }
+ ret = legacy_player_set_display(g_player[i], surface_type, g_eo[i]);
+ }
+ }
+ if (ret) {
+ g_print("failed to set display, surface_type(%d)\n", surface_type);
+ return;
+ }
+ g_current_surface_type = surface_type;
+ } else {
+ g_print("could not change surface type, current_state(%d)\n", player_state);
+ }
+ }
+ return;
+}
+
+static void set_display_mode(int mode)
+{
+ if (legacy_player_set_display_mode(g_player[0], mode) != PLAYER_ERROR_NONE)
+ g_print("failed to legacy_player_set_display_mode\n");
+}
+
+static void get_display_mode()
+{
+ player_display_mode_e mode;
+ legacy_player_get_display_mode(g_player[0], &mode);
+ g_print(" ==> [Player_Test] Display mode: [%d ] \n", mode);
+}
+
+static void set_display_rotation(int rotation)
+{
+ if (legacy_player_set_display_rotation(g_player[0], rotation) != PLAYER_ERROR_NONE)
+ g_print("failed to set_display_rotation\n");
+}
+
+static void get_display_rotation()
+{
+ player_display_rotation_e rotation = 0;
+ legacy_player_get_display_rotation(g_player[0], &rotation);
+ g_print(" ==> [Player_Test] X11 Display rotation: [%d ] \n", rotation);
+}
+
+static void set_display_visible(bool visible)
+{
+ if (legacy_player_set_display_visible(g_player[0], visible) != PLAYER_ERROR_NONE)
+ g_print("failed to player_set_x11_display_visible\n");
+}
+
+static void get_display_visible(bool * visible)
+{
+ legacy_player_is_display_visible(g_player[0], visible);
+ g_print(" ==> [Player_Test] X11 Display Visible = %d\n", *visible);
+}
+
+static void set_display_dst_roi(int x, int y, int w, int h)
+{
+#if 0
+ if (legacy_player_set_x11_display_dst_roi(g_player[0], x, y, w, h) != PLAYER_ERROR_NONE)
+ g_print("failed to player_set_x11_display_dst_roi\n");
+ else
+ g_print(" ==> [Player_Test] set X11 Display DST ROI (x:%d, y:%d, w:%d, h:%d)\n", x, y, w, h);
+#endif
+}
+
+static void get_display_dst_roi()
+{
+#if 0
+ int x = 0;
+ int y = 0;
+ int w = 0;
+ int h = 0;
+
+ if (legacy_player_get_x11_display_dst_roi(g_player[0], &x, &y, &w, &h) != PLAYER_ERROR_NONE)
+ g_print("failed to legacy_player_get_x11_display_dst_roi\n");
+ else
+ g_print(" ==> [Player_Test] got X11 Display DST ROI (x:%d, y:%d, w:%d, h:%d)\n", x, y, w, h);
+#endif
+}
+
+static void set_display_roi_mode(int mode)
+{
+#if 0
+ if (legacy_player_set_x11_display_roi_mode(g_player[0], (player_display_roi_mode_e) mode) != PLAYER_ERROR_NONE)
+ g_print("failed to legacy_player_set_x11_display_roi_mode\n");
+ else
+ g_print(" ==> [Player_Test] set X11 Display ROI mode (%d)\n", mode);
+#endif
+}
+
+static void get_display_roi_mode()
+{
+#if 0
+ player_display_roi_mode_e mode;
+ if (legacy_player_get_x11_display_roi_mode(g_player[0], &mode) != PLAYER_ERROR_NONE)
+ g_print("failed to legacy_player_get_x11_display_roi_mode\n");
+ else
+ g_print(" ==> [Player_Test] got X11 Display ROI mode (%d)\n", mode);
+#endif
+}
+
+static void set_display_src_crop(int x, int y, int w, int h)
+{
+#if 0
+ if (legacy_player_set_x11_display_src_crop(g_player[0], x, y, w, h) != PLAYER_ERROR_NONE)
+ g_print("failed to legacy_player_set_x11_display_src_crop\n");
+ else
+ g_print(" ==> [Player_Test] set X11 Display SRC CROP (x:%d, y:%d, w:%d, h:%d)\n", x, y, w, h);
+#endif
+}
+
+static void get_display_src_crop()
+{
+#if 0
+ int x = 0;
+ int y = 0;
+ int w = 0;
+ int h = 0;
+
+ if (legacy_player_get_x11_display_src_crop(g_player[0], &x, &y, &w, &h) != PLAYER_ERROR_NONE)
+ g_print("failed to legacy_player_get_x11_display_src_crop\n");
+ else
+ g_print(" ==> [Player_Test] got X11 Display SRC CROP (x:%d, y:%d, w:%d, h:%d)\n", x, y, w, h);
+#endif
+}
+
+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);
+ legacy_player_set_subtitle_path(g_player[0], g_subtitle_uri);
+}
+
+static void switch_subtitle(int index)
+{
+ char *lang_code = NULL;
+ if (legacy_player_select_track(g_player[0], PLAYER_STREAM_TYPE_TEXT, index) != PLAYER_ERROR_NONE)
+ g_print("legacy_player_select_track failed\n");
+
+ if (legacy_player_get_track_language_code(g_player[0], PLAYER_STREAM_TYPE_TEXT, index, &lang_code) == PLAYER_ERROR_NONE) {
+ g_print("selected track code %s\n", lang_code);
+ free(lang_code);
+ }
+}
+
+static void capture_video()
+{
+ if (legacy_player_capture_video(g_player[0], video_captured_cb, NULL) != PLAYER_ERROR_NONE)
+ g_print("failed to legacy_player_capture_video\n");
+}
+
+static void decoding_audio()
+{
+#if 0
+ int ret;
+ char *suffix, *dump_path;
+ GDateTime *time = g_date_time_new_now_local();
+
+ suffix = g_date_time_format(time, "%Y%m%d_%H%M%S.pcm");
+ dump_path = g_strjoin(NULL, PLAYER_TEST_DUMP_PATH_PREFIX, suffix, NULL);
+ g_pcm_fd = fopen(dump_path, "w+");
+ g_free(dump_path);
+ g_free(suffix);
+ g_date_time_unref(time);
+ if (!g_pcm_fd)
+ g_print("Can not create debug dump file");
+
+ ret = legacy_player_set_audio_frame_decoded_cb(g_player[0], 0, 0, audio_frame_decoded_cb, (void *)g_player[0]);
+ if (ret != PLAYER_ERROR_NONE)
+ g_print("legacy_player_set_audio_frame_decoded_cb is failed (errno = %d) \n", ret);
+
+#endif
+}
+
+static void set_audio_eq(int value)
+{
+ bool available = FALSE;
+ int index, min, max;
+
+ if (value) {
+ if (legacy_player_audio_effect_equalizer_is_available(g_player[0], &available) != PLAYER_ERROR_NONE)
+ g_print("failed to legacy_player_audio_effect_equalizer_is_available\n");
+
+ if (available) {
+ if ((legacy_player_audio_effect_get_equalizer_bands_count(g_player[0], &index) != PLAYER_ERROR_NONE) || (legacy_player_audio_effect_get_equalizer_level_range(g_player[0], &min, &max) != PLAYER_ERROR_NONE) || (legacy_player_audio_effect_set_equalizer_band_level(g_player[0], index / 2, max) != PLAYER_ERROR_NONE))
+ g_print("failed to legacy_player_audio_effect_set_equalizer_band_level index %d, level %d\n", index / 2, max);
+ }
+ }
+
+ else {
+ if (legacy_player_audio_effect_equalizer_clear(g_player[0]) != PLAYER_ERROR_NONE)
+ g_print("failed to legacy_player_audio_effect_equalizer_clear\n");
+ }
+
+}
+
+static void get_audio_eq()
+{
+ int index, min, max, value;
+ legacy_player_audio_effect_get_equalizer_bands_count(g_player[0], &index);
+ g_print(" ==> [Player_Test] eq bands count: [%d] \n", index);
+ legacy_player_audio_effect_get_equalizer_level_range(g_player[0], &min, &max);
+ g_print(" ==> [Player_Test] eq bands range: [%d~%d] \n", min, max);
+ legacy_player_audio_effect_get_equalizer_band_level(g_player[0], index / 2, &value);
+ g_print(" ==> [Player_Test] eq bands level: [%d] \n", value);
+ legacy_player_audio_effect_get_equalizer_band_frequency(g_player[0], 0, &value);
+ g_print(" ==> [Player_Test] eq bands frequency: [%d] \n", value);
+ legacy_player_audio_effect_get_equalizer_band_frequency_range(g_player[0], 0, &value);
+ g_print(" ==> [Player_Test] eq bands frequency range: [%d] \n", value);
+}
+
+void quit_program()
+{
+ int i = 0;
+
+ if (g_pcm_fd)
+ fclose(g_pcm_fd);
+
+ for (i = 0; i < g_handle_num; i++) {
+ if (g_player[i] != NULL) {
+ legacy_player_unprepare(g_player[i]);
+ legacy_player_destroy(g_player[i]);
+ g_player[i] = 0;
+ }
+ }
+ elm_exit();
+
+ if (g_audio_fmt)
+ media_format_unref(g_audio_fmt);
+
+ if (g_video_fmt)
+ media_format_unref(g_video_fmt);
+}
+
+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, "z", 1) == 0) {
+ g_menu_state = CURRENT_STATUS_SOUND_TYPE;
+ } else if (strncmp(cmd, "k", 1) == 0) {
+ g_menu_state = CURRENT_STATUS_SOUND_STREAM_INFO;
+ } 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, "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, "x", 1) == 0) {
+ g_menu_state = CURRENT_STATUS_DISPLAY_DST_ROI;
+ } else if (strncmp(cmd, "y", 1) == 0) {
+ get_display_dst_roi();
+ } else if (strncmp(cmd, "M", 1) == 0) {
+ g_menu_state = CURRENT_STATUS_DISPLAY_ROI_MODE;
+ } else if (strncmp(cmd, "N", 1) == 0) {
+ get_display_roi_mode();
+ } else if (strncmp(cmd, "F", 1) == 0) {
+ g_menu_state = CURRENT_STATUS_DISPLAY_SRC_CROP;
+ } else if (strncmp(cmd, "G", 1) == 0) {
+ get_display_src_crop();
+ } 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, "q", 1) == 0) {
+ quit_pushing = TRUE;
+ quit_program();
+ } else if (strncmp(cmd, "E", 1) == 0) {
+ g_menu_state = CURRENT_STATUS_AUDIO_EQUALIZER;
+ } else if (strncmp(cmd, "H", 1) == 0) {
+ get_audio_eq();
+ } else {
+ g_print("unknown menu \n");
+ }
+ } else if (len == 2) {
+ if (strncmp(cmd, "pr", 2) == 0) {
+ _player_prepare(FALSE); /* sync */
+ } else if (strncmp(cmd, "pa", 2) == 0) {
+ _player_prepare(TRUE); /* async */
+ } else if (strncmp(cmd, "un", 2) == 0) {
+ _player_unprepare();
+ } else if (strncmp(cmd, "dt", 2) == 0) {
+ _player_destroy();
+ } else if (strncmp(cmd, "sp", 2) == 0) {
+ _player_set_progressive_download();
+ } else if (strncmp(cmd, "mp", 2) == 0) {
+ g_memory_playback = (g_memory_playback ? FALSE : TRUE);
+ g_print("memory playback = %d\n", g_memory_playback);
+ } else if (strncmp(cmd, "ds", 2) == 0) {
+ g_menu_state = CURRENT_STATUS_DISPLAY_SURFACE_CHANGE;
+ } else if (strncmp(cmd, "nb", 2) == 0) {
+ g_menu_state = CURRENT_STATUS_HANDLE_NUM;
+ } else if (strncmp(cmd, "tr", 2) == 0) {
+ g_menu_state = CURRENT_STATUS_PLAYBACK_RATE;
+ } else if (strncmp(cmd, "ss", 2) == 0) {
+ g_menu_state = CURRENT_STATUS_SWITCH_SUBTITLE;
+ } else if (strncmp(cmd, "X3", 2) == 0) {
+ audio_frame_decoded_cb_ex();
+ } else if (strncmp(cmd, "X4", 2) == 0) {
+ set_pcm_spec();
+ } else if (strncmp(cmd, "dp", 2) == 0) {
+ get_download_progress();
+ } 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] \t", MMTS_SAMPLELIST_INI_DEFAULT_PATH);
+ g_print("nb. num. of handles \n");
+ 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("pa. Prepare async \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 \t");
+ g_print("dt. Destroy \n");
+ g_print("[State] S. Player State \n");
+ g_print("[ volume ] f. Set Volume\t");
+ g_print("g. Get Volume\t");
+ g_print("z. Set Sound type\t");
+ g_print("k. Set Sound Stream Info.\t");
+ g_print("[ mute ] h. Set Mute\t");
+ g_print("i. Get Mute\n");
+ g_print("[audio eq] E. Set Audio EQ\t");
+ g_print("H. Get Audio EQ\n");
+ g_print("[position] j. Set Position \t");
+ g_print("l. Get Position\n");
+ g_print("[trick] tr. set playback rate\n");
+ g_print("[duration] m. Get Duration\n");
+ g_print("[buffering] dp. Get Download Progress\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("[display] v. Set display visible\t");
+ g_print("w. Get display visible\n");
+ g_print("[display] ds. Change display surface type\n");
+ g_print("[x display] r. Set display mode\t");
+ g_print("s. Get display mode\n");
+ g_print("[x display] t. Set display Rotation\t");
+ g_print("[Track] tl. Get Track language info(single only)\n");
+ g_print("[subtitle] A. Set(or change) subtitle path\n");
+ g_print("[subtitle] ss. Select(or change) subtitle track\n");
+ g_print("[Video Capture] C. Capture \n");
+ g_print("[etc] sp. Set Progressive Download\t");
+ g_print("mp. memory playback\n");
+ g_print("[audio_frame_decoded_cb_ex] X3. (input) set audio_frame_decoded_cb_ex callback \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_HANDLE_NUM) {
+ g_print("*** input number of handles.(recommended only for EVAS surface)\n");
+ } 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_SOUND_TYPE) {
+ g_print("*** input sound type.(0:SYSTEM 1:NOTIFICATION 2:ALARM 3:RINGTONE 4:MEDIA 5:CALL 6:VOIP 7:FIXED)\n");
+ } else if (g_menu_state == CURRENT_STATUS_SOUND_STREAM_INFO) {
+ g_print("*** input sound stream type.(0:MEDIA 1:SYSTEM 2:ALARM 3:NOTIFICATION 4:RINGTONE 5:CALL 6:VOIP)\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_LOOPING) {
+ g_print("*** input looping value.(0: Not Looping, 1: Looping) \n");
+ } else if (g_menu_state == CURRENT_STATUS_DISPLAY_SURFACE_CHANGE) {
+ g_print("*** input display surface type.(0: X surface, 1: EVAS surface) \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, 4: ORIGIN_OR_LETTER, 5: ROI) \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_DISPLAY_ROI_MODE) {
+ g_print("*** input display roi mode.(0: FULL_SCREEN, 1: LETTER BOX)\n");
+ } else if (g_menu_state == CURRENT_STATUS_DISPLAY_DST_ROI) {
+ g_print("*** input display roi value sequentially.(x, y, w, h)\n");
+ } else if (g_menu_state == CURRENT_STATUS_DISPLAY_SRC_CROP) {
+ g_print("*** input display source crop value sequentially.(x, y, w, h)\n");
+ } else if (g_menu_state == CURRENT_STATUS_SUBTITLE_FILENAME) {
+ g_print(" *** input subtitle file path.\n");
+ } else if (g_menu_state == CURRENT_STATUS_AUDIO_EQUALIZER) {
+ g_print(" *** input audio eq value.(0: UNSET, 1: SET) \n");
+ } else if (g_menu_state == CURRENT_STATUS_PLAYBACK_RATE) {
+ g_print(" *** input playback rate.(-5.0 ~ 5.0)\n");
+ } else if (g_menu_state == CURRENT_STATUS_SWITCH_SUBTITLE) {
+ int count = 0, cur_index = 0;
+ int ret = 0;
+
+ ret = legacy_player_get_track_count(g_player[0], PLAYER_STREAM_TYPE_TEXT, &count);
+ if (ret != PLAYER_ERROR_NONE)
+ g_print("legacy_player_get_track_count fail!!!!\n");
+ else if (count) {
+ g_print("Total subtitle tracks = %d \n", count);
+ legacy_player_get_current_track(g_player[0], PLAYER_STREAM_TYPE_TEXT, &cur_index);
+ g_print("Current index = %d \n", cur_index);
+ g_print(" *** input correct index 0 to %d\n:", (count - 1));
+ } else
+ g_print("no track\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_HANDLE_NUM:
+ {
+ int num_handle = atoi(cmd);
+ if (0 >= num_handle || num_handle > MAX_HANDLE)
+ g_print("not supported this number for handles(%d)\n", num_handle);
+ else
+ g_handle_num = num_handle;
+
+ reset_menu_state();
+ }
+ 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_SOUND_TYPE:
+ {
+ int type = atoi(cmd);
+ set_sound_type(type);
+ reset_menu_state();
+ }
+ break;
+ case CURRENT_STATUS_SOUND_STREAM_INFO:
+ {
+ int type = atoi(cmd);
+ set_sound_stream_info(type);
+ 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_LOOPING:
+ {
+ int looping = atoi(cmd);
+ set_looping(looping);
+ reset_menu_state();
+ }
+ break;
+ case CURRENT_STATUS_DISPLAY_SURFACE_CHANGE:
+ {
+ int type = atoi(cmd);
+ change_surface(type);
+ 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_DISPLAY_DST_ROI:
+ {
+ int value = atoi(cmd);
+ static int roi_x = 0;
+ static int roi_y = 0;
+ static int roi_w = 0;
+ static int roi_h = 0;
+ static int cnt = 0;
+ switch (cnt) {
+ case 0:
+ roi_x = value;
+ cnt++;
+ break;
+ case 1:
+ roi_y = value;
+ cnt++;
+ break;
+ case 2:
+ roi_w = value;
+ cnt++;
+ break;
+ case 3:
+ cnt = 0;
+ roi_h = value;
+ set_display_dst_roi(roi_x, roi_y, roi_w, roi_h);
+ roi_x = roi_y = roi_w = roi_h = 0;
+ reset_menu_state();
+ break;
+ default:
+ break;
+ }
+ }
+ break;
+ case CURRENT_STATUS_DISPLAY_SRC_CROP:
+ {
+ int value = atoi(cmd);
+ static int crop_x = 0;
+ static int crop_y = 0;
+ static int crop_w = 0;
+ static int crop_h = 0;
+ static int crop_cnt = 0;
+ switch (crop_cnt) {
+ case 0:
+ crop_x = value;
+ crop_cnt++;
+ break;
+ case 1:
+ crop_y = value;
+ crop_cnt++;
+ break;
+ case 2:
+ crop_w = value;
+ crop_cnt++;
+ break;
+ case 3:
+ crop_cnt = 0;
+ crop_h = value;
+ set_display_src_crop(crop_x, crop_y, crop_w, crop_h);
+ crop_x = crop_y = crop_w = crop_h = 0;
+ reset_menu_state();
+ break;
+ default:
+ break;
+ }
+ }
+ break;
+ case CURRENT_STATUS_DISPLAY_ROI_MODE:
+ {
+ int value = atoi(cmd);
+ set_display_roi_mode(value);
+ reset_menu_state();
+ }
+ break;
+ case CURRENT_STATUS_SUBTITLE_FILENAME:
+ {
+ input_subtitle_filename(cmd);
+ reset_menu_state();
+ }
+ break;
+ case CURRENT_STATUS_AUDIO_EQUALIZER:
+ {
+ int value = atoi(cmd);
+ set_audio_eq(value);
+ reset_menu_state();
+ }
+ break;
+ case CURRENT_STATUS_PLAYBACK_RATE:
+ {
+ float rate = atof(cmd);
+ set_playback_rate(rate);
+ reset_menu_state();
+ }
+ break;
+ case CURRENT_STATUS_SWITCH_SUBTITLE:
+ {
+ int index = atoi(cmd);
+ switch_subtitle(index);
+ reset_menu_state();
+ }
+ break;
+ }
+ g_timeout_add(100, timeout_menu_display, 0);
+}
+
+gboolean input(GIOChannel *channel)
+{
+ gchar buf[MAX_STRING_LEN];
+ gsize read;
+ GError *error = NULL;
+
+ g_io_channel_read_chars(channel, buf, MAX_STRING_LEN, &read, &error);
+ 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_channel_set_flags(stdin_channel, G_IO_FLAG_NONBLOCK, NULL);
+ 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);
+}
--- /dev/null
+
+# Package Information for pkg-config
+
+prefix=@PREFIX@
+exec_prefix=/usr
+libdir=@LIB_INSTALL_DIR@
+includedir=/usr/include/media
+
+Name: @PC_NAME@
+Description: @PACKAGE_DESCRIPTION@
+Version: @VERSION@
+Requires: @PC_REQUIRED@
+Libs: -L${libdir} @PC_LDFLAGS@
+Cflags: -I${includedir}
+
+++ /dev/null
-
-# 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}
-
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+SET(service "muse")
+SET(submodule "player")
+
+SET(dependents "dlog mused mm-common libtbm capi-system-info")
+SET(fw_name "${service}-${submodule}")
+
+PROJECT(${fw_name})
+
+SET(CMAKE_INSTALL_PREFIX /usr)
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+
+SET(INC_DIR include)
+INCLUDE_DIRECTORIES(${INC_DIR})
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${fw_name} REQUIRED ${dependents})
+FOREACH(flag ${${fw_name}_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "-I./include -I../legacy/include ${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror -Wno-deprecated -Wno-deprecated-declarations")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+
+IF("${ARCH}" STREQUAL "arm")
+ ADD_DEFINITIONS("-DTARGET")
+ENDIF("${ARCH}" STREQUAL "arm")
+
+IF(WAYLAND_SUPPORT)
+ ADD_DEFINITIONS("-DHAVE_WAYLAND")
+ENDIF(WAYLAND_SUPPORT)
+IF(X11_SUPPORT)
+ ADD_DEFINITIONS("-DHAVE_X11")
+ENDIF(X11_SUPPORT)
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+ADD_DEFINITIONS("-DTIZEN_DEBUG")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${LIB_INSTALL_DIR}")
+
+aux_source_directory(src MUSED_SOURCES)
+ADD_LIBRARY(${fw_name} SHARED ${MUSED_SOURCES})
+
+TARGET_LINK_LIBRARIES(${fw_name} legacy-player ${${fw_name}_LDFLAGS})
+
+SET_TARGET_PROPERTIES(${fw_name}
+ PROPERTIES
+ VERSION ${FULLVER}
+ SOVERSION ${MAJORVER}
+ CLEAN_DIRECT_OUTPUT 1
+)
+
+INSTALL(TARGETS ${fw_name} DESTINATION ${LIB_INSTALL_DIR})
+INSTALL(
+ DIRECTORY ${INC_DIR}/ DESTINATION include/media
+ FILES_MATCHING
+ PATTERN "*_private.h" EXCLUDE
+ PATTERN "${INC_DIR}/*.h"
+ )
+
--- /dev/null
+/*
+* 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_MUSE_PLAYER_H__
+#define __TIZEN_MEDIA_MUSE_PLAYER_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "TIZEN_N_PLAYER"
+
+#define MUSE_PLAYER_HEAD_GAP(api) ((api)/(1000)+(1))*(1000)
+
+typedef enum {
+ MUSE_PLAYER_API_CREATE = API_CREATE,
+ MUSE_PLAYER_API_DESTROY = API_DESTROY,
+ MUSE_PLAYER_API_PREPARE,
+ MUSE_PLAYER_API_PREPARE_ASYNC,
+ MUSE_PLAYER_API_UNPREPARE,
+ MUSE_PLAYER_API_SET_URI,
+ MUSE_PLAYER_API_START,
+ MUSE_PLAYER_API_STOP,
+ MUSE_PLAYER_API_PAUSE,
+ MUSE_PLAYER_API_SET_MEMORY_BUFFER,
+ MUSE_PLAYER_API_DEINIT_MEMORY_BUFFER,
+ MUSE_PLAYER_API_GET_STATE,
+ MUSE_PLAYER_API_SET_VOLUME,
+ MUSE_PLAYER_API_GET_VOLUME,
+ MUSE_PLAYER_API_SET_SOUND_TYPE,
+ MUSE_PLAYER_API_SET_AUDIO_POLICY_INFO,
+ MUSE_PLAYER_API_SET_AUDIO_LATENCY_MODE,
+ MUSE_PLAYER_API_GET_AUDIO_LATENCY_MODE,
+ MUSE_PLAYER_API_SET_PLAY_POSITION,
+ MUSE_PLAYER_API_GET_PLAY_POSITION,
+ MUSE_PLAYER_API_SET_MUTE,
+ MUSE_PLAYER_API_IS_MUTED,
+ MUSE_PLAYER_API_SET_LOOPING,
+ MUSE_PLAYER_API_IS_LOOPING,
+ MUSE_PLAYER_API_GET_DURATION,
+ MUSE_PLAYER_API_SET_DISPLAY,
+ MUSE_PLAYER_API_SET_DISPLAY_MODE,
+ MUSE_PLAYER_API_GET_DISPLAY_MODE,
+ MUSE_PLAYER_API_SET_PLAYBACK_RATE,
+ MUSE_PLAYER_API_SET_DISPLAY_ROTATION,
+ MUSE_PLAYER_API_GET_DISPLAY_ROTATION,
+ MUSE_PLAYER_API_SET_DISPLAY_VISIBLE,
+ MUSE_PLAYER_API_IS_DISPLAY_VISIBLE,
+ MUSE_PLAYER_API_RESIZE_VIDEO_RENDER_RECT,
+ MUSE_PLAYER_API_GET_CONTENT_INFO,
+ MUSE_PLAYER_API_GET_CODEC_INFO,
+ MUSE_PLAYER_API_GET_AUDIO_STREAM_INFO,
+ MUSE_PLAYER_API_GET_VIDEO_STREAM_INFO,
+ MUSE_PLAYER_API_GET_VIDEO_SIZE,
+ MUSE_PLAYER_API_GET_ALBUM_ART,
+ MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_BANDS_COUNT,
+ MUSE_PLAYER_API_AUDIO_EFFECT_SET_EQUALIZER_ALL_BANDS,
+ MUSE_PLAYER_API_AUDIO_EFFECT_SET_EQUALIZER_BAND_LEVEL,
+ MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_BAND_LEVEL,
+ MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_LEVEL_RANGE,
+ MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_BAND_FREQUENCY,
+ MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_BAND_FREQUENCY_RANGE,
+ MUSE_PLAYER_API_AUDIO_EFFECT_EQUALIZER_CLEAR,
+ MUSE_PLAYER_API_AUDIO_EFFECT_EQUALIZER_IS_AVAILABLE,
+ MUSE_PLAYER_API_SET_PROGRESSIVE_DOWNLOAD_PATH,
+ MUSE_PLAYER_API_GET_PROGRESSIVE_DOWNLOAD_STATUS,
+ MUSE_PLAYER_API_CAPTURE_VIDEO,
+ MUSE_PLAYER_API_SET_STREAMING_COOKIE,
+ MUSE_PLAYER_API_SET_STREAMING_USER_AGENT,
+ MUSE_PLAYER_API_GET_STREAMING_DOWNLOAD_PROGRESS,
+ MUSE_PLAYER_API_SET_SUBTITLE_PATH,
+ MUSE_PLAYER_API_SET_SUBTITLE_POSITION_OFFSET,
+ MUSE_PLAYER_API_PUSH_MEDIA_STREAM,
+ MUSE_PLAYER_API_SET_MEDIA_STREAM_INFO,
+ MUSE_PLAYER_API_SET_CALLBACK,
+ MUSE_PLAYER_API_MEDIA_PACKET_FINALIZE_CB,
+ MUSE_PLAYER_API_SET_MEDIA_STREAM_BUFFER_MAX_SIZE,
+ MUSE_PLAYER_API_GET_MEDIA_STREAM_BUFFER_MAX_SIZE,
+ MUSE_PLAYER_API_SET_MEDIA_STREAM_BUFFER_MIN_THRESHOLD,
+ MUSE_PLAYER_API_GET_MEDIA_STREAM_BUFFER_MIN_THRESHOLD,
+ MUSE_PLAYER_API_GET_TRACK_COUNT,
+ MUSE_PLAYER_API_GET_CURRENT_TRACK,
+ MUSE_PLAYER_API_SELECT_TRACK,
+ MUSE_PLAYER_API_GET_TRACK_LANGUAGE_CODE,
+ MUSE_PLAYER_API_SET_PCM_EXTRACTION_MODE,
+ MUSE_PLAYER_API_SET_PCM_SPEC,
+ MUSE_PLAYER_API_SET_STREAMING_PLAYBACK_RATE,
+ MUSE_PLAYER_API_MAX
+} muse_player_api_e;
+
+typedef enum {
+ MUSE_PLAYER_CB_EVENT = MUSE_PLAYER_HEAD_GAP(MUSE_PLAYER_API_MAX),
+ MUSE_PLAYER_CB_MAX
+} muse_player_cb_e;
+
+/**
+ * @brief Enumeration for the muse player events.
+ * @remark This enum should be sync with _player_event_e.
+ */
+typedef enum {
+ MUSE_PLAYER_EVENT_TYPE_PREPARE,
+ MUSE_PLAYER_EVENT_TYPE_COMPLETE,
+ MUSE_PLAYER_EVENT_TYPE_INTERRUPT,
+ MUSE_PLAYER_EVENT_TYPE_ERROR,
+ MUSE_PLAYER_EVENT_TYPE_BUFFERING,
+ MUSE_PLAYER_EVENT_TYPE_SUBTITLE,
+ MUSE_PLAYER_EVENT_TYPE_CAPTURE,
+ MUSE_PLAYER_EVENT_TYPE_SEEK,
+ MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME,
+ MUSE_PLAYER_EVENT_TYPE_AUDIO_FRAME,
+ MUSE_PLAYER_EVENT_TYPE_VIDEO_FRAME_RENDER_ERROR,
+ MUSE_PLAYER_EVENT_TYPE_PD,
+ MUSE_PLAYER_EVENT_TYPE_SUPPORTED_AUDIO_EFFECT,
+ MUSE_PLAYER_EVENT_TYPE_SUPPORTED_AUDIO_EFFECT_PRESET,
+ MUSE_PLAYER_EVENT_TYPE_MISSED_PLUGIN,
+#ifdef _PLAYER_FOR_PRODUCT
+ MUSE_PLAYER_EVENT_TYPE_IMAGE_BUFFER,
+ MUSE_PLAYER_EVENT_TYPE_SELECTED_SUBTITLE_LANGUAGE,
+#endif
+ MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS,
+ MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS,
+ MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO,
+ MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO,
+ MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK,
+ MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK,
+ MUSE_PLAYER_EVENT_TYPE_AUDIO_STREAM_CHANGED,
+ MUSE_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED,
+ MUSE_PLAYER_EVENT_TYPE_NUM
+}muse_player_event_e;
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //__TIZEN_MEDIA_MUSE_PLAYER_H__
--- /dev/null
+/*
+* 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_MUSE_PLAYER_MSG_H__
+#define __TIZEN_MEDIA_MUSE_PLAYER_MSG_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <tbm_bufmgr.h>
+#include <media_packet.h>
+#include <media_format.h>
+#include <muse_core_ipc.h>
+#include <muse_core_msg_json.h>
+
+typedef int32_t INT;
+typedef int64_t INT64;
+typedef intptr_t POINTER;
+typedef double DOUBLE;
+typedef const char* STRING;
+
+typedef enum {
+ PUSH_MEDIA_BUF_TYPE_TBM,
+ PUSH_MEDIA_BUF_TYPE_MSG,
+ PUSH_MEDIA_BUF_TYPE_RAW
+} push_media_buf_type_e;
+
+typedef struct _player_push_media_msg_type{
+ push_media_buf_type_e buf_type;
+ uint64_t size;
+ uint64_t pts;
+ media_format_mimetype_e mimetype;
+ media_buffer_flags_e flags;
+ tbm_key key;
+}player_push_media_msg_type;
+
+typedef struct {
+ int type;
+ unsigned int wl_surface_id;
+ int wl_window_x;
+ int wl_window_y;
+ int wl_window_width;
+ int wl_window_height;
+}wl_win_msg_type;
+
+/**
+ * @brief Get value from Message.
+ * @remarks Does NOT guarantee thread safe.
+ * @param[out] param the name of param is key, must be local variable. never be pointer.
+ * @param[in] buf string of message buffer. has key and value
+ */
+#define player_msg_get(param, buf) \
+ muse_core_msg_json_deserialize(#param, buf, NULL, ¶m, NULL, MUSE_TYPE_ANY)
+
+/**
+ * @brief Get value from Message.
+ * @remarks Does NOT guarantee thread safe.
+ * @param[out] param the name of param is key, must be local variable. never be pointer.
+ * @param[in] buf string of message buffer. has key and value
+ * @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
+ */
+#define player_msg_get_type(param, buf, type) \
+ muse_core_msg_json_deserialize(#param, buf, NULL, ¶m, NULL, MUSE_TYPE_##type)
+
+/**
+ * @brief Get value from Message.
+ * @remarks Does NOT guarantee thread safe.
+ * @param[out] param the name of param is key, must be local pointer variable.
+ * @param[in] buf string of message buffer. has key and value
+ */
+#define player_msg_get_string(param, buf) \
+ muse_core_msg_json_deserialize(#param, buf, NULL, param, NULL, MUSE_TYPE_ANY)
+
+/**
+ * @brief Get value from Message.
+ * @remarks Does NOT guarantee thread safe.
+ * @param[out] param the name of param is key, must be local pointer variable.
+ * @param[in] buf string of message buffer. has key and value
+ */
+#define player_msg_get_array(param, buf) \
+ muse_core_msg_json_deserialize(#param, buf, NULL, param, NULL, MUSE_TYPE_ANY)
+
+/**
+ * @brief Get value from Message.
+ * @remarks Does NOT guarantee thread safe.
+ * @param[out] param the name of param is key, must be local variable. never be pointer.
+ * @param[in] buf string of message buffer. has key and value
+ * @param[in/out] len size of buffer. After retrun len is set parsed length.
+ * @param[out] e the error number.
+ */
+#define player_msg_get_error_e(param, buf, len, e) \
+ muse_core_msg_json_deserialize(#param, buf, &len, ¶m, &e, MUSE_TYPE_INT)
+
+/**
+ * @brief Create and send message. Wait for server result.
+ * @remarks Does NOT guarantee thread safe.
+ * @param[in] api The enum of module API.
+ * @param[in] player The handle of capi media player.
+ * @param[out] retbuf The buffer of return message. Must be char pointer.
+ * @param[out] ret The return value from server.
+ */
+#define player_msg_send(api, player, retbuf, ret) \
+ do{ \
+ char *__sndMsg__; \
+ int __len__; \
+ int __fd__; \
+ int __timeout__ = _get_api_timeout(player, api); \
+ if(CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
+ else {ret = PLAYER_ERROR_INVALID_STATE;break;} \
+ __sndMsg__ = muse_core_msg_json_factory_new(api, \
+ 0); \
+ __len__ = muse_core_ipc_send_msg(__fd__, __sndMsg__); \
+ if (__len__ <= 0) { \
+ LOGE("sending message failed"); \
+ ret = PLAYER_ERROR_INVALID_OPERATION; \
+ } else \
+ ret = wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, __timeout__); \
+ muse_core_msg_json_factory_free(__sndMsg__); \
+ }while(0)
+
+/**
+ * @brief Create and send message. Wait for server result.
+ * @remarks Does NOT guarantee thread safe.
+ * @param[in] api The enum of module API.
+ * @param[in] player The handle of capi media player.
+ * @param[out] retbuf The buffer of return message. Must be char pointer.Must free after use.
+ * @param[out] ret The return value from server.
+ * @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
+ * @param[in] param the name of param is key, must be local variable. never be pointer.
+ */
+#define player_msg_send1(api, player, retbuf, ret, type, param) \
+ do{ \
+ char *__sndMsg__; \
+ int __len__; \
+ int __fd__; \
+ int __timeout__ = _get_api_timeout(player, api); \
+ type __value__ = (type)param; \
+ if(CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
+ else {ret = PLAYER_ERROR_INVALID_STATE;break;} \
+ __sndMsg__ = muse_core_msg_json_factory_new(api, \
+ MUSE_TYPE_##type, #param, __value__, \
+ 0); \
+ __len__ = muse_core_ipc_send_msg(__fd__, __sndMsg__); \
+ if (__len__ <= 0) { \
+ LOGE("sending message failed"); \
+ ret = PLAYER_ERROR_INVALID_OPERATION; \
+ } else \
+ ret = wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, __timeout__); \
+ muse_core_msg_json_factory_free(__sndMsg__); \
+ }while(0)
+
+/**
+ * @brief Create and send message. Wait for server result.
+ * @remarks Does NOT guarantee thread safe.
+ * @param[in] api The enum of module API.
+ * @param[in] player The handle of capi media player.
+ * @param[out] retbuf The buffer of return message. Must be char pointer.Must free after use.
+ * @param[out] ret The return value from server.
+ * @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
+ * @param[in] param# the name of param is key, must be local variable. never be pointer.
+ */
+#define player_msg_send2(api, player, retbuf, ret, type1, param1, type2, param2) \
+ do{ \
+ char *__sndMsg__; \
+ int __len__; \
+ int __fd__; \
+ int __timeout__ = _get_api_timeout(player, api); \
+ type1 __value1__ = (type1)param1; \
+ type2 __value2__ = (type2)param2; \
+ if(CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
+ else {ret = PLAYER_ERROR_INVALID_STATE;break;} \
+ __sndMsg__ = muse_core_msg_json_factory_new(api, \
+ MUSE_TYPE_##type1, #param1, __value1__, \
+ MUSE_TYPE_##type2, #param2, __value2__, \
+ 0); \
+ __len__ = muse_core_ipc_send_msg(__fd__, __sndMsg__); \
+ if (__len__ <= 0) { \
+ LOGE("sending message failed"); \
+ ret = PLAYER_ERROR_INVALID_OPERATION; \
+ } else \
+ ret = wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, __timeout__); \
+ muse_core_msg_json_factory_free(__sndMsg__); \
+ }while(0)
+
+/**
+ * @brief Create and send message. Wait for server result.
+ * @remarks Does NOT guarantee thread safe.
+ * @param[in] api The enum of module API.
+ * @param[in] player The handle of capi media player.
+ * @param[out] retbuf The buffer of return message. Must be char pointer.Must free after use.
+ * @param[out] ret The return value from server.
+ * @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
+ * @param[in] param# the name of param is key, must be local variable. never be pointer.
+ */
+#define player_msg_send3(api, player, retbuf, ret, type1, param1, type2, param2, type3, param3) \
+ do{ \
+ char *__sndMsg__; \
+ int __len__; \
+ int __fd__; \
+ int __timeout__ = _get_api_timeout(player, api); \
+ type1 __value1__ = (type1)param1; \
+ type2 __value2__ = (type2)param2; \
+ type3 __value3__ = (type3)param3; \
+ if(CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
+ else {ret = PLAYER_ERROR_INVALID_STATE;break;} \
+ __sndMsg__ = muse_core_msg_json_factory_new(api, \
+ MUSE_TYPE_##type1, #param1, __value1__, \
+ MUSE_TYPE_##type2, #param2, __value2__, \
+ MUSE_TYPE_##type3, #param3, __value3__, \
+ 0); \
+ __len__ = muse_core_ipc_send_msg(__fd__, __sndMsg__); \
+ if (__len__ <= 0) { \
+ LOGE("sending message failed"); \
+ ret = PLAYER_ERROR_INVALID_OPERATION; \
+ } else \
+ ret = wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, __timeout__); \
+ muse_core_msg_json_factory_free(__sndMsg__); \
+ }while(0)
+
+/**
+ * @brief Create and send message. Wait for server result.
+ * @remarks Does NOT guarantee thread safe.
+ * @param[in] api The enum of module API.
+ * @param[in] player The handle of capi media player.
+ * @param[out] retbuf The buffer of return message. Must be char pointer.Must free after use.
+ * @param[out] ret The return value from server.
+ * @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
+ * @param[in] param# the name of param is key, must be local variable. never be pointer.
+ */
+#define player_msg_send6(api, player, retbuf, ret, type1, param1, type2, param2, type3, param3, type4, param4, type5, param5, type6, param6) \
+ do{ \
+ char *__sndMsg__; \
+ int __len__; \
+ int __fd__; \
+ int __timeout__ = _get_api_timeout(player, api); \
+ type1 __value1__ = (type1)param1; \
+ type2 __value2__ = (type2)param2; \
+ type3 __value3__ = (type3)param3; \
+ type4 __value4__ = (type4)param4; \
+ type5 __value5__ = (type5)param5; \
+ type6 __value6__ = (type6)param6; \
+ if(CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
+ else {ret = PLAYER_ERROR_INVALID_STATE;break;} \
+ __sndMsg__ = muse_core_msg_json_factory_new(api, \
+ MUSE_TYPE_##type1, #param1, __value1__, \
+ MUSE_TYPE_##type2, #param2, __value2__, \
+ MUSE_TYPE_##type3, #param3, __value3__, \
+ MUSE_TYPE_##type4, #param4, __value4__, \
+ MUSE_TYPE_##type5, #param5, __value5__, \
+ MUSE_TYPE_##type6, #param6, __value6__, \
+ 0); \
+ __len__ = muse_core_ipc_send_msg(__fd__, __sndMsg__); \
+ if (__len__ <= 0) { \
+ LOGE("sending message failed"); \
+ ret = PLAYER_ERROR_INVALID_OPERATION; \
+ } else \
+ ret = wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, __timeout__); \
+ muse_core_msg_json_factory_free(__sndMsg__); \
+ }while(0)
+
+/**
+ * @brief Create and send message. Wait for server result.
+ * @remarks Does NOT guarantee thread safe.
+ * @param[in] api The enum of module API.
+ * @param[in] player The handle of capi media player.
+ * @param[out] retbuf The buffer of return message. Must be char pointer.Must free after use.
+ * @param[out] ret The return value from server.
+ * @param[in] param the name of param is key, must be local array/pointer variable.
+ * @param[in] length The size of array.
+ * @param[in] datum_size The size of a array's datum.
+ */
+#define player_msg_send_array(api, player, retbuf, ret, param, length, datum_size) \
+ do{ \
+ char *__sndMsg__; \
+ int __len__; \
+ int __fd__; \
+ int __timeout__ = _get_api_timeout(player, api); \
+ int *__value__ = (int *)param; \
+ if(CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
+ else {ret = PLAYER_ERROR_INVALID_STATE;break;} \
+ __sndMsg__ = muse_core_msg_json_factory_new(api, \
+ MUSE_TYPE_INT, #length, length, \
+ MUSE_TYPE_ARRAY, #param, \
+ datum_size == sizeof(int)? length : \
+ length / sizeof(int) + (length % sizeof(int)?1:0), \
+ __value__, \
+ 0); \
+ __len__ = muse_core_ipc_send_msg(__fd__, __sndMsg__); \
+ if (__len__ <= 0) { \
+ LOGE("sending message failed"); \
+ ret = PLAYER_ERROR_INVALID_OPERATION; \
+ } else \
+ ret = wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, __timeout__); \
+ muse_core_msg_json_factory_free(__sndMsg__); \
+ }while(0)
+
+/**
+ * @brief Create and send message. Wait for server result.
+ * @remarks Does NOT guarantee thread safe.
+ * @param[in] api The enum of module API.
+ * @param[in] player The handle of capi media player.
+ * @param[out] retbuf The buffer of return message. Must be char pointer.Must free after use.
+ * @param[out] ret The return value from server.
+ * @param[in] param# the name of param is key, must be local array/pointer variable.
+ * @param[in] length# The size of array.
+ * @param[in] datum_size# The size of a array's datum.
+ */
+#define player_msg_send_array2(api, player, retbuf, ret, param1, length1, datum_size1, param2, length2, datum_size2) \
+ do{ \
+ char *__sndMsg__; \
+ int __len__; \
+ int __fd__; \
+ int __timeout__ = _get_api_timeout(player, api); \
+ int *__value1__ = (int *)param1; \
+ int *__value2__ = (int *)param2; \
+ if(CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
+ else {ret = PLAYER_ERROR_INVALID_STATE;break;} \
+ __sndMsg__ = muse_core_msg_json_factory_new(api, \
+ MUSE_TYPE_INT, #length1, length1, \
+ MUSE_TYPE_ARRAY, #param1, \
+ datum_size1 == sizeof(int)? length1 : \
+ length1 / sizeof(int) + (length1 % sizeof(int)?1:0), \
+ __value1__, \
+ MUSE_TYPE_INT, #length2, length2, \
+ MUSE_TYPE_ARRAY, #param2, \
+ datum_size2 == sizeof(int)? length2 : \
+ length2 / sizeof(int) + (length2 % sizeof(int)?1:0), \
+ __value2__, \
+ 0); \
+ __len__ = muse_core_ipc_send_msg(__fd__, __sndMsg__); \
+ if (__len__ <= 0) { \
+ LOGE("sending message failed"); \
+ ret = PLAYER_ERROR_INVALID_OPERATION; \
+ } else \
+ ret = wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, __timeout__); \
+ muse_core_msg_json_factory_free(__sndMsg__); \
+ }while(0)
+
+
+/**
+ * @brief Create and send message. Does not wait server result.
+ * @remarks Does NOT guarantee thread safe.
+ * @param[in] api The enum of module API.
+ * @param[in] player The handle of capi media player.
+ * @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
+ * @param[in] param the name of param is key, must be local variable. never be pointer.
+ */
+#define player_msg_send1_async(api, player, type, param) \
+ do{ \
+ char *__sndMsg__; \
+ int __len__; \
+ int __fd__; \
+ type __value__ = (type)param; \
+ if(CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
+ else {ret = PLAYER_ERROR_INVALID_STATE;break;} \
+ __sndMsg__ = muse_core_msg_json_factory_new(api, \
+ MUSE_TYPE_##type, #param, __value__, \
+ 0); \
+ __len__ = muse_core_ipc_send_msg(__fd__, __sndMsg__); \
+ muse_core_msg_json_factory_free(__sndMsg__); \
+ if (__len__ <= 0) { \
+ LOGE("sending message failed"); \
+ return PLAYER_ERROR_INVALID_OPERATION; \
+ } \
+ }while(0)
+
+/**
+ * @brief Create and send message. Does not wait server result.
+ * @remarks Does NOT guarantee thread safe.
+ * @param[in] api The enum of module API.
+ * @param[in] player The server side handle of media player.
+ * @param[in] fd socket fd
+ * @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
+ * @param[in] param the name of param is key, must be local variable. never be pointer.
+ */
+#define player_msg_create_handle(api, fd, type1, param1, type2, param2) \
+ do{ \
+ char *__sndMsg__; \
+ int __len__; \
+ type1 __value1__ = (type1)param1; \
+ type2 __value2__ = (type2)param2; \
+ __sndMsg__ = muse_core_msg_json_factory_new(api, \
+ MUSE_TYPE_##type1, #param1, __value1__, \
+ MUSE_TYPE_##type2, #param2, __value2__, \
+ 0); \
+ __len__ = muse_core_ipc_send_msg(fd, __sndMsg__); \
+ muse_core_msg_json_factory_free(__sndMsg__); \
+ if (__len__ <= 0) { \
+ LOGE("sending message failed"); \
+ return PLAYER_ERROR_INVALID_OPERATION; \
+ } \
+ }while(0)
+
+
+/**
+ * @brief Create and send message for callback. Does not wait server result.
+ * @remarks Does NOT guarantee thread safe.
+ * @param[in] api The enum of module API.
+ * @param[in] player The handle of capi media player.
+ * @param[out] ret set ERROR when fail to send msg.
+ * @param[in] event_type type of event (muse_player_event_e).
+ * @param[in] set 1 is set the user callback, 0 is unset the user callback.
+ */
+#define player_msg_set_callback(api, player, ret, event_type, set) \
+ do{ \
+ char *__sndMsg__; \
+ int __len__; \
+ int __fd__; \
+ int __value1__ = (int)event_type; \
+ int __value2__ = (int)set; \
+ if(CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
+ else {ret = PLAYER_ERROR_INVALID_STATE;break;} \
+ __sndMsg__ = muse_core_msg_json_factory_new(api, \
+ MUSE_TYPE_INT, #event_type, __value1__, \
+ MUSE_TYPE_INT, #set, __value2__, \
+ 0); \
+ __len__ = muse_core_ipc_send_msg(__fd__, __sndMsg__); \
+ muse_core_msg_json_factory_free(__sndMsg__); \
+ if (__len__ <= 0) { \
+ LOGE("sending message failed"); \
+ ret = PLAYER_ERROR_INVALID_OPERATION; \
+ } \
+ }while(0)
+
+/**
+ * @brief Create and send return message.
+ * @remarks Does NOT guarantee thread safe.
+ * @param[in] api The enum of module API.
+ * @param[in] ret Thre result of API.
+ * @param[in] module mused module information
+ */
+#define player_msg_return(api, ret, module) \
+ do{ \
+ char *__sndMsg__; \
+ int __len__; \
+ __sndMsg__ = muse_core_msg_json_factory_new(api, \
+ MUSE_TYPE_INT, MUSE_PARAM_RETURN, ret, \
+ 0); \
+ __len__ = muse_core_ipc_send_msg(muse_core_client_get_msg_fd(module), __sndMsg__); \
+ if (__len__ <= 0) { \
+ LOGE("sending message failed"); \
+ ret = PLAYER_ERROR_INVALID_OPERATION; \
+ } \
+ muse_core_msg_json_factory_free(__sndMsg__); \
+ }while(0)
+
+/**
+ * @brief Create and send return message.
+ * @remarks Does NOT guarantee thread safe.
+ * @param[in] api The enum of module API.
+ * @param[in] ret Thre result of API.
+ * @param[in] module mused module information
+ * @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
+ * @param[in] param the name of param is key, must be local variable. never be pointer.
+ */
+#define player_msg_return1(api, ret, module, type, param) \
+ do{ \
+ char *__sndMsg__; \
+ int __len__; \
+ type __value__ = (type)param; \
+ __sndMsg__ = muse_core_msg_json_factory_new(api, \
+ MUSE_TYPE_INT, MUSE_PARAM_RETURN, ret, \
+ MUSE_TYPE_##type, #param, __value__, \
+ 0); \
+ __len__ = muse_core_ipc_send_msg(muse_core_client_get_msg_fd(module), __sndMsg__); \
+ if (__len__ <= 0) { \
+ LOGE("sending message failed"); \
+ ret = PLAYER_ERROR_INVALID_OPERATION; \
+ } \
+ muse_core_msg_json_factory_free(__sndMsg__); \
+ }while(0)
+
+/**
+ * @brief Create and send return message.
+ * @remarks Does NOT guarantee thread safe.
+ * @param[in] api The enum of module API.
+ * @param[in] ret Thre result of API.
+ * @param[in] module mused module information
+ * @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
+ * @param[in] param# the name of param is key, must be local variable. never be pointer.
+ */
+#define player_msg_return2(api, ret, module, type1, param1, type2, param2) \
+ do{ \
+ char *__sndMsg__; \
+ int __len__; \
+ type1 __value1__ = (type1)param1; \
+ type2 __value2__ = (type2)param2; \
+ __sndMsg__ = muse_core_msg_json_factory_new(api, \
+ MUSE_TYPE_INT, MUSE_PARAM_RETURN, ret, \
+ MUSE_TYPE_##type1, #param1, __value1__, \
+ MUSE_TYPE_##type2, #param2, __value2__, \
+ 0); \
+ __len__ = muse_core_ipc_send_msg(muse_core_client_get_msg_fd(module), __sndMsg__); \
+ if (__len__ <= 0) { \
+ LOGE("sending message failed"); \
+ ret = PLAYER_ERROR_INVALID_OPERATION; \
+ } \
+ muse_core_msg_json_factory_free(__sndMsg__); \
+ }while(0)
+
+/**
+ * @brief Create and send return message.
+ * @remarks Does NOT guarantee thread safe.
+ * @param[in] api The enum of module API.
+ * @param[in] ret Thre result of API.
+ * @param[in] module mused module information
+ * @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
+ * @param[in] param# the name of param is key, must be local variable. never be pointer.
+ */
+#define player_msg_return3(api, ret, module, type1, param1, type2, param2, type3, param3) \
+ do{ \
+ char *__sndMsg__; \
+ int __len__; \
+ type1 __value1__ = (type1)param1; \
+ type2 __value2__ = (type2)param2; \
+ type3 __value3__ = (type3)param3; \
+ __sndMsg__ = muse_core_msg_json_factory_new(api, \
+ MUSE_TYPE_INT, MUSE_PARAM_RETURN, ret, \
+ MUSE_TYPE_##type1, #param1, __value1__, \
+ MUSE_TYPE_##type2, #param2, __value2__, \
+ MUSE_TYPE_##type3, #param3, __value3__, \
+ 0); \
+ __len__ = muse_core_ipc_send_msg(muse_core_client_get_msg_fd(module), __sndMsg__); \
+ if (__len__ <= 0) { \
+ LOGE("sending message failed"); \
+ ret = PLAYER_ERROR_INVALID_OPERATION; \
+ } \
+ muse_core_msg_json_factory_free(__sndMsg__); \
+ }while(0)
+
+/**
+ * @brief Create and send return message.
+ * @remarks Does NOT guarantee thread safe.
+ * @param[in] api The enum of module API.
+ * @param[in] ret Thre result of API.
+ * @param[in] module mused module information
+ * @param[in] param the name of param is key, must be local array/pointer variable.
+ * @param[in] length The size of array.
+ * @param[in] datum_size The size of a array's datum.
+ */
+#define player_msg_return_array(api, ret, module, param, length, datum_size) \
+ do{ \
+ char *__sndMsg__; \
+ int __len__; \
+ int *__value__ = (int *)param; \
+ __sndMsg__ = muse_core_msg_json_factory_new(api, \
+ MUSE_TYPE_INT, MUSE_PARAM_RETURN, ret, \
+ MUSE_TYPE_INT, #length, length, \
+ MUSE_TYPE_ARRAY, #param, \
+ datum_size == sizeof(int)? length : \
+ length / sizeof(int) + (length % sizeof(int)?1:0), \
+ __value__, \
+ 0); \
+ __len__ = muse_core_ipc_send_msg(muse_core_client_get_msg_fd(module), __sndMsg__); \
+ if (__len__ <= 0) { \
+ LOGE("sending message failed"); \
+ ret = PLAYER_ERROR_INVALID_OPERATION; \
+ } \
+ muse_core_msg_json_factory_free(__sndMsg__); \
+ }while(0)
+
+/**
+ * @brief Create and send return message.
+ * @remarks Does NOT guarantee thread safe.
+ * @param[in] api The enum of module API.
+ * @param[in] event The event number.
+ * @param[in] module mused module information
+ */
+#define player_msg_event(api, event, module) \
+ do{ \
+ char *__sndMsg__; \
+ __sndMsg__ = muse_core_msg_json_factory_new(api, \
+ MUSE_TYPE_INT, MUSE_PARAM_EVENT, event, \
+ 0); \
+ muse_core_ipc_send_msg(muse_core_client_get_msg_fd(module), __sndMsg__); \
+ muse_core_msg_json_factory_free(__sndMsg__); \
+ }while(0)
+
+/**
+ * @brief Create and send return message.
+ * @remarks Does NOT guarantee thread safe.
+ * @param[in] api The enum of module API.
+ * @param[in] event The event number.
+ * @param[in] module mused module information
+ * @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
+ * @param[in] param the name of param is key, must be local variable. never be pointer.
+ */
+#define player_msg_event1(api, event, module, type, param) \
+ do{ \
+ char *__sndMsg__; \
+ type __value__ = (type)param; \
+ __sndMsg__ = muse_core_msg_json_factory_new(api, \
+ MUSE_TYPE_INT, MUSE_PARAM_EVENT, event, \
+ MUSE_TYPE_##type, #param, __value__, \
+ 0); \
+ muse_core_ipc_send_msg(muse_core_client_get_msg_fd(module), __sndMsg__); \
+ muse_core_msg_json_factory_free(__sndMsg__); \
+ }while(0)
+
+/**
+ * @brief Create and send return message.
+ * @remarks Does NOT guarantee thread safe.
+ * @param[in] api The enum of module API.
+ * @param[in] event The event number.
+ * @param[in] module mused module information
+ * @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
+ * @param[in] param# the name of param is key, must be local variable. never be pointer.
+ */
+#define player_msg_event2(api, event, module, type1, param1, type2, param2) \
+ do{ \
+ char *__sndMsg__; \
+ type1 __value1__ = (type1)param1; \
+ type2 __value2__ = (type2)param2; \
+ __sndMsg__ = muse_core_msg_json_factory_new(api, \
+ MUSE_TYPE_INT, MUSE_PARAM_EVENT, event, \
+ MUSE_TYPE_##type1, #param1, __value1__, \
+ MUSE_TYPE_##type2, #param2, __value2__, \
+ 0); \
+ muse_core_ipc_send_msg(muse_core_client_get_msg_fd(module), __sndMsg__); \
+ muse_core_msg_json_factory_free(__sndMsg__); \
+ }while(0)
+
+/**
+ * @brief Create and send return message.
+ * @remarks Does NOT guarantee thread safe.
+ * @param[in] api The enum of module API.
+ * @param[in] event The event number.
+ * @param[in] module mused module information
+ * @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
+ * @param[in] param# the name of param is key, must be local variable. never be pointer.
+ */
+#define player_msg_event4(api, event, module, type1, param1, type2, param2, type3, param3, type4, param4) \
+ do{ \
+ char *__sndMsg__; \
+ type1 __value1__ = (type1)param1; \
+ type2 __value2__ = (type2)param2; \
+ type3 __value3__ = (type3)param3; \
+ type4 __value4__ = (type4)param4; \
+ __sndMsg__ = muse_core_msg_json_factory_new(api, \
+ MUSE_TYPE_INT, MUSE_PARAM_EVENT, event, \
+ MUSE_TYPE_##type1, #param1, __value1__, \
+ MUSE_TYPE_##type2, #param2, __value2__, \
+ MUSE_TYPE_##type3, #param3, __value3__, \
+ MUSE_TYPE_##type4, #param4, __value4__, \
+ 0); \
+ muse_core_ipc_send_msg(muse_core_client_get_msg_fd(module), __sndMsg__); \
+ muse_core_msg_json_factory_free(__sndMsg__); \
+ }while(0)
+
+/**
+ * @brief Create and send return message.
+ * @remarks Does NOT guarantee thread safe.
+ * @param[in] api The enum of module API.
+ * @param[in] event The event number.
+ * @param[in] module mused module information
+ * @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
+ * @param[in] param# the name of param is key, must be local variable. never be pointer.
+ * @param[in] arr_param the name of param is key, must be local pointer/array variable.
+ * @param[in] length The size of array.
+ * @param[in] datum_size The size of a array's datum.
+ */
+#define player_msg_event2_array(api, event, module, type1, param1, type2, param2, arr_param, length, datum_size) \
+ do{ \
+ char *__sndMsg__; \
+ type1 __value1__ = (type1)param1; \
+ type2 __value2__ = (type2)param2; \
+ int *__arr_value__ = (int *)arr_param; \
+ __sndMsg__ = muse_core_msg_json_factory_new(api, \
+ MUSE_TYPE_INT, MUSE_PARAM_EVENT, event, \
+ MUSE_TYPE_##type1, #param1, __value1__, \
+ MUSE_TYPE_##type2, #param2, __value2__, \
+ MUSE_TYPE_INT, #length, length, \
+ MUSE_TYPE_ARRAY, #arr_param, \
+ datum_size == sizeof(int)? length : \
+ length / sizeof(int) + (length % sizeof(int)?1:0), \
+ __arr_value__, \
+ 0); \
+ muse_core_ipc_send_msg(muse_core_client_get_msg_fd(module), __sndMsg__); \
+ muse_core_msg_json_factory_free(__sndMsg__); \
+ }while(0)
+
+/**
+ * @brief Create and send return message.
+ * @remarks Does NOT guarantee thread safe.
+ * @param[in] api The enum of module API.
+ * @param[in] event The event number.
+ * @param[in] module mused module information
+ * @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
+ * @param[in] param# the name of param is key, must be local variable. never be pointer.
+ * @param[in] arr_param the name of param is key, must be local array/pointer variable.
+ * @param[in] length The size of array.
+ * @param[in] datum_size The size of a array's datum.
+ */
+#define player_msg_event7_array(api, event, module, type1, param1, type2, param2, type3, param3, type4, param4, type5, param5, type6, param6, type7, param7, arr_param, length, datum_size) \
+ do{ \
+ char *__sndMsg__; \
+ type1 __value1__ = (type1)param1; \
+ type2 __value2__ = (type2)param2; \
+ type3 __value3__ = (type3)param3; \
+ type4 __value4__ = (type4)param4; \
+ type5 __value5__ = (type5)param5; \
+ type6 __value6__ = (type6)param6; \
+ type7 __value7__ = (type7)param7; \
+ int *__arr_value__ = (int *)arr_param; \
+ __sndMsg__ = muse_core_msg_json_factory_new(api, \
+ MUSE_TYPE_INT, MUSE_PARAM_EVENT, event, \
+ MUSE_TYPE_##type1, #param1, __value1__, \
+ MUSE_TYPE_##type2, #param2, __value2__, \
+ MUSE_TYPE_##type3, #param3, __value3__, \
+ MUSE_TYPE_##type4, #param4, __value4__, \
+ MUSE_TYPE_##type5, #param5, __value5__, \
+ MUSE_TYPE_##type6, #param6, __value6__, \
+ MUSE_TYPE_##type7, #param7, __value7__, \
+ MUSE_TYPE_INT, #length, length, \
+ MUSE_TYPE_ARRAY, #arr_param, \
+ datum_size == sizeof(int)? length : \
+ length / sizeof(int) + (length % sizeof(int)?1:0), \
+ __arr_value__, \
+ 0); \
+ muse_core_ipc_send_msg(muse_core_client_get_msg_fd(module), __sndMsg__); \
+ muse_core_msg_json_factory_free(__sndMsg__); \
+ }while(0)
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*__TIZEN_MEDIA_MUSE_PLAYER_MSG_H__*/
--- /dev/null
+/*
+* 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 <dlog.h>
+#include "muse_core.h"
+#include "muse_core_ipc.h"
+#include "legacy_player.h"
+
+static int player_cmd_shutdown(muse_module_h module)
+{
+ intptr_t handle;
+ player_state_e state;
+ int ret;
+
+ handle = muse_core_ipc_get_handle(module);
+
+ ret = legacy_player_get_state((player_h)handle, &state);
+
+ if (ret != PLAYER_ERROR_NONE)
+ return ret;
+
+ switch (state) {
+ case PLAYER_STATE_PLAYING:
+ legacy_player_stop((player_h)handle);
+ /* FALLTHROUGH */
+ case PLAYER_STATE_PAUSED:
+ case PLAYER_STATE_READY:
+ legacy_player_unprepare((player_h)handle);
+ /* FALLTHROUGH */
+ case PLAYER_STATE_IDLE:
+ legacy_player_destroy((player_h)handle);
+ break;
+
+ default:
+ LOGD("Nothing to do");
+ break;
+ }
+
+ return PLAYER_ERROR_NONE;
+}
+
+int (*cmd_dispatcher[MUSE_MODULE_EVENT_MAX])(muse_module_h module) = {
+ player_cmd_shutdown, /* MUSE_MODULE_EVENT_SHUTDOWN */
+ NULL, /* MUSE_MODULE_EVENT_DEBUG_INFO_DUMP */
+};
--- /dev/null
+/*
+* 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 <tbm_bufmgr.h>
+#include <tbm_surface.h>
+#include <tbm_surface_internal.h>
+#include <media_packet.h>
+#include "muse_core.h"
+#include "muse_core_ipc.h"
+#include "muse_player.h"
+#include "muse_player_msg.h"
+#include "legacy_player_private.h"
+#include "legacy_player_internal.h"
+
+static tbm_bufmgr bufmgr;
+__thread media_format_h audio_format = NULL;
+__thread media_format_h video_format = NULL;
+
+typedef struct {
+ intptr_t handle;
+ uint64_t pts;
+ uint64_t size;
+ media_format_mimetype_e mimetype;
+ media_buffer_flags_e flags;
+} push_data_q_t;
+
+typedef struct {
+ player_h player;
+ muse_module_h module;
+} prepare_data_t;
+
+/*
+* Internal Implementation
+*/
+static int _push_media_stream(intptr_t handle, player_push_media_msg_type *push_media, char *buf);
+
+static void __player_callback(muse_player_event_e ev, muse_module_h module)
+{
+ muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
+
+ LOGD("ENTER");
+
+ player_msg_event(api, ev, module);
+}
+
+static void _prepare_async_cb(void *user_data)
+{
+ muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_PREPARE;
+ muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
+ prepare_data_t *prepare_data = (prepare_data_t *)user_data;
+ muse_module_h module;
+
+ if (!prepare_data) {
+ LOGE("user data of callback is NULL");
+ return;
+ }
+ module = prepare_data->module;
+ g_free(prepare_data);
+
+ player_msg_event(api, ev, module);
+}
+
+static void _seek_complate_cb(void *user_data)
+{
+ muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_SEEK;
+ __player_callback(ev, (muse_module_h)user_data);
+}
+
+static void _buffering_cb(int percent, void *user_data)
+{
+ muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
+ muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_BUFFERING;
+ muse_module_h module = (muse_module_h)user_data;
+
+ LOGD("ENTER");
+
+ player_msg_event1(api, ev, module, INT, percent);
+
+}
+
+static void _completed_cb(void *user_data)
+{
+ muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_COMPLETE;
+ __player_callback(ev, (muse_module_h)user_data);
+}
+
+static void _interrupted_cb(player_interrupted_code_e code, void *user_data)
+{
+ muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
+ muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_INTERRUPT;
+ muse_module_h module = (muse_module_h)user_data;
+
+ LOGD("ENTER");
+
+ player_msg_event1(api, ev, module, INT, code);
+}
+
+static void _error_cb(int code, void *user_data)
+{
+ muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
+ muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_ERROR;
+ muse_module_h module = (muse_module_h)user_data;
+
+ LOGD("ENTER");
+
+ player_msg_event1(api, ev, module, INT, code);
+}
+
+static void _subtitle_updated_cb(unsigned long duration, char *text, void *user_data)
+{
+ muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
+ muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_SUBTITLE;
+ muse_module_h module = (muse_module_h)user_data;
+
+ LOGD("ENTER");
+
+ player_msg_event2(api, ev, module, INT, duration, STRING, text);
+}
+
+static void _capture_video_cb(unsigned char *data, int width, int height, unsigned int size, void *user_data)
+{
+ muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
+ muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_CAPTURE;
+ muse_module_h module = (muse_module_h)user_data;
+ tbm_bo bo;
+ tbm_bo_handle thandle;
+ tbm_key key;
+ char checker = 1;
+ unsigned int expired = 0x0fffffff;
+
+ LOGD("ENTER");
+
+ bo = tbm_bo_alloc(bufmgr, size + 1, TBM_BO_DEFAULT);
+ if (!bo) {
+ LOGE("TBM get error : tbm_bo_alloc return NULL");
+ return;
+ }
+ thandle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_WRITE);
+ if (thandle.ptr == NULL) {
+ LOGE("TBM get error : handle pointer is NULL");
+ goto capture_event_exit1;
+ }
+ memcpy(thandle.ptr, data, size);
+ key = tbm_bo_export(bo);
+ if (key == 0) {
+ LOGE("TBM get error : export key is 0");
+ checker = 0;
+ goto capture_event_exit2;
+ }
+ /* mark to write */
+ *((char *)thandle.ptr + size) = 1;
+
+ player_msg_event4(api, ev, module, INT, width, INT, height, INT, size, INT, key);
+
+capture_event_exit2:
+ tbm_bo_unmap(bo);
+
+ while (checker && expired--) {
+ thandle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
+ checker = *((char *)thandle.ptr + size);
+ tbm_bo_unmap(bo);
+ }
+
+capture_event_exit1:
+ tbm_bo_unref(bo);
+}
+
+static void _pd_msg_cb(player_pd_message_type_e type, void *user_data)
+{
+ muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
+ muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_PD;
+ muse_module_h module = (muse_module_h)user_data;
+
+ LOGD("ENTER");
+
+ player_msg_event1(api, ev, module, INT, type);
+}
+
+static void _media_packet_video_decoded_cb(media_packet_h pkt, void *user_data)
+{
+ int ret;
+ muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
+ muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME;
+ muse_module_h module = (muse_module_h)user_data;
+ tbm_surface_h suf;
+ tbm_bo bo[4];
+ int bo_num;
+ tbm_key key[4] = {0, };
+ tbm_surface_info_s sinfo;
+ int i;
+ char *surface_info = (char *)&sinfo;
+ int surface_info_size = sizeof(tbm_surface_info_s);
+ intptr_t packet = (intptr_t)pkt;
+ media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
+ media_format_h fmt;
+ uint64_t pts = 0;
+
+ memset(&sinfo, 0, sizeof(tbm_surface_info_s));
+
+ ret = media_packet_get_tbm_surface(pkt, &suf);
+ if (ret != MEDIA_PACKET_ERROR_NONE) {
+ LOGE("get tbm surface error %d", ret);
+ return;
+ }
+
+ bo_num = tbm_surface_internal_get_num_bos(suf);
+ for (i = 0; i < bo_num; i++) {
+ bo[i] = tbm_surface_internal_get_bo(suf, i);
+ if (bo[i])
+ key[i] = tbm_bo_export(bo[i]);
+ else
+ LOGE("bo_num is %d, bo[%d] is NULL", bo_num, i);
+ }
+
+ ret = tbm_surface_get_info(suf, &sinfo);
+ if (ret != TBM_SURFACE_ERROR_NONE) {
+ LOGE("tbm_surface_get_info error %d", ret);
+ return;
+ }
+ media_packet_get_format(pkt, &fmt);
+ media_format_get_video_info(fmt, &mimetype, NULL, NULL, NULL, NULL);
+ media_packet_get_pts(pkt, &pts);
+ player_msg_event7_array(api, ev, module, INT, key[0], INT, key[1], INT, key[2], INT, key[3], POINTER, packet, INT, mimetype, INT64, pts, surface_info, surface_info_size, sizeof(char));
+}
+
+static void _audio_frame_decoded_cb(player_audio_raw_data_s * audio_frame, void *user_data)
+{
+ muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
+ muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_AUDIO_FRAME;
+ muse_module_h module = (muse_module_h)user_data;
+ tbm_bo bo;
+ tbm_bo_handle thandle;
+ tbm_key key;
+ char checker = 1;
+ unsigned int expired = 0x0fffffff;
+ int size = 0;
+ void *data = NULL;
+ if (audio_frame) {
+ size = audio_frame->size;
+ data = audio_frame->data;
+ } else {
+ LOGE("audio frame is NULL");
+ return;
+ }
+
+ LOGD("ENTER");
+
+ bo = tbm_bo_alloc(bufmgr, size + 1, TBM_BO_DEFAULT);
+ if (!bo) {
+ LOGE("TBM get error : tbm_bo_alloc return NULL");
+ return;
+ }
+ thandle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_WRITE);
+ if (thandle.ptr == NULL) {
+ LOGE("TBM get error : handle pointer is NULL");
+ tbm_bo_unref(bo);
+ return;
+ }
+ memcpy(thandle.ptr, data, size);
+ key = tbm_bo_export(bo);
+ if (key == 0) {
+ LOGE("TBM get error : export key is 0");
+ checker = 0;
+ tbm_bo_unmap(bo);
+ tbm_bo_unref(bo);
+ return;
+ }
+ /* mark to write */
+ *((char *)thandle.ptr + size) = 1;
+
+ tbm_bo_unmap(bo);
+
+ player_msg_event2_array(api, ev, module, INT, key, INT, size, audio_frame, sizeof(player_audio_raw_data_s), sizeof(char));
+
+ while (checker && expired--) {
+ thandle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
+ checker = *((char *)thandle.ptr + size);
+ tbm_bo_unmap(bo);
+ }
+
+ tbm_bo_unref(bo);
+}
+
+static void _video_stream_changed_cb(int width, int height, int fps, int bit_rate, void *user_data)
+{
+ muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
+ muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED;
+ muse_module_h module = (muse_module_h)user_data;
+
+ player_msg_event4(api, ev, module, INT, width, INT, height, INT, fps, INT, bit_rate);
+}
+
+static void _media_stream_audio_buffer_status_cb(player_media_stream_buffer_status_e status, void *user_data)
+{
+ muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
+ muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS;
+ muse_module_h module = (muse_module_h)user_data;
+
+ player_msg_event1(api, ev, module, INT, status);
+}
+
+static void _media_stream_video_buffer_status_cb(player_media_stream_buffer_status_e status, void *user_data)
+{
+ muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
+ muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS;
+ muse_module_h module = (muse_module_h)user_data;
+
+ player_msg_event1(api, ev, module, INT, status);
+}
+
+static void _media_stream_audio_buffer_status_cb_ex(player_media_stream_buffer_status_e status, unsigned long long bytes, void *user_data)
+{
+ muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
+ muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO;
+ muse_module_h module = (muse_module_h)user_data;
+
+ player_msg_event2(api, ev, module, INT, status, INT64, bytes);
+}
+
+static void _media_stream_video_buffer_status_cb_ex(player_media_stream_buffer_status_e status, unsigned long long bytes, void *user_data)
+{
+ muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
+ muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO;
+ muse_module_h module = (muse_module_h)user_data;
+
+ player_msg_event2(api, ev, module, INT, status, INT64, bytes);
+}
+
+static void _media_stream_audio_seek_cb(unsigned long long offset, void *user_data)
+{
+ muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
+ muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK;
+ muse_module_h module = (muse_module_h)user_data;
+
+ player_msg_event1(api, ev, module, INT64, offset);
+}
+
+static void _media_stream_video_seek_cb(unsigned long long offset, void *user_data)
+{
+ muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
+ muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK;
+ muse_module_h module = (muse_module_h)user_data;
+
+ player_msg_event1(api, ev, module, INT64, offset);
+}
+
+static void _set_completed_cb(player_h player, void *module, bool set)
+{
+ if (set)
+ legacy_player_set_completed_cb(player, _completed_cb, module);
+ else
+ legacy_player_unset_completed_cb(player);
+}
+
+static void _set_interrupted_cb(player_h player, void *module, bool set)
+{
+ if (set)
+ legacy_player_set_interrupted_cb(player, _interrupted_cb, module);
+ else
+ legacy_player_unset_interrupted_cb(player);
+}
+
+static void _set_error_cb(player_h player, void *module, bool set)
+{
+ if (set)
+ legacy_player_set_error_cb(player, _error_cb, module);
+ else
+ legacy_player_unset_error_cb(player);
+}
+
+static void _set_subtitle_cb(player_h player, void *module, bool set)
+{
+ if (set)
+ legacy_player_set_subtitle_updated_cb(player, _subtitle_updated_cb, module);
+ else
+ legacy_player_unset_subtitle_updated_cb(player);
+}
+
+static void _set_buffering_cb(player_h player, void *module, bool set)
+{
+ if (set)
+ legacy_player_set_buffering_cb(player, _buffering_cb, module);
+ else
+ legacy_player_unset_buffering_cb(player);
+}
+
+static void _set_pd_msg_cb(player_h player, void *module, bool set)
+{
+ int ret = PLAYER_ERROR_NONE;
+ muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
+
+ if (set)
+ ret = legacy_player_set_progressive_download_message_cb(player, _pd_msg_cb, module);
+ else
+ ret = legacy_player_unset_progressive_download_message_cb(player);
+
+ player_msg_return(api, ret, module);
+}
+
+static void _set_media_packet_video_frame_cb(player_h player, void *data, bool set)
+{
+ int ret = PLAYER_ERROR_NONE;
+ muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
+ muse_module_h module = (muse_module_h)data;
+
+ if (set)
+ ret = legacy_player_set_media_packet_video_frame_decoded_cb(player, _media_packet_video_decoded_cb, module);
+ else
+ ret = legacy_player_unset_media_packet_video_frame_decoded_cb(player);
+
+ player_msg_return(api, ret, module);
+}
+
+static void _set_video_stream_changed_cb(player_h player, void *data, bool set)
+{
+ int ret = PLAYER_ERROR_NONE;
+ muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
+ muse_module_h module = (muse_module_h)data;
+
+ if (set)
+ ret = legacy_player_set_video_stream_changed_cb(player, _video_stream_changed_cb, module);
+ else
+ ret = legacy_player_unset_video_stream_changed_cb(player);
+
+ player_msg_return(api, ret, module);
+}
+
+static void _set_media_stream_audio_seek_cb(player_h player, void *data, bool set)
+{
+ int ret = PLAYER_ERROR_NONE;
+ muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
+ muse_module_h module = (muse_module_h)data;
+
+ if (set)
+ ret = legacy_player_set_media_stream_seek_cb(player, PLAYER_STREAM_TYPE_AUDIO, _media_stream_audio_seek_cb, module);
+ else
+ ret = legacy_player_unset_media_stream_seek_cb(player, PLAYER_STREAM_TYPE_AUDIO);
+
+ player_msg_return(api, ret, module);
+}
+
+static void _set_media_stream_video_seek_cb(player_h player, void *data, bool set)
+{
+ int ret = PLAYER_ERROR_NONE;
+ muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
+ muse_module_h module = (muse_module_h)data;
+
+ if (set)
+ ret = legacy_player_set_media_stream_seek_cb(player, PLAYER_STREAM_TYPE_VIDEO, _media_stream_video_seek_cb, module);
+ else
+ ret = legacy_player_unset_media_stream_seek_cb(player, PLAYER_STREAM_TYPE_VIDEO);
+
+ player_msg_return(api, ret, module);
+}
+
+static void _set_media_stream_audio_buffer_cb(player_h player, void *data, bool set)
+{
+ int ret = PLAYER_ERROR_NONE;
+ muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
+ muse_module_h module = (muse_module_h)data;
+
+ if (set)
+ ret = legacy_player_set_media_stream_buffer_status_cb(player, PLAYER_STREAM_TYPE_AUDIO, _media_stream_audio_buffer_status_cb, module);
+ else
+ ret = legacy_player_unset_media_stream_buffer_status_cb(player, PLAYER_STREAM_TYPE_AUDIO);
+
+ player_msg_return(api, ret, module);
+}
+
+static void _set_media_stream_video_buffer_cb(player_h player, void *data, bool set)
+{
+ int ret = PLAYER_ERROR_NONE;
+ muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
+ muse_module_h module = (muse_module_h)data;
+
+ if (set)
+ ret = legacy_player_set_media_stream_buffer_status_cb(player, PLAYER_STREAM_TYPE_VIDEO, _media_stream_video_buffer_status_cb, module);
+ else
+ ret = legacy_player_unset_media_stream_buffer_status_cb(player, PLAYER_STREAM_TYPE_VIDEO);
+
+ player_msg_return(api, ret, module);
+}
+
+static void _set_media_stream_audio_buffer_cb_ex(player_h player, void *data, bool set)
+{
+ int ret = PLAYER_ERROR_NONE;
+ muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
+ muse_module_h module = (muse_module_h)data;
+
+ if (set)
+ ret = legacy_player_set_media_stream_buffer_status_cb_ex(player, PLAYER_STREAM_TYPE_AUDIO, _media_stream_audio_buffer_status_cb_ex, module);
+ else
+ ret = legacy_player_unset_media_stream_buffer_status_cb_ex(player, PLAYER_STREAM_TYPE_AUDIO);
+
+ player_msg_return(api, ret, module);
+}
+
+static void _set_media_stream_video_buffer_cb_ex(player_h player, void *data, bool set)
+{
+ int ret = PLAYER_ERROR_NONE;
+ muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
+ muse_module_h module = (muse_module_h)data;
+
+ if (set)
+ ret = legacy_player_set_media_stream_buffer_status_cb_ex(player, PLAYER_STREAM_TYPE_VIDEO, _media_stream_video_buffer_status_cb_ex, module);
+ else
+ ret = legacy_player_unset_media_stream_buffer_status_cb_ex(player, PLAYER_STREAM_TYPE_VIDEO);
+
+ player_msg_return(api, ret, module);
+}
+
+static void (*set_callback_func[MUSE_PLAYER_EVENT_TYPE_NUM])(player_h player, void *user_data, bool set) = {
+ NULL, /* MUSE_PLAYER_EVENT_TYPE_PREPARE */
+ _set_completed_cb, /* MUSE_PLAYER_EVENT_TYPE_COMPLETE */
+ _set_interrupted_cb, /* MUSE_PLAYER_EVENT_TYPE_INTERRUPT */
+ _set_error_cb, /* MUSE_PLAYER_EVENT_TYPE_ERROR */
+ _set_buffering_cb, /* MUSE_PLAYER_EVENT_TYPE_BUFFERING */
+ _set_subtitle_cb, /* MUSE_PLAYER_EVENT_TYPE_SUBTITLE */
+ NULL, /* MUSE_PLAYER_EVENT_TYPE_CAPTURE */
+ NULL, /* MUSE_PLAYER_EVENT_TYPE_SEEK */
+ _set_media_packet_video_frame_cb, /* MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME */
+ NULL, /* MUSE_PLAYER_EVENT_TYPE_AUDIO_FRAME */
+ NULL, /* MUSE_PLAYER_EVENT_TYPE_VIDEO_FRAME_RENDER_ERROR */
+ _set_pd_msg_cb, /* MUSE_PLAYER_EVENT_TYPE_PD */
+ NULL, /* MUSE_PLAYER_EVENT_TYPE_SUPPORTED_AUDIO_EFFECT */
+ NULL, /* MUSE_PLAYER_EVENT_TYPE_SUPPORTED_AUDIO_EFFECT_PRESET */
+ NULL, /* MUSE_PLAYER_EVENT_TYPE_MISSED_PLUGIN */
+#ifdef _PLAYER_FOR_PRODUCT
+ NULL, /* MUSE_PLAYER_EVENT_TYPE_IMAGE_BUFFER */
+ NULL, /* MUSE_PLAYER_EVENT_TYPE_SELECTED_SUBTITLE_LANGUAGE */
+#endif
+ _set_media_stream_video_buffer_cb, /* MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS */
+ _set_media_stream_audio_buffer_cb, /* MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS */
+ _set_media_stream_video_buffer_cb_ex, /* MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO */
+ _set_media_stream_audio_buffer_cb_ex, /* MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO */
+ _set_media_stream_video_seek_cb, /* MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK */
+ _set_media_stream_audio_seek_cb, /* MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK */
+ NULL, /* MUSE_PLAYER_EVENT_TYPE_AUDIO_STREAM_CHANGED */
+ _set_video_stream_changed_cb, /* MUSE_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED */
+};
+
+static int player_disp_set_callback(muse_module_h module)
+{
+ intptr_t handle;
+ muse_player_event_e type;
+ int set;
+
+ handle = muse_core_ipc_get_handle(module);
+ player_msg_get(type, muse_core_client_get_msg(module));
+ player_msg_get(set, muse_core_client_get_msg(module));
+
+ if (type < MUSE_PLAYER_EVENT_TYPE_NUM && set_callback_func[type] != NULL)
+ set_callback_func[type] ((player_h)handle, module, set);
+
+ return PLAYER_ERROR_NONE;
+}
+
+static int player_disp_create(muse_module_h module)
+{
+ int ret = -1;
+ player_h player;
+ muse_player_api_e api = MUSE_PLAYER_API_CREATE;
+ intptr_t handle = 0;
+ intptr_t module_addr = (intptr_t)module;
+ int pid;
+
+ ret = legacy_player_create(&player);
+ LOGD("handle : %p, module : %p", player, module);
+
+ player_msg_get(pid, muse_core_client_get_msg(module));
+
+ if (ret == PLAYER_ERROR_NONE)
+ ret = legacy_player_sound_register(player, pid);
+ else
+ player_msg_return(api, ret, module);
+
+ if (ret == PLAYER_ERROR_NONE) {
+ handle = (intptr_t)player;
+ muse_core_ipc_set_handle(module, handle);
+ muse_core_ipc_get_bufmgr(&bufmgr);
+ player_msg_return1(api, ret, module, POINTER, module_addr);
+ } else
+ player_msg_return(api, ret, module);
+
+ return ret;
+}
+
+static int player_disp_set_uri(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_SET_URI;
+ char uri[MUSE_URI_MAX_LENGTH] = { 0, };
+
+ handle = muse_core_ipc_get_handle(module);
+ player_msg_get_string(uri, muse_core_client_get_msg(module));
+
+ ret = legacy_player_set_uri((player_h)handle, uri);
+
+ player_msg_return(api, ret, module);
+
+ return ret;
+}
+
+static int player_disp_prepare(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_PREPARE;
+ player_h player;
+
+ handle = muse_core_ipc_get_handle(module);
+
+ player = (player_h)handle;
+
+ ret = legacy_player_prepare(player);
+ player_msg_return(api, ret, module);
+
+ return ret;
+}
+
+static int player_disp_prepare_async(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_PREPARE_ASYNC;
+ player_h player;
+ prepare_data_t *prepare_data;
+
+ handle = muse_core_ipc_get_handle(module);
+
+ player = (player_h)handle;
+
+ prepare_data = g_new(prepare_data_t, 1);
+ prepare_data->player = player;
+ prepare_data->module = module;
+
+ ret = legacy_player_prepare_async(player, _prepare_async_cb, prepare_data);
+ player_msg_return(api, ret, module);
+
+ return ret;
+}
+
+static int player_disp_unprepare(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_UNPREPARE;
+ player_h player;
+
+ handle = muse_core_ipc_get_handle(module);
+ player = (player_h)handle;
+
+ ret = legacy_player_unprepare(player);
+
+ player_msg_return(api, ret, module);
+
+ return ret;
+}
+
+static int player_disp_destroy(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_DESTROY;
+ handle = muse_core_ipc_get_handle(module);
+
+ ret = legacy_player_destroy((player_h)handle);
+
+ if (audio_format) {
+ media_format_unref(audio_format);
+ audio_format = NULL;
+ }
+ if (video_format) {
+ media_format_unref(video_format);
+ video_format = NULL;
+ }
+
+ player_msg_return(api, ret, module);
+
+ return ret;
+}
+
+static int player_disp_start(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_START;
+
+ handle = muse_core_ipc_get_handle(module);
+
+ ret = legacy_player_start((player_h)handle);
+
+ player_msg_return(api, ret, module);
+
+ return ret;
+}
+
+static int player_disp_stop(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_STOP;
+
+ handle = muse_core_ipc_get_handle(module);
+
+ ret = legacy_player_stop((player_h)handle);
+
+ player_msg_return(api, ret, module);
+
+ return ret;
+}
+
+static int player_disp_pause(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_PAUSE;
+
+ handle = muse_core_ipc_get_handle(module);
+
+ ret = legacy_player_pause((player_h)handle);
+
+ player_msg_return(api, ret, module);
+
+ return ret;
+}
+
+static int player_disp_set_memory_buffer(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_SET_MEMORY_BUFFER;
+ tbm_bo bo;
+ tbm_bo_handle thandle;
+ tbm_key key;
+ int size;
+ intptr_t bo_addr;
+
+ handle = muse_core_ipc_get_handle(module);
+ player_msg_get(key, muse_core_client_get_msg(module));
+ player_msg_get(size, muse_core_client_get_msg(module));
+
+ bo = tbm_bo_import(bufmgr, key);
+ if (bo == NULL) {
+ LOGE("TBM get error : bo is NULL");
+ ret = PLAYER_ERROR_INVALID_OPERATION;
+ player_msg_return(api, ret, module);
+ return ret;
+ }
+ thandle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
+ if (thandle.ptr == NULL) {
+ LOGE("TBM get error : handle pointer is NULL");
+ ret = PLAYER_ERROR_INVALID_OPERATION;
+ player_msg_return(api, ret, module);
+ return ret;
+ }
+
+ bo_addr = (intptr_t)bo;
+ ret = legacy_player_set_memory_buffer((player_h)handle, thandle.ptr, size);
+ player_msg_return1(api, ret, module, INT, bo_addr);
+
+ return ret;
+}
+
+static int player_disp_deinit_memory_buffer(muse_module_h module)
+{
+ intptr_t bo_addr;
+ tbm_bo bo;
+
+ if (player_msg_get(bo_addr, muse_core_client_get_msg(module))) {
+
+ bo = (tbm_bo) bo_addr;
+
+ tbm_bo_unmap(bo);
+ tbm_bo_unref(bo);
+ }
+
+ return PLAYER_ERROR_NONE;
+}
+
+static int player_disp_set_volume(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_SET_VOLUME;
+ double left, right;
+
+ handle = muse_core_ipc_get_handle(module);
+ player_msg_get_type(left, muse_core_client_get_msg(module), DOUBLE);
+ player_msg_get_type(right, muse_core_client_get_msg(module), DOUBLE);
+
+ ret = legacy_player_set_volume((player_h)handle, (float)left, (float)right);
+
+ player_msg_return(api, ret, module);
+
+ return ret;
+}
+
+static int player_disp_get_volume(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_GET_VOLUME;
+ float left, right;
+
+ handle = muse_core_ipc_get_handle(module);
+
+ ret = legacy_player_get_volume((player_h)handle, &left, &right);
+
+ player_msg_return2(api, ret, module, DOUBLE, left, DOUBLE, right);
+
+ return ret;
+}
+
+static int player_disp_get_state(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_GET_STATE;
+ player_state_e state;
+
+ handle = muse_core_ipc_get_handle(module);
+
+ ret = legacy_player_get_state((player_h)handle, &state);
+
+ player_msg_return1(api, ret, module, INT, state);
+
+ return ret;
+}
+
+static int player_disp_set_play_position(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_SET_PLAY_POSITION;
+ int pos;
+ int accurate;
+
+ handle = muse_core_ipc_get_handle(module);
+ player_msg_get(pos, muse_core_client_get_msg(module));
+ player_msg_get(accurate, muse_core_client_get_msg(module));
+
+ ret = legacy_player_set_play_position((player_h)handle, pos, accurate, _seek_complate_cb, module);
+
+ player_msg_return(api, ret, module);
+
+ return ret;
+}
+
+static int player_disp_get_play_position(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_GET_PLAY_POSITION;
+ int pos;
+
+ handle = muse_core_ipc_get_handle(module);
+
+ ret = legacy_player_get_play_position((player_h)handle, &pos);
+
+ player_msg_return1(api, ret, module, INT, pos);
+
+ return ret;
+}
+
+static int player_disp_set_display(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_SET_DISPLAY;
+#ifdef HAVE_WAYLAND
+ wl_win_msg_type wl_win;
+ char *wl_win_msg = (char *)&wl_win;
+#else
+ int type;
+ unsigned int xhandle;
+#endif
+
+ handle = muse_core_ipc_get_handle(module);
+#ifdef HAVE_WAYLAND
+ player_msg_get_array(wl_win_msg, muse_core_client_get_msg(module));
+
+ ret = legacy_player_set_display_wl_for_mused((player_h)handle, wl_win.type, wl_win.wl_surface_id, wl_win.wl_window_x, wl_win.wl_window_y, wl_win.wl_window_width, wl_win.wl_window_height);
+#else
+ player_msg_get(type, muse_core_client_get_msg(module));
+ player_msg_get(xhandle, muse_core_client_get_msg(module));
+
+ ret = legacy_player_set_display_for_mused((player_h)handle, type, xhandle);
+#endif
+ player_msg_return(api, ret, module);
+
+ return ret;
+}
+
+static int player_disp_set_mute(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_SET_MUTE;
+ int mute;
+
+ handle = muse_core_ipc_get_handle(module);
+ player_msg_get(mute, muse_core_client_get_msg(module));
+
+ ret = legacy_player_set_mute((player_h)handle, (bool)mute);
+
+ player_msg_return(api, ret, module);
+
+ return ret;
+}
+
+static int player_disp_is_muted(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_IS_MUTED;
+ bool mute;
+
+ handle = muse_core_ipc_get_handle(module);
+
+ ret = legacy_player_is_muted((player_h)handle, &mute);
+
+ player_msg_return1(api, ret, module, INT, mute);
+
+ return ret;
+}
+
+static int player_disp_get_duration(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_GET_DURATION;
+ int duration = 0;
+
+ handle = muse_core_ipc_get_handle(module);
+
+ ret = legacy_player_get_duration((player_h)handle, &duration);
+
+ player_msg_return1(api, ret, module, INT, duration);
+
+ return ret;
+}
+
+static int player_disp_set_sound_type(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_SET_SOUND_TYPE;
+ int type;
+
+ handle = muse_core_ipc_get_handle(module);
+ player_msg_get(type, muse_core_client_get_msg(module));
+
+ ret = legacy_player_set_sound_type((player_h)handle, (sound_type_e)type);
+
+ player_msg_return(api, ret, module);
+
+ return ret;
+}
+
+static int player_disp_set_audio_policy_info(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_SET_AUDIO_POLICY_INFO;
+ int stream_index;
+ char stream_type[MUSE_URI_MAX_LENGTH] = { 0, };
+
+ handle = muse_core_ipc_get_handle(module);
+ player_msg_get(stream_index, muse_core_client_get_msg(module));
+ player_msg_get_string(stream_type, muse_core_client_get_msg(module));
+
+ ret = legacy_player_set_audio_policy_info_for_mused((player_h)handle, stream_type, stream_index);
+
+ player_msg_return(api, ret, module);
+
+ return ret;
+}
+
+static int player_disp_set_latency_mode(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_SET_AUDIO_LATENCY_MODE;
+ int latency_mode;
+
+ handle = muse_core_ipc_get_handle(module);
+ player_msg_get(latency_mode, muse_core_client_get_msg(module));
+
+ ret = legacy_player_set_audio_latency_mode((player_h)handle, (audio_latency_mode_e)latency_mode);
+
+ player_msg_return(api, ret, module);
+
+ return ret;
+}
+
+static int player_disp_get_latency_mode(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_GET_AUDIO_LATENCY_MODE;
+ audio_latency_mode_e latency_mode;
+
+ handle = muse_core_ipc_get_handle(module);
+
+ ret = legacy_player_get_audio_latency_mode((player_h)handle, &latency_mode);
+
+ player_msg_return1(api, ret, module, INT, latency_mode);
+
+ return ret;
+}
+
+static int player_disp_set_looping(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_SET_LOOPING;
+ int looping;
+
+ handle = muse_core_ipc_get_handle(module);
+ player_msg_get(looping, muse_core_client_get_msg(module));
+
+ ret = legacy_player_set_looping((player_h)handle, (bool)looping);
+
+ player_msg_return(api, ret, module);
+
+ return ret;
+}
+
+static int player_disp_is_looping(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_IS_LOOPING;
+ bool looping;
+
+ handle = muse_core_ipc_get_handle(module);
+
+ ret = legacy_player_is_looping((player_h)handle, &looping);
+
+ player_msg_return1(api, ret, module, INT, looping);
+
+ return ret;
+}
+
+static int player_disp_set_display_mode(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_SET_DISPLAY_MODE;
+ int mode = 0;
+
+ handle = muse_core_ipc_get_handle(module);
+ player_msg_get(mode, muse_core_client_get_msg(module));
+
+ ret = legacy_player_set_display_mode((player_h)handle, (player_display_mode_e)mode);
+
+ player_msg_return(api, ret, module);
+
+ return ret;
+}
+
+static int player_disp_get_display_mode(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_GET_DISPLAY_MODE;
+ player_display_mode_e mode = 0;
+
+ handle = muse_core_ipc_get_handle(module);
+
+ ret = legacy_player_get_display_mode((player_h)handle, &mode);
+
+ player_msg_return1(api, ret, module, INT, mode);
+
+ return ret;
+}
+
+static int player_disp_set_playback_rate(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_SET_PLAYBACK_RATE;
+ double rate = 0;
+
+ handle = muse_core_ipc_get_handle(module);
+ player_msg_get_type(rate, muse_core_client_get_msg(module), DOUBLE);
+
+ ret = legacy_player_set_playback_rate((player_h)handle, (float)rate);
+
+ player_msg_return(api, ret, module);
+
+ return ret;
+}
+
+static int player_disp_set_display_rotation(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_SET_DISPLAY_ROTATION;
+ int rotation = 0;
+
+ handle = muse_core_ipc_get_handle(module);
+ player_msg_get(rotation, muse_core_client_get_msg(module));
+
+ ret = legacy_player_set_display_rotation((player_h)handle, (player_display_rotation_e)rotation);
+
+ player_msg_return(api, ret, module);
+
+ return ret;
+}
+
+static int player_disp_get_display_rotation(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_GET_DISPLAY_ROTATION;
+ player_display_rotation_e rotation;
+
+ handle = muse_core_ipc_get_handle(module);
+
+ ret = legacy_player_get_display_rotation((player_h)handle, &rotation);
+
+ player_msg_return1(api, ret, module, INT, rotation);
+
+ return ret;
+}
+
+static int player_disp_set_display_visible(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_SET_DISPLAY_VISIBLE;
+ int visible = 0;
+
+ handle = muse_core_ipc_get_handle(module);
+ player_msg_get(visible, muse_core_client_get_msg(module));
+
+ ret = legacy_player_set_display_visible((player_h)handle, visible);
+
+ player_msg_return(api, ret, module);
+
+ return ret;
+}
+
+static int player_disp_is_display_visible(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_IS_DISPLAY_VISIBLE;
+ bool visible = 0;
+
+ handle = muse_core_ipc_get_handle(module);
+
+ ret = legacy_player_is_display_visible((player_h)handle, &visible);
+
+ player_msg_return1(api, ret, module, INT, visible);
+
+ return ret;
+}
+#ifdef HAVE_WAYLAND
+static int player_disp_resize_video_render_rect(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_RESIZE_VIDEO_RENDER_RECT;
+
+ wl_win_msg_type wl_win;
+ char *wl_win_msg = (char *)&wl_win;
+
+ handle = muse_core_ipc_get_handle(module);
+
+ player_msg_get_array(wl_win_msg, muse_core_client_get_msg(module));
+
+ ret = legacy_player_resize_video_render_rect((player_h)handle, wl_win.wl_window_x, wl_win.wl_window_y, wl_win.wl_window_width, wl_win.wl_window_height);
+ player_msg_return(api, ret, module);
+
+ return ret;
+
+}
+#endif
+static int player_disp_get_content_info(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_GET_CONTENT_INFO;
+ char *value;
+ player_content_info_e key;
+
+ handle = muse_core_ipc_get_handle(module);
+ player_msg_get(key, muse_core_client_get_msg(module));
+
+ ret = legacy_player_get_content_info((player_h)handle, key, &value);
+
+ if (ret == PLAYER_ERROR_NONE) {
+ player_msg_return1(api, ret, module, STRING, value);
+ free(value);
+ } else
+ player_msg_return(api, ret, module);
+
+ return ret;
+}
+
+static int player_disp_get_codec_info(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_GET_CODEC_INFO;
+ char *video_codec;
+ char *audio_codec;
+
+ handle = muse_core_ipc_get_handle(module);
+
+ ret = legacy_player_get_codec_info((player_h)handle, &audio_codec, &video_codec);
+
+ if (ret == PLAYER_ERROR_NONE) {
+ player_msg_return2(api, ret, module, STRING, audio_codec, STRING, video_codec);
+
+ free(audio_codec);
+ free(video_codec);
+ } else
+ player_msg_return(api, ret, module);
+
+ return ret;
+}
+
+static int player_disp_get_audio_stream_info(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_GET_AUDIO_STREAM_INFO;
+ int sample_rate = 0;
+ int channel = 0;
+ int bit_rate = 0;
+
+ handle = muse_core_ipc_get_handle(module);
+
+ ret = legacy_player_get_audio_stream_info((player_h)handle, &sample_rate, &channel, &bit_rate);
+
+ player_msg_return3(api, ret, module, INT, sample_rate, INT, channel, INT, bit_rate);
+
+ return ret;
+}
+
+static int player_disp_get_video_stream_info(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_GET_VIDEO_STREAM_INFO;
+ int fps = 0;
+ int bit_rate = 0;
+
+ handle = muse_core_ipc_get_handle(module);
+
+ ret = legacy_player_get_video_stream_info((player_h)handle, &fps, &bit_rate);
+
+ player_msg_return2(api, ret, module, INT, fps, INT, bit_rate);
+
+ return ret;
+}
+
+static int player_disp_get_video_size(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_GET_VIDEO_SIZE;
+ int width = 0;
+ int height = 0;
+
+ handle = muse_core_ipc_get_handle(module);
+
+ ret = legacy_player_get_video_size((player_h)handle, &width, &height);
+
+ player_msg_return2(api, ret, module, INT, width, INT, height);
+
+ return ret;
+}
+
+static int player_disp_get_album_art(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_GET_ALBUM_ART;
+ void *album_art;
+ int size;
+
+ handle = muse_core_ipc_get_handle(module);
+
+ ret = legacy_player_get_album_art((player_h)handle, &album_art, &size);
+
+ if (ret == PLAYER_ERROR_NONE)
+ player_msg_return_array(api, ret, module, album_art, size, sizeof(char));
+ else
+ player_msg_return(api, ret, module);
+
+ return ret;
+}
+
+static int player_disp_get_eq_bands_count(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_BANDS_COUNT;
+ int count;
+
+ handle = muse_core_ipc_get_handle(module);
+
+ ret = legacy_player_audio_effect_get_equalizer_bands_count((player_h)handle, &count);
+
+ player_msg_return1(api, ret, module, INT, count);
+
+ return ret;
+}
+
+static int player_disp_set_eq_all_bands(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_SET_EQUALIZER_ALL_BANDS;
+ int *band_levels;
+ int length;
+
+ handle = muse_core_ipc_get_handle(module);
+ player_msg_get(length, muse_core_client_get_msg(module));
+ band_levels = (int *)g_try_new(int, length);
+
+ if (band_levels) {
+ player_msg_get_array(band_levels, muse_core_client_get_msg(module));
+ ret = legacy_player_audio_effect_set_equalizer_all_bands((player_h)handle, band_levels, length);
+ g_free(band_levels);
+ } else
+ ret = PLAYER_ERROR_INVALID_OPERATION;
+
+ player_msg_return(api, ret, module);
+
+ return ret;
+}
+
+static int player_disp_set_eq_band_level(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_SET_EQUALIZER_BAND_LEVEL;
+ int index, level;
+
+ handle = muse_core_ipc_get_handle(module);
+ player_msg_get(index, muse_core_client_get_msg(module));
+ player_msg_get(level, muse_core_client_get_msg(module));
+
+ ret = legacy_player_audio_effect_set_equalizer_band_level((player_h)handle, index, level);
+
+ player_msg_return(api, ret, module);
+
+ return ret;
+}
+
+static int player_disp_get_eq_band_level(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_BAND_LEVEL;
+ int index, level;
+
+ handle = muse_core_ipc_get_handle(module);
+ player_msg_get(index, muse_core_client_get_msg(module));
+
+ ret = legacy_player_audio_effect_get_equalizer_band_level((player_h)handle, index, &level);
+
+ player_msg_return1(api, ret, module, INT, level);
+
+ return ret;
+}
+
+static int player_disp_get_eq_level_range(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_LEVEL_RANGE;
+ int min, max;
+
+ handle = muse_core_ipc_get_handle(module);
+
+ ret = legacy_player_audio_effect_get_equalizer_level_range((player_h)handle, &min, &max);
+
+ player_msg_return2(api, ret, module, INT, min, INT, max);
+
+ return ret;
+}
+
+static int player_disp_get_eq_band_frequency(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_BAND_FREQUENCY;
+ int index, frequency;
+
+ handle = muse_core_ipc_get_handle(module);
+ player_msg_get(index, muse_core_client_get_msg(module));
+
+ ret = legacy_player_audio_effect_get_equalizer_band_frequency((player_h)handle, index, &frequency);
+
+ player_msg_return1(api, ret, module, INT, frequency);
+
+ return ret;
+}
+
+static int player_disp_get_eq_band_frequency_range(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_BAND_FREQUENCY_RANGE;
+ int index, range;
+
+ handle = muse_core_ipc_get_handle(module);
+ player_msg_get(index, muse_core_client_get_msg(module));
+
+ ret = legacy_player_audio_effect_get_equalizer_band_frequency_range((player_h)handle, index, &range);
+
+ player_msg_return1(api, ret, module, INT, range);
+
+ return ret;
+}
+
+static int player_disp_eq_clear(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_EQUALIZER_CLEAR;
+
+ handle = muse_core_ipc_get_handle(module);
+
+ ret = legacy_player_audio_effect_equalizer_clear((player_h)handle);
+
+ player_msg_return(api, ret, module);
+
+ return ret;
+}
+
+static int player_disp_eq_is_available(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_EQUALIZER_IS_AVAILABLE;
+ bool available;
+
+ handle = muse_core_ipc_get_handle(module);
+
+ ret = legacy_player_audio_effect_equalizer_is_available((player_h)handle, &available);
+
+ player_msg_return1(api, ret, module, INT, available);
+
+ return ret;
+}
+
+static int player_disp_set_subtitle_path(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_SET_SUBTITLE_PATH;
+ char path[MUSE_URI_MAX_LENGTH] = { 0, };
+
+ handle = muse_core_ipc_get_handle(module);
+ player_msg_get_string(path, muse_core_client_get_msg(module));
+
+ ret = legacy_player_set_subtitle_path((player_h)handle, path);
+
+ player_msg_return(api, ret, module);
+
+ return ret;
+}
+
+static int player_disp_set_subtitle_position_offset(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_SET_SUBTITLE_POSITION_OFFSET;
+ int millisecond;
+
+ handle = muse_core_ipc_get_handle(module);
+ player_msg_get(millisecond, muse_core_client_get_msg(module));
+
+ ret = legacy_player_set_subtitle_position_offset((player_h)handle, millisecond);
+
+ player_msg_return(api, ret, module);
+
+ return ret;
+}
+
+static int player_disp_set_progressive_download_path(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_SET_PROGRESSIVE_DOWNLOAD_PATH;
+ char path[MUSE_URI_MAX_LENGTH] = { 0, };
+
+ handle = muse_core_ipc_get_handle(module);
+ player_msg_get_string(path, muse_core_client_get_msg(module));
+
+ ret = legacy_player_set_progressive_download_path((player_h)handle, path);
+ player_msg_return(api, ret, module);
+
+ return ret;
+}
+
+static int player_disp_get_progressive_download_status(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_GET_PROGRESSIVE_DOWNLOAD_STATUS;
+ unsigned long current = 0;
+ unsigned long total_size = 0;
+
+ handle = muse_core_ipc_get_handle(module);
+
+ ret = legacy_player_get_progressive_download_status((player_h)handle, ¤t, &total_size);
+
+ player_msg_return2(api, ret, module, POINTER, current, POINTER, total_size);
+
+ return ret;
+}
+
+static int player_disp_capture_video(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_CAPTURE_VIDEO;
+
+ handle = muse_core_ipc_get_handle(module);
+
+ ret = legacy_player_capture_video((player_h)handle, _capture_video_cb, module);
+
+ player_msg_return(api, ret, module);
+
+ return ret;
+}
+
+static int player_disp_set_streaming_cookie(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_SET_STREAMING_COOKIE;
+ char *cookie = NULL;
+ int size;
+
+ handle = muse_core_ipc_get_handle(module);
+ player_msg_get(size, muse_core_client_get_msg(module));
+ cookie = (char *)g_try_new(char, size + 1);
+ if (cookie) {
+ player_msg_get_string(cookie, muse_core_client_get_msg(module));
+ ret = legacy_player_set_streaming_cookie((player_h)handle, cookie, size);
+ g_free(cookie);
+ } else
+ ret = PLAYER_ERROR_INVALID_OPERATION;
+
+ player_msg_return(api, ret, module);
+
+ return ret;
+}
+
+static int player_disp_set_streaming_user_agent(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_SET_STREAMING_USER_AGENT;
+ char *user_agent;
+ int size;
+
+ handle = muse_core_ipc_get_handle(module);
+ player_msg_get(size, muse_core_client_get_msg(module));
+ user_agent = (char *)g_try_new(char, size + 1);
+ if (user_agent) {
+ player_msg_get_string(user_agent, muse_core_client_get_msg(module));
+ ret = legacy_player_set_streaming_user_agent((player_h)handle, user_agent, size);
+ g_free(user_agent);
+ } else
+ ret = PLAYER_ERROR_INVALID_OPERATION;
+
+ player_msg_return(api, ret, module);
+
+ return ret;
+}
+
+static int player_disp_get_streaming_download_progress(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_GET_STREAMING_DOWNLOAD_PROGRESS;
+ int start, current;
+
+ handle = muse_core_ipc_get_handle(module);
+
+ ret = legacy_player_get_streaming_download_progress((player_h)handle, &start, ¤t);
+
+ player_msg_return2(api, ret, module, INT, start, INT, current);
+
+ return ret;
+}
+
+static int _push_media_stream(intptr_t handle, player_push_media_msg_type *push_media, char *buf)
+{
+ int ret = MEDIA_FORMAT_ERROR_NONE;
+ media_format_h format;
+ media_packet_h packet;
+ media_format_mimetype_e mimetype;
+
+ if (push_media->mimetype & MEDIA_FORMAT_VIDEO) {
+ if (!video_format) {
+ media_format_create(&video_format);
+ if (!video_format) {
+ LOGE("fail to create media format");
+ return PLAYER_ERROR_INVALID_PARAMETER;
+ }
+ ret |= media_format_set_video_mime(video_format, push_media->mimetype);
+ }
+ ret |= media_format_get_video_info(video_format, &mimetype, NULL, NULL, NULL, NULL);
+ if (mimetype != push_media->mimetype) {
+ media_format_unref(video_format);
+ media_format_create(&video_format);
+ ret |= media_format_set_video_mime(video_format, push_media->mimetype);
+ }
+ format = video_format;
+ } else if (push_media->mimetype & MEDIA_FORMAT_AUDIO) {
+ if (!audio_format) {
+ media_format_create(&audio_format);
+ if (!audio_format) {
+ LOGE("fail to create media format");
+ return PLAYER_ERROR_INVALID_PARAMETER;
+ }
+ ret |= media_format_set_audio_mime(audio_format, push_media->mimetype);
+ }
+ ret |= media_format_get_audio_info(audio_format, &mimetype, NULL, NULL, NULL, NULL);
+ if (mimetype != push_media->mimetype) {
+ media_format_unref(audio_format);
+ media_format_create(&audio_format);
+ ret |= media_format_set_audio_mime(audio_format, push_media->mimetype);
+ }
+ format = audio_format;
+ } else
+ ret = MEDIA_FORMAT_ERROR_INVALID_PARAMETER;
+
+ if (ret != MEDIA_FORMAT_ERROR_NONE) {
+ LOGE("Invalid MIME %d", push_media->mimetype);
+ return PLAYER_ERROR_INVALID_PARAMETER;
+ }
+
+ if (buf) {
+ ret = media_packet_create_from_external_memory(format, buf, push_media->size, NULL, NULL, &packet);
+ if (ret != MEDIA_PACKET_ERROR_NONE) {
+ LOGE("fail to create media packet with external mem");
+ return PLAYER_ERROR_INVALID_PARAMETER;
+ }
+ } else {
+ ret = media_packet_create(format, NULL, NULL, &packet);
+ if (ret != MEDIA_PACKET_ERROR_NONE) {
+ LOGE("fail to create media packet");
+ return PLAYER_ERROR_INVALID_PARAMETER;
+ }
+ }
+
+ media_packet_set_pts(packet, push_media->pts);
+ media_packet_set_flags(packet, push_media->flags);
+
+ ret = legacy_player_push_media_stream((player_h)handle, packet);
+ if (ret != PLAYER_ERROR_NONE)
+ LOGE("ret %d", ret);
+
+ media_packet_destroy(packet);
+
+ return ret;
+}
+
+static int player_disp_push_media_stream(muse_module_h module)
+{
+ int ret = MEDIA_FORMAT_ERROR_NONE;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_PUSH_MEDIA_STREAM;
+ player_push_media_msg_type push_media;
+ char *push_media_msg = (char *)&push_media;
+ tbm_bo bo = NULL;
+ tbm_bo_handle thandle;
+ char *buf = NULL;
+
+ handle = muse_core_ipc_get_handle(module);
+ if (!player_msg_get_array(push_media_msg, muse_core_client_get_msg(module))) {
+ ret = PLAYER_ERROR_INVALID_OPERATION;
+ goto push_media_stream_exit1;
+ }
+
+ if (push_media.buf_type == PUSH_MEDIA_BUF_TYPE_TBM) {
+ bo = tbm_bo_import(bufmgr, push_media.key);
+ if (bo == NULL) {
+ LOGE("TBM get error : bo is NULL");
+ ret = PLAYER_ERROR_INVALID_OPERATION;
+ goto push_media_stream_exit1;
+ }
+ thandle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
+ if (thandle.ptr == NULL) {
+ LOGE("TBM get error : handle pointer is NULL");
+ ret = PLAYER_ERROR_INVALID_OPERATION;
+ goto push_media_stream_exit2;
+ }
+ buf = thandle.ptr;
+ } else if (push_media.buf_type == PUSH_MEDIA_BUF_TYPE_MSG) {
+ buf = g_new(char, push_media.size);
+ if (!buf) {
+ ret = PLAYER_ERROR_OUT_OF_MEMORY;
+ goto push_media_stream_exit1;
+ }
+ player_msg_get_array(buf, muse_core_client_get_msg(module));
+ } else if (push_media.buf_type == PUSH_MEDIA_BUF_TYPE_RAW) {
+ buf = muse_core_ipc_get_data(module);
+ }
+
+ ret = _push_media_stream(handle, &push_media, buf);
+
+ if (push_media.buf_type == PUSH_MEDIA_BUF_TYPE_TBM)
+ tbm_bo_unmap(bo);
+push_media_stream_exit2:
+ if (push_media.buf_type == PUSH_MEDIA_BUF_TYPE_TBM)
+ tbm_bo_unref(bo);
+ else if (push_media.buf_type == PUSH_MEDIA_BUF_TYPE_MSG)
+ g_free(buf);
+ else if (push_media.buf_type == PUSH_MEDIA_BUF_TYPE_RAW && buf)
+ muse_core_ipc_delete_data(buf);
+push_media_stream_exit1:
+ player_msg_return(api, ret, module);
+ return ret;
+}
+
+static int player_disp_set_media_stream_info(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_SET_MEDIA_STREAM_INFO;
+ media_format_mimetype_e mimetype;
+ player_stream_type_e type;
+ int width;
+ int height;
+ int avg_bps;
+ int max_bps;
+ int channel;
+ int samplerate;
+ int bit;
+ media_format_h format;
+
+ handle = muse_core_ipc_get_handle(module);
+ player_msg_get(mimetype, muse_core_client_get_msg(module));
+ player_msg_get(type, muse_core_client_get_msg(module));
+ player_msg_get(avg_bps, muse_core_client_get_msg(module));
+ if (type == PLAYER_STREAM_TYPE_VIDEO) {
+ player_msg_get(width, muse_core_client_get_msg(module));
+ player_msg_get(height, muse_core_client_get_msg(module));
+ player_msg_get(max_bps, muse_core_client_get_msg(module));
+ } else if (type == PLAYER_STREAM_TYPE_AUDIO) {
+ player_msg_get(channel, muse_core_client_get_msg(module));
+ player_msg_get(samplerate, muse_core_client_get_msg(module));
+ player_msg_get(bit, muse_core_client_get_msg(module));
+ } else {
+ ret = PLAYER_ERROR_INVALID_PARAMETER;
+ goto set_media_stream_info_exit;
+ }
+
+ if (media_format_create(&format) == MEDIA_FORMAT_ERROR_NONE) {
+ if (type == PLAYER_STREAM_TYPE_VIDEO) {
+ ret = media_format_set_video_mime(format, mimetype);
+ ret |= media_format_set_video_width(format, width);
+ ret |= media_format_set_video_height(format, height);
+ ret |= media_format_set_video_avg_bps(format, avg_bps);
+ ret |= media_format_set_video_max_bps(format, max_bps);
+ } else if (type == PLAYER_STREAM_TYPE_AUDIO) {
+ ret = media_format_set_audio_mime(format, mimetype);
+ ret |= media_format_set_audio_channel(format, channel);
+ ret |= media_format_set_audio_samplerate(format, samplerate);
+ ret |= media_format_set_audio_bit(format, bit);
+ ret |= media_format_set_audio_avg_bps(format, avg_bps);
+ }
+ if (ret != MEDIA_FORMAT_ERROR_NONE) {
+ ret = PLAYER_ERROR_INVALID_OPERATION;
+ goto set_media_stream_info_exit;
+ }
+ } else {
+ ret = PLAYER_ERROR_OUT_OF_MEMORY;
+ goto set_media_stream_info_exit;
+ }
+
+ ret = legacy_player_set_media_stream_info((player_h)handle, type, format);
+
+ set_media_stream_info_exit:
+ player_msg_return(api, ret, module);
+ return ret;
+}
+
+static int player_disp_media_packet_finalize_cb(muse_module_h module)
+{
+ media_packet_h packet;
+
+ player_msg_get_type(packet, muse_core_client_get_msg(module), POINTER);
+
+ media_packet_destroy(packet);
+
+ return PLAYER_ERROR_NONE;
+}
+
+static int player_disp_set_media_stream_buffer_max_size(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_SET_MEDIA_STREAM_BUFFER_MAX_SIZE;
+ player_stream_type_e type;
+ unsigned long long max_size;
+ /* unsigned upper_max_size, lower_max_size; */
+
+ handle = muse_core_ipc_get_handle(module);
+ player_msg_get(type, muse_core_client_get_msg(module));
+#if 0
+ player_msg_get(upper_max_size, muse_core_client_get_msg(module));
+ player_msg_get(lower_max_size, muse_core_client_get_msg(module));
+
+ max_size = (((unsigned long long)upper_max_size << 32) & 0xffffffff00000000)
+ | (lower_max_size & 0xffffffff);
+#else
+ player_msg_get_type(max_size, muse_core_client_get_msg(module), INT64);
+#endif
+
+ ret = legacy_player_set_media_stream_buffer_max_size((player_h) handle, type, max_size);
+
+ player_msg_return(api, ret, module);
+
+ return ret;
+}
+
+static int player_disp_get_media_stream_buffer_max_size(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_GET_MEDIA_STREAM_BUFFER_MAX_SIZE;
+ player_stream_type_e type;
+ unsigned long long max_size;
+ /* unsigned upper_max_size, lower_max_size; */
+
+ handle = muse_core_ipc_get_handle(module);
+ player_msg_get(type, muse_core_client_get_msg(module));
+
+ ret = legacy_player_get_media_stream_buffer_max_size((player_h)handle, type, &max_size);
+ if (ret == PLAYER_ERROR_NONE) {
+#if 0
+ upper_max_size = (unsigned)((max_size >> 32) & 0xffffffff);
+ lower_max_size = (unsigned)(max_size & 0xffffffff);
+ player_msg_return2(api, ret, module, INT, upper_max_size, INT, lower_max_size);
+#else
+ player_msg_return1(api, ret, module, INT64, max_size);
+#endif
+ } else
+ player_msg_return(api, ret, module);
+
+ return ret;
+}
+
+static int player_disp_set_media_stream_buffer_min_threshold(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_SET_MEDIA_STREAM_BUFFER_MIN_THRESHOLD;
+ player_stream_type_e type;
+ unsigned percent;
+
+ handle = muse_core_ipc_get_handle(module);
+ player_msg_get(type, muse_core_client_get_msg(module));
+ player_msg_get(percent, muse_core_client_get_msg(module));
+
+ ret = legacy_player_set_media_stream_buffer_min_threshold((player_h)handle, type, percent);
+
+ player_msg_return(api, ret, module);
+
+ return ret;
+}
+
+static int player_disp_get_media_stream_buffer_min_threshold(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_GET_MEDIA_STREAM_BUFFER_MIN_THRESHOLD;
+ player_stream_type_e type;
+ unsigned percent;
+
+ handle = muse_core_ipc_get_handle(module);
+ player_msg_get(type, muse_core_client_get_msg(module));
+
+ ret = legacy_player_get_media_stream_buffer_min_threshold((player_h)handle, type, &percent);
+ if (ret == PLAYER_ERROR_NONE)
+ player_msg_return1(api, ret, module, INT, percent);
+ else
+ player_msg_return(api, ret, module);
+
+ return ret;
+}
+
+static int player_disp_get_track_count(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_GET_TRACK_COUNT;
+ player_stream_type_e type;
+ int count;
+
+ handle = muse_core_ipc_get_handle(module);
+ player_msg_get(type, muse_core_client_get_msg(module));
+
+ ret = legacy_player_get_track_count((player_h)handle, type, &count);
+ if (ret == PLAYER_ERROR_NONE)
+ player_msg_return1(api, ret, module, INT, count);
+ else
+ player_msg_return(api, ret, module);
+
+ return ret;
+}
+
+static int player_disp_get_current_track(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_GET_CURRENT_TRACK;
+ player_stream_type_e type;
+ int index;
+
+ handle = muse_core_ipc_get_handle(module);
+ player_msg_get(type, muse_core_client_get_msg(module));
+
+ ret = legacy_player_get_current_track((player_h)handle, type, &index);
+ if (ret == PLAYER_ERROR_NONE)
+ player_msg_return1(api, ret, module, INT, index);
+ else
+ player_msg_return(api, ret, module);
+
+ return ret;
+}
+
+static int player_disp_select_track(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_SELECT_TRACK;
+ player_stream_type_e type;
+ int index;
+
+ handle = muse_core_ipc_get_handle(module);
+ player_msg_get(type, muse_core_client_get_msg(module));
+ player_msg_get(index, muse_core_client_get_msg(module));
+
+ ret = legacy_player_select_track((player_h)handle, type, index);
+ player_msg_return(api, ret, module);
+
+ return ret;
+}
+
+static int player_disp_get_track_language_code(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_GET_TRACK_LANGUAGE_CODE;
+ player_stream_type_e type;
+ int index;
+ char *code;
+ const int code_len = 2;
+
+ handle = muse_core_ipc_get_handle(module);
+ player_msg_get(type, muse_core_client_get_msg(module));
+ player_msg_get(index, muse_core_client_get_msg(module));
+
+ ret = legacy_player_get_track_language_code((player_h)handle, type, index, &code);
+ if (ret == PLAYER_ERROR_NONE)
+ player_msg_return_array(api, ret, module, code, code_len, sizeof(char));
+ else
+ player_msg_return(api, ret, module);
+
+ return ret;
+}
+
+static int player_disp_set_pcm_extraction_mode(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_SET_PCM_EXTRACTION_MODE;
+ int sync;
+
+ handle = muse_core_ipc_get_handle(module);
+ player_msg_get(sync, muse_core_client_get_msg(module));
+
+ ret = legacy_player_set_pcm_extraction_mode((player_h)handle, sync, _audio_frame_decoded_cb, module);
+
+ player_msg_return(api, ret, module);
+
+ return ret;
+}
+
+static int player_disp_set_pcm_spec(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_SET_PCM_SPEC;
+ char format[MUSE_URI_MAX_LENGTH] = { 0, };
+ int samplerate;
+ int channel;
+
+ handle = muse_core_ipc_get_handle(module);
+ player_msg_get_string(format, muse_core_client_get_msg(module));
+ player_msg_get(samplerate, muse_core_client_get_msg(module));
+ player_msg_get(channel, muse_core_client_get_msg(module));
+
+ ret = legacy_player_set_pcm_spec((player_h)handle, format, samplerate, channel);
+
+ player_msg_return(api, ret, module);
+
+ return ret;
+}
+
+static int player_disp_set_streaming_playback_rate(muse_module_h module)
+{
+ int ret = -1;
+ intptr_t handle;
+ muse_player_api_e api = MUSE_PLAYER_API_SET_STREAMING_PLAYBACK_RATE;
+ double rate = 0;
+
+ handle = muse_core_ipc_get_handle(module);
+ player_msg_get_type(rate, muse_core_client_get_msg(module), DOUBLE);
+
+ ret = legacy_player_set_streaming_playback_rate((player_h)handle, (float)rate);
+
+ player_msg_return(api, ret, module);
+
+ return ret;
+}
+
+int (*dispatcher[MUSE_PLAYER_API_MAX])(muse_module_h module) = {
+ player_disp_create, /* MUSE_PLAYER_API_CREATE */
+ player_disp_destroy, /* MUSE_PLAYER_API_DESTROY */
+ player_disp_prepare, /* MUSE_PLAYER_API_PREPARE */
+ player_disp_prepare_async, /* MUSE_PLAYER_API_PREPARE_ASYNC */
+ player_disp_unprepare, /* MUSE_PLAYER_API_UNPREPARE */
+ player_disp_set_uri, /* MUSE_PLAYER_API_SET_URI */
+ player_disp_start, /* MUSE_PLAYER_API_START */
+ player_disp_stop, /* MUSE_PLAYER_API_STOP */
+ player_disp_pause, /* MUSE_PLAYER_API_PAUSE */
+ player_disp_set_memory_buffer, /* MUSE_PLAYER_API_SET_MEMORY_BUFFER */
+ player_disp_deinit_memory_buffer, /* MUSE_PLAYER_API_DEINIT_MEMORY_BUFFER */
+ player_disp_get_state, /* MUSE_PLAYER_API_GET_STATE */
+ player_disp_set_volume, /* MUSE_PLAYER_API_SET_VOLUME */
+ player_disp_get_volume, /* MUSE_PLAYER_API_GET_VOLUME */
+ player_disp_set_sound_type, /* MUSE_PLAYER_API_SET_SOUND_TYPE */
+ player_disp_set_audio_policy_info, /* MUSE_PLAYER_API_SET_AUDIO_POLICY_INFO */
+ player_disp_set_latency_mode, /* MUSE_PLAYER_API_SET_AUDIO_LATENCY_MODE */
+ player_disp_get_latency_mode, /* MUSE_PLAYER_API_GET_AUDIO_LATENCY_MODE */
+ player_disp_set_play_position, /* MUSE_PLAYER_API_SET_PLAY_POSITION */
+ player_disp_get_play_position, /* MUSE_PLAYER_API_GET_PLAY_POSITION */
+ player_disp_set_mute, /* MUSE_PLAYER_API_SET_MUTE */
+ player_disp_is_muted, /* MUSE_PLAYER_API_IS_MUTED */
+ player_disp_set_looping, /* MUSE_PLAYER_API_SET_LOOPING */
+ player_disp_is_looping, /* MUSE_PLAYER_API_IS_LOOPING */
+ player_disp_get_duration, /* MUSE_PLAYER_API_GET_DURATION */
+ player_disp_set_display, /* MUSE_PLAYER_API_SET_DISPLAY */
+ player_disp_set_display_mode, /* MUSE_PLAYER_API_SET_DISPLAY_MODE */
+ player_disp_get_display_mode, /* MUSE_PLAYER_API_GET_DISPLAY_MODE */
+ player_disp_set_playback_rate, /* MUSE_PLAYER_API_SET_PLAYBACK_RATE */
+ player_disp_set_display_rotation, /* MUSE_PLAYER_API_SET_DISPLAY_ROTATION */
+ player_disp_get_display_rotation, /* MUSE_PLAYER_API_GET_DISPLAY_ROTATION */
+ player_disp_set_display_visible, /* MUSE_PLAYER_API_SET_DISPLAY_VISIBLE */
+ player_disp_is_display_visible, /* MUSE_PLAYER_API_IS_DISPLAY_VISIBLE */
+ player_disp_resize_video_render_rect, /* MUSE_PLAYER_API_RESIZE_VIDEO_RENDER_RECT */
+ player_disp_get_content_info, /* MUSE_PLAYER_API_GET_CONTENT_INFO */
+ player_disp_get_codec_info, /* MUSE_PLAYER_API_GET_CODEC_INFO */
+ player_disp_get_audio_stream_info, /* MUSE_PLAYER_API_GET_AUDIO_STREAM_INFO */
+ player_disp_get_video_stream_info, /* MUSE_PLAYER_API_GET_VIDEO_STREAM_INFO */
+ player_disp_get_video_size, /* MUSE_PLAYER_API_GET_VIDEO_SIZE */
+ player_disp_get_album_art, /* MUSE_PLAYER_API_GET_ALBUM_ART */
+ player_disp_get_eq_bands_count, /* MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_BANDS_COUNT */
+ player_disp_set_eq_all_bands, /* MUSE_PLAYER_API_AUDIO_EFFECT_SET_EQUALIZER_ALL_BANDS */
+ player_disp_set_eq_band_level, /* MUSE_PLAYER_API_AUDIO_EFFECT_SET_EQUALIZER_BAND_LEVEL */
+ player_disp_get_eq_band_level, /* MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_BAND_LEVEL */
+ player_disp_get_eq_level_range, /* MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_LEVEL_RANGE */
+ player_disp_get_eq_band_frequency, /* MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_BAND_FREQUENCY */
+ player_disp_get_eq_band_frequency_range, /* MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_BAND_FREQUENCY_RANGE */
+ player_disp_eq_clear, /* MUSE_PLAYER_API_AUDIO_EFFECT_EQUALIZER_CLEAR */
+ player_disp_eq_is_available, /* MUSE_PLAYER_API_AUDIO_EFFECT_EQUALIZER_IS_AVAILABLE */
+ player_disp_set_progressive_download_path, /* MUSE_PLAYER_API_SET_PROGRESSIVE_DOWNLOAD_PATH */
+ player_disp_get_progressive_download_status, /* MUSE_PLAYER_API_GET_PROGRESSIVE_DOWNLOAD_STATUS */
+ player_disp_capture_video, /* MUSE_PLAYER_API_CAPTURE_VIDEO */
+ player_disp_set_streaming_cookie, /* MUSE_PLAYER_API_SET_STREAMING_COOKIE */
+ player_disp_set_streaming_user_agent, /* MUSE_PLAYER_API_SET_STREAMING_USER_AGENT */
+ player_disp_get_streaming_download_progress, /* MUSE_PLAYER_API_GET_STREAMING_DOWNLOAD_PROGRESS */
+ player_disp_set_subtitle_path, /* MUSE_PLAYER_API_SET_SUBTITLE_PATH */
+ player_disp_set_subtitle_position_offset, /* MUSE_PLAYER_API_SET_SUBTITLE_POSITION_OFFSET */
+ player_disp_push_media_stream, /* MUSE_PLAYER_API_PUSH_MEDIA_STREAM */
+ player_disp_set_media_stream_info, /* MUSE_PLAYER_API_SET_MEDIA_STREAM_INFO */
+ player_disp_set_callback, /* MUSE_PLAYER_API_SET_CALLBACK */
+ player_disp_media_packet_finalize_cb, /* MUSE_PLAYER_API_MEDIA_PACKET_FINALIZE_CB */
+ player_disp_set_media_stream_buffer_max_size, /* MUSE_PLAYER_API_SET_MEDIA_STREAM_BUFFER_MAX_SIZE */
+ player_disp_get_media_stream_buffer_max_size, /* MUSE_PLAYER_API_GET_MEDIA_STREAM_BUFFER_MAX_SIZE */
+ player_disp_set_media_stream_buffer_min_threshold, /* MUSE_PLAYER_API_SET_MEDIA_STREAM_BUFFER_MIN_THRESHOLD */
+ player_disp_get_media_stream_buffer_min_threshold, /* MUSE_PLAYER_API_GET_MEDIA_STREAM_BUFFER_MIN_THRESHOLD */
+ player_disp_get_track_count, /* MUSE_PLAYER_API_GET_TRACK_COUNT */
+ player_disp_get_current_track, /* MUSE_PLAYER_API_GET_CURRENT_TRACK */
+ player_disp_select_track, /* MUSE_PLAYER_API_SELECT_TRACK */
+ player_disp_get_track_language_code, /* MUSE_PLAYER_API_GET_TRACK_LANGUAGE_CODE */
+ player_disp_set_pcm_extraction_mode, /* MUSE_PLAYER_API_SET_PCM_EXTRACTION_MODE */
+ player_disp_set_pcm_spec, /* MUSE_PLAYER_API_SET_PCM_SPEC */
+ player_disp_set_streaming_playback_rate, /* MUSE_PLAYER_API_SET_STREAMING_PLAYBACK_RATE */
+};
+++ /dev/null
-%bcond_with wayland
-%bcond_with x
-
-Name: capi-media-player
-Summary: A Media Daemon player library in Tizen Native API
-Version: 0.3.3
-Release: 2
-Group: Multimedia/API
-License: Apache-2.0
-Source0: %{name}-%{version}.tar.gz
-BuildRequires: cmake
-BuildRequires: pkgconfig(dlog)
-BuildRequires: pkgconfig(glib-2.0)
-BuildRequires: pkgconfig(mused)
-BuildRequires: pkgconfig(mm-common)
-BuildRequires: pkgconfig(mm-player)
-BuildRequires: pkgconfig(capi-base-common)
-BuildRequires: pkgconfig(capi-media-sound-manager)
-BuildRequires: pkgconfig(legacy-capi-media-player)
-BuildRequires: pkgconfig(tizen-extension-client)
-BuildRequires: pkgconfig(appcore-efl)
-BuildRequires: pkgconfig(elementary)
-BuildRequires: pkgconfig(ecore)
-BuildRequires: pkgconfig(evas)
-%if %{with x}
-BuildRequires: pkgconfig(ecore-x)
-%endif
-%if %{with wayland}
-BuildRequires: pkgconfig(ecore-wayland)
-%endif
-BuildRequires: pkgconfig(capi-media-tool)
-BuildRequires: pkgconfig(json-c)
-BuildRequires: pkgconfig(libtbm)
-BuildRequires: pkgconfig(eom)
-
-Requires(post): /sbin/ldconfig
-Requires(postun): /sbin/ldconfig
-
-%description
-A Media Player Daemon library in Tizen Native API.
-
-%package devel
-Summary: A Media Player Daemon library in Tizen Native API.(Development)
-Group: Development/Multimedia
-Requires: %{name} = %{version}-%{release}
-
-%description devel
-
-%prep
-%setup -q
-
-
-%build
-%if 0%{?sec_build_binary_debug_enable}
-export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE"
-#export CFLAGS+=" -D_USE_X_DIRECT_"
-export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE"
-export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
-%endif
-MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
-%cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER} \
-%if "%{?profile}" == "wearable"
- -DTIZEN_WEARABLE=YES \
- %else
- -DTIZEN_MOBILE=YES \
- %endif
-%if %{with wayland}
- -DWAYLAND_SUPPORT=On \
-%else
- -DWAYLAND_SUPPORT=Off \
-%endif
-%if %{with x}
- -DX11_SUPPORT=On \
-%else
- -DX11_SUPPORT=Off \
-%endif
- -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER} \
- -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
-
-make %{?jobs:-j%jobs}
-
-%install
-rm -rf %{buildroot}
-mkdir -p %{buildroot}/usr/share/license
-mkdir -p %{buildroot}/usr/bin
-cp LICENSE.APLv2 %{buildroot}/usr/share/license/%{name}
-cp client/test/player_test %{buildroot}/usr/bin
-cp client/test/player_media_packet_test %{buildroot}/usr/bin
-cp client/test/player_es_push_test %{buildroot}/usr/bin
-
-%make_install
-
-%post
-/sbin/ldconfig
-
-%postun -p /sbin/ldconfig
-
-
-%files
-%manifest capi-media-player.manifest
-%{_libdir}/libmuse-player.so*
-%{_libdir}/libcapi-media-player.so*
-%{_datadir}/license/%{name}
-/usr/bin/player_test
-/usr/bin/player_media_packet_test
-/usr/bin/player_es_push_test
-
-%files devel
-%{_includedir}/media/*.h
-%{_libdir}/pkgconfig/*.pc
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_" />
+ </request>
+ <assign>
+ <filesystem path="/usr/bin/legacy_player_test" label="_" exec_label="none" />
+ </assign>
+</manifest>
--- /dev/null
+%bcond_with wayland
+%bcond_with x
+
+Name: mmsvc-player
+Summary: A Media Player module for muse server
+Version: 0.2.9
+Release: 0
+Group: Multimedia/Libraries
+License: Apache-2.0
+Source0: %{name}-%{version}.tar.gz
+Source1001: mmsvc-player.manifest
+BuildRequires: cmake
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(mused)
+BuildRequires: pkgconfig(mm-common)
+BuildRequires: pkgconfig(mm-player)
+BuildRequires: pkgconfig(capi-base-common)
+BuildRequires: pkgconfig(capi-media-sound-manager)
+BuildRequires: pkgconfig(appcore-efl)
+BuildRequires: pkgconfig(elementary)
+BuildRequires: pkgconfig(ecore)
+BuildRequires: pkgconfig(evas)
+%if %{with x}
+BuildRequires: pkgconfig(ecore-x)
+%endif
+%if %{with wayland}
+BuildRequires: pkgconfig(ecore-wayland)
+%endif
+BuildRequires: pkgconfig(capi-media-tool)
+BuildRequires: pkgconfig(json-c)
+BuildRequires: pkgconfig(libtbm)
+BuildRequires: pkgconfig(ttrace)
+BuildRequires: pkgconfig(capi-system-info)
+BuildRequires: pkgconfig(mm-sound)
+BuildRequires: pkgconfig(eom)
+
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+
+%description
+A Media Player module for muse server and Tizen Native API.
+%package devel
+Summary: A Media Player module for muse server.(Development)
+Group: Development/Multimedia
+Requires: %{name} = %{version}-%{release}
+
+%description devel
+%devel_desc
+
+%prep
+%setup -q
+cp %{SOURCE1001} .
+
+
+%build
+%if 0%{?sec_build_binary_debug_enable}
+export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE"
+#export CFLAGS+=" -D_USE_X_DIRECT_"
+export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE"
+export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
+%endif
+MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
+%cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER} \
+%if "%{?profile}" == "wearable"
+ -DTIZEN_WEARABLE=YES \
+ %else
+ -DTIZEN_MOBILE=YES \
+ %endif
+%if %{with wayland}
+ -DWAYLAND_SUPPORT=On \
+%else
+ -DWAYLAND_SUPPORT=Off \
+%endif
+%if %{with x}
+ -DX11_SUPPORT=On \
+%else
+ -DX11_SUPPORT=Off \
+%endif
+ -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER} \
+ -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
+
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+
+%make_install
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+%files
+%manifest mmsvc-player.manifest
+%license LICENSE.APLv2
+%{_libdir}/liblegacy-player.so*
+%{_libdir}/libmuse-player.so*
+%{_bindir}/*
+
+%files devel
+%{_includedir}/media/*.h
+%{_libdir}/pkgconfig/*.pc
+%{_libdir}/liblegacy-player.so
+%{_libdir}/libmuse-player.so
+++ /dev/null
-/*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <glib.h>
-
-#include "mm_types.h"
-#include "mm_debug.h"
-#include "mm_error.h"
-#include "mm_player.h"
-#include "muse_core.h"
-#include "muse_core_ipc.h"
-#include "player2_private.h"
-#include "player_msg_private.h"
-
-static int player_cmd_shutdown(muse_module_h module)
-{
- intptr_t handle;
- player_state_e state;
- int ret;
-
- handle = muse_core_ipc_get_handle(module);
-
- ret = player_get_state((player_h)handle, &state);
-
- if (ret != PLAYER_ERROR_NONE)
- return ret;
-
- switch (state) {
- case PLAYER_STATE_PLAYING:
- player_stop((player_h)handle);
- /* FALLTHROUGH */
- case PLAYER_STATE_PAUSED:
- case PLAYER_STATE_READY:
- player_unprepare((player_h)handle);
- /* FALLTHROUGH */
- case PLAYER_STATE_IDLE:
- player_destroy((player_h)handle);
- break;
-
- default:
- LOGD("Nothing to do");
- break;
- }
-
- return PLAYER_ERROR_NONE;
-}
-
-int (*cmd_dispatcher[MUSE_MODULE_EVENT_MAX])(muse_module_h module) = {
- player_cmd_shutdown, /* MUSE_MODULE_EVENT_SHUTDOWN */
- NULL, /* MUSE_MODULE_EVENT_DEBUG_INFO_DUMP */
-};
+++ /dev/null
-/*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <glib.h>
-
-#include "tbm_bufmgr.h"
-#include "tbm_surface.h"
-#include "tbm_surface_internal.h"
-#include "media_packet.h"
-#include "mm_types.h"
-#include "mm_debug.h"
-#include "mm_error.h"
-#include "mm_player.h"
-#include "muse_core.h"
-#include "muse_core_ipc.h"
-#include "player2_private.h"
-#include "player_msg_private.h"
-#include "player_internal.h"
-
-#define STREAM_PATH_LENGTH 32
-#define STREAM_PATH_BASE "/tmp/mused_gst.%d"
-
-static tbm_bufmgr bufmgr;
-__thread media_format_h audio_format = NULL;
-__thread media_format_h video_format = NULL;
-
-#ifdef USE_PUSH_THREAD
-typedef struct {
- GThread *thread;
- GQueue *queue;
- GMutex mutex;
- GCond cond;
- gint running;
-} data_thread_info_t;
-#endif
-typedef struct {
- intptr_t handle;
- uint64_t pts;
- uint64_t size;
- media_format_mimetype_e mimetype;
- media_buffer_flags_e flags;
-} push_data_q_t;
-
-typedef struct {
- player_h player;
- muse_module_h module;
-} prepare_data_t;
-
-/*
-* define for lagacy API for mused
-*/
-#ifdef HAVE_WAYLAND
-extern int player_set_display_wl_for_mused(player_h player, player_display_type_e type, int wl_surface_id, int x, int y, int w, int h);
-extern int player_resize_video_render_rect(player_h player, int x, int y, int w, int h);
-#else
-extern int player_set_display_for_mused(player_h player, player_display_type_e type, unsigned int xhandle);
-#endif
-extern int player_set_audio_policy_info_for_mused(player_h player, char *stream_type, int stream_index);
-
-int player_set_shm_stream_path_for_mused(player_h player, const char *stream_path);
-int player_get_raw_video_caps(player_h player, char **caps);
-/*
-* Internal Implementation
-*/
-static int _push_media_stream(intptr_t handle, player_push_media_msg_type *push_media, char *buf);
-#ifdef USE_PUSH_THREAD
-static gpointer _player_push_media_stream_handler(gpointer param);
-#endif
-
-static void __player_callback(_player_event_e ev, muse_module_h module)
-{
- muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
-
- LOGD("ENTER");
-
- player_msg_event(api, ev, module);
-}
-
-static void _prepare_async_cb(void *user_data)
-{
- _player_event_e ev = _PLAYER_EVENT_TYPE_PREPARE;
- muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
- prepare_data_t *prepare_data = (prepare_data_t *)user_data;
- muse_module_h module;
- player_h player;
- char *caps = NULL;
-
- if (!prepare_data) {
- LOGE("user data of callback is NULL");
- return;
- }
- module = prepare_data->module;
- player = prepare_data->player;
- g_free(prepare_data);
-
- if (player_get_raw_video_caps(player, &caps) == PLAYER_ERROR_NONE) {
- if (caps) {
- player_msg_event1(api, ev, module, STRING, caps);
- g_free(caps);
- return;
- }
- }
- player_msg_event(api, ev, module);
-}
-
-static void _seek_complate_cb(void *user_data)
-{
- _player_event_e ev = _PLAYER_EVENT_TYPE_SEEK;
- __player_callback(ev, (muse_module_h)user_data);
-}
-
-static void _buffering_cb(int percent, void *user_data)
-{
- muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
- _player_event_e ev = _PLAYER_EVENT_TYPE_BUFFERING;
- muse_module_h module = (muse_module_h)user_data;
-
- LOGD("ENTER");
-
- player_msg_event1(api, ev, module, INT, percent);
-
-}
-
-static void _completed_cb(void *user_data)
-{
- _player_event_e ev = _PLAYER_EVENT_TYPE_COMPLETE;
- __player_callback(ev, (muse_module_h)user_data);
-}
-
-static void _interrupted_cb(player_interrupted_code_e code, void *user_data)
-{
- muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
- _player_event_e ev = _PLAYER_EVENT_TYPE_INTERRUPT;
- muse_module_h module = (muse_module_h)user_data;
-
- LOGD("ENTER");
-
- player_msg_event1(api, ev, module, INT, code);
-}
-
-static void _error_cb(int code, void *user_data)
-{
- muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
- _player_event_e ev = _PLAYER_EVENT_TYPE_ERROR;
- muse_module_h module = (muse_module_h)user_data;
-
- LOGD("ENTER");
-
- player_msg_event1(api, ev, module, INT, code);
-}
-
-static void _subtitle_updated_cb(unsigned long duration, char *text, void *user_data)
-{
- muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
- _player_event_e ev = _PLAYER_EVENT_TYPE_SUBTITLE;
- muse_module_h module = (muse_module_h)user_data;
-
- LOGD("ENTER");
-
- player_msg_event2(api, ev, module, INT, duration, STRING, text);
-}
-
-static void _capture_video_cb(unsigned char *data, int width, int height, unsigned int size, void *user_data)
-{
- muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
- _player_event_e ev = _PLAYER_EVENT_TYPE_CAPTURE;
- muse_module_h module = (muse_module_h)user_data;
- tbm_bo bo;
- tbm_bo_handle thandle;
- tbm_key key;
- char checker = 1;
- unsigned int expired = 0x0fffffff;
-
- LOGD("ENTER");
-
- bo = tbm_bo_alloc(bufmgr, size + 1, TBM_BO_DEFAULT);
- if (!bo) {
- LOGE("TBM get error : tbm_bo_alloc return NULL");
- return;
- }
- thandle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_WRITE);
- if (thandle.ptr == NULL) {
- LOGE("TBM get error : handle pointer is NULL");
- goto capture_event_exit1;
- }
- memcpy(thandle.ptr, data, size);
- key = tbm_bo_export(bo);
- if (key == 0) {
- LOGE("TBM get error : export key is 0");
- checker = 0;
- goto capture_event_exit2;
- }
- /* mark to write */
- *((char *)thandle.ptr + size) = 1;
-
- player_msg_event4(api, ev, module, INT, width, INT, height, INT, size, INT, key);
-
-capture_event_exit2:
- tbm_bo_unmap(bo);
-
- while (checker && expired--) {
- thandle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
- checker = *((char *)thandle.ptr + size);
- tbm_bo_unmap(bo);
- }
-
-capture_event_exit1:
- tbm_bo_unref(bo);
-}
-
-static void _pd_msg_cb(player_pd_message_type_e type, void *user_data)
-{
- muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
- _player_event_e ev = _PLAYER_EVENT_TYPE_PD;
- muse_module_h module = (muse_module_h)user_data;
-
- LOGD("ENTER");
-
- player_msg_event1(api, ev, module, INT, type);
-}
-
-static void _media_packet_video_decoded_cb(media_packet_h pkt, void *user_data)
-{
- int ret;
- muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
- _player_event_e ev = _PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME;
- muse_module_h module = (muse_module_h)user_data;
- tbm_surface_h suf;
- tbm_bo bo[4];
- int bo_num;
- tbm_key key[4] = {0, };
- tbm_surface_info_s sinfo;
- int i;
- char *surface_info = (char *)&sinfo;
- int surface_info_size = sizeof(tbm_surface_info_s);
- intptr_t packet = (intptr_t)pkt;
- media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
- media_format_h fmt;
- uint64_t pts = 0;
-
- memset(&sinfo, 0, sizeof(tbm_surface_info_s));
-
- ret = media_packet_get_tbm_surface(pkt, &suf);
- if (ret != MEDIA_PACKET_ERROR_NONE) {
- LOGE("get tbm surface error %d", ret);
- return;
- }
-
- bo_num = tbm_surface_internal_get_num_bos(suf);
- for (i = 0; i < bo_num; i++) {
- bo[i] = tbm_surface_internal_get_bo(suf, i);
- if (bo[i])
- key[i] = tbm_bo_export(bo[i]);
- else
- LOGE("bo_num is %d, bo[%d] is NULL", bo_num, i);
- }
-
- ret = tbm_surface_get_info(suf, &sinfo);
- if (ret != TBM_SURFACE_ERROR_NONE) {
- LOGE("tbm_surface_get_info error %d", ret);
- return;
- }
- media_packet_get_format(pkt, &fmt);
- media_format_get_video_info(fmt, &mimetype, NULL, NULL, NULL, NULL);
- media_packet_get_pts(pkt, &pts);
- player_msg_event7_array(api, ev, module, INT, key[0], INT, key[1], INT, key[2], INT, key[3], POINTER, packet, INT, mimetype, INT64, pts, surface_info, surface_info_size, sizeof(char));
-}
-
-static void _audio_frame_decoded_cb(player_audio_raw_data_s * audio_frame, void *user_data)
-{
- muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
- _player_event_e ev = _PLAYER_EVENT_TYPE_AUDIO_FRAME;
- muse_module_h module = (muse_module_h)user_data;
- tbm_bo bo;
- tbm_bo_handle thandle;
- tbm_key key;
- char checker = 1;
- unsigned int expired = 0x0fffffff;
- int size = 0;
- void *data = NULL;
- if (audio_frame) {
- size = audio_frame->size;
- data = audio_frame->data;
- } else {
- LOGE("audio frame is NULL");
- return;
- }
-
- LOGD("ENTER");
-
- bo = tbm_bo_alloc(bufmgr, size + 1, TBM_BO_DEFAULT);
- if (!bo) {
- LOGE("TBM get error : tbm_bo_alloc return NULL");
- return;
- }
- thandle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_WRITE);
- if (thandle.ptr == NULL) {
- LOGE("TBM get error : handle pointer is NULL");
- tbm_bo_unref(bo);
- return;
- }
- memcpy(thandle.ptr, data, size);
- key = tbm_bo_export(bo);
- if (key == 0) {
- LOGE("TBM get error : export key is 0");
- checker = 0;
- tbm_bo_unmap(bo);
- tbm_bo_unref(bo);
- return;
- }
- /* mark to write */
- *((char *)thandle.ptr + size) = 1;
-
- tbm_bo_unmap(bo);
-
- player_msg_event2_array(api, ev, module, INT, key, INT, size, audio_frame, sizeof(player_audio_raw_data_s), sizeof(char));
-
- while (checker && expired--) {
- thandle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
- checker = *((char *)thandle.ptr + size);
- tbm_bo_unmap(bo);
- }
-
- tbm_bo_unref(bo);
-}
-
-static void _video_stream_changed_cb(int width, int height, int fps, int bit_rate, void *user_data)
-{
- muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
- _player_event_e ev = _PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED;
- muse_module_h module = (muse_module_h)user_data;
-
- player_msg_event4(api, ev, module, INT, width, INT, height, INT, fps, INT, bit_rate);
-}
-
-static void _media_stream_audio_buffer_status_cb(player_media_stream_buffer_status_e status, void *user_data)
-{
- muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
- _player_event_e ev = _PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS;
- muse_module_h module = (muse_module_h)user_data;
-
- player_msg_event1(api, ev, module, INT, status);
-}
-
-static void _media_stream_video_buffer_status_cb(player_media_stream_buffer_status_e status, void *user_data)
-{
- muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
- _player_event_e ev = _PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS;
- muse_module_h module = (muse_module_h)user_data;
-
- player_msg_event1(api, ev, module, INT, status);
-}
-
-static void _media_stream_audio_buffer_status_cb_ex(player_media_stream_buffer_status_e status, unsigned long long bytes, void *user_data)
-{
- muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
- _player_event_e ev = _PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO;
- muse_module_h module = (muse_module_h)user_data;
-
- player_msg_event2(api, ev, module, INT, status, INT64, bytes);
-}
-
-static void _media_stream_video_buffer_status_cb_ex(player_media_stream_buffer_status_e status, unsigned long long bytes, void *user_data)
-{
- muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
- _player_event_e ev = _PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO;
- muse_module_h module = (muse_module_h)user_data;
-
- player_msg_event2(api, ev, module, INT, status, INT64, bytes);
-}
-
-static void _media_stream_audio_seek_cb(unsigned long long offset, void *user_data)
-{
- muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
- _player_event_e ev = _PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK;
- muse_module_h module = (muse_module_h)user_data;
-
- player_msg_event1(api, ev, module, INT64, offset);
-}
-
-static void _media_stream_video_seek_cb(unsigned long long offset, void *user_data)
-{
- muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
- _player_event_e ev = _PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK;
- muse_module_h module = (muse_module_h)user_data;
-
- player_msg_event1(api, ev, module, INT64, offset);
-}
-
-static void _set_completed_cb(player_h player, void *module, bool set)
-{
- if (set)
- player_set_completed_cb(player, _completed_cb, module);
- else
- player_unset_completed_cb(player);
-}
-
-static void _set_interrupted_cb(player_h player, void *module, bool set)
-{
- if (set)
- player_set_interrupted_cb(player, _interrupted_cb, module);
- else
- player_unset_interrupted_cb(player);
-}
-
-static void _set_error_cb(player_h player, void *module, bool set)
-{
- if (set)
- player_set_error_cb(player, _error_cb, module);
- else
- player_unset_error_cb(player);
-}
-
-static void _set_subtitle_cb(player_h player, void *module, bool set)
-{
- if (set)
- player_set_subtitle_updated_cb(player, _subtitle_updated_cb, module);
- else
- player_unset_subtitle_updated_cb(player);
-}
-
-static void _set_buffering_cb(player_h player, void *module, bool set)
-{
- if (set)
- player_set_buffering_cb(player, _buffering_cb, module);
- else
- player_unset_buffering_cb(player);
-}
-
-static void _set_pd_msg_cb(player_h player, void *module, bool set)
-{
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
-
- if (set)
- ret = player_set_progressive_download_message_cb(player, _pd_msg_cb, module);
- else
- ret = player_unset_progressive_download_message_cb(player);
-
- player_msg_return(api, ret, module);
-}
-
-static void _set_media_packet_video_frame_cb(player_h player, void *data, bool set)
-{
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
- muse_module_h module = (muse_module_h)data;
-
- if (set)
- ret = player_set_media_packet_video_frame_decoded_cb(player, _media_packet_video_decoded_cb, module);
- else
- ret = player_unset_media_packet_video_frame_decoded_cb(player);
-
- player_msg_return(api, ret, module);
-}
-
-static void _set_video_stream_changed_cb(player_h player, void *data, bool set)
-{
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
- muse_module_h module = (muse_module_h)data;
-
- if (set)
- ret = player_set_video_stream_changed_cb(player, _video_stream_changed_cb, module);
- else
- ret = player_unset_video_stream_changed_cb(player);
-
- player_msg_return(api, ret, module);
-}
-
-static void _set_media_stream_audio_seek_cb(player_h player, void *data, bool set)
-{
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
- muse_module_h module = (muse_module_h)data;
-
- if (set)
- ret = player_set_media_stream_seek_cb(player, PLAYER_STREAM_TYPE_AUDIO, _media_stream_audio_seek_cb, module);
- else
- ret = player_unset_media_stream_seek_cb(player, PLAYER_STREAM_TYPE_AUDIO);
-
- player_msg_return(api, ret, module);
-}
-
-static void _set_media_stream_video_seek_cb(player_h player, void *data, bool set)
-{
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
- muse_module_h module = (muse_module_h)data;
-
- if (set)
- ret = player_set_media_stream_seek_cb(player, PLAYER_STREAM_TYPE_VIDEO, _media_stream_video_seek_cb, module);
- else
- ret = player_unset_media_stream_seek_cb(player, PLAYER_STREAM_TYPE_VIDEO);
-
- player_msg_return(api, ret, module);
-}
-
-static void _set_media_stream_audio_buffer_cb(player_h player, void *data, bool set)
-{
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
- muse_module_h module = (muse_module_h)data;
-
- if (set)
- ret = player_set_media_stream_buffer_status_cb(player, PLAYER_STREAM_TYPE_AUDIO, _media_stream_audio_buffer_status_cb, module);
- else
- ret = player_unset_media_stream_buffer_status_cb(player, PLAYER_STREAM_TYPE_AUDIO);
-
- player_msg_return(api, ret, module);
-}
-
-static void _set_media_stream_video_buffer_cb(player_h player, void *data, bool set)
-{
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
- muse_module_h module = (muse_module_h)data;
-
- if (set)
- ret = player_set_media_stream_buffer_status_cb(player, PLAYER_STREAM_TYPE_VIDEO, _media_stream_video_buffer_status_cb, module);
- else
- ret = player_unset_media_stream_buffer_status_cb(player, PLAYER_STREAM_TYPE_VIDEO);
-
- player_msg_return(api, ret, module);
-}
-
-static void _set_media_stream_audio_buffer_cb_ex(player_h player, void *data, bool set)
-{
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
- muse_module_h module = (muse_module_h)data;
-
- if (set)
- ret = player_set_media_stream_buffer_status_cb_ex(player, PLAYER_STREAM_TYPE_AUDIO, _media_stream_audio_buffer_status_cb_ex, module);
- else
- ret = player_unset_media_stream_buffer_status_cb_ex(player, PLAYER_STREAM_TYPE_AUDIO);
-
- player_msg_return(api, ret, module);
-}
-
-static void _set_media_stream_video_buffer_cb_ex(player_h player, void *data, bool set)
-{
- int ret = PLAYER_ERROR_NONE;
- muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
- muse_module_h module = (muse_module_h)data;
-
- if (set)
- ret = player_set_media_stream_buffer_status_cb_ex(player, PLAYER_STREAM_TYPE_VIDEO, _media_stream_video_buffer_status_cb_ex, module);
- else
- ret = player_unset_media_stream_buffer_status_cb_ex(player, PLAYER_STREAM_TYPE_VIDEO);
-
- player_msg_return(api, ret, module);
-}
-
-static void (*set_callback_func[_PLAYER_EVENT_TYPE_NUM])(player_h player, void *user_data, bool set) = {
- NULL, /* _PLAYER_EVENT_TYPE_PREPARE */
- _set_completed_cb, /* _PLAYER_EVENT_TYPE_COMPLETE */
- _set_interrupted_cb, /* _PLAYER_EVENT_TYPE_INTERRUPT */
- _set_error_cb, /* _PLAYER_EVENT_TYPE_ERROR */
- _set_buffering_cb, /* _PLAYER_EVENT_TYPE_BUFFERING */
- _set_subtitle_cb, /* _PLAYER_EVENT_TYPE_SUBTITLE */
- NULL, /* _PLAYER_EVENT_TYPE_CAPTURE */
- NULL, /* _PLAYER_EVENT_TYPE_SEEK */
- _set_media_packet_video_frame_cb, /* _PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME */
- NULL, /* _PLAYER_EVENT_TYPE_AUDIO_FRAME */
- NULL, /* _PLAYER_EVENT_TYPE_VIDEO_FRAME_RENDER_ERROR */
- _set_pd_msg_cb, /* _PLAYER_EVENT_TYPE_PD */
- NULL, /* _PLAYER_EVENT_TYPE_SUPPORTED_AUDIO_EFFECT */
- NULL, /* _PLAYER_EVENT_TYPE_SUPPORTED_AUDIO_EFFECT_PRESET */
- NULL, /* _PLAYER_EVENT_TYPE_MISSED_PLUGIN */
-#ifdef _PLAYER_FOR_PRODUCT
- NULL, /* _PLAYER_EVENT_TYPE_IMAGE_BUFFER */
- NULL, /*_PLAYER_EVENT_TYPE_SELECTED_SUBTITLE_LANGUAGE */
-#endif
- _set_media_stream_video_buffer_cb, /*_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS*/
- _set_media_stream_audio_buffer_cb, /*_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS*/
- _set_media_stream_video_buffer_cb_ex, /*_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO*/
- _set_media_stream_audio_buffer_cb_ex, /*_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO*/
- _set_media_stream_video_seek_cb, /*_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK*/
- _set_media_stream_audio_seek_cb, /*_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK*/
- NULL, /*_PLAYER_EVENT_TYPE_AUDIO_STREAM_CHANGED*/
- _set_video_stream_changed_cb, /*_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED*/
-};
-
-static int player_disp_set_callback(muse_module_h module)
-{
- intptr_t handle;
- _player_event_e type;
- int set;
-
- handle = muse_core_ipc_get_handle(module);
- player_msg_get(type, muse_core_client_get_msg(module));
- player_msg_get(set, muse_core_client_get_msg(module));
-
- if (type < _PLAYER_EVENT_TYPE_NUM && set_callback_func[type] != NULL)
- set_callback_func[type] ((player_h)handle, module, set);
-
- return PLAYER_ERROR_NONE;
-}
-
-static int player_disp_create(muse_module_h module)
-{
- int ret = -1;
- player_h player;
- muse_player_api_e api = MUSE_PLAYER_API_CREATE;
- intptr_t handle = 0;
- intptr_t module_addr = (intptr_t)module;
-#ifdef USE_PUSH_THREAD
- data_thread_info_t *thread_i;
-#endif
- static guint stream_id = 0;
- char stream_path[STREAM_PATH_LENGTH];
- int pid;
-
- ret = player_create(&player);
- LOGD("handle : %p, module : %p", player, module);
-
- player_msg_get(pid, muse_core_client_get_msg(module));
-
- if (ret == PLAYER_ERROR_NONE)
- ret = player_sound_register(player, pid);
- else
- player_msg_return(api, ret, module);
-
- if (ret == PLAYER_ERROR_NONE) {
- handle = (intptr_t)player;
- muse_core_ipc_set_handle(module, handle);
-#ifdef USE_PUSH_THREAD
- thread_i = g_new(data_thread_info_t, 1);
- thread_i->running = 1;
- g_mutex_init(&thread_i->mutex);
- g_cond_init(&thread_i->cond);
- thread_i->queue = g_queue_new();
- thread_i->thread = (gpointer)g_thread_new("push_media", _player_push_media_stream_handler, module);
-
- muse_core_client_set_cust_data(module, thread_i);
-#endif
- muse_core_ipc_get_bufmgr(&bufmgr);
-
- stream_id = muse_core_get_atomic_uint();
- snprintf(stream_path, STREAM_PATH_LENGTH, STREAM_PATH_BASE, stream_id);
- unlink(stream_path);
- ret = player_set_shm_stream_path_for_mused(player, stream_path);
-
- player_msg_return2(api, ret, module, POINTER, module_addr, STRING, stream_path);
- } else
- player_msg_return(api, ret, module);
-
- return ret;
-}
-
-static int player_disp_set_uri(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_SET_URI;
- char uri[MUSE_URI_MAX_LENGTH] = { 0, };
-
- handle = muse_core_ipc_get_handle(module);
- player_msg_get_string(uri, muse_core_client_get_msg(module));
-
- ret = player_set_uri((player_h)handle, uri);
-
- player_msg_return(api, ret, module);
-
- return ret;
-}
-
-static int player_disp_prepare(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_PREPARE;
- player_h player;
- char *caps = NULL;
- bool is_streaming = FALSE;
-
- handle = muse_core_ipc_get_handle(module);
-
- player = (player_h)handle;
-
- ret = player_prepare(player);
- if (ret == PLAYER_ERROR_NONE) {
- player_is_streaming(player, &is_streaming);
- ret = player_get_raw_video_caps(player, &caps);
- if (ret == PLAYER_ERROR_NONE && caps) {
- player_msg_return2(api, ret, module, STRING, caps, INT, is_streaming);
- g_free(caps);
- } else
- player_msg_return1(api, ret, module, INT, is_streaming);
-
- return ret;
- }
-
- player_msg_return(api, ret, module);
-
- return ret;
-}
-
-static int player_disp_prepare_async(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_PREPARE_ASYNC;
- player_h player;
- prepare_data_t *prepare_data;
- bool is_streaming = FALSE;
-
- handle = muse_core_ipc_get_handle(module);
-
- player = (player_h)handle;
-
- prepare_data = g_new(prepare_data_t, 1);
- prepare_data->player = player;
- prepare_data->module = module;
-
- ret = player_prepare_async(player, _prepare_async_cb, prepare_data);
- if (ret == PLAYER_ERROR_NONE) {
- player_is_streaming(player, &is_streaming);
- player_msg_return1(api, ret, module, INT, is_streaming);
- return ret;
- }
-
- player_msg_return(api, ret, module);
-
- return ret;
-}
-
-static int player_disp_unprepare(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_UNPREPARE;
- player_h player;
-
- handle = muse_core_ipc_get_handle(module);
- player = (player_h)handle;
-
- ret = player_unprepare(player);
-
- player_msg_return(api, ret, module);
-
- return ret;
-}
-
-static int player_disp_destroy(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_DESTROY;
-#ifdef USE_PUSH_THREAD
- data_thread_info_t *thread_i;
-#endif
- handle = muse_core_ipc_get_handle(module);
-
- ret = player_destroy((player_h)handle);
-#ifdef USE_PUSH_THREAD
-
- thread_i = (data_thread_info_t *)muse_core_client_get_cust_data(module);
- thread_i->running = 0;
- g_cond_signal(&thread_i->cond);
-
- g_thread_join(thread_i->thread);
- g_thread_unref(thread_i->thread);
- g_queue_free(thread_i->queue);
- g_mutex_clear(&thread_i->mutex);
- g_cond_clear(&thread_i->cond);
- g_free(thread_i);
- muse_core_client_set_cust_data(module, NULL);
-#endif
- if (audio_format) {
- media_format_unref(audio_format);
- audio_format = NULL;
- }
- if (video_format) {
- media_format_unref(video_format);
- video_format = NULL;
- }
-
- player_msg_return(api, ret, module);
-
- return ret;
-}
-
-static int player_disp_start(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_START;
-
- handle = muse_core_ipc_get_handle(module);
-
- ret = player_start((player_h)handle);
-
- player_msg_return(api, ret, module);
-
- return ret;
-}
-
-static int player_disp_stop(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_STOP;
-
- handle = muse_core_ipc_get_handle(module);
-
- ret = player_stop((player_h)handle);
-
- player_msg_return(api, ret, module);
-
- return ret;
-}
-
-static int player_disp_pause(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_PAUSE;
-
- handle = muse_core_ipc_get_handle(module);
-
- ret = player_pause((player_h)handle);
-
- player_msg_return(api, ret, module);
-
- return ret;
-}
-
-static int player_disp_set_memory_buffer(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_SET_MEMORY_BUFFER;
- tbm_bo bo;
- tbm_bo_handle thandle;
- tbm_key key;
- int size;
- intptr_t bo_addr;
-
- handle = muse_core_ipc_get_handle(module);
- player_msg_get(key, muse_core_client_get_msg(module));
- player_msg_get(size, muse_core_client_get_msg(module));
-
- bo = tbm_bo_import(bufmgr, key);
- if (bo == NULL) {
- LOGE("TBM get error : bo is NULL");
- ret = PLAYER_ERROR_INVALID_OPERATION;
- player_msg_return(api, ret, module);
- return ret;
- }
- thandle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
- if (thandle.ptr == NULL) {
- LOGE("TBM get error : handle pointer is NULL");
- ret = PLAYER_ERROR_INVALID_OPERATION;
- player_msg_return(api, ret, module);
- return ret;
- }
-
- bo_addr = (intptr_t)bo;
- ret = player_set_memory_buffer((player_h)handle, thandle.ptr, size);
- player_msg_return1(api, ret, module, INT, bo_addr);
-
- return ret;
-}
-
-static int player_disp_deinit_memory_buffer(muse_module_h module)
-{
- intptr_t bo_addr;
- tbm_bo bo;
-
- if (player_msg_get(bo_addr, muse_core_client_get_msg(module))) {
-
- bo = (tbm_bo) bo_addr;
-
- tbm_bo_unmap(bo);
- tbm_bo_unref(bo);
- }
-
- return PLAYER_ERROR_NONE;
-}
-
-static int player_disp_set_volume(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_SET_VOLUME;
- double left, right;
-
- handle = muse_core_ipc_get_handle(module);
- player_msg_get_type(left, muse_core_client_get_msg(module), DOUBLE);
- player_msg_get_type(right, muse_core_client_get_msg(module), DOUBLE);
-
- ret = player_set_volume((player_h)handle, (float)left, (float)right);
-
- player_msg_return(api, ret, module);
-
- return ret;
-}
-
-static int player_disp_get_volume(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_GET_VOLUME;
- float left, right;
-
- handle = muse_core_ipc_get_handle(module);
-
- ret = player_get_volume((player_h)handle, &left, &right);
-
- player_msg_return2(api, ret, module, DOUBLE, left, DOUBLE, right);
-
- return ret;
-}
-
-static int player_disp_get_state(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_GET_STATE;
- player_state_e state;
-
- handle = muse_core_ipc_get_handle(module);
-
- ret = player_get_state((player_h)handle, &state);
-
- player_msg_return1(api, ret, module, INT, state);
-
- return ret;
-}
-
-static int player_disp_set_play_position(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_SET_PLAY_POSITION;
- int pos;
- int accurate;
-
- handle = muse_core_ipc_get_handle(module);
- player_msg_get(pos, muse_core_client_get_msg(module));
- player_msg_get(accurate, muse_core_client_get_msg(module));
-
- ret = player_set_play_position((player_h)handle, pos, accurate, _seek_complate_cb, module);
-
- player_msg_return(api, ret, module);
-
- return ret;
-}
-
-static int player_disp_get_play_position(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_GET_PLAY_POSITION;
- int pos;
-
- handle = muse_core_ipc_get_handle(module);
-
- ret = player_get_play_position((player_h)handle, &pos);
-
- player_msg_return1(api, ret, module, INT, pos);
-
- return ret;
-}
-
-static int player_disp_set_display(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_SET_DISPLAY;
-#ifdef HAVE_WAYLAND
- wl_win_msg_type wl_win;
- char *wl_win_msg = (char *)&wl_win;
-#else
- int type;
- unsigned int xhandle;
-#endif
-
- handle = muse_core_ipc_get_handle(module);
-#ifdef HAVE_WAYLAND
- player_msg_get_array(wl_win_msg, muse_core_client_get_msg(module));
-
- ret = player_set_display_wl_for_mused((player_h)handle, wl_win.type, wl_win.wl_surface_id, wl_win.wl_window_x, wl_win.wl_window_y, wl_win.wl_window_width, wl_win.wl_window_height);
-#else
- player_msg_get(type, muse_core_client_get_msg(module));
- player_msg_get(xhandle, muse_core_client_get_msg(module));
-
- ret = player_set_display_for_mused((player_h)handle, type, xhandle);
-#endif
- player_msg_return(api, ret, module);
-
- return ret;
-}
-
-static int player_disp_set_mute(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_SET_MUTE;
- int mute;
-
- handle = muse_core_ipc_get_handle(module);
- player_msg_get(mute, muse_core_client_get_msg(module));
-
- ret = player_set_mute((player_h)handle, (bool)mute);
-
- player_msg_return(api, ret, module);
-
- return ret;
-}
-
-static int player_disp_is_muted(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_IS_MUTED;
- bool mute;
-
- handle = muse_core_ipc_get_handle(module);
-
- ret = player_is_muted((player_h)handle, &mute);
-
- player_msg_return1(api, ret, module, INT, mute);
-
- return ret;
-}
-
-static int player_disp_get_duration(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_GET_DURATION;
- int duration = 0;
-
- handle = muse_core_ipc_get_handle(module);
-
- ret = player_get_duration((player_h)handle, &duration);
-
- player_msg_return1(api, ret, module, INT, duration);
-
- return ret;
-}
-
-static int player_disp_set_sound_type(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_SET_SOUND_TYPE;
- int type;
-
- handle = muse_core_ipc_get_handle(module);
- player_msg_get(type, muse_core_client_get_msg(module));
-
- ret = player_set_sound_type((player_h)handle, (sound_type_e)type);
-
- player_msg_return(api, ret, module);
-
- return ret;
-}
-
-static int player_disp_set_audio_policy_info(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_SET_AUDIO_POLICY_INFO;
- int stream_index;
- char stream_type[MUSE_URI_MAX_LENGTH] = { 0, };
-
- handle = muse_core_ipc_get_handle(module);
- player_msg_get(stream_index, muse_core_client_get_msg(module));
- player_msg_get_string(stream_type, muse_core_client_get_msg(module));
-
- ret = player_set_audio_policy_info_for_mused((player_h)handle, stream_type, stream_index);
-
- player_msg_return(api, ret, module);
-
- return ret;
-}
-
-static int player_disp_set_latency_mode(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_SET_AUDIO_LATENCY_MODE;
- int latency_mode;
-
- handle = muse_core_ipc_get_handle(module);
- player_msg_get(latency_mode, muse_core_client_get_msg(module));
-
- ret = player_set_audio_latency_mode((player_h)handle, (audio_latency_mode_e)latency_mode);
-
- player_msg_return(api, ret, module);
-
- return ret;
-}
-
-static int player_disp_get_latency_mode(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_GET_AUDIO_LATENCY_MODE;
- audio_latency_mode_e latency_mode;
-
- handle = muse_core_ipc_get_handle(module);
-
- ret = player_get_audio_latency_mode((player_h)handle, &latency_mode);
-
- player_msg_return1(api, ret, module, INT, latency_mode);
-
- return ret;
-}
-
-static int player_disp_set_looping(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_SET_LOOPING;
- int looping;
-
- handle = muse_core_ipc_get_handle(module);
- player_msg_get(looping, muse_core_client_get_msg(module));
-
- ret = player_set_looping((player_h)handle, (bool)looping);
-
- player_msg_return(api, ret, module);
-
- return ret;
-}
-
-static int player_disp_is_looping(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_IS_LOOPING;
- bool looping;
-
- handle = muse_core_ipc_get_handle(module);
-
- ret = player_is_looping((player_h)handle, &looping);
-
- player_msg_return1(api, ret, module, INT, looping);
-
- return ret;
-}
-
-static int player_disp_set_display_mode(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_SET_DISPLAY_MODE;
- int mode = 0;
-
- handle = muse_core_ipc_get_handle(module);
- player_msg_get(mode, muse_core_client_get_msg(module));
-
- ret = player_set_display_mode((player_h)handle, (player_display_mode_e)mode);
-
- player_msg_return(api, ret, module);
-
- return ret;
-}
-
-static int player_disp_get_display_mode(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_GET_DISPLAY_MODE;
- player_display_mode_e mode = 0;
-
- handle = muse_core_ipc_get_handle(module);
-
- ret = player_get_display_mode((player_h)handle, &mode);
-
- player_msg_return1(api, ret, module, INT, mode);
-
- return ret;
-}
-
-static int player_disp_set_playback_rate(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_SET_PLAYBACK_RATE;
- double rate = 0;
-
- handle = muse_core_ipc_get_handle(module);
- player_msg_get_type(rate, muse_core_client_get_msg(module), DOUBLE);
-
- ret = player_set_playback_rate((player_h)handle, (float)rate);
-
- player_msg_return(api, ret, module);
-
- return ret;
-}
-
-static int player_disp_set_display_rotation(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_SET_DISPLAY_ROTATION;
- int rotation = 0;
-
- handle = muse_core_ipc_get_handle(module);
- player_msg_get(rotation, muse_core_client_get_msg(module));
-
- ret = player_set_display_rotation((player_h)handle, (player_display_rotation_e)rotation);
-
- player_msg_return(api, ret, module);
-
- return ret;
-}
-
-static int player_disp_get_display_rotation(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_GET_DISPLAY_ROTATION;
- player_display_rotation_e rotation;
-
- handle = muse_core_ipc_get_handle(module);
-
- ret = player_get_display_rotation((player_h)handle, &rotation);
-
- player_msg_return1(api, ret, module, INT, rotation);
-
- return ret;
-}
-
-static int player_disp_set_display_visible(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_SET_DISPLAY_VISIBLE;
- int visible = 0;
-
- handle = muse_core_ipc_get_handle(module);
- player_msg_get(visible, muse_core_client_get_msg(module));
-
- ret = player_set_display_visible((player_h)handle, visible);
-
- player_msg_return(api, ret, module);
-
- return ret;
-}
-
-static int player_disp_is_display_visible(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_IS_DISPLAY_VISIBLE;
- bool visible = 0;
-
- handle = muse_core_ipc_get_handle(module);
-
- ret = player_is_display_visible((player_h)handle, &visible);
-
- player_msg_return1(api, ret, module, INT, visible);
-
- return ret;
-}
-#ifdef HAVE_WAYLAND
-static int player_disp_resize_video_render_rect(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_RESIZE_VIDEO_RENDER_RECT;
-
- wl_win_msg_type wl_win;
- char *wl_win_msg = (char *)&wl_win;
-
- handle = muse_core_ipc_get_handle(module);
-
- player_msg_get_array(wl_win_msg, muse_core_client_get_msg(module));
-
- ret = player_resize_video_render_rect((player_h)handle, wl_win.wl_window_x, wl_win.wl_window_y, wl_win.wl_window_width, wl_win.wl_window_height);
- player_msg_return(api, ret, module);
-
- return ret;
-
-}
-#endif
-static int player_disp_get_content_info(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_GET_CONTENT_INFO;
- char *value;
- player_content_info_e key;
-
- handle = muse_core_ipc_get_handle(module);
- player_msg_get(key, muse_core_client_get_msg(module));
-
- ret = player_get_content_info((player_h)handle, key, &value);
-
- if (ret == PLAYER_ERROR_NONE) {
- player_msg_return1(api, ret, module, STRING, value);
- free(value);
- } else
- player_msg_return(api, ret, module);
-
- return ret;
-}
-
-static int player_disp_get_codec_info(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_GET_CODEC_INFO;
- char *video_codec;
- char *audio_codec;
-
- handle = muse_core_ipc_get_handle(module);
-
- ret = player_get_codec_info((player_h)handle, &audio_codec, &video_codec);
-
- if (ret == PLAYER_ERROR_NONE) {
- player_msg_return2(api, ret, module, STRING, audio_codec, STRING, video_codec);
-
- free(audio_codec);
- free(video_codec);
- } else
- player_msg_return(api, ret, module);
-
- return ret;
-}
-
-static int player_disp_get_audio_stream_info(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_GET_AUDIO_STREAM_INFO;
- int sample_rate = 0;
- int channel = 0;
- int bit_rate = 0;
-
- handle = muse_core_ipc_get_handle(module);
-
- ret = player_get_audio_stream_info((player_h)handle, &sample_rate, &channel, &bit_rate);
-
- player_msg_return3(api, ret, module, INT, sample_rate, INT, channel, INT, bit_rate);
-
- return ret;
-}
-
-static int player_disp_get_video_stream_info(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_GET_VIDEO_STREAM_INFO;
- int fps = 0;
- int bit_rate = 0;
-
- handle = muse_core_ipc_get_handle(module);
-
- ret = player_get_video_stream_info((player_h)handle, &fps, &bit_rate);
-
- player_msg_return2(api, ret, module, INT, fps, INT, bit_rate);
-
- return ret;
-}
-
-static int player_disp_get_video_size(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_GET_VIDEO_SIZE;
- int width = 0;
- int height = 0;
-
- handle = muse_core_ipc_get_handle(module);
-
- ret = player_get_video_size((player_h)handle, &width, &height);
-
- player_msg_return2(api, ret, module, INT, width, INT, height);
-
- return ret;
-}
-
-static int player_disp_get_album_art(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_GET_ALBUM_ART;
- void *album_art;
- int size;
-
- handle = muse_core_ipc_get_handle(module);
-
- ret = player_get_album_art((player_h)handle, &album_art, &size);
-
- if (ret == PLAYER_ERROR_NONE)
- player_msg_return_array(api, ret, module, album_art, size, sizeof(char));
- else
- player_msg_return(api, ret, module);
-
- return ret;
-}
-
-static int player_disp_get_eq_bands_count(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_BANDS_COUNT;
- int count;
-
- handle = muse_core_ipc_get_handle(module);
-
- ret = player_audio_effect_get_equalizer_bands_count((player_h)handle, &count);
-
- player_msg_return1(api, ret, module, INT, count);
-
- return ret;
-}
-
-static int player_disp_set_eq_all_bands(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_SET_EQUALIZER_ALL_BANDS;
- int *band_levels;
- int length;
-
- handle = muse_core_ipc_get_handle(module);
- player_msg_get(length, muse_core_client_get_msg(module));
- band_levels = (int *)g_try_new(int, length);
-
- if (band_levels) {
- player_msg_get_array(band_levels, muse_core_client_get_msg(module));
- ret = player_audio_effect_set_equalizer_all_bands((player_h)handle, band_levels, length);
- g_free(band_levels);
- } else
- ret = PLAYER_ERROR_INVALID_OPERATION;
-
- player_msg_return(api, ret, module);
-
- return ret;
-}
-
-static int player_disp_set_eq_band_level(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_SET_EQUALIZER_BAND_LEVEL;
- int index, level;
-
- handle = muse_core_ipc_get_handle(module);
- player_msg_get(index, muse_core_client_get_msg(module));
- player_msg_get(level, muse_core_client_get_msg(module));
-
- ret = player_audio_effect_set_equalizer_band_level((player_h)handle, index, level);
-
- player_msg_return(api, ret, module);
-
- return ret;
-}
-
-static int player_disp_get_eq_band_level(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_BAND_LEVEL;
- int index, level;
-
- handle = muse_core_ipc_get_handle(module);
- player_msg_get(index, muse_core_client_get_msg(module));
-
- ret = player_audio_effect_get_equalizer_band_level((player_h)handle, index, &level);
-
- player_msg_return1(api, ret, module, INT, level);
-
- return ret;
-}
-
-static int player_disp_get_eq_level_range(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_LEVEL_RANGE;
- int min, max;
-
- handle = muse_core_ipc_get_handle(module);
-
- ret = player_audio_effect_get_equalizer_level_range((player_h)handle, &min, &max);
-
- player_msg_return2(api, ret, module, INT, min, INT, max);
-
- return ret;
-}
-
-static int player_disp_get_eq_band_frequency(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_BAND_FREQUENCY;
- int index, frequency;
-
- handle = muse_core_ipc_get_handle(module);
- player_msg_get(index, muse_core_client_get_msg(module));
-
- ret = player_audio_effect_get_equalizer_band_frequency((player_h)handle, index, &frequency);
-
- player_msg_return1(api, ret, module, INT, frequency);
-
- return ret;
-}
-
-static int player_disp_get_eq_band_frequency_range(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_BAND_FREQUENCY_RANGE;
- int index, range;
-
- handle = muse_core_ipc_get_handle(module);
- player_msg_get(index, muse_core_client_get_msg(module));
-
- ret = player_audio_effect_get_equalizer_band_frequency_range((player_h)handle, index, &range);
-
- player_msg_return1(api, ret, module, INT, range);
-
- return ret;
-}
-
-static int player_disp_eq_clear(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_EQUALIZER_CLEAR;
-
- handle = muse_core_ipc_get_handle(module);
-
- ret = player_audio_effect_equalizer_clear((player_h)handle);
-
- player_msg_return(api, ret, module);
-
- return ret;
-}
-
-static int player_disp_eq_is_available(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_AUDIO_EFFECT_EQUALIZER_IS_AVAILABLE;
- bool available;
-
- handle = muse_core_ipc_get_handle(module);
-
- ret = player_audio_effect_equalizer_is_available((player_h)handle, &available);
-
- player_msg_return1(api, ret, module, INT, available);
-
- return ret;
-}
-
-static int player_disp_set_subtitle_path(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_SET_SUBTITLE_PATH;
- char path[MUSE_URI_MAX_LENGTH] = { 0, };
-
- handle = muse_core_ipc_get_handle(module);
- player_msg_get_string(path, muse_core_client_get_msg(module));
-
- ret = player_set_subtitle_path((player_h)handle, path);
-
- player_msg_return(api, ret, module);
-
- return ret;
-}
-
-static int player_disp_set_subtitle_position_offset(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_SET_SUBTITLE_POSITION_OFFSET;
- int millisecond;
-
- handle = muse_core_ipc_get_handle(module);
- player_msg_get(millisecond, muse_core_client_get_msg(module));
-
- ret = player_set_subtitle_position_offset((player_h)handle, millisecond);
-
- player_msg_return(api, ret, module);
-
- return ret;
-}
-
-static int player_disp_set_progressive_download_path(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_SET_PROGRESSIVE_DOWNLOAD_PATH;
- char path[MUSE_URI_MAX_LENGTH] = { 0, };
-
- handle = muse_core_ipc_get_handle(module);
- player_msg_get_string(path, muse_core_client_get_msg(module));
-
- ret = player_set_progressive_download_path((player_h)handle, path);
- player_msg_return(api, ret, module);
-
- return ret;
-}
-
-static int player_disp_get_progressive_download_status(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_GET_PROGRESSIVE_DOWNLOAD_STATUS;
- unsigned long current = 0;
- unsigned long total_size = 0;
-
- handle = muse_core_ipc_get_handle(module);
-
- ret = player_get_progressive_download_status((player_h)handle, ¤t, &total_size);
-
- player_msg_return2(api, ret, module, POINTER, current, POINTER, total_size);
-
- return ret;
-}
-
-static int player_disp_capture_video(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_CAPTURE_VIDEO;
-
- handle = muse_core_ipc_get_handle(module);
-
- ret = player_capture_video((player_h)handle, _capture_video_cb, module);
-
- player_msg_return(api, ret, module);
-
- return ret;
-}
-
-static int player_disp_set_streaming_cookie(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_SET_STREAMING_COOKIE;
- char *cookie = NULL;
- int size;
-
- handle = muse_core_ipc_get_handle(module);
- player_msg_get(size, muse_core_client_get_msg(module));
- cookie = (char *)g_try_new(char, size + 1);
- if (cookie) {
- player_msg_get_string(cookie, muse_core_client_get_msg(module));
- ret = player_set_streaming_cookie((player_h)handle, cookie, size);
- g_free(cookie);
- } else
- ret = PLAYER_ERROR_INVALID_OPERATION;
-
- player_msg_return(api, ret, module);
-
- return ret;
-}
-
-static int player_disp_set_streaming_user_agent(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_SET_STREAMING_USER_AGENT;
- char *user_agent;
- int size;
-
- handle = muse_core_ipc_get_handle(module);
- player_msg_get(size, muse_core_client_get_msg(module));
- user_agent = (char *)g_try_new(char, size + 1);
- if (user_agent) {
- player_msg_get_string(user_agent, muse_core_client_get_msg(module));
- ret = player_set_streaming_user_agent((player_h)handle, user_agent, size);
- g_free(user_agent);
- } else
- ret = PLAYER_ERROR_INVALID_OPERATION;
-
- player_msg_return(api, ret, module);
-
- return ret;
-}
-
-static int player_disp_get_streaming_download_progress(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_GET_STREAMING_DOWNLOAD_PROGRESS;
- int start, current;
-
- handle = muse_core_ipc_get_handle(module);
-
- ret = player_get_streaming_download_progress((player_h)handle, &start, ¤t);
-
- player_msg_return2(api, ret, module, INT, start, INT, current);
-
- return ret;
-}
-
-#ifdef USE_PUSH_THREAD
-
-static gpointer _player_push_media_stream_handler(gpointer param)
-{
- muse_module_h module = (muse_module_h)param;
- char *buf;
- push_data_q_t *qData;
- player_push_media_msg_type push_media;
-
- LOGD("Enter");
-
- if (!module) {
- LOGE("Null parameter");
- return NULL;
- }
- data_thread_info_t *thread_i = (data_thread_info_t *)muse_core_client_get_cust_data(module);
- if (!thread_i) {
- LOGE("Null parameter");
- return NULL;
- }
-
- g_mutex_lock(&thread_i->mutex);
- while (thread_i->running) {
- if (g_queue_is_empty(thread_i->queue)) {
- g_cond_wait(&thread_i->cond, &thread_i->mutex);
- if (!thread_i->running)
- break;
- }
- while (1) {
- qData = g_queue_pop_head(thread_i->queue);
- g_mutex_unlock(&thread_i->mutex);
- if (qData) {
- push_media.mimetype = qData->mimetype;
- push_media.pts = qData->pts;
- push_media.size = qData->size;
- push_media.flags = qData->flags;
- buf = muse_core_ipc_get_data(module);
- _push_media_stream(qData->handle, &push_media, buf);
- if (buf)
- muse_core_ipc_delete_data(buf);
- g_free(qData);
- } else {
- g_mutex_lock(&thread_i->mutex);
- break;
- }
- g_mutex_lock(&thread_i->mutex);
- }
- }
- g_mutex_unlock(&thread_i->mutex);
-
- LOGD("Leave");
-
- return NULL;
-}
-#endif
-
-static int _push_media_stream(intptr_t handle, player_push_media_msg_type *push_media, char *buf)
-{
- int ret = MEDIA_FORMAT_ERROR_NONE;
- media_format_h format;
- media_packet_h packet;
- media_format_mimetype_e mimetype;
-
- if (push_media->mimetype & MEDIA_FORMAT_VIDEO) {
- if (!video_format) {
- media_format_create(&video_format);
- if (!video_format) {
- LOGE("fail to create media format");
- return PLAYER_ERROR_INVALID_PARAMETER;
- }
- ret |= media_format_set_video_mime(video_format, push_media->mimetype);
- }
- ret |= media_format_get_video_info(video_format, &mimetype, NULL, NULL, NULL, NULL);
- if (mimetype != push_media->mimetype) {
- media_format_unref(video_format);
- media_format_create(&video_format);
- ret |= media_format_set_video_mime(video_format, push_media->mimetype);
- }
- format = video_format;
- } else if (push_media->mimetype & MEDIA_FORMAT_AUDIO) {
- if (!audio_format) {
- media_format_create(&audio_format);
- if (!audio_format) {
- LOGE("fail to create media format");
- return PLAYER_ERROR_INVALID_PARAMETER;
- }
- ret |= media_format_set_audio_mime(audio_format, push_media->mimetype);
- }
- ret |= media_format_get_audio_info(audio_format, &mimetype, NULL, NULL, NULL, NULL);
- if (mimetype != push_media->mimetype) {
- media_format_unref(audio_format);
- media_format_create(&audio_format);
- ret |= media_format_set_audio_mime(audio_format, push_media->mimetype);
- }
- format = audio_format;
- } else
- ret = MEDIA_FORMAT_ERROR_INVALID_PARAMETER;
-
- if (ret != MEDIA_FORMAT_ERROR_NONE) {
- LOGE("Invalid MIME %d", push_media->mimetype);
- return PLAYER_ERROR_INVALID_PARAMETER;
- }
-
- if (buf) {
- ret = media_packet_create_from_external_memory(format, buf, push_media->size, NULL, NULL, &packet);
- if (ret != MEDIA_PACKET_ERROR_NONE) {
- LOGE("fail to create media packet with external mem");
- return PLAYER_ERROR_INVALID_PARAMETER;
- }
- } else {
- ret = media_packet_create(format, NULL, NULL, &packet);
- if (ret != MEDIA_PACKET_ERROR_NONE) {
- LOGE("fail to create media packet");
- return PLAYER_ERROR_INVALID_PARAMETER;
- }
- }
-
- media_packet_set_pts(packet, push_media->pts);
- media_packet_set_flags(packet, push_media->flags);
-
- ret = player_push_media_stream((player_h)handle, packet);
- if (ret != PLAYER_ERROR_NONE)
- LOGE("ret %d", ret);
-
- media_packet_destroy(packet);
-
- return ret;
-}
-
-static int player_disp_push_media_stream(muse_module_h module)
-{
- int ret = MEDIA_FORMAT_ERROR_NONE;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_PUSH_MEDIA_STREAM;
- player_push_media_msg_type push_media;
- char *push_media_msg = (char *)&push_media;
- tbm_bo bo = NULL;
- tbm_bo_handle thandle;
- char *buf = NULL;
-
- handle = muse_core_ipc_get_handle(module);
- if (!player_msg_get_array(push_media_msg, muse_core_client_get_msg(module))) {
- ret = PLAYER_ERROR_INVALID_OPERATION;
- goto push_media_stream_exit1;
- }
-
- if (push_media.buf_type == PUSH_MEDIA_BUF_TYPE_TBM) {
- bo = tbm_bo_import(bufmgr, push_media.key);
- if (bo == NULL) {
- LOGE("TBM get error : bo is NULL");
- ret = PLAYER_ERROR_INVALID_OPERATION;
- goto push_media_stream_exit1;
- }
- thandle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
- if (thandle.ptr == NULL) {
- LOGE("TBM get error : handle pointer is NULL");
- ret = PLAYER_ERROR_INVALID_OPERATION;
- goto push_media_stream_exit2;
- }
- buf = thandle.ptr;
- } else if (push_media.buf_type == PUSH_MEDIA_BUF_TYPE_MSG) {
- buf = g_new(char, push_media.size);
- if (!buf) {
- ret = PLAYER_ERROR_OUT_OF_MEMORY;
- goto push_media_stream_exit1;
- }
- player_msg_get_array(buf, muse_core_client_get_msg(module));
- } else if (push_media.buf_type == PUSH_MEDIA_BUF_TYPE_RAW) {
-#ifdef USE_PUSH_THREAD
- push_data_q_t *qData = g_new(push_data_q_t, 1);
- data_thread_info_t *thread_i = (data_thread_info_t *)muse_core_client_get_cust_data(module);
- if (!qData) {
- ret = PLAYER_ERROR_OUT_OF_MEMORY;
- goto push_media_stream_exit1;
- }
- qData->handle = handle;
- qData->mimetype = push_media.mimetype;
- qData->pts = push_media.pts;
- qData->size = push_media.size;
- qData->flags = push_media.flags;
-
- g_queue_push_tail(thread_i->queue, qData);
- g_cond_signal(&thread_i->cond);
-#else
- buf = muse_core_ipc_get_data(module);
-#endif
- }
-
-#ifdef USE_PUSH_THREAD
- if (push_media.buf_type == PUSH_MEDIA_BUF_TYPE_RAW)
- ret = PLAYER_ERROR_NONE;
- else
-#endif
- ret = _push_media_stream(handle, &push_media, buf);
-
- if (push_media.buf_type == PUSH_MEDIA_BUF_TYPE_TBM)
- tbm_bo_unmap(bo);
-push_media_stream_exit2:
- if (push_media.buf_type == PUSH_MEDIA_BUF_TYPE_TBM)
- tbm_bo_unref(bo);
- else if (push_media.buf_type == PUSH_MEDIA_BUF_TYPE_MSG)
- g_free(buf);
-#ifndef USE_PUSH_THREAD
- else if (push_media.buf_type == PUSH_MEDIA_BUF_TYPE_RAW && buf)
- muse_core_ipc_delete_data(buf);
-#endif
-push_media_stream_exit1:
- player_msg_return(api, ret, module);
- return ret;
-}
-
-static int player_disp_set_media_stream_info(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_SET_MEDIA_STREAM_INFO;
- media_format_mimetype_e mimetype;
- player_stream_type_e type;
- int width;
- int height;
- int avg_bps;
- int max_bps;
- int channel;
- int samplerate;
- int bit;
- media_format_h format;
-
- handle = muse_core_ipc_get_handle(module);
- player_msg_get(mimetype, muse_core_client_get_msg(module));
- player_msg_get(type, muse_core_client_get_msg(module));
- player_msg_get(avg_bps, muse_core_client_get_msg(module));
- if (type == PLAYER_STREAM_TYPE_VIDEO) {
- player_msg_get(width, muse_core_client_get_msg(module));
- player_msg_get(height, muse_core_client_get_msg(module));
- player_msg_get(max_bps, muse_core_client_get_msg(module));
- } else if (type == PLAYER_STREAM_TYPE_AUDIO) {
- player_msg_get(channel, muse_core_client_get_msg(module));
- player_msg_get(samplerate, muse_core_client_get_msg(module));
- player_msg_get(bit, muse_core_client_get_msg(module));
- } else {
- ret = PLAYER_ERROR_INVALID_PARAMETER;
- goto set_media_stream_info_exit;
- }
-
- if (media_format_create(&format) == MEDIA_FORMAT_ERROR_NONE) {
- if (type == PLAYER_STREAM_TYPE_VIDEO) {
- ret = media_format_set_video_mime(format, mimetype);
- ret |= media_format_set_video_width(format, width);
- ret |= media_format_set_video_height(format, height);
- ret |= media_format_set_video_avg_bps(format, avg_bps);
- ret |= media_format_set_video_max_bps(format, max_bps);
- } else if (type == PLAYER_STREAM_TYPE_AUDIO) {
- ret = media_format_set_audio_mime(format, mimetype);
- ret |= media_format_set_audio_channel(format, channel);
- ret |= media_format_set_audio_samplerate(format, samplerate);
- ret |= media_format_set_audio_bit(format, bit);
- ret |= media_format_set_audio_avg_bps(format, avg_bps);
- }
- if (ret != MEDIA_FORMAT_ERROR_NONE) {
- ret = PLAYER_ERROR_INVALID_OPERATION;
- goto set_media_stream_info_exit;
- }
- } else {
- ret = PLAYER_ERROR_OUT_OF_MEMORY;
- goto set_media_stream_info_exit;
- }
-
- ret = player_set_media_stream_info((player_h)handle, type, format);
-
- set_media_stream_info_exit:
- player_msg_return(api, ret, module);
- return ret;
-}
-
-static int player_disp_media_packet_finalize_cb(muse_module_h module)
-{
- media_packet_h packet;
-
- player_msg_get_type(packet, muse_core_client_get_msg(module), POINTER);
-
- media_packet_destroy(packet);
-
- return PLAYER_ERROR_NONE;
-}
-
-static int player_disp_set_media_stream_buffer_max_size(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_SET_MEDIA_STREAM_BUFFER_MAX_SIZE;
- player_stream_type_e type;
- unsigned long long max_size;
- /* unsigned upper_max_size, lower_max_size; */
-
- handle = muse_core_ipc_get_handle(module);
- player_msg_get(type, muse_core_client_get_msg(module));
-#if 0
- player_msg_get(upper_max_size, muse_core_client_get_msg(module));
- player_msg_get(lower_max_size, muse_core_client_get_msg(module));
-
- max_size = (((unsigned long long)upper_max_size << 32) & 0xffffffff00000000)
- | (lower_max_size & 0xffffffff);
-#else
- player_msg_get_type(max_size, muse_core_client_get_msg(module), INT64);
-#endif
-
- ret = player_set_media_stream_buffer_max_size((player_h) handle, type, max_size);
-
- player_msg_return(api, ret, module);
-
- return ret;
-}
-
-static int player_disp_get_media_stream_buffer_max_size(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_GET_MEDIA_STREAM_BUFFER_MAX_SIZE;
- player_stream_type_e type;
- unsigned long long max_size;
- /* unsigned upper_max_size, lower_max_size; */
-
- handle = muse_core_ipc_get_handle(module);
- player_msg_get(type, muse_core_client_get_msg(module));
-
- ret = player_get_media_stream_buffer_max_size((player_h)handle, type, &max_size);
- if (ret == PLAYER_ERROR_NONE) {
-#if 0
- upper_max_size = (unsigned)((max_size >> 32) & 0xffffffff);
- lower_max_size = (unsigned)(max_size & 0xffffffff);
- player_msg_return2(api, ret, module, INT, upper_max_size, INT, lower_max_size);
-#else
- player_msg_return1(api, ret, module, INT64, max_size);
-#endif
- } else
- player_msg_return(api, ret, module);
-
- return ret;
-}
-
-static int player_disp_set_media_stream_buffer_min_threshold(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_SET_MEDIA_STREAM_BUFFER_MIN_THRESHOLD;
- player_stream_type_e type;
- unsigned percent;
-
- handle = muse_core_ipc_get_handle(module);
- player_msg_get(type, muse_core_client_get_msg(module));
- player_msg_get(percent, muse_core_client_get_msg(module));
-
- ret = player_set_media_stream_buffer_min_threshold((player_h)handle, type, percent);
-
- player_msg_return(api, ret, module);
-
- return ret;
-}
-
-static int player_disp_get_media_stream_buffer_min_threshold(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_GET_MEDIA_STREAM_BUFFER_MIN_THRESHOLD;
- player_stream_type_e type;
- unsigned percent;
-
- handle = muse_core_ipc_get_handle(module);
- player_msg_get(type, muse_core_client_get_msg(module));
-
- ret = player_get_media_stream_buffer_min_threshold((player_h)handle, type, &percent);
- if (ret == PLAYER_ERROR_NONE)
- player_msg_return1(api, ret, module, INT, percent);
- else
- player_msg_return(api, ret, module);
-
- return ret;
-}
-
-static int player_disp_get_track_count(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_GET_TRACK_COUNT;
- player_stream_type_e type;
- int count;
-
- handle = muse_core_ipc_get_handle(module);
- player_msg_get(type, muse_core_client_get_msg(module));
-
- ret = player_get_track_count((player_h)handle, type, &count);
- if (ret == PLAYER_ERROR_NONE)
- player_msg_return1(api, ret, module, INT, count);
- else
- player_msg_return(api, ret, module);
-
- return ret;
-}
-
-static int player_disp_get_current_track(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_GET_CURRENT_TRACK;
- player_stream_type_e type;
- int index;
-
- handle = muse_core_ipc_get_handle(module);
- player_msg_get(type, muse_core_client_get_msg(module));
-
- ret = player_get_current_track((player_h)handle, type, &index);
- if (ret == PLAYER_ERROR_NONE)
- player_msg_return1(api, ret, module, INT, index);
- else
- player_msg_return(api, ret, module);
-
- return ret;
-}
-
-static int player_disp_select_track(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_SELECT_TRACK;
- player_stream_type_e type;
- int index;
-
- handle = muse_core_ipc_get_handle(module);
- player_msg_get(type, muse_core_client_get_msg(module));
- player_msg_get(index, muse_core_client_get_msg(module));
-
- ret = player_select_track((player_h)handle, type, index);
- player_msg_return(api, ret, module);
-
- return ret;
-}
-
-static int player_disp_get_track_language_code(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_GET_TRACK_LANGUAGE_CODE;
- player_stream_type_e type;
- int index;
- char *code;
- const int code_len = 2;
-
- handle = muse_core_ipc_get_handle(module);
- player_msg_get(type, muse_core_client_get_msg(module));
- player_msg_get(index, muse_core_client_get_msg(module));
-
- ret = player_get_track_language_code((player_h)handle, type, index, &code);
- if (ret == PLAYER_ERROR_NONE)
- player_msg_return_array(api, ret, module, code, code_len, sizeof(char));
- else
- player_msg_return(api, ret, module);
-
- return ret;
-}
-
-static int player_disp_set_pcm_extraction_mode(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_SET_PCM_EXTRACTION_MODE;
- int sync;
-
- handle = muse_core_ipc_get_handle(module);
- player_msg_get(sync, muse_core_client_get_msg(module));
-
- ret = player_set_pcm_extraction_mode((player_h)handle, sync, _audio_frame_decoded_cb, module);
-
- player_msg_return(api, ret, module);
-
- return ret;
-}
-
-static int player_disp_set_pcm_spec(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_SET_PCM_SPEC;
- char format[MUSE_URI_MAX_LENGTH] = { 0, };
- int samplerate;
- int channel;
-
- handle = muse_core_ipc_get_handle(module);
- player_msg_get_string(format, muse_core_client_get_msg(module));
- player_msg_get(samplerate, muse_core_client_get_msg(module));
- player_msg_get(channel, muse_core_client_get_msg(module));
-
- ret = player_set_pcm_spec((player_h)handle, format, samplerate, channel);
-
- player_msg_return(api, ret, module);
-
- return ret;
-}
-
-static int player_disp_set_streaming_playback_rate(muse_module_h module)
-{
- int ret = -1;
- intptr_t handle;
- muse_player_api_e api = MUSE_PLAYER_API_SET_STREAMING_PLAYBACK_RATE;
- double rate = 0;
-
- handle = muse_core_ipc_get_handle(module);
- player_msg_get_type(rate, muse_core_client_get_msg(module), DOUBLE);
-
- ret = player_set_streaming_playback_rate((player_h)handle, (float)rate);
-
- player_msg_return(api, ret, module);
-
- return ret;
-}
-
-int (*dispatcher[MUSE_PLAYER_API_MAX])(muse_module_h module) = {
- player_disp_create, /* MUSE_PLAYER_API_CREATE */
- player_disp_destroy, /* MUSE_PLAYER_API_DESTROY */
- player_disp_prepare, /* MUSE_PLAYER_API_PREPARE */
- player_disp_prepare_async, /* MUSE_PLAYER_API_PREPARE_ASYNC */
- player_disp_unprepare, /* MUSE_PLAYER_API_UNPREPARE */
- player_disp_set_uri, /* MUSE_PLAYER_API_SET_URI */
- player_disp_start, /* MUSE_PLAYER_API_START */
- player_disp_stop, /* MUSE_PLAYER_API_STOP */
- player_disp_pause, /* MUSE_PLAYER_API_PAUSE */
- player_disp_set_memory_buffer, /* MUSE_PLAYER_API_SET_MEMORY_BUFFER */
- player_disp_deinit_memory_buffer, /* MUSE_PLAYER_API_DEINIT_MEMORY_BUFFER */
- player_disp_get_state, /* MUSE_PLAYER_API_GET_STATE */
- player_disp_set_volume, /* MUSE_PLAYER_API_SET_VOLUME */
- player_disp_get_volume, /* MUSE_PLAYER_API_GET_VOLUME */
- player_disp_set_sound_type, /* MUSE_PLAYER_API_SET_SOUND_TYPE */
- player_disp_set_audio_policy_info, /* MUSE_PLAYER_API_SET_AUDIO_POLICY_INFO */
- player_disp_set_latency_mode, /* MUSE_PLAYER_API_SET_AUDIO_LATENCY_MODE */
- player_disp_get_latency_mode, /* MUSE_PLAYER_API_GET_AUDIO_LATENCY_MODE */
- player_disp_set_play_position, /* MUSE_PLAYER_API_SET_PLAY_POSITION */
- player_disp_get_play_position, /* MUSE_PLAYER_API_GET_PLAY_POSITION */
- player_disp_set_mute, /* MUSE_PLAYER_API_SET_MUTE */
- player_disp_is_muted, /* MUSE_PLAYER_API_IS_MUTED */
- player_disp_set_looping, /* MUSE_PLAYER_API_SET_LOOPING */
- player_disp_is_looping, /* MUSE_PLAYER_API_IS_LOOPING */
- player_disp_get_duration, /* MUSE_PLAYER_API_GET_DURATION */
- player_disp_set_display, /* MUSE_PLAYER_API_SET_DISPLAY */
- player_disp_set_display_mode, /* MUSE_PLAYER_API_SET_DISPLAY_MODE */
- player_disp_get_display_mode, /* MUSE_PLAYER_API_GET_DISPLAY_MODE */
- player_disp_set_playback_rate, /* MUSE_PLAYER_API_SET_PLAYBACK_RATE */
- player_disp_set_display_rotation, /* MUSE_PLAYER_API_SET_DISPLAY_ROTATION */
- player_disp_get_display_rotation, /* MUSE_PLAYER_API_GET_DISPLAY_ROTATION */
- player_disp_set_display_visible, /* MUSE_PLAYER_API_SET_DISPLAY_VISIBLE */
- player_disp_is_display_visible, /* MUSE_PLAYER_API_IS_DISPLAY_VISIBLE */
- player_disp_resize_video_render_rect, /* MUSE_PLAYER_API_RESIZE_VIDEO_RENDER_RECT */
- player_disp_get_content_info, /* MUSE_PLAYER_API_GET_CONTENT_INFO */
- player_disp_get_codec_info, /* MUSE_PLAYER_API_GET_CODEC_INFO */
- player_disp_get_audio_stream_info, /* MUSE_PLAYER_API_GET_AUDIO_STREAM_INFO */
- player_disp_get_video_stream_info, /* MUSE_PLAYER_API_GET_VIDEO_STREAM_INFO */
- player_disp_get_video_size, /* MUSE_PLAYER_API_GET_VIDEO_SIZE */
- player_disp_get_album_art, /* MUSE_PLAYER_API_GET_ALBUM_ART */
- player_disp_get_eq_bands_count, /* MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_BANDS_COUNT */
- player_disp_set_eq_all_bands, /* MUSE_PLAYER_API_AUDIO_EFFECT_SET_EQUALIZER_ALL_BANDS */
- player_disp_set_eq_band_level, /* MUSE_PLAYER_API_AUDIO_EFFECT_SET_EQUALIZER_BAND_LEVEL */
- player_disp_get_eq_band_level, /* MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_BAND_LEVEL */
- player_disp_get_eq_level_range, /* MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_LEVEL_RANGE */
- player_disp_get_eq_band_frequency, /* MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_BAND_FREQUENCY */
- player_disp_get_eq_band_frequency_range, /* MUSE_PLAYER_API_AUDIO_EFFECT_GET_EQUALIZER_BAND_FREQUENCY_RANGE */
- player_disp_eq_clear, /* MUSE_PLAYER_API_AUDIO_EFFECT_EQUALIZER_CLEAR */
- player_disp_eq_is_available, /* MUSE_PLAYER_API_AUDIO_EFFECT_EQUALIZER_IS_AVAILABLE */
- player_disp_set_progressive_download_path, /* MUSE_PLAYER_API_SET_PROGRESSIVE_DOWNLOAD_PATH */
- player_disp_get_progressive_download_status, /* MUSE_PLAYER_API_GET_PROGRESSIVE_DOWNLOAD_STATUS */
- player_disp_capture_video, /* MUSE_PLAYER_API_CAPTURE_VIDEO */
- player_disp_set_streaming_cookie, /* MUSE_PLAYER_API_SET_STREAMING_COOKIE */
- player_disp_set_streaming_user_agent, /* MUSE_PLAYER_API_SET_STREAMING_USER_AGENT */
- player_disp_get_streaming_download_progress, /* MUSE_PLAYER_API_GET_STREAMING_DOWNLOAD_PROGRESS */
- player_disp_set_subtitle_path, /* MUSE_PLAYER_API_SET_SUBTITLE_PATH */
- player_disp_set_subtitle_position_offset, /* MUSE_PLAYER_API_SET_SUBTITLE_POSITION_OFFSET */
- player_disp_push_media_stream, /* MUSE_PLAYER_API_PUSH_MEDIA_STREAM */
- player_disp_set_media_stream_info, /* MUSE_PLAYER_API_SET_MEDIA_STREAM_INFO */
- player_disp_set_callback, /* MUSE_PLAYER_API_SET_CALLBACK */
- player_disp_media_packet_finalize_cb, /* MUSE_PLAYER_API_MEDIA_PACKET_FINALIZE_CB */
- player_disp_set_media_stream_buffer_max_size, /* MUSE_PLAYER_API_SET_MEDIA_STREAM_BUFFER_MAX_SIZE */
- player_disp_get_media_stream_buffer_max_size, /* MUSE_PLAYER_API_GET_MEDIA_STREAM_BUFFER_MAX_SIZE */
- player_disp_set_media_stream_buffer_min_threshold, /* MUSE_PLAYER_API_SET_MEDIA_STREAM_BUFFER_MIN_THRESHOLD */
- player_disp_get_media_stream_buffer_min_threshold, /* MUSE_PLAYER_API_GET_MEDIA_STREAM_BUFFER_MIN_THRESHOLD */
- player_disp_get_track_count, /* MUSE_PLAYER_API_GET_TRACK_COUNT */
- player_disp_get_current_track, /* MUSE_PLAYER_API_GET_CURRENT_TRACK */
- player_disp_select_track, /* MUSE_PLAYER_API_SELECT_TRACK */
- player_disp_get_track_language_code, /* MUSE_PLAYER_API_GET_TRACK_LANGUAGE_CODE */
- player_disp_set_pcm_extraction_mode, /* MUSE_PLAYER_API_SET_PCM_EXTRACTION_MODE */
- player_disp_set_pcm_spec, /* MUSE_PLAYER_API_SET_PCM_SPEC */
- player_disp_set_streaming_playback_rate, /* MUSE_PLAYER_API_SET_STREAMING_PLAYBACK_RATE */
-};