2017-09-18 15:43:21 +00:00
|
|
|
// Copyright 2017 Google Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file or at
|
|
|
|
// https://developers.google.com/open-source/licenses/bsd
|
|
|
|
|
|
|
|
#include <gmock/gmock.h>
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
|
|
|
#include "packager/media/base/media_handler_test_base.h"
|
2018-03-23 22:28:30 +00:00
|
|
|
#include "packager/media/chunking/text_chunker.h"
|
2017-09-18 15:43:21 +00:00
|
|
|
#include "packager/status_test_util.h"
|
|
|
|
|
2018-05-25 17:41:02 +00:00
|
|
|
using ::testing::_;
|
|
|
|
|
2017-09-18 15:43:21 +00:00
|
|
|
namespace shaka {
|
|
|
|
namespace media {
|
|
|
|
|
|
|
|
namespace {
|
2018-03-23 01:33:01 +00:00
|
|
|
const uint64_t kStreamIndex = 0;
|
2018-06-06 18:41:21 +00:00
|
|
|
const uint64_t kMsTimeScale = 1000u;
|
2017-09-18 15:43:21 +00:00
|
|
|
|
2018-03-23 01:33:01 +00:00
|
|
|
const size_t kInputs = 1;
|
|
|
|
const size_t kOutputs = 1;
|
2017-09-18 15:43:21 +00:00
|
|
|
|
2018-03-23 01:33:01 +00:00
|
|
|
const size_t kInput = 0;
|
|
|
|
const size_t kOutput = 0;
|
2017-09-18 15:43:21 +00:00
|
|
|
|
|
|
|
const bool kEncrypted = true;
|
|
|
|
const bool kSubSegment = true;
|
|
|
|
|
2018-06-06 18:41:21 +00:00
|
|
|
const uint64_t kTimescaleMs = 1000;
|
2017-09-18 15:43:21 +00:00
|
|
|
|
2018-03-23 01:33:01 +00:00
|
|
|
const char* kNoId = "";
|
|
|
|
const char* kNoSettings = "";
|
|
|
|
const char* kNoPayload = "";
|
2017-09-18 15:43:21 +00:00
|
|
|
} // namespace
|
|
|
|
|
2018-03-23 22:28:30 +00:00
|
|
|
class TextChunkerTest : public MediaHandlerTestBase {
|
2017-09-18 15:43:21 +00:00
|
|
|
protected:
|
2018-06-21 18:31:09 +00:00
|
|
|
Status Init(double segment_duration) {
|
|
|
|
return SetUpAndInitializeGraph(
|
|
|
|
std::make_shared<TextChunker>(segment_duration), kInputs, kOutputs);
|
2017-09-18 15:43:21 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-06-21 18:31:09 +00:00
|
|
|
// Verify that the chunker will use the first sample's start time as the start
|
|
|
|
// time for the first segment.
|
|
|
|
//
|
|
|
|
// Segment Duration = 100 MS
|
|
|
|
//
|
|
|
|
// TIME (ms):0 5 1 1 2 2 3
|
|
|
|
// 0 0 5 0 5 0
|
|
|
|
// 0 0 0 0 0
|
|
|
|
// SAMPLES : [-----A-----]
|
|
|
|
// SEGMENTS : ^ ^ ^
|
|
|
|
//
|
|
|
|
TEST_F(TextChunkerTest, SegmentsStartAtFirstSample) {
|
|
|
|
const double kSegmentDurationSec = 0.1;
|
|
|
|
const int64_t kSegmentDurationMs = 100;
|
|
|
|
const int64_t kSegment0Start = 100;
|
|
|
|
const int64_t kSegment1Start = 200;
|
|
|
|
|
|
|
|
const int64_t kSampleAStart = 120;
|
|
|
|
const int64_t kSampleAEnd = 220;
|
|
|
|
|
|
|
|
ASSERT_OK(Init(kSegmentDurationSec));
|
|
|
|
|
|
|
|
{
|
|
|
|
testing::InSequence s;
|
|
|
|
|
|
|
|
EXPECT_CALL(*Output(kOutput), OnProcess(IsStreamInfo(_, _, _, _)));
|
|
|
|
EXPECT_CALL(*Output(kOutput), OnProcess(IsTextSample(_, _, kSampleAStart,
|
|
|
|
kSampleAEnd, _, _)));
|
|
|
|
EXPECT_CALL(
|
|
|
|
*Output(kOutput),
|
|
|
|
OnProcess(IsSegmentInfo(_, kSegment0Start, kSegmentDurationMs, _, _)));
|
|
|
|
EXPECT_CALL(*Output(kOutput), OnProcess(IsTextSample(_, _, kSampleAStart,
|
|
|
|
kSampleAEnd, _, _)));
|
|
|
|
EXPECT_CALL(
|
|
|
|
*Output(kOutput),
|
|
|
|
OnProcess(IsSegmentInfo(_, kSegment1Start, kSegmentDurationMs, _, _)));
|
|
|
|
EXPECT_CALL(*Output(kOutput), OnFlush(kStreamIndex));
|
|
|
|
}
|
|
|
|
|
|
|
|
ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromStreamInfo(
|
|
|
|
kStreamIndex, GetTextStreamInfo(kMsTimeScale))));
|
|
|
|
ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromTextSample(
|
|
|
|
kStreamIndex,
|
|
|
|
GetTextSample(kNoId, kSampleAStart, kSampleAEnd, kNoPayload))));
|
|
|
|
ASSERT_OK(Input(kInput)->FlushAllDownstreams());
|
|
|
|
}
|
|
|
|
|
2018-06-06 18:41:21 +00:00
|
|
|
// Verify that when a sample elapses a full segment, that it only appears
|
|
|
|
// in the one segment.
|
|
|
|
//
|
|
|
|
// Segment Duration = 100 MS
|
|
|
|
//
|
|
|
|
// TIME (ms):0 5 1
|
|
|
|
// 0 0
|
|
|
|
// 0
|
|
|
|
// SAMPLES :[-----A-----]
|
|
|
|
// SEGMENTS : ^
|
|
|
|
//
|
2018-03-23 01:33:01 +00:00
|
|
|
TEST_F(TextChunkerTest, SampleEndingOnSegmentStart) {
|
2018-06-06 18:41:21 +00:00
|
|
|
const double kSegmentDurationSec = 0.1;
|
|
|
|
const int64_t kSegmentDurationMs = 100;
|
2018-03-23 01:33:01 +00:00
|
|
|
|
2018-06-06 18:41:21 +00:00
|
|
|
const int64_t kSegment0Start = 0;
|
2018-03-23 01:33:01 +00:00
|
|
|
|
2018-06-06 18:41:21 +00:00
|
|
|
const int64_t kSampleAStart = 0;
|
|
|
|
const int64_t kSampleAEnd = 100;
|
|
|
|
|
|
|
|
Init(kSegmentDurationSec);
|
2017-09-18 15:43:21 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
testing::InSequence s;
|
|
|
|
|
2018-05-25 17:41:02 +00:00
|
|
|
EXPECT_CALL(*Output(kOutput),
|
|
|
|
OnProcess(IsStreamInfo(kStreamIndex, _, _, _)));
|
2017-09-18 15:43:21 +00:00
|
|
|
|
2018-03-23 01:33:01 +00:00
|
|
|
EXPECT_CALL(*Output(kOutput),
|
2018-05-25 17:41:02 +00:00
|
|
|
OnProcess(IsTextSample(_, kNoId, kSampleAStart, kSampleAEnd,
|
2018-03-23 01:33:01 +00:00
|
|
|
kNoSettings, kNoPayload)));
|
2018-06-06 18:41:21 +00:00
|
|
|
EXPECT_CALL(*Output(kOutput),
|
|
|
|
OnProcess(IsSegmentInfo(kStreamIndex, kSegment0Start,
|
|
|
|
kSegmentDurationMs, !kSubSegment,
|
|
|
|
!kEncrypted)));
|
2018-03-23 01:33:01 +00:00
|
|
|
EXPECT_CALL(*Output(kOutput), OnFlush(kStreamIndex));
|
2017-09-18 15:43:21 +00:00
|
|
|
}
|
|
|
|
|
2018-06-06 18:41:21 +00:00
|
|
|
ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromStreamInfo(
|
|
|
|
kStreamIndex, GetTextStreamInfo(kMsTimeScale))));
|
2018-03-23 01:33:01 +00:00
|
|
|
ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromTextSample(
|
|
|
|
kStreamIndex,
|
2018-06-06 18:41:21 +00:00
|
|
|
GetTextSample(kNoId, kSampleAStart, kSampleAEnd, kNoPayload))));
|
2018-03-23 01:33:01 +00:00
|
|
|
ASSERT_OK(Input(kInput)->FlushAllDownstreams());
|
2017-09-18 15:43:21 +00:00
|
|
|
}
|
|
|
|
|
2018-06-06 18:41:21 +00:00
|
|
|
// Verify that samples only appear in the correct segments when they only exist
|
|
|
|
// in one segment.
|
|
|
|
//
|
|
|
|
// Segment Duration = 100 MS
|
|
|
|
//
|
|
|
|
// TIME (ms):0 5 1 1 2
|
|
|
|
// 0 0 5 0
|
|
|
|
// 0 0 0
|
2018-06-21 18:31:09 +00:00
|
|
|
// SAMPLES :[--A--]
|
|
|
|
// [--B--]
|
2018-06-06 18:41:21 +00:00
|
|
|
// SEGMENTS : ^ ^
|
|
|
|
//
|
2018-03-23 01:33:01 +00:00
|
|
|
TEST_F(TextChunkerTest, CreatesSegmentsForSamples) {
|
2018-06-06 18:41:21 +00:00
|
|
|
const double kSegmentDurationSec = 0.1;
|
|
|
|
const int64_t kSegmentDurationMs = 100;
|
|
|
|
|
2018-03-23 01:33:01 +00:00
|
|
|
const int64_t kSegment0Start = 0;
|
2018-06-06 18:41:21 +00:00
|
|
|
const int64_t kSegment1Start = 100;
|
2018-03-23 01:33:01 +00:00
|
|
|
|
2018-06-21 18:31:09 +00:00
|
|
|
const int64_t kSampleAStart = 0;
|
|
|
|
const int64_t kSampleAEnd = 50;
|
2018-03-23 01:33:01 +00:00
|
|
|
|
2018-06-21 18:31:09 +00:00
|
|
|
const int64_t kSampleBStart = 100;
|
|
|
|
const int64_t kSampleBEnd = 150;
|
2018-03-23 01:33:01 +00:00
|
|
|
|
2018-06-06 18:41:21 +00:00
|
|
|
Init(kSegmentDurationSec);
|
2017-09-18 15:43:21 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
testing::InSequence s;
|
|
|
|
|
2018-05-25 17:41:02 +00:00
|
|
|
EXPECT_CALL(*Output(kOutput),
|
|
|
|
OnProcess(IsStreamInfo(kStreamIndex, _, _, _)));
|
2017-09-18 15:43:21 +00:00
|
|
|
|
|
|
|
// Segment One
|
2018-03-23 01:33:01 +00:00
|
|
|
EXPECT_CALL(*Output(kOutput),
|
2018-05-25 17:41:02 +00:00
|
|
|
OnProcess(IsTextSample(_, kNoId, kSampleAStart, kSampleAEnd,
|
2018-03-23 01:33:01 +00:00
|
|
|
kNoSettings, kNoPayload)));
|
2018-06-06 18:41:21 +00:00
|
|
|
EXPECT_CALL(*Output(kOutput),
|
|
|
|
OnProcess(IsSegmentInfo(kStreamIndex, kSegment0Start,
|
|
|
|
kSegmentDurationMs, !kSubSegment,
|
|
|
|
!kEncrypted)));
|
2017-09-18 15:43:21 +00:00
|
|
|
|
|
|
|
// Segment Two
|
2018-03-23 01:33:01 +00:00
|
|
|
EXPECT_CALL(*Output(kOutput),
|
2018-05-25 17:41:02 +00:00
|
|
|
OnProcess(IsTextSample(_, kNoId, kSampleBStart, kSampleBEnd,
|
2018-03-23 01:33:01 +00:00
|
|
|
kNoSettings, kNoPayload)));
|
2018-06-06 18:41:21 +00:00
|
|
|
EXPECT_CALL(*Output(kOutput),
|
|
|
|
OnProcess(IsSegmentInfo(kStreamIndex, kSegment1Start,
|
|
|
|
kSegmentDurationMs, !kSubSegment,
|
|
|
|
!kEncrypted)));
|
2017-09-18 15:43:21 +00:00
|
|
|
|
2018-03-23 01:33:01 +00:00
|
|
|
EXPECT_CALL(*Output(kOutput), OnFlush(kStreamIndex));
|
2017-09-18 15:43:21 +00:00
|
|
|
}
|
|
|
|
|
2018-06-06 18:41:21 +00:00
|
|
|
ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromStreamInfo(
|
|
|
|
kStreamIndex, GetTextStreamInfo(kMsTimeScale))));
|
2018-03-23 01:33:01 +00:00
|
|
|
ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromTextSample(
|
|
|
|
kStreamIndex,
|
2018-06-06 18:41:21 +00:00
|
|
|
GetTextSample(kNoId, kSampleAStart, kSampleAEnd, kNoPayload))));
|
2018-03-23 01:33:01 +00:00
|
|
|
ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromTextSample(
|
|
|
|
kStreamIndex,
|
2018-06-06 18:41:21 +00:00
|
|
|
GetTextSample(kNoId, kSampleBStart, kSampleBEnd, kNoPayload))));
|
2018-03-23 01:33:01 +00:00
|
|
|
ASSERT_OK(Input(kInput)->FlushAllDownstreams());
|
2017-09-18 15:43:21 +00:00
|
|
|
}
|
|
|
|
|
2018-06-06 18:41:21 +00:00
|
|
|
// Verify that a segment will get outputted even if there are no samples
|
|
|
|
// overlapping with it.
|
|
|
|
//
|
|
|
|
// Segment Duration = 100 MS
|
|
|
|
//
|
|
|
|
// TIME (ms):0 5 1 1 2 2 3
|
|
|
|
// 0 0 5 0 5 0
|
|
|
|
// 0 0 0 0 0
|
2018-06-21 18:31:09 +00:00
|
|
|
// SAMPLES :[--A--]
|
|
|
|
// [--B--]
|
2018-06-06 18:41:21 +00:00
|
|
|
// SEGMENTS : ^ ^ ^
|
|
|
|
//
|
2018-03-23 22:28:30 +00:00
|
|
|
TEST_F(TextChunkerTest, OutputsEmptySegments) {
|
2018-06-06 18:41:21 +00:00
|
|
|
const double kSegmentDurationSec = 0.1;
|
|
|
|
const int64_t kSegmentDurationMs = 100;
|
|
|
|
|
2018-03-23 01:33:01 +00:00
|
|
|
const int64_t kSegment0Start = 0;
|
2018-06-06 18:41:21 +00:00
|
|
|
const int64_t kSegment1Start = 100;
|
|
|
|
const int64_t kSegment2Start = 200;
|
2018-03-23 01:33:01 +00:00
|
|
|
|
2018-06-21 18:31:09 +00:00
|
|
|
const int64_t kSampleAStart = 0;
|
|
|
|
const int64_t kSampleAEnd = 50;
|
2018-03-23 01:33:01 +00:00
|
|
|
|
2018-06-21 18:31:09 +00:00
|
|
|
const int64_t kSampleBStart = 200;
|
|
|
|
const int64_t kSampleBEnd = 250;
|
2018-03-23 01:33:01 +00:00
|
|
|
|
2018-06-06 18:41:21 +00:00
|
|
|
Init(kSegmentDurationSec);
|
2018-02-05 19:16:00 +00:00
|
|
|
|
2017-09-18 15:43:21 +00:00
|
|
|
{
|
|
|
|
testing::InSequence s;
|
|
|
|
|
2018-05-25 17:41:02 +00:00
|
|
|
EXPECT_CALL(*Output(kOutput),
|
|
|
|
OnProcess(IsStreamInfo(kStreamIndex, _, _, _)));
|
2017-09-18 15:43:21 +00:00
|
|
|
|
|
|
|
// Segment One
|
2018-03-23 01:33:01 +00:00
|
|
|
EXPECT_CALL(*Output(kOutput),
|
2018-05-25 17:41:02 +00:00
|
|
|
OnProcess(IsTextSample(_, kNoId, kSampleAStart, kSampleAEnd,
|
2018-03-23 01:33:01 +00:00
|
|
|
kNoSettings, kNoPayload)));
|
2018-06-06 18:41:21 +00:00
|
|
|
EXPECT_CALL(*Output(kOutput),
|
|
|
|
OnProcess(IsSegmentInfo(kStreamIndex, kSegment0Start,
|
|
|
|
kSegmentDurationMs, !kSubSegment,
|
|
|
|
!kEncrypted)));
|
2017-09-18 15:43:21 +00:00
|
|
|
|
2018-02-05 19:16:00 +00:00
|
|
|
// Segment Two (empty segment)
|
2018-06-06 18:41:21 +00:00
|
|
|
EXPECT_CALL(*Output(kOutput),
|
|
|
|
OnProcess(IsSegmentInfo(kStreamIndex, kSegment1Start,
|
|
|
|
kSegmentDurationMs, !kSubSegment,
|
|
|
|
!kEncrypted)));
|
2018-02-05 19:16:00 +00:00
|
|
|
|
|
|
|
// Segment Three
|
2018-03-23 01:33:01 +00:00
|
|
|
EXPECT_CALL(*Output(kOutput),
|
2018-05-25 17:41:02 +00:00
|
|
|
OnProcess(IsTextSample(_, kNoId, kSampleBStart, kSampleBEnd,
|
2018-03-23 01:33:01 +00:00
|
|
|
kNoSettings, kNoPayload)));
|
2018-06-06 18:41:21 +00:00
|
|
|
EXPECT_CALL(*Output(kOutput),
|
|
|
|
OnProcess(IsSegmentInfo(kStreamIndex, kSegment2Start,
|
|
|
|
kSegmentDurationMs, !kSubSegment,
|
|
|
|
!kEncrypted)));
|
2017-09-18 15:43:21 +00:00
|
|
|
|
2018-03-23 01:33:01 +00:00
|
|
|
EXPECT_CALL(*Output(kOutput), OnFlush(kStreamIndex));
|
2017-09-18 15:43:21 +00:00
|
|
|
}
|
|
|
|
|
2018-06-06 18:41:21 +00:00
|
|
|
ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromStreamInfo(
|
|
|
|
kStreamIndex, GetTextStreamInfo(kMsTimeScale))));
|
2018-03-23 01:33:01 +00:00
|
|
|
ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromTextSample(
|
|
|
|
kStreamIndex,
|
2018-06-06 18:41:21 +00:00
|
|
|
GetTextSample(kNoId, kSampleAStart, kSampleAEnd, kNoPayload))));
|
2018-03-23 01:33:01 +00:00
|
|
|
ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromTextSample(
|
|
|
|
kStreamIndex,
|
2018-06-06 18:41:21 +00:00
|
|
|
GetTextSample(kNoId, kSampleBStart, kSampleBEnd, kNoPayload))));
|
2018-03-23 01:33:01 +00:00
|
|
|
ASSERT_OK(Input(kInput)->FlushAllDownstreams());
|
2017-09-18 15:43:21 +00:00
|
|
|
}
|
|
|
|
|
2018-06-06 18:41:21 +00:00
|
|
|
// Verify that samples that overlap multiple samples get dispatch in all
|
|
|
|
// segments.
|
|
|
|
//
|
|
|
|
// Segment Duration = 100 MS
|
|
|
|
//
|
|
|
|
// TIME (ms):0 5 1 1
|
|
|
|
// 0 0 5
|
|
|
|
// 0 0
|
2018-06-21 18:31:09 +00:00
|
|
|
// SAMPLES :[--------A--------]
|
2018-06-06 18:41:21 +00:00
|
|
|
// SEGMENTS : ^
|
|
|
|
//
|
2018-03-23 01:33:01 +00:00
|
|
|
TEST_F(TextChunkerTest, SampleCrossesSegments) {
|
2018-06-06 18:41:21 +00:00
|
|
|
const double kSegmentDurationSec = 0.1;
|
|
|
|
const int64_t kSegmentDurationMs = 100;
|
|
|
|
|
2018-03-23 01:33:01 +00:00
|
|
|
const int64_t kSegment0Start = 0;
|
2018-06-06 18:41:21 +00:00
|
|
|
const int64_t kSegment1Start = 100;
|
2018-03-23 01:33:01 +00:00
|
|
|
|
2018-06-21 18:31:09 +00:00
|
|
|
const int64_t kSampleAStart = 0;
|
2018-06-06 18:41:21 +00:00
|
|
|
const int64_t kSampleAEnd = 150;
|
2018-03-23 01:33:01 +00:00
|
|
|
|
2018-06-06 18:41:21 +00:00
|
|
|
Init(kSegmentDurationSec);
|
2017-09-18 15:43:21 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
testing::InSequence s;
|
|
|
|
|
2018-05-25 17:41:02 +00:00
|
|
|
EXPECT_CALL(*Output(kOutput),
|
|
|
|
OnProcess(IsStreamInfo(kStreamIndex, _, _, _)));
|
2017-09-18 15:43:21 +00:00
|
|
|
|
|
|
|
// Segment One
|
2018-03-23 01:33:01 +00:00
|
|
|
EXPECT_CALL(*Output(kOutput),
|
2018-05-25 17:41:02 +00:00
|
|
|
OnProcess(IsTextSample(_, kNoId, kSampleAStart, kSampleAEnd,
|
2018-03-23 01:33:01 +00:00
|
|
|
kNoSettings, kNoPayload)));
|
2018-06-06 18:41:21 +00:00
|
|
|
EXPECT_CALL(*Output(kOutput),
|
|
|
|
OnProcess(IsSegmentInfo(kStreamIndex, kSegment0Start,
|
|
|
|
kSegmentDurationMs, !kSubSegment,
|
|
|
|
!kEncrypted)));
|
2018-01-02 21:58:47 +00:00
|
|
|
|
|
|
|
// Segment Two
|
2018-03-23 01:33:01 +00:00
|
|
|
EXPECT_CALL(*Output(kOutput),
|
2018-05-25 17:41:02 +00:00
|
|
|
OnProcess(IsTextSample(_, kNoId, kSampleAStart, kSampleAEnd,
|
2018-03-23 01:33:01 +00:00
|
|
|
kNoSettings, kNoPayload)));
|
2018-06-06 18:41:21 +00:00
|
|
|
EXPECT_CALL(*Output(kOutput),
|
|
|
|
OnProcess(IsSegmentInfo(kStreamIndex, kSegment1Start,
|
|
|
|
kSegmentDurationMs, !kSubSegment,
|
|
|
|
!kEncrypted)));
|
2017-09-18 15:43:21 +00:00
|
|
|
|
2018-03-23 01:33:01 +00:00
|
|
|
EXPECT_CALL(*Output(kOutput), OnFlush(kStreamIndex));
|
2017-09-18 15:43:21 +00:00
|
|
|
}
|
|
|
|
|
2018-06-06 18:41:21 +00:00
|
|
|
ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromStreamInfo(
|
2018-06-06 18:41:21 +00:00
|
|
|
kStreamIndex, GetTextStreamInfo(kTimescaleMs))));
|
2018-03-23 01:33:01 +00:00
|
|
|
ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromTextSample(
|
|
|
|
kStreamIndex,
|
2018-06-06 18:41:21 +00:00
|
|
|
GetTextSample(kNoId, kSampleAStart, kSampleAEnd, kNoPayload))));
|
2018-03-23 01:33:01 +00:00
|
|
|
ASSERT_OK(Input(kInput)->FlushAllDownstreams());
|
2017-09-18 15:43:21 +00:00
|
|
|
}
|
|
|
|
|
2018-06-06 18:41:21 +00:00
|
|
|
// Verify that samples that overlap multiple samples get dispatch in all
|
|
|
|
// segments, even if different samples elapse different number of segments.
|
|
|
|
//
|
|
|
|
// Segment Duration = 100 MS
|
|
|
|
//
|
|
|
|
// TIME (ms):0 5 1 1 2 2 3
|
|
|
|
// 0 0 5 0 5 0
|
|
|
|
// 0 0 0 0 0
|
2018-06-21 18:31:09 +00:00
|
|
|
// SAMPLES :[--------A--------]
|
|
|
|
// [--------B--------]
|
|
|
|
// [-----------------C-----------]
|
2018-06-06 18:41:21 +00:00
|
|
|
// SEGMENTS : ^ ^ ^
|
|
|
|
//
|
2018-03-23 01:33:01 +00:00
|
|
|
TEST_F(TextChunkerTest, PreservesOrder) {
|
2018-06-06 18:41:21 +00:00
|
|
|
const double kSegmentDurationSec = 0.1;
|
|
|
|
const int64_t kSegmentDurationMs = 100;
|
2018-03-23 01:33:01 +00:00
|
|
|
|
|
|
|
const int64_t kSegment0Start = 0;
|
2018-06-06 18:41:21 +00:00
|
|
|
const int64_t kSegment1Start = 100;
|
|
|
|
const int64_t kSegment2Start = 200;
|
2018-03-23 01:33:01 +00:00
|
|
|
|
2018-06-21 18:31:09 +00:00
|
|
|
const int64_t kSampleAStart = 0;
|
2018-06-06 18:41:21 +00:00
|
|
|
const int64_t kSampleAEnd = 150;
|
2018-02-02 22:28:10 +00:00
|
|
|
|
2018-06-21 18:31:09 +00:00
|
|
|
const int64_t kSampleBStart = 0;
|
2018-06-06 18:41:21 +00:00
|
|
|
const int64_t kSampleBEnd = 150;
|
2018-02-02 22:28:10 +00:00
|
|
|
|
2018-06-21 18:31:09 +00:00
|
|
|
const int64_t kSampleCStart = 0;
|
2018-06-06 18:41:21 +00:00
|
|
|
const int64_t kSampleCEnd = 250;
|
2018-02-02 22:28:10 +00:00
|
|
|
|
2018-06-06 18:41:21 +00:00
|
|
|
const char* kSampleAId = "sample 0";
|
|
|
|
const char* kSampleBId = "sample 1";
|
|
|
|
const char* kSampleCId = "sample 2";
|
2018-02-02 22:28:10 +00:00
|
|
|
|
2018-06-06 18:41:21 +00:00
|
|
|
Init(kSegmentDurationSec);
|
2018-02-02 22:28:10 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
testing::InSequence s;
|
|
|
|
|
2018-05-25 17:41:02 +00:00
|
|
|
EXPECT_CALL(*Output(kOutput),
|
|
|
|
OnProcess(IsStreamInfo(kStreamIndex, _, _, _)));
|
2018-02-02 22:28:10 +00:00
|
|
|
|
|
|
|
// Segment One
|
|
|
|
EXPECT_CALL(*Output(kOutput),
|
2018-05-25 17:41:02 +00:00
|
|
|
OnProcess(IsTextSample(_, kSampleAId, kSampleAStart,
|
|
|
|
kSampleAEnd, kNoSettings, kNoPayload)));
|
2018-03-23 01:33:01 +00:00
|
|
|
EXPECT_CALL(*Output(kOutput),
|
2018-05-25 17:41:02 +00:00
|
|
|
OnProcess(IsTextSample(_, kSampleBId, kSampleBStart,
|
|
|
|
kSampleBEnd, kNoSettings, kNoPayload)));
|
2018-03-23 01:33:01 +00:00
|
|
|
EXPECT_CALL(*Output(kOutput),
|
2018-05-25 17:41:02 +00:00
|
|
|
OnProcess(IsTextSample(_, kSampleCId, kSampleCStart,
|
|
|
|
kSampleCEnd, kNoSettings, kNoPayload)));
|
2018-06-06 18:41:21 +00:00
|
|
|
EXPECT_CALL(*Output(kOutput),
|
|
|
|
OnProcess(IsSegmentInfo(kStreamIndex, kSegment0Start,
|
|
|
|
kSegmentDurationMs, !kSubSegment,
|
|
|
|
!kEncrypted)));
|
2018-03-23 01:33:01 +00:00
|
|
|
|
|
|
|
// Segment Two
|
|
|
|
EXPECT_CALL(*Output(kOutput),
|
2018-05-25 17:41:02 +00:00
|
|
|
OnProcess(IsTextSample(_, kSampleAId, kSampleAStart,
|
|
|
|
kSampleAEnd, kNoSettings, kNoPayload)));
|
2018-02-02 22:28:10 +00:00
|
|
|
EXPECT_CALL(*Output(kOutput),
|
2018-05-25 17:41:02 +00:00
|
|
|
OnProcess(IsTextSample(_, kSampleBId, kSampleBStart,
|
|
|
|
kSampleBEnd, kNoSettings, kNoPayload)));
|
2018-02-02 22:28:10 +00:00
|
|
|
EXPECT_CALL(*Output(kOutput),
|
2018-05-25 17:41:02 +00:00
|
|
|
OnProcess(IsTextSample(_, kSampleCId, kSampleCStart,
|
|
|
|
kSampleCEnd, kNoSettings, kNoPayload)));
|
2018-06-06 18:41:21 +00:00
|
|
|
EXPECT_CALL(*Output(kOutput),
|
|
|
|
OnProcess(IsSegmentInfo(kStreamIndex, kSegment1Start,
|
|
|
|
kSegmentDurationMs, !kSubSegment,
|
|
|
|
!kEncrypted)));
|
2018-02-02 22:28:10 +00:00
|
|
|
|
|
|
|
// Segment Two
|
|
|
|
EXPECT_CALL(*Output(kOutput),
|
2018-05-25 17:41:02 +00:00
|
|
|
OnProcess(IsTextSample(_, kSampleCId, kSampleCStart,
|
|
|
|
kSampleCEnd, kNoSettings, kNoPayload)));
|
2018-06-06 18:41:21 +00:00
|
|
|
EXPECT_CALL(*Output(kOutput),
|
|
|
|
OnProcess(IsSegmentInfo(kStreamIndex, kSegment2Start,
|
|
|
|
kSegmentDurationMs, !kSubSegment,
|
|
|
|
!kEncrypted)));
|
2018-03-23 01:33:01 +00:00
|
|
|
|
|
|
|
EXPECT_CALL(*Output(kOutput), OnFlush(kStreamIndex));
|
|
|
|
}
|
|
|
|
|
2018-06-06 18:41:21 +00:00
|
|
|
ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromStreamInfo(
|
|
|
|
kStreamIndex, GetTextStreamInfo(kMsTimeScale))));
|
2018-03-23 01:33:01 +00:00
|
|
|
ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromTextSample(
|
|
|
|
kStreamIndex,
|
2018-06-06 18:41:21 +00:00
|
|
|
GetTextSample(kSampleAId, kSampleAStart, kSampleAEnd, kNoPayload))));
|
2018-03-23 01:33:01 +00:00
|
|
|
ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromTextSample(
|
|
|
|
kStreamIndex,
|
2018-06-06 18:41:21 +00:00
|
|
|
GetTextSample(kSampleBId, kSampleBStart, kSampleBEnd, kNoPayload))));
|
2018-03-23 01:33:01 +00:00
|
|
|
ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromTextSample(
|
|
|
|
kStreamIndex,
|
2018-06-06 18:41:21 +00:00
|
|
|
GetTextSample(kSampleCId, kSampleCStart, kSampleCEnd, kNoPayload))));
|
2018-03-23 01:33:01 +00:00
|
|
|
ASSERT_OK(Input(kInput)->FlushAllDownstreams());
|
|
|
|
}
|
|
|
|
|
2018-06-06 18:41:21 +00:00
|
|
|
// Check that when samples overlap/contain other samples, that they still
|
|
|
|
// get outputted in the correct segments.
|
|
|
|
//
|
|
|
|
// Segment Duration = 50 MS
|
|
|
|
//
|
|
|
|
// TIME (ms):0 5 1 1 2 2
|
|
|
|
// 0 0 5 0 5
|
|
|
|
// 0 0 0 0
|
2018-06-21 18:31:09 +00:00
|
|
|
// SAMPLES :[--------------A--------------]
|
2018-06-06 18:41:21 +00:00
|
|
|
// [-----B------]
|
|
|
|
// SEGMENTS : ^ ^ ^ ^ ^
|
|
|
|
//
|
2018-03-23 01:33:01 +00:00
|
|
|
TEST_F(TextChunkerTest, NestedSamples) {
|
2018-06-06 18:41:21 +00:00
|
|
|
const double kSegmentDurationSec = 0.05;
|
|
|
|
const int64_t kSegmentDurationMs = 50;
|
2018-03-23 01:33:01 +00:00
|
|
|
|
2018-06-21 18:31:09 +00:00
|
|
|
const int64_t kSampleAStart = 0;
|
|
|
|
const int64_t kSampleAEnd = 250;
|
2018-03-23 01:33:01 +00:00
|
|
|
|
2018-06-06 18:41:21 +00:00
|
|
|
const int64_t kSampleBStart = 75;
|
|
|
|
const int64_t kSampleBEnd = 175;
|
2018-03-23 01:33:01 +00:00
|
|
|
|
|
|
|
const int64_t kSegment0Start = 0;
|
2018-06-06 18:41:21 +00:00
|
|
|
const int64_t kSegment1Start = 50;
|
|
|
|
const int64_t kSegment2Start = 100;
|
|
|
|
const int64_t kSegment3Start = 150;
|
|
|
|
const int64_t kSegment4Start = 200;
|
2018-03-23 01:33:01 +00:00
|
|
|
|
2018-06-06 18:41:21 +00:00
|
|
|
Init(kSegmentDurationSec);
|
2018-03-23 01:33:01 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
testing::InSequence s;
|
|
|
|
|
2018-05-25 17:41:02 +00:00
|
|
|
EXPECT_CALL(*Output(kOutput),
|
|
|
|
OnProcess(IsStreamInfo(kStreamIndex, _, _, _)));
|
2018-03-23 01:33:01 +00:00
|
|
|
|
|
|
|
// Segment 0
|
|
|
|
EXPECT_CALL(*Output(kOutput),
|
2018-05-25 17:41:02 +00:00
|
|
|
OnProcess(IsTextSample(_, kNoId, kSampleAStart, kSampleAEnd,
|
2018-03-23 01:33:01 +00:00
|
|
|
kNoSettings, kNoPayload)));
|
2018-06-06 18:41:21 +00:00
|
|
|
EXPECT_CALL(*Output(kOutput),
|
|
|
|
OnProcess(IsSegmentInfo(kStreamIndex, kSegment0Start,
|
|
|
|
kSegmentDurationMs, !kSubSegment,
|
|
|
|
!kEncrypted)));
|
2018-02-02 22:28:10 +00:00
|
|
|
|
2018-03-23 01:33:01 +00:00
|
|
|
// Segment 1
|
|
|
|
EXPECT_CALL(*Output(kOutput),
|
2018-05-25 17:41:02 +00:00
|
|
|
OnProcess(IsTextSample(_, kNoId, kSampleAStart, kSampleAEnd,
|
2018-03-23 01:33:01 +00:00
|
|
|
kNoSettings, kNoPayload)));
|
|
|
|
EXPECT_CALL(*Output(kOutput),
|
2018-05-25 17:41:02 +00:00
|
|
|
OnProcess(IsTextSample(_, kNoId, kSampleBStart, kSampleBEnd,
|
2018-03-23 01:33:01 +00:00
|
|
|
kNoSettings, kNoPayload)));
|
2018-06-06 18:41:21 +00:00
|
|
|
EXPECT_CALL(*Output(kOutput),
|
|
|
|
OnProcess(IsSegmentInfo(kStreamIndex, kSegment1Start,
|
|
|
|
kSegmentDurationMs, !kSubSegment,
|
|
|
|
!kEncrypted)));
|
2018-03-23 01:33:01 +00:00
|
|
|
|
|
|
|
// Segment 2
|
|
|
|
EXPECT_CALL(*Output(kOutput),
|
2018-05-25 17:41:02 +00:00
|
|
|
OnProcess(IsTextSample(_, kNoId, kSampleAStart, kSampleAEnd,
|
2018-03-23 01:33:01 +00:00
|
|
|
kNoSettings, kNoPayload)));
|
|
|
|
EXPECT_CALL(*Output(kOutput),
|
2018-05-25 17:41:02 +00:00
|
|
|
OnProcess(IsTextSample(_, kNoId, kSampleBStart, kSampleBEnd,
|
2018-03-23 01:33:01 +00:00
|
|
|
kNoSettings, kNoPayload)));
|
2018-06-06 18:41:21 +00:00
|
|
|
EXPECT_CALL(*Output(kOutput),
|
|
|
|
OnProcess(IsSegmentInfo(kStreamIndex, kSegment2Start,
|
|
|
|
kSegmentDurationMs, !kSubSegment,
|
|
|
|
!kEncrypted)));
|
2018-03-23 01:33:01 +00:00
|
|
|
|
|
|
|
// Segment 3
|
|
|
|
EXPECT_CALL(*Output(kOutput),
|
2018-05-25 17:41:02 +00:00
|
|
|
OnProcess(IsTextSample(_, kNoId, kSampleAStart, kSampleAEnd,
|
2018-03-23 01:33:01 +00:00
|
|
|
kNoSettings, kNoPayload)));
|
|
|
|
EXPECT_CALL(*Output(kOutput),
|
2018-05-25 17:41:02 +00:00
|
|
|
OnProcess(IsTextSample(_, kNoId, kSampleBStart, kSampleBEnd,
|
2018-03-23 01:33:01 +00:00
|
|
|
kNoSettings, kNoPayload)));
|
2018-06-06 18:41:21 +00:00
|
|
|
EXPECT_CALL(*Output(kOutput),
|
|
|
|
OnProcess(IsSegmentInfo(kStreamIndex, kSegment3Start,
|
|
|
|
kSegmentDurationMs, !kSubSegment,
|
|
|
|
!kEncrypted)));
|
2018-03-23 01:33:01 +00:00
|
|
|
|
|
|
|
// Segment 4
|
|
|
|
EXPECT_CALL(*Output(kOutput),
|
2018-05-25 17:41:02 +00:00
|
|
|
OnProcess(IsTextSample(_, kNoId, kSampleAStart, kSampleAEnd,
|
2018-03-23 01:33:01 +00:00
|
|
|
kNoSettings, kNoPayload)));
|
2018-06-06 18:41:21 +00:00
|
|
|
EXPECT_CALL(*Output(kOutput),
|
|
|
|
OnProcess(IsSegmentInfo(kStreamIndex, kSegment4Start,
|
|
|
|
kSegmentDurationMs, !kSubSegment,
|
|
|
|
!kEncrypted)));
|
2018-03-23 01:33:01 +00:00
|
|
|
|
|
|
|
EXPECT_CALL(*Output(kOutput), OnFlush(kStreamIndex));
|
2018-02-02 22:28:10 +00:00
|
|
|
}
|
|
|
|
|
2018-06-06 18:41:21 +00:00
|
|
|
ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromStreamInfo(
|
|
|
|
kStreamIndex, GetTextStreamInfo(kMsTimeScale))));
|
2018-02-02 22:28:10 +00:00
|
|
|
ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromTextSample(
|
2018-03-23 01:33:01 +00:00
|
|
|
kStreamIndex,
|
2018-06-06 18:41:21 +00:00
|
|
|
GetTextSample(kNoId, kSampleAStart, kSampleAEnd, kNoPayload))));
|
2018-02-02 22:28:10 +00:00
|
|
|
ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromTextSample(
|
2018-03-23 01:33:01 +00:00
|
|
|
kStreamIndex,
|
2018-06-06 18:41:21 +00:00
|
|
|
GetTextSample(kNoId, kSampleBStart, kSampleBEnd, kNoPayload))));
|
2018-03-23 01:33:01 +00:00
|
|
|
ASSERT_OK(Input(kInput)->FlushAllDownstreams());
|
|
|
|
}
|
|
|
|
|
2018-06-06 18:41:21 +00:00
|
|
|
// Make sure that a sample that extends multiple segments is dropped when
|
|
|
|
// it no longer overlaps with a later segment.
|
|
|
|
//
|
|
|
|
// Segment Duration = 100 MS
|
|
|
|
//
|
|
|
|
// TIME (ms):0 5 1 1 2 2 3
|
|
|
|
// 0 0 5 0 5 0
|
|
|
|
// 0 0 0 0 0
|
2018-06-21 18:31:09 +00:00
|
|
|
// SAMPLES :[-----------A-----------]
|
2018-06-06 18:41:21 +00:00
|
|
|
// [--B--]
|
|
|
|
// SEGMENTS : ^ ^ ^
|
|
|
|
//
|
2018-03-23 01:33:01 +00:00
|
|
|
TEST_F(TextChunkerTest, SecondSampleStartsAfterMultiSegmentSampleEnds) {
|
2018-06-06 18:41:21 +00:00
|
|
|
const double kSegmentDurationSec = 0.1;
|
|
|
|
const int64_t kSegmentDurationMs = 100;
|
|
|
|
|
2018-03-23 01:33:01 +00:00
|
|
|
const int64_t kSegment0Start = 0;
|
2018-06-06 18:41:21 +00:00
|
|
|
const int64_t kSegment1Start = 100;
|
|
|
|
const int64_t kSegment2Start = 200;
|
2018-03-23 01:33:01 +00:00
|
|
|
|
2018-06-21 18:31:09 +00:00
|
|
|
const int64_t kSampleAStart = 0;
|
2018-06-06 18:41:21 +00:00
|
|
|
const int64_t kSampleAEnd = 200;
|
2018-03-23 01:33:01 +00:00
|
|
|
|
2018-06-06 18:41:21 +00:00
|
|
|
const int64_t kSampleBStart = 200;
|
|
|
|
const int64_t kSampleBEnd = 250;
|
2018-03-23 01:33:01 +00:00
|
|
|
|
2018-06-06 18:41:21 +00:00
|
|
|
Init(kSegmentDurationSec);
|
2018-03-23 01:33:01 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
testing::InSequence s;
|
|
|
|
|
2018-05-25 17:41:02 +00:00
|
|
|
EXPECT_CALL(*Output(kOutput),
|
|
|
|
OnProcess(IsStreamInfo(kStreamIndex, _, _, _)));
|
2018-03-23 01:33:01 +00:00
|
|
|
|
|
|
|
// Segment One
|
|
|
|
EXPECT_CALL(*Output(kOutput),
|
2018-05-25 17:41:02 +00:00
|
|
|
OnProcess(IsTextSample(_, kNoId, kSampleAStart, kSampleAEnd,
|
2018-03-23 01:33:01 +00:00
|
|
|
kNoSettings, kNoPayload)));
|
2018-06-06 18:41:21 +00:00
|
|
|
EXPECT_CALL(*Output(kOutput),
|
|
|
|
OnProcess(IsSegmentInfo(kStreamIndex, kSegment0Start,
|
|
|
|
kSegmentDurationMs, !kSubSegment,
|
|
|
|
!kEncrypted)));
|
2018-03-23 01:33:01 +00:00
|
|
|
|
|
|
|
// Segment Two
|
|
|
|
EXPECT_CALL(*Output(kOutput),
|
2018-05-25 17:41:02 +00:00
|
|
|
OnProcess(IsTextSample(_, kNoId, kSampleAStart, kSampleAEnd,
|
2018-03-23 01:33:01 +00:00
|
|
|
kNoSettings, kNoPayload)));
|
2018-06-06 18:41:21 +00:00
|
|
|
EXPECT_CALL(*Output(kOutput),
|
|
|
|
OnProcess(IsSegmentInfo(kStreamIndex, kSegment1Start,
|
|
|
|
kSegmentDurationMs, !kSubSegment,
|
|
|
|
!kEncrypted)));
|
2018-03-23 01:33:01 +00:00
|
|
|
|
|
|
|
// Segment Three
|
|
|
|
EXPECT_CALL(*Output(kOutput),
|
2018-05-25 17:41:02 +00:00
|
|
|
OnProcess(IsTextSample(_, kNoId, kSampleBStart, kSampleBEnd,
|
2018-03-23 01:33:01 +00:00
|
|
|
kNoSettings, kNoPayload)));
|
2018-06-06 18:41:21 +00:00
|
|
|
EXPECT_CALL(*Output(kOutput),
|
|
|
|
OnProcess(IsSegmentInfo(kStreamIndex, kSegment2Start,
|
|
|
|
kSegmentDurationMs, !kSubSegment,
|
|
|
|
!kEncrypted)));
|
2018-03-23 01:33:01 +00:00
|
|
|
|
|
|
|
EXPECT_CALL(*Output(kOutput), OnFlush(kStreamIndex));
|
|
|
|
}
|
|
|
|
|
2018-06-06 18:41:21 +00:00
|
|
|
ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromStreamInfo(
|
2018-06-06 18:41:21 +00:00
|
|
|
kStreamIndex, GetTextStreamInfo(kTimescaleMs))));
|
2018-03-23 01:33:01 +00:00
|
|
|
ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromTextSample(
|
|
|
|
kStreamIndex,
|
2018-06-06 18:41:21 +00:00
|
|
|
GetTextSample(kNoId, kSampleAStart, kSampleAEnd, kNoPayload))));
|
2018-02-02 22:28:10 +00:00
|
|
|
ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromTextSample(
|
2018-03-23 01:33:01 +00:00
|
|
|
kStreamIndex,
|
2018-06-06 18:41:21 +00:00
|
|
|
GetTextSample(kNoId, kSampleBStart, kSampleBEnd, kNoPayload))));
|
2018-03-23 01:33:01 +00:00
|
|
|
ASSERT_OK(Input(kInput)->FlushAllDownstreams());
|
|
|
|
}
|
|
|
|
|
2018-06-06 18:41:21 +00:00
|
|
|
// Check that segments will be injected when a cue event comes down the
|
|
|
|
// pipeline and that the segment duration will get reset after the cues
|
|
|
|
// are dispatched.
|
|
|
|
//
|
|
|
|
// Segment Duration = 300 MS
|
|
|
|
//
|
|
|
|
// TIME (ms):0 5 1 1 2 2 3 3 4 5
|
|
|
|
// 0 0 5 0 5 0 5 5 0
|
|
|
|
// 0 0 0 0 0 0 0 0
|
2018-06-21 18:31:09 +00:00
|
|
|
// SAMPLES :[--------------A--------------]
|
2018-06-06 18:41:21 +00:00
|
|
|
// CUES : ^ ^
|
|
|
|
// SEGMENTS : ^ ^ ^
|
|
|
|
//
|
2018-03-23 01:33:01 +00:00
|
|
|
TEST_F(TextChunkerTest, SampleSpanningMultipleCues) {
|
2018-06-06 18:41:21 +00:00
|
|
|
const double kSegmentDurationSec = 0.3;
|
|
|
|
const int64_t kSegmentDurationMs = 300;
|
2018-03-23 01:33:01 +00:00
|
|
|
|
2018-06-21 18:31:09 +00:00
|
|
|
const int64_t kSampleAStart = 0;
|
2018-06-06 18:41:21 +00:00
|
|
|
const int64_t kSampleAEnd = 250;
|
2018-03-23 01:33:01 +00:00
|
|
|
|
2018-06-06 18:41:21 +00:00
|
|
|
const double kC0 = 0.1;
|
|
|
|
const double kC1 = 0.2;
|
2018-03-23 01:33:01 +00:00
|
|
|
|
|
|
|
const int64_t kSegment0Start = 0;
|
2018-06-06 18:41:21 +00:00
|
|
|
const int64_t kSegment1Start = 100;
|
|
|
|
const int64_t kSegment2Start = 200;
|
|
|
|
;
|
2018-03-23 01:33:01 +00:00
|
|
|
|
2018-06-06 18:41:21 +00:00
|
|
|
const double kSegment0StartLength = 100;
|
|
|
|
const double kSegment1StartLength = 100;
|
|
|
|
|
|
|
|
Init(kSegmentDurationSec);
|
2018-03-23 01:33:01 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
testing::InSequence s;
|
2018-02-02 22:28:10 +00:00
|
|
|
|
2018-05-25 17:41:02 +00:00
|
|
|
EXPECT_CALL(*Output(kOutput),
|
|
|
|
OnProcess(IsStreamInfo(kStreamIndex, _, _, _)));
|
2018-03-23 01:33:01 +00:00
|
|
|
|
|
|
|
// Segment 0 and Cue 0
|
|
|
|
EXPECT_CALL(*Output(kOutput),
|
2018-05-25 17:41:02 +00:00
|
|
|
OnProcess(IsTextSample(_, kNoId, kSampleAStart, kSampleAEnd,
|
2018-03-23 01:33:01 +00:00
|
|
|
kNoSettings, kNoPayload)));
|
|
|
|
EXPECT_CALL(*Output(kOutput),
|
2018-06-06 18:41:21 +00:00
|
|
|
OnProcess(IsSegmentInfo(kStreamIndex, kSegment0Start,
|
|
|
|
kSegment0StartLength, !kSubSegment,
|
|
|
|
!kEncrypted)));
|
|
|
|
EXPECT_CALL(*Output(kOutput), OnProcess(IsCueEvent(kStreamIndex, kC0)));
|
2018-03-23 01:33:01 +00:00
|
|
|
|
|
|
|
// Segment 1 and Cue 1
|
|
|
|
EXPECT_CALL(*Output(kOutput),
|
2018-05-25 17:41:02 +00:00
|
|
|
OnProcess(IsTextSample(_, kNoId, kSampleAStart, kSampleAEnd,
|
2018-03-23 01:33:01 +00:00
|
|
|
kNoSettings, kNoPayload)));
|
|
|
|
EXPECT_CALL(*Output(kOutput),
|
2018-06-06 18:41:21 +00:00
|
|
|
OnProcess(IsSegmentInfo(kStreamIndex, kSegment1Start,
|
|
|
|
kSegment1StartLength, !kSubSegment,
|
|
|
|
!kEncrypted)));
|
|
|
|
EXPECT_CALL(*Output(kOutput), OnProcess(IsCueEvent(kStreamIndex, kC1)));
|
2018-03-23 01:33:01 +00:00
|
|
|
|
|
|
|
// Segment 2
|
|
|
|
EXPECT_CALL(*Output(kOutput),
|
2018-05-25 17:41:02 +00:00
|
|
|
OnProcess(IsTextSample(_, kNoId, kSampleAStart, kSampleAEnd,
|
2018-03-23 01:33:01 +00:00
|
|
|
kNoSettings, kNoPayload)));
|
2018-06-06 18:41:21 +00:00
|
|
|
EXPECT_CALL(*Output(kOutput),
|
|
|
|
OnProcess(IsSegmentInfo(kStreamIndex, kSegment2Start,
|
|
|
|
kSegmentDurationMs, !kSubSegment,
|
|
|
|
!kEncrypted)));
|
2018-03-23 01:33:01 +00:00
|
|
|
}
|
|
|
|
|
2018-06-06 18:41:21 +00:00
|
|
|
ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromStreamInfo(
|
2018-06-06 18:41:21 +00:00
|
|
|
kStreamIndex, GetTextStreamInfo(kTimescaleMs))));
|
2018-03-23 01:33:01 +00:00
|
|
|
ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromTextSample(
|
|
|
|
kStreamIndex,
|
2018-06-06 18:41:21 +00:00
|
|
|
GetTextSample(kNoId, kSampleAStart, kSampleAEnd, kNoPayload))));
|
2018-03-23 01:33:01 +00:00
|
|
|
ASSERT_OK(Input(kInput)->Dispatch(
|
2018-06-06 18:41:21 +00:00
|
|
|
StreamData::FromCueEvent(kStreamIndex, GetCueEvent(kC0))));
|
2018-03-23 01:33:01 +00:00
|
|
|
ASSERT_OK(Input(kInput)->Dispatch(
|
2018-06-06 18:41:21 +00:00
|
|
|
StreamData::FromCueEvent(kStreamIndex, GetCueEvent(kC1))));
|
2018-03-23 01:33:01 +00:00
|
|
|
ASSERT_OK(Input(kInput)->FlushAllDownstreams());
|
2018-02-02 22:28:10 +00:00
|
|
|
}
|
|
|
|
|
2017-09-18 15:43:21 +00:00
|
|
|
} // namespace media
|
|
|
|
} // namespace shaka
|