[0.6.222] support codec type setting with u3
[platform/core/multimedia/libmm-player.git] / src / mm_player_priv.c
index c633373..a15b493 100644 (file)
@@ -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);