add operation to add generic track
Change-Id: I34e4ab14c0a5b022b77b98d9403125550024e730
This commit is contained in:
parent
21a2bd14c7
commit
38173f9d49
32
mkvmuxer.cpp
32
mkvmuxer.cpp
@ -880,12 +880,22 @@ bool Tracks::AddTrack(Track* track, int32 number) {
|
||||
if (number < 0)
|
||||
return false;
|
||||
|
||||
// This muxer only supports track numbers in the range [1, 126], in
|
||||
// order to be able (to use Matroska integer representation) to
|
||||
// serialize the block header (of which the track number is a part)
|
||||
// for a frame using exactly 4 bytes.
|
||||
|
||||
if (number > 0x7E)
|
||||
return false;
|
||||
|
||||
uint32 track_num = number;
|
||||
|
||||
// Check to make sure a track does not already have |track_num|.
|
||||
for (uint32 i = 0; i < track_entries_size_; ++i) {
|
||||
if (track_entries_[i]->number() == track_num)
|
||||
return false;
|
||||
if (track_num > 0) {
|
||||
// Check to make sure a track does not already have |track_num|.
|
||||
for (uint32 i = 0; i < track_entries_size_; ++i) {
|
||||
if (track_entries_[i]->number() == track_num)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
const uint32 count = track_entries_size_ + 1;
|
||||
@ -1584,6 +1594,20 @@ bool Segment::Finalize() {
|
||||
return true;
|
||||
}
|
||||
|
||||
Track* Segment::AddTrack(int32 number) {
|
||||
Track* const track = new (std::nothrow) Track; // NOLINT
|
||||
|
||||
if (!track)
|
||||
return NULL;
|
||||
|
||||
if (!tracks_.AddTrack(track, number)) {
|
||||
delete track;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return track;
|
||||
}
|
||||
|
||||
uint64 Segment::AddVideoTrack(int32 width, int32 height, int32 number) {
|
||||
VideoTrack* const vid_track = new (std::nothrow) VideoTrack(); // NOLINT
|
||||
if (!vid_track)
|
||||
|
@ -668,6 +668,13 @@ class Segment {
|
||||
// |ptr_writer| is NULL.
|
||||
bool Init(IMkvWriter* ptr_writer);
|
||||
|
||||
// Adds a generic track to the segment. Returns the newly-allocated
|
||||
// track object (which is owned by the segment) on success, NULL on
|
||||
// error. |number| is the number to use for the track. |number|
|
||||
// must be >= 0. If |number| == 0 then the muxer will decide on the
|
||||
// track number.
|
||||
Track* AddTrack(int32 number);
|
||||
|
||||
// Adds an audio track to the segment. Returns the number of the track on
|
||||
// success, 0 on error. |number| is the number to use for the audio track.
|
||||
// |number| must be >= 0. If |number| == 0 then the muxer will decide on
|
||||
|
Loading…
x
Reference in New Issue
Block a user