changeset 826:e143cbba4819 trunk

[svn] Ask the decoder whether this is a WMA file, instead of depending on file magic.
author chainsaw
date Sun, 12 Mar 2006 14:49:19 -0800
parents 7b903bd39180
children 6812adf5ff2e
files Plugins/Input/wma/wma.c
diffstat 1 files changed, 23 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/Plugins/Input/wma/wma.c	Sun Mar 12 14:07:38 2006 -0800
+++ b/Plugins/Input/wma/wma.c	Sun Mar 12 14:49:19 2006 -0800
@@ -62,11 +62,13 @@
 static int wma_decode = 0;
 static gboolean wma_pause = 0;
 static int wma_seekpos = -1;
-static int wma_st_buff, wma_idx;
+static int wma_st_buff, wma_idx, wma_idx2;
 static GThread *wma_decode_thread;
 GStaticMutex wma_mutex = G_STATIC_MUTEX_INIT;
 static AVCodecContext *c = NULL;
 static AVFormatContext *ic = NULL;
+static AVCodecContext *c2 = NULL;
+static AVFormatContext *ic2 = NULL;
 static uint8_t *wma_outbuf, *wma_s_outbuf;
 
 char description[64];
@@ -185,12 +187,26 @@
 
 static int wma_is_our_file(char *filename)
 {
-    gchar *ext;
-    ext = strrchr(filename, '.');
-    if(ext)
-        if(!strcasecmp(ext, ".wma"))
-            return 1;
-    return 0;
+    AVCodec *codec2;
+
+    if(av_open_input_file(&ic2, str_twenty_to_space(filename), NULL, 0, NULL) < 0) return 0;
+
+    for(wma_idx2 = 0; wma_idx2 < ic2->nb_streams; wma_idx2++) {
+        c2 = &ic2->streams[wma_idx2]->codec;
+        if(c2->codec_type == CODEC_TYPE_AUDIO) break;
+    }
+
+    av_find_stream_info(ic2);
+
+    codec2 = avcodec_find_decoder(c2->codec_id);
+
+    if(!codec2) {
+        av_close_input_file(ic2);
+	return 0;
+    }
+	
+    av_close_input_file(ic2);
+    return 1;
 }
 
 static void wma_do_pause(short p)