From: Hyunil Date: Thu, 30 Aug 2018 08:25:32 +0000 (+0900) Subject: [VPR-306/ACR-1275] Add new API to set/get the video roi area X-Git-Tag: submit/tizen/20180904.110532~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4f386f514fc88cd56e44aa7ac4e0c5c6a870f464;p=platform%2Fcore%2Fmultimedia%2Flibmm-player.git [VPR-306/ACR-1275] Add new API to set/get the video roi area Change-Id: I0fee5750b259e2c66f87f92211ff7d72964ceef1 Signed-off-by: Hyunil --- diff --git a/src/include/mm_player.h b/src/include/mm_player.h index 5ee8484..b941138 100644 --- a/src/include/mm_player.h +++ b/src/include/mm_player.h @@ -1643,6 +1643,13 @@ int mm_player_set_codec_type(MMHandleType player, MMPlayerStreamType stream_type */ int mm_player_set_replaygain_enabled(MMHandleType player, bool enabled); int mm_player_is_replaygain_enabled(MMHandleType player, bool *enabled); + +/** + * This function is to set/get video content ROI area + */ +int mm_player_set_video_roi_area(MMHandleType player, double scale_x, double scale_y, double scale_width, double scale_height); +int mm_player_get_video_roi_area(MMHandleType player, double *scale_x, double *scale_y, double *scale_width, double *scale_height); + /** @} */ diff --git a/src/include/mm_player_priv.h b/src/include/mm_player_priv.h index 54299e6..bd017c6 100644 --- a/src/include/mm_player_priv.h +++ b/src/include/mm_player_priv.h @@ -465,6 +465,14 @@ typedef struct { GList *uri_list; } MMPlayerUriList; +typedef struct { + bool is_set; + double scale_x; + double scale_y; + double scale_width; + double scale_height; +} MMPlayerVideoROI; + typedef struct { gint active_pad_index; gint total_track_num; @@ -848,6 +856,8 @@ typedef struct { int video360_horizontal_fov; int video360_vertical_fov; + /* Video ROI area scale value */ + MMPlayerVideoROI video_roi; } mm_player_t; typedef struct { @@ -942,6 +952,8 @@ int _mmplayer_get_streaming_buffering_time(MMHandleType hplayer, int *buffer_ms, int _mmplayer_set_codec_type(MMHandleType hplayer, MMPlayerStreamType stream_type, MMPlayerVideoCodecType codec_type); int _mmplayer_set_replaygain_enabled(MMHandleType hplayer, bool enabled); int _mmplayer_is_replaygain_enabled(MMHandleType hplayer, bool *enabled); +int _mmplayer_set_video_roi_area(MMHandleType hplayer, double scale_x, double scale_y, double scale_width, double scale_height); +int _mmplayer_get_video_roi_area(MMHandleType hplayer, double *scale_x, double *scale_y, double *scale_width, double *scale_height); /* internal */ void __mmplayer_bus_msg_thread_destroy(MMHandleType hplayer); diff --git a/src/mm_player.c b/src/mm_player.c index 6cbea96..f06bc4c 100644 --- a/src/mm_player.c +++ b/src/mm_player.c @@ -1467,3 +1467,33 @@ int mm_player_is_replaygain_enabled(MMHandleType player, bool *enabled) return result; } + +int mm_player_set_video_roi_area(MMHandleType player, double scale_x, double scale_y, double scale_width, double scale_height) +{ + int result = MM_ERROR_NONE; + + MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); + + MMPLAYER_CMD_LOCK(player); + + result = _mmplayer_set_video_roi_area(player, scale_x, scale_y, scale_width, scale_height); + + MMPLAYER_CMD_UNLOCK(player); + + return result; +} + +int mm_player_get_video_roi_area(MMHandleType player, double *scale_x, double *scale_y, double *scale_width, double *scale_height) +{ + int result = MM_ERROR_NONE; + + MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); + + MMPLAYER_CMD_LOCK(player); + + result = _mmplayer_get_video_roi_area(player, scale_x, scale_y, scale_width, scale_height); + + MMPLAYER_CMD_UNLOCK(player); + + return result; +} diff --git a/src/mm_player_priv.c b/src/mm_player_priv.c index 8ec62a0..6c52dd2 100644 --- a/src/mm_player_priv.c +++ b/src/mm_player_priv.c @@ -2526,6 +2526,33 @@ __mmplayer_video_param_set_display_method(mm_player_t* player) g_object_set(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "display-geometry-method", display_method, NULL); LOGD("set video param : method %d", display_method); } +void +__mmplayer_video_param_set_video_roi_area(mm_player_t* player) +{ + MMHandleType attrs = 0; + void *handle = NULL; + MMPLAYER_FENTER(); + + if (!player->video_roi.is_set) { + LOGE("Video content ROI is not set"); + return; + } + + /* check video sinkbin is created */ + if (MM_ERROR_NONE != __mmplayer_video_param_check_video_sink_bin(player)) + return; + + attrs = MMPLAYER_GET_ATTRS(player); + MMPLAYER_RETURN_IF_FAIL(attrs); + mm_attrs_get_data_by_name(attrs, "display_overlay", &handle); + if (handle) { + gst_video_overlay_set_video_roi_area( + GST_VIDEO_OVERLAY(player->pipeline->videobin[MMPLAYER_V_SINK].gst), + player->video_roi.scale_x, player->video_roi.scale_y, player->video_roi.scale_width, player->video_roi.scale_height); + LOGD("set video param : video roi area scale value: x(%f) y(%f) width(%f) height(%f)", + player->video_roi.scale_x, player->video_roi.scale_y, player->video_roi.scale_width, player->video_roi.scale_height); + } +} void __mmplayer_video_param_set_roi_area(mm_player_t* player) @@ -2623,6 +2650,8 @@ __mmplayer_update_wayland_videosink_video_param(mm_player_t* player, char *param __mmplayer_video_param_set_display_rotation(player); if (update_all_param || !g_strcmp0(param_name, "display_win_roi_x")) __mmplayer_video_param_set_roi_area(player); + if (update_all_param) + __mmplayer_video_param_set_video_roi_area(player); return MM_ERROR_NONE; } @@ -10333,3 +10362,77 @@ _mmplayer_is_replaygain_enabled(MMHandleType hplayer, bool *enabled) return MM_ERROR_NONE; } + +int +_mmplayer_set_video_roi_area(MMHandleType hplayer, double scale_x, double scale_y, double scale_width, double scale_height) +{ + mm_player_t* player = (mm_player_t*) hplayer; + MMHandleType attrs = 0; + void *handle = NULL; + int ret = MM_ERROR_NONE; + + MMPLAYER_FENTER(); + + MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); + + /* check video sinkbin is created */ + if (ret != __mmplayer_video_param_check_video_sink_bin(player)) + return ret; + + attrs = MMPLAYER_GET_ATTRS(player); + MMPLAYER_RETURN_VAL_IF_FAIL(attrs, MM_ERROR_PLAYER_INTERNAL); + + mm_attrs_get_data_by_name(attrs, "display_overlay", &handle); + + if (!handle) { + LOGE("Display handle is NULL, after setting window handle, set video roi area"); + return MM_ERROR_PLAYER_INTERNAL; + } + + player->video_roi.scale_x = scale_x; + player->video_roi.scale_y = scale_y; + player->video_roi.scale_width = scale_width; + player->video_roi.scale_height = scale_height; + + player->video_roi.is_set = gst_video_overlay_set_video_roi_area( + GST_VIDEO_OVERLAY(player->pipeline->videobin[MMPLAYER_V_SINK].gst), + scale_x, scale_y, scale_width, scale_height); + + if (player->video_roi.is_set) { + LOGD("set video param : video roi area scale value: x(%f) y(%f) width(%f) height(%f)", + scale_x, scale_y, scale_width, scale_height); + } + + return ret; +} + +int +_mmplayer_get_video_roi_area(MMHandleType hplayer, double *scale_x, double *scale_y, double *scale_width, double *scale_height) +{ + mm_player_t* player = (mm_player_t*) hplayer; + int ret = MM_ERROR_NONE; + + MMPLAYER_FENTER(); + + MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); + MMPLAYER_RETURN_VAL_IF_FAIL(scale_x && scale_y && scale_width && scale_height, MM_ERROR_INVALID_ARGUMENT); + + /* check video sinkbin is created */ + if (ret != __mmplayer_video_param_check_video_sink_bin(player)) + return ret; + + if (player->video_roi.is_set) { + *scale_x = player->video_roi.scale_x; + *scale_y = player->video_roi.scale_y; + *scale_width = player->video_roi.scale_width; + *scale_height = player->video_roi.scale_height; + } else { + LOGE("Video content ROI is not set"); + *scale_x = 0.0; + *scale_y = 0.0; + *scale_width = 1.0; + *scale_height = 1.0; + } + + return ret; +}