Add CueEvent Support To WebVtt Output
The WebVtt Output Handler did not recognize cue events. This change allows the handler to accept the events and tell muxer listener about them. Issue #362 Change-Id: I7c3318b72e539adc19af587c8e213fdb0af8290b
This commit is contained in:
parent
ad75b9bd42
commit
061777db9b
|
@ -13,6 +13,10 @@
|
|||
|
||||
namespace shaka {
|
||||
namespace media {
|
||||
namespace {
|
||||
double kMillisecondsToSeconds = 1000.0;
|
||||
} // namespace
|
||||
|
||||
void WebVttOutputHandler::WriteCue(const std::string& id,
|
||||
uint64_t start_ms,
|
||||
uint64_t end_ms,
|
||||
|
@ -91,6 +95,8 @@ Status WebVttOutputHandler::Process(std::unique_ptr<StreamData> stream_data) {
|
|||
return OnStreamInfo(*stream_data->stream_info);
|
||||
case StreamDataType::kSegmentInfo:
|
||||
return OnSegmentInfo(*stream_data->segment_info);
|
||||
case StreamDataType::kCueEvent:
|
||||
return OnCueEvent(*stream_data->cue_event);
|
||||
case StreamDataType::kTextSample:
|
||||
return OnTextSample(*stream_data->text_sample);
|
||||
default:
|
||||
|
@ -143,6 +149,14 @@ Status WebVttSegmentedOutputHandler::OnSegmentInfo(const SegmentInfo& info) {
|
|||
return Status::OK;
|
||||
}
|
||||
|
||||
Status WebVttSegmentedOutputHandler::OnCueEvent(const CueEvent& event) {
|
||||
double timestamp_seconds = event.time_in_seconds;
|
||||
double timestamp_ms = timestamp_seconds * kMillisecondsToSeconds;
|
||||
uint64_t timestamp = static_cast<uint64_t>(timestamp_ms);
|
||||
muxer_listener_->OnCueEvent(timestamp, event.cue_data);
|
||||
return Status::OK;
|
||||
}
|
||||
|
||||
Status WebVttSegmentedOutputHandler::OnTextSample(const TextSample& sample) {
|
||||
const std::string& id = sample.id();
|
||||
const uint64_t start_ms = sample.start_time();
|
||||
|
|
|
@ -29,6 +29,7 @@ class WebVttOutputHandler : public MediaHandler {
|
|||
protected:
|
||||
virtual Status OnStreamInfo(const StreamInfo& info) = 0;
|
||||
virtual Status OnSegmentInfo(const SegmentInfo& info) = 0;
|
||||
virtual Status OnCueEvent(const CueEvent& event) = 0;
|
||||
virtual Status OnTextSample(const TextSample& sample) = 0;
|
||||
virtual Status OnStreamEnd() = 0;
|
||||
|
||||
|
@ -65,6 +66,7 @@ class WebVttSegmentedOutputHandler : public WebVttOutputHandler {
|
|||
private:
|
||||
Status OnStreamInfo(const StreamInfo& info) override;
|
||||
Status OnSegmentInfo(const SegmentInfo& info) override;
|
||||
Status OnCueEvent(const CueEvent& event) override;
|
||||
Status OnTextSample(const TextSample& sample) override;
|
||||
Status OnStreamEnd() override;
|
||||
|
||||
|
|
Loading…
Reference in New Issue