Shaka Packager SDK
Loading...
Searching...
No Matches
webm_webvtt_parser.h
1// Copyright 2014 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef PACKAGER_MEDIA_FORMATS_WEBM_WEBM_WEBVTT_PARSER_H_
6#define PACKAGER_MEDIA_FORMATS_WEBM_WEBM_WEBVTT_PARSER_H_
7
8#include <cstdint>
9#include <string>
10
11#include <packager/macros/classes.h>
12
13namespace shaka {
14namespace media {
15
17 public:
19 static void Parse(const uint8_t* payload,
20 int payload_size,
21 std::string* id,
22 std::string* settings,
23 std::string* content);
24
25 private:
26 // The payload is the embedded WebVTT cue, stored in a WebM block.
27 // The parser treats this as a UTF-8 byte stream.
28 WebMWebVTTParser(const uint8_t* payload, int payload_size);
29
30 // Parse the cue identifier, settings, and content from the stream.
31 void Parse(std::string* id, std::string* settings, std::string* content);
32 // Remove a byte from the stream, advancing the stream pointer.
33 // Returns true if a character was returned; false means "end of stream".
34 bool GetByte(uint8_t* byte);
35
36 // Backup the stream pointer.
37 void UngetByte();
38
39 // Parse a line of text from the stream.
40 void ParseLine(std::string* line);
41
42 // Represents the portion of the stream that has not been consumed yet.
43 const uint8_t* ptr_;
44 const uint8_t* const ptr_end_;
45
46 DISALLOW_COPY_AND_ASSIGN(WebMWebVTTParser);
47};
48
49} // namespace media
50} // namespace shaka
51
52#endif // PACKAGER_MEDIA_FORMATS_WEBM_WEBM_WEBVTT_PARSER_H_
static void Parse(const uint8_t *payload, int payload_size, std::string *id, std::string *settings, std::string *content)
Utility function to parse the WebVTT cue from a byte stream.
All the methods that are virtual are virtual for mocking.