Make Test Util 'GetTextStreamInfo' require Time Scale
Make the text stream info factory method in media_handler_test_base require the caller to specify the time scale. Issue: #399 Change-Id: Ibdfb183e0aa3f4ff50edf6b58c4e9b966006c6d2
This commit is contained in:
parent
55cc50baa0
commit
30b189cb99
|
@ -194,14 +194,12 @@ std::unique_ptr<SegmentInfo> MediaHandlerTestBase::GetSegmentInfo(
|
|||
return info;
|
||||
}
|
||||
|
||||
std::unique_ptr<StreamInfo> MediaHandlerTestBase::GetTextStreamInfo() const {
|
||||
// Assume that text will use milliseconds.
|
||||
const uint64_t kTimeScaleMs = 1000;
|
||||
|
||||
std::unique_ptr<StreamInfo> MediaHandlerTestBase::GetTextStreamInfo(
|
||||
uint32_t timescale) const {
|
||||
// None of this information is actually used by the text out handler.
|
||||
// The stream info is just needed to signal the start of the stream.
|
||||
return std::unique_ptr<StreamInfo>(
|
||||
new TextStreamInfo(0, kTimeScaleMs, 0, kUnknownCodec, "", "", 0, 0, ""));
|
||||
new TextStreamInfo(0, timescale, 0, kUnknownCodec, "", "", 0, 0, ""));
|
||||
}
|
||||
|
||||
std::unique_ptr<TextSample> MediaHandlerTestBase::GetTextSample(
|
||||
|
|
|
@ -231,7 +231,7 @@ class MediaHandlerTestBase : public ::testing::Test {
|
|||
int64_t duration,
|
||||
bool is_subsegment) const;
|
||||
|
||||
std::unique_ptr<StreamInfo> GetTextStreamInfo() const;
|
||||
std::unique_ptr<StreamInfo> GetTextStreamInfo(uint32_t timescale) const;
|
||||
|
||||
std::unique_ptr<TextSample> GetTextSample(const std::string& id,
|
||||
int64_t start,
|
||||
|
|
|
@ -192,7 +192,7 @@ TEST_F(CueAlignmentHandlerTest, TextInputWithNoCues) {
|
|||
EXPECT_CALL(*Output(kTextStream), OnFlush(kParent));
|
||||
}
|
||||
|
||||
auto stream_info = GetTextStreamInfo();
|
||||
auto stream_info = GetTextStreamInfo(kMsTimeScale);
|
||||
auto sample_0 = GetTextSample(kNoId, kSample0Start, kSample0End, kNoPayload);
|
||||
auto sample_1 = GetTextSample(kNoId, kSample1Start, kSample1End, kNoPayload);
|
||||
auto sample_2 = GetTextSample(kNoId, kSample2Start, kSample2End, kNoPayload);
|
||||
|
@ -277,7 +277,7 @@ TEST_F(CueAlignmentHandlerTest, TextAudioVideoInputWithNoCues) {
|
|||
}
|
||||
|
||||
// Text samples
|
||||
auto text_stream_info = GetTextStreamInfo();
|
||||
auto text_stream_info = GetTextStreamInfo(kMsTimeScale);
|
||||
auto text_sample_0 =
|
||||
GetTextSample(kNoId, kSample0Start, kSample0End, kNoPayload);
|
||||
auto text_sample_1 =
|
||||
|
@ -480,7 +480,7 @@ TEST_F(CueAlignmentHandlerTest, TextInputWithCues) {
|
|||
EXPECT_CALL(*Output(kTextStream), OnFlush(kParent));
|
||||
}
|
||||
|
||||
auto stream_info = GetTextStreamInfo();
|
||||
auto stream_info = GetTextStreamInfo(kMsTimeScale);
|
||||
auto sample_0 = GetTextSample(kNoId, kSample0Start, kSample0End, kNoPayload);
|
||||
auto sample_1 = GetTextSample(kNoId, kSample1Start, kSample1End, kNoPayload);
|
||||
auto sample_2 = GetTextSample(kNoId, kSample2Start, kSample2End, kNoPayload);
|
||||
|
@ -539,7 +539,7 @@ TEST_F(CueAlignmentHandlerTest, TextInputWithCueAfterLastStart) {
|
|||
EXPECT_CALL(*Output(kTextStream), OnFlush(kParent));
|
||||
}
|
||||
|
||||
auto stream_info = GetTextStreamInfo();
|
||||
auto stream_info = GetTextStreamInfo(kMsTimeScale);
|
||||
auto sample_0 = GetTextSample(kNoId, kSample0Start, kSample0End, kNoPayload);
|
||||
auto sample_1 = GetTextSample(kNoId, kSample1Start, kSample1End, kNoPayload);
|
||||
auto sample_2 = GetTextSample(kNoId, kSample2Start, kSample2End, kNoPayload);
|
||||
|
@ -639,7 +639,7 @@ TEST_F(CueAlignmentHandlerTest, TextAudioVideoInputWithCues) {
|
|||
}
|
||||
|
||||
// Text samples
|
||||
auto text_stream_info = GetTextStreamInfo();
|
||||
auto text_stream_info = GetTextStreamInfo(kMsTimeScale);
|
||||
auto text_sample_0 =
|
||||
GetTextSample(kNoId, kSample0Start, kSample0End, kNoPayload);
|
||||
auto text_sample_1 =
|
||||
|
|
|
@ -16,6 +16,7 @@ namespace media {
|
|||
|
||||
namespace {
|
||||
const uint64_t kStreamIndex = 0;
|
||||
const uint64_t kMsTimeScale = 1000u;
|
||||
|
||||
const size_t kInputs = 1;
|
||||
const size_t kOutputs = 1;
|
||||
|
@ -70,8 +71,8 @@ TEST_F(TextChunkerTest, SampleEndingOnSegmentStart) {
|
|||
EXPECT_CALL(*Output(kOutput), OnFlush(kStreamIndex));
|
||||
}
|
||||
|
||||
ASSERT_OK(Input(kInput)->Dispatch(
|
||||
StreamData::FromStreamInfo(kStreamIndex, GetTextStreamInfo())));
|
||||
ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromStreamInfo(
|
||||
kStreamIndex, GetTextStreamInfo(kMsTimeScale))));
|
||||
ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromTextSample(
|
||||
kStreamIndex,
|
||||
GetTextSample(kNoId, kSampleStart, kSampleEnd, kNoPayload))));
|
||||
|
@ -124,8 +125,8 @@ TEST_F(TextChunkerTest, CreatesSegmentsForSamples) {
|
|||
EXPECT_CALL(*Output(kOutput), OnFlush(kStreamIndex));
|
||||
}
|
||||
|
||||
ASSERT_OK(Input(kInput)->Dispatch(
|
||||
StreamData::FromStreamInfo(kStreamIndex, GetTextStreamInfo())));
|
||||
ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromStreamInfo(
|
||||
kStreamIndex, GetTextStreamInfo(kMsTimeScale))));
|
||||
ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromTextSample(
|
||||
kStreamIndex,
|
||||
GetTextSample(kNoId, kSample0Start, kSample0End, kNoPayload))));
|
||||
|
@ -188,8 +189,8 @@ TEST_F(TextChunkerTest, OutputsEmptySegments) {
|
|||
EXPECT_CALL(*Output(kOutput), OnFlush(kStreamIndex));
|
||||
}
|
||||
|
||||
ASSERT_OK(Input(kInput)->Dispatch(
|
||||
StreamData::FromStreamInfo(kStreamIndex, GetTextStreamInfo())));
|
||||
ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromStreamInfo(
|
||||
kStreamIndex, GetTextStreamInfo(kMsTimeScale))));
|
||||
ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromTextSample(
|
||||
kStreamIndex,
|
||||
GetTextSample(kNoId, kSample0Start, kSample0End, kNoPayload))));
|
||||
|
@ -240,8 +241,8 @@ TEST_F(TextChunkerTest, SampleCrossesSegments) {
|
|||
EXPECT_CALL(*Output(kOutput), OnFlush(kStreamIndex));
|
||||
}
|
||||
|
||||
ASSERT_OK(Input(kInput)->Dispatch(
|
||||
StreamData::FromStreamInfo(kStreamIndex, GetTextStreamInfo())));
|
||||
ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromStreamInfo(
|
||||
kStreamIndex, GetTextStreamInfo(kMsTimeScale))));
|
||||
ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromTextSample(
|
||||
kStreamIndex,
|
||||
GetTextSample(kNoId, kSampleStart, kSampleEnd, kNoPayload))));
|
||||
|
@ -326,8 +327,8 @@ TEST_F(TextChunkerTest, PreservesOrder) {
|
|||
EXPECT_CALL(*Output(kOutput), OnFlush(kStreamIndex));
|
||||
}
|
||||
|
||||
ASSERT_OK(Input(kInput)->Dispatch(
|
||||
StreamData::FromStreamInfo(kStreamIndex, GetTextStreamInfo())));
|
||||
ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromStreamInfo(
|
||||
kStreamIndex, GetTextStreamInfo(kMsTimeScale))));
|
||||
ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromTextSample(
|
||||
kStreamIndex,
|
||||
GetTextSample(kSample0Id, kSample0Start, kSample0End, kNoPayload))));
|
||||
|
@ -426,8 +427,8 @@ TEST_F(TextChunkerTest, NestedSamples) {
|
|||
EXPECT_CALL(*Output(kOutput), OnFlush(kStreamIndex));
|
||||
}
|
||||
|
||||
ASSERT_OK(Input(kInput)->Dispatch(
|
||||
StreamData::FromStreamInfo(kStreamIndex, GetTextStreamInfo())));
|
||||
ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromStreamInfo(
|
||||
kStreamIndex, GetTextStreamInfo(kMsTimeScale))));
|
||||
ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromTextSample(
|
||||
kStreamIndex,
|
||||
GetTextSample(kNoId, kSample0Start, kSample0End, kNoPayload))));
|
||||
|
@ -493,8 +494,8 @@ TEST_F(TextChunkerTest, SecondSampleStartsAfterMultiSegmentSampleEnds) {
|
|||
EXPECT_CALL(*Output(kOutput), OnFlush(kStreamIndex));
|
||||
}
|
||||
|
||||
ASSERT_OK(Input(kInput)->Dispatch(
|
||||
StreamData::FromStreamInfo(kStreamIndex, GetTextStreamInfo())));
|
||||
ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromStreamInfo(
|
||||
kStreamIndex, GetTextStreamInfo(kMsTimeScale))));
|
||||
ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromTextSample(
|
||||
kStreamIndex,
|
||||
GetTextSample(kNoId, kSample0Start, kSample0End, kNoPayload))));
|
||||
|
@ -569,8 +570,8 @@ TEST_F(TextChunkerTest, SampleSpanningMultipleCues) {
|
|||
!kSubSegment, !kEncrypted)));
|
||||
}
|
||||
|
||||
ASSERT_OK(Input(kInput)->Dispatch(
|
||||
StreamData::FromStreamInfo(kStreamIndex, GetTextStreamInfo())));
|
||||
ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromStreamInfo(
|
||||
kStreamIndex, GetTextStreamInfo(kMsTimeScale))));
|
||||
ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromTextSample(
|
||||
kStreamIndex,
|
||||
GetTextSample(kNoId, kSampleStart, kSampleEnd, kNoPayload))));
|
||||
|
|
|
@ -28,6 +28,8 @@ const size_t kStreamIndex = 0;
|
|||
const bool kEncrypted = true;
|
||||
const char* kNoId = "";
|
||||
|
||||
const uint64_t kMsTimeScale = 1000u;
|
||||
|
||||
const char* kSegmentedFileTemplate = "memory://output/template-$Number$.vtt";
|
||||
const char* kSegmentedFileOutput1 = "memory://output/template-1.vtt";
|
||||
const char* kSegmentedFileOutput2 = "memory://output/template-2.vtt";
|
||||
|
@ -72,8 +74,8 @@ TEST_F(WebVttSegmentedOutputTest, WithNoSegmentAndWithNoSamples) {
|
|||
}
|
||||
|
||||
ASSERT_OK(Input(kInputIndex)
|
||||
->Dispatch(StreamData::FromStreamInfo(kStreamIndex,
|
||||
GetTextStreamInfo())));
|
||||
->Dispatch(StreamData::FromStreamInfo(
|
||||
kStreamIndex, GetTextStreamInfo(kMsTimeScale))));
|
||||
ASSERT_OK(Input(kInputIndex)->FlushAllDownstreams());
|
||||
}
|
||||
|
||||
|
@ -100,8 +102,8 @@ TEST_F(WebVttSegmentedOutputTest, WithOneSegmentAndWithOneSample) {
|
|||
}
|
||||
|
||||
ASSERT_OK(Input(kInputIndex)
|
||||
->Dispatch(StreamData::FromStreamInfo(kStreamIndex,
|
||||
GetTextStreamInfo())));
|
||||
->Dispatch(StreamData::FromStreamInfo(
|
||||
kStreamIndex, GetTextStreamInfo(kMsTimeScale))));
|
||||
ASSERT_OK(
|
||||
Input(kInputIndex)
|
||||
->Dispatch(StreamData::FromTextSample(
|
||||
|
@ -150,7 +152,8 @@ TEST_F(WebVttSegmentedOutputTest, WithTwoSegmentAndWithOneSample) {
|
|||
}
|
||||
|
||||
ASSERT_OK(Input(kInputIndex)
|
||||
->Dispatch(StreamData::FromStreamInfo(0, GetTextStreamInfo())));
|
||||
->Dispatch(StreamData::FromStreamInfo(
|
||||
0, GetTextStreamInfo(kMsTimeScale))));
|
||||
|
||||
// Segment One
|
||||
ASSERT_OK(
|
||||
|
@ -209,7 +212,8 @@ TEST_F(WebVttSegmentedOutputTest, WithAnEmptySegment) {
|
|||
}
|
||||
|
||||
ASSERT_OK(Input(kInputIndex)
|
||||
->Dispatch(StreamData::FromStreamInfo(0, GetTextStreamInfo())));
|
||||
->Dispatch(StreamData::FromStreamInfo(
|
||||
0, GetTextStreamInfo(kMsTimeScale))));
|
||||
// Segment One
|
||||
ASSERT_OK(
|
||||
Input(kInputIndex)
|
||||
|
|
|
@ -70,7 +70,9 @@ class WebVttToMp4HandlerTest : public MediaHandlerTestBase {
|
|||
}
|
||||
|
||||
Status DispatchStream() {
|
||||
auto info = GetTextStreamInfo();
|
||||
const uint64_t kMsTimeScale = 1000u;
|
||||
|
||||
auto info = GetTextStreamInfo(kMsTimeScale);
|
||||
return In()->Dispatch(
|
||||
StreamData::FromStreamInfo(kStreamIndex, std::move(info)));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue