Bug 1219163. Part 2 - Move some functions that are never called from the interface of AbstractMediaDecoder down the class hierarchy. r=jya.
--- a/dom/media/AbstractMediaDecoder.h
+++ b/dom/media/AbstractMediaDecoder.h
@@ -52,20 +52,16 @@ public:
// A special version of the above for the ogg decoder that is allowed to be
// called cross-thread.
virtual bool IsOggDecoderShutdown() { return false; }
// Get the current MediaResource being used. Its URI will be returned
// by currentSrc. Returns what was passed to Load(), if Load() has been called.
virtual MediaResource* GetResource() const = 0;
- // Called by the decode thread to keep track of the number of bytes read
- // from the resource.
- virtual void NotifyBytesConsumed(int64_t aBytes, int64_t aOffset) = 0;
-
// Increments the parsed, decoded and dropped frame counters by the passed in
// counts.
// Can be called on any thread.
virtual void NotifyDecodedFrames(uint32_t aParsed, uint32_t aDecoded,
uint32_t aDropped) = 0;
virtual AbstractCanonical<media::NullableTimeUnit>* CanonicalDurationOrNull() { return nullptr; };
@@ -97,39 +93,26 @@ public:
nsCOMPtr<nsIRunnable> r = NS_NewRunnableMethodWithArg<bool>(
this, &AbstractMediaDecoder::SetMediaSeekable, aMediaSeekable);
NS_DispatchToMainThread(r);
}
virtual VideoFrameContainer* GetVideoFrameContainer() = 0;
virtual mozilla::layers::ImageContainer* GetImageContainer() = 0;
- // Return true if the media layer supports seeking.
- virtual bool IsTransportSeekable() = 0;
-
- // Return true if the transport layer supports seeking.
- virtual bool IsMediaSeekable() = 0;
-
virtual void MetadataLoaded(nsAutoPtr<MediaInfo> aInfo, nsAutoPtr<MetadataTags> aTags, MediaDecoderEventVisibility aEventVisibility) = 0;
virtual void FirstFrameLoaded(nsAutoPtr<MediaInfo> aInfo, MediaDecoderEventVisibility aEventVisibility) = 0;
// Returns the owner of this media decoder. The owner should only be used
// on the main thread.
virtual MediaDecoderOwner* GetOwner() = 0;
- // Called by the reader's MediaResource as data arrives over the network.
- // Must be called on the main thread.
- virtual void NotifyDataArrived() = 0;
-
// Set by Reader if the current audio track can be offloaded
virtual void SetPlatformCanOffloadAudio(bool aCanOffloadAudio) {}
- // Called from HTMLMediaElement when owner document activity changes
- virtual void SetElementVisibility(bool aIsVisible) {}
-
// Stack based class to assist in notifying the frame statistics of
// parsed and decoded frames. Use inside video demux & decode functions
// to ensure all parsed and decoded frames are reported on all return paths.
class AutoNotifyDecoded {
public:
explicit AutoNotifyDecoded(AbstractMediaDecoder* aDecoder)
: mParsed(0), mDecoded(0), mDropped(0), mDecoder(aDecoder) {}
~AutoNotifyDecoded() {
--- a/dom/media/MediaDecoder.h
+++ b/dom/media/MediaDecoder.h
@@ -437,17 +437,17 @@ public:
virtual bool IsInfinite();
// Called by MediaResource when some data has been received.
// Call on the main thread only.
virtual void NotifyBytesDownloaded();
// Called as data arrives on the stream and is read into the cache. Called
// on the main thread only.
- virtual void NotifyDataArrived() override;
+ void NotifyDataArrived();
// Return true if we are currently seeking in the media resource.
// Call on the main thread only.
virtual bool IsSeeking() const;
// Return true if the decoder has reached the end of playback or the decoder
// has shutdown.
// Call on the main thread only.
@@ -458,27 +458,30 @@ protected:
// played, calls before the media has reached loaded metadata are ignored.
// The duration is assumed to be an estimate, and so a degree of
// instability is expected; if the incoming duration is not significantly
// different from the existing duration, the change request is ignored.
// If the incoming duration is significantly different, the duration is
// changed, this causes a durationchanged event to fire to the media
// element.
void UpdateEstimatedMediaDuration(int64_t aDuration) override;
+
public:
+ // Called from HTMLMediaElement when owner document activity changes
+ virtual void SetElementVisibility(bool aIsVisible) {}
// Set a flag indicating whether seeking is supported
virtual void SetMediaSeekable(bool aMediaSeekable) override;
// Returns true if this media supports seeking. False for example for WebM
// files without an index and chained ogg files.
- virtual bool IsMediaSeekable() final override;
+ bool IsMediaSeekable();
// Returns true if seeking is supported on a transport level (e.g. the server
// supports range requests, we are playing a file, etc.).
- virtual bool IsTransportSeekable() override;
+ bool IsTransportSeekable();
// Return the time ranges that can be seeked into.
virtual media::TimeIntervals GetSeekable();
// Set the end time of the media resource. When playback reaches
// this point the media pauses. aTime is in seconds.
virtual void SetFragmentEndTime(double aTime);
@@ -1076,17 +1079,17 @@ private:
// If MediaResource::IsSuspendedByCache returns true, then the decoder
// should stop buffering or otherwise waiting for download progress and
// start consuming data, if possible, because the cache is full.
void NotifySuspendedStatusChanged();
// Called by the MediaResource to keep track of the number of bytes read
// from the resource. Called on the main by an event runner dispatched
// by the MediaResource read functions.
- void NotifyBytesConsumed(int64_t aBytes, int64_t aOffset) final override;
+ void NotifyBytesConsumed(int64_t aBytes, int64_t aOffset);
// Called by nsChannelToPipeListener or MediaResource when the
// download has ended. Called on the main thread only. aStatus is
// the result from OnStopRequest.
void NotifyDownloadEnded(nsresult aStatus);
};
} // namespace mozilla
--- a/dom/media/webaudio/BufferDecoder.cpp
+++ b/dom/media/webaudio/BufferDecoder.cpp
@@ -35,22 +35,16 @@ BufferDecoder::BeginDecoding(TaskQueue*
MediaResource*
BufferDecoder::GetResource() const
{
return mResource;
}
void
-BufferDecoder::NotifyBytesConsumed(int64_t aBytes, int64_t aOffset)
-{
- // ignore
-}
-
-void
BufferDecoder::NotifyDecodedFrames(uint32_t aParsed, uint32_t aDecoded,
uint32_t aDropped)
{
// ignore
}
void
BufferDecoder::SetMediaSeekable(bool aMediaSeekable)
@@ -67,28 +61,16 @@ BufferDecoder::GetVideoFrameContainer()
layers::ImageContainer*
BufferDecoder::GetImageContainer()
{
// no image container
return nullptr;
}
-bool
-BufferDecoder::IsTransportSeekable()
-{
- return false;
-}
-
-bool
-BufferDecoder::IsMediaSeekable()
-{
- return false;
-}
-
void
BufferDecoder::MetadataLoaded(nsAutoPtr<MediaInfo> aInfo, nsAutoPtr<MetadataTags> aTags, MediaDecoderEventVisibility aEventVisibility)
{
// ignore
}
void
BufferDecoder::FirstFrameLoaded(nsAutoPtr<MediaInfo> aInfo, MediaDecoderEventVisibility aEventVisibility)
--- a/dom/media/webaudio/BufferDecoder.h
+++ b/dom/media/webaudio/BufferDecoder.h
@@ -28,40 +28,32 @@ public:
NS_DECL_THREADSAFE_ISUPPORTS
// This has to be called before decoding begins
void BeginDecoding(TaskQueue* aTaskQueueIdentity);
virtual MediaResource* GetResource() const final override;
- virtual void NotifyBytesConsumed(int64_t aBytes, int64_t aOffset) final override;
-
virtual void NotifyDecodedFrames(uint32_t aParsed, uint32_t aDecoded,
uint32_t aDropped) final override;
virtual void SetMediaSeekable(bool aMediaSeekable) final override;
virtual VideoFrameContainer* GetVideoFrameContainer() final override;
virtual layers::ImageContainer* GetImageContainer() final override;
- virtual bool IsTransportSeekable() final override;
-
- virtual bool IsMediaSeekable() final override;
-
virtual void MetadataLoaded(nsAutoPtr<MediaInfo> aInfo,
nsAutoPtr<MetadataTags> aTags,
MediaDecoderEventVisibility aEventVisibility) final override;
virtual void FirstFrameLoaded(nsAutoPtr<MediaInfo> aInfo,
MediaDecoderEventVisibility aEventVisibility) final override;
virtual MediaDecoderOwner* GetOwner() final override;
- virtual void NotifyDataArrived() final override {};
-
private:
virtual ~BufferDecoder();
RefPtr<TaskQueue> mTaskQueueIdentity;
RefPtr<MediaResource> mResource;
};
} // namespace mozilla