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.
5 #ifndef MEDIA_FORMATS_WEBM_WEBM_WEBVTT_PARSER_H_
6 #define MEDIA_FORMATS_WEBM_WEBM_WEBVTT_PARSER_H_
10 #include "base/basictypes.h"
11 #include "media/base/media_export.h"
15 class MEDIA_EXPORT WebMWebVTTParser
{
17 // Utility function to parse the WebVTT cue from a byte stream.
18 static void Parse(const uint8
* payload
, int payload_size
,
20 std::string
* settings
,
21 std::string
* content
);
24 // The payload is the embedded WebVTT cue, stored in a WebM block.
25 // The parser treats this as a UTF-8 byte stream.
26 WebMWebVTTParser(const uint8
* payload
, int payload_size
);
28 // Parse the cue identifier, settings, and content from the stream.
29 void Parse(std::string
* id
, std::string
* settings
, std::string
* content
);
30 // Remove a byte from the stream, advancing the stream pointer.
31 // Returns true if a character was returned; false means "end of stream".
32 bool GetByte(uint8
* byte
);
34 // Backup the stream pointer.
37 // Parse a line of text from the stream.
38 void ParseLine(std::string
* line
);
40 // Represents the portion of the stream that has not been consumed yet.
42 const uint8
* const ptr_end_
;
44 DISALLOW_COPY_AND_ASSIGN(WebMWebVTTParser
);
49 #endif // MEDIA_FORMATS_WEBM_WEBM_WEBVTT_PARSER_H_