From: Sangchul Lee Date: Tue, 30 Jul 2013 15:17:20 +0000 (+0900) Subject: Add player_set_x11_display_roi()/player_get_x11_display_roi() APIs X-Git-Tag: accepted/tizen/20131011.081245~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=06b5bdf2a7cb0ce398b8b1b6e7da1ae66be2db72;p=platform%2Fcore%2Fapi%2Fplayer.git Add player_set_x11_display_roi()/player_get_x11_display_roi() APIs Change-Id: Ibbd07d2916d85254e7e38cf0434b00ce5e77f815 --- diff --git a/include/player.h b/include/player.h index 7ac8502..4458a8a 100644 --- a/include/player.h +++ b/include/player.h @@ -166,6 +166,7 @@ typedef enum PLAYER_DISPLAY_MODE_FULL_SCREEN, /**< full-screen*/ PLAYER_DISPLAY_MODE_CROPPED_FULL, /**< Cropped full-screen*/ PLAYER_DISPLAY_MODE_ORIGIN_OR_LETTER, /**< Origin size (if surface size is larger than video size(width/height)) or Letter box (if video size(width/height) is larger than surface size)*/ + PLAYER_DISPLAY_MODE_ROI, /**< ROI mode*/ } player_display_mode_e; @@ -1085,6 +1086,40 @@ int player_set_x11_display_pixmap (player_h player, player_x11_pixmap_updated_cb int player_set_x11_display_pixmap_error_cb (player_h player, player_x11_pixmap_error_cb callback, void *user_data); /** + * @brief Sets information of ROI + * @remarks If current display mode is not #PLAYER_DISPLAY_MODE_ROI, #PLAYER_ERROR_INVALID_OPERATION will be returned. + * @param[in] player The handle to media player + * @param[in] x The x coordinate of ROI + * @param[in] y The y coordinate of ROI + * @param[in] w The width of ROI + * @param[in] h The height of ROI + * @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 + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @see player_get_x11_display_roi() + */ +int player_set_x11_display_roi (player_h player, int x, int y, int w, int h); + +/** + * @brief Gets information of ROI + * @remarks If current display mode is not #PLAYER_DISPLAY_MODE_ROI, #PLAYER_ERROR_INVALID_OPERATION will be returned. + * @param[in] player The handle to media player + * @param[out] x The x coordinate of ROI + * @param[out] y The y coordinate of ROI + * @param[out] w The width of ROI + * @param[out] h The height of ROI + * @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 + * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation + * @see player_set_x11_display_roi() + */ +int player_get_x11_display_roi (player_h player, int *x, int *y, int *w, int *h); + +/** * @} */ diff --git a/packaging/capi-media-player.spec b/packaging/capi-media-player.spec index bb8557a..d62ff34 100644 --- a/packaging/capi-media-player.spec +++ b/packaging/capi-media-player.spec @@ -1,7 +1,7 @@ Name: capi-media-player Summary: A Media Player library in Tizen Native API -Version: 0.1.0 -Release: 60 +Version: 0.1.1 +Release: 0 Group: TO_BE/FILLED_IN License: TO BE FILLED IN Source0: %{name}-%{version}.tar.gz diff --git a/src/player.c b/src/player.c index 3b0aa4d..97036c0 100644 --- a/src/player.c +++ b/src/player.c @@ -1617,6 +1617,91 @@ int player_set_x11_display_pixmap_error_cb (player_h player, player_x11_pixmap_e } } +int player_set_x11_display_roi (player_h player, int x, int y, int w, int h) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_CHECK_CONDITION(x >= 0 && y >= 0 && w >= 0 && h >= 0,PLAYER_ERROR_INVALID_PARAMETER,"PLAYER_ERROR_INVALID_PARAMETER" ); + + player_display_mode_e 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__); + } + if (mode != PLAYER_DISPLAY_MODE_ROI) + { + ret = MM_ERROR_PLAYER_INTERNAL; + return __convert_error_code(ret,(char*)__FUNCTION__); + } + + ret = mm_player_set_attribute(handle->mm_handle, NULL, + "display_roi_x", x, + "display_roi_y", y, + "display_roi_width", w, + "display_roi_height", h, + (char*)NULL); + if(ret != MM_ERROR_NONE) + { + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + return PLAYER_ERROR_NONE; + } +} + +int player_get_x11_display_roi (player_h player, int *x, int *y, int *w, int *h) +{ + PLAYER_INSTANCE_CHECK(player); + PLAYER_NULL_ARG_CHECK(x); + PLAYER_NULL_ARG_CHECK(y); + PLAYER_NULL_ARG_CHECK(w); + PLAYER_NULL_ARG_CHECK(h); + + player_display_mode_e mode; + player_s * handle = (player_s *) player; + int _x = 0; + int _y = 0; + int _w = 0; + int _h = 0; + + 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__); + } + if (mode != PLAYER_DISPLAY_MODE_ROI) + { + ret = MM_ERROR_PLAYER_INTERNAL; + return __convert_error_code(ret,(char*)__FUNCTION__); + } + + ret = mm_player_get_attribute(handle->mm_handle, NULL, + "display_roi_x", &_x, + "display_roi_y", &_y, + "display_roi_width", &_w, + "display_roi_height", &_h, + (char*)NULL); + if(ret != MM_ERROR_NONE) + { + *x = _x = 0; + *y = _y = 0; + *w = _w = 0; + *h = _h = 0; + return __convert_error_code(ret,(char*)__FUNCTION__); + } + else + { + *x = _x; + *y = _y; + *w = _w; + *h = _h; + return PLAYER_ERROR_NONE; + } +} + int player_enable_evas_display_scaling(player_h player, bool enable) { PLAYER_INSTANCE_CHECK(player); diff --git a/test/player_test.c b/test/player_test.c index c5611e7..d4d28db 100644 --- a/test/player_test.c +++ b/test/player_test.c @@ -42,6 +42,7 @@ enum CURRENT_STATUS_DISPLAY_MODE, CURRENT_STATUS_DISPLAY_ROTATION, CURRENT_STATUS_DISPLAY_VISIBLE, + CURRENT_STATUS_DISPLAY_ROI, CURRENT_STATUS_SUBTITLE_FILENAME }; @@ -473,6 +474,30 @@ static void get_display_visible(bool *visible) g_print(" ==> [Player_Test] X11 Display Visible = %d\n", *visible); } +static void set_display_roi(int x, int y, int w, int h) +{ + if ( player_set_x11_display_roi(g_player, x, y, w, h) != PLAYER_ERROR_NONE ) + { + g_print("failed to player_set_x11_display_roi\n"); + } else { + g_print(" ==> [Player_Test] set X11 Display ROI (x:%d, y:%d, w:%d, h:%d)\n", x, y, w, h); + } +} + +static void get_display_roi() +{ + int x = 0; + int y = 0; + int w = 0; + int h = 0; + if ( player_get_x11_display_roi(g_player, &x, &y, &w, &h) != PLAYER_ERROR_NONE ) + { + g_print("failed to player_get_x11_display_roi\n"); + } else { + g_print(" ==> [Player_Test] got X11 Display ROI (x:%d, y:%d, w:%d, h:%d)\n", x, y, w, h); + } +} + static void input_subtitle_filename(char *subtitle_filename) { int len = strlen(subtitle_filename); @@ -664,9 +689,17 @@ void _interpret_main_menu(char *cmd) bool visible; get_display_visible(&visible); } + else if (strncmp(cmd, "x", 1) == 0 ) + { + g_menu_state = CURRENT_STATUS_DISPLAY_ROI; + } + else if (strncmp(cmd, "y", 1) == 0 ) + { + get_display_roi(); + } else if (strncmp(cmd, "A", 1) == 0 ) { - g_menu_state=CURRENT_STATUS_SUBTITLE_FILENAME; + g_menu_state = CURRENT_STATUS_SUBTITLE_FILENAME; } else if (strncmp(cmd, "C", 1) == 0 ) { @@ -764,7 +797,9 @@ void display_sub_basic() g_print("t. Set display Rotation\t"); g_print("u. Get display Rotation\n"); g_print("[x display] v. Set display visible\t"); - g_print("w. Get display visible\n"); + g_print("w. Get display visible\t"); + g_print("x. Set ROI\t"); + g_print("y. Get ROI\n"); g_print("[subtitle] A. Set subtitle path\n"); g_print("[Video Capture] C. Capture \n"); g_print("[Audio Frame Decode] D. Decoding Audio Frame E. Decoding Video Frame \n"); @@ -816,6 +851,10 @@ static void displaymenu() { g_print("*** input display visible value.(0: HIDE, 1: SHOW) \n"); } + else if (g_menu_state == CURRENT_STATUS_DISPLAY_ROI) + { + g_print("*** input display roi value sequencially.(x, y, w, h)\n"); + } else if (g_menu_state == CURRENT_STATUS_SUBTITLE_FILENAME) { g_print(" *** input subtitle file path.\n"); @@ -923,6 +962,39 @@ static void interpret (char *cmd) reset_menu_state(); } break; + case CURRENT_STATUS_DISPLAY_ROI: + { + int value = atoi(cmd); + static int roi_x = 0; + static int roi_y = 0; + static int roi_w = 0; + static int roi_h = 0; + static int cnt = 0; + switch (cnt) { + case 0: + roi_x = value; + cnt++; + break; + case 1: + roi_y = value; + cnt++; + break; + case 2: + roi_w = value; + cnt++; + break; + case 3: + cnt = 0; + roi_h = value; + set_display_roi(roi_x, roi_y, roi_w, roi_h); + roi_x = roi_y = roi_w = roi_h = 0; + reset_menu_state(); + break; + default: + break; + } + } + break; case CURRENT_STATUS_SUBTITLE_FILENAME: { input_subtitle_filename(cmd);