Shaka Packager SDK
Loading...
Searching...
No Matches
webvtt_file_buffer.h
1// Copyright 2018 Google LLC All rights reserved.
2//
3// Use of this source code is governed by a BSD-style
4// license that can be found in the LICENSE file or at
5// https://developers.google.com/open-source/licenses/bsd
6
7#ifndef PACKAGER_MEDIA_FORMATS_WEBVTT_WEBVTT_FILE_BUFFER_H_
8#define PACKAGER_MEDIA_FORMATS_WEBVTT_WEBVTT_FILE_BUFFER_H_
9
10#include <cstdint>
11#include <string>
12
13#include <packager/file.h>
14
15namespace shaka {
16namespace media {
17
18class TextSample;
19
20// A class to abstract writing a webvtt file to disk. This class will handle
21// all the formatting requirements for a webvtt file.
23 public:
24 WebVttFileBuffer(int32_t transport_stream_timestamp_offset_ms,
25 const std::string& style_region_config);
26 virtual ~WebVttFileBuffer() = default;
27
28 void Reset();
29 void Append(const TextSample& sample);
30
31 bool WriteTo(File* file, uint64_t* size);
32
33 // Get the number of samples that have been appended to this file.
34 size_t sample_count() const { return sample_count_; }
35
36 private:
37 WebVttFileBuffer(const WebVttFileBuffer&) = delete;
38 WebVttFileBuffer& operator=(const WebVttFileBuffer&) = delete;
39
40 const int32_t transport_stream_timestamp_offset_ = 0;
41 const std::string style_region_config_;
42 std::string buffer_;
43 size_t sample_count_ = 0;
44};
45
46} // namespace media
47} // namespace shaka
48
49#endif // PACKAGER_MEDIA_FORMATS_WEBVTT_WEBVTT_FILE_BUFFER_H_
All the methods that are virtual are virtual for mocking.