comparison data/fileio/QuickTimeFileReader.cpp @ 392:183ee2a55fc7

* More work to abstract out interactive components used in the data library, so that it does not need to depend on QtGui.
author Chris Cannam
date Fri, 14 Mar 2008 17:14:21 +0000
parents b92513201610
children be49bf95d4a5
comparison
equal deleted inserted replaced
391:5858cc462d0a 392:183ee2a55fc7
18 18
19 #ifdef HAVE_QUICKTIME 19 #ifdef HAVE_QUICKTIME
20 20
21 #include "QuickTimeFileReader.h" 21 #include "QuickTimeFileReader.h"
22 #include "base/Profiler.h" 22 #include "base/Profiler.h"
23 #include "base/ProgressReporter.h"
23 #include "system/System.h" 24 #include "system/System.h"
24 25
25 #include <QApplication>
26 #include <QFileInfo> 26 #include <QFileInfo>
27 #include <QProgressDialog>
28 27
29 #ifdef _WIN32 28 #ifdef _WIN32
30 #include <QTML.h> 29 #include <QTML.h>
31 #include <Movies.h> 30 #include <Movies.h>
32 #else 31 #else
49 48
50 49
51 QuickTimeFileReader::QuickTimeFileReader(FileSource source, 50 QuickTimeFileReader::QuickTimeFileReader(FileSource source,
52 DecodeMode decodeMode, 51 DecodeMode decodeMode,
53 CacheMode mode, 52 CacheMode mode,
54 size_t targetRate) : 53 size_t targetRate,
54 ProgressReporter *reporter) :
55 CodedAudioFileReader(mode, targetRate), 55 CodedAudioFileReader(mode, targetRate),
56 m_source(source), 56 m_source(source),
57 m_path(source.getLocalFilename()), 57 m_path(source.getLocalFilename()),
58 m_d(new D), 58 m_d(new D),
59 m_progress(0), 59 m_reporter(reporter),
60 m_cancelled(false), 60 m_cancelled(false),
61 m_completion(0), 61 m_completion(0),
62 m_decodeThread(0) 62 m_decodeThread(0)
63 { 63 {
64 m_channelCount = 0; 64 m_channelCount = 0;
214 214
215 initialiseDecodeCache(); 215 initialiseDecodeCache();
216 216
217 if (decodeMode == DecodeAtOnce) { 217 if (decodeMode == DecodeAtOnce) {
218 218
219 if (dynamic_cast<QApplication *>(QCoreApplication::instance())) { 219 if (m_reporter) {
220 m_progress = new QProgressDialog 220 connect(m_reporter, SIGNAL(cancelled()), this, SLOT(cancelled()));
221 (QObject::tr("Decoding %1...").arg(QFileInfo(m_path).fileName()), 221 m_reporter->setMessage
222 QObject::tr("Stop"), 0, 100); 222 (tr("Decoding %1...").arg(QFileInfo(m_path).fileName()));
223 m_progress->hide();
224 } 223 }
225 224
226 while (1) { 225 while (1) {
227 226
228 UInt32 framesRead = m_d->blockSize; 227 UInt32 framesRead = m_d->blockSize;
253 m_error = QString("Error ending QuickTime extraction session: code %1").arg(m_d->err); 252 m_error = QString("Error ending QuickTime extraction session: code %1").arg(m_d->err);
254 } 253 }
255 254
256 m_completion = 100; 255 m_completion = 100;
257 256
258 delete m_progress;
259 m_progress = 0;
260
261 } else { 257 } else {
258 if (m_reporter) m_reporter->setProgress(100);
259
262 if (m_channelCount > 0) { 260 if (m_channelCount > 0) {
263 m_decodeThread = new DecodeThread(this); 261 m_decodeThread = new DecodeThread(this);
264 m_decodeThread->start(); 262 m_decodeThread->start();
265 } 263 }
266 } 264 }
281 SetMovieActive(m_d->movie, FALSE); 279 SetMovieActive(m_d->movie, FALSE);
282 DisposeMovie(m_d->movie); 280 DisposeMovie(m_d->movie);
283 281
284 delete[] m_d->data; 282 delete[] m_d->data;
285 delete m_d; 283 delete m_d;
284 }
285
286 void
287 QuickTimeFileReader::cancelled()
288 {
289 m_cancelled = true;
286 } 290 }
287 291
288 void 292 void
289 QuickTimeFileReader::DecodeThread::run() 293 QuickTimeFileReader::DecodeThread::run()
290 { 294 {