Mercurial > hg > svcore
comparison 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 |
comparison
equal
deleted
inserted
replaced
315:96ef9746c560 | 316:3a6725f285d6 |
---|---|
46 Movie movie; | 46 Movie movie; |
47 size_t blockSize; | 47 size_t blockSize; |
48 }; | 48 }; |
49 | 49 |
50 | 50 |
51 QuickTimeFileReader::QuickTimeFileReader(QString path, | 51 QuickTimeFileReader::QuickTimeFileReader(RemoteFile source, |
52 DecodeMode decodeMode, | 52 DecodeMode decodeMode, |
53 CacheMode mode, | 53 CacheMode mode, |
54 size_t targetRate) : | 54 size_t targetRate) : |
55 CodedAudioFileReader(mode, targetRate), | 55 CodedAudioFileReader(mode, targetRate), |
56 m_path(path), | 56 m_source(source), |
57 m_path(source.getLocalFilename()), | |
57 m_d(new D), | 58 m_d(new D), |
58 m_progress(0), | 59 m_progress(0), |
59 m_cancelled(false), | 60 m_cancelled(false), |
60 m_completion(0), | 61 m_completion(0), |
61 m_decodeThread(0) | 62 m_decodeThread(0) |
63 m_channelCount = 0; | 64 m_channelCount = 0; |
64 m_fileRate = 0; | 65 m_fileRate = 0; |
65 | 66 |
66 Profiler profiler("QuickTimeFileReader::QuickTimeFileReader", true); | 67 Profiler profiler("QuickTimeFileReader::QuickTimeFileReader", true); |
67 | 68 |
68 std::cerr << "QuickTimeFileReader: path is \"" << path.toStdString() << "\"" << std::endl; | 69 std::cerr << "QuickTimeFileReader: path is \"" << m_path.toStdString() << "\"" << std::endl; |
69 | 70 |
70 long QTversion; | 71 long QTversion; |
71 | 72 |
72 #ifdef WIN32 | 73 #ifdef WIN32 |
73 InitializeQTML(0); // FIXME should check QT version | 74 InitializeQTML(0); // FIXME should check QT version |
88 // (0, m_path.toLocal8Bit().data(), 0); | 89 // (0, m_path.toLocal8Bit().data(), 0); |
89 | 90 |
90 | 91 |
91 CFURLRef url = CFURLCreateFromFileSystemRepresentation | 92 CFURLRef url = CFURLCreateFromFileSystemRepresentation |
92 (kCFAllocatorDefault, | 93 (kCFAllocatorDefault, |
93 (const UInt8 *)path.toLocal8Bit().data(), | 94 (const UInt8 *)m_path.toLocal8Bit().data(), |
94 (CFIndex)path.length(), | 95 (CFIndex)m_path.length(), |
95 false); | 96 false); |
96 | 97 |
97 | 98 |
98 // m_d->err = QTNewDataReferenceFromURLCFString | 99 // m_d->err = QTNewDataReferenceFromURLCFString |
99 m_d->err = QTNewDataReferenceFromCFURL | 100 m_d->err = QTNewDataReferenceFromCFURL |
214 initialiseDecodeCache(); | 215 initialiseDecodeCache(); |
215 | 216 |
216 if (decodeMode == DecodeAtOnce) { | 217 if (decodeMode == DecodeAtOnce) { |
217 | 218 |
218 m_progress = new QProgressDialog | 219 m_progress = new QProgressDialog |
219 (QObject::tr("Decoding %1...").arg(QFileInfo(path).fileName()), | 220 (QObject::tr("Decoding %1...").arg(QFileInfo(m_path).fileName()), |
220 QObject::tr("Stop"), 0, 100); | 221 QObject::tr("Stop"), 0, 100); |
221 m_progress->hide(); | 222 m_progress->hide(); |
222 | 223 |
223 while (1) { | 224 while (1) { |
224 | 225 |
333 extensions.insert("mp3"); | 334 extensions.insert("mp3"); |
334 extensions.insert("mp4"); | 335 extensions.insert("mp4"); |
335 extensions.insert("wav"); | 336 extensions.insert("wav"); |
336 } | 337 } |
337 | 338 |
339 bool | |
340 QuickTimeFileReader::supportsExtension(QString extension) | |
341 { | |
342 std::set<QString> extensions; | |
343 getSupportedExtensions(extensions); | |
344 return (extensions.find(extension.toLower()) != extensions.end()); | |
345 } | |
346 | |
347 bool | |
348 QuickTimeFileReader::supportsContentType(QString type) | |
349 { | |
350 return (type == "audio/x-aiff" || | |
351 type == "audio/x-wav" || | |
352 type == "audio/mpeg" || | |
353 type == "audio/basic" || | |
354 type == "audio/x-aac" || | |
355 type == "video/mp4" || | |
356 type == "video/quicktime"); | |
357 } | |
358 | |
359 bool | |
360 QuickTimeFileReader::supports(RemoteFile &source) | |
361 { | |
362 return (supportsExtension(source.getExtension()) || | |
363 supportsContentType(source.getContentType())); | |
364 } | |
365 | |
338 #endif | 366 #endif |
339 | 367 |