Changed Text Segmenter to output segment info last
To better align with the Chunking Handler, the Text Segmenter now outputs the SegmentInfo at the end of the segment rather than the start. Change-Id: If69ab951947d00779b4b63a52c4b6662bbdc4c0d
This commit is contained in:
parent
66f713fd23
commit
b0edec8c40
|
@ -85,18 +85,22 @@ Status WebVttSegmenter::OnSegmentEnd() {
|
||||||
|
|
||||||
const uint64_t segment = samples_.top().segment;
|
const uint64_t segment = samples_.top().segment;
|
||||||
|
|
||||||
std::shared_ptr<SegmentInfo> info = std::make_shared<SegmentInfo>();
|
Status status;
|
||||||
info->start_timestamp = segment * segment_duration_ms_;
|
|
||||||
info->duration = segment_duration_ms_;
|
|
||||||
|
|
||||||
Status status = DispatchSegmentInfo(kStreamIndex, std::move(info));
|
|
||||||
|
|
||||||
while (status.ok() && samples_.size() && samples_.top().segment == segment) {
|
while (status.ok() && samples_.size() && samples_.top().segment == segment) {
|
||||||
status.Update(
|
status.Update(
|
||||||
DispatchTextSample(kStreamIndex, std::move(samples_.top().sample)));
|
DispatchTextSample(kStreamIndex, std::move(samples_.top().sample)));
|
||||||
samples_.pop();
|
samples_.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Only send the segment info if all the samples were accepted.
|
||||||
|
if (status.ok()) {
|
||||||
|
std::shared_ptr<SegmentInfo> info = std::make_shared<SegmentInfo>();
|
||||||
|
info->start_timestamp = segment * segment_duration_ms_;
|
||||||
|
info->duration = segment_duration_ms_;
|
||||||
|
|
||||||
|
status.Update(DispatchSegmentInfo(kStreamIndex, std::move(info)));
|
||||||
|
}
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
} // namespace media
|
} // namespace media
|
||||||
|
|
|
@ -58,15 +58,14 @@ TEST_F(WebVttSegmenterTest, CueEndingOnSegmentStart) {
|
||||||
EXPECT_CALL(*Output(kOutputIndex), OnProcess(IsStreamInfo(kStreamIndex)));
|
EXPECT_CALL(*Output(kOutputIndex), OnProcess(IsStreamInfo(kStreamIndex)));
|
||||||
|
|
||||||
// Segment One
|
// Segment One
|
||||||
EXPECT_CALL(
|
|
||||||
*Output(kOutputIndex),
|
|
||||||
OnProcess(IsSegmentInfo(kStreamIndex, kStartTimeSigned,
|
|
||||||
kSegmentDuration, !kSubSegment, !kEncrypted)));
|
|
||||||
EXPECT_CALL(
|
EXPECT_CALL(
|
||||||
*Output(kOutputIndex),
|
*Output(kOutputIndex),
|
||||||
OnProcess(IsTextSample(kId[0], kStartTime, kStartTime + kSampleDuration,
|
OnProcess(IsTextSample(kId[0], kStartTime, kStartTime + kSampleDuration,
|
||||||
kNoSettings, kPayload[0])));
|
kNoSettings, kPayload[0])));
|
||||||
|
EXPECT_CALL(
|
||||||
|
*Output(kOutputIndex),
|
||||||
|
OnProcess(IsSegmentInfo(kStreamIndex, kStartTimeSigned,
|
||||||
|
kSegmentDuration, !kSubSegment, !kEncrypted)));
|
||||||
EXPECT_CALL(*Output(kOutputIndex), OnFlush(kStreamIndex));
|
EXPECT_CALL(*Output(kOutputIndex), OnFlush(kStreamIndex));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,25 +97,25 @@ TEST_F(WebVttSegmenterTest, CreatesSegmentsForCues) {
|
||||||
EXPECT_CALL(*Output(kOutputIndex), OnProcess(IsStreamInfo(kStreamIndex)));
|
EXPECT_CALL(*Output(kOutputIndex), OnProcess(IsStreamInfo(kStreamIndex)));
|
||||||
|
|
||||||
// Segment One
|
// Segment One
|
||||||
EXPECT_CALL(
|
|
||||||
*Output(kOutputIndex),
|
|
||||||
OnProcess(IsSegmentInfo(kStreamIndex, kStartTimeSigned,
|
|
||||||
kSegmentDuration, !kSubSegment, !kEncrypted)));
|
|
||||||
EXPECT_CALL(
|
EXPECT_CALL(
|
||||||
*Output(kOutputIndex),
|
*Output(kOutputIndex),
|
||||||
OnProcess(IsTextSample(kId[0], kStartTime, kStartTime + kSampleDuration,
|
OnProcess(IsTextSample(kId[0], kStartTime, kStartTime + kSampleDuration,
|
||||||
kNoSettings, kPayload[0])));
|
kNoSettings, kPayload[0])));
|
||||||
|
EXPECT_CALL(
|
||||||
|
*Output(kOutputIndex),
|
||||||
|
OnProcess(IsSegmentInfo(kStreamIndex, kStartTimeSigned,
|
||||||
|
kSegmentDuration, !kSubSegment, !kEncrypted)));
|
||||||
|
|
||||||
// Segment Two
|
// Segment Two
|
||||||
EXPECT_CALL(*Output(kOutputIndex),
|
|
||||||
OnProcess(IsSegmentInfo(
|
|
||||||
kStreamIndex, kStartTimeSigned + kSegmentDuration,
|
|
||||||
kSegmentDuration, !kSubSegment, !kEncrypted)));
|
|
||||||
EXPECT_CALL(
|
EXPECT_CALL(
|
||||||
*Output(kOutputIndex),
|
*Output(kOutputIndex),
|
||||||
OnProcess(IsTextSample(kId[1], kStartTime + kSegmentDuration,
|
OnProcess(IsTextSample(kId[1], kStartTime + kSegmentDuration,
|
||||||
kStartTime + kSegmentDuration + kSampleDuration,
|
kStartTime + kSegmentDuration + kSampleDuration,
|
||||||
kNoSettings, kPayload[1])));
|
kNoSettings, kPayload[1])));
|
||||||
|
EXPECT_CALL(*Output(kOutputIndex),
|
||||||
|
OnProcess(IsSegmentInfo(
|
||||||
|
kStreamIndex, kStartTimeSigned + kSegmentDuration,
|
||||||
|
kSegmentDuration, !kSubSegment, !kEncrypted)));
|
||||||
|
|
||||||
EXPECT_CALL(*Output(kOutputIndex), OnFlush(kStreamIndex));
|
EXPECT_CALL(*Output(kOutputIndex), OnFlush(kStreamIndex));
|
||||||
}
|
}
|
||||||
|
@ -152,27 +151,27 @@ TEST_F(WebVttSegmenterTest, SkipsEmptySegments) {
|
||||||
EXPECT_CALL(*Output(kOutputIndex), OnProcess(IsStreamInfo(kStreamIndex)));
|
EXPECT_CALL(*Output(kOutputIndex), OnProcess(IsStreamInfo(kStreamIndex)));
|
||||||
|
|
||||||
// Segment One
|
// Segment One
|
||||||
EXPECT_CALL(
|
|
||||||
*Output(kOutputIndex),
|
|
||||||
OnProcess(IsSegmentInfo(kStreamIndex, kStartTimeSigned,
|
|
||||||
kSegmentDuration, !kSubSegment, !kEncrypted)));
|
|
||||||
EXPECT_CALL(
|
EXPECT_CALL(
|
||||||
*Output(kOutputIndex),
|
*Output(kOutputIndex),
|
||||||
OnProcess(IsTextSample(kId[0], kStartTime, kStartTime + kSampleDuration,
|
OnProcess(IsTextSample(kId[0], kStartTime, kStartTime + kSampleDuration,
|
||||||
kNoSettings, kPayload[0])));
|
kNoSettings, kPayload[0])));
|
||||||
|
EXPECT_CALL(
|
||||||
|
*Output(kOutputIndex),
|
||||||
|
OnProcess(IsSegmentInfo(kStreamIndex, kStartTimeSigned,
|
||||||
|
kSegmentDuration, !kSubSegment, !kEncrypted)));
|
||||||
|
|
||||||
// There is no segment two
|
// There is no segment two
|
||||||
|
|
||||||
// Segment Three
|
// Segment Three
|
||||||
EXPECT_CALL(*Output(kOutputIndex),
|
|
||||||
OnProcess(IsSegmentInfo(
|
|
||||||
kStreamIndex, kStartTimeSigned + 2 * kSegmentDuration,
|
|
||||||
kSegmentDuration, !kSubSegment, !kEncrypted)));
|
|
||||||
EXPECT_CALL(*Output(kOutputIndex),
|
EXPECT_CALL(*Output(kOutputIndex),
|
||||||
OnProcess(IsTextSample(
|
OnProcess(IsTextSample(
|
||||||
kId[1], kStartTime + 2 * kSegmentDuration,
|
kId[1], kStartTime + 2 * kSegmentDuration,
|
||||||
kStartTime + 2 * kSegmentDuration + kSampleDuration,
|
kStartTime + 2 * kSegmentDuration + kSampleDuration,
|
||||||
kNoSettings, kPayload[1])));
|
kNoSettings, kPayload[1])));
|
||||||
|
EXPECT_CALL(*Output(kOutputIndex),
|
||||||
|
OnProcess(IsSegmentInfo(
|
||||||
|
kStreamIndex, kStartTimeSigned + 2 * kSegmentDuration,
|
||||||
|
kSegmentDuration, !kSubSegment, !kEncrypted)));
|
||||||
|
|
||||||
EXPECT_CALL(*Output(kOutputIndex), OnFlush(kStreamIndex));
|
EXPECT_CALL(*Output(kOutputIndex), OnFlush(kStreamIndex));
|
||||||
}
|
}
|
||||||
|
@ -209,24 +208,24 @@ TEST_F(WebVttSegmenterTest, CueCrossesSegments) {
|
||||||
EXPECT_CALL(*Output(kOutputIndex), OnProcess(IsStreamInfo(kStreamIndex)));
|
EXPECT_CALL(*Output(kOutputIndex), OnProcess(IsStreamInfo(kStreamIndex)));
|
||||||
|
|
||||||
// Segment One
|
// Segment One
|
||||||
|
EXPECT_CALL(
|
||||||
|
*Output(kOutputIndex),
|
||||||
|
OnProcess(IsTextSample(kId[0], kStartTime, kStartTime + kSampleDuration,
|
||||||
|
kNoSettings, kPayload[0])));
|
||||||
EXPECT_CALL(
|
EXPECT_CALL(
|
||||||
*Output(kOutputIndex),
|
*Output(kOutputIndex),
|
||||||
OnProcess(IsSegmentInfo(kStreamIndex, kStartTimeSigned,
|
OnProcess(IsSegmentInfo(kStreamIndex, kStartTimeSigned,
|
||||||
kSegmentDuration, !kSubSegment, !kEncrypted)));
|
kSegmentDuration, !kSubSegment, !kEncrypted)));
|
||||||
|
|
||||||
|
// Segment Two
|
||||||
EXPECT_CALL(
|
EXPECT_CALL(
|
||||||
*Output(kOutputIndex),
|
*Output(kOutputIndex),
|
||||||
OnProcess(IsTextSample(kId[0], kStartTime, kStartTime + kSampleDuration,
|
OnProcess(IsTextSample(kId[0], kStartTime, kStartTime + kSampleDuration,
|
||||||
kNoSettings, kPayload[0])));
|
kNoSettings, kPayload[0])));
|
||||||
|
|
||||||
// Segment Two
|
|
||||||
EXPECT_CALL(*Output(kOutputIndex),
|
EXPECT_CALL(*Output(kOutputIndex),
|
||||||
OnProcess(IsSegmentInfo(
|
OnProcess(IsSegmentInfo(
|
||||||
kStreamIndex, kStartTimeSigned + kSegmentDuration,
|
kStreamIndex, kStartTimeSigned + kSegmentDuration,
|
||||||
kSegmentDuration, !kSubSegment, !kEncrypted)));
|
kSegmentDuration, !kSubSegment, !kEncrypted)));
|
||||||
EXPECT_CALL(
|
|
||||||
*Output(kOutputIndex),
|
|
||||||
OnProcess(IsTextSample(kId[0], kStartTime, kStartTime + kSampleDuration,
|
|
||||||
kNoSettings, kPayload[0])));
|
|
||||||
|
|
||||||
EXPECT_CALL(*Output(kOutputIndex), OnFlush(kStreamIndex));
|
EXPECT_CALL(*Output(kOutputIndex), OnFlush(kStreamIndex));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue