OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 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 MEDIA_WEBM_WEBM_PARSER_H_ |
| 6 #define MEDIA_WEBM_WEBM_PARSER_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 |
| 12 namespace media { |
| 13 |
| 14 // Interface for receiving WebM parser events. |
| 15 // |
| 16 // Each method is called when an element of the specified type is parsed. |
| 17 // The ID of the element that was parsed is given along with the value |
| 18 // stored in the element. List elements generate calls at the start and |
| 19 // end of the list. Any pointers passed to these methods are only guaranteed |
| 20 // to be valid for the life of that call. Each method returns a bool that |
| 21 // indicates whether the parsed data is valid. If false is returned |
| 22 // then the parse is immediately terminated and an error is reported by the |
| 23 // parser. |
| 24 class WebMParserClient { |
| 25 public: |
| 26 virtual ~WebMParserClient(); |
| 27 |
| 28 virtual bool OnListStart(int id) = 0; |
| 29 virtual bool OnListEnd(int id) = 0; |
| 30 virtual bool OnUInt(int id, int64 val) = 0; |
| 31 virtual bool OnFloat(int id, double val) = 0; |
| 32 virtual bool OnBinary(int id, const uint8* data, int size) = 0; |
| 33 virtual bool OnString(int id, const std::string& str) = 0; |
| 34 virtual bool OnSimpleBlock(int track_num, int timecode, |
| 35 int flags, |
| 36 const uint8* data, int size) = 0; |
| 37 }; |
| 38 |
| 39 // Parses a buffer that contains INFO & TRACKS elements. |
| 40 // |
| 41 // If the headers were successfully parsed, this method will |
| 42 // return the number of bytes parsed. If an error occurs this |
| 43 // method returns -1. |
| 44 int ParseWebMHeaders(WebMParserClient* client, |
| 45 const uint8* buf, int size); |
| 46 |
| 47 // Parses a buffer that contains a CLUSTER element. |
| 48 // |
| 49 // If a cluster was successfully parsed, this method will |
| 50 // return the number of bytes parsed. If an error occurs this |
| 51 // method returns -1. |
| 52 int ParseWebMCluster(WebMParserClient* client, |
| 53 const uint8* buf, int size); |
| 54 |
| 55 } // namespace media |
| 56 |
| 57 #endif // MEDIA_WEBM_WEBM_PARSER_H_ |
OLD | NEW |