Bug 1216850. Part 1 - backout bug 1215003. r=me.

This commit is contained in:
JW Wang 2015-10-21 10:59:56 +08:00
parent eda0d89757
commit 44d9dd6f96
29 changed files with 71 additions and 73 deletions

View File

@ -249,12 +249,12 @@ MediaDecoderReader::GetBuffered()
}
RefPtr<MediaDecoderReader::MetadataPromise>
MediaDecoderReader::AsyncReadMetadataInternal()
MediaDecoderReader::AsyncReadMetadata()
{
typedef ReadMetadataFailureReason Reason;
MOZ_ASSERT(OnTaskQueue());
DECODER_LOG("MediaDecoderReader::AsyncReadMetadataInternal");
DECODER_LOG("MediaDecoderReader::AsyncReadMetadata");
// Attempt to read the metadata.
RefPtr<MetadataHolder> metadata = new MetadataHolder();

View File

@ -94,14 +94,6 @@ public:
// on failure.
virtual nsresult Init() { return NS_OK; }
RefPtr<MetadataPromise> AsyncReadMetadata()
{
return OnTaskQueue() ?
AsyncReadMetadataInternal() :
InvokeAsync(OwnerThread(), this, __func__,
&MediaDecoderReader::AsyncReadMetadataInternal);
}
// Release media resources they should be released in dormant state
// The reader can be made usable again by calling ReadMetadata().
void ReleaseMediaResources()
@ -185,6 +177,18 @@ public:
virtual bool HasAudio() = 0;
virtual bool HasVideo() = 0;
// The default implementation of AsyncReadMetadata is implemented in terms of
// synchronous ReadMetadata() calls. Implementations may also
// override AsyncReadMetadata to create a more proper async implementation.
virtual RefPtr<MetadataPromise> AsyncReadMetadata();
// Read header data for all bitstreams in the file. Fills aInfo with
// 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(); }
// 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) { };
@ -264,18 +268,6 @@ private:
virtual void ReleaseMediaResourcesInternal() {}
virtual void DisableHardwareAccelerationInternal() {}
// Read header data for all bitstreams in the file. Fills aInfo with
// 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*, MetadataTags**) { MOZ_CRASH(); }
// The default implementation of AsyncReadMetadataInternal is implemented in
// terms of synchronous ReadMetadata() calls. Implementations may also
// override AsyncReadMetadataInternal to create a more proper async
// implementation.
virtual RefPtr<MetadataPromise> AsyncReadMetadataInternal();
protected:
friend class TrackBuffer;
virtual void NotifyDataArrivedInternal(uint32_t aLength, int64_t aOffset) { }

View File

@ -2280,10 +2280,11 @@ nsresult MediaDecoderStateMachine::RunStateMachine()
case DECODER_STATE_DECODING_METADATA: {
if (!mMetadataRequest.Exists()) {
DECODER_LOG("Calling AsyncReadMetadata");
DECODER_LOG("Dispatching AsyncReadMetadata");
// Set mode to METADATA since we are about to read metadata.
mResource->SetReadMode(MediaCacheStream::MODE_METADATA);
mMetadataRequest.Begin(mReader->AsyncReadMetadata()
mMetadataRequest.Begin(InvokeAsync(DecodeTaskQueue(), mReader.get(), __func__,
&MediaDecoderReader::AsyncReadMetadata)
->Then(OwnerThread(), __func__, this,
&MediaDecoderStateMachine::OnMetadataRead,
&MediaDecoderStateMachine::OnMetadataNotRead));

View File

@ -243,7 +243,7 @@ MediaFormatReader::IsWaitingOnCDMResource() {
}
RefPtr<MediaDecoderReader::MetadataPromise>
MediaFormatReader::AsyncReadMetadataInternal()
MediaFormatReader::AsyncReadMetadata()
{
MOZ_ASSERT(OnTaskQueue());

View File

@ -52,6 +52,8 @@ public:
return mAudio.mTrackDemuxer;
}
RefPtr<MetadataPromise> AsyncReadMetadata() override;
void ReadUpdatedMetadata(MediaInfo* aInfo) override;
RefPtr<SeekPromise>
@ -440,7 +442,6 @@ private:
// For Media Resource Management
void ReleaseMediaResourcesInternal() override;
void DisableHardwareAccelerationInternal() override;
RefPtr<MetadataPromise> AsyncReadMetadataInternal() override;
};
} // namespace mozilla

View File

@ -35,8 +35,8 @@ AndroidMediaReader::AndroidMediaReader(AbstractMediaDecoder *aDecoder,
{
}
nsresult
AndroidMediaReader::ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags)
nsresult AndroidMediaReader::ReadMetadata(MediaInfo* aInfo,
MetadataTags** aTags)
{
MOZ_ASSERT(OnTaskQueue());

View File

@ -64,6 +64,8 @@ public:
return true;
}
virtual nsresult ReadMetadata(MediaInfo* aInfo,
MetadataTags** aTags);
virtual RefPtr<SeekPromise>
Seek(int64_t aTime, int64_t aEndTime) override;
@ -85,8 +87,6 @@ public:
RefPtr<Image> mImage;
};
private:
virtual nsresult ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags);
};
} // namespace mozilla

View File

@ -351,7 +351,8 @@ GetProperty(AudioFileStreamID aAudioFileStream,
nsresult
AppleMP3Reader::ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags)
AppleMP3Reader::ReadMetadata(MediaInfo* aInfo,
MetadataTags** aTags)
{
MOZ_ASSERT(OnTaskQueue());

View File

@ -31,6 +31,9 @@ public:
virtual bool HasAudio() override;
virtual bool HasVideo() override;
virtual nsresult ReadMetadata(MediaInfo* aInfo,
MetadataTags** aTags) override;
virtual RefPtr<SeekPromise>
Seek(int64_t aTime, int64_t aEndTime) override;
@ -47,11 +50,10 @@ protected:
virtual void NotifyDataArrivedInternal(uint32_t aLength,
int64_t aOffset) override;
public:
virtual bool IsMediaSeekable() override;
private:
virtual nsresult ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags) override;
void SetupDecoder();
nsresult Read(uint32_t *aNumBytes, char *aData);

View File

@ -90,7 +90,8 @@ static const GUID CLSID_MPEG_LAYER_3_DECODER_FILTER =
{ 0x38BE3000, 0xDBF4, 0x11D0, {0x86, 0x0E, 0x00, 0xA0, 0x24, 0xCF, 0xEF, 0x6D} };
nsresult
DirectShowReader::ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags)
DirectShowReader::ReadMetadata(MediaInfo* aInfo,
MetadataTags** aTags)
{
MOZ_ASSERT(OnTaskQueue());
HRESULT hr;

View File

@ -50,6 +50,9 @@ public:
bool HasAudio() override;
bool HasVideo() override;
nsresult ReadMetadata(MediaInfo* aInfo,
MetadataTags** aTags) override;
RefPtr<SeekPromise>
Seek(int64_t aTime, int64_t aEndTime) override;
@ -61,7 +64,6 @@ public:
bool IsMediaSeekable() override;
private:
nsresult ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags) override;
// Notifies the filter graph that playback is complete. aStatus is
// the code to send to the filter graph. Always returns false, so

View File

@ -360,8 +360,8 @@ GStreamerReader::GetDataLength()
return streamLen - mDataOffset;
}
nsresult
GStreamerReader::ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags)
nsresult GStreamerReader::ReadMetadata(MediaInfo* aInfo,
MetadataTags** aTags)
{
MOZ_ASSERT(OnTaskQueue());
nsresult ret = NS_OK;

View File

@ -46,6 +46,8 @@ public:
virtual bool DecodeAudioData() override;
virtual bool DecodeVideoFrame(bool &aKeyframeSkip,
int64_t aTimeThreshold) override;
virtual nsresult ReadMetadata(MediaInfo* aInfo,
MetadataTags** aTags) override;
virtual RefPtr<SeekPromise>
Seek(int64_t aTime, int64_t aEndTime) override;
virtual media::TimeIntervals GetBuffered() override;
@ -68,7 +70,6 @@ public:
virtual bool IsMediaSeekable() override;
private:
virtual nsresult ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags) override;
void ReadAndPushData(guint aLength);
RefPtr<layers::PlanarYCbCrImage> GetImageFromBuffer(GstBuffer* aBuffer);

View File

@ -371,8 +371,8 @@ void OggReader::SetupMediaTracksInfo(const nsTArray<uint32_t>& aSerials)
}
}
nsresult
OggReader::ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags)
nsresult OggReader::ReadMetadata(MediaInfo* aInfo,
MetadataTags** aTags)
{
MOZ_ASSERT(OnTaskQueue());

View File

@ -69,6 +69,8 @@ public:
return mTheoraState != 0 && mTheoraState->mActive;
}
virtual nsresult ReadMetadata(MediaInfo* aInfo,
MetadataTags** aTags) override;
virtual RefPtr<SeekPromise>
Seek(int64_t aTime, int64_t aEndTime) override;
virtual media::TimeIntervals GetBuffered() override;
@ -76,8 +78,6 @@ public:
virtual bool IsMediaSeekable() override;
private:
virtual nsresult ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags) override;
// TODO: DEPRECATED. This uses synchronous decoding.
// Stores the presentation time of the first frame we'd be able to play if
// we started playback at the current position. Returns the first video

View File

@ -660,7 +660,7 @@ MediaCodecReader::ParseDataSegment(const char* aBuffer,
}
RefPtr<MediaDecoderReader::MetadataPromise>
MediaCodecReader::AsyncReadMetadataInternal()
MediaCodecReader::AsyncReadMetadata()
{
MOZ_ASSERT(OnTaskQueue());

View File

@ -70,11 +70,8 @@ protected:
// all contents have been continuously parsed. (ex. total duration of some
// variable-bit-rate MP3 files.)
virtual void NotifyDataArrivedInternal(uint32_t aLength, int64_t aOffset) override;
virtual RefPtr<MediaDecoderReader::MetadataPromise>
AsyncReadMetadataInternal() override;
public:
// Flush the TaskQueue, flush MediaCodec and raise the mDiscontinuity.
virtual nsresult ResetDecode() override;
@ -89,6 +86,8 @@ public:
virtual bool HasAudio();
virtual bool HasVideo();
virtual RefPtr<MediaDecoderReader::MetadataPromise> AsyncReadMetadata() override;
// Moves the decode head to aTime microseconds. aStartTime and aEndTime
// denote the start and end times of the media in usecs, and aCurrentTime
// is the current playback position in microseconds.

View File

@ -212,7 +212,7 @@ nsresult MediaOmxReader::InitOmxDecoder()
}
RefPtr<MediaDecoderReader::MetadataPromise>
MediaOmxReader::AsyncReadMetadataInternal()
MediaOmxReader::AsyncReadMetadata()
{
MOZ_ASSERT(OnTaskQueue());
EnsureActive();

View File

@ -72,10 +72,6 @@ public:
protected:
virtual void NotifyDataArrivedInternal(uint32_t aLength, int64_t aOffset) override;
virtual RefPtr<MediaDecoderReader::MetadataPromise>
AsyncReadMetadataInternal() override;
public:
virtual nsresult ResetDecode()
@ -99,6 +95,8 @@ public:
return mHasVideo;
}
virtual RefPtr<MediaDecoderReader::MetadataPromise> AsyncReadMetadata() override;
virtual RefPtr<SeekPromise>
Seek(int64_t aTime, int64_t aEndTime) override;

View File

@ -89,13 +89,13 @@ RtspMediaCodecReader::RequestVideoData(bool aSkipToNextKeyframe,
}
RefPtr<MediaDecoderReader::MetadataPromise>
RtspMediaCodecReader::AsyncReadMetadataInternal()
RtspMediaCodecReader::AsyncReadMetadata()
{
mRtspResource->DisablePlayoutDelay();
EnsureActive();
RefPtr<MediaDecoderReader::MetadataPromise> p =
MediaCodecReader::AsyncReadMetadataInternal();
MediaCodecReader::AsyncReadMetadata();
// Send a PAUSE to the RTSP server because the underlying media resource is
// not ready.

View File

@ -58,12 +58,12 @@ public:
// Disptach a DecodeAudioDataTask to decode audio data.
virtual RefPtr<AudioDataPromise> RequestAudioData() override;
virtual RefPtr<MediaDecoderReader::MetadataPromise> AsyncReadMetadata()
override;
virtual void HandleResourceAllocated() override;
private:
virtual RefPtr<MediaDecoderReader::MetadataPromise>
AsyncReadMetadataInternal() override;
// A pointer to RtspMediaResource for calling the Rtsp specific function.
// The lifetime of mRtspResource is controlled by MediaDecoder. MediaDecoder
// holds the MediaDecoderStateMachine and RtspMediaResource.

View File

@ -87,14 +87,14 @@ void RtspOmxReader::EnsureActive() {
}
RefPtr<MediaDecoderReader::MetadataPromise>
RtspOmxReader::AsyncReadMetadataInternal()
RtspOmxReader::AsyncReadMetadata()
{
// Send a PLAY command to the RTSP server before reading metadata.
// Because we might need some decoded samples to ensure we have configuration.
mRtspResource->DisablePlayoutDelay();
RefPtr<MediaDecoderReader::MetadataPromise> p =
MediaOmxReader::AsyncReadMetadataInternal();
MediaOmxReader::AsyncReadMetadata();
// Send a PAUSE to the RTSP server because the underlying media resource is
// not ready.

View File

@ -66,12 +66,12 @@ public:
virtual void SetIdle() override;
virtual RefPtr<MediaDecoderReader::MetadataPromise> AsyncReadMetadata()
override;
virtual void HandleResourceAllocated() override;
private:
virtual RefPtr<MediaDecoderReader::MetadataPromise>
AsyncReadMetadataInternal() override;
// A pointer to RtspMediaResource for calling the Rtsp specific function.
// The lifetime of mRtspResource is controlled by MediaDecoder. MediaDecoder
// holds the MediaDecoderStateMachine and RtspMediaResource.

View File

@ -32,8 +32,8 @@ nsresult RawReader::ResetDecode()
return MediaDecoderReader::ResetDecode();
}
nsresult
RawReader::ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags)
nsresult RawReader::ReadMetadata(MediaInfo* aInfo,
MetadataTags** aTags)
{
MOZ_ASSERT(OnTaskQueue());

View File

@ -36,6 +36,8 @@ public:
return true;
}
virtual nsresult ReadMetadata(MediaInfo* aInfo,
MetadataTags** aTags) override;
virtual RefPtr<SeekPromise>
Seek(int64_t aTime, int64_t aEndTime) override;
@ -44,7 +46,6 @@ public:
virtual bool IsMediaSeekable() override;
private:
virtual nsresult ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags) override;
bool ReadFromResource(uint8_t *aBuf, uint32_t aLength);
RawVideoHeader mMetadata;

View File

@ -116,8 +116,8 @@ WaveReader::~WaveReader()
MOZ_COUNT_DTOR(WaveReader);
}
nsresult
WaveReader::ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags)
nsresult WaveReader::ReadMetadata(MediaInfo* aInfo,
MetadataTags** aTags)
{
MOZ_ASSERT(OnTaskQueue());

View File

@ -36,6 +36,8 @@ public:
return false;
}
virtual nsresult ReadMetadata(MediaInfo* aInfo,
MetadataTags** aTags) override;
virtual RefPtr<SeekPromise>
Seek(int64_t aTime, int64_t aEndTime) override;
@ -44,7 +46,6 @@ public:
virtual bool IsMediaSeekable() override;
private:
virtual nsresult ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags) override;
bool ReadAll(char* aBuf, int64_t aSize, int64_t* aBytesRead = nullptr);
bool LoadRIFFChunk();
bool LoadFormatChunk(uint32_t aChunkSize);

View File

@ -227,10 +227,8 @@ void WebMReader::Cleanup()
}
RefPtr<MediaDecoderReader::MetadataPromise>
WebMReader::AsyncReadMetadataInternal()
WebMReader::AsyncReadMetadata()
{
MOZ_ASSERT(OnTaskQueue());
RefPtr<MetadataHolder> metadata = new MetadataHolder();
if (NS_FAILED(RetrieveWebMMetadata(&metadata->mInfo)) ||

View File

@ -89,6 +89,8 @@ public:
return mHasVideo;
}
virtual RefPtr<MetadataPromise> AsyncReadMetadata() override;
virtual RefPtr<SeekPromise>
Seek(int64_t aTime, int64_t aEndTime) override;
@ -142,8 +144,6 @@ protected:
bool ShouldSkipVideoFrame(int64_t aTimeThreshold);
private:
virtual RefPtr<MetadataPromise> AsyncReadMetadataInternal() override;
nsresult RetrieveWebMMetadata(MediaInfo* aInfo);
// Get the timestamp of keyframe greater than aTimeThreshold.