WebVtt Text to MP4 - Test That No Payloads Becomes Gaps

Text Samples with no payload should be ignored, so this adds a
test to check that samples with no payload get treated the
same as a gap.

As long as this case is true, using gaps in our other tests should
functionally be the same as using samples with no payload.

Change-Id: Ic16b240c43eda2514b537a2d938d4135638adc4e
This commit is contained in:
Aaron Vaage 2018-06-01 10:29:44 -07:00
parent e96fe3aedf
commit 47f20031dd
1 changed files with 46 additions and 0 deletions

View File

@ -26,6 +26,7 @@ const char* kId2 = "sample-id-2";
const char* kId3 = "sample-id-3";
const char* kSimplePayload = "simple-payload-that-has-some-text";
const char* kEmptyPayload = "";
} // namespace
MATCHER_P(MediaSampleContainsId, id, "") {
@ -97,6 +98,51 @@ class WebVttToMp4HandlerTest : public MediaHandlerTestBase {
Status Flush() { return In()->FlushAllDownstreams(); }
};
// Verify that samples with no payload are ignored and act as gaps.
//
// |[-- SEGMENT ------------------]|
// | [--- EMPTY SAMPLE ---]|
// |[- GAP -] |
//
TEST_F(WebVttToMp4HandlerTest, IngoresEmptyPayloadSamples) {
const int64_t kSegmentStart = 0;
const int64_t kSegmentEnd = 10000;
const int64_t kSegmentDuration = kSegmentEnd - kSegmentStart;
const int64_t kGapStart = kSegmentStart;
const int64_t kGapEnd = kGapStart + 200;
const int64_t kSampleStart = kGapEnd;
const int64_t kSampleEnd = kSegmentEnd;
ASSERT_OK(SetUpTestGraph());
{
testing::InSequence s;
EXPECT_CALL(*Out(), OnProcess(IsStreamInfo(kStreamIndex)));
// Gap - The gap and sample should be combines into a new gap that spans
// the while segment.
EXPECT_CALL(*Out(),
OnProcess(IsMediaSample(kStreamIndex, kSegmentStart,
kSegmentDuration, !kEncrypted)));
// Segment
EXPECT_CALL(*Out(), OnProcess(IsSegmentInfo(kStreamIndex, kSegmentStart,
kSegmentDuration, !kSubSegment,
!kEncrypted)));
EXPECT_CALL(*Out(), OnFlush(kStreamIndex));
}
ASSERT_OK(DispatchStream());
// Even if the sample has an id, it should still get ignored if it has no
// payload.
ASSERT_OK(DispatchText(kId1, kEmptyPayload, kSampleStart, kSampleEnd));
ASSERT_OK(DispatchSegment(kSegmentStart, kSegmentEnd));
ASSERT_OK(Flush());
}
// Verify that when the stream starts at a non-zero value, the gap at the
// start will be filled.
//