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 #include "media/formats/webm/webm_webvtt_parser.h"
9 void WebMWebVTTParser::Parse(const uint8
* payload
, int payload_size
,
11 std::string
* settings
,
12 std::string
* content
) {
13 WebMWebVTTParser
parser(payload
, payload_size
);
14 parser
.Parse(id
, settings
, content
);
17 WebMWebVTTParser::WebMWebVTTParser(const uint8
* payload
, int payload_size
)
19 ptr_end_(payload
+ payload_size
) {
22 void WebMWebVTTParser::Parse(std::string
* id
,
23 std::string
* settings
,
24 std::string
* content
) {
27 content
->assign(ptr_
, ptr_end_
);
30 bool WebMWebVTTParser::GetByte(uint8
* byte
) {
32 return false; // indicates end-of-stream
38 void WebMWebVTTParser::UngetByte() {
42 void WebMWebVTTParser::ParseLine(std::string
* line
) {
45 // Consume characters from the stream, until we reach end-of-line.
47 // The WebVTT spec states that lines may be terminated in any of the following
54 // http://wiki.webmproject.org/webm-metadata/temporal-metadata/webvtt-in-webm
64 if (!GetByte(&byte
) || byte
== kLF
)
68 if (GetByte(&byte
) && byte
!= kLF
)
74 line
->push_back(byte
);