Changeset 846 for trunk/src/3rdparty/phonon/mmf
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 23 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp
r769 r846 185 185 { 186 186 // Default implementation 187 Q_UNUSED(param) 188 Q_UNUSED(value) 187 189 Q_ASSERT_X(false, Q_FUNC_INFO, "Effect has no parameters"); 188 190 return 0; -
trunk/src/3rdparty/phonon/mmf/abstractaudioeffect.h
r769 r846 119 119 // in the implementations of the backend effect nodes. 120 120 121 #ifdef Q_CC_NOKIAX86 122 # pragma warn_illtokenpasting off 123 #endif 124 121 125 #define PHONON_MMF_DEFINE_EFFECT_FUNCTIONS(Effect) \ 122 126 \ -
trunk/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp
r769 r846 17 17 */ 18 18 19 #include <QResource> 19 20 #include <QUrl> 20 21 … … 23 24 #include "mediaobject.h" 24 25 #include "utils.h" 26 #include <cdbcols.h> 27 #include <cdblen.h> 28 #include <commdb.h> 25 29 26 30 QT_BEGIN_NAMESPACE … … 51 55 , m_pending(NothingPending) 52 56 , m_positionTimer(new QTimer(this)) 57 , m_position(0) 53 58 , m_bufferStatusTimer(new QTimer(this)) 54 59 , m_mmfMaxVolume(NullMaxVolume) 55 60 , m_prefinishMarkSent(false) 56 61 , m_aboutToFinishSent(false) 62 #ifdef PHONON_MMF_PROGRESSIVE_DOWNLOAD 63 , m_download(0) 64 , m_downloadStalled(false) 65 #endif 57 66 { 58 67 connect(m_positionTimer.data(), SIGNAL(timeout()), this, SLOT(positionTick())); … … 183 192 184 193 doSeek(ms); 194 m_position = ms; 185 195 resetMarksIfRewound(); 186 196 … … 207 217 } 208 218 219 qint64 MMF::AbstractMediaPlayer::currentTime() const 220 { 221 return m_position; 222 } 223 209 224 void MMF::AbstractMediaPlayer::doSetTickInterval(qint32 interval) 210 225 { … … 217 232 } 218 233 219 void MMF::AbstractMediaPlayer::open(const MediaSource &source, RFile& file) 220 { 221 TRACE_CONTEXT(AbstractMediaPlayer::setFileSource, EAudioApi); 234 void MMF::AbstractMediaPlayer::open() 235 { 236 TRACE_CONTEXT(AbstractMediaPlayer::open, EAudioApi); 237 const MediaSource source = m_parent->source(); 222 238 TRACE_ENTRY("state %d source.type %d", privateState(), source.type()); 223 239 … … 230 246 switch (source.type()) { 231 247 case MediaSource::LocalFile: { 232 symbianErr = openFile(file); 248 RFile *const file = m_parent->file(); 249 Q_ASSERT(file); 250 symbianErr = openFile(*file); 233 251 if (KErrNone != symbianErr) 234 252 errorMessage = tr("Error opening file"); … … 238 256 case MediaSource::Url: { 239 257 const QUrl url(source.url()); 240 241 258 if (url.scheme() == QLatin1String("file")) { 242 symbianErr = openFile(file); 259 RFile *const file = m_parent->file(); 260 Q_ASSERT(file); 261 symbianErr = openFile(*file); 243 262 if (KErrNone != symbianErr) 244 263 errorMessage = tr("Error opening file"); 245 } else { 246 symbianErr = openUrl(url.toString()); 264 } 265 #ifdef PHONON_MMF_PROGRESSIVE_DOWNLOAD 266 else if (url.scheme() == QLatin1String("http")) { 267 Q_ASSERT(!m_download); 268 m_download = new Download(url, this); 269 connect(m_download, SIGNAL(lengthChanged(qint64)), 270 this, SLOT(downloadLengthChanged(qint64))); 271 connect(m_download, SIGNAL(stateChanged(Download::State)), 272 this, SLOT(downloadStateChanged(Download::State))); 273 int iap = m_parent->currentIAP(); 274 TRACE("HTTP Url: Using IAP %d", iap); 275 m_download->start(iap); 276 } 277 #endif 278 else { 279 int iap = m_parent->currentIAP(); 280 TRACE("Using IAP %d", iap); 281 symbianErr = openUrl(url.toString(), iap); 247 282 if (KErrNone != symbianErr) 248 283 errorMessage = tr("Error opening URL"); 249 284 } 250 285 286 break; 287 } 288 289 case MediaSource::Stream: { 290 QResource *const resource = m_parent->resource(); 291 if (resource) { 292 m_buffer.Set(resource->data(), resource->size()); 293 symbianErr = openDescriptor(m_buffer); 294 if (KErrNone != symbianErr) 295 errorMessage = tr("Error opening resource"); 296 } else { 297 errorMessage = tr("Error opening source: resource not opened"); 298 } 251 299 break; 252 300 } … … 271 319 } 272 320 321 void MMF::AbstractMediaPlayer::close() 322 { 323 doClose(); 324 #ifdef PHONON_MMF_PROGRESSIVE_DOWNLOAD 325 delete m_download; 326 m_download = 0; 327 #endif 328 m_position = 0; 329 } 330 273 331 void MMF::AbstractMediaPlayer::volumeChanged(qreal volume) 274 332 { … … 357 415 stopBufferStatusTimer(); 358 416 emit MMF::AbstractPlayer::bufferStatus(100); 359 changeState(m_stateBeforeBuffering); 417 if (!progressiveDownloadStalled()) 418 changeState(m_stateBeforeBuffering); 360 419 } 361 420 … … 368 427 void MMF::AbstractMediaPlayer::loadingComplete(int error) 369 428 { 370 Q_ASSERT(Phonon::LoadingState == state()); 371 372 if (KErrNone == error) { 373 updateMetaData(); 374 changeState(StoppedState); 429 TRACE_CONTEXT(AbstractMediaPlayer::loadingComplete, EAudioApi); 430 TRACE_ENTRY("state %d error %d", state(), error); 431 if (progressiveDownloadStalled()) { 432 Q_ASSERT(Phonon::BufferingState == state()); 433 if (KErrNone == error) { 434 bufferingComplete(); 435 doSeek(m_position); 436 startPlayback(); 437 #ifdef PHONON_MMF_PROGRESSIVE_DOWNLOAD 438 m_downloadStalled = false; 439 #endif 440 } 375 441 } else { 376 setError(tr("Loading clip failed"), error); 442 Q_ASSERT(Phonon::LoadingState == state()); 443 if (KErrNone == error) { 444 updateMetaData(); 445 changeState(StoppedState); 446 } else { 447 if (isProgressiveDownload() && KErrCorrupt == error) { 448 setProgressiveDownloadStalled(); 449 } else { 450 setError(tr("Loading clip failed"), error); 451 } 452 } 377 453 } 378 454 } … … 398 474 } 399 475 else { 400 setError(tr("Playback complete"), error); 401 emit finished(); 476 if (isProgressiveDownload() && KErrCorrupt == error) { 477 setProgressiveDownloadStalled(); 478 } else { 479 setError(tr("Playback complete"), error); 480 emit finished(); 481 } 402 482 } 403 483 } … … 408 488 } 409 489 490 bool MMF::AbstractMediaPlayer::isProgressiveDownload() const 491 { 492 #ifdef PHONON_MMF_PROGRESSIVE_DOWNLOAD 493 return (0 != m_download); 494 #else 495 return false; 496 #endif 497 } 498 499 bool MMF::AbstractMediaPlayer::progressiveDownloadStalled() const 500 { 501 #ifdef PHONON_MMF_PROGRESSIVE_DOWNLOAD 502 return m_downloadStalled; 503 #else 504 return false; 505 #endif 506 } 507 410 508 //----------------------------------------------------------------------------- 411 509 // Slots … … 414 512 void MMF::AbstractMediaPlayer::positionTick() 415 513 { 416 const qint64 current = currentTime(); 417 emitMarksIfReached(current); 418 emit MMF::AbstractPlayer::tick(current); 514 const qint64 pos = getCurrentTime(); 515 if (pos > m_position) { 516 m_position = pos; 517 emitMarksIfReached(m_position); 518 emit MMF::AbstractPlayer::tick(m_position); 519 } 419 520 } 420 521 … … 441 542 void MMF::AbstractMediaPlayer::resetMarksIfRewound() 442 543 { 443 const qint64 current = currentTime();544 const qint64 current = getCurrentTime(); 444 545 const qint64 total = totalTime(); 445 546 const qint64 remaining = total - current; … … 470 571 } 471 572 573 void MMF::AbstractMediaPlayer::setProgressiveDownloadStalled() 574 { 575 #ifdef PHONON_MMF_PROGRESSIVE_DOWNLOAD 576 TRACE_CONTEXT(AbstractMediaPlayer::setProgressiveDownloadStalled, EAudioApi); 577 TRACE_ENTRY("state %d", state()); 578 Q_ASSERT(isProgressiveDownload()); 579 m_downloadStalled = true; 580 doClose(); 581 bufferingStarted(); 582 // Video player loses window handle when closed - need to reapply it here 583 videoOutputChanged(); 584 m_download->resume(); 585 #endif 586 } 587 472 588 void MMF::AbstractMediaPlayer::bufferStatusTick() 473 589 { 474 emit MMF::AbstractPlayer::bufferStatus(bufferStatus()); 475 } 590 // During progressive download, there is no way to detect the buffering status. 591 // Phonon does not support a "buffering; amount unknown" signal, therefore we 592 // return a buffering status of zero. 593 const int status = progressiveDownloadStalled() ? 0 : bufferStatus(); 594 emit MMF::AbstractPlayer::bufferStatus(status); 595 } 596 597 #ifdef PHONON_MMF_PROGRESSIVE_DOWNLOAD 598 void MMF::AbstractMediaPlayer::downloadLengthChanged(qint64 length) 599 { 600 TRACE_CONTEXT(AbstractMediaPlayer::downloadLengthChanged, EAudioApi); 601 TRACE_ENTRY("length %Ld", length); 602 Q_UNUSED(length) 603 if (m_downloadStalled) { 604 bufferingComplete(); 605 int err = m_parent->openFileHandle(m_download->targetFileName()); 606 if (KErrNone == err) 607 err = openFile(*m_parent->file()); 608 if (KErrNone != err) 609 setError(tr("Error opening file")); 610 } 611 } 612 613 void MMF::AbstractMediaPlayer::downloadStateChanged(Download::State state) 614 { 615 TRACE_CONTEXT(AbstractMediaPlayer::downloadStateChanged, EAudioApi); 616 TRACE_ENTRY("state %d", state); 617 switch (state) { 618 case Download::Idle: 619 case Download::Initializing: 620 break; 621 case Download::Downloading: 622 { 623 int err = m_parent->openFileHandle(m_download->targetFileName()); 624 if (KErrNone == err) 625 err = openFile(*m_parent->file()); 626 else if (KErrCorrupt == err) 627 // Insufficient data downloaded - enter Buffering state 628 setProgressiveDownloadStalled(); 629 if (KErrNone != err) 630 setError(tr("Error opening file")); 631 } 632 break; 633 case Download::Complete: 634 break; 635 case Download::Error: 636 setError(tr("Download error")); 637 break; 638 } 639 } 640 #endif // PHONON_MMF_PROGRESSIVE_DOWNLOAD 476 641 477 642 Phonon::State MMF::AbstractMediaPlayer::phononState(PrivateState state) const -
trunk/src/3rdparty/phonon/mmf/abstractmediaplayer.h
r769 r846 24 24 #include <e32std.h> 25 25 #include "abstractplayer.h" 26 #ifdef PHONON_MMF_PROGRESSIVE_DOWNLOAD 27 # include "download.h" 28 #endif 26 29 27 30 class RFile; … … 48 51 49 52 public: 50 virtual void open(const Phonon::MediaSource&, RFile&); 53 virtual void open(); 54 virtual void close(); 51 55 52 56 // MediaObjectInterface … … 56 60 virtual void seek(qint64 milliseconds); 57 61 virtual bool isSeekable() const; 62 virtual qint64 currentTime() const; 58 63 virtual void volumeChanged(qreal volume); 59 64 … … 69 74 virtual void doSeek(qint64 pos) = 0; 70 75 virtual int setDeviceVolume(int mmfVolume) = 0; 76 virtual int openFile(const QString &fileName) = 0; 71 77 virtual int openFile(RFile& file) = 0; 72 virtual int openUrl(const QString& url) = 0; 78 virtual int openUrl(const QString& url, int iap) = 0; 79 virtual int openDescriptor(const TDesC8 &des) = 0; 73 80 virtual int bufferStatus() const = 0; 74 virtual void close() = 0;81 virtual void doClose() = 0; 75 82 76 83 void updateMetaData(); 84 virtual qint64 getCurrentTime() const = 0; 77 85 virtual int numberOfMetaDataEntries() const = 0; 78 86 virtual QPair<QString, QString> metaDataEntry(int index) const = 0; … … 87 95 static qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &); 88 96 97 bool isProgressiveDownload() const; 98 bool progressiveDownloadStalled() const; 99 89 100 private: 90 101 void startPositionTimer(); … … 97 108 void resetMarksIfRewound(); 98 109 void startPlayback(); 110 void setProgressiveDownloadStalled(); 99 111 100 112 enum Pending { … … 109 121 void positionTick(); 110 122 void bufferStatusTick(); 123 #ifdef PHONON_MMF_PROGRESSIVE_DOWNLOAD 124 void downloadLengthChanged(qint64); 125 void downloadStateChanged(Download::State); 126 #endif 111 127 112 128 private: … … 116 132 117 133 QScopedPointer<QTimer> m_positionTimer; 134 qint64 m_position; 118 135 119 136 QScopedPointer<QTimer> m_bufferStatusTimer; … … 124 141 bool m_prefinishMarkSent; 125 142 bool m_aboutToFinishSent; 143 144 // Used for playback of resource files 145 TPtrC8 m_buffer; 146 147 #ifdef PHONON_MMF_PROGRESSIVE_DOWNLOAD 148 Download *m_download; 149 bool m_downloadStalled; 150 #endif 126 151 127 152 QMultiMap<QString, QString> m_metaData; -
trunk/src/3rdparty/phonon/mmf/abstractplayer.h
r769 r846 27 27 #include "abstractvideooutput.h" 28 28 29 class RFile;30 31 29 QT_BEGIN_NAMESPACE 32 30 … … 55 53 AbstractPlayer(const AbstractPlayer *player); 56 54 57 virtual void open(const Phonon::MediaSource&, RFile&) = 0; 55 virtual void open() = 0; 56 virtual void close() = 0; 58 57 59 58 // MediaObjectInterface (implemented) -
trunk/src/3rdparty/phonon/mmf/abstractvideooutput.cpp
r769 r846 61 61 , m_scaleMode(DefaultScaleMode) 62 62 { 63 63 // Ensure that this widget has a native window handle 64 winId(); 64 65 } 65 66 … … 161 162 #ifndef QT_NO_DEBUG 162 163 TRACE_CONTEXT(AbstractVideoOutput::dump, EVideoInternal); 163 164 164 QScopedPointer<ObjectDump::QVisitor> visitor(new ObjectDump::QVisitor); 165 165 visitor->setPrefix("Phonon::MMF"); // to aid searchability of logs 166 166 ObjectDump::addDefaultAnnotators(*visitor); 167 168 if (QWidget *window = QApplication::activeWindow()) {169 TRACE("Dumping from root window 0x%08x:", window);170 ObjectDump::dumpTreeFromLeaf(*window, *visitor);171 }172 173 TRACE("Dumping tree from leaf 0x%08x:", this);174 167 ObjectDump::dumpTreeFromLeaf(*this, *visitor); 175 176 QScopedPointer<ObjectDump::QDumper> dumper(new ObjectDump::QDumper);177 dumper->setPrefix("Phonon::MMF"); // to aid searchability of logs178 ObjectDump::addDefaultAnnotators(*dumper);179 TRACE_0("Dumping AbstractVideoOutput:");180 dumper->dumpObject(*this);181 168 #endif 182 169 } -
trunk/src/3rdparty/phonon/mmf/abstractvideoplayer.cpp
r769 r846 17 17 */ 18 18 19 #include <QDir> 19 20 #include <QUrl> 20 21 #include <QTimer> … … 67 68 createPlayer(); 68 69 70 m_player->RegisterForVideoLoadingNotification(*this); 71 69 72 TRACE_EXIT_0(); 70 73 } … … 131 134 } 132 135 136 int MMF::AbstractVideoPlayer::openFile(const QString &fileName) 137 { 138 const QHBufC nativeFileName(QDir::toNativeSeparators(fileName)); 139 TRAPD(err, m_player->OpenFileL(*nativeFileName)); 140 return err; 141 } 142 133 143 int MMF::AbstractVideoPlayer::openFile(RFile &file) 134 144 { … … 137 147 } 138 148 139 int MMF::AbstractVideoPlayer::openUrl(const QString &url) 140 { 141 TRAPD(err, m_player->OpenUrlL(qt_QString2TPtrC(url))); 149 int MMF::AbstractVideoPlayer::openUrl(const QString &url, int iap) 150 { 151 TRAPD(err, m_player->OpenUrlL(qt_QString2TPtrC(url), iap)); 152 return err; 153 } 154 155 int MMF::AbstractVideoPlayer::openDescriptor(const TDesC8 &des) 156 { 157 TRAPD(err, m_player->OpenDesL(des)); 142 158 return err; 143 159 } … … 150 166 } 151 167 152 void MMF::AbstractVideoPlayer:: close()168 void MMF::AbstractVideoPlayer::doClose() 153 169 { 154 170 m_player->Close(); … … 160 176 } 161 177 162 qint64 MMF::AbstractVideoPlayer:: currentTime() const163 { 164 TRACE_CONTEXT(AbstractVideoPlayer:: currentTime, EVideoApi);178 qint64 MMF::AbstractVideoPlayer::getCurrentTime() const 179 { 180 TRACE_CONTEXT(AbstractVideoPlayer::getCurrentTime, EVideoApi); 165 181 166 182 TTimeIntervalMicroSeconds us; … … 212 228 TRACE_ENTRY("state %d aspectRatio %d", state()); 213 229 214 updateScaleFactors(m_videoOutput->videoWindowSize()); 230 if (m_videoOutput) 231 updateScaleFactors(m_videoOutput->videoWindowSize()); 215 232 216 233 TRACE_EXIT_0(); … … 222 239 TRACE_ENTRY("state %d", state()); 223 240 224 updateScaleFactors(m_videoOutput->videoWindowSize()); 241 if (m_videoOutput) 242 updateScaleFactors(m_videoOutput->videoWindowSize()); 225 243 226 244 TRACE_EXIT_0(); … … 237 255 TRACE_ENTRY("state %d error %d", state(), aError); 238 256 239 __ASSERT_ALWAYS(LoadingState == state(), Utils::panic(InvalidStatePanic)); 257 __ASSERT_ALWAYS(LoadingState == state() || 258 progressiveDownloadStalled() && BufferingState == state(), 259 Utils::panic(InvalidStatePanic)); 240 260 241 261 if (KErrNone == aError) … … 252 272 TRACE_ENTRY("state %d error %d", state(), aError); 253 273 254 __ASSERT_ALWAYS(LoadingState == state(), Utils::panic(InvalidStatePanic)); 274 __ASSERT_ALWAYS(LoadingState == state() || 275 progressiveDownloadStalled() && BufferingState == state(), 276 Utils::panic(InvalidStatePanic)); 255 277 256 278 TRAPD(err, getVideoClipParametersL(aError)); … … 358 380 void MMF::AbstractVideoPlayer::initVideoOutput() 359 381 { 382 Q_ASSERT(m_videoOutput); 383 360 384 bool connected = connect( 361 385 m_videoOutput, SIGNAL(videoWindowChanged()), … … 379 403 Q_UNUSED(connected); 380 404 381 // Do these after all connections are complete, to ensure382 // that any signals generated get to their destinations.383 m_videoOutput->winId();384 405 m_videoOutput->setVideoSize(m_videoFrameSize); 385 406 } … … 401 422 void MMF::AbstractVideoPlayer::updateScaleFactors(const QSize &windowSize, bool apply) 402 423 { 424 Q_ASSERT(m_videoOutput); 425 403 426 if (m_videoFrameSize.isValid()) { 404 427 QRect videoRect; … … 460 483 void MMF::AbstractVideoPlayer::parametersChanged(VideoParameters parameters) 461 484 { 462 if (state() == LoadingState )485 if (state() == LoadingState || progressiveDownloadStalled() && BufferingState == state()) 463 486 m_pendingChanges |= parameters; 464 487 else -
trunk/src/3rdparty/phonon/mmf/abstractvideoplayer.h
r769 r846 65 65 virtual void doSeek(qint64 milliseconds); 66 66 virtual int setDeviceVolume(int mmfVolume); 67 virtual int openFile(const QString &fileName); 67 68 virtual int openFile(RFile &file); 68 virtual int openUrl(const QString &url); 69 virtual int openUrl(const QString &url, int iap); 70 virtual int openDescriptor(const TDesC8 &des); 69 71 virtual int bufferStatus() const; 70 virtual void close();72 virtual void doClose(); 71 73 72 74 // MediaObjectInterface 73 75 virtual bool hasVideo() const; 74 virtual qint64 currentTime() const;75 76 virtual qint64 totalTime() const; 76 77 … … 79 80 80 81 // AbstractMediaPlayer 82 virtual qint64 getCurrentTime() const; 81 83 virtual int numberOfMetaDataEntries() const; 82 84 virtual QPair<QString, QString> metaDataEntry(int index) const; -
trunk/src/3rdparty/phonon/mmf/audiooutput.cpp
r561 r846 79 79 Q_ASSERT_X(index == AudioOutputDeviceID, Q_FUNC_INFO, 80 80 "We only support one output device, with id 0"); 81 #ifdef QT_NO_DEBUG 82 Q_UNUSED(index) 83 #endif 81 84 return true; 82 85 } -
trunk/src/3rdparty/phonon/mmf/audioplayer.cpp
r769 r846 17 17 */ 18 18 19 #include <QDir> 19 20 #include <QUrl> 20 21 … … 110 111 } 111 112 113 int MMF::AudioPlayer::openFile(const QString &fileName) 114 { 115 const QHBufC nativeFileName(QDir::toNativeSeparators(fileName)); 116 TRAPD(err, m_player->OpenFileL(*nativeFileName)); 117 return err; 118 } 119 112 120 int MMF::AudioPlayer::openFile(RFile& file) 113 121 { … … 127 135 } 128 136 129 int MMF::AudioPlayer::openUrl(const QString& /*url*/ )137 int MMF::AudioPlayer::openUrl(const QString& /*url*/, int /*iap*/) 130 138 { 131 139 // Streaming playback is generally not supported by the implementation … … 138 146 } 139 147 148 int MMF::AudioPlayer::openDescriptor(const TDesC8 &des) 149 { 150 TRAPD(err, m_player->OpenDesL(des)); 151 return err; 152 } 153 140 154 int MMF::AudioPlayer::bufferStatus() const 141 155 { … … 145 159 } 146 160 147 void MMF::AudioPlayer:: close()161 void MMF::AudioPlayer::doClose() 148 162 { 149 163 m_player->Close(); … … 155 169 } 156 170 157 qint64 MMF::AudioPlayer:: currentTime() const158 { 159 TRACE_CONTEXT(AudioPlayer:: currentTime, EAudioApi);171 qint64 MMF::AudioPlayer::getCurrentTime() const 172 { 173 TRACE_CONTEXT(AudioPlayer::getCurrentTime, EAudioApi); 160 174 161 175 TTimeIntervalMicroSeconds us; … … 198 212 TRACE_ENTRY("state %d error %d", state(), aError); 199 213 200 __ASSERT_ALWAYS(LoadingState == state(), Utils::panic(InvalidStatePanic)); 214 __ASSERT_ALWAYS(LoadingState == state() || 215 progressiveDownloadStalled() && BufferingState == state(), 216 Utils::panic(InvalidStatePanic)); 201 217 202 218 if (KErrNone == aError) { -
trunk/src/3rdparty/phonon/mmf/audioplayer.h
r561 r846 66 66 virtual void doSeek(qint64 milliseconds); 67 67 virtual int setDeviceVolume(int mmfVolume); 68 virtual int openFile(const QString &fileName); 68 69 virtual int openFile(RFile& file); 69 virtual int openUrl(const QString& url); 70 virtual int openUrl(const QString& url, int iap); 71 virtual int openDescriptor(const TDesC8 &des); 70 72 virtual int bufferStatus() const; 71 virtual void close();73 virtual void doClose(); 72 74 73 75 // MediaObjectInterface 74 76 virtual bool hasVideo() const; 75 virtual qint64 currentTime() const;76 77 virtual qint64 totalTime() const; 77 78 78 79 // AbstractMediaPlayer 80 virtual qint64 getCurrentTime() const; 79 81 virtual int numberOfMetaDataEntries() const; 80 82 virtual QPair<QString, QString> metaDataEntry(int index) const; -
trunk/src/3rdparty/phonon/mmf/bassboost.cpp
r651 r846 50 50 QList<EffectParameter> ¶meters) 51 51 { 52 Q_UNUSED(parameters) 52 53 QScopedPointer<CBassBoost> effect; 53 54 TRAPD(err, effect.reset(CBassBoost::NewL(*stream))); -
trunk/src/3rdparty/phonon/mmf/dummyplayer.cpp
r561 r846 93 93 } 94 94 95 void MMF::DummyPlayer::open( const Phonon::MediaSource &, RFile &)95 void MMF::DummyPlayer::open() 96 96 { 97 97 98 98 } 99 99 100 void MMF::DummyPlayer::close() 101 { 102 103 } 100 104 101 105 //----------------------------------------------------------------------------- -
trunk/src/3rdparty/phonon/mmf/dummyplayer.h
r561 r846 58 58 59 59 // AbstractPlayer 60 virtual void open(const Phonon::MediaSource&, RFile&); 60 virtual void open(); 61 virtual void close(); 61 62 virtual void doSetTickInterval(qint32 interval); 62 63 }; -
trunk/src/3rdparty/phonon/mmf/effectfactory.cpp
r651 r846 184 184 data.m_parameters.append(param); 185 185 186 if (data.m_supported = BackendNode::getParameters 187 (stream.data(), data.m_parameters)) { 186 data.m_supported = BackendNode::getParameters(stream.data(), 187 data.m_parameters); 188 if (data.m_supported) { 188 189 const QString description = QCoreApplication::translate 189 190 ("Phonon::MMF::EffectFactory", BackendNode::description()); -
trunk/src/3rdparty/phonon/mmf/loudness.cpp
r651 r846 50 50 QList<EffectParameter> ¶meters) 51 51 { 52 Q_UNUSED(parameters) 52 53 QScopedPointer<CLoudness> effect; 53 54 TRAPD(err, effect.reset(CLoudness::NewL(*stream))); -
trunk/src/3rdparty/phonon/mmf/mediaobject.cpp
r769 r846 35 35 36 36 #include <QDir> 37 #include <QResource> 37 38 #include <QUrl> 39 #include <cdbcols.h> 40 #include <cdblen.h> 41 #include <commdb.h> 42 #include <mmf/common/mmfcontrollerframeworkbase.h> 38 43 39 44 QT_BEGIN_NAMESPACE … … 53 58 , m_recognizerOpened(false) 54 59 , m_nextSourceSet(false) 60 , m_file(0) 61 , m_resource(0) 55 62 { 56 63 m_player.reset(new DummyPlayer()); … … 59 66 TRACE_ENTRY_0(); 60 67 61 Q_UNUSED(parent); 68 const int err = m_fileServer.Connect(); 69 QT_TRAP_THROWING(User::LeaveIfError(err)); 70 71 parent->installEventFilter(this); 72 m_iap = KUseDefaultIap; 62 73 63 74 TRACE_EXIT_0(); … … 69 80 TRACE_ENTRY_0(); 70 81 71 m_file.Close(); 82 parent()->removeEventFilter(this); 83 delete m_resource; 84 85 if (m_file) 86 m_file->Close(); 87 delete m_file; 88 72 89 m_fileServer.Close(); 73 90 m_recognizer.Close(); … … 89 106 if (KErrNone != err) { 90 107 TRACE("RApaLsSession::Connect error %d", err); 91 return false;92 }93 94 err = m_fileServer.Connect();95 if (KErrNone != err) {96 TRACE("RFs::Connect error %d", err);97 108 return false; 98 109 } … … 120 131 121 132 if (openRecognizer()) { 122 123 const QHBufC fileNameSymbian(QDir::toNativeSeparators(fileName)); 124 125 m_file.Close(); 126 TInt err = m_file.Open(m_fileServer, *fileNameSymbian, EFileRead | EFileShareReadersOnly); 127 133 TInt err = openFileHandle(fileName); 134 const QHBufC nativeFileName(QDir::toNativeSeparators(fileName)); 128 135 if (KErrNone == err) { 129 136 TDataRecognitionResult recognizerResult; 130 err = m_recognizer.RecognizeData( m_file, recognizerResult);137 err = m_recognizer.RecognizeData(*m_file, recognizerResult); 131 138 if (KErrNone == err) { 132 139 const TPtrC mimeType = recognizerResult.iDataType.Des(); 133 140 result = Utils::mimeTypeToMediaType(mimeType); 134 141 } else { 135 TRACE("RApaLsSession::RecognizeData filename %S error %d", fileNameSymbian.data(), err);142 TRACE("RApaLsSession::RecognizeData filename %S error %d", nativeFileName.data(), err); 136 143 } 137 144 } else { 138 TRACE("RFile::Open filename %S error %d", fileNameSymbian.data(), err);145 TRACE("RFile::Open filename %S error %d", nativeFileName.data(), err); 139 146 } 140 147 } … … 143 150 } 144 151 152 int MMF::MediaObject::openFileHandle(const QString &fileName) 153 { 154 TRACE_CONTEXT(MediaObject::openFileHandle, EAudioInternal); 155 const QHBufC nativeFileName(QDir::toNativeSeparators(fileName)); 156 TRACE_ENTRY("filename %S", nativeFileName.data()); 157 if (m_file) 158 m_file->Close(); 159 delete m_file; 160 m_file = 0; 161 m_file = new RFile; 162 TInt err = m_file->Open(m_fileServer, *nativeFileName, EFileRead | EFileShareReadersOrWriters); 163 return err; 164 } 165 166 MMF::MediaType MMF::MediaObject::bufferMediaType(const uchar *data, qint64 size) 167 { 168 TRACE_CONTEXT(MediaObject::bufferMediaType, EAudioInternal); 169 MediaType result = MediaTypeUnknown; 170 if (openRecognizer()) { 171 TDataRecognitionResult recognizerResult; 172 const TPtrC8 des(data, size); 173 const TInt err = m_recognizer.RecognizeData(KNullDesC, des, recognizerResult); 174 if (KErrNone == err) { 175 const TPtrC mimeType = recognizerResult.iDataType.Des(); 176 result = Utils::mimeTypeToMediaType(mimeType); 177 } else { 178 TRACE("RApaLsSession::RecognizeData error %d", err); 179 } 180 } 181 return result; 182 } 145 183 146 184 //----------------------------------------------------------------------------- … … 229 267 void MMF::MediaObject::switchToSource(const MediaSource &source) 230 268 { 269 if (m_file) 270 m_file->Close(); 271 delete m_file; 272 m_file = 0; 273 274 delete m_resource; 275 m_resource = 0; 276 231 277 createPlayer(source); 232 278 m_source = source; 233 m_player->open( m_source, m_file);279 m_player->open(); 234 280 emit currentSourceChanged(m_source); 235 281 } … … 273 319 case MediaSource::Invalid: 274 320 case MediaSource::Disc: 321 errorMessage = tr("Error opening source: type not supported"); 322 break; 323 275 324 case MediaSource::Stream: 276 errorMessage = tr("Error opening source: type not supported"); 325 { 326 const QString fileName = source.url().toLocalFile(); 327 if (fileName.startsWith(QLatin1String(":/")) || fileName.startsWith(QLatin1String("qrc://"))) { 328 Q_ASSERT(!m_resource); 329 m_resource = new QResource(fileName); 330 if (m_resource->isValid()) { 331 if (m_resource->isCompressed()) 332 errorMessage = tr("Error opening source: resource is compressed"); 333 else 334 mediaType = bufferMediaType(m_resource->data(), m_resource->size()); 335 } else { 336 errorMessage = tr("Error opening source: resource not valid"); 337 } 338 } else { 339 errorMessage = tr("Error opening source: type not supported"); 340 } 341 } 277 342 break; 278 343 … … 281 346 break; 282 347 } 348 349 if (oldPlayer) 350 oldPlayer->close(); 283 351 284 352 AbstractPlayer* newPlayer = 0; … … 372 440 } 373 441 442 RFile* MMF::MediaObject::file() const 443 { 444 return m_file; 445 } 446 447 QResource* MMF::MediaObject::resource() const 448 { 449 return m_resource; 450 } 451 374 452 //----------------------------------------------------------------------------- 375 453 // MediaNode … … 422 500 423 501 //----------------------------------------------------------------------------- 502 // IAP support 503 //----------------------------------------------------------------------------- 504 505 int MMF::MediaObject::currentIAP() const 506 { 507 return m_iap; 508 } 509 510 bool MMF::MediaObject::eventFilter(QObject *watched, QEvent *event) 511 { 512 if (event->type() == QEvent::DynamicPropertyChange ) { 513 QDynamicPropertyChangeEvent* dynamicEvent = static_cast<QDynamicPropertyChangeEvent*>(event); 514 if (dynamicEvent->propertyName() == "InternetAccessPointName") { 515 QVariant value = watched->property("InternetAccessPointName"); 516 if (value.isValid()) { 517 QString iapName = value.toString(); 518 TRAPD(err, setIAPIdFromNameL(iapName)); 519 if (err) 520 m_player->setError(tr("Failed to set requested IAP"), err); 521 } 522 } 523 } 524 return false; 525 } 526 527 void MMF::MediaObject::setIAPIdFromNameL(const QString& iapString) 528 { 529 TRACE_CONTEXT(MediaObject::getIapIdFromName, EVideoInternal); 530 TBuf<KCommsDbSvrMaxColumnNameLength> iapDes = qt_QString2TPtrC(iapString); 531 CCommsDatabase *commsDb = CCommsDatabase::NewL(EDatabaseTypeIAP); 532 CleanupStack::PushL(commsDb); 533 commsDb->ShowHiddenRecords(); 534 CCommsDbTableView *view = commsDb->OpenTableLC(TPtrC(IAP)); 535 for (TInt l = view->GotoFirstRecord(); l != KErrNotFound; l = view->GotoNextRecord()) { 536 TBuf<KCommsDbSvrMaxColumnNameLength> iapName; 537 view->ReadTextL(TPtrC(COMMDB_NAME), iapName); 538 TRACE("found IAP %S", &iapName); 539 if (iapName.CompareF(iapDes) == 0) { 540 TUint32 uiap; 541 view->ReadUintL(TPtrC(COMMDB_ID), uiap); 542 TRACE("matched IAP %S, setting m_iap %d", &iapName, uiap); 543 m_iap = uiap; 544 break; 545 } 546 } 547 CleanupStack::PopAndDestroy(2); // commsDb, view 548 } 549 550 //----------------------------------------------------------------------------- 424 551 // Other private functions 425 552 //----------------------------------------------------------------------------- -
trunk/src/3rdparty/phonon/mmf/mediaobject.h
r769 r846 24 24 #include <QScopedPointer> 25 25 #include <QTimer> 26 #include <QString> 26 27 27 28 // For recognizer … … 33 34 34 35 QT_BEGIN_NAMESPACE 36 37 class QResource; 35 38 36 39 namespace Phonon … … 88 91 void setVideoOutput(AbstractVideoOutput* videoOutput); 89 92 93 int openFileHandle(const QString &fileName); 94 RFile* file() const; 95 QResource* resource() const; 96 int currentIAP() const; 97 90 98 public Q_SLOTS: 91 99 void volumeChanged(qreal volume); … … 108 116 void tick(qint64 time); 109 117 118 protected: 119 bool eventFilter(QObject *watched, QEvent *event); 120 110 121 private Q_SLOTS: 111 122 void handlePrefinishMarkReached(qint32); … … 115 126 void createPlayer(const MediaSource &source); 116 127 bool openRecognizer(); 128 void setIAPIdFromNameL(const QString& iapString); 117 129 118 130 // Audio / video media type recognition 119 131 MediaType fileMediaType(const QString& fileName); 132 MediaType bufferMediaType(const uchar *data, qint64 size); 120 133 // TODO: urlMediaType function 121 134 … … 133 146 bool m_nextSourceSet; 134 147 135 // Storing the file handle here to work around KErrInUse error 136 // from MMF player utility OpenFileL functions 137 RFile m_file; 148 RFile* m_file; 149 QResource* m_resource; 138 150 139 151 QScopedPointer<AbstractPlayer> m_player; 152 int m_iap; 140 153 141 154 }; -
trunk/src/3rdparty/phonon/mmf/videoplayer_dsa.cpp
r769 r846 62 62 void MMF::DsaVideoPlayer::videoWindowScreenRectChanged() 63 63 { 64 Q_ASSERT(m_videoOutput); 65 64 66 QRect windowRect = static_cast<DsaVideoOutput *>(m_videoOutput)->videoWindowScreenRect(); 65 67 … … 125 127 // CVideoPlayerUtility::NewL starts DSA 126 128 m_dsaActive = true; 127 128 m_player->RegisterForVideoLoadingNotification(*this);129 129 } 130 130 131 131 void MMF::DsaVideoPlayer::initVideoOutput() 132 132 { 133 Q_ASSERT(m_videoOutput); 134 133 135 bool connected = connect( 134 136 m_videoOutput, SIGNAL(videoWindowScreenRectChanged()), … … 157 159 void MMF::DsaVideoPlayer::prepareCompleted() 158 160 { 159 videoWindowScreenRectChanged(); 161 if (m_videoOutput) 162 videoWindowScreenRectChanged(); 160 163 } 161 164 -
trunk/src/3rdparty/phonon/mmf/videoplayer_surface.cpp
r769 r846 60 60 void MMF::SurfaceVideoPlayer::videoWindowSizeChanged() 61 61 { 62 updateScaleFactors(m_videoOutput->videoWindowSize()); 62 if (m_videoOutput) 63 updateScaleFactors(m_videoOutput->videoWindowSize()); 63 64 } 64 65 … … 81 82 void MMF::SurfaceVideoPlayer::initVideoOutput() 82 83 { 84 Q_ASSERT(m_videoOutput); 85 83 86 bool connected = connect( 84 87 m_videoOutput, SIGNAL(videoWindowSizeChanged()), … … 105 108 void MMF::SurfaceVideoPlayer::handleParametersChanged(VideoParameters parameters) 106 109 { 110 TRACE_CONTEXT(SurfaceVideoPlayer::handleParametersChanged, EVideoApi); 111 TRACE_ENTRY("parameters 0x%x", parameters.operator int()); 112 107 113 TRect rect; 108 114 if (m_videoOutput) { … … 116 122 int err = KErrNone; 117 123 if (parameters & WindowHandle) { 118 if (m_displayWindow) 119 player->RemoveDisplayWindow(*m_displayWindow); 120 121 RWindow *window = static_cast<RWindow *>(m_window); 122 if (window) { 123 window->SetBackgroundColor(TRgb(0, 0, 0, 255)); 124 TRAP(err, player->AddDisplayWindowL(m_wsSession, m_screenDevice, *window, rect, rect)); 125 if (KErrNone != err) { 126 setError(tr("Video display error"), err); 127 window = 0; 128 } 129 } 130 m_displayWindow = window; 124 removeDisplayWindow(); 125 addDisplayWindow(rect); 131 126 } 132 127 133 128 if (KErrNone == err) { 134 129 if (parameters & ScaleFactors) { 130 if (!m_displayWindow) 131 addDisplayWindow(rect); 135 132 Q_ASSERT(m_displayWindow); 136 133 TRAP(err, player->SetVideoExtentL(*m_displayWindow, rect)); … … 144 141 } 145 142 } 143 144 TRACE_EXIT_0(); 145 } 146 147 void MMF::SurfaceVideoPlayer::addDisplayWindow(const TRect &rect) 148 { 149 TRACE_CONTEXT(SurfaceVideoPlayer::addDisplayWindow, EVideoApi); 150 TRACE_ENTRY("rect %d %d - %d %d", rect.iTl.iX, rect.iTl.iY, rect.iBr.iX, rect.iBr.iY); 151 152 Q_ASSERT(!m_displayWindow); 153 RWindow *window = static_cast<RWindow *>(m_window); 154 155 TRACE("window 0x%08x", window); 156 157 if (window) { 158 window->SetBackgroundColor(TRgb(0, 0, 0, 255)); 159 CVideoPlayerUtility2 *player = static_cast<CVideoPlayerUtility2 *>(m_player.data()); 160 Q_ASSERT(player); 161 TRAPD(err, player->AddDisplayWindowL(m_wsSession, m_screenDevice, *window, rect, rect)); 162 if (KErrNone == err) 163 m_displayWindow = window; 164 else 165 setError(tr("Video display error"), err); 166 TRACE("err %d", err); 167 } 168 169 TRACE_EXIT_0(); 170 } 171 172 void MMF::SurfaceVideoPlayer::removeDisplayWindow() 173 { 174 TRACE_CONTEXT(SurfaceVideoPlayer::removeDisplayWindow, EVideoApi); 175 TRACE("player 0x%08x window 0x%08x", m_player.data(), m_displayWindow); 176 177 CVideoPlayerUtility2 *player = static_cast<CVideoPlayerUtility2 *>(m_player.data()); 178 if (player && m_displayWindow) { 179 player->RemoveDisplayWindow(*m_displayWindow); 180 m_displayWindow = 0; 181 } 146 182 } 147 183 -
trunk/src/3rdparty/phonon/mmf/videoplayer_surface.h
r769 r846 63 63 void handleParametersChanged(VideoParameters parameters); 64 64 65 void addDisplayWindow(const TRect &rect); 66 void removeDisplayWindow(); 67 65 68 private: 66 69 // Window handle which has been passed to the MMF via -
trunk/src/3rdparty/phonon/mmf/videowidget.cpp
r769 r846 65 65 TRACE_CONTEXT(VideoWidget::VideoWidget, EVideoApi); 66 66 TRACE_ENTRY_0(); 67 68 parent->setProperty("_q_DummyWindowSurface", true); 67 69 68 70 TRACE_EXIT_0();
Note:
See TracChangeset
for help on using the changeset viewer.