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:
24  virtual ~WebVttFileBuffer() = default;
25 
26  void Reset();
27  void Append(const TextSample& sample);
28 
29  bool WriteTo(File* file);
30 
31  // Get the number of samples that have been appended to this file.
32  size_t sample_count() const { return sample_count_; }
33 
34  private:
35  WebVttFileBuffer(const WebVttFileBuffer&) = delete;
36  WebVttFileBuffer& operator=(const WebVttFileBuffer&) = delete;
37 
38  std::string buffer_;
39  size_t sample_count_ = 0;
40 };
41 
42 } // namespace media
43 } // namespace shaka
44 
45 #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.