diff --git a/dom/media/AbstractMediaDecoder.h b/dom/media/AbstractMediaDecoder.h index d7a848af706..4f79ecb989f 100644 --- a/dom/media/AbstractMediaDecoder.h +++ b/dom/media/AbstractMediaDecoder.h @@ -103,7 +103,7 @@ public: virtual bool IsMediaSeekable() = 0; virtual void MetadataLoaded(nsAutoPtr aInfo, nsAutoPtr aTags, MediaDecoderEventVisibility aEventVisibility) = 0; - virtual void QueueMetadata(int64_t aTime, nsAutoPtr aInfo, nsAutoPtr aTags) = 0; + virtual void QueueMetadata(const media::TimeUnit& aTime, nsAutoPtr aInfo, nsAutoPtr aTags) = 0; virtual void FirstFrameLoaded(nsAutoPtr aInfo, MediaDecoderEventVisibility aEventVisibility) = 0; virtual void RemoveMediaTracks() = 0; diff --git a/dom/media/MediaDecoder.cpp b/dom/media/MediaDecoder.cpp index 563af128f2a..6a042182f6c 100644 --- a/dom/media/MediaDecoder.cpp +++ b/dom/media/MediaDecoder.cpp @@ -638,7 +638,7 @@ already_AddRefed MediaDecoder::GetCurrentPrincipal() return mResource ? mResource->GetCurrentPrincipal() : nullptr; } -void MediaDecoder::QueueMetadata(int64_t aPublishTime, +void MediaDecoder::QueueMetadata(const TimeUnit& aPublishTime, nsAutoPtr aInfo, nsAutoPtr aTags) { diff --git a/dom/media/MediaDecoder.h b/dom/media/MediaDecoder.h index 866bf1625ae..6fff7a57441 100644 --- a/dom/media/MediaDecoder.h +++ b/dom/media/MediaDecoder.h @@ -582,7 +582,7 @@ public: // Send a new set of metadata to the state machine, to be dispatched to the // main thread to be presented when the |currentTime| of the media is greater // or equal to aPublishTime. - void QueueMetadata(int64_t aPublishTime, + void QueueMetadata(const media::TimeUnit& aPublishTime, nsAutoPtr aInfo, nsAutoPtr aTags) override; diff --git a/dom/media/MediaDecoderStateMachine.cpp b/dom/media/MediaDecoderStateMachine.cpp index 5eae55a691e..bedd6110a4e 100644 --- a/dom/media/MediaDecoderStateMachine.cpp +++ b/dom/media/MediaDecoderStateMachine.cpp @@ -1106,7 +1106,7 @@ void MediaDecoderStateMachine::UpdatePlaybackPosition(int64_t aTime) UpdatePlaybackPositionInternal(aTime); bool fragmentEnded = mFragmentEndTime >= 0 && GetMediaTime() >= mFragmentEndTime; - mMetadataManager.DispatchMetadataIfNeeded(mDecoder, aTime); + mMetadataManager.DispatchMetadataIfNeeded(mDecoder, TimeUnit::FromMicroseconds(aTime)); if (fragmentEnded) { StopPlayback(); @@ -3007,7 +3007,7 @@ bool MediaDecoderStateMachine::IsShutdown() return mIsShutdown; } -void MediaDecoderStateMachine::QueueMetadata(int64_t aPublishTime, +void MediaDecoderStateMachine::QueueMetadata(const TimeUnit& aPublishTime, nsAutoPtr aInfo, nsAutoPtr aTags) { diff --git a/dom/media/MediaDecoderStateMachine.h b/dom/media/MediaDecoderStateMachine.h index 813939c094e..2891455c30c 100644 --- a/dom/media/MediaDecoderStateMachine.h +++ b/dom/media/MediaDecoderStateMachine.h @@ -332,7 +332,7 @@ public: // shutting down. The decoder monitor must be held while calling this. bool IsShutdown(); - void QueueMetadata(int64_t aPublishTime, + void QueueMetadata(const media::TimeUnit& aPublishTime, nsAutoPtr aInfo, nsAutoPtr aTags); diff --git a/dom/media/MediaMetadataManager.h b/dom/media/MediaMetadataManager.h index d75575cf941..3414f0a9cce 100644 --- a/dom/media/MediaMetadataManager.h +++ b/dom/media/MediaMetadataManager.h @@ -11,6 +11,7 @@ #include "nsAutoPtr.h" #include "AbstractMediaDecoder.h" +#include "TimeUnits.h" #include "VideoUtils.h" namespace mozilla { @@ -20,7 +21,7 @@ namespace mozilla { class TimedMetadata : public LinkedListElement { public: // The time, in microseconds, at which those metadata should be available. - int64_t mPublishTime; + media::TimeUnit mPublishTime; // The metadata. The ownership is transfered to the element when dispatching to // the main threads. nsAutoPtr mTags; @@ -46,9 +47,9 @@ public: mMetadataQueue.insertBack(aMetadata); } - void DispatchMetadataIfNeeded(AbstractMediaDecoder* aDecoder, double aCurrentTime) { + void DispatchMetadataIfNeeded(AbstractMediaDecoder* aDecoder, const media::TimeUnit& aCurrentTime) { TimedMetadata* metadata = mMetadataQueue.getFirst(); - while (metadata && aCurrentTime >= static_cast(metadata->mPublishTime) / USECS_PER_S) { + while (metadata && aCurrentTime >= metadata->mPublishTime) { // Remove all media tracks from the list first. nsCOMPtr removeTracksEvent = new RemoveMediaTracksEventRunner(aDecoder); diff --git a/dom/media/mediasource/SourceBufferDecoder.cpp b/dom/media/mediasource/SourceBufferDecoder.cpp index 9a34cde2885..a17e7858bd4 100644 --- a/dom/media/mediasource/SourceBufferDecoder.cpp +++ b/dom/media/mediasource/SourceBufferDecoder.cpp @@ -100,7 +100,7 @@ SourceBufferDecoder::FirstFrameLoaded(nsAutoPtr aInfo, } void -SourceBufferDecoder::QueueMetadata(int64_t aTime, +SourceBufferDecoder::QueueMetadata(const media::TimeUnit& aTime, nsAutoPtr aInfo, nsAutoPtr aTags) { diff --git a/dom/media/mediasource/SourceBufferDecoder.h b/dom/media/mediasource/SourceBufferDecoder.h index 1d9b89aaa29..4183da57b65 100644 --- a/dom/media/mediasource/SourceBufferDecoder.h +++ b/dom/media/mediasource/SourceBufferDecoder.h @@ -51,7 +51,7 @@ public: virtual void NotifyDecodedFrames(uint32_t aParsed, uint32_t aDecoded, uint32_t aDropped) final override; virtual void NotifyWaitingForResourcesStatusChanged() final override; virtual void OnReadMetadataCompleted() final override; - virtual void QueueMetadata(int64_t aTime, nsAutoPtr aInfo, nsAutoPtr aTags) final override; + virtual void QueueMetadata(const media::TimeUnit& aTime, nsAutoPtr aInfo, nsAutoPtr aTags) final override; virtual void RemoveMediaTracks() final override; virtual void SetMediaSeekable(bool aMediaSeekable) final override; virtual bool HasInitializationData() final override; diff --git a/dom/media/ogg/OggReader.cpp b/dom/media/ogg/OggReader.cpp index 88f5688287e..b54e1f3c6bf 100644 --- a/dom/media/ogg/OggReader.cpp +++ b/dom/media/ogg/OggReader.cpp @@ -814,11 +814,10 @@ bool OggReader::ReadOggChain() if (chained) { SetChained(true); { - nsAutoPtr info(new MediaInfo()); - *info = mInfo; + nsAutoPtr info(new MediaInfo(mInfo)); ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor()); - mDecoder->QueueMetadata((mDecodedAudioFrames * USECS_PER_S) / mInfo.mAudio.mRate, - info, tags); + auto t = mDecodedAudioFrames * USECS_PER_S / mInfo.mAudio.mRate; + mDecoder->QueueMetadata(media::TimeUnit::FromMicroseconds(t), info, tags); } return true; } diff --git a/dom/media/webaudio/BufferDecoder.cpp b/dom/media/webaudio/BufferDecoder.cpp index 2b4c8feff05..8018451929e 100644 --- a/dom/media/webaudio/BufferDecoder.cpp +++ b/dom/media/webaudio/BufferDecoder.cpp @@ -130,7 +130,7 @@ BufferDecoder::FirstFrameLoaded(nsAutoPtr aInfo, MediaDecoderEventVis } void -BufferDecoder::QueueMetadata(int64_t aTime, nsAutoPtr aInfo, nsAutoPtr aTags) +BufferDecoder::QueueMetadata(const media::TimeUnit& aTime, nsAutoPtr aInfo, nsAutoPtr aTags) { // ignore } diff --git a/dom/media/webaudio/BufferDecoder.h b/dom/media/webaudio/BufferDecoder.h index 8b152b3ff3e..916f6853d67 100644 --- a/dom/media/webaudio/BufferDecoder.h +++ b/dom/media/webaudio/BufferDecoder.h @@ -58,7 +58,7 @@ public: virtual void MetadataLoaded(nsAutoPtr aInfo, nsAutoPtr aTags, MediaDecoderEventVisibility aEventVisibility) final override; - virtual void QueueMetadata(int64_t aTime, nsAutoPtr aInfo, nsAutoPtr aTags) final override; + virtual void QueueMetadata(const media::TimeUnit& aTime, nsAutoPtr aInfo, nsAutoPtr aTags) final override; virtual void FirstFrameLoaded(nsAutoPtr aInfo, MediaDecoderEventVisibility aEventVisibility) final override;