From 88bb7f29c15fc02b07dfca002bdff58f7f182e35 Mon Sep 17 00:00:00 2001 From: Matthew Gregan Date: Mon, 18 Nov 2013 17:22:47 +1300 Subject: [PATCH] Bug 939662 - Remove "using namespace mozilla::dom;" from MediaDecoder.h and fix fallout. r=cpearce --- content/media/DecoderTraits.cpp | 2 +- content/media/MediaDecoder.cpp | 8 +++--- content/media/MediaDecoder.h | 25 ++++++++----------- content/media/MediaDecoderStateMachine.cpp | 6 ++--- content/media/MediaDecoderStateMachine.h | 2 +- content/media/MediaResource.cpp | 18 ++++++------- content/media/RtspMediaResource.cpp | 6 ++--- content/media/gstreamer/GStreamerReader.cpp | 2 +- content/media/mediasource/MediaSource.h | 1 - .../media/mediasource/MediaSourceDecoder.cpp | 8 +++--- .../media/mediasource/MediaSourceDecoder.h | 8 +++--- content/media/mediasource/SubBufferDecoder.h | 2 +- content/media/ogg/OggReader.cpp | 2 +- content/media/wmf/WMFReader.cpp | 2 +- 14 files changed, 43 insertions(+), 49 deletions(-) diff --git a/content/media/DecoderTraits.cpp b/content/media/DecoderTraits.cpp index 7c8143441b28..ec1622f31f7b 100644 --- a/content/media/DecoderTraits.cpp +++ b/content/media/DecoderTraits.cpp @@ -476,7 +476,7 @@ DecoderTraits::CreateDecoder(const nsACString& aType, MediaDecoderOwner* aOwner) // AMR audio is enabled for MMS, but we are discouraging Web and App // developers from using AMR, thus we only allow AMR to be played on WebApps. if (aType.EqualsASCII("audio/amr")) { - HTMLMediaElement* element = aOwner->GetMediaElement(); + dom::HTMLMediaElement* element = aOwner->GetMediaElement(); if (!element) { return nullptr; } diff --git a/content/media/MediaDecoder.cpp b/content/media/MediaDecoder.cpp index fad35fa7ad45..30d4c670aeb5 100644 --- a/content/media/MediaDecoder.cpp +++ b/content/media/MediaDecoder.cpp @@ -570,7 +570,7 @@ nsresult MediaDecoder::Play() * (and can be -1 if aValue is before aRanges.Start(0)). */ static bool -IsInRanges(TimeRanges& aRanges, double aValue, int32_t& aIntervalIndex) +IsInRanges(dom::TimeRanges& aRanges, double aValue, int32_t& aIntervalIndex) { uint32_t length; aRanges.GetLength(&length); @@ -598,7 +598,7 @@ nsresult MediaDecoder::Seek(double aTime) NS_ABORT_IF_FALSE(aTime >= 0.0, "Cannot seek to a negative value."); - TimeRanges seekable; + dom::TimeRanges seekable; nsresult res; uint32_t length = 0; res = GetSeekable(&seekable); @@ -1326,7 +1326,7 @@ bool MediaDecoder::IsMediaSeekable() return mMediaSeekable; } -nsresult MediaDecoder::GetSeekable(TimeRanges* aSeekable) +nsresult MediaDecoder::GetSeekable(dom::TimeRanges* aSeekable) { double initialTime = 0.0; @@ -1492,7 +1492,7 @@ void MediaDecoder::Invalidate() // Constructs the time ranges representing what segments of the media // are buffered and playable. -nsresult MediaDecoder::GetBuffered(TimeRanges* aBuffered) { +nsresult MediaDecoder::GetBuffered(dom::TimeRanges* aBuffered) { if (mDecoderStateMachine) { return mDecoderStateMachine->GetBuffered(aBuffered); } diff --git a/content/media/MediaDecoder.h b/content/media/MediaDecoder.h index 0fcbf44fd8d1..27a66180f142 100644 --- a/content/media/MediaDecoder.h +++ b/content/media/MediaDecoder.h @@ -201,8 +201,6 @@ class TimeRanges; } } -using namespace mozilla::dom; - namespace mozilla { namespace layers { class Image; @@ -232,8 +230,6 @@ class MediaDecoder : public nsIObserver, public AbstractMediaDecoder { public: - typedef mozilla::layers::Image Image; - NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_NSIOBSERVER @@ -371,7 +367,7 @@ public: MediaDecoder* mDecoder; // The last video image sent to the stream. Useful if we need to replicate // the image. - nsRefPtr mLastVideoImage; + nsRefPtr mLastVideoImage; gfxIntSize mLastVideoImageDisplaySize; // This is set to true when the stream is initialized (audio and // video tracks added). @@ -523,7 +519,7 @@ public: virtual bool IsTransportSeekable(); // Return the time ranges that can be seeked into. - virtual nsresult GetSeekable(TimeRanges* aSeekable); + virtual nsresult GetSeekable(dom::TimeRanges* aSeekable); // Set the end time of the media resource. When playback reaches // this point the media pauses. aTime is in seconds. @@ -559,7 +555,7 @@ public: virtual void MoveLoadsToBackground(); // Returns a weak reference to the media decoder owner. - mozilla::MediaDecoderOwner* GetMediaOwner() const; + MediaDecoderOwner* GetMediaOwner() const; // Returns the current size of the framebuffer used in // MozAudioAvailable events. @@ -584,7 +580,7 @@ public: // Constructs the time ranges representing what segments of the media // are buffered and playable. - virtual nsresult GetBuffered(TimeRanges* aBuffered); + virtual nsresult GetBuffered(dom::TimeRanges* aBuffered); // Returns the size, in bytes, of the heap memory used by the currently // queued decoded video and audio data. @@ -595,7 +591,7 @@ public: { return mVideoFrameContainer; } - mozilla::layers::ImageContainer* GetImageContainer() MOZ_OVERRIDE; + layers::ImageContainer* GetImageContainer() MOZ_OVERRIDE; // Sets the length of the framebuffer used in MozAudioAvailable events. // The new size must be between 512 and 16384. @@ -661,8 +657,8 @@ public: // held. void UpdatePlaybackPosition(int64_t aTime) MOZ_FINAL MOZ_OVERRIDE; - void SetAudioChannelType(AudioChannelType aType) { mAudioChannelType = aType; } - AudioChannelType GetAudioChannelType() { return mAudioChannelType; } + void SetAudioChannelType(dom::AudioChannelType aType) { mAudioChannelType = aType; } + dom::AudioChannelType GetAudioChannelType() { return mAudioChannelType; } // 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 @@ -927,6 +923,7 @@ public: GetFrameStatistics().NotifyDecodedFrames(aParsed, aDecoded); } +protected: /****** * The following members should be accessed with the decoder lock held. ******/ @@ -1025,7 +1022,7 @@ private: // The |RestrictedAccessMonitor| member object. RestrictedAccessMonitor mReentrantMonitor; -public: +protected: // Data about MediaStreams that are being fed by this decoder. nsTArray mOutputStreams; // The SourceMediaStream we are using to feed the mOutputStreams. This stream @@ -1087,8 +1084,6 @@ public: // PlaybackEnded when mDecodedStream->mStream finishes. bool mTriggerPlaybackEndedWhenSourceStreamFinishes; -protected: - // Start timer to update download progress information. nsresult StartProgress(); @@ -1148,7 +1143,7 @@ protected: // Be assigned from media element during the initialization and pass to // AudioStream Class. - AudioChannelType mAudioChannelType; + dom::AudioChannelType mAudioChannelType; }; } // namespace mozilla diff --git a/content/media/MediaDecoderStateMachine.cpp b/content/media/MediaDecoderStateMachine.cpp index 72297f9ffa51..a056ceb874cb 100644 --- a/content/media/MediaDecoderStateMachine.cpp +++ b/content/media/MediaDecoderStateMachine.cpp @@ -1605,7 +1605,7 @@ void MediaDecoderStateMachine::NotifyDataArrived(const char* aBuffer, // faster than played, mEndTime won't reflect the end of playable data // since we haven't played the frame at the end of buffered data. So update // mEndTime here as new data is downloaded to prevent such a lag. - TimeRanges buffered; + dom::TimeRanges buffered; if (mDecoder->IsInfinite() && NS_SUCCEEDED(mDecoder->GetBuffered(&buffered))) { @@ -1851,7 +1851,7 @@ int64_t MediaDecoderStateMachine::GetUndecodedData() const AssertCurrentThreadInMonitor(); NS_ASSERTION(mState > DECODER_STATE_DECODING_METADATA, "Must have loaded metadata for GetBuffered() to work"); - TimeRanges buffered; + dom::TimeRanges buffered; nsresult res = mDecoder->GetBuffered(&buffered); NS_ENSURE_SUCCESS(res, 0); @@ -2713,7 +2713,7 @@ void MediaDecoderStateMachine::StartBuffering() stats.mDownloadRate/1024, stats.mDownloadRateReliable ? "" : " (unreliable)")); } -nsresult MediaDecoderStateMachine::GetBuffered(TimeRanges* aBuffered) { +nsresult MediaDecoderStateMachine::GetBuffered(dom::TimeRanges* aBuffered) { MediaResource* resource = mDecoder->GetResource(); NS_ENSURE_TRUE(resource, NS_ERROR_FAILURE); resource->Pin(); diff --git a/content/media/MediaDecoderStateMachine.h b/content/media/MediaDecoderStateMachine.h index 7e5aad6b01a6..8897ef6e8b38 100644 --- a/content/media/MediaDecoderStateMachine.h +++ b/content/media/MediaDecoderStateMachine.h @@ -255,7 +255,7 @@ public: return mState == DECODER_STATE_SEEKING; } - nsresult GetBuffered(TimeRanges* aBuffered); + nsresult GetBuffered(dom::TimeRanges* aBuffered); void SetPlaybackRate(double aPlaybackRate); void SetPreservesPitch(bool aPreservesPitch); diff --git a/content/media/MediaResource.cpp b/content/media/MediaResource.cpp index 555058282dc1..f5806b659e73 100644 --- a/content/media/MediaResource.cpp +++ b/content/media/MediaResource.cpp @@ -147,7 +147,7 @@ ChannelMediaResource::OnStartRequest(nsIRequest* aRequest) MediaDecoderOwner* owner = mDecoder->GetMediaOwner(); NS_ENSURE_TRUE(owner, NS_ERROR_FAILURE); - HTMLMediaElement* element = owner->GetMediaElement(); + dom::HTMLMediaElement* element = owner->GetMediaElement(); NS_ENSURE_TRUE(element, NS_ERROR_FAILURE); nsresult status; nsresult rv = aRequest->GetStatus(&status); @@ -583,7 +583,7 @@ nsresult ChannelMediaResource::OpenChannel(nsIStreamListener** aStreamListener) // an authorizing Access-Control header. MediaDecoderOwner* owner = mDecoder->GetMediaOwner(); NS_ENSURE_TRUE(owner, NS_ERROR_FAILURE); - HTMLMediaElement* element = owner->GetMediaElement(); + dom::HTMLMediaElement* element = owner->GetMediaElement(); NS_ENSURE_TRUE(element, NS_ERROR_FAILURE); if (element->ShouldCheckAllowOrigin()) { nsRefPtr crossSiteListener = @@ -642,7 +642,7 @@ void ChannelMediaResource::SetupChannelHeaders() if (!owner) { return; } - HTMLMediaElement* element = owner->GetMediaElement(); + dom::HTMLMediaElement* element = owner->GetMediaElement(); if (!element) { return; } @@ -805,7 +805,7 @@ void ChannelMediaResource::Suspend(bool aCloseImmediately) // Shutting down; do nothing. return; } - HTMLMediaElement* element = owner->GetMediaElement(); + dom::HTMLMediaElement* element = owner->GetMediaElement(); if (!element) { // Shutting down; do nothing. return; @@ -840,7 +840,7 @@ void ChannelMediaResource::Resume() // Shutting down; do nothing. return; } - HTMLMediaElement* element = owner->GetMediaElement(); + dom::HTMLMediaElement* element = owner->GetMediaElement(); if (!element) { // Shutting down; do nothing. return; @@ -889,7 +889,7 @@ ChannelMediaResource::RecreateChannel() // The decoder is being shut down, so don't bother opening a new channel return NS_OK; } - HTMLMediaElement* element = owner->GetMediaElement(); + dom::HTMLMediaElement* element = owner->GetMediaElement(); if (!element) { // The decoder is being shut down, so don't bother opening a new channel return NS_OK; @@ -1309,7 +1309,7 @@ nsresult FileMediaResource::Open(nsIStreamListener** aStreamListener) // web server. MediaDecoderOwner* owner = mDecoder->GetMediaOwner(); NS_ENSURE_TRUE(owner, NS_ERROR_FAILURE); - HTMLMediaElement* element = owner->GetMediaElement(); + dom::HTMLMediaElement* element = owner->GetMediaElement(); NS_ENSURE_TRUE(element, NS_ERROR_FAILURE); rv = nsContentUtils::GetSecurityManager()-> @@ -1374,7 +1374,7 @@ already_AddRefed FileMediaResource::CloneData(MediaDecoder* aDeco // The decoder is being shut down, so we can't clone return nullptr; } - HTMLMediaElement* element = owner->GetMediaElement(); + dom::HTMLMediaElement* element = owner->GetMediaElement(); if (!element) { // The decoder is being shut down, so we can't clone return nullptr; @@ -1533,7 +1533,7 @@ void BaseMediaResource::MoveLoadsToBackground() { NS_WARNING("Null owner in MediaResource::MoveLoadsToBackground()"); return; } - HTMLMediaElement* element = owner->GetMediaElement(); + dom::HTMLMediaElement* element = owner->GetMediaElement(); if (!element) { NS_WARNING("Null element in MediaResource::MoveLoadsToBackground()"); return; diff --git a/content/media/RtspMediaResource.cpp b/content/media/RtspMediaResource.cpp index a9d4074e94cf..20f78594e002 100644 --- a/content/media/RtspMediaResource.cpp +++ b/content/media/RtspMediaResource.cpp @@ -504,7 +504,7 @@ RtspMediaResource::OnConnected(uint8_t aTrackIdx, MediaDecoderOwner* owner = mDecoder->GetMediaOwner(); NS_ENSURE_TRUE(owner, NS_ERROR_FAILURE); - HTMLMediaElement* element = owner->GetMediaElement(); + dom::HTMLMediaElement* element = owner->GetMediaElement(); NS_ENSURE_TRUE(element, NS_ERROR_FAILURE); element->FinishDecoderSetup(mDecoder, this); @@ -535,7 +535,7 @@ void RtspMediaResource::Suspend(bool aCloseImmediately) MediaDecoderOwner* owner = mDecoder->GetMediaOwner(); NS_ENSURE_TRUE_VOID(owner); - HTMLMediaElement* element = owner->GetMediaElement(); + dom::HTMLMediaElement* element = owner->GetMediaElement(); NS_ENSURE_TRUE_VOID(element); mMediaStreamController->Suspend(); @@ -548,7 +548,7 @@ void RtspMediaResource::Resume() MediaDecoderOwner* owner = mDecoder->GetMediaOwner(); NS_ENSURE_TRUE_VOID(owner); - HTMLMediaElement* element = owner->GetMediaElement(); + dom::HTMLMediaElement* element = owner->GetMediaElement(); NS_ENSURE_TRUE_VOID(element); if (mChannel) { diff --git a/content/media/gstreamer/GStreamerReader.cpp b/content/media/gstreamer/GStreamerReader.cpp index 4cb1b80092fc..c35d2e3149b4 100644 --- a/content/media/gstreamer/GStreamerReader.cpp +++ b/content/media/gstreamer/GStreamerReader.cpp @@ -654,7 +654,7 @@ nsresult GStreamerReader::Seek(int64_t aTarget, return DecodeToTarget(aTarget); } -nsresult GStreamerReader::GetBuffered(TimeRanges* aBuffered, +nsresult GStreamerReader::GetBuffered(dom::TimeRanges* aBuffered, int64_t aStartTime) { if (!mInfo.HasValidMedia()) { diff --git a/content/media/mediasource/MediaSource.h b/content/media/mediasource/MediaSource.h index 0e920fef121b..295e82b8e3ec 100644 --- a/content/media/mediasource/MediaSource.h +++ b/content/media/mediasource/MediaSource.h @@ -35,7 +35,6 @@ namespace dom { class GlobalObject; class SourceBuffer; class SourceBufferList; -class TimeRanges; template class Optional; #define MOZILLA_DOM_MEDIASOURCE_IMPLEMENTATION_IID \ diff --git a/content/media/mediasource/MediaSourceDecoder.cpp b/content/media/mediasource/MediaSourceDecoder.cpp index 13895b9a95cb..beeb3f3624ad 100644 --- a/content/media/mediasource/MediaSourceDecoder.cpp +++ b/content/media/mediasource/MediaSourceDecoder.cpp @@ -120,7 +120,7 @@ private: } }; -MediaSourceDecoder::MediaSourceDecoder(HTMLMediaElement* aElement) +MediaSourceDecoder::MediaSourceDecoder(dom::HTMLMediaElement* aElement) : mMediaSource(nullptr) , mVideoReader(nullptr), mAudioReader(nullptr) @@ -148,13 +148,13 @@ MediaSourceDecoder::Load(nsIStreamListener**, MediaDecoder*) } nsresult -MediaSourceDecoder::GetSeekable(TimeRanges* aSeekable) +MediaSourceDecoder::GetSeekable(dom::TimeRanges* aSeekable) { double duration = mMediaSource->Duration(); if (IsNaN(duration)) { // Return empty range. } else if (duration > 0 && mozilla::IsInfinite(duration)) { - nsRefPtr bufferedRanges = new TimeRanges(); + nsRefPtr bufferedRanges = new dom::TimeRanges(); GetBuffered(bufferedRanges); aSeekable->Add(0, bufferedRanges->GetFinalEndTime()); } else { @@ -164,7 +164,7 @@ MediaSourceDecoder::GetSeekable(TimeRanges* aSeekable) } void -MediaSourceDecoder::AttachMediaSource(MediaSource* aMediaSource) +MediaSourceDecoder::AttachMediaSource(dom::MediaSource* aMediaSource) { MOZ_ASSERT(!mMediaSource && !mDecoderStateMachine); mMediaSource = aMediaSource; diff --git a/content/media/mediasource/MediaSourceDecoder.h b/content/media/mediasource/MediaSourceDecoder.h index e85f61640600..747876a6ba4f 100644 --- a/content/media/mediasource/MediaSourceDecoder.h +++ b/content/media/mediasource/MediaSourceDecoder.h @@ -36,14 +36,14 @@ class MediaSource; class MediaSourceDecoder : public MediaDecoder { public: - MediaSourceDecoder(HTMLMediaElement* aElement); + MediaSourceDecoder(dom::HTMLMediaElement* aElement); virtual MediaDecoder* Clone() MOZ_OVERRIDE; virtual MediaDecoderStateMachine* CreateStateMachine() MOZ_OVERRIDE; virtual nsresult Load(nsIStreamListener**, MediaDecoder*) MOZ_OVERRIDE; - virtual nsresult GetSeekable(TimeRanges* aSeekable) MOZ_OVERRIDE; + virtual nsresult GetSeekable(dom::TimeRanges* aSeekable) MOZ_OVERRIDE; - void AttachMediaSource(MediaSource* aMediaSource); + void AttachMediaSource(dom::MediaSource* aMediaSource); void DetachMediaSource(); SubBufferDecoder* CreateSubDecoder(const nsACString& aType); @@ -80,7 +80,7 @@ public: } private: - MediaSource* mMediaSource; + dom::MediaSource* mMediaSource; nsTArray > mDecoders; nsTArray mReaders; // Readers owned by Decoders. diff --git a/content/media/mediasource/SubBufferDecoder.h b/content/media/mediasource/SubBufferDecoder.h index cb11a4440765..2444474e3d99 100644 --- a/content/media/mediasource/SubBufferDecoder.h +++ b/content/media/mediasource/SubBufferDecoder.h @@ -48,7 +48,7 @@ public: mParentDecoder->NotifyDataArrived(aBuffer, aLength, aOffset); } - nsresult GetBuffered(TimeRanges* aBuffered) + nsresult GetBuffered(dom::TimeRanges* aBuffered) { // XXX: Need mStartTime (from StateMachine) instead of passing 0. return mReader->GetBuffered(aBuffered, 0); diff --git a/content/media/ogg/OggReader.cpp b/content/media/ogg/OggReader.cpp index eb670c96a81a..941cc04204cb 100644 --- a/content/media/ogg/OggReader.cpp +++ b/content/media/ogg/OggReader.cpp @@ -1772,7 +1772,7 @@ nsresult OggReader::SeekBisection(int64_t aTarget, return NS_OK; } -nsresult OggReader::GetBuffered(TimeRanges* aBuffered, int64_t aStartTime) +nsresult OggReader::GetBuffered(dom::TimeRanges* aBuffered, int64_t aStartTime) { { mozilla::ReentrantMonitorAutoEnter mon(mMonitor); diff --git a/content/media/wmf/WMFReader.cpp b/content/media/wmf/WMFReader.cpp index 17c2610054b0..48ba03be7d6a 100644 --- a/content/media/wmf/WMFReader.cpp +++ b/content/media/wmf/WMFReader.cpp @@ -114,7 +114,7 @@ WMFReader::InitializeDXVA() MediaDecoderOwner* owner = mDecoder->GetOwner(); NS_ENSURE_TRUE(owner, false); - HTMLMediaElement* element = owner->GetMediaElement(); + dom::HTMLMediaElement* element = owner->GetMediaElement(); NS_ENSURE_TRUE(element, false); nsRefPtr layerManager =