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
--- a/dom/media/mediasource/TrackBuffersManager.cpp
+++ b/dom/media/mediasource/TrackBuffersManager.cpp
@@ -631,32 +631,45 @@ TrackBuffersManager::SegmentParserLoop()
// ignored from the start of the input buffer.
// We do not remove bytes from our input buffer. Instead we enforce that
// our ContainerParser is able to skip over all data that is supposed to be
// ignored.
// 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.
RecreateParser(false);
}
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;
}
int64_t start, end;
bool newData = mParser->ParseStartAndEndTimestamps(mInputBuffer, start, end);
mProcessedInput += mInputBuffer->Length();