Bug 231254 - [PATCH] Not all available mime types are listed due to ignoring all but the first caps-struct
Summary: [PATCH] Not all available mime types are listed due to ignoring all but the f...
Status: RESOLVED FIXED
Alias: None
Product: phonon-backend-gstreamer
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Mandriva RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: Matthias Kretz
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-03-18 22:48 UTC by Shlomi Fish
Modified: 2011-04-27 21:16 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 4.4.1


Attachments
Patch to correct the problem. (1.13 KB, patch)
2010-03-18 22:49 UTC, Shlomi Fish
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Shlomi Fish 2010-03-18 22:48:56 UTC
Version:           4.3.80 (using KDE 4.4.1)
OS:                Linux
Installed from:    Mandriva RPMs

The Phonon gstreamer backend does not list all available mime types because it only access the 0'th struct of the caps struct. As a result, many file types (including .it , .xm and .s3m files) cannot be dragged and dropped and played in Amarok. Here is a patch that corrects the problem (I will also attach it):


--- phonon-4.3.80/gstreamer/backend.cpp.orig	2010-03-18 23:15:48.723577146 +0200
+++ phonon-4.3.80/gstreamer/backend.cpp	2010-03-18 23:16:00.270575574 +0200
@@ -240,10 +240,13 @@
                     GstCaps *caps = gst_static_pad_template_get_caps (padTemplate);
 
                     if (caps) {
-                        const GstStructure* capsStruct = gst_caps_get_structure (caps, 0);
-                        QString mime = QString::fromUtf8(gst_structure_get_name (capsStruct));
-                        if (!availableMimeTypes.contains(mime))
-                              availableMimeTypes.append(mime);
+                        for (unsigned int struct_idx = 0; struct_idx < gst_caps_get_size (caps); struct_idx++) {
+
+                            const GstStructure* capsStruct = gst_caps_get_structure (caps, struct_idx);
+                            QString mime = QString::fromUtf8(gst_structure_get_name (capsStruct));
+                            if (!availableMimeTypes.contains(mime))
+                                availableMimeTypes.append(mime);
+                        }
                     }
                 }
             }
Comment 1 Shlomi Fish 2010-03-18 22:49:57 UTC
Created attachment 41749 [details]
Patch to correct the problem.

This is a patch that corrects the problem. I hereby disclaim any ownership on it and licences it under public-domain / CC-Zero.
Comment 2 Colin Guthrie 2010-03-20 12:59:44 UTC
commit 97555adfca6830c23682f03eba72b8b44ec38f28
Author: Colin Guthrie <cguthrie@mandriva.org>
Date:   Sat Mar 20 11:57:25 2010 +0000

    gstreamer: Include all supported mime types.
    
    Shlomi Fish discovered that not all mime types supported by the gstreamer
    backend were parsed into Phonon. This change ensures that that all mime types are
    parsed correctly.
    
    Thanks to Shlomi for the patch.
    BUG: 231254

diff --git a/gstreamer/backend.cpp b/gstreamer/backend.cpp
index 3a794b0..729a1d3 100644
--- a/gstreamer/backend.cpp
+++ b/gstreamer/backend.cpp
@@ -240,10 +240,13 @@ QStringList Backend::availableMimeTypes() const
                     GstCaps *caps = gst_static_pad_template_get_caps (padTemplate);
 
                     if (caps) {
-                        const GstStructure* capsStruct = gst_caps_get_structure (caps, 0);
-                        QString mime = QString::fromUtf8(gst_structure_get_name (capsStruct));
-                        if (!availableMimeTypes.contains(mime))
-                              availableMimeTypes.append(mime);
+                        for (unsigned int struct_idx = 0; struct_idx < gst_caps_get_size (caps); struct_idx++) {
+
+                            const GstStructure* capsStruct = gst_caps_get_structure (caps, struct_idx);
+                            QString mime = QString::fromUtf8(gst_structure_get_name (capsStruct));
+                            if (!availableMimeTypes.contains(mime))
+                                availableMimeTypes.append(mime);
+                        }
                     }
                 }
             }
Comment 3 Myriam Schweingruber 2011-04-27 21:16:49 UTC
reassigning to the new bugzilla product for better bug tracing of the various backends. Sorry for the noise.