[vlc-devel] [PATCH 2/2] playlist: use ACCESS_GET_CONTENT_TYPE instead of psz_demux hack

Edward Wang edward.c.wang at compdigitec.com
Sat Oct 12 06:13:10 CEST 2013


Remove the hack and use a clean method.

Ref #8449
---
 modules/access/directory.c    |  9 +++++----
 modules/demux/playlist/xspf.c | 13 +++++++++++++
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/modules/access/directory.c b/modules/access/directory.c
index 0159042..c18bc5b 100644
--- a/modules/access/directory.c
+++ b/modules/access/directory.c
@@ -198,10 +198,7 @@ int DirInit (access_t *p_access, DIR *handle)
     p_access->pf_read  = NULL;
     p_access->pf_block = DirBlock;
     p_access->pf_seek  = NULL;
-    p_access->pf_control= DirControl;
-    free (p_access->psz_demux);
-    p_access->psz_demux = strdup ("xspf-open");
-
+    p_access->pf_control = DirControl;
     return VLC_SUCCESS;
 
 error:
@@ -483,6 +480,10 @@ int DirControl( access_t *p_access, int i_query, va_list args )
             *va_arg( args, int64_t * ) = DEFAULT_PTS_DELAY * 1000;
             break;
 
+        case ACCESS_GET_CONTENT_TYPE:
+            *va_arg( args, char** ) = strdup("application/xspf+xml");
+            return VLC_SUCCESS;
+
         default:
             return VLC_EGENERIC;
     }
diff --git a/modules/demux/playlist/xspf.c b/modules/demux/playlist/xspf.c
index 8606759..2705be3 100644
--- a/modules/demux/playlist/xspf.c
+++ b/modules/demux/playlist/xspf.c
@@ -84,6 +84,19 @@ static int Demux(demux_t *);
  */
 int Import_xspf(vlc_object_t *p_this)
 {
+    char* mimetype = NULL;
+    {
+        demux_t *p_demux = (demux_t *)p_this;
+
+        stream_Control( p_demux->s, STREAM_GET_CONTENT_TYPE, &mimetype );
+        if( mimetype && !strcmp( "application/xspf+xml", mimetype ) ) {
+            free( mimetype );
+            STANDARD_DEMUX_INIT_MSG( "using XSPF playlist reader" );
+            return VLC_SUCCESS;
+        }
+    }
+    free( mimetype );
+
     DEMUX_BY_EXTENSION_OR_FORCED_MSG(".xspf", "xspf-open",
                                       "using XSPF playlist reader");
     return VLC_SUCCESS;
-- 
1.8.4.rc3




More information about the vlc-devel mailing list