ini->num_of_video_bo = iniparser_getint(dict, "general:video bo max", DEFAULT_NUM_OF_VIDEO_BO);
ini->video_bo_timeout = iniparser_getint(dict, "general:video bo timeout", DEFAULT_TIMEOUT_OF_VIDEO_BO);
- MMPLAYER_INI_GET_STRING(dict, ini->videosink_element_overlay, "general:videosink element overlay", DEFAULT_VIDEOSINK_OVERLAY);
- MMPLAYER_INI_GET_STRING(dict, ini->videosink_element_fake, "general:videosink element fake", DEFAULT_VIDEOSINK_FAKE);
MMPLAYER_INI_GET_STRING(dict, ini->audioresampler_element, "general:audio resampler element", DEFAULT_AUDIORESAMPLER);
+ MMPLAYER_INI_GET_STRING(dict, ini->audiocodec_element_hw, "general:audio codec element hw", DEFAULT_CODEC_HW);
MMPLAYER_INI_GET_STRING(dict, ini->audiosink_element, "general:audiosink element", DEFAULT_AUDIOSINK);
- MMPLAYER_INI_GET_STRING(dict, ini->videocodec_element_hw, "general:video codec element hw", DEFAULT_VIDEOCODEC_HW);
+
+ MMPLAYER_INI_GET_STRING(dict, ini->videosink_element_overlay, "general:videosink element overlay", DEFAULT_VIDEOSINK_OVERLAY);
+ MMPLAYER_INI_GET_STRING(dict, ini->videosink_element_fake, "general:videosink element fake", DEFAULT_VIDEOSINK_FAKE);
+ MMPLAYER_INI_GET_STRING(dict, ini->videocodec_element_hw, "general:video codec element hw", DEFAULT_CODEC_HW);
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);
+ iniparser_getstring(dict, "general:audio codec element sw", DEFAULT_CODEC_SW), KEYWORD_A_SW_CODEC);
+
+ __get_element_list(ini,
+ iniparser_getstring(dict, "general:video codec element sw", DEFAULT_CODEC_SW), KEYWORD_V_SW_CODEC);
__get_element_list(ini,
iniparser_getstring(dict, "general:element exclude keyword", DEFAULT_EXCLUDE_KEYWORD), KEYWORD_EXCLUDE);
strncpy(ini->audioresampler_element, DEFAULT_AUDIORESAMPLER, PLAYER_INI_MAX_STRLEN -1);
strncpy(ini->audiosink_element, DEFAULT_AUDIOSINK, PLAYER_INI_MAX_STRLEN -1);
- strncpy(ini->videocodec_element_hw, DEFAULT_VIDEOCODEC_HW, PLAYER_INI_MAX_STRLEN - 1);
+ strncpy(ini->audiocodec_element_hw, DEFAULT_CODEC_HW, PLAYER_INI_MAX_STRLEN - 1);
+ strncpy(ini->videocodec_element_hw, DEFAULT_CODEC_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_CODEC_SW, KEYWORD_A_SW_CODEC);
+ __get_element_list(ini, DEFAULT_CODEC_SW, KEYWORD_V_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);
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 codec element(hw) : %s\n", ini->audiocodec_element_hw);
+ for (idx = 0; ini->audiocodec_element_sw[idx][0] != '\0'; idx++)
+ LOGD("audio codec element(sw%d) %s\n", idx, ini->audiocodec_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);
break;
}
- case KEYWORD_SW_CODEC:
+ case KEYWORD_V_SW_CODEC:
{
for (walk = list; *walk; walk++) {
strncpy(ini->videocodec_element_sw[i], *walk, (PLAYER_INI_MAX_STRLEN - 1));
ini->videocodec_element_sw[i][0] = '\0';
break;
}
+ case KEYWORD_A_SW_CODEC:
+ {
+ for (walk = list; *walk; walk++) {
+ strncpy(ini->audiocodec_element_sw[i], *walk, (PLAYER_INI_MAX_STRLEN - 1));
+
+ g_strstrip(ini->audiocodec_element_sw[i]);
+
+ ini->audiocodec_element_sw[i][PLAYER_INI_MAX_STRLEN -1] = '\0';
+
+ i++;
+ }
+ /* mark last item to NULL */
+ ini->audiocodec_element_sw[i][0] = '\0';
+ break;
+ }
default:
break;
return ret;
}
+static int
+__mmplayer_check_codec_info(mm_player_t* player, const char* klass, GstCaps* caps, char* factory_name)
+{
+ int ret = MM_ERROR_NONE;
+ int idx = 0;
+ int codec_type = MM_PLAYER_CODEC_TYPE_DEFAULT;
+
+ if ((g_strrstr(klass, "Codec/Decoder/Audio"))) {
+ GstStructure* str = NULL;
+ gint channels = 0;
+ mm_attrs_get_int_by_name(player->attrs, "audio_codec_type", &codec_type);
+
+ LOGD("audio codec type: %d", codec_type);
+ if (codec_type == MM_PLAYER_CODEC_TYPE_HW) {
+ /* sw codec will be skipped */
+ for (idx = 0; player->ini.audiocodec_element_sw[idx][0] != '\0'; idx++) {
+ if (strstr(factory_name, player->ini.audiocodec_element_sw[idx])) {
+ LOGW("skipping sw acodec:[%s] by codec type", factory_name);
+ ret = MM_ERROR_PLAYER_INTERNAL;
+ goto DONE;
+ }
+ }
+ } else if (codec_type == MM_PLAYER_CODEC_TYPE_SW) {
+ /* hw codec will be skipped */
+ if (strcmp(player->ini.audiocodec_element_hw, "") &&
+ g_strrstr(factory_name, player->ini.audiocodec_element_hw)) {
+ LOGW("skipping hw acodec:[%s] by codec type", factory_name);
+ ret = MM_ERROR_PLAYER_INTERNAL;
+ goto DONE;
+ }
+ }
+
+ str = gst_caps_get_structure(caps, 0);
+ if (str) {
+ gst_structure_get_int(str, "channels", &channels);
+
+ LOGD("check audio ch : %d %d\n", player->max_audio_channels, channels);
+ if (player->max_audio_channels < channels)
+ player->max_audio_channels = channels;
+ }
+ /* set stream information */
+ if (!player->audiodec_linked)
+ __mmplayer_set_audio_attrs(player, caps);
+
+ /* update codec info */
+ player->not_supported_codec &= MISSING_PLUGIN_VIDEO;
+ player->can_support_codec |= FOUND_PLUGIN_AUDIO;
+ player->audiodec_linked = 1;
+
+ } else if (g_strrstr(klass, "Codec/Decoder/Video")) {
+
+ mm_attrs_get_int_by_name(player->attrs, "video_codec_type", &codec_type);
+
+ LOGD("video codec type: %d", codec_type);
+ if (codec_type == MM_PLAYER_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 vcodec:[%s] by codec type", factory_name);
+ ret = MM_ERROR_PLAYER_INTERNAL;
+ goto DONE;
+ }
+ }
+ } else if (codec_type == MM_PLAYER_CODEC_TYPE_SW) {
+ /* hw codec is skipped */
+ if (g_strrstr(factory_name, player->ini.videocodec_element_hw)) {
+ LOGW("skipping hw vcodec:[%s] by codec type", factory_name);
+ ret = MM_ERROR_PLAYER_INTERNAL;
+ goto DONE;
+ }
+ }
+
+ if ((strlen(player->ini.videocodec_element_hw) > 0) &&
+ (g_strrstr(factory_name, player->ini.videocodec_element_hw))) {
+
+ /* mark video decoder for acquire */
+ if (player->video_decoder_resource == NULL) {
+ if (mm_resource_manager_mark_for_acquire(player->resource_manager,
+ MM_RESOURCE_MANAGER_RES_TYPE_VIDEO_DECODER,
+ MM_RESOURCE_MANAGER_RES_VOLUME_FULL,
+ &player->video_decoder_resource)
+ != MM_RESOURCE_MANAGER_ERROR_NONE) {
+ LOGE("could not mark video_decoder resource for acquire");
+ goto DONE;
+ }
+ } else {
+ LOGW("video decoder resource is already acquired, skip it.");
+ ret = MM_ERROR_PLAYER_INTERNAL;
+ goto DONE;
+ }
+
+ player->interrupted_by_resource = FALSE;
+ /* acquire resources for video playing */
+ if (mm_resource_manager_commit(player->resource_manager)
+ != MM_RESOURCE_MANAGER_ERROR_NONE) {
+ LOGE("could not acquire resources for video decoding\n");
+ ret = MM_ERROR_PLAYER_INTERNAL;
+ goto DONE;
+ }
+ }
+
+ /* update codec info */
+ player->not_supported_codec &= MISSING_PLUGIN_AUDIO;
+ player->can_support_codec |= FOUND_PLUGIN_VIDEO;
+ player->videodec_linked = 1;
+ }
+
+DONE:
+ return ret;
+}
+
static gint
__mmplayer_gst_decode_autoplug_select(GstElement *bin, GstPad* pad,
GstCaps* caps, GstElementFactory* factory, gpointer data)
if (g_strrstr(factory_name, "mssdemux"))
player->smooth_streaming = TRUE;
- /* check ALP Codec can be used or not */
- if ((g_strrstr(klass, "Codec/Decoder/Audio"))) {
- GstStructure* str = NULL;
- gint channels = 0;
-
- str = gst_caps_get_structure(caps, 0);
- if (str) {
- gst_structure_get_int(str, "channels", &channels);
-
- LOGD("check audio ch : %d %d\n", player->max_audio_channels, channels);
- if (player->max_audio_channels < channels)
- player->max_audio_channels = channels;
- }
- /* set stream information */
- 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))) {
-
- /* mark video decoder for acquire */
- if (player->video_decoder_resource == NULL) {
- if (mm_resource_manager_mark_for_acquire(player->resource_manager,
- MM_RESOURCE_MANAGER_RES_TYPE_VIDEO_DECODER,
- MM_RESOURCE_MANAGER_RES_VOLUME_FULL,
- &player->video_decoder_resource)
- != MM_RESOURCE_MANAGER_ERROR_NONE) {
- LOGE("could not mark video_decoder resource for acquire");
- goto DONE;
- }
- } else {
- LOGW("video decoder resource is already acquired, skip it.");
- result = GST_AUTOPLUG_SELECT_SKIP;
- goto DONE;
- }
-
- player->interrupted_by_resource = FALSE;
- /* acquire resources for video playing */
- if (mm_resource_manager_commit(player->resource_manager)
- != MM_RESOURCE_MANAGER_ERROR_NONE) {
- LOGE("could not acquire resources for video decoding\n");
- goto DONE;
- }
- }
- }
-
if ((g_strrstr(klass, "Codec/Parser/Converter/Video")) ||
(g_strrstr(klass, "Codec/Decoder/Video"))) {
gint stype = 0;
}
/* get w/h for omx state-tune */
+ /* FIXME: deprecated? */
str = gst_caps_get_structure(caps, 0);
gst_structure_get_int(str, "width", &width);
}
}
- if (g_strrstr(klass, "Decoder")) {
- const char* mime = NULL;
- mime = gst_structure_get_name(gst_caps_get_structure(caps, 0));
-
- if (g_str_has_prefix(mime, "video")) {
- player->not_supported_codec &= MISSING_PLUGIN_AUDIO;
- player->can_support_codec |= FOUND_PLUGIN_VIDEO;
-
- player->videodec_linked = 1;
- } else if (g_str_has_prefix(mime, "audio")) {
- player->not_supported_codec &= MISSING_PLUGIN_VIDEO;
- player->can_support_codec |= FOUND_PLUGIN_AUDIO;
-
- player->audiodec_linked = 1;
+ if (g_strrstr(klass, "Codec/Decoder")) {
+ if (__mmplayer_check_codec_info(player, klass, caps, factory_name) != MM_ERROR_NONE) {
+ LOGD("skipping %s codec", factory_name);
+ result = GST_AUTOPLUG_SELECT_SKIP;
+ goto DONE;
}
}
MMPLAYER_FLEAVE();
return ret;
}
+
+int _mmplayer_set_codec_type(MMHandleType hplayer, MMPlayerStreamType stream_type, MMPlayerVideoCodecType codec_type)
+{
+#define IDX_FIRST_SW_CODEC 0
+ mm_player_t* player = (mm_player_t*) hplayer;
+ const char* attr_name = (stream_type == MM_PLAYER_STREAM_TYPE_AUDIO) ? (MM_PLAYER_AUDIO_CODEC_TYPE) : (MM_PLAYER_VIDEO_CODEC_TYPE);
+ MMHandleType attrs = 0;
+
+ 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]);
+
+ switch (stream_type) {
+ case MM_PLAYER_STREAM_TYPE_AUDIO:
+ 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 a codec for codec_type %d", codec_type);
+ return MM_ERROR_PLAYER_NO_OP;
+ }
+ break;
+ case MM_PLAYER_STREAM_TYPE_VIDEO:
+ 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 v codec for codec_type %d", codec_type);
+ return MM_ERROR_PLAYER_NO_OP;
+ }
+
+ break;
+ default:
+ LOGE("Invalid stream type %d", stream_type);
+ return MM_ERROR_COMMON_INVALID_ARGUMENT;
+ break;
+ }
+
+ LOGD("update %s codec_type to %d", attr_name, codec_type);
+
+ attrs = MMPLAYER_GET_ATTRS(player);
+ mm_attrs_set_int_by_name(attrs, attr_name, codec_type);
+
+ if (mmf_attrs_commit(player->attrs)) {
+ LOGE("failed to commit codec_type attributes");
+ return MM_ERROR_PLAYER_INTERNAL;
+ }
+
+ MMPLAYER_FLEAVE();
+ return MM_ERROR_NONE;
+}