Shaka Packager SDK
text_readers.h
1 // Copyright 2017 Google Inc. 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_
shaka::media::BlockReader::Flush
void Flush()
Definition: text_readers.cc:103
shaka
All the methods that are virtual are virtual for mocking.
Definition: gflags_hex_bytes.cc:11
shaka::media::LineReader::PushData
void PushData(const uint8_t *data, size_t data_size)
Pushes data onto the end of the buffer.
Definition: text_readers.cc:18
shaka::media::BlockReader
Definition: text_readers.h:43
shaka::media::LineReader::Flush
void Flush()
Definition: text_readers.cc:67
shaka::media::LineReader::Next
bool Next(std::string *out)
Definition: text_readers.cc:24
shaka::media::ByteQueue
Definition: byte_queue.h:22
shaka::media::BlockReader::PushData
void PushData(const uint8_t *data, size_t data_size)
Pushes data onto the end of the buffer.
Definition: text_readers.cc:73
shaka::media::LineReader
Definition: text_readers.h:22
shaka::media::BlockReader::Next
bool Next(std::vector< std::string > *out)
Definition: text_readers.cc:78