Bug 1314533: [MSE] P2. Reject appendBuffer if invalid data found. r=gerald

This still requires all the ContainerParser to be updated in properly handling errors.

MozReview-Commit-ID: A7gDmXSJXmc

--HG--
extra : rebase_source : c438fdd40deb843e43f341d107e48171141dc746
This commit is contained in:
Jean-Yves Avenard 2016-11-02 21:39:14 +11:00
Родитель fa47b59611
Коммит d7ed0c4335
1 изменённых файлов: 18 добавлений и 5 удалений

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

@ -636,7 +636,8 @@ TrackBuffersManager::SegmentParserLoop()
// 4. If the append state equals WAITING_FOR_SEGMENT, then run the following
// steps:
if (mSourceBufferAttributes->GetAppendState() == AppendState::WAITING_FOR_SEGMENT) {
if (NS_SUCCEEDED(mParser->IsInitSegmentPresent(mInputBuffer))) {
MediaResult haveInitSegment = mParser->IsInitSegmentPresent(mInputBuffer);
if (NS_SUCCEEDED(haveInitSegment)) {
SetAppendState(AppendState::PARSING_INIT_SEGMENT);
if (mFirstInitializationSegmentReceived) {
// This is a new initialization segment. Obsolete the old one.
@ -644,14 +645,26 @@ TrackBuffersManager::SegmentParserLoop()
}
continue;
}
if (NS_SUCCEEDED(mParser->IsMediaSegmentPresent(mInputBuffer))) {
MediaResult haveMediaSegment =
mParser->IsMediaSegmentPresent(mInputBuffer);
if (NS_SUCCEEDED(haveMediaSegment)) {
SetAppendState(AppendState::PARSING_MEDIA_SEGMENT);
mNewMediaSegmentStarted = true;
continue;
}
// We have neither an init segment nor a media segment, this is either
// invalid data or not enough data to detect a segment type.
MSE_DEBUG("Found invalid or incomplete data.");
// We have neither an init segment nor a media segment.
// Check if it was invalid data.
if (haveInitSegment != NS_ERROR_NOT_AVAILABLE) {
MSE_DEBUG("Found invalid data.");
RejectAppend(haveInitSegment, __func__);
return;
}
if (haveMediaSegment != NS_ERROR_NOT_AVAILABLE) {
MSE_DEBUG("Found invalid data.");
RejectAppend(haveMediaSegment, __func__);
return;
}
MSE_DEBUG("Found incomplete data.");
NeedMoreData();
return;
}