Shaka Packager SDK
text_readers.h
1 // Copyright 2017 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_TEXT_READERS_H_
8 #define PACKAGER_MEDIA_FORMATS_WEBVTT_TEXT_READERS_H_
9 
10 #include <memory>
11 #include <string>
12 #include <vector>
13 
14 #include <packager/media/base/byte_queue.h>
15 #include <packager/status.h>
16 
17 namespace shaka {
18 class File;
19 
20 namespace media {
21 
22 class LineReader {
23  public:
24  LineReader();
25 
27  void PushData(const uint8_t* data, size_t data_size);
30  bool Next(std::string* out);
33  void Flush();
34 
35  private:
36  LineReader(const LineReader&) = delete;
37  LineReader operator=(const LineReader&) = delete;
38 
39  ByteQueue buffer_;
40  bool should_flush_;
41 };
42 
43 class BlockReader {
44  public:
45  BlockReader();
46 
48  void PushData(const uint8_t* data, size_t data_size);
51  bool Next(std::vector<std::string>* out);
54  void Flush();
55 
56  private:
57  BlockReader(const BlockReader&) = delete;
58  BlockReader operator=(const BlockReader&) = delete;
59 
60  LineReader source_;
61  std::vector<std::string> temp_;
62  bool should_flush_;
63 };
64 
65 } // namespace media
66 } // namespace shaka
67 
68 #endif // MEDIA_FORMATS_WEBVTT_TEXT_READERS_H_
void PushData(const uint8_t *data, size_t data_size)
Pushes data onto the end of the buffer.
Definition: text_readers.cc:74
bool Next(std::vector< std::string > *out)
Definition: text_readers.cc:79
bool Next(std::string *out)
Definition: text_readers.cc:25
void PushData(const uint8_t *data, size_t data_size)
Pushes data onto the end of the buffer.
Definition: text_readers.cc:19
All the methods that are virtual are virtual for mocking.
Definition: crypto_flags.cc:66