зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1217692. Part 2 - fix some styles to keep 80 cols limit. r=jya.
This commit is contained in:
Родитель
82503359f9
Коммит
ab48413bfa
|
@ -62,6 +62,8 @@ class MediaDecoderReader {
|
||||||
friend class ReRequestVideoWithSkipTask;
|
friend class ReRequestVideoWithSkipTask;
|
||||||
friend class ReRequestAudioTask;
|
friend class ReRequestAudioTask;
|
||||||
|
|
||||||
|
static const bool IsExclusive = true;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum NotDecodedReason {
|
enum NotDecodedReason {
|
||||||
END_OF_STREAM,
|
END_OF_STREAM,
|
||||||
|
@ -70,16 +72,20 @@ public:
|
||||||
CANCELED
|
CANCELED
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef MozPromise<RefPtr<MetadataHolder>, ReadMetadataFailureReason, /* IsExclusive = */ true> MetadataPromise;
|
using MetadataPromise =
|
||||||
typedef MozPromise<RefPtr<MediaData>, NotDecodedReason, /* IsExclusive = */ true> AudioDataPromise;
|
MozPromise<RefPtr<MetadataHolder>, ReadMetadataFailureReason, IsExclusive>;
|
||||||
typedef MozPromise<RefPtr<MediaData>, NotDecodedReason, /* IsExclusive = */ true> VideoDataPromise;
|
using AudioDataPromise =
|
||||||
typedef MozPromise<int64_t, nsresult, /* IsExclusive = */ true> SeekPromise;
|
MozPromise<RefPtr<MediaData>, NotDecodedReason, IsExclusive>;
|
||||||
|
using VideoDataPromise =
|
||||||
|
MozPromise<RefPtr<MediaData>, NotDecodedReason, IsExclusive>;
|
||||||
|
using SeekPromise = MozPromise<int64_t, nsresult, IsExclusive>;
|
||||||
|
|
||||||
// Note that, conceptually, WaitForData makes sense in a non-exclusive sense.
|
// Note that, conceptually, WaitForData makes sense in a non-exclusive sense.
|
||||||
// But in the current architecture it's only ever used exclusively (by MDSM),
|
// But in the current architecture it's only ever used exclusively (by MDSM),
|
||||||
// so we mark it that way to verify our assumptions. If you have a use-case
|
// so we mark it that way to verify our assumptions. If you have a use-case
|
||||||
// for multiple WaitForData consumers, feel free to flip the exclusivity here.
|
// for multiple WaitForData consumers, feel free to flip the exclusivity here.
|
||||||
typedef MozPromise<MediaData::Type, WaitForDataRejectValue, /* IsExclusive = */ true> WaitForDataPromise;
|
using WaitForDataPromise =
|
||||||
|
MozPromise<MediaData::Type, WaitForDataRejectValue, IsExclusive>;
|
||||||
|
|
||||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaDecoderReader)
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaDecoderReader)
|
||||||
|
|
||||||
|
@ -93,7 +99,7 @@ public:
|
||||||
|
|
||||||
// Release media resources they should be released in dormant state
|
// Release media resources they should be released in dormant state
|
||||||
// The reader can be made usable again by calling ReadMetadata().
|
// The reader can be made usable again by calling ReadMetadata().
|
||||||
virtual void ReleaseMediaResources() {};
|
virtual void ReleaseMediaResources() {}
|
||||||
// Breaks reference-counted cycles. Called during shutdown.
|
// Breaks reference-counted cycles. Called during shutdown.
|
||||||
// WARNING: If you override this, you must call the base implementation
|
// WARNING: If you override this, you must call the base implementation
|
||||||
// in your override.
|
// in your override.
|
||||||
|
@ -145,7 +151,11 @@ public:
|
||||||
// in buffering mode. Some readers support a promise-based mechanism by which
|
// in buffering mode. Some readers support a promise-based mechanism by which
|
||||||
// they notify the state machine when the data arrives.
|
// they notify the state machine when the data arrives.
|
||||||
virtual bool IsWaitForDataSupported() { return false; }
|
virtual bool IsWaitForDataSupported() { return false; }
|
||||||
virtual RefPtr<WaitForDataPromise> WaitForData(MediaData::Type aType) { MOZ_CRASH(); }
|
|
||||||
|
virtual RefPtr<WaitForDataPromise> WaitForData(MediaData::Type aType)
|
||||||
|
{
|
||||||
|
MOZ_CRASH();
|
||||||
|
}
|
||||||
|
|
||||||
// By default, the reader return the decoded data. Some readers support
|
// By default, the reader return the decoded data. Some readers support
|
||||||
// retuning demuxed data.
|
// retuning demuxed data.
|
||||||
|
@ -165,13 +175,12 @@ public:
|
||||||
|
|
||||||
// Fills aInfo with the latest cached data required to present the media,
|
// Fills aInfo with the latest cached data required to present the media,
|
||||||
// ReadUpdatedMetadata will always be called once ReadMetadata has succeeded.
|
// ReadUpdatedMetadata will always be called once ReadMetadata has succeeded.
|
||||||
virtual void ReadUpdatedMetadata(MediaInfo* aInfo) { };
|
virtual void ReadUpdatedMetadata(MediaInfo* aInfo) {}
|
||||||
|
|
||||||
// Moves the decode head to aTime microseconds. aEndTime denotes the end
|
// Moves the decode head to aTime microseconds. aEndTime denotes the end
|
||||||
// time of the media in usecs. This is only needed for OggReader, and should
|
// time of the media in usecs. This is only needed for OggReader, and should
|
||||||
// probably be removed somehow.
|
// probably be removed somehow.
|
||||||
virtual RefPtr<SeekPromise>
|
virtual RefPtr<SeekPromise> Seek(int64_t aTime, int64_t aEndTime) = 0;
|
||||||
Seek(int64_t aTime, int64_t aEndTime) = 0;
|
|
||||||
|
|
||||||
// Called to move the reader into idle state. When the reader is
|
// Called to move the reader into idle state. When the reader is
|
||||||
// created it is assumed to be active (i.e. not idle). When the media
|
// created it is assumed to be active (i.e. not idle). When the media
|
||||||
|
@ -183,7 +192,7 @@ public:
|
||||||
// Note: DecodeVideoFrame, DecodeAudioData, ReadMetadata and Seek should
|
// Note: DecodeVideoFrame, DecodeAudioData, ReadMetadata and Seek should
|
||||||
// activate the decoder if necessary. The state machine only needs to know
|
// activate the decoder if necessary. The state machine only needs to know
|
||||||
// when to call SetIdle().
|
// when to call SetIdle().
|
||||||
virtual void SetIdle() { }
|
virtual void SetIdle() {}
|
||||||
|
|
||||||
#ifdef MOZ_EME
|
#ifdef MOZ_EME
|
||||||
virtual void SetCDMProxy(CDMProxy* aProxy) {}
|
virtual void SetCDMProxy(CDMProxy* aProxy) {}
|
||||||
|
@ -223,13 +232,19 @@ public:
|
||||||
// throttling when the update comes from MSE code, since that code needs the
|
// throttling when the update comes from MSE code, since that code needs the
|
||||||
// updates to be observable immediately, and is generally less
|
// updates to be observable immediately, and is generally less
|
||||||
// trigger-happy with notifications anyway.
|
// trigger-happy with notifications anyway.
|
||||||
void DispatchNotifyDataArrived(uint32_t aLength, int64_t aOffset, bool aThrottleUpdates)
|
void DispatchNotifyDataArrived(uint32_t aLength,
|
||||||
|
int64_t aOffset,
|
||||||
|
bool aThrottleUpdates)
|
||||||
{
|
{
|
||||||
RefPtr<nsRunnable> r =
|
typedef media::Interval<int64_t> Interval;
|
||||||
NS_NewRunnableMethodWithArg<media::Interval<int64_t>>(this, aThrottleUpdates ? &MediaDecoderReader::ThrottledNotifyDataArrived
|
RefPtr<nsRunnable> r = NS_NewRunnableMethodWithArg<Interval>(
|
||||||
: &MediaDecoderReader::NotifyDataArrived,
|
this,
|
||||||
media::Interval<int64_t>(aOffset, aOffset + aLength));
|
aThrottleUpdates ? &MediaDecoderReader::ThrottledNotifyDataArrived :
|
||||||
OwnerThread()->Dispatch(r.forget(), AbstractThread::DontAssertDispatchSuccess);
|
&MediaDecoderReader::NotifyDataArrived,
|
||||||
|
Interval(aOffset, aOffset + aLength));
|
||||||
|
|
||||||
|
OwnerThread()->Dispatch(
|
||||||
|
r.forget(), AbstractThread::DontAssertDispatchSuccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotifyDataArrived(const media::Interval<int64_t>& aInfo)
|
void NotifyDataArrived(const media::Interval<int64_t>& aInfo)
|
||||||
|
@ -240,20 +255,25 @@ public:
|
||||||
UpdateBuffered();
|
UpdateBuffered();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notify the reader that data from the resource was evicted (MediaSource only)
|
// Notify the reader that data from the resource was evicted
|
||||||
|
// (MediaSource only).
|
||||||
virtual void NotifyDataRemoved() {}
|
virtual void NotifyDataRemoved() {}
|
||||||
|
|
||||||
virtual MediaQueue<AudioData>& AudioQueue() { return mAudioQueue; }
|
virtual MediaQueue<AudioData>& AudioQueue() { return mAudioQueue; }
|
||||||
virtual MediaQueue<VideoData>& VideoQueue() { return mVideoQueue; }
|
virtual MediaQueue<VideoData>& VideoQueue() { return mVideoQueue; }
|
||||||
|
|
||||||
// Returns a pointer to the decoder.
|
// Returns a pointer to the decoder.
|
||||||
AbstractMediaDecoder* GetDecoder() {
|
AbstractMediaDecoder* GetDecoder()
|
||||||
|
{
|
||||||
return mDecoder;
|
return mDecoder;
|
||||||
}
|
}
|
||||||
|
|
||||||
MediaInfo GetMediaInfo() { return mInfo; }
|
MediaInfo GetMediaInfo() { return mInfo; }
|
||||||
|
|
||||||
AbstractCanonical<media::TimeIntervals>* CanonicalBuffered() { return &mBuffered; }
|
AbstractCanonical<media::TimeIntervals>* CanonicalBuffered()
|
||||||
|
{
|
||||||
|
return &mBuffered;
|
||||||
|
}
|
||||||
|
|
||||||
// Indicates if the media is seekable.
|
// Indicates if the media is seekable.
|
||||||
// ReadMetada should be called before calling this method.
|
// ReadMetada should be called before calling this method.
|
||||||
|
@ -273,7 +293,8 @@ public:
|
||||||
OwnerThread()->Dispatch(r.forget());
|
OwnerThread()->Dispatch(r.forget());
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskQueue* OwnerThread() const {
|
TaskQueue* OwnerThread() const
|
||||||
|
{
|
||||||
return mTaskQueue;
|
return mTaskQueue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,7 +310,8 @@ public:
|
||||||
|
|
||||||
virtual void DisableHardwareAcceleration() {}
|
virtual void DisableHardwareAcceleration() {}
|
||||||
|
|
||||||
TimedMetadataEventSource& TimedMetadataEvent() {
|
TimedMetadataEventSource& TimedMetadataEvent()
|
||||||
|
{
|
||||||
return mTimedMetadataEvent;
|
return mTimedMetadataEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,7 +338,12 @@ protected:
|
||||||
|
|
||||||
RefPtr<VideoDataPromise> DecodeToFirstVideoData();
|
RefPtr<VideoDataPromise> DecodeToFirstVideoData();
|
||||||
|
|
||||||
bool HaveStartTime() { MOZ_ASSERT(OnTaskQueue()); return mStartTime.isSome(); }
|
bool HaveStartTime()
|
||||||
|
{
|
||||||
|
MOZ_ASSERT(OnTaskQueue());
|
||||||
|
return mStartTime.isSome();
|
||||||
|
}
|
||||||
|
|
||||||
int64_t StartTime() { MOZ_ASSERT(HaveStartTime()); return mStartTime.ref(); }
|
int64_t StartTime() { MOZ_ASSERT(HaveStartTime()); return mStartTime.ref(); }
|
||||||
|
|
||||||
// Queue of audio frames. This queue is threadsafe, and is accessed from
|
// Queue of audio frames. This queue is threadsafe, and is accessed from
|
||||||
|
@ -398,15 +425,18 @@ private:
|
||||||
// the data required to present the media, and optionally fills *aTags
|
// the data required to present the media, and optionally fills *aTags
|
||||||
// with tag metadata from the file.
|
// with tag metadata from the file.
|
||||||
// Returns NS_OK on success, or NS_ERROR_FAILURE on failure.
|
// Returns NS_OK on success, or NS_ERROR_FAILURE on failure.
|
||||||
virtual nsresult ReadMetadata(MediaInfo* aInfo,
|
virtual nsresult ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags)
|
||||||
MetadataTags** aTags) { MOZ_CRASH(); }
|
{
|
||||||
|
MOZ_CRASH();
|
||||||
|
}
|
||||||
|
|
||||||
// Recomputes mBuffered.
|
// Recomputes mBuffered.
|
||||||
virtual void UpdateBuffered();
|
virtual void UpdateBuffered();
|
||||||
|
|
||||||
virtual void NotifyDataArrivedInternal(uint32_t aLength, int64_t aOffset) { }
|
virtual void NotifyDataArrivedInternal(uint32_t aLength, int64_t aOffset) {}
|
||||||
|
|
||||||
// Invokes NotifyDataArrived while throttling the calls to occur at most every mThrottleDuration ms.
|
// Invokes NotifyDataArrived while throttling the calls to occur
|
||||||
|
// at most every mThrottleDuration ms.
|
||||||
void ThrottledNotifyDataArrived(const media::Interval<int64_t>& aInterval);
|
void ThrottledNotifyDataArrived(const media::Interval<int64_t>& aInterval);
|
||||||
void DoThrottledNotify();
|
void DoThrottledNotify();
|
||||||
|
|
||||||
|
@ -415,7 +445,8 @@ private:
|
||||||
// when there's more audio to decode, false if the audio is finished,
|
// when there's more audio to decode, false if the audio is finished,
|
||||||
// end of file has been reached, or an un-recoverable read error has
|
// end of file has been reached, or an un-recoverable read error has
|
||||||
// occured. This function blocks until the decode is complete.
|
// occured. This function blocks until the decode is complete.
|
||||||
virtual bool DecodeAudioData() {
|
virtual bool DecodeAudioData()
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -424,7 +455,8 @@ private:
|
||||||
// (unless they're not keyframes and aKeyframeSkip is true), but will
|
// (unless they're not keyframes and aKeyframeSkip is true), but will
|
||||||
// not be added to the queue. This function blocks until the decode
|
// not be added to the queue. This function blocks until the decode
|
||||||
// is complete.
|
// is complete.
|
||||||
virtual bool DecodeVideoFrame(bool &aKeyframeSkip, int64_t aTimeThreshold) {
|
virtual bool DecodeVideoFrame(bool &aKeyframeSkip, int64_t aTimeThreshold)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче