Bug 1217692. Part 2 - fix some styles to keep 80 cols limit. r=jya.

This commit is contained in:
JW Wang 2015-10-26 11:29:48 +08:00
Родитель 82503359f9
Коммит ab48413bfa
1 изменённых файлов: 61 добавлений и 29 удалений

Просмотреть файл

@ -62,6 +62,8 @@ class MediaDecoderReader {
friend class ReRequestVideoWithSkipTask;
friend class ReRequestAudioTask;
static const bool IsExclusive = true;
public:
enum NotDecodedReason {
END_OF_STREAM,
@ -70,16 +72,20 @@ public:
CANCELED
};
typedef MozPromise<RefPtr<MetadataHolder>, ReadMetadataFailureReason, /* IsExclusive = */ true> MetadataPromise;
typedef MozPromise<RefPtr<MediaData>, NotDecodedReason, /* IsExclusive = */ true> AudioDataPromise;
typedef MozPromise<RefPtr<MediaData>, NotDecodedReason, /* IsExclusive = */ true> VideoDataPromise;
typedef MozPromise<int64_t, nsresult, /* IsExclusive = */ true> SeekPromise;
using MetadataPromise =
MozPromise<RefPtr<MetadataHolder>, ReadMetadataFailureReason, IsExclusive>;
using AudioDataPromise =
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.
// 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
// 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)
@ -93,7 +99,7 @@ public:
// Release media resources they should be released in dormant state
// The reader can be made usable again by calling ReadMetadata().
virtual void ReleaseMediaResources() {};
virtual void ReleaseMediaResources() {}
// Breaks reference-counted cycles. Called during shutdown.
// WARNING: If you override this, you must call the base implementation
// in your override.
@ -145,7 +151,11 @@ public:
// in buffering mode. Some readers support a promise-based mechanism by which
// they notify the state machine when the data arrives.
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
// retuning demuxed data.
@ -165,13 +175,12 @@ public:
// Fills aInfo with the latest cached data required to present the media,
// 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
// time of the media in usecs. This is only needed for OggReader, and should
// probably be removed somehow.
virtual RefPtr<SeekPromise>
Seek(int64_t aTime, int64_t aEndTime) = 0;
virtual RefPtr<SeekPromise> Seek(int64_t aTime, int64_t aEndTime) = 0;
// 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
@ -223,13 +232,19 @@ public:
// throttling when the update comes from MSE code, since that code needs the
// updates to be observable immediately, and is generally less
// 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 =
NS_NewRunnableMethodWithArg<media::Interval<int64_t>>(this, aThrottleUpdates ? &MediaDecoderReader::ThrottledNotifyDataArrived
: &MediaDecoderReader::NotifyDataArrived,
media::Interval<int64_t>(aOffset, aOffset + aLength));
OwnerThread()->Dispatch(r.forget(), AbstractThread::DontAssertDispatchSuccess);
typedef media::Interval<int64_t> Interval;
RefPtr<nsRunnable> r = NS_NewRunnableMethodWithArg<Interval>(
this,
aThrottleUpdates ? &MediaDecoderReader::ThrottledNotifyDataArrived :
&MediaDecoderReader::NotifyDataArrived,
Interval(aOffset, aOffset + aLength));
OwnerThread()->Dispatch(
r.forget(), AbstractThread::DontAssertDispatchSuccess);
}
void NotifyDataArrived(const media::Interval<int64_t>& aInfo)
@ -240,20 +255,25 @@ public:
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 MediaQueue<AudioData>& AudioQueue() { return mAudioQueue; }
virtual MediaQueue<VideoData>& VideoQueue() { return mVideoQueue; }
// Returns a pointer to the decoder.
AbstractMediaDecoder* GetDecoder() {
AbstractMediaDecoder* GetDecoder()
{
return mDecoder;
}
MediaInfo GetMediaInfo() { return mInfo; }
AbstractCanonical<media::TimeIntervals>* CanonicalBuffered() { return &mBuffered; }
AbstractCanonical<media::TimeIntervals>* CanonicalBuffered()
{
return &mBuffered;
}
// Indicates if the media is seekable.
// ReadMetada should be called before calling this method.
@ -273,7 +293,8 @@ public:
OwnerThread()->Dispatch(r.forget());
}
TaskQueue* OwnerThread() const {
TaskQueue* OwnerThread() const
{
return mTaskQueue;
}
@ -289,7 +310,8 @@ public:
virtual void DisableHardwareAcceleration() {}
TimedMetadataEventSource& TimedMetadataEvent() {
TimedMetadataEventSource& TimedMetadataEvent()
{
return mTimedMetadataEvent;
}
@ -316,7 +338,12 @@ protected:
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(); }
// 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
// with tag metadata from the file.
// Returns NS_OK on success, or NS_ERROR_FAILURE on failure.
virtual nsresult ReadMetadata(MediaInfo* aInfo,
MetadataTags** aTags) { MOZ_CRASH(); }
virtual nsresult ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags)
{
MOZ_CRASH();
}
// Recomputes mBuffered.
virtual void UpdateBuffered();
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 DoThrottledNotify();
@ -415,7 +445,8 @@ private:
// 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
// occured. This function blocks until the decode is complete.
virtual bool DecodeAudioData() {
virtual bool DecodeAudioData()
{
return false;
}
@ -424,7 +455,8 @@ private:
// (unless they're not keyframes and aKeyframeSkip is true), but will
// not be added to the queue. This function blocks until the decode
// is complete.
virtual bool DecodeVideoFrame(bool &aKeyframeSkip, int64_t aTimeThreshold) {
virtual bool DecodeVideoFrame(bool &aKeyframeSkip, int64_t aTimeThreshold)
{
return false;
}