- Timestamp:
- Aug 8, 2016 12:47:24 PM (8 years ago)
- Location:
- trunk/src/VBox/Main/src-client
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/EbmlWriter.cpp
r62485 r63160 16 16 */ 17 17 18 /*19 * This code is based on:20 *21 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.22 *23 * Use of this source code is governed by a BSD-style license24 * that can be found in the LICENSE file in the root of the source25 * tree. An additional intellectual property rights grant can be found26 * in the file PATENTS. All contributing project authors may27 * be found in the AUTHORS file in the root of the source tree.28 */29 18 30 19 #include <list> … … 37 26 #include <VBox/log.h> 38 27 #include "EbmlWriter.h" 39 40 /* Matroska EBML Class IDs supported by WebM */ 41 enum Mkv 42 { 43 EBML = 0x1A45DFA3, 44 EBMLVersion = 0x4286, 45 EBMLReadVersion = 0x42F7, 46 EBMLMaxIDLength = 0x42F2, 47 EBMLMaxSizeLength = 0x42F3, 48 DocType = 0x4282, 49 DocTypeVersion = 0x4287, 50 DocTypeReadVersion = 0x4285, 51 // CRC_32 = 0xBF, 52 Void = 0xEC, 53 SignatureSlot = 0x1B538667, 54 SignatureAlgo = 0x7E8A, 55 SignatureHash = 0x7E9A, 56 SignaturePublicKey = 0x7EA5, 57 Signature = 0x7EB5, 58 SignatureElements = 0x7E5B, 59 SignatureElementList = 0x7E7B, 60 SignedElement = 0x6532, 61 //segment 62 Segment = 0x18538067, 63 //Meta Seek Information 64 SeekHead = 0x114D9B74, 65 Seek = 0x4DBB, 66 SeekID = 0x53AB, 67 SeekPosition = 0x53AC, 68 //Segment Information 69 Info = 0x1549A966, 70 // SegmentUID = 0x73A4, 71 // SegmentFilename = 0x7384, 72 // PrevUID = 0x3CB923, 73 // PrevFilename = 0x3C83AB, 74 // NextUID = 0x3EB923, 75 // NextFilename = 0x3E83BB, 76 // SegmentFamily = 0x4444, 77 // ChapterTranslate = 0x6924, 78 // ChapterTranslateEditionUID = 0x69FC, 79 // ChapterTranslateCodec = 0x69BF, 80 // ChapterTranslateID = 0x69A5, 81 TimecodeScale = 0x2AD7B1, 82 Segment_Duration = 0x4489, 83 DateUTC = 0x4461, 84 // Title = 0x7BA9, 85 MuxingApp = 0x4D80, 86 WritingApp = 0x5741, 87 //Cluster 88 Cluster = 0x1F43B675, 89 Timecode = 0xE7, 90 // SilentTracks = 0x5854, 91 // SilentTrackNumber = 0x58D7, 92 // Position = 0xA7, 93 PrevSize = 0xAB, 94 BlockGroup = 0xA0, 95 Block = 0xA1, 96 // BlockVirtual = 0xA2, 97 // BlockAdditions = 0x75A1, 98 // BlockMore = 0xA6, 99 // BlockAddID = 0xEE, 100 // BlockAdditional = 0xA5, 101 BlockDuration = 0x9B, 102 // ReferencePriority = 0xFA, 103 ReferenceBlock = 0xFB, 104 // ReferenceVirtual = 0xFD, 105 // CodecState = 0xA4, 106 // Slices = 0x8E, 107 // TimeSlice = 0xE8, 108 LaceNumber = 0xCC, 109 // FrameNumber = 0xCD, 110 // BlockAdditionID = 0xCB, 111 // MkvDelay = 0xCE, 112 // Cluster_Duration = 0xCF, 113 SimpleBlock = 0xA3, 114 // EncryptedBlock = 0xAF, 115 //Track 116 Tracks = 0x1654AE6B, 117 TrackEntry = 0xAE, 118 TrackNumber = 0xD7, 119 TrackUID = 0x73C5, 120 TrackType = 0x83, 121 FlagEnabled = 0xB9, 122 FlagDefault = 0x88, 123 FlagForced = 0x55AA, 124 FlagLacing = 0x9C, 125 // MinCache = 0x6DE7, 126 // MaxCache = 0x6DF8, 127 DefaultDuration = 0x23E383, 128 // TrackTimecodeScale = 0x23314F, 129 // TrackOffset = 0x537F, 130 // MaxBlockAdditionID = 0x55EE, 131 Name = 0x536E, 132 Language = 0x22B59C, 133 CodecID = 0x86, 134 CodecPrivate = 0x63A2, 135 CodecName = 0x258688, 136 // AttachmentLink = 0x7446, 137 // CodecSettings = 0x3A9697, 138 // CodecInfoURL = 0x3B4040, 139 // CodecDownloadURL = 0x26B240, 140 // CodecDecodeAll = 0xAA, 141 // TrackOverlay = 0x6FAB, 142 // TrackTranslate = 0x6624, 143 // TrackTranslateEditionUID = 0x66FC, 144 // TrackTranslateCodec = 0x66BF, 145 // TrackTranslateTrackID = 0x66A5, 146 //video 147 Video = 0xE0, 148 FlagInterlaced = 0x9A, 149 // StereoMode = 0x53B8, 150 PixelWidth = 0xB0, 151 PixelHeight = 0xBA, 152 PixelCropBottom = 0x54AA, 153 PixelCropTop = 0x54BB, 154 PixelCropLeft = 0x54CC, 155 PixelCropRight = 0x54DD, 156 DisplayWidth = 0x54B0, 157 DisplayHeight = 0x54BA, 158 DisplayUnit = 0x54B2, 159 AspectRatioType = 0x54B3, 160 // ColourSpace = 0x2EB524, 161 // GammaValue = 0x2FB523, 162 FrameRate = 0x2383E3, 163 //end video 164 //audio 165 Audio = 0xE1, 166 SamplingFrequency = 0xB5, 167 OutputSamplingFrequency = 0x78B5, 168 Channels = 0x9F, 169 // ChannelPositions = 0x7D7B, 170 BitDepth = 0x6264, 171 //end audio 172 //content encoding 173 // ContentEncodings = 0x6d80, 174 // ContentEncoding = 0x6240, 175 // ContentEncodingOrder = 0x5031, 176 // ContentEncodingScope = 0x5032, 177 // ContentEncodingType = 0x5033, 178 // ContentCompression = 0x5034, 179 // ContentCompAlgo = 0x4254, 180 // ContentCompSettings = 0x4255, 181 // ContentEncryption = 0x5035, 182 // ContentEncAlgo = 0x47e1, 183 // ContentEncKeyID = 0x47e2, 184 // ContentSignature = 0x47e3, 185 // ContentSigKeyID = 0x47e4, 186 // ContentSigAlgo = 0x47e5, 187 // ContentSigHashAlgo = 0x47e6, 188 //end content encoding 189 //Cueing Data 190 Cues = 0x1C53BB6B, 191 CuePoint = 0xBB, 192 CueTime = 0xB3, 193 CueTrackPositions = 0xB7, 194 CueTrack = 0xF7, 195 CueClusterPosition = 0xF1, 196 CueBlockNumber = 0x5378 197 // CueCodecState = 0xEA, 198 // CueReference = 0xDB, 199 // CueRefTime = 0x96, 200 // CueRefCluster = 0x97, 201 // CueRefNumber = 0x535F, 202 // CueRefCodecState = 0xEB, 203 //Attachment 204 // Attachments = 0x1941A469, 205 // AttachedFile = 0x61A7, 206 // FileDescription = 0x467E, 207 // FileName = 0x466E, 208 // FileMimeType = 0x4660, 209 // FileData = 0x465C, 210 // FileUID = 0x46AE, 211 // FileReferral = 0x4675, 212 //Chapters 213 // Chapters = 0x1043A770, 214 // EditionEntry = 0x45B9, 215 // EditionUID = 0x45BC, 216 // EditionFlagHidden = 0x45BD, 217 // EditionFlagDefault = 0x45DB, 218 // EditionFlagOrdered = 0x45DD, 219 // ChapterAtom = 0xB6, 220 // ChapterUID = 0x73C4, 221 // ChapterTimeStart = 0x91, 222 // ChapterTimeEnd = 0x92, 223 // ChapterFlagHidden = 0x98, 224 // ChapterFlagEnabled = 0x4598, 225 // ChapterSegmentUID = 0x6E67, 226 // ChapterSegmentEditionUID = 0x6EBC, 227 // ChapterPhysicalEquiv = 0x63C3, 228 // ChapterTrack = 0x8F, 229 // ChapterTrackNumber = 0x89, 230 // ChapterDisplay = 0x80, 231 // ChapString = 0x85, 232 // ChapLanguage = 0x437C, 233 // ChapCountry = 0x437E, 234 // ChapProcess = 0x6944, 235 // ChapProcessCodecID = 0x6955, 236 // ChapProcessPrivate = 0x450D, 237 // ChapProcessCommand = 0x6911, 238 // ChapProcessTime = 0x6922, 239 // ChapProcessData = 0x6933, 240 //Tagging 241 // Tags = 0x1254C367, 242 // Tag = 0x7373, 243 // Targets = 0x63C0, 244 // TargetTypeValue = 0x68CA, 245 // TargetType = 0x63CA, 246 // Tagging_TrackUID = 0x63C5, 247 // Tagging_EditionUID = 0x63C9, 248 // Tagging_ChapterUID = 0x63C4, 249 // AttachmentUID = 0x63C6, 250 // SimpleTag = 0x67C8, 251 // TagName = 0x45A3, 252 // TagLanguage = 0x447A, 253 // TagDefault = 0x4484, 254 // TagString = 0x4487, 255 // TagBinary = 0x4485, 256 }; 28 #include "EbmlIDs.h" 29 257 30 258 31 class Ebml … … 275 48 public: 276 49 277 /* Creates EBML output file. */50 /** Creates EBML output file. */ 278 51 inline int create(const char *a_pszFilename) 279 52 { … … 281 54 } 282 55 283 /* Returns file size. */56 /** Returns file size. */ 284 57 inline uint64_t getFileSize() 285 58 { … … 287 60 } 288 61 289 /* Get reference to file descriptor */62 /** Get reference to file descriptor */ 290 63 inline const RTFILE &getFile() 291 64 { … … 293 66 } 294 67 295 /* Returns available space on storage. */68 /** Returns available space on storage. */ 296 69 inline uint64_t getAvailableSpace() 297 70 { … … 301 74 } 302 75 303 /* Closes the file. */76 /** Closes the file. */ 304 77 inline void close() 305 78 { … … 307 80 } 308 81 309 /* Starts an EBML sub-element. */82 /** Starts an EBML sub-element. */ 310 83 inline Ebml &subStart(EbmlClassId classId) 311 84 { … … 320 93 } 321 94 322 /* Ends an EBML sub-element. */95 /** Ends an EBML sub-element. */ 323 96 inline Ebml &subEnd(EbmlClassId classId) 324 97 { … … 339 112 } 340 113 341 /* Serializes a null-terminated string. */114 /** Serializes a null-terminated string. */ 342 115 inline Ebml &serializeString(EbmlClassId classId, const char *str) 343 116 { … … 360 133 } 361 134 362 /* Serializes a floating point value. 135 /** Serializes a floating point value. 136 * 363 137 * Only 8-bytes double precision values are supported 364 138 * by this function. … … 372 146 } 373 147 374 /* Writes raw data to file. */148 /** Writes raw data to file. */ 375 149 inline void write(const void *data, size_t size) 376 150 { … … 379 153 } 380 154 381 /* Writes an unsigned integer of variable of fixed size. */155 /** Writes an unsigned integer of variable of fixed size. */ 382 156 inline void writeUnsignedInteger(uint64_t value, size_t size = sizeof(uint64_t)) 383 157 { … … 387 161 } 388 162 389 /* Writes EBML class ID to file. 163 /** Writes EBML class ID to file. 164 * 390 165 * EBML ID already has a UTF8-like represenation 391 166 * so getSizeOfUInt is used to determine … … 397 172 } 398 173 399 /* Writes data size value. */174 /** Writes data size value. */ 400 175 inline void writeSize(uint64_t parm) 401 176 { … … 419 194 writeUnsignedInteger((parm & (((mask << 1) - 1) >> size)) | (mask >> (size - 1)), size); 420 195 } 421 /* Size calculation for variable size UNSIGNED integer. 196 197 /** Size calculation for variable size UNSIGNED integer. 198 * 422 199 * The function defines the size of the number by trimming 423 200 * consequent trailing zero bytes starting from the most significant. … … 730 507 return m_Impl->m_Ebml.getAvailableSpace(); 731 508 } 509 -
trunk/src/VBox/Main/src-client/EbmlWriter.h
r62485 r63160 16 16 */ 17 17 18 /*19 * This code is based on:20 *21 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.22 *23 * Use of this source code is governed by a BSD-style license24 * that can be found in the LICENSE file in the root of the source25 * tree. An additional intellectual property rights grant can be found26 * in the file PATENTS. All contributing project authors may27 * be found in the AUTHORS file in the root of the source tree.28 */29 30 18 #ifndef ____EBMLWRITER 31 19 #define ____EBMLWRITER 32 20 21 #ifdef _MSC_VER 22 # pragma warning(push) 23 # pragma warning(disable: 4668) /* vpx_codec.h(64) : warning C4668: '__GNUC__' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif' */ 33 24 #include <vpx/vpx_encoder.h> 25 # pragma warning(pop) 26 #else 27 # include <vpx/vpx_encoder.h> 28 #endif 34 29 35 30 class WebMWriter_Impl; … … 41 36 virtual ~WebMWriter(); 42 37 43 /* Creates output file38 /** Creates output file 44 39 * 45 40 * @param a_pszFilename Name of the file to create. … … 51 46 void close(); 52 47 53 /* Writes WebM header to file. 48 /** Writes WebM header to file. 49 * 54 50 * Should be called before any writeBlock call. 55 51 * … … 61 57 int writeHeader(const vpx_codec_enc_cfg_t *a_pCfg, const vpx_rational *a_pFps); 62 58 63 /* Writes a block of compressed data59 /** Writes a block of compressed data 64 60 * 65 61 * @param a_pCfg Pointer to VPX Codec configuration structure. … … 70 66 int writeBlock(const vpx_codec_enc_cfg_t *a_pCfg, const vpx_codec_cx_pkt_t *a_pPkt); 71 67 72 /* Writes WebM footer. 68 /** Writes WebM footer. 69 * 73 70 * No other write functions should be called after this one. 71 * 74 72 * @param a_u64Hash Hash value for the data written. 75 73 * … … 78 76 int writeFooter(uint32_t a_u64Hash); 79 77 80 /* Gets current output file size. 78 /** Gets current output file size. 79 * 81 80 * @returns File size in bytes. 82 81 */ 83 82 uint64_t getFileSize(); 84 83 85 /* Gets current free storage space84 /** Gets current free storage space 86 85 * available for the file. 87 86 * … … 91 90 92 91 private: 93 /* WebMWriter implementation.92 /** WebMWriter implementation. 94 93 * To isolate some include files */ 95 94 WebMWriter_Impl *m_Impl; 96 95 97 /* Not defined */ 98 void operator=(const WebMWriter &); 99 WebMWriter(const WebMWriter &); 96 DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP(WebMWriter); 100 97 }; 101 98
Note:
See TracChangeset
for help on using the changeset viewer.