зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1540748 - part1 : Android decoder should throw an error when the decoded sample's time is smaller than the time of first demuxed sample. r=jolin
Considering that the audio sample's time is always increased, the decoded sample's time decoder returns should always be equal or larger than its demuxed time. When the decoded sample's time is smaller than the time of first demuxed sample, that time would probably cause a problem so we should throw an error for that. Differential Revision: https://phabricator.services.mozilla.com/D28167 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
6e8934bb87
Коммит
4e0420416f
|
@ -364,6 +364,19 @@ class RemoteAudioDecoder : public RemoteDataDecoder {
|
|||
return InitPromise::CreateAndResolve(TrackInfo::kAudioTrack, __func__);
|
||||
}
|
||||
|
||||
RefPtr<FlushPromise> Flush() override {
|
||||
mFirstDemuxedSampleTime.reset();
|
||||
return RemoteDataDecoder::Flush();
|
||||
}
|
||||
|
||||
RefPtr<DecodePromise> Decode(MediaRawData* aSample) override {
|
||||
if (mFirstDemuxedSampleTime.isNothing()) {
|
||||
MOZ_ASSERT(aSample->mTime.IsValid());
|
||||
mFirstDemuxedSampleTime.emplace(aSample->mTime);
|
||||
}
|
||||
return RemoteDataDecoder::Decode(aSample);
|
||||
}
|
||||
|
||||
private:
|
||||
class CallbacksSupport final : public JavaCallbacksSupport {
|
||||
public:
|
||||
|
@ -408,6 +421,10 @@ class RemoteAudioDecoder : public RemoteDataDecoder {
|
|||
RemoteAudioDecoder* mDecoder;
|
||||
};
|
||||
|
||||
bool IsSampleTimeSmallerThanFirstDemuxedSampleTime(int64_t aTime) const {
|
||||
return TimeUnit::FromMicroseconds(aTime) < mFirstDemuxedSampleTime.ref();
|
||||
}
|
||||
|
||||
// Param and LocalRef are only valid for the duration of a JNI method call.
|
||||
// Use GlobalRef as the parameter type to keep the Java object referenced
|
||||
// until running.
|
||||
|
@ -448,7 +465,8 @@ class RemoteAudioDecoder : public RemoteDataDecoder {
|
|||
int32_t size;
|
||||
ok &= NS_SUCCEEDED(info->Size(&size));
|
||||
|
||||
if (!ok) {
|
||||
if (!ok ||
|
||||
IsSampleTimeSmallerThanFirstDemuxedSampleTime(presentationTimeUs)) {
|
||||
Error(MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR, __func__));
|
||||
return;
|
||||
}
|
||||
|
@ -500,6 +518,7 @@ class RemoteAudioDecoder : public RemoteDataDecoder {
|
|||
|
||||
int32_t mOutputChannels;
|
||||
int32_t mOutputSampleRate;
|
||||
Maybe<TimeUnit> mFirstDemuxedSampleTime;
|
||||
};
|
||||
|
||||
already_AddRefed<MediaDataDecoder> RemoteDataDecoder::CreateAudioDecoder(
|
||||
|
|
Загрузка…
Ссылка в новой задаче