Merge "Set VPX_FRAME_IS_DROPPABLE"
[libvpx.git] / libmkv / testlibmkv.c
blob7edfc43470fd93d740d95ad0b55be244c9a183d5
1 // Copyright (c) 2010 The WebM project authors. All Rights Reserved.
2 //
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
5 // tree. An additional intellectual property rights grant can be found
6 // in the file PATENTS. All contributing project authors may
7 // be found in the AUTHORS file in the root of the source tree.
11 #include "EbmlIDs.h"
12 #include "EbmlBufferWriter.h"
13 #include "WebMElement.h"
15 #include <stdio.h>
16 int main(int argc, char *argv[])
18 //init the datatype we're using for ebml output
19 unsigned char data[8192];
20 EbmlGlobal ebml;
21 ebml.buf = data;
22 ebml.offset = 0;
23 ebml.length = 8192;
25 writeHeader(&ebml);
27 EbmlLoc startSegment;
28 Ebml_StartSubElement(&ebml, &startSegment, Segment); //segment
30 //segment info
31 EbmlLoc startInfo;
32 Ebml_StartSubElement(&ebml, &startInfo, Info);
33 Ebml_SerializeString(&ebml, 0x4D80, "muxingAppLibMkv");
34 Ebml_SerializeString(&ebml, 0x5741, "writingAppLibMkv");
35 Ebml_EndSubElement(&ebml, &startInfo);
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);
47 EbmlLoc clusterStart;
48 Ebml_StartSubElement(&ebml, &clusterStart, Cluster); //cluster
49 Ebml_SerializeUnsigned(&ebml, Timecode, 0);
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);
58 //dump ebml stuff to the file
59 FILE *file_out = fopen("test.mkv", "wb");
60 size_t bytesWritten = fwrite(data, 1, ebml.offset, file_out);
61 fclose(file_out);
62 return 0;