2012-01-23 16:41:50 -05:00
|
|
|
// Copyright (c) 2012 The WebM project authors. All Rights Reserved.
|
2011-06-21 14:42:55 -04:00
|
|
|
//
|
|
|
|
// Use of this source code is governed by a BSD-style license
|
|
|
|
// that can be found in the LICENSE file in the root of the source
|
|
|
|
// tree. An additional intellectual property rights grant can be found
|
|
|
|
// in the file PATENTS. All contributing project authors may
|
|
|
|
// be found in the AUTHORS file in the root of the source tree.
|
2016-03-18 11:16:35 -07:00
|
|
|
#ifndef MKVMUXER_MKVMUXERUTIL_HPP_
|
|
|
|
#define MKVMUXER_MKVMUXERUTIL_HPP_
|
2011-06-21 14:42:55 -04:00
|
|
|
|
2016-03-16 21:14:26 -07:00
|
|
|
#include <stdint.h>
|
2011-06-21 14:42:55 -04:00
|
|
|
|
2016-03-18 09:32:52 -07:00
|
|
|
namespace libwebm {
|
2011-06-21 14:42:55 -04:00
|
|
|
namespace mkvmuxer {
|
2016-03-09 14:22:28 -08:00
|
|
|
class Cluster;
|
|
|
|
class Frame;
|
2011-06-21 14:42:55 -04:00
|
|
|
class IMkvWriter;
|
|
|
|
|
2016-03-16 21:14:26 -07:00
|
|
|
const uint64_t kEbmlUnknownValue = 0x01FFFFFFFFFFFFFFULL;
|
|
|
|
const int64_t kMaxBlockTimecode = 0x07FFFLL;
|
2011-06-21 14:42:55 -04:00
|
|
|
|
|
|
|
// Writes out |value| in Big Endian order. Returns 0 on success.
|
2016-03-16 21:14:26 -07:00
|
|
|
int32_t SerializeInt(IMkvWriter* writer, int64_t value, int32_t size);
|
2011-06-21 14:42:55 -04:00
|
|
|
|
2012-01-24 18:21:54 -05:00
|
|
|
// Returns the size in bytes of the element.
|
2016-03-16 21:14:26 -07:00
|
|
|
int32_t GetUIntSize(uint64_t value);
|
|
|
|
int32_t GetIntSize(int64_t value);
|
|
|
|
int32_t GetCodedUIntSize(uint64_t value);
|
|
|
|
uint64_t EbmlMasterElementSize(uint64_t type, uint64_t value);
|
|
|
|
uint64_t EbmlElementSize(uint64_t type, int64_t value);
|
|
|
|
uint64_t EbmlElementSize(uint64_t type, uint64_t value);
|
|
|
|
uint64_t EbmlElementSize(uint64_t type, float value);
|
|
|
|
uint64_t EbmlElementSize(uint64_t type, const char* value);
|
|
|
|
uint64_t EbmlElementSize(uint64_t type, const uint8_t* value, uint64_t size);
|
|
|
|
uint64_t EbmlDateElementSize(uint64_t type);
|
2011-06-21 14:42:55 -04:00
|
|
|
|
|
|
|
// Creates an EBML coded number from |value| and writes it out. The size of
|
|
|
|
// the coded number is determined by the value of |value|. |value| must not
|
|
|
|
// be in a coded form. Returns 0 on success.
|
2016-03-16 21:14:26 -07:00
|
|
|
int32_t WriteUInt(IMkvWriter* writer, uint64_t value);
|
2011-06-21 14:42:55 -04:00
|
|
|
|
|
|
|
// Creates an EBML coded number from |value| and writes it out. The size of
|
|
|
|
// the coded number is determined by the value of |size|. |value| must not
|
|
|
|
// be in a coded form. Returns 0 on success.
|
2016-03-16 21:14:26 -07:00
|
|
|
int32_t WriteUIntSize(IMkvWriter* writer, uint64_t value, int32_t size);
|
2011-06-21 14:42:55 -04:00
|
|
|
|
|
|
|
// Output an Mkv master element. Returns true if the element was written.
|
2016-03-16 21:14:26 -07:00
|
|
|
bool WriteEbmlMasterElement(IMkvWriter* writer, uint64_t value, uint64_t size);
|
2011-06-21 14:42:55 -04:00
|
|
|
|
2012-01-23 16:41:50 -05:00
|
|
|
// Outputs an Mkv ID, calls |IMkvWriter::ElementStartNotify|, and passes the
|
|
|
|
// ID to |SerializeInt|. Returns 0 on success.
|
2016-03-16 21:14:26 -07:00
|
|
|
int32_t WriteID(IMkvWriter* writer, uint64_t type);
|
2012-01-23 16:41:50 -05:00
|
|
|
|
2011-06-21 14:42:55 -04:00
|
|
|
// Output an Mkv non-master element. Returns true if the element was written.
|
2016-03-16 21:14:26 -07:00
|
|
|
bool WriteEbmlElement(IMkvWriter* writer, uint64_t type, uint64_t value);
|
|
|
|
bool WriteEbmlElement(IMkvWriter* writer, uint64_t type, int64_t value);
|
|
|
|
bool WriteEbmlElement(IMkvWriter* writer, uint64_t type, float value);
|
|
|
|
bool WriteEbmlElement(IMkvWriter* writer, uint64_t type, const char* value);
|
|
|
|
bool WriteEbmlElement(IMkvWriter* writer, uint64_t type, const uint8_t* value,
|
|
|
|
uint64_t size);
|
|
|
|
bool WriteEbmlDateElement(IMkvWriter* writer, uint64_t type, int64_t value);
|
2011-06-21 14:42:55 -04:00
|
|
|
|
2015-05-07 13:58:33 -07:00
|
|
|
// Output a Mkv Frame. It decides the correct element to write (Block vs
|
|
|
|
// SimpleBlock) based on the parameters of the Frame.
|
2016-03-16 21:14:26 -07:00
|
|
|
uint64_t WriteFrame(IMkvWriter* writer, const Frame* const frame,
|
|
|
|
Cluster* cluster);
|
2014-01-22 23:26:26 -08:00
|
|
|
|
2011-06-21 14:42:55 -04:00
|
|
|
// Output a void element. |size| must be the entire size in bytes that will be
|
|
|
|
// void. The function will calculate the size of the void header and subtract
|
|
|
|
// it from |size|.
|
2016-03-16 21:14:26 -07:00
|
|
|
uint64_t WriteVoidElement(IMkvWriter* writer, uint64_t size);
|
2011-06-21 14:42:55 -04:00
|
|
|
|
|
|
|
// Returns the version number of the muxer in |major|, |minor|, |build|,
|
|
|
|
// and |revision|.
|
2016-03-16 21:14:26 -07:00
|
|
|
void GetVersion(int32_t* major, int32_t* minor, int32_t* build,
|
|
|
|
int32_t* revision);
|
2011-06-21 14:42:55 -04:00
|
|
|
|
2012-10-18 16:22:35 -07:00
|
|
|
// Returns a random number to be used for UID, using |seed| to seed
|
|
|
|
// the random-number generator (see POSIX rand_r() for semantics).
|
2016-03-16 21:14:26 -07:00
|
|
|
uint64_t MakeUID(unsigned int* seed);
|
2012-10-18 16:22:35 -07:00
|
|
|
|
2016-03-18 09:32:52 -07:00
|
|
|
} // namespace mkvmuxer
|
|
|
|
} // namespace libwebm
|
2011-06-21 14:42:55 -04:00
|
|
|
|
2016-03-18 11:16:35 -07:00
|
|
|
#endif // MKVMUXER_MKVMUXERUTIL_HPP_
|