Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Unified Diff: media/webm/webm_webvtt_parser.h

Issue 13419002: Media Source dispatches inband text tracks (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: incorporated aaron's comments Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/webm/webm_webvtt_parser.h
diff --git a/media/webm/webm_webvtt_parser.h b/media/webm/webm_webvtt_parser.h
new file mode 100644
index 0000000000000000000000000000000000000000..7a1ac40a1819a4276e734c3eaff84aad5f5caf3d
--- /dev/null
+++ b/media/webm/webm_webvtt_parser.h
@@ -0,0 +1,49 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MEDIA_WEBM_WEBM_WEBVTT_PARSER_H_
+#define MEDIA_WEBM_WEBM_WEBVTT_PARSER_H_
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "media/base/media_export.h"
+
+namespace media {
+
+class MEDIA_EXPORT WebMWebVTTParser {
+ public:
+ // Utility function to parse the WebVTT cue from a byte stream.
+ static void Parse(const uint8* payload, int payload_size,
+ std::string* id,
+ std::string* settings,
+ std::string* content);
+
+ private:
+ // The payload is the embedded WebVTT cue, stored in a WebM block.
+ // The parser treats this as a UTF-8 byte stream.
+ WebMWebVTTParser(const uint8* payload, int payload_size);
+
+ // Parse the cue identifier, settings, and content from the stream.
+ void Parse(std::string* id, std::string* settings, std::string* content);
+ // Remove a byte from the stream, advancing the stream pointer.
+ // Returns true if a character was returned; false means "end of stream".
+ bool GetByte(uint8* byte);
+
+ // Backup the stream pointer.
+ void UngetByte();
+
+ // Parse a line of text from the stream.
+ void ParseLine(std::string* line);
+
+ // Represents the portion of the stream that has not been consumed yet.
+ const uint8* ptr_;
+ const uint8* const ptr_end_;
+
+ DISALLOW_COPY_AND_ASSIGN(WebMWebVTTParser);
+};
+
+} // namespace media
+
+#endif // MEDIA_WEBM_WEBM_WEBVTT_PARSER_H_

Powered by Google App Engine
This is Rietveld 408576698