Bug 905513 - Don't clobber audio VideoInfo fields when accepting video configuration. r=doublec

This commit is contained in:
Matthew Gregan 2013-09-27 17:22:38 +12:00
parent e5ba858708
commit b64f0348e3
4 changed files with 20 additions and 14 deletions

View File

@ -38,7 +38,7 @@ public:
bool OnDecodeThread() const MOZ_OVERRIDE; bool OnDecodeThread() const MOZ_OVERRIDE;
MediaResource* GetResource() const MOZ_FINAL MOZ_OVERRIDE; MediaResource* GetResource() const MOZ_OVERRIDE;
void NotifyBytesConsumed(int64_t aBytes, int64_t aOffset) MOZ_FINAL MOZ_OVERRIDE; void NotifyBytesConsumed(int64_t aBytes, int64_t aOffset) MOZ_FINAL MOZ_OVERRIDE;
@ -74,7 +74,7 @@ public:
MediaDecoderOwner* GetOwner() MOZ_FINAL MOZ_OVERRIDE; MediaDecoderOwner* GetOwner() MOZ_FINAL MOZ_OVERRIDE;
private: protected:
// This monitor object is not really used to synchronize access to anything. // This monitor object is not really used to synchronize access to anything.
// It's just there in order for us to be able to override // It's just there in order for us to be able to override
// GetReentrantMonitor correctly. // GetReentrantMonitor correctly.

View File

@ -35,7 +35,7 @@ class TimeRanges;
class MediaSourceReader : public MediaDecoderReader class MediaSourceReader : public MediaDecoderReader
{ {
public: public:
MediaSourceReader(AbstractMediaDecoder* aDecoder) MediaSourceReader(MediaSourceDecoder* aDecoder)
: MediaDecoderReader(aDecoder) : MediaDecoderReader(aDecoder)
{ {
} }
@ -184,8 +184,6 @@ MediaSourceReader::ReadMetadata(VideoInfo* aInfo, MetadataTags** aTags)
MediaSourceDecoder* decoder = static_cast<MediaSourceDecoder*>(mDecoder); MediaSourceDecoder* decoder = static_cast<MediaSourceDecoder*>(mDecoder);
const nsTArray<MediaDecoderReader*>& readers = decoder->GetReaders(); const nsTArray<MediaDecoderReader*>& readers = decoder->GetReaders();
bool gotVideo = false;
bool gotAudio = false;
for (uint32_t i = 0; i < readers.Length(); ++i) { for (uint32_t i = 0; i < readers.Length(); ++i) {
MediaDecoderReader* reader = readers[i]; MediaDecoderReader* reader = readers[i];
VideoInfo vi; VideoInfo vi;
@ -194,17 +192,17 @@ MediaSourceReader::ReadMetadata(VideoInfo* aInfo, MetadataTags** aTags)
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return rv; return rv;
} }
if (vi.mHasVideo && !gotVideo) { if (vi.mHasVideo && !mInfo.mHasVideo) {
mInfo = vi; mInfo.mDisplay = vi.mDisplay;
mInfo.mStereoMode = vi.mStereoMode;
mInfo.mHasVideo = true;
decoder->SetVideoReader(reader); decoder->SetVideoReader(reader);
gotVideo = true;
} }
if (vi.mHasAudio && !gotAudio) { if (vi.mHasAudio && !mInfo.mHasAudio) {
mInfo.mAudioRate = vi.mAudioRate; mInfo.mAudioRate = vi.mAudioRate;
mInfo.mAudioChannels = vi.mAudioChannels; mInfo.mAudioChannels = vi.mAudioChannels;
mInfo.mHasAudio = true; mInfo.mHasAudio = true;
decoder->SetAudioReader(reader); decoder->SetAudioReader(reader);
gotAudio = true;
} }
} }
*aInfo = mInfo; *aInfo = mInfo;

View File

@ -60,6 +60,12 @@ SubBufferDecoder::OnDecodeThread() const
return mParentDecoder->OnDecodeThread(); return mParentDecoder->OnDecodeThread();
} }
SourceBufferResource*
SubBufferDecoder::GetResource() const
{
return static_cast<SourceBufferResource*>(mResource.get());
}
void void
SubBufferDecoder::SetMediaDuration(int64_t aDuration) SubBufferDecoder::SetMediaDuration(int64_t aDuration)
{ {
@ -226,7 +232,7 @@ SourceBuffer::Detach()
void void
SourceBuffer::Ended() SourceBuffer::Ended()
{ {
static_cast<SourceBufferResource*>(mDecoder->GetResource())->Ended(); mDecoder->GetResource()->Ended();
} }
SourceBuffer::SourceBuffer(MediaSource* aMediaSource, const nsACString& aType) SourceBuffer::SourceBuffer(MediaSource* aMediaSource, const nsACString& aType)
@ -247,7 +253,7 @@ SourceBuffer::SourceBuffer(MediaSource* aMediaSource, const nsACString& aType)
SourceBuffer::~SourceBuffer() SourceBuffer::~SourceBuffer()
{ {
if (mDecoder) { if (mDecoder) {
static_cast<SourceBufferResource*>(mDecoder->GetResource())->Ended(); mDecoder->GetResource()->Ended();
} }
} }
@ -321,9 +327,9 @@ SourceBuffer::AppendData(const uint8_t* aData, uint32_t aLength, ErrorResult& aR
// XXX: For future reference: NDA call must run on the main thread. // XXX: For future reference: NDA call must run on the main thread.
mDecoder->NotifyDataArrived(reinterpret_cast<const char*>(aData), mDecoder->NotifyDataArrived(reinterpret_cast<const char*>(aData),
aLength, aLength,
static_cast<SourceBufferResource*>(mDecoder->GetResource())->GetLength()); mDecoder->GetResource()->GetLength());
// TODO: Run buffer append algorithm asynchronously (would call StopUpdating()). // TODO: Run buffer append algorithm asynchronously (would call StopUpdating()).
static_cast<SourceBufferResource*>(mDecoder->GetResource())->AppendData(aData, aLength); mDecoder->GetResource()->AppendData(aData, aLength);
StopUpdating(); StopUpdating();
} }

View File

@ -8,6 +8,7 @@
#define MOZILLA_SUBBUFFERDECODER_H_ #define MOZILLA_SUBBUFFERDECODER_H_
#include "BufferDecoder.h" #include "BufferDecoder.h"
#include "SourceBufferResource.h"
namespace mozilla { namespace mozilla {
@ -32,6 +33,7 @@ public:
ReentrantMonitor& GetReentrantMonitor() MOZ_OVERRIDE; ReentrantMonitor& GetReentrantMonitor() MOZ_OVERRIDE;
bool OnStateMachineThread() const MOZ_OVERRIDE; bool OnStateMachineThread() const MOZ_OVERRIDE;
bool OnDecodeThread() const MOZ_OVERRIDE; bool OnDecodeThread() const MOZ_OVERRIDE;
SourceBufferResource* GetResource() const MOZ_OVERRIDE;
void SetMediaDuration(int64_t aDuration) MOZ_OVERRIDE; void SetMediaDuration(int64_t aDuration) MOZ_OVERRIDE;
void UpdateEstimatedMediaDuration(int64_t aDuration) MOZ_OVERRIDE; void UpdateEstimatedMediaDuration(int64_t aDuration) MOZ_OVERRIDE;
void SetMediaSeekable(bool aMediaSeekable) MOZ_OVERRIDE; void SetMediaSeekable(bool aMediaSeekable) MOZ_OVERRIDE;