| OLD | NEW |
| 1 // Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 1 // Copyright (c) 2010 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 | 9 |
| 10 | 10 |
| 11 #include "EbmlIDs.h" | 11 #include "EbmlIDs.h" |
| 12 #include "EbmlBufferWriter.h" | 12 #include "EbmlBufferWriter.h" |
| 13 #include "WebMElement.h" | 13 #include "WebMElement.h" |
| 14 | 14 |
| 15 #include <stdio.h> | 15 #include <stdio.h> |
| 16 int main(int argc, char *argv[]) | 16 int main(int argc, char *argv[]) { |
| 17 { | 17 // init the datatype we're using for ebml output |
| 18 //init the datatype we're using for ebml output | 18 unsigned char data[8192]; |
| 19 unsigned char data[8192]; | 19 EbmlGlobal ebml; |
| 20 EbmlGlobal ebml; | 20 ebml.buf = data; |
| 21 ebml.buf = data; | 21 ebml.offset = 0; |
| 22 ebml.offset = 0; | 22 ebml.length = 8192; |
| 23 ebml.length = 8192; | |
| 24 | 23 |
| 25 writeHeader(&ebml); | 24 writeHeader(&ebml); |
| 25 { |
| 26 EbmlLoc startSegment; |
| 27 Ebml_StartSubElement(&ebml, &startSegment, Segment); // segment |
| 26 { | 28 { |
| 27 EbmlLoc startSegment; | 29 // segment info |
| 28 Ebml_StartSubElement(&ebml, &startSegment, Segment); //segment | 30 EbmlLoc startInfo; |
| 29 { | 31 Ebml_StartSubElement(&ebml, &startInfo, Info); |
| 30 //segment info | 32 Ebml_SerializeString(&ebml, 0x4D80, "muxingAppLibMkv"); |
| 31 EbmlLoc startInfo; | 33 Ebml_SerializeString(&ebml, 0x5741, "writingAppLibMkv"); |
| 32 Ebml_StartSubElement(&ebml, &startInfo, Info); | 34 Ebml_EndSubElement(&ebml, &startInfo); |
| 33 Ebml_SerializeString(&ebml, 0x4D80, "muxingAppLibMkv"); | |
| 34 Ebml_SerializeString(&ebml, 0x5741, "writingAppLibMkv"); | |
| 35 Ebml_EndSubElement(&ebml, &startInfo); | |
| 36 } | |
| 37 | |
| 38 { | |
| 39 EbmlLoc trackStart; | |
| 40 Ebml_StartSubElement(&ebml, &trackStart, Tracks); | |
| 41 writeVideoTrack(&ebml, 1, 1, "V_MS/VFW/FOURCC", 320, 240, 29.97); | |
| 42 //writeAudioTrack(&ebml,2,1, "A_VORBIS", 32000, 1, NULL, 0); | |
| 43 Ebml_EndSubElement(&ebml, &trackStart); | |
| 44 } | |
| 45 | |
| 46 { | |
| 47 EbmlLoc clusterStart; | |
| 48 Ebml_StartSubElement(&ebml, &clusterStart, Cluster); //cluster | |
| 49 Ebml_SerializeUnsigned(&ebml, Timecode, 0); | |
| 50 | |
| 51 unsigned char someData[4] = {1, 2, 3, 4}; | |
| 52 writeSimpleBlock(&ebml, 1, 0, 1, 0, 0, someData, 4); | |
| 53 Ebml_EndSubElement(&ebml, &clusterStart); | |
| 54 } //end cluster | |
| 55 Ebml_EndSubElement(&ebml, &startSegment); | |
| 56 } | 35 } |
| 57 | 36 |
| 58 //dump ebml stuff to the file | 37 { |
| 59 FILE *file_out = fopen("test.mkv", "wb"); | 38 EbmlLoc trackStart; |
| 60 size_t bytesWritten = fwrite(data, 1, ebml.offset, file_out); | 39 Ebml_StartSubElement(&ebml, &trackStart, Tracks); |
| 61 fclose(file_out); | 40 writeVideoTrack(&ebml, 1, 1, "V_MS/VFW/FOURCC", 320, 240, 29.97); |
| 62 return 0; | 41 // writeAudioTrack(&ebml,2,1, "A_VORBIS", 32000, 1, NULL, 0); |
| 42 Ebml_EndSubElement(&ebml, &trackStart); |
| 43 } |
| 44 |
| 45 { |
| 46 EbmlLoc clusterStart; |
| 47 Ebml_StartSubElement(&ebml, &clusterStart, Cluster); // cluster |
| 48 Ebml_SerializeUnsigned(&ebml, Timecode, 0); |
| 49 |
| 50 unsigned char someData[4] = {1, 2, 3, 4}; |
| 51 writeSimpleBlock(&ebml, 1, 0, 1, 0, 0, someData, 4); |
| 52 Ebml_EndSubElement(&ebml, &clusterStart); |
| 53 } // end cluster |
| 54 Ebml_EndSubElement(&ebml, &startSegment); |
| 55 } |
| 56 |
| 57 // dump ebml stuff to the file |
| 58 FILE *file_out = fopen("test.mkv", "wb"); |
| 59 size_t bytesWritten = fwrite(data, 1, ebml.offset, file_out); |
| 60 fclose(file_out); |
| 61 return 0; |
| 63 } | 62 } |
| OLD | NEW |