From: Eunhye Choi Date: Mon, 20 Apr 2020 10:14:02 +0000 (+0900) Subject: [0.6.222] support codec type setting with u3 X-Git-Tag: accepted/tizen/unified/20200422.032159^0 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fmultimedia%2Flibmm-player.git;a=commitdiff_plain;h=fb4ccd152b91377ac03a0cbd9e2bb644f766c046 [0.6.222] support codec type setting with u3 - fix bug about attr default from ini file - support codec type setting with uridecodebin3 - decoder element sorting is not supported in uridecodebin3, so use 'force-sw-decoders-xxx' property instead. - the default type decoder have to be described in ini file. Change-Id: I2410e1d3a31f85353a2d86e1080f8a5b30fbabd1 --- diff --git a/packaging/libmm-player.spec b/packaging/libmm-player.spec index 1929e3e..0b0f964 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.222 +Version: 0.6.223 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 diff --git a/src/mm_player_attrs.c b/src/mm_player_attrs.c index 3e82e01..386a752 100644 --- a/src/mm_player_attrs.c +++ b/src/mm_player_attrs.c @@ -239,16 +239,6 @@ static int __mmplayer_get_available_format(MMHandleType handle, int type, int ** return total_count; } -static int __mmplayer_get_default_audio_codec_type(MMHandleType handle) -{ - mmplayer_t *player = MM_PLAYER_CAST(handle); - - if (!strcmp(player->ini.audiocodec_default_type, "hw")) - return MM_PLAYER_CODEC_TYPE_HW; - else - return MM_PLAYER_CODEC_TYPE_SW; -} - static int __mmplayer_set_ini_to_valid_info(MMHandleType handle) { mmplayer_t *player = MM_PLAYER_CAST(handle); @@ -269,8 +259,12 @@ static int __mmplayer_set_ini_to_valid_info(MMHandleType handle) player->default_attrs[MMPLAYER_ATTRS_MEDIA_STREAM_INPUT_FORMAT].validity_value_2.count = total_count; } - /* default audio codec type */ - player->default_attrs[MMPLAYER_ATTRS_AUDIO_CODEC_TYPE].default_value.value_int = __mmplayer_get_default_audio_codec_type(handle); + /* default codec type */ + if (!strcmp(player->ini.audiocodec_default_type, "sw")) + player->default_attrs[MMPLAYER_ATTRS_AUDIO_CODEC_TYPE].default_value.value_int = MM_PLAYER_CODEC_TYPE_SW; + + if (!strcmp(player->ini.videocodec_default_type, "sw")) + player->default_attrs[MMPLAYER_ATTRS_VIDEO_CODEC_TYPE].default_value.value_int = MM_PLAYER_CODEC_TYPE_SW; return MM_ERROR_NONE; } @@ -1068,10 +1062,10 @@ MMHandleType _mmplayer_construct_attribute(MMHandleType handle) (char *)"video_codec_type", MM_ATTRS_TYPE_INT, MM_ATTRS_FLAG_RW, - {(void *)MM_PLAYER_CODEC_TYPE_DEFAULT}, + {(void *)MM_PLAYER_CODEC_TYPE_HW}, MM_ATTRS_VALID_TYPE_INT_RANGE, {.int_min = MM_PLAYER_CODEC_TYPE_HW}, - {.int_max = MM_PLAYER_CODEC_TYPE_DEFAULT}, + {.int_max = MM_PLAYER_CODEC_TYPE_SW}, NULL, }, { @@ -1079,7 +1073,7 @@ MMHandleType _mmplayer_construct_attribute(MMHandleType handle) (char *)"audio_codec_type", MM_ATTRS_TYPE_INT, MM_ATTRS_FLAG_RW, - {(void *)MM_PLAYER_CODEC_TYPE_SW}, + {(void *)MM_PLAYER_CODEC_TYPE_HW}, MM_ATTRS_VALID_TYPE_INT_RANGE, {.int_min = MM_PLAYER_CODEC_TYPE_HW}, {.int_max = MM_PLAYER_CODEC_TYPE_SW}, @@ -1196,12 +1190,22 @@ MMHandleType _mmplayer_construct_attribute(MMHandleType handle) return NULL; } + /* alloc default attribute info */ + player->default_attrs = (mmplayer_attrs_spec_t *)g_try_malloc(sizeof(mmplayer_attrs_spec_t) * num_of_attrs); + if (player->default_attrs == NULL) { + LOGE("failed to alloc default attribute info"); + goto ERROR; + } + + memcpy(player->default_attrs, player_attrs, sizeof(mmplayer_attrs_spec_t) * num_of_attrs); + __mmplayer_set_ini_to_valid_info(handle); + /* initialize values of attributes */ for (idx = 0; idx < num_of_attrs; idx++) { - base[idx].name = player_attrs[idx].name; - base[idx].value_type = player_attrs[idx].value_type; - base[idx].flags = player_attrs[idx].flags; - base[idx].default_value = player_attrs[idx].default_value.value_void; /* FIXME: need to consider the double data type */ + base[idx].name = player->default_attrs[idx].name; + base[idx].value_type = player->default_attrs[idx].value_type; + base[idx].flags = player->default_attrs[idx].flags; + base[idx].default_value = player->default_attrs[idx].default_value.value_void; /* FIXME: need to consider the double data type */ } result = mm_attrs_new(base, num_of_attrs, "mmplayer_attrs", @@ -1210,22 +1214,11 @@ MMHandleType _mmplayer_construct_attribute(MMHandleType handle) /* clean */ MMPLAYER_FREEIF(base); - if (result) { + if (result != MM_ERROR_NONE) { LOGE("failed to create player attrs"); - return NULL; - } - - /* alloc default attribute info */ - player->default_attrs = (mmplayer_attrs_spec_t *)g_try_malloc(sizeof(mmplayer_attrs_spec_t) * num_of_attrs); - if (player->default_attrs == NULL) { - LOGE("failed to alloc default attribute info"); goto ERROR; } - memcpy(player->default_attrs, player_attrs, sizeof(mmplayer_attrs_spec_t) * num_of_attrs); - - __mmplayer_set_ini_to_valid_info(handle); - /* set validity type and range */ for (idx = 0; idx < num_of_attrs; idx++) { mm_attrs_set_valid_type(attrs, idx, player->default_attrs[idx].valid_type); @@ -1270,6 +1263,7 @@ MMHandleType _mmplayer_construct_attribute(MMHandleType handle) return attrs; ERROR: + MMPLAYER_FREEIF(base); MMPLAYER_FREEIF(player->default_attrs); if (attrs) diff --git a/src/mm_player_gst.c b/src/mm_player_gst.c index 269a8d1..da38d53 100644 --- a/src/mm_player_gst.c +++ b/src/mm_player_gst.c @@ -3132,10 +3132,11 @@ __mmplayer_gst_deep_element_added(GstElement *bin, GstBin *child, GstElement *el /* CAUTION: if there is hw decoder, the rank value has to be higher than sw decoder and codec default type in ini has to be hw. */ + LOGD("set codec type v(%d) a(%d)", video_codec_type, audio_codec_type); if (video_codec_type == MM_PLAYER_CODEC_TYPE_SW) - g_object_set(G_OBJECT(child), "force-sw-decoder-for-video", TRUE, NULL); + g_object_set(G_OBJECT(child), "force-sw-decoders-for-video", TRUE, NULL); if (audio_codec_type == MM_PLAYER_CODEC_TYPE_SW) - g_object_set(G_OBJECT(child), "force-sw-decoder-for-audio", TRUE, NULL); + g_object_set(G_OBJECT(child), "force-sw-decoders-for-audio", TRUE, NULL); mainbin[MMPLAYER_M_AUTOPLUG_PARSEBIN].id = MMPLAYER_M_AUTOPLUG_PARSEBIN; mainbin[MMPLAYER_M_AUTOPLUG_PARSEBIN].gst = element; diff --git a/src/mm_player_priv.c b/src/mm_player_priv.c index c633373..a15b493 100644 --- a/src/mm_player_priv.c +++ b/src/mm_player_priv.c @@ -5053,9 +5053,7 @@ _mmplayer_realize(MMHandleType hplayer) char *uri = NULL; void *param = NULL; MMHandleType attrs = 0; - int video_codec_type = 0; - int audio_codec_type = 0; - int default_codec_type = 0; + MMPLAYER_FENTER(); /* check player handle */ @@ -5138,23 +5136,6 @@ _mmplayer_realize(MMHandleType hplayer) player->streamer->buffering_req.rebuffer_time); } - mm_attrs_get_int_by_name(player->attrs, MM_PLAYER_AUDIO_CODEC_TYPE, &audio_codec_type); - if (!strcmp(player->ini.audiocodec_default_type, "hw")) - default_codec_type = MM_PLAYER_CODEC_TYPE_HW; - else - default_codec_type = MM_PLAYER_CODEC_TYPE_SW; - - if (audio_codec_type != default_codec_type) { - LOGD("audio dec sorting is required"); - player->need_audio_dec_sorting = TRUE; - } - - mm_attrs_get_int_by_name(player->attrs, MM_PLAYER_VIDEO_CODEC_TYPE, &video_codec_type); - if (video_codec_type != MM_PLAYER_CODEC_TYPE_DEFAULT) { - LOGD("video dec sorting is required"); - player->need_video_dec_sorting = TRUE; - } - /* realize pipeline */ ret = __mmplayer_gst_realize(player); if (ret != MM_ERROR_NONE) @@ -8887,47 +8868,62 @@ _mmplayer_set_codec_type(MMHandleType hplayer, mmplayer_stream_type_e stream_typ { #define IDX_FIRST_SW_CODEC 0 mmplayer_t *player = (mmplayer_t *)hplayer; - const char *attr_name = (stream_type == MM_PLAYER_STREAM_TYPE_AUDIO) ? (MM_PLAYER_AUDIO_CODEC_TYPE) : (MM_PLAYER_VIDEO_CODEC_TYPE); + int default_codec_type = MM_PLAYER_CODEC_TYPE_DEFAULT; + const char *attr_name = NULL; + const char *default_type = NULL; + const char *element_hw = NULL; + const char *element_sw = NULL; MMPLAYER_FENTER(); MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - LOGD("ini setting : [a][h:%s][s:%s] / [v][h:%s][s:%s]", - player->ini.audiocodec_element_hw, player->ini.audiocodec_element_sw[IDX_FIRST_SW_CODEC], - player->ini.videocodec_element_hw, player->ini.videocodec_element_sw[IDX_FIRST_SW_CODEC]); + LOGD("stream type: %d, codec_type: %d", stream_type, codec_type); + /* FIXME: player need to know whether the decoder exist or not about required codec type since 6.0*/ switch (stream_type) { case MM_PLAYER_STREAM_TYPE_AUDIO: - /* to support audio codec selection, codec info have to be added in ini file as below. - audio codec element hw = xxxx - audio codec element sw = avdec - and in case of audio hw codec is supported and selected, - audio filter elements should be applied depending on the hw capabilities. - */ - if (((codec_type == MM_PLAYER_CODEC_TYPE_HW) && - (!strcmp(player->ini.audiocodec_element_hw, ""))) || - ((codec_type == MM_PLAYER_CODEC_TYPE_SW) && - (!strcmp(player->ini.audiocodec_element_sw[IDX_FIRST_SW_CODEC], "")))) { - LOGE("There is no audio codec info for codec_type %d", codec_type); - return MM_ERROR_PLAYER_NO_OP; - } - break; + attr_name = MM_PLAYER_AUDIO_CODEC_TYPE; + default_type = player->ini.audiocodec_default_type; + element_hw = player->ini.audiocodec_element_hw; + element_sw = player->ini.audiocodec_element_sw[IDX_FIRST_SW_CODEC]; + break; case MM_PLAYER_STREAM_TYPE_VIDEO: - /* to support video codec selection, codec info have to be added in ini file as below. - video codec element hw = omx - video codec element sw = avdec */ - if (((codec_type == MM_PLAYER_CODEC_TYPE_HW) && - (!strcmp(player->ini.videocodec_element_hw, ""))) || - ((codec_type == MM_PLAYER_CODEC_TYPE_SW) && - (!strcmp(player->ini.videocodec_element_sw[IDX_FIRST_SW_CODEC], "")))) { - LOGE("There is no video codec info for codec_type %d", codec_type); - return MM_ERROR_PLAYER_NO_OP; - } - break; + attr_name = MM_PLAYER_VIDEO_CODEC_TYPE; + default_type = player->ini.videocodec_default_type; + element_hw = player->ini.videocodec_element_hw; + element_sw = player->ini.videocodec_element_sw[IDX_FIRST_SW_CODEC]; + break; default: LOGE("Invalid stream type %s", MMPLAYER_STREAM_TYPE_GET_NAME(stream_type)); return MM_ERROR_COMMON_INVALID_ARGUMENT; - break; + break; + } + + LOGD("default setting: [%s][%s][h:%s][s:%s]", attr_name, default_type, element_hw, element_sw); + + if (!strcmp(default_type, "sw")) + default_codec_type = MM_PLAYER_CODEC_TYPE_SW; + else + default_codec_type = MM_PLAYER_CODEC_TYPE_HW; + + if (codec_type == MM_PLAYER_CODEC_TYPE_DEFAULT) + codec_type = default_codec_type; + + /* to support codec selection, codec info have to be added in ini file. + in case of hw codec is selected, filter elements should be applied + depending on the hw capabilities. */ + if (codec_type != default_codec_type) { + if (((codec_type == MM_PLAYER_CODEC_TYPE_HW) && (!strcmp(element_hw, ""))) || + ((codec_type == MM_PLAYER_CODEC_TYPE_SW) && (!strcmp(element_sw, "")))) { + LOGE("There is no codec for type %d", codec_type); + return MM_ERROR_PLAYER_NO_OP; + } + + LOGD("sorting is required"); + if (stream_type == MM_PLAYER_STREAM_TYPE_AUDIO) + player->need_audio_dec_sorting = TRUE; + else + player->need_video_dec_sorting = TRUE; } LOGD("update %s codec_type to %d", attr_name, codec_type);