+#ifdef __DEBUG__
+static void
+print_tag(const GstTagList *list, const gchar *tag, gpointer unused)
+{
+ gint i, count;
+
+ count = gst_tag_list_get_tag_size(list, tag);
+
+ LOGD("count = %d", count);
+
+ for (i = 0; i < count; i++) {
+ gchar *str;
+
+ if (gst_tag_get_type(tag) == G_TYPE_STRING) {
+ if (!gst_tag_list_get_string_index(list, tag, i, &str))
+ g_assert_not_reached();
+ } else {
+ str = g_strdup_value_contents(gst_tag_list_get_value_index(list, tag, i));
+ }
+
+ if (i == 0)
+ g_print(" %15s: %s", gst_tag_get_nick(tag), str);
+ else
+ g_print(" : %s", str);
+
+ g_free(str);
+ }
+}
+#endif
+
+static gboolean
+__mmplayer_check_error_posted_from_activated_track(mmplayer_t *player, gchar *src_element_name)
+{
+ /* check whether the error is posted from not-activated track or not */
+ int msg_src_pos = 0;
+ gint active_pad_index = 0;
+
+ MMPLAYER_RETURN_VAL_IF_FAIL(player->pipeline->mainbin[MMPLAYER_M_A_INPUT_SELECTOR].gst, TRUE);
+
+ active_pad_index = player->selector[MM_PLAYER_TRACK_TYPE_AUDIO].active_pad_index;
+ LOGD("current active pad index -%d", active_pad_index);
+
+ if (src_element_name) {
+ int idx = 0;
+
+ if (player->audio_decoders) {
+ GList *adec = player->audio_decoders;
+ for (; adec ; adec = g_list_next(adec)) {
+ gchar *name = adec->data;
+
+ LOGD("found audio decoder name = %s", name);
+ if (g_strrstr(name, src_element_name)) {
+ msg_src_pos = idx;
+ break;
+ }
+ idx++;
+ }
+ }
+ LOGD("active pad = %d, error src index = %d", active_pad_index, msg_src_pos);
+ }
+
+ if (active_pad_index != msg_src_pos) {
+ LOGD("skip error because error is posted from no activated track");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static int
+__mmplayer_gst_transform_error_decode(mmplayer_t *player, const char *klass)
+{
+ /* Demuxer can't parse one track because it's corrupted.
+ * So, the decoder for it is not linked.
+ * But, it has one playable track.
+ */
+ if (g_strrstr(klass, "Demux")) {
+ if (player->can_support_codec == FOUND_PLUGIN_VIDEO) {
+ return MM_ERROR_PLAYER_AUDIO_CODEC_NOT_FOUND;
+ } else if (player->can_support_codec == FOUND_PLUGIN_AUDIO) {
+ return MM_ERROR_PLAYER_VIDEO_CODEC_NOT_FOUND;
+ } else {
+ if (player->pipeline->audiobin) { // PCM
+ return MM_ERROR_PLAYER_VIDEO_CODEC_NOT_FOUND;
+ } else {
+ LOGD("not found any available codec. Player should be destroyed.");
+ return MM_ERROR_PLAYER_CODEC_NOT_FOUND;
+ }
+ }
+ }
+
+ return MM_ERROR_PLAYER_INVALID_STREAM;
+}
+
+static int
+__mmplayer_gst_transform_error_type(mmplayer_t *player, GstElement *src_element)
+{
+ if (src_element == player->pipeline->mainbin[MMPLAYER_M_SUBPARSE].gst) {
+ LOGE("Not supported subtitle.");
+ return MM_ERROR_PLAYER_NOT_SUPPORTED_SUBTITLE;
+ }
+ return MM_ERROR_PLAYER_NOT_SUPPORTED_FORMAT;
+}
+
+static int
+__mmplayer_gst_transform_error_failed(mmplayer_t *player, const char *klass, GError *error)
+{
+ /* Decoder Custom Message */
+ if (!strstr(error->message, "ongoing"))
+ return MM_ERROR_PLAYER_NOT_SUPPORTED_FORMAT;
+
+ if (strncasecmp(klass, "audio", 5)) {
+ if ((player->can_support_codec & FOUND_PLUGIN_VIDEO)) {
+ LOGD("Video can keep playing.");
+ return MM_ERROR_PLAYER_AUDIO_CODEC_NOT_FOUND;
+ }
+ } else if (strncasecmp(klass, "video", 5)) {
+ if ((player->can_support_codec & FOUND_PLUGIN_AUDIO)) {
+ LOGD("Audio can keep playing.");
+ return MM_ERROR_PLAYER_VIDEO_CODEC_NOT_FOUND;
+ }
+ }
+
+ LOGD("not found any available codec. Player should be destroyed.");
+ return MM_ERROR_PLAYER_CODEC_NOT_FOUND;
+}
+
+static int
+__mmplayer_gst_transform_error_decrypt(mmplayer_t *player, GError *error)
+{
+ if (strstr(error->message, "rights expired"))
+ return MM_ERROR_PLAYER_DRM_EXPIRED;
+ else if (strstr(error->message, "no rights"))
+ return MM_ERROR_PLAYER_DRM_NO_LICENSE;
+ else if (strstr(error->message, "has future rights"))
+ return MM_ERROR_PLAYER_DRM_FUTURE_USE;
+ else if (strstr(error->message, "opl violation"))
+ return MM_ERROR_PLAYER_DRM_OUTPUT_PROTECTION;
+
+ return MM_ERROR_PLAYER_DRM_NOT_AUTHORIZED;
+}