clang-format on mkvmuxer.[ch]pp

Conformance of mkvmuxer.[ch]pp to Google C++ style guide.

Change-Id: I9bcd14710adbad4f32aa1a6be2ea7e40fb715e91
This commit is contained in:
Vignesh Venkatasubramanian 2014-04-11 11:41:01 -07:00
parent ce775929a6
commit fb6b6e6444
2 changed files with 276 additions and 519 deletions

File diff suppressed because it is too large Load Diff

View File

@ -15,7 +15,7 @@
// http://www.webmproject.org/code/specs/container/. // http://www.webmproject.org/code/specs/container/.
namespace mkvparser { namespace mkvparser {
class IMkvReader; class IMkvReader;
} // end namespace } // end namespace
namespace mkvmuxer { namespace mkvmuxer {
@ -60,8 +60,8 @@ class IMkvWriter {
bool WriteEbmlHeader(IMkvWriter* writer); bool WriteEbmlHeader(IMkvWriter* writer);
// Copies in Chunk from source to destination between the given byte positions // Copies in Chunk from source to destination between the given byte positions
bool ChunkedCopy(mkvparser::IMkvReader* source, IMkvWriter* dst, bool ChunkedCopy(mkvparser::IMkvReader* source, IMkvWriter* dst, int64 start,
int64 start, int64 size); int64 size);
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////
// Class to hold data the will be written to a block. // Class to hold data the will be written to a block.
@ -74,8 +74,7 @@ class Frame {
bool Init(const uint8* frame, uint64 length); bool Init(const uint8* frame, uint64 length);
// Copies |additional| data into |additional_|. Returns true on success. // Copies |additional| data into |additional_|. Returns true on success.
bool AddAdditionalData(const uint8* additional, uint64 length, bool AddAdditionalData(const uint8* additional, uint64 length, uint64 add_id);
uint64 add_id);
uint64 add_id() const { return add_id_; } uint64 add_id() const { return add_id_; }
const uint8* additional() const { return additional_; } const uint8* additional() const { return additional_; }
@ -223,9 +222,7 @@ class Cues {
// ContentEncAESSettings element // ContentEncAESSettings element
class ContentEncAESSettings { class ContentEncAESSettings {
public: public:
enum { enum { kCTR = 1 };
kCTR = 1
};
ContentEncAESSettings(); ContentEncAESSettings();
~ContentEncAESSettings() {} ~ContentEncAESSettings() {}
@ -396,16 +393,13 @@ class VideoTrack : public Track {
// Supported modes for stereo 3D. // Supported modes for stereo 3D.
enum StereoMode { enum StereoMode {
kMono = 0, kMono = 0,
kSideBySideLeftIsFirst = 1, kSideBySideLeftIsFirst = 1,
kTopBottomRightIsFirst = 2, kTopBottomRightIsFirst = 2,
kTopBottomLeftIsFirst = 3, kTopBottomLeftIsFirst = 3,
kSideBySideRightIsFirst = 11 kSideBySideRightIsFirst = 11
}; };
enum AlphaMode { enum AlphaMode { kNoAlpha = 0, kAlpha = 1 };
kNoAlpha = 0,
kAlpha = 1
};
// The |seed| parameter is used to synthesize a UID for the track. // The |seed| parameter is used to synthesize a UID for the track.
explicit VideoTrack(unsigned int* seed); explicit VideoTrack(unsigned int* seed);
@ -489,10 +483,7 @@ class AudioTrack : public Track {
class Tracks { class Tracks {
public: public:
// Audio and video type defined by the Matroska specs. // Audio and video type defined by the Matroska specs.
enum { enum { kVideo = 0x1, kAudio = 0x2 };
kVideo = 0x1,
kAudio = 0x2
};
// Opus, Vorbis, VP8, and VP9 codec ids defined by the Matroska specs. // Opus, Vorbis, VP8, and VP9 codec ids defined by the Matroska specs.
static const char kOpusCodecId[]; static const char kOpusCodecId[];
static const char kVorbisCodecId[]; static const char kVorbisCodecId[];
@ -549,8 +540,7 @@ class Chapter {
// Converts the nanosecond start and stop times of this chapter to // Converts the nanosecond start and stop times of this chapter to
// their corresponding timecode values, and stores them that way. // their corresponding timecode values, and stores them that way.
void set_time(const Segment& segment, void set_time(const Segment& segment, uint64 start_time_ns,
uint64 start_time_ns,
uint64 end_time_ns); uint64 end_time_ns);
// Sets the uid for this chapter. Primarily used to enable // Sets the uid for this chapter. Primarily used to enable
@ -573,9 +563,7 @@ class Chapter {
// http://www.iana.org/domains/root/db/ // http://www.iana.org/domains/root/db/
// //
// The function returns false if the string could not be allocated. // The function returns false if the string could not be allocated.
bool add_string(const char* title, bool add_string(const char* title, const char* language, const char* country);
const char* language,
const char* country);
private: private:
friend class Chapters; friend class Chapters;
@ -729,9 +717,7 @@ class Cluster {
// timecode: Absolute (not relative to cluster) timestamp of the // timecode: Absolute (not relative to cluster) timestamp of the
// frame, expressed in timecode units. // frame, expressed in timecode units.
// is_key: Flag telling whether or not this frame is a key frame. // is_key: Flag telling whether or not this frame is a key frame.
bool AddFrame(const uint8* frame, bool AddFrame(const uint8* frame, uint64 length, uint64 track_number,
uint64 length,
uint64 track_number,
uint64 timecode, // timecode units (absolute) uint64 timecode, // timecode units (absolute)
bool is_key); bool is_key);
@ -748,14 +734,10 @@ class Cluster {
// abs_timecode: Absolute (not relative to cluster) timestamp of the // abs_timecode: Absolute (not relative to cluster) timestamp of the
// frame, expressed in timecode units. // frame, expressed in timecode units.
// is_key: Flag telling whether or not this frame is a key frame. // is_key: Flag telling whether or not this frame is a key frame.
bool AddFrameWithAdditional(const uint8* frame, bool AddFrameWithAdditional(const uint8* frame, uint64 length,
uint64 length, const uint8* additional, uint64 additional_length,
const uint8* additional, uint64 add_id, uint64 track_number,
uint64 additional_length, uint64 abs_timecode, bool is_key);
uint64 add_id,
uint64 track_number,
uint64 abs_timecode,
bool is_key);
// Adds a frame to be output in the file. The frame is written out through // Adds a frame to be output in the file. The frame is written out through
// |writer_| if successful. Returns true on success. // |writer_| if successful. Returns true on success.
@ -768,12 +750,9 @@ class Cluster {
// abs_timecode: Absolute (not relative to cluster) timestamp of the // abs_timecode: Absolute (not relative to cluster) timestamp of the
// frame, expressed in timecode units. // frame, expressed in timecode units.
// is_key: Flag telling whether or not this frame is a key frame. // is_key: Flag telling whether or not this frame is a key frame.
bool AddFrameWithDiscardPadding(const uint8* frame, bool AddFrameWithDiscardPadding(const uint8* frame, uint64 length,
uint64 length, int64 discard_padding, uint64 track_number,
int64 discard_padding, uint64 abs_timecode, bool is_key);
uint64 track_number,
uint64 abs_timecode,
bool is_key);
// Writes a frame of metadata to the output medium; returns true on // Writes a frame of metadata to the output medium; returns true on
// success. // success.
@ -789,10 +768,8 @@ class Cluster {
// The metadata frame is written as a block group, with a duration // The metadata frame is written as a block group, with a duration
// sub-element but no reference time sub-elements (indicating that // sub-element but no reference time sub-elements (indicating that
// it is considered a keyframe, per Matroska semantics). // it is considered a keyframe, per Matroska semantics).
bool AddMetadata(const uint8* frame, bool AddMetadata(const uint8* frame, uint64 length, uint64 track_number,
uint64 length, uint64 timecode, // timecode units (absolute)
uint64 track_number,
uint64 timecode, // timecode units (absolute)
uint64 duration); // timecode units uint64 duration); // timecode units
// Increments the size of the cluster's data in bytes. // Increments the size of the cluster's data in bytes.
@ -814,34 +791,26 @@ class Cluster {
private: private:
// Signature that matches either of WriteSimpleBlock or WriteMetadataBlock // Signature that matches either of WriteSimpleBlock or WriteMetadataBlock
// in the muxer utilities package. // in the muxer utilities package.
typedef uint64 (*WriteBlock)(IMkvWriter* writer, typedef uint64 (*WriteBlock)(IMkvWriter* writer, const uint8* data,
const uint8* data, uint64 length, uint64 track_number,
uint64 length, int64 timecode, uint64 generic_arg);
uint64 track_number,
int64 timecode,
uint64 generic_arg);
// Signature that matches WriteBlockWithAdditional // Signature that matches WriteBlockWithAdditional
// in the muxer utilities package. // in the muxer utilities package.
typedef uint64 (*WriteBlockAdditional)(IMkvWriter* writer, typedef uint64 (*WriteBlockAdditional)(IMkvWriter* writer, const uint8* data,
const uint8* data, uint64 length, const uint8* additional,
uint64 length,
const uint8* additional,
uint64 add_id, uint64 add_id,
uint64 additional_length, uint64 additional_length,
uint64 track_number, uint64 track_number, int64 timecode,
int64 timecode,
uint64 is_key); uint64 is_key);
// Signature that matches WriteBlockWithDiscardPadding // Signature that matches WriteBlockWithDiscardPadding
// in the muxer utilities package. // in the muxer utilities package.
typedef uint64 (*WriteBlockDiscardPadding)(IMkvWriter* writer, typedef uint64 (*WriteBlockDiscardPadding)(IMkvWriter* writer,
const uint8* data, const uint8* data, uint64 length,
uint64 length,
int64 discard_padding, int64 discard_padding,
uint64 track_number, uint64 track_number,
int64 timecode, int64 timecode, uint64 is_key);
uint64 is_key);
// Utility method that confirms that blocks can still be added, and that the // Utility method that confirms that blocks can still be added, and that the
// cluster header has been written. Used by |DoWriteBlock*|. Returns true // cluster header has been written. Used by |DoWriteBlock*|. Returns true
@ -863,27 +832,20 @@ class Cluster {
int64 GetRelativeTimecode(int64 abs_timecode) const; int64 GetRelativeTimecode(int64 abs_timecode) const;
// Used to implement AddFrame and AddMetadata. // Used to implement AddFrame and AddMetadata.
bool DoWriteBlock(const uint8* frame, bool DoWriteBlock(const uint8* frame, uint64 length, uint64 track_number,
uint64 length, uint64 absolute_timecode, uint64 generic_arg,
uint64 track_number,
uint64 absolute_timecode,
uint64 generic_arg,
WriteBlock write_block); WriteBlock write_block);
// Used to implement AddFrameWithAdditional // Used to implement AddFrameWithAdditional
bool DoWriteBlockWithAdditional(const uint8* frame, bool DoWriteBlockWithAdditional(const uint8* frame, uint64 length,
uint64 length,
const uint8* additional, const uint8* additional,
uint64 additional_length, uint64 additional_length, uint64 add_id,
uint64 add_id, uint64 track_number, uint64 absolute_timecode,
uint64 track_number,
uint64 absolute_timecode,
uint64 generic_arg, uint64 generic_arg,
WriteBlockAdditional write_block); WriteBlockAdditional write_block);
// Used to implement AddFrameWithDiscardPadding // Used to implement AddFrameWithDiscardPadding
bool DoWriteBlockWithDiscardPadding(const uint8* frame, bool DoWriteBlockWithDiscardPadding(const uint8* frame, uint64 length,
uint64 length,
int64 discard_padding, int64 discard_padding,
uint64 track_number, uint64 track_number,
uint64 absolute_timecode, uint64 absolute_timecode,
@ -1028,10 +990,7 @@ class SegmentInfo {
// |Init| must be called before any other method in this class. // |Init| must be called before any other method in this class.
class Segment { class Segment {
public: public:
enum Mode { enum Mode { kLive = 0x1, kFile = 0x2 };
kLive = 0x1,
kFile = 0x2
};
enum CuesPosition { enum CuesPosition {
kAfterClusters = 0x0, // Position Cues after Clusters - Default kAfterClusters = 0x0, // Position Cues after Clusters - Default
@ -1079,11 +1038,8 @@ class Segment {
// functions. // functions.
// timestamp: Timestamp of the frame in nanoseconds from 0. // timestamp: Timestamp of the frame in nanoseconds from 0.
// is_key: Flag telling whether or not this frame is a key frame. // is_key: Flag telling whether or not this frame is a key frame.
bool AddFrame(const uint8* frame, bool AddFrame(const uint8* frame, uint64 length, uint64 track_number,
uint64 length, uint64 timestamp_ns, bool is_key);
uint64 track_number,
uint64 timestamp_ns,
bool is_key);
// Writes a frame of metadata to the output medium; returns true on // Writes a frame of metadata to the output medium; returns true on
// success. // success.
@ -1099,11 +1055,8 @@ class Segment {
// The metadata frame is written as a block group, with a duration // The metadata frame is written as a block group, with a duration
// sub-element but no reference time sub-elements (indicating that // sub-element but no reference time sub-elements (indicating that
// it is considered a keyframe, per Matroska semantics). // it is considered a keyframe, per Matroska semantics).
bool AddMetadata(const uint8* frame, bool AddMetadata(const uint8* frame, uint64 length, uint64 track_number,
uint64 length, uint64 timestamp_ns, uint64 duration_ns);
uint64 track_number,
uint64 timestamp_ns,
uint64 duration_ns);
// Writes a frame with additional data to the output medium; returns true on // Writes a frame with additional data to the output medium; returns true on
// success. // success.
@ -1118,14 +1071,10 @@ class Segment {
// timestamp: Absolute timestamp of the frame, expressed in nanosecond // timestamp: Absolute timestamp of the frame, expressed in nanosecond
// units. // units.
// is_key: Flag telling whether or not this frame is a key frame. // is_key: Flag telling whether or not this frame is a key frame.
bool AddFrameWithAdditional(const uint8* frame, bool AddFrameWithAdditional(const uint8* frame, uint64 length,
uint64 length, const uint8* additional, uint64 additional_length,
const uint8* additional, uint64 add_id, uint64 track_number,
uint64 additional_length, uint64 timestamp, bool is_key);
uint64 add_id,
uint64 track_number,
uint64 timestamp,
bool is_key);
// Writes a frame with DiscardPadding to the output medium; returns true on // Writes a frame with DiscardPadding to the output medium; returns true on
// success. // success.
@ -1138,12 +1087,9 @@ class Segment {
// timestamp: Absolute timestamp of the frame, expressed in nanosecond // timestamp: Absolute timestamp of the frame, expressed in nanosecond
// units. // units.
// is_key: Flag telling whether or not this frame is a key frame. // is_key: Flag telling whether or not this frame is a key frame.
bool AddFrameWithDiscardPadding(const uint8* frame, bool AddFrameWithDiscardPadding(const uint8* frame, uint64 length,
uint64 length, int64 discard_padding, uint64 track_number,
int64 discard_padding, uint64 timestamp, bool is_key);
uint64 track_number,
uint64 timestamp,
bool is_key);
// Writes a Frame to the output medium. Chooses the correct way of writing // Writes a Frame to the output medium. Chooses the correct way of writing
// the frame (Block vs SimpleBlock) based on the parameters passed. // the frame (Block vs SimpleBlock) based on the parameters passed.
@ -1277,7 +1223,6 @@ class Segment {
// was necessary but creation was not successful. // was necessary but creation was not successful.
bool DoNewClusterProcessing(uint64 track_num, uint64 timestamp_ns, bool key); bool DoNewClusterProcessing(uint64 track_num, uint64 timestamp_ns, bool key);
// Adjusts Cue Point values (to place Cues before Clusters) so that they // Adjusts Cue Point values (to place Cues before Clusters) so that they
// reflect the correct offsets. // reflect the correct offsets.
void MoveCuesBeforeClusters(); void MoveCuesBeforeClusters();
@ -1407,6 +1352,6 @@ class Segment {
LIBWEBM_DISALLOW_COPY_AND_ASSIGN(Segment); LIBWEBM_DISALLOW_COPY_AND_ASSIGN(Segment);
}; };
} //end namespace mkvmuxer } // end namespace mkvmuxer
#endif //MKVMUXER_HPP #endif // MKVMUXER_HPP