Bug 1050064 - Reconfigure WMFAACDecoder on stream change. r=padenot

This commit is contained in:
Chris Pearce 2014-08-13 09:56:33 +12:00
Родитель 8f78184d9a
Коммит 6f3e8d4952
2 изменённых файлов: 35 добавлений и 5 удалений

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

@ -136,16 +136,44 @@ WMFAudioMFTManager::Input(mp4_demuxer::MP4Sample* aSample)
return mDecoder->Input(data, length, aSample->composition_timestamp);
}
HRESULT
WMFAudioMFTManager::UpdateOutputType()
{
HRESULT hr;
RefPtr<IMFMediaType> type;
hr = mDecoder->GetOutputMediaType(type);
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
hr = type->GetUINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, &mAudioRate);
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
hr = type->GetUINT32(MF_MT_AUDIO_NUM_CHANNELS, &mAudioChannels);
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
return S_OK;
}
HRESULT
WMFAudioMFTManager::Output(int64_t aStreamOffset,
nsAutoPtr<MediaData>& aOutData)
{
aOutData = nullptr;
RefPtr<IMFSample> sample;
HRESULT hr = mDecoder->Output(&sample);
if (hr == MF_E_TRANSFORM_NEED_MORE_INPUT) {
return MF_E_TRANSFORM_NEED_MORE_INPUT;
HRESULT hr;
while (true) {
hr = mDecoder->Output(&sample);
if (hr == MF_E_TRANSFORM_NEED_MORE_INPUT) {
return hr;
}
if (hr == MF_E_TRANSFORM_STREAM_CHANGE) {
hr = UpdateOutputType();
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
continue;
}
break;
}
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
RefPtr<IMFMediaBuffer> buffer;

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

@ -31,12 +31,14 @@ public:
nsAutoPtr<MediaData>& aOutput) MOZ_OVERRIDE;
private:
HRESULT UpdateOutputType();
// IMFTransform wrapper that performs the decoding.
RefPtr<MFTDecoder> mDecoder;
const uint32_t mAudioChannels;
uint32_t mAudioChannels;
const uint32_t mAudioBytesPerSample;
const uint32_t mAudioRate;
uint32_t mAudioRate;
nsTArray<BYTE> mUserData;
// The offset, in audio frames, at which playback started since the