diff options
author | Justin McPherson <justin.mcpherson@nokia.com> | 2010-03-25 04:28:49 (GMT) |
---|---|---|
committer | Justin McPherson <justin.mcpherson@nokia.com> | 2010-03-25 04:28:49 (GMT) |
commit | b7add13a0c363c9ca435256d879b398b15cb8dca (patch) | |
tree | 3fad08485d2f4c5aab943f74e6aa476119bdb292 /src/3rdparty/phonon/qt7 | |
parent | 19a3fc3bd817628070e5637caf158b0be79eee82 (diff) | |
download | Qt-b7add13a0c363c9ca435256d879b398b15cb8dca.zip Qt-b7add13a0c363c9ca435256d879b398b15cb8dca.tar.gz Qt-b7add13a0c363c9ca435256d879b398b15cb8dca.tar.bz2 |
Update Phonon qt7 backend to 4.4.0.
Diffstat (limited to 'src/3rdparty/phonon/qt7')
-rw-r--r-- | src/3rdparty/phonon/qt7/audionode.h | 2 | ||||
-rw-r--r-- | src/3rdparty/phonon/qt7/audionode.mm | 16 | ||||
-rw-r--r-- | src/3rdparty/phonon/qt7/backendinfo.mm | 1 | ||||
-rw-r--r-- | src/3rdparty/phonon/qt7/mediaobject.h | 40 | ||||
-rw-r--r-- | src/3rdparty/phonon/qt7/mediaobject.mm | 286 | ||||
-rw-r--r-- | src/3rdparty/phonon/qt7/quicktimemetadata.h | 8 | ||||
-rw-r--r-- | src/3rdparty/phonon/qt7/quicktimemetadata.mm | 41 | ||||
-rw-r--r-- | src/3rdparty/phonon/qt7/quicktimevideoplayer.h | 28 | ||||
-rw-r--r-- | src/3rdparty/phonon/qt7/quicktimevideoplayer.mm | 265 | ||||
-rw-r--r-- | src/3rdparty/phonon/qt7/videoframe.mm | 24 |
10 files changed, 137 insertions, 574 deletions
diff --git a/src/3rdparty/phonon/qt7/audionode.h b/src/3rdparty/phonon/qt7/audionode.h index 2498e49..dfec817f 100644 --- a/src/3rdparty/phonon/qt7/audionode.h +++ b/src/3rdparty/phonon/qt7/audionode.h @@ -72,7 +72,7 @@ namespace QT7 AudioUnit m_audioUnit; // Only the following methods needs to - // be overidden by only_one-audio-unit nodes: + // be overridden by only_one-audio-unit nodes: virtual ComponentDescription getAudioNodeDescription() const; virtual void initializeAudioUnit(); diff --git a/src/3rdparty/phonon/qt7/audionode.mm b/src/3rdparty/phonon/qt7/audionode.mm index 961230c..cb9e82f 100644 --- a/src/3rdparty/phonon/qt7/audionode.mm +++ b/src/3rdparty/phonon/qt7/audionode.mm @@ -68,15 +68,13 @@ void AudioNode::createAndConnectAUNodes() << QString(!FindNextComponent(0, &description) ? "ERROR: COMPONENT NOT FOUND!" : "OK!")) OSStatus err = noErr; - - // The proper function to call here is AUGraphAddNode() but the type has - // changed between 10.5 and 10.6. it's still OK to call this function, but - // if we want to use the proper thing we need to move over to - // AudioComponentDescription everywhere, which is very similar to the - // ComponentDescription, but a different size. however, - // AudioComponentDescription only exists on 10.6+. More fun than we need to - // deal with at the moment, so we'll take the "deprecated" warning instead. - err = AUGraphNewNode(m_audioGraph->audioGraphRef(), &description, 0, 0, &m_auNode); +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 + if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) + err = AUGraphAddNode(m_audioGraph->audioGraphRef(), &description, &m_auNode); + else +#endif + err = AUGraphNewNode(m_audioGraph->audioGraphRef(), &description, 0, 0, &m_auNode); + BACKEND_ASSERT2(err != kAUGraphErr_OutputNodeErr, "A MediaObject can only be connected to one audio output device.", FATAL_ERROR) BACKEND_ASSERT2(err == noErr, "Could not create new AUNode.", FATAL_ERROR) } diff --git a/src/3rdparty/phonon/qt7/backendinfo.mm b/src/3rdparty/phonon/qt7/backendinfo.mm index 0d51db0..e173f05 100644 --- a/src/3rdparty/phonon/qt7/backendinfo.mm +++ b/src/3rdparty/phonon/qt7/backendinfo.mm @@ -22,7 +22,6 @@ #include <AudioUnit/AudioUnit.h> #include <CoreServices/CoreServices.h> -#include <QtGui/qmacdefines_mac.h> #import <QTKit/QTMovie.h> #ifdef QUICKTIME_C_API_AVAILABLE diff --git a/src/3rdparty/phonon/qt7/mediaobject.h b/src/3rdparty/phonon/qt7/mediaobject.h index c93eddc..27949ec 100644 --- a/src/3rdparty/phonon/qt7/mediaobject.h +++ b/src/3rdparty/phonon/qt7/mediaobject.h @@ -25,10 +25,6 @@ #include "medianode.h" -#if QT_ALLOW_QUICKTIME - #include <QuickTime/QuickTime.h> -#endif - QT_BEGIN_NAMESPACE namespace Phonon @@ -42,10 +38,7 @@ namespace QT7 class MediaObjectAudioNode; class MediaObject : public MediaNode, - public Phonon::MediaObjectInterface -#ifndef QT_NO_PHONON_MEDIACONTROLLER - , public Phonon::AddonInterface -#endif + public Phonon::MediaObjectInterface, public Phonon::AddonInterface { Q_OBJECT Q_INTERFACES(Phonon::MediaObjectInterface Phonon::AddonInterface) @@ -99,10 +92,6 @@ namespace QT7 int videoOutputCount(); -#if QT_ALLOW_QUICKTIME - void displayLinkEvent(); -#endif - signals: void stateChanged(Phonon::State,Phonon::State); void tick(qint64); @@ -116,16 +105,6 @@ namespace QT7 void metaDataChanged(QMultiMap<QString,QString>); void currentSourceChanged(const MediaSource &newSource); - // Add-on interface: - void availableSubtitlesChanged(); - void availableAudioChannelsChanged(); - void titleChanged(int); - void availableTitlesChanged(int); - void chapterChanged(int); - void availableChaptersChanged(int); - void angleChanged(int); - void availableAnglesChanged(int); - protected: void mediaNodeEvent(const MediaNodeEvent *event); bool event(QEvent *event); @@ -139,14 +118,7 @@ namespace QT7 QuickTimeVideoPlayer *m_nextVideoPlayer; QuickTimeAudioPlayer *m_nextAudioPlayer; MediaObjectAudioNode *m_mediaObjectAudioNode; - -#if QT_ALLOW_QUICKTIME - CVDisplayLinkRef m_displayLink; - QMutex m_displayLinkMutex; - bool m_pendingDisplayLinkEvent; - void startDisplayLink(); - void stopDisplayLink(); -#endif + QuickTimeMetaData *m_metaData; qint32 m_tickInterval; qint32 m_transitionTime; @@ -155,14 +127,12 @@ namespace QT7 float m_percentageLoaded; int m_tickTimer; - int m_videoTimer; - int m_audioTimer; + int m_bufferTimer; int m_rapidTimer; bool m_waitNextSwap; int m_swapTimeLeft; QTime m_swapTime; - bool m_autoplayTitles; void synchAudioVideo(); void updateCurrentTime(); @@ -171,7 +141,8 @@ namespace QT7 void pause_internal(); void play_internal(); void setupAudioSystem(); - void restartAudioVideoTimers(); + void updateTimer(int &timer, int interval); + void bufferAudioVideo(); void updateRapidly(); void updateCrossFade(); void updateAudioBuffers(); @@ -183,7 +154,6 @@ namespace QT7 void inspectVideoGraphRecursive(MediaNode *node, int &effectCount, int &outputCount); void inspectGraph(); bool isCrossFading(); - void setCurrentTrack(int track); QString m_errorString; Phonon::ErrorType m_errorType; diff --git a/src/3rdparty/phonon/qt7/mediaobject.mm b/src/3rdparty/phonon/qt7/mediaobject.mm index 677640c..f8d635a 100644 --- a/src/3rdparty/phonon/qt7/mediaobject.mm +++ b/src/3rdparty/phonon/qt7/mediaobject.mm @@ -46,6 +46,7 @@ MediaObject::MediaObject(QObject *parent) : MediaNode(AudioSource | VideoSource, m_mediaObjectAudioNode = new MediaObjectAudioNode(m_audioPlayer, m_nextAudioPlayer); setAudioNode(m_mediaObjectAudioNode); + m_metaData = new QuickTimeMetaData(); m_audioGraph = new AudioGraph(this); m_tickInterval = 0; @@ -54,7 +55,6 @@ MediaObject::MediaObject(QObject *parent) : MediaNode(AudioSource | VideoSource, m_transitionTime = 0; m_percentageLoaded = 0; m_waitNextSwap = false; - m_autoplayTitles = true; m_audioEffectCount = 0; m_audioOutputCount = 0; m_videoEffectCount = 0; @@ -63,28 +63,20 @@ MediaObject::MediaObject(QObject *parent) : MediaNode(AudioSource | VideoSource, m_errorType = Phonon::NoError; m_tickTimer = 0; - m_videoTimer = 0; - m_audioTimer = 0; + m_bufferTimer = 0; m_rapidTimer = 0; -#if QT_ALLOW_QUICKTIME - m_displayLink = 0; - m_pendingDisplayLinkEvent = false; -#endif - checkForError(); } MediaObject::~MediaObject() -{ - // m_mediaObjectAudioNode is owned by super class. -#if QT_ALLOW_QUICKTIME - stopDisplayLink(); -#endif +{ + // m_mediaObjectAudioNode is owned by super class. m_audioPlayer->unsetVideoPlayer(); m_nextAudioPlayer->unsetVideoPlayer(); delete m_videoPlayer; delete m_nextVideoPlayer; + delete m_metaData; checkForError(); } @@ -222,28 +214,28 @@ void MediaObject::setSource(const MediaSource &source) IMPLEMENTED; PhononAutoReleasePool pool; setState(Phonon::LoadingState); - + // Save current state for event/signal handling below: bool prevHasVideo = m_videoPlayer->hasVideo(); qint64 prevTotalTime = totalTime(); - int prevTrackCount = m_videoPlayer->trackCount(); m_waitNextSwap = false; - + // Cancel cross-fade if any: m_nextVideoPlayer->pause(); m_nextAudioPlayer->pause(); m_mediaObjectAudioNode->cancelCrossFade(); - + // Set new source: m_audioPlayer->unsetVideoPlayer(); m_videoPlayer->setMediaSource(source); m_audioPlayer->setVideoPlayer(m_videoPlayer); + m_metaData->setVideo(m_videoPlayer); - m_audioGraph->updateStreamSpecifications(); + m_audioGraph->updateStreamSpecifications(); m_nextAudioPlayer->unsetVideoPlayer(); - m_nextVideoPlayer->unsetCurrentMediaSource(); + m_nextVideoPlayer->unsetVideo(); m_currentTime = 0; - + // Emit/notify information about the new source: QRect videoRect = m_videoPlayer->videoRect(); MediaNodeEvent e1(MediaNodeEvent::VideoFrameSizeChanged, &videoRect); @@ -254,14 +246,12 @@ void MediaObject::setSource(const MediaSource &source) updateVideo(emptyFrame); emit currentSourceChanged(source); - emit metaDataChanged(m_videoPlayer->metaData()); + emit metaDataChanged(m_metaData->metaData()); if (prevHasVideo != m_videoPlayer->hasVideo()) - emit hasVideoChanged(m_videoPlayer->hasVideo()); + emit hasVideoChanged(m_videoPlayer->hasVideo()); if (prevTotalTime != totalTime()) - emit totalTimeChanged(totalTime()); - if (prevTrackCount != m_videoPlayer->trackCount()) - emit availableTitlesChanged(m_videoPlayer->trackCount()); + emit totalTimeChanged(totalTime()); if (checkForError()) return; if (!m_videoPlayer->isDrmAuthorized()) @@ -297,30 +287,28 @@ void MediaObject::swapCurrentWithNext(qint32 transitionTime) // Save current state for event/signal handling below: bool prevHasVideo = m_videoPlayer->hasVideo(); qint64 prevTotalTime = totalTime(); - int prevTrackCount = m_videoPlayer->trackCount(); qSwap(m_audioPlayer, m_nextAudioPlayer); qSwap(m_videoPlayer, m_nextVideoPlayer); m_mediaObjectAudioNode->startCrossFade(transitionTime); m_audioGraph->updateStreamSpecifications(); + m_metaData->setVideo(m_videoPlayer); m_waitNextSwap = false; m_currentTime = 0; - + // Emit/notify information about the new source: QRect videoRect = m_videoPlayer->videoRect(); MediaNodeEvent e1(MediaNodeEvent::VideoFrameSizeChanged, &videoRect); notify(&e1); emit currentSourceChanged(m_videoPlayer->mediaSource()); - emit metaDataChanged(m_videoPlayer->metaData()); + emit metaDataChanged(m_metaData->metaData()); if (prevHasVideo != m_videoPlayer->hasVideo()) - emit hasVideoChanged(m_videoPlayer->hasVideo()); + emit hasVideoChanged(m_videoPlayer->hasVideo()); if (prevTotalTime != totalTime()) emit totalTimeChanged(totalTime()); - if (prevTrackCount != m_videoPlayer->trackCount()) - emit availableTitlesChanged(m_videoPlayer->trackCount()); if (checkForError()) return; if (!m_videoPlayer->isDrmAuthorized()) @@ -339,107 +327,28 @@ void MediaObject::swapCurrentWithNext(qint32 transitionTime) } } -#if QT_ALLOW_QUICKTIME -static CVReturn displayLinkCallback(CVDisplayLinkRef /*displayLink*/, - const CVTimeStamp */*inNow*/, - const CVTimeStamp */*inOutputTime*/, - CVOptionFlags /*flagsIn*/, - CVOptionFlags */*flagsOut*/, - void *userData) +void MediaObject::updateTimer(int &timer, int interval) { - MediaObject *mediaObject = static_cast<MediaObject *>(userData); - mediaObject->displayLinkEvent(); - return kCVReturnSuccess; -} - -void MediaObject::displayLinkEvent() -{ - // This function is called from a - // thread != gui thread. So we post the event. - // But we need to make sure that we don't post faster - // than the event loop can eat: - m_displayLinkMutex.lock(); - bool pending = m_pendingDisplayLinkEvent; - m_pendingDisplayLinkEvent = true; - m_displayLinkMutex.unlock(); - - if (!pending) - qApp->postEvent(this, new QEvent(QEvent::User), Qt::HighEventPriority); -} - -void MediaObject::startDisplayLink() -{ - if (m_displayLink) - return; - OSStatus err = CVDisplayLinkCreateWithCGDisplay(kCGDirectMainDisplay, &m_displayLink); - if (err != noErr) - goto fail; - err = CVDisplayLinkSetCurrentCGDisplay(m_displayLink, kCGDirectMainDisplay); - if (err != noErr) - goto fail; - err = CVDisplayLinkSetOutputCallback(m_displayLink, displayLinkCallback, this); - if (err != noErr) - goto fail; - err = CVDisplayLinkStart(m_displayLink); - if (err != noErr) - goto fail; - return; -fail: - stopDisplayLink(); -} - -void MediaObject::stopDisplayLink() -{ - if (!m_displayLink) - return; - CVDisplayLinkStop(m_displayLink); - CFRelease(m_displayLink); - m_displayLink = 0; -} -#endif - -void MediaObject::restartAudioVideoTimers() -{ - if (m_videoTimer) - killTimer(m_videoTimer); - if (m_audioTimer) - killTimer(m_audioTimer); - -#if QT_ALLOW_QUICKTIME - // We prefer to use a display link as timer if available, since - // it is more steady, and results in better and smoother frame drawing: - startDisplayLink(); - if (!m_displayLink){ - float fps = m_videoPlayer->staticFps(); - long videoUpdateFrequency = fps ? long(1000.0f / fps) : 0.001; - m_videoTimer = startTimer(videoUpdateFrequency); - } -#else - float fps = m_videoPlayer->staticFps(); - long videoUpdateFrequency = fps ? long(1000.0f / fps) : 0.001; - m_videoTimer = startTimer(videoUpdateFrequency); -#endif - - long audioUpdateFrequency = m_audioPlayer->regularTaskFrequency(); - m_audioTimer = startTimer(audioUpdateFrequency); - updateVideoFrames(); - updateAudioBuffers(); + if (timer) + killTimer(timer); + timer = 0; + if (interval >= 0) + timer = startTimer(interval); } void MediaObject::play_internal() { // Play main audio/video: m_videoPlayer->play(); - m_audioPlayer->play(); + m_audioPlayer->play(); updateLipSynch(0); // Play old audio/video to finish cross-fade: if (m_nextVideoPlayer->currentTime() > 0){ m_nextVideoPlayer->play(); m_nextAudioPlayer->play(); } - restartAudioVideoTimers(); - if (!m_rapidTimer) - m_rapidTimer = startTimer(100); + bufferAudioVideo(); + updateTimer(m_rapidTimer, 100); } void MediaObject::pause_internal() @@ -449,15 +358,9 @@ void MediaObject::pause_internal() m_nextAudioPlayer->pause(); m_videoPlayer->pause(); m_nextVideoPlayer->pause(); - killTimer(m_rapidTimer); - killTimer(m_videoTimer); - killTimer(m_audioTimer); - m_rapidTimer = 0; - m_videoTimer = 0; - m_audioTimer = 0; -#if QT_ALLOW_QUICKTIME - stopDisplayLink(); -#endif + updateTimer(m_rapidTimer, -1); + updateTimer(m_bufferTimer, -1); + if (m_waitNextSwap) m_swapTimeLeft = m_swapTime.msecsTo(QTime::currentTime()); } @@ -520,7 +423,7 @@ void MediaObject::stop() if (!setState(Phonon::StoppedState)) return; m_waitNextSwap = false; - m_nextVideoPlayer->unsetCurrentMediaSource(); + m_nextVideoPlayer->unsetVideo(); m_nextAudioPlayer->unsetVideoPlayer(); pause_internal(); seek(0); @@ -532,9 +435,9 @@ void MediaObject::seek(qint64 milliseconds) IMPLEMENTED; if (m_state == Phonon::ErrorState) return; - + // Stop cross-fade if any: - m_nextVideoPlayer->unsetCurrentMediaSource(); + m_nextVideoPlayer->unsetVideo(); m_nextAudioPlayer->unsetVideoPlayer(); m_mediaObjectAudioNode->cancelCrossFade(); @@ -664,24 +567,19 @@ void MediaObject::updateCurrentTime() m_currentTime = (m_audioSystem == AS_Graph) ? m_audioPlayer->currentTime() : m_videoPlayer->currentTime(); quint64 total = m_videoPlayer->duration(); - if (m_videoPlayer->currentTrack() < m_videoPlayer->trackCount() - 1){ - // There are still more tracks to play after the current track. - if (m_autoplayTitles) { - if (lastUpdateTime < m_currentTime && m_currentTime == total) - setCurrentTrack(m_videoPlayer->currentTrack() + 1); - } - } else if (m_nextVideoPlayer->state() == QuickTimeVideoPlayer::NoMedia){ - // There is no more sources or tracks to play after the current source. - // Check if it's time to emit aboutToFinish: - quint32 mark = qMax(quint64(0), qMin(total, total + m_transitionTime - 2000)); - if (lastUpdateTime < mark && mark <= m_currentTime) - emit aboutToFinish(); - - // Check if it's time to emit prefinishMarkReached: - mark = qMax(quint64(0), total - m_prefinishMark); - if (lastUpdateTime < mark && mark <= m_currentTime) - emit prefinishMarkReached(total - m_currentTime); + // Check if it's time to emit aboutToFinish: + quint32 mark = qMax(quint64(0), qMin(total, total + m_transitionTime - 2000)); + if (lastUpdateTime < mark && mark <= m_currentTime) + emit aboutToFinish(); + + // Check if it's time to emit prefinishMarkReached: + mark = qMax(quint64(0), total - m_prefinishMark); + if (lastUpdateTime < mark && mark <= m_currentTime) + emit prefinishMarkReached(total - m_currentTime); + if (m_nextVideoPlayer->state() == QuickTimeVideoPlayer::NoMedia){ + // There is no next source in que. + // Check if it's time to emit finished: if (lastUpdateTime < m_currentTime && m_currentTime == total){ emit finished(); m_currentTime = (m_audioSystem == AS_Graph) ? m_audioPlayer->currentTime() : m_videoPlayer->currentTime(); @@ -691,7 +589,7 @@ void MediaObject::updateCurrentTime() } else { // We have a next source. // Check if it's time to swap to next source: - quint32 mark = qMax(quint64(0), total + m_transitionTime); + mark = qMax(quint64(0), total + m_transitionTime); if (m_waitNextSwap && m_state == Phonon::PlayingState && m_transitionTime < m_swapTime.msecsTo(QTime::currentTime())){ swapCurrentWithNext(0); @@ -794,14 +692,14 @@ bool MediaObject::setAudioDeviceOnMovie(int id) void MediaObject::updateCrossFade() { - m_mediaObjectAudioNode->updateCrossFade(m_currentTime); + m_mediaObjectAudioNode->updateCrossFade(m_currentTime); // Clean-up previous movie if done fading: if (m_mediaObjectAudioNode->m_fadeDuration == 0){ if (m_nextVideoPlayer->isPlaying() || m_nextAudioPlayer->isPlaying()){ - m_nextVideoPlayer->unsetCurrentMediaSource(); + m_nextVideoPlayer->unsetVideo(); m_nextAudioPlayer->unsetVideoPlayer(); } - } + } } void MediaObject::updateBufferStatus() @@ -830,7 +728,7 @@ void MediaObject::updateVideoFrames() // Draw next frame if awailable: if (m_videoPlayer->videoFrameChanged()){ updateLipSynch(50); - VideoFrame frame(m_videoPlayer); + VideoFrame frame(m_videoPlayer); if (m_nextVideoPlayer->isPlaying() && m_nextVideoPlayer->hasVideo() && isCrossFading()){ @@ -838,9 +736,9 @@ void MediaObject::updateVideoFrames() frame.setBackgroundFrame(bgFrame); frame.setBaseOpacity(m_mediaObjectAudioNode->m_volume1); } - + // Send the frame through the graph: - updateVideo(frame); + updateVideo(frame); checkForError(); } } @@ -851,7 +749,7 @@ void MediaObject::updateLipSynch(int allowedOffset) return; if (m_videoSinkList.isEmpty() || m_audioSinkList.isEmpty()) return; - + if (m_videoPlayer->hasVideo()){ qint64 diff = m_audioPlayer->currentTime() - m_videoPlayer->currentTime(); if (-allowedOffset > diff || diff > allowedOffset) @@ -865,6 +763,16 @@ void MediaObject::updateLipSynch(int allowedOffset) } } +void MediaObject::bufferAudioVideo() +{ + long nextVideoUpdate = m_videoPlayer->hasVideo() ? 30 : INT_MAX; + long nextAudioUpdate = m_audioPlayer->regularTaskFrequency(); + updateAudioBuffers(); + updateVideoFrames(); + if (m_state == Phonon::PlayingState) + updateTimer(m_bufferTimer, qMin(nextVideoUpdate, nextAudioUpdate)); +} + void MediaObject::updateRapidly() { updateCurrentTime(); @@ -889,8 +797,8 @@ void MediaObject::mediaNodeEvent(const MediaNodeEvent *event) synchAudioVideo(); checkForError(); m_mediaObjectAudioNode->setMute(false); - if (m_state == Phonon::PlayingState) - restartAudioVideoTimers(); + if (m_state == Phonon::PlayingState) + bufferAudioVideo(); break; case MediaNodeEvent::AudioGraphCannotPlay: case MediaNodeEvent::AudioGraphInitialized: @@ -901,7 +809,7 @@ void MediaObject::mediaNodeEvent(const MediaNodeEvent *event) checkForError(); m_mediaObjectAudioNode->setMute(false); } - break; + break; default: break; } @@ -910,67 +818,29 @@ void MediaObject::mediaNodeEvent(const MediaNodeEvent *event) bool MediaObject::event(QEvent *event) { switch (event->type()){ -#if QT_ALLOW_QUICKTIME - case QEvent::User:{ - m_displayLinkMutex.lock(); - m_pendingDisplayLinkEvent = false; - m_displayLinkMutex.unlock(); - updateVideoFrames(); - break; } -#endif - case QEvent::Timer:{ - int timerId = static_cast<QTimerEvent *>(event)->timerId(); - if (timerId == m_rapidTimer) + case QEvent::Timer: { + QTimerEvent *timerEvent = static_cast<QTimerEvent *>(event); + if (timerEvent->timerId() == m_rapidTimer) updateRapidly(); - else if (timerId == m_tickTimer) + else if (timerEvent->timerId() == m_tickTimer) emit tick(currentTime()); - else if (timerId == m_videoTimer) - updateVideoFrames(); - else if (timerId == m_audioTimer) - updateAudioBuffers(); - break; } + else if (timerEvent->timerId() == m_bufferTimer) + bufferAudioVideo(); + } + break; default: break; } return QObject::event(event); } -void MediaObject::setCurrentTrack(int track) -{ - if (track == m_videoPlayer->currentTrack() || track < 0 || track >= m_videoPlayer->trackCount()) - return; - - m_videoPlayer->setCurrentTrack(track); - emit titleChanged(track); - emit metaDataChanged(m_videoPlayer->metaData()); -} - -bool MediaObject::hasInterface(Interface iface) const +bool MediaObject::hasInterface(Interface /*interface*/) const { - return iface == AddonInterface::TitleInterface; + return false; } -QVariant MediaObject::interfaceCall(Interface iface, int command, const QList<QVariant> ¶ms) +QVariant MediaObject::interfaceCall(Interface /*interface*/, int /*command*/, const QList<QVariant> &/*arguments*/) { - switch (iface) { - case TitleInterface: - switch (command) { - case availableTitles: - return m_videoPlayer->trackCount(); - case title: - return m_videoPlayer->currentTrack(); - case setTitle: - setCurrentTrack(params.first().toInt()); - break; - case autoplayTitles: - return m_autoplayTitles; - case setAutoplayTitles: - m_autoplayTitles = params.first().toBool(); - break; - } - default: - break; - } return QVariant(); } diff --git a/src/3rdparty/phonon/qt7/quicktimemetadata.h b/src/3rdparty/phonon/qt7/quicktimemetadata.h index c589535..d524183 100644 --- a/src/3rdparty/phonon/qt7/quicktimemetadata.h +++ b/src/3rdparty/phonon/qt7/quicktimemetadata.h @@ -38,8 +38,10 @@ namespace QT7 class QuickTimeMetaData { public: - QuickTimeMetaData(QuickTimeVideoPlayer *videoPlayer); - void update(); + QuickTimeMetaData(); + virtual ~QuickTimeMetaData(); + + void setVideo(QuickTimeVideoPlayer *videoPlayer); QMultiMap<QString, QString> metaData(); private: @@ -47,8 +49,6 @@ namespace QT7 bool m_movieChanged; QuickTimeVideoPlayer *m_videoPlayer; void readMetaData(); - void guessMetaDataForCD(); - void readMetaDataFromMovie(); #ifdef QUICKTIME_C_API_AVAILABLE QString stripCopyRightSymbol(const QString &key); diff --git a/src/3rdparty/phonon/qt7/quicktimemetadata.mm b/src/3rdparty/phonon/qt7/quicktimemetadata.mm index 2dcc152..851e707 100644 --- a/src/3rdparty/phonon/qt7/quicktimemetadata.mm +++ b/src/3rdparty/phonon/qt7/quicktimemetadata.mm @@ -15,7 +15,6 @@ along with this library. If not, see <http://www.gnu.org/licenses/>. */ -#include <QtCore/QFileInfo> #include "quicktimemetadata.h" #include "quicktimevideoplayer.h" @@ -26,14 +25,19 @@ namespace Phonon namespace QT7 { -QuickTimeMetaData::QuickTimeMetaData(QuickTimeVideoPlayer *videoPlayer) +QuickTimeMetaData::QuickTimeMetaData() { - m_videoPlayer = videoPlayer; + m_videoPlayer = 0; m_movieChanged = false; } -void QuickTimeMetaData::update() +QuickTimeMetaData::~QuickTimeMetaData() { +} + +void QuickTimeMetaData::setVideo(QuickTimeVideoPlayer *videoPlayer) +{ + m_videoPlayer = videoPlayer; m_movieChanged = true; m_metaData.clear(); } @@ -141,22 +145,14 @@ void QuickTimeMetaData::readFormattedData(QTMetaDataRef metaDataRef, OSType form #endif // QUICKTIME_C_API_AVAILABLE -void QuickTimeMetaData::guessMetaDataForCD() -{ - QString album = QFileInfo(m_videoPlayer->movieCompactDiscPath()).fileName(); - QString title = QFileInfo(m_videoPlayer->currentTrackPath()).fileName(); - title = title.left(title.lastIndexOf('.')); - m_metaData.insert(QLatin1String("ALBUM"), album); - m_metaData.insert(QLatin1String("TITLE"), title); - m_metaData.insert(QLatin1String("TRACKNUMBER"), QString::number(m_videoPlayer->currentTrack())); -} - -void QuickTimeMetaData::readMetaDataFromMovie() +void QuickTimeMetaData::readMetaData() { + if (!m_videoPlayer) + return; QMultiMap<QString, QString> metaMap; - + #ifdef QUICKTIME_C_API_AVAILABLE - QTMetaDataRef metaDataRef; + QTMetaDataRef metaDataRef; OSStatus err = QTCopyMovieMetaData([m_videoPlayer->qtMovie() quickTimeMovie], &metaDataRef); BACKEND_ASSERT2(err == noErr, "Could not read QuickTime meta data", NORMAL_ERROR) @@ -177,17 +173,6 @@ void QuickTimeMetaData::readMetaDataFromMovie() m_metaData.insert(QLatin1String("DESCRIPTION"), metaMap.value(QLatin1String("des"))); } -void QuickTimeMetaData::readMetaData() -{ - if (!m_videoPlayer) - return; - - if (m_videoPlayer->mediaSource().type() == Phonon::MediaSource::Disc) - guessMetaDataForCD(); - else - readMetaDataFromMovie(); -} - QMultiMap<QString, QString> QuickTimeMetaData::metaData() { if (m_videoPlayer && m_videoPlayer->hasMovie() && m_movieChanged) diff --git a/src/3rdparty/phonon/qt7/quicktimevideoplayer.h b/src/3rdparty/phonon/qt7/quicktimevideoplayer.h index 98eacb5..0b3aec2 100644 --- a/src/3rdparty/phonon/qt7/quicktimevideoplayer.h +++ b/src/3rdparty/phonon/qt7/quicktimevideoplayer.h @@ -20,7 +20,6 @@ #include "backendheader.h" -#include <QtGui/qmacdefines_mac.h> #import <QTKit/QTDataReference.h> #import <QTKit/QTMovie.h> @@ -39,7 +38,6 @@ namespace Phonon namespace QT7 { class QuickTimeStreamReader; - class QuickTimeMetaData; class VideoRenderWidgetQTMovieView; class QuickTimeVideoPlayer : QObject @@ -57,7 +55,7 @@ namespace QT7 void setMediaSource(const MediaSource &source); MediaSource mediaSource() const; - void unsetCurrentMediaSource(); + void unsetVideo(); void play(); void pause(); @@ -68,13 +66,11 @@ namespace QT7 GLuint currentFrameAsGLTexture(); void *currentFrameAsCIImage(); QImage currentFrameAsQImage(); - void releaseImageCache(); QRect videoRect() const; quint64 duration() const; quint64 currentTime() const; long timeScale() const; - float staticFps(); QString currentTimeString(); void setColors(qreal brightness = 0, qreal contrast = 1, qreal hue = 0, qreal saturation = 1); @@ -87,7 +83,6 @@ namespace QT7 bool setAudioDevice(int id); void setPlaybackRate(float rate); QTMovie *qtMovie() const; - QMultiMap<QString, QString> metaData(); float playbackRate() const; float prefferedPlaybackRate() const; @@ -107,12 +102,6 @@ namespace QT7 float percentageLoaded(); quint64 timeLoaded(); - int trackCount() const; - int currentTrack() const; - void setCurrentTrack(int track); - QString movieCompactDiscPath() const; - QString currentTrackPath() const; - static QString timeToString(quint64 ms); // Help functions when drawing to more that one widget in cocoa 64: @@ -126,10 +115,6 @@ namespace QT7 QTMovie *m_QTMovie; State m_state; QGLPixelBuffer *m_QImagePixelBuffer; - QuickTimeMetaData *m_metaData; - - CVOpenGLTextureRef m_cachedCVTextureRef; - QImage m_cachedQImage; bool m_playbackRateSat; bool m_isDrmProtected; @@ -140,18 +125,13 @@ namespace QT7 float m_masterVolume; float m_relativeVolume; float m_playbackRate; - float m_staticFps; quint64 m_currentTime; MediaSource m_mediaSource; - void *m_primaryRenderingCIImage; qreal m_brightness; qreal m_contrast; qreal m_hue; qreal m_saturation; - NSArray *m_folderTracks; - int m_currentTrack; - QString m_movieCompactDiscPath; #ifdef QUICKTIME_C_API_AVAILABLE QTVisualContextRef m_visualContext; @@ -159,26 +139,20 @@ namespace QT7 VideoFrame m_currentFrame; QuickTimeStreamReader *m_streamReader; - void prepareCurrentMovieForPlayback(); void createVisualContext(); void openMovieFromCurrentMediaSource(); void openMovieFromDataRef(QTDataReference *dataRef); void openMovieFromFile(); void openMovieFromUrl(); void openMovieFromStream(); - void openMovieFromCompactDisc(); void openMovieFromData(QByteArray *data, char *fileType); void openMovieFromDataGuessType(QByteArray *data); QString mediaSourcePath(); bool codecExistsAccordingToSuffix(const QString &fileName); - NSString* pathToCompactDisc(); - bool isCompactDisc(NSString *path); - NSArray* scanFolder(NSString *path); void setError(NSError *error); bool errorOccured(); void readProtection(); - void calculateStaticFps(); void checkIfVideoAwailable(); bool movieNotLoaded(); void waitStatePlayable(); diff --git a/src/3rdparty/phonon/qt7/quicktimevideoplayer.mm b/src/3rdparty/phonon/qt7/quicktimevideoplayer.mm index 23c76e3..3f76132 100644 --- a/src/3rdparty/phonon/qt7/quicktimevideoplayer.mm +++ b/src/3rdparty/phonon/qt7/quicktimevideoplayer.mm @@ -20,7 +20,6 @@ #include "videowidget.h" #include "audiodevice.h" #include "quicktimestreamreader.h" -#include "quicktimemetadata.h" #include <QtCore/QCoreApplication> #include <QtCore/QEventLoop> @@ -53,7 +52,6 @@ QuickTimeVideoPlayer::QuickTimeVideoPlayer() : QObject(0) { m_state = NoMedia; m_mediaSource = MediaSource(); - m_metaData = new QuickTimeMetaData(this); m_QTMovie = 0; m_streamReader = 0; m_playbackRate = 1.0f; @@ -63,16 +61,12 @@ QuickTimeVideoPlayer::QuickTimeVideoPlayer() : QObject(0) m_mute = false; m_audioEnabled = false; m_hasVideo = false; - m_staticFps = 0; m_playbackRateSat = false; m_isDrmProtected = false; m_isDrmAuthorized = true; m_primaryRenderingTarget = 0; m_primaryRenderingCIImage = 0; m_QImagePixelBuffer = 0; - m_cachedCVTextureRef = 0; - m_folderTracks = 0; - m_currentTrack = 0; #ifdef QUICKTIME_C_API_AVAILABLE OSStatus err = EnterMovies(); @@ -83,9 +77,7 @@ QuickTimeVideoPlayer::QuickTimeVideoPlayer() : QObject(0) QuickTimeVideoPlayer::~QuickTimeVideoPlayer() { - PhononAutoReleasePool pool; - unsetCurrentMediaSource(); - delete m_metaData; + unsetVideo(); [(NSObject*)m_primaryRenderingTarget release]; m_primaryRenderingTarget = 0; #ifdef QUICKTIME_C_API_AVAILABLE @@ -94,15 +86,6 @@ QuickTimeVideoPlayer::~QuickTimeVideoPlayer() #endif } -void QuickTimeVideoPlayer::releaseImageCache() -{ - if (m_cachedCVTextureRef){ - CVOpenGLTextureRelease(m_cachedCVTextureRef); - m_cachedCVTextureRef = 0; - } - m_cachedQImage = QImage(); -} - void QuickTimeVideoPlayer::createVisualContext() { #ifdef QUICKTIME_C_API_AVAILABLE @@ -142,10 +125,7 @@ bool QuickTimeVideoPlayer::videoFrameChanged() return false; QTVisualContextTask(m_visualContext); - bool changed = QTVisualContextIsNewImageAvailable(m_visualContext, 0); - if (changed) - releaseImageCache(); - return changed; + return QTVisualContextIsNewImageAvailable(m_visualContext, 0); #elif defined(QT_MAC_USE_COCOA) return true; @@ -160,11 +140,10 @@ CVOpenGLTextureRef QuickTimeVideoPlayer::currentFrameAsCVTexture() #ifdef QUICKTIME_C_API_AVAILABLE if (!m_visualContext) return 0; - if (!m_cachedCVTextureRef){ - OSStatus err = QTVisualContextCopyImageForTime(m_visualContext, 0, 0, &m_cachedCVTextureRef); - BACKEND_ASSERT3(err == noErr, "Could not copy image for time in QuickTime player", FATAL_ERROR, 0) - } - return m_cachedCVTextureRef; + CVOpenGLTextureRef texture = 0; + OSStatus err = QTVisualContextCopyImageForTime(m_visualContext, 0, 0, &texture); + BACKEND_ASSERT3(err == noErr, "Could not copy image for time in QuickTime player", FATAL_ERROR, 0) + return texture; #else return 0; @@ -173,9 +152,6 @@ CVOpenGLTextureRef QuickTimeVideoPlayer::currentFrameAsCVTexture() QImage QuickTimeVideoPlayer::currentFrameAsQImage() { - if (!m_cachedQImage.isNull()) - return m_cachedQImage; - #ifdef QUICKTIME_C_API_AVAILABLE QGLContext *prevContext = const_cast<QGLContext *>(QGLContext::currentContext()); CVOpenGLTextureRef texture = currentFrameAsCVTexture(); @@ -205,11 +181,12 @@ QImage QuickTimeVideoPlayer::currentFrameAsQImage() glVertex2i(-1, -1); glEnd(); - m_cachedQImage = m_QImagePixelBuffer->toImage(); + QImage image = m_QImagePixelBuffer->toImage(); + CVOpenGLTextureRelease(texture); // Because of QuickTime, m_QImagePixelBuffer->doneCurrent() will fail. // So we store, and restore, the context our selves: prevContext->makeCurrent(); - return m_cachedQImage; + return image; #else CIImage *img = (CIImage *)currentFrameAsCIImage(); if (!img) @@ -218,10 +195,10 @@ QImage QuickTimeVideoPlayer::currentFrameAsQImage() NSBitmapImageRep* bitmap = [[NSBitmapImageRep alloc] initWithCIImage:img]; CGRect bounds = [img extent]; QImage qImg([bitmap bitmapData], bounds.size.width, bounds.size.height, QImage::Format_ARGB32); - m_cachedQImage = qImg.rgbSwapped(); + QImage swapped = qImg.rgbSwapped(); [bitmap release]; [img release]; - return m_cachedQImage; + return swapped; #endif } @@ -273,7 +250,8 @@ void *QuickTimeVideoPlayer::currentFrameAsCIImage() #ifdef QUICKTIME_C_API_AVAILABLE CVOpenGLTextureRef cvImg = currentFrameAsCVTexture(); CIImage *img = [[CIImage alloc] initWithCVImageBuffer:cvImg]; - return img; + CVOpenGLTextureRelease(cvImg); + return img; #else return 0; #endif @@ -295,7 +273,7 @@ GLuint QuickTimeVideoPlayer::currentFrameAsGLTexture() int samplesPerPixel = [bitmap samplesPerPixel]; if (![bitmap isPlanar] && (samplesPerPixel == 3 || samplesPerPixel == 4)){ - glTexImage2D(GL_TEXTURE_RECTANGLE_EXT, 0, + glTexImage2D(GL_TEXTURE_RECTANGLE_EXT, 0, samplesPerPixel == 4 ? GL_RGBA8 : GL_RGB8, [bitmap pixelsWide], [bitmap pixelsHigh], 0, samplesPerPixel == 4 ? GL_RGBA : GL_RGB, @@ -324,7 +302,7 @@ void QuickTimeVideoPlayer::setVolume(float masterVolume, float relativeVolume) m_masterVolume = masterVolume; m_relativeVolume = relativeVolume; if (!m_QTMovie || !m_audioEnabled || m_mute) - return; + return; [m_QTMovie setVolume:(m_masterVolume * m_relativeVolume)]; } @@ -335,7 +313,7 @@ void QuickTimeVideoPlayer::setMute(bool mute) return; // Work-around bug that happends if you set/unset mute - // before movie is playing, and audio is not played + // before movie is playing, and audio is not played // through graph. Then audio is delayed. [m_QTMovie setMuted:mute]; [m_QTMovie setVolume:(mute ? 0 : m_masterVolume * m_relativeVolume)]; @@ -348,7 +326,7 @@ void QuickTimeVideoPlayer::enableAudio(bool enable) return; // Work-around bug that happends if you set/unset mute - // before movie is playing, and audio is not played + // before movie is playing, and audio is not played // through graph. Then audio is delayed. [m_QTMovie setMuted:(!enable || m_mute)]; [m_QTMovie setVolume:((!enable || m_mute) ? 0 : m_masterVolume * m_relativeVolume)]; @@ -367,7 +345,7 @@ bool QuickTimeVideoPlayer::setAudioDevice(int id) #ifdef QUICKTIME_C_API_AVAILABLE // The following code will not work for some media codecs that // typically mingle audio/video frames (e.g mpeg). - CFStringRef idString = PhononCFString::toCFStringRef(AudioDevice::deviceUID(id)); + CFStringRef idString = PhononCFString::toCFStringRef(AudioDevice::deviceUID(id)); QTAudioContextRef context; QTAudioContextCreateForAudioDevice(kCFAllocatorDefault, idString, 0, &context); OSStatus err = SetMovieAudioContext([m_QTMovie quickTimeMovie], context); @@ -391,16 +369,11 @@ void QuickTimeVideoPlayer::setColors(qreal brightness, qreal contrast, qreal hue contrast += 1; saturation += 1; - if (m_brightness == brightness - && m_contrast == contrast - && m_hue == hue - && m_saturation == saturation) - return; - m_brightness = brightness; m_contrast = contrast; m_hue = hue; m_saturation = saturation; + #ifdef QUICKTIME_C_API_AVAILABLE Float32 value; value = brightness; @@ -412,7 +385,6 @@ void QuickTimeVideoPlayer::setColors(qreal brightness, qreal contrast, qreal hue value = saturation; SetMovieVisualSaturation([m_QTMovie quickTimeMovie], value, 0); #endif - releaseImageCache(); } QRect QuickTimeVideoPlayer::videoRect() const @@ -425,7 +397,7 @@ QRect QuickTimeVideoPlayer::videoRect() const return QRect(0, 0, size.width, size.height); } -void QuickTimeVideoPlayer::unsetCurrentMediaSource() +void QuickTimeVideoPlayer::unsetVideo() { if (!m_QTMovie) return; @@ -438,17 +410,11 @@ void QuickTimeVideoPlayer::unsetCurrentMediaSource() m_state = NoMedia; m_isDrmProtected = false; m_isDrmAuthorized = true; - m_hasVideo = false; - m_staticFps = 0; m_mediaSource = MediaSource(); - m_movieCompactDiscPath.clear(); [(CIImage *)m_primaryRenderingCIImage release]; m_primaryRenderingCIImage = 0; delete m_QImagePixelBuffer; m_QImagePixelBuffer = 0; - releaseImageCache(); - [m_folderTracks release]; - m_folderTracks = 0; } QuickTimeVideoPlayer::State QuickTimeVideoPlayer::state() const @@ -558,25 +524,18 @@ bool QuickTimeVideoPlayer::codecExistsAccordingToSuffix(const QString &fileName) void QuickTimeVideoPlayer::setMediaSource(const MediaSource &mediaSource) { PhononAutoReleasePool pool; - unsetCurrentMediaSource(); - + unsetVideo(); m_mediaSource = mediaSource; if (mediaSource.type() == MediaSource::Empty || mediaSource.type() == MediaSource::Invalid){ m_state = NoMedia; return; } - openMovieFromCurrentMediaSource(); if (errorOccured()){ - unsetCurrentMediaSource(); + unsetVideo(); return; } - prepareCurrentMovieForPlayback(); -} - -void QuickTimeVideoPlayer::prepareCurrentMovieForPlayback() -{ #ifdef QUICKTIME_C_API_AVAILABLE if (m_visualContext) SetMovieVisualContext([m_QTMovie quickTimeMovie], m_visualContext); @@ -584,25 +543,23 @@ void QuickTimeVideoPlayer::prepareCurrentMovieForPlayback() waitStatePlayable(); if (errorOccured()){ - unsetCurrentMediaSource(); + unsetVideo(); return; } readProtection(); preRollMovie(); if (errorOccured()){ - unsetCurrentMediaSource(); + unsetVideo(); return; } if (!m_playbackRateSat) m_playbackRate = prefferedPlaybackRate(); checkIfVideoAwailable(); - calculateStaticFps(); enableAudio(m_audioEnabled); setMute(m_mute); setVolume(m_masterVolume, m_relativeVolume); - m_metaData->update(); pause(); } @@ -616,7 +573,7 @@ void QuickTimeVideoPlayer::openMovieFromCurrentMediaSource() openMovieFromUrl(); break; case MediaSource::Disc: - openMovieFromCompactDisc(); + CASE_UNSUPPORTED("Could not open media source.", FATAL_ERROR) break; case MediaSource::Stream: openMovieFromStream(); @@ -678,7 +635,7 @@ void QuickTimeVideoPlayer::openMovieFromDataGuessType(QByteArray *data) // than using e.g [QTMovie movieFileTypes:QTIncludeCommonTypes]. Some // codecs *think* they can decode the stream, and crash... #define TryOpenMovieWithCodec(type) gClearError(); \ - openMovieFromData(data, (char *)"."type); \ + openMovieFromData(data, "."type); \ if (m_QTMovie) return; TryOpenMovieWithCodec("avi"); @@ -718,50 +675,6 @@ void QuickTimeVideoPlayer::openMovieFromStream() openMovieFromDataGuessType(m_streamReader->pointerToData()); } -typedef void (*qt_sighandler_t)(int); -static void sigtest(int) { - qApp->exit(0); -} - -void QuickTimeVideoPlayer::openMovieFromCompactDisc() -{ - // Interrupting the application while the device is open - // causes the application to hang. So we need to handle - // this in a more graceful way: - qt_sighandler_t hndl = signal(SIGINT, sigtest); - if (hndl) - signal(SIGINT, hndl); - - PhononAutoReleasePool pool; - NSString *cd = 0; - QString devName = m_mediaSource.deviceName(); - if (devName.isEmpty()) { - cd = pathToCompactDisc(); - if (!cd) { - SET_ERROR("Could not open media source.", NORMAL_ERROR) - return; - } - m_movieCompactDiscPath = PhononCFString::toQString(reinterpret_cast<CFStringRef>(cd)); - } else { - if (!QFileInfo(devName).isAbsolute()) - devName = QLatin1String("/Volumes/") + devName; - cd = [reinterpret_cast<const NSString *>(PhononCFString::toCFStringRef(devName)) autorelease]; - if (!isCompactDisc(cd)) { - SET_ERROR("Could not open media source.", NORMAL_ERROR) - return; - } - m_movieCompactDiscPath = devName; - } - - m_folderTracks = [scanFolder(cd) retain]; - setCurrentTrack(0); -} - -QString QuickTimeVideoPlayer::movieCompactDiscPath() const -{ - return m_movieCompactDiscPath; -} - MediaSource QuickTimeVideoPlayer::mediaSource() const { return m_mediaSource; @@ -807,44 +720,6 @@ long QuickTimeVideoPlayer::timeScale() const return [[m_QTMovie attributeForKey:@"QTMovieTimeScaleAttribute"] longValue]; } -float QuickTimeVideoPlayer::staticFps() -{ - return m_staticFps; -} - -void QuickTimeVideoPlayer::calculateStaticFps() -{ - if (!m_hasVideo){ - m_staticFps = 0; - return; - } - -#ifdef QT_ALLOW_QUICKTIME - Boolean isMpeg = false; - Track videoTrack = GetMovieIndTrackType([m_QTMovie quickTimeMovie], 1, - FOUR_CHAR_CODE('vfrr'), // 'vfrr' means: has frame rate - movieTrackCharacteristic | movieTrackEnabledOnly); - Media media = GetTrackMedia(videoTrack); - MediaHandler mediaH = GetMediaHandler(media); - MediaHasCharacteristic(mediaH, FOUR_CHAR_CODE('mpeg'), &isMpeg); - - if (isMpeg){ - MHInfoEncodedFrameRateRecord frameRate; - Size frameRateSize = sizeof(frameRate); - MediaGetPublicInfo(mediaH, kMHInfoEncodedFrameRate, &frameRate, &frameRateSize); - m_staticFps = float(Fix2X(frameRate.encodedFrameRate)); - } else { - Media media = GetTrackMedia(videoTrack); - long sampleCount = GetMediaSampleCount(media); - TimeValue64 duration = GetMediaDisplayDuration(media); - TimeValue64 timeScale = GetMediaTimeScale(media); - m_staticFps = float((double)sampleCount * (double)timeScale / (double)duration); - } -#else - m_staticFps = 30.0f; -#endif -} - QString QuickTimeVideoPlayer::timeToString(quint64 ms) { int sec = ms/1000; @@ -1075,94 +950,6 @@ void QuickTimeVideoPlayer::readProtection() } } -QMultiMap<QString, QString> QuickTimeVideoPlayer::metaData() -{ - return m_metaData->metaData(); -} - -int QuickTimeVideoPlayer::trackCount() const -{ - if (!m_folderTracks) - return 0; - return [m_folderTracks count]; -} - -int QuickTimeVideoPlayer::currentTrack() const -{ - return m_currentTrack; -} - -QString QuickTimeVideoPlayer::currentTrackPath() const -{ - if (!m_folderTracks) - return QString(); - - PhononAutoReleasePool pool; - NSString *trackPath = [m_folderTracks objectAtIndex:m_currentTrack]; - return PhononCFString::toQString(reinterpret_cast<CFStringRef>(trackPath)); -} - -NSString* QuickTimeVideoPlayer::pathToCompactDisc() -{ - PhononAutoReleasePool pool; - NSArray *devices = [[NSWorkspace sharedWorkspace] mountedRemovableMedia]; - for (unsigned int i=0; i<[devices count]; ++i) { - NSString *dev = [devices objectAtIndex:i]; - if (isCompactDisc(dev)) - return [dev retain]; - } - return 0; -} - -bool QuickTimeVideoPlayer::isCompactDisc(NSString *path) -{ - PhononAutoReleasePool pool; - NSString *type = [NSString string]; - [[NSWorkspace sharedWorkspace] getFileSystemInfoForPath:path - isRemovable:0 - isWritable:0 - isUnmountable:0 - description:0 - type:&type]; - return [type hasPrefix:@"cdd"]; -} - -NSArray* QuickTimeVideoPlayer::scanFolder(NSString *path) -{ - NSMutableArray *tracks = [NSMutableArray arrayWithCapacity:20]; - if (!path) - return tracks; - - NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtPath:path]; - while (NSString *track = [enumerator nextObject]) { - if (![track hasPrefix:@"."]) - [tracks addObject:[path stringByAppendingPathComponent:track]]; - } - return tracks; -} - -void QuickTimeVideoPlayer::setCurrentTrack(int track) -{ - PhononAutoReleasePool pool; - [m_QTMovie release]; - m_QTMovie = 0; - m_currentTime = 0; - m_currentTrack = track; - - if (!m_folderTracks) - return; - if (track < 0 || track >= (int)[m_folderTracks count]) - return; - - NSString *trackPath = [m_folderTracks objectAtIndex:track]; - QTDataReference *dataRef = [QTDataReference dataReferenceWithReferenceToFile:trackPath]; - State currentState = m_state; - openMovieFromDataRef(dataRef); - prepareCurrentMovieForPlayback(); - if (currentState == Playing) - play(); -} - }} QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/qt7/videoframe.mm b/src/3rdparty/phonon/qt7/videoframe.mm index 7b67b5e..92a3cd5 100644 --- a/src/3rdparty/phonon/qt7/videoframe.mm +++ b/src/3rdparty/phonon/qt7/videoframe.mm @@ -20,8 +20,6 @@ #import <QuartzCore/CIFilter.h> #import <QuartzCore/CIContext.h> -//#define CACHE_CV_TEXTURE - QT_BEGIN_NAMESPACE namespace Phonon @@ -72,9 +70,7 @@ namespace QT7 void VideoFrame::copyMembers(const VideoFrame& frame) { -#ifdef CACHE_CV_TEXTURE m_cachedCVTextureRef = frame.m_cachedCVTextureRef; -#endif m_cachedCIImage = frame.m_cachedCIImage; m_cachedQImage = frame.m_cachedQImage; m_cachedNSBitmap = frame.m_cachedNSBitmap; @@ -109,20 +105,11 @@ namespace QT7 CVOpenGLTextureRef VideoFrame::cachedCVTexture() const { -#ifdef CACHE_CV_TEXTURE if (!m_cachedCVTextureRef && m_videoPlayer){ m_videoPlayer->setColors(m_brightness, m_contrast, m_hue, m_saturation); (const_cast<VideoFrame *>(this))->m_cachedCVTextureRef = m_videoPlayer->currentFrameAsCVTexture(); - CVOpenGLTextureRetain((const_cast<VideoFrame *>(this))->m_cachedCVTextureRef); } return m_cachedCVTextureRef; -#else - if (m_videoPlayer){ - m_videoPlayer->setColors(m_brightness, m_contrast, m_hue, m_saturation); - return m_videoPlayer->currentFrameAsCVTexture(); - } - return 0; -#endif } void *VideoFrame::cachedCIImage() const @@ -342,12 +329,10 @@ namespace QT7 void VideoFrame::invalidateImage() const { -#ifdef CACHE_CV_TEXTURE if (m_cachedCVTextureRef){ CVOpenGLTextureRelease(m_cachedCVTextureRef); (const_cast<VideoFrame *>(this))->m_cachedCVTextureRef = 0; } -#endif if (m_cachedCIImage){ [(CIImage *) m_cachedCIImage release]; (const_cast<VideoFrame *>(this))->m_cachedCIImage = 0; @@ -361,10 +346,8 @@ namespace QT7 void VideoFrame::retain() const { -#ifdef CACHE_CV_TEXTURE if (m_cachedCVTextureRef) CVOpenGLTextureRetain(m_cachedCVTextureRef); -#endif if (m_cachedCIImage) [(CIImage *) m_cachedCIImage retain]; if (m_backgroundFrame) @@ -375,12 +358,8 @@ namespace QT7 void VideoFrame::release() const { -#ifdef CACHE_CV_TEXTURE - if (m_cachedCVTextureRef){ + if (m_cachedCVTextureRef) CVOpenGLTextureRelease(m_cachedCVTextureRef); - (const_cast<VideoFrame *>(this))->m_cachedCVTextureRef = 0; - } -#endif if (m_cachedCIImage) [(CIImage *) m_cachedCIImage release]; if (m_backgroundFrame) @@ -389,6 +368,7 @@ namespace QT7 [m_cachedNSBitmap release]; (const_cast<VideoFrame *>(this))->m_backgroundFrame = 0; + (const_cast<VideoFrame *>(this))->m_cachedCVTextureRef = 0; (const_cast<VideoFrame *>(this))->m_cachedCIImage = 0; (const_cast<VideoFrame *>(this))->m_cachedNSBitmap = 0; } |