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