diff data/fileio/QuickTimeFileReader.cpp @ 316:3a6725f285d6

* Make RemoteFile far more pervasive, and use it for local files as well so that we can handle both transparently. Make it shallow copy with reference counting, so it can be used by value without having to worry about the cache file lifetime. Use RemoteFile for MainWindow file-open functions, etc
author Chris Cannam
date Thu, 18 Oct 2007 15:31:20 +0000
parents 1c9143b2b658
children c324d410b096
line wrap: on
line diff
--- a/data/fileio/QuickTimeFileReader.cpp	Thu Oct 18 10:24:26 2007 +0000
+++ b/data/fileio/QuickTimeFileReader.cpp	Thu Oct 18 15:31:20 2007 +0000
@@ -48,12 +48,13 @@
 };
 
 
-QuickTimeFileReader::QuickTimeFileReader(QString path,
+QuickTimeFileReader::QuickTimeFileReader(RemoteFile source,
                                          DecodeMode decodeMode,
                                          CacheMode mode,
                                          size_t targetRate) :
     CodedAudioFileReader(mode, targetRate),
-    m_path(path),
+    m_source(source),
+    m_path(source.getLocalFilename()),
     m_d(new D),
     m_progress(0),
     m_cancelled(false),
@@ -65,7 +66,7 @@
 
     Profiler profiler("QuickTimeFileReader::QuickTimeFileReader", true);
 
-std::cerr << "QuickTimeFileReader: path is \"" << path.toStdString() << "\"" << std::endl;
+std::cerr << "QuickTimeFileReader: path is \"" << m_path.toStdString() << "\"" << std::endl;
 
     long QTversion;
 
@@ -90,8 +91,8 @@
 
     CFURLRef url = CFURLCreateFromFileSystemRepresentation
         (kCFAllocatorDefault,
-         (const UInt8 *)path.toLocal8Bit().data(),
-         (CFIndex)path.length(),
+         (const UInt8 *)m_path.toLocal8Bit().data(),
+         (CFIndex)m_path.length(),
          false);
 
 
@@ -216,7 +217,7 @@
     if (decodeMode == DecodeAtOnce) {
 
 	m_progress = new QProgressDialog
-	    (QObject::tr("Decoding %1...").arg(QFileInfo(path).fileName()),
+	    (QObject::tr("Decoding %1...").arg(QFileInfo(m_path).fileName()),
 	     QObject::tr("Stop"), 0, 100);
 	m_progress->hide();
 
@@ -335,5 +336,32 @@
     extensions.insert("wav");
 }
 
+bool
+QuickTimeFileReader::supportsExtension(QString extension)
+{
+    std::set<QString> extensions;
+    getSupportedExtensions(extensions);
+    return (extensions.find(extension.toLower()) != extensions.end());
+}
+
+bool
+QuickTimeFileReader::supportsContentType(QString type)
+{
+    return (type == "audio/x-aiff" ||
+            type == "audio/x-wav" ||
+            type == "audio/mpeg" ||
+            type == "audio/basic" ||
+            type == "audio/x-aac" ||
+            type == "video/mp4" ||
+            type == "video/quicktime");
+}
+
+bool
+QuickTimeFileReader::supports(RemoteFile &source)
+{
+    return (supportsExtension(source.getExtension()) ||
+            supportsContentType(source.getContentType()));
+}
+
 #endif