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 <cstddef>
11#include <cstdint>
12#include <string>
13
14#include <packager/file.h>
15
16namespace shaka {
17namespace media {
18
19class TextSample;
20
21// A class to abstract writing a webvtt file to disk. This class will handle
22// all the formatting requirements for a webvtt file.
24 public:
25 WebVttFileBuffer(int32_t transport_stream_timestamp_offset_ms,
26 const std::string& style_region_config);
27 virtual ~WebVttFileBuffer() = default;
28
29 void Reset();
30 void Append(const TextSample& sample);
31
32 bool WriteTo(File* file, uint64_t* size);
33
34 // Get the number of samples that have been appended to this file.
35 size_t sample_count() const { return sample_count_; }
36
37 private:
38 WebVttFileBuffer(const WebVttFileBuffer&) = delete;
39 WebVttFileBuffer& operator=(const WebVttFileBuffer&) = delete;
40
41 const int32_t transport_stream_timestamp_offset_ = 0;
42 const std::string style_region_config_;
43 std::string buffer_;
44 size_t sample_count_ = 0;
45};
46
47} // namespace media
48} // namespace shaka
49
50#endif // PACKAGER_MEDIA_FORMATS_WEBVTT_WEBVTT_FILE_BUFFER_H_
All the methods that are virtual are virtual for mocking.