From: Younghwan Ahn Date: Tue, 21 Aug 2012 13:53:43 +0000 (+0900) Subject: 2.0 beta init X-Git-Tag: 2.0_alpha~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b9592e700f2ed2035014064a50dc6f43ac75ce95;p=platform%2Fcore%2Fapi%2Fplayer.git 2.0 beta init --- diff --git a/CMakeLists.txt b/CMakeLists.txt old mode 100644 new mode 100755 index 354ff5c..199ca0a --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(INC_DIR include) INCLUDE_DIRECTORIES(${INC_DIR}) -SET(dependents "dlog mm-player capi-base-common capi-media-sound-manager") +SET(dependents "dlog mm-player capi-base-common capi-media-sound-manager mm-ta") SET(pc_dependents "capi-base-common capi-media-sound-manager") INCLUDE(FindPkgConfig) @@ -19,7 +19,7 @@ FOREACH(flag ${${fw_name}_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror -DGST_EXT_TIME_ANALYSIS") SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") IF("${ARCH}" STREQUAL "arm") diff --git a/TC/_export_env.sh b/TC/_export_env.sh new file mode 100755 index 0000000..72a11ec --- /dev/null +++ b/TC/_export_env.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +. ./config +export TET_INSTALL_PATH=$TET_INSTALL_HOST_PATH # tetware root path +export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target # tetware target path +export PATH=$TET_TARGET_PATH/bin:$PATH +export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH +export TET_ROOT=$TET_TARGET_PATH diff --git a/TC/_export_target_env.sh b/TC/_export_target_env.sh new file mode 100755 index 0000000..5ddaa53 --- /dev/null +++ b/TC/_export_target_env.sh @@ -0,0 +1,7 @@ +#!/bin/sh +. ./config +export TET_INSTALL_PATH=$TET_INSTALL_TARGET_PATH # path to path +export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target +export PATH=$TET_TARGET_PATH/bin:$PATH +export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH +export TET_ROOT=$TET_TARGET_PATH diff --git a/TC/build.sh b/TC/build.sh new file mode 100755 index 0000000..72aad6c --- /dev/null +++ b/TC/build.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +. ./_export_env.sh # setting environment variables + +export TET_SUITE_ROOT=`pwd` +FILE_NAME_EXTENSION=`date +%s` + +RESULT_DIR=results +HTML_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.html +JOURNAL_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.journal + +mkdir -p $RESULT_DIR + +tcc -c -p ./ +tcc -b -j $JOURNAL_RESULT -p ./ +grw -c 7 -f chtml -o $HTML_RESULT $JOURNAL_RESULT diff --git a/TC/clean.sh b/TC/clean.sh new file mode 100755 index 0000000..29743e0 --- /dev/null +++ b/TC/clean.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +. ./_export_env.sh # setting environment variables + +export TET_SUITE_ROOT=`pwd` +RESULT_DIR=results + +tcc -c -p ./ # executing tcc, with clean option (-c) +rm -r $RESULT_DIR +rm -r tet_tmp_dir +rm testcase/tet_captured diff --git a/TC/config b/TC/config new file mode 100644 index 0000000..04684f0 --- /dev/null +++ b/TC/config @@ -0,0 +1,2 @@ +TET_INSTALL_HOST_PATH=/home/rookiejava/dts_tool/TETware +TET_INSTALL_TARGET_PATH=/mnt/nfs/dts_tool/TETware diff --git a/TC/execute.sh b/TC/execute.sh new file mode 100755 index 0000000..a4f6095 --- /dev/null +++ b/TC/execute.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +. ./_export_target_env.sh # setting environment variables + +export TET_SUITE_ROOT=`pwd` +FILE_NAME_EXTENSION=`date +%s` + +RESULT_DIR=results +HTML_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.html +JOURNAL_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.journal + +mkdir -p $RESULT_DIR + +tcc -e -j $JOURNAL_RESULT -p ./ +grw -c 3 -f chtml -o $HTML_RESULT $JOURNAL_RESULT diff --git a/TC/media_samsung.mp4 b/TC/media_samsung.mp4 new file mode 100644 index 0000000..983f6ac Binary files /dev/null and b/TC/media_samsung.mp4 differ diff --git a/TC/testcase/Makefile b/TC/testcase/Makefile new file mode 100755 index 0000000..7718bc5 --- /dev/null +++ b/TC/testcase/Makefile @@ -0,0 +1,25 @@ +CC ?= gcc + +C_FILES = $(shell ls *.c) + +PKGS = capi-media-player dlog glib-2.0 gthread-2.0 + +LDFLAGS = `pkg-config --libs $(PKGS)` +LDFLAGS += $(TET_ROOT)/lib/tet3/tcm_s.o +LDFLAGS += -L$(TET_ROOT)/lib/tet3 -ltcm_s +LDFLAGS += -L$(TET_ROOT)/lib/tet3 -lapi_s + +CFLAGS = -I. `pkg-config --cflags $(PKGS)` +CFLAGS += -I$(TET_ROOT)/inc/tet3 +CFLAGS += -Wall + +#TARGETS = $(C_FILES:%.c=tc-%) +TCS := $(shell ls -1 *.c | cut -d. -f1) + +all: $(TCS) + +%: %.c + $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS) + +clean: + rm -f $(TCS) diff --git a/TC/testcase/tslist b/TC/testcase/tslist new file mode 100644 index 0000000..c39d0e9 --- /dev/null +++ b/TC/testcase/tslist @@ -0,0 +1,3 @@ +/testcase/utc_media_player +/testcase/utc_media_player_callback +/testcase/utc_media_player_lifecycle \ No newline at end of file diff --git a/TC/testcase/utc_media_player.c b/TC/testcase/utc_media_player.c new file mode 100644 index 0000000..87fd305 --- /dev/null +++ b/TC/testcase/utc_media_player.c @@ -0,0 +1,1044 @@ +/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include +#include +#include + +#define MEDIA_PATH "/mnt/nfs/workspace/capi/media/player/TC/media_samsung.mp4" + +enum { + POSITIVE_TC_IDX = 0x01, + NEGATIVE_TC_IDX, +}; + +//keeping ret and player global, since using startup function for all +player_h player; +int sRet; + +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + +static void utc_media_player_get_duration_p(void); +static void utc_media_player_get_duration_n(void); +static void utc_media_player_set_position_p(void); +static void utc_media_player_set_position_n(void); +static void utc_media_player_get_position_p(void); +static void utc_media_player_get_position_n(void); +static void utc_media_player_set_position_ratio_p(void); +static void utc_media_player_set_position_ratio_n(void); +static void utc_media_player_get_position_ratio_p(void); +static void utc_media_player_get_position_ratio_n(void); +static void utc_media_player_get_state_p(void); +static void utc_media_player_get_state_n(void); +static void utc_media_player_get_video_size_p(void); +static void utc_media_player_get_video_size_n(void); +static void utc_media_player_set_looping_p(void); +static void utc_media_player_set_looping_n(void); +static void utc_media_player_is_looping_p(void); +static void utc_media_player_is_looping_n(void); +static void utc_media_player_set_mute_p(void); +static void utc_media_player_set_mute_n(void); +static void utc_media_player_is_muted_p(void); +static void utc_media_player_is_muted_n(void); +static void utc_media_player_set_display_p(void); +static void utc_media_player_set_display_n(void); +static void utc_media_player_set_memory_buffer_p(void); +static void utc_media_player_set_memory_buffer_n(void); +static void utc_media_player_set_volume_p(void); +static void utc_media_player_set_volume_n(void); +static void utc_media_player_get_volume_p(void); +static void utc_media_player_get_volume_n(void); +static void utc_media_player_set_sound_type_p(void); +static void utc_media_player_set_sound_type_n(void); +static void utc_media_player_set_subtitle_path_p(void); +static void utc_media_player_set_subtitle_path_n(void); +static void utc_media_player_set_x11_display_visible_p(void); +static void utc_media_player_set_x11_display_visible_n(void); +static void utc_media_player_is_x11_display_visible_p(void); +static void utc_media_player_is_x11_display_visible_n(void); +static void utc_media_player_set_x11_display_rotation_p(void); +static void utc_media_player_set_x11_display_rotation_n(void); +static void utc_media_player_get_x11_display_rotation_p(void); +static void utc_media_player_get_x11_display_rotation_n(void); +static void utc_media_player_set_display_mode_p(void); +static void utc_media_player_set_display_mode_n(void); +static void utc_media_player_get_display_mode_p(void); +static void utc_media_player_get_display_mode_n(void); +static void utc_media_player_capture_video_p(void); +static void utc_media_player_capture_video_n(void); + +struct tet_testlist tet_testlist[] = { + { utc_media_player_get_duration_p , POSITIVE_TC_IDX }, + { utc_media_player_get_duration_n , NEGATIVE_TC_IDX }, + { utc_media_player_set_position_p , POSITIVE_TC_IDX }, + { utc_media_player_set_position_n , NEGATIVE_TC_IDX }, + { utc_media_player_get_position_p , POSITIVE_TC_IDX }, + { utc_media_player_get_position_n , NEGATIVE_TC_IDX }, + { utc_media_player_set_position_ratio_p , POSITIVE_TC_IDX }, + { utc_media_player_set_position_ratio_n , NEGATIVE_TC_IDX }, + { utc_media_player_get_position_ratio_p , POSITIVE_TC_IDX }, + { utc_media_player_get_position_ratio_n , NEGATIVE_TC_IDX }, + { utc_media_player_get_state_p , POSITIVE_TC_IDX }, + { utc_media_player_get_state_n , NEGATIVE_TC_IDX }, + { utc_media_player_get_video_size_p , POSITIVE_TC_IDX }, + { utc_media_player_get_video_size_n , NEGATIVE_TC_IDX }, + { utc_media_player_set_looping_p , POSITIVE_TC_IDX }, + { utc_media_player_set_looping_n , NEGATIVE_TC_IDX }, + { utc_media_player_is_looping_p , POSITIVE_TC_IDX }, + { utc_media_player_is_looping_n , NEGATIVE_TC_IDX }, + { utc_media_player_set_mute_p , POSITIVE_TC_IDX }, + { utc_media_player_set_mute_n , NEGATIVE_TC_IDX }, + { utc_media_player_is_muted_p , POSITIVE_TC_IDX }, + { utc_media_player_is_muted_n , NEGATIVE_TC_IDX }, + { utc_media_player_set_display_p , POSITIVE_TC_IDX }, + { utc_media_player_set_display_n , NEGATIVE_TC_IDX }, + { utc_media_player_set_memory_buffer_p , POSITIVE_TC_IDX }, + { utc_media_player_set_memory_buffer_n, NEGATIVE_TC_IDX }, + { utc_media_player_set_volume_p , POSITIVE_TC_IDX }, + { utc_media_player_set_volume_n , NEGATIVE_TC_IDX }, + { utc_media_player_get_volume_p , POSITIVE_TC_IDX }, + { utc_media_player_get_volume_n , NEGATIVE_TC_IDX }, + { utc_media_player_set_sound_type_p , POSITIVE_TC_IDX }, + { utc_media_player_set_sound_type_n , NEGATIVE_TC_IDX }, + { utc_media_player_set_subtitle_path_p , POSITIVE_TC_IDX }, + { utc_media_player_set_subtitle_path_n , NEGATIVE_TC_IDX }, + { utc_media_player_set_x11_display_visible_p , POSITIVE_TC_IDX }, + { utc_media_player_set_x11_display_visible_n , NEGATIVE_TC_IDX }, + { utc_media_player_is_x11_display_visible_p , POSITIVE_TC_IDX }, + { utc_media_player_is_x11_display_visible_n , NEGATIVE_TC_IDX }, + { utc_media_player_set_x11_display_rotation_p , POSITIVE_TC_IDX }, + { utc_media_player_set_x11_display_rotation_n , NEGATIVE_TC_IDX }, + { utc_media_player_get_x11_display_rotation_p , POSITIVE_TC_IDX }, + { utc_media_player_get_x11_display_rotation_n , NEGATIVE_TC_IDX }, + { utc_media_player_set_display_mode_p , POSITIVE_TC_IDX }, + { utc_media_player_set_display_mode_n , NEGATIVE_TC_IDX }, + { utc_media_player_get_display_mode_p , POSITIVE_TC_IDX }, + { utc_media_player_get_display_mode_n , NEGATIVE_TC_IDX }, + { utc_media_player_capture_video_p , POSITIVE_TC_IDX }, + { utc_media_player_capture_video_n , NEGATIVE_TC_IDX }, + { NULL, 0 }, +}; + +static GMainLoop *g_mainloop = NULL; +static GThread *event_thread; + +gpointer GmainThread(gpointer data){ + g_mainloop = g_main_loop_new (NULL, 0); + g_main_loop_run (g_mainloop); + + return NULL; +} + +static void startup(void) +{ + if( !g_thread_supported() ) + { + g_thread_init(NULL); + } + + GError *gerr = NULL; + event_thread = g_thread_create(GmainThread, NULL, 1, &gerr); + + if ((sRet = player_create(&player)) == PLAYER_ERROR_NONE) + { + sRet = player_set_uri(player, MEDIA_PATH); + } +} + +static void cleanup(void) +{ + player_destroy(player); + g_main_loop_quit (g_mainloop); + g_thread_join(event_thread); +} + +static void player_video_capture_cb(unsigned char *data, int width, int height, unsigned int size, void *user_data) +{ + dts_message("Player", "player_video_capture_cb!!!"); +} + +static void reset(void) +{ + if ((sRet = player_unprepare(player)) == PLAYER_ERROR_NONE) + { + sRet = player_set_uri(player, MEDIA_PATH); + } +} + +static void utc_media_player_get_duration_p(void) +{ + char* api_name = "player_get_duration"; + int ret; + int duration; + if (sRet == PLAYER_ERROR_NONE) + { + player_prepare(player); + { + if ((ret = player_start(player)) == PLAYER_ERROR_NONE) + { + sleep(3); + if ((ret = player_get_duration(player, &duration)) == PLAYER_ERROR_NONE) + { + player_stop(player); + reset(); + dts_pass(api_name); + } + if ((sRet = player_stop(player)) == PLAYER_ERROR_NONE) + { + dts_message(api_name, "Call log: %d %d", sRet, ret); + } + } + reset(); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_get_duration_n(void) +{ + char* api_name = "player_get_duration"; + int ret; + int duration; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_get_duration(player, &duration)) != PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_set_position_p(void) +{ + char* api_name = "utc_media_player_set_position_p"; + int ret; + int position = 10000; + if (sRet == PLAYER_ERROR_NONE) + { + player_prepare(player); + { + if ((ret = player_set_position(player, position,NULL,NULL)) == PLAYER_ERROR_NONE) + { + reset(); + dts_pass(api_name); + } + } + reset(); + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_set_position_n(void) +{ + char* api_name = "utc_media_player_set_position_n"; + int ret; + int position = 10000; + player_h player1 = NULL; + if ((ret = player_set_position(player1, position,NULL,NULL)) != PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_get_position_p(void) +{ + char* api_name = "player_get_position"; + int ret; + int position; + if (sRet == PLAYER_ERROR_NONE) + { + player_prepare(player); + { + if ((ret = player_get_position(player, &position)) == PLAYER_ERROR_NONE) + { + reset(); + dts_pass(api_name); + } + } + reset(); + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_get_position_n(void) +{ + char* api_name = "player_get_position"; + int ret; + int position; + player_h player1 = NULL; + if ((ret = player_get_position(player1, &position)) != PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_set_position_ratio_p(void) +{ + char* api_name = "utc_media_player_set_position_ratio_p"; + int ret; + int pos_ratio = 10; + + if (sRet == PLAYER_ERROR_NONE) + { + player_prepare(player); + { + if ((ret = player_set_position_ratio(player, pos_ratio,NULL,NULL)) == PLAYER_ERROR_NONE) + { + reset(); + dts_pass(api_name); + } + } + reset(); + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_set_position_ratio_n(void) +{ + char* api_name = "utc_media_player_set_position_ratio_n"; + int ret; + int pos_ratio = 10; + player_h player1 = NULL; + if ((ret = player_get_position_ratio(player1, pos_ratio)) != PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_get_position_ratio_p(void) +{ + char* api_name = "player_get_position_ratio"; + int ret; + int pos_ratio; + + if (sRet == PLAYER_ERROR_NONE) + { + player_prepare(player); + { + if ((ret = player_get_position_ratio(player, &pos_ratio)) == PLAYER_ERROR_NONE) + { + reset(); + dts_pass(api_name); + } + } + reset(); + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_get_position_ratio_n(void) +{ + char* api_name = "player_get_position_ratio"; + int ret; + int pos_ratio; + player_h player1 = NULL; + if ((ret = player_get_position_ratio(player1, &pos_ratio)) != PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_get_state_p(void) +{ + char* api_name = "player_get_state"; + int ret; + player_state_e cur_state; + if (sRet == PLAYER_ERROR_NONE) + { + player_prepare(player); + { + if ((ret = player_get_state(player, &cur_state)) == PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_get_state_n(void) +{ + char* api_name = "player_get_state"; + int ret; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_get_state(player, NULL)) != PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_get_video_size_p(void) +{ + char* api_name = "player_get_video_size"; + int ret; + int width, height; + if (sRet == PLAYER_ERROR_NONE) + { + player_prepare(player); + if ((ret = player_get_video_size(player, &width, &height)) == PLAYER_ERROR_NONE) + { + reset(); + dts_pass(api_name); + } + if ((sRet = player_unprepare(player)) == PLAYER_ERROR_NONE) + { + sRet = player_set_uri(player, MEDIA_PATH); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_get_video_size_n(void) +{ + char* api_name = "player_get_video_size"; + int ret; + int width, height; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_get_video_size(player, &width, &height)) != PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_set_looping_p(void) +{ + char* api_name = "player_set_looping"; + int ret; + bool looping = true; + if (sRet == PLAYER_ERROR_NONE) + { + player_prepare(player); + { + if ((ret = player_set_looping(player, looping)) == PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_set_looping_n(void) +{ + char* api_name = "player_set_looping"; + int ret; + bool looping = true; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_set_looping(NULL, looping)) != PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_is_looping_p(void) +{ + char* api_name = "player_is_looping"; + int ret; + bool looping; + if (sRet == PLAYER_ERROR_NONE) + { + player_prepare(player); + { + if ((ret = player_is_looping(player, &looping)) == PLAYER_ERROR_NONE) + { + reset(); + dts_pass(api_name); + } + reset(); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_is_looping_n(void) +{ + char* api_name = "player_is_looping"; + int ret; + bool looping; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_is_looping(NULL, &looping)) != PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_set_mute_p(void) +{ + char* api_name = "utc_media_player_set_mute_p"; + int ret; + bool muted=false; + if (sRet == PLAYER_ERROR_NONE) + { + player_prepare(player); + { + if ((ret = player_set_mute(player, muted)) == PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_set_mute_n(void) +{ + char* api_name = "utc_media_player_set_mute_n"; + int ret; + player_h player1 = NULL; + bool muted = false; + if ((ret = player_set_mute(player1, muted)) != PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + + + +static void utc_media_player_is_muted_p(void) +{ + char* api_name = "player_is_muted"; + int ret; + bool muted; + if (sRet == PLAYER_ERROR_NONE) + { + player_prepare(player); + if ((ret = player_is_muted(player, &muted)) == PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_is_muted_n(void) +{ + char* api_name = "player_is_muted"; + int ret; + player_h player1 = NULL; + bool muted; + if ((ret = player_is_muted(player1, &muted)) != PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_set_display_p(void) +{ + char* api_name = "player_set_display"; + int ret; + reset(); + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_set_display(player, PLAYER_DISPLAY_TYPE_X11,0)) == PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_set_display_n(void) +{ + char* api_name = "player_set_display"; + int ret; + if (sRet == PLAYER_ERROR_NONE) + { + player_prepare(player); + { + if ((ret = player_set_display(player,PLAYER_DISPLAY_TYPE_X11, 0)) != PLAYER_ERROR_NONE) + { + reset(); + dts_pass(api_name); + } + reset(); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_set_memory_buffer_p(void) +{ + char* api_name = "utc_media_player_set_memory_buffer_p"; + int ret; + if (sRet == PLAYER_ERROR_NONE) + { + reset(); + GMappedFile *file; + gsize file_size; + guint8* g_media_mem = NULL; + + file = g_mapped_file_new (MEDIA_PATH, FALSE,NULL); + file_size = g_mapped_file_get_length (file); + g_media_mem = (guint8 *) g_mapped_file_get_contents (file); + + if ((ret = player_set_memory_buffer(player, (void*)g_media_mem ,file_size)) == PLAYER_ERROR_NONE) + { + player_prepare(player); + reset(); + dts_pass(api_name); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_set_memory_buffer_n(void) +{ + char* api_name = "utc_media_player_set_memory_buffer_n"; + int ret; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_set_memory_buffer(player, NULL, 0)) != PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_set_volume_p(void) +{ + char* api_name = "utc_media_player_set_volume_p"; + int ret; + float left, right = 1.0f; + { + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_set_volume(player, left, right)) == PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_set_volume_n(void) +{ + char* api_name = "utc_media_player_set_volume_n"; + int ret; + float left, right = 1.0f; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_set_volume(NULL, left, right)) != PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_get_volume_p(void) +{ + char* api_name = "player_get_volume"; + int ret; + float left, right; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_get_volume(player, &left, &right)) == PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_get_volume_n(void) +{ + char* api_name = "player_get_volume"; + int ret; + float left, right; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_get_volume(player, &left, NULL)) != PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_set_sound_type_p(void) +{ + char* api_name = "utc_media_player_set_sound_type_p"; + int ret; + sound_type_e sound_type = SOUND_TYPE_MEDIA; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_set_sound_type(player,sound_type)) == PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_set_sound_type_n(void) +{ + char* api_name = "utc_media_player_set_sound_type_n"; + int ret; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_set_sound_type(NULL, SOUND_TYPE_MEDIA)) != PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_set_subtitle_path_p(void) +{ + char* api_name = "utc_media_player_set_subtitle_path_p"; + int ret; + sound_type_e sound_type = SOUND_TYPE_MEDIA; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_set_subtitle_path(player,MEDIA_PATH)) == PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_set_subtitle_path_n(void) +{ + char* api_name = "utc_media_player_set_subtitle_path_n"; + int ret; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_set_subtitle_path(NULL, NULL)) != PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_set_x11_display_visible_p(void) +{ + char* api_name = "utc_media_player_set_x11_display_visible_p"; + int ret; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_set_display(player, PLAYER_DISPLAY_TYPE_X11,0)) == PLAYER_ERROR_NONE) + { + if ((ret = player_set_x11_display_visible(player, true)) == PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_set_x11_display_visible_n(void) +{ + char* api_name = "utc_media_player_set_x11_display_visible_n"; + int ret; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_set_display(player, PLAYER_DISPLAY_TYPE_X11,0)) == PLAYER_ERROR_NONE) + { + if ((ret = player_set_x11_display_visible(NULL, true)) != PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_is_x11_display_visible_p(void) +{ + char* api_name = "utc_media_player_is_x11_display_visible_p"; + int ret; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_set_display(player, PLAYER_DISPLAY_TYPE_X11,0)) == PLAYER_ERROR_NONE) + { + bool isVisible; + if ((ret = player_is_x11_display_visible(player, &isVisible)) == PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_is_x11_display_visible_n(void) +{ + char* api_name = "utc_media_player_is_x11_display_visible_n"; + int ret; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_set_display(player, PLAYER_DISPLAY_TYPE_X11,0)) == PLAYER_ERROR_NONE) + { + if ((ret = player_is_x11_display_visible(NULL, NULL)) != PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_set_x11_display_rotation_p(void) +{ + char* api_name = "utc_media_player_set_x11_display_rotation_p"; + int ret; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_set_display(player, PLAYER_DISPLAY_TYPE_X11,0)) == PLAYER_ERROR_NONE) + { + if ((ret = player_set_x11_display_rotation(player, PLAYER_DISPLAY_ROTATION_180)) == PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_set_x11_display_rotation_n(void) +{ + char* api_name = "utc_media_player_set_x11_display_rotation_n"; + int ret; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_set_display(player, PLAYER_DISPLAY_TYPE_X11,0)) == PLAYER_ERROR_NONE) + { + if ((ret = player_set_x11_display_rotation(NULL, PLAYER_DISPLAY_ROTATION_180)) != PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_get_x11_display_rotation_p(void) +{ + char* api_name = "utc_media_player_get_x11_display_rotation_p"; + int ret; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_set_display(player, PLAYER_DISPLAY_TYPE_X11,0)) == PLAYER_ERROR_NONE) + { + player_display_rotation_e rotation; + if ((ret = player_get_x11_display_rotation(player, &rotation)) == PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_get_x11_display_rotation_n(void) +{ + char* api_name = "utc_media_player_get_x11_display_rotation_n"; + int ret; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_get_x11_display_rotation(NULL, PLAYER_DISPLAY_ROTATION_180)) != PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_set_display_mode_p(void) +{ + char* api_name = "utc_media_player_set_display_mode_p"; + int ret; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_set_display(player, PLAYER_DISPLAY_TYPE_X11,0)) == PLAYER_ERROR_NONE) + { + if ((ret = player_set_display_mode(player, PLAYER_DISPLAY_MODE_FULL_SCREEN)) == PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_set_display_mode_n(void) +{ + char* api_name = "utc_media_player_set_display_mode_n"; + int ret; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_set_display(player, PLAYER_DISPLAY_TYPE_X11,0)) == PLAYER_ERROR_NONE) + { + if ((ret = player_set_display_mode(NULL, PLAYER_DISPLAY_MODE_FULL_SCREEN)) != PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_get_display_mode_p(void) +{ + char* api_name = "utc_media_player_get_display_mode_p"; + int ret; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_set_display(player, PLAYER_DISPLAY_TYPE_X11,0)) == PLAYER_ERROR_NONE) + { + player_display_mode_e mode; + if ((ret = player_get_display_mode(player, &mode)) == PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_get_display_mode_n(void) +{ + char* api_name = "utc_media_player_get_display_mode_n"; + int ret; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_get_display_mode(NULL, PLAYER_DISPLAY_MODE_FULL_SCREEN)) != PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_capture_video_p(void) +{ + char* api_name = "utc_media_player_capture_video_p"; + int ret; + + if (sRet == PLAYER_ERROR_NONE) + { + player_prepare(player); + { + if ((ret = player_start(player)) == PLAYER_ERROR_NONE) + { + sleep(3); + if ((ret = player_capture_video(player,player_video_capture_cb ,NULL)) == PLAYER_ERROR_NONE) + { + player_stop(player); + reset(); + dts_pass(api_name); + } + if ((sRet = player_stop(player)) == PLAYER_ERROR_NONE) + { + dts_message(api_name, "Call log: %d %d", sRet, ret); + } + } + reset(); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_capture_video_n(void) +{ + char* api_name = "utc_media_player_capture_video_n"; + int ret; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_capture_video(NULL,player_video_capture_cb ,NULL)) != PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} \ No newline at end of file diff --git a/TC/testcase/utc_media_player_callback.c b/TC/testcase/utc_media_player_callback.c new file mode 100644 index 0000000..656e1d0 --- /dev/null +++ b/TC/testcase/utc_media_player_callback.c @@ -0,0 +1,577 @@ +/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include +#include +#include + +enum { + POSITIVE_TC_IDX = 0x01, + NEGATIVE_TC_IDX, +}; + +//keeping ret and player global, since using startup function for all +player_h player; +int sRet; + +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + +static void utc_media_player_set_started_callback_p(void); +static void utc_media_player_set_started_callback_n(void); +static void utc_media_player_unset_started_callback_p(void); +static void utc_media_player_unset_started_callback_n(void); +static void utc_media_player_set_buffering_callback_p(void); +static void utc_media_player_set_buffering_callback_n(void); +static void utc_media_player_unset_buffering_callback_p(void); +static void utc_media_player_unset_buffering_callback_n(void); +static void utc_media_player_set_complete_callback_p(void); +static void utc_media_player_set_complete_callback_n(void); +static void utc_media_player_unset_complete_callback_p(void); +static void utc_media_player_unset_complete_callback_n(void); +static void utc_media_player_set_error_callback_p(void); +static void utc_media_player_set_error_callback_n(void); +static void utc_media_player_unset_error_callback_p(void); +static void utc_media_player_unset_error_callback_n(void); +static void utc_media_player_set_interrupt_callback_p(void); +static void utc_media_player_set_interrupt_callback_n(void); +static void utc_media_player_unset_interrupt_callback_p(void); +static void utc_media_player_unset_interrupt_callback_n(void); +static void utc_media_player_set_paused_callback_p(void); +static void utc_media_player_set_paused_callback_n(void); +static void utc_media_player_unset_paused_callback_p(void); +static void utc_media_player_unset_paused_callback_n(void); +static void utc_media_player_set_subtitle_updated_callback_p(void); +static void utc_media_player_set_subtitle_updated_callback_n(void); +static void utc_media_player_unset_subtitle_updated_callback_p(void); +static void utc_media_player_unset_subtitle_updated_callback_n(void); + +struct tet_testlist tet_testlist[] = { + { utc_media_player_set_started_callback_p, POSITIVE_TC_IDX }, + { utc_media_player_set_started_callback_n, NEGATIVE_TC_IDX }, + { utc_media_player_unset_started_callback_p, POSITIVE_TC_IDX }, + { utc_media_player_unset_started_callback_n, NEGATIVE_TC_IDX }, + { utc_media_player_set_buffering_callback_p, POSITIVE_TC_IDX }, + { utc_media_player_set_buffering_callback_n, NEGATIVE_TC_IDX }, + { utc_media_player_unset_buffering_callback_p, POSITIVE_TC_IDX }, + { utc_media_player_unset_buffering_callback_n, NEGATIVE_TC_IDX }, + { utc_media_player_set_complete_callback_p, POSITIVE_TC_IDX }, + { utc_media_player_set_complete_callback_n, NEGATIVE_TC_IDX }, + { utc_media_player_unset_complete_callback_p, POSITIVE_TC_IDX }, + { utc_media_player_unset_complete_callback_n, NEGATIVE_TC_IDX }, + { utc_media_player_set_error_callback_p, POSITIVE_TC_IDX }, + { utc_media_player_set_error_callback_n, NEGATIVE_TC_IDX }, + { utc_media_player_unset_error_callback_p, POSITIVE_TC_IDX }, + { utc_media_player_unset_error_callback_n, NEGATIVE_TC_IDX }, + { utc_media_player_set_interrupt_callback_p, POSITIVE_TC_IDX }, + { utc_media_player_set_interrupt_callback_n, NEGATIVE_TC_IDX }, + { utc_media_player_unset_interrupt_callback_p, POSITIVE_TC_IDX }, + { utc_media_player_unset_interrupt_callback_n, NEGATIVE_TC_IDX }, + { utc_media_player_set_paused_callback_p, POSITIVE_TC_IDX }, + { utc_media_player_set_paused_callback_n, NEGATIVE_TC_IDX }, + { utc_media_player_unset_paused_callback_p, POSITIVE_TC_IDX }, + { utc_media_player_unset_paused_callback_n, NEGATIVE_TC_IDX }, + { utc_media_player_set_subtitle_updated_callback_p, POSITIVE_TC_IDX }, + { utc_media_player_set_subtitle_updated_callback_n, NEGATIVE_TC_IDX }, + { utc_media_player_unset_subtitle_updated_callback_p, POSITIVE_TC_IDX }, + { utc_media_player_unset_subtitle_updated_callback_n, NEGATIVE_TC_IDX }, + { NULL, 0 }, +}; + +static GMainLoop *g_mainloop = NULL; +static GThread *event_thread; + +gpointer GmainThread(gpointer data){ + g_mainloop = g_main_loop_new (NULL, 0); + g_main_loop_run (g_mainloop); + + return NULL; +} + +static void startup(void) +{ + if( !g_thread_supported() ) + { + g_thread_init(NULL); + } + + GError *gerr = NULL; + event_thread = g_thread_create(GmainThread, NULL, 1, &gerr); + sRet = player_create(&player); +} + +static void cleanup(void) +{ + player_destroy(player); + g_main_loop_quit (g_mainloop); + g_thread_join(event_thread); +} + +static void player_start_cb(void *data) +{ + dts_message("PlayerEvent", "Player Started!!!"); +} + +static void player_complete_cb(void *data) +{ + dts_message("PlayerEvent", "Player Started!!!"); +} + + +static void player_pause_cb(void *data) +{ + dts_message("PlayerEvent", "Player Paused!!!"); +} + +static void player_buffer_cb(int percent, void *data) +{ + dts_message("PlayerEvent", "Player Buffering : %d!!!", percent); +} + +static void player_interrupt_cb(player_interrupted_code_e code, void *data) +{ + dts_message("PlayerEvent", "Player Interrupted!!!"); +} + +static void player_subtitle_update_cb(unsigned long duration, char *text, void *user_data) +{ + dts_message("PlayerEvent", "Player Subtitle Updated duration : %ld, text : %s!!!", duration, text); +} + +static void utc_media_player_set_started_callback_p(void) +{ + char* api_name = "player_set_started_cb"; + int ret; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_set_started_cb(player, player_start_cb, &sRet)) == PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_set_started_callback_n(void) +{ + char* api_name = "player_set_started_cb"; + int ret; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_set_started_cb(player, NULL, &sRet)) != PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_unset_started_callback_p(void) +{ + char* api_name = "utc_media_player_unset_started_callback_p"; + int ret; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_unset_started_cb(player)) == PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_unset_started_callback_n(void) +{ + char* api_name = "utc_media_player_unset_started_callback_n"; + int ret; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_unset_started_cb(NULL)) != PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_set_buffering_callback_p(void) +{ + char* api_name = "player_set_buffering_cb"; + int ret; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_set_buffering_cb(player, player_buffer_cb, &sRet)) == PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_set_buffering_callback_n(void) +{ + char* api_name = "player_set_buffering_cb"; + int ret; + player_h player1 = NULL; + if ((ret = player_set_buffering_cb(player1, player_buffer_cb, &sRet)) != PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_unset_buffering_callback_p(void) +{ + char* api_name = "utc_media_player_unset_buffering_callback_p"; + int ret; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_unset_buffering_cb(player)) == PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_unset_buffering_callback_n(void) +{ + char* api_name = "utc_media_player_unset_buffering_callback_n"; + int ret; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_unset_buffering_cb(NULL)) != PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_set_complete_callback_p(void) +{ + char* api_name = "utc_media_player_set_complete_callback_p"; + int ret; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_set_completed_cb(player, player_complete_cb, &sRet)) == PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_set_complete_callback_n(void) +{ + char* api_name = "player_set_completed_cb"; + int ret; + player_h player1 = NULL; + if ((ret = player_set_completed_cb(player1, player_complete_cb, &sRet)) != PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_unset_complete_callback_p(void) +{ + char* api_name = "utc_media_player_unset_complete_callback_p"; + int ret; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_unset_completed_cb(player)) == PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_unset_complete_callback_n(void) +{ + char* api_name = "utc_media_player_unset_complete_callback_n"; + int ret; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_unset_completed_cb(NULL)) != PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_set_error_callback_p(void) +{ + char* api_name = "player_set_error_cb"; + int ret; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_set_error_cb(player, player_buffer_cb, &sRet)) == PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_set_error_callback_n(void) +{ + char* api_name = "player_set_error_cb"; + int ret; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_destroy(player)) == PLAYER_ERROR_NONE) + { + player = NULL; + if ((ret = player_set_error_cb(player, player_buffer_cb, &sRet)) != PLAYER_ERROR_NONE) + { + sRet = player_create(&player); + dts_pass(api_name); + } + sRet = player_create(&player); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_unset_error_callback_p(void) +{ + char* api_name = "utc_media_player_unset_error_callback_p"; + int ret; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_unset_error_cb(player)) == PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_unset_error_callback_n(void) +{ + char* api_name = "utc_media_player_unset_error_callback_n"; + int ret; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_unset_error_cb(NULL)) != PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_set_interrupt_callback_p(void) +{ + char* api_name = "player_set_interrupted_cb"; + int ret; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_set_interrupted_cb(player, player_interrupt_cb, &sRet)) == PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_set_interrupt_callback_n(void) +{ + char* api_name = "player_set_interrupted_cb"; + int ret; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_set_interrupted_cb(player, NULL, &sRet)) != PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_unset_interrupt_callback_p(void) +{ + char* api_name = "utc_media_player_unset_interrupt_callback_p"; + int ret; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_unset_interrupted_cb(player)) == PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_unset_interrupt_callback_n(void) +{ + char* api_name = "utc_media_player_unset_interrupt_callback_n"; + int ret; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_unset_interrupted_cb(NULL)) != PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_set_paused_callback_p(void) +{ + char* api_name = "utc_media_player_set_paused_callback_p"; + int ret; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_set_paused_cb(player, player_pause_cb, &sRet)) == PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_set_paused_callback_n(void) +{ + char* api_name = "utc_media_player_set_paused_callback_n"; + int ret; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_set_paused_cb(player, NULL, &sRet)) != PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_unset_paused_callback_p(void) +{ + char* api_name = "utc_media_player_unset_paused_callback_p"; + int ret; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_unset_paused_cb(player)) == PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_unset_paused_callback_n(void) +{ + char* api_name = "utc_media_player_unset_paused_callback_n"; + int ret; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_unset_paused_cb(NULL)) != PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_set_subtitle_updated_callback_p(void) +{ + char* api_name = "utc_media_player_set_subtitle_updated_callback_p"; + int ret; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_set_subtitle_updated_cb(player, player_subtitle_update_cb, &sRet)) == PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_set_subtitle_updated_callback_n(void) +{ + char* api_name = "utc_media_player_set_subtitle_updated_callback_n"; + int ret; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_set_subtitle_updated_cb(player, NULL, &sRet)) != PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_unset_subtitle_updated_callback_p(void) +{ + char* api_name = "utc_media_player_unset_subtitle_updated_callback_p"; + int ret; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_unset_subtitle_updated_cb(player)) == PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} + +static void utc_media_player_unset_subtitle_updated_callback_n(void) +{ + char* api_name = "utc_media_player_unset_subtitle_updated_callback_n"; + int ret; + if (sRet == PLAYER_ERROR_NONE) + { + if ((ret = player_unset_subtitle_updated_cb(NULL)) != PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + dts_message(api_name, "Call log: %d %d", sRet, ret); + dts_fail(api_name); +} \ No newline at end of file diff --git a/TC/testcase/utc_media_player_lifecycle.c b/TC/testcase/utc_media_player_lifecycle.c new file mode 100644 index 0000000..670740a --- /dev/null +++ b/TC/testcase/utc_media_player_lifecycle.c @@ -0,0 +1,278 @@ +/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include +#include +#include + +#define MEDIA_PATH "/mnt/nfs/workspace/capi/media/player/TC/media_samsung.mp4" +#define INVALID_MEDIA_PATH "./invalid.mp7" + +enum { + POSITIVE_TC_IDX = 0x01, + NEGATIVE_TC_IDX, +}; + +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + +static void utc_media_player_create_p(void); +static void utc_media_player_create_n(void); +static void utc_media_player_destroy_p(void); +static void utc_media_player_destroy_n(void); +static void utc_media_player_pause_p(void); +static void utc_media_player_pause_n(void); +static void utc_media_player_prepare_p(void); +static void utc_media_player_prepare_n(void); + +struct tet_testlist tet_testlist[] = { + { utc_media_player_create_p, POSITIVE_TC_IDX }, + { utc_media_player_create_n, NEGATIVE_TC_IDX }, + { utc_media_player_destroy_p, POSITIVE_TC_IDX }, + { utc_media_player_destroy_n, NEGATIVE_TC_IDX }, + { utc_media_player_pause_p, POSITIVE_TC_IDX }, + { utc_media_player_pause_n, NEGATIVE_TC_IDX }, + { utc_media_player_prepare_p, POSITIVE_TC_IDX }, + { utc_media_player_prepare_n, NEGATIVE_TC_IDX }, + { NULL, 0 }, +}; + +static GMainLoop *g_mainloop = NULL; +static GThread *event_thread; + +gpointer GmainThread(gpointer data){ + g_mainloop = g_main_loop_new (NULL, 0); + g_main_loop_run (g_mainloop); + + return NULL; +} + +static void startup(void) +{ + if( !g_thread_supported() ) + { + g_thread_init(NULL); + } + + GError *gerr = NULL; + event_thread = g_thread_create(GmainThread, NULL, 1, &gerr); +} + +static void cleanup(void) +{ + g_main_loop_quit (g_mainloop); + g_thread_join(event_thread); +} + + + +/** + * @brief Positive test case of player_create() + */ +static void utc_media_player_create_p(void) +{ + char* api_name = "player_create"; + player_h player; + int ret; + if ((ret = player_create(&player)) == PLAYER_ERROR_NONE) + { + player_destroy(player); + dts_pass(api_name); + } + dts_message(api_name, "Call log: %d", ret); + dts_fail(api_name); +} + +static void utc_media_player_create_n(void) +{ + char* api_name = "player_create"; + int ret; + if ((ret = player_create(NULL)) != PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + dts_message(api_name, "Call log: %d", ret); + dts_fail(api_name); +} + +static void utc_media_player_destroy_p(void) +{ + char* api_name = "player_destroy"; + player_h player; + int ret; + if ((ret = player_create(&player)) == PLAYER_ERROR_NONE) + { + if ((ret = player_destroy(player)) == PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + } + dts_message(api_name, "Call log: %d", ret); + dts_fail(api_name); +} + +static void utc_media_player_destroy_n(void) +{ + char* api_name = "player_destroy"; + int ret; + if ((ret = player_destroy(NULL)) != PLAYER_ERROR_NONE) + { + dts_pass(api_name); + } + dts_message(api_name, "Call log: %d", ret); + dts_fail(api_name); +} + +static void player_start_cb(void *data) +{ + char* api_name = "player_pause"; + player_h p = (player_h)data; + dts_message(api_name, "Player Started !!!"); + player_state_e s; + player_get_state(p, &s); + dts_message(api_name, "Current state : %d", s); +} + + +static void utc_media_player_pause_p(void) +{ + char* api_name = "player_pause"; + player_h player; + int ret; + if ((ret = player_create(&player)) == PLAYER_ERROR_NONE) + { + ret =player_set_started_cb(player, player_start_cb, player); + if ((ret = player_set_uri(player, MEDIA_PATH)) == PLAYER_ERROR_NONE) + { + if ((ret = player_prepare(player)) == PLAYER_ERROR_NONE) + { + if ((ret = player_start(player)) == PLAYER_ERROR_NONE) + { + int timeout = 3 ; + player_state_e state; + int i; + for(i = 0; i Mon, 23 Jul 2012 14:59:34 +0900 + +capi-media-player (0.1.0-22) unstable; urgency=low + + * Additional stream information APIs and Zooming APIS have been added + * Git: slp-source.sec.samsung.net:slp/api/player + * Tag: capi-media-player_0.1.0-22 + + -- Kangho Hur Mon, 16 Jul 2012 20:40:46 +0900 + +capi-media-player (0.1.0-21) unstable; urgency=low + + * Renew audio effect apis (sound alive support) + * Git: slp-source.sec.samsung.net:slp/api/player + * Tag: capi-media-player_0.1.0-21 + + -- Kangho Hur Wed, 04 Jul 2012 21:44:11 +0900 + +capi-media-player (0.1.0-20) unstable; urgency=low + + * Support to evas surface display scaling mode + * Git: slp-source.sec.samsung.net:slp/api/player + * Tag: capi-media-player_0.1.0-20 + + -- Kangho Hur Thu, 28 Jun 2012 15:32:36 +0900 + +capi-media-player (0.1.0-19) unstable; urgency=low + + * add mmta to check API performance + * Git: slp-source.sec.samsung.net:slp/api/player + * Tag: capi-media-player_0.1.0-19 + + -- Younghwan Ahn Thu, 14 Jun 2012 17:12:21 +0900 + +capi-media-player (0.1.0-18) unstable; urgency=low + + * bug fix to seek + * Git: slp-source.sec.samsung.net:slp/api/player + * Tag: capi-media-player_0.1.0-18 + + -- Kangho Hur Tue, 05 Jun 2012 10:20:14 +0900 + +capi-media-player (0.1.0-17) unstable; urgency=low + + * Stream Inforamtion APIs have been added. + * Git: slp-source.sec.samsung.net:slp/api/player + * Tag: capi-media-player_0.1.0-17 + + -- Kangho Hur Tue, 29 May 2012 13:23:36 +0900 + +capi-media-player (0.1.0-16) unstable; urgency=low + + * Fix bugs & Add the player_set_subtitle_position. + * Git: slp-source.sec.samsung.net:slp/api/player + * Tag: capi-media-player_0.1.0-16 + + -- Kangho Hur Mon, 21 May 2012 18:58:57 +0900 + +capi-media-player (0.1.0-15) unstable; urgency=low + + * Patches for player state when interrputed + * Git: slp-source.sec.samsung.net:slp/api/player + * Tag: capi-media-player_0.1.0-15 + + -- Kangho Hur Thu, 17 May 2012 10:10:11 +0900 + +capi-media-player (0.1.0-14) unstable; urgency=low + + * Support to the progressive download. + * Git: slp-source.sec.samsung.net:slp/api/player + * Tag: capi-media-player_0.1.0-14 + + -- Kangho Hur Thu, 10 May 2012 21:28:37 +0900 + +capi-media-player (0.1.0-13) unstable; urgency=low + + * Remove duplicated enum + * Git: slp-source.sec.samsung.net:slp/api/player + * Tag: capi-media-player_0.1.0-13 + + -- Seungbae Shin Fri, 27 Apr 2012 11:20:33 +0900 + capi-media-player (0.1.0-12) unstable; urgency=low - * capture video callback updated + * Resolve the video capture issue + * Git: slp-source.sec.samsung.net:slp/api/player + * Tag: capi-media-player_0.1.0-12 - -- Kangho Hur Mon, 26 Mar 2012 23:01:54 +0900 + -- Kangho Hur Mon, 26 Mar 2012 22:43:13 +0900 capi-media-player (0.1.0-11) unstable; urgency=low - * Add the new features (playback rate, video/audio frame decoded, audio effects and so on.) + * Add the new features (playback rate, video/audio frame decoded, audio effects and so on.) + * Git: slp-source.sec.samsung.net:slp/api/player + * Tag: capi-media-player_0.1.0-11 + + -- Kangho Hur Wed, 14 Mar 2012 18:43:47 +0900 - -- Kangho Hur Mon, 19 Mar 2012 17:40:35 +0900 +capi-media-player (0.1.0-10) unstable; urgency=low + + * Fix the bug ( state doesn't changed to PAUSED when user unplug earjack while playing the music) + * Git: slp-source.sec.samsung.net:slp/api/player + * Tag: capi-media-player_0.1.0-10 + + -- Kangho Hur Wed, 07 Mar 2012 19:10:46 +0900 + +capi-media-player (0.1.0-9) unstable; urgency=low + + * fix typo + * Git: slp-source.sec.samsung.net:slp/api/player + * Tag: capi-media-player_0.1.0-9 + + -- Seungkeun Lee Tue, 28 Feb 2012 15:27:39 +0900 + +capi-media-player (0.1.0-8) unstable; urgency=low + + * Fix package dependancy + * Git: slp-source.sec.samsung.net:slp/api/player + * Tag: capi-media-player_0.1.0-8 + + -- Kangho Hur Mon, 27 Feb 2012 20:02:53 +0900 capi-media-player (0.1.0-7) unstable; urgency=low - * Use 'static' to local function which is limited to the current source file. + * Use 'static' to local function which is limited to the current source file. + * Git: slp-source.sec.samsung.net:slp/api/player + * Tag: capi-media-player_0.1.0-7 - -- Kangho Hur Tue, 21 Feb 2012 10:23:22 +0900 + -- Kangho Hur Tue, 21 Feb 2012 10:04:25 +0900 capi-media-player (0.1.0-6) unstable; urgency=low - * Apply the SOVERSION + * Apply the SOVERSION + * Git: slp-source.sec.samsung.net:slp/api/player + * Tag: capi-media-player_0.1.0-6 - -- Kangho Hur Tue, 14 Feb 2012 18:21:11 +0900 + -- Kangho Hur Tue, 14 Feb 2012 16:36:42 +0900 capi-media-player (0.1.0-5) unstable; urgency=low - * Initial release. + * Add the video capture + * Git: slp-source.sec.samsung.net:slp/api/player + * Tag: capi-media-player_0.1.0-5 + + -- Kangho Hur Tue, 06 Dec 2011 19:06:03 +0900 + +capi-media-player (0.1.0-4) unstable; urgency=low + + * Changes the value of ERROR_NONE + * Git: slp-source.sec.samsung.net:slp/api/player + * Tag: capi-media-player_0.1.0-4 + + -- Kangho Hur Mon, 05 Dec 2011 11:24:40 +0900 + +capi-media-player (0.1.0-3) unstable; urgency=low + + * Apply the Tizen + * Git: slp-source.sec.samsung.net:slp/api/player + * Tag: capi-media-player_0.1.0-3 + + -- Kangho Hur Wed, 23 Nov 2011 15:39:20 +0900 + +capi-media-player (0.1.0-2) unstable; urgency=low + + * Apply the error messages + * Git: slp-source.sec.samsung.net:slp/api/player + * Tag: capi-media-player_0.1.0-2 + + -- Kangho Hur Fri, 07 Oct 2011 21:02:37 +0900 + +capi-media-player (0.1.0-1) unstable; urgency=low + + * Alpha Release + * Git: slp-source.sec.samsung.net:slp/api/player + * Tag: capi-media-player_0.1.0-1 + + -- Kangho Hur Tue, 27 Sep 2011 19:47:58 +0900 + +capi-media-player (0.0.1-4) unstable; urgency=low + + * Fix TC failed and debian control. + * Git: slp-source.sec.samsung.net:slp/api/player + * Tag: capi-media-player_0.0.1-4 + + -- Kangho Hur Mon, 19 Sep 2011 19:06:00 +0900 + +capi-media-player (0.0.1-3) unstable; urgency=low + + * Add the player_set_sound_type() + * Git: slp-source.sec.samsung.net:slp/api/player + * Tag: capi-media-player_0.0.1-3 + + -- Kangho Hur Wed, 14 Sep 2011 19:43:05 +0900 + +capi-media-player (0.0.1-2) unstable; urgency=low + + * Support various diplay type api and add subtilte api + * Git: slp-source.sec.samsung.net:slp/api/player + * Tag: capi-media-player_0.0.1-2 + + -- Kangho Hur Fri, 26 Aug 2011 14:39:24 +0900 + +capi-media-player (0.0.1-1) unstable; urgency=low + + * Initial Upload + * Git: slp-source.sec.samsung.net:slp/api/player + * Tag: capi-media-player_0.0.1-1 - -- Kangho Hur Wed, 07 Dec 2011 12:54:23 +0900 + -- Kangho Hur Thu, 04 Aug 2011 17:32:41 +0900 diff --git a/debian/control b/debian/control index 81e4255..c777428 100644 --- a/debian/control +++ b/debian/control @@ -3,6 +3,7 @@ Source: capi-media-player Section: libs Priority: extra Maintainer: Kangho Hur , Seungkeun Lee +Uploaders: YoungHwan Ahn , Seungbae Shin Build-Depends: debhelper (>= 5), dlog-dev, libmm-player-dev, libmm-player-internal-dev, capi-base-common-dev, capi-media-sound-manager-dev Package: capi-media-player diff --git a/include/player.h b/include/player.h index 82c5308..4dfe783 100644 --- a/include/player.h +++ b/include/player.h @@ -84,9 +84,18 @@ typedef enum PLAYER_INTERRUPTED_BY_CALL, /**< Interrupted by incoming call*/ PLAYER_INTERRUPTED_BY_EARJACK_UNPLUG, /**< Interrupted by unplugging headphone*/ PLAYER_INTERRUPTED_BY_RESOURCE_CONFLICT, /**< Interrupted by resource conflict*/ - PLAYER_INTERRUPTED_BY_ALARM, /**< Interrupted by alarm starting*/ + PLAYER_INTERRUPTED_BY_ALARM, /**< Interrupted by alarm*/ } player_interrupted_code_e; +/** + * @brief Enumerations of progressive download message type + */ +typedef enum +{ + PLAYER_PD_STARTED = 0, /**< Progressive download is started */ + PLAYER_PD_COMPLETED, /**< Progressive download is completed */ +} player_pd_message_type_e; + /** * @brief * Enumerations of display type @@ -95,7 +104,6 @@ typedef enum { PLAYER_DISPLAY_TYPE_X11 = 0, /**< X surface display */ PLAYER_DISPLAY_TYPE_EVAS = 1, /**< Evas image object surface display */ - PLAYER_DISPLAY_TYPE_NONE = 3 /**< This just disposes of buffers */ } player_display_type_e; /** @@ -148,71 +156,85 @@ typedef enum */ /** - * @addtogroup CAPI_MEDIA_PLAYER_AUDIO_EFFECT_MODULE + * @addtogroup CAPI_MEDIA_PLAYER_STREAM_INFO_MODULE * @{ */ /** - * @brief Enumerations of audio output device type. + * @brief Enumerations of media stream content information */ -typedef enum{ - SOUND_DEVICE_OUT_SPEAKER = 0x01<<8, /**< Device builtin speaker */ - SOUND_DEVICE_OUT_RECEIVER = 0x02<<8, /**< Device builtin receiver */ - SOUND_DEVICE_OUT_WIRED_ACCESSORY = 0x04<<8, /**< Wired output devices such as headphone, headset, and so on. */ - SOUND_DEVICE_OUT_BT_SCO = 0x08<<8, /**< Bluetooth SCO device */ - SOUND_DEVICE_OUT_BT_A2DP = 0x10<<8, /**< Bluetooth A2DP device */ -} sound_device_out_e; +typedef enum +{ + PLAYER_CONTENT_INFO_ALBUM, /**< Album */ + PLAYER_CONTENT_INFO_ARTIST, /**< Artist */ + PLAYER_CONTENT_INFO_AUTHOR, /**< Author */ + PLAYER_CONTENT_INFO_GENRE, /**< Genre */ + PLAYER_CONTENT_INFO_TITLE, /**< Title */ + PLAYER_CONTENT_INFO_YEAR, /**< Year */ +} player_content_info_e; /** - * @brief Enumerations of 3D effect - */ -typedef enum{ - AUDIO_EFFECT_3D_WIDE =1, /**< Wide mode */ - AUDIO_EFFECT_3D_DYNAMIC, /**< Dynamic mode */ - AUDIO_EFFECT_3D_SURROUND, /**< Surround mode */ -} audio_effect_3d_e; + * @} + */ /** - * @brief - * Enumerations of equalizer effect - */ -typedef enum{ - AUDIO_EFFECT_EQ_ROCK =1, /**< Rock mode */ - AUDIO_EFFECT_EQ_JAZZ, /**< Jazz mode*/ - AUDIO_EFFECT_EQ_LIVE, /**< Live mode*/ - AUDIO_EFFECT_EQ_CLASSIC, /**< Classic mode*/ - AUDIO_EFFECT_EQ_FULL_BASS, /**< Bass mode*/ - AUDIO_EFFECT_EQ_FULL_BASS_AND_TREBLE, /**< Bass and Treble mode*/ - AUDIO_EFFECT_EQ_DANCE, /**< Dance mode*/ - AUDIO_EFFECT_EQ_POP, /**< Pop mode*/ - AUDIO_EFFECT_EQ_FULL_TREBLE, /**< Treble mode*/ - AUDIO_EFFECT_EQ_CLUB, /**< Club mode*/ - AUDIO_EFFECT_EQ_PARTY, /**< Party mode*/ - AUDIO_EFFECT_EQ_LARGE_HALL, /**< Large Hall mode*/ - AUDIO_EFFECT_EQ_SOFT, /**< Soft mode*/ - AUDIO_EFFECT_EQ_SOFT_ROCK, /**< Soft Rock mode*/ -} audio_effect_equalizer_e; + * @addtogroup CAPI_MEDIA_PLAYER_AUDIO_EFFECT_MODULE + * @{ + */ /** - * @brief - * Enumerations of reverberation effect - */ + * @brief Enumerations of audio effect + */ typedef enum{ - AUDIO_EFFECT_REVERB_JAZZ_CLUB =1, /**< Jazz club mode */ - AUDIO_EFFECT_REVERB_CONCERT_HALL, /**< Concert Hall mode*/ - AUDIO_EFFECT_REVERB_STADIUM, /**< Stadium mode*/ -} audio_effect_reverb_e; + AUDIO_EFFECT_3D = 1, /**< 3D effect */ + AUDIO_EFFECT_BASS, /**< Bass effect */ + AUDIO_EFFECT_ROOM, /**< Room effect */ + AUDIO_EFFECT_REVERB, /**< Reverberation effect */ + AUDIO_EFFECT_CLARITY, /**< Clarity effect */ +} audio_effect_e; /** - * @brief - * Enumerations of extra effect - */ + * @brief Enumerations of preset audio effect + */ typedef enum{ - AUDIO_EFFECT_EX_BASE =1, /**< Bass Enhancement effect */ - AUDIO_EFFECT_EX_MUSIC_CLARITY, /**< Music clarity effect*/ - AUDIO_EFFECT_EX_SURROUND, /**< 5.1 channel surround sound effect*/ - AUDIO_EFFECT_EX_SOUND_EXTERNAL, /**< Sound externalization effect*/ -} audio_effect_extra_e; + AUDIO_EFFECT_PRESET_AUTO = 0, /**< Auto */ + AUDIO_EFFECT_PRESET_NONE, /**< None */ + AUDIO_EFFECT_PRESET_POP, /**< POP */ + AUDIO_EFFECT_PRESET_ROCK, /**< Rock */ + AUDIO_EFFECT_PRESET_DANCE, /**< Dance */ + AUDIO_EFFECT_PRESET_JAZZ, /**< Jazz */ + AUDIO_EFFECT_PRESET_CLASSIC, /**< Classic */ + AUDIO_EFFECT_PRESET_VOCAL, /**< Vocal */ + AUDIO_EFFECT_PRESET_BASS_BOOST, /**< Bass boost */ + AUDIO_EFFECT_PRESET_TREBLE_BOOST, /**< Treble boost */ + AUDIO_EFFECT_PRESET_MTHEATER, /**< Theater */ + AUDIO_EFFECT_PRESET_EXTERNALIZATION, /**< Externalization */ + AUDIO_EFFECT_PRESET_CAFE, /**< Cafe */ + AUDIO_EFFECT_PRESET_CONCERT_HALL, /**< Concert Hall */ + AUDIO_EFFECT_PRESET_VOICE, /**< Voice */ + AUDIO_EFFECT_PRESET_MOVIE, /**< Movie */ + AUDIO_EFFECT_PRESET_VIRTUAL_5_1, /**< Virtual 5.1 */ +} audio_effect_preset_e; + +/** + * @brief Called once for each supported audio effect. + * @param[in] effect The audio effect + * @param[in] user_data The user data passed from the foreach function + * @return @c true to continue with the next iteration of the loop, \n @c false to break outsp of the loop. + * @pre player_audio_effect_foreach_supported_effect() will invoke this callback. + * @see player_audio_effect_foreach_supported_effect() + */ +typedef bool (*player_audio_effect_supported_effect_cb)(audio_effect_e effect, void *user_data); + +/** + * @brief Called once for each supported preset audio effect. + * @param[in] preset The preset audio effect + * @param[in] user_data The user data passed from the foreach function + * @return @c true to continue with the next iteration of the loop, \n @c false to break outsp of the loop. + * @pre player_audio_effect_foreach_supported_preset() will invoke this callback. + * @see player_audio_effect_foreach_supported_preset() + */ +typedef bool (*player_audio_effect_supported_preset_cb)(audio_effect_preset_e preset, void *user_data); /** * @} @@ -224,17 +246,17 @@ typedef enum{ * @{ */ +typedef void (*player_started_cb)(void *user_data); + /** - * @brief Called when the media player is started. + * @brief Called when the media player is prepared. * @details It will be invoked when player has reached the begin of stream * @param[in] user_data The user data passed from the callback registration function - * @pre The player state should be #PLAYER_STATE_READY - * @pre player_start() will cause this callback if you register this callback using player_set_started_cb() - * @see player_start() - * @see player_set_started_cb() - * @see player_unset_started_cb() + * @pre player_prepare_async() will cause this callback + * @post The player state will be #PLAYER_STATE_READY + * @see player_prepare_async() */ -typedef void (*player_started_cb)(void *user_data); +typedef void (*player_prepared_cb)(void *user_data); /** * @brief Called when the media player is completed. @@ -246,16 +268,15 @@ typedef void (*player_started_cb)(void *user_data); */ typedef void (*player_completed_cb)(void *user_data); +typedef void (*player_paused_cb)(void *user_data); /** - * @brief Called when the media player is paused. + * @brief Called when the seek operation is completed. * @param[in] user_data The user data passed from the callback registration function - * @pre player_pause() will cause this callback if you register this callback using player_set_paused_cb() - * @see player_pause() - * @see player_set_paused_cb() - * @see player_unset_paused_cb() + * @see player_set_position() + * @see player_set_position_ratio() */ -typedef void (*player_paused_cb)(void *user_data); +typedef void (*player_seek_completed_cb)(void *user_data); /** * @brief Called when the media player is interrupted. @@ -297,6 +318,14 @@ typedef void (*player_buffering_cb)(int percent, void *user_data); */ typedef void (*player_subtitle_updated_cb)(unsigned long duration, char *text, void *user_data); +/** + * @brief Called when the progressive download is started or completed. + * @param[in] type The message type of progressive download + * @param[in] user_data The user data passed from the callback registration function + * @see player_set_progressive_download_path() + */ +typedef void (*player_pd_message_cb)(player_pd_message_type_e type, void *user_data); + /** * @brief Called when the video is captured. * @remarks The color space format of the captured image is #IMAGE_UTIL_COLORSPACE_RGB888. @@ -311,6 +340,7 @@ typedef void (*player_video_captured_cb)(unsigned char *data, int width, int hei /** * @brief Called when the video frame is decoded. + * @remarks The color space format of the captured image is #IMAGE_UTIL_COLORSPACE_RGB888. * @param[in] data The decoded video frame data * @param[in] width The width of video frame * @param[in] height The height of video frame @@ -366,7 +396,6 @@ int player_create(player_h *player); */ int player_destroy(player_h player); - /** * @brief Prepares the media player for playback. * @param[in] player The handle to media player @@ -378,13 +407,34 @@ int player_destroy(player_h player); * @retval #PLAYER_ERROR_NOT_SUPPORTED_FILE Not supported file * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state - * @pre The player state should be #PLAYER_STATE_IDLE by player_create() or player_unprepare().. After that, call player_set_uri() to load the media content you want to play. + * @pre The player state should be #PLAYER_STATE_IDLE by player_create() or player_unprepare(). After that, call player_set_uri() to load the media content you want to play. * @post The player state will be #PLAYER_STATE_READY. + * @see player_prepare_async() * @see player_unprepare() * @see player_set_uri() */ int player_prepare(player_h player); +/** + * @brief Prepares the media player for playback, asynchronously. + * @param[in] player The handle to media player + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_URI Invalid URI + * @retval #PLAYER_ERROR_NO_SUCH_FILE File not found + * @retval #PLAYER_ERROR_NOT_SUPPORTED_FILE Not supported file + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state should be #PLAYER_STATE_IDLE by player_create() or player_unprepare().. After that, call player_set_uri() to load the media content you want to play.. + * @post It invokes player_prepared_cb() when playback is prepare. + * @see player_prepare() + * @see player_prepared_cb() + * @see player_unprepare() + * @see player_set_uri() + */ +int player_prepare_async (player_h player, player_prepared_cb callback, void* user_data); + /** * @brief Reset the media player. * @details @@ -517,7 +567,7 @@ int player_get_volume(player_h player, float *left, float *right); int player_set_sound_type(player_h player, sound_type_e type); /** - * @brief Starts or resumes playback, asynchronously. + * @brief Starts or resumes playback. * * @details Plays current media content, or resumes play if paused. * @@ -532,15 +582,17 @@ int player_set_sound_type(player_h player, sound_type_e type); * @pre Call player_prepare() before calling this function. * @pre The player state must be #PLAYER_STATE_READY by player_prepare() or #PLAYER_STATE_PAUSED by player_pause(). * @post The player state will be #PLAYER_STATE_PLAYING. - * @post It invokes player_started_cb() when playback starts(not resume), if you set a callback with player_set_started_cb(). * @post It invokes player_completed_cb() when playback completes, if you set a callback with player_set_completed_cb(). + * @post It invokes player_pd_message_cb() when progressive download starts or completes, if you set a download path with player_set_progressive_download_path() and a callback with player_set_progressive_download_message_cb(). * @see player_prepare() + * @see player_prepare_async() * @see player_stop() * @see player_pause() - * @see player_set_started_cb() - * @see player_started_cb() * @see player_set_completed_cb() * @see player_completed_cb() + * @see player_set_progressive_download_path() + * @see player_set_progressive_download_message_cb() + * @see player_pd_message_cb() */ int player_start(player_h player); @@ -556,13 +608,14 @@ int player_start(player_h player); * @retval #PLAYER_ERROR_SOUND_POLICY Sound policy error * @pre The player state must be either #PLAYER_STATE_PLAYING by player_start() or #PLAYER_STATE_PAUSED by player_pause(). * @post The player state will be #PLAYER_STATE_READY. + * @post The downloading will be aborted if you use progressive download. * @see player_start() * @see player_pause() */ int player_stop(player_h player); /** - * @brief Pauses the player, asynchronously. + * @brief Pauses the player. * * @remarks Playback can be resumed with player_start(). * @@ -575,46 +628,48 @@ int player_stop(player_h player); * @retval #PLAYER_ERROR_SOUND_POLICY Sound policy error * @pre The player state must be #PLAYER_STATE_PLAYING. * @post The player state will be #PLAYER_STATE_READY. - * @post It invokes player_paused_cb() when playback is pauses, if you set a callback with player_set_paused_cb(). * @see player_start() - * @see player_set_paused_cb() - * @see player_unset_paused_cb() - * @see player_paused_cb() */ int player_pause(player_h player); /** - * @brief Sets the seek position for playback. - * @param[in] player The handle to media player - * @param[in] millisecond The position in milliseconds from the start to seek to + * @brief Sets the seek position for playback, asynchronously. + * @param[in] player The handle to media player + * @param[in] millisecond The position in milliseconds from the start to seek to + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function * @return 0 on success, otherwise a negative error value. * @retval #PLAYER_ERROR_NONE Successful * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation * @retval #PLAYER_ERROR_SEEK_FAILED Seek operation failure * @pre The player state must be one of these: #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + * @post It invokes player_seek_completed_cb() when seek operation completes, if you set a callback. * @see player_get_position() * @see player_get_position_ratio() * @see player_set_position_ratio() */ -int player_set_position(player_h player, int millisecond); +int player_set_position(player_h player, int millisecond, player_seek_completed_cb callback, void *user_data); /** - * @brief Sets the playback position specified by percent of media content played. - * @param[in] player The handle to media player - * @param[in] percent The position in percentage from the start to seek to. \n The position is relative to content. (length, 0 = beginning, 100 = end) + * @brief Sets the playback position specified by percent of media content played, asynchronously. + * @param[in] player The handle to media player + * @param[in] percent The position in percentage from the start to seek to. \n The position is relative to content. (length, 0 = beginning, 100 = end) + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function * @return 0 on success, otherwise a negative error value. * @retval #PLAYER_ERROR_NONE Successful * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation * @retval #PLAYER_ERROR_SEEK_FAILED Seek operation failure * @pre The player state must be one of these: #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + * @post It invokes player_seek_completed_cb() when seek operation completes, if you set a callback. * @see player_get_position() * @see player_get_position_ratio() * @see player_set_position() */ -int player_set_position_ratio(player_h player, int percent); +int player_set_position_ratio(player_h player, int percent, player_seek_completed_cb callback, void *user_data); /** * @brief Gets current position in milliseconds. @@ -719,6 +774,7 @@ int player_is_looping(player_h player, bool *looping); /** * @brief Gets the total running time of the associated media. * @remarks The media source is associated with the player, using either player_set_uri() or player_set_memory_buffer(). + * @remarks The playback type should be local playback or http streaming playback. * @param[in] player The handle to media player * @param[out] duration The duration is in milliseconds * @return 0 on success, otherwise a negative error value. @@ -726,7 +782,7 @@ int player_is_looping(player_h player, bool *looping); * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state - * @pre The player state must be one of: #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + * @pre The player state must be one of: #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. * @see player_get_position() * @see player_set_uri() * @see player_set_memory_buffer() @@ -736,6 +792,7 @@ int player_get_duration(player_h player, int *duration); /** * @brief Sets the video display. * @remaks To get @a display to set, use #GET_DISPLAY(). + * @remaks To use multiple surface display mode, use player_set_display() again with different display type. * @param[in] player The handle to media player * @param[in] type The display type * @param[in] display The handle to display @@ -744,10 +801,48 @@ int player_get_duration(player_h player, int *duration); * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state - * @pre The player state must be #PLAYER_STATE_IDLE by player_prepare() or player_unprepare(). + * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. */ int player_set_display(player_h player, player_display_type_e type, player_display_h display); +/** + * @brief Gets the availability of display mode change + * @remark The result can be changed by display setting. + * @param[in] player The handle to media player + * @param[out] changeable The cuurent availability of display mode change (@c true = changeable, @c false = non-changeable ) + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @see player_set_display_mode() + */ +int player_is_display_mode_changeable(player_h player, bool* changeable); + +/** + * @brief Sets a video display mode + * @remarks If no display is not set, no operation is performed. + * @param[in] player The handle to media player + * @param[in] mode The display mode + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_STATE Invalid state + * @pre The player should be supported display mode changing. (player_is_display_mode_changeable()) + * @see player_get_display_mode() + */ +int player_set_display_mode(player_h player, player_display_mode_e mode); + +/** + * @brief Gets the video display mode + * @remarks If no display is not set, no operation is performed. + * @param[in] player The handle to media player + * @param[out] mode The current display mode + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @see player_set_display_mode() + */ +int player_get_display_mode(player_h player, player_display_mode_e *mode); + /** * @brief Sets the playback rate * @details The default value is 1.0. @@ -826,125 +921,401 @@ int player_set_x11_display_visible(player_h player, bool visible); int player_is_x11_display_visible(player_h player, bool* visible); /** - * @brief Sets a x surface video display mode + * @brief Sets the zoom level of the x surface video display * @remarks If current display type is not #PLAYER_DISPLAY_TYPE_X11, no operation is performed. * @param[in] player The handle to media player - * @param[in] mode The display mode + * @param[in] level The level of zoom [1~9] * @return 0 on success, otherwise a negative error value. * @retval #PLAYER_ERROR_NONE Successful * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #PLAYER_ERROR_INVALID_STATE Invalid state - * @see player_get_x11_display_mode() + * @see player_get_x11_display_zoom() */ -int player_set_x11_display_mode(player_h player, player_display_mode_e mode); +int player_set_x11_display_zoom(player_h player, int level); /** - * @brief Gets the x surface video display mode + * @brief Gets a zoom level of the x surface video display * @remarks If current display type is not #PLAYER_DISPLAY_TYPE_X11, no operation is performed. * @param[in] player The handle to media player - * @param[out] mode The current display mode + * @param[out] level The level of zoom [1~9] * @return 0 on success, otherwise a negative error value. * @retval #PLAYER_ERROR_NONE Successful * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter - * @see player_set_x11_display_mode() + * @see player_set_x11_display_zoom() */ -int player_get_x11_display_mode(player_h player, player_display_mode_e *mode); +int player_get_x11_display_zoom( player_h player, int *level); /** * @} */ /** - * @addtogroup CAPI_MEDIA_PLAYER_AUDIO_EFFECT_MODULE + * @addtogroup CAPI_MEDIA_PLAYER_EVAS_DISPLAY_MODULE * @{ */ - + /** - * @brief Sets a audio effect output device. - * @remarks Both #SOUND_DEVICE_OUT_RECEIVER and #SOUND_DEVICE_OUT_BT_SCO output devices are not supported. It occurs #PLAYER_ERROR_INVALID_OPERATION. + * @brief Sets the evas surface video display scaling status. + * @remarks If current display type is not #PLAYER_DISPLAY_TYPE_EVAS, no operation is performed. + * @remarks If the scaling status is @c false, player_is_display_mode_changeable() always return @a false. * @param[in] player The handle to media player - * @param[in] output The output device to apply audio effect + * @param[in] enable New evas surface video display scaling status: (@c true = scaling, @c false = not scaled) * @return 0 on success, otherwise a negative error value. * @retval #PLAYER_ERROR_NONE Successful * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation - * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. */ -int player_set_audio_effect_output(player_h player, sound_device_out_e output); +int player_enable_evas_display_scaling(player_h player, bool enable); /** - * @brief Sets a 3D audio effect. - * @remarks Equalizer, 3D and reverberation effects can be used together - * @param[in] player The handle to media player - * @param[in] effect The 3D audio effect + * @} + */ + +/** + * @addtogroup CAPI_MEDIA_PLAYER_STREAM_INFO_MODULE + * @{ + */ + + /** + * @brief Get the media content information + * @remarks @a value must be released with @c free() by you + * @remarks The playback type should be local playback or http streaming playback. + * @param[in] player The handle to media player + * @param[in] key The key attribute name to get + * @param[out] value The value of the key attribute. It can be empty string if there is no content information. + * @return 0 on success, otherwise a negative error value + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_OUT_OF_MEMORY Not enough memory is available + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of: #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + */ +int player_get_content_info(player_h player, player_content_info_e key, char ** value); + +/** + * @brief Gets the audio and video codec information + * @remarks @a audio_codec and @a video_codec must be released with @c free() by you + * @remarks The playback type should be local playback or http streaming playback. + * @param[in] player The handle to media player + * @param[out] audio_codec The name of audio codec. It can be @c NULL if there is no audio codec. + * @param[out] video_codec The name of video codec. It can be @c NULL if there is no video codec. + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of: #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + */ +int player_get_codec_info(player_h player, char **audio_codec, char **video_codec); + +/** + * @brief Gets the audio stream information + * @remarks The playback type should be local playback or http streaming playback. + * @param[in] player The handle to media player + * @param[out] sample_rate The audio sample rate [Hz]. It can be invalid value if there is no audio stream information. + * @param[out] channel The audio channel (1: mono, 2: stereo). It can be invalid value if there is no audio stream information. + * @param[out] bit_rate The audio bit rate [Hz]. It can be invalid value if there is no audio stream information. + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of: #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + */ +int player_get_audio_stream_info(player_h player, int *sample_rate, int *channel, int *bit_rate); + +/** + * @brief Gets the video stream information + * @remarks The playback type should be local playback or http streaming playback. + * @param[in] player The handle to media player + * @param[out] fps The frame per second of video. It can be 0 if there is no video stream information. + * @param[out] bit_rate The video bit rate [Hz]. It can be invalid value if there is no video stream information. + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of: #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + */ +int player_get_video_stream_info(player_h player, int *fps, int *bit_rate); + +/** + * @brief Gets the video display's height and width. + * @remarks The playback type should be local playback or http streaming playback. + * @param[in] player The handle to media player + * @param[out] width The width of video. It can be invalid value if there is no video, no display was set. + * @param[out] height The height of video. It can be invalid value if there is no video, no display was set. + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of: #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + */ +int player_get_video_size(player_h player, int *width, int *height); + +/** + * @brief Gets the album art in media resource + * @remarks Do not release @a album_art. It will be released by framework when player destroys. + * @param[in] player The handle to media player + * @param [out] artwork encoded artwork image + * @param [out] size encoded artwork size + * @return 0 on success, otherwise a negative error value + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of: #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + */ +int player_get_album_art(player_h player, void **album_art, int *size); + +/** + * @} + */ + + +/** + * @addtogroup CAPI_MEDIA_PLAYER_AUDIO_EFFECT_MODULE + * @{ + */ + +/** + * @brief Sets an audio effect value. + * @param[in] player The handle to media player + * @param[in] effect The audio effect type + * @param[in] value The value of given effect type * @return 0 on success, otherwise a negative error value. * @retval #PLAYER_ERROR_NONE Successful * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + * @see player_audio_effect_get_value() + * @see player_audio_effect_clear() + * @see player_audio_effect_get_value_range() */ -int player_set_audio_effect_3d(player_h player, audio_effect_3d_e effect); +int player_audio_effect_set_value(player_h player, audio_effect_e effect, int value); /** - * @brief Sets an equalizer audio effect. - * @remarks Equalizer, 3D and reverberation effects can be used together - * @param[in] player The handle to media player - * @param[in] effect The equalizer audio effect + * @brief Gets an audio effect value. + * @param[in] player The handle to media player + * @param[in] effect The audio effect type + * @param[out] value The value of given effect type + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + * @see player_audio_effect_set_value() + */ +int player_audio_effect_get_value(player_h player, audio_effect_e effect, int *value); + +/** + * @brief Clears audio effect. + * @param[in] player The handle to media player + * @param[in] effect The audio effect type * @return 0 on success, otherwise a negative error value. * @retval #PLAYER_ERROR_NONE Successful * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + * @see player_audio_effect_set_value() */ -int player_set_audio_effect_equalizer(player_h player, audio_effect_equalizer_e effect); +int player_audio_effect_clear(player_h player, audio_effect_e effect); /** - * @brief Sets an reverberation audio effect. - * @remarks Equalizer, 3D and reverberation effects can be used together - * @param[in] player The handle to media player - * @param[in] effect The reverberation audio effect + * @brief Gets the range of audio effect value. + * @param[in] player The handle to media player + * @param[in] effect The audio effect type + * @param[out] min The minumum value to be set + * @param[out] max The maximum value to be set + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + * @see player_audio_effect_set_value() + */ +int player_audio_effect_get_value_range(player_h player, audio_effect_e effect, int* min, int* max); + +/** + * @brief Checks whether the given effect is avaliable or not. + * @param[in] player The handle to media player + * @param[in] effect The audio effect to be checked + * @param[out] available @c true if the specified audio effect is available, else @c false + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + */ +int player_audio_effect_is_available(player_h player, audio_effect_e effect, bool *available); + +/** + * @brief Retrieves all supported audio effects by invoking callback function once for each supported audio effect. + * @param[in] player The handle to media player + * @param[in] callback The callback function to invoke + * @param[in] user_data The user data to be passed to the callback function + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + * @post This function invokes player_audio_effect_supported_effect_cb() repeatly to retrieve each supported audio effect. + * @see player_audio_effect_set_value() + * @see player_audio_effect_get_value() + * @see player_audio_effect_foreach_supported_effect() + */ +int player_audio_effect_foreach_supported_effect(player_h player, player_audio_effect_supported_effect_cb callback, void *user_data); + +/** + * @brief Sets an preset audio effect. + * @remarks Audio effects or equalizer which is set be ignored. + * @param[in] player The handle to media player + * @param[in] preset The preset audio effect * @return 0 on success, otherwise a negative error value. * @retval #PLAYER_ERROR_NONE Successful * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + * @see player_audio_effect_preset_is_available() + * @see player_audio_effect_foreach_supported_preset() */ -int player_set_audio_effect_reverb(player_h player, audio_effect_reverb_e effect); +int player_audio_effect_set_preset(player_h player, audio_effect_preset_e preset); +/** + * @brief Checks whether the given preset is avaliable or not. + * @param[in] player The handle to media player + * @param[in] preset The preset to be checked + * @param[out] available @c true if the specified preset is available, else @c false + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + */ +int player_audio_effect_preset_is_available(player_h player, audio_effect_preset_e preset, bool *available); /** - * @brief Sets an extra(Bass Enhancement, AEQ, Music clarity, 5.1 SRS circle surround, Wow HD, and Sound externalization) audio effect. - * @remarks Previous applied other effects(equalizer, 3D, reverberation) should be ignored. - * @param[in] player The handle to media player - * @param[in] effect The extra audio effect + * @brief Retrieves all supported presets by invoking callback function once for each supported preset audio effect. + * @param[in] player The handle to media player + * @param[in] callback The callback function to invoke + * @param[in] user_data The user data to be passed to the callback function + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + * @post This function invokes player_audio_effect_supported_preset_cb() repeatly to retrieve each supported preset audio effect. + * @see player_audio_effect_set_preset() + * @see player_audio_effect_supported_preset_cb() + */ +int player_audio_effect_foreach_supported_preset(player_h player, player_audio_effect_supported_preset_cb callback, void *user_data); + +/** + * @brief Gets the bands number of equalizer. + * @param[in] player The handle to media player + * @param[out] count The number of equalizer bands + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + * @see player_audio_effect_set_equalizer_band_level() + * @see player_audio_effect_set_equalizer_all_bands() + */ +int player_audio_effect_get_equalizer_bands_count (player_h player, int *count); + +/** + * @brief Sets the all bands of equalizer. + * @param[in] player The handle to media player + * @param[in] band_levels The list of band level to be set + * @param[in] length The length of the band level * @return 0 on success, otherwise a negative error value. * @retval #PLAYER_ERROR_NONE Successful * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + * @see player_audio_effect_get_equalizer_bands_count() + * @see player_audio_effect_get_equalizer_level_range() + * @see player_audio_effect_set_equalizer_band_level() */ -int player_set_audio_effect_extra(player_h player, audio_effect_extra_e effect); +int player_audio_effect_set_equalizer_all_bands(player_h player, int *band_levels, int length); /** - * @brief Clears all audio effects. + * @brief Sets the gain set for the given equalizer band. + * @param[in] player The handle to media player + * @param[in] index The index of qualizer band to be set + * @param[in] level New gain in decibel that will be set to the given band.[dB] + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + * @see player_audio_effect_get_equalizer_bands_count() + * @see player_audio_effect_get_equalizer_level_range() + * @see player_audio_effect_get_equalizer_band_level() + * @see player_audio_effect_set_equalizer_all_bands() + */ +int player_audio_effect_set_equalizer_band_level(player_h player, int index, int level); + +/** + * @brief Gets the gain set for the given equalizer band. * @param[in] player The handle to media player + * @param[in] index The index of qualizer band which is requested + * @param[out] level The gain in decibel of the given band [dB] * @return 0 on success, otherwise a negative error value. * @retval #PLAYER_ERROR_NONE Successful * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + * @see player_audio_effect_set_equalizer_band_level() + */ +int player_audio_effect_get_equalizer_band_level(player_h player, int index, int *level); + +/** + * @brief Gets the valid level range of equalizer. + * @param[in] player The handle to media player + * @param[out] min The minumum value to be set [dB] + * @param[out] max The maximum value to be set [dB] + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + * @see player_audio_effect_set_equalizer_band_level() + * @see player_audio_effect_set_equalizer_all_bands() + */ +int player_audio_effect_get_equalizer_level_range(player_h player, int* min, int* max); + +/** + * @brief Clears the equalizer effect. + * @param[in] player The handle to media player + * @param[in] effect The audio effect type + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. - * @see player_set_audio_effect_3d() - * @see player_set_audio_effect_equalizer() - * @see player_set_audio_effect_reverb() - * @see player_set_audio_effect_extra() + * @see player_audio_effect_set_equalizer_band_level() + * @see player_audio_effect_set_equalizer_all_bands() */ -int player_clear_audio_effect(player_h player); +int player_audio_effect_equalizer_clear(player_h player); + +/** + * @brief Checks whether the custom equilizer effect is avaliable or not. + * @param[in] player The handle to media player + * @param[out] available @c true if the specified audio effect is available, else @c false + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + * @see player_audio_effect_set_equalizer_band_level() + * @see player_audio_effect_set_equalizer_all_bands() + */ +int player_audio_effect_equalizer_is_available(player_h player, bool *available); /** * @} @@ -956,32 +1327,64 @@ int player_clear_audio_effect(player_h player); */ /** - * @brief Gets the video display's height and width. - * @param[in] player The handle to media player - * @param[out] width The width of video. It can be invalid value if there is no video, no display was set. - * @param[out] height The height of video. It can be invalid value if there is no video, no display was set. + * @brief Sets a subtitle path. + * @remarks Only MicroDVD/SubViewer(*.sub), SAMI(*.smi), and SubRip(*.srt) subtitle formats are supported. + * @param[in] player The handle to media player + * @param[in] path The absolute path of the subtitle file * @return 0 on success, otherwise a negative error value. * @retval #PLAYER_ERROR_NONE Successful * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state - * @pre The player state must be #PLAYER_STATE_READY by player_prepare() . + * @pre The player state should be #PLAYER_STATE_IDLE by player_prepare() or player_unprepare(). */ -int player_get_video_size(player_h player, int *width, int *height); +int player_set_subtitle_path(player_h player,const char *path); /** - * @brief Sets a subtitle path. + * @brief Sets the seek position for subtitle. * @remarks Only MicroDVD/SubViewer(*.sub), SAMI(*.smi), and SubRip(*.srt) subtitle formats are supported. + * @param[in] player The handle to media player + * @param[in] millisecond The position in milliseconds from the start to seek to + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The subtitle must be set by player_set_subtitle_path(). + * @pre The player state must be one of: #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. + */ +int player_set_subtitle_position(player_h player, int millisecond); + +/** + * @brief Sets a path to download, progressively. + * @remarks Progressive download will be started when you invoke player_start(). * @param[in] player The handle to media player - * @param[in] path The absolute path of the subtitle file + * @param[in] path The absolute path to download * @return 0 on success, otherwise a negative error value. * @retval #PLAYER_ERROR_NONE Successful * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state * @pre The player state should be #PLAYER_STATE_IDLE by player_prepare() or player_unprepare(). + * @see player_set_progressive_download_message_cb() + * @see player_unset_progressive_download_message_cb() */ -int player_set_subtitle_path(player_h player, char* path); +int player_set_progressive_download_path(player_h player, const char *path); + +/** + * @brief Gets the staus of progressive download. + * @param[in] player The handle to media player + * @param[out] current The current download position (bytes) + * @param[out] total_size The total size of file (bytes) + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state + * @pre The progressive download path must be set by player_set_progressive_download_path(). + * @pre The player state must be either #PLAYER_STATE_PLAYING by player_start() or #PLAYER_STATE_PAUSED by player_pause(). + */ +int player_get_progressive_download_status(player_h player, unsigned long *current, unsigned long *total_size); /** * @brief Captures the video frame, asynchronously. @@ -1028,15 +1431,6 @@ int player_set_streaming_cookie(player_h player, const char *cookie, int size); */ int player_set_started_cb(player_h player, player_started_cb callback, void *user_data); -/** - * @brief Unregisters the callback function. - * @param[in] player The handle to media player - * @return 0 on success, otherwise a negative error value. - * @retval #PLAYER_ERROR_NONE Successful - * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation - * @see player_set_started_cb() - */ int player_unset_started_cb(player_h player); /** @@ -1066,34 +1460,10 @@ int player_set_completed_cb(player_h player, player_completed_cb callback, void */ int player_unset_completed_cb(player_h player); -/** - * @brief Registers a callback function to be invoked when the playback is paused. - * @param[in] player The handle to media player - * @param[in] callback The callback function to register - * @param[in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #PLAYER_ERROR_NONE Successful - * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation - * @post player_paused_cb() will be invoked - * @see player_unset_paused_cb() - * @see player_paused_cb() - * @see player_pause() - */ int player_set_paused_cb(player_h player, player_paused_cb callback, void *user_data); -/** - * @brief Unregisters the callback function. - * @param[in] player The handle to media player - * @return 0 on success, otherwise a negative error value. - * @retval #PLAYER_ERROR_NONE Successful - * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation - * @see player_set_paused_cb() - */ int player_unset_paused_cb(player_h player); - /** * @brief Registers a callback function to be invoked when the playback is interrupted or interrupt completed. * @param[in] player The handle to media player @@ -1176,6 +1546,33 @@ int player_set_buffering_cb(player_h player, player_buffering_cb callback, void */ int player_unset_buffering_cb(player_h player); +/** + * @brief Registers a callback function to be invoked when progressive download is starts or completes. + * @param[in] player The handle to media player + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @pre The path to download must be set by player_set_progressive_download_path(). + * @post player_pd_message_cb() will be invoked + * @see player_unset_progressive_download_message_cb() + * @see player_set_progressive_download_path() + */ +int player_set_progressive_download_message_cb(player_h player, player_pd_message_cb callback, void *user_data); + +/** + * @brief Unregisters the callback function. + * @param[in] player The handle to media player + * @return 0 on success, otherwise a negative error value. + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @see player_set_progressive_download_message_cb() + */ +int player_unset_progressive_download_message_cb(player_h player); + /** * @brief Registers a callback function to be invoked when subtitle updates. * @param[in] player The handle to media player @@ -1185,7 +1582,7 @@ int player_unset_buffering_cb(player_h player); * @retval #PLAYER_ERROR_NONE Successful * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation - * @pre The subtile must be set by player_set_subtitle_path(). + * @pre The subtitle must be set by player_set_subtitle_path(). * @post player_subtitle_updated_cb() will be invoked * @see player_unset_subtitle_updated_cb() * @see player_subtitle_updated_cb() diff --git a/include/player_private.h b/include/player_private.h index 0d43372..af5e3e1 100644 --- a/include/player_private.h +++ b/include/player_private.h @@ -24,7 +24,8 @@ extern "C" { #endif typedef enum { - _PLAYER_EVENT_TYPE_BEGIN, + _PLAYER_EVENT_TYPE_BEGIN, + _PLAYER_EVENT_TYPE_PREPARE, _PLAYER_EVENT_TYPE_COMPLETE, _PLAYER_EVENT_TYPE_PAUSE, _PLAYER_EVENT_TYPE_INTERRUPT, @@ -32,8 +33,12 @@ typedef enum { _PLAYER_EVENT_TYPE_BUFFERING, _PLAYER_EVENT_TYPE_SUBTITLE, _PLAYER_EVENT_TYPE_CAPTURE, + _PLAYER_EVENT_TYPE_SEEK, _PLAYER_EVENT_TYPE_VIDEO_FRAME, _PLAYER_EVENT_TYPE_AUDIO_FRAME, + _PLAYER_EVENT_TYPE_PD, + _PLAYER_SUPPORTED_AUDIO_EFFECT_TYPE, + _PLAYER_SUPPORTED_AUDIO_EFFECT_PRESET, _PLAYER_EVENT_TYPE_NUM }_player_event_e; @@ -44,6 +49,7 @@ typedef struct _player_s{ void* display_handle; player_display_type_e display_type; int state; + int is_prepare_sync; } player_s; #ifdef __cplusplus diff --git a/packaging/capi-media-player.spec b/packaging/capi-media-player.spec index d2e16d5..9956ed7 100644 --- a/packaging/capi-media-player.spec +++ b/packaging/capi-media-player.spec @@ -1,15 +1,17 @@ +#sbs-git:slp/api/player capi-media-player 0.1.0 6b3c03f72f7fd67cdee06dbde70eb2e10335b57a Name: capi-media-player Summary: A Media Player library in Tizen Native API Version: 0.1.0 -Release: 12 +Release: 24 Group: TO_BE/FILLED_IN -License: Apache-2.0 +License: TO BE FILLED IN Source0: %{name}-%{version}.tar.gz BuildRequires: cmake BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(mm-player) BuildRequires: pkgconfig(capi-base-common) BuildRequires: pkgconfig(capi-media-sound-manager) +BuildRequires: pkgconfig(mm-ta) Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig @@ -28,9 +30,8 @@ Requires: %{name} = %{version}-%{release} %build -FULLVER=%{version} -MAJORVER=`echo ${FULLVER} | cut -d '.' -f 1` -cmake . -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=${FULLVER} -DMAJORVER=${MAJORVER} +MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` +cmake . -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER} make %{?jobs:-j%jobs} @@ -45,10 +46,11 @@ rm -rf %{buildroot} %files -%{_libdir}/libcapi-media-player.so* +%{_libdir}/libcapi-media-player.so.* %files devel %{_includedir}/media/*.h %{_libdir}/pkgconfig/*.pc +%{_libdir}/libcapi-media-player.so diff --git a/src/player.c b/src/player.c old mode 100644 new mode 100755 index ab66090..09a435a --- a/src/player.c +++ b/src/player.c @@ -25,6 +25,7 @@ #include #include #include +#include #ifdef LOG_TAG #undef LOG_TAG @@ -81,9 +82,14 @@ static int __convert_error_code(int code, char* func_name) case MM_ERROR_PLAYER_INVALID_STREAM: case MM_ERROR_PLAYER_STREAMING_FAIL: case MM_ERROR_PLAYER_NO_OP: + case MM_ERROR_NOT_SUPPORT_API: ret = PLAYER_ERROR_INVALID_OPERATION; msg = "PLAYER_ERROR_INVALID_OPERATION"; break; + case MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER: + ret = PLAYER_ERROR_INVALID_OPERATION; + msg = "PLAYER_ERROR_INVALID_OPERATION (NOT SUPPORTED AUDIO EFFECT)"; + break; case MM_ERROR_PLAYER_NO_FREE_SPACE: ret = PLAYER_ERROR_OUT_OF_MEMORY; msg = "PLAYER_ERROR_OUT_OF_MEMORY"; @@ -155,6 +161,33 @@ static int __convert_error_code(int code, char* func_name) return ret; } +static player_interrupted_code_e __convert_interrupted_code(int code) +{ + player_interrupted_code_e ret = PLAYER_INTERRUPTED_BY_RESOURCE_CONFLICT; + switch(code) + { + case MM_MSG_CODE_INTERRUPTED_BY_OTHER_APP: + ret = PLAYER_INTERRUPTED_BY_OTHER_APP; + break; + case MM_MSG_CODE_INTERRUPTED_BY_CALL_START: + case PLAYER_INTERRUPTED_BY_CALL: + ret = PLAYER_INTERRUPTED_BY_OTHER_APP; + break; + case MM_MSG_CODE_INTERRUPTED_BY_EARJACK_UNPLUG: + ret = PLAYER_INTERRUPTED_BY_EARJACK_UNPLUG; + break; + case MM_MSG_CODE_INTERRUPTED_BY_ALARM_START: + case MM_MSG_CODE_INTERRUPTED_BY_ALARM_END: + ret = PLAYER_INTERRUPTED_BY_ALARM; + break; + case MM_MSG_CODE_INTERRUPTED_BY_RESOURCE_CONFLICT: + default : + ret = PLAYER_INTERRUPTED_BY_RESOURCE_CONFLICT; + break; + } + return ret; +} + static player_state_e __convert_player_state(MMPlayerStateType state) { if(state == MM_PLAYER_STATE_NONE) @@ -195,7 +228,7 @@ static int __msg_callback(int message, void *param, void *user_data) { player_s * handle = (player_s*)user_data; MMMessageParamType *msg = (MMMessageParamType*)param; - LOGI("[%s] Got message type : 0x%x" ,__FUNCTION__, message); + LOGI("[%s] Start : Got message type : 0x%x" ,__FUNCTION__, message); player_error_e err_code = PLAYER_ERROR_NONE; switch(message) { @@ -203,11 +236,13 @@ static int __msg_callback(int message, void *param, void *user_data) err_code = __convert_error_code(msg->code,(char*)__FUNCTION__); break; case MM_MESSAGE_STATE_CHANGED: //0x03 - handle->state = __convert_player_state(msg->state.current); - if(handle->state == PLAYER_STATE_PAUSED && handle->user_cb[_PLAYER_EVENT_TYPE_PAUSE] ) + LOGE("STATE CHANGED INTERNALLY - from : %d, to : %d (CAPI State : %d)", msg->state.previous, msg->state.current, handle->state); + + if(handle->state == PLAYER_STATE_PLAYING && msg->state.current == MM_PLAYER_STATE_PAUSED && handle->user_cb[_PLAYER_EVENT_TYPE_PAUSE] ) { + LOGE("Invoke the paused callback"); ((player_paused_cb)handle->user_cb[_PLAYER_EVENT_TYPE_PAUSE])(handle->user_data[_PLAYER_EVENT_TYPE_PAUSE]); - } + } break; case MM_MESSAGE_READY_TO_RESUME: //0x05 if( handle->user_cb[_PLAYER_EVENT_TYPE_INTERRUPT] ) @@ -216,10 +251,26 @@ static int __msg_callback(int message, void *param, void *user_data) } break; case MM_MESSAGE_BEGIN_OF_STREAM: //0x104 - if( handle->user_cb[_PLAYER_EVENT_TYPE_BEGIN] ) + if(handle->is_prepare_sync)//sync && started cb has been set { - ((player_started_cb)handle->user_cb[_PLAYER_EVENT_TYPE_BEGIN])(handle->user_data[_PLAYER_EVENT_TYPE_BEGIN]); - } + if(handle->user_cb[_PLAYER_EVENT_TYPE_BEGIN]) + { + MMTA_ACUM_ITEM_END("[CAPI] player_start ~ BOS", 0); + ((player_started_cb)handle->user_cb[_PLAYER_EVENT_TYPE_BEGIN])(handle->user_data[_PLAYER_EVENT_TYPE_BEGIN]); + } + } + else + { + handle->state=PLAYER_STATE_READY; + if(handle->user_cb[_PLAYER_EVENT_TYPE_PREPARE]) // asyc && prepared cb has been set + { + mm_player_pause(handle->mm_handle); + mm_player_set_mute(handle->mm_handle,0); + ((player_prepared_cb)handle->user_cb[_PLAYER_EVENT_TYPE_PREPARE])(handle->user_data[_PLAYER_EVENT_TYPE_PREPARE]); + handle->user_cb[_PLAYER_EVENT_TYPE_PREPARE] = NULL; + handle->user_data[_PLAYER_EVENT_TYPE_PREPARE] = NULL; + } + } break; case MM_MESSAGE_END_OF_STREAM://0x105 if( handle->user_cb[_PLAYER_EVENT_TYPE_COMPLETE] ) @@ -236,10 +287,8 @@ static int __msg_callback(int message, void *param, void *user_data) case MM_MESSAGE_STATE_INTERRUPTED: //0x04 if( handle->user_cb[_PLAYER_EVENT_TYPE_INTERRUPT] ) { - MMPlayerStateType currentStat = MM_PLAYER_STATE_PAUSED; - int ret = mm_player_get_state(handle->mm_handle, ¤tStat); - handle->state = (ret != MM_ERROR_NONE )? currentStat: __convert_player_state(currentStat); - ((player_interrupted_cb)handle->user_cb[_PLAYER_EVENT_TYPE_INTERRUPT])(msg->code,handle->user_data[_PLAYER_EVENT_TYPE_INTERRUPT]); + handle->state = __convert_player_state(msg->state.current); + ((player_interrupted_cb)handle->user_cb[_PLAYER_EVENT_TYPE_INTERRUPT])(__convert_interrupted_code(msg->code),handle->user_data[_PLAYER_EVENT_TYPE_INTERRUPT]); } break; case MM_MESSAGE_CONNECTION_TIMEOUT: //0x102 @@ -281,6 +330,8 @@ static int __msg_callback(int message, void *param, void *user_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 @@ -295,6 +346,14 @@ static int __msg_callback(int message, void *param, void *user_data) LOGE("[%s] PLAYER_ERROR_NOT_SUPPORTED_FILE (0x%08x) : DRM_NOT_AUTHORIZED" ,__FUNCTION__, PLAYER_ERROR_NOT_SUPPORTED_FILE); err_code = PLAYER_ERROR_NOT_SUPPORTED_FILE; break; + case MM_MESSAGE_SEEK_COMPLETED: //0x114 + if( handle->user_cb[_PLAYER_EVENT_TYPE_SEEK]) + { + ((player_seek_completed_cb)handle->user_cb[_PLAYER_EVENT_TYPE_SEEK])(handle->user_data[_PLAYER_EVENT_TYPE_SEEK]); + handle->user_cb[_PLAYER_EVENT_TYPE_SEEK] = NULL; + handle->user_data[_PLAYER_EVENT_TYPE_SEEK] = NULL; + } + break; case MM_MESSAGE_UNKNOWN: //0x00 case MM_MESSAGE_WARNING: //0x02 case MM_MESSAGE_CONNECTING: //0x100 @@ -307,7 +366,6 @@ static int __msg_callback(int message, void *param, void *user_data) case MM_MESSAGE_RTP_SESSION_STATUS: //0x10c case MM_MESSAGE_SENDER_STATE: //0x10d case MM_MESSAGE_RECEIVER_STATE: //0x10e - case MM_MESSAGE_SEEK_COMPLETED: //0x114 default: break; } @@ -316,15 +374,19 @@ static int __msg_callback(int message, void *param, void *user_data) { ((player_error_cb)handle->user_cb[_PLAYER_EVENT_TYPE_ERROR])(err_code,handle->user_data[_PLAYER_EVENT_TYPE_ERROR]); } + LOGE("[%s] End", __FUNCTION__); return 1; } static bool __video_stream_callback(void *stream, int stream_size, void *user_data, int width, int height) { player_s * handle = (player_s*)user_data; - if( handle->user_cb[_PLAYER_EVENT_TYPE_VIDEO_FRAME] ) + if( handle->user_cb[_PLAYER_EVENT_TYPE_VIDEO_FRAME]) { - ((player_video_frame_decoded_cb)handle->user_cb[_PLAYER_EVENT_TYPE_VIDEO_FRAME])((unsigned char *)stream, width, height, stream_size, handle->user_data[_PLAYER_EVENT_TYPE_VIDEO_FRAME]); + if(handle->state==PLAYER_STATE_PLAYING) + ((player_video_frame_decoded_cb)handle->user_cb[_PLAYER_EVENT_TYPE_VIDEO_FRAME])((unsigned char *)stream, width, height, stream_size, handle->user_data[_PLAYER_EVENT_TYPE_VIDEO_FRAME]); + else + LOGE("[%s] Skip stream - current state : %d", __FUNCTION__,handle->state); } return TRUE; } @@ -334,11 +396,69 @@ static bool __audio_stream_callback(void *stream, int stream_size, void *user_d player_s * handle = (player_s*)user_data; if( handle->user_cb[_PLAYER_EVENT_TYPE_AUDIO_FRAME] ) { - ((player_audio_frame_decoded_cb)handle->user_cb[_PLAYER_EVENT_TYPE_AUDIO_FRAME])((unsigned char *)stream, stream_size, handle->user_data[_PLAYER_EVENT_TYPE_AUDIO_FRAME]); + if(handle->state==PLAYER_STATE_PLAYING) + ((player_audio_frame_decoded_cb)handle->user_cb[_PLAYER_EVENT_TYPE_AUDIO_FRAME])((unsigned char *)stream, stream_size, handle->user_data[_PLAYER_EVENT_TYPE_AUDIO_FRAME]); + else + LOGE("[%s] Skip stream - current state : %d", __FUNCTION__,handle->state); } return TRUE; } +static int __pd_message_callback(int message, void *param, void *user_data) +{ + player_s * handle = (player_s*)user_data; + player_pd_message_type_e type; + switch(message) + { + case MM_MESSAGE_PD_DOWNLOADER_START: + type = PLAYER_PD_STARTED; + break; + case MM_MESSAGE_PD_DOWNLOADER_END: + type = PLAYER_PD_COMPLETED; + break; + default: + return 0; + } + + if( handle->user_cb[_PLAYER_EVENT_TYPE_PD] ) + { + ((player_pd_message_cb)handle->user_cb[_PLAYER_EVENT_TYPE_PD])(type, handle->user_data[_PLAYER_EVENT_TYPE_PD]); + } + return 0; +} + +static bool __supported_audio_effect_type (int filter, int type, void *user_data) +{ + player_s * handle = (player_s*)user_data; + if(filter != MM_AUDIO_FILTER_TYPE_CUSTOM || type == MM_AUDIO_FILTER_CUSTOM_EQ) + { + LOGI("[%s] Skip invalid filter: %d or type : %d",__FUNCTION__, filter, type); + return TRUE; + } + + if( handle->user_cb[_PLAYER_SUPPORTED_AUDIO_EFFECT_TYPE] ) + { + return ((player_audio_effect_supported_effect_cb)handle->user_cb[_PLAYER_SUPPORTED_AUDIO_EFFECT_TYPE])(type, handle->user_data[_PLAYER_SUPPORTED_AUDIO_EFFECT_TYPE]); + } + return FALSE; +} + +static bool __supported_audio_effect_preset (int filter, int type, void *user_data) +{ + player_s * handle = (player_s*)user_data; + if(filter != MM_AUDIO_FILTER_TYPE_PRESET) + { + LOGI("[%s] Skip invalid filter: %d or type : %d",__FUNCTION__, filter, type); + return TRUE; + } + + if( handle->user_cb[_PLAYER_SUPPORTED_AUDIO_EFFECT_PRESET] ) + { + return ((player_audio_effect_supported_effect_cb)handle->user_cb[_PLAYER_SUPPORTED_AUDIO_EFFECT_PRESET])(type, handle->user_data[_PLAYER_SUPPORTED_AUDIO_EFFECT_PRESET]); + } + return FALSE; +} + /* * Public Implementation @@ -346,17 +466,21 @@ static bool __audio_stream_callback(void *stream, int stream_size, void *user_d int player_create (player_h *player) { + LOGE("[%s] Start", __FUNCTION__); PLAYER_INSTANCE_CHECK(player); + MMTA_INIT(); + MMTA_ACUM_ITEM_BEGIN("[CAPI] player_create", 0); player_s * handle; handle = (player_s*)malloc( sizeof(player_s)); if (handle != NULL) memset(handle, 0 , sizeof(player_s)); else { - LOGE("[%s] PLAYER_ERROR_OUT_OF_MEMORY" ,__FUNCTION__,PLAYER_ERROR_OUT_OF_MEMORY); + LOGE("[%s] PLAYER_ERROR_OUT_OF_MEMORY(0x%08x)" ,__FUNCTION__,PLAYER_ERROR_OUT_OF_MEMORY); return PLAYER_ERROR_OUT_OF_MEMORY; } int ret = mm_player_create(&handle->mm_handle); + MMTA_ACUM_ITEM_END("[CAPI] player_create", 0); if( ret != MM_ERROR_NONE) { LOGE("[%s] PLAYER_ERROR_INVALID_OPERATION(0x%08x)" ,__FUNCTION__,PLAYER_ERROR_INVALID_OPERATION); @@ -369,7 +493,8 @@ int player_create (player_h *player) { *player = (player_h)handle; handle->state = PLAYER_STATE_IDLE; - handle->display_type = PLAYER_DISPLAY_TYPE_NONE; + handle->display_type = MM_DISPLAY_SURFACE_NULL; // means DISPLAY_TYPE_NONE(3) + LOGE("[%s] End", __FUNCTION__); return PLAYER_ERROR_NONE; } } @@ -377,8 +502,11 @@ int player_create (player_h *player) int player_destroy (player_h player) { + LOGE("[%s] Start", __FUNCTION__); PLAYER_INSTANCE_CHECK(player); player_s * handle = (player_s *) player; + MMTA_ACUM_ITEM_SHOW_RESULT_TO(MMTA_SHOW_FILE); + if (mm_player_destroy(handle->mm_handle)!= MM_ERROR_NONE) { LOGE("[%s] PLAYER_ERROR_INVALID_OPERATION(0x%08x)" ,__FUNCTION__,PLAYER_ERROR_INVALID_OPERATION); @@ -389,15 +517,80 @@ int player_destroy (player_h player) handle->state = PLAYER_STATE_NONE; free(handle); handle= NULL; + LOGE("[%s] End", __FUNCTION__); + return PLAYER_ERROR_NONE; + } +} + +int player_prepare_async (player_h player, player_prepared_cb callback, void* user_data) +{ + LOGE("[%s] Start", __FUNCTION__); + PLAYER_INSTANCE_CHECK(player); + player_s * handle = (player_s *) player; + PLAYER_STATE_CHECK(handle,PLAYER_STATE_IDLE); + handle->is_prepare_sync=0; + + if(handle->user_cb[_PLAYER_EVENT_TYPE_PREPARE]) + { + LOGE("[%s] PLAYER_ERROR_INVALID_OPERATION (0x%08x) : preparing... we can't do any more " ,__FUNCTION__, PLAYER_ERROR_INVALID_OPERATION); + return PLAYER_ERROR_INVALID_OPERATION; + } + else + { + LOGI("[%s] Event type : %d ",__FUNCTION__, _PLAYER_EVENT_TYPE_PREPARE); + handle->user_cb[_PLAYER_EVENT_TYPE_PREPARE] = callback; + handle->user_data[_PLAYER_EVENT_TYPE_PREPARE] = user_data; + } + + int ret; + ret = mm_player_set_message_callback(handle->mm_handle, __msg_callback, (void*)handle); + if(ret != MM_ERROR_NONE) + { + LOGW("[%s] Failed to set message callback function (0x%x)" ,__FUNCTION__, ret); + } + + if (handle->display_type==((int)MM_DISPLAY_SURFACE_NULL)) + { + ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_surface_type", MM_DISPLAY_SURFACE_NULL, (char*)NULL); + if(ret != MM_ERROR_NONE) + { + LOGW("[%s] Failed to set display surface type 'MM_DISPLAY_SURFACE_NULL' (0x%x)" ,__FUNCTION__, ret); + } + } + else + { + mm_player_set_attribute(handle->mm_handle, NULL,"display_visible" , 0, (char*)NULL); + } + + ret = mm_player_set_attribute(handle->mm_handle, NULL, "profile_async_start", 1, (char*)NULL); + if(ret != MM_ERROR_NONE) + { + LOGE("[%s] Failed to set profile_async_start '1' (0x%x)" ,__FUNCTION__, ret); + } + ret = mm_player_realize(handle->mm_handle); + mm_player_set_mute(handle->mm_handle, 1); + mm_player_start(handle->mm_handle); + LOGE("START on Prepare() Async!!!!!!"); + + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + LOGE("[%s] End", __FUNCTION__); return PLAYER_ERROR_NONE; } } int player_prepare (player_h player) { + LOGE("[%s] Start", __FUNCTION__); PLAYER_INSTANCE_CHECK(player); + MMTA_ACUM_ITEM_BEGIN("[CAPI] player_prepare", 0); player_s * handle = (player_s *) player; PLAYER_STATE_CHECK(handle,PLAYER_STATE_IDLE); + handle->is_prepare_sync=1; int ret; ret = mm_player_set_message_callback(handle->mm_handle, __msg_callback, (void*)handle); @@ -405,7 +598,35 @@ int player_prepare (player_h player) { LOGW("[%s] Failed to set message callback function (0x%x)" ,__FUNCTION__, ret); } + + if (handle->display_type==((int)MM_DISPLAY_SURFACE_NULL)) + { + ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_surface_type", MM_DISPLAY_SURFACE_NULL, (char*)NULL); + if(ret != MM_ERROR_NONE) + { + LOGW("[%s] Failed to set display surface type 'MM_DISPLAY_SURFACE_NULL' (0x%x)" ,__FUNCTION__, ret); + } + } + else + { + mm_player_set_attribute(handle->mm_handle, NULL,"display_visible" , 0, (char*)NULL); + } + + ret = mm_player_set_attribute(handle->mm_handle, NULL, "profile_async_start", 0, (char*)NULL); + if(ret != MM_ERROR_NONE) + { + LOGE("[%s] Failed to set profile_async_start '0' (0x%x)" ,__FUNCTION__, ret); + } + + int err; + mm_player_set_mute(handle->mm_handle, 1); ret = mm_player_realize(handle->mm_handle); + err = mm_player_start(handle->mm_handle); + LOGE("START on Prepare() Sync!!!!!! : %d", err); + err = mm_player_pause(handle->mm_handle); + mm_player_set_mute(handle->mm_handle, 0); + + MMTA_ACUM_ITEM_END("[CAPI] player_prepare", 0); if(ret != MM_ERROR_NONE) { return __convert_error_code(ret,(char*)__FUNCTION__); @@ -413,12 +634,14 @@ int player_prepare (player_h player) else { handle->state = PLAYER_STATE_READY; + LOGE("[%s] End", __FUNCTION__); return PLAYER_ERROR_NONE; } } int player_unprepare (player_h player) { + LOGE("[%s] Start", __FUNCTION__); PLAYER_INSTANCE_CHECK(player); player_s * handle = (player_s *) player; if (!__player_state_validate(handle, PLAYER_STATE_READY)) @@ -435,6 +658,8 @@ int player_unprepare (player_h player) else { handle->state = PLAYER_STATE_IDLE; + handle->display_type = MM_DISPLAY_SURFACE_NULL; // means DISPLAY_TYPE_NONE(3) + LOGE("[%s] End", __FUNCTION__); return PLAYER_ERROR_NONE; } } @@ -480,19 +705,11 @@ int player_get_state (player_h player, player_state_e *state) PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(state); player_s * handle = (player_s *) player; + *state = handle->state; MMPlayerStateType currentStat = MM_PLAYER_STATE_NULL; - int ret = mm_player_get_state(handle->mm_handle, ¤tStat); - if(ret != MM_ERROR_NONE) - { - *state = handle->state; - return __convert_error_code(ret,(char*)__FUNCTION__); - } - else - { - handle->state = __convert_player_state(currentStat); - *state = handle->state; - return PLAYER_ERROR_NONE; - } + mm_player_get_state(handle->mm_handle, ¤tStat); + LOGE("[%s] State : %d (FW state : %d)", __FUNCTION__,handle->state, currentStat); + return PLAYER_ERROR_NONE; } int player_set_volume (player_h player, float left, float right) @@ -551,15 +768,24 @@ int player_set_sound_type(player_h player, sound_type_e type) int player_start (player_h player) { + LOGE("[%s] Start", __FUNCTION__); PLAYER_INSTANCE_CHECK(player); + MMTA_ACUM_ITEM_BEGIN("[CAPI] player_start only", 0); + MMTA_ACUM_ITEM_BEGIN("[CAPI] player_start ~ BOS", 0); player_s * handle = (player_s *) player; int ret; - if (handle->state == PLAYER_STATE_READY ) - { - ret = mm_player_start(handle->mm_handle); - } - else if ( handle->state == PLAYER_STATE_PAUSED) + if ( handle->state ==PLAYER_STATE_READY || handle->state ==PLAYER_STATE_PAUSED) { + if(handle->display_type == PLAYER_DISPLAY_TYPE_X11 || handle->display_type == PLAYER_DISPLAY_TYPE_EVAS) + { + ret = mm_player_set_attribute(handle->mm_handle, NULL,"display_visible" , 1, (char*)NULL); + LOGE("[%s] show video display : %d",__FUNCTION__, ret); + } + if(handle->is_prepare_sync) + { + //TODO: fix it ! + ret = mm_player_pause(handle->mm_handle); + } ret = mm_player_resume(handle->mm_handle); } else @@ -575,12 +801,14 @@ int player_start (player_h player) else { handle->state = PLAYER_STATE_PLAYING; + LOGE("[%s] End", __FUNCTION__); return PLAYER_ERROR_NONE; } } int player_stop (player_h player) { + LOGE("[%s] Start", __FUNCTION__); PLAYER_INSTANCE_CHECK(player); player_s * handle = (player_s *) player; if (handle->state == PLAYER_STATE_PLAYING || handle->state == PLAYER_STATE_PAUSED) @@ -593,18 +821,20 @@ int player_stop (player_h player) else { handle->state = PLAYER_STATE_READY; + LOGE("[%s] End", __FUNCTION__); return PLAYER_ERROR_NONE; } } else { - LOGE("[%s] PLAYER_ERROR_INVALID_STATE (current state : %d)" ,__FUNCTION__, handle->state); + LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d" ,__FUNCTION__,PLAYER_ERROR_INVALID_STATE, handle->state); return PLAYER_ERROR_INVALID_STATE; } } int player_pause (player_h player) { + LOGE("[%s] Start", __FUNCTION__); PLAYER_INSTANCE_CHECK(player); player_s * handle = (player_s *) player; PLAYER_STATE_CHECK(handle,PLAYER_STATE_PLAYING); @@ -617,15 +847,28 @@ int player_pause (player_h player) else { handle->state = PLAYER_STATE_PAUSED; + LOGE("[%s] End", __FUNCTION__); return PLAYER_ERROR_NONE; } } -int player_set_position (player_h player, int millisecond) +int player_set_position (player_h player, int millisecond, player_seek_completed_cb callback, void *user_data) { PLAYER_INSTANCE_CHECK(player); PLAYER_CHECK_CONDITION(millisecond>=0 ,PLAYER_ERROR_INVALID_PARAMETER ,"PLAYER_ERROR_INVALID_PARAMETER" ); + player_s * handle = (player_s *) player; + if(handle->user_cb[_PLAYER_EVENT_TYPE_SEEK]) + { + LOGE("[%s] PLAYER_ERROR_SEEK_FAILED (0x%08x) : seeking... we can't do any more " ,__FUNCTION__, PLAYER_ERROR_SEEK_FAILED); + return PLAYER_ERROR_SEEK_FAILED; + } + else + { + LOGI("[%s] Event type : %d ",__FUNCTION__, _PLAYER_EVENT_TYPE_SEEK); + handle->user_cb[_PLAYER_EVENT_TYPE_SEEK] = callback; + handle->user_data[_PLAYER_EVENT_TYPE_SEEK] = user_data; + } int ret = mm_player_set_position(handle->mm_handle, MM_PLAYER_POS_FORMAT_TIME, millisecond); if(ret != MM_ERROR_NONE) @@ -638,12 +881,23 @@ int player_set_position (player_h player, int millisecond) } } - -int player_set_position_ratio (player_h player, int percent) +int player_set_position_ratio (player_h player, int percent, player_seek_completed_cb callback, void *user_data) { PLAYER_INSTANCE_CHECK(player); PLAYER_CHECK_CONDITION(percent>=0 && percent <= 100 ,PLAYER_ERROR_INVALID_PARAMETER ,"PLAYER_ERROR_INVALID_PARAMETER" ); + player_s * handle = (player_s *) player; + if(handle->user_cb[_PLAYER_EVENT_TYPE_SEEK]) + { + LOGE("[%s] PLAYER_ERROR_SEEK_FAILED (0x%08x) : seeking... we can't do any more " ,__FUNCTION__, PLAYER_ERROR_SEEK_FAILED); + return PLAYER_ERROR_SEEK_FAILED; + } + else + { + LOGI("[%s] Event type : %d ",__FUNCTION__, _PLAYER_EVENT_TYPE_SEEK); + handle->user_cb[_PLAYER_EVENT_TYPE_SEEK] = callback; + handle->user_data[_PLAYER_EVENT_TYPE_SEEK] = user_data; + } int ret = mm_player_set_position(handle->mm_handle, MM_PLAYER_POS_FORMAT_PERCENT , percent); if(ret != MM_ERROR_NONE) @@ -664,7 +918,7 @@ int player_get_position (player_h player, int *millisecond) player_s * handle = (player_s *) player; if (!__player_state_validate(handle, PLAYER_STATE_READY)) { - LOGE("[%s] PLAYER_ERROR_INVALID_STATE (current state : %d)" ,__FUNCTION__, handle->state); + LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d" ,__FUNCTION__,PLAYER_ERROR_INVALID_STATE, handle->state); return PLAYER_ERROR_INVALID_STATE; } int pos; @@ -687,7 +941,7 @@ int player_get_position_ratio (player_h player,int *percent) player_s * handle = (player_s *) player; if (!__player_state_validate(handle, PLAYER_STATE_READY)) { - LOGE("[%s] PLAYER_ERROR_INVALID_STATE (current state : %d)" ,__FUNCTION__, handle->state); + LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d" ,__FUNCTION__,PLAYER_ERROR_INVALID_STATE, handle->state); return PLAYER_ERROR_INVALID_STATE; } int pos; @@ -751,7 +1005,7 @@ int player_set_looping (player_h player, bool looping) player_s * handle = (player_s *) player; if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) { - LOGE("[%s] PLAYER_ERROR_INVALID_STATE (current state : %d)" ,__FUNCTION__, handle->state); + LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d" ,__FUNCTION__,PLAYER_ERROR_INVALID_STATE, handle->state); return PLAYER_ERROR_INVALID_STATE; } @@ -779,7 +1033,7 @@ int player_is_looping (player_h player, bool *looping) player_s * handle = (player_s *) player; if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) { - LOGE("[%s] PLAYER_ERROR_INVALID_STATE (current state : %d)" ,__FUNCTION__, handle->state); + LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d" ,__FUNCTION__,PLAYER_ERROR_INVALID_STATE, handle->state); return PLAYER_ERROR_INVALID_STATE; } int count; @@ -807,9 +1061,9 @@ int player_get_duration (player_h player, int *duration) PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(duration); player_s * handle = (player_s *) player; - if (!__player_state_validate(handle, PLAYER_STATE_PLAYING)) + if (!__player_state_validate(handle, PLAYER_STATE_READY)) { - LOGE("[%s] PLAYER_ERROR_INVALID_STATE (current state : %d)" ,__FUNCTION__, handle->state); + 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; @@ -821,6 +1075,7 @@ int player_get_duration (player_h player, int *duration) else { *duration = _duration; + LOGE("[%s] duration : %d",__FUNCTION__,_duration); return PLAYER_ERROR_NONE; } } @@ -829,17 +1084,102 @@ int player_set_display(player_h player, player_display_type_e type, player_displ { PLAYER_INSTANCE_CHECK(player); player_s * handle = (player_s *) player; - PLAYER_STATE_CHECK(handle,PLAYER_STATE_IDLE); + if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d" ,__FUNCTION__,PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + + int ret; + if(handle->display_type == (int)MM_DISPLAY_SURFACE_NULL) + { + handle->display_handle = display; + handle->display_type = type; + LOGE("[%s] video display has been set initailly - type :%d",__FUNCTION__,type); + ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_surface_use_multi",0,"display_surface_type", type, "display_overlay" , type == PLAYER_DISPLAY_TYPE_X11 ? &handle->display_handle : display, sizeof(display), (char*)NULL); + } + else + { + LOGE("[%s] video display has been set again- type :%d",__FUNCTION__,type); + player_display_type_e prev_type = handle->display_type; + player_display_h prev = handle->display_handle; + handle->display_handle = display; + handle->display_type = type; + LOGE("[%s] Type : %d, display addr : %x (%d) , Prev Type : %d, Prev display addr : %x (%d)",__FUNCTION__,type, handle->display_handle, handle->display_handle, prev_type, prev, prev); + ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_surface_use_multi",1,"display_surface_type", type, "display_overlay" , type == PLAYER_DISPLAY_TYPE_X11 ? &handle->display_handle : display, sizeof(display), "display_overlay_ext",prev_type == PLAYER_DISPLAY_TYPE_X11 ? &prev : prev, sizeof(prev) ,(char*)NULL); + } + + if(ret != MM_ERROR_NONE) + { + handle->display_type = MM_DISPLAY_SURFACE_NULL; + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + LOGE("[%s] End",__FUNCTION__); + return PLAYER_ERROR_NONE; + } +} + +int player_is_display_mode_changeable(player_h player, bool* changeable) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(changeable); + player_s * handle = (player_s *) player; + switch(handle->display_type) + { + case PLAYER_DISPLAY_TYPE_X11: + *changeable = TRUE; + break; + case PLAYER_DISPLAY_TYPE_EVAS: + { + char *sink_name = NULL; + int length; + int scaling; + int ret = mm_player_get_attribute(handle->mm_handle, NULL,"display_evas_surface_sink" ,&sink_name, &length, "display_evas_do_scaling", &scaling, (char*)NULL); + if(ret != MM_ERROR_NONE) + *changeable = FALSE; + if (!strncmp(sink_name,"evaspixmapsink",length) && scaling==1) + { + *changeable = TRUE; + } + break; + } + default: + *changeable = FALSE; + break; + } + return PLAYER_ERROR_NONE; +} + +int player_set_display_mode(player_h player, player_display_mode_e mode) +{ + PLAYER_INSTANCE_CHECK(player); + player_s * handle = (player_s *) player; + + int ret = mm_player_set_attribute(handle->mm_handle, NULL,"display_method" , mode, (char*)NULL); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + return PLAYER_ERROR_NONE; +} - handle->display_handle = display; - handle->display_type = type; - int ret = mm_player_set_attribute(handle->mm_handle, NULL, "display_surface_type", type, "display_overlay" , type == PLAYER_DISPLAY_TYPE_X11 ? &handle->display_handle : display, sizeof(display), (char*)NULL); +int player_get_display_mode(player_h player, player_display_mode_e *mode) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(mode); + player_s * handle = (player_s *) player; + int ret = mm_player_get_attribute(handle->mm_handle, NULL,"display_method" ,mode, (char*)NULL); if(ret != MM_ERROR_NONE) { return __convert_error_code(ret,(char*)__FUNCTION__); } else + { return PLAYER_ERROR_NONE; + } } int player_set_playback_rate(player_h player, float rate) @@ -859,7 +1199,7 @@ int player_set_playback_rate(player_h player, float rate) break; case MM_ERROR_NOT_SUPPORT_API: case MM_ERROR_PLAYER_SEEK: - LOGE("[%s] %s(0x%08x)",__FUNCTION__, PLAYER_ERROR_INVALID_OPERATION,"PLAYER_ERROR_INVALID_OPERATION" ); + LOGE("[%s] PLAYER_ERROR_INVALID_OPERATION(0x%08x) : seek error",__FUNCTION__, PLAYER_ERROR_INVALID_OPERATION); ret = PLAYER_ERROR_INVALID_OPERATION; break; default: @@ -868,6 +1208,7 @@ int player_set_playback_rate(player_h player, float rate) return ret; } + int player_set_x11_display_rotation(player_h player, player_display_rotation_e rotation) { PLAYER_INSTANCE_CHECK(player); @@ -944,13 +1285,13 @@ int player_is_x11_display_visible(player_h player, bool* visible) } } - -int player_set_x11_display_mode(player_h player, player_display_mode_e mode) +int player_set_x11_display_zoom(player_h player, int level) { PLAYER_INSTANCE_CHECK(player); - player_s * handle = (player_s *) player; + PLAYER_CHECK_CONDITION(level>0 && level < 10 ,PLAYER_ERROR_INVALID_PARAMETER,"PLAYER_ERROR_INVALID_PARAMETER" ); - int ret = mm_player_set_attribute(handle->mm_handle, NULL,"display_method" , mode, (char*)NULL); + player_s * handle = (player_s *) player; + int ret = mm_player_set_attribute(handle->mm_handle, NULL,"display_zoom" , level, (char*)NULL); if(ret != MM_ERROR_NONE) { return __convert_error_code(ret,(char*)__FUNCTION__); @@ -959,276 +1300,485 @@ int player_set_x11_display_mode(player_h player, player_display_mode_e mode) return PLAYER_ERROR_NONE; } -int player_get_x11_display_mode(player_h player, player_display_mode_e *mode) +int player_get_x11_display_zoom( player_h player, int *level) { PLAYER_INSTANCE_CHECK(player); - PLAYER_NULL_ARG_CHECK(mode); + PLAYER_NULL_ARG_CHECK(level); player_s * handle = (player_s *) player; - int ret = mm_player_get_attribute(handle->mm_handle, NULL,"display_method" ,mode, (char*)NULL); + int _level; + int ret = mm_player_get_attribute(handle->mm_handle, NULL,"display_zoom" , &_level, (char*)NULL); if(ret != MM_ERROR_NONE) { + *level=-1; return __convert_error_code(ret,(char*)__FUNCTION__); } else { + *level = _level; return PLAYER_ERROR_NONE; } } -int player_set_audio_effect_output(player_h player, sound_device_out_e output) +int player_enable_evas_display_scaling(player_h player, bool enable) { PLAYER_INSTANCE_CHECK(player); player_s * handle = (player_s *) player; - MMAudioFilterOutputMode _mode=MM_AUDIO_FILTER_OUTPUT_SPK; - switch(output) - { - case SOUND_DEVICE_OUT_SPEAKER: - _mode = MM_AUDIO_FILTER_OUTPUT_SPK; - break; - case SOUND_DEVICE_OUT_WIRED_ACCESSORY: - case SOUND_DEVICE_OUT_BT_A2DP: - _mode = MM_AUDIO_FILTER_OUTPUT_EAR; - break; - case SOUND_DEVICE_OUT_BT_SCO: - case SOUND_DEVICE_OUT_RECEIVER: - LOGE("[%s] PLAYER_ERROR_INVALID_OPERATION BT_SCO and RECEIVER doesn't supported( output : %d)" ,__FUNCTION__, output); - return PLAYER_ERROR_INVALID_OPERATION; - } - - MMAudioFilterInfo filter; - memset(&filter, 0, sizeof(MMAudioFilterInfo)); - filter.output_mode = _mode; - int ret = mm_player_apply_sound_filter(handle->mm_handle, &filter); + int scaling = enable?1:0; + int ret = mm_player_set_attribute(handle->mm_handle, NULL,"display_evas_do_scaling" , scaling, (char*)NULL); if(ret != MM_ERROR_NONE) { return __convert_error_code(ret,(char*)__FUNCTION__); } else - { return PLAYER_ERROR_NONE; - } } -int player_set_audio_effect_3d(player_h player, audio_effect_3d_e effect) +int player_get_content_info(player_h player, player_content_info_e key, char ** value) { PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(value); player_s * handle = (player_s *) player; + if (!__player_state_validate(handle, PLAYER_STATE_READY)) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d" ,__FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } - MMAudioFilterInfo filter; - memset(&filter, 0, sizeof(MMAudioFilterInfo)); - filter.filter_type = MM_AUDIO_FILTER_3D; + char* attr=NULL; + char* val=NULL; + int val_len=0; - switch(effect) + switch(key) { - case AUDIO_EFFECT_3D_WIDE: - filter.sound_3d.mode = MM_3DSOUND_WIDE; - break; - case AUDIO_EFFECT_3D_DYNAMIC: - filter.sound_3d.mode = MM_3DSOUND_DYNAMIC; - break; - case AUDIO_EFFECT_3D_SURROUND: - filter.sound_3d.mode = MM_3DSOUND_SURROUND; - break; + 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_apply_sound_filter(handle->mm_handle, &filter); + int ret = mm_player_get_attribute(handle->mm_handle, NULL,attr ,&val, &val_len, (char*)NULL); if(ret != MM_ERROR_NONE) { return __convert_error_code(ret,(char*)__FUNCTION__); } else { + *value = NULL; + if(val!=NULL) + *value = strndup(val,val_len); + else + *value = strndup("",0); + + if (*value == NULL) + { + LOGE("[%s] PLAYER_ERROR_OUT_OF_MEMORY(0x%08x) : fail to strdup ", __FUNCTION__,PLAYER_ERROR_OUT_OF_MEMORY); + return PLAYER_ERROR_OUT_OF_MEMORY; + } return PLAYER_ERROR_NONE; } } -int player_set_audio_effect_equalizer(player_h player, audio_effect_equalizer_e effect) +int player_get_codec_info(player_h player, char **audio_codec, char **video_codec) { PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(audio_codec); + PLAYER_NULL_ARG_CHECK(video_codec); player_s * handle = (player_s *) player; - - MMAudioFilterInfo filter; - memset(&filter, 0, sizeof(MMAudioFilterInfo)); - filter.filter_type = MM_AUDIO_FILTER_EQUALIZER; - - switch(effect) + if (!__player_state_validate(handle, PLAYER_STATE_READY)) { - case AUDIO_EFFECT_EQ_ROCK: - filter.equalizer.mode = MM_EQ_ROCK; - break; - case AUDIO_EFFECT_EQ_JAZZ: - filter.equalizer.mode = MM_EQ_JAZZ; - break; - case AUDIO_EFFECT_EQ_LIVE: - filter.equalizer.mode = MM_EQ_LIVE; - break; - case AUDIO_EFFECT_EQ_CLASSIC: - filter.equalizer.mode = MM_EQ_CLASSIC; - break; - case AUDIO_EFFECT_EQ_FULL_BASS: - filter.equalizer.mode = MM_EQ_FULL_BASS; - break; - case AUDIO_EFFECT_EQ_FULL_BASS_AND_TREBLE: - filter.equalizer.mode = MM_EQ_FULL_BASS_AND_TREBLE; - break; - case AUDIO_EFFECT_EQ_DANCE: - filter.equalizer.mode = MM_EQ_DANCE; - break; - case AUDIO_EFFECT_EQ_POP: - filter.equalizer.mode = MM_EQ_POP; - break; - case AUDIO_EFFECT_EQ_FULL_TREBLE: - filter.equalizer.mode = MM_EQ_FULL_TREBLE; - break; - case AUDIO_EFFECT_EQ_CLUB: - filter.equalizer.mode = MM_EQ_CLUB; - break; - case AUDIO_EFFECT_EQ_PARTY: - filter.equalizer.mode = MM_EQ_PARTY; - break; - case AUDIO_EFFECT_EQ_LARGE_HALL: - filter.equalizer.mode = MM_EQ_LARGE_HALL; - break; - case AUDIO_EFFECT_EQ_SOFT: - filter.equalizer.mode = MM_EQ_SOFT; - break; - case AUDIO_EFFECT_EQ_SOFT_ROCK: - filter.equalizer.mode = MM_EQ_SOFT_ROCK; - break; + 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_apply_sound_filter(handle->mm_handle, &filter); + char* audio=NULL; + int audio_len=0; + char* video=NULL; + int video_len=0; + + int ret = mm_player_get_attribute(handle->mm_handle, NULL,MM_PLAYER_AUDIO_CODEC,&audio,&audio_len,MM_PLAYER_VIDEO_CODEC,&video,&video_len,(char*)NULL); if(ret != MM_ERROR_NONE) { return __convert_error_code(ret,(char*)__FUNCTION__); } else { + *audio_codec = NULL; + if(audio!=NULL) + *audio_codec = strndup(audio,audio_len); + else + *audio_codec = strndup("",0); + + *video_codec = NULL; + if(video!=NULL) + *video_codec = strndup(video,video_len); + else + *video_codec = strndup("",0); + return PLAYER_ERROR_NONE; } } -int player_set_audio_effect_reverb(player_h player, audio_effect_reverb_e effect) +int player_get_audio_stream_info(player_h player, int *sample_rate, int *channel, int *bit_rate) { PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(sample_rate); + PLAYER_NULL_ARG_CHECK(channel); + PLAYER_NULL_ARG_CHECK(bit_rate); player_s * handle = (player_s *) player; + if (!__player_state_validate(handle, PLAYER_STATE_READY)) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d" ,__FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + int ret = mm_player_get_attribute(handle->mm_handle, NULL,MM_PLAYER_AUDIO_SAMPLERATE,sample_rate,MM_PLAYER_AUDIO_CHANNEL,channel,MM_PLAYER_AUDIO_BITRATE,bit_rate,(char*)NULL); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + return PLAYER_ERROR_NONE; +} - MMAudioFilterInfo filter; - memset(&filter, 0, sizeof(MMAudioFilterInfo)); - filter.filter_type = MM_AUDIO_FILTER_REVERB; - - switch(effect) +int player_get_video_stream_info(player_h player, int *fps, int *bit_rate) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(fps); + PLAYER_NULL_ARG_CHECK(bit_rate); + player_s * handle = (player_s *) player; + if (!__player_state_validate(handle, PLAYER_STATE_READY)) { - case AUDIO_EFFECT_REVERB_JAZZ_CLUB: - filter.reverb.mode = MM_REVERB_JAZZ_CLUB; - break; - case AUDIO_EFFECT_REVERB_CONCERT_HALL: - filter.reverb.mode = MM_REVERB_CONCERT_HALL; - break; - case AUDIO_EFFECT_REVERB_STADIUM: - filter.reverb.mode = MM_REVERB_STADIUM; - break; + LOGE("[%s] PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d" ,__FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + int ret = mm_player_get_attribute(handle->mm_handle, NULL,"content_video_fps",fps,"content_video_bitrate",bit_rate,(char*)NULL); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); } + return PLAYER_ERROR_NONE; +} - int ret = mm_player_apply_sound_filter(handle->mm_handle, &filter); +int player_get_video_size (player_h player, int *width, int *height) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(width); + PLAYER_NULL_ARG_CHECK(height); + player_s * handle = (player_s *) player; + if (!__player_state_validate(handle, PLAYER_STATE_READY)) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d" ,__FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + int w; + int h; + int ret = mm_player_get_attribute(handle->mm_handle, NULL,MM_PLAYER_VIDEO_WIDTH ,&w, MM_PLAYER_VIDEO_HEIGHT, &h, (char*)NULL); if(ret != MM_ERROR_NONE) { return __convert_error_code(ret,(char*)__FUNCTION__); } else { + *width = w; + *height = h; + LOGE("[%s] width : %d, height : %d",__FUNCTION__,w, h); return PLAYER_ERROR_NONE; } } -int player_set_audio_effect_extra(player_h player, audio_effect_extra_e effect) +int player_get_album_art(player_h player, void **album_art, int *size) { PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(size); player_s * handle = (player_s *) player; + if (!__player_state_validate(handle, PLAYER_STATE_READY)) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE (0x%08x) : current state - %d" ,__FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } - MMAudioFilterInfo filter; - memset(&filter, 0, sizeof(MMAudioFilterInfo)); - - switch(effect) + int ret = mm_player_get_attribute(handle->mm_handle, NULL,"tag_album_cover",album_art,size,(char*)NULL); + if(ret != MM_ERROR_NONE) { - case AUDIO_EFFECT_EX_BASE: - filter.filter_type = MM_AUDIO_FILTER_BE; - break; - case AUDIO_EFFECT_EX_MUSIC_CLARITY: - filter.filter_type = MM_AUDIO_FILTER_MC; - break; - case AUDIO_EFFECT_EX_SURROUND: - filter.filter_type = MM_AUDIO_FILTER_SRSCSHP; - break; - case AUDIO_EFFECT_EX_SOUND_EXTERNAL: - filter.filter_type = MM_AUDIO_FILTER_SOUND_EX; - break; + return __convert_error_code(ret,(char*)__FUNCTION__); } + return PLAYER_ERROR_NONE; +} - int ret = mm_player_apply_sound_filter(handle->mm_handle, &filter); +int player_audio_effect_set_value(player_h player, audio_effect_e effect, int value) +{ + PLAYER_INSTANCE_CHECK(player); + player_s * handle = (player_s *) player; + int ret = mm_player_sound_filter_custom_set_level(handle->mm_handle,effect,0,value); if(ret != MM_ERROR_NONE) { return __convert_error_code(ret,(char*)__FUNCTION__); } else { + ret = mm_player_sound_filter_custom_apply(handle->mm_handle); + return (ret==MM_ERROR_NONE)?PLAYER_ERROR_NONE:__convert_error_code(ret,(char*)__FUNCTION__); + } +} + +int player_audio_effect_get_value(player_h player, audio_effect_e effect, int *value) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(value); + player_s * handle = (player_s *) player; + int ret = mm_player_sound_filter_custom_get_level(handle->mm_handle,effect,0,value); + if(ret != MM_ERROR_NONE) + return __convert_error_code(ret,(char*)__FUNCTION__); + else return PLAYER_ERROR_NONE; +} + +int player_audio_effect_clear(player_h player, audio_effect_e effect) +{ + PLAYER_INSTANCE_CHECK(player); + player_s * handle = (player_s *) player; + int ret = mm_player_sound_filter_custom_clear_ext_all(handle->mm_handle); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); } + else + { + ret = mm_player_sound_filter_custom_apply(handle->mm_handle); + return (ret==MM_ERROR_NONE)?PLAYER_ERROR_NONE:__convert_error_code(ret,(char*)__FUNCTION__); + } +} + +int player_audio_effect_get_value_range(player_h player, audio_effect_e effect, int* min, int* max) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(min); + PLAYER_NULL_ARG_CHECK(max); + player_s * handle = (player_s *) player; + int ret = mm_player_sound_filter_custom_get_level_range(handle->mm_handle, effect, min, max); + if(ret != MM_ERROR_NONE) + return __convert_error_code(ret,(char*)__FUNCTION__); + else + return PLAYER_ERROR_NONE; +} + +int player_audio_effect_is_available(player_h player, audio_effect_e effect, bool *available) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(available); + player_s * handle = (player_s *) player; + int ret = mm_player_is_supported_custom_filter_type(handle->mm_handle, effect); + if(ret != MM_ERROR_NONE) + *available = FALSE; + else + *available = TRUE; + return PLAYER_ERROR_NONE; +} + +int player_audio_effect_foreach_supported_effect(player_h player, player_audio_effect_supported_effect_cb callback, void *user_data) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(callback); + player_s * handle = (player_s *) player; + + LOGI("[%s] Event type : %d ",__FUNCTION__, _PLAYER_SUPPORTED_AUDIO_EFFECT_TYPE); + handle->user_cb[_PLAYER_SUPPORTED_AUDIO_EFFECT_TYPE] = callback; + handle->user_data[_PLAYER_SUPPORTED_AUDIO_EFFECT_TYPE] = user_data; + int ret = mm_player_get_foreach_present_supported_filter_type(handle->mm_handle, MM_AUDIO_FILTER_TYPE_CUSTOM, __supported_audio_effect_type, (void*)handle); + if(ret != MM_ERROR_NONE) + return __convert_error_code(ret,(char*)__FUNCTION__); + else + return PLAYER_ERROR_NONE; +} + +int player_audio_effect_set_preset(player_h player, audio_effect_preset_e preset) +{ + PLAYER_INSTANCE_CHECK(player); + player_s * handle = (player_s *) player; + int ret = mm_player_sound_filter_preset_apply(handle->mm_handle, preset); + if(ret != MM_ERROR_NONE) + return __convert_error_code(ret,(char*)__FUNCTION__); + else + return PLAYER_ERROR_NONE; +} + +int player_audio_effect_preset_is_available(player_h player, audio_effect_preset_e preset, bool *available) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(available); + player_s * handle = (player_s *) player; + int ret = mm_player_is_supported_preset_filter_type(handle->mm_handle, preset); + if(ret != MM_ERROR_NONE) + *available = FALSE; + else + *available = TRUE; + return PLAYER_ERROR_NONE; +} + +int player_audio_effect_foreach_supported_preset(player_h player, player_audio_effect_supported_preset_cb callback, void *user_data) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(callback); + player_s * handle = (player_s *) player; + + LOGI("[%s] Event type : %d ",__FUNCTION__, _PLAYER_SUPPORTED_AUDIO_EFFECT_PRESET); + handle->user_cb[_PLAYER_SUPPORTED_AUDIO_EFFECT_PRESET] = callback; + handle->user_data[_PLAYER_SUPPORTED_AUDIO_EFFECT_PRESET] = user_data; + int ret = mm_player_get_foreach_present_supported_filter_type(handle->mm_handle, MM_AUDIO_FILTER_TYPE_PRESET, __supported_audio_effect_preset, (void*)handle); + if(ret != MM_ERROR_NONE) + return __convert_error_code(ret,(char*)__FUNCTION__); + else + return PLAYER_ERROR_NONE; +} + +int player_audio_effect_get_equalizer_bands_count (player_h player, int *count) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(count); + player_s * handle = (player_s *) player; + int ret = mm_player_sound_filter_custom_get_eq_bands_number(handle->mm_handle, count); + if(ret != MM_ERROR_NONE) + return __convert_error_code(ret,(char*)__FUNCTION__); + else + return PLAYER_ERROR_NONE; } -int player_clear_audio_effect(player_h player) +int player_audio_effect_set_equalizer_all_bands(player_h player, int *band_levels, int length) { PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(band_levels); player_s * handle = (player_s *) player; - MMAudioFilterInfo filter; - memset(&filter, 0, sizeof(MMAudioFilterInfo)); - filter.filter_type = MM_AUDIO_FILTER_NONE; - int ret = mm_player_apply_sound_filter(handle->mm_handle, &filter); + int ret = mm_player_sound_filter_custom_set_level_eq_from_list(handle->mm_handle, band_levels, length); + if(ret != MM_ERROR_NONE) + return __convert_error_code(ret,(char*)__FUNCTION__); + else + return PLAYER_ERROR_NONE; +} + +int player_audio_effect_set_equalizer_band_level(player_h player, int index, int level) +{ + PLAYER_INSTANCE_CHECK(player); + player_s * handle = (player_s *) player; + int ret = mm_player_sound_filter_custom_set_level(handle->mm_handle,MM_AUDIO_FILTER_CUSTOM_EQ, index, level); if(ret != MM_ERROR_NONE) { return __convert_error_code(ret,(char*)__FUNCTION__); } else { + ret = mm_player_sound_filter_custom_apply(handle->mm_handle); + return (ret==MM_ERROR_NONE)?PLAYER_ERROR_NONE:__convert_error_code(ret,(char*)__FUNCTION__); + } +} + +int player_audio_effect_get_equalizer_band_level(player_h player, int index, int *level) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(level); + player_s * handle = (player_s *) player; + int ret = mm_player_sound_filter_custom_get_level(handle->mm_handle,MM_AUDIO_FILTER_CUSTOM_EQ, index, level); + if(ret != MM_ERROR_NONE) + return __convert_error_code(ret,(char*)__FUNCTION__); + else + return PLAYER_ERROR_NONE; +} + +int player_audio_effect_get_equalizer_level_range(player_h player, int* min, int* max) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(min); + PLAYER_NULL_ARG_CHECK(max); + player_s * handle = (player_s *) player; + int ret = mm_player_sound_filter_custom_get_level_range(handle->mm_handle, MM_AUDIO_FILTER_CUSTOM_EQ, min, max); + if(ret != MM_ERROR_NONE) + return __convert_error_code(ret,(char*)__FUNCTION__); + else + return PLAYER_ERROR_NONE; +} + +int player_audio_effect_equalizer_clear(player_h player) +{ + PLAYER_INSTANCE_CHECK(player); + player_s * handle = (player_s *) player; + int ret = mm_player_sound_filter_custom_clear_eq_all(handle->mm_handle); + if(ret != MM_ERROR_NONE) + return __convert_error_code(ret,(char*)__FUNCTION__); + else return PLAYER_ERROR_NONE; +} + +int player_audio_effect_equalizer_is_available(player_h player, bool *available) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(available); + player_s * handle = (player_s *) player; + int ret = mm_player_is_supported_custom_filter_type(handle->mm_handle, MM_AUDIO_FILTER_CUSTOM_EQ); + if(ret != MM_ERROR_NONE) + *available = FALSE; + else + *available = TRUE; + return PLAYER_ERROR_NONE; +} + +int player_set_subtitle_path(player_h player,const char* path) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(path); + player_s * handle = (player_s *) player; + PLAYER_STATE_CHECK(handle,PLAYER_STATE_IDLE); + + int ret = mm_player_set_attribute(handle->mm_handle, NULL,"subtitle_uri" , path, strlen(path),"subtitle_silent", 0, (char*)NULL); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); } + else + return PLAYER_ERROR_NONE; } -int player_get_video_size (player_h player, int *width, int *height) +int player_set_subtitle_position(player_h player, int millisecond) { PLAYER_INSTANCE_CHECK(player); - PLAYER_NULL_ARG_CHECK(width); - PLAYER_NULL_ARG_CHECK(height); + 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)) + if (!__player_state_validate(handle, PLAYER_STATE_PLAYING)) { - LOGE("[%s] PLAYER_ERROR_INVALID_STATE (current state : %d)" ,__FUNCTION__, handle->state); + 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); + + int ret = mm_player_adjust_subtitle_position(handle->mm_handle, MM_PLAYER_POS_FORMAT_TIME, millisecond); if(ret != MM_ERROR_NONE) { return __convert_error_code(ret,(char*)__FUNCTION__); } else - { - *width = w; - *height = h; return PLAYER_ERROR_NONE; - } } -int player_set_subtitle_path(player_h player, char* path) +int player_set_progressive_download_path(player_h player, const char *path) { PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(path); player_s * handle = (player_s *) player; PLAYER_STATE_CHECK(handle,PLAYER_STATE_IDLE); - int ret = mm_player_set_attribute(handle->mm_handle, NULL,"subtitle_uri" , path, strlen(path),"subtitle_silent", 0, (char*)NULL); + int ret = mm_player_set_attribute(handle->mm_handle, NULL,"pd_mode", MM_PLAYER_PD_MODE_URI, "pd_location", path, strlen(path), (char*)NULL); if(ret != MM_ERROR_NONE) { return __convert_error_code(ret,(char*)__FUNCTION__); @@ -1237,18 +1787,65 @@ int player_set_subtitle_path(player_h player, char* path) return PLAYER_ERROR_NONE; } +int player_get_progressive_download_status(player_h player, unsigned long *current, unsigned long *total_size) +{ + + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(current); + PLAYER_NULL_ARG_CHECK(total_size); + player_s * handle = (player_s *) player; + if (handle->state != PLAYER_STATE_PLAYING && handle->state != PLAYER_STATE_PAUSED) + { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d" ,__FUNCTION__,PLAYER_ERROR_INVALID_STATE, handle->state); + return PLAYER_ERROR_INVALID_STATE; + } + guint64 _current; + guint64 _total; + int ret = mm_player_get_pd_status(handle->mm_handle, &_current, &_total); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + *current = _current; + *total_size = _total; + return PLAYER_ERROR_NONE; + } +} + int player_capture_video(player_h player, player_video_captured_cb callback, void *user_data) { - int ret =__set_callback(_PLAYER_EVENT_TYPE_CAPTURE,player,callback,user_data); - if(ret != PLAYER_ERROR_NONE) - return ret; - + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(callback); + player_s * handle = (player_s *) player; + if(handle->user_cb[_PLAYER_EVENT_TYPE_CAPTURE]) + { + LOGE("[%s] PLAYER_ERROR_VIDEO_CAPTURE_FAILED (0x%08x) : capturing... we can't do any more " ,__FUNCTION__, PLAYER_ERROR_VIDEO_CAPTURE_FAILED); + return PLAYER_ERROR_VIDEO_CAPTURE_FAILED; + } + else + { + LOGI("[%s] Event type : %d ",__FUNCTION__, _PLAYER_EVENT_TYPE_CAPTURE); + handle->user_cb[_PLAYER_EVENT_TYPE_CAPTURE] = callback; + handle->user_data[_PLAYER_EVENT_TYPE_CAPTURE] = user_data; + } + if(handle->state == PLAYER_STATE_PAUSED || handle->state == PLAYER_STATE_PLAYING ) { - ret = mm_player_do_video_capture(handle->mm_handle); + int ret = mm_player_do_video_capture(handle->mm_handle); + if(ret==MM_ERROR_PLAYER_NO_OP) + { + handle->user_cb[_PLAYER_EVENT_TYPE_CAPTURE] = NULL; + handle->user_data[_PLAYER_EVENT_TYPE_CAPTURE] = NULL; + LOGE("[%s] PLAYER_ERROR_INVALID_OPERATION (0x%08x) : video display must be set : %d" ,__FUNCTION__, PLAYER_ERROR_INVALID_OPERATION, handle->display_type); + return PLAYER_ERROR_INVALID_OPERATION; + } if(ret != MM_ERROR_NONE) { + handle->user_cb[_PLAYER_EVENT_TYPE_CAPTURE] = NULL; + handle->user_data[_PLAYER_EVENT_TYPE_CAPTURE] = NULL; return __convert_error_code(ret,(char*)__FUNCTION__); } else @@ -1256,7 +1853,9 @@ int player_capture_video(player_h player, player_video_captured_cb callback, voi } else { - LOGE("[%s] PLAYER_ERROR_INVALID_STATE (current state : %d)" ,__FUNCTION__, handle->state); + 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; } } @@ -1355,18 +1954,18 @@ int player_set_video_frame_decoded_cb(player_h player, player_video_frame_decode player_s * handle = (player_s *) player; if (handle->state != PLAYER_STATE_IDLE && handle->state != PLAYER_STATE_READY) { - LOGE("[%s] PLAYER_ERROR_INVALID_STATE (current state : %d)" ,__FUNCTION__, handle->state); + LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d" ,__FUNCTION__,PLAYER_ERROR_INVALID_STATE, handle->state); return PLAYER_ERROR_INVALID_STATE; } - handle->user_cb[_PLAYER_EVENT_TYPE_VIDEO_FRAME] = callback; - handle->user_data[_PLAYER_EVENT_TYPE_VIDEO_FRAME] = user_data; - LOGI("[%s] Event type : %d ",__FUNCTION__, _PLAYER_EVENT_TYPE_VIDEO_FRAME); int ret = mm_player_set_video_stream_callback(handle->mm_handle, __video_stream_callback, (void*)handle); if(ret != MM_ERROR_NONE) return __convert_error_code(ret,(char*)__FUNCTION__); - else - return PLAYER_ERROR_NONE; + + handle->user_cb[_PLAYER_EVENT_TYPE_VIDEO_FRAME] = callback; + handle->user_data[_PLAYER_EVENT_TYPE_VIDEO_FRAME] = user_data; + LOGI("[%s] Event type : %d ",__FUNCTION__, _PLAYER_EVENT_TYPE_VIDEO_FRAME); + return PLAYER_ERROR_NONE; } int player_unset_video_frame_decoded_cb(player_h player) @@ -1388,44 +1987,79 @@ int player_set_audio_frame_decoded_cb(player_h player, int start, int end, playe PLAYER_INSTANCE_CHECK(player); PLAYER_NULL_ARG_CHECK(callback); PLAYER_CHECK_CONDITION(start>=0 ,PLAYER_ERROR_INVALID_PARAMETER,"PLAYER_ERROR_INVALID_PARAMETER" ); - PLAYER_CHECK_CONDITION(end>=1 ,PLAYER_ERROR_INVALID_PARAMETER,"PLAYER_ERROR_INVALID_PARAMETER" ); - PLAYER_CHECK_CONDITION((end-start)>0 ,PLAYER_ERROR_INVALID_PARAMETER,"PLAYER_ERROR_INVALID_PARAMETER" ); + PLAYER_CHECK_CONDITION(end>=start ,PLAYER_ERROR_INVALID_PARAMETER,"PLAYER_ERROR_INVALID_PARAMETER" ); player_s * handle = (player_s *) player; if (handle->state != PLAYER_STATE_IDLE && handle->state != PLAYER_STATE_READY) { - LOGE("[%s] PLAYER_ERROR_INVALID_STATE (current state : %d)" ,__FUNCTION__, handle->state); + LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d" ,__FUNCTION__,PLAYER_ERROR_INVALID_STATE, handle->state); return PLAYER_ERROR_INVALID_STATE; } + + int ret = mm_player_set_attribute(handle->mm_handle, NULL, "pcm_extraction",TRUE, "pcm_extraction_start_msec", start, "pcm_extraction_end_msec", end, NULL); + if(ret != MM_ERROR_NONE) + return __convert_error_code(ret,(char*)__FUNCTION__); + ret = mm_player_set_audio_stream_callback(handle->mm_handle, __audio_stream_callback, (void*)handle); + if(ret != MM_ERROR_NONE) + return __convert_error_code(ret,(char*)__FUNCTION__); + handle->user_cb[_PLAYER_EVENT_TYPE_AUDIO_FRAME] = callback; handle->user_data[_PLAYER_EVENT_TYPE_AUDIO_FRAME] = user_data; LOGI("[%s] Event type : %d ",__FUNCTION__, _PLAYER_EVENT_TYPE_AUDIO_FRAME); + return PLAYER_ERROR_NONE; +} - int ret = mm_player_set_attribute(handle->mm_handle, NULL, "pcm_extraction",TRUE, "pcm_extraction_start_msec", start, "pcm_extraction_end_msec", end, NULL); +int player_unset_audio_frame_decoded_cb(player_h player) +{ + PLAYER_INSTANCE_CHECK(player); + player_s * handle = (player_s *) player; + + handle->user_cb[_PLAYER_EVENT_TYPE_AUDIO_FRAME] = NULL; + handle->user_data[_PLAYER_EVENT_TYPE_AUDIO_FRAME] = NULL; + LOGI("[%s] Event type : %d ",__FUNCTION__, _PLAYER_EVENT_TYPE_AUDIO_FRAME); + + int ret = mm_player_set_attribute(handle->mm_handle, NULL, "pcm_extraction",FALSE, NULL); if(ret != MM_ERROR_NONE) return __convert_error_code(ret,(char*)__FUNCTION__); - ret = mm_player_set_audio_buffer_callback(handle->mm_handle, __audio_stream_callback, (void*)handle); + ret = mm_player_set_audio_buffer_callback(handle->mm_handle, NULL, NULL); if(ret != MM_ERROR_NONE) return __convert_error_code(ret,(char*)__FUNCTION__); else return PLAYER_ERROR_NONE; } -int player_unset_audio_frame_decoded_cb(player_h 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); 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_attribute(handle->mm_handle, NULL, "pcm_extraction",FALSE, NULL); + int ret = mm_player_set_pd_message_callback(handle->mm_handle, __pd_message_callback, (void*)handle); if(ret != MM_ERROR_NONE) return __convert_error_code(ret,(char*)__FUNCTION__); - - handle->user_cb[_PLAYER_EVENT_TYPE_AUDIO_FRAME] = NULL; - handle->user_data[_PLAYER_EVENT_TYPE_AUDIO_FRAME] = NULL; - LOGI("[%s] Event type : %d ",__FUNCTION__, _PLAYER_EVENT_TYPE_AUDIO_FRAME); - ret = mm_player_set_audio_buffer_callback(handle->mm_handle, NULL, NULL); + handle->user_cb[_PLAYER_EVENT_TYPE_PD] = callback; + handle->user_data[_PLAYER_EVENT_TYPE_PD] = user_data; + LOGI("[%s] Event type : %d ",__FUNCTION__, _PLAYER_EVENT_TYPE_PD); + return PLAYER_ERROR_NONE; +} + +int player_unset_progressive_download_message_cb(player_h player) +{ + PLAYER_INSTANCE_CHECK(player); + player_s * handle = (player_s *) player; + + handle->user_cb[_PLAYER_EVENT_TYPE_PD] = NULL; + handle->user_data[_PLAYER_EVENT_TYPE_PD] = NULL; + LOGI("[%s] Event type : %d ",__FUNCTION__, _PLAYER_EVENT_TYPE_PD); + + int ret = mm_player_set_pd_message_callback(handle->mm_handle, NULL, NULL); if(ret != MM_ERROR_NONE) return __convert_error_code(ret,(char*)__FUNCTION__); else diff --git a/test/player_test.c b/test/player_test.c index aa272b6..5fe2082 100644 --- a/test/player_test.c +++ b/test/player_test.c @@ -127,7 +127,10 @@ 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) { @@ -296,7 +299,7 @@ static void get_position() static void set_position(int position) { - if ( player_set_position(g_player, position) != PLAYER_ERROR_NONE ) + if ( player_set_position(g_player, position, seek_completed_cb, g_player) != PLAYER_ERROR_NONE ) { g_print("failed to set position\n"); } @@ -304,7 +307,7 @@ static void set_position(int position) static void set_position_ratio(int percent) { - if ( player_set_position_ratio(g_player, percent) != PLAYER_ERROR_NONE ) + if ( player_set_position_ratio(g_player, percent, seek_completed_cb, g_player) != PLAYER_ERROR_NONE ) { g_print("failed to set position ratio\n"); } @@ -319,10 +322,48 @@ static void get_duration() g_print(" ==> [Player_Test] Duration: [%d ] msec\n",duration); } -static void get_video_size() +static void get_stream_info() { int w = 0; int h = 0; + char *value = NULL; + player_get_content_info(g_player, PLAYER_CONTENT_INFO_ALBUM, &value); + g_print(" ==> [Player_Test] PLAYER_CONTENT_INFO_ALBUM: [%s ] \n",value); + player_get_content_info(g_player, PLAYER_CONTENT_INFO_ARTIST, &value); + g_print(" ==> [Player_Test] PLAYER_CONTENT_INFO_ARTIST: [%s ] \n",value); + player_get_content_info(g_player, PLAYER_CONTENT_INFO_AUTHOR, &value); + g_print(" ==> [Player_Test] PLAYER_CONTENT_INFO_AUTHOR: [%s ] \n",value); + player_get_content_info(g_player, PLAYER_CONTENT_INFO_GENRE, &value); + g_print(" ==> [Player_Test] PLAYER_CONTENT_INFO_GENRE: [%s ] \n",value); + player_get_content_info(g_player, PLAYER_CONTENT_INFO_TITLE, &value); + g_print(" ==> [Player_Test] PLAYER_CONTENT_INFO_TITLE: [%s ] \n",value); + if(value!=NULL) + { + free(value); + value = NULL; + } + + int sample_rate; + int channel; + int bit_rate; + player_get_audio_stream_info(g_player, &sample_rate, &channel, &bit_rate); + g_print(" ==> [Player_Test] Sample Rate: [%d ] , Channel: [%d ] , Bit Rate: [%d ] \n",sample_rate,channel,bit_rate); + + char *audio_codec = NULL; + char *video_codec = NULL; + player_get_codec_info(g_player, &audio_codec, &video_codec); + if(audio_codec!=NULL) + { + g_print(" ==> [Player_Test] Audio Codec: [%s ] \n",audio_codec); + free(audio_codec); + audio_codec = NULL; + } + if(video_codec!=NULL) + { + g_print(" ==> [Player_Test] Video Codec: [%s ] \n",video_codec); + free(video_codec); + video_codec = NULL; + } player_get_video_size(g_player, &w, &h); g_print(" ==> [Player_Test] Width: [%d ] , Height: [%d ] \n",w,h); } @@ -343,17 +384,17 @@ static void get_looping(bool *looping) static void set_display_mode(int mode) { - if ( player_set_x11_display_mode(g_player, mode) != PLAYER_ERROR_NONE ) + if ( player_set_display_mode(g_player, mode) != PLAYER_ERROR_NONE ) { - g_print("failed to player_set_x11_display_mode\n"); + g_print("failed to player_set_display_mode\n"); } } static void get_display_mode() { player_display_mode_e mode; - player_get_x11_display_mode(g_player, &mode); - g_print(" ==> [Player_Test] X11 Display mode: [%d ] \n",mode); + player_get_display_mode(g_player, &mode); + g_print(" ==> [Player_Test] Display mode: [%d ] \n",mode); } static void set_display_rotation(int rotation) @@ -520,7 +561,7 @@ void _interpret_main_menu(char *cmd) } else if (strncmp(cmd, "n", 1) == 0 ) { - get_video_size(); + get_stream_info(); } else if (strncmp(cmd, "o", 1) == 0 ) { @@ -609,7 +650,7 @@ void display_sub_basic() g_print("k. Set Position (%%)\t"); g_print("l. Get Position\n"); g_print("[duration] m. Get Duration\n"); - g_print("[video size] n. Get Video Size\n"); + g_print("[Stream Info] n. Get stream info (Video Size, codec, audio stream info, and tag info)\n"); g_print("[Looping] o. Set Looping\t"); g_print("p. Get Looping\n"); g_print("[x display] r. Set display mode\t");