[0.6.87] add err handling about setting codec_type 22/166622/3
authorEunhae Choi <eunhae1.choi@samsung.com>
Thu, 11 Jan 2018 07:25:25 +0000 (16:25 +0900)
committerEunhae Choi <eunhae1.choi@samsung.com>
Thu, 11 Jan 2018 07:28:32 +0000 (16:28 +0900)
- add err handling
- add audio codec type setting

Change-Id: I359da0571e3d3da17417a59d8c5dc8806e61c623

packaging/libmm-player.spec
src/include/mm_player.h
src/include/mm_player_ini.h
src/include/mm_player_priv.h
src/mm_player.c
src/mm_player_attrs.c
src/mm_player_ini.c
src/mm_player_priv.c

index d8e9874..0e361e4 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-player
 Summary:    Multimedia Framework Player Library
-Version:    0.6.86
+Version:    0.6.87
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index bd02302..4d3a48f 100644 (file)
  */
 #define MM_PLAYER_VIDEO_CODEC_TYPE          "video_codec_type"
 
+/**
+ * MM_PLAYER_AUDIO_CODEC_TYPE
+ *
+ * audio codec type (int)
+ */
+#define MM_PLAYER_AUDIO_CODEC_TYPE          "audio_codec_type"
+
 #define BUFFER_MAX_PLANE_NUM (4)
 
 typedef struct {
@@ -827,9 +834,9 @@ typedef enum {
 } 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 */
+       MM_PLAYER_CODEC_TYPE_DEFAULT = 0, /**< codec is selected by the priority */
+       MM_PLAYER_CODEC_TYPE_HW,          /**< HW codec can only be selected */
+       MM_PLAYER_CODEC_TYPE_SW,          /**< SW codec can only be selected */
 } MMPlayerVideoCodecType;
 
 /**
@@ -1873,15 +1880,6 @@ int mm_player_set_video_share_master_clock(MMHandleType player, long long clock,
 int mm_player_get_video_share_master_clock(MMHandleType player, long long *video_time, long long *media_clock, long long *audio_time);
 
 /**
- * This function is to get the content angle
- *
- * @param       player         [in]    handle of player
- * @param       angle          [out]   orignal angle from content
- * @return      This function returns zero on success, or negative value with error code.
- */
-int mm_player_get_video_rotate_angle(MMHandleType player, int *angle);
-
-/**
  * This function is to set download mode of video hub
  *
  * @param       player         [in]    handle of player
@@ -2179,6 +2177,11 @@ int mm_player_360_set_field_of_view(MMHandleType player, int horizontal_degrees,
 int mm_player_360_get_field_of_view(MMHandleType player, int *horizontal_degrees, int *vertical_degrees);
 
 /**
+ * This function is to set codec type
+ */
+int mm_player_set_codec_type(MMHandleType player, MMPlayerStreamType stream_type, MMPlayerVideoCodecType codec_type);
+
+/**
        @}
  */
 
index 5919d54..88982d6 100644 (file)
@@ -54,7 +54,8 @@
 enum keyword_type {
        KEYWORD_EXCLUDE,        // for element exclude keyworld
        KEYWORD_DUMP,           // for dump element keyworld
-       KEYWORD_SW_CODEC        // for video sw codec
+       KEYWORD_A_SW_CODEC,     // for audio sw codec
+       KEYWORD_V_SW_CODEC      // for video sw codec
 };
 
 typedef struct __mm_player_ini {
@@ -64,6 +65,8 @@ typedef struct __mm_player_ini {
        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 audiocodec_element_hw[PLAYER_INI_MAX_STRLEN];
+       gchar audiocodec_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;
@@ -144,8 +147,8 @@ typedef struct __mm_player_ini {
 #define DEFAULT_VIDEOSINK_FAKE                         "fakesink"
 #define DEFAULT_AUDIORESAMPLER                 "audioresample"
 #define DEFAULT_AUDIOSINK                              "pulsesink"
-#define DEFAULT_VIDEOCODEC_HW                  ""
-#define DEFAULT_VIDEOCODEC_SW                  ""
+#define DEFAULT_CODEC_HW                       ""
+#define DEFAULT_CODEC_SW                       ""
 #define DEFAULT_GST_PARAM                              ""
 #define DEFAULT_EXCLUDE_KEYWORD                        ""
 #define DEFAULT_ASYNC_START                            TRUE
index df48220..e13d6e7 100644 (file)
@@ -988,6 +988,7 @@ int _mmplayer_set_audio_only(MMHandleType hplayer, bool audio_only);
 int _mmplayer_get_audio_only(MMHandleType hplayer, bool *paudio_only);
 int _mmplayer_set_streaming_buffering_time(MMHandleType hplayer, int buffer_ms, int rebuffer_ms);
 int _mmplayer_get_streaming_buffering_time(MMHandleType hplayer, int *buffer_ms, int *rebuffer_ms);
+int _mmplayer_set_codec_type(MMHandleType hplayer, MMPlayerStreamType stream_type, MMPlayerVideoCodecType codec_type);
 
 #ifdef __cplusplus
        }
index b6d8612..7f85b59 100644 (file)
@@ -795,22 +795,6 @@ int mm_player_get_video_share_master_clock(MMHandleType player,
        return result;
 }
 
-int mm_player_get_video_rotate_angle(MMHandleType player, int *angle)
-{
-       int result = MM_ERROR_NONE;
-
-       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
-       MMPLAYER_RETURN_VAL_IF_FAIL(angle, MM_ERROR_COMMON_INVALID_ARGUMENT);
-
-       MMPLAYER_CMD_LOCK(player);
-
-       result = _mmplayer_get_video_rotate_angle(player, angle);
-
-       MMPLAYER_CMD_UNLOCK(player);
-
-       return result;
-}
-
 int mm_player_set_video_hub_download_mode(MMHandleType player, bool mode)
 {
        int result = MM_ERROR_NONE;
@@ -1482,3 +1466,18 @@ int mm_player_360_get_field_of_view(MMHandleType player, int *horizontal_degrees
 
        return result;
 }
+
+int mm_player_set_codec_type(MMHandleType player, MMPlayerStreamType stream_type, MMPlayerVideoCodecType codec_type)
+{
+       int result = MM_ERROR_NONE;
+
+       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
+
+       MMPLAYER_CMD_LOCK(player);
+
+       result = _mmplayer_set_codec_type(player, stream_type, codec_type);
+
+       MMPLAYER_CMD_UNLOCK(player);
+
+       return result;
+}
index a0f9ec4..c058c6b 100644 (file)
@@ -1110,12 +1110,20 @@ _mmplayer_construct_attribute(MMHandleType handle)
                        "video_codec_type",
                        MM_ATTRS_TYPE_INT,
                        MM_ATTRS_FLAG_RW,
-                       (void *) MM_PLAYER_VIDEO_CODEC_TYPE_DEFAULT,
+                       (void *) MM_PLAYER_CODEC_TYPE_DEFAULT,
                        MM_ATTRS_VALID_TYPE_INT_RANGE,
-                       MM_PLAYER_VIDEO_CODEC_TYPE_DEFAULT,
-                       MM_PLAYER_VIDEO_CODEC_TYPE_SW
+                       MM_PLAYER_CODEC_TYPE_DEFAULT,
+                       MM_PLAYER_CODEC_TYPE_SW
+               },
+               {
+                       "audio_codec_type",
+                       MM_ATTRS_TYPE_INT,
+                       MM_ATTRS_FLAG_RW,
+                       (void *) MM_PLAYER_CODEC_TYPE_DEFAULT,
+                       MM_ATTRS_VALID_TYPE_INT_RANGE,
+                       MM_PLAYER_CODEC_TYPE_DEFAULT,
+                       MM_PLAYER_CODEC_TYPE_SW
                },
-
        };
 
        num_of_attrs = ARRAY_SIZE(player_attrs);
index 8662314..91c1efa 100644 (file)
@@ -152,15 +152,20 @@ mm_player_ini_load(mm_player_ini_t* ini)
                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);
@@ -208,10 +213,12 @@ mm_player_ini_load(mm_player_ini_t* ini)
 
                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);
@@ -249,6 +256,9 @@ mm_player_ini_load(mm_player_ini_t* ini)
        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);
@@ -495,7 +505,7 @@ void __get_element_list(mm_player_ini_t* ini, gchar* str, int keyword_type)
 
                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));
@@ -510,6 +520,21 @@ void __get_element_list(mm_player_ini_t* ini, gchar* str, int keyword_type)
                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;
index 9e17f92..7d3b6b0 100644 (file)
@@ -11491,6 +11491,117 @@ GstCaps * caps,  gpointer data)
        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)
@@ -11574,77 +11685,6 @@ 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;
@@ -11661,6 +11701,7 @@ GstCaps* caps, GstElementFactory* factory, gpointer data)
                }
 
                /* get w/h for omx state-tune */
+               /* FIXME: deprecated? */
                str = gst_caps_get_structure(caps, 0);
                gst_structure_get_int(str, "width", &width);
 
@@ -11676,20 +11717,11 @@ GstCaps* caps, GstElementFactory* factory, gpointer data)
                }
        }
 
-       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;
                }
        }
 
@@ -14331,3 +14363,57 @@ int _mmplayer_get_streaming_buffering_time(MMHandleType hplayer, int *buffer_ms,
        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;
+}