7#include <packager/media/formats/webvtt/webvtt_muxer.h>
13#include <packager/file.h>
14#include <packager/file/file_closer.h>
15#include <packager/media/base/muxer_options.h>
16#include <packager/media/base/stream_info.h>
17#include <packager/media/base/text_muxer.h>
18#include <packager/media/base/text_sample.h>
19#include <packager/media/base/text_stream_info.h>
20#include <packager/media/formats/webvtt/webvtt_file_buffer.h>
21#include <packager/media/formats/webvtt/webvtt_utils.h>
22#include <packager/status.h>
29WebVttMuxer::~WebVttMuxer() {}
32 stream->set_codec(kCodecWebVtt);
33 stream->set_codec_string(
"wvtt");
35 const std::string preamble = WebVttGetPreamble(*stream);
37 options().transport_stream_timestamp_offset_ms, preamble));
41Status WebVttMuxer::AddTextSampleInternal(
const TextSample& sample) {
42 if (sample.id().find(
'\n') != std::string::npos) {
43 return Status(error::MUXER_FAILURE,
"Text id cannot contain newlines");
46 buffer_->Append(sample);
50Status WebVttMuxer::WriteToFile(
const std::string& filename, uint64_t* size) {
53 std::unique_ptr<File, FileCloser> file(File::Open(filename.c_str(),
"w"));
55 return Status(error::FILE_FAILURE,
"Failed to open " + filename);
58 buffer_->WriteTo(file.get(), size);
60 if (!file.release()->Close()) {
61 return Status(error::FILE_FAILURE,
"Failed to close " + filename);
All the methods that are virtual are virtual for mocking.