From: Eunhae Choi Date: Tue, 19 Dec 2017 03:01:49 +0000 (+0900) Subject: [0.6.85] support video codec selection by api X-Git-Tag: accepted/tizen/4.0/unified/20171226.073634^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d63166a6dad9359e3a9beaccc0e2968969d10938;p=platform%2Fcore%2Fmultimedia%2Flibmm-player.git [0.6.85] support video codec selection by api - can fix the video codec type among the sw, hw and default. - in case of 'default', the higher priority video codec will be selected as before. Change-Id: Ie9fb2242e47c58c937b835db94ebdc6bb6a62e01 --- diff --git a/packaging/libmm-player.spec b/packaging/libmm-player.spec index 3a1cab3..c89b2b3 100644 --- a/packaging/libmm-player.spec +++ b/packaging/libmm-player.spec @@ -1,6 +1,6 @@ Name: libmm-player Summary: Multimedia Framework Player Library -Version: 0.6.84 +Version: 0.6.85 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 diff --git a/src/include/mm_player.h b/src/include/mm_player.h index 0dc0a7f..ee1fd6b 100644 --- a/src/include/mm_player.h +++ b/src/include/mm_player.h @@ -420,7 +420,7 @@ * uri to play (string) * */ -#define MM_PLAYER_CONTENT_URI "profile_uri" +#define MM_PLAYER_CONTENT_URI "profile_uri" /** * MM_PLAYER_CONTENT_DURATION: * @@ -428,14 +428,14 @@ * receiving MM_MESSAGE_BEGIN_OF_STREAM. * */ -#define MM_PLAYER_CONTENT_DURATION "content_duration" +#define MM_PLAYER_CONTENT_DURATION "content_duration" /** * MM_PLAYER_VIDEO_ROTATION * * can change video angle (int) * @see MMDisplayRotationType */ -#define MM_PLAYER_VIDEO_ROTATION "display_rotation" +#define MM_PLAYER_VIDEO_ROTATION "display_rotation" /** * MM_PLAYER_VIDEO_WIDTH: * @@ -443,7 +443,7 @@ * receiving MM_MESSAGE_BEGIN_OF_STREAM. * */ -#define MM_PLAYER_VIDEO_WIDTH "content_video_width" +#define MM_PLAYER_VIDEO_WIDTH "content_video_width" /** * MM_PLAYER_VIDEO_HEIGHT: * @@ -451,7 +451,7 @@ * receiving MM_MESSAGE_BEGIN_OF_STREAM. * */ -#define MM_PLAYER_VIDEO_HEIGHT "content_video_height" +#define MM_PLAYER_VIDEO_HEIGHT "content_video_height" /** * MM_PLAYER_VIDEO_EVAS_SURFACE_DO_SCALING: * @@ -460,218 +460,225 @@ * if FALSE, it does not scale down any frames. * */ -#define MM_PLAYER_VIDEO_EVAS_SURFACE_DO_SCALING "display_evas_do_scaling" +#define MM_PLAYER_VIDEO_EVAS_SURFACE_DO_SCALING "display_evas_do_scaling" /** * MM_PLAYER_VIDEO_EVAS_SURFACE_SINK: * * get the video evas surface sink plugin name (string), It's guaranteed after calling mm_player_create() * */ -#define MM_PLAYER_VIDEO_EVAS_SURFACE_SINK "display_evas_surface_sink" +#define MM_PLAYER_VIDEO_EVAS_SURFACE_SINK "display_evas_surface_sink" /** * MM_PLAYER_MEM_SRC: * * set memory pointer to play (data) * */ -#define MM_PLAYER_MEMORY_SRC "profile_user_param" +#define MM_PLAYER_MEMORY_SRC "profile_user_param" /** * MM_PLAYER_PLAYBACK_COUNT * * can set playback count (int), Default value is 1 and -1 is for infinity playing until releasing it. * */ -#define MM_PLAYER_PLAYBACK_COUNT "profile_play_count" +#define MM_PLAYER_PLAYBACK_COUNT "profile_play_count" /** * MM_PLAYER_SUBTITLE_URI * * set the subtitle path (string) */ -#define MM_PLAYER_SUBTITLE_URI "subtitle_uri" +#define MM_PLAYER_SUBTITLE_URI "subtitle_uri" /** * MM_PLAYER_STREAMING_TYPE * * set the streaming type (int) * @see MMStreamingType */ -#define MM_PLAYER_STREAMING_TYPE "streaming_type" +#define MM_PLAYER_STREAMING_TYPE "streaming_type" /** * MM_PLAYER_STREAMING_UDP_TIMEOUT * * set the streaming udp timeout(int) */ -#define MM_PLAYER_STREAMING_UDP_TIMEOUT "streaming_udp_timeout" +#define MM_PLAYER_STREAMING_UDP_TIMEOUT "streaming_udp_timeout" /** * MM_PLAYER_STREAMING_USER_AGENT * * set the streaming user agent (string) */ -#define MM_PLAYER_STREAMING_USER_AGENT "streaming_user_agent" +#define MM_PLAYER_STREAMING_USER_AGENT "streaming_user_agent" /** * MM_PLAYER_STREAMING_WAP_PROFILE * * set the streaming wap profile (int) */ -#define MM_PLAYER_STREAMING_WAP_PROFILE "streaming_wap_profile" +#define MM_PLAYER_STREAMING_WAP_PROFILE "streaming_wap_profile" /** * MM_PLAYER_STREAMING_NET_BANDWIDTH * * set the streaming network bandwidth (int) */ -#define MM_PLAYER_STREAMING_NET_BANDWIDTH "streaming_network_bandwidth" +#define MM_PLAYER_STREAMING_NET_BANDWIDTH "streaming_network_bandwidth" /** * MM_PLAYER_STREAMING_COOKIE * * set the streaming cookie (int) */ -#define MM_PLAYER_STREAMING_COOKIE "streaming_cookie" +#define MM_PLAYER_STREAMING_COOKIE "streaming_cookie" /** * MM_PLAYER_STREAMING_PROXY_IP * * set the streaming proxy ip (string) */ -#define MM_PLAYER_STREAMING_PROXY_IP "streaming_proxy_ip" +#define MM_PLAYER_STREAMING_PROXY_IP "streaming_proxy_ip" /** * MM_PLAYER_STREAMING_PROXY_PORT * * set the streaming proxy port (int) */ -#define MM_PLAYER_STREAMING_PROXY_PORT "streaming_proxy_port" +#define MM_PLAYER_STREAMING_PROXY_PORT "streaming_proxy_port" /** * MM_PLAYER_STREAMING_TIMEOUT * * set the streaming timeout (int) */ -#define MM_PLAYER_STREAMING_TIMEOUT "streaming_timeout" +#define MM_PLAYER_STREAMING_TIMEOUT "streaming_timeout" /** * MM_PLAYER_VIDEO_CODEC * * codec the video data is stored in (string) */ -#define MM_PLAYER_VIDEO_CODEC "content_video_codec" +#define MM_PLAYER_VIDEO_CODEC "content_video_codec" /** * MM_PLAYER_VIDEO_TRACK_NUM * * track number inside a collection (int) */ -#define MM_PLAYER_VIDEO_TRACK_NUM "content_video_track_num" +#define MM_PLAYER_VIDEO_TRACK_NUM "content_video_track_num" /** * MM_PLAYER_AUDIO_CODEC * * codec the audio data is stored in (string) */ -#define MM_PLAYER_AUDIO_CODEC "content_audio_codec" +#define MM_PLAYER_AUDIO_CODEC "content_audio_codec" /** * MM_PLAYER_AUDIO_BITRATE * * set the streaming proxy port (int) */ -#define MM_PLAYER_AUDIO_BITRATE "content_audio_bitrate" +#define MM_PLAYER_AUDIO_BITRATE "content_audio_bitrate" /** * MM_PLAYER_AUDIO_CHANNEL * * the number of audio channel (int) */ -#define MM_PLAYER_AUDIO_CHANNEL "content_audio_channels" +#define MM_PLAYER_AUDIO_CHANNEL "content_audio_channels" /** * MM_PLAYER_AUDIO_SAMPLERATE * * audio samplerate (int) */ -#define MM_PLAYER_AUDIO_SAMPLERATE "content_audio_samplerate" +#define MM_PLAYER_AUDIO_SAMPLERATE "content_audio_samplerate" /** * MM_PLAYER_AUDIO_TRACK_NUM * * track number inside a collection (int) */ -#define MM_PLAYER_AUDIO_TRACK_NUM "content_audio_track_num" +#define MM_PLAYER_AUDIO_TRACK_NUM "content_audio_track_num" /** * MM_PLAYER_TEXT_TRACK_NUM * * track number inside a collection (int) */ -#define MM_PLAYER_TEXT_TRACK_NUM "content_text_track_num" +#define MM_PLAYER_TEXT_TRACK_NUM "content_text_track_num" /** * MM_PLAYER_TAG_ARTIST * * person(s) responsible for the recording (string) */ -#define MM_PLAYER_TAG_ARTIST "tag_artist" +#define MM_PLAYER_TAG_ARTIST "tag_artist" /** * MM_PLAYER_TAG_ARTIST * * title (string) */ -#define MM_PLAYER_TAG_TITLE "tag_title" +#define MM_PLAYER_TAG_TITLE "tag_title" /** * MM_PLAYER_TAG_ARTIST * * album containing this data (string) */ -#define MM_PLAYER_TAG_ALBUM "tag_album" +#define MM_PLAYER_TAG_ALBUM "tag_album" /** * MM_PLAYER_TAG_ARTIST * * genre this data belongs to (string) */ -#define MM_PLAYER_TAG_GENRE "tag_genre" +#define MM_PLAYER_TAG_GENRE "tag_genre" /** * MM_PLAYER_TAG_ARTIST * * author (string) */ -#define MM_PLAYER_TAG_AUTHOUR "tag_author" +#define MM_PLAYER_TAG_AUTHOUR "tag_author" /** * MM_PLAYER_TAG_ARTIST * * copyright notice of the data (string) */ -#define MM_PLAYER_TAG_COPYRIGHT "tag_copyright" +#define MM_PLAYER_TAG_COPYRIGHT "tag_copyright" /** * MM_PLAYER_TAG_ARTIST * * date the data was created (string) */ -#define MM_PLAYER_TAG_DATE "tag_date" +#define MM_PLAYER_TAG_DATE "tag_date" /** * MM_PLAYER_TAG_ARTIST * * short text describing the content of the data (string) */ -#define MM_PLAYER_TAG_DESCRIPRION "tag_description" +#define MM_PLAYER_TAG_DESCRIPRION "tag_description" /** * MM_PLAYER_TAG_ARTIST * * track number inside a collection (int) */ -#define MM_PLAYER_TAG_TRACK_NUM "tag_track_num" +#define MM_PLAYER_TAG_TRACK_NUM "tag_track_num" /** * MM_PLAYER_PD_MODE * * progressive download mode (int) */ -#define MM_PLAYER_PD_MODE "pd_mode" +#define MM_PLAYER_PD_MODE "pd_mode" /** * MM_PLAYER_DRC_MODE * * dynamic resolution change mode (int) */ -#define MM_PLAYER_DRC_MODE "drc_mode" +#define MM_PLAYER_DRC_MODE "drc_mode" /** * MM_PLAYER_GAPLESS_MODE * * gapless playback mode (int) */ -#define MM_PLAYER_GAPLESS_MODE "gapless_mode" +#define MM_PLAYER_GAPLESS_MODE "gapless_mode" /** * MM_PLAYER_ENABLE_VIDEO_DECODED_CB * * enable video decoded callback (int) */ -#define MM_PLAYER_ENABLE_VIDEO_DECODED_CB "enable_video_decoded_cb" +#define MM_PLAYER_ENABLE_VIDEO_DECODED_CB "enable_video_decoded_cb" + +/** + * MM_PLAYER_VIDEO_CODEC_TYPE + * + * video codec type (int) + */ +#define MM_PLAYER_VIDEO_CODEC_TYPE "video_codec_type" #define BUFFER_MAX_PLANE_NUM (4) @@ -819,6 +826,12 @@ typedef enum { MM_PLAYER_STREAM_TYPE_MAX, } MMPlayerStreamType; +typedef enum { + MM_PLAYER_VIDEO_CODEC_TYPE_DEFAULT = 0, /**< codec is selected by the priority */ + MM_PLAYER_VIDEO_CODEC_TYPE_HW, /**< HW codec can only be selected */ + MM_PLAYER_VIDEO_CODEC_TYPE_SW, /**< SW codec can only be selected */ +} MMPlayerVideoCodecType; + /** * Attribute validity structure */ diff --git a/src/include/mm_player_ini.h b/src/include/mm_player_ini.h index 7f312aa..1024beb 100644 --- a/src/include/mm_player_ini.h +++ b/src/include/mm_player_ini.h @@ -53,7 +53,8 @@ */ enum keyword_type { KEYWORD_EXCLUDE, // for element exclude keyworld - KEYWORD_DUMP // for dump element keyworld + KEYWORD_DUMP, // for dump element keyworld + KEYWORD_SW_CODEC // for video sw codec }; typedef struct __mm_player_ini { @@ -62,6 +63,7 @@ typedef struct __mm_player_ini { gchar videosink_element_fake[PLAYER_INI_MAX_STRLEN]; gchar videoconverter_element[PLAYER_INI_MAX_STRLEN]; gchar videocodec_element_hw[PLAYER_INI_MAX_STRLEN]; + gchar videocodec_element_sw[PLAYER_INI_MAX_ELEMENT][PLAYER_INI_MAX_STRLEN]; gchar audioresampler_element[PLAYER_INI_MAX_STRLEN]; gchar audiosink_element[PLAYER_INI_MAX_STRLEN]; gboolean skip_rescan; @@ -143,6 +145,7 @@ typedef struct __mm_player_ini { #define DEFAULT_AUDIORESAMPLER "audioresample" #define DEFAULT_AUDIOSINK "pulsesink" #define DEFAULT_VIDEOCODEC_HW "" +#define DEFAULT_VIDEOCODEC_SW "" #define DEFAULT_GST_PARAM "" #define DEFAULT_EXCLUDE_KEYWORD "" #define DEFAULT_ASYNC_START TRUE diff --git a/src/mm_player_attrs.c b/src/mm_player_attrs.c index 7b1279a..bddd16f 100644 --- a/src/mm_player_attrs.c +++ b/src/mm_player_attrs.c @@ -1096,7 +1096,17 @@ _mmplayer_construct_attribute(MMHandleType handle) MM_ATTRS_VALID_TYPE_INT_RANGE, FALSE, TRUE - } + }, + { + "video_codec_type", + MM_ATTRS_TYPE_INT, + MM_ATTRS_FLAG_RW, + (void *) MM_PLAYER_VIDEO_CODEC_TYPE_DEFAULT, + MM_ATTRS_VALID_TYPE_INT_RANGE, + MM_PLAYER_VIDEO_CODEC_TYPE_DEFAULT, + MM_PLAYER_VIDEO_CODEC_TYPE_SW + }, + }; num_of_attrs = ARRAY_SIZE(player_attrs); diff --git a/src/mm_player_ini.c b/src/mm_player_ini.c index d303994..8662314 100644 --- a/src/mm_player_ini.c +++ b/src/mm_player_ini.c @@ -160,6 +160,9 @@ mm_player_ini_load(mm_player_ini_t* ini) MMPLAYER_INI_GET_STRING(dict, ini->videoconverter_element, "general:video converter element", DEFAULT_VIDEO_CONVERTER); __get_element_list(ini, + iniparser_getstring(dict, "general:video codec element sw", DEFAULT_VIDEOCODEC_SW), KEYWORD_SW_CODEC); + + __get_element_list(ini, iniparser_getstring(dict, "general:element exclude keyword", DEFAULT_EXCLUDE_KEYWORD), KEYWORD_EXCLUDE); MMPLAYER_INI_GET_STRING(dict, ini->gst_param[0], "general:gstparam1", DEFAULT_GST_PARAM); @@ -208,6 +211,7 @@ mm_player_ini_load(mm_player_ini_t* ini) strncpy(ini->videocodec_element_hw, DEFAULT_VIDEOCODEC_HW, PLAYER_INI_MAX_STRLEN - 1); strncpy(ini->videoconverter_element, DEFAULT_VIDEO_CONVERTER, PLAYER_INI_MAX_STRLEN -1); + __get_element_list(ini, DEFAULT_VIDEOCODEC_SW, KEYWORD_SW_CODEC); __get_element_list(ini, DEFAULT_EXCLUDE_KEYWORD, KEYWORD_EXCLUDE); strncpy(ini->gst_param[0], DEFAULT_GST_PARAM, PLAYER_INI_MAX_PARAM_STRLEN - 1); @@ -243,6 +247,8 @@ mm_player_ini_load(mm_player_ini_t* ini) LOGD("videosink element fake: %s\n", ini->videosink_element_fake); LOGD("video converter element : %s\n", ini->videoconverter_element); LOGD("video codec element(hw) : %s\n", ini->videocodec_element_hw); + for (idx = 0; ini->videocodec_element_sw[idx][0] != '\0'; idx++) + LOGD("video codec element(sw%d) %s\n", idx, ini->videocodec_element_sw[idx]); LOGD("audio resampler element : %s\n", ini->audioresampler_element); LOGD("audiosink element : %s\n", ini->audiosink_element); LOGD("generate dot : %d\n", ini->generate_dot); @@ -489,6 +495,22 @@ void __get_element_list(mm_player_ini_t* ini, gchar* str, int keyword_type) break; } + case KEYWORD_SW_CODEC: + { + for (walk = list; *walk; walk++) { + strncpy(ini->videocodec_element_sw[i], *walk, (PLAYER_INI_MAX_STRLEN - 1)); + + g_strstrip(ini->videocodec_element_sw[i]); + + ini->videocodec_element_sw[i][PLAYER_INI_MAX_STRLEN -1] = '\0'; + + i++; + } + /* mark last item to NULL */ + ini->videocodec_element_sw[i][0] = '\0'; + break; + } + default: break; } diff --git a/src/mm_player_priv.c b/src/mm_player_priv.c index d31c1ee..39c0887 100644 --- a/src/mm_player_priv.c +++ b/src/mm_player_priv.c @@ -11276,9 +11276,8 @@ GstCaps* caps, GstElementFactory* factory, gpointer data) for (idx = 0; player->ini.exclude_element_keyword[idx][0] != '\0'; idx++) { if (strstr(factory_name, player->ini.exclude_element_keyword[idx])) { LOGW("skipping [%s] by exculde keyword [%s]\n", - factory_name, player->ini.exclude_element_keyword[idx]); + factory_name, player->ini.exclude_element_keyword[idx]); - // NOTE : does we need to check n_value against the number of item selected? result = GST_AUTOPLUG_SELECT_SKIP; goto DONE; } @@ -11341,6 +11340,31 @@ GstCaps* caps, GstElementFactory* factory, gpointer data) if (!player->audiodec_linked) __mmplayer_set_audio_attrs(player, caps); } else if (g_strrstr(klass, "Codec/Decoder/Video")) { + + int video_codec_type = MM_PLAYER_VIDEO_CODEC_TYPE_DEFAULT; + mm_attrs_get_int_by_name(player->attrs, "video_codec_type", &video_codec_type); + + LOGD("video codec type: %d", video_codec_type); + if (video_codec_type == MM_PLAYER_VIDEO_CODEC_TYPE_HW) { + /* sw codec is skipped */ + for (idx = 0; player->ini.videocodec_element_sw[idx][0] != '\0'; idx++) { + if (strstr(factory_name, player->ini.videocodec_element_sw[idx])) { + LOGW("skipping sw codec:[%s] by codec type", factory_name); + + result = GST_AUTOPLUG_SELECT_SKIP; + goto DONE; + } + } + } else if (video_codec_type == MM_PLAYER_VIDEO_CODEC_TYPE_SW) { + /* hw codec is skipped */ + if (g_strrstr(factory_name, player->ini.videocodec_element_hw)) { + LOGW("skipping hw codec:[%s] by codec type", factory_name); + + result = GST_AUTOPLUG_SELECT_SKIP; + goto DONE; + } + } + if ((strlen(player->ini.videocodec_element_hw) > 0) && (g_strrstr(factory_name, player->ini.videocodec_element_hw))) { /* prepare resource manager for video decoder */ @@ -11607,9 +11631,9 @@ __mmplayer_gst_element_added(GstElement *bin, GstElement *element, gpointer data LOGD("[mpegaudioparse] set streaming pull mode."); g_object_set(G_OBJECT(element), "http-pull-mp3dec", TRUE, NULL); } - } else if (g_strrstr(factory_name, player->ini.videocodec_element_hw)) + } else if (g_strrstr(factory_name, player->ini.videocodec_element_hw)) { player->pipeline->mainbin[MMPLAYER_M_DEC1].gst = element; - + } if ((player->pipeline->mainbin[MMPLAYER_M_DEMUX].gst) && (g_strrstr(GST_ELEMENT_NAME(element), "multiqueue"))) {