mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 812032 - Refactor the media reader classes to not access MediaDecoder directly; r=cpearce
This commit is contained in:
parent
e588f7b754
commit
f69801b25f
@ -2884,7 +2884,7 @@ void nsHTMLMediaElement::MetadataLoaded(uint32_t aChannels,
|
||||
DispatchAsyncEvent(NS_LITERAL_STRING("loadedmetadata"));
|
||||
if (mDecoder && mDecoder->IsSeekable()) {
|
||||
ProcessMediaFragmentURI();
|
||||
mDecoder->SetEndTime(mFragmentEnd);
|
||||
mDecoder->SetFragmentEndTime(mFragmentEnd);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3661,7 +3661,7 @@ void nsHTMLMediaElement::FireTimeUpdate(bool aPeriodic)
|
||||
Pause();
|
||||
mFragmentEnd = -1.0;
|
||||
mFragmentStart = -1.0;
|
||||
mDecoder->SetEndTime(mFragmentEnd);
|
||||
mDecoder->SetFragmentEndTime(mFragmentEnd);
|
||||
}
|
||||
}
|
||||
|
||||
|
103
content/media/AbstractMediaDecoder.h
Normal file
103
content/media/AbstractMediaDecoder.h
Normal file
@ -0,0 +1,103 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef AbstractMediaDecoder_h_
|
||||
#define AbstractMediaDecoder_h_
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
namespace mozilla
|
||||
{
|
||||
|
||||
namespace layers
|
||||
{
|
||||
class ImageContainer;
|
||||
}
|
||||
class MediaResource;
|
||||
class ReentrantMonitor;
|
||||
class VideoFrameContainer;
|
||||
|
||||
/**
|
||||
* The AbstractMediaDecoder class describes the public interface for a media decoder
|
||||
* and is used by the MediaReader classes.
|
||||
*/
|
||||
class AbstractMediaDecoder : public nsISupports
|
||||
{
|
||||
public:
|
||||
// Returns the monitor for other threads to synchronise access to
|
||||
// state.
|
||||
virtual ReentrantMonitor& GetReentrantMonitor() = 0;
|
||||
|
||||
// Returns true if the decoder is shut down.
|
||||
virtual bool IsShutdown() const = 0;
|
||||
|
||||
virtual bool OnStateMachineThread() const = 0;
|
||||
|
||||
virtual bool OnDecodeThread() const = 0;
|
||||
|
||||
// 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) = 0;
|
||||
|
||||
// Increments the parsed and decoded frame counters by the passed in counts.
|
||||
// Can be called on any thread.
|
||||
virtual void NotifyDecodedFrames(uint32_t aParsed, uint32_t aDecoded) = 0;
|
||||
|
||||
// Returns the end time of the last sample in the media. Note that a media
|
||||
// can have a non-zero start time, so the end time may not necessarily be
|
||||
// the same as the duration (i.e. duration is (end_time - start_time)).
|
||||
virtual int64_t GetEndMediaTime() const = 0;
|
||||
|
||||
// Return the duration of the media in microseconds.
|
||||
virtual int64_t GetMediaDuration() = 0;
|
||||
|
||||
// Set the duration of the media in microseconds.
|
||||
virtual void SetMediaDuration(int64_t aDuration) = 0;
|
||||
|
||||
virtual VideoFrameContainer* GetVideoFrameContainer() = 0;
|
||||
virtual mozilla::layers::ImageContainer* GetImageContainer() = 0;
|
||||
|
||||
// Return true if seeking is supported.
|
||||
virtual bool IsMediaSeekable() = 0;
|
||||
|
||||
// Set the media end time in microseconds
|
||||
virtual void SetMediaEndTime(int64_t aTime) = 0;
|
||||
|
||||
// Make the decoder state machine update the playback position. Called by
|
||||
// the reader on the decoder thread (Assertions for this checked by
|
||||
// mDecoderStateMachine). This must be called with the decode monitor
|
||||
// held.
|
||||
virtual void UpdatePlaybackPosition(int64_t aTime) = 0;
|
||||
|
||||
// Called when the metadata from the media file has been read by the reader.
|
||||
// Call on the decode thread only.
|
||||
virtual void OnReadMetadataCompleted() = 0;
|
||||
|
||||
// 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:
|
||||
AutoNotifyDecoded(AbstractMediaDecoder* aDecoder, uint32_t& aParsed, uint32_t& aDecoded)
|
||||
: mDecoder(aDecoder), mParsed(aParsed), mDecoded(aDecoded) {}
|
||||
~AutoNotifyDecoded() {
|
||||
mDecoder->NotifyDecodedFrames(mParsed, mDecoded);
|
||||
}
|
||||
private:
|
||||
AbstractMediaDecoder* mDecoder;
|
||||
uint32_t& mParsed;
|
||||
uint32_t& mDecoded;
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -16,7 +16,7 @@ static const nsTArray< nsCOMPtr<nsIRunnable> >::size_type MAX_PENDING_EVENTS = 1
|
||||
class nsAudioAvailableEventRunner : public nsRunnable
|
||||
{
|
||||
private:
|
||||
nsCOMPtr<MediaDecoder> mDecoder;
|
||||
nsRefPtr<MediaDecoder> mDecoder;
|
||||
nsAutoArrayPtr<float> mFrameBuffer;
|
||||
public:
|
||||
nsAudioAvailableEventRunner(MediaDecoder* aDecoder, float* aFrameBuffer,
|
||||
|
@ -15,6 +15,7 @@ LIBRARY_NAME = gkconmedia_s
|
||||
LIBXUL_LIBRARY = 1
|
||||
|
||||
EXPORTS = \
|
||||
AbstractMediaDecoder.h \
|
||||
AudioSampleFormat.h \
|
||||
AudioSegment.h \
|
||||
FileBlockCache.h \
|
||||
|
@ -279,6 +279,11 @@ double MediaDecoder::GetDuration()
|
||||
return std::numeric_limits<double>::quiet_NaN();
|
||||
}
|
||||
|
||||
int64_t MediaDecoder::GetMediaDuration()
|
||||
{
|
||||
return GetStateMachine()->GetDuration();
|
||||
}
|
||||
|
||||
void MediaDecoder::SetInfinite(bool aInfinite)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
|
||||
@ -1179,6 +1184,11 @@ void MediaDecoder::SetDuration(double aDuration)
|
||||
UpdatePlaybackRate();
|
||||
}
|
||||
|
||||
void MediaDecoder::SetMediaDuration(int64_t aDuration)
|
||||
{
|
||||
GetStateMachine()->SetDuration(aDuration);
|
||||
}
|
||||
|
||||
void MediaDecoder::SetSeekable(bool aSeekable)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
|
||||
@ -1195,6 +1205,11 @@ bool MediaDecoder::IsSeekable()
|
||||
return mSeekable;
|
||||
}
|
||||
|
||||
bool MediaDecoder::IsMediaSeekable()
|
||||
{
|
||||
return GetStateMachine()->IsSeekable();
|
||||
}
|
||||
|
||||
nsresult MediaDecoder::GetSeekable(nsTimeRanges* aSeekable)
|
||||
{
|
||||
//TODO : change 0.0 to GetInitialTime() when available
|
||||
@ -1216,7 +1231,7 @@ nsresult MediaDecoder::GetSeekable(nsTimeRanges* aSeekable)
|
||||
}
|
||||
}
|
||||
|
||||
void MediaDecoder::SetEndTime(double aTime)
|
||||
void MediaDecoder::SetFragmentEndTime(double aTime)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
|
||||
if (mDecoderStateMachine) {
|
||||
@ -1225,6 +1240,11 @@ void MediaDecoder::SetEndTime(double aTime)
|
||||
}
|
||||
}
|
||||
|
||||
void MediaDecoder::SetMediaEndTime(int64_t aTime)
|
||||
{
|
||||
GetStateMachine()->SetMediaEndTime(aTime);
|
||||
}
|
||||
|
||||
void MediaDecoder::Suspend()
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
|
||||
@ -1353,10 +1373,18 @@ void MediaDecoder::UpdatePlaybackPosition(int64_t aTime)
|
||||
}
|
||||
|
||||
// Provide access to the state machine object
|
||||
MediaDecoderStateMachine* MediaDecoder::GetStateMachine() {
|
||||
MediaDecoderStateMachine* MediaDecoder::GetStateMachine() const {
|
||||
return mDecoderStateMachine;
|
||||
}
|
||||
|
||||
bool MediaDecoder::IsShutdown() const {
|
||||
return GetStateMachine()->IsShutdown();
|
||||
}
|
||||
|
||||
int64_t MediaDecoder::GetEndMediaTime() const {
|
||||
return GetStateMachine()->GetEndMediaTime();
|
||||
}
|
||||
|
||||
// Drop reference to state machine. Only called during shutdown dance.
|
||||
void MediaDecoder::ReleaseStateMachine() {
|
||||
mDecoderStateMachine = nullptr;
|
||||
|
@ -193,6 +193,7 @@ destroying the MediaDecoder object.
|
||||
#include "MediaStreamGraph.h"
|
||||
#include "MediaDecoderOwner.h"
|
||||
#include "AudioChannelCommon.h"
|
||||
#include "AbstractMediaDecoder.h"
|
||||
|
||||
class nsIStreamListener;
|
||||
class nsTimeRanges;
|
||||
@ -227,7 +228,8 @@ static inline bool IsCurrentThread(nsIThread* aThread) {
|
||||
return NS_GetCurrentThread() == aThread;
|
||||
}
|
||||
|
||||
class MediaDecoder : public nsIObserver
|
||||
class MediaDecoder : public nsIObserver,
|
||||
public AbstractMediaDecoder
|
||||
{
|
||||
public:
|
||||
typedef mozilla::layers::Image Image;
|
||||
@ -288,7 +290,10 @@ public:
|
||||
|
||||
// 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() { return mResource; }
|
||||
MediaResource* GetResource() const MOZ_FINAL MOZ_OVERRIDE
|
||||
{
|
||||
return mResource;
|
||||
}
|
||||
|
||||
// Return the principal of the current URI being played or downloaded.
|
||||
virtual already_AddRefed<nsIPrincipal> GetCurrentPrincipal();
|
||||
@ -435,6 +440,9 @@ public:
|
||||
// Return the duration of the video in seconds.
|
||||
virtual double GetDuration();
|
||||
|
||||
// Return the duration of the video in seconds.
|
||||
int64_t GetMediaDuration() MOZ_FINAL MOZ_OVERRIDE;
|
||||
|
||||
// A media stream is assumed to be infinite if the metadata doesn't
|
||||
// contain the duration, and range requests are not supported, and
|
||||
// no headers give a hint of a possible duration (Content-Length,
|
||||
@ -473,7 +481,9 @@ public:
|
||||
|
||||
// Called by the decode thread to keep track of the number of bytes read
|
||||
// from the resource.
|
||||
void NotifyBytesConsumed(int64_t aBytes);
|
||||
void NotifyBytesConsumed(int64_t aBytes) MOZ_FINAL MOZ_OVERRIDE;
|
||||
|
||||
int64_t GetEndMediaTime() const MOZ_FINAL MOZ_OVERRIDE;
|
||||
|
||||
// Return true if we are currently seeking in the media resource.
|
||||
// Call on the main thread only.
|
||||
@ -488,18 +498,24 @@ public:
|
||||
// from a content header. Must be called from the main thread only.
|
||||
virtual void SetDuration(double aDuration);
|
||||
|
||||
void SetMediaDuration(int64_t aDuration) MOZ_FINAL MOZ_OVERRIDE;
|
||||
|
||||
// Set a flag indicating whether seeking is supported
|
||||
virtual void SetSeekable(bool aSeekable);
|
||||
|
||||
// Return true if seeking is supported.
|
||||
virtual bool IsSeekable();
|
||||
bool IsMediaSeekable() MOZ_FINAL MOZ_OVERRIDE;
|
||||
|
||||
// Return the time ranges that can be seeked into.
|
||||
virtual nsresult GetSeekable(nsTimeRanges* aSeekable);
|
||||
|
||||
// Set the end time of the media resource. When playback reaches
|
||||
// this point the media pauses. aTime is in seconds.
|
||||
virtual void SetEndTime(double aTime);
|
||||
virtual void SetFragmentEndTime(double aTime);
|
||||
|
||||
// Set the end time of the media. aTime is in microseconds.
|
||||
void SetMediaEndTime(int64_t aTime) MOZ_FINAL MOZ_OVERRIDE;
|
||||
|
||||
// Invalidate the frame.
|
||||
void Invalidate();
|
||||
@ -539,13 +555,16 @@ public:
|
||||
// has changed.
|
||||
void DurationChanged();
|
||||
|
||||
virtual bool OnStateMachineThread() const;
|
||||
bool OnStateMachineThread() const MOZ_OVERRIDE;
|
||||
|
||||
virtual bool OnDecodeThread() const;
|
||||
bool OnDecodeThread() const MOZ_OVERRIDE;
|
||||
|
||||
// Returns the monitor for other threads to synchronise access to
|
||||
// state.
|
||||
virtual ReentrantMonitor& GetReentrantMonitor();
|
||||
ReentrantMonitor& GetReentrantMonitor() MOZ_OVERRIDE;
|
||||
|
||||
// Returns true if the decoder is shut down
|
||||
bool IsShutdown() const MOZ_FINAL MOZ_OVERRIDE;
|
||||
|
||||
// Constructs the time ranges representing what segments of the media
|
||||
// are buffered and playable.
|
||||
@ -556,8 +575,11 @@ public:
|
||||
virtual int64_t VideoQueueMemoryInUse();
|
||||
virtual int64_t AudioQueueMemoryInUse();
|
||||
|
||||
VideoFrameContainer* GetVideoFrameContainer() { return mVideoFrameContainer; }
|
||||
virtual mozilla::layers::ImageContainer* GetImageContainer();
|
||||
VideoFrameContainer* GetVideoFrameContainer() MOZ_FINAL MOZ_OVERRIDE
|
||||
{
|
||||
return mVideoFrameContainer;
|
||||
}
|
||||
mozilla::layers::ImageContainer* GetImageContainer() MOZ_OVERRIDE;
|
||||
|
||||
// Sets the length of the framebuffer used in MozAudioAvailable events.
|
||||
// The new size must be between 512 and 16384.
|
||||
@ -603,7 +625,7 @@ public:
|
||||
// the reader on the decoder thread (Assertions for this checked by
|
||||
// mDecoderStateMachine). This must be called with the decode monitor
|
||||
// held.
|
||||
void UpdatePlaybackPosition(int64_t aTime);
|
||||
void UpdatePlaybackPosition(int64_t aTime) MOZ_FINAL MOZ_OVERRIDE;
|
||||
|
||||
void SetAudioChannelType(AudioChannelType aType) { mAudioChannelType = aType; }
|
||||
AudioChannelType GetAudioChannelType() { return mAudioChannelType; }
|
||||
@ -620,7 +642,7 @@ public:
|
||||
|
||||
// Called when the metadata from the media file has been read by the reader.
|
||||
// Call on the decode thread only.
|
||||
virtual void OnReadMetadataCompleted() { }
|
||||
void OnReadMetadataCompleted() MOZ_OVERRIDE { }
|
||||
|
||||
// Called when the metadata from the media file has been loaded by the
|
||||
// state machine. Call on the main thread only.
|
||||
@ -673,7 +695,7 @@ public:
|
||||
void UpdatePlaybackOffset(int64_t aOffset);
|
||||
|
||||
// Provide access to the state machine object
|
||||
MediaDecoderStateMachine* GetStateMachine();
|
||||
MediaDecoderStateMachine* GetStateMachine() const;
|
||||
|
||||
// Drop reference to state machine. Only called during shutdown dance.
|
||||
virtual void ReleaseStateMachine();
|
||||
@ -823,25 +845,16 @@ public:
|
||||
uint32_t mPresentedFrames;
|
||||
};
|
||||
|
||||
// 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:
|
||||
AutoNotifyDecoded(MediaDecoder* aDecoder, uint32_t& aParsed, uint32_t& aDecoded)
|
||||
: mDecoder(aDecoder), mParsed(aParsed), mDecoded(aDecoded) {}
|
||||
~AutoNotifyDecoded() {
|
||||
mDecoder->GetFrameStatistics().NotifyDecodedFrames(mParsed, mDecoded);
|
||||
}
|
||||
private:
|
||||
MediaDecoder* mDecoder;
|
||||
uint32_t& mParsed;
|
||||
uint32_t& mDecoded;
|
||||
};
|
||||
|
||||
// Return the frame decode/paint related statistics.
|
||||
FrameStatistics& GetFrameStatistics() { return mFrameStats; }
|
||||
|
||||
// Increments the parsed and decoded frame counters by the passed in counts.
|
||||
// Can be called on any thread.
|
||||
virtual void NotifyDecodedFrames(uint32_t aParsed, uint32_t aDecoded) MOZ_FINAL MOZ_OVERRIDE
|
||||
{
|
||||
GetFrameStatistics().NotifyDecodedFrames(aParsed, aDecoded);
|
||||
}
|
||||
|
||||
/******
|
||||
* The following members should be accessed with the decoder lock held.
|
||||
******/
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include "GonkIOSurfaceImage.h"
|
||||
#include "MediaDecoderReader.h"
|
||||
#include "MediaDecoder.h"
|
||||
#include "AbstractMediaDecoder.h"
|
||||
#include "MediaDecoderStateMachine.h"
|
||||
#include "VideoUtils.h"
|
||||
#include "ImageContainer.h"
|
||||
@ -321,7 +321,7 @@ void* MediaDecoderReader::VideoQueueMemoryFunctor::operator()(void* anObject) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MediaDecoderReader::MediaDecoderReader(MediaDecoder* aDecoder)
|
||||
MediaDecoderReader::MediaDecoderReader(AbstractMediaDecoder* aDecoder)
|
||||
: mDecoder(aDecoder)
|
||||
{
|
||||
MOZ_COUNT_CTOR(MediaDecoderReader);
|
||||
@ -349,7 +349,7 @@ VideoData* MediaDecoderReader::DecodeToFirstVideoData()
|
||||
while (!eof && mVideoQueue.GetSize() == 0) {
|
||||
{
|
||||
ReentrantMonitorAutoEnter decoderMon(mDecoder->GetReentrantMonitor());
|
||||
if (mDecoder->GetStateMachine()->IsShutdown()) {
|
||||
if (mDecoder->IsShutdown()) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
@ -366,7 +366,7 @@ AudioData* MediaDecoderReader::DecodeToFirstAudioData()
|
||||
while (!eof && mAudioQueue.GetSize() == 0) {
|
||||
{
|
||||
ReentrantMonitorAutoEnter decoderMon(mDecoder->GetReentrantMonitor());
|
||||
if (mDecoder->GetStateMachine()->IsShutdown()) {
|
||||
if (mDecoder->IsShutdown()) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
@ -421,7 +421,7 @@ nsresult MediaDecoderReader::DecodeToTarget(int64_t aTarget)
|
||||
eof = !DecodeVideoFrame(skip, 0);
|
||||
{
|
||||
ReentrantMonitorAutoEnter decoderMon(mDecoder->GetReentrantMonitor());
|
||||
if (mDecoder->GetStateMachine()->IsShutdown()) {
|
||||
if (mDecoder->IsShutdown()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
@ -448,7 +448,7 @@ nsresult MediaDecoderReader::DecodeToTarget(int64_t aTarget)
|
||||
}
|
||||
{
|
||||
ReentrantMonitorAutoEnter decoderMon(mDecoder->GetReentrantMonitor());
|
||||
if (mDecoder->GetStateMachine()->IsShutdown()) {
|
||||
if (mDecoder->IsShutdown()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
@ -463,7 +463,7 @@ nsresult MediaDecoderReader::DecodeToTarget(int64_t aTarget)
|
||||
eof = !DecodeAudioData();
|
||||
{
|
||||
ReentrantMonitorAutoEnter decoderMon(mDecoder->GetReentrantMonitor());
|
||||
if (mDecoder->GetStateMachine()->IsShutdown()) {
|
||||
if (mDecoder->IsShutdown()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class MediaDecoder;
|
||||
class AbstractMediaDecoder;
|
||||
|
||||
// Stores info relevant to presenting media frames.
|
||||
class nsVideoInfo {
|
||||
@ -355,7 +355,7 @@ private:
|
||||
// this class can only be accessed on the decode thread.
|
||||
class MediaDecoderReader {
|
||||
public:
|
||||
MediaDecoderReader(MediaDecoder* aDecoder);
|
||||
MediaDecoderReader(AbstractMediaDecoder* aDecoder);
|
||||
virtual ~MediaDecoderReader();
|
||||
|
||||
NS_INLINE_DECL_REFCOUNTING(MediaDecoderReader)
|
||||
@ -464,7 +464,7 @@ public:
|
||||
virtual MediaQueue<VideoData>& VideoQueue() { return mVideoQueue; }
|
||||
|
||||
// Returns a pointer to the decoder.
|
||||
MediaDecoder* GetDecoder() {
|
||||
AbstractMediaDecoder* GetDecoder() {
|
||||
return mDecoder;
|
||||
}
|
||||
|
||||
@ -488,7 +488,7 @@ protected:
|
||||
nsresult DecodeToTarget(int64_t aTarget);
|
||||
|
||||
// Reference to the owning decoder object.
|
||||
MediaDecoder* mDecoder;
|
||||
AbstractMediaDecoder* mDecoder;
|
||||
|
||||
// Stores presentation info required for playback.
|
||||
nsVideoInfo mInfo;
|
||||
|
@ -116,7 +116,7 @@ static int64_t DurationToUsecs(TimeDuration aDuration) {
|
||||
class nsAudioMetadataEventRunner : public nsRunnable
|
||||
{
|
||||
private:
|
||||
nsCOMPtr<MediaDecoder> mDecoder;
|
||||
nsRefPtr<MediaDecoder> mDecoder;
|
||||
public:
|
||||
nsAudioMetadataEventRunner(MediaDecoder* aDecoder, uint32_t aChannels,
|
||||
uint32_t aRate, bool aHasAudio,
|
||||
@ -1382,7 +1382,7 @@ void MediaDecoderStateMachine::SetDuration(int64_t aDuration)
|
||||
}
|
||||
}
|
||||
|
||||
void MediaDecoderStateMachine::SetEndTime(int64_t aEndTime)
|
||||
void MediaDecoderStateMachine::SetMediaEndTime(int64_t aEndTime)
|
||||
{
|
||||
NS_ASSERTION(OnDecodeThread(), "Should be on decode thread");
|
||||
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
|
||||
|
@ -147,7 +147,7 @@ public:
|
||||
// Called while decoding metadata to set the end time of the media
|
||||
// resource. The decoder monitor must be obtained before calling this.
|
||||
// aEndTime is in microseconds.
|
||||
void SetEndTime(int64_t aEndTime);
|
||||
void SetMediaEndTime(int64_t aEndTime);
|
||||
|
||||
// Functions used by assertions to ensure we're calling things
|
||||
// on the appropriate threads.
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
#include "nsTimeRanges.h"
|
||||
#include "VideoFrameContainer.h"
|
||||
#include "MediaDecoder.h"
|
||||
#include "AbstractMediaDecoder.h"
|
||||
#include "DASHReader.h"
|
||||
|
||||
namespace mozilla {
|
||||
@ -181,7 +181,7 @@ DASHReader::GetBuffered(nsTimeRanges* aBuffered,
|
||||
NS_ENSURE_ARG(aBuffered);
|
||||
|
||||
MediaResource* resource = nullptr;
|
||||
MediaDecoder* decoder = nullptr;
|
||||
AbstractMediaDecoder* decoder = nullptr;
|
||||
|
||||
// Need to find intersect of |nsTimeRanges| for audio and video.
|
||||
nsTimeRanges audioBuffered, videoBuffered;
|
||||
|
@ -23,7 +23,7 @@ namespace mozilla {
|
||||
class DASHReader : public MediaDecoderReader
|
||||
{
|
||||
public:
|
||||
DASHReader(MediaDecoder* aDecoder) :
|
||||
DASHReader(AbstractMediaDecoder* aDecoder) :
|
||||
MediaDecoderReader(aDecoder),
|
||||
mReadMetadataMonitor("media.dashreader.readmetadata"),
|
||||
mReadyToReadMetadata(false),
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include "nsError.h"
|
||||
#include "MediaDecoderStateMachine.h"
|
||||
#include "MediaDecoder.h"
|
||||
#include "AbstractMediaDecoder.h"
|
||||
#include "MediaResource.h"
|
||||
#include "GStreamerReader.h"
|
||||
#include "VideoUtils.h"
|
||||
@ -47,7 +47,7 @@ typedef enum {
|
||||
GST_PLAY_FLAG_SOFT_COLORBALANCE = (1 << 10)
|
||||
} PlayFlags;
|
||||
|
||||
GStreamerReader::GStreamerReader(MediaDecoder* aDecoder)
|
||||
GStreamerReader::GStreamerReader(AbstractMediaDecoder* aDecoder)
|
||||
: MediaDecoderReader(aDecoder),
|
||||
mPlayBin(NULL),
|
||||
mBus(NULL),
|
||||
@ -296,7 +296,7 @@ nsresult GStreamerReader::ReadMetadata(nsVideoInfo* aInfo,
|
||||
LOG(PR_LOG_DEBUG, ("returning duration %" GST_TIME_FORMAT,
|
||||
GST_TIME_ARGS (duration)));
|
||||
duration = GST_TIME_AS_USECONDS (duration);
|
||||
mDecoder->GetStateMachine()->SetDuration(duration);
|
||||
mDecoder->SetMediaDuration(duration);
|
||||
}
|
||||
|
||||
int n_video = 0, n_audio = 0;
|
||||
@ -391,12 +391,6 @@ bool GStreamerReader::DecodeAudioData()
|
||||
mAudioQueue.Push(audio);
|
||||
gst_buffer_unref(buffer);
|
||||
|
||||
if (mAudioQueue.GetSize() < 2) {
|
||||
nsCOMPtr<nsIRunnable> event =
|
||||
NS_NewRunnableMethod(mDecoder, &MediaDecoder::NextFrameAvailable);
|
||||
NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -413,7 +407,7 @@ bool GStreamerReader::DecodeVideoFrame(bool &aKeyFrameSkip,
|
||||
mVideoQueue.Finish();
|
||||
break;
|
||||
}
|
||||
mDecoder->GetFrameStatistics().NotifyDecodedFrames(0, 1);
|
||||
mDecoder->NotifyDecodedFrames(0, 1);
|
||||
|
||||
buffer = gst_app_sink_pull_buffer(mVideoAppSink);
|
||||
bool isKeyframe = !GST_BUFFER_FLAG_IS_SET(buffer, GST_BUFFER_FLAG_DISCONT);
|
||||
@ -489,12 +483,6 @@ bool GStreamerReader::DecodeVideoFrame(bool &aKeyFrameSkip,
|
||||
mVideoQueue.Push(video);
|
||||
gst_buffer_unref(buffer);
|
||||
|
||||
if (mVideoQueue.GetSize() < 2) {
|
||||
nsCOMPtr<nsIRunnable> event =
|
||||
NS_NewRunnableMethod(mDecoder, &MediaDecoder::NextFrameAvailable);
|
||||
NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -797,7 +785,7 @@ void GStreamerReader::NewVideoBuffer()
|
||||
/* We have a new video buffer queued in the video sink. Increment the counter
|
||||
* and notify the decode thread potentially blocked in DecodeVideoFrame
|
||||
*/
|
||||
mDecoder->GetFrameStatistics().NotifyDecodedFrames(1, 0);
|
||||
mDecoder->NotifyDecodedFrames(1, 0);
|
||||
mVideoSinkBufferCount++;
|
||||
mon.NotifyAll();
|
||||
}
|
||||
|
@ -15,12 +15,12 @@ class nsTimeRanges;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class MediaDecoder;
|
||||
class AbstractMediaDecoder;
|
||||
|
||||
class GStreamerReader : public MediaDecoderReader
|
||||
{
|
||||
public:
|
||||
GStreamerReader(MediaDecoder* aDecoder);
|
||||
GStreamerReader(AbstractMediaDecoder* aDecoder);
|
||||
virtual ~GStreamerReader();
|
||||
|
||||
virtual nsresult Init(MediaDecoderReader* aCloneDonor);
|
||||
|
@ -75,7 +75,7 @@ PageSync(MediaResource* aResource,
|
||||
// is about 4300 bytes, so we read the file in chunks larger than that.
|
||||
static const int PAGE_STEP = 8192;
|
||||
|
||||
OggReader::OggReader(MediaDecoder* aDecoder)
|
||||
OggReader::OggReader(AbstractMediaDecoder* aDecoder)
|
||||
: MediaDecoderReader(aDecoder),
|
||||
mTheoraState(nullptr),
|
||||
mVorbisState(nullptr),
|
||||
@ -325,7 +325,7 @@ nsresult OggReader::ReadMetadata(nsVideoInfo* aInfo,
|
||||
int64_t duration = 0;
|
||||
if (NS_SUCCEEDED(mSkeletonState->GetDuration(tracks, duration))) {
|
||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||
mDecoder->GetStateMachine()->SetDuration(duration);
|
||||
mDecoder->SetMediaDuration(duration);
|
||||
LOG(PR_LOG_DEBUG, ("Got duration from Skeleton index %lld", duration));
|
||||
}
|
||||
}
|
||||
@ -335,10 +335,10 @@ nsresult OggReader::ReadMetadata(nsVideoInfo* aInfo,
|
||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||
|
||||
MediaResource* resource = mDecoder->GetResource();
|
||||
if (mDecoder->GetStateMachine()->GetDuration() == -1 &&
|
||||
!mDecoder->GetStateMachine()->IsShutdown() &&
|
||||
if (mDecoder->GetMediaDuration() == -1 &&
|
||||
!mDecoder->IsShutdown() &&
|
||||
resource->GetLength() >= 0 &&
|
||||
mDecoder->GetStateMachine()->IsSeekable())
|
||||
mDecoder->IsMediaSeekable())
|
||||
{
|
||||
// We didn't get a duration from the index or a Content-Duration header.
|
||||
// Seek to the end of file to find the end time.
|
||||
@ -353,7 +353,7 @@ nsresult OggReader::ReadMetadata(nsVideoInfo* aInfo,
|
||||
endTime = RangeEndTime(length);
|
||||
}
|
||||
if (endTime != -1) {
|
||||
mDecoder->GetStateMachine()->SetEndTime(endTime);
|
||||
mDecoder->SetMediaEndTime(endTime);
|
||||
LOG(PR_LOG_DEBUG, ("Got Ogg duration from seeking to end %lld", endTime));
|
||||
}
|
||||
mDecoder->GetResource()->EndSeekingForMetadata();
|
||||
@ -669,7 +669,7 @@ bool OggReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
||||
// Record number of frames decoded and parsed. Automatically update the
|
||||
// stats counters using the AutoNotifyDecoded stack-based class.
|
||||
uint32_t parsed = 0, decoded = 0;
|
||||
MediaDecoder::AutoNotifyDecoded autoNotify(mDecoder, parsed, decoded);
|
||||
AbstractMediaDecoder::AutoNotifyDecoded autoNotify(mDecoder, parsed, decoded);
|
||||
|
||||
// Read the next data packet. Skip any non-data packets we encounter.
|
||||
ogg_packet* packet = 0;
|
||||
@ -1136,7 +1136,7 @@ nsresult OggReader::SeekInBufferedRange(int64_t aTarget,
|
||||
eof = !DecodeVideoFrame(skip, 0);
|
||||
{
|
||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||
if (mDecoder->GetStateMachine()->IsShutdown()) {
|
||||
if (mDecoder->IsShutdown()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
@ -1608,7 +1608,7 @@ nsresult OggReader::GetBuffered(nsTimeRanges* aBuffered, int64_t aStartTime)
|
||||
int64_t durationUs = 0;
|
||||
{
|
||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||
durationUs = mDecoder->GetStateMachine()->GetDuration();
|
||||
durationUs = mDecoder->GetMediaDuration();
|
||||
}
|
||||
GetEstimatedBufferedTimeRanges(stream, durationUs, aBuffered);
|
||||
|
||||
|
@ -21,12 +21,10 @@ class nsTimeRanges;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class MediaDecoder;
|
||||
|
||||
class OggReader : public MediaDecoderReader
|
||||
{
|
||||
public:
|
||||
OggReader(MediaDecoder* aDecoder);
|
||||
OggReader(AbstractMediaDecoder* aDecoder);
|
||||
~OggReader();
|
||||
|
||||
virtual nsresult Init(MediaDecoderReader* aCloneDonor);
|
||||
|
@ -12,12 +12,13 @@
|
||||
#include "MediaResource.h"
|
||||
#include "VideoUtils.h"
|
||||
#include "MediaOmxDecoder.h"
|
||||
#include "AbstractMediaDecoder.h"
|
||||
|
||||
using namespace android;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
MediaOmxReader::MediaOmxReader(MediaDecoder *aDecoder) :
|
||||
MediaOmxReader::MediaOmxReader(AbstractMediaDecoder *aDecoder) :
|
||||
MediaDecoderReader(aDecoder),
|
||||
mOmxDecoder(nullptr),
|
||||
mHasVideo(false),
|
||||
@ -55,7 +56,7 @@ nsresult MediaOmxReader::ReadMetadata(nsVideoInfo* aInfo,
|
||||
mOmxDecoder->GetDuration(&durationUs);
|
||||
if (durationUs) {
|
||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||
mDecoder->GetStateMachine()->SetDuration(durationUs);
|
||||
mDecoder->SetMediaDuration(durationUs);
|
||||
}
|
||||
|
||||
if (mOmxDecoder->HasVideo()) {
|
||||
@ -124,7 +125,7 @@ bool MediaOmxReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
||||
// Record number of frames decoded and parsed. Automatically update the
|
||||
// stats counters using the AutoNotifyDecoded stack-based class.
|
||||
uint32_t parsed = 0, decoded = 0;
|
||||
MediaDecoder::AutoNotifyDecoded autoNotify(mDecoder, parsed, decoded);
|
||||
AbstractMediaDecoder::AutoNotifyDecoded autoNotify(mDecoder, parsed, decoded);
|
||||
|
||||
// Throw away the currently buffered frame if we are seeking.
|
||||
if (mLastVideoFrame && mVideoSeekTimeUs != -1) {
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
#include "base/basictypes.h"
|
||||
#include "MediaResource.h"
|
||||
#include "MediaDecoder.h"
|
||||
#include "MediaDecoderReader.h"
|
||||
#include "OmxDecoder.h"
|
||||
|
||||
@ -16,6 +15,8 @@
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class AbstractMediaDecoder;
|
||||
|
||||
class MediaOmxReader : public MediaDecoderReader
|
||||
{
|
||||
nsCString mType;
|
||||
@ -28,7 +29,7 @@ class MediaOmxReader : public MediaDecoderReader
|
||||
int64_t mAudioSeekTimeUs;
|
||||
VideoData *mLastVideoFrame;
|
||||
public:
|
||||
MediaOmxReader(MediaDecoder* aDecoder);
|
||||
MediaOmxReader(AbstractMediaDecoder* aDecoder);
|
||||
~MediaOmxReader();
|
||||
|
||||
virtual nsresult Init(MediaDecoderReader* aCloneDonor);
|
||||
|
@ -64,7 +64,7 @@ VideoGraphicBuffer::Unlock()
|
||||
namespace android {
|
||||
|
||||
MediaStreamSource::MediaStreamSource(MediaResource *aResource,
|
||||
MediaDecoder *aDecoder) :
|
||||
AbstractMediaDecoder *aDecoder) :
|
||||
mDecoder(aDecoder), mResource(aResource)
|
||||
{
|
||||
}
|
||||
@ -112,7 +112,7 @@ status_t MediaStreamSource::getSize(off64_t *size)
|
||||
using namespace android;
|
||||
|
||||
OmxDecoder::OmxDecoder(MediaResource *aResource,
|
||||
MediaDecoder *aDecoder) :
|
||||
AbstractMediaDecoder *aDecoder) :
|
||||
mResource(aResource),
|
||||
mDecoder(aDecoder),
|
||||
mVideoWidth(0),
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "GonkIOSurfaceImage.h"
|
||||
#include "MPAPI.h"
|
||||
#include "MediaResource.h"
|
||||
#include "MediaDecoder.h"
|
||||
#include "AbstractMediaDecoder.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
@ -31,13 +31,13 @@ namespace android {
|
||||
// MediaStreamSource is a DataSource that reads from a MPAPI media stream.
|
||||
class MediaStreamSource : public DataSource {
|
||||
typedef mozilla::MediaResource MediaResource;
|
||||
typedef mozilla::MediaDecoder MediaDecoder;
|
||||
typedef mozilla::AbstractMediaDecoder AbstractMediaDecoder;
|
||||
|
||||
MediaResource *mResource;
|
||||
MediaDecoder *mDecoder;
|
||||
AbstractMediaDecoder *mDecoder;
|
||||
public:
|
||||
MediaStreamSource(MediaResource *aResource,
|
||||
MediaDecoder *aDecoder);
|
||||
AbstractMediaDecoder *aDecoder);
|
||||
|
||||
virtual status_t initCheck() const;
|
||||
virtual ssize_t readAt(off64_t offset, void *data, size_t size);
|
||||
@ -66,13 +66,13 @@ class OmxDecoder {
|
||||
typedef MPAPI::AudioFrame AudioFrame;
|
||||
typedef MPAPI::VideoFrame VideoFrame;
|
||||
typedef mozilla::MediaResource MediaResource;
|
||||
typedef mozilla::MediaDecoder MediaDecoder;
|
||||
typedef mozilla::AbstractMediaDecoder AbstractMediaDecoder;
|
||||
|
||||
enum {
|
||||
kPreferSoftwareCodecs = 1
|
||||
};
|
||||
|
||||
MediaDecoder *mDecoder;
|
||||
AbstractMediaDecoder *mDecoder;
|
||||
MediaResource *mResource;
|
||||
sp<GonkNativeWindow> mNativeWindow;
|
||||
sp<MediaSource> mVideoTrack;
|
||||
@ -110,7 +110,7 @@ class OmxDecoder {
|
||||
bool ToAudioFrame(AudioFrame *aFrame, int64_t aTimeUs, void *aData, size_t aDataOffset, size_t aSize,
|
||||
int32_t aAudioChannels, int32_t aAudioSampleRate);
|
||||
public:
|
||||
OmxDecoder(MediaResource *aResource, MediaDecoder *aDecoder);
|
||||
OmxDecoder(MediaResource *aResource, AbstractMediaDecoder *aDecoder);
|
||||
~OmxDecoder();
|
||||
|
||||
bool Init();
|
||||
|
@ -11,10 +11,11 @@
|
||||
#include "MediaPluginDecoder.h"
|
||||
#include "MediaPluginHost.h"
|
||||
#include "MediaDecoderStateMachine.h"
|
||||
#include "AbstractMediaDecoder.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
MediaPluginReader::MediaPluginReader(MediaDecoder *aDecoder) :
|
||||
MediaPluginReader::MediaPluginReader(AbstractMediaDecoder *aDecoder) :
|
||||
MediaDecoderReader(aDecoder),
|
||||
mPlugin(NULL),
|
||||
mHasAudio(false),
|
||||
@ -53,7 +54,7 @@ nsresult MediaPluginReader::ReadMetadata(nsVideoInfo* aInfo,
|
||||
mPlugin->GetDuration(mPlugin, &durationUs);
|
||||
if (durationUs) {
|
||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||
mDecoder->GetStateMachine()->SetDuration(durationUs);
|
||||
mDecoder->SetMediaDuration(durationUs);
|
||||
}
|
||||
|
||||
if (mPlugin->HasVideo(mPlugin)) {
|
||||
@ -116,7 +117,7 @@ bool MediaPluginReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
||||
// Record number of frames decoded and parsed. Automatically update the
|
||||
// stats counters using the AutoNotifyDecoded stack-based class.
|
||||
uint32_t parsed = 0, decoded = 0;
|
||||
MediaDecoder::AutoNotifyDecoded autoNotify(mDecoder, parsed, decoded);
|
||||
AbstractMediaDecoder::AutoNotifyDecoded autoNotify(mDecoder, parsed, decoded);
|
||||
|
||||
// Throw away the currently buffered frame if we are seeking.
|
||||
if (mLastVideoFrame && mVideoSeekTimeUs != -1) {
|
||||
|
@ -7,13 +7,14 @@
|
||||
#define MediaPluginReader_h_
|
||||
|
||||
#include "MediaResource.h"
|
||||
#include "MediaDecoder.h"
|
||||
#include "MediaDecoderReader.h"
|
||||
|
||||
#include "MPAPI.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class AbstractMediaDecoder;
|
||||
|
||||
class MediaPluginReader : public MediaDecoderReader
|
||||
{
|
||||
nsCString mType;
|
||||
@ -26,7 +27,7 @@ class MediaPluginReader : public MediaDecoderReader
|
||||
int64_t mAudioSeekTimeUs;
|
||||
VideoData *mLastVideoFrame;
|
||||
public:
|
||||
MediaPluginReader(MediaDecoder* aDecoder);
|
||||
MediaPluginReader(AbstractMediaDecoder* aDecoder);
|
||||
~MediaPluginReader();
|
||||
|
||||
virtual nsresult Init(MediaDecoderReader* aCloneDonor);
|
||||
|
@ -4,14 +4,14 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "MediaDecoderStateMachine.h"
|
||||
#include "MediaDecoder.h"
|
||||
#include "AbstractMediaDecoder.h"
|
||||
#include "RawReader.h"
|
||||
#include "RawDecoder.h"
|
||||
#include "VideoUtils.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
RawReader::RawReader(MediaDecoder* aDecoder)
|
||||
RawReader::RawReader(AbstractMediaDecoder* aDecoder)
|
||||
: MediaDecoderReader(aDecoder),
|
||||
mCurrentFrame(0), mFrameSize(0)
|
||||
{
|
||||
@ -99,9 +99,9 @@ nsresult RawReader::ReadMetadata(nsVideoInfo* aInfo,
|
||||
int64_t length = resource->GetLength();
|
||||
if (length != -1) {
|
||||
ReentrantMonitorAutoEnter autoMonitor(mDecoder->GetReentrantMonitor());
|
||||
mDecoder->GetStateMachine()->SetDuration(USECS_PER_S *
|
||||
(length - sizeof(RawVideoHeader)) /
|
||||
(mFrameSize * mFrameRate));
|
||||
mDecoder->SetMediaDuration(USECS_PER_S *
|
||||
(length - sizeof(RawVideoHeader)) /
|
||||
(mFrameSize * mFrameRate));
|
||||
}
|
||||
|
||||
*aInfo = mInfo;
|
||||
@ -150,7 +150,7 @@ bool RawReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
||||
// Record number of frames decoded and parsed. Automatically update the
|
||||
// stats counters using the AutoNotifyDecoded stack-based class.
|
||||
uint32_t parsed = 0, decoded = 0;
|
||||
MediaDecoder::AutoNotifyDecoded autoNotify(mDecoder, parsed, decoded);
|
||||
AbstractMediaDecoder::AutoNotifyDecoded autoNotify(mDecoder, parsed, decoded);
|
||||
|
||||
if (!mFrameSize)
|
||||
return false; // Metadata read failed. We should refuse to play.
|
||||
@ -258,7 +258,7 @@ nsresult RawReader::Seek(int64_t aTime, int64_t aStartTime, int64_t aEndTime, in
|
||||
|
||||
{
|
||||
ReentrantMonitorAutoEnter autoMonitor(mDecoder->GetReentrantMonitor());
|
||||
if (mDecoder->GetStateMachine()->IsShutdown()) {
|
||||
if (mDecoder->IsShutdown()) {
|
||||
mCurrentFrame = frame;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ namespace mozilla {
|
||||
class RawReader : public MediaDecoderReader
|
||||
{
|
||||
public:
|
||||
RawReader(MediaDecoder* aDecoder);
|
||||
RawReader(AbstractMediaDecoder* aDecoder);
|
||||
~RawReader();
|
||||
|
||||
virtual nsresult Init(MediaDecoderReader* aCloneDonor);
|
||||
|
@ -4,7 +4,7 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
#include "nsError.h"
|
||||
#include "MediaDecoder.h"
|
||||
#include "AbstractMediaDecoder.h"
|
||||
#include "MediaResource.h"
|
||||
#include "WaveReader.h"
|
||||
#include "nsTimeRanges.h"
|
||||
@ -104,7 +104,7 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
WaveReader::WaveReader(MediaDecoder* aDecoder)
|
||||
WaveReader::WaveReader(AbstractMediaDecoder* aDecoder)
|
||||
: MediaDecoderReader(aDecoder)
|
||||
{
|
||||
MOZ_COUNT_CTOR(WaveReader);
|
||||
@ -141,7 +141,7 @@ nsresult WaveReader::ReadMetadata(nsVideoInfo* aInfo,
|
||||
|
||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||
|
||||
mDecoder->GetStateMachine()->SetDuration(
|
||||
mDecoder->SetMediaDuration(
|
||||
static_cast<int64_t>(BytesToTime(GetDataLength()) * USECS_PER_S));
|
||||
|
||||
return NS_OK;
|
||||
|
@ -12,12 +12,10 @@ class nsTimeRanges;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class MediaDecoder;
|
||||
|
||||
class WaveReader : public MediaDecoderReader
|
||||
{
|
||||
public:
|
||||
WaveReader(MediaDecoder* aDecoder);
|
||||
WaveReader(AbstractMediaDecoder* aDecoder);
|
||||
~WaveReader();
|
||||
|
||||
virtual nsresult Init(MediaDecoderReader* aCloneDonor);
|
||||
|
@ -5,7 +5,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
#include "nsError.h"
|
||||
#include "MediaDecoderStateMachine.h"
|
||||
#include "MediaDecoder.h"
|
||||
#include "AbstractMediaDecoder.h"
|
||||
#include "MediaResource.h"
|
||||
#include "WebMReader.h"
|
||||
#include "WebMBufferedParser.h"
|
||||
@ -59,8 +59,8 @@ static const int SEEK_DECODE_MARGIN = 250000;
|
||||
// decoder from which the media resource is obtained.
|
||||
static int webm_read(void *aBuffer, size_t aLength, void *aUserData)
|
||||
{
|
||||
NS_ASSERTION(aUserData, "aUserData must point to a valid MediaDecoder");
|
||||
MediaDecoder* decoder = reinterpret_cast<MediaDecoder*>(aUserData);
|
||||
NS_ASSERTION(aUserData, "aUserData must point to a valid AbstractMediaDecoder");
|
||||
AbstractMediaDecoder* decoder = reinterpret_cast<AbstractMediaDecoder*>(aUserData);
|
||||
MediaResource* resource = decoder->GetResource();
|
||||
NS_ASSERTION(resource, "Decoder has no media resource");
|
||||
|
||||
@ -85,8 +85,8 @@ static int webm_read(void *aBuffer, size_t aLength, void *aUserData)
|
||||
|
||||
static int webm_seek(int64_t aOffset, int aWhence, void *aUserData)
|
||||
{
|
||||
NS_ASSERTION(aUserData, "aUserData must point to a valid MediaDecoder");
|
||||
MediaDecoder* decoder = reinterpret_cast<MediaDecoder*>(aUserData);
|
||||
NS_ASSERTION(aUserData, "aUserData must point to a valid AbstractMediaDecoder");
|
||||
AbstractMediaDecoder* decoder = reinterpret_cast<AbstractMediaDecoder*>(aUserData);
|
||||
MediaResource* resource = decoder->GetResource();
|
||||
NS_ASSERTION(resource, "Decoder has no media resource");
|
||||
nsresult rv = resource->Seek(aWhence, aOffset);
|
||||
@ -95,14 +95,14 @@ static int webm_seek(int64_t aOffset, int aWhence, void *aUserData)
|
||||
|
||||
static int64_t webm_tell(void *aUserData)
|
||||
{
|
||||
NS_ASSERTION(aUserData, "aUserData must point to a valid MediaDecoder");
|
||||
MediaDecoder* decoder = reinterpret_cast<MediaDecoder*>(aUserData);
|
||||
NS_ASSERTION(aUserData, "aUserData must point to a valid AbstractMediaDecoder");
|
||||
AbstractMediaDecoder* decoder = reinterpret_cast<AbstractMediaDecoder*>(aUserData);
|
||||
MediaResource* resource = decoder->GetResource();
|
||||
NS_ASSERTION(resource, "Decoder has no media resource");
|
||||
return resource->Tell();
|
||||
}
|
||||
|
||||
WebMReader::WebMReader(MediaDecoder* aDecoder)
|
||||
WebMReader::WebMReader(AbstractMediaDecoder* aDecoder)
|
||||
: MediaDecoderReader(aDecoder),
|
||||
mContext(nullptr),
|
||||
mPacketCount(0),
|
||||
@ -196,7 +196,7 @@ nsresult WebMReader::ReadMetadata(nsVideoInfo* aInfo,
|
||||
io.read = webm_read;
|
||||
io.seek = webm_seek;
|
||||
io.tell = webm_tell;
|
||||
io.userdata = static_cast<MediaDecoder*>(mDecoder);
|
||||
io.userdata = mDecoder;
|
||||
int64_t maxOffset = mInitByteRange.IsNull() ? -1 : mInitByteRange.mEnd;
|
||||
int r = nestegg_init(&mContext, io, nullptr, maxOffset);
|
||||
if (r == -1) {
|
||||
@ -207,7 +207,7 @@ nsresult WebMReader::ReadMetadata(nsVideoInfo* aInfo,
|
||||
r = nestegg_duration(mContext, &duration);
|
||||
if (r == 0) {
|
||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||
mDecoder->GetStateMachine()->SetDuration(duration / NS_PER_USEC);
|
||||
mDecoder->SetMediaDuration(duration / NS_PER_USEC);
|
||||
}
|
||||
|
||||
unsigned int ntracks = 0;
|
||||
@ -606,7 +606,7 @@ bool WebMReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
||||
// Record number of frames decoded and parsed. Automatically update the
|
||||
// stats counters using the AutoNotifyDecoded stack-based class.
|
||||
uint32_t parsed = 0, decoded = 0;
|
||||
MediaDecoder::AutoNotifyDecoded autoNotify(mDecoder, parsed, decoded);
|
||||
AbstractMediaDecoder::AutoNotifyDecoded autoNotify(mDecoder, parsed, decoded);
|
||||
|
||||
nsAutoRef<NesteggPacketHolder> holder(NextPacket(VIDEO));
|
||||
if (!holder) {
|
||||
@ -648,9 +648,7 @@ bool WebMReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
||||
mVideoPackets.PushFront(next_holder.disown());
|
||||
} else {
|
||||
ReentrantMonitorAutoEnter decoderMon(mDecoder->GetReentrantMonitor());
|
||||
MediaDecoderStateMachine* s =
|
||||
static_cast<MediaDecoderStateMachine*>(mDecoder->GetStateMachine());
|
||||
int64_t endTime = s->GetEndMediaTime();
|
||||
int64_t endTime = mDecoder->GetEndMediaTime();
|
||||
if (endTime == -1) {
|
||||
return false;
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ class PacketQueue : private nsDeque {
|
||||
class WebMReader : public MediaDecoderReader
|
||||
{
|
||||
public:
|
||||
WebMReader(MediaDecoder* aDecoder);
|
||||
WebMReader(AbstractMediaDecoder* aDecoder);
|
||||
~WebMReader();
|
||||
|
||||
virtual nsresult Init(MediaDecoderReader* aCloneDonor);
|
||||
|
Loading…
Reference in New Issue
Block a user