Bug 1119757: MSE: handle duration of 0 in metadata as infinity. r=mattwoodrow

--HG--
extra : rebase_source : 6bc09d18b0b5d8144c8242d94f1ebd92d1f0efa5
This commit is contained in:
Jean-Yves Avenard 2015-01-16 23:49:01 +11:00
Родитель b0638f45f3
Коммит 776799bb61
2 изменённых файлов: 17 добавлений и 7 удалений

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

@ -214,7 +214,10 @@ MediaSourceDecoder::SetDecodedDuration(int64_t aDuration)
return;
}
double duration = aDuration;
duration /= USECS_PER_S;
// A duration of -1 is +Infinity.
if (aDuration >= 0) {
duration /= USECS_PER_S;
}
SetMediaSourceDuration(duration);
}
@ -223,13 +226,18 @@ MediaSourceDecoder::SetMediaSourceDuration(double aDuration)
{
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
double oldDuration = mMediaSourceDuration;
mMediaSourceDuration = aDuration;
mDecoderStateMachine->SetDuration(aDuration * USECS_PER_S);
if (aDuration >= 0) {
mDecoderStateMachine->SetDuration(aDuration * USECS_PER_S);
mMediaSourceDuration = aDuration;
} else {
mDecoderStateMachine->SetDuration(INT64_MAX);
mMediaSourceDuration = PositiveInfinity<double>();
}
if (NS_IsMainThread()) {
DurationChanged(oldDuration, aDuration);
DurationChanged(oldDuration, mMediaSourceDuration);
} else {
nsRefPtr<nsIRunnable> task =
new DurationChangedRunnable(this, oldDuration, aDuration);
new DurationChangedRunnable(this, oldDuration, mMediaSourceDuration);
NS_DispatchToMainThread(task);
}
}

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

@ -845,9 +845,11 @@ MediaSourceReader::ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags)
this, mVideoReader.get(), maxDuration);
}
if (maxDuration != -1) {
static_cast<MediaSourceDecoder*>(mDecoder)->SetDecodedDuration(maxDuration);
if (!maxDuration) {
// Treat a duration of 0 as infinity
maxDuration = -1;
}
static_cast<MediaSourceDecoder*>(mDecoder)->SetDecodedDuration(maxDuration);
*aInfo = mInfo;
*aTags = nullptr; // TODO: Handle metadata.