From 0f3056b5511432230fc452025ef61915535e9227 Mon Sep 17 00:00:00 2001 From: Rintaro Kuroiwa Date: Wed, 8 Jan 2014 11:56:59 -0800 Subject: [PATCH] Use scoped_ptr for box ownership transfer MP4Muxer passes ownership of ftyp and moov box to MP4Segmenter. Change-Id: Iae7c7161560c744d8d3e7e5382450e7d056112ec --- media/mp4/mp4_general_segmenter.cc | 10 +++++----- media/mp4/mp4_general_segmenter.h | 4 +++- media/mp4/mp4_muxer.cc | 4 ++-- media/mp4/mp4_segmenter.cc | 8 ++++---- media/mp4/mp4_segmenter.h | 4 +++- media/mp4/mp4_vod_segmenter.cc | 6 +++--- media/mp4/mp4_vod_segmenter.h | 4 +++- 7 files changed, 23 insertions(+), 17 deletions(-) diff --git a/media/mp4/mp4_general_segmenter.cc b/media/mp4/mp4_general_segmenter.cc index 75922bdb53..e9dfccc921 100644 --- a/media/mp4/mp4_general_segmenter.cc +++ b/media/mp4/mp4_general_segmenter.cc @@ -16,14 +16,14 @@ namespace media { namespace mp4 { MP4GeneralSegmenter::MP4GeneralSegmenter(const MuxerOptions& options, - FileType* ftyp, - Movie* moov) - : MP4Segmenter(options, ftyp, moov), + scoped_ptr ftyp, + scoped_ptr moov) + : MP4Segmenter(options, ftyp.Pass(), moov.Pass()), styp_(new SegmentType), num_segments_(0) { // Use the same brands for styp as ftyp. - styp_->major_brand = ftyp->major_brand; - styp_->compatible_brands = ftyp->compatible_brands; + styp_->major_brand = MP4Segmenter::ftyp()->major_brand; + styp_->compatible_brands = MP4Segmenter::ftyp()->compatible_brands; } MP4GeneralSegmenter::~MP4GeneralSegmenter() {} diff --git a/media/mp4/mp4_general_segmenter.h b/media/mp4/mp4_general_segmenter.h index 13fa5367ac..ce237ab609 100644 --- a/media/mp4/mp4_general_segmenter.h +++ b/media/mp4/mp4_general_segmenter.h @@ -29,7 +29,9 @@ struct SegmentType; class MP4GeneralSegmenter : public MP4Segmenter { public: // 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 ftyp, + scoped_ptr moov); ~MP4GeneralSegmenter(); // MP4Segmenter implementations. diff --git a/media/mp4/mp4_muxer.cc b/media/mp4/mp4_muxer.cc index acc35d40ef..310862aebe 100644 --- a/media/mp4/mp4_muxer.cc +++ b/media/mp4/mp4_muxer.cc @@ -93,10 +93,10 @@ Status MP4Muxer::Initialize() { if (options().single_segment) { segmenter_.reset( - new MP4VODSegmenter(options(), ftyp.release(), moov.release())); + new MP4VODSegmenter(options(), ftyp.Pass(), moov.Pass())); } else { segmenter_.reset( - new MP4GeneralSegmenter(options(), ftyp.release(), moov.release())); + new MP4GeneralSegmenter(options(), ftyp.Pass(), moov.Pass())); } return segmenter_->Initialize(encryptor_source(), streams()); } diff --git a/media/mp4/mp4_segmenter.cc b/media/mp4/mp4_segmenter.cc index 3169dd6ccc..0b91208ee4 100644 --- a/media/mp4/mp4_segmenter.cc +++ b/media/mp4/mp4_segmenter.cc @@ -26,12 +26,12 @@ namespace media { namespace mp4 { MP4Segmenter::MP4Segmenter(const MuxerOptions& options, - FileType* ftyp, - Movie* moov) + scoped_ptr ftyp, + scoped_ptr moov) : options_(options), fragment_buffer_(new BufferWriter()), - ftyp_(ftyp), - moov_(moov), + ftyp_(ftyp.Pass()), + moov_(moov.Pass()), moof_(new MovieFragment()), sidx_(new SegmentIndex()), segment_initialized_(false), diff --git a/media/mp4/mp4_segmenter.h b/media/mp4/mp4_segmenter.h index 6e0f2f6533..0c77acbf3f 100644 --- a/media/mp4/mp4_segmenter.h +++ b/media/mp4/mp4_segmenter.h @@ -40,7 +40,9 @@ struct SegmentIndex; class MP4Segmenter { public: // 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 ftyp, + scoped_ptr moov); virtual ~MP4Segmenter(); // Initialize the segmenter. Caller retains the ownership of diff --git a/media/mp4/mp4_vod_segmenter.cc b/media/mp4/mp4_vod_segmenter.cc index 64bb1b3cd4..7e4f9af2fc 100644 --- a/media/mp4/mp4_vod_segmenter.cc +++ b/media/mp4/mp4_vod_segmenter.cc @@ -14,9 +14,9 @@ namespace media { namespace mp4 { MP4VODSegmenter::MP4VODSegmenter(const MuxerOptions& options, - FileType* ftyp, - Movie* moov) - : MP4Segmenter(options, ftyp, moov) {} + scoped_ptr ftyp, + scoped_ptr moov) + : MP4Segmenter(options, ftyp.Pass(), moov.Pass()) {} MP4VODSegmenter::~MP4VODSegmenter() {} Status MP4VODSegmenter::Initialize(EncryptorSource* encryptor_source, diff --git a/media/mp4/mp4_vod_segmenter.h b/media/mp4/mp4_vod_segmenter.h index f90a4c24c2..0ec7936bb1 100644 --- a/media/mp4/mp4_vod_segmenter.h +++ b/media/mp4/mp4_vod_segmenter.h @@ -26,7 +26,9 @@ namespace mp4 { class MP4VODSegmenter : public MP4Segmenter { public: // 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 ftyp, + scoped_ptr moov); ~MP4VODSegmenter(); // MP4Segmenter implementations.