1 /* 2 * $Id: ebml_internal.h 775 2011-07-03 08:27:03Z robux4 $ 3 * Copyright (c) 2010, Matroska (non-profit organisation) 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are met: 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * * Neither the name of the Matroska assocation nor the 14 * names of its contributors may be used to endorse or promote products 15 * derived from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY the Matroska association ``AS IS'' AND ANY 18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 * DISCLAIMED. IN NO EVENT SHALL The Matroska Foundation BE LIABLE FOR ANY 21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 #ifndef LIBEBML2_INTERNAL_H 30 #define LIBEBML2_INTERNAL_H 31 32 /* 33 * ONLY INCLUDE THIS FILE IF YOU PLAN TO CREATE YOUR OWN EBML-BASED CLASS 34 */ 35 36 #include "corec/node/node.h" 37 38 #ifdef __cplusplus 39 extern "C" { 40 #endif 41 42 INTERNAL_C_API size_t GetIdLength(fourcc_t Id); 43 44 struct ebml_context 45 { 46 fourcc_t Id; 47 fourcc_t Class; // TODO: store a pointer to make creation faster 48 bool_t HasDefault; 49 intptr_t DefaultValue; 50 const char *ElementName; 51 // TODO: create sub class so we don't have to assign it all the time 52 const ebml_semantic *Semantic; // table with last element class set to NULL 53 const ebml_semantic *GlobalContext; // table with last element class set to NULL 54 void (*PostCreate)(ebml_element *p, const void *Cookie); 55 }; 56 57 struct ebml_element 58 { 59 nodetree Base; 60 filepos_t DataSize; // size of the data inside the element 61 filepos_t ElementPosition; 62 filepos_t SizePosition; // TODO: is this needed since we have the ElementPosition and SizeLength ? 63 const ebml_context *Context; 64 int DefaultSize; 65 int8_t SizeLength; 66 boolmem_t bValueIsSet; 67 boolmem_t bNeedDataSizeUpdate; 68 }; 69 70 struct ebml_master 71 { 72 ebml_element Base; 73 int CheckSumStatus; // 0: not set, 1: requested/invalid, 2: verified 74 75 }; 76 77 struct ebml_string 78 { 79 ebml_element Base; 80 const char *Buffer; // UTF-8 internal storage 81 82 }; 83 84 struct ebml_integer 85 { 86 ebml_element Base; 87 int64_t Value; 88 89 }; 90 91 struct ebml_float 92 { 93 ebml_element Base; 94 double Value; 95 96 }; 97 98 struct ebml_binary 99 { 100 ebml_element Base; 101 array Data; 102 103 }; 104 105 struct ebml_dummy 106 { 107 ebml_binary Base; 108 ebml_context DummyContext; 109 110 }; 111 112 #ifdef __cplusplus 113 } 114 #endif 115 116 #endif /* LIBEBML2_INTERNAL_H */ 117