From 644629c6167e3d7d364b486345cc3e7be71cc273 Mon Sep 17 00:00:00 2001 From: Kongqun Yang Date: Wed, 17 Aug 2016 10:41:40 -0700 Subject: [PATCH] Replace scoped_ptr with std::unique_ptr Change-Id: I1ed18bf876b6154d08a1f7913aa7e76c525451f9 --- packager/app/libcrypto_threading.cc | 4 +- packager/app/packager_main.cc | 49 ++++---- packager/app/packager_util.cc | 48 ++++---- packager/app/packager_util.h | 13 +-- packager/hls/base/master_playlist.cc | 4 +- packager/hls/base/media_playlist.cc | 5 +- packager/hls/base/media_playlist.h | 2 - packager/hls/base/simple_hls_notifier.cc | 6 +- packager/hls/base/simple_hls_notifier.h | 8 +- .../hls/base/simple_hls_notifier_unittest.cc | 93 ++++++++------- packager/media/base/aes_cryptor.h | 4 +- packager/media/base/aes_cryptor_unittest.cc | 9 +- packager/media/base/aes_encryptor.h | 1 - packager/media/base/aes_pattern_cryptor.cc | 4 +- packager/media/base/aes_pattern_cryptor.h | 7 +- .../base/aes_pattern_cryptor_unittest.cc | 12 +- packager/media/base/buffer_writer_unittest.cc | 6 +- packager/media/base/byte_queue.cc | 2 +- packager/media/base/byte_queue.h | 6 +- .../media/base/closure_thread_unittest.cc | 5 +- packager/media/base/decrypt_config.h | 2 +- packager/media/base/decryptor_source.cc | 6 +- packager/media/base/demuxer.cc | 4 +- packager/media/base/demuxer.h | 10 +- packager/media/base/fixed_key_source.cc | 23 ++-- packager/media/base/fixed_key_source.h | 8 +- .../media/base/fixed_key_source_unittest.cc | 14 ++- packager/media/base/key_source.h | 1 - packager/media/base/media_parser.h | 3 +- packager/media/base/media_sample.h | 1 - packager/media/base/media_stream.h | 2 +- packager/media/base/muxer.cc | 10 +- packager/media/base/muxer.h | 10 +- .../media/base/offset_byte_queue_unittest.cc | 5 +- .../base/producer_consumer_queue_unittest.cc | 8 +- packager/media/base/request_signer.cc | 19 ++-- packager/media/base/request_signer.h | 11 +- packager/media/base/rsa_key_unittest.cc | 20 ++-- packager/media/base/text_track.h | 10 +- packager/media/base/widevine_key_source.cc | 18 +-- packager/media/base/widevine_key_source.h | 13 +-- .../base/widevine_key_source_unittest.cc | 20 ++-- packager/media/codecs/h264_parser.cc | 6 +- packager/media/codecs/h265_parser.cc | 6 +- packager/media/codecs/h265_parser.h | 2 +- .../media/event/hls_notify_muxer_listener.cc | 2 +- .../media/event/mpd_notify_muxer_listener.cc | 6 +- .../media/event/mpd_notify_muxer_listener.h | 6 +- .../mpd_notify_muxer_listener_unittest.cc | 4 +- .../vod_media_info_dump_muxer_listener.h | 7 +- ...media_info_dump_muxer_listener_unittest.cc | 4 +- packager/media/file/file.cc | 25 ++-- packager/media/file/file.h | 2 +- packager/media/file/file_closer.h | 2 +- packager/media/file/io_cache_unittest.cc | 4 +- packager/media/file/memory_file.cc | 6 +- packager/media/file/memory_file_unittest.cc | 23 ++-- packager/media/file/threaded_io_file.cc | 4 +- packager/media/file/threaded_io_file.h | 6 +- packager/media/formats/mp2t/es_parser_adts.h | 4 +- packager/media/formats/mp2t/es_parser_h264.cc | 2 +- packager/media/formats/mp2t/es_parser_h264.h | 5 +- packager/media/formats/mp2t/es_parser_h265.cc | 2 +- packager/media/formats/mp2t/es_parser_h265.h | 4 +- packager/media/formats/mp2t/es_parser_h26x.cc | 5 +- packager/media/formats/mp2t/es_parser_h26x.h | 8 +- .../formats/mp2t/es_parser_h26x_unittest.cc | 4 +- .../media/formats/mp2t/mp2t_media_parser.cc | 50 ++++---- .../media/formats/mp2t/mp2t_media_parser.h | 3 +- .../mp2t/mp2t_media_parser_unittest.cc | 2 +- .../formats/mp2t/pes_packet_generator.cc | 10 +- .../media/formats/mp2t/pes_packet_generator.h | 14 +-- .../mp2t/pes_packet_generator_unittest.cc | 56 ++++----- packager/media/formats/mp2t/ts_muxer.h | 2 +- packager/media/formats/mp2t/ts_packet.cc | 4 +- packager/media/formats/mp2t/ts_section_pes.cc | 14 +-- packager/media/formats/mp2t/ts_section_pes.h | 7 +- packager/media/formats/mp2t/ts_segmenter.cc | 18 +-- packager/media/formats/mp2t/ts_segmenter.h | 12 +- .../formats/mp2t/ts_segmenter_unittest.cc | 54 ++++----- packager/media/formats/mp2t/ts_writer.cc | 6 +- packager/media/formats/mp2t/ts_writer.h | 10 +- .../media/formats/mp2t/ts_writer_unittest.cc | 40 +++---- .../formats/mp4/box_definitions_unittest.cc | 20 ++-- packager/media/formats/mp4/box_reader.cc | 6 +- .../media/formats/mp4/box_reader_unittest.cc | 21 ++-- .../mp4/chunk_info_iterator_unittest.cc | 5 +- .../composition_offset_iterator_unittest.cc | 5 +- .../mp4/decoding_time_iterator_unittest.cc | 5 +- .../formats/mp4/encrypting_fragmenter.cc | 20 ++-- .../media/formats/mp4/encrypting_fragmenter.h | 16 +-- packager/media/formats/mp4/fragmenter.h | 4 +- .../formats/mp4/key_rotation_fragmenter.cc | 6 +- .../media/formats/mp4/mp4_media_parser.cc | 6 +- packager/media/formats/mp4/mp4_media_parser.h | 10 +- .../formats/mp4/mp4_media_parser_unittest.cc | 2 +- packager/media/formats/mp4/mp4_muxer.cc | 10 +- packager/media/formats/mp4/mp4_muxer.h | 2 +- .../formats/mp4/multi_segment_segmenter.cc | 10 +- .../formats/mp4/multi_segment_segmenter.h | 6 +- packager/media/formats/mp4/segmenter.cc | 12 +- packager/media/formats/mp4/segmenter.h | 16 +-- .../formats/mp4/single_segment_segmenter.cc | 14 +-- .../formats/mp4/single_segment_segmenter.h | 8 +- .../media/formats/mp4/track_run_iterator.cc | 8 +- .../media/formats/mp4/track_run_iterator.h | 4 +- .../mp4/track_run_iterator_unittest.cc | 17 ++- .../media/formats/webm/cluster_builder.cc | 18 +-- packager/media/formats/webm/cluster_builder.h | 14 ++- .../webm/encrypted_segmenter_unittest.cc | 7 +- packager/media/formats/webm/encryptor.cc | 8 +- packager/media/formats/webm/encryptor.h | 11 +- packager/media/formats/webm/mkv_writer.h | 4 +- .../formats/webm/multi_segment_segmenter.cc | 4 +- .../formats/webm/multi_segment_segmenter.h | 9 +- .../webm/multi_segment_segmenter_unittest.cc | 5 +- packager/media/formats/webm/segmenter.cc | 4 +- packager/media/formats/webm/segmenter.h | 10 +- .../media/formats/webm/segmenter_test_base.h | 19 ++-- .../formats/webm/single_segment_segmenter.cc | 4 +- .../formats/webm/single_segment_segmenter.h | 10 +- .../webm/single_segment_segmenter_unittest.cc | 5 +- .../webm/two_pass_single_segment_segmenter.cc | 16 +-- .../webm/two_pass_single_segment_segmenter.h | 9 +- .../media/formats/webm/webm_audio_client.h | 2 +- .../media/formats/webm/webm_cluster_parser.cc | 4 +- .../media/formats/webm/webm_cluster_parser.h | 8 +- .../webm/webm_cluster_parser_unittest.cc | 65 ++++++----- .../formats/webm/webm_content_encodings.h | 3 +- .../webm/webm_content_encodings_client.h | 4 +- .../media/formats/webm/webm_crypto_helpers.cc | 2 +- .../media/formats/webm/webm_crypto_helpers.h | 5 +- .../media/formats/webm/webm_media_parser.h | 2 +- packager/media/formats/webm/webm_muxer.cc | 4 +- packager/media/formats/webm/webm_muxer.h | 2 +- .../formats/webm/webm_parser_unittest.cc | 8 +- .../media/formats/webm/webm_tracks_parser.h | 5 +- .../webm/webm_tracks_parser_unittest.cc | 12 +- .../media/formats/webm/webm_video_client.h | 2 +- .../media/formats/wvm/wvm_media_parser.cc | 4 +- packager/media/formats/wvm/wvm_media_parser.h | 4 +- .../formats/wvm/wvm_media_parser_unittest.cc | 4 +- packager/media/test/packager_test.cc | 12 +- packager/mpd/base/dash_iop_mpd_notifier.h | 6 +- .../base/dash_iop_mpd_notifier_unittest.cc | 107 ++++++++++-------- packager/mpd/base/mock_mpd_builder.cc | 2 +- packager/mpd/base/mpd_builder.cc | 18 +-- packager/mpd/base/mpd_builder.h | 10 +- packager/mpd/base/mpd_builder_unittest.cc | 43 +++---- packager/mpd/base/mpd_notifier_util.cc | 4 +- packager/mpd/base/simple_mpd_notifier.h | 8 +- .../mpd/base/simple_mpd_notifier_unittest.cc | 77 +++++++------ packager/mpd/base/xml/scoped_xml_ptr.h | 9 +- packager/mpd/base/xml/xml_node.cc | 4 +- packager/mpd/base/xml/xml_node.h | 1 + packager/mpd/base/xml/xml_node_unittest.cc | 2 +- packager/mpd/test/xml_compare.cc | 5 +- packager/mpd/util/mpd_writer.cc | 26 ++--- packager/mpd/util/mpd_writer.h | 9 +- packager/mpd/util/mpd_writer_unittest.cc | 18 +-- 160 files changed, 948 insertions(+), 900 deletions(-) diff --git a/packager/app/libcrypto_threading.cc b/packager/app/libcrypto_threading.cc index a0f0e663e3..5fc8e5cdc7 100644 --- a/packager/app/libcrypto_threading.cc +++ b/packager/app/libcrypto_threading.cc @@ -8,10 +8,10 @@ #include +#include #include #include "packager/base/logging.h" -#include "packager/base/memory/scoped_ptr.h" #include "packager/base/synchronization/lock.h" #include "packager/base/threading/platform_thread.h" @@ -20,7 +20,7 @@ namespace media { namespace { -scoped_ptr global_locks; +std::unique_ptr global_locks; void LockFunction(int mode, int n, const char* file, int line) { VLOG(2) << "CryptoLock @ " << file << ":" << line; diff --git a/packager/app/packager_main.cc b/packager/app/packager_main.cc index edc3d6ed77..a8dad39cb2 100644 --- a/packager/app/packager_main.cc +++ b/packager/app/packager_main.cc @@ -164,15 +164,14 @@ class FakeClock : public base::Clock { // Demux, Mux(es) and worker thread used to remux a source file/stream. class RemuxJob : public base::SimpleThread { public: - RemuxJob(scoped_ptr demuxer) - : SimpleThread("RemuxJob"), - demuxer_(demuxer.Pass()) {} + RemuxJob(std::unique_ptr demuxer) + : SimpleThread("RemuxJob"), demuxer_(std::move(demuxer)) {} ~RemuxJob() override { STLDeleteElements(&muxers_); } - void AddMuxer(scoped_ptr mux) { + void AddMuxer(std::unique_ptr mux) { muxers_.push_back(mux.release()); } @@ -185,7 +184,7 @@ class RemuxJob : public base::SimpleThread { status_ = demuxer_->Run(); } - scoped_ptr demuxer_; + std::unique_ptr demuxer_; std::vector muxers_; Status status_; @@ -231,15 +230,15 @@ bool StreamInfoToTextMediaInfo(const StreamDescriptor& stream_descriptor, return true; } -scoped_ptr CreateOutputMuxer(const MuxerOptions& options, - MediaContainerName container) { +std::unique_ptr CreateOutputMuxer(const MuxerOptions& options, + MediaContainerName container) { if (container == CONTAINER_WEBM) { - return scoped_ptr(new webm::WebMMuxer(options)); + return std::unique_ptr(new webm::WebMMuxer(options)); } else if (container == CONTAINER_MPEG2TS) { - return scoped_ptr(new mp2t::TsMuxer(options)); + return std::unique_ptr(new mp2t::TsMuxer(options)); } else { DCHECK_EQ(container, CONTAINER_MOV); - return scoped_ptr(new mp4::MP4Muxer(options)); + return std::unique_ptr(new mp4::MP4Muxer(options)); } } @@ -308,13 +307,13 @@ bool CreateRemuxJobs(const StreamDescriptorList& stream_descriptors, if (stream_iter->input != previous_input) { // New remux job needed. Create demux and job thread. - scoped_ptr demuxer(new Demuxer(stream_iter->input)); + std::unique_ptr demuxer(new Demuxer(stream_iter->input)); if (FLAGS_enable_widevine_decryption || FLAGS_enable_fixed_key_decryption) { - scoped_ptr key_source(CreateDecryptionKeySource()); + std::unique_ptr key_source(CreateDecryptionKeySource()); if (!key_source) return false; - demuxer->SetKeySource(key_source.Pass()); + demuxer->SetKeySource(std::move(key_source)); } Status status = demuxer->Initialize(); if (!status.ok()) { @@ -327,12 +326,12 @@ bool CreateRemuxJobs(const StreamDescriptorList& stream_descriptors, if (stream_iter->output.empty()) continue; // just need stream info. } - remux_jobs->push_back(new RemuxJob(demuxer.Pass())); + remux_jobs->push_back(new RemuxJob(std::move(demuxer))); previous_input = stream_iter->input; } DCHECK(!remux_jobs->empty()); - scoped_ptr muxer( + std::unique_ptr muxer( CreateOutputMuxer(stream_muxer_options, stream_iter->output_format)); if (FLAGS_use_fake_clock_for_muxer) muxer->set_clock(fake_clock); @@ -344,20 +343,20 @@ bool CreateRemuxJobs(const StreamDescriptorList& stream_descriptors, GetProtectionScheme(FLAGS_protection_scheme)); } - scoped_ptr muxer_listener; + std::unique_ptr muxer_listener; DCHECK(!(FLAGS_output_media_info && mpd_notifier)); if (FLAGS_output_media_info) { const std::string output_media_info_file_name = stream_muxer_options.output_file_name + kMediaInfoSuffix; - scoped_ptr + std::unique_ptr vod_media_info_dump_muxer_listener( new VodMediaInfoDumpMuxerListener(output_media_info_file_name)); - muxer_listener = vod_media_info_dump_muxer_listener.Pass(); + muxer_listener = std::move(vod_media_info_dump_muxer_listener); } if (mpd_notifier) { - scoped_ptr mpd_notify_muxer_listener( + std::unique_ptr mpd_notify_muxer_listener( new MpdNotifyMuxerListener(mpd_notifier)); - muxer_listener = mpd_notify_muxer_listener.Pass(); + muxer_listener = std::move(mpd_notify_muxer_listener); } if (hls_notifier) { @@ -378,7 +377,7 @@ bool CreateRemuxJobs(const StreamDescriptorList& stream_descriptors, } if (muxer_listener) - muxer->SetMuxerListener(muxer_listener.Pass()); + muxer->SetMuxerListener(std::move(muxer_listener)); if (!AddStreamToMuxer(remux_jobs->back()->demuxer()->streams(), stream_iter->stream_selector, @@ -386,7 +385,7 @@ bool CreateRemuxJobs(const StreamDescriptorList& stream_descriptors, muxer.get())) { return false; } - remux_jobs->back()->AddMuxer(muxer.Pass()); + remux_jobs->back()->AddMuxer(std::move(muxer)); } return true; @@ -459,14 +458,14 @@ bool RunPackager(const StreamDescriptorList& stream_descriptors) { return false; // Create encryption key source if needed. - scoped_ptr encryption_key_source; + std::unique_ptr encryption_key_source; if (FLAGS_enable_widevine_encryption || FLAGS_enable_fixed_key_encryption) { encryption_key_source = CreateEncryptionKeySource(); if (!encryption_key_source) return false; } - scoped_ptr mpd_notifier; + std::unique_ptr mpd_notifier; if (!FLAGS_mpd_output.empty()) { DashProfile profile = FLAGS_single_segment ? kOnDemandProfile : kLiveProfile; @@ -485,7 +484,7 @@ bool RunPackager(const StreamDescriptorList& stream_descriptors) { } } - scoped_ptr hls_notifier; + std::unique_ptr hls_notifier; if (!FLAGS_hls_master_playlist_output.empty()) { base::FilePath master_playlist_path( base::FilePath::FromUTF8Unsafe(FLAGS_hls_master_playlist_output)); diff --git a/packager/app/packager_util.cc b/packager/app/packager_util.cc index 46e02be0be..e08c6a3f58 100644 --- a/packager/app/packager_util.cc +++ b/packager/app/packager_util.cc @@ -42,8 +42,8 @@ void DumpStreamInfo(const std::vector& streams) { printf("Stream [%zu] %s\n", i, streams[i]->info()->ToString().c_str()); } -scoped_ptr CreateSigner() { - scoped_ptr signer; +std::unique_ptr CreateSigner() { + std::unique_ptr signer; if (!FLAGS_aes_signing_key.empty()) { signer.reset(AesRequestSigner::CreateSigner( @@ -52,7 +52,7 @@ scoped_ptr CreateSigner() { LOG(ERROR) << "Cannot create an AES signer object from '" << FLAGS_aes_signing_key << "':'" << FLAGS_aes_signing_iv << "'."; - return scoped_ptr(); + return std::unique_ptr(); } } else if (!FLAGS_rsa_signing_key_path.empty()) { std::string rsa_private_key; @@ -60,69 +60,69 @@ scoped_ptr CreateSigner() { &rsa_private_key)) { LOG(ERROR) << "Failed to read from '" << FLAGS_rsa_signing_key_path << "'."; - return scoped_ptr(); + return std::unique_ptr(); } signer.reset(RsaRequestSigner::CreateSigner(FLAGS_signer, rsa_private_key)); if (!signer) { LOG(ERROR) << "Cannot create a RSA signer object from '" << FLAGS_rsa_signing_key_path << "'."; - return scoped_ptr(); + return std::unique_ptr(); } } - return signer.Pass(); + return signer; } -scoped_ptr CreateEncryptionKeySource() { - scoped_ptr encryption_key_source; +std::unique_ptr CreateEncryptionKeySource() { + std::unique_ptr encryption_key_source; if (FLAGS_enable_widevine_encryption) { - scoped_ptr widevine_key_source( + std::unique_ptr widevine_key_source( new WidevineKeySource(FLAGS_key_server_url, FLAGS_include_common_pssh)); if (!FLAGS_signer.empty()) { - scoped_ptr request_signer(CreateSigner()); + std::unique_ptr request_signer(CreateSigner()); if (!request_signer) - return scoped_ptr(); - widevine_key_source->set_signer(request_signer.Pass()); + return std::unique_ptr(); + widevine_key_source->set_signer(std::move(request_signer)); } std::vector content_id; if (!base::HexStringToBytes(FLAGS_content_id, &content_id)) { LOG(ERROR) << "Invalid content_id hex string specified."; - return scoped_ptr(); + return std::unique_ptr(); } Status status = widevine_key_source->FetchKeys(content_id, FLAGS_policy); if (!status.ok()) { LOG(ERROR) << "Widevine encryption key source failed to fetch keys: " << status.ToString(); - return scoped_ptr(); + return std::unique_ptr(); } - encryption_key_source = widevine_key_source.Pass(); + encryption_key_source = std::move(widevine_key_source); } else if (FLAGS_enable_fixed_key_encryption) { encryption_key_source = FixedKeySource::CreateFromHexStrings( FLAGS_key_id, FLAGS_key, FLAGS_pssh, FLAGS_iv); } - return encryption_key_source.Pass(); + return encryption_key_source; } -scoped_ptr CreateDecryptionKeySource() { - scoped_ptr decryption_key_source; +std::unique_ptr CreateDecryptionKeySource() { + std::unique_ptr decryption_key_source; if (FLAGS_enable_widevine_decryption) { - scoped_ptr widevine_key_source( + std::unique_ptr widevine_key_source( new WidevineKeySource(FLAGS_key_server_url, FLAGS_include_common_pssh)); if (!FLAGS_signer.empty()) { - scoped_ptr request_signer(CreateSigner()); + std::unique_ptr request_signer(CreateSigner()); if (!request_signer) - return scoped_ptr(); - widevine_key_source->set_signer(request_signer.Pass()); + return std::unique_ptr(); + widevine_key_source->set_signer(std::move(request_signer)); } - decryption_key_source = widevine_key_source.Pass(); + decryption_key_source = std::move(widevine_key_source); } else if (FLAGS_enable_fixed_key_decryption) { const char kNoPssh[] = ""; const char kNoIv[] = ""; decryption_key_source = FixedKeySource::CreateFromHexStrings( FLAGS_key_id, FLAGS_key, kNoPssh, kNoIv); } - return decryption_key_source.Pass(); + return decryption_key_source; } bool AssignFlagsFromProfile() { diff --git a/packager/app/packager_util.h b/packager/app/packager_util.h index cdd6fa7231..3bc90e1627 100644 --- a/packager/app/packager_util.h +++ b/packager/app/packager_util.h @@ -10,11 +10,10 @@ #define APP_PACKAGER_UTIL_H_ #include +#include #include #include -#include "packager/base/memory/scoped_ptr.h" - DECLARE_bool(dump_stream_info); namespace shaka { @@ -33,15 +32,15 @@ void DumpStreamInfo(const std::vector& streams); /// Create KeySource based on provided command line options for content /// encryption. Also fetches keys. -/// @return A scoped_ptr containing a new KeySource, or NULL if +/// @return A std::unique_ptr containing a new KeySource, or nullptr if /// encryption is not required. -scoped_ptr CreateEncryptionKeySource(); +std::unique_ptr CreateEncryptionKeySource(); /// Create KeySource based on provided command line options for content /// decryption. Does not fetch keys. -/// @return A scoped_ptr containing a new KeySource, or NULL if decryption -/// is not required. -scoped_ptr CreateDecryptionKeySource(); +/// @return A std::unique_ptr containing a new KeySource, or nullptr if +/// decryption is not required. +std::unique_ptr CreateDecryptionKeySource(); /// Set flags according to profile. bool AssignFlagsFromProfile(); diff --git a/packager/hls/base/master_playlist.cc b/packager/hls/base/master_playlist.cc index 3e9c689a6b..2cccc369bc 100644 --- a/packager/hls/base/master_playlist.cc +++ b/packager/hls/base/master_playlist.cc @@ -57,7 +57,7 @@ bool MasterPlaylist::WriteAllPlaylists(const std::string& base_url, << "Target duration was already set for " << file_path; } - scoped_ptr file( + std::unique_ptr file( media::File::Open(file_path.c_str(), "w")); if (!file) { LOG(ERROR) << "Failed to open file " << file_path; @@ -76,7 +76,7 @@ bool MasterPlaylist::WriteAllPlaylists(const std::string& base_url, bool MasterPlaylist::WriteMasterPlaylist(const std::string& base_url, const std::string& output_dir) { std::string file_path = output_dir + file_name_; - scoped_ptr file( + std::unique_ptr file( media::File::Open(file_path.c_str(), "w")); if (!file) { LOG(ERROR) << "Failed to open file " << file_path; diff --git a/packager/hls/base/media_playlist.cc b/packager/hls/base/media_playlist.cc index b2f92f6652..77d2e5dd8a 100644 --- a/packager/hls/base/media_playlist.cc +++ b/packager/hls/base/media_playlist.cc @@ -200,9 +200,8 @@ void MediaPlaylist::AddSegment(const std::string& file_name, // Note that when erasing std::list iterators, only the deleted iterators are // invalidated. void MediaPlaylist::RemoveOldestSegment() { - static_assert( - base::is_same>::value, - "This algorithm assumes std::list."); + static_assert(std::is_same>::value, + "This algorithm assumes std::list."); if (entries_.empty()) return; if (entries_.front()->type() == HlsEntry::EntryType::kExtInf) { diff --git a/packager/hls/base/media_playlist.h b/packager/hls/base/media_playlist.h index d90d1ea964..2a53e5df4c 100644 --- a/packager/hls/base/media_playlist.h +++ b/packager/hls/base/media_playlist.h @@ -11,7 +11,6 @@ #include #include "packager/base/macros.h" -#include "packager/base/memory/scoped_ptr.h" #include "packager/base/stl_util.h" #include "packager/mpd/base/media_info.pb.h" @@ -165,7 +164,6 @@ class MediaPlaylist { uint32_t time_scale_ = 0; uint64_t max_bitrate_ = 0; - double total_duration_in_seconds_ = 0.0; // See SetTargetDuration() comments. bool target_duration_set_ = false; diff --git a/packager/hls/base/simple_hls_notifier.cc b/packager/hls/base/simple_hls_notifier.cc index 287a877e87..7f5549553d 100644 --- a/packager/hls/base/simple_hls_notifier.cc +++ b/packager/hls/base/simple_hls_notifier.cc @@ -114,12 +114,12 @@ bool WidevinePsshToJson(const std::vector& pssh_data, MediaPlaylistFactory::~MediaPlaylistFactory() {} -scoped_ptr MediaPlaylistFactory::Create( +std::unique_ptr MediaPlaylistFactory::Create( MediaPlaylist::MediaPlaylistType type, const std::string& file_name, const std::string& name, const std::string& group_id) { - return scoped_ptr( + return std::unique_ptr( new MediaPlaylist(type, file_name, name, group_id)); } @@ -163,7 +163,7 @@ bool SimpleHlsNotifier::NotifyNewStream(const MediaInfo& media_info, MediaInfo adjusted_media_info(media_info); MakePathsRelativeToOutputDirectory(output_dir_, &adjusted_media_info); - scoped_ptr media_playlist = + std::unique_ptr media_playlist = media_playlist_factory_->Create(type, playlist_name, name, group_id); if (!media_playlist->SetMediaInfo(adjusted_media_info)) { LOG(ERROR) << "Failed to set media info for playlist " << playlist_name; diff --git a/packager/hls/base/simple_hls_notifier.h b/packager/hls/base/simple_hls_notifier.h index 2336afaf22..1f17041b59 100644 --- a/packager/hls/base/simple_hls_notifier.h +++ b/packager/hls/base/simple_hls_notifier.h @@ -8,12 +8,12 @@ #define PACKAGER_HLS_BASE_SIMPLE_HLS_NOTIFIER_H_ #include +#include #include #include #include "packager/base/atomic_sequence_num.h" #include "packager/base/macros.h" -#include "packager/base/memory/scoped_ptr.h" #include "packager/base/stl_util.h" #include "packager/base/synchronization/lock.h" #include "packager/hls/base/hls_notifier.h" @@ -28,7 +28,7 @@ namespace hls { class MediaPlaylistFactory { public: virtual ~MediaPlaylistFactory(); - virtual scoped_ptr Create( + virtual std::unique_ptr Create( MediaPlaylist::MediaPlaylistType type, const std::string& file_name, const std::string& name, @@ -80,8 +80,8 @@ class SimpleHlsNotifier : public HlsNotifier { const std::string prefix_; const std::string output_dir_; - scoped_ptr media_playlist_factory_; - scoped_ptr master_playlist_; + std::unique_ptr media_playlist_factory_; + std::unique_ptr master_playlist_; std::map media_playlist_map_; STLValueDeleter media_playlist_map_deleter_; diff --git a/packager/hls/base/simple_hls_notifier_unittest.cc b/packager/hls/base/simple_hls_notifier_unittest.cc index fb9ed31f9f..7027d25fe2 100644 --- a/packager/hls/base/simple_hls_notifier_unittest.cc +++ b/packager/hls/base/simple_hls_notifier_unittest.cc @@ -45,11 +45,11 @@ class MockMediaPlaylistFactory : public MediaPlaylistFactory { const std::string& name, const std::string& group_id)); - scoped_ptr Create(MediaPlaylist::MediaPlaylistType type, - const std::string& file_name, - const std::string& name, - const std::string& group_id) override { - return scoped_ptr( + std::unique_ptr Create(MediaPlaylist::MediaPlaylistType type, + const std::string& file_name, + const std::string& name, + const std::string& group_id) override { + return std::unique_ptr( CreateMock(type, file_name, name, group_id)); } }; @@ -82,22 +82,23 @@ class SimpleHlsNotifierTest : public ::testing::Test { media::kCommonSystemId, media::kCommonSystemId + arraysize(media::kCommonSystemId)) {} - void InjectMediaPlaylistFactory(scoped_ptr factory) { - notifier_.media_playlist_factory_ = factory.Pass(); + void InjectMediaPlaylistFactory( + std::unique_ptr factory) { + notifier_.media_playlist_factory_ = std::move(factory); } - void InjectMediaPlaylistFactory(scoped_ptr factory, + void InjectMediaPlaylistFactory(std::unique_ptr factory, SimpleHlsNotifier* notifier) { - notifier->media_playlist_factory_ = factory.Pass(); + notifier->media_playlist_factory_ = std::move(factory); } - void InjectMasterPlaylist(scoped_ptr playlist) { - notifier_.master_playlist_ = playlist.Pass(); + void InjectMasterPlaylist(std::unique_ptr playlist) { + notifier_.master_playlist_ = std::move(playlist); } - void InjectMasterPlaylist(scoped_ptr playlist, + void InjectMasterPlaylist(std::unique_ptr playlist, SimpleHlsNotifier* notifier) { - notifier->master_playlist_ = playlist.Pass(); + notifier->master_playlist_ = std::move(playlist); } const std::map& GetMediaPlaylistMap() { @@ -105,9 +106,9 @@ class SimpleHlsNotifierTest : public ::testing::Test { } uint32_t SetupStream(MockMediaPlaylist* mock_media_playlist) { - scoped_ptr mock_master_playlist( + std::unique_ptr mock_master_playlist( new MockMasterPlaylist()); - scoped_ptr factory( + std::unique_ptr factory( new MockMediaPlaylistFactory()); EXPECT_CALL( @@ -117,8 +118,8 @@ class SimpleHlsNotifierTest : public ::testing::Test { EXPECT_CALL(*factory, CreateMock(_, _, _, _)) .WillOnce(Return(mock_media_playlist)); - InjectMasterPlaylist(mock_master_playlist.Pass()); - InjectMediaPlaylistFactory(factory.Pass()); + InjectMasterPlaylist(std::move(mock_master_playlist)); + InjectMediaPlaylistFactory(std::move(factory)); EXPECT_TRUE(notifier_.Init()); MediaInfo media_info; uint32_t stream_id; @@ -140,8 +141,10 @@ TEST_F(SimpleHlsNotifierTest, Init) { // For this test, since the prefix "anything/" matches, the prefix should be // stripped. TEST_F(SimpleHlsNotifierTest, RebaseSegmentTemplateRelative) { - scoped_ptr mock_master_playlist(new MockMasterPlaylist()); - scoped_ptr factory(new MockMediaPlaylistFactory()); + std::unique_ptr mock_master_playlist( + new MockMasterPlaylist()); + std::unique_ptr factory( + new MockMediaPlaylistFactory()); // Pointer released by SimpleHlsNotifier. MockMediaPlaylist* mock_media_playlist = @@ -160,8 +163,8 @@ TEST_F(SimpleHlsNotifierTest, RebaseSegmentTemplateRelative) { StrEq("name"), StrEq("groupid"))) .WillOnce(Return(mock_media_playlist)); - InjectMasterPlaylist(mock_master_playlist.Pass()); - InjectMediaPlaylistFactory(factory.Pass()); + InjectMasterPlaylist(std::move(mock_master_playlist)); + InjectMediaPlaylistFactory(std::move(factory)); EXPECT_TRUE(notifier_.Init()); MediaInfo media_info; media_info.set_segment_template("anything/path/to/media$Number$.ts"); @@ -184,8 +187,10 @@ TEST_F(SimpleHlsNotifierTest, kTestPrefix, kAbsoluteOutputDir, kMasterPlaylistName); - scoped_ptr mock_master_playlist(new MockMasterPlaylist()); - scoped_ptr factory(new MockMediaPlaylistFactory()); + std::unique_ptr mock_master_playlist( + new MockMasterPlaylist()); + std::unique_ptr factory( + new MockMediaPlaylistFactory()); // Pointer released by SimpleHlsNotifier. MockMediaPlaylist* mock_media_playlist = @@ -203,8 +208,8 @@ TEST_F(SimpleHlsNotifierTest, StrEq("name"), StrEq("groupid"))) .WillOnce(Return(mock_media_playlist)); - InjectMasterPlaylist(mock_master_playlist.Pass(), &test_notifier); - InjectMediaPlaylistFactory(factory.Pass(), &test_notifier); + InjectMasterPlaylist(std::move(mock_master_playlist), &test_notifier); + InjectMediaPlaylistFactory(std::move(factory), &test_notifier); EXPECT_TRUE(test_notifier.Init()); MediaInfo media_info; media_info.set_segment_template("/tmp/something/media$Number$.ts"); @@ -226,8 +231,10 @@ TEST_F(SimpleHlsNotifierTest, kTestPrefix, kAbsoluteOutputDir, kMasterPlaylistName); - scoped_ptr mock_master_playlist(new MockMasterPlaylist()); - scoped_ptr factory(new MockMediaPlaylistFactory()); + std::unique_ptr mock_master_playlist( + new MockMasterPlaylist()); + std::unique_ptr factory( + new MockMediaPlaylistFactory()); // Pointer released by SimpleHlsNotifier. MockMediaPlaylist* mock_media_playlist = @@ -245,8 +252,8 @@ TEST_F(SimpleHlsNotifierTest, StrEq("name"), StrEq("groupid"))) .WillOnce(Return(mock_media_playlist)); - InjectMasterPlaylist(mock_master_playlist.Pass(), &test_notifier); - InjectMediaPlaylistFactory(factory.Pass(), &test_notifier); + InjectMasterPlaylist(std::move(mock_master_playlist), &test_notifier); + InjectMediaPlaylistFactory(std::move(factory), &test_notifier); EXPECT_TRUE(test_notifier.Init()); MediaInfo media_info; media_info.set_segment_template("/var/somewhereelse/media$Number$.ts"); @@ -259,8 +266,10 @@ TEST_F(SimpleHlsNotifierTest, } TEST_F(SimpleHlsNotifierTest, NotifyNewStream) { - scoped_ptr mock_master_playlist(new MockMasterPlaylist()); - scoped_ptr factory(new MockMediaPlaylistFactory()); + std::unique_ptr mock_master_playlist( + new MockMasterPlaylist()); + std::unique_ptr factory( + new MockMediaPlaylistFactory()); // Pointer released by SimpleHlsNotifier. MockMediaPlaylist* mock_media_playlist = @@ -272,8 +281,8 @@ TEST_F(SimpleHlsNotifierTest, NotifyNewStream) { StrEq("name"), StrEq("groupid"))) .WillOnce(Return(mock_media_playlist)); - InjectMasterPlaylist(mock_master_playlist.Pass()); - InjectMediaPlaylistFactory(factory.Pass()); + InjectMasterPlaylist(std::move(mock_master_playlist)); + InjectMediaPlaylistFactory(std::move(factory)); EXPECT_TRUE(notifier_.Init()); MediaInfo media_info; uint32_t stream_id; @@ -283,8 +292,10 @@ TEST_F(SimpleHlsNotifierTest, NotifyNewStream) { } TEST_F(SimpleHlsNotifierTest, NotifyNewSegment) { - scoped_ptr mock_master_playlist(new MockMasterPlaylist()); - scoped_ptr factory(new MockMediaPlaylistFactory()); + std::unique_ptr mock_master_playlist( + new MockMasterPlaylist()); + std::unique_ptr factory( + new MockMediaPlaylistFactory()); // Pointer released by SimpleHlsNotifier. MockMediaPlaylist* mock_media_playlist = @@ -304,8 +315,8 @@ TEST_F(SimpleHlsNotifierTest, NotifyNewSegment) { EXPECT_CALL(*mock_media_playlist, AddSegment(StrEq(kTestPrefix + segment_name), kDuration, kSize)); - InjectMasterPlaylist(mock_master_playlist.Pass()); - InjectMediaPlaylistFactory(factory.Pass()); + InjectMasterPlaylist(std::move(mock_master_playlist)); + InjectMediaPlaylistFactory(std::move(factory)); EXPECT_TRUE(notifier_.Init()); MediaInfo media_info; uint32_t stream_id; @@ -527,13 +538,15 @@ TEST_F(SimpleHlsNotifierTest, NotifyEncryptionUpdateWithoutStreamsRegistered) { } TEST_F(SimpleHlsNotifierTest, Flush) { - scoped_ptr mock_master_playlist(new MockMasterPlaylist()); + std::unique_ptr mock_master_playlist( + new MockMasterPlaylist()); EXPECT_CALL(*mock_master_playlist, WriteAllPlaylists(StrEq(kTestPrefix), StrEq(kAnyOutputDir))) .WillOnce(Return(true)); - scoped_ptr factory(new MockMediaPlaylistFactory()); + std::unique_ptr factory( + new MockMediaPlaylistFactory()); - InjectMasterPlaylist(mock_master_playlist.Pass()); + InjectMasterPlaylist(std::move(mock_master_playlist)); EXPECT_TRUE(notifier_.Init()); EXPECT_TRUE(notifier_.Flush()); } diff --git a/packager/media/base/aes_cryptor.h b/packager/media/base/aes_cryptor.h index 1ca85c1369..ecd1caf4d5 100644 --- a/packager/media/base/aes_cryptor.h +++ b/packager/media/base/aes_cryptor.h @@ -7,11 +7,11 @@ #ifndef PACKAGER_MEDIA_BASE_AES_CRYPTOR_H_ #define PACKAGER_MEDIA_BASE_AES_CRYPTOR_H_ +#include #include #include #include "packager/base/macros.h" -#include "packager/base/memory/scoped_ptr.h" #include "packager/media/base/fourccs.h" struct aes_key_st; @@ -119,7 +119,7 @@ class AesCryptor { virtual size_t NumPaddingBytes(size_t size) const; // Openssl AES_KEY. - scoped_ptr aes_key_; + std::unique_ptr aes_key_; // Indicates whether a constant iv is used. Internal iv will be reset to // |iv_| before calling Crypt if that is the case. diff --git a/packager/media/base/aes_cryptor_unittest.cc b/packager/media/base/aes_cryptor_unittest.cc index 6df17a5df4..7b85cbbeea 100644 --- a/packager/media/base/aes_cryptor_unittest.cc +++ b/packager/media/base/aes_cryptor_unittest.cc @@ -6,11 +6,12 @@ #include +#include + #include "packager/base/logging.h" -#include "packager/base/memory/scoped_ptr.h" #include "packager/base/strings/string_number_conversions.h" -#include "packager/media/base/aes_encryptor.h" #include "packager/media/base/aes_decryptor.h" +#include "packager/media/base/aes_encryptor.h" namespace { @@ -361,8 +362,8 @@ class AesCbcTest : public ::testing::Test { EXPECT_EQ(plaintext, buffer); } - scoped_ptr encryptor_; - scoped_ptr decryptor_; + std::unique_ptr encryptor_; + std::unique_ptr decryptor_; std::vector key_; std::vector iv_; }; diff --git a/packager/media/base/aes_encryptor.h b/packager/media/base/aes_encryptor.h index 0f94d05fbd..c8830d5a3d 100644 --- a/packager/media/base/aes_encryptor.h +++ b/packager/media/base/aes_encryptor.h @@ -13,7 +13,6 @@ #include #include "packager/base/macros.h" -#include "packager/base/memory/scoped_ptr.h" #include "packager/media/base/aes_cryptor.h" namespace shaka { diff --git a/packager/media/base/aes_pattern_cryptor.cc b/packager/media/base/aes_pattern_cryptor.cc index 55a3be6b81..987e8fa25c 100644 --- a/packager/media/base/aes_pattern_cryptor.cc +++ b/packager/media/base/aes_pattern_cryptor.cc @@ -17,12 +17,12 @@ AesPatternCryptor::AesPatternCryptor(uint8_t crypt_byte_block, uint8_t skip_byte_block, PatternEncryptionMode encryption_mode, ConstantIvFlag constant_iv_flag, - scoped_ptr cryptor) + std::unique_ptr cryptor) : AesCryptor(constant_iv_flag), crypt_byte_block_(crypt_byte_block), skip_byte_block_(skip_byte_block), encryption_mode_(encryption_mode), - cryptor_(cryptor.Pass()) { + cryptor_(std::move(cryptor)) { // |crypt_byte_block_| should never be 0. |skip_byte_block_| can be 0 to allow // a special pattern of 1:0, which is the pattern for the case of pattern // encryption when applied to non video tracks. diff --git a/packager/media/base/aes_pattern_cryptor.h b/packager/media/base/aes_pattern_cryptor.h index ba351304a6..d3b5bbe78d 100644 --- a/packager/media/base/aes_pattern_cryptor.h +++ b/packager/media/base/aes_pattern_cryptor.h @@ -6,8 +6,9 @@ #include "packager/media/base/aes_cryptor.h" +#include + #include "packager/base/macros.h" -#include "packager/base/memory/scoped_ptr.h" namespace shaka { namespace media { @@ -53,7 +54,7 @@ class AesPatternCryptor : public AesCryptor { uint8_t skip_byte_block, PatternEncryptionMode encryption_mode, ConstantIvFlag constant_iv_flag, - scoped_ptr cryptor); + std::unique_ptr cryptor); ~AesPatternCryptor() override; /// @name AesCryptor implementation overrides. @@ -74,7 +75,7 @@ class AesPatternCryptor : public AesCryptor { const uint8_t crypt_byte_block_; const uint8_t skip_byte_block_; const PatternEncryptionMode encryption_mode_; - scoped_ptr cryptor_; + std::unique_ptr cryptor_; DISALLOW_COPY_AND_ASSIGN(AesPatternCryptor); }; diff --git a/packager/media/base/aes_pattern_cryptor_unittest.cc b/packager/media/base/aes_pattern_cryptor_unittest.cc index f7f311be04..c42f99975d 100644 --- a/packager/media/base/aes_pattern_cryptor_unittest.cc +++ b/packager/media/base/aes_pattern_cryptor_unittest.cc @@ -45,7 +45,7 @@ class AesPatternCryptorTest : public ::testing::Test { kSkipByteBlock, AesPatternCryptor::kEncryptIfCryptByteBlockRemaining, AesCryptor::kDontUseConstantIv, - scoped_ptr(mock_cryptor_)) {} + std::unique_ptr(mock_cryptor_)) {} protected: MockAesCryptor* mock_cryptor_; @@ -146,7 +146,7 @@ TEST(AesPatternCryptorConstIvTest, UseConstantIv) { kCryptByteBlock, kSkipByteBlock, AesPatternCryptor::kEncryptIfCryptByteBlockRemaining, AesPatternCryptor::kUseConstantIv, - scoped_ptr(mock_cryptor)); + std::unique_ptr(mock_cryptor)); std::vector iv(8, 'i'); // SetIv will be called twice: @@ -165,7 +165,7 @@ TEST(AesPatternCryptorConstIvTest, DontUseConstantIv) { kCryptByteBlock, kSkipByteBlock, AesPatternCryptor::kEncryptIfCryptByteBlockRemaining, AesPatternCryptor::kDontUseConstantIv, - scoped_ptr(mock_cryptor)); + std::unique_ptr(mock_cryptor)); std::vector iv(8, 'i'); // SetIv will be called only once by AesPatternCryptor::SetIv. @@ -186,7 +186,7 @@ TEST(SampleAesPatternCryptor, 16Bytes) { kSampleAesEncryptedBlock, kSampleAesClearBlock, AesPatternCryptor::kSkipIfCryptByteBlockRemaining, AesPatternCryptor::kUseConstantIv, - scoped_ptr(mock_cryptor)); + std::unique_ptr(mock_cryptor)); std::vector iv(8, 'i'); // SetIv will be called only once by AesPatternCryptor::SetIv. @@ -208,7 +208,7 @@ TEST(SampleAesPatternCryptor, MoreThan16Bytes) { kSampleAesEncryptedBlock, kSampleAesClearBlock, AesPatternCryptor::kSkipIfCryptByteBlockRemaining, AesPatternCryptor::kUseConstantIv, - scoped_ptr(mock_cryptor)); + std::unique_ptr(mock_cryptor)); std::vector iv(8, 'i'); // SetIv will be called only once by AesPatternCryptor::SetIv. @@ -236,7 +236,7 @@ TEST(FullSampleSpecialPatternTest, Test) { kFulLSampleCryptBlock, kFullSampleSkipBlock, AesPatternCryptor::kSkipIfCryptByteBlockRemaining, AesPatternCryptor::kUseConstantIv, - scoped_ptr(mock_cryptor)); + std::unique_ptr(mock_cryptor)); std::vector iv(8, 'i'); // SetIv will be called only once by AesPatternCryptor::SetIv. diff --git a/packager/media/base/buffer_writer_unittest.cc b/packager/media/base/buffer_writer_unittest.cc index bbed3f7402..80107e0e23 100644 --- a/packager/media/base/buffer_writer_unittest.cc +++ b/packager/media/base/buffer_writer_unittest.cc @@ -7,9 +7,9 @@ #include "packager/media/base/buffer_writer.h" #include +#include #include "packager/base/files/file_util.h" -#include "packager/base/memory/scoped_ptr.h" #include "packager/media/base/buffer_reader.h" #include "packager/media/base/test/status_test_util.h" #include "packager/media/file/file.h" @@ -69,8 +69,8 @@ class BufferWriterTest : public testing::Test { } protected: - scoped_ptr writer_; - scoped_ptr reader_; + std::unique_ptr writer_; + std::unique_ptr reader_; private: DISALLOW_COPY_AND_ASSIGN(BufferWriterTest); diff --git a/packager/media/base/byte_queue.cc b/packager/media/base/byte_queue.cc index 9de7c5f4f6..eb5028bc9a 100644 --- a/packager/media/base/byte_queue.cc +++ b/packager/media/base/byte_queue.cc @@ -41,7 +41,7 @@ void ByteQueue::Push(const uint8_t* data, int size) { // Sanity check to make sure we didn't overflow. CHECK_GT(new_size, size_); - scoped_ptr new_buffer(new uint8_t[new_size]); + std::unique_ptr new_buffer(new uint8_t[new_size]); // Copy the data from the old buffer to the start of the new one. if (used_ > 0) diff --git a/packager/media/base/byte_queue.h b/packager/media/base/byte_queue.h index 70d6edba4c..c8c05405a4 100644 --- a/packager/media/base/byte_queue.h +++ b/packager/media/base/byte_queue.h @@ -7,7 +7,9 @@ #include -#include "packager/base/memory/scoped_ptr.h" +#include + +#include "packager/base/macros.h" namespace shaka { namespace media { @@ -40,7 +42,7 @@ class ByteQueue { // Returns a pointer to the front of the queue. uint8_t* front() const; - scoped_ptr buffer_; + std::unique_ptr buffer_; // Size of |buffer_|. size_t size_; diff --git a/packager/media/base/closure_thread_unittest.cc b/packager/media/base/closure_thread_unittest.cc index 28e1c6d892..8bf8b21c9b 100644 --- a/packager/media/base/closure_thread_unittest.cc +++ b/packager/media/base/closure_thread_unittest.cc @@ -7,8 +7,9 @@ #include #include +#include + #include "packager/base/bind.h" -#include "packager/base/memory/scoped_ptr.h" #include "packager/base/synchronization/waitable_event.h" #include "packager/media/base/closure_thread.h" @@ -55,7 +56,7 @@ class ClosureThreadTest : public ::testing::Test { void set_val(int val) { val_ = val; } MockOperation operation_; - scoped_ptr thread_; + std::unique_ptr thread_; private: int val_; diff --git a/packager/media/base/decrypt_config.h b/packager/media/base/decrypt_config.h index b0ad28b0c2..29019f49dc 100644 --- a/packager/media/base/decrypt_config.h +++ b/packager/media/base/decrypt_config.h @@ -10,7 +10,7 @@ #include #include -#include "packager/base/memory/scoped_ptr.h" +#include "packager/base/macros.h" #include "packager/media/base/fourccs.h" namespace shaka { diff --git a/packager/media/base/decryptor_source.cc b/packager/media/base/decryptor_source.cc index 09235c686b..22d9d07686 100644 --- a/packager/media/base/decryptor_source.cc +++ b/packager/media/base/decryptor_source.cc @@ -40,7 +40,7 @@ bool DecryptorSource::DecryptSampleBuffer(const DecryptConfig* decrypt_config, return false; } - scoped_ptr aes_decryptor; + std::unique_ptr aes_decryptor; switch (decrypt_config->protection_scheme()) { case FOURCC_cenc: aes_decryptor.reset(new AesCtrDecryptor); @@ -54,7 +54,7 @@ bool DecryptorSource::DecryptSampleBuffer(const DecryptConfig* decrypt_config, decrypt_config->skip_byte_block(), AesPatternCryptor::kEncryptIfCryptByteBlockRemaining, AesCryptor::kDontUseConstantIv, - scoped_ptr(new AesCtrDecryptor()))); + std::unique_ptr(new AesCtrDecryptor()))); break; case FOURCC_cbcs: aes_decryptor.reset(new AesPatternCryptor( @@ -62,7 +62,7 @@ bool DecryptorSource::DecryptSampleBuffer(const DecryptConfig* decrypt_config, decrypt_config->skip_byte_block(), AesPatternCryptor::kEncryptIfCryptByteBlockRemaining, AesCryptor::kUseConstantIv, - scoped_ptr(new AesCbcDecryptor(kNoPadding)))); + std::unique_ptr(new AesCbcDecryptor(kNoPadding)))); break; default: LOG(ERROR) << "Unsupported protection scheme: " diff --git a/packager/media/base/demuxer.cc b/packager/media/base/demuxer.cc index 62f866bd6c..75276cd05e 100644 --- a/packager/media/base/demuxer.cc +++ b/packager/media/base/demuxer.cc @@ -49,8 +49,8 @@ Demuxer::~Demuxer() { STLDeleteElements(&streams_); } -void Demuxer::SetKeySource(scoped_ptr key_source) { - key_source_ = key_source.Pass(); +void Demuxer::SetKeySource(std::unique_ptr key_source) { + key_source_ = std::move(key_source); } Status Demuxer::Initialize() { diff --git a/packager/media/base/demuxer.h b/packager/media/base/demuxer.h index 01696d181e..4336532ca5 100644 --- a/packager/media/base/demuxer.h +++ b/packager/media/base/demuxer.h @@ -8,11 +8,11 @@ #define MEDIA_BASE_DEMUXER_H_ #include +#include #include #include "packager/base/compiler_specific.h" #include "packager/base/memory/ref_counted.h" -#include "packager/base/memory/scoped_ptr.h" #include "packager/media/base/container_names.h" #include "packager/media/base/status.h" @@ -41,7 +41,7 @@ class Demuxer { /// @param key_source points to the source of decryption keys. The key /// source must support fetching of keys for the type of media being /// demuxed. - void SetKeySource(scoped_ptr key_source); + void SetKeySource(std::unique_ptr key_source); /// Initialize the Demuxer. Calling other public methods of this class /// without this method returning OK, results in an undefined behavior. @@ -96,11 +96,11 @@ class Demuxer { Status init_parsing_status_; // Queued samples received in NewSampleEvent() before ParserInitEvent(). std::deque queued_samples_; - scoped_ptr parser_; + std::unique_ptr parser_; std::vector streams_; MediaContainerName container_name_; - scoped_ptr buffer_; - scoped_ptr key_source_; + std::unique_ptr buffer_; + std::unique_ptr key_source_; bool cancelled_; DISALLOW_COPY_AND_ASSIGN(Demuxer); diff --git a/packager/media/base/fixed_key_source.cc b/packager/media/base/fixed_key_source.cc index c57282e823..9c80effb82 100644 --- a/packager/media/base/fixed_key_source.cc +++ b/packager/media/base/fixed_key_source.cc @@ -83,38 +83,38 @@ Status FixedKeySource::GetCryptoPeriodKey(uint32_t crypto_period_index, return Status::OK; } -scoped_ptr FixedKeySource::CreateFromHexStrings( +std::unique_ptr FixedKeySource::CreateFromHexStrings( const std::string& key_id_hex, const std::string& key_hex, const std::string& pssh_boxes_hex, const std::string& iv_hex) { - scoped_ptr encryption_key(new EncryptionKey()); + std::unique_ptr encryption_key(new EncryptionKey()); if (!base::HexStringToBytes(key_id_hex, &encryption_key->key_id)) { LOG(ERROR) << "Cannot parse key_id_hex " << key_id_hex; - return scoped_ptr(); + return std::unique_ptr(); } else if (encryption_key->key_id.size() != 16) { LOG(ERROR) << "Invalid key ID size '" << encryption_key->key_id.size() << "', must be 16 bytes."; - return scoped_ptr(); + return std::unique_ptr(); } if (!base::HexStringToBytes(key_hex, &encryption_key->key)) { LOG(ERROR) << "Cannot parse key_hex " << key_hex; - return scoped_ptr(); + return std::unique_ptr(); } std::vector pssh_boxes; if (!pssh_boxes_hex.empty() && !base::HexStringToBytes(pssh_boxes_hex, &pssh_boxes)) { LOG(ERROR) << "Cannot parse pssh_hex " << pssh_boxes_hex; - return scoped_ptr(); + return std::unique_ptr(); } if (!iv_hex.empty()) { if (!base::HexStringToBytes(iv_hex, &encryption_key->iv)) { LOG(ERROR) << "Cannot parse iv_hex " << iv_hex; - return scoped_ptr(); + return std::unique_ptr(); } } @@ -122,7 +122,7 @@ scoped_ptr FixedKeySource::CreateFromHexStrings( pssh_boxes.data(), pssh_boxes.size(), &encryption_key->key_system_info)) { LOG(ERROR) << "--pssh argument should be full PSSH boxes."; - return scoped_ptr(); + return std::unique_ptr(); } // If there aren't any PSSH boxes given, create one with the common system ID. @@ -135,12 +135,13 @@ scoped_ptr FixedKeySource::CreateFromHexStrings( encryption_key->key_system_info.push_back(info); } - return scoped_ptr(new FixedKeySource(encryption_key.Pass())); + return std::unique_ptr( + new FixedKeySource(std::move(encryption_key))); } FixedKeySource::FixedKeySource() {} -FixedKeySource::FixedKeySource(scoped_ptr key) - : encryption_key_(key.Pass()) {} +FixedKeySource::FixedKeySource(std::unique_ptr key) + : encryption_key_(std::move(key)) {} } // namespace media } // namespace shaka diff --git a/packager/media/base/fixed_key_source.h b/packager/media/base/fixed_key_source.h index 4ee3fb18de..e0f2674ca4 100644 --- a/packager/media/base/fixed_key_source.h +++ b/packager/media/base/fixed_key_source.h @@ -7,10 +7,10 @@ #ifndef MEDIA_BASE_FIXED_KEY_SOURCE_H_ #define MEDIA_BASE_FIXED_KEY_SOURCE_H_ +#include #include #include -#include "packager/base/memory/scoped_ptr.h" #include "packager/media/base/key_source.h" namespace shaka { @@ -51,7 +51,7 @@ class FixedKeySource : public KeySource { /// generated IV with the default length will be used. /// Note: GetKey on the created key source will always return the same key /// for all track types. - static scoped_ptr CreateFromHexStrings( + static std::unique_ptr CreateFromHexStrings( const std::string& key_id_hex, const std::string& key_hex, const std::string& pssh_boxes_hex, @@ -62,9 +62,9 @@ class FixedKeySource : public KeySource { FixedKeySource(); private: - explicit FixedKeySource(scoped_ptr key); + explicit FixedKeySource(std::unique_ptr key); - scoped_ptr encryption_key_; + std::unique_ptr encryption_key_; DISALLOW_COPY_AND_ASSIGN(FixedKeySource); }; diff --git a/packager/media/base/fixed_key_source_unittest.cc b/packager/media/base/fixed_key_source_unittest.cc index 7e633171ef..34f61bdf80 100644 --- a/packager/media/base/fixed_key_source_unittest.cc +++ b/packager/media/base/fixed_key_source_unittest.cc @@ -47,8 +47,9 @@ const char kDefaultPsshBoxHex[] = TEST(FixedKeySourceTest, CreateFromHexStrings_Succes) { std::string pssh_boxes = std::string(kPsshBox1Hex) + kPsshBox2Hex; - scoped_ptr key_source = FixedKeySource::CreateFromHexStrings( - kKeyIdHex, kKeyHex, pssh_boxes, kIvHex); + std::unique_ptr key_source = + FixedKeySource::CreateFromHexStrings(kKeyIdHex, kKeyHex, pssh_boxes, + kIvHex); ASSERT_NE(nullptr, key_source); EncryptionKey key; @@ -64,8 +65,8 @@ TEST(FixedKeySourceTest, CreateFromHexStrings_Succes) { } TEST(FixedKeySourceTest, CreateFromHexStrings_EmptyPssh) { - scoped_ptr key_source = FixedKeySource::CreateFromHexStrings( - kKeyIdHex, kKeyHex, "", kIvHex); + std::unique_ptr key_source = + FixedKeySource::CreateFromHexStrings(kKeyIdHex, kKeyHex, "", kIvHex); ASSERT_NE(nullptr, key_source); EncryptionKey key; @@ -80,8 +81,9 @@ TEST(FixedKeySourceTest, CreateFromHexStrings_EmptyPssh) { } TEST(FixedKeySourceTest, CreateFromHexStrings_Failure) { - scoped_ptr key_source = FixedKeySource::CreateFromHexStrings( - kKeyIdHex, "invalid_hex_value", kPsshBox1Hex, kIvHex); + std::unique_ptr key_source = + FixedKeySource::CreateFromHexStrings(kKeyIdHex, "invalid_hex_value", + kPsshBox1Hex, kIvHex); EXPECT_EQ(nullptr, key_source); // Invalid key id size. diff --git a/packager/media/base/key_source.h b/packager/media/base/key_source.h index 5d41f2c5c8..788c83ff78 100644 --- a/packager/media/base/key_source.h +++ b/packager/media/base/key_source.h @@ -10,7 +10,6 @@ #include #include -#include "packager/base/memory/scoped_ptr.h" #include "packager/media/base/protection_system_specific_info.h" #include "packager/media/base/status.h" diff --git a/packager/media/base/media_parser.h b/packager/media/base/media_parser.h index 72bf581dc2..a6257ae623 100644 --- a/packager/media/base/media_parser.h +++ b/packager/media/base/media_parser.h @@ -7,13 +7,12 @@ #ifndef MEDIA_BASE_MEDIA_PARSER_H_ #define MEDIA_BASE_MEDIA_PARSER_H_ +#include #include #include - #include "packager/base/callback.h" #include "packager/base/compiler_specific.h" #include "packager/base/memory/ref_counted.h" -#include "packager/base/memory/scoped_ptr.h" #include "packager/media/base/container_names.h" namespace shaka { diff --git a/packager/media/base/media_sample.h b/packager/media/base/media_sample.h index 791c50dd75..720b0e9dfa 100644 --- a/packager/media/base/media_sample.h +++ b/packager/media/base/media_sample.h @@ -13,7 +13,6 @@ #include "packager/base/logging.h" #include "packager/base/memory/ref_counted.h" -#include "packager/base/memory/scoped_ptr.h" namespace shaka { namespace media { diff --git a/packager/media/base/media_stream.h b/packager/media/base/media_stream.h index 1be48816ef..7c326dcad8 100644 --- a/packager/media/base/media_stream.h +++ b/packager/media/base/media_stream.h @@ -8,9 +8,9 @@ #define MEDIA_BASE_MEDIA_STREAM_H_ #include +#include #include "packager/base/memory/ref_counted.h" -#include "packager/base/memory/scoped_ptr.h" #include "packager/media/base/status.h" namespace shaka { diff --git a/packager/media/base/muxer.cc b/packager/media/base/muxer.cc index 162201cb5f..e863be886a 100644 --- a/packager/media/base/muxer.cc +++ b/packager/media/base/muxer.cc @@ -6,6 +6,8 @@ #include "packager/media/base/muxer.h" +#include + #include "packager/media/base/fourccs.h" #include "packager/media/base/media_sample.h" #include "packager/media/base/media_stream.h" @@ -83,13 +85,13 @@ void Muxer::Cancel() { cancelled_ = true; } -void Muxer::SetMuxerListener(scoped_ptr muxer_listener) { - muxer_listener_ = muxer_listener.Pass(); +void Muxer::SetMuxerListener(std::unique_ptr muxer_listener) { + muxer_listener_ = std::move(muxer_listener); } void Muxer::SetProgressListener( - scoped_ptr progress_listener) { - progress_listener_ = progress_listener.Pass(); + std::unique_ptr progress_listener) { + progress_listener_ = std::move(progress_listener); } Status Muxer::AddSample(const MediaStream* stream, diff --git a/packager/media/base/muxer.h b/packager/media/base/muxer.h index 613f945a98..751b497539 100644 --- a/packager/media/base/muxer.h +++ b/packager/media/base/muxer.h @@ -9,10 +9,10 @@ #ifndef MEDIA_BASE_MUXER_H_ #define MEDIA_BASE_MUXER_H_ +#include #include #include "packager/base/memory/ref_counted.h" -#include "packager/base/memory/scoped_ptr.h" #include "packager/base/time/clock.h" #include "packager/media/base/fourccs.h" #include "packager/media/base/muxer_options.h" @@ -65,11 +65,11 @@ class Muxer { /// Set a MuxerListener event handler for this object. /// @param muxer_listener should not be NULL. - void SetMuxerListener(scoped_ptr muxer_listener); + void SetMuxerListener(std::unique_ptr muxer_listener); /// Set a ProgressListener event handler for this object. /// @param progress_listener should not be NULL. - void SetProgressListener(scoped_ptr progress_listener); + void SetProgressListener(std::unique_ptr progress_listener); const std::vector& streams() const { return streams_; } @@ -125,8 +125,8 @@ class Muxer { FourCC protection_scheme_; bool cancelled_; - scoped_ptr muxer_listener_; - scoped_ptr progress_listener_; + std::unique_ptr muxer_listener_; + std::unique_ptr progress_listener_; // An external injected clock, can be NULL. base::Clock* clock_; diff --git a/packager/media/base/offset_byte_queue_unittest.cc b/packager/media/base/offset_byte_queue_unittest.cc index ab4c511c97..298f83c3cd 100644 --- a/packager/media/base/offset_byte_queue_unittest.cc +++ b/packager/media/base/offset_byte_queue_unittest.cc @@ -5,8 +5,7 @@ #include #include #include - -#include "packager/base/memory/scoped_ptr.h" +#include #include "packager/media/base/offset_byte_queue.h" namespace shaka { @@ -29,7 +28,7 @@ class OffsetByteQueueTest : public testing::Test { } protected: - scoped_ptr queue_; + std::unique_ptr queue_; }; TEST_F(OffsetByteQueueTest, SetUp) { diff --git a/packager/media/base/producer_consumer_queue_unittest.cc b/packager/media/base/producer_consumer_queue_unittest.cc index 029d133e2e..a5bf106e2b 100644 --- a/packager/media/base/producer_consumer_queue_unittest.cc +++ b/packager/media/base/producer_consumer_queue_unittest.cc @@ -88,7 +88,7 @@ TEST(ProducerConsumerQueueTest, PeekOnPoppedElement) { } TEST(ProducerConsumerQueueTest, PushWithTimeout) { - scoped_ptr timer; + std::unique_ptr timer; ProducerConsumerQueue queue(kCapacity); for (size_t i = 0; i < kCapacity; ++i) { @@ -105,7 +105,7 @@ TEST(ProducerConsumerQueueTest, PushWithTimeout) { } TEST(ProducerConsumerQueueTest, PopWithTimeout) { - scoped_ptr timer; + std::unique_ptr timer; ProducerConsumerQueue queue(kCapacity); for (size_t i = 0; i < kCapacity; ++i) @@ -127,7 +127,7 @@ TEST(ProducerConsumerQueueTest, PopWithTimeout) { } TEST(ProducerConsumerQueueTest, PeekWithTimeout) { - scoped_ptr timer; + std::unique_ptr timer; ProducerConsumerQueue queue(kCapacity); for (size_t i = 0; i < kCapacity; ++i) @@ -150,7 +150,7 @@ TEST(ProducerConsumerQueueTest, PeekWithTimeout) { } TEST(ProducerConsumerQueueTest, CheckStop) { - scoped_ptr timer; + std::unique_ptr timer; ProducerConsumerQueue queue(kUnlimitedCapacity); ASSERT_FALSE(queue.Stopped()); diff --git a/packager/media/base/request_signer.cc b/packager/media/base/request_signer.cc index 9ebd90fe5a..e3800528e7 100644 --- a/packager/media/base/request_signer.cc +++ b/packager/media/base/request_signer.cc @@ -20,8 +20,8 @@ RequestSigner::RequestSigner(const std::string& signer_name) RequestSigner::~RequestSigner() {} AesRequestSigner::AesRequestSigner(const std::string& signer_name, - scoped_ptr encryptor) - : RequestSigner(signer_name), aes_cbc_encryptor_(encryptor.Pass()) { + std::unique_ptr encryptor) + : RequestSigner(signer_name), aes_cbc_encryptor_(std::move(encryptor)) { DCHECK(aes_cbc_encryptor_); } AesRequestSigner::~AesRequestSigner() {} @@ -40,11 +40,11 @@ AesRequestSigner* AesRequestSigner::CreateSigner(const std::string& signer_name, return NULL; } - scoped_ptr encryptor( + std::unique_ptr encryptor( new AesCbcEncryptor(kPkcs5Padding, AesCryptor::kUseConstantIv)); if (!encryptor->InitializeWithIv(aes_key, iv)) return NULL; - return new AesRequestSigner(signer_name, encryptor.Pass()); + return new AesRequestSigner(signer_name, std::move(encryptor)); } bool AesRequestSigner::GenerateSignature(const std::string& message, @@ -53,9 +53,10 @@ bool AesRequestSigner::GenerateSignature(const std::string& message, return true; } -RsaRequestSigner::RsaRequestSigner(const std::string& signer_name, - scoped_ptr rsa_private_key) - : RequestSigner(signer_name), rsa_private_key_(rsa_private_key.Pass()) { +RsaRequestSigner::RsaRequestSigner( + const std::string& signer_name, + std::unique_ptr rsa_private_key) + : RequestSigner(signer_name), rsa_private_key_(std::move(rsa_private_key)) { DCHECK(rsa_private_key_); } RsaRequestSigner::~RsaRequestSigner() {} @@ -63,11 +64,11 @@ RsaRequestSigner::~RsaRequestSigner() {} RsaRequestSigner* RsaRequestSigner::CreateSigner( const std::string& signer_name, const std::string& pkcs1_rsa_key) { - scoped_ptr rsa_private_key( + std::unique_ptr rsa_private_key( RsaPrivateKey::Create(pkcs1_rsa_key)); if (!rsa_private_key) return NULL; - return new RsaRequestSigner(signer_name, rsa_private_key.Pass()); + return new RsaRequestSigner(signer_name, std::move(rsa_private_key)); } bool RsaRequestSigner::GenerateSignature(const std::string& message, diff --git a/packager/media/base/request_signer.h b/packager/media/base/request_signer.h index d7a6072253..b69818e1b5 100644 --- a/packager/media/base/request_signer.h +++ b/packager/media/base/request_signer.h @@ -7,9 +7,10 @@ #ifndef MEDIA_BASE_REQUEST_SIGNER_H_ #define MEDIA_BASE_REQUEST_SIGNER_H_ +#include #include -#include "packager/base/memory/scoped_ptr.h" +#include "packager/base/macros.h" namespace shaka { namespace media { @@ -56,9 +57,9 @@ class AesRequestSigner : public RequestSigner { private: AesRequestSigner(const std::string& signer_name, - scoped_ptr encryptor); + std::unique_ptr encryptor); - scoped_ptr aes_cbc_encryptor_; + std::unique_ptr aes_cbc_encryptor_; DISALLOW_COPY_AND_ASSIGN(AesRequestSigner); }; @@ -79,9 +80,9 @@ class RsaRequestSigner : public RequestSigner { private: RsaRequestSigner(const std::string& signer_name, - scoped_ptr rsa_private_key); + std::unique_ptr rsa_private_key); - scoped_ptr rsa_private_key_; + std::unique_ptr rsa_private_key_; DISALLOW_COPY_AND_ASSIGN(RsaRequestSigner); }; diff --git a/packager/media/base/rsa_key_unittest.cc b/packager/media/base/rsa_key_unittest.cc index ce1a832bfc..9f9fa5b024 100644 --- a/packager/media/base/rsa_key_unittest.cc +++ b/packager/media/base/rsa_key_unittest.cc @@ -7,8 +7,7 @@ // Unit test for rsa_key RSA encryption and signing. #include - -#include "packager/base/memory/scoped_ptr.h" +#include #include "packager/media/base/rsa_key.h" #include "packager/media/base/test/fake_prng.h" #include "packager/media/base/test/rsa_test_data.h" @@ -44,41 +43,42 @@ class RsaKeyTest : public ::testing::TestWithParam { protected: const RsaTestSet& test_set_; - scoped_ptr private_key_; - scoped_ptr public_key_; + std::unique_ptr private_key_; + std::unique_ptr public_key_; }; TEST_P(RsaKeyTest, BadPublicKey) { - scoped_ptr public_key(RsaPublicKey::Create("bad_public_key")); + std::unique_ptr public_key( + RsaPublicKey::Create("bad_public_key")); EXPECT_TRUE(public_key == NULL); } TEST_P(RsaKeyTest, BadPrivateKey) { - scoped_ptr private_key( + std::unique_ptr private_key( RsaPrivateKey::Create("bad_private_key")); EXPECT_TRUE(private_key == NULL); } TEST_P(RsaKeyTest, LoadPublicKey) { - scoped_ptr public_key( + std::unique_ptr public_key( RsaPublicKey::Create(test_set_.public_key)); EXPECT_TRUE(public_key != NULL); } TEST_P(RsaKeyTest, LoadPrivateKey) { - scoped_ptr private_key( + std::unique_ptr private_key( RsaPrivateKey::Create(test_set_.private_key)); EXPECT_TRUE(private_key != NULL); } TEST_P(RsaKeyTest, LoadPublicKeyInPrivateKey) { - scoped_ptr private_key( + std::unique_ptr private_key( RsaPrivateKey::Create(test_set_.public_key)); EXPECT_TRUE(private_key == NULL); } TEST_P(RsaKeyTest, LoadPrivateKeyInPublicKey) { - scoped_ptr public_key( + std::unique_ptr public_key( RsaPublicKey::Create(test_set_.private_key)); EXPECT_TRUE(public_key == NULL); } diff --git a/packager/media/base/text_track.h b/packager/media/base/text_track.h index 3b90f50aec..a3f71528a4 100644 --- a/packager/media/base/text_track.h +++ b/packager/media/base/text_track.h @@ -5,10 +5,10 @@ #ifndef MEDIA_BASE_TEXT_TRACK_H_ #define MEDIA_BASE_TEXT_TRACK_H_ +#include #include #include "packager/base/callback.h" -#include "packager/base/memory/scoped_ptr.h" #include "packager/base/time/time.h" namespace shaka { @@ -33,10 +33,10 @@ class TextTrack { const std::string& settings) = 0; }; -typedef base::Callback - (TextKind kind, - const std::string& label, - const std::string& language)> AddTextTrackCB; +typedef base::Callback(TextKind kind, + const std::string& label, + const std::string& language)> + AddTextTrackCB; } // namespace media } // namespace shaka diff --git a/packager/media/base/widevine_key_source.cc b/packager/media/base/widevine_key_source.cc index 7a8bb1d5c8..c215a932d5 100644 --- a/packager/media/base/widevine_key_source.cc +++ b/packager/media/base/widevine_key_source.cc @@ -277,12 +277,13 @@ Status WidevineKeySource::GetCryptoPeriodKey(uint32_t crypto_period_index, return GetKeyInternal(crypto_period_index, track_type, key); } -void WidevineKeySource::set_signer(scoped_ptr signer) { - signer_ = signer.Pass(); +void WidevineKeySource::set_signer(std::unique_ptr signer) { + signer_ = std::move(signer); } -void WidevineKeySource::set_key_fetcher(scoped_ptr key_fetcher) { - key_fetcher_ = key_fetcher.Pass(); +void WidevineKeySource::set_key_fetcher( + std::unique_ptr key_fetcher) { + key_fetcher_ = std::move(key_fetcher); } Status WidevineKeySource::GetKeyInternal(uint32_t crypto_period_index, @@ -465,7 +466,9 @@ bool WidevineKeySource::DecodeResponse( DCHECK(response); // Extract base64 formatted response from JSON formatted raw response. - scoped_ptr root(base::JSONReader::Read(raw_response)); + // TODO(kqyang): Remove ".release()" when base is updated to use unique_ptr. + std::unique_ptr root( + base::JSONReader::Read(raw_response).release()); if (!root) { LOG(ERROR) << "'" << raw_response << "' is not in JSON format."; return false; @@ -487,7 +490,8 @@ bool WidevineKeySource::ExtractEncryptionKey( DCHECK(transient_error); *transient_error = false; - scoped_ptr root(base::JSONReader::Read(response)); + // TODO(kqyang): Remove ".release()" when base is updated to use unique_ptr. + std::unique_ptr root(base::JSONReader::Read(response).release()); if (!root) { LOG(ERROR) << "'" << response << "' is not in JSON format."; return false; @@ -541,7 +545,7 @@ bool WidevineKeySource::ExtractEncryptionKey( DCHECK_NE(TRACK_TYPE_UNKNOWN, track_type); RCHECK(encryption_key_map.find(track_type) == encryption_key_map.end()); - scoped_ptr encryption_key(new EncryptionKey()); + std::unique_ptr encryption_key(new EncryptionKey()); if (!GetKeyFromTrack(*track_dict, &encryption_key->key)) return false; diff --git a/packager/media/base/widevine_key_source.h b/packager/media/base/widevine_key_source.h index 1a1e61b259..47b8582840 100644 --- a/packager/media/base/widevine_key_source.h +++ b/packager/media/base/widevine_key_source.h @@ -8,8 +8,7 @@ #define MEDIA_BASE_WIDEVINE_KEY_SOURCE_H_ #include - -#include "packager/base/memory/scoped_ptr.h" +#include #include "packager/base/synchronization/waitable_event.h" #include "packager/base/values.h" #include "packager/media/base/closure_thread.h" @@ -58,11 +57,11 @@ class WidevineKeySource : public KeySource { /// Set signer for the key source. /// @param signer signs the request message. - void set_signer(scoped_ptr signer); + void set_signer(std::unique_ptr signer); /// Inject an @b KeyFetcher object, mainly used for testing. /// @param key_fetcher points to the @b KeyFetcher object to be injected. - void set_key_fetcher(scoped_ptr key_fetcher); + void set_key_fetcher(std::unique_ptr key_fetcher); protected: ClosureThread key_production_thread_; @@ -111,9 +110,9 @@ class WidevineKeySource : public KeySource { // The fetcher object used to fetch keys from the license service. // It is initialized to a default fetcher on class initialization. // Can be overridden using set_key_fetcher for testing or other purposes. - scoped_ptr key_fetcher_; + std::unique_ptr key_fetcher_; std::string server_url_; - scoped_ptr signer_; + std::unique_ptr signer_; base::DictionaryValue request_dict_; const uint32_t crypto_period_count_; @@ -122,7 +121,7 @@ class WidevineKeySource : public KeySource { bool key_production_started_; base::WaitableEvent start_key_production_; uint32_t first_crypto_period_index_; - scoped_ptr key_pool_; + std::unique_ptr key_pool_; EncryptionKeyMap encryption_key_map_; // For non key rotation request. Status common_encryption_request_status_; diff --git a/packager/media/base/widevine_key_source_unittest.cc b/packager/media/base/widevine_key_source_unittest.cc index d580603fe6..75f15198b9 100644 --- a/packager/media/base/widevine_key_source_unittest.cc +++ b/packager/media/base/widevine_key_source_unittest.cc @@ -175,7 +175,7 @@ class WidevineKeySourceTest : public ::testing::Test, protected: void CreateWidevineKeySource() { widevine_key_source_.reset(new WidevineKeySource(kServerUrl, GetParam())); - widevine_key_source_->set_key_fetcher(mock_key_fetcher_.Pass()); + widevine_key_source_->set_key_fetcher(std::move(mock_key_fetcher_)); } void VerifyKeys(bool classic) { @@ -214,9 +214,9 @@ class WidevineKeySourceTest : public ::testing::Test, } } } - scoped_ptr mock_request_signer_; - scoped_ptr mock_key_fetcher_; - scoped_ptr widevine_key_source_; + std::unique_ptr mock_request_signer_; + std::unique_ptr mock_key_fetcher_; + std::unique_ptr widevine_key_source_; std::vector content_id_; private: @@ -239,7 +239,7 @@ TEST_P(WidevineKeySourceTest, GenerateSignatureFailure) { .WillOnce(Return(false)); CreateWidevineKeySource(); - widevine_key_source_->set_signer(mock_request_signer_.Pass()); + widevine_key_source_->set_signer(std::move(mock_request_signer_)); ASSERT_EQ(Status(error::INTERNAL_ERROR, "Signature generation failed."), widevine_key_source_->FetchKeys(content_id_, kPolicy)); } @@ -264,7 +264,7 @@ TEST_P(WidevineKeySourceTest, HttpFetchFailure) { .WillOnce(Return(kMockStatus)); CreateWidevineKeySource(); - widevine_key_source_->set_signer(mock_request_signer_.Pass()); + widevine_key_source_->set_signer(std::move(mock_request_signer_)); ASSERT_EQ(kMockStatus, widevine_key_source_->FetchKeys(content_id_, kPolicy)); } @@ -309,7 +309,7 @@ TEST_P(WidevineKeySourceTest, LicenseStatusCencWithPsshBoxOK) { .WillOnce(DoAll(SetArgPointee<2>(mock_response), Return(Status::OK))); CreateWidevineKeySource(); - widevine_key_source_->set_signer(mock_request_signer_.Pass()); + widevine_key_source_->set_signer(std::move(mock_request_signer_)); std::vector pssh_box(kRequestPsshBox, kRequestPsshBox + arraysize(kRequestPsshBox)); ASSERT_OK(widevine_key_source_->FetchKeys(pssh_box)); @@ -333,7 +333,7 @@ TEST_P(WidevineKeySourceTest, LicenseStatusCencWithKeyIdsOK) { .WillOnce(DoAll(SetArgPointee<2>(mock_response), Return(Status::OK))); CreateWidevineKeySource(); - widevine_key_source_->set_signer(mock_request_signer_.Pass()); + widevine_key_source_->set_signer(std::move(mock_request_signer_)); std::vector> key_ids; key_ids.push_back(std::vector( kRequestKeyId, kRequestKeyId + arraysize(kRequestKeyId))); @@ -355,7 +355,7 @@ TEST_P(WidevineKeySourceTest, LicenseStatusClassicOK) { .WillOnce(DoAll(SetArgPointee<2>(mock_response), Return(Status::OK))); CreateWidevineKeySource(); - widevine_key_source_->set_signer(mock_request_signer_.Pass()); + widevine_key_source_->set_signer(std::move(mock_request_signer_)); ASSERT_OK(widevine_key_source_->FetchKeys(kClassicAssetId)); VerifyKeys(true); } @@ -490,7 +490,7 @@ TEST_P(WidevineKeySourceTest, KeyRotationTest) { } CreateWidevineKeySource(); - widevine_key_source_->set_signer(mock_request_signer_.Pass()); + widevine_key_source_->set_signer(std::move(mock_request_signer_)); ASSERT_OK(widevine_key_source_->FetchKeys(content_id_, kPolicy)); EncryptionKey encryption_key; diff --git a/packager/media/codecs/h264_parser.cc b/packager/media/codecs/h264_parser.cc index c73acf4f90..92c612fdea 100644 --- a/packager/media/codecs/h264_parser.cc +++ b/packager/media/codecs/h264_parser.cc @@ -4,8 +4,8 @@ #include "packager/media/codecs/h264_parser.h" +#include #include "packager/base/logging.h" -#include "packager/base/memory/scoped_ptr.h" #include "packager/base/stl_util.h" #include "packager/media/base/buffer_reader.h" @@ -596,7 +596,7 @@ H264Parser::Result H264Parser::ParseSps(const Nalu& nalu, int* sps_id) { *sps_id = -1; - scoped_ptr sps(new H264Sps()); + std::unique_ptr sps(new H264Sps()); READ_BITS_OR_RETURN(8, &sps->profile_idc); READ_BOOL_OR_RETURN(&sps->constraint_set0_flag); @@ -718,7 +718,7 @@ H264Parser::Result H264Parser::ParsePps(const Nalu& nalu, int* pps_id) { *pps_id = -1; - scoped_ptr pps(new H264Pps()); + std::unique_ptr pps(new H264Pps()); READ_UE_OR_RETURN(&pps->pic_parameter_set_id); READ_UE_OR_RETURN(&pps->seq_parameter_set_id); diff --git a/packager/media/codecs/h265_parser.cc b/packager/media/codecs/h265_parser.cc index 667a58aa8c..6b2cfa4641 100644 --- a/packager/media/codecs/h265_parser.cc +++ b/packager/media/codecs/h265_parser.cc @@ -6,8 +6,8 @@ #include "packager/media/codecs/h265_parser.h" -#include #include +#include #include "packager/base/logging.h" #include "packager/base/stl_util.h" @@ -410,7 +410,7 @@ H265Parser::Result H265Parser::ParsePps(const Nalu& nalu, int* pps_id) { H26xBitReader* br = &reader; *pps_id = -1; - scoped_ptr pps(new H265Pps); + std::unique_ptr pps(new H265Pps); TRUE_OR_RETURN(br->ReadUE(&pps->pic_parameter_set_id)); TRUE_OR_RETURN(br->ReadUE(&pps->seq_parameter_set_id)); @@ -520,7 +520,7 @@ H265Parser::Result H265Parser::ParseSps(const Nalu& nalu, int* sps_id) { *sps_id = -1; - scoped_ptr sps(new H265Sps); + std::unique_ptr sps(new H265Sps); TRUE_OR_RETURN(br->ReadBits(4, &sps->video_parameter_set_id)); TRUE_OR_RETURN(br->ReadBits(3, &sps->max_sub_layers_minus1)); diff --git a/packager/media/codecs/h265_parser.h b/packager/media/codecs/h265_parser.h index 4e848db389..ad07418c0c 100644 --- a/packager/media/codecs/h265_parser.h +++ b/packager/media/codecs/h265_parser.h @@ -8,9 +8,9 @@ #define MEDIA_CODECS_H265_PARSER_H_ #include +#include #include -#include "packager/base/memory/scoped_ptr.h" #include "packager/media/codecs/h26x_bit_reader.h" namespace shaka { diff --git a/packager/media/event/hls_notify_muxer_listener.cc b/packager/media/event/hls_notify_muxer_listener.cc index fcd17bb0ff..df89279dc6 100644 --- a/packager/media/event/hls_notify_muxer_listener.cc +++ b/packager/media/event/hls_notify_muxer_listener.cc @@ -6,8 +6,8 @@ #include "packager/media/event/hls_notify_muxer_listener.h" +#include #include "packager/base/logging.h" -#include "packager/base/memory/scoped_ptr.h" #include "packager/hls/base/hls_notifier.h" #include "packager/media/base/muxer_options.h" #include "packager/media/base/protection_system_specific_info.h" diff --git a/packager/media/event/mpd_notify_muxer_listener.cc b/packager/media/event/mpd_notify_muxer_listener.cc index fd017f8ca6..53d2c39069 100644 --- a/packager/media/event/mpd_notify_muxer_listener.cc +++ b/packager/media/event/mpd_notify_muxer_listener.cc @@ -10,8 +10,8 @@ #include "packager/base/logging.h" #include "packager/media/base/audio_stream_info.h" -#include "packager/media/base/video_stream_info.h" #include "packager/media/base/protection_system_specific_info.h" +#include "packager/media/base/video_stream_info.h" #include "packager/media/event/muxer_listener_internal.h" #include "packager/mpd/base/media_info.pb.h" #include "packager/mpd/base/mpd_notifier.h" @@ -61,7 +61,7 @@ void MpdNotifyMuxerListener::OnMediaStart( const StreamInfo& stream_info, uint32_t time_scale, ContainerType container_type) { - scoped_ptr media_info(new MediaInfo()); + std::unique_ptr media_info(new MediaInfo()); if (!internal::GenerateMediaInfo(muxer_options, stream_info, time_scale, @@ -80,7 +80,7 @@ void MpdNotifyMuxerListener::OnMediaStart( // TODO(kqyang): Check return result. mpd_notifier_->NotifyNewContainer(*media_info, ¬ification_id_); } else { - media_info_ = media_info.Pass(); + media_info_ = std::move(media_info); } } diff --git a/packager/media/event/mpd_notify_muxer_listener.h b/packager/media/event/mpd_notify_muxer_listener.h index cfed22ce14..b119559bec 100644 --- a/packager/media/event/mpd_notify_muxer_listener.h +++ b/packager/media/event/mpd_notify_muxer_listener.h @@ -10,10 +10,10 @@ #define MEDIA_EVENT_MPD_NOTIFY_MUXER_LISTENER_H_ #include +#include #include -#include "packager/base/compiler_specific.h" -#include "packager/base/memory/scoped_ptr.h" +#include "packager/base/macros.h" #include "packager/media/base/muxer_options.h" #include "packager/media/event/muxer_listener.h" @@ -69,7 +69,7 @@ class MpdNotifyMuxerListener : public MuxerListener { MpdNotifier* const mpd_notifier_; uint32_t notification_id_; - scoped_ptr media_info_; + std::unique_ptr media_info_; bool is_encrypted_; // Storage for values passed to OnEncryptionInfoReady(). diff --git a/packager/media/event/mpd_notify_muxer_listener_unittest.cc b/packager/media/event/mpd_notify_muxer_listener_unittest.cc index bec0abb228..14712ac3a2 100644 --- a/packager/media/event/mpd_notify_muxer_listener_unittest.cc +++ b/packager/media/event/mpd_notify_muxer_listener_unittest.cc @@ -90,8 +90,8 @@ class MpdNotifyMuxerListenerTest : public ::testing::Test { params.file_size); } - scoped_ptr listener_; - scoped_ptr notifier_; + std::unique_ptr listener_; + std::unique_ptr notifier_; }; MATCHER_P(ExpectMediaInfoEq, expected_text_format, "") { diff --git a/packager/media/event/vod_media_info_dump_muxer_listener.h b/packager/media/event/vod_media_info_dump_muxer_listener.h index 70daa66da8..6cee30073e 100644 --- a/packager/media/event/vod_media_info_dump_muxer_listener.h +++ b/packager/media/event/vod_media_info_dump_muxer_listener.h @@ -11,11 +11,11 @@ #ifndef MEDIA_EVENT_VOD_MEDIA_INFO_DUMP_MUXER_LISTENER_H_ #define MEDIA_EVENT_VOD_MEDIA_INFO_DUMP_MUXER_LISTENER_H_ +#include #include #include -#include "packager/base/compiler_specific.h" -#include "packager/base/memory/scoped_ptr.h" +#include "packager/base/macros.h" #include "packager/media/base/muxer_options.h" #include "packager/media/event/muxer_listener.h" @@ -68,9 +68,8 @@ class VodMediaInfoDumpMuxerListener : public MuxerListener { const std::string& output_file_path); private: - std::string output_file_name_; - scoped_ptr media_info_; + std::unique_ptr media_info_; bool is_encrypted_; // Storage for values passed to OnEncryptionInfoReady(). diff --git a/packager/media/event/vod_media_info_dump_muxer_listener_unittest.cc b/packager/media/event/vod_media_info_dump_muxer_listener_unittest.cc index b6cd4deca4..2a664f28d1 100644 --- a/packager/media/event/vod_media_info_dump_muxer_listener_unittest.cc +++ b/packager/media/event/vod_media_info_dump_muxer_listener_unittest.cc @@ -9,8 +9,8 @@ #include -#include "packager/base/files/file_util.h" #include "packager/base/files/file_path.h" +#include "packager/base/files/file_util.h" #include "packager/media/base/fourccs.h" #include "packager/media/base/muxer_options.h" #include "packager/media/base/video_stream_info.h" @@ -117,7 +117,7 @@ class VodMediaInfoDumpMuxerListenerTest : public ::testing::Test { protected: base::FilePath temp_file_path_; - scoped_ptr listener_; + std::unique_ptr listener_; private: DISALLOW_COPY_AND_ASSIGN(VodMediaInfoDumpMuxerListenerTest); diff --git a/packager/media/file/file.cc b/packager/media/file/file.cc index 16b70454d2..e5a391f183 100644 --- a/packager/media/file/file.cc +++ b/packager/media/file/file.cc @@ -8,14 +8,13 @@ #include #include - +#include #include "packager/base/logging.h" -#include "packager/base/memory/scoped_ptr.h" +#include "packager/base/strings/string_util.h" #include "packager/media/file/local_file.h" #include "packager/media/file/memory_file.h" #include "packager/media/file/threaded_io_file.h" #include "packager/media/file/udp_file.h" -#include "packager/base/strings/string_util.h" DEFINE_uint64(io_cache_size, 32ULL << 20, @@ -98,7 +97,7 @@ static const SupportedTypeInfo kSupportedTypeInfo[] = { } // namespace File* File::Create(const char* file_name, const char* mode) { - scoped_ptr internal_file( + std::unique_ptr internal_file( CreateInternalFile(file_name, mode)); if (!strncmp(file_name, kMemoryFilePrefix, strlen(kMemoryFilePrefix))) { @@ -109,15 +108,13 @@ File* File::Create(const char* file_name, const char* mode) { if (FLAGS_io_cache_size) { // Enable threaded I/O for "r", "w", and "a" modes only. if (!strcmp(mode, "r")) { - return new ThreadedIoFile(internal_file.Pass(), - ThreadedIoFile::kInputMode, - FLAGS_io_cache_size, + return new ThreadedIoFile(std::move(internal_file), + ThreadedIoFile::kInputMode, FLAGS_io_cache_size, FLAGS_io_block_size); } else if (!strcmp(mode, "w") || !strcmp(mode, "a")) { - return new ThreadedIoFile(internal_file.Pass(), + return new ThreadedIoFile(std::move(internal_file), ThreadedIoFile::kOutputMode, - FLAGS_io_cache_size, - FLAGS_io_block_size); + FLAGS_io_cache_size, FLAGS_io_block_size); } } @@ -127,7 +124,7 @@ File* File::Create(const char* file_name, const char* mode) { } File* File::CreateInternalFile(const char* file_name, const char* mode) { - scoped_ptr internal_file; + std::unique_ptr internal_file; for (size_t i = 0; i < arraysize(kSupportedTypeInfo); ++i) { const SupportedTypeInfo& type_info = kSupportedTypeInfo[i]; if (strncmp(type_info.type, file_name, type_info.type_length) == 0) { @@ -194,7 +191,7 @@ bool File::ReadFileToString(const char* file_name, std::string* contents) { return false; const size_t kBufferSize = 0x40000; // 256KB. - scoped_ptr buf(new char[kBufferSize]); + std::unique_ptr buf(new char[kBufferSize]); int64_t len; while ((len = file->Read(buf.get(), kBufferSize)) > 0) @@ -211,7 +208,7 @@ bool File::Copy(const char* from_file_name, const char* to_file_name) { return false; } - scoped_ptr output_file(File::Open(to_file_name, "w")); + std::unique_ptr output_file(File::Open(to_file_name, "w")); if (!output_file) { LOG(ERROR) << "Failed to write to " << to_file_name; return false; @@ -244,7 +241,7 @@ int64_t File::CopyFile(File* source, File* destination, int64_t max_copy) { max_copy = std::numeric_limits::max(); const int64_t kBufferSize = 0x40000; // 256KB. - scoped_ptr buffer(new uint8_t[kBufferSize]); + std::unique_ptr buffer(new uint8_t[kBufferSize]); int64_t bytes_copied = 0; while (bytes_copied < max_copy) { const int64_t size = std::min(kBufferSize, max_copy - bytes_copied); diff --git a/packager/media/file/file.h b/packager/media/file/file.h index 9ba9ceedfe..ef66ed663b 100644 --- a/packager/media/file/file.h +++ b/packager/media/file/file.h @@ -128,7 +128,7 @@ class File { protected: explicit File(const std::string& file_name) : file_name_(file_name) {} /// Do *not* call the destructor directly (with the "delete" keyword) - /// nor use scoped_ptr; instead use Close(). + /// nor use std::unique_ptr; instead use Close(). virtual ~File() {} /// Internal open. Should not be used directly. diff --git a/packager/media/file/file_closer.h b/packager/media/file/file_closer.h index 29f343e30a..8b8531d781 100644 --- a/packager/media/file/file_closer.h +++ b/packager/media/file/file_closer.h @@ -13,7 +13,7 @@ namespace shaka { namespace media { -/// Used by scoped_ptr to automatically close the file when it goes out of +/// Used by std::unique_ptr to automatically close the file when it goes out of /// scope. struct FileCloser { inline void operator()(File* file) const { diff --git a/packager/media/file/io_cache_unittest.cc b/packager/media/file/io_cache_unittest.cc index 2ba7192b30..f31101fee8 100644 --- a/packager/media/file/io_cache_unittest.cc +++ b/packager/media/file/io_cache_unittest.cc @@ -91,8 +91,8 @@ class IoCacheTest : public testing::Test { } } - scoped_ptr cache_; - scoped_ptr writer_thread_; + std::unique_ptr cache_; + std::unique_ptr writer_thread_; uint8_t reference_block_[kBlockSize]; bool cache_closed_; }; diff --git a/packager/media/file/memory_file.cc b/packager/media/file/memory_file.cc index 4e13bd0ad3..a3235502ae 100644 --- a/packager/media/file/memory_file.cc +++ b/packager/media/file/memory_file.cc @@ -9,9 +9,9 @@ #include // for memcpy #include +#include #include "packager/base/logging.h" -#include "packager/base/memory/scoped_ptr.h" namespace shaka { namespace media { @@ -44,13 +44,13 @@ class FileSystem { private: FileSystem() {} - static scoped_ptr g_file_system_; + static std::unique_ptr g_file_system_; std::map > files_; DISALLOW_COPY_AND_ASSIGN(FileSystem); }; -scoped_ptr FileSystem::g_file_system_; +std::unique_ptr FileSystem::g_file_system_; } // namespace diff --git a/packager/media/file/memory_file_unittest.cc b/packager/media/file/memory_file_unittest.cc index cbd263545a..a930b8c2d2 100644 --- a/packager/media/file/memory_file_unittest.cc +++ b/packager/media/file/memory_file_unittest.cc @@ -3,8 +3,7 @@ // found in the LICENSE file. #include - -#include "packager/base/memory/scoped_ptr.h" +#include #include "packager/media/file/file.h" #include "packager/media/file/file_closer.h" #include "packager/media/file/memory_file.h" @@ -26,14 +25,14 @@ class MemoryFileTest : public testing::Test { }; TEST_F(MemoryFileTest, ModifiesSameFile) { - scoped_ptr writer(File::Open("memory://file1", "w")); + std::unique_ptr writer(File::Open("memory://file1", "w")); ASSERT_TRUE(writer); ASSERT_EQ(kWriteBufferSize, writer->Write(kWriteBuffer, kWriteBufferSize)); // Since File::Open should not create a ThreadedIoFile so there should be // no cache. - scoped_ptr reader(File::Open("memory://file1", "r")); + std::unique_ptr reader(File::Open("memory://file1", "r")); ASSERT_TRUE(reader); uint8_t read_buffer[kWriteBufferSize]; @@ -42,8 +41,8 @@ TEST_F(MemoryFileTest, ModifiesSameFile) { } TEST_F(MemoryFileTest, SupportsDifferentFiles) { - scoped_ptr writer(File::Open("memory://file1", "w")); - scoped_ptr reader(File::Open("memory://file2", "w")); + std::unique_ptr writer(File::Open("memory://file1", "w")); + std::unique_ptr reader(File::Open("memory://file2", "w")); ASSERT_TRUE(writer); ASSERT_TRUE(reader); @@ -52,7 +51,7 @@ TEST_F(MemoryFileTest, SupportsDifferentFiles) { } TEST_F(MemoryFileTest, SeekAndTell) { - scoped_ptr file(File::Open("memory://file1", "w")); + std::unique_ptr file(File::Open("memory://file1", "w")); ASSERT_TRUE(file); ASSERT_EQ(kWriteBufferSize, file->Write(kWriteBuffer, kWriteBufferSize)); @@ -67,7 +66,7 @@ TEST_F(MemoryFileTest, SeekAndTell) { } TEST_F(MemoryFileTest, EndOfFile) { - scoped_ptr file(File::Open("memory://file1", "w")); + std::unique_ptr file(File::Open("memory://file1", "w")); ASSERT_TRUE(file); ASSERT_EQ(kWriteBufferSize, file->Write(kWriteBuffer, kWriteBufferSize)); @@ -83,7 +82,7 @@ TEST_F(MemoryFileTest, EndOfFile) { } TEST_F(MemoryFileTest, ExtendsSize) { - scoped_ptr file(File::Open("memory://file1", "w")); + std::unique_ptr file(File::Open("memory://file1", "w")); ASSERT_TRUE(file); ASSERT_EQ(kWriteBufferSize, file->Write(kWriteBuffer, kWriteBufferSize)); @@ -97,16 +96,16 @@ TEST_F(MemoryFileTest, ExtendsSize) { } TEST_F(MemoryFileTest, ReadMissingFileFails) { - scoped_ptr file(File::Open("memory://file1", "r")); + std::unique_ptr file(File::Open("memory://file1", "r")); EXPECT_FALSE(file); } TEST_F(MemoryFileTest, WriteExistingFileDeletes) { - scoped_ptr file1(File::Open("memory://file1", "w")); + std::unique_ptr file1(File::Open("memory://file1", "w")); ASSERT_TRUE(file1); ASSERT_EQ(kWriteBufferSize, file1->Write(kWriteBuffer, kWriteBufferSize)); - scoped_ptr file2(File::Open("memory://file1", "w")); + std::unique_ptr file2(File::Open("memory://file1", "w")); ASSERT_TRUE(file2); EXPECT_EQ(0, file2->Size()); } diff --git a/packager/media/file/threaded_io_file.cc b/packager/media/file/threaded_io_file.cc index d2e6bf0fae..ed5bce6232 100644 --- a/packager/media/file/threaded_io_file.cc +++ b/packager/media/file/threaded_io_file.cc @@ -17,12 +17,12 @@ namespace media { using base::subtle::NoBarrier_Load; using base::subtle::NoBarrier_Store; -ThreadedIoFile::ThreadedIoFile(scoped_ptr internal_file, +ThreadedIoFile::ThreadedIoFile(std::unique_ptr internal_file, Mode mode, uint64_t io_cache_size, uint64_t io_block_size) : File(internal_file->file_name()), - internal_file_(internal_file.Pass()), + internal_file_(std::move(internal_file)), mode_(mode), cache_(io_cache_size), io_buffer_(io_block_size), diff --git a/packager/media/file/threaded_io_file.h b/packager/media/file/threaded_io_file.h index 4056fa5451..5b57a1bc02 100644 --- a/packager/media/file/threaded_io_file.h +++ b/packager/media/file/threaded_io_file.h @@ -7,8 +7,8 @@ #ifndef PACKAGER_FILE_THREADED_IO_FILE_H_ #define PACKAGER_FILE_THREADED_IO_FILE_H_ +#include #include "packager/base/atomicops.h" -#include "packager/base/memory/scoped_ptr.h" #include "packager/base/synchronization/waitable_event.h" #include "packager/media/file/file.h" #include "packager/media/file/file_closer.h" @@ -25,7 +25,7 @@ class ThreadedIoFile : public File { kOutputMode }; - ThreadedIoFile(scoped_ptr internal_file, + ThreadedIoFile(std::unique_ptr internal_file, Mode mode, uint64_t io_cache_size, uint64_t io_block_size); @@ -53,7 +53,7 @@ class ThreadedIoFile : public File { void RunInInputMode(); void RunInOutputMode(); - scoped_ptr internal_file_; + std::unique_ptr internal_file_; const Mode mode_; IoCache cache_; std::vector io_buffer_; diff --git a/packager/media/formats/mp2t/es_parser_adts.h b/packager/media/formats/mp2t/es_parser_adts.h index 5b899ae55b..12524e346d 100644 --- a/packager/media/formats/mp2t/es_parser_adts.h +++ b/packager/media/formats/mp2t/es_parser_adts.h @@ -6,11 +6,11 @@ #define MEDIA_FORMATS_MP2T_ES_PARSER_ADTS_H_ #include +#include #include #include "packager/base/callback.h" #include "packager/base/compiler_specific.h" -#include "packager/base/memory/scoped_ptr.h" #include "packager/media/base/audio_stream_info.h" #include "packager/media/base/byte_queue.h" #include "packager/media/formats/mp2t/es_parser.h" @@ -65,7 +65,7 @@ class EsParserAdts : public EsParser { EsPtsList pts_list_; // Interpolated PTS for frames that don't have one. - scoped_ptr audio_timestamp_helper_; + std::unique_ptr audio_timestamp_helper_; scoped_refptr last_audio_decoder_config_; diff --git a/packager/media/formats/mp2t/es_parser_h264.cc b/packager/media/formats/mp2t/es_parser_h264.cc index e5d4eeeb82..c6123fd6b5 100644 --- a/packager/media/formats/mp2t/es_parser_h264.cc +++ b/packager/media/formats/mp2t/es_parser_h264.cc @@ -23,7 +23,7 @@ EsParserH264::EsParserH264(uint32_t pid, const NewStreamInfoCB& new_stream_info_cb, const EmitSampleCB& emit_sample_cb) : EsParserH26x(Nalu::kH264, - scoped_ptr( + std::unique_ptr( new H264ByteToUnitStreamConverter()), pid, emit_sample_cb), diff --git a/packager/media/formats/mp2t/es_parser_h264.h b/packager/media/formats/mp2t/es_parser_h264.h index 24b05041d4..b8478f4b16 100644 --- a/packager/media/formats/mp2t/es_parser_h264.h +++ b/packager/media/formats/mp2t/es_parser_h264.h @@ -6,9 +6,8 @@ #define MEDIA_FORMATS_MP2T_ES_PARSER_H264_H_ #include - +#include #include "packager/base/callback.h" -#include "packager/base/memory/scoped_ptr.h" #include "packager/media/formats/mp2t/es_parser_h26x.h" namespace shaka { @@ -50,7 +49,7 @@ class EsParserH264 : public EsParserH26x { scoped_refptr last_video_decoder_config_; bool decoder_config_check_pending_; - scoped_ptr h264_parser_; + std::unique_ptr h264_parser_; }; } // namespace mp2t diff --git a/packager/media/formats/mp2t/es_parser_h265.cc b/packager/media/formats/mp2t/es_parser_h265.cc index ead8d96c9c..7383a34441 100644 --- a/packager/media/formats/mp2t/es_parser_h265.cc +++ b/packager/media/formats/mp2t/es_parser_h265.cc @@ -26,7 +26,7 @@ EsParserH265::EsParserH265(uint32_t pid, const NewStreamInfoCB& new_stream_info_cb, const EmitSampleCB& emit_sample_cb) : EsParserH26x(Nalu::kH265, - scoped_ptr( + std::unique_ptr( new H265ByteToUnitStreamConverter()), pid, emit_sample_cb), diff --git a/packager/media/formats/mp2t/es_parser_h265.h b/packager/media/formats/mp2t/es_parser_h265.h index b43a6be1c8..a639d32e18 100644 --- a/packager/media/formats/mp2t/es_parser_h265.h +++ b/packager/media/formats/mp2t/es_parser_h265.h @@ -10,11 +10,11 @@ #include #include +#include #include #include "packager/base/callback.h" #include "packager/base/compiler_specific.h" -#include "packager/base/memory/scoped_ptr.h" #include "packager/media/formats/mp2t/es_parser_h26x.h" namespace shaka { @@ -52,7 +52,7 @@ class EsParserH265 : public EsParserH26x { scoped_refptr last_video_decoder_config_; bool decoder_config_check_pending_; - scoped_ptr h265_parser_; + std::unique_ptr h265_parser_; }; } // namespace mp2t diff --git a/packager/media/formats/mp2t/es_parser_h26x.cc b/packager/media/formats/mp2t/es_parser_h26x.cc index 35a497971b..f607d847f0 100644 --- a/packager/media/formats/mp2t/es_parser_h26x.cc +++ b/packager/media/formats/mp2t/es_parser_h26x.cc @@ -27,10 +27,9 @@ const int kH265NaluHeaderSize = 2; } // namespace - EsParserH26x::EsParserH26x( Nalu::CodecType type, - scoped_ptr stream_converter, + std::unique_ptr stream_converter, uint32_t pid, const EmitSampleCB& emit_sample_cb) : EsParser(pid), @@ -38,7 +37,7 @@ EsParserH26x::EsParserH26x( type_(type), es_queue_(new media::OffsetByteQueue()), current_search_position_(0), - stream_converter_(stream_converter.Pass()), + stream_converter_(std::move(stream_converter)), pending_sample_duration_(0), waiting_for_key_frame_(true) {} diff --git a/packager/media/formats/mp2t/es_parser_h26x.h b/packager/media/formats/mp2t/es_parser_h26x.h index c8a001c05c..312746830b 100644 --- a/packager/media/formats/mp2t/es_parser_h26x.h +++ b/packager/media/formats/mp2t/es_parser_h26x.h @@ -9,10 +9,10 @@ #include #include +#include #include "packager/base/callback.h" #include "packager/base/compiler_specific.h" -#include "packager/base/memory/scoped_ptr.h" #include "packager/media/codecs/nalu_reader.h" #include "packager/media/formats/mp2t/es_parser.h" @@ -28,7 +28,7 @@ namespace mp2t { class EsParserH26x : public EsParser { public: EsParserH26x(Nalu::CodecType type, - scoped_ptr stream_converter, + std::unique_ptr stream_converter, uint32_t pid, const EmitSampleCB& emit_sample_cb); ~EsParserH26x() override; @@ -99,7 +99,7 @@ class EsParserH26x : public EsParser { Nalu::CodecType type_; // Bytes of the ES stream that have not been emitted yet. - scoped_ptr es_queue_; + std::unique_ptr es_queue_; std::list> timing_desc_list_; // Parser state. @@ -111,7 +111,7 @@ class EsParserH26x : public EsParser { std::deque access_unit_nalus_; // Filter to convert H.264/H.265 Annex B byte stream to unit stream. - scoped_ptr stream_converter_; + std::unique_ptr stream_converter_; // Frame for which we do not yet have a duration. scoped_refptr pending_sample_; diff --git a/packager/media/formats/mp2t/es_parser_h26x_unittest.cc b/packager/media/formats/mp2t/es_parser_h26x_unittest.cc index 06c1130d48..5fe80680da 100644 --- a/packager/media/formats/mp2t/es_parser_h26x_unittest.cc +++ b/packager/media/formats/mp2t/es_parser_h26x_unittest.cc @@ -60,9 +60,9 @@ class FakeByteToUnitStreamConverter : public H26xByteToUnitStreamConverter { class TestableEsParser : public EsParserH26x { public: TestableEsParser(const NewStreamInfoCB& new_stream_info_cb, - const EmitSampleCB& emit_sample_cb) + const EmitSampleCB& emit_sample_cb) : EsParserH26x(Nalu::kH265, - scoped_ptr( + std::unique_ptr( new FakeByteToUnitStreamConverter()), 0, emit_sample_cb), diff --git a/packager/media/formats/mp2t/mp2t_media_parser.cc b/packager/media/formats/mp2t/mp2t_media_parser.cc index 885f65687f..3e2d4f0a7d 100644 --- a/packager/media/formats/mp2t/mp2t_media_parser.cc +++ b/packager/media/formats/mp2t/mp2t_media_parser.cc @@ -4,8 +4,8 @@ #include "packager/media/formats/mp2t/mp2t_media_parser.h" +#include #include "packager/base/bind.h" -#include "packager/base/memory/scoped_ptr.h" #include "packager/base/stl_util.h" #include "packager/media/base/media_sample.h" #include "packager/media/base/stream_info.h" @@ -41,8 +41,9 @@ class PidState { kPidVideoPes, }; - PidState(int pid, PidType pid_type, - scoped_ptr section_parser); + PidState(int pid, + PidType pid_type, + std::unique_ptr section_parser); // Extract the content of the TS packet and parse it. // Return true if successful. @@ -71,7 +72,7 @@ class PidState { int pid_; PidType pid_type_; - scoped_ptr section_parser_; + std::unique_ptr section_parser_; bool enable_; int continuity_counter_; @@ -79,11 +80,12 @@ class PidState { SampleQueue sample_queue_; }; -PidState::PidState(int pid, PidType pid_type, - scoped_ptr section_parser) +PidState::PidState(int pid, + PidType pid_type, + std::unique_ptr section_parser) : pid_(pid), pid_type_(pid_type), - section_parser_(section_parser.Pass()), + section_parser_(std::move(section_parser)), enable_(false), continuity_counter_(-1) { DCHECK(section_parser_); @@ -210,7 +212,8 @@ bool Mp2tMediaParser::Parse(const uint8_t* buf, int size) { } // Parse the TS header, skipping 1 byte if the header is invalid. - scoped_ptr ts_packet(TsPacket::Parse(ts_buffer, ts_buffer_size)); + std::unique_ptr ts_packet( + TsPacket::Parse(ts_buffer, ts_buffer_size)); if (!ts_packet) { DVLOG(1) << "Error: invalid TS packet"; ts_byte_queue_.Pop(1); @@ -225,13 +228,10 @@ bool Mp2tMediaParser::Parse(const uint8_t* buf, int size) { if (it == pids_.end() && ts_packet->pid() == TsSection::kPidPat) { // Create the PAT state here if needed. - scoped_ptr pat_section_parser( - new TsSectionPat( - base::Bind(&Mp2tMediaParser::RegisterPmt, - base::Unretained(this)))); - scoped_ptr pat_pid_state( - new PidState(ts_packet->pid(), PidState::kPidPat, - pat_section_parser.Pass())); + std::unique_ptr pat_section_parser(new TsSectionPat( + base::Bind(&Mp2tMediaParser::RegisterPmt, base::Unretained(this)))); + std::unique_ptr pat_pid_state(new PidState( + ts_packet->pid(), PidState::kPidPat, std::move(pat_section_parser))); pat_pid_state->Enable(); it = pids_.insert( std::pair(ts_packet->pid(), @@ -271,12 +271,10 @@ void Mp2tMediaParser::RegisterPmt(int program_number, int pmt_pid) { // Create the PMT state here if needed. DVLOG(1) << "Create a new PMT parser"; - scoped_ptr pmt_section_parser( - new TsSectionPmt( - base::Bind(&Mp2tMediaParser::RegisterPes, - base::Unretained(this), pmt_pid))); - scoped_ptr pmt_pid_state( - new PidState(pmt_pid, PidState::kPidPmt, pmt_section_parser.Pass())); + std::unique_ptr pmt_section_parser(new TsSectionPmt(base::Bind( + &Mp2tMediaParser::RegisterPes, base::Unretained(this), pmt_pid))); + std::unique_ptr pmt_pid_state( + new PidState(pmt_pid, PidState::kPidPmt, std::move(pmt_section_parser))); pmt_pid_state->Enable(); pids_.insert(std::pair(pmt_pid, pmt_pid_state.release())); } @@ -293,7 +291,7 @@ void Mp2tMediaParser::RegisterPes(int pmt_pid, // Create a stream parser corresponding to the stream type. bool is_audio = false; - scoped_ptr es_parser; + std::unique_ptr es_parser; if (stream_type == kStreamTypeAVC) { es_parser.reset( new EsParserH264( @@ -326,12 +324,12 @@ void Mp2tMediaParser::RegisterPes(int pmt_pid, // Create the PES state here. DVLOG(1) << "Create a new PES state"; - scoped_ptr pes_section_parser( - new TsSectionPes(es_parser.Pass())); + std::unique_ptr pes_section_parser( + new TsSectionPes(std::move(es_parser))); PidState::PidType pid_type = is_audio ? PidState::kPidAudioPes : PidState::kPidVideoPes; - scoped_ptr pes_pid_state( - new PidState(pes_pid, pid_type, pes_section_parser.Pass())); + std::unique_ptr pes_pid_state( + new PidState(pes_pid, pid_type, std::move(pes_section_parser))); pes_pid_state->Enable(); pids_.insert(std::pair(pes_pid, pes_pid_state.release())); } diff --git a/packager/media/formats/mp2t/mp2t_media_parser.h b/packager/media/formats/mp2t/mp2t_media_parser.h index 04ee04a6c6..13879f9d3f 100644 --- a/packager/media/formats/mp2t/mp2t_media_parser.h +++ b/packager/media/formats/mp2t/mp2t_media_parser.h @@ -7,10 +7,9 @@ #include #include +#include -#include "packager/base/compiler_specific.h" #include "packager/base/memory/ref_counted.h" -#include "packager/base/memory/scoped_ptr.h" #include "packager/media/base/byte_queue.h" #include "packager/media/base/media_parser.h" #include "packager/media/base/stream_info.h" diff --git a/packager/media/formats/mp2t/mp2t_media_parser_unittest.cc b/packager/media/formats/mp2t/mp2t_media_parser_unittest.cc index 6cd2b569e2..f37041a172 100644 --- a/packager/media/formats/mp2t/mp2t_media_parser_unittest.cc +++ b/packager/media/formats/mp2t/mp2t_media_parser_unittest.cc @@ -36,7 +36,7 @@ class Mp2tMediaParserTest : public testing::Test { protected: typedef std::map > StreamMap; - scoped_ptr parser_; + std::unique_ptr parser_; StreamMap stream_map_; int audio_frame_count_; int video_frame_count_; diff --git a/packager/media/formats/mp2t/pes_packet_generator.cc b/packager/media/formats/mp2t/pes_packet_generator.cc index 1a952dc36d..861b37ef35 100644 --- a/packager/media/formats/mp2t/pes_packet_generator.cc +++ b/packager/media/formats/mp2t/pes_packet_generator.cc @@ -180,9 +180,9 @@ bool PesPacketGenerator::PushSample(scoped_refptr sample) { } bool PesPacketGenerator::SetEncryptionKey( - scoped_ptr encryption_key) { + std::unique_ptr encryption_key) { if (stream_type_ == kStreamVideo) { - scoped_ptr cbc( + std::unique_ptr cbc( new AesCbcEncryptor(CbcPaddingScheme::kNoPadding)); const uint8_t kEncryptedBlocks = 1; @@ -190,7 +190,7 @@ bool PesPacketGenerator::SetEncryptionKey( encryptor_.reset(new AesPatternCryptor( kEncryptedBlocks, kClearBlocks, AesPatternCryptor::kSkipIfCryptByteBlockRemaining, - AesCryptor::ConstantIvFlag::kUseConstantIv, cbc.Pass())); + AesCryptor::ConstantIvFlag::kUseConstantIv, std::move(cbc))); } else if (stream_type_ == kStreamAudio) { encryptor_.reset( new AesCbcEncryptor(CbcPaddingScheme::kNoPadding, @@ -207,11 +207,11 @@ size_t PesPacketGenerator::NumberOfReadyPesPackets() { return pes_packets_.size(); } -scoped_ptr PesPacketGenerator::GetNextPesPacket() { +std::unique_ptr PesPacketGenerator::GetNextPesPacket() { DCHECK(!pes_packets_.empty()); PesPacket* pes = pes_packets_.front(); pes_packets_.pop_front(); - return scoped_ptr(pes); + return std::unique_ptr(pes); } bool PesPacketGenerator::Flush() { diff --git a/packager/media/formats/mp2t/pes_packet_generator.h b/packager/media/formats/mp2t/pes_packet_generator.h index 7e50bdd7b0..a2801c67a0 100644 --- a/packager/media/formats/mp2t/pes_packet_generator.h +++ b/packager/media/formats/mp2t/pes_packet_generator.h @@ -8,8 +8,8 @@ #define PACKAGER_MEDIA_FORMATS_MP2T_PES_PACKET_GENERATOR_H_ #include +#include -#include "packager/base/memory/scoped_ptr.h" #include "packager/base/stl_util.h" #include "packager/media/base/aes_cryptor.h" #include "packager/media/base/key_source.h" @@ -51,7 +51,7 @@ class PesPacketGenerator { /// @param encryption_key is the key that will be used to encrypt further /// samples. /// @return true on success, false otherwise. - virtual bool SetEncryptionKey(scoped_ptr encryption_key); + virtual bool SetEncryptionKey(std::unique_ptr encryption_key); /// @return The number of PES packets that are ready to be consumed. virtual size_t NumberOfReadyPesPackets(); @@ -59,7 +59,7 @@ class PesPacketGenerator { /// Removes the next PES packet from the stream and returns it. Must have at /// least one packet ready. /// @return Next PES packet that is ready. - virtual scoped_ptr GetNextPesPacket(); + virtual std::unique_ptr GetNextPesPacket(); /// Flush the object. /// This may increase NumberOfReadyPesPackets(). @@ -75,18 +75,18 @@ class PesPacketGenerator { // timestamps. double timescale_scale_ = 0.0; - scoped_ptr converter_; - scoped_ptr adts_converter_; + std::unique_ptr converter_; + std::unique_ptr adts_converter_; // This is the PES packet that this object is currently working on. // This can be used to create a PES from multiple audio samples. - scoped_ptr current_processing_pes_; + std::unique_ptr current_processing_pes_; std::list pes_packets_; STLElementDeleter pes_packets_deleter_; // Current encryption key. - scoped_ptr encryptor_; + std::unique_ptr encryptor_; DISALLOW_COPY_AND_ASSIGN(PesPacketGenerator); }; diff --git a/packager/media/formats/mp2t/pes_packet_generator_unittest.cc b/packager/media/formats/mp2t/pes_packet_generator_unittest.cc index f4e2fe3846..94fc32bdaf 100644 --- a/packager/media/formats/mp2t/pes_packet_generator_unittest.cc +++ b/packager/media/formats/mp2t/pes_packet_generator_unittest.cc @@ -124,14 +124,14 @@ scoped_refptr CreateAudioStreamInfo(Codec codec) { class PesPacketGeneratorTest : public ::testing::Test { protected: void UseMockNalUnitToByteStreamConverter( - scoped_ptr + std::unique_ptr mock_nal_unit_to_byte_stream_converter) { - generator_.converter_ = mock_nal_unit_to_byte_stream_converter.Pass(); + generator_.converter_ = std::move(mock_nal_unit_to_byte_stream_converter); } void UseMockAACAudioSpecificConfig( - scoped_ptr mock) { - generator_.adts_converter_ = mock.Pass(); + std::unique_ptr mock) { + generator_.adts_converter_ = std::move(mock); } void H264EncryptionTest(const uint8_t* input, @@ -150,7 +150,7 @@ class PesPacketGeneratorTest : public ::testing::Test { sample->set_pts(kPts); sample->set_dts(kDts); - scoped_ptr mock( + std::unique_ptr mock( new MockNalUnitToByteStreamConverter()); // Returning only the input data so that it doesn't have all the unnecessary @@ -159,17 +159,17 @@ class PesPacketGeneratorTest : public ::testing::Test { EXPECT_CALL(*mock, ConvertUnitToByteStream(_, input_size, kIsKeyFrame, _)) .WillOnce(DoAll(SetArgPointee<3>(clear_data), Return(true))); - UseMockNalUnitToByteStreamConverter(mock.Pass()); + UseMockNalUnitToByteStreamConverter(std::move(mock)); const std::vector all_zero(16, 0); - scoped_ptr encryption_key(new EncryptionKey()); + std::unique_ptr encryption_key(new EncryptionKey()); encryption_key->key = all_zero; encryption_key->iv = all_zero; - EXPECT_TRUE(generator_.SetEncryptionKey(encryption_key.Pass())); + EXPECT_TRUE(generator_.SetEncryptionKey(std::move(encryption_key))); EXPECT_TRUE(generator_.PushSample(sample)); EXPECT_EQ(1u, generator_.NumberOfReadyPesPackets()); - scoped_ptr pes_packet = generator_.GetNextPesPacket(); + std::unique_ptr pes_packet = generator_.GetNextPesPacket(); ASSERT_TRUE(pes_packet); std::vector expected(expected_output, @@ -197,21 +197,21 @@ class PesPacketGeneratorTest : public ::testing::Test { scoped_refptr sample = MediaSample::CopyFrom( input, input_size, kIsKeyFrame); - scoped_ptr mock( + std::unique_ptr mock( new MockAACAudioSpecificConfig()); EXPECT_CALL(*mock, ConvertToADTS(_)).WillOnce(Return(true)); - UseMockAACAudioSpecificConfig(mock.Pass()); + UseMockAACAudioSpecificConfig(std::move(mock)); const std::vector all_zero(16, 0); - scoped_ptr encryption_key(new EncryptionKey()); + std::unique_ptr encryption_key(new EncryptionKey()); encryption_key->key = all_zero; encryption_key->iv = all_zero; - EXPECT_TRUE(generator_.SetEncryptionKey(encryption_key.Pass())); + EXPECT_TRUE(generator_.SetEncryptionKey(std::move(encryption_key))); EXPECT_TRUE(generator_.PushSample(sample)); EXPECT_EQ(1u, generator_.NumberOfReadyPesPackets()); - scoped_ptr pes_packet = generator_.GetNextPesPacket(); + std::unique_ptr pes_packet = generator_.GetNextPesPacket(); ASSERT_TRUE(pes_packet); std::vector expected(expected_output, @@ -266,17 +266,17 @@ TEST_F(PesPacketGeneratorTest, AddVideoSample) { std::vector expected_data(kAnyData, kAnyData + arraysize(kAnyData)); - scoped_ptr mock( + std::unique_ptr mock( new MockNalUnitToByteStreamConverter()); EXPECT_CALL(*mock, ConvertUnitToByteStream(_, arraysize(kAnyData), kIsKeyFrame, _)) .WillOnce(DoAll(SetArgPointee<3>(expected_data), Return(true))); - UseMockNalUnitToByteStreamConverter(mock.Pass()); + UseMockNalUnitToByteStreamConverter(std::move(mock)); EXPECT_TRUE(generator_.PushSample(sample)); EXPECT_EQ(1u, generator_.NumberOfReadyPesPackets()); - scoped_ptr pes_packet = generator_.GetNextPesPacket(); + std::unique_ptr pes_packet = generator_.GetNextPesPacket(); ASSERT_TRUE(pes_packet); EXPECT_EQ(0u, generator_.NumberOfReadyPesPackets()); @@ -297,13 +297,13 @@ TEST_F(PesPacketGeneratorTest, AddVideoSampleFailedToConvert) { MediaSample::CopyFrom(kAnyData, arraysize(kAnyData), kIsKeyFrame); std::vector expected_data(kAnyData, kAnyData + arraysize(kAnyData)); - scoped_ptr mock( + std::unique_ptr mock( new MockNalUnitToByteStreamConverter()); EXPECT_CALL(*mock, ConvertUnitToByteStream(_, arraysize(kAnyData), kIsKeyFrame, _)) .WillOnce(Return(false)); - UseMockNalUnitToByteStreamConverter(mock.Pass()); + UseMockNalUnitToByteStreamConverter(std::move(mock)); EXPECT_FALSE(generator_.PushSample(sample)); EXPECT_EQ(0u, generator_.NumberOfReadyPesPackets()); @@ -320,15 +320,16 @@ TEST_F(PesPacketGeneratorTest, AddAudioSample) { std::vector expected_data(kAnyData, kAnyData + arraysize(kAnyData)); - scoped_ptr mock(new MockAACAudioSpecificConfig()); + std::unique_ptr mock( + new MockAACAudioSpecificConfig()); EXPECT_CALL(*mock, ConvertToADTS(_)) .WillOnce(DoAll(SetArgPointee<0>(expected_data), Return(true))); - UseMockAACAudioSpecificConfig(mock.Pass()); + UseMockAACAudioSpecificConfig(std::move(mock)); EXPECT_TRUE(generator_.PushSample(sample)); EXPECT_EQ(1u, generator_.NumberOfReadyPesPackets()); - scoped_ptr pes_packet = generator_.GetNextPesPacket(); + std::unique_ptr pes_packet = generator_.GetNextPesPacket(); ASSERT_TRUE(pes_packet); EXPECT_EQ(0u, generator_.NumberOfReadyPesPackets()); @@ -346,10 +347,11 @@ TEST_F(PesPacketGeneratorTest, AddAudioSampleFailedToConvert) { scoped_refptr sample = MediaSample::CopyFrom(kAnyData, arraysize(kAnyData), kIsKeyFrame); - scoped_ptr mock(new MockAACAudioSpecificConfig()); + std::unique_ptr mock( + new MockAACAudioSpecificConfig()); EXPECT_CALL(*mock, ConvertToADTS(_)).WillOnce(Return(false)); - UseMockAACAudioSpecificConfig(mock.Pass()); + UseMockAACAudioSpecificConfig(std::move(mock)); EXPECT_FALSE(generator_.PushSample(sample)); EXPECT_EQ(0u, generator_.NumberOfReadyPesPackets()); @@ -375,17 +377,17 @@ TEST_F(PesPacketGeneratorTest, TimeStampScaling) { sample->set_pts(kPts); sample->set_dts(kDts); - scoped_ptr mock( + std::unique_ptr mock( new MockNalUnitToByteStreamConverter()); EXPECT_CALL(*mock, ConvertUnitToByteStream(_, arraysize(kAnyData), kIsKeyFrame, _)) .WillOnce(Return(true)); - UseMockNalUnitToByteStreamConverter(mock.Pass()); + UseMockNalUnitToByteStreamConverter(std::move(mock)); EXPECT_TRUE(generator_.PushSample(sample)); EXPECT_EQ(1u, generator_.NumberOfReadyPesPackets()); - scoped_ptr pes_packet = generator_.GetNextPesPacket(); + std::unique_ptr pes_packet = generator_.GetNextPesPacket(); ASSERT_TRUE(pes_packet); EXPECT_EQ(0u, generator_.NumberOfReadyPesPackets()); diff --git a/packager/media/formats/mp2t/ts_muxer.h b/packager/media/formats/mp2t/ts_muxer.h index ce62cb66aa..35a1fa333b 100644 --- a/packager/media/formats/mp2t/ts_muxer.h +++ b/packager/media/formats/mp2t/ts_muxer.h @@ -32,7 +32,7 @@ class TsMuxer : public Muxer { void FireOnMediaStartEvent(); void FireOnMediaEndEvent(); - scoped_ptr segmenter_; + std::unique_ptr segmenter_; DISALLOW_COPY_AND_ASSIGN(TsMuxer); }; diff --git a/packager/media/formats/mp2t/ts_packet.cc b/packager/media/formats/mp2t/ts_packet.cc index 3e0d918419..e1de014279 100644 --- a/packager/media/formats/mp2t/ts_packet.cc +++ b/packager/media/formats/mp2t/ts_packet.cc @@ -4,7 +4,7 @@ #include "packager/media/formats/mp2t/ts_packet.h" -#include "packager/base/memory/scoped_ptr.h" +#include #include "packager/media/base/bit_reader.h" #include "packager/media/formats/mp2t/mp2t_common.h" @@ -57,7 +57,7 @@ TsPacket* TsPacket::Parse(const uint8_t* buf, int size) { return NULL; } - scoped_ptr ts_packet(new TsPacket()); + std::unique_ptr ts_packet(new TsPacket()); bool status = ts_packet->ParseHeader(buf); if (!status) { DVLOG(1) << "Parsing header failed"; diff --git a/packager/media/formats/mp2t/ts_section_pes.cc b/packager/media/formats/mp2t/ts_section_pes.cc index 8ec595010f..1063d42952 100644 --- a/packager/media/formats/mp2t/ts_section_pes.cc +++ b/packager/media/formats/mp2t/ts_section_pes.cc @@ -82,13 +82,13 @@ namespace shaka { namespace media { namespace mp2t { -TsSectionPes::TsSectionPes(scoped_ptr es_parser) - : es_parser_(es_parser.release()), - wait_for_pusi_(true), - previous_pts_valid_(false), - previous_pts_(0), - previous_dts_valid_(false), - previous_dts_(0) { +TsSectionPes::TsSectionPes(std::unique_ptr es_parser) + : es_parser_(es_parser.release()), + wait_for_pusi_(true), + previous_pts_valid_(false), + previous_pts_(0), + previous_dts_valid_(false), + previous_dts_(0) { DCHECK(es_parser_); } diff --git a/packager/media/formats/mp2t/ts_section_pes.h b/packager/media/formats/mp2t/ts_section_pes.h index 40f5b21c69..d96d16ebe0 100644 --- a/packager/media/formats/mp2t/ts_section_pes.h +++ b/packager/media/formats/mp2t/ts_section_pes.h @@ -6,9 +6,8 @@ #define MEDIA_FORMATS_MP2T_TS_SECTION_PES_H_ #include - +#include #include "packager/base/compiler_specific.h" -#include "packager/base/memory/scoped_ptr.h" #include "packager/media/base/byte_queue.h" #include "packager/media/formats/mp2t/ts_section.h" @@ -20,7 +19,7 @@ class EsParser; class TsSectionPes : public TsSection { public: - explicit TsSectionPes(scoped_ptr es_parser); + explicit TsSectionPes(std::unique_ptr es_parser); ~TsSectionPes() override; // TsSection implementation. @@ -46,7 +45,7 @@ class TsSectionPes : public TsSection { ByteQueue pes_byte_queue_; // ES parser. - scoped_ptr es_parser_; + std::unique_ptr es_parser_; // Do not start parsing before getting a unit start indicator. bool wait_for_pusi_; diff --git a/packager/media/formats/mp2t/ts_segmenter.cc b/packager/media/formats/mp2t/ts_segmenter.cc index fa1be6d98c..b2002a079f 100644 --- a/packager/media/formats/mp2t/ts_segmenter.cc +++ b/packager/media/formats/mp2t/ts_segmenter.cc @@ -45,7 +45,7 @@ Status TsSegmenter::Initialize(const StreamInfo& stream_info, } if (encryption_key_source) { - scoped_ptr encryption_key(new EncryptionKey()); + std::unique_ptr encryption_key(new EncryptionKey()); const KeySource::TrackType type = GetTrackTypeForEncryption(stream_info, max_sd_pixels); Status status = encryption_key_source->GetKey(type, encryption_key.get()); @@ -58,7 +58,7 @@ Status TsSegmenter::Initialize(const StreamInfo& stream_info, if (!status.ok()) return status; - encryption_key_ = encryption_key.Pass(); + encryption_key_ = std::move(encryption_key); clear_lead_in_seconds_ = clear_lead_in_seconds; if (listener_) { @@ -109,13 +109,13 @@ Status TsSegmenter::AddSample(scoped_refptr sample) { return WritePesPacketsToFile(); } -void TsSegmenter::InjectTsWriterForTesting(scoped_ptr writer) { - ts_writer_ = writer.Pass(); +void TsSegmenter::InjectTsWriterForTesting(std::unique_ptr writer) { + ts_writer_ = std::move(writer); } void TsSegmenter::InjectPesPacketGeneratorForTesting( - scoped_ptr generator) { - pes_packet_generator_ = generator.Pass(); + std::unique_ptr generator) { + pes_packet_generator_ = std::move(generator); } void TsSegmenter::SetTsWriterFileOpenedForTesting(bool value) { @@ -138,14 +138,14 @@ Status TsSegmenter::OpenNewSegmentIfClosed(uint32_t next_pts) { Status TsSegmenter::WritePesPacketsToFile() { while (pes_packet_generator_->NumberOfReadyPesPackets() > 0u) { - scoped_ptr pes_packet = + std::unique_ptr pes_packet = pes_packet_generator_->GetNextPesPacket(); Status status = OpenNewSegmentIfClosed(pes_packet->pts()); if (!status.ok()) return status; - if (!ts_writer_->AddPesPacket(pes_packet.Pass())) + if (!ts_writer_->AddPesPacket(std::move(pes_packet))) return Status(error::MUXER_FAILURE, "Failed to add PES packet."); } return Status::OK; @@ -187,7 +187,7 @@ Status TsSegmenter::NotifyEncrypted() { if (listener_) listener_->OnEncryptionStart(); - if (!pes_packet_generator_->SetEncryptionKey(encryption_key_.Pass())) + if (!pes_packet_generator_->SetEncryptionKey(std::move(encryption_key_))) return Status(error::INTERNAL_ERROR, "Failed to set encryption key."); ts_writer_->SignalEncrypted(); } diff --git a/packager/media/formats/mp2t/ts_segmenter.h b/packager/media/formats/mp2t/ts_segmenter.h index b554f79eb9..55055c633c 100644 --- a/packager/media/formats/mp2t/ts_segmenter.h +++ b/packager/media/formats/mp2t/ts_segmenter.h @@ -7,7 +7,7 @@ #ifndef PACKAGER_MEDIA_FORMATS_MP2T_TS_SEGMENTER_H_ #define PACKAGER_MEDIA_FORMATS_MP2T_TS_SEGMENTER_H_ -#include "packager/base/memory/scoped_ptr.h" +#include #include "packager/media/base/media_stream.h" #include "packager/media/base/muxer_options.h" #include "packager/media/base/status.h" @@ -54,11 +54,11 @@ class TsSegmenter { Status AddSample(scoped_refptr sample); /// Only for testing. - void InjectTsWriterForTesting(scoped_ptr writer); + void InjectTsWriterForTesting(std::unique_ptr writer); /// Only for testing. void InjectPesPacketGeneratorForTesting( - scoped_ptr generator); + std::unique_ptr generator); /// Only for testing. void SetTsWriterFileOpenedForTesting(bool value); @@ -94,11 +94,11 @@ class TsSegmenter { // Used for segment template. uint64_t segment_number_ = 0; - scoped_ptr ts_writer_; + std::unique_ptr ts_writer_; // Set to true if TsWriter::NewFile() succeeds, set to false after // TsWriter::FinalizeFile() succeeds. bool ts_writer_file_opened_ = false; - scoped_ptr pes_packet_generator_; + std::unique_ptr pes_packet_generator_; // For OnNewSegment(). uint64_t current_segment_start_time_ = 0; @@ -106,7 +106,7 @@ class TsSegmenter { // the segment has been finalized. std::string current_segment_path_; - scoped_ptr encryption_key_; + std::unique_ptr encryption_key_; double clear_lead_in_seconds_ = 0; // The total duration of the segments that it has segmented. This only diff --git a/packager/media/formats/mp2t/ts_segmenter_unittest.cc b/packager/media/formats/mp2t/ts_segmenter_unittest.cc index 11bbb5a346..e24a8a42f1 100644 --- a/packager/media/formats/mp2t/ts_segmenter_unittest.cc +++ b/packager/media/formats/mp2t/ts_segmenter_unittest.cc @@ -55,17 +55,19 @@ class MockPesPacketGenerator : public PesPacketGenerator { MOCK_METHOD1(Initialize, bool(const StreamInfo& info)); MOCK_METHOD1(PushSample, bool(scoped_refptr sample)); MOCK_METHOD1(SetEncryptionKeyMock, bool(EncryptionKey* encryption_key)); - bool SetEncryptionKey(scoped_ptr encryption_key) override { + bool SetEncryptionKey( + std::unique_ptr encryption_key) override { return SetEncryptionKeyMock(encryption_key.get()); } MOCK_METHOD0(NumberOfReadyPesPackets, size_t()); - // Hack found at the URL below for mocking methods that return scoped_ptr. + // Hack found at the URL below for mocking methods that return + // std::unique_ptr. // https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/01sDxsJ1OYw MOCK_METHOD0(GetNextPesPacketMock, PesPacket*()); - scoped_ptr GetNextPesPacket() override { - return scoped_ptr(GetNextPesPacketMock()); + std::unique_ptr GetNextPesPacket() override { + return std::unique_ptr(GetNextPesPacketMock()); } MOCK_METHOD0(Flush, bool()); @@ -78,9 +80,9 @@ class MockTsWriter : public TsWriter { MOCK_METHOD0(SignalEncrypted, void()); MOCK_METHOD0(FinalizeSegment, bool()); - // Similar to the hack above but takes a scoped_ptr. + // Similar to the hack above but takes a std::unique_ptr. MOCK_METHOD1(AddPesPacketMock, bool(PesPacket* pes_packet)); - bool AddPesPacket(scoped_ptr pes_packet) override { + bool AddPesPacket(std::unique_ptr pes_packet) override { // No need to keep the pes packet around for the current tests. return AddPesPacketMock(pes_packet.get()); } @@ -101,8 +103,8 @@ class TsSegmenterTest : public ::testing::Test { mock_pes_packet_generator_.reset(new MockPesPacketGenerator()); } - scoped_ptr mock_ts_writer_; - scoped_ptr mock_pes_packet_generator_; + std::unique_ptr mock_ts_writer_; + std::unique_ptr mock_pes_packet_generator_; }; TEST_F(TsSegmenterTest, Initialize) { @@ -118,9 +120,9 @@ TEST_F(TsSegmenterTest, Initialize) { EXPECT_CALL(*mock_pes_packet_generator_, Initialize(_)) .WillOnce(Return(true)); - segmenter.InjectTsWriterForTesting(mock_ts_writer_.Pass()); + segmenter.InjectTsWriterForTesting(std::move(mock_ts_writer_)); segmenter.InjectPesPacketGeneratorForTesting( - mock_pes_packet_generator_.Pass()); + std::move(mock_pes_packet_generator_)); EXPECT_OK(segmenter.Initialize(*stream_info, nullptr, 0, 0)); } @@ -165,9 +167,9 @@ TEST_F(TsSegmenterTest, AddSample) { EXPECT_CALL(*mock_pes_packet_generator_, GetNextPesPacketMock()) .WillOnce(Return(new PesPacket())); - segmenter.InjectTsWriterForTesting(mock_ts_writer_.Pass()); + segmenter.InjectTsWriterForTesting(std::move(mock_ts_writer_)); segmenter.InjectPesPacketGeneratorForTesting( - mock_pes_packet_generator_.Pass()); + std::move(mock_pes_packet_generator_)); EXPECT_OK(segmenter.Initialize(*stream_info, nullptr, 0, 0)); EXPECT_OK(segmenter.AddSample(sample)); @@ -270,9 +272,9 @@ TEST_F(TsSegmenterTest, PassedSegmentDuration) { .InSequence(pes_packet_sequence) .WillOnce(Return(new PesPacket())); - segmenter.InjectTsWriterForTesting(mock_ts_writer_.Pass()); + segmenter.InjectTsWriterForTesting(std::move(mock_ts_writer_)); segmenter.InjectPesPacketGeneratorForTesting( - mock_pes_packet_generator_.Pass()); + std::move(mock_pes_packet_generator_)); EXPECT_OK(segmenter.Initialize(*stream_info, nullptr, 0, 0)); EXPECT_OK(segmenter.AddSample(sample1)); EXPECT_OK(segmenter.AddSample(sample2)); @@ -297,9 +299,9 @@ TEST_F(TsSegmenterTest, InitializeThenFinalize) { ON_CALL(*mock_pes_packet_generator_, NumberOfReadyPesPackets()) .WillByDefault(Return(0)); - segmenter.InjectTsWriterForTesting(mock_ts_writer_.Pass()); + segmenter.InjectTsWriterForTesting(std::move(mock_ts_writer_)); segmenter.InjectPesPacketGeneratorForTesting( - mock_pes_packet_generator_.Pass()); + std::move(mock_pes_packet_generator_)); EXPECT_OK(segmenter.Initialize(*stream_info, nullptr, 0, 0)); EXPECT_OK(segmenter.Finalize()); } @@ -328,9 +330,9 @@ TEST_F(TsSegmenterTest, Finalize) { .WillOnce(Return(0u)); EXPECT_CALL(*mock_ts_writer_, FinalizeSegment()).WillOnce(Return(true)); - segmenter.InjectTsWriterForTesting(mock_ts_writer_.Pass()); + segmenter.InjectTsWriterForTesting(std::move(mock_ts_writer_)); segmenter.InjectPesPacketGeneratorForTesting( - mock_pes_packet_generator_.Pass()); + std::move(mock_pes_packet_generator_)); EXPECT_OK(segmenter.Initialize(*stream_info, nullptr, 0, 0)); segmenter.SetTsWriterFileOpenedForTesting(true); EXPECT_OK(segmenter.Finalize()); @@ -434,9 +436,9 @@ TEST_F(TsSegmenterTest, SegmentOnlyBeforeKeyFrame) { .InSequence(pes_packet_sequence) .WillOnce(Return(new PesPacket())); - segmenter.InjectTsWriterForTesting(mock_ts_writer_.Pass()); + segmenter.InjectTsWriterForTesting(std::move(mock_ts_writer_)); segmenter.InjectPesPacketGeneratorForTesting( - mock_pes_packet_generator_.Pass()); + std::move(mock_pes_packet_generator_)); EXPECT_OK(segmenter.Initialize(*stream_info, nullptr, 0, 0)); EXPECT_OK(segmenter.AddSample(key_frame_sample1)); EXPECT_OK(segmenter.AddSample(non_key_frame_sample)); @@ -464,9 +466,9 @@ TEST_F(TsSegmenterTest, WithEncryptionNoClearLead) { EXPECT_CALL(*mock_pes_packet_generator_, SetEncryptionKeyMock(_)) .WillOnce(Return(true)); - segmenter.InjectTsWriterForTesting(mock_ts_writer_.Pass()); + segmenter.InjectTsWriterForTesting(std::move(mock_ts_writer_)); segmenter.InjectPesPacketGeneratorForTesting( - mock_pes_packet_generator_.Pass()); + std::move(mock_pes_packet_generator_)); MockKeySource mock_key_source; EXPECT_CALL(mock_key_source, GetKey(KeySource::TRACK_TYPE_HD, _)) @@ -502,9 +504,9 @@ TEST_F(TsSegmenterTest, WithEncryptionNoClearLeadNoMuxerListener) { EXPECT_CALL(*mock_pes_packet_generator_, SetEncryptionKeyMock(_)) .WillOnce(Return(true)); - segmenter.InjectTsWriterForTesting(mock_ts_writer_.Pass()); + segmenter.InjectTsWriterForTesting(std::move(mock_ts_writer_)); segmenter.InjectPesPacketGeneratorForTesting( - mock_pes_packet_generator_.Pass()); + std::move(mock_pes_packet_generator_)); MockKeySource mock_key_source; EXPECT_CALL(mock_key_source, GetKey(KeySource::TRACK_TYPE_HD, _)) @@ -597,9 +599,9 @@ TEST_F(TsSegmenterTest, WithEncryptionWithClearLead) { MockTsWriter* mock_ts_writer_raw = mock_ts_writer_.get(); - segmenter.InjectTsWriterForTesting(mock_ts_writer_.Pass()); + segmenter.InjectTsWriterForTesting(std::move(mock_ts_writer_)); segmenter.InjectPesPacketGeneratorForTesting( - mock_pes_packet_generator_.Pass()); + std::move(mock_pes_packet_generator_)); MockKeySource mock_key_source; // This should be called AFTER the first AddSample(). diff --git a/packager/media/formats/mp2t/ts_writer.cc b/packager/media/formats/mp2t/ts_writer.cc index 9e5fb76d31..cc631597a6 100644 --- a/packager/media/formats/mp2t/ts_writer.cc +++ b/packager/media/formats/mp2t/ts_writer.cc @@ -235,7 +235,7 @@ bool TsWriter::FinalizeSegment() { return current_file_.release()->Close(); } -bool TsWriter::AddPesPacket(scoped_ptr pes_packet) { +bool TsWriter::AddPesPacket(std::unique_ptr pes_packet) { DCHECK(current_file_); if (!WritePesToFile(*pes_packet, &elementary_stream_continuity_counter_, current_file_.get())) { @@ -248,8 +248,8 @@ bool TsWriter::AddPesPacket(scoped_ptr pes_packet) { } void TsWriter::SetProgramMapTableWriterForTesting( - scoped_ptr table_writer) { - pmt_writer_ = table_writer.Pass(); + std::unique_ptr table_writer) { + pmt_writer_ = std::move(table_writer); } } // namespace mp2t diff --git a/packager/media/formats/mp2t/ts_writer.h b/packager/media/formats/mp2t/ts_writer.h index b46a0b7aa6..d40ce95ddb 100644 --- a/packager/media/formats/mp2t/ts_writer.h +++ b/packager/media/formats/mp2t/ts_writer.h @@ -9,9 +9,9 @@ #include #include +#include #include -#include "packager/base/memory/scoped_ptr.h" #include "packager/media/base/media_stream.h" #include "packager/media/file/file.h" #include "packager/media/file/file_closer.h" @@ -53,11 +53,11 @@ class TsWriter { /// immediately. /// @param pes_packet gets added to the writer. /// @return true on success, false otherwise. - virtual bool AddPesPacket(scoped_ptr pes_packet); + virtual bool AddPesPacket(std::unique_ptr pes_packet); /// Only for testing. void SetProgramMapTableWriterForTesting( - scoped_ptr table_writer); + std::unique_ptr table_writer); private: // True if further segments generated by this instance should be encrypted. @@ -67,9 +67,9 @@ class TsWriter { ContinuityCounter pat_continuity_counter_; ContinuityCounter elementary_stream_continuity_counter_; - scoped_ptr pmt_writer_; + std::unique_ptr pmt_writer_; - scoped_ptr current_file_; + std::unique_ptr current_file_; DISALLOW_COPY_AND_ASSIGN(TsWriter); }; diff --git a/packager/media/formats/mp2t/ts_writer_unittest.cc b/packager/media/formats/mp2t/ts_writer_unittest.cc index 78c189a81b..b632d7bec9 100644 --- a/packager/media/formats/mp2t/ts_writer_unittest.cc +++ b/packager/media/formats/mp2t/ts_writer_unittest.cc @@ -194,7 +194,7 @@ TEST_F(TsWriterTest, InitializeAudioNonAac) { // This test covers verifies the PAT, and since it doesn't change, other tests // shouldn't have to check this. TEST_F(TsWriterTest, ClearH264Psi) { - scoped_ptr mock_pmt_writer( + std::unique_ptr mock_pmt_writer( new MockProgramMapTableWriter()); EXPECT_CALL(*mock_pmt_writer, ClearSegmentPmt(_)).WillOnce(WriteOnePmt()); @@ -204,7 +204,7 @@ TEST_F(TsWriterTest, ClearH264Psi) { kTrickPlayRate, kNaluLengthSize, kLanguage, kIsEncrypted)); EXPECT_TRUE(ts_writer_.Initialize(*stream_info)); - ts_writer_.SetProgramMapTableWriterForTesting(mock_pmt_writer.Pass()); + ts_writer_.SetProgramMapTableWriterForTesting(std::move(mock_pmt_writer)); EXPECT_TRUE(ts_writer_.NewSegment(test_file_name_)); ASSERT_TRUE(ts_writer_.FinalizeSegment()); @@ -248,7 +248,7 @@ TEST_F(TsWriterTest, ClearH264Psi) { } TEST_F(TsWriterTest, ClearAacPmt) { - scoped_ptr mock_pmt_writer( + std::unique_ptr mock_pmt_writer( new MockProgramMapTableWriter()); EXPECT_CALL(*mock_pmt_writer, ClearSegmentPmt(_)).WillOnce(WriteOnePmt()); @@ -259,7 +259,7 @@ TEST_F(TsWriterTest, ClearAacPmt) { kMaxBitrate, kAverageBitrate, kLanguage, kIsEncrypted)); EXPECT_TRUE(ts_writer_.Initialize(*stream_info)); - ts_writer_.SetProgramMapTableWriterForTesting(mock_pmt_writer.Pass()); + ts_writer_.SetProgramMapTableWriterForTesting(std::move(mock_pmt_writer)); EXPECT_TRUE(ts_writer_.NewSegment(test_file_name_)); ASSERT_TRUE(ts_writer_.FinalizeSegment()); @@ -275,7 +275,7 @@ TEST_F(TsWriterTest, ClearAacPmt) { // The stream is flaged with will_be_encrypted. Verify that 2 PMTs are created. // One for clear lead and another for encrypted segments that follow. TEST_F(TsWriterTest, ClearLeadH264Pmt) { - scoped_ptr mock_pmt_writer( + std::unique_ptr mock_pmt_writer( new MockProgramMapTableWriter()); EXPECT_CALL(*mock_pmt_writer, ClearSegmentPmt(_)) .WillOnce(WriteTwoPmts()); @@ -286,7 +286,7 @@ TEST_F(TsWriterTest, ClearLeadH264Pmt) { kTrickPlayRate, kNaluLengthSize, kLanguage, kIsEncrypted)); EXPECT_TRUE(ts_writer_.Initialize(*stream_info)); - ts_writer_.SetProgramMapTableWriterForTesting(mock_pmt_writer.Pass()); + ts_writer_.SetProgramMapTableWriterForTesting(std::move(mock_pmt_writer)); EXPECT_TRUE(ts_writer_.NewSegment(test_file_name_)); EXPECT_TRUE(ts_writer_.FinalizeSegment()); @@ -303,7 +303,7 @@ TEST_F(TsWriterTest, ClearLeadH264Pmt) { // Check the encrypted segments' PMT (after clear lead). TEST_F(TsWriterTest, EncryptedSegmentsH264Pmt) { - scoped_ptr mock_pmt_writer( + std::unique_ptr mock_pmt_writer( new MockProgramMapTableWriter()); InSequence s; EXPECT_CALL(*mock_pmt_writer, ClearSegmentPmt(_)).WillOnce(Return(true)); @@ -315,7 +315,7 @@ TEST_F(TsWriterTest, EncryptedSegmentsH264Pmt) { kTrickPlayRate, kNaluLengthSize, kLanguage, kIsEncrypted)); EXPECT_TRUE(ts_writer_.Initialize(*stream_info)); - ts_writer_.SetProgramMapTableWriterForTesting(mock_pmt_writer.Pass()); + ts_writer_.SetProgramMapTableWriterForTesting(std::move(mock_pmt_writer)); EXPECT_TRUE(ts_writer_.NewSegment(test_file_name_)); EXPECT_TRUE(ts_writer_.FinalizeSegment()); @@ -335,7 +335,7 @@ TEST_F(TsWriterTest, EncryptedSegmentsH264Pmt) { // Same as ClearLeadH264Pmt but for AAC. TEST_F(TsWriterTest, ClearLeadAacPmt) { - scoped_ptr mock_pmt_writer( + std::unique_ptr mock_pmt_writer( new MockProgramMapTableWriter()); EXPECT_CALL(*mock_pmt_writer, ClearSegmentPmt(_)) .WillOnce(WriteTwoPmts()); @@ -347,7 +347,7 @@ TEST_F(TsWriterTest, ClearLeadAacPmt) { kMaxBitrate, kAverageBitrate, kLanguage, kIsEncrypted)); EXPECT_TRUE(ts_writer_.Initialize(*stream_info)); - ts_writer_.SetProgramMapTableWriterForTesting(mock_pmt_writer.Pass()); + ts_writer_.SetProgramMapTableWriterForTesting(std::move(mock_pmt_writer)); EXPECT_TRUE(ts_writer_.NewSegment(test_file_name_)); ASSERT_TRUE(ts_writer_.FinalizeSegment()); @@ -364,7 +364,7 @@ TEST_F(TsWriterTest, ClearLeadAacPmt) { // Same as EncryptedSegmentsH264Pmt but for AAC. TEST_F(TsWriterTest, EncryptedSegmentsAacPmt) { - scoped_ptr mock_pmt_writer( + std::unique_ptr mock_pmt_writer( new MockProgramMapTableWriter()); InSequence s; EXPECT_CALL(*mock_pmt_writer, ClearSegmentPmt(_)).WillOnce(Return(true)); @@ -377,7 +377,7 @@ TEST_F(TsWriterTest, EncryptedSegmentsAacPmt) { kMaxBitrate, kAverageBitrate, kLanguage, kIsEncrypted)); EXPECT_TRUE(ts_writer_.Initialize(*stream_info)); - ts_writer_.SetProgramMapTableWriterForTesting(mock_pmt_writer.Pass()); + ts_writer_.SetProgramMapTableWriterForTesting(std::move(mock_pmt_writer)); EXPECT_TRUE(ts_writer_.NewSegment(test_file_name_)); EXPECT_TRUE(ts_writer_.FinalizeSegment()); @@ -404,7 +404,7 @@ TEST_F(TsWriterTest, AddPesPacket) { EXPECT_TRUE(ts_writer_.Initialize(*stream_info)); EXPECT_TRUE(ts_writer_.NewSegment(test_file_name_)); - scoped_ptr pes(new PesPacket()); + std::unique_ptr pes(new PesPacket()); pes->set_stream_id(0xE0); pes->set_pts(0x900); pes->set_dts(0x900); @@ -413,7 +413,7 @@ TEST_F(TsWriterTest, AddPesPacket) { }; pes->mutable_data()->assign(kAnyData, kAnyData + arraysize(kAnyData)); - EXPECT_TRUE(ts_writer_.AddPesPacket(pes.Pass())); + EXPECT_TRUE(ts_writer_.AddPesPacket(std::move(pes))); ASSERT_TRUE(ts_writer_.FinalizeSegment()); std::vector content; @@ -469,14 +469,14 @@ TEST_F(TsWriterTest, BigPesPacket) { EXPECT_TRUE(ts_writer_.Initialize(*stream_info)); EXPECT_TRUE(ts_writer_.NewSegment(test_file_name_)); - scoped_ptr pes(new PesPacket()); + std::unique_ptr pes(new PesPacket()); pes->set_pts(0); pes->set_dts(0); // A little over 2 TS Packets (3 TS Packets). const std::vector big_data(400, 0x23); *pes->mutable_data() = big_data; - EXPECT_TRUE(ts_writer_.AddPesPacket(pes.Pass())); + EXPECT_TRUE(ts_writer_.AddPesPacket(std::move(pes))); ASSERT_TRUE(ts_writer_.FinalizeSegment()); std::vector content; @@ -505,7 +505,7 @@ TEST_F(TsWriterTest, PesPtsZeroNoDts) { EXPECT_TRUE(ts_writer_.Initialize(*stream_info)); EXPECT_TRUE(ts_writer_.NewSegment(test_file_name_)); - scoped_ptr pes(new PesPacket()); + std::unique_ptr pes(new PesPacket()); pes->set_stream_id(0xE0); pes->set_pts(0x0); const uint8_t kAnyData[] = { @@ -513,7 +513,7 @@ TEST_F(TsWriterTest, PesPtsZeroNoDts) { }; pes->mutable_data()->assign(kAnyData, kAnyData + arraysize(kAnyData)); - EXPECT_TRUE(ts_writer_.AddPesPacket(pes.Pass())); + EXPECT_TRUE(ts_writer_.AddPesPacket(std::move(pes))); ASSERT_TRUE(ts_writer_.FinalizeSegment()); std::vector content; @@ -565,7 +565,7 @@ TEST_F(TsWriterTest, TsPacketPayload183Bytes) { EXPECT_TRUE(ts_writer_.Initialize(*stream_info)); EXPECT_TRUE(ts_writer_.NewSegment(test_file_name_)); - scoped_ptr pes(new PesPacket()); + std::unique_ptr pes(new PesPacket()); pes->set_stream_id(0xE0); pes->set_pts(0x00); pes->set_dts(0x00); @@ -577,7 +577,7 @@ TEST_F(TsWriterTest, TsPacketPayload183Bytes) { std::vector pes_payload(157 + 183, 0xAF); *pes->mutable_data() = pes_payload; - EXPECT_TRUE(ts_writer_.AddPesPacket(pes.Pass())); + EXPECT_TRUE(ts_writer_.AddPesPacket(std::move(pes))); ASSERT_TRUE(ts_writer_.FinalizeSegment()); const uint8_t kExpectedOutputPrefix[] = { diff --git a/packager/media/formats/mp4/box_definitions_unittest.cc b/packager/media/formats/mp4/box_definitions_unittest.cc index 2384f63641..8ee2a9114b 100644 --- a/packager/media/formats/mp4/box_definitions_unittest.cc +++ b/packager/media/formats/mp4/box_definitions_unittest.cc @@ -7,10 +7,10 @@ #include #include +#include -#include "packager/base/memory/scoped_ptr.h" -#include "packager/media/base/protection_system_specific_info.h" #include "packager/media/base/buffer_writer.h" +#include "packager/media/base/protection_system_specific_info.h" #include "packager/media/formats/mp4/box_definitions.h" #include "packager/media/formats/mp4/box_definitions_comparison.h" #include "packager/media/formats/mp4/box_reader.h" @@ -53,14 +53,14 @@ class BoxDefinitionsTestGeneral : public testing::Test { } bool ReadBack(Box* box) { - scoped_ptr reader(CreateReader()); + std::unique_ptr reader(CreateReader()); RCHECK(reader->ScanChildren() && reader->ReadChild(box)); return true; } // FourCC for VideoSampleEntry is fixed, e.g. could be avc1, or encv. bool ReadBack(VideoSampleEntry* video) { - scoped_ptr reader(CreateReader()); + std::unique_ptr reader(CreateReader()); std::vector video_entries; RCHECK(reader->ReadAllChildren(&video_entries)); RCHECK(video_entries.size() == 1); @@ -70,7 +70,7 @@ class BoxDefinitionsTestGeneral : public testing::Test { // FourCC for AudioSampleEntry is fixed, e.g. could be mp4a, or enca. bool ReadBack(AudioSampleEntry* audio) { - scoped_ptr reader(CreateReader()); + std::unique_ptr reader(CreateReader()); std::vector audio_entries; RCHECK(reader->ReadAllChildren(&audio_entries)); RCHECK(audio_entries.size() == 1); @@ -80,7 +80,7 @@ class BoxDefinitionsTestGeneral : public testing::Test { // FourCC for TextSampleEntry is fixed, e.g. could be text, or wvtt. bool ReadBack(TextSampleEntry* text) { - scoped_ptr reader(CreateReader()); + std::unique_ptr reader(CreateReader()); std::vector text_entries; RCHECK(reader->ReadAllChildren(&text_entries)); RCHECK(text_entries.size() == 1); @@ -92,7 +92,7 @@ class BoxDefinitionsTestGeneral : public testing::Test { // be preset before scanning the box. bool ReadBack(SampleDescription* stsd) { stsd->type = kSampleDescriptionTrackType; - scoped_ptr reader(CreateReader()); + std::unique_ptr reader(CreateReader()); RCHECK(reader->ScanChildren() && reader->ReadChild(stsd)); return true; } @@ -100,7 +100,7 @@ class BoxDefinitionsTestGeneral : public testing::Test { // SampleTable contains SampleDescription, which cannot parse on its own. bool ReadBack(SampleTable* stbl) { stbl->description.type = kSampleDescriptionTrackType; - scoped_ptr reader(CreateReader()); + std::unique_ptr reader(CreateReader()); RCHECK(reader->ScanChildren() && reader->ReadChild(stbl)); return true; } @@ -108,7 +108,7 @@ class BoxDefinitionsTestGeneral : public testing::Test { // MediaInformation contains SampleDescription, which cannot parse on its own. bool ReadBack(MediaInformation* minf) { minf->sample_table.description.type = kSampleDescriptionTrackType; - scoped_ptr reader(CreateReader()); + std::unique_ptr reader(CreateReader()); RCHECK(reader->ScanChildren() && reader->ReadChild(minf)); return true; } @@ -983,7 +983,7 @@ class BoxDefinitionsTestGeneral : public testing::Test { bool IsOptional(const OpusSpecific* box) {return true; } protected: - scoped_ptr buffer_; + std::unique_ptr buffer_; }; // GTEST support a maximum of 50 types in the template list, so we have to diff --git a/packager/media/formats/mp4/box_reader.cc b/packager/media/formats/mp4/box_reader.cc index 1f86c8db52..a803e84c3c 100644 --- a/packager/media/formats/mp4/box_reader.cc +++ b/packager/media/formats/mp4/box_reader.cc @@ -7,9 +7,9 @@ #include #include +#include #include "packager/base/logging.h" -#include "packager/base/memory/scoped_ptr.h" #include "packager/base/strings/stringprintf.h" #include "packager/media/formats/mp4/box.h" @@ -37,7 +37,7 @@ BoxReader::~BoxReader() { BoxReader* BoxReader::ReadBox(const uint8_t* buf, const size_t buf_size, bool* err) { - scoped_ptr reader(new BoxReader(buf, buf_size)); + std::unique_ptr reader(new BoxReader(buf, buf_size)); if (!reader->ReadHeader(err)) return NULL; @@ -70,7 +70,7 @@ bool BoxReader::ScanChildren() { scanned_ = true; while (pos() < size()) { - scoped_ptr child( + std::unique_ptr child( new BoxReader(&data()[pos()], size() - pos())); bool err; if (!child->ReadHeader(&err)) diff --git a/packager/media/formats/mp4/box_reader_unittest.cc b/packager/media/formats/mp4/box_reader_unittest.cc index d94a5a976b..5b6121a9e6 100644 --- a/packager/media/formats/mp4/box_reader_unittest.cc +++ b/packager/media/formats/mp4/box_reader_unittest.cc @@ -6,8 +6,9 @@ #include #include +#include + #include "packager/base/logging.h" -#include "packager/base/memory/scoped_ptr.h" #include "packager/media/base/rcheck.h" #include "packager/media/formats/mp4/box_buffer.h" @@ -93,7 +94,8 @@ class BoxReaderTest : public testing::Test { TEST_F(BoxReaderTest, ExpectedOperationTest) { std::vector buf = GetBuf(); bool err; - scoped_ptr reader(BoxReader::ReadBox(&buf[0], buf.size(), &err)); + std::unique_ptr reader( + BoxReader::ReadBox(&buf[0], buf.size(), &err)); EXPECT_FALSE(err); EXPECT_TRUE(reader.get()); @@ -120,7 +122,8 @@ TEST_F(BoxReaderTest, OuterTooShortTest) { bool err; // Create a soft failure by truncating the outer box. - scoped_ptr r(BoxReader::ReadBox(&buf[0], buf.size() - 2, &err)); + std::unique_ptr r( + BoxReader::ReadBox(&buf[0], buf.size() - 2, &err)); EXPECT_FALSE(err); EXPECT_FALSE(r.get()); @@ -132,7 +135,8 @@ TEST_F(BoxReaderTest, InnerTooLongTest) { // Make an inner box too big for its outer box. buf[25] = 1; - scoped_ptr reader(BoxReader::ReadBox(&buf[0], buf.size(), &err)); + std::unique_ptr reader( + BoxReader::ReadBox(&buf[0], buf.size(), &err)); SkipBox box; EXPECT_FALSE(box.Parse(reader.get())); @@ -141,7 +145,8 @@ TEST_F(BoxReaderTest, InnerTooLongTest) { TEST_F(BoxReaderTest, ScanChildrenTest) { std::vector buf = GetBuf(); bool err; - scoped_ptr reader(BoxReader::ReadBox(&buf[0], buf.size(), &err)); + std::unique_ptr reader( + BoxReader::ReadBox(&buf[0], buf.size(), &err)); EXPECT_TRUE(reader->SkipBytes(16) && reader->ScanChildren()); @@ -164,7 +169,8 @@ TEST_F(BoxReaderTest, ReadAllChildrenTest) { // Modify buffer to exclude its last 'free' box. buf[3] = 0x38; bool err; - scoped_ptr reader(BoxReader::ReadBox(&buf[0], buf.size(), &err)); + std::unique_ptr reader( + BoxReader::ReadBox(&buf[0], buf.size(), &err)); std::vector kids; EXPECT_TRUE(reader->SkipBytes(16) && reader->ReadAllChildren(&kids)); @@ -182,7 +188,8 @@ TEST_F(BoxReaderTest, SkippingBloc) { std::vector buf(kData, kData + sizeof(kData)); bool err; - scoped_ptr reader(BoxReader::ReadBox(&buf[0], buf.size(), &err)); + std::unique_ptr reader( + BoxReader::ReadBox(&buf[0], buf.size(), &err)); EXPECT_FALSE(err); EXPECT_TRUE(reader); diff --git a/packager/media/formats/mp4/chunk_info_iterator_unittest.cc b/packager/media/formats/mp4/chunk_info_iterator_unittest.cc index a33deabd5b..b089d54ee6 100644 --- a/packager/media/formats/mp4/chunk_info_iterator_unittest.cc +++ b/packager/media/formats/mp4/chunk_info_iterator_unittest.cc @@ -5,9 +5,8 @@ // https://developers.google.com/open-source/licenses/bsd #include - +#include #include "packager/base/logging.h" -#include "packager/base/memory/scoped_ptr.h" #include "packager/media/formats/mp4/chunk_info_iterator.h" namespace { @@ -50,7 +49,7 @@ class ChunkInfoIteratorTest : public testing::Test { protected: std::vector chunk_info_table_; SampleToChunk sample_to_chunk_; - scoped_ptr chunk_info_iterator_; + std::unique_ptr chunk_info_iterator_; private: DISALLOW_COPY_AND_ASSIGN(ChunkInfoIteratorTest); diff --git a/packager/media/formats/mp4/composition_offset_iterator_unittest.cc b/packager/media/formats/mp4/composition_offset_iterator_unittest.cc index abb36a88f9..3004a18703 100644 --- a/packager/media/formats/mp4/composition_offset_iterator_unittest.cc +++ b/packager/media/formats/mp4/composition_offset_iterator_unittest.cc @@ -5,8 +5,7 @@ // https://developers.google.com/open-source/licenses/bsd #include - -#include "packager/base/memory/scoped_ptr.h" +#include #include "packager/media/formats/mp4/composition_offset_iterator.h" namespace shaka { @@ -37,7 +36,7 @@ class CompositionOffsetIteratorTest : public testing::Test { protected: std::vector composition_offset_table_; CompositionTimeToSample composition_time_to_sample_; - scoped_ptr composition_offset_iterator_; + std::unique_ptr composition_offset_iterator_; private: DISALLOW_COPY_AND_ASSIGN(CompositionOffsetIteratorTest); diff --git a/packager/media/formats/mp4/decoding_time_iterator_unittest.cc b/packager/media/formats/mp4/decoding_time_iterator_unittest.cc index 996e5a03f8..c78826c600 100644 --- a/packager/media/formats/mp4/decoding_time_iterator_unittest.cc +++ b/packager/media/formats/mp4/decoding_time_iterator_unittest.cc @@ -5,8 +5,7 @@ // https://developers.google.com/open-source/licenses/bsd #include - -#include "packager/base/memory/scoped_ptr.h" +#include #include "packager/media/formats/mp4/decoding_time_iterator.h" namespace shaka { @@ -38,7 +37,7 @@ class DecodingTimeIteratorTest : public testing::Test { protected: std::vector decoding_time_table_; DecodingTimeToSample decoding_time_to_sample_; - scoped_ptr decoding_time_iterator_; + std::unique_ptr decoding_time_iterator_; private: DISALLOW_COPY_AND_ASSIGN(DecodingTimeIteratorTest); diff --git a/packager/media/formats/mp4/encrypting_fragmenter.cc b/packager/media/formats/mp4/encrypting_fragmenter.cc index f0d58ae74d..53675a9369 100644 --- a/packager/media/formats/mp4/encrypting_fragmenter.cc +++ b/packager/media/formats/mp4/encrypting_fragmenter.cc @@ -59,13 +59,17 @@ uint8_t GetNaluLengthSize(const StreamInfo& stream_info) { } // namespace EncryptingFragmenter::EncryptingFragmenter( - scoped_refptr info, TrackFragment* traf, - scoped_ptr encryption_key, int64_t clear_time, - FourCC protection_scheme, uint8_t crypt_byte_block, uint8_t skip_byte_block, + scoped_refptr info, + TrackFragment* traf, + std::unique_ptr encryption_key, + int64_t clear_time, + FourCC protection_scheme, + uint8_t crypt_byte_block, + uint8_t skip_byte_block, MuxerListener* listener) : Fragmenter(info, traf), info_(info), - encryption_key_(encryption_key.Pass()), + encryption_key_(std::move(encryption_key)), nalu_length_size_(GetNaluLengthSize(*info)), video_codec_(GetCodec(*info)), clear_time_(clear_time), @@ -203,7 +207,7 @@ void EncryptingFragmenter::FinalizeFragmentForEncryption() { Status EncryptingFragmenter::CreateEncryptor() { DCHECK(encryption_key_); - scoped_ptr encryptor; + std::unique_ptr encryptor; switch (protection_scheme_) { case FOURCC_cenc: encryptor.reset(new AesCtrEncryptor); @@ -216,14 +220,14 @@ Status EncryptingFragmenter::CreateEncryptor() { crypt_byte_block(), skip_byte_block(), AesPatternCryptor::kEncryptIfCryptByteBlockRemaining, AesCryptor::kDontUseConstantIv, - scoped_ptr(new AesCtrEncryptor()))); + std::unique_ptr(new AesCtrEncryptor()))); break; case FOURCC_cbcs: encryptor.reset(new AesPatternCryptor( crypt_byte_block(), skip_byte_block(), AesPatternCryptor::kEncryptIfCryptByteBlockRemaining, AesCryptor::kUseConstantIv, - scoped_ptr(new AesCbcEncryptor(kNoPadding)))); + std::unique_ptr(new AesCbcEncryptor(kNoPadding)))); break; default: return Status(error::MUXER_FAILURE, "Unsupported protection scheme."); @@ -234,7 +238,7 @@ Status EncryptingFragmenter::CreateEncryptor() { encryptor->InitializeWithIv(encryption_key_->key, encryption_key_->iv); if (!initialized) return Status(error::MUXER_FAILURE, "Failed to create the encryptor."); - encryptor_ = encryptor.Pass(); + encryptor_ = std::move(encryptor); return Status::OK; } diff --git a/packager/media/formats/mp4/encrypting_fragmenter.h b/packager/media/formats/mp4/encrypting_fragmenter.h index 0c93a75786..84e11bd2db 100644 --- a/packager/media/formats/mp4/encrypting_fragmenter.h +++ b/packager/media/formats/mp4/encrypting_fragmenter.h @@ -7,8 +7,8 @@ #ifndef MEDIA_FORMATS_MP4_ENCRYPTING_FRAGMENTER_H_ #define MEDIA_FORMATS_MP4_ENCRYPTING_FRAGMENTER_H_ +#include #include "packager/base/memory/ref_counted.h" -#include "packager/base/memory/scoped_ptr.h" #include "packager/media/base/fourccs.h" #include "packager/media/codecs/video_slice_header_parser.h" #include "packager/media/codecs/vpx_parser.h" @@ -40,7 +40,7 @@ class EncryptingFragmenter : public Fragmenter { /// in pattern based encryption. EncryptingFragmenter(scoped_refptr info, TrackFragment* traf, - scoped_ptr encryption_key, + std::unique_ptr encryption_key, int64_t clear_time, FourCC protection_scheme, uint8_t crypt_byte_block, @@ -74,8 +74,8 @@ class EncryptingFragmenter : public Fragmenter { uint8_t crypt_byte_block() const { return crypt_byte_block_; } uint8_t skip_byte_block() const { return skip_byte_block_; } - void set_encryption_key(scoped_ptr encryption_key) { - encryption_key_ = encryption_key.Pass(); + void set_encryption_key(std::unique_ptr encryption_key) { + encryption_key_ = std::move(encryption_key); } private: @@ -86,8 +86,8 @@ class EncryptingFragmenter : public Fragmenter { bool IsSubsampleEncryptionRequired(); scoped_refptr info_; - scoped_ptr encryption_key_; - scoped_ptr encryptor_; + std::unique_ptr encryption_key_; + std::unique_ptr encryptor_; // If this stream contains AVC, subsample encryption specifies that the size // and type of NAL units remain unencrypted. This function returns the size of // the size field in bytes. Can be 1, 2 or 4 bytes. @@ -99,8 +99,8 @@ class EncryptingFragmenter : public Fragmenter { const uint8_t skip_byte_block_; MuxerListener* listener_; - scoped_ptr vpx_parser_; - scoped_ptr header_parser_; + std::unique_ptr vpx_parser_; + std::unique_ptr header_parser_; DISALLOW_COPY_AND_ASSIGN(EncryptingFragmenter); }; diff --git a/packager/media/formats/mp4/fragmenter.h b/packager/media/formats/mp4/fragmenter.h index 5502bbbc08..b27c6aa9fe 100644 --- a/packager/media/formats/mp4/fragmenter.h +++ b/packager/media/formats/mp4/fragmenter.h @@ -7,11 +7,11 @@ #ifndef MEDIA_FORMATS_MP4_FRAGMENTER_H_ #define MEDIA_FORMATS_MP4_FRAGMENTER_H_ +#include #include #include "packager/base/logging.h" #include "packager/base/memory/ref_counted.h" -#include "packager/base/memory/scoped_ptr.h" #include "packager/media/base/status.h" namespace shaka { @@ -93,7 +93,7 @@ class Fragmenter { int64_t presentation_start_time_; int64_t earliest_presentation_time_; int64_t first_sap_time_; - scoped_ptr data_; + std::unique_ptr data_; DISALLOW_COPY_AND_ASSIGN(Fragmenter); }; diff --git a/packager/media/formats/mp4/key_rotation_fragmenter.cc b/packager/media/formats/mp4/key_rotation_fragmenter.cc index 0249a2bfbf..5a9702250a 100644 --- a/packager/media/formats/mp4/key_rotation_fragmenter.cc +++ b/packager/media/formats/mp4/key_rotation_fragmenter.cc @@ -30,7 +30,7 @@ KeyRotationFragmenter::KeyRotationFragmenter(MovieFragment* moof, MuxerListener* muxer_listener) : EncryptingFragmenter(info, traf, - scoped_ptr(new EncryptionKey()), + std::unique_ptr(new EncryptionKey()), clear_time, protection_scheme, crypt_byte_block, @@ -55,7 +55,7 @@ Status KeyRotationFragmenter::PrepareFragmentForEncryption( int64_t current_crypto_period_index = traf()->decode_time.decode_time / crypto_period_duration_; if (current_crypto_period_index != prev_crypto_period_index_) { - scoped_ptr encryption_key(new EncryptionKey()); + std::unique_ptr encryption_key(new EncryptionKey()); Status status = encryption_key_source_->GetCryptoPeriodKey( current_crypto_period_index, track_type_, encryption_key.get()); if (!status.ok()) @@ -66,7 +66,7 @@ Status KeyRotationFragmenter::PrepareFragmentForEncryption( return Status(error::INTERNAL_ERROR, "Failed to generate random iv."); } } - set_encryption_key(encryption_key.Pass()); + set_encryption_key(std::move(encryption_key)); prev_crypto_period_index_ = current_crypto_period_index; need_to_refresh_encryptor = true; } diff --git a/packager/media/formats/mp4/mp4_media_parser.cc b/packager/media/formats/mp4/mp4_media_parser.cc index b86979e876..99e5f1efbe 100644 --- a/packager/media/formats/mp4/mp4_media_parser.cc +++ b/packager/media/formats/mp4/mp4_media_parser.cc @@ -156,7 +156,7 @@ bool MP4MediaParser::Parse(const uint8_t* buf, int size) { } bool MP4MediaParser::LoadMoov(const std::string& file_path) { - scoped_ptr file( + std::unique_ptr file( File::OpenWithNoBuffering(file_path.c_str(), "r")); if (!file) { LOG(ERROR) << "Unable to open media file '" << file_path << "'"; @@ -237,7 +237,7 @@ bool MP4MediaParser::ParseBox(bool* err) { if (!size) return false; - scoped_ptr reader(BoxReader::ReadBox(buf, size, err)); + std::unique_ptr reader(BoxReader::ReadBox(buf, size, err)); if (reader.get() == NULL) return false; @@ -690,7 +690,7 @@ bool MP4MediaParser::EnqueueSample(bool* err) { return false; } - scoped_ptr decrypt_config = runs_->GetDecryptConfig(); + std::unique_ptr decrypt_config = runs_->GetDecryptConfig(); if (!decrypt_config || !decryptor_source_->DecryptSampleBuffer(decrypt_config.get(), stream_sample->writable_data(), diff --git a/packager/media/formats/mp4/mp4_media_parser.h b/packager/media/formats/mp4/mp4_media_parser.h index 46f36b6636..d68930f588 100644 --- a/packager/media/formats/mp4/mp4_media_parser.h +++ b/packager/media/formats/mp4/mp4_media_parser.h @@ -10,13 +10,11 @@ #include #include +#include #include #include "packager/base/callback_forward.h" -#include "packager/base/compiler_specific.h" -#include "packager/base/memory/scoped_ptr.h" #include "packager/base/memory/ref_counted.h" -#include "packager/base/memory/scoped_ptr.h" #include "packager/media/base/decryptor_source.h" #include "packager/media/base/media_parser.h" #include "packager/media/base/offset_byte_queue.h" @@ -87,7 +85,7 @@ class MP4MediaParser : public MediaParser { InitCB init_cb_; NewSampleCB new_sample_cb_; KeySource* decryption_key_source_; - scoped_ptr decryptor_source_; + std::unique_ptr decryptor_source_; OffsetByteQueue queue_; @@ -101,8 +99,8 @@ class MP4MediaParser : public MediaParser { // Valid iff it is greater than the head of the queue. int64_t mdat_tail_; - scoped_ptr moov_; - scoped_ptr runs_; + std::unique_ptr moov_; + std::unique_ptr runs_; DISALLOW_COPY_AND_ASSIGN(MP4MediaParser); }; diff --git a/packager/media/formats/mp4/mp4_media_parser_unittest.cc b/packager/media/formats/mp4/mp4_media_parser_unittest.cc index 552ba67d85..dcce7e9ff2 100644 --- a/packager/media/formats/mp4/mp4_media_parser_unittest.cc +++ b/packager/media/formats/mp4/mp4_media_parser_unittest.cc @@ -48,7 +48,7 @@ class MP4MediaParserTest : public testing::Test { protected: typedef std::map > StreamMap; StreamMap stream_map_; - scoped_ptr parser_; + std::unique_ptr parser_; size_t num_streams_; size_t num_samples_; diff --git a/packager/media/formats/mp4/mp4_muxer.cc b/packager/media/formats/mp4/mp4_muxer.cc index 277c10ae44..f19d4ea335 100644 --- a/packager/media/formats/mp4/mp4_muxer.cc +++ b/packager/media/formats/mp4/mp4_muxer.cc @@ -85,8 +85,8 @@ MP4Muxer::~MP4Muxer() {} Status MP4Muxer::Initialize() { DCHECK(!streams().empty()); - scoped_ptr ftyp(new FileType); - scoped_ptr moov(new Movie); + std::unique_ptr ftyp(new FileType); + std::unique_ptr moov(new Movie); ftyp->major_brand = FOURCC_dash; ftyp->compatible_brands.push_back(FOURCC_iso6); @@ -135,11 +135,11 @@ Status MP4Muxer::Initialize() { } if (options().single_segment) { - segmenter_.reset( - new SingleSegmentSegmenter(options(), ftyp.Pass(), moov.Pass())); + segmenter_.reset(new SingleSegmentSegmenter(options(), std::move(ftyp), + std::move(moov))); } else { segmenter_.reset( - new MultiSegmentSegmenter(options(), ftyp.Pass(), moov.Pass())); + new MultiSegmentSegmenter(options(), std::move(ftyp), std::move(moov))); } const Status segmenter_initialized = segmenter_->Initialize( diff --git a/packager/media/formats/mp4/mp4_muxer.h b/packager/media/formats/mp4/mp4_muxer.h index cd71d9e8d4..9ef82aad02 100644 --- a/packager/media/formats/mp4/mp4_muxer.h +++ b/packager/media/formats/mp4/mp4_muxer.h @@ -64,7 +64,7 @@ class MP4Muxer : public Muxer { // Get time in seconds since midnight, Jan. 1, 1904, in UTC Time. uint64_t IsoTimeNow(); - scoped_ptr segmenter_; + std::unique_ptr segmenter_; DISALLOW_COPY_AND_ASSIGN(MP4Muxer); }; diff --git a/packager/media/formats/mp4/multi_segment_segmenter.cc b/packager/media/formats/mp4/multi_segment_segmenter.cc index b7f146f2b6..39109a29e6 100644 --- a/packager/media/formats/mp4/multi_segment_segmenter.cc +++ b/packager/media/formats/mp4/multi_segment_segmenter.cc @@ -21,9 +21,9 @@ namespace media { namespace mp4 { MultiSegmentSegmenter::MultiSegmentSegmenter(const MuxerOptions& options, - scoped_ptr ftyp, - scoped_ptr moov) - : Segmenter(options, ftyp.Pass(), moov.Pass()), + std::unique_ptr ftyp, + std::unique_ptr moov) + : Segmenter(options, std::move(ftyp), std::move(moov)), styp_(new SegmentType), num_segments_(0) { // Use the same brands for styp as ftyp. @@ -53,7 +53,7 @@ Status MultiSegmentSegmenter::DoInitialize() { return Status(error::FILE_FAILURE, "Cannot open file for write " + options().output_file_name); } - scoped_ptr buffer(new BufferWriter); + std::unique_ptr buffer(new BufferWriter); ftyp()->Write(buffer.get()); moov()->Write(buffer.get()); Status status = buffer->WriteToFile(file); @@ -135,7 +135,7 @@ Status MultiSegmentSegmenter::WriteSegment() { DCHECK(fragment_buffer()); DCHECK(styp_); - scoped_ptr buffer(new BufferWriter()); + std::unique_ptr buffer(new BufferWriter()); File* file; std::string file_name; if (options().segment_template.empty()) { diff --git a/packager/media/formats/mp4/multi_segment_segmenter.h b/packager/media/formats/mp4/multi_segment_segmenter.h index 802629350d..f65cf7b1cd 100644 --- a/packager/media/formats/mp4/multi_segment_segmenter.h +++ b/packager/media/formats/mp4/multi_segment_segmenter.h @@ -31,8 +31,8 @@ struct SegmentType; class MultiSegmentSegmenter : public Segmenter { public: MultiSegmentSegmenter(const MuxerOptions& options, - scoped_ptr ftyp, - scoped_ptr moov); + std::unique_ptr ftyp, + std::unique_ptr moov); ~MultiSegmentSegmenter() override; /// @name Segmenter implementation overrides. @@ -50,7 +50,7 @@ class MultiSegmentSegmenter : public Segmenter { // Write segment to file. Status WriteSegment(); - scoped_ptr styp_; + std::unique_ptr styp_; uint32_t num_segments_; DISALLOW_COPY_AND_ASSIGN(MultiSegmentSegmenter); diff --git a/packager/media/formats/mp4/segmenter.cc b/packager/media/formats/mp4/segmenter.cc index ec8cff6506..a5214f983e 100644 --- a/packager/media/formats/mp4/segmenter.cc +++ b/packager/media/formats/mp4/segmenter.cc @@ -147,11 +147,11 @@ void GenerateEncryptedSampleEntry(const EncryptionKey& encryption_key, } // namespace Segmenter::Segmenter(const MuxerOptions& options, - scoped_ptr ftyp, - scoped_ptr moov) + std::unique_ptr ftyp, + std::unique_ptr moov) : options_(options), - ftyp_(ftyp.Pass()), - moov_(moov.Pass()), + ftyp_(std::move(ftyp)), + moov_(std::move(moov)), moof_(new MovieFragment()), fragment_buffer_(new BufferWriter()), sidx_(new SegmentIndex()), @@ -230,7 +230,7 @@ Status Segmenter::Initialize(const std::vector& streams, continue; } - scoped_ptr encryption_key(new EncryptionKey()); + std::unique_ptr encryption_key(new EncryptionKey()); Status status = encryption_key_source->GetKey(track_type, encryption_key.get()); if (!status.ok()) @@ -259,7 +259,7 @@ Status Segmenter::Initialize(const std::vector& streams, } fragmenters_[i] = new EncryptingFragmenter( - streams[i]->info(), &moof_->tracks[i], encryption_key.Pass(), + streams[i]->info(), &moof_->tracks[i], std::move(encryption_key), clear_lead_in_seconds * streams[i]->info()->time_scale(), protection_scheme, pattern.crypt_byte_block, pattern.skip_byte_block, muxer_listener_); diff --git a/packager/media/formats/mp4/segmenter.h b/packager/media/formats/mp4/segmenter.h index 21471af289..0b77bd41a1 100644 --- a/packager/media/formats/mp4/segmenter.h +++ b/packager/media/formats/mp4/segmenter.h @@ -8,10 +8,10 @@ #define MEDIA_FORMATS_MP4_SEGMENTER_H_ #include +#include #include #include "packager/base/memory/ref_counted.h" -#include "packager/base/memory/scoped_ptr.h" #include "packager/media/base/fourccs.h" #include "packager/media/base/status.h" #include "packager/media/formats/mp4/box_definitions.h" @@ -41,8 +41,8 @@ class Fragmenter; class Segmenter { public: Segmenter(const MuxerOptions& options, - scoped_ptr ftyp, - scoped_ptr moov); + std::unique_ptr ftyp, + std::unique_ptr moov); virtual ~Segmenter(); /// Initialize the segmenter. @@ -129,11 +129,11 @@ class Segmenter { Status FinalizeFragment(bool finalize_segment, Fragmenter* fragment); const MuxerOptions& options_; - scoped_ptr ftyp_; - scoped_ptr moov_; - scoped_ptr moof_; - scoped_ptr fragment_buffer_; - scoped_ptr sidx_; + std::unique_ptr ftyp_; + std::unique_ptr moov_; + std::unique_ptr moof_; + std::unique_ptr fragment_buffer_; + std::unique_ptr sidx_; std::vector fragmenters_; std::vector segment_durations_; std::map stream_map_; diff --git a/packager/media/formats/mp4/single_segment_segmenter.cc b/packager/media/formats/mp4/single_segment_segmenter.cc index 25b8dd7ae7..b8f4466a9e 100644 --- a/packager/media/formats/mp4/single_segment_segmenter.cc +++ b/packager/media/formats/mp4/single_segment_segmenter.cc @@ -40,9 +40,9 @@ std::string TempFileName() { } // namespace SingleSegmentSegmenter::SingleSegmentSegmenter(const MuxerOptions& options, - scoped_ptr ftyp, - scoped_ptr moov) - : Segmenter(options, ftyp.Pass(), moov.Pass()) {} + std::unique_ptr ftyp, + std::unique_ptr moov) + : Segmenter(options, std::move(ftyp), std::move(moov)) {} SingleSegmentSegmenter::~SingleSegmentSegmenter() { if (temp_file_) @@ -108,7 +108,7 @@ Status SingleSegmentSegmenter::DoFinalize() { "Cannot close the temp file " + temp_file_name_); } - scoped_ptr file( + std::unique_ptr file( File::Open(options().output_file_name.c_str(), "w")); if (file == NULL) { return Status(error::FILE_FAILURE, @@ -119,7 +119,7 @@ Status SingleSegmentSegmenter::DoFinalize() { << options().output_file_name << "'."; // Write ftyp, moov and sidx to output file. - scoped_ptr buffer(new BufferWriter()); + std::unique_ptr buffer(new BufferWriter()); ftyp()->Write(buffer.get()); moov()->Write(buffer.get()); vod_sidx_->Write(buffer.get()); @@ -128,7 +128,7 @@ Status SingleSegmentSegmenter::DoFinalize() { return status; // Load the temp file and write to output file. - scoped_ptr temp_file( + std::unique_ptr temp_file( File::Open(temp_file_name_.c_str(), "r")); if (temp_file == NULL) { return Status(error::FILE_FAILURE, @@ -139,7 +139,7 @@ Status SingleSegmentSegmenter::DoFinalize() { const uint64_t re_segment_progress_target = progress_target() * 0.5; const int kBufSize = 0x200000; // 2MB. - scoped_ptr buf(new uint8_t[kBufSize]); + std::unique_ptr buf(new uint8_t[kBufSize]); while (true) { int64_t size = temp_file->Read(buf.get(), kBufSize); if (size == 0) { diff --git a/packager/media/formats/mp4/single_segment_segmenter.h b/packager/media/formats/mp4/single_segment_segmenter.h index 301bd1cf58..a56892d1f9 100644 --- a/packager/media/formats/mp4/single_segment_segmenter.h +++ b/packager/media/formats/mp4/single_segment_segmenter.h @@ -28,8 +28,8 @@ namespace mp4 { class SingleSegmentSegmenter : public Segmenter { public: SingleSegmentSegmenter(const MuxerOptions& options, - scoped_ptr ftyp, - scoped_ptr moov); + std::unique_ptr ftyp, + std::unique_ptr moov); ~SingleSegmentSegmenter() override; /// @name Segmenter implementation overrides. @@ -44,9 +44,9 @@ class SingleSegmentSegmenter : public Segmenter { Status DoFinalize() override; Status DoFinalizeSegment() override; - scoped_ptr vod_sidx_; + std::unique_ptr vod_sidx_; std::string temp_file_name_; - scoped_ptr temp_file_; + std::unique_ptr temp_file_; DISALLOW_COPY_AND_ASSIGN(SingleSegmentSegmenter); }; diff --git a/packager/media/formats/mp4/track_run_iterator.cc b/packager/media/formats/mp4/track_run_iterator.cc index e745fba0d0..87551d7084 100644 --- a/packager/media/formats/mp4/track_run_iterator.cc +++ b/packager/media/formats/mp4/track_run_iterator.cc @@ -588,7 +588,7 @@ const TrackEncryption& TrackRunIterator::track_encryption() const { return video_description().sinf.info.track_encryption; } -scoped_ptr TrackRunIterator::GetDecryptConfig() { +std::unique_ptr TrackRunIterator::GetDecryptConfig() { size_t sample_idx = sample_itr_ - run_itr_->samples.begin(); DCHECK_LT(sample_idx, run_itr_->sample_encryption_entries.size()); const SampleEncryptionEntry& sample_encryption_entry = @@ -601,7 +601,7 @@ scoped_ptr TrackRunIterator::GetDecryptConfig() { if (total_size_of_subsamples != 0 && total_size_of_subsamples != static_cast(sample_size())) { LOG(ERROR) << "Incorrect CENC subsample size."; - return scoped_ptr(); + return std::unique_ptr(); } FourCC protection_scheme = is_audio() ? audio_description().sinf.type.type @@ -615,10 +615,10 @@ scoped_ptr TrackRunIterator::GetDecryptConfig() { iv = track_encryption().default_constant_iv; if (iv.empty()) { LOG(ERROR) << "IV cannot be empty."; - return scoped_ptr(); + return std::unique_ptr(); } } - return scoped_ptr(new DecryptConfig( + return std::unique_ptr(new DecryptConfig( track_encryption().default_kid, iv, sample_encryption_entry.subsamples, protection_scheme, track_encryption().default_crypt_byte_block, track_encryption().default_skip_byte_block)); diff --git a/packager/media/formats/mp4/track_run_iterator.h b/packager/media/formats/mp4/track_run_iterator.h index 81d1fadd73..892c254f3a 100644 --- a/packager/media/formats/mp4/track_run_iterator.h +++ b/packager/media/formats/mp4/track_run_iterator.h @@ -5,9 +5,9 @@ #ifndef MEDIA_FORMATS_MP4_TRACK_RUN_ITERATOR_H_ #define MEDIA_FORMATS_MP4_TRACK_RUN_ITERATOR_H_ +#include #include -#include "packager/base/memory/scoped_ptr.h" #include "packager/media/formats/mp4/box_definitions.h" namespace shaka { @@ -98,7 +98,7 @@ class TrackRunIterator { /// Only call when is_encrypted() is true and AuxInfoNeedsToBeCached() is /// false. Result is owned by caller. - scoped_ptr GetDecryptConfig(); + std::unique_ptr GetDecryptConfig(); private: void ResetRun(); diff --git a/packager/media/formats/mp4/track_run_iterator_unittest.cc b/packager/media/formats/mp4/track_run_iterator_unittest.cc index 75acee32c1..41168b3f5f 100644 --- a/packager/media/formats/mp4/track_run_iterator_unittest.cc +++ b/packager/media/formats/mp4/track_run_iterator_unittest.cc @@ -4,9 +4,8 @@ #include #include - +#include #include "packager/base/logging.h" -#include "packager/base/memory/scoped_ptr.h" #include "packager/media/formats/mp4/box_definitions.h" #include "packager/media/formats/mp4/track_run_iterator.h" @@ -104,7 +103,7 @@ class TrackRunIteratorTest : public testing::Test { protected: Movie moov_; - scoped_ptr iter_; + std::unique_ptr iter_; void CreateMovie() { moov_.header.timescale = 1000; @@ -456,7 +455,7 @@ TEST_F(TrackRunIteratorTest, EXPECT_EQ(iter_->aux_info_size(), 0); EXPECT_EQ(iter_->sample_offset(), 200); EXPECT_EQ(iter_->GetMaxClearOffset(), moof.tracks[1].runs[0].data_offset); - scoped_ptr config = iter_->GetDecryptConfig(); + std::unique_ptr config = iter_->GetDecryptConfig(); EXPECT_EQ(std::vector(kKeyId, kKeyId + arraysize(kKeyId)), config->key_id()); EXPECT_EQ(std::vector(kIv1, kIv1 + arraysize(kIv1)), config->iv()); @@ -494,7 +493,7 @@ TEST_F(TrackRunIteratorTest, EXPECT_EQ(iter_->aux_info_size(), 0); EXPECT_EQ(iter_->sample_offset(), 200); EXPECT_EQ(iter_->GetMaxClearOffset(), moof.tracks[1].runs[0].data_offset); - scoped_ptr config = iter_->GetDecryptConfig(); + std::unique_ptr config = iter_->GetDecryptConfig(); EXPECT_EQ(std::vector(kKeyId, kKeyId + arraysize(kKeyId)), config->key_id()); EXPECT_EQ(std::vector(kIv1, kIv1 + arraysize(kIv1)), config->iv()); @@ -523,7 +522,7 @@ TEST_F(TrackRunIteratorTest, EXPECT_TRUE(iter_->is_encrypted()); EXPECT_EQ(iter_->sample_offset(), 200); EXPECT_EQ(iter_->GetMaxClearOffset(), moof.tracks[1].runs[0].data_offset); - scoped_ptr config = iter_->GetDecryptConfig(); + std::unique_ptr config = iter_->GetDecryptConfig(); EXPECT_EQ(FOURCC_cbcs, config->protection_scheme()); EXPECT_EQ(kDefaultCryptByteBlock, config->crypt_byte_block()); EXPECT_EQ(kDefaultSkipByteBlock, config->skip_byte_block()); @@ -565,7 +564,7 @@ TEST_F(TrackRunIteratorTest, EXPECT_TRUE(iter_->is_encrypted()); EXPECT_EQ(iter_->sample_offset(), 200); EXPECT_EQ(iter_->GetMaxClearOffset(), moof.tracks[1].runs[0].data_offset); - scoped_ptr config = iter_->GetDecryptConfig(); + std::unique_ptr config = iter_->GetDecryptConfig(); EXPECT_EQ(FOURCC_cbcs, config->protection_scheme()); EXPECT_EQ(std::vector(kKeyId, kKeyId + arraysize(kKeyId)), config->key_id()); @@ -605,7 +604,7 @@ TEST_F(TrackRunIteratorTest, DecryptConfigTestWithAuxInfo) { EXPECT_FALSE(iter_->AuxInfoNeedsToBeCached()); EXPECT_EQ(iter_->sample_offset(), 200); EXPECT_EQ(iter_->GetMaxClearOffset(), moof.tracks[0].runs[0].data_offset); - scoped_ptr config = iter_->GetDecryptConfig(); + std::unique_ptr config = iter_->GetDecryptConfig(); EXPECT_EQ(std::vector(kKeyId, kKeyId + arraysize(kKeyId)), config->key_id()); EXPECT_EQ(std::vector(kIv1, kIv1 + arraysize(kIv1)), config->iv()); @@ -633,7 +632,7 @@ TEST_F(TrackRunIteratorTest, SharedAuxInfoTest) { EXPECT_EQ(iter_->track_id(), 1u); EXPECT_EQ(iter_->aux_info_offset(), 50); EXPECT_TRUE(iter_->CacheAuxInfo(kAuxInfo, arraysize(kAuxInfo))); - scoped_ptr config = iter_->GetDecryptConfig(); + std::unique_ptr config = iter_->GetDecryptConfig(); ASSERT_EQ(arraysize(kIv1), config->iv().size()); EXPECT_TRUE(!memcmp(kIv1, config->iv().data(), config->iv().size())); iter_->AdvanceSample(); diff --git a/packager/media/formats/webm/cluster_builder.cc b/packager/media/formats/webm/cluster_builder.cc index 17a7ae6af6..939a92db71 100644 --- a/packager/media/formats/webm/cluster_builder.cc +++ b/packager/media/formats/webm/cluster_builder.cc @@ -59,8 +59,8 @@ enum { kInitialBufferSize = 32768, }; -Cluster::Cluster(scoped_ptr data, int size) - : data_(data.Pass()), size_(size) {} +Cluster::Cluster(std::unique_ptr data, int size) + : data_(std::move(data)), size_(size) {} Cluster::~Cluster() {} ClusterBuilder::ClusterBuilder() { Reset(); } @@ -200,24 +200,24 @@ void ClusterBuilder::WriteBlock(uint8_t* buf, memcpy(buf + 4, data, size); } -scoped_ptr ClusterBuilder::Finish() { +std::unique_ptr ClusterBuilder::Finish() { DCHECK_NE(cluster_timecode_, -1); UpdateUInt64(kClusterSizeOffset, bytes_used_ - (kClusterSizeOffset + 8)); - scoped_ptr ret(new Cluster(buffer_.Pass(), bytes_used_)); + std::unique_ptr ret(new Cluster(std::move(buffer_), bytes_used_)); Reset(); - return ret.Pass(); + return ret; } -scoped_ptr ClusterBuilder::FinishWithUnknownSize() { +std::unique_ptr ClusterBuilder::FinishWithUnknownSize() { DCHECK_NE(cluster_timecode_, -1); UpdateUInt64(kClusterSizeOffset, kWebMUnknownSize); - scoped_ptr ret(new Cluster(buffer_.Pass(), bytes_used_)); + std::unique_ptr ret(new Cluster(std::move(buffer_), bytes_used_)); Reset(); - return ret.Pass(); + return ret; } void ClusterBuilder::Reset() { @@ -234,7 +234,7 @@ void ClusterBuilder::ExtendBuffer(int bytes_needed) { while ((new_buffer_size - bytes_used_) < bytes_needed) new_buffer_size *= 2; - scoped_ptr new_buffer(new uint8_t[new_buffer_size]); + std::unique_ptr new_buffer(new uint8_t[new_buffer_size]); memcpy(new_buffer.get(), buffer_.get(), bytes_used_); buffer_.reset(new_buffer.release()); diff --git a/packager/media/formats/webm/cluster_builder.h b/packager/media/formats/webm/cluster_builder.h index f21ce6ce21..2491bb2828 100644 --- a/packager/media/formats/webm/cluster_builder.h +++ b/packager/media/formats/webm/cluster_builder.h @@ -6,21 +6,23 @@ #define MEDIA_FORMATS_WEBM_CLUSTER_BUILDER_H_ #include -#include "packager/base/memory/scoped_ptr.h" +#include + +#include "packager/base/macros.h" namespace shaka { namespace media { class Cluster { public: - Cluster(scoped_ptr data, int size); + Cluster(std::unique_ptr data, int size); ~Cluster(); const uint8_t* data() const { return data_.get(); } int size() const { return size_; } private: - scoped_ptr data_; + std::unique_ptr data_; int size_; DISALLOW_IMPLICIT_CONSTRUCTORS(Cluster); @@ -51,8 +53,8 @@ class ClusterBuilder { const uint8_t* data, int size); - scoped_ptr Finish(); - scoped_ptr FinishWithUnknownSize(); + std::unique_ptr Finish(); + std::unique_ptr FinishWithUnknownSize(); private: void AddBlockGroupInternal(int track_num, @@ -73,7 +75,7 @@ class ClusterBuilder { const uint8_t* data, int size); - scoped_ptr buffer_; + std::unique_ptr buffer_; int buffer_size_; int bytes_used_; int64_t cluster_timecode_; diff --git a/packager/media/formats/webm/encrypted_segmenter_unittest.cc b/packager/media/formats/webm/encrypted_segmenter_unittest.cc index dd15efbc08..cb02d9cad9 100644 --- a/packager/media/formats/webm/encrypted_segmenter_unittest.cc +++ b/packager/media/formats/webm/encrypted_segmenter_unittest.cc @@ -6,8 +6,7 @@ #include "packager/media/formats/webm/two_pass_single_segment_segmenter.h" #include - -#include "packager/base/memory/scoped_ptr.h" +#include #include "packager/media/base/fixed_key_source.h" #include "packager/media/formats/webm/segmenter_test_base.h" @@ -208,8 +207,8 @@ class EncrypedSegmenterTest : public SegmentTestBase { } scoped_refptr info_; - scoped_ptr segmenter_; - scoped_ptr key_source_; + std::unique_ptr segmenter_; + std::unique_ptr key_source_; }; TEST_F(EncrypedSegmenterTest, BasicSupport) { diff --git a/packager/media/formats/webm/encryptor.cc b/packager/media/formats/webm/encryptor.cc index 9808cbc19c..ffc5dfbb69 100644 --- a/packager/media/formats/webm/encryptor.cc +++ b/packager/media/formats/webm/encryptor.cc @@ -174,7 +174,7 @@ Status Encryptor::CreateEncryptor(MuxerListener* muxer_listener, Codec codec, KeySource* key_source, bool webm_subsample_encryption) { - scoped_ptr encryption_key(new EncryptionKey()); + std::unique_ptr encryption_key(new EncryptionKey()); Status status = key_source->GetKey(track_type, encryption_key.get()); if (!status.ok()) return status; @@ -183,7 +183,7 @@ Status Encryptor::CreateEncryptor(MuxerListener* muxer_listener, return Status(error::INTERNAL_ERROR, "Failed to generate random iv."); } DCHECK_EQ(kWebMIvSize, encryption_key->iv.size()); - scoped_ptr encryptor(new AesCtrEncryptor()); + std::unique_ptr encryptor(new AesCtrEncryptor()); const bool initialized = encryptor->InitializeWithIv(encryption_key->key, encryption_key->iv); if (!initialized) @@ -201,8 +201,8 @@ Status Encryptor::CreateEncryptor(MuxerListener* muxer_listener, encryptor->iv(), encryption_key->key_system_info); } - key_ = encryption_key.Pass(); - encryptor_ = encryptor.Pass(); + key_ = std::move(encryption_key); + encryptor_ = std::move(encryptor); return Status::OK; } diff --git a/packager/media/formats/webm/encryptor.h b/packager/media/formats/webm/encryptor.h index 0cdfe7fb0e..29511cdd75 100644 --- a/packager/media/formats/webm/encryptor.h +++ b/packager/media/formats/webm/encryptor.h @@ -7,8 +7,9 @@ #ifndef MEDIA_FORMATS_WEBM_ENCRYPTOR_H_ #define MEDIA_FORMATS_WEBM_ENCRYPTOR_H_ +#include +#include "packager/base/macros.h" #include "packager/base/memory/ref_counted.h" -#include "packager/base/memory/scoped_ptr.h" #include "packager/media/base/key_source.h" #include "packager/media/base/status.h" #include "packager/media/base/stream_info.h" @@ -59,9 +60,11 @@ class Encryptor { bool webm_subsample_encryption); private: - scoped_ptr key_; - scoped_ptr encryptor_; - scoped_ptr vpx_parser_; + std::unique_ptr key_; + std::unique_ptr encryptor_; + std::unique_ptr vpx_parser_; + + DISALLOW_COPY_AND_ASSIGN(Encryptor); }; } // namespace webm diff --git a/packager/media/formats/webm/mkv_writer.h b/packager/media/formats/webm/mkv_writer.h index 1b1a9cb9e6..2edae29e1c 100644 --- a/packager/media/formats/webm/mkv_writer.h +++ b/packager/media/formats/webm/mkv_writer.h @@ -7,9 +7,9 @@ #ifndef MEDIA_FORMATS_WEBM_MKV_WRITER_H_ #define MEDIA_FORMATS_WEBM_MKV_WRITER_H_ +#include #include -#include "packager/base/memory/scoped_ptr.h" #include "packager/media/base/status.h" #include "packager/media/file/file_closer.h" #include "packager/third_party/libwebm/src/mkvmuxer.hpp" @@ -61,7 +61,7 @@ class MkvWriter : public mkvmuxer::IMkvWriter { File* file() { return file_.get(); } private: - scoped_ptr file_; + std::unique_ptr file_; // Keep track of the position and whether we can seek. mkvmuxer::int64 position_; bool seekable_; diff --git a/packager/media/formats/webm/multi_segment_segmenter.cc b/packager/media/formats/webm/multi_segment_segmenter.cc index d36e01b523..1efd3a3415 100644 --- a/packager/media/formats/webm/multi_segment_segmenter.cc +++ b/packager/media/formats/webm/multi_segment_segmenter.cc @@ -31,8 +31,8 @@ bool MultiSegmentSegmenter::GetIndexRangeStartAndEnd(uint64_t* start, return false; } -Status MultiSegmentSegmenter::DoInitialize(scoped_ptr writer) { - writer_ = writer.Pass(); +Status MultiSegmentSegmenter::DoInitialize(std::unique_ptr writer) { + writer_ = std::move(writer); return WriteSegmentHeader(0, writer_.get()); } diff --git a/packager/media/formats/webm/multi_segment_segmenter.h b/packager/media/formats/webm/multi_segment_segmenter.h index 7646ff1487..99da7b1f90 100644 --- a/packager/media/formats/webm/multi_segment_segmenter.h +++ b/packager/media/formats/webm/multi_segment_segmenter.h @@ -7,11 +7,10 @@ #ifndef MEDIA_FORMATS_WEBM_MULTI_SEGMENT_SEGMENTER_H_ #define MEDIA_FORMATS_WEBM_MULTI_SEGMENT_SEGMENTER_H_ -#include "packager/media/formats/webm/segmenter.h" - -#include "packager/base/memory/scoped_ptr.h" +#include #include "packager/media/base/status.h" #include "packager/media/formats/webm/mkv_writer.h" +#include "packager/media/formats/webm/segmenter.h" namespace shaka { namespace media { @@ -35,7 +34,7 @@ class MultiSegmentSegmenter : public Segmenter { protected: // Segmenter implementation overrides. - Status DoInitialize(scoped_ptr writer) override; + Status DoInitialize(std::unique_ptr writer) override; Status DoFinalize() override; private: @@ -45,7 +44,7 @@ class MultiSegmentSegmenter : public Segmenter { Status FinalizeSegment(); - scoped_ptr writer_; + std::unique_ptr writer_; uint32_t num_segment_; DISALLOW_COPY_AND_ASSIGN(MultiSegmentSegmenter); diff --git a/packager/media/formats/webm/multi_segment_segmenter_unittest.cc b/packager/media/formats/webm/multi_segment_segmenter_unittest.cc index 492955cacd..fe08e1a410 100644 --- a/packager/media/formats/webm/multi_segment_segmenter_unittest.cc +++ b/packager/media/formats/webm/multi_segment_segmenter_unittest.cc @@ -5,8 +5,7 @@ #include "packager/media/formats/webm/multi_segment_segmenter.h" #include - -#include "packager/base/memory/scoped_ptr.h" +#include #include "packager/media/formats/webm/segmenter_test_base.h" namespace shaka { @@ -119,7 +118,7 @@ class MultiSegmentSegmenterTest : public SegmentTestBase { } scoped_refptr info_; - scoped_ptr segmenter_; + std::unique_ptr segmenter_; }; TEST_F(MultiSegmentSegmenterTest, BasicSupport) { diff --git a/packager/media/formats/webm/segmenter.cc b/packager/media/formats/webm/segmenter.cc index 0d590850b8..044418dcd0 100644 --- a/packager/media/formats/webm/segmenter.cc +++ b/packager/media/formats/webm/segmenter.cc @@ -46,7 +46,7 @@ Segmenter::Segmenter(const MuxerOptions& options) Segmenter::~Segmenter() {} -Status Segmenter::Initialize(scoped_ptr writer, +Status Segmenter::Initialize(std::unique_ptr writer, StreamInfo* info, ProgressListener* progress_listener, MuxerListener* muxer_listener, @@ -101,7 +101,7 @@ Status Segmenter::Initialize(scoped_ptr writer, if (!status.ok()) return status; - return DoInitialize(writer.Pass()); + return DoInitialize(std::move(writer)); } Status Segmenter::Finalize() { diff --git a/packager/media/formats/webm/segmenter.h b/packager/media/formats/webm/segmenter.h index f1f10911cd..2bf03a11ac 100644 --- a/packager/media/formats/webm/segmenter.h +++ b/packager/media/formats/webm/segmenter.h @@ -7,8 +7,8 @@ #ifndef MEDIA_FORMATS_WEBM_SEGMENTER_H_ #define MEDIA_FORMATS_WEBM_SEGMENTER_H_ +#include #include "packager/base/memory/ref_counted.h" -#include "packager/base/memory/scoped_ptr.h" #include "packager/media/base/status.h" #include "packager/media/formats/webm/encryptor.h" #include "packager/media/formats/webm/mkv_writer.h" @@ -50,7 +50,7 @@ class Segmenter { /// pixels per frame than max_sd_pixels, it is HD, SD otherwise. /// @param clear_time specifies clear lead duration in seconds. /// @return OK on success, an error status otherwise. - Status Initialize(scoped_ptr writer, + Status Initialize(std::unique_ptr writer, StreamInfo* info, ProgressListener* progress_listener, MuxerListener* muxer_listener, @@ -106,7 +106,7 @@ class Segmenter { uint64_t segment_payload_pos() const { return segment_payload_pos_; } double cluster_length_sec() const { return cluster_length_sec_; } - virtual Status DoInitialize(scoped_ptr writer) = 0; + virtual Status DoInitialize(std::unique_ptr writer) = 0; virtual Status DoFinalize() = 0; private: @@ -133,10 +133,10 @@ class Segmenter { uint64_t reference_frame_timestamp_; const MuxerOptions& options_; - scoped_ptr encryptor_; + std::unique_ptr encryptor_; double clear_lead_; - scoped_ptr cluster_; + std::unique_ptr cluster_; mkvmuxer::Cues cues_; SeekHead seek_head_; mkvmuxer::SegmentInfo segment_info_; diff --git a/packager/media/formats/webm/segmenter_test_base.h b/packager/media/formats/webm/segmenter_test_base.h index 45717f5de7..4f3168092b 100644 --- a/packager/media/formats/webm/segmenter_test_base.h +++ b/packager/media/formats/webm/segmenter_test_base.h @@ -11,10 +11,10 @@ #include "packager/media/base/media_sample.h" #include "packager/media/base/muxer_options.h" -#include "packager/media/base/video_stream_info.h" #include "packager/media/base/status.h" #include "packager/media/base/stream_info.h" #include "packager/media/base/test/status_test_util.h" +#include "packager/media/base/video_stream_info.h" #include "packager/media/file/file_closer.h" #include "packager/media/file/file_test_util.h" #include "packager/media/file/memory_file.h" @@ -44,19 +44,20 @@ class SegmentTestBase : public ::testing::Test { /// Creates a Segmenter of the given type and initializes it. template - void CreateAndInitializeSegmenter(const MuxerOptions& options, - StreamInfo* info, - KeySource* key_source, - scoped_ptr* result) const { - scoped_ptr segmenter(new S(options)); + void CreateAndInitializeSegmenter( + const MuxerOptions& options, + StreamInfo* info, + KeySource* key_source, + std::unique_ptr* result) const { + std::unique_ptr segmenter(new S(options)); - scoped_ptr writer(new MkvWriter()); + std::unique_ptr writer(new MkvWriter()); ASSERT_OK(writer->Open(options.output_file_name)); ASSERT_OK(segmenter->Initialize( - writer.Pass(), info, NULL /* progress_listener */, + std::move(writer), info, NULL /* progress_listener */, NULL /* muxer_listener */, key_source, 0 /* max_sd_pixels */, 1 /* clear_lead_in_seconds */)); - *result = segmenter.Pass(); + *result = std::move(segmenter); } /// Creates a new media sample. diff --git a/packager/media/formats/webm/single_segment_segmenter.cc b/packager/media/formats/webm/single_segment_segmenter.cc index 285b4d9036..81688b1bbc 100644 --- a/packager/media/formats/webm/single_segment_segmenter.cc +++ b/packager/media/formats/webm/single_segment_segmenter.cc @@ -18,8 +18,8 @@ SingleSegmentSegmenter::SingleSegmentSegmenter(const MuxerOptions& options) SingleSegmentSegmenter::~SingleSegmentSegmenter() {} -Status SingleSegmentSegmenter::DoInitialize(scoped_ptr writer) { - writer_ = writer.Pass(); +Status SingleSegmentSegmenter::DoInitialize(std::unique_ptr writer) { + writer_ = std::move(writer); Status ret = WriteSegmentHeader(0, writer_.get()); init_end_ = writer_->Position() - 1; seek_head()->set_cluster_pos(init_end_ + 1 - segment_payload_pos()); diff --git a/packager/media/formats/webm/single_segment_segmenter.h b/packager/media/formats/webm/single_segment_segmenter.h index e363272236..1044a810d5 100644 --- a/packager/media/formats/webm/single_segment_segmenter.h +++ b/packager/media/formats/webm/single_segment_segmenter.h @@ -9,7 +9,7 @@ #include "packager/media/formats/webm/segmenter.h" -#include "packager/base/memory/scoped_ptr.h" +#include #include "packager/media/base/status.h" #include "packager/media/formats/webm/mkv_writer.h" @@ -39,10 +39,12 @@ class SingleSegmentSegmenter : public Segmenter { void set_init_end(uint64_t end) { init_end_ = end; } void set_index_start(uint64_t start) { index_start_ = start; } void set_index_end(uint64_t end) { index_end_ = end; } - void set_writer(scoped_ptr writer) { writer_ = writer.Pass(); } + void set_writer(std::unique_ptr writer) { + writer_ = std::move(writer); + } // Segmenter implementation overrides. - Status DoInitialize(scoped_ptr writer) override; + Status DoInitialize(std::unique_ptr writer) override; Status DoFinalize() override; private: @@ -50,7 +52,7 @@ class SingleSegmentSegmenter : public Segmenter { Status NewSubsegment(uint64_t start_timescale) override; Status NewSegment(uint64_t start_timescale) override; - scoped_ptr writer_; + std::unique_ptr writer_; uint64_t init_end_; uint64_t index_start_; uint64_t index_end_; diff --git a/packager/media/formats/webm/single_segment_segmenter_unittest.cc b/packager/media/formats/webm/single_segment_segmenter_unittest.cc index 098e6717d8..c30c1a9285 100644 --- a/packager/media/formats/webm/single_segment_segmenter_unittest.cc +++ b/packager/media/formats/webm/single_segment_segmenter_unittest.cc @@ -6,8 +6,7 @@ #include "packager/media/formats/webm/two_pass_single_segment_segmenter.h" #include - -#include "packager/base/memory/scoped_ptr.h" +#include #include "packager/media/formats/webm/segmenter_test_base.h" namespace shaka { @@ -171,7 +170,7 @@ class SingleSegmentSegmenterTest : public SegmentTestBase, } scoped_refptr info_; - scoped_ptr segmenter_; + std::unique_ptr segmenter_; }; TEST_P(SingleSegmentSegmenterTest, BasicSupport) { diff --git a/packager/media/formats/webm/two_pass_single_segment_segmenter.cc b/packager/media/formats/webm/two_pass_single_segment_segmenter.cc index 1b77bbf075..a8166c4248 100644 --- a/packager/media/formats/webm/two_pass_single_segment_segmenter.cc +++ b/packager/media/formats/webm/two_pass_single_segment_segmenter.cc @@ -48,7 +48,7 @@ std::string TempFileName(const MuxerOptions& options) { // forward-seeking in non-seekable files. bool ReadSkip(File* file, int64_t byte_count) { const int64_t kBufferSize = 0x40000; // 256KB. - scoped_ptr buffer(new char[kBufferSize]); + std::unique_ptr buffer(new char[kBufferSize]); int64_t bytes_read = 0; while (bytes_read < byte_count) { int64_t size = std::min(kBufferSize, byte_count - bytes_read); @@ -72,21 +72,21 @@ TwoPassSingleSegmentSegmenter::TwoPassSingleSegmentSegmenter( TwoPassSingleSegmentSegmenter::~TwoPassSingleSegmentSegmenter() {} -Status -TwoPassSingleSegmentSegmenter::DoInitialize(scoped_ptr writer) { +Status TwoPassSingleSegmentSegmenter::DoInitialize( + std::unique_ptr writer) { // Assume the amount of time to copy the temp file as the same amount // of time as to make it. set_progress_target(info()->duration() * 2); - real_writer_ = writer.Pass(); + real_writer_ = std::move(writer); temp_file_name_ = TempFileName(options()); - scoped_ptr temp(new MkvWriter); + std::unique_ptr temp(new MkvWriter); Status status = temp->Open(temp_file_name_); if (!status.ok()) return status; - return SingleSegmentSegmenter::DoInitialize(temp.Pass()); + return SingleSegmentSegmenter::DoInitialize(std::move(temp)); } Status TwoPassSingleSegmentSegmenter::DoFinalize() { @@ -106,8 +106,8 @@ Status TwoPassSingleSegmentSegmenter::DoFinalize() { return temp; // Close the temp file and open it for reading. - set_writer(scoped_ptr()); - scoped_ptr temp_reader( + set_writer(std::unique_ptr()); + std::unique_ptr temp_reader( File::Open(temp_file_name_.c_str(), "r")); if (!temp_reader) return Status(error::FILE_FAILURE, "Error opening temp file."); diff --git a/packager/media/formats/webm/two_pass_single_segment_segmenter.h b/packager/media/formats/webm/two_pass_single_segment_segmenter.h index 3806750e3d..acdc4670e8 100644 --- a/packager/media/formats/webm/two_pass_single_segment_segmenter.h +++ b/packager/media/formats/webm/two_pass_single_segment_segmenter.h @@ -7,13 +7,12 @@ #ifndef MEDIA_FORMATS_WEBM_TWO_PASS_SINGLE_SEGMENT_SEGMENTER_H_ #define MEDIA_FORMATS_WEBM_TWO_PASS_SINGLE_SEGMENT_SEGMENTER_H_ +#include #include -#include "packager/media/formats/webm/single_segment_segmenter.h" - -#include "packager/base/memory/scoped_ptr.h" #include "packager/media/base/status.h" #include "packager/media/formats/webm/mkv_writer.h" +#include "packager/media/formats/webm/single_segment_segmenter.h" namespace shaka { namespace media { @@ -30,7 +29,7 @@ class TwoPassSingleSegmentSegmenter : public SingleSegmentSegmenter { ~TwoPassSingleSegmentSegmenter() override; // Segmenter implementation overrides. - Status DoInitialize(scoped_ptr writer) override; + Status DoInitialize(std::unique_ptr writer) override; Status DoFinalize() override; private: @@ -42,7 +41,7 @@ class TwoPassSingleSegmentSegmenter : public SingleSegmentSegmenter { MkvWriter* dest, uint64_t last_size); - scoped_ptr real_writer_; + std::unique_ptr real_writer_; std::string temp_file_name_; DISALLOW_COPY_AND_ASSIGN(TwoPassSingleSegmentSegmenter); diff --git a/packager/media/formats/webm/webm_audio_client.h b/packager/media/formats/webm/webm_audio_client.h index 69c282751c..2f255aab10 100644 --- a/packager/media/formats/webm/webm_audio_client.h +++ b/packager/media/formats/webm/webm_audio_client.h @@ -5,10 +5,10 @@ #ifndef MEDIA_FORMATS_WEBM_WEBM_AUDIO_CLIENT_H_ #define MEDIA_FORMATS_WEBM_WEBM_AUDIO_CLIENT_H_ +#include #include #include -#include "packager/base/memory/scoped_ptr.h" #include "packager/media/base/audio_stream_info.h" #include "packager/media/formats/webm/webm_parser.h" diff --git a/packager/media/formats/webm/webm_cluster_parser.cc b/packager/media/formats/webm/webm_cluster_parser.cc index 3907db0289..4d32103970 100644 --- a/packager/media/formats/webm/webm_cluster_parser.cc +++ b/packager/media/formats/webm/webm_cluster_parser.cc @@ -356,7 +356,7 @@ bool WebMClusterParser::OnBlock(bool is_simple_block, // Every encrypted Block has a signal byte and IV prepended to it. Current // encrypted WebM request for comments specification is here // http://wiki.webmproject.org/encryption/webm-encryption-rfc - scoped_ptr decrypt_config; + std::unique_ptr decrypt_config; int data_offset = 0; if (!encryption_key_id.empty() && !WebMCreateDecryptConfig( @@ -411,7 +411,7 @@ bool WebMClusterParser::OnBlock(bool is_simple_block, streams.push_back(audio_stream_info_); if (video_stream_info_) { if (stream_type == kStreamVideo) { - scoped_ptr vpx_parser; + std::unique_ptr vpx_parser; switch (video_stream_info_->codec()) { case kCodecVP8: vpx_parser.reset(new VP8Parser); diff --git a/packager/media/formats/webm/webm_cluster_parser.h b/packager/media/formats/webm/webm_cluster_parser.h index 5e21139176..20e294ddad 100644 --- a/packager/media/formats/webm/webm_cluster_parser.h +++ b/packager/media/formats/webm/webm_cluster_parser.h @@ -7,11 +7,11 @@ #include #include +#include #include #include #include "packager/base/compiler_specific.h" -#include "packager/base/memory/scoped_ptr.h" #include "packager/media/base/decryptor_source.h" #include "packager/media/base/media_parser.h" #include "packager/media/base/media_sample.h" @@ -190,7 +190,7 @@ class WebMClusterParser : public WebMParserClient { scoped_refptr video_stream_info_; std::set ignored_tracks_; - scoped_ptr decryptor_source_; + std::unique_ptr decryptor_source_; std::string audio_encryption_key_id_; std::string video_encryption_key_id_; @@ -203,12 +203,12 @@ class WebMClusterParser : public WebMParserClient { MediaParser::InitCB init_cb_; int64_t last_block_timecode_ = -1; - scoped_ptr block_data_; + std::unique_ptr block_data_; int block_data_size_ = -1; int64_t block_duration_ = -1; int64_t block_add_id_ = -1; - scoped_ptr block_additional_data_; + std::unique_ptr block_additional_data_; // Must be 0 if |block_additional_data_| is null. Must be > 0 if // |block_additional_data_| is NOT null. int block_additional_data_size_ = 0; diff --git a/packager/media/formats/webm/webm_cluster_parser_unittest.cc b/packager/media/formats/webm/webm_cluster_parser_unittest.cc index 8235094fb8..1920445002 100644 --- a/packager/media/formats/webm/webm_cluster_parser_unittest.cc +++ b/packager/media/formats/webm/webm_cluster_parser_unittest.cc @@ -183,9 +183,9 @@ class MockKeySource : public FixedKeySource { Status(const std::vector& key_id, EncryptionKey* key)); }; -scoped_ptr CreateCluster(int timecode, - const BlockInfo* block_info, - int block_count) { +std::unique_ptr CreateCluster(int timecode, + const BlockInfo* block_info, + int block_count) { ClusterBuilder cb; cb.SetClusterTimecode(0); @@ -227,7 +227,7 @@ scoped_ptr CreateCluster(int timecode, } // Creates a Cluster with one block. -scoped_ptr CreateCluster(const uint8_t* data, size_t data_size) { +std::unique_ptr CreateCluster(const uint8_t* data, size_t data_size) { ClusterBuilder cb; cb.SetClusterTimecode(0); cb.AddSimpleBlock(kVideoTrackNum, 0, 0, data, data_size); @@ -450,7 +450,7 @@ class WebMClusterParserTest : public testing::Test { scoped_refptr audio_stream_info_; scoped_refptr video_stream_info_; - scoped_ptr parser_; + std::unique_ptr parser_; std::vector> streams_from_init_event_; BufferQueue audio_buffers_; BufferQueue video_buffers_; @@ -529,7 +529,7 @@ TEST_F(WebMClusterParserTest, TracksWithSampleMissingDuration) { parser_->Reset(); const int blocks_in_cluster = i + 1; - scoped_ptr cluster( + std::unique_ptr cluster( CreateCluster(0, kBlockInfo, blocks_in_cluster)); EXPECT_EQ(cluster->size(), @@ -549,7 +549,8 @@ TEST_F(WebMClusterParserTest, Reset) { InSequence s; int block_count = arraysize(kDefaultBlockInfo); - scoped_ptr cluster(CreateCluster(0, kDefaultBlockInfo, block_count)); + std::unique_ptr cluster( + CreateCluster(0, kDefaultBlockInfo, block_count)); // Send slightly less than the full cluster so all but the last block is // parsed. @@ -568,7 +569,8 @@ TEST_F(WebMClusterParserTest, Reset) { TEST_F(WebMClusterParserTest, ParseClusterWithSingleCall) { int block_count = arraysize(kDefaultBlockInfo); - scoped_ptr cluster(CreateCluster(0, kDefaultBlockInfo, block_count)); + std::unique_ptr cluster( + CreateCluster(0, kDefaultBlockInfo, block_count)); int result = parser_->Parse(cluster->data(), cluster->size()); EXPECT_EQ(cluster->size(), result); @@ -577,7 +579,8 @@ TEST_F(WebMClusterParserTest, ParseClusterWithSingleCall) { TEST_F(WebMClusterParserTest, ParseClusterWithMultipleCalls) { int block_count = arraysize(kDefaultBlockInfo); - scoped_ptr cluster(CreateCluster(0, kDefaultBlockInfo, block_count)); + std::unique_ptr cluster( + CreateCluster(0, kDefaultBlockInfo, block_count)); BufferQueue audio_buffers; BufferQueue video_buffers; @@ -648,7 +651,7 @@ TEST_F(WebMClusterParserTest, ParseSimpleBlockAndBlockGroupMixture) { {kVideoTrackNum, 67, 33, false, NULL, 0, false}, }; int block_count = arraysize(kBlockInfo); - scoped_ptr cluster(CreateCluster(0, kBlockInfo, block_count)); + std::unique_ptr cluster(CreateCluster(0, kBlockInfo, block_count)); int result = parser_->Parse(cluster->data(), cluster->size()); EXPECT_EQ(cluster->size(), result); @@ -680,7 +683,7 @@ TEST_F(WebMClusterParserTest, IgnoredTracks) { }; int output_block_count = arraysize(kOutputBlockInfo); - scoped_ptr cluster( + std::unique_ptr cluster( CreateCluster(0, kInputBlockInfo, input_block_count)); int result = parser_->Parse(cluster->data(), cluster->size()); @@ -710,7 +713,7 @@ TEST_F(WebMClusterParserTest, ParseTextTracks) { }; int input_block_count = arraysize(kInputBlockInfo); - scoped_ptr cluster( + std::unique_ptr cluster( CreateCluster(0, kInputBlockInfo, input_block_count)); int result = parser_->Parse(cluster->data(), cluster->size()); @@ -734,7 +737,7 @@ TEST_F(WebMClusterParserTest, TextTracksSimpleBlock) { }; int input_block_count = arraysize(kInputBlockInfo); - scoped_ptr cluster( + std::unique_ptr cluster( CreateCluster(0, kInputBlockInfo, input_block_count)); int result = parser_->Parse(cluster->data(), cluster->size()); @@ -770,7 +773,7 @@ TEST_F(WebMClusterParserTest, ParseMultipleTextTracks) { }; int input_block_count = arraysize(kInputBlockInfo); - scoped_ptr cluster( + std::unique_ptr cluster( CreateCluster(0, kInputBlockInfo, input_block_count)); int result = parser_->Parse(cluster->data(), cluster->size()); @@ -787,7 +790,8 @@ TEST_F(WebMClusterParserTest, ParseMultipleTextTracks) { } TEST_F(WebMClusterParserTest, ParseVP8) { - scoped_ptr cluster(CreateCluster(kVP8Frame, arraysize(kVP8Frame))); + std::unique_ptr cluster( + CreateCluster(kVP8Frame, arraysize(kVP8Frame))); parser_.reset(CreateParserWithCodec(kCodecVP8)); EXPECT_EQ(cluster->size(), parser_->Parse(cluster->data(), cluster->size())); @@ -800,7 +804,8 @@ TEST_F(WebMClusterParserTest, ParseVP8) { } TEST_F(WebMClusterParserTest, ParseVP9) { - scoped_ptr cluster(CreateCluster(kVP9Frame, arraysize(kVP9Frame))); + std::unique_ptr cluster( + CreateCluster(kVP9Frame, arraysize(kVP9Frame))); parser_.reset(CreateParserWithCodec(kCodecVP9)); EXPECT_EQ(cluster->size(), parser_->Parse(cluster->data(), cluster->size())); @@ -822,7 +827,7 @@ TEST_F(WebMClusterParserTest, ParseEncryptedBlock) { GetKey(std::vector(video_key_id.begin(), video_key_id.end()), _)) .WillOnce(DoAll(SetArgPointee<1>(encryption_key), Return(Status::OK))); - scoped_ptr cluster( + std::unique_ptr cluster( CreateCluster(kEncryptedFrame, arraysize(kEncryptedFrame))); parser_.reset(CreateParserWithKeyIdsAndCodec(std::string(), video_key_id, @@ -843,7 +848,7 @@ TEST_F(WebMClusterParserTest, ParseEncryptedBlock) { TEST_F(WebMClusterParserTest, ParseEncryptedBlockGetKeyFailed) { EXPECT_CALL(mock_key_source_, GetKey(_, _)).WillOnce(Return(Status::UNKNOWN)); - scoped_ptr cluster( + std::unique_ptr cluster( CreateCluster(kEncryptedFrame, arraysize(kEncryptedFrame))); parser_.reset(CreateParserWithKeyIdsAndCodec(std::string(), "video_key_id", @@ -854,7 +859,7 @@ TEST_F(WebMClusterParserTest, ParseEncryptedBlockGetKeyFailed) { } TEST_F(WebMClusterParserTest, ParseBadEncryptedBlock) { - scoped_ptr cluster( + std::unique_ptr cluster( CreateCluster(kEncryptedFrame, arraysize(kEncryptedFrame) - 2)); parser_.reset(CreateParserWithKeyIdsAndCodec(std::string(), "video_key_id", @@ -864,7 +869,7 @@ TEST_F(WebMClusterParserTest, ParseBadEncryptedBlock) { } TEST_F(WebMClusterParserTest, ParseClearFrameInEncryptedTrack) { - scoped_ptr cluster(CreateCluster( + std::unique_ptr cluster(CreateCluster( kClearFrameInEncryptedTrack, arraysize(kClearFrameInEncryptedTrack))); parser_.reset(CreateParserWithKeyIdsAndCodec(std::string(), "video_key_id", @@ -916,7 +921,7 @@ TEST_F(WebMClusterParserTest, ParseInvalidTextBlockGroupWithoutDuration) { {kTextTrackNum, 33, -42, false, NULL, 0, false}, }; int block_count = arraysize(kBlockInfo); - scoped_ptr cluster(CreateCluster(0, kBlockInfo, block_count)); + std::unique_ptr cluster(CreateCluster(0, kBlockInfo, block_count)); int result = parser_->Parse(cluster->data(), cluster->size()); EXPECT_LT(result, 0); } @@ -942,7 +947,7 @@ TEST_F(WebMClusterParserTest, ParseWithDefaultDurationsSimpleBlocks) { }; int block_count = arraysize(kBlockInfo); - scoped_ptr cluster(CreateCluster(0, kBlockInfo, block_count)); + std::unique_ptr cluster(CreateCluster(0, kBlockInfo, block_count)); // Now parse a whole cluster to verify that all the blocks will get parsed // and the last audio and video are held back due to no duration. @@ -976,7 +981,8 @@ TEST_F(WebMClusterParserTest, ParseWithoutAnyDurationsSimpleBlocks) { }; int block_count1 = arraysize(kBlockInfo1); - scoped_ptr cluster1(CreateCluster(0, kBlockInfo1, block_count1)); + std::unique_ptr cluster1( + CreateCluster(0, kBlockInfo1, block_count1)); // Verify the last fully parsed audio and video buffer are both missing from // the result (parser should hold them aside for duration estimation until @@ -997,7 +1003,8 @@ TEST_F(WebMClusterParserTest, ParseWithoutAnyDurationsSimpleBlocks) { }; int block_count2 = arraysize(kBlockInfo2); - scoped_ptr cluster2(CreateCluster(0, kBlockInfo2, block_count2)); + std::unique_ptr cluster2( + CreateCluster(0, kBlockInfo2, block_count2)); EXPECT_EQ(cluster2->size(), parser_->Parse(cluster2->data(), cluster2->size())); @@ -1028,7 +1035,8 @@ TEST_F(WebMClusterParserTest, ParseWithoutAnyDurationsBlockGroups) { }; int block_count1 = arraysize(kBlockInfo1); - scoped_ptr cluster1(CreateCluster(0, kBlockInfo1, block_count1)); + std::unique_ptr cluster1( + CreateCluster(0, kBlockInfo1, block_count1)); // Verify the last fully parsed audio and video buffer are both missing from // the result (parser should hold them aside for duration estimation until @@ -1051,7 +1059,8 @@ TEST_F(WebMClusterParserTest, ParseWithoutAnyDurationsBlockGroups) { }; int block_count2 = arraysize(kBlockInfo2); - scoped_ptr cluster2(CreateCluster(0, kBlockInfo2, block_count2)); + std::unique_ptr cluster2( + CreateCluster(0, kBlockInfo2, block_count2)); EXPECT_EQ(cluster2->size(), parser_->Parse(cluster2->data(), cluster2->size())); @@ -1073,7 +1082,7 @@ TEST_F(WebMClusterParserTest, }; int block_count = arraysize(kBlockInfo); - scoped_ptr cluster(CreateCluster(0, kBlockInfo, block_count)); + std::unique_ptr cluster(CreateCluster(0, kBlockInfo, block_count)); int result = parser_->Parse(cluster->data(), cluster->size()); EXPECT_EQ(cluster->size(), result); EXPECT_TRUE(parser_->Flush()); @@ -1092,7 +1101,7 @@ TEST_F(WebMClusterParserTest, }; int block_count = arraysize(kBlockInfo); - scoped_ptr cluster(CreateCluster(0, kBlockInfo, block_count)); + std::unique_ptr cluster(CreateCluster(0, kBlockInfo, block_count)); int result = parser_->Parse(cluster->data(), cluster->size()); EXPECT_EQ(cluster->size(), result); EXPECT_TRUE(parser_->Flush()); diff --git a/packager/media/formats/webm/webm_content_encodings.h b/packager/media/formats/webm/webm_content_encodings.h index 95b7a6135a..0a6f2c90b1 100644 --- a/packager/media/formats/webm/webm_content_encodings.h +++ b/packager/media/formats/webm/webm_content_encodings.h @@ -6,10 +6,9 @@ #define MEDIA_FORMATS_WEBM_WEBM_CONTENT_ENCODINGS_H_ #include +#include #include -#include "packager/base/memory/scoped_ptr.h" - namespace shaka { namespace media { diff --git a/packager/media/formats/webm/webm_content_encodings_client.h b/packager/media/formats/webm/webm_content_encodings_client.h index 8cc2eca7be..0fea165b61 100644 --- a/packager/media/formats/webm/webm_content_encodings_client.h +++ b/packager/media/formats/webm/webm_content_encodings_client.h @@ -5,11 +5,11 @@ #ifndef MEDIA_FORMATS_WEBM_WEBM_CONTENT_ENCODINGS_CLIENT_H_ #define MEDIA_FORMATS_WEBM_WEBM_CONTENT_ENCODINGS_CLIENT_H_ +#include #include #include "packager/base/callback.h" #include "packager/base/compiler_specific.h" -#include "packager/base/memory/scoped_ptr.h" #include "packager/media/formats/webm/webm_content_encodings.h" #include "packager/media/formats/webm/webm_parser.h" @@ -33,7 +33,7 @@ class WebMContentEncodingsClient : public WebMParserClient { bool OnBinary(int id, const uint8_t* data, int size) override; private: - scoped_ptr cur_content_encoding_; + std::unique_ptr cur_content_encoding_; bool content_encryption_encountered_; ContentEncodings content_encodings_; diff --git a/packager/media/formats/webm/webm_crypto_helpers.cc b/packager/media/formats/webm/webm_crypto_helpers.cc index f858bc415f..74c16d7e2d 100644 --- a/packager/media/formats/webm/webm_crypto_helpers.cc +++ b/packager/media/formats/webm/webm_crypto_helpers.cc @@ -31,7 +31,7 @@ bool WebMCreateDecryptConfig(const uint8_t* data, int data_size, const uint8_t* key_id, int key_id_size, - scoped_ptr* decrypt_config, + std::unique_ptr* decrypt_config, int* data_offset) { int header_size = kWebMSignalByteSize; if (data_size < header_size) { diff --git a/packager/media/formats/webm/webm_crypto_helpers.h b/packager/media/formats/webm/webm_crypto_helpers.h index 839a948732..e0162db4b3 100644 --- a/packager/media/formats/webm/webm_crypto_helpers.h +++ b/packager/media/formats/webm/webm_crypto_helpers.h @@ -6,8 +6,7 @@ #define MEDIA_FORMATS_WEBM_WEBM_CRYPTO_HELPERS_H_ #include - -#include "packager/base/memory/scoped_ptr.h" +#include #include "packager/media/base/decrypt_config.h" namespace shaka { @@ -25,7 +24,7 @@ bool WebMCreateDecryptConfig(const uint8_t* data, int data_size, const uint8_t* key_id, int key_id_size, - scoped_ptr* decrypt_config, + std::unique_ptr* decrypt_config, int* data_offset); } // namespace media diff --git a/packager/media/formats/webm/webm_media_parser.h b/packager/media/formats/webm/webm_media_parser.h index 47a20d44ba..b4bd3ab61e 100644 --- a/packager/media/formats/webm/webm_media_parser.h +++ b/packager/media/formats/webm/webm_media_parser.h @@ -71,7 +71,7 @@ class WebMMediaParser : public MediaParser { bool unknown_segment_size_; - scoped_ptr cluster_parser_; + std::unique_ptr cluster_parser_; ByteQueue byte_queue_; DISALLOW_COPY_AND_ASSIGN(WebMMediaParser); diff --git a/packager/media/formats/webm/webm_muxer.cc b/packager/media/formats/webm/webm_muxer.cc index ff9f7cb85d..d4ac37db70 100644 --- a/packager/media/formats/webm/webm_muxer.cc +++ b/packager/media/formats/webm/webm_muxer.cc @@ -38,7 +38,7 @@ Status WebMMuxer::Initialize() { "WebM does not support protection scheme other than 'cenc'."); } - scoped_ptr writer(new MkvWriter); + std::unique_ptr writer(new MkvWriter); Status status = writer->Open(options().output_file_name); if (!status.ok()) return status; @@ -52,7 +52,7 @@ Status WebMMuxer::Initialize() { } Status initialized = segmenter_->Initialize( - writer.Pass(), streams()[0]->info().get(), progress_listener(), + std::move(writer), streams()[0]->info().get(), progress_listener(), muxer_listener(), encryption_key_source(), max_sd_pixels(), clear_lead_in_seconds()); diff --git a/packager/media/formats/webm/webm_muxer.h b/packager/media/formats/webm/webm_muxer.h index d60a42dba8..828e4de335 100644 --- a/packager/media/formats/webm/webm_muxer.h +++ b/packager/media/formats/webm/webm_muxer.h @@ -32,7 +32,7 @@ class WebMMuxer : public Muxer { void FireOnMediaStartEvent(); void FireOnMediaEndEvent(); - scoped_ptr segmenter_; + std::unique_ptr segmenter_; DISALLOW_COPY_AND_ASSIGN(WebMMuxer); }; diff --git a/packager/media/formats/webm/webm_parser_unittest.cc b/packager/media/formats/webm/webm_parser_unittest.cc index b20c9acbb2..a3918493bc 100644 --- a/packager/media/formats/webm/webm_parser_unittest.cc +++ b/packager/media/formats/webm/webm_parser_unittest.cc @@ -40,7 +40,7 @@ class WebMParserTest : public testing::Test { StrictMock client_; }; -static scoped_ptr CreateCluster(int block_count) { +static std::unique_ptr CreateCluster(int block_count) { ClusterBuilder cb; cb.SetClusterTimecode(0); @@ -220,7 +220,7 @@ TEST_F(WebMParserTest, VoidAndCRC32InList) { TEST_F(WebMParserTest, ParseListElementWithSingleCall) { - scoped_ptr cluster(CreateCluster(kBlockCount)); + std::unique_ptr cluster(CreateCluster(kBlockCount)); CreateClusterExpectations(kBlockCount, true, &client_); WebMListParser parser(kWebMIdCluster, &client_); @@ -229,7 +229,7 @@ TEST_F(WebMParserTest, ParseListElementWithSingleCall) { } TEST_F(WebMParserTest, ParseListElementWithMultipleCalls) { - scoped_ptr cluster(CreateCluster(kBlockCount)); + std::unique_ptr cluster(CreateCluster(kBlockCount)); CreateClusterExpectations(kBlockCount, true, &client_); const uint8_t* data = cluster->data(); @@ -263,7 +263,7 @@ TEST_F(WebMParserTest, ParseListElementWithMultipleCalls) { TEST_F(WebMParserTest, Reset) { InSequence s; - scoped_ptr cluster(CreateCluster(kBlockCount)); + std::unique_ptr cluster(CreateCluster(kBlockCount)); // First expect all but the last block. CreateClusterExpectations(kBlockCount - 1, false, &client_); diff --git a/packager/media/formats/webm/webm_tracks_parser.h b/packager/media/formats/webm/webm_tracks_parser.h index dfce0d3466..ca4c40a5c1 100644 --- a/packager/media/formats/webm/webm_tracks_parser.h +++ b/packager/media/formats/webm/webm_tracks_parser.h @@ -6,12 +6,11 @@ #define MEDIA_FORMATS_WEBM_WEBM_TRACKS_PARSER_H_ #include +#include #include #include #include -#include "packager/base/compiler_specific.h" -#include "packager/base/memory/scoped_ptr.h" #include "packager/base/time/time.h" #include "packager/media/base/audio_stream_info.h" #include "packager/media/base/text_track_config.h" @@ -88,7 +87,7 @@ class WebMTracksParser : public WebMParserClient { int64_t seek_preroll_; int64_t codec_delay_; int64_t default_duration_; - scoped_ptr track_content_encodings_client_; + std::unique_ptr track_content_encodings_client_; int64_t audio_track_num_; int64_t audio_default_duration_; diff --git a/packager/media/formats/webm/webm_tracks_parser_unittest.cc b/packager/media/formats/webm/webm_tracks_parser_unittest.cc index 825e8f5810..006b9d55b4 100644 --- a/packager/media/formats/webm/webm_tracks_parser_unittest.cc +++ b/packager/media/formats/webm/webm_tracks_parser_unittest.cc @@ -33,7 +33,7 @@ class WebMTracksParserTest : public testing::Test { TextKind text_kind, const std::string& name, const std::string& language) { - scoped_ptr parser(new WebMTracksParser(false)); + std::unique_ptr parser(new WebMTracksParser(false)); int result = parser->Parse(buffer, buffer_size); EXPECT_GT(result, 0); @@ -101,7 +101,7 @@ TEST_F(WebMTracksParserTest, IgnoringTextTracks) { tb.AddTextTrack(2, 2, kWebMCodecSubtitles, "Commentary", "fre"); const std::vector buf = tb.Finish(); - scoped_ptr parser(new WebMTracksParser(true)); + std::unique_ptr parser(new WebMTracksParser(true)); int result = parser->Parse(&buf[0], buf.size()); EXPECT_GT(result, 0); @@ -134,7 +134,7 @@ TEST_F(WebMTracksParserTest, AudioVideoDefaultDurationUnset) { tb.AddVideoTrack(2, 2, "V_VP8", "video", "", -1, 320, 240); const std::vector buf = tb.Finish(); - scoped_ptr parser(new WebMTracksParser(true)); + std::unique_ptr parser(new WebMTracksParser(true)); int result = parser->Parse(&buf[0], buf.size()); EXPECT_LE(0, result); EXPECT_EQ(static_cast(buf.size()), result); @@ -165,7 +165,7 @@ TEST_F(WebMTracksParserTest, AudioVideoDefaultDurationSet) { tb.AddVideoTrack(2, 2, "V_VP8", "video", "", 987654321, 320, 240); const std::vector buf = tb.Finish(); - scoped_ptr parser(new WebMTracksParser(true)); + std::unique_ptr parser(new WebMTracksParser(true)); int result = parser->Parse(&buf[0], buf.size()); EXPECT_LE(0, result); EXPECT_EQ(static_cast(buf.size()), result); @@ -185,7 +185,7 @@ TEST_F(WebMTracksParserTest, InvalidZeroDefaultDurationSet) { tb.AddAudioTrack(1, 1, "A_VORBIS", "audio", "", 0, 2, 8000); const std::vector buf = tb.Finish(); - scoped_ptr parser(new WebMTracksParser(true)); + std::unique_ptr parser(new WebMTracksParser(true)); EXPECT_EQ(-1, parser->Parse(&buf[0], buf.size())); } @@ -197,7 +197,7 @@ TEST_F(WebMTracksParserTest, HighTrackUID) { tb.AddAudioTrack(1, 1ULL << 31, "A_VORBIS", "audio", "", 40, 2, 8000); const std::vector buf = tb.Finish(); - scoped_ptr parser(new WebMTracksParser(true)); + std::unique_ptr parser(new WebMTracksParser(true)); EXPECT_GT(parser->Parse(&buf[0], buf.size()),0); } diff --git a/packager/media/formats/webm/webm_video_client.h b/packager/media/formats/webm/webm_video_client.h index 1a1ecdebbb..26f085745f 100644 --- a/packager/media/formats/webm/webm_video_client.h +++ b/packager/media/formats/webm/webm_video_client.h @@ -5,10 +5,10 @@ #ifndef MEDIA_FORMATS_WEBM_WEBM_VIDEO_CLIENT_H_ #define MEDIA_FORMATS_WEBM_WEBM_VIDEO_CLIENT_H_ +#include #include #include -#include "packager/base/memory/scoped_ptr.h" #include "packager/media/base/video_stream_info.h" #include "packager/media/formats/webm/webm_parser.h" diff --git a/packager/media/formats/wvm/wvm_media_parser.cc b/packager/media/formats/wvm/wvm_media_parser.cc index 4f23ad4765..44c63f9fac 100644 --- a/packager/media/formats/wvm/wvm_media_parser.cc +++ b/packager/media/formats/wvm/wvm_media_parser.cc @@ -1134,7 +1134,7 @@ bool WvmMediaParser::ProcessEcm() { std::vector decrypted_content_key_vec( content_key_buffer.begin() + 4, content_key_buffer.begin() + 20); - scoped_ptr content_decryptor( + std::unique_ptr content_decryptor( new AesCbcDecryptor(kCtsPadding, AesCryptor::kUseConstantIv)); if (!content_decryptor->InitializeWithIv(decrypted_content_key_vec, zero_iv)) { @@ -1142,7 +1142,7 @@ bool WvmMediaParser::ProcessEcm() { return false; } - content_decryptor_ = content_decryptor.Pass(); + content_decryptor_ = std::move(content_decryptor); return true; } diff --git a/packager/media/formats/wvm/wvm_media_parser.h b/packager/media/formats/wvm/wvm_media_parser.h index 6b7df972f0..ea92982fed 100644 --- a/packager/media/formats/wvm/wvm_media_parser.h +++ b/packager/media/formats/wvm/wvm_media_parser.h @@ -8,11 +8,11 @@ #include #include +#include #include #include #include "packager/base/compiler_specific.h" -#include "packager/base/memory/scoped_ptr.h" #include "packager/media/base/media_parser.h" #include "packager/media/base/network_util.h" #include "packager/media/codecs/h264_byte_to_unit_stream_converter.h" @@ -252,7 +252,7 @@ class WvmMediaParser : public MediaParser { std::deque media_sample_queue_; std::vector sample_data_; KeySource* decryption_key_source_; - scoped_ptr content_decryptor_; + std::unique_ptr content_decryptor_; DISALLOW_COPY_AND_ASSIGN(WvmMediaParser); }; diff --git a/packager/media/formats/wvm/wvm_media_parser_unittest.cc b/packager/media/formats/wvm/wvm_media_parser_unittest.cc index 8cf1f66ba2..25546d4fc7 100644 --- a/packager/media/formats/wvm/wvm_media_parser_unittest.cc +++ b/packager/media/formats/wvm/wvm_media_parser_unittest.cc @@ -81,8 +81,8 @@ class WvmMediaParserTest : public testing::Test { protected: typedef std::map > StreamMap; - scoped_ptr parser_; - scoped_ptr key_source_; + std::unique_ptr parser_; + std::unique_ptr key_source_; StreamMap stream_map_; int audio_frame_count_; int video_frame_count_; diff --git a/packager/media/test/packager_test.cc b/packager/media/test/packager_test.cc index 23112aa055..bd8c696289 100644 --- a/packager/media/test/packager_test.cc +++ b/packager/media/test/packager_test.cc @@ -157,11 +157,11 @@ void PackagerTestBasic::Remux(const std::string& input, Demuxer demuxer(GetFullPath(input)); ASSERT_OK(demuxer.Initialize()); - scoped_ptr encryption_key_source( + std::unique_ptr encryption_key_source( FixedKeySource::CreateFromHexStrings(kKeyIdHex, kKeyHex, "", "")); DCHECK(encryption_key_source); - scoped_ptr muxer_video; + std::unique_ptr muxer_video; if (!video_output.empty()) { muxer_video.reset( new mp4::MP4Muxer(SetupOptions(video_output, single_segment))); @@ -181,7 +181,7 @@ void PackagerTestBasic::Remux(const std::string& input, } } - scoped_ptr muxer_audio; + std::unique_ptr muxer_audio; if (!audio_output.empty()) { muxer_audio.reset( new mp4::MP4Muxer(SetupOptions(audio_output, single_segment))); @@ -211,13 +211,13 @@ void PackagerTestBasic::Decrypt(const std::string& input, CHECK(!video_output.empty() || !audio_output.empty()); Demuxer demuxer(GetFullPath(input)); - scoped_ptr decryption_key_source( + std::unique_ptr decryption_key_source( FixedKeySource::CreateFromHexStrings(kKeyIdHex, kKeyHex, "", "")); ASSERT_TRUE(decryption_key_source); - demuxer.SetKeySource(decryption_key_source.Pass()); + demuxer.SetKeySource(std::move(decryption_key_source)); ASSERT_OK(demuxer.Initialize()); - scoped_ptr muxer; + std::unique_ptr muxer; MediaStream* stream(NULL); if (!video_output.empty()) { muxer.reset( diff --git a/packager/mpd/base/dash_iop_mpd_notifier.h b/packager/mpd/base/dash_iop_mpd_notifier.h index 3a597fc4b3..381db88def 100644 --- a/packager/mpd/base/dash_iop_mpd_notifier.h +++ b/packager/mpd/base/dash_iop_mpd_notifier.h @@ -89,8 +89,8 @@ class DashIopMpdNotifier : public MpdNotifier { } // Testing only method. Sets mpd_builder_. - void SetMpdBuilderForTesting(scoped_ptr mpd_builder) { - mpd_builder_ = mpd_builder.Pass(); + void SetMpdBuilderForTesting(std::unique_ptr mpd_builder) { + mpd_builder_ = std::move(mpd_builder); } std::map> adaptation_set_list_map_; @@ -101,7 +101,7 @@ class DashIopMpdNotifier : public MpdNotifier { // MPD output path. std::string output_path_; - scoped_ptr mpd_builder_; + std::unique_ptr mpd_builder_; base::Lock lock_; // Next group ID to use for AdapationSets that can be grouped. diff --git a/packager/mpd/base/dash_iop_mpd_notifier_unittest.cc b/packager/mpd/base/dash_iop_mpd_notifier_unittest.cc index 4c42a98bb9..bc55ab4a80 100644 --- a/packager/mpd/base/dash_iop_mpd_notifier_unittest.cc +++ b/packager/mpd/base/dash_iop_mpd_notifier_unittest.cc @@ -115,8 +115,8 @@ class DashIopMpdNotifierTest } void SetMpdBuilder(DashIopMpdNotifier* notifier, - scoped_ptr mpd_builder) { - notifier->SetMpdBuilderForTesting(mpd_builder.Pass()); + std::unique_ptr mpd_builder) { + notifier->SetMpdBuilderForTesting(std::move(mpd_builder)); } MpdBuilder::MpdType mpd_type() { @@ -136,8 +136,8 @@ class DashIopMpdNotifierTest // Default mocks that can be used for the tests. // IOW, if a test only requires one instance of // Mock{AdaptationSet,Representation}, these can be used. - scoped_ptr default_mock_adaptation_set_; - scoped_ptr default_mock_representation_; + std::unique_ptr default_mock_adaptation_set_; + std::unique_ptr default_mock_representation_; private: base::FilePath temp_file_path_; @@ -162,7 +162,8 @@ TEST_P(DashIopMpdNotifierTest, NotifyNewContainer) { DashIopMpdNotifier notifier(dash_profile(), empty_mpd_option_, empty_base_urls_, output_path_); - scoped_ptr mock_mpd_builder(new MockMpdBuilder(mpd_type())); + std::unique_ptr mock_mpd_builder( + new MockMpdBuilder(mpd_type())); EXPECT_CALL(*mock_mpd_builder, AddAdaptationSet(_)) .WillOnce(Return(default_mock_adaptation_set_.get())); @@ -171,11 +172,11 @@ TEST_P(DashIopMpdNotifierTest, NotifyNewContainer) { .WillOnce(Return(default_mock_representation_.get())); // This is for the Flush() below but adding expectation here because the next - // lines Pass() the pointer. + // std::move(lines) the pointer. EXPECT_CALL(*mock_mpd_builder, ToString(_)).WillOnce(Return(true)); uint32_t unused_container_id; - SetMpdBuilder(¬ifier, mock_mpd_builder.Pass()); + SetMpdBuilder(¬ifier, std::move(mock_mpd_builder)); EXPECT_TRUE(notifier.NotifyNewContainer(ConvertToMediaInfo(kValidMediaInfo), &unused_container_id)); EXPECT_TRUE(notifier.Flush()); @@ -193,7 +194,8 @@ TEST_P(DashIopMpdNotifierTest, NotifyNewTextContainer) { DashIopMpdNotifier notifier(dash_profile(), empty_mpd_option_, empty_base_urls_, output_path_); - scoped_ptr mock_mpd_builder(new MockMpdBuilder(mpd_type())); + std::unique_ptr mock_mpd_builder( + new MockMpdBuilder(mpd_type())); EXPECT_CALL(*mock_mpd_builder, AddAdaptationSet(StrEq("en"))) .WillOnce(Return(default_mock_adaptation_set_.get())); @@ -203,11 +205,11 @@ TEST_P(DashIopMpdNotifierTest, NotifyNewTextContainer) { .WillOnce(Return(default_mock_representation_.get())); // This is for the Flush() below but adding expectation here because the next - // lines Pass() the pointer. + // std::move(lines) the pointer. EXPECT_CALL(*mock_mpd_builder, ToString(_)).WillOnce(Return(true)); uint32_t unused_container_id; - SetMpdBuilder(¬ifier, mock_mpd_builder.Pass()); + SetMpdBuilder(¬ifier, std::move(mock_mpd_builder)); EXPECT_TRUE(notifier.NotifyNewContainer(ConvertToMediaInfo(kTextMediaInfo), &unused_container_id)); EXPECT_TRUE(notifier.Flush()); @@ -221,7 +223,8 @@ TEST_P(DashIopMpdNotifierTest, NotifyNewContainersWithDifferentProtectedContent) { DashIopMpdNotifier notifier(dash_profile(), empty_mpd_option_, empty_base_urls_, output_path_); - scoped_ptr mock_mpd_builder(new MockMpdBuilder(mpd_type())); + std::unique_ptr mock_mpd_builder( + new MockMpdBuilder(mpd_type())); // Note they both have different (bogus) pssh, like real use case. // default Key ID = _default_key_id_ @@ -287,9 +290,9 @@ TEST_P(DashIopMpdNotifierTest, // mocks by named mocks. const uint32_t kSdAdaptationSetId = 2u; const uint32_t kHdAdaptationSetId = 3u; - scoped_ptr sd_adaptation_set( + std::unique_ptr sd_adaptation_set( new MockAdaptationSet(kSdAdaptationSetId)); - scoped_ptr hd_adaptation_set( + std::unique_ptr hd_adaptation_set( new MockAdaptationSet(kHdAdaptationSetId)); ON_CALL(*sd_adaptation_set, Group()).WillByDefault(Return(kDefaultGroupId)); @@ -299,9 +302,9 @@ TEST_P(DashIopMpdNotifierTest, const uint32_t kSdRepresentation = 4u; const uint32_t kHdRepresentation = 5u; - scoped_ptr sd_representation( + std::unique_ptr sd_representation( new MockRepresentation(kSdRepresentation)); - scoped_ptr hd_representation( + std::unique_ptr hd_representation( new MockRepresentation(kHdRepresentation)); InSequence in_sequence; @@ -328,7 +331,7 @@ TEST_P(DashIopMpdNotifierTest, .WillOnce(Return(hd_representation.get())); uint32_t unused_container_id; - SetMpdBuilder(¬ifier, mock_mpd_builder.Pass()); + SetMpdBuilder(¬ifier, std::move(mock_mpd_builder)); EXPECT_TRUE(notifier.NotifyNewContainer( ConvertToMediaInfo(kSdProtectedContent), &unused_container_id)); EXPECT_TRUE(notifier.NotifyNewContainer( @@ -341,7 +344,8 @@ TEST_P(DashIopMpdNotifierTest, TEST_P(DashIopMpdNotifierTest, NotifyNewContainersWithSameProtectedContent) { DashIopMpdNotifier notifier(dash_profile(), empty_mpd_option_, empty_base_urls_, output_path_); - scoped_ptr mock_mpd_builder(new MockMpdBuilder(mpd_type())); + std::unique_ptr mock_mpd_builder( + new MockMpdBuilder(mpd_type())); // These have the same default key ID and PSSH. const char kSdProtectedContent[] = @@ -401,9 +405,9 @@ TEST_P(DashIopMpdNotifierTest, NotifyNewContainersWithSameProtectedContent) { const uint32_t kSdRepresentation = 6u; const uint32_t kHdRepresentation = 7u; - scoped_ptr sd_representation( + std::unique_ptr sd_representation( new MockRepresentation(kSdRepresentation)); - scoped_ptr hd_representation( + std::unique_ptr hd_representation( new MockRepresentation(kHdRepresentation)); // No reason to set @group if there is only one AdaptationSet. @@ -431,7 +435,7 @@ TEST_P(DashIopMpdNotifierTest, NotifyNewContainersWithSameProtectedContent) { .WillOnce(Return(hd_representation.get())); uint32_t unused_container_id; - SetMpdBuilder(¬ifier, mock_mpd_builder.Pass()); + SetMpdBuilder(¬ifier, std::move(mock_mpd_builder)); EXPECT_TRUE(notifier.NotifyNewContainer( ConvertToMediaInfo(kSdProtectedContent), &unused_container_id)); EXPECT_TRUE(notifier.NotifyNewContainer( @@ -443,7 +447,8 @@ TEST_P(DashIopMpdNotifierTest, AddContentProtection) { DashIopMpdNotifier notifier(dash_profile(), empty_mpd_option_, empty_base_urls_, output_path_); - scoped_ptr mock_mpd_builder(new MockMpdBuilder(mpd_type())); + std::unique_ptr mock_mpd_builder( + new MockMpdBuilder(mpd_type())); EXPECT_CALL(*mock_mpd_builder, AddAdaptationSet(_)) .WillOnce(Return(default_mock_adaptation_set_.get())); @@ -451,7 +456,7 @@ TEST_P(DashIopMpdNotifierTest, AddContentProtection) { .WillOnce(Return(default_mock_representation_.get())); uint32_t container_id; - SetMpdBuilder(¬ifier, mock_mpd_builder.Pass()); + SetMpdBuilder(¬ifier, std::move(mock_mpd_builder)); EXPECT_TRUE(notifier.NotifyNewContainer(ConvertToMediaInfo(kValidMediaInfo), &container_id)); @@ -474,7 +479,8 @@ TEST_P(DashIopMpdNotifierTest, AddContentProtection) { TEST_P(DashIopMpdNotifierTest, SetGroup) { DashIopMpdNotifier notifier(dash_profile(), empty_mpd_option_, empty_base_urls_, output_path_); - scoped_ptr mock_mpd_builder(new MockMpdBuilder(mpd_type())); + std::unique_ptr mock_mpd_builder( + new MockMpdBuilder(mpd_type())); // These have the same default key ID and PSSH. const char kSdProtectedContent[] = @@ -519,9 +525,9 @@ TEST_P(DashIopMpdNotifierTest, SetGroup) { const uint32_t kSdAdaptationSetId = 6u; const uint32_t kHdAdaptationSetId = 7u; - scoped_ptr sd_adaptation_set( + std::unique_ptr sd_adaptation_set( new MockAdaptationSet(kSdAdaptationSetId)); - scoped_ptr hd_adaptation_set( + std::unique_ptr hd_adaptation_set( new MockAdaptationSet(kHdAdaptationSetId)); ON_CALL(*sd_adaptation_set, Group()).WillByDefault(Return(kDefaultGroupId)); @@ -529,9 +535,9 @@ TEST_P(DashIopMpdNotifierTest, SetGroup) { const uint32_t kSdRepresentation = 4u; const uint32_t kHdRepresentation = 5u; - scoped_ptr sd_representation( + std::unique_ptr sd_representation( new MockRepresentation(kSdRepresentation)); - scoped_ptr hd_representation( + std::unique_ptr hd_representation( new MockRepresentation(kHdRepresentation)); InSequence in_sequence; @@ -555,7 +561,7 @@ TEST_P(DashIopMpdNotifierTest, SetGroup) { // This is not very nice but we need it for settings expectations later. MockMpdBuilder* mock_mpd_builder_raw = mock_mpd_builder.get(); uint32_t unused_container_id; - SetMpdBuilder(¬ifier, mock_mpd_builder.Pass()); + SetMpdBuilder(¬ifier, std::move(mock_mpd_builder)); EXPECT_TRUE(notifier.NotifyNewContainer( ConvertToMediaInfo(kSdProtectedContent), &unused_container_id)); EXPECT_TRUE(notifier.NotifyNewContainer( @@ -588,13 +594,13 @@ TEST_P(DashIopMpdNotifierTest, SetGroup) { "container_type: 1\n"; const uint32_t k4kAdaptationSetId = 4000u; - scoped_ptr fourk_adaptation_set( + std::unique_ptr fourk_adaptation_set( new MockAdaptationSet(k4kAdaptationSetId)); ON_CALL(*fourk_adaptation_set, Group()) .WillByDefault(Return(kDefaultGroupId)); const uint32_t k4kRepresentationId = 4001u; - scoped_ptr fourk_representation( + std::unique_ptr fourk_representation( new MockRepresentation(k4kRepresentationId)); EXPECT_CALL(*mock_mpd_builder_raw, AddAdaptationSet(_)) @@ -615,7 +621,8 @@ TEST_P(DashIopMpdNotifierTest, SetGroup) { TEST_P(DashIopMpdNotifierTest, DoNotSetGroupIfContentTypesDifferent) { DashIopMpdNotifier notifier(dash_profile(), empty_mpd_option_, empty_base_urls_, output_path_); - scoped_ptr mock_mpd_builder(new MockMpdBuilder(mpd_type())); + std::unique_ptr mock_mpd_builder( + new MockMpdBuilder(mpd_type())); // These have the same default key ID and PSSH. const char kVideoContent[] = @@ -659,9 +666,9 @@ TEST_P(DashIopMpdNotifierTest, DoNotSetGroupIfContentTypesDifferent) { const uint32_t kVideoAdaptationSetId = 6u; const uint32_t kAudioAdaptationSetId = 7u; - scoped_ptr video_adaptation_set( + std::unique_ptr video_adaptation_set( new MockAdaptationSet(kVideoAdaptationSetId)); - scoped_ptr audio_adaptation_set( + std::unique_ptr audio_adaptation_set( new MockAdaptationSet(kAudioAdaptationSetId)); ON_CALL(*video_adaptation_set, Group()) @@ -675,9 +682,9 @@ TEST_P(DashIopMpdNotifierTest, DoNotSetGroupIfContentTypesDifferent) { const uint32_t kVideoRepresentation = 8u; const uint32_t kAudioRepresentation = 9u; - scoped_ptr video_representation( + std::unique_ptr video_representation( new MockRepresentation(kVideoRepresentation)); - scoped_ptr audio_representation( + std::unique_ptr audio_representation( new MockRepresentation(kAudioRepresentation)); InSequence in_sequence; @@ -696,7 +703,7 @@ TEST_P(DashIopMpdNotifierTest, DoNotSetGroupIfContentTypesDifferent) { .WillOnce(Return(audio_representation.get())); uint32_t unused_container_id; - SetMpdBuilder(¬ifier, mock_mpd_builder.Pass()); + SetMpdBuilder(¬ifier, std::move(mock_mpd_builder)); EXPECT_TRUE(notifier.NotifyNewContainer( ConvertToMediaInfo(kVideoContent), &unused_container_id)); EXPECT_TRUE(notifier.NotifyNewContainer( @@ -727,7 +734,8 @@ TEST_P(DashIopMpdNotifierTest, UpdateEncryption) { DashIopMpdNotifier notifier(dash_profile(), empty_mpd_option_, empty_base_urls_, output_path_); - scoped_ptr mock_mpd_builder(new MockMpdBuilder(mpd_type())); + std::unique_ptr mock_mpd_builder( + new MockMpdBuilder(mpd_type())); EXPECT_CALL(*mock_mpd_builder, AddAdaptationSet(_)) .WillOnce(Return(default_mock_adaptation_set_.get())); @@ -736,7 +744,7 @@ TEST_P(DashIopMpdNotifierTest, UpdateEncryption) { .WillOnce(Return(default_mock_representation_.get())); uint32_t container_id; - SetMpdBuilder(¬ifier, mock_mpd_builder.Pass()); + SetMpdBuilder(¬ifier, std::move(mock_mpd_builder)); EXPECT_TRUE(notifier.NotifyNewContainer(ConvertToMediaInfo(kProtectedContent), &container_id)); @@ -830,16 +838,21 @@ TEST_P(DashIopMpdNotifierTest, SplitAdaptationSetsByLanguageAndCodec) { DashIopMpdNotifier notifier(dash_profile(), empty_mpd_option_, empty_base_urls_, output_path_); - scoped_ptr mock_mpd_builder(new MockMpdBuilder(mpd_type())); + std::unique_ptr mock_mpd_builder( + new MockMpdBuilder(mpd_type())); - scoped_ptr adaptation_set1(new MockAdaptationSet(1)); - scoped_ptr adaptation_set2(new MockAdaptationSet(2)); - scoped_ptr adaptation_set3(new MockAdaptationSet(3)); + std::unique_ptr adaptation_set1(new MockAdaptationSet(1)); + std::unique_ptr adaptation_set2(new MockAdaptationSet(2)); + std::unique_ptr adaptation_set3(new MockAdaptationSet(3)); - scoped_ptr representation1(new MockRepresentation(1)); - scoped_ptr representation2(new MockRepresentation(2)); - scoped_ptr representation3(new MockRepresentation(3)); - scoped_ptr representation4(new MockRepresentation(4)); + std::unique_ptr representation1( + new MockRepresentation(1)); + std::unique_ptr representation2( + new MockRepresentation(2)); + std::unique_ptr representation3( + new MockRepresentation(3)); + std::unique_ptr representation4( + new MockRepresentation(4)); // We expect three AdaptationSets. EXPECT_CALL(*mock_mpd_builder, AddAdaptationSet(_)) @@ -858,7 +871,7 @@ TEST_P(DashIopMpdNotifierTest, SplitAdaptationSetsByLanguageAndCodec) { .WillOnce(Return(representation4.get())); uint32_t unused_container_id; - SetMpdBuilder(¬ifier, mock_mpd_builder.Pass()); + SetMpdBuilder(¬ifier, std::move(mock_mpd_builder)); EXPECT_TRUE(notifier.NotifyNewContainer( ConvertToMediaInfo(kAudioContent1), &unused_container_id)); EXPECT_TRUE(notifier.NotifyNewContainer( diff --git a/packager/mpd/base/mock_mpd_builder.cc b/packager/mpd/base/mock_mpd_builder.cc index c53004f6bf..e229d00764 100644 --- a/packager/mpd/base/mock_mpd_builder.cc +++ b/packager/mpd/base/mock_mpd_builder.cc @@ -27,7 +27,7 @@ MockRepresentation::MockRepresentation(uint32_t representation_id) : Representation(MediaInfo(), kDefaultMpdOptions, representation_id, - scoped_ptr()) {} + std::unique_ptr()) {} MockRepresentation::~MockRepresentation() {} } // namespace shaka diff --git a/packager/mpd/base/mpd_builder.cc b/packager/mpd/base/mpd_builder.cc index c783482548..6caf5be2ae 100644 --- a/packager/mpd/base/mpd_builder.cc +++ b/packager/mpd/base/mpd_builder.cc @@ -12,13 +12,13 @@ #include #include #include +#include #include #include "packager/base/base64.h" #include "packager/base/bind.h" #include "packager/base/files/file_path.h" #include "packager/base/logging.h" -#include "packager/base/memory/scoped_ptr.h" #include "packager/base/strings/string_number_conversions.h" #include "packager/base/strings/stringprintf.h" #include "packager/base/synchronization/lock.h" @@ -411,7 +411,7 @@ void MpdBuilder::AddBaseUrl(const std::string& base_url) { } AdaptationSet* MpdBuilder::AddAdaptationSet(const std::string& lang) { - scoped_ptr adaptation_set( + std::unique_ptr adaptation_set( new AdaptationSet(adaptation_set_counter_.GetNext(), lang, mpd_options_, type_, &representation_counter_)); @@ -468,7 +468,7 @@ xmlDocPtr MpdBuilder::GenerateMpd() { adaptation_sets_.begin(); for (; adaptation_sets_it != adaptation_sets_.end(); ++adaptation_sets_it) { xml::scoped_xml_ptr child((*adaptation_sets_it)->GetXml()); - if (!child.get() || !period.AddChild(child.Pass())) + if (!child.get() || !period.AddChild(std::move(child))) return NULL; } @@ -694,10 +694,10 @@ Representation* AdaptationSet::AddRepresentation(const MediaInfo& media_info) { const uint32_t representation_id = representation_counter_->GetNext(); // Note that AdaptationSet outlive Representation, so this object // will die before AdaptationSet. - scoped_ptr listener( + std::unique_ptr listener( new RepresentationStateChangeListenerImpl(representation_id, this)); - scoped_ptr representation(new Representation( - media_info, mpd_options_, representation_id, listener.Pass())); + std::unique_ptr representation(new Representation( + media_info, mpd_options_, representation_id, std::move(listener))); if (!representation->Init()) return NULL; @@ -826,7 +826,7 @@ xml::scoped_xml_ptr AdaptationSet::GetXml() { if (suppress_representation_frame_rate) representation->SuppressOnce(Representation::kSuppressFrameRate); xml::scoped_xml_ptr child(representation->GetXml()); - if (!child || !adaptation_set.AddChild(child.Pass())) + if (!child || !adaptation_set.AddChild(std::move(child))) return xml::scoped_xml_ptr(); } @@ -1036,13 +1036,13 @@ Representation::Representation( const MediaInfo& media_info, const MpdOptions& mpd_options, uint32_t id, - scoped_ptr state_change_listener) + std::unique_ptr state_change_listener) : media_info_(media_info), id_(id), bandwidth_estimator_(BandwidthEstimator::kUseAllBlocks), mpd_options_(mpd_options), start_number_(1), - state_change_listener_(state_change_listener.Pass()), + state_change_listener_(std::move(state_change_listener)), output_suppression_flags_(0) {} Representation::~Representation() {} diff --git a/packager/mpd/base/mpd_builder.h b/packager/mpd/base/mpd_builder.h index c630ccdfc3..77c5287449 100644 --- a/packager/mpd/base/mpd_builder.h +++ b/packager/mpd/base/mpd_builder.h @@ -102,8 +102,8 @@ class MpdBuilder { // Inject a |clock| that returns the current time. /// This is for testing. - void InjectClockForTesting(scoped_ptr clock) { - clock_ = clock.Pass(); + void InjectClockForTesting(std::unique_ptr clock) { + clock_ = std::move(clock); } private: @@ -157,7 +157,7 @@ class MpdBuilder { // By default, this returns the current time. This can be injected for // testing. - scoped_ptr clock_; + std::unique_ptr clock_; DISALLOW_COPY_AND_ASSIGN(MpdBuilder); }; @@ -515,7 +515,7 @@ class Representation { const MediaInfo& media_info, const MpdOptions& mpd_options, uint32_t representation_id, - scoped_ptr state_change_listener); + std::unique_ptr state_change_listener); private: friend class AdaptationSet; @@ -567,7 +567,7 @@ class Representation { // If this is not null, then Representation is responsible for calling the // right methods at right timings. - scoped_ptr state_change_listener_; + std::unique_ptr state_change_listener_; // Bit vector for tracking witch attributes should not be output. int output_suppression_flags_; diff --git a/packager/mpd/base/mpd_builder_unittest.cc b/packager/mpd/base/mpd_builder_unittest.cc index 52f4195f5b..ddaf2b760e 100644 --- a/packager/mpd/base/mpd_builder_unittest.cc +++ b/packager/mpd/base/mpd_builder_unittest.cc @@ -136,31 +136,32 @@ class MpdBuilderTest : public ::testing::Test { // TODO(rkuroiwa): Once std::forward() is allowed by chromium style guide, use // variadic template and std::forward() so that we don't need to copy the // constructor signatures. - scoped_ptr CreateRepresentation( + std::unique_ptr CreateRepresentation( const MediaInfo& media_info, const MpdOptions& mpd_options, uint32_t representation_id, - scoped_ptr state_change_listener) { - return make_scoped_ptr(new Representation(media_info, mpd_options, - representation_id, - state_change_listener.Pass())); + std::unique_ptr + state_change_listener) { + return std::unique_ptr( + new Representation(media_info, mpd_options, representation_id, + std::move(state_change_listener))); } - scoped_ptr CreateAdaptationSet( + std::unique_ptr CreateAdaptationSet( uint32_t adaptation_set_id, const std::string& lang, const MpdOptions& mpd_options, MpdBuilder::MpdType mpd_type, base::AtomicSequenceNumber* representation_counter) { - return make_scoped_ptr(new AdaptationSet(adaptation_set_id, lang, - mpd_options, mpd_type, - representation_counter)); + return std::unique_ptr( + new AdaptationSet(adaptation_set_id, lang, mpd_options, mpd_type, + representation_counter)); } // Helper function to return an empty listener for tests that don't need // it. - scoped_ptr NoListener() { - return scoped_ptr(); + std::unique_ptr NoListener() { + return std::unique_ptr(); } MpdBuilder mpd_; @@ -203,7 +204,7 @@ class DynamicMpdBuilderTest : public MpdBuilderTest { 24, // second. 0 }; // millisecond. ASSERT_TRUE(test_time.HasValidValues()); - mpd_.InjectClockForTesting(scoped_ptr( + mpd_.InjectClockForTesting(std::unique_ptr( new TestClock(base::Time::FromUTCExploded(test_time)))); } @@ -613,13 +614,13 @@ TEST_F(CommonMpdBuilderTest, const uint64_t kStartTime = 199238u; const uint64_t kDuration = 98u; - scoped_ptr listener( + std::unique_ptr listener( new MockRepresentationStateChangeListener()); EXPECT_CALL(*listener, OnNewSegmentForRepresentation(kStartTime, kDuration)); - auto representation = CreateRepresentation(ConvertToMediaInfo(kTestMediaInfo), - MpdOptions(), kAnyRepresentationId, - listener.Pass()); + auto representation = + CreateRepresentation(ConvertToMediaInfo(kTestMediaInfo), MpdOptions(), + kAnyRepresentationId, std::move(listener)); EXPECT_TRUE(representation->Init()); representation->AddNewSegment(kStartTime, kDuration, 10 /* any size */); @@ -644,13 +645,13 @@ TEST_F(CommonMpdBuilderTest, const uint64_t kTimeScale = 1000u; const uint64_t kFrameDuration = 33u; - scoped_ptr listener( + std::unique_ptr listener( new MockRepresentationStateChangeListener()); EXPECT_CALL(*listener, OnSetFrameRateForRepresentation(kFrameDuration, kTimeScale)); auto representation = CreateRepresentation(ConvertToMediaInfo(kTestMediaInfo), MpdOptions(), - kAnyRepresentationId, listener.Pass()); + kAnyRepresentationId, std::move(listener)); EXPECT_TRUE(representation->Init()); representation->SetSampleDuration(kFrameDuration); @@ -747,7 +748,7 @@ TEST_F(CommonMpdBuilderTest, TtmlMp4MimeType) { auto representation = CreateRepresentation(ConvertToMediaInfo(kTtmlMp4MediaInfo), MpdOptions(), - kAnyRepresentationId, NoListener()).Pass(); + kAnyRepresentationId, NoListener()); EXPECT_TRUE(representation->Init()); EXPECT_NO_FATAL_FAILURE(ExpectAttributeEqString( "mimeType", "application/mp4", representation->GetXml().get())); @@ -762,7 +763,7 @@ TEST_F(CommonMpdBuilderTest, WebVttMimeType) { auto representation = CreateRepresentation(ConvertToMediaInfo(kWebVttMediaInfo), MpdOptions(), - kAnyRepresentationId, NoListener()).Pass(); + kAnyRepresentationId, NoListener()); EXPECT_TRUE(representation->Init()); EXPECT_NO_FATAL_FAILURE(ExpectAttributeEqString( "mimeType", "text/vtt", representation->GetXml().get())); @@ -1660,7 +1661,7 @@ TEST_F(CommonMpdBuilderTest, SetSampleDuration) { ExpectAttributeNotSet("frameRate", adaptation_set_xml.get())); representation->SetSampleDuration(2u); - adaptation_set_xml = adaptation_set->GetXml().Pass(); + adaptation_set_xml = adaptation_set->GetXml(); EXPECT_NO_FATAL_FAILURE( ExpectAttributeEqString("frameRate", "3000/2", adaptation_set_xml.get())); } diff --git a/packager/mpd/base/mpd_notifier_util.cc b/packager/mpd/base/mpd_notifier_util.cc index eb898cc166..96ff81b6ac 100644 --- a/packager/mpd/base/mpd_notifier_util.cc +++ b/packager/mpd/base/mpd_notifier_util.cc @@ -8,8 +8,8 @@ #include "packager/base/strings/string_number_conversions.h" #include "packager/base/strings/string_util.h" -#include "packager/media/file/file_closer.h" #include "packager/media/file/file.h" +#include "packager/media/file/file_closer.h" #include "packager/mpd/base/mpd_utils.h" namespace shaka { @@ -26,7 +26,7 @@ bool WriteMpdToFile(const std::string& output_path, MpdBuilder* mpd_builder) { return false; } - scoped_ptr file(File::Open(output_path.c_str(), "w")); + std::unique_ptr file(File::Open(output_path.c_str(), "w")); if (!file) { LOG(ERROR) << "Failed to open file for writing: " << output_path; return false; diff --git a/packager/mpd/base/simple_mpd_notifier.h b/packager/mpd/base/simple_mpd_notifier.h index 3e8fa201b2..32bbcc680f 100644 --- a/packager/mpd/base/simple_mpd_notifier.h +++ b/packager/mpd/base/simple_mpd_notifier.h @@ -8,11 +8,11 @@ #define MPD_BASE_SIMPLE_MPD_NOTIFIER_H_ #include +#include #include #include #include "packager/base/gtest_prod_util.h" -#include "packager/base/memory/scoped_ptr.h" #include "packager/base/synchronization/lock.h" #include "packager/mpd/base/mpd_notifier.h" #include "packager/mpd/base/mpd_notifier_util.h" @@ -65,13 +65,13 @@ class SimpleMpdNotifier : public MpdNotifier { } // Testing only method. Sets mpd_builder_. - void SetMpdBuilderForTesting(scoped_ptr mpd_builder) { - mpd_builder_ = mpd_builder.Pass(); + void SetMpdBuilderForTesting(std::unique_ptr mpd_builder) { + mpd_builder_ = std::move(mpd_builder); } // MPD output path. std::string output_path_; - scoped_ptr mpd_builder_; + std::unique_ptr mpd_builder_; base::Lock lock_; typedef std::map AdaptationSetMap; diff --git a/packager/mpd/base/simple_mpd_notifier_unittest.cc b/packager/mpd/base/simple_mpd_notifier_unittest.cc index 4225e3dfb3..0847537cf6 100644 --- a/packager/mpd/base/simple_mpd_notifier_unittest.cc +++ b/packager/mpd/base/simple_mpd_notifier_unittest.cc @@ -51,12 +51,14 @@ class SimpleMpdNotifierTest base::DeleteFile(temp_file_path_, false /* non recursive, just 1 file */); } - scoped_ptr StaticMpdBuilderMock() { - return make_scoped_ptr(new MockMpdBuilder(MpdBuilder::kStatic)); + std::unique_ptr StaticMpdBuilderMock() { + return std::unique_ptr( + new MockMpdBuilder(MpdBuilder::kStatic)); } - scoped_ptr DynamicMpdBuilderMock() { - return make_scoped_ptr(new MockMpdBuilder(MpdBuilder::kDynamic)); + std::unique_ptr DynamicMpdBuilderMock() { + return std::unique_ptr( + new MockMpdBuilder(MpdBuilder::kDynamic)); } MpdBuilder::MpdType GetMpdBuilderType(const SimpleMpdNotifier& notifier) { @@ -64,8 +66,8 @@ class SimpleMpdNotifierTest } void SetMpdBuilder(SimpleMpdNotifier* notifier, - scoped_ptr mpd_builder) { - notifier->SetMpdBuilderForTesting(mpd_builder.Pass()); + std::unique_ptr mpd_builder) { + notifier->SetMpdBuilderForTesting(std::move(mpd_builder)); } // Use output_path_ for specifying the MPD output path so that @@ -75,7 +77,7 @@ class SimpleMpdNotifierTest const std::vector empty_base_urls_; // Default AdaptationSet mock. - scoped_ptr default_mock_adaptation_set_; + std::unique_ptr default_mock_adaptation_set_; private: base::FilePath temp_file_path_; @@ -102,8 +104,9 @@ TEST_P(SimpleMpdNotifierTest, NotifyNewContainer) { const uint32_t kRepresentationId = 1u; const MpdBuilder::MpdType mpd_type = GetParam(); - scoped_ptr mock_mpd_builder(new MockMpdBuilder(mpd_type)); - scoped_ptr mock_representation( + std::unique_ptr mock_mpd_builder( + new MockMpdBuilder(mpd_type)); + std::unique_ptr mock_representation( new MockRepresentation(kRepresentationId)); EXPECT_CALL(*mock_mpd_builder, AddAdaptationSet(_)) @@ -112,11 +115,11 @@ TEST_P(SimpleMpdNotifierTest, NotifyNewContainer) { .WillOnce(Return(mock_representation.get())); // This is for the Flush() below but adding expectation here because the next - // lines Pass() the pointer. + // std::move(lines) the pointer. EXPECT_CALL(*mock_mpd_builder, ToString(_)).WillOnce(Return(true)); uint32_t unused_container_id; - SetMpdBuilder(¬ifier, mock_mpd_builder.Pass()); + SetMpdBuilder(¬ifier, std::move(mock_mpd_builder)); EXPECT_TRUE(notifier.NotifyNewContainer(ConvertToMediaInfo(kValidMediaInfo), &unused_container_id)); EXPECT_TRUE(notifier.Flush()); @@ -128,8 +131,8 @@ TEST_F(SimpleMpdNotifierTest, LiveNotifySampleDuration) { output_path_); const uint32_t kRepresentationId = 8u; - scoped_ptr mock_mpd_builder(DynamicMpdBuilderMock()); - scoped_ptr mock_representation( + std::unique_ptr mock_mpd_builder(DynamicMpdBuilderMock()); + std::unique_ptr mock_representation( new MockRepresentation(kRepresentationId)); EXPECT_CALL(*mock_mpd_builder, AddAdaptationSet(_)) @@ -138,7 +141,7 @@ TEST_F(SimpleMpdNotifierTest, LiveNotifySampleDuration) { .WillOnce(Return(mock_representation.get())); uint32_t container_id; - SetMpdBuilder(¬ifier, mock_mpd_builder.Pass()); + SetMpdBuilder(¬ifier, std::move(mock_mpd_builder)); EXPECT_TRUE(notifier.NotifyNewContainer(ConvertToMediaInfo(kValidMediaInfo), &container_id)); EXPECT_EQ(kRepresentationId, container_id); @@ -159,8 +162,8 @@ TEST_F(SimpleMpdNotifierTest, OnDemandNotifySampleDuration) { empty_base_urls_, output_path_); const uint32_t kRepresentationId = 14u; - scoped_ptr mock_mpd_builder(StaticMpdBuilderMock()); - scoped_ptr mock_representation( + std::unique_ptr mock_mpd_builder(StaticMpdBuilderMock()); + std::unique_ptr mock_representation( new MockRepresentation(kRepresentationId)); EXPECT_CALL(*mock_mpd_builder, AddAdaptationSet(_)) @@ -169,7 +172,7 @@ TEST_F(SimpleMpdNotifierTest, OnDemandNotifySampleDuration) { .WillOnce(Return(mock_representation.get())); uint32_t container_id; - SetMpdBuilder(¬ifier, mock_mpd_builder.Pass()); + SetMpdBuilder(¬ifier, std::move(mock_mpd_builder)); EXPECT_TRUE(notifier.NotifyNewContainer(ConvertToMediaInfo(kValidMediaInfo), &container_id)); EXPECT_EQ(kRepresentationId, container_id); @@ -202,8 +205,8 @@ TEST_F(SimpleMpdNotifierTest, LiveNotifyNewSegment) { output_path_); const uint32_t kRepresentationId = 447834u; - scoped_ptr mock_mpd_builder(DynamicMpdBuilderMock()); - scoped_ptr mock_representation( + std::unique_ptr mock_mpd_builder(DynamicMpdBuilderMock()); + std::unique_ptr mock_representation( new MockRepresentation(kRepresentationId)); EXPECT_CALL(*mock_mpd_builder, AddAdaptationSet(_)) @@ -212,7 +215,7 @@ TEST_F(SimpleMpdNotifierTest, LiveNotifyNewSegment) { .WillOnce(Return(mock_representation.get())); uint32_t container_id; - SetMpdBuilder(¬ifier, mock_mpd_builder.Pass()); + SetMpdBuilder(¬ifier, std::move(mock_mpd_builder)); EXPECT_TRUE(notifier.NotifyNewContainer(ConvertToMediaInfo(kValidMediaInfo), &container_id)); EXPECT_EQ(kRepresentationId, container_id); @@ -233,8 +236,8 @@ TEST_F(SimpleMpdNotifierTest, AddContentProtectionElement) { empty_base_urls_, output_path_); const uint32_t kRepresentationId = 0u; - scoped_ptr mock_mpd_builder(StaticMpdBuilderMock()); - scoped_ptr mock_representation( + std::unique_ptr mock_mpd_builder(StaticMpdBuilderMock()); + std::unique_ptr mock_representation( new MockRepresentation(kRepresentationId)); EXPECT_CALL(*mock_mpd_builder, AddAdaptationSet(_)) @@ -243,7 +246,7 @@ TEST_F(SimpleMpdNotifierTest, AddContentProtectionElement) { .WillOnce(Return(mock_representation.get())); uint32_t container_id; - SetMpdBuilder(¬ifier, mock_mpd_builder.Pass()); + SetMpdBuilder(¬ifier, std::move(mock_mpd_builder)); EXPECT_TRUE(notifier.NotifyNewContainer(ConvertToMediaInfo(kValidMediaInfo), &container_id)); EXPECT_EQ(kRepresentationId, container_id); @@ -276,8 +279,8 @@ TEST_P(SimpleMpdNotifierTest, UpdateEncryption) { SimpleMpdNotifier notifier(kLiveProfile, empty_mpd_option_, empty_base_urls_, output_path_); const uint32_t kRepresentationId = 447834u; - scoped_ptr mock_mpd_builder(DynamicMpdBuilderMock()); - scoped_ptr mock_representation( + std::unique_ptr mock_mpd_builder(DynamicMpdBuilderMock()); + std::unique_ptr mock_representation( new MockRepresentation(kRepresentationId)); EXPECT_CALL(*mock_mpd_builder, AddAdaptationSet(_)) @@ -286,7 +289,7 @@ TEST_P(SimpleMpdNotifierTest, UpdateEncryption) { .WillOnce(Return(mock_representation.get())); uint32_t container_id; - SetMpdBuilder(¬ifier, mock_mpd_builder.Pass()); + SetMpdBuilder(¬ifier, std::move(mock_mpd_builder)); EXPECT_TRUE(notifier.NotifyNewContainer(ConvertToMediaInfo(kProtectedContent), &container_id)); @@ -364,16 +367,20 @@ TEST_P(SimpleMpdNotifierTest, SplitAdaptationSetsByLanguageAndCodec) { SimpleMpdNotifier notifier(kOnDemandProfile, empty_mpd_option_, empty_base_urls_, output_path_); - scoped_ptr mock_mpd_builder(StaticMpdBuilderMock()); + std::unique_ptr mock_mpd_builder(StaticMpdBuilderMock()); - scoped_ptr adaptation_set1(new MockAdaptationSet(1)); - scoped_ptr adaptation_set2(new MockAdaptationSet(2)); - scoped_ptr adaptation_set3(new MockAdaptationSet(3)); + std::unique_ptr adaptation_set1(new MockAdaptationSet(1)); + std::unique_ptr adaptation_set2(new MockAdaptationSet(2)); + std::unique_ptr adaptation_set3(new MockAdaptationSet(3)); - scoped_ptr representation1(new MockRepresentation(1)); - scoped_ptr representation2(new MockRepresentation(2)); - scoped_ptr representation3(new MockRepresentation(3)); - scoped_ptr representation4(new MockRepresentation(4)); + std::unique_ptr representation1( + new MockRepresentation(1)); + std::unique_ptr representation2( + new MockRepresentation(2)); + std::unique_ptr representation3( + new MockRepresentation(3)); + std::unique_ptr representation4( + new MockRepresentation(4)); // We expect three AdaptationSets. EXPECT_CALL(*mock_mpd_builder, AddAdaptationSet(_)) @@ -392,7 +399,7 @@ TEST_P(SimpleMpdNotifierTest, SplitAdaptationSetsByLanguageAndCodec) { .WillOnce(Return(representation4.get())); uint32_t unused_container_id; - SetMpdBuilder(¬ifier, mock_mpd_builder.Pass()); + SetMpdBuilder(¬ifier, std::move(mock_mpd_builder)); EXPECT_TRUE(notifier.NotifyNewContainer( ConvertToMediaInfo(kAudioContent1), &unused_container_id)); EXPECT_TRUE(notifier.NotifyNewContainer( diff --git a/packager/mpd/base/xml/scoped_xml_ptr.h b/packager/mpd/base/xml/scoped_xml_ptr.h index 6d20d7d7e3..a3cd875d65 100644 --- a/packager/mpd/base/xml/scoped_xml_ptr.h +++ b/packager/mpd/base/xml/scoped_xml_ptr.h @@ -4,7 +4,7 @@ // license that can be found in the LICENSE file or at // https://developers.google.com/open-source/licenses/bsd // -// scoped_ptr alias for libxml2 objects. Deleters for the objects are also +// unique_ptr alias for libxml2 objects. Deleters for the objects are also // defined in this file. #ifndef MPD_BASE_XML_SCOPED_XML_PTR_H_ @@ -13,7 +13,7 @@ #include #include -#include "packager/base/memory/scoped_ptr.h" +#include namespace shaka { namespace xml { @@ -21,7 +21,7 @@ namespace xml { /// Deleter functor for deleting libxml2 pointers. This is used with /// ScopedXmlPtr. struct XmlDeleter { - // Called by scoped_ptr. http://goo.gl/YaLbcS + // Called by std::unique_ptr. inline void operator()(xmlSchemaParserCtxtPtr ptr) const { xmlSchemaFreeParserCtxt(ptr); } @@ -35,8 +35,9 @@ struct XmlDeleter { }; template -using scoped_xml_ptr = scoped_ptr; +using scoped_xml_ptr = std::unique_ptr; } // namespace xml } // namespace shaka + #endif // MPD_BASE_XML_SCOPED_XML_PTR_H_ diff --git a/packager/mpd/base/xml/xml_node.cc b/packager/mpd/base/xml/xml_node.cc index 6d7461338c..e0ed414384 100644 --- a/packager/mpd/base/xml/xml_node.cc +++ b/packager/mpd/base/xml/xml_node.cc @@ -12,8 +12,8 @@ #include "packager/base/logging.h" #include "packager/base/macros.h" #include "packager/base/stl_util.h" -#include "packager/base/sys_byteorder.h" #include "packager/base/strings/string_number_conversions.h" +#include "packager/base/sys_byteorder.h" #include "packager/mpd/base/media_info.pb.h" #include "packager/mpd/base/segment_info.h" @@ -137,7 +137,7 @@ void XmlNode::SetContent(const std::string& content) { scoped_xml_ptr XmlNode::PassScopedPtr() { DVLOG(2) << "Passing node_."; DCHECK(node_); - return node_.Pass(); + return std::move(node_); } xmlNodePtr XmlNode::Release() { diff --git a/packager/mpd/base/xml/xml_node.h b/packager/mpd/base/xml/xml_node.h index 17d8729b04..6ed186487f 100644 --- a/packager/mpd/base/xml/xml_node.h +++ b/packager/mpd/base/xml/xml_node.h @@ -15,6 +15,7 @@ #include +#include "packager/base/macros.h" #include "packager/mpd/base/content_protection_element.h" #include "packager/mpd/base/media_info.pb.h" #include "packager/mpd/base/xml/scoped_xml_ptr.h" diff --git a/packager/mpd/base/xml/xml_node_unittest.cc b/packager/mpd/base/xml/xml_node_unittest.cc index 190a339716..7528acbbbf 100644 --- a/packager/mpd/base/xml/xml_node_unittest.cc +++ b/packager/mpd/base/xml/xml_node_unittest.cc @@ -47,7 +47,7 @@ std::string GetDocAsFlatString(xmlDocPtr doc) { scoped_xml_ptr MakeDoc(scoped_xml_ptr node) { xml::scoped_xml_ptr doc(xmlNewDoc(BAD_CAST "")); xmlDocSetRootElement(doc.get(), node.release()); - return doc.Pass(); + return doc; } } // namespace diff --git a/packager/mpd/test/xml_compare.cc b/packager/mpd/test/xml_compare.cc index fb6670d9ce..9f34bbfa24 100644 --- a/packager/mpd/test/xml_compare.cc +++ b/packager/mpd/test/xml_compare.cc @@ -16,9 +16,8 @@ namespace shaka { namespace { xml::scoped_xml_ptr GetDocFromString(const std::string& xml_str) { - xml::scoped_xml_ptr schema_as_doc(xmlReadMemory( - xml_str.data(), xml_str.size(), NULL, NULL, 0)); - return schema_as_doc.Pass(); + return xml::scoped_xml_ptr( + xmlReadMemory(xml_str.data(), xml_str.size(), NULL, NULL, 0)); } // Make a map from attributes of the node. diff --git a/packager/mpd/util/mpd_writer.cc b/packager/mpd/util/mpd_writer.cc index baf3513d07..51596b4920 100644 --- a/packager/mpd/util/mpd_writer.cc +++ b/packager/mpd/util/mpd_writer.cc @@ -35,11 +35,11 @@ class DashIopMpdNotifierFactory : public MpdNotifierFactory { DashIopMpdNotifierFactory() {} ~DashIopMpdNotifierFactory() override {} - scoped_ptr Create(DashProfile dash_profile, - const MpdOptions& mpd_options, - const std::vector& base_urls, - const std::string& output_path) override { - return scoped_ptr(new DashIopMpdNotifier( + std::unique_ptr Create(DashProfile dash_profile, + const MpdOptions& mpd_options, + const std::vector& base_urls, + const std::string& output_path) override { + return std::unique_ptr(new DashIopMpdNotifier( dash_profile, mpd_options, base_urls, output_path)); } }; @@ -50,11 +50,11 @@ class SimpleMpdNotifierFactory : public MpdNotifierFactory { SimpleMpdNotifierFactory() {} ~SimpleMpdNotifierFactory() override {} - scoped_ptr Create(DashProfile dash_profile, - const MpdOptions& mpd_options, - const std::vector& base_urls, - const std::string& output_path) override { - return scoped_ptr(new SimpleMpdNotifier( + std::unique_ptr Create(DashProfile dash_profile, + const MpdOptions& mpd_options, + const std::vector& base_urls, + const std::string& output_path) override { + return std::unique_ptr(new SimpleMpdNotifier( dash_profile, mpd_options, base_urls, output_path)); } }; @@ -96,7 +96,7 @@ void MpdWriter::AddBaseUrl(const std::string& base_url) { bool MpdWriter::WriteMpdToFile(const char* file_name) { CHECK(file_name); - scoped_ptr notifier = notifier_factory_->Create( + std::unique_ptr notifier = notifier_factory_->Create( kOnDemandProfile, MpdOptions(), base_urls_, file_name); if (!notifier->Init()) { LOG(ERROR) << "failed to initialize MpdNotifier."; @@ -122,8 +122,8 @@ bool MpdWriter::WriteMpdToFile(const char* file_name) { } void MpdWriter::SetMpdNotifierFactoryForTest( - scoped_ptr factory) { - notifier_factory_ = factory.Pass(); + std::unique_ptr factory) { + notifier_factory_ = std::move(factory); } } // namespace shaka diff --git a/packager/mpd/util/mpd_writer.h b/packager/mpd/util/mpd_writer.h index d4cad875b7..6b30b0fea5 100644 --- a/packager/mpd/util/mpd_writer.h +++ b/packager/mpd/util/mpd_writer.h @@ -10,11 +10,11 @@ #define MPD_UTIL_MPD_WRITER_H_ #include +#include #include #include #include "packager/base/macros.h" -#include "packager/base/memory/scoped_ptr.h" #include "packager/mpd/base/mpd_notifier.h" #include "packager/mpd/base/mpd_options.h" @@ -34,7 +34,7 @@ class MpdNotifierFactory { MpdNotifierFactory() {} virtual ~MpdNotifierFactory() {} - virtual scoped_ptr Create( + virtual std::unique_ptr Create( DashProfile dash_profile, const MpdOptions& mpd_options, const std::vector& base_urls, @@ -77,12 +77,13 @@ class MpdWriter { private: friend class MpdWriterTest; - void SetMpdNotifierFactoryForTest(scoped_ptr factory); + void SetMpdNotifierFactoryForTest( + std::unique_ptr factory); std::list media_infos_; std::vector base_urls_; - scoped_ptr notifier_factory_; + std::unique_ptr notifier_factory_; DISALLOW_COPY_AND_ASSIGN(MpdWriter); }; diff --git a/packager/mpd/util/mpd_writer_unittest.cc b/packager/mpd/util/mpd_writer_unittest.cc index a0ad5f3eef..c3f5d490bc 100644 --- a/packager/mpd/util/mpd_writer_unittest.cc +++ b/packager/mpd/util/mpd_writer_unittest.cc @@ -30,16 +30,16 @@ class TestMpdNotifierFactory : public MpdNotifierFactory { // So sad that this method cannot be mocked (gmock errors at compile time). // Also (probably) this version of gmock does not support returning - // scoped_ptr. + // std::unique_ptr. // For now we only need to return MockMpdNotifier() with these set of // expectations for all the tests. - scoped_ptr Create(DashProfile dash_profile, - const MpdOptions& mpd_options, - const std::vector& base_urls, - const std::string& output_path) override { + std::unique_ptr Create(DashProfile dash_profile, + const MpdOptions& mpd_options, + const std::vector& base_urls, + const std::string& output_path) override { EXPECT_EQ(expected_base_urls_, base_urls); - scoped_ptr mock_notifier( + std::unique_ptr mock_notifier( new MockMpdNotifier(kOnDemandProfile)); EXPECT_CALL(*mock_notifier, Init()).WillOnce(Return(true)); @@ -47,7 +47,7 @@ class TestMpdNotifierFactory : public MpdNotifierFactory { .Times(2) .WillRepeatedly(Return(true)); EXPECT_CALL(*mock_notifier, Flush()).WillOnce(Return(true)); - return mock_notifier.Pass(); + return std::move(mock_notifier); } void SetExpectedBaseUrls(const std::vector& base_urls) { @@ -68,10 +68,10 @@ class MpdWriterTest : public ::testing::Test { } void SetMpdNotifierFactoryForTest() { - mpd_writer_.SetMpdNotifierFactoryForTest(notifier_factory_.Pass()); + mpd_writer_.SetMpdNotifierFactoryForTest(std::move(notifier_factory_)); } - scoped_ptr notifier_factory_; + std::unique_ptr notifier_factory_; MpdWriter mpd_writer_; };