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