Index: media/webm/webm_parser.h |
diff --git a/media/webm/webm_parser.h b/media/webm/webm_parser.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..8096798db169e66c3c368b31c0c2a855ea43073a |
--- /dev/null |
+++ b/media/webm/webm_parser.h |
@@ -0,0 +1,57 @@ |
+// Copyright (c) 2011 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_PARSER_H_ |
+#define MEDIA_WEBM_WEBM_PARSER_H_ |
+ |
+#include <string> |
+ |
+#include "base/basictypes.h" |
+ |
+namespace media { |
+ |
+// Interface for receiving WebM parser events. |
+// |
+// Each method is called when an element of the specified type is parsed. |
+// The ID of the element that was parsed is given along with the value |
+// stored in the element. List elements generate calls at the start and |
+// end of the list. Any pointers passed to these methods are only guaranteed |
+// to be valid for the life of that call. Each method returns a bool that |
+// indicates whether the parsed data is valid. If false is returned |
+// then the parse is immediately terminated and an error is reported by the |
+// parser. |
+class WebMParserClient { |
+ public: |
+ virtual ~WebMParserClient(); |
+ |
+ virtual bool OnListStart(int id) = 0; |
+ virtual bool OnListEnd(int id) = 0; |
+ virtual bool OnUInt(int id, int64 val) = 0; |
+ virtual bool OnFloat(int id, double val) = 0; |
+ virtual bool OnBinary(int id, const uint8* data, int size) = 0; |
+ virtual bool OnString(int id, const std::string& str) = 0; |
+ virtual bool OnSimpleBlock(int track_num, int timecode, |
+ int flags, |
+ const uint8* data, int size) = 0; |
+}; |
+ |
+// Parses a buffer that contains INFO & TRACKS elements. |
+// |
+// If the headers were successfully parsed, this method will |
+// return the number of bytes parsed. If an error occurs this |
+// method returns -1. |
+int ParseWebMHeaders(WebMParserClient* client, |
+ const uint8* buf, int size); |
+ |
+// Parses a buffer that contains a CLUSTER element. |
+// |
+// If a cluster was successfully parsed, this method will |
+// return the number of bytes parsed. If an error occurs this |
+// method returns -1. |
+int ParseWebMCluster(WebMParserClient* client, |
+ const uint8* buf, int size); |
+ |
+} // namespace media |
+ |
+#endif // MEDIA_WEBM_WEBM_PARSER_H_ |