| OLD | NEW | 
|    1 // Copyright (c) 2012 The WebM project authors. All Rights Reserved. |    1 // Copyright (c) 2012 The WebM project authors. All Rights Reserved. | 
|    2 // |    2 // | 
|    3 // Use of this source code is governed by a BSD-style license |    3 // Use of this source code is governed by a BSD-style license | 
|    4 // that can be found in the LICENSE file in the root of the source |    4 // that can be found in the LICENSE file in the root of the source | 
|    5 // tree. An additional intellectual property rights grant can be found |    5 // tree. An additional intellectual property rights grant can be found | 
|    6 // in the file PATENTS.  All contributing project authors may |    6 // in the file PATENTS.  All contributing project authors may | 
|    7 // be found in the AUTHORS file in the root of the source tree. |    7 // be found in the AUTHORS file in the root of the source tree. | 
|    8  |    8  | 
|    9 #ifndef MKVMUXERUTIL_HPP |    9 #ifndef MKVMUXERUTIL_HPP | 
|   10 #define MKVMUXERUTIL_HPP |   10 #define MKVMUXERUTIL_HPP | 
|   11  |   11  | 
 |   12 #include "mkvmuxer.hpp" | 
|   12 #include "mkvmuxertypes.hpp" |   13 #include "mkvmuxertypes.hpp" | 
|   13  |   14  | 
|   14 namespace mkvmuxer { |   15 namespace mkvmuxer { | 
|   15  |   16  | 
|   16 class IMkvWriter; |   17 class IMkvWriter; | 
|   17  |   18  | 
|   18 const uint64 kEbmlUnknownValue = 0x01FFFFFFFFFFFFFFULL; |   19 const uint64 kEbmlUnknownValue = 0x01FFFFFFFFFFFFFFULL; | 
|   19 const int64 kMaxBlockTimecode = 0x07FFFLL; |   20 const int64 kMaxBlockTimecode = 0x07FFFLL; | 
|   20  |   21  | 
|   21 // Writes out |value| in Big Endian order. Returns 0 on success. |   22 // Writes out |value| in Big Endian order. Returns 0 on success. | 
|   22 int32 SerializeInt(IMkvWriter* writer, int64 value, int32 size); |   23 int32 SerializeInt(IMkvWriter* writer, int64 value, int32 size); | 
|   23  |   24  | 
|   24 // Returns the size in bytes of the element. |   25 // Returns the size in bytes of the element. | 
|   25 int32 GetUIntSize(uint64 value); |   26 int32 GetUIntSize(uint64 value); | 
 |   27 int32 GetIntSize(int64 value); | 
|   26 int32 GetCodedUIntSize(uint64 value); |   28 int32 GetCodedUIntSize(uint64 value); | 
|   27 uint64 EbmlMasterElementSize(uint64 type, uint64 value); |   29 uint64 EbmlMasterElementSize(uint64 type, uint64 value); | 
|   28 uint64 EbmlElementSize(uint64 type, int64 value); |   30 uint64 EbmlElementSize(uint64 type, int64 value); | 
|   29 uint64 EbmlElementSize(uint64 type, uint64 value); |   31 uint64 EbmlElementSize(uint64 type, uint64 value); | 
|   30 uint64 EbmlElementSize(uint64 type, float value); |   32 uint64 EbmlElementSize(uint64 type, float value); | 
|   31 uint64 EbmlElementSize(uint64 type, const char* value); |   33 uint64 EbmlElementSize(uint64 type, const char* value); | 
|   32 uint64 EbmlElementSize(uint64 type, const uint8* value, uint64 size); |   34 uint64 EbmlElementSize(uint64 type, const uint8* value, uint64 size); | 
|   33 uint64 EbmlDateElementSize(uint64 type, int64 value); |   35 uint64 EbmlDateElementSize(uint64 type); | 
|   34  |   36  | 
|   35 // Creates an EBML coded number from |value| and writes it out. The size of |   37 // Creates an EBML coded number from |value| and writes it out. The size of | 
|   36 // the coded number is determined by the value of |value|. |value| must not |   38 // the coded number is determined by the value of |value|. |value| must not | 
|   37 // be in a coded form. Returns 0 on success. |   39 // be in a coded form. Returns 0 on success. | 
|   38 int32 WriteUInt(IMkvWriter* writer, uint64 value); |   40 int32 WriteUInt(IMkvWriter* writer, uint64 value); | 
|   39  |   41  | 
|   40 // Creates an EBML coded number from |value| and writes it out. The size of |   42 // Creates an EBML coded number from |value| and writes it out. The size of | 
|   41 // the coded number is determined by the value of |size|. |value| must not |   43 // the coded number is determined by the value of |size|. |value| must not | 
|   42 // be in a coded form. Returns 0 on success. |   44 // be in a coded form. Returns 0 on success. | 
|   43 int32 WriteUIntSize(IMkvWriter* writer, uint64 value, int32 size); |   45 int32 WriteUIntSize(IMkvWriter* writer, uint64 value, int32 size); | 
|   44  |   46  | 
|   45 // Output an Mkv master element. Returns true if the element was written. |   47 // Output an Mkv master element. Returns true if the element was written. | 
|   46 bool WriteEbmlMasterElement(IMkvWriter* writer, uint64 value, uint64 size); |   48 bool WriteEbmlMasterElement(IMkvWriter* writer, uint64 value, uint64 size); | 
|   47  |   49  | 
|   48 // Outputs an Mkv ID, calls |IMkvWriter::ElementStartNotify|, and passes the |   50 // Outputs an Mkv ID, calls |IMkvWriter::ElementStartNotify|, and passes the | 
|   49 // ID to |SerializeInt|. Returns 0 on success. |   51 // ID to |SerializeInt|. Returns 0 on success. | 
|   50 int32 WriteID(IMkvWriter* writer, uint64 type); |   52 int32 WriteID(IMkvWriter* writer, uint64 type); | 
|   51  |   53  | 
|   52 // Output an Mkv non-master element. Returns true if the element was written. |   54 // Output an Mkv non-master element. Returns true if the element was written. | 
|   53 bool WriteEbmlElement(IMkvWriter* writer, uint64 type, uint64 value); |   55 bool WriteEbmlElement(IMkvWriter* writer, uint64 type, uint64 value); | 
 |   56 bool WriteEbmlElement(IMkvWriter* writer, uint64 type, int64 value); | 
|   54 bool WriteEbmlElement(IMkvWriter* writer, uint64 type, float value); |   57 bool WriteEbmlElement(IMkvWriter* writer, uint64 type, float value); | 
|   55 bool WriteEbmlElement(IMkvWriter* writer, uint64 type, const char* value); |   58 bool WriteEbmlElement(IMkvWriter* writer, uint64 type, const char* value); | 
|   56 bool WriteEbmlElement(IMkvWriter* writer, uint64 type, const uint8* value, |   59 bool WriteEbmlElement(IMkvWriter* writer, uint64 type, const uint8* value, | 
|   57                       uint64 size); |   60                       uint64 size); | 
|   58 bool WriteEbmlDateElement(IMkvWriter* writer, uint64 type, int64 value); |   61 bool WriteEbmlDateElement(IMkvWriter* writer, uint64 type, int64 value); | 
|   59  |   62  | 
|   60 // Output an Mkv Simple Block. |   63 // Output a Mkv Frame. It decides the correct element to write (Block vs | 
|   61 // Inputs: |   64 // SimpleBlock) based on the parameters of the Frame. | 
|   62 //   data:         Pointer to the data. |   65 uint64 WriteFrame(IMkvWriter* writer, const Frame* const frame, | 
|   63 //   length:       Length of the data. |   66                   Cluster* cluster); | 
|   64 //   track_number: Track to add the data to. Value returned by Add track |  | 
|   65 //                  functions.  Only values in the range [1, 126] are |  | 
|   66 //                  permitted. |  | 
|   67 //   timecode:     Relative timecode of the Block.  Only values in the |  | 
|   68 //                  range [0, 2^15) are permitted. |  | 
|   69 //   is_key:       Non-zero value specifies that frame is a key frame. |  | 
|   70 uint64 WriteSimpleBlock(IMkvWriter* writer, const uint8* data, uint64 length, |  | 
|   71                         uint64 track_number, int64 timecode, uint64 is_key); |  | 
|   72  |  | 
|   73 // Output a metadata keyframe, using a Block Group element. |  | 
|   74 // Inputs: |  | 
|   75 //   data:         Pointer to the (meta)data. |  | 
|   76 //   length:       Length of the (meta)data. |  | 
|   77 //   track_number: Track to add the data to. Value returned by Add track |  | 
|   78 //                  functions.  Only values in the range [1, 126] are |  | 
|   79 //                  permitted. |  | 
|   80 //   timecode      Timecode of frame, relative to cluster timecode.  Only |  | 
|   81 //                  values in the range [0, 2^15) are permitted. |  | 
|   82 //   duration_timecode  Duration of frame, using timecode units. |  | 
|   83 uint64 WriteMetadataBlock(IMkvWriter* writer, const uint8* data, uint64 length, |  | 
|   84                           uint64 track_number, int64 timecode, |  | 
|   85                           uint64 duration_timecode); |  | 
|   86  |  | 
|   87 // Output an Mkv Block with BlockAdditional data. |  | 
|   88 // Inputs: |  | 
|   89 //   data:         Pointer to the data. |  | 
|   90 //   length:       Length of the data. |  | 
|   91 //   additional:   Pointer to the additional data |  | 
|   92 //   additional_length: Length of the additional data. |  | 
|   93 //   add_id: Value of BlockAddID element. |  | 
|   94 //   track_number: Track to add the data to. Value returned by Add track |  | 
|   95 //                  functions.  Only values in the range [1, 126] are |  | 
|   96 //                  permitted. |  | 
|   97 //   timecode:     Relative timecode of the Block.  Only values in the |  | 
|   98 //                  range [0, 2^15) are permitted. |  | 
|   99 //   is_key:       Non-zero value specifies that frame is a key frame. |  | 
|  100 uint64 WriteBlockWithAdditional(IMkvWriter* writer, const uint8* data, |  | 
|  101                                 uint64 length, const uint8* additional, |  | 
|  102                                 uint64 additional_length, uint64 add_id, |  | 
|  103                                 uint64 track_number, int64 timecode, |  | 
|  104                                 uint64 is_key); |  | 
|  105  |  | 
|  106 // Output an Mkv Block with a DiscardPadding element. |  | 
|  107 // Inputs: |  | 
|  108 //   data:            Pointer to the data. |  | 
|  109 //   length:          Length of the data. |  | 
|  110 //   discard_padding: DiscardPadding value. |  | 
|  111 //   track_number:    Track to add the data to. Value returned by Add track |  | 
|  112 //                    functions. Only values in the range [1, 126] are |  | 
|  113 //                    permitted. |  | 
|  114 //   timecode:        Relative timecode of the Block.  Only values in the |  | 
|  115 //                    range [0, 2^15) are permitted. |  | 
|  116 //   is_key:          Non-zero value specifies that frame is a key frame. |  | 
|  117 uint64 WriteBlockWithDiscardPadding(IMkvWriter* writer, const uint8* data, |  | 
|  118                                     uint64 length, int64 discard_padding, |  | 
|  119                                     uint64 track_number, int64 timecode, |  | 
|  120                                     uint64 is_key); |  | 
|  121  |   67  | 
|  122 // Output a void element. |size| must be the entire size in bytes that will be |   68 // Output a void element. |size| must be the entire size in bytes that will be | 
|  123 // void. The function will calculate the size of the void header and subtract |   69 // void. The function will calculate the size of the void header and subtract | 
|  124 // it from |size|. |   70 // it from |size|. | 
|  125 uint64 WriteVoidElement(IMkvWriter* writer, uint64 size); |   71 uint64 WriteVoidElement(IMkvWriter* writer, uint64 size); | 
|  126  |   72  | 
|  127 // Returns the version number of the muxer in |major|, |minor|, |build|, |   73 // Returns the version number of the muxer in |major|, |minor|, |build|, | 
|  128 // and |revision|. |   74 // and |revision|. | 
|  129 void GetVersion(int32* major, int32* minor, int32* build, int32* revision); |   75 void GetVersion(int32* major, int32* minor, int32* build, int32* revision); | 
|  130  |   76  | 
|  131 // Returns a random number to be used for UID, using |seed| to seed |   77 // Returns a random number to be used for UID, using |seed| to seed | 
|  132 // the random-number generator (see POSIX rand_r() for semantics). |   78 // the random-number generator (see POSIX rand_r() for semantics). | 
|  133 uint64 MakeUID(unsigned int* seed); |   79 uint64 MakeUID(unsigned int* seed); | 
|  134  |   80  | 
|  135 }  // end namespace mkvmuxer |   81 }  // end namespace mkvmuxer | 
|  136  |   82  | 
|  137 #endif  // MKVMUXERUTIL_HPP |   83 #endif  // MKVMUXERUTIL_HPP | 
| OLD | NEW |