Use scoped_ptr for box ownership transfer
MP4Muxer passes ownership of ftyp and moov box to MP4Segmenter. Change-Id: Iae7c7161560c744d8d3e7e5382450e7d056112ec
This commit is contained in:
parent
1b5c3b5316
commit
0f3056b551
|
@ -16,14 +16,14 @@ namespace media {
|
||||||
namespace mp4 {
|
namespace mp4 {
|
||||||
|
|
||||||
MP4GeneralSegmenter::MP4GeneralSegmenter(const MuxerOptions& options,
|
MP4GeneralSegmenter::MP4GeneralSegmenter(const MuxerOptions& options,
|
||||||
FileType* ftyp,
|
scoped_ptr<FileType> ftyp,
|
||||||
Movie* moov)
|
scoped_ptr<Movie> moov)
|
||||||
: MP4Segmenter(options, ftyp, moov),
|
: MP4Segmenter(options, ftyp.Pass(), moov.Pass()),
|
||||||
styp_(new SegmentType),
|
styp_(new SegmentType),
|
||||||
num_segments_(0) {
|
num_segments_(0) {
|
||||||
// Use the same brands for styp as ftyp.
|
// Use the same brands for styp as ftyp.
|
||||||
styp_->major_brand = ftyp->major_brand;
|
styp_->major_brand = MP4Segmenter::ftyp()->major_brand;
|
||||||
styp_->compatible_brands = ftyp->compatible_brands;
|
styp_->compatible_brands = MP4Segmenter::ftyp()->compatible_brands;
|
||||||
}
|
}
|
||||||
|
|
||||||
MP4GeneralSegmenter::~MP4GeneralSegmenter() {}
|
MP4GeneralSegmenter::~MP4GeneralSegmenter() {}
|
||||||
|
|
|
@ -29,7 +29,9 @@ struct SegmentType;
|
||||||
class MP4GeneralSegmenter : public MP4Segmenter {
|
class MP4GeneralSegmenter : public MP4Segmenter {
|
||||||
public:
|
public:
|
||||||
// Caller transfers the ownership of |ftyp| and |moov| to this class.
|
// Caller transfers the ownership of |ftyp| and |moov| to this class.
|
||||||
MP4GeneralSegmenter(const MuxerOptions& options, FileType* ftyp, Movie* moov);
|
MP4GeneralSegmenter(const MuxerOptions& options,
|
||||||
|
scoped_ptr<FileType> ftyp,
|
||||||
|
scoped_ptr<Movie> moov);
|
||||||
~MP4GeneralSegmenter();
|
~MP4GeneralSegmenter();
|
||||||
|
|
||||||
// MP4Segmenter implementations.
|
// MP4Segmenter implementations.
|
||||||
|
|
|
@ -93,10 +93,10 @@ Status MP4Muxer::Initialize() {
|
||||||
|
|
||||||
if (options().single_segment) {
|
if (options().single_segment) {
|
||||||
segmenter_.reset(
|
segmenter_.reset(
|
||||||
new MP4VODSegmenter(options(), ftyp.release(), moov.release()));
|
new MP4VODSegmenter(options(), ftyp.Pass(), moov.Pass()));
|
||||||
} else {
|
} else {
|
||||||
segmenter_.reset(
|
segmenter_.reset(
|
||||||
new MP4GeneralSegmenter(options(), ftyp.release(), moov.release()));
|
new MP4GeneralSegmenter(options(), ftyp.Pass(), moov.Pass()));
|
||||||
}
|
}
|
||||||
return segmenter_->Initialize(encryptor_source(), streams());
|
return segmenter_->Initialize(encryptor_source(), streams());
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,12 +26,12 @@ namespace media {
|
||||||
namespace mp4 {
|
namespace mp4 {
|
||||||
|
|
||||||
MP4Segmenter::MP4Segmenter(const MuxerOptions& options,
|
MP4Segmenter::MP4Segmenter(const MuxerOptions& options,
|
||||||
FileType* ftyp,
|
scoped_ptr<FileType> ftyp,
|
||||||
Movie* moov)
|
scoped_ptr<Movie> moov)
|
||||||
: options_(options),
|
: options_(options),
|
||||||
fragment_buffer_(new BufferWriter()),
|
fragment_buffer_(new BufferWriter()),
|
||||||
ftyp_(ftyp),
|
ftyp_(ftyp.Pass()),
|
||||||
moov_(moov),
|
moov_(moov.Pass()),
|
||||||
moof_(new MovieFragment()),
|
moof_(new MovieFragment()),
|
||||||
sidx_(new SegmentIndex()),
|
sidx_(new SegmentIndex()),
|
||||||
segment_initialized_(false),
|
segment_initialized_(false),
|
||||||
|
|
|
@ -40,7 +40,9 @@ struct SegmentIndex;
|
||||||
class MP4Segmenter {
|
class MP4Segmenter {
|
||||||
public:
|
public:
|
||||||
// Caller transfers the ownership of |ftyp| and |moov| to this class.
|
// Caller transfers the ownership of |ftyp| and |moov| to this class.
|
||||||
MP4Segmenter(const MuxerOptions& options, FileType* ftyp, Movie* moov);
|
MP4Segmenter(const MuxerOptions& options,
|
||||||
|
scoped_ptr<FileType> ftyp,
|
||||||
|
scoped_ptr<Movie> moov);
|
||||||
virtual ~MP4Segmenter();
|
virtual ~MP4Segmenter();
|
||||||
|
|
||||||
// Initialize the segmenter. Caller retains the ownership of
|
// Initialize the segmenter. Caller retains the ownership of
|
||||||
|
|
|
@ -14,9 +14,9 @@ namespace media {
|
||||||
namespace mp4 {
|
namespace mp4 {
|
||||||
|
|
||||||
MP4VODSegmenter::MP4VODSegmenter(const MuxerOptions& options,
|
MP4VODSegmenter::MP4VODSegmenter(const MuxerOptions& options,
|
||||||
FileType* ftyp,
|
scoped_ptr<FileType> ftyp,
|
||||||
Movie* moov)
|
scoped_ptr<Movie> moov)
|
||||||
: MP4Segmenter(options, ftyp, moov) {}
|
: MP4Segmenter(options, ftyp.Pass(), moov.Pass()) {}
|
||||||
MP4VODSegmenter::~MP4VODSegmenter() {}
|
MP4VODSegmenter::~MP4VODSegmenter() {}
|
||||||
|
|
||||||
Status MP4VODSegmenter::Initialize(EncryptorSource* encryptor_source,
|
Status MP4VODSegmenter::Initialize(EncryptorSource* encryptor_source,
|
||||||
|
|
|
@ -26,7 +26,9 @@ namespace mp4 {
|
||||||
class MP4VODSegmenter : public MP4Segmenter {
|
class MP4VODSegmenter : public MP4Segmenter {
|
||||||
public:
|
public:
|
||||||
// Caller transfers the ownership of |ftyp| and |moov| to this class.
|
// Caller transfers the ownership of |ftyp| and |moov| to this class.
|
||||||
MP4VODSegmenter(const MuxerOptions& options, FileType* ftyp, Movie* moov);
|
MP4VODSegmenter(const MuxerOptions& options,
|
||||||
|
scoped_ptr<FileType> ftyp,
|
||||||
|
scoped_ptr<Movie> moov);
|
||||||
~MP4VODSegmenter();
|
~MP4VODSegmenter();
|
||||||
|
|
||||||
// MP4Segmenter implementations.
|
// MP4Segmenter implementations.
|
||||||
|
|
Loading…
Reference in New Issue