From f104891fe41b60c2060310c40a7efd07e70946ad Mon Sep 17 00:00:00 2001 From: Ralph Giles Date: Wed, 22 Jul 2015 11:40:09 -0700 Subject: [PATCH] Bug 1186257 - Avoid 'using' namespace imports in headers. r=jya This is poor style as it can have side-effects in the caller's code. Instead, use full namespace prefixes. --- dom/media/mediasource/SourceBuffer.h | 9 +-- .../mediasource/SourceBufferContentManager.h | 18 ++--- dom/media/mediasource/TrackBuffer.cpp | 1 + dom/media/mediasource/TrackBuffer.h | 16 ++-- dom/media/mediasource/TrackBuffersManager.cpp | 5 +- dom/media/mediasource/TrackBuffersManager.h | 80 ++++++++++--------- 6 files changed, 68 insertions(+), 61 deletions(-) diff --git a/dom/media/mediasource/SourceBuffer.h b/dom/media/mediasource/SourceBuffer.h index 1ec7881f45ba..400d0c6a25b6 100644 --- a/dom/media/mediasource/SourceBuffer.h +++ b/dom/media/mediasource/SourceBuffer.h @@ -38,9 +38,6 @@ class TrackBuffersManager; namespace dom { -using media::TimeUnit; -using media::TimeIntervals; - class TimeRanges; class SourceBuffer final : public DOMEventTargetHelper @@ -60,7 +57,7 @@ public: } already_AddRefed GetBuffered(ErrorResult& aRv); - TimeIntervals GetTimeIntervals(); + media::TimeIntervals GetTimeIntervals(); double TimestampOffset() const { @@ -168,7 +165,7 @@ private: void AppendDataErrored(nsresult aError); // Set timestampOffset, must be called on the main thread. - void SetTimestampOffset(const TimeUnit& aTimestampOffset); + void SetTimestampOffset(const media::TimeUnit& aTimestampOffset); nsRefPtr mMediaSource; @@ -180,7 +177,7 @@ private: double mAppendWindowEnd; double mApparentTimestampOffset; - TimeUnit mTimestampOffset; + media::TimeUnit mTimestampOffset; SourceBufferAppendMode mAppendMode; bool mUpdating; diff --git a/dom/media/mediasource/SourceBufferContentManager.h b/dom/media/mediasource/SourceBufferContentManager.h index f45932638d77..37c739b32ef9 100644 --- a/dom/media/mediasource/SourceBufferContentManager.h +++ b/dom/media/mediasource/SourceBufferContentManager.h @@ -16,9 +16,6 @@ namespace mozilla { -using media::TimeUnit; -using media::TimeIntervals; - namespace dom { class SourceBuffer; } @@ -37,7 +34,7 @@ public: // Add data to the end of the input buffer. // Returns false if the append failed. virtual bool - AppendData(MediaByteBuffer* aData, TimeUnit aTimestampOffset) = 0; + AppendData(MediaByteBuffer* aData, media::TimeUnit aTimestampOffset) = 0; // Run MSE Buffer Append Algorithm // 3.5.5 Buffer Append Algorithm. @@ -54,7 +51,8 @@ public: // Runs MSE range removal algorithm. // http://w3c.github.io/media-source/#sourcebuffer-coded-frame-removal - virtual nsRefPtr RangeRemoval(TimeUnit aStart, TimeUnit aEnd) = 0; + virtual nsRefPtr RangeRemoval(media::TimeUnit aStart, + media::TimeUnit aEnd) = 0; enum class EvictDataResult : int8_t { @@ -69,10 +67,12 @@ public: // bytes. aBufferStartTime contains the new start time of the data after the // eviction. virtual EvictDataResult - EvictData(TimeUnit aPlaybackTime, uint32_t aThreshold, TimeUnit* aBufferStartTime) = 0; + EvictData(media::TimeUnit aPlaybackTime, + uint32_t aThreshold, + media::TimeUnit* aBufferStartTime) = 0; // Evicts data up to aTime. - virtual void EvictBefore(TimeUnit aTime) = 0; + virtual void EvictBefore(media::TimeUnit aTime) = 0; // Returns the buffered range currently managed. // This may be called on any thread. @@ -102,9 +102,9 @@ public: return AppendState::WAITING_FOR_SEGMENT; } - virtual void SetGroupStartTimestamp(const TimeUnit& aGroupStartTimestamp) {} + virtual void SetGroupStartTimestamp(const media::TimeUnit& aGroupStartTimestamp) {} virtual void RestartGroupStartTimestamp() {} - virtual TimeUnit GroupEndTimestamp() = 0; + virtual media::TimeUnit GroupEndTimestamp() = 0; #if defined(DEBUG) virtual void Dump(const char* aPath) { } diff --git a/dom/media/mediasource/TrackBuffer.cpp b/dom/media/mediasource/TrackBuffer.cpp index 400dfc0c738d..b530c4965faf 100644 --- a/dom/media/mediasource/TrackBuffer.cpp +++ b/dom/media/mediasource/TrackBuffer.cpp @@ -40,6 +40,7 @@ namespace mozilla { using media::TimeIntervals; using media::Interval; +using media::TimeUnit; TrackBuffer::TrackBuffer(MediaSourceDecoder* aParentDecoder, const nsACString& aType) : mParentDecoder(aParentDecoder) diff --git a/dom/media/mediasource/TrackBuffer.h b/dom/media/mediasource/TrackBuffer.h index eaaddb32cca6..4b1a114a7f21 100644 --- a/dom/media/mediasource/TrackBuffer.h +++ b/dom/media/mediasource/TrackBuffer.h @@ -31,7 +31,8 @@ public: nsRefPtr Shutdown(); - bool AppendData(MediaByteBuffer* aData, TimeUnit aTimestampOffset) override; + bool AppendData(MediaByteBuffer* aData, + media::TimeUnit aTimestampOffset) override; // Append data to the current decoder. Also responsible for calling // NotifyDataArrived on the decoder to keep buffered range computation up @@ -43,13 +44,16 @@ public: // bound the data being evicted. It will not evict more than aThreshold // bytes. aBufferStartTime contains the new start time of the current // decoders buffered data after the eviction. - EvictDataResult EvictData(TimeUnit aPlaybackTime, uint32_t aThreshold, TimeUnit* aBufferStartTime) override; + EvictDataResult EvictData(media::TimeUnit aPlaybackTime, + uint32_t aThreshold, + media::TimeUnit* aBufferStartTime) override; // Evicts data held in all the decoders SourceBufferResource from the start // of the buffer through to aTime. - void EvictBefore(TimeUnit aTime) override; + void EvictBefore(media::TimeUnit aTime) override; - nsRefPtr RangeRemoval(TimeUnit aStart, TimeUnit aEnd) override; + nsRefPtr RangeRemoval(media::TimeUnit aStart, + media::TimeUnit aEnd) override; void AbortAppendData() override; @@ -68,7 +72,7 @@ public: void Detach() override; - TimeUnit GroupEndTimestamp() override + media::TimeUnit GroupEndTimestamp() override { return Buffered().GetEnd(); } @@ -211,7 +215,7 @@ private: // AppendData. Accessed on the main thread only. int64_t mLastStartTimestamp; Maybe mLastEndTimestamp; - void AdjustDecodersTimestampOffset(TimeUnit aOffset); + void AdjustDecodersTimestampOffset(media::TimeUnit aOffset); // The timestamp offset used by our current decoder. media::TimeUnit mLastTimestampOffset; diff --git a/dom/media/mediasource/TrackBuffersManager.cpp b/dom/media/mediasource/TrackBuffersManager.cpp index 99811a2b75f2..ab3404d8d2bf 100644 --- a/dom/media/mediasource/TrackBuffersManager.cpp +++ b/dom/media/mediasource/TrackBuffersManager.cpp @@ -37,6 +37,9 @@ PRLogModuleInfo* GetMediaSourceSamplesLog() namespace mozilla { using dom::SourceBufferAppendMode; +using media::TimeUnit; +using media::TimeInterval; +using media::TimeIntervals; static const char* AppendStateToStr(TrackBuffersManager::AppendState aState) @@ -253,7 +256,7 @@ TrackBuffersManager::EvictBefore(TimeUnit aTime) GetTaskQueue()->Dispatch(task.forget()); } -media::TimeIntervals +TimeIntervals TrackBuffersManager::Buffered() { MSE_DEBUG(""); diff --git a/dom/media/mediasource/TrackBuffersManager.h b/dom/media/mediasource/TrackBuffersManager.h index 86bd4cbb25e6..794d5667bf35 100644 --- a/dom/media/mediasource/TrackBuffersManager.h +++ b/dom/media/mediasource/TrackBuffersManager.h @@ -28,10 +28,6 @@ class MediaSourceDemuxer; class SourceBuffer; class SourceBufferResource; -using media::TimeUnit; -using media::TimeInterval; -using media::TimeIntervals; - class TrackBuffersManager : public SourceBufferContentManager { public: typedef MozPromise CodedFrameProcessingPromise; @@ -41,7 +37,8 @@ public: TrackBuffersManager(dom::SourceBuffer* aParent, MediaSourceDecoder* aParentDecoder, const nsACString& aType); - bool AppendData(MediaByteBuffer* aData, TimeUnit aTimestampOffset) override; + bool AppendData(MediaByteBuffer* aData, + media::TimeUnit aTimestampOffset) override; nsRefPtr BufferAppend() override; @@ -49,14 +46,17 @@ public: void ResetParserState() override; - nsRefPtr RangeRemoval(TimeUnit aStart, TimeUnit aEnd) override; + nsRefPtr RangeRemoval(media::TimeUnit aStart, + media::TimeUnit aEnd) override; EvictDataResult - EvictData(TimeUnit aPlaybackTime, uint32_t aThreshold, TimeUnit* aBufferStartTime) override; + EvictData(media::TimeUnit aPlaybackTime, + uint32_t aThreshold, + media::TimeUnit* aBufferStartTime) override; - void EvictBefore(TimeUnit aTime) override; + void EvictBefore(media::TimeUnit aTime) override; - TimeIntervals Buffered() override; + media::TimeIntervals Buffered() override; int64_t GetSize() override; @@ -69,27 +69,28 @@ public: return mAppendState; } - void SetGroupStartTimestamp(const TimeUnit& aGroupStartTimestamp) override; + void SetGroupStartTimestamp(const media::TimeUnit& aGroupStartTimestamp) override; void RestartGroupStartTimestamp() override; - TimeUnit GroupEndTimestamp() override; + media::TimeUnit GroupEndTimestamp() override; // Interface for MediaSourceDemuxer MediaInfo GetMetadata(); const TrackBuffer& GetTrackBuffer(TrackInfo::TrackType aTrack); - const TimeIntervals& Buffered(TrackInfo::TrackType); - TimeIntervals SafeBuffered(TrackInfo::TrackType) const; + const media::TimeIntervals& Buffered(TrackInfo::TrackType); + media::TimeIntervals SafeBuffered(TrackInfo::TrackType) const; bool IsEnded() const { return mEnded; } - TimeUnit Seek(TrackInfo::TrackType aTrack, const TimeUnit& aTime); + media::TimeUnit Seek(TrackInfo::TrackType aTrack, + const media::TimeUnit& aTime); uint32_t SkipToNextRandomAccessPoint(TrackInfo::TrackType aTrack, - const TimeUnit& aTimeThreadshold, + const media::TimeUnit& aTimeThreadshold, bool& aFound); already_AddRefed GetSample(TrackInfo::TrackType aTrack, - const TimeUnit& aFuzz, + const media::TimeUnit& aFuzz, bool& aError); - TimeUnit GetNextRandomAccessPoint(TrackInfo::TrackType aTrack); + media::TimeUnit GetNextRandomAccessPoint(TrackInfo::TrackType aTrack); #if defined(DEBUG) void Dump(const char* aPath) override; @@ -117,8 +118,9 @@ private: // current media segment. void FinishCodedFrameProcessing(); void CompleteResetParserState(); - nsRefPtr CodedFrameRemovalWithPromise(TimeInterval aInterval); - bool CodedFrameRemoval(TimeInterval aInterval); + nsRefPtr + CodedFrameRemovalWithPromise(media::TimeInterval aInterval); + bool CodedFrameRemoval(media::TimeInterval aInterval); void SetAppendState(AppendState aAppendState); bool HasVideo() const @@ -130,7 +132,7 @@ private: return mAudioTracks.mNumTracks > 0; } - typedef Pair, TimeUnit> IncomingBuffer; + typedef Pair, media::TimeUnit> IncomingBuffer; void AppendIncomingBuffer(IncomingBuffer aData); nsTArray mIncomingBuffers; @@ -145,8 +147,8 @@ private: Atomic mBufferFull; bool mFirstInitializationSegmentReceived; bool mActiveTrack; - Maybe mGroupStartTimestamp; - TimeUnit mGroupEndTimestamp; + Maybe mGroupStartTimestamp; + media::TimeUnit mGroupEndTimestamp; nsCString mType; // ContainerParser objects and methods. @@ -185,7 +187,7 @@ private: OnDemuxFailed(TrackType::kAudioTrack, aFailure); } - void DoEvictData(const TimeUnit& aPlaybackTime, uint32_t aThreshold); + void DoEvictData(const media::TimeUnit& aPlaybackTime, uint32_t aThreshold); struct TrackData { TrackData() @@ -200,20 +202,20 @@ private: // last coded frame appended in the current coded frame group. // The variable is initially unset to indicate that no coded frames have // been appended yet. - Maybe mLastDecodeTimestamp; + Maybe mLastDecodeTimestamp; // Last frame duration variable that stores the coded frame duration of the // last coded frame appended in the current coded frame group. // The variable is initially unset to indicate that no coded frames have // been appended yet. - Maybe mLastFrameDuration; + Maybe mLastFrameDuration; // Highest end timestamp variable that stores the highest coded frame end // timestamp across all coded frames in the current coded frame group that // were appended to this track buffer. // The variable is initially unset to indicate that no coded frames have // been appended yet. - Maybe mHighestEndTimestamp; + Maybe mHighestEndTimestamp; // Longest frame duration seen in a coded frame group. - Maybe mLongestFrameDuration; + Maybe mLongestFrameDuration; // Need random access point flag variable that keeps track of whether the // track buffer is waiting for a random access point coded frame. // The variable is initially set to true to indicate that random access @@ -232,7 +234,7 @@ private: nsTArray mBuffers; // Track buffer ranges variable that represents the presentation time ranges // occupied by the coded frames currently stored in the track buffer. - TimeIntervals mBufferedRanges; + media::TimeIntervals mBufferedRanges; // Byte size of all samples contained in this track buffer. uint32_t mSizeBuffer; // TrackInfo of the first metadata received. @@ -243,9 +245,9 @@ private: // If set, position of the next sample to be retrieved by GetSample(). Maybe mNextGetSampleIndex; // Approximation of the next sample's decode timestamp. - TimeUnit mNextSampleTimecode; + media::TimeUnit mNextSampleTimecode; // Approximation of the next sample's presentation timestamp. - TimeUnit mNextSampleTime; + media::TimeUnit mNextSampleTime; void ResetAppendState() { @@ -262,11 +264,11 @@ private: void CheckSequenceDiscontinuity(); void ProcessFrames(TrackBuffer& aSamples, TrackData& aTrackData); void CheckNextInsertionIndex(TrackData& aTrackData, - const TimeUnit& aSampleTime); + const media::TimeUnit& aSampleTime); void InsertFrames(TrackBuffer& aSamples, - const TimeIntervals& aIntervals, + const media::TimeIntervals& aIntervals, TrackData& aTrackData); - void RemoveFrames(const TimeIntervals& aIntervals, + void RemoveFrames(const media::TimeIntervals& aIntervals, TrackData& aTrackData, uint32_t aStartIndex); void UpdateBufferedRanges(); @@ -306,9 +308,9 @@ private: } RefPtr mTaskQueue; - TimeInterval mAppendWindow; - TimeUnit mTimestampOffset; - TimeUnit mLastTimestampOffset; + media::TimeInterval mAppendWindow; + media::TimeUnit mTimestampOffset; + media::TimeUnit mLastTimestampOffset; void RestoreCachedVariables(); // Strong references to external objects. @@ -332,9 +334,9 @@ private: // Monitor to protect following objects accessed across multipple threads. mutable Monitor mMonitor; // Stable audio and video track time ranges. - TimeIntervals mVideoBufferedRanges; - TimeIntervals mAudioBufferedRanges; - TimeUnit mOfficialGroupEndTimestamp; + media::TimeIntervals mVideoBufferedRanges; + media::TimeIntervals mAudioBufferedRanges; + media::TimeUnit mOfficialGroupEndTimestamp; // MediaInfo of the first init segment read. MediaInfo mInfo; };