From 628b6b0c4ca5739e9c59dc57c77eec42546659e0 Mon Sep 17 00:00:00 2001 From: Hyongtaek Lim Date: Thu, 10 Sep 2015 22:33:52 +0900 Subject: [PATCH] Add callback of video bin created Signed-off-by: Hyongtaek Lim Change-Id: I9d060aa640f82ce98dca4141bada0b39999eeef7 --- include/mobile/player_internal.h | 2 +- include/player_private.h | 40 ++++++++++++++++++++++++++++++++++ include/wearable/player_internal.h | 2 +- src/player.c | 11 ++++++++++ src/player_internal.c | 25 +++++++++++++++++++++ test/legacy_player_media_packet_test.c | 2 +- test/legacy_player_test.c | 4 ++-- 7 files changed, 81 insertions(+), 5 deletions(-) diff --git a/include/mobile/player_internal.h b/include/mobile/player_internal.h index c724bd0..244f46e 100644 --- a/include/mobile/player_internal.h +++ b/include/mobile/player_internal.h @@ -43,7 +43,7 @@ typedef struct int rate; /**< Samplerate */ int depth; /**< Depth */ bool little_endian; /**< Endianness */ - guint64 channel_mask; /**< channel_mask */ + guint64 channel_mask; /**< channel_mask */ } player_audio_raw_data_s; /** diff --git a/include/player_private.h b/include/player_private.h index eee43ac..d83991d 100644 --- a/include/player_private.h +++ b/include/player_private.h @@ -86,6 +86,7 @@ typedef enum { _PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK, _PLAYER_EVENT_TYPE_AUDIO_STREAM_CHANGED, _PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED, + _PLAYER_EVENT_TYPE_VIDEO_BIN_CREATED, _PLAYER_EVENT_TYPE_NUM }_player_event_e; @@ -133,6 +134,45 @@ typedef struct _player_s{ int __player_convert_error_code(int code, char* func_name); bool __player_state_validate(player_s * handle, player_state_e threshold); +/** + * @brief Called when the video sink bin is crated. + * @since_tizen 3.0 + * @param[out] caps video sink current caps + * @param[out ] user_data The user data passed from the callback registration function + * @see player_set_vidoe_bin_created_cb() + * @see player_unset_vidoe_bin_created_cb() + */ +typedef void (*player_video_bin_created_cb)(const char *caps, void *user_data); + +/** + * @brief Registers a callback function to be invoked when video sink bin is created. + * @since_tizen 3.0 + * @param[in] player The handle to the media player + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return @c 0 on success, + * otherwise a negative error value + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @post player_video_bin_created_cb() will be invoked. + * @see player_unset_vidoe_bin_created_cb() + */ +int player_set_video_bin_created_cb(player_h player, player_video_bin_created_cb callback, void *user_data); + +/** + * @brief Unregisters a callback function to be invoked when video sink bin is created. + * @since_tizen 3.0 + * @param[in] player The handle to the media player + * @return @c 0 on success, + * otherwise a negative error value + * @retval #PLAYER_ERROR_NONE Successful + * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter + * @post player_video_bin_created_cb() will be invoked. + * @see player_unset_vidoe_bin_created_cb() + */ +int player_unset_video_bin_created_cb(player_h player); + + #ifdef __cplusplus } #endif diff --git a/include/wearable/player_internal.h b/include/wearable/player_internal.h index 31e4c17..54fb92b 100644 --- a/include/wearable/player_internal.h +++ b/include/wearable/player_internal.h @@ -43,7 +43,7 @@ typedef struct int rate; /**< Samplerate */ int depth; /**< Depth */ bool little_endian; /**< Endianness */ - guint64 channel_mask; /**< channel_mask */ + guint64 channel_mask; /**< channel_mask */ } player_audio_raw_data_s; /** diff --git a/src/player.c b/src/player.c index e5a135b..1653ec6 100644 --- a/src/player.c +++ b/src/player.c @@ -824,6 +824,17 @@ static int __msg_callback(int message, void *param, void *user_data) #endif } break; + case MM_MESSAGE_VIDEO_BIN_CREATED: + if( handle->user_cb[_PLAYER_EVENT_TYPE_VIDEO_BIN_CREATED]) + { + char *caps = (char *)msg->data; + if(caps) + ((player_video_bin_created_cb) + handle->user_cb[_PLAYER_EVENT_TYPE_VIDEO_BIN_CREATED])( + caps, handle->user_data[_PLAYER_EVENT_TYPE_VIDEO_BIN_CREATED]); + g_free(caps); + } + break; case MM_MESSAGE_UNKNOWN: //0x00 case MM_MESSAGE_WARNING: //0x02 case MM_MESSAGE_CONNECTING: //0x100 diff --git a/src/player_internal.c b/src/player_internal.c index 94b27d0..2eb7e36 100644 --- a/src/player_internal.c +++ b/src/player_internal.c @@ -422,3 +422,28 @@ int player_get_raw_video_caps(player_h player, char **caps) return PLAYER_ERROR_NONE; } + +int player_set_video_bin_created_cb(player_h player, player_video_bin_created_cb callback, void *user_data) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(callback); + int type = _PLAYER_EVENT_TYPE_VIDEO_BIN_CREATED; + + player_s * handle = (player_s *) player; + handle->user_cb[type] = callback; + handle->user_data[type] = user_data; + LOGI("[%s] Event type : %d ",__FUNCTION__, type); + return PLAYER_ERROR_NONE; +} + +int player_unset_video_bin_created_cb(player_h player) +{ + PLAYER_INSTANCE_CHECK(player); + player_s * handle = (player_s *) player; + int type = _PLAYER_EVENT_TYPE_VIDEO_BIN_CREATED; + + handle->user_cb[type] = NULL; + handle->user_data[type] = NULL; + LOGI("[%s] Event type : %d ",__FUNCTION__, type); + return PLAYER_ERROR_NONE; +} diff --git a/test/legacy_player_media_packet_test.c b/test/legacy_player_media_packet_test.c index 8134a67..9a72afd 100644 --- a/test/legacy_player_media_packet_test.c +++ b/test/legacy_player_media_packet_test.c @@ -22,7 +22,7 @@ #include #define KEY_END "XF86Stop" -#define MEDIA_FILE_PATH "/opt/usr/media/Color.mp4" +#define MEDIA_FILE_PATH "/home/owner/content/Color.mp4" #ifdef PACKAGE #undef PACKAGE #endif diff --git a/test/legacy_player_test.c b/test/legacy_player_test.c index 925fd68..b1bf9f6 100644 --- a/test/legacy_player_test.c +++ b/test/legacy_player_test.c @@ -35,7 +35,7 @@ #define PACKAGE "player_test" #define MAX_STRING_LEN 2048 #define MMTS_SAMPLELIST_INI_DEFAULT_PATH "/opt/etc/mmts_filelist.ini" -#define PLAYER_TEST_DUMP_PATH_PREFIX "/opt/usr/media/dump_pcm_" +#define PLAYER_TEST_DUMP_PATH_PREFIX "/home/owner/content/dump_pcm_" #define INI_SAMPLE_LIST_MAX 9 #define DEFAULT_HTTP_TIMEOUT -1 @@ -987,7 +987,7 @@ static void _player_state() static void _player_set_progressive_download() { - player_set_progressive_download_path(g_player[0], "/opt/test.pd"); + player_set_progressive_download_path(g_player[0], "/home/owner/test.pd"); player_set_progressive_download_message_cb(g_player[0], progress_down_cb, (void*)g_player[0]); } -- 2.7.4