Replace scoped_ptr with std::unique_ptr

Change-Id: I1ed18bf876b6154d08a1f7913aa7e76c525451f9
This commit is contained in:
Kongqun Yang 2016-08-17 10:41:40 -07:00
parent d501b457d0
commit 644629c616
160 changed files with 948 additions and 900 deletions

View File

@ -8,10 +8,10 @@
#include <openssl/thread.h>
#include <memory>
#include <vector>
#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<base::Lock[]> global_locks;
std::unique_ptr<base::Lock[]> global_locks;
void LockFunction(int mode, int n, const char* file, int line) {
VLOG(2) << "CryptoLock @ " << file << ":" << line;

View File

@ -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> demuxer)
: SimpleThread("RemuxJob"),
demuxer_(demuxer.Pass()) {}
RemuxJob(std::unique_ptr<Demuxer> demuxer)
: SimpleThread("RemuxJob"), demuxer_(std::move(demuxer)) {}
~RemuxJob() override {
STLDeleteElements(&muxers_);
}
void AddMuxer(scoped_ptr<Muxer> mux) {
void AddMuxer(std::unique_ptr<Muxer> mux) {
muxers_.push_back(mux.release());
}
@ -185,7 +184,7 @@ class RemuxJob : public base::SimpleThread {
status_ = demuxer_->Run();
}
scoped_ptr<Demuxer> demuxer_;
std::unique_ptr<Demuxer> demuxer_;
std::vector<Muxer*> muxers_;
Status status_;
@ -231,15 +230,15 @@ bool StreamInfoToTextMediaInfo(const StreamDescriptor& stream_descriptor,
return true;
}
scoped_ptr<Muxer> CreateOutputMuxer(const MuxerOptions& options,
std::unique_ptr<Muxer> CreateOutputMuxer(const MuxerOptions& options,
MediaContainerName container) {
if (container == CONTAINER_WEBM) {
return scoped_ptr<Muxer>(new webm::WebMMuxer(options));
return std::unique_ptr<Muxer>(new webm::WebMMuxer(options));
} else if (container == CONTAINER_MPEG2TS) {
return scoped_ptr<Muxer>(new mp2t::TsMuxer(options));
return std::unique_ptr<Muxer>(new mp2t::TsMuxer(options));
} else {
DCHECK_EQ(container, CONTAINER_MOV);
return scoped_ptr<Muxer>(new mp4::MP4Muxer(options));
return std::unique_ptr<Muxer>(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> demuxer(new Demuxer(stream_iter->input));
std::unique_ptr<Demuxer> demuxer(new Demuxer(stream_iter->input));
if (FLAGS_enable_widevine_decryption ||
FLAGS_enable_fixed_key_decryption) {
scoped_ptr<KeySource> key_source(CreateDecryptionKeySource());
std::unique_ptr<KeySource> 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> muxer(
std::unique_ptr<Muxer> 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<MuxerListener> muxer_listener;
std::unique_ptr<MuxerListener> 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<VodMediaInfoDumpMuxerListener>
std::unique_ptr<VodMediaInfoDumpMuxerListener>
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<MpdNotifyMuxerListener> mpd_notify_muxer_listener(
std::unique_ptr<MpdNotifyMuxerListener> 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<KeySource> encryption_key_source;
std::unique_ptr<KeySource> 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<MpdNotifier> mpd_notifier;
std::unique_ptr<MpdNotifier> 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::HlsNotifier> hls_notifier;
std::unique_ptr<hls::HlsNotifier> hls_notifier;
if (!FLAGS_hls_master_playlist_output.empty()) {
base::FilePath master_playlist_path(
base::FilePath::FromUTF8Unsafe(FLAGS_hls_master_playlist_output));

View File

@ -42,8 +42,8 @@ void DumpStreamInfo(const std::vector<MediaStream*>& streams) {
printf("Stream [%zu] %s\n", i, streams[i]->info()->ToString().c_str());
}
scoped_ptr<RequestSigner> CreateSigner() {
scoped_ptr<RequestSigner> signer;
std::unique_ptr<RequestSigner> CreateSigner() {
std::unique_ptr<RequestSigner> signer;
if (!FLAGS_aes_signing_key.empty()) {
signer.reset(AesRequestSigner::CreateSigner(
@ -52,7 +52,7 @@ scoped_ptr<RequestSigner> CreateSigner() {
LOG(ERROR) << "Cannot create an AES signer object from '"
<< FLAGS_aes_signing_key << "':'" << FLAGS_aes_signing_iv
<< "'.";
return scoped_ptr<RequestSigner>();
return std::unique_ptr<RequestSigner>();
}
} else if (!FLAGS_rsa_signing_key_path.empty()) {
std::string rsa_private_key;
@ -60,69 +60,69 @@ scoped_ptr<RequestSigner> CreateSigner() {
&rsa_private_key)) {
LOG(ERROR) << "Failed to read from '" << FLAGS_rsa_signing_key_path
<< "'.";
return scoped_ptr<RequestSigner>();
return std::unique_ptr<RequestSigner>();
}
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<RequestSigner>();
return std::unique_ptr<RequestSigner>();
}
}
return signer.Pass();
return signer;
}
scoped_ptr<KeySource> CreateEncryptionKeySource() {
scoped_ptr<KeySource> encryption_key_source;
std::unique_ptr<KeySource> CreateEncryptionKeySource() {
std::unique_ptr<KeySource> encryption_key_source;
if (FLAGS_enable_widevine_encryption) {
scoped_ptr<WidevineKeySource> widevine_key_source(
std::unique_ptr<WidevineKeySource> widevine_key_source(
new WidevineKeySource(FLAGS_key_server_url, FLAGS_include_common_pssh));
if (!FLAGS_signer.empty()) {
scoped_ptr<RequestSigner> request_signer(CreateSigner());
std::unique_ptr<RequestSigner> request_signer(CreateSigner());
if (!request_signer)
return scoped_ptr<KeySource>();
widevine_key_source->set_signer(request_signer.Pass());
return std::unique_ptr<KeySource>();
widevine_key_source->set_signer(std::move(request_signer));
}
std::vector<uint8_t> content_id;
if (!base::HexStringToBytes(FLAGS_content_id, &content_id)) {
LOG(ERROR) << "Invalid content_id hex string specified.";
return scoped_ptr<KeySource>();
return std::unique_ptr<KeySource>();
}
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<KeySource>();
return std::unique_ptr<KeySource>();
}
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<KeySource> CreateDecryptionKeySource() {
scoped_ptr<KeySource> decryption_key_source;
std::unique_ptr<KeySource> CreateDecryptionKeySource() {
std::unique_ptr<KeySource> decryption_key_source;
if (FLAGS_enable_widevine_decryption) {
scoped_ptr<WidevineKeySource> widevine_key_source(
std::unique_ptr<WidevineKeySource> widevine_key_source(
new WidevineKeySource(FLAGS_key_server_url, FLAGS_include_common_pssh));
if (!FLAGS_signer.empty()) {
scoped_ptr<RequestSigner> request_signer(CreateSigner());
std::unique_ptr<RequestSigner> request_signer(CreateSigner());
if (!request_signer)
return scoped_ptr<KeySource>();
widevine_key_source->set_signer(request_signer.Pass());
return std::unique_ptr<KeySource>();
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() {

View File

@ -10,11 +10,10 @@
#define APP_PACKAGER_UTIL_H_
#include <gflags/gflags.h>
#include <memory>
#include <string>
#include <vector>
#include "packager/base/memory/scoped_ptr.h"
DECLARE_bool(dump_stream_info);
namespace shaka {
@ -33,15 +32,15 @@ void DumpStreamInfo(const std::vector<MediaStream*>& 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<KeySource> CreateEncryptionKeySource();
std::unique_ptr<KeySource> 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<KeySource> CreateDecryptionKeySource();
/// @return A std::unique_ptr containing a new KeySource, or nullptr if
/// decryption is not required.
std::unique_ptr<KeySource> CreateDecryptionKeySource();
/// Set flags according to profile.
bool AssignFlagsFromProfile();

View File

@ -57,7 +57,7 @@ bool MasterPlaylist::WriteAllPlaylists(const std::string& base_url,
<< "Target duration was already set for " << file_path;
}
scoped_ptr<media::File, media::FileCloser> file(
std::unique_ptr<media::File, media::FileCloser> 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<media::File, media::FileCloser> file(
std::unique_ptr<media::File, media::FileCloser> file(
media::File::Open(file_path.c_str(), "w"));
if (!file) {
LOG(ERROR) << "Failed to open file " << file_path;

View File

@ -200,8 +200,7 @@ 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<decltype(entries_), std::list<HlsEntry*>>::value,
static_assert(std::is_same<decltype(entries_), std::list<HlsEntry*>>::value,
"This algorithm assumes std::list.");
if (entries_.empty())
return;

View File

@ -11,7 +11,6 @@
#include <string>
#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;

View File

@ -114,12 +114,12 @@ bool WidevinePsshToJson(const std::vector<uint8_t>& pssh_data,
MediaPlaylistFactory::~MediaPlaylistFactory() {}
scoped_ptr<MediaPlaylist> MediaPlaylistFactory::Create(
std::unique_ptr<MediaPlaylist> MediaPlaylistFactory::Create(
MediaPlaylist::MediaPlaylistType type,
const std::string& file_name,
const std::string& name,
const std::string& group_id) {
return scoped_ptr<MediaPlaylist>(
return std::unique_ptr<MediaPlaylist>(
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<MediaPlaylist> media_playlist =
std::unique_ptr<MediaPlaylist> 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;

View File

@ -8,12 +8,12 @@
#define PACKAGER_HLS_BASE_SIMPLE_HLS_NOTIFIER_H_
#include <map>
#include <memory>
#include <string>
#include <vector>
#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<MediaPlaylist> Create(
virtual std::unique_ptr<MediaPlaylist> 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<MediaPlaylistFactory> media_playlist_factory_;
scoped_ptr<MasterPlaylist> master_playlist_;
std::unique_ptr<MediaPlaylistFactory> media_playlist_factory_;
std::unique_ptr<MasterPlaylist> master_playlist_;
std::map<uint32_t, MediaPlaylist*> media_playlist_map_;
STLValueDeleter<decltype(media_playlist_map_)> media_playlist_map_deleter_;

View File

@ -45,11 +45,11 @@ class MockMediaPlaylistFactory : public MediaPlaylistFactory {
const std::string& name,
const std::string& group_id));
scoped_ptr<MediaPlaylist> Create(MediaPlaylist::MediaPlaylistType type,
std::unique_ptr<MediaPlaylist> Create(MediaPlaylist::MediaPlaylistType type,
const std::string& file_name,
const std::string& name,
const std::string& group_id) override {
return scoped_ptr<MediaPlaylist>(
return std::unique_ptr<MediaPlaylist>(
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<MediaPlaylistFactory> factory) {
notifier_.media_playlist_factory_ = factory.Pass();
void InjectMediaPlaylistFactory(
std::unique_ptr<MediaPlaylistFactory> factory) {
notifier_.media_playlist_factory_ = std::move(factory);
}
void InjectMediaPlaylistFactory(scoped_ptr<MediaPlaylistFactory> factory,
void InjectMediaPlaylistFactory(std::unique_ptr<MediaPlaylistFactory> factory,
SimpleHlsNotifier* notifier) {
notifier->media_playlist_factory_ = factory.Pass();
notifier->media_playlist_factory_ = std::move(factory);
}
void InjectMasterPlaylist(scoped_ptr<MasterPlaylist> playlist) {
notifier_.master_playlist_ = playlist.Pass();
void InjectMasterPlaylist(std::unique_ptr<MasterPlaylist> playlist) {
notifier_.master_playlist_ = std::move(playlist);
}
void InjectMasterPlaylist(scoped_ptr<MasterPlaylist> playlist,
void InjectMasterPlaylist(std::unique_ptr<MasterPlaylist> playlist,
SimpleHlsNotifier* notifier) {
notifier->master_playlist_ = playlist.Pass();
notifier->master_playlist_ = std::move(playlist);
}
const std::map<uint32_t, MediaPlaylist*>& GetMediaPlaylistMap() {
@ -105,9 +106,9 @@ class SimpleHlsNotifierTest : public ::testing::Test {
}
uint32_t SetupStream(MockMediaPlaylist* mock_media_playlist) {
scoped_ptr<MockMasterPlaylist> mock_master_playlist(
std::unique_ptr<MockMasterPlaylist> mock_master_playlist(
new MockMasterPlaylist());
scoped_ptr<MockMediaPlaylistFactory> factory(
std::unique_ptr<MockMediaPlaylistFactory> 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<MockMasterPlaylist> mock_master_playlist(new MockMasterPlaylist());
scoped_ptr<MockMediaPlaylistFactory> factory(new MockMediaPlaylistFactory());
std::unique_ptr<MockMasterPlaylist> mock_master_playlist(
new MockMasterPlaylist());
std::unique_ptr<MockMediaPlaylistFactory> 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<MockMasterPlaylist> mock_master_playlist(new MockMasterPlaylist());
scoped_ptr<MockMediaPlaylistFactory> factory(new MockMediaPlaylistFactory());
std::unique_ptr<MockMasterPlaylist> mock_master_playlist(
new MockMasterPlaylist());
std::unique_ptr<MockMediaPlaylistFactory> 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<MockMasterPlaylist> mock_master_playlist(new MockMasterPlaylist());
scoped_ptr<MockMediaPlaylistFactory> factory(new MockMediaPlaylistFactory());
std::unique_ptr<MockMasterPlaylist> mock_master_playlist(
new MockMasterPlaylist());
std::unique_ptr<MockMediaPlaylistFactory> 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<MockMasterPlaylist> mock_master_playlist(new MockMasterPlaylist());
scoped_ptr<MockMediaPlaylistFactory> factory(new MockMediaPlaylistFactory());
std::unique_ptr<MockMasterPlaylist> mock_master_playlist(
new MockMasterPlaylist());
std::unique_ptr<MockMediaPlaylistFactory> 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<MockMasterPlaylist> mock_master_playlist(new MockMasterPlaylist());
scoped_ptr<MockMediaPlaylistFactory> factory(new MockMediaPlaylistFactory());
std::unique_ptr<MockMasterPlaylist> mock_master_playlist(
new MockMasterPlaylist());
std::unique_ptr<MockMediaPlaylistFactory> 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<MockMasterPlaylist> mock_master_playlist(new MockMasterPlaylist());
std::unique_ptr<MockMasterPlaylist> mock_master_playlist(
new MockMasterPlaylist());
EXPECT_CALL(*mock_master_playlist,
WriteAllPlaylists(StrEq(kTestPrefix), StrEq(kAnyOutputDir)))
.WillOnce(Return(true));
scoped_ptr<MockMediaPlaylistFactory> factory(new MockMediaPlaylistFactory());
std::unique_ptr<MockMediaPlaylistFactory> factory(
new MockMediaPlaylistFactory());
InjectMasterPlaylist(mock_master_playlist.Pass());
InjectMasterPlaylist(std::move(mock_master_playlist));
EXPECT_TRUE(notifier_.Init());
EXPECT_TRUE(notifier_.Flush());
}

View File

@ -7,11 +7,11 @@
#ifndef PACKAGER_MEDIA_BASE_AES_CRYPTOR_H_
#define PACKAGER_MEDIA_BASE_AES_CRYPTOR_H_
#include <memory>
#include <string>
#include <vector>
#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> aes_key_;
std::unique_ptr<AES_KEY> aes_key_;
// Indicates whether a constant iv is used. Internal iv will be reset to
// |iv_| before calling Crypt if that is the case.

View File

@ -6,11 +6,12 @@
#include <gtest/gtest.h>
#include <memory>
#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<AesCbcEncryptor> encryptor_;
scoped_ptr<AesCbcDecryptor> decryptor_;
std::unique_ptr<AesCbcEncryptor> encryptor_;
std::unique_ptr<AesCbcDecryptor> decryptor_;
std::vector<uint8_t> key_;
std::vector<uint8_t> iv_;
};

View File

@ -13,7 +13,6 @@
#include <vector>
#include "packager/base/macros.h"
#include "packager/base/memory/scoped_ptr.h"
#include "packager/media/base/aes_cryptor.h"
namespace shaka {

View File

@ -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<AesCryptor> cryptor)
std::unique_ptr<AesCryptor> 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.

View File

@ -6,8 +6,9 @@
#include "packager/media/base/aes_cryptor.h"
#include <memory>
#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<AesCryptor> cryptor);
std::unique_ptr<AesCryptor> 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<AesCryptor> cryptor_;
std::unique_ptr<AesCryptor> cryptor_;
DISALLOW_COPY_AND_ASSIGN(AesPatternCryptor);
};

View File

@ -45,7 +45,7 @@ class AesPatternCryptorTest : public ::testing::Test {
kSkipByteBlock,
AesPatternCryptor::kEncryptIfCryptByteBlockRemaining,
AesCryptor::kDontUseConstantIv,
scoped_ptr<MockAesCryptor>(mock_cryptor_)) {}
std::unique_ptr<MockAesCryptor>(mock_cryptor_)) {}
protected:
MockAesCryptor* mock_cryptor_;
@ -146,7 +146,7 @@ TEST(AesPatternCryptorConstIvTest, UseConstantIv) {
kCryptByteBlock, kSkipByteBlock,
AesPatternCryptor::kEncryptIfCryptByteBlockRemaining,
AesPatternCryptor::kUseConstantIv,
scoped_ptr<MockAesCryptor>(mock_cryptor));
std::unique_ptr<MockAesCryptor>(mock_cryptor));
std::vector<uint8_t> iv(8, 'i');
// SetIv will be called twice:
@ -165,7 +165,7 @@ TEST(AesPatternCryptorConstIvTest, DontUseConstantIv) {
kCryptByteBlock, kSkipByteBlock,
AesPatternCryptor::kEncryptIfCryptByteBlockRemaining,
AesPatternCryptor::kDontUseConstantIv,
scoped_ptr<MockAesCryptor>(mock_cryptor));
std::unique_ptr<MockAesCryptor>(mock_cryptor));
std::vector<uint8_t> 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<MockAesCryptor>(mock_cryptor));
std::unique_ptr<MockAesCryptor>(mock_cryptor));
std::vector<uint8_t> 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<MockAesCryptor>(mock_cryptor));
std::unique_ptr<MockAesCryptor>(mock_cryptor));
std::vector<uint8_t> 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<MockAesCryptor>(mock_cryptor));
std::unique_ptr<MockAesCryptor>(mock_cryptor));
std::vector<uint8_t> iv(8, 'i');
// SetIv will be called only once by AesPatternCryptor::SetIv.

View File

@ -7,9 +7,9 @@
#include "packager/media/base/buffer_writer.h"
#include <limits>
#include <memory>
#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<BufferWriter> writer_;
scoped_ptr<BufferReader> reader_;
std::unique_ptr<BufferWriter> writer_;
std::unique_ptr<BufferReader> reader_;
private:
DISALLOW_COPY_AND_ASSIGN(BufferWriterTest);

View File

@ -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<uint8_t[]> new_buffer(new uint8_t[new_size]);
std::unique_ptr<uint8_t[]> new_buffer(new uint8_t[new_size]);
// Copy the data from the old buffer to the start of the new one.
if (used_ > 0)

View File

@ -7,7 +7,9 @@
#include <stdint.h>
#include "packager/base/memory/scoped_ptr.h"
#include <memory>
#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<uint8_t[]> buffer_;
std::unique_ptr<uint8_t[]> buffer_;
// Size of |buffer_|.
size_t size_;

View File

@ -7,8 +7,9 @@
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <memory>
#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<ClosureThread> thread_;
std::unique_ptr<ClosureThread> thread_;
private:
int val_;

View File

@ -10,7 +10,7 @@
#include <string>
#include <vector>
#include "packager/base/memory/scoped_ptr.h"
#include "packager/base/macros.h"
#include "packager/media/base/fourccs.h"
namespace shaka {

View File

@ -40,7 +40,7 @@ bool DecryptorSource::DecryptSampleBuffer(const DecryptConfig* decrypt_config,
return false;
}
scoped_ptr<AesCryptor> aes_decryptor;
std::unique_ptr<AesCryptor> 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<AesCryptor>(new AesCtrDecryptor())));
std::unique_ptr<AesCryptor>(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<AesCryptor>(new AesCbcDecryptor(kNoPadding))));
std::unique_ptr<AesCryptor>(new AesCbcDecryptor(kNoPadding))));
break;
default:
LOG(ERROR) << "Unsupported protection scheme: "

View File

@ -49,8 +49,8 @@ Demuxer::~Demuxer() {
STLDeleteElements(&streams_);
}
void Demuxer::SetKeySource(scoped_ptr<KeySource> key_source) {
key_source_ = key_source.Pass();
void Demuxer::SetKeySource(std::unique_ptr<KeySource> key_source) {
key_source_ = std::move(key_source);
}
Status Demuxer::Initialize() {

View File

@ -8,11 +8,11 @@
#define MEDIA_BASE_DEMUXER_H_
#include <deque>
#include <memory>
#include <vector>
#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<KeySource> key_source);
void SetKeySource(std::unique_ptr<KeySource> 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<QueuedSample> queued_samples_;
scoped_ptr<MediaParser> parser_;
std::unique_ptr<MediaParser> parser_;
std::vector<MediaStream*> streams_;
MediaContainerName container_name_;
scoped_ptr<uint8_t[]> buffer_;
scoped_ptr<KeySource> key_source_;
std::unique_ptr<uint8_t[]> buffer_;
std::unique_ptr<KeySource> key_source_;
bool cancelled_;
DISALLOW_COPY_AND_ASSIGN(Demuxer);

View File

@ -83,38 +83,38 @@ Status FixedKeySource::GetCryptoPeriodKey(uint32_t crypto_period_index,
return Status::OK;
}
scoped_ptr<FixedKeySource> FixedKeySource::CreateFromHexStrings(
std::unique_ptr<FixedKeySource> 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<EncryptionKey> encryption_key(new EncryptionKey());
std::unique_ptr<EncryptionKey> 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<FixedKeySource>();
return std::unique_ptr<FixedKeySource>();
} 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<FixedKeySource>();
return std::unique_ptr<FixedKeySource>();
}
if (!base::HexStringToBytes(key_hex, &encryption_key->key)) {
LOG(ERROR) << "Cannot parse key_hex " << key_hex;
return scoped_ptr<FixedKeySource>();
return std::unique_ptr<FixedKeySource>();
}
std::vector<uint8_t> 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<FixedKeySource>();
return std::unique_ptr<FixedKeySource>();
}
if (!iv_hex.empty()) {
if (!base::HexStringToBytes(iv_hex, &encryption_key->iv)) {
LOG(ERROR) << "Cannot parse iv_hex " << iv_hex;
return scoped_ptr<FixedKeySource>();
return std::unique_ptr<FixedKeySource>();
}
}
@ -122,7 +122,7 @@ scoped_ptr<FixedKeySource> 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<FixedKeySource>();
return std::unique_ptr<FixedKeySource>();
}
// If there aren't any PSSH boxes given, create one with the common system ID.
@ -135,12 +135,13 @@ scoped_ptr<FixedKeySource> FixedKeySource::CreateFromHexStrings(
encryption_key->key_system_info.push_back(info);
}
return scoped_ptr<FixedKeySource>(new FixedKeySource(encryption_key.Pass()));
return std::unique_ptr<FixedKeySource>(
new FixedKeySource(std::move(encryption_key)));
}
FixedKeySource::FixedKeySource() {}
FixedKeySource::FixedKeySource(scoped_ptr<EncryptionKey> key)
: encryption_key_(key.Pass()) {}
FixedKeySource::FixedKeySource(std::unique_ptr<EncryptionKey> key)
: encryption_key_(std::move(key)) {}
} // namespace media
} // namespace shaka

View File

@ -7,10 +7,10 @@
#ifndef MEDIA_BASE_FIXED_KEY_SOURCE_H_
#define MEDIA_BASE_FIXED_KEY_SOURCE_H_
#include <memory>
#include <string>
#include <vector>
#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<FixedKeySource> CreateFromHexStrings(
static std::unique_ptr<FixedKeySource> 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<EncryptionKey> key);
explicit FixedKeySource(std::unique_ptr<EncryptionKey> key);
scoped_ptr<EncryptionKey> encryption_key_;
std::unique_ptr<EncryptionKey> encryption_key_;
DISALLOW_COPY_AND_ASSIGN(FixedKeySource);
};

View File

@ -47,8 +47,9 @@ const char kDefaultPsshBoxHex[] =
TEST(FixedKeySourceTest, CreateFromHexStrings_Succes) {
std::string pssh_boxes = std::string(kPsshBox1Hex) + kPsshBox2Hex;
scoped_ptr<FixedKeySource> key_source = FixedKeySource::CreateFromHexStrings(
kKeyIdHex, kKeyHex, pssh_boxes, kIvHex);
std::unique_ptr<FixedKeySource> 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<FixedKeySource> key_source = FixedKeySource::CreateFromHexStrings(
kKeyIdHex, kKeyHex, "", kIvHex);
std::unique_ptr<FixedKeySource> 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<FixedKeySource> key_source = FixedKeySource::CreateFromHexStrings(
kKeyIdHex, "invalid_hex_value", kPsshBox1Hex, kIvHex);
std::unique_ptr<FixedKeySource> key_source =
FixedKeySource::CreateFromHexStrings(kKeyIdHex, "invalid_hex_value",
kPsshBox1Hex, kIvHex);
EXPECT_EQ(nullptr, key_source);
// Invalid key id size.

View File

@ -10,7 +10,6 @@
#include <string>
#include <vector>
#include "packager/base/memory/scoped_ptr.h"
#include "packager/media/base/protection_system_specific_info.h"
#include "packager/media/base/status.h"

View File

@ -7,13 +7,12 @@
#ifndef MEDIA_BASE_MEDIA_PARSER_H_
#define MEDIA_BASE_MEDIA_PARSER_H_
#include <memory>
#include <string>
#include <vector>
#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 {

View File

@ -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 {

View File

@ -8,9 +8,9 @@
#define MEDIA_BASE_MEDIA_STREAM_H_
#include <deque>
#include <memory>
#include "packager/base/memory/ref_counted.h"
#include "packager/base/memory/scoped_ptr.h"
#include "packager/media/base/status.h"
namespace shaka {

View File

@ -6,6 +6,8 @@
#include "packager/media/base/muxer.h"
#include <algorithm>
#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<MuxerListener> muxer_listener) {
muxer_listener_ = muxer_listener.Pass();
void Muxer::SetMuxerListener(std::unique_ptr<MuxerListener> muxer_listener) {
muxer_listener_ = std::move(muxer_listener);
}
void Muxer::SetProgressListener(
scoped_ptr<ProgressListener> progress_listener) {
progress_listener_ = progress_listener.Pass();
std::unique_ptr<ProgressListener> progress_listener) {
progress_listener_ = std::move(progress_listener);
}
Status Muxer::AddSample(const MediaStream* stream,

View File

@ -9,10 +9,10 @@
#ifndef MEDIA_BASE_MUXER_H_
#define MEDIA_BASE_MUXER_H_
#include <memory>
#include <vector>
#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<MuxerListener> muxer_listener);
void SetMuxerListener(std::unique_ptr<MuxerListener> muxer_listener);
/// Set a ProgressListener event handler for this object.
/// @param progress_listener should not be NULL.
void SetProgressListener(scoped_ptr<ProgressListener> progress_listener);
void SetProgressListener(std::unique_ptr<ProgressListener> progress_listener);
const std::vector<MediaStream*>& streams() const { return streams_; }
@ -125,8 +125,8 @@ class Muxer {
FourCC protection_scheme_;
bool cancelled_;
scoped_ptr<MuxerListener> muxer_listener_;
scoped_ptr<ProgressListener> progress_listener_;
std::unique_ptr<MuxerListener> muxer_listener_;
std::unique_ptr<ProgressListener> progress_listener_;
// An external injected clock, can be NULL.
base::Clock* clock_;

View File

@ -5,8 +5,7 @@
#include <gtest/gtest.h>
#include <stdint.h>
#include <string.h>
#include "packager/base/memory/scoped_ptr.h"
#include <memory>
#include "packager/media/base/offset_byte_queue.h"
namespace shaka {
@ -29,7 +28,7 @@ class OffsetByteQueueTest : public testing::Test {
}
protected:
scoped_ptr<OffsetByteQueue> queue_;
std::unique_ptr<OffsetByteQueue> queue_;
};
TEST_F(OffsetByteQueueTest, SetUp) {

View File

@ -88,7 +88,7 @@ TEST(ProducerConsumerQueueTest, PeekOnPoppedElement) {
}
TEST(ProducerConsumerQueueTest, PushWithTimeout) {
scoped_ptr<base::ElapsedTimer> timer;
std::unique_ptr<base::ElapsedTimer> timer;
ProducerConsumerQueue<int> queue(kCapacity);
for (size_t i = 0; i < kCapacity; ++i) {
@ -105,7 +105,7 @@ TEST(ProducerConsumerQueueTest, PushWithTimeout) {
}
TEST(ProducerConsumerQueueTest, PopWithTimeout) {
scoped_ptr<base::ElapsedTimer> timer;
std::unique_ptr<base::ElapsedTimer> timer;
ProducerConsumerQueue<size_t> queue(kCapacity);
for (size_t i = 0; i < kCapacity; ++i)
@ -127,7 +127,7 @@ TEST(ProducerConsumerQueueTest, PopWithTimeout) {
}
TEST(ProducerConsumerQueueTest, PeekWithTimeout) {
scoped_ptr<base::ElapsedTimer> timer;
std::unique_ptr<base::ElapsedTimer> timer;
ProducerConsumerQueue<size_t> queue(kCapacity);
for (size_t i = 0; i < kCapacity; ++i)
@ -150,7 +150,7 @@ TEST(ProducerConsumerQueueTest, PeekWithTimeout) {
}
TEST(ProducerConsumerQueueTest, CheckStop) {
scoped_ptr<base::ElapsedTimer> timer;
std::unique_ptr<base::ElapsedTimer> timer;
ProducerConsumerQueue<int> queue(kUnlimitedCapacity);
ASSERT_FALSE(queue.Stopped());

View File

@ -20,8 +20,8 @@ RequestSigner::RequestSigner(const std::string& signer_name)
RequestSigner::~RequestSigner() {}
AesRequestSigner::AesRequestSigner(const std::string& signer_name,
scoped_ptr<AesCbcEncryptor> encryptor)
: RequestSigner(signer_name), aes_cbc_encryptor_(encryptor.Pass()) {
std::unique_ptr<AesCbcEncryptor> 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<AesCbcEncryptor> encryptor(
std::unique_ptr<AesCbcEncryptor> 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<RsaPrivateKey> rsa_private_key)
: RequestSigner(signer_name), rsa_private_key_(rsa_private_key.Pass()) {
RsaRequestSigner::RsaRequestSigner(
const std::string& signer_name,
std::unique_ptr<RsaPrivateKey> 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<RsaPrivateKey> rsa_private_key(
std::unique_ptr<RsaPrivateKey> 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,

View File

@ -7,9 +7,10 @@
#ifndef MEDIA_BASE_REQUEST_SIGNER_H_
#define MEDIA_BASE_REQUEST_SIGNER_H_
#include <memory>
#include <string>
#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<AesCbcEncryptor> encryptor);
std::unique_ptr<AesCbcEncryptor> encryptor);
scoped_ptr<AesCbcEncryptor> aes_cbc_encryptor_;
std::unique_ptr<AesCbcEncryptor> 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<RsaPrivateKey> rsa_private_key);
std::unique_ptr<RsaPrivateKey> rsa_private_key);
scoped_ptr<RsaPrivateKey> rsa_private_key_;
std::unique_ptr<RsaPrivateKey> rsa_private_key_;
DISALLOW_COPY_AND_ASSIGN(RsaRequestSigner);
};

View File

@ -7,8 +7,7 @@
// Unit test for rsa_key RSA encryption and signing.
#include <gtest/gtest.h>
#include "packager/base/memory/scoped_ptr.h"
#include <memory>
#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<RsaTestSet> {
protected:
const RsaTestSet& test_set_;
scoped_ptr<RsaPrivateKey> private_key_;
scoped_ptr<RsaPublicKey> public_key_;
std::unique_ptr<RsaPrivateKey> private_key_;
std::unique_ptr<RsaPublicKey> public_key_;
};
TEST_P(RsaKeyTest, BadPublicKey) {
scoped_ptr<RsaPublicKey> public_key(RsaPublicKey::Create("bad_public_key"));
std::unique_ptr<RsaPublicKey> public_key(
RsaPublicKey::Create("bad_public_key"));
EXPECT_TRUE(public_key == NULL);
}
TEST_P(RsaKeyTest, BadPrivateKey) {
scoped_ptr<RsaPrivateKey> private_key(
std::unique_ptr<RsaPrivateKey> private_key(
RsaPrivateKey::Create("bad_private_key"));
EXPECT_TRUE(private_key == NULL);
}
TEST_P(RsaKeyTest, LoadPublicKey) {
scoped_ptr<RsaPublicKey> public_key(
std::unique_ptr<RsaPublicKey> public_key(
RsaPublicKey::Create(test_set_.public_key));
EXPECT_TRUE(public_key != NULL);
}
TEST_P(RsaKeyTest, LoadPrivateKey) {
scoped_ptr<RsaPrivateKey> private_key(
std::unique_ptr<RsaPrivateKey> private_key(
RsaPrivateKey::Create(test_set_.private_key));
EXPECT_TRUE(private_key != NULL);
}
TEST_P(RsaKeyTest, LoadPublicKeyInPrivateKey) {
scoped_ptr<RsaPrivateKey> private_key(
std::unique_ptr<RsaPrivateKey> private_key(
RsaPrivateKey::Create(test_set_.public_key));
EXPECT_TRUE(private_key == NULL);
}
TEST_P(RsaKeyTest, LoadPrivateKeyInPublicKey) {
scoped_ptr<RsaPublicKey> public_key(
std::unique_ptr<RsaPublicKey> public_key(
RsaPublicKey::Create(test_set_.private_key));
EXPECT_TRUE(public_key == NULL);
}

View File

@ -5,10 +5,10 @@
#ifndef MEDIA_BASE_TEXT_TRACK_H_
#define MEDIA_BASE_TEXT_TRACK_H_
#include <memory>
#include <string>
#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<scoped_ptr<TextTrack>
(TextKind kind,
typedef base::Callback<std::unique_ptr<TextTrack>(TextKind kind,
const std::string& label,
const std::string& language)> AddTextTrackCB;
const std::string& language)>
AddTextTrackCB;
} // namespace media
} // namespace shaka

View File

@ -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<RequestSigner> signer) {
signer_ = signer.Pass();
void WidevineKeySource::set_signer(std::unique_ptr<RequestSigner> signer) {
signer_ = std::move(signer);
}
void WidevineKeySource::set_key_fetcher(scoped_ptr<KeyFetcher> key_fetcher) {
key_fetcher_ = key_fetcher.Pass();
void WidevineKeySource::set_key_fetcher(
std::unique_ptr<KeyFetcher> 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<base::Value> root(base::JSONReader::Read(raw_response));
// TODO(kqyang): Remove ".release()" when base is updated to use unique_ptr.
std::unique_ptr<base::Value> 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<base::Value> root(base::JSONReader::Read(response));
// TODO(kqyang): Remove ".release()" when base is updated to use unique_ptr.
std::unique_ptr<base::Value> 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<EncryptionKey> encryption_key(new EncryptionKey());
std::unique_ptr<EncryptionKey> encryption_key(new EncryptionKey());
if (!GetKeyFromTrack(*track_dict, &encryption_key->key))
return false;

View File

@ -8,8 +8,7 @@
#define MEDIA_BASE_WIDEVINE_KEY_SOURCE_H_
#include <map>
#include "packager/base/memory/scoped_ptr.h"
#include <memory>
#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<RequestSigner> signer);
void set_signer(std::unique_ptr<RequestSigner> 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<KeyFetcher> key_fetcher);
void set_key_fetcher(std::unique_ptr<KeyFetcher> 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<KeyFetcher> key_fetcher_;
std::unique_ptr<KeyFetcher> key_fetcher_;
std::string server_url_;
scoped_ptr<RequestSigner> signer_;
std::unique_ptr<RequestSigner> 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<EncryptionKeyQueue> key_pool_;
std::unique_ptr<EncryptionKeyQueue> key_pool_;
EncryptionKeyMap encryption_key_map_; // For non key rotation request.
Status common_encryption_request_status_;

View File

@ -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<MockRequestSigner> mock_request_signer_;
scoped_ptr<MockKeyFetcher> mock_key_fetcher_;
scoped_ptr<WidevineKeySource> widevine_key_source_;
std::unique_ptr<MockRequestSigner> mock_request_signer_;
std::unique_ptr<MockKeyFetcher> mock_key_fetcher_;
std::unique_ptr<WidevineKeySource> widevine_key_source_;
std::vector<uint8_t> 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<uint8_t> 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<std::vector<uint8_t>> key_ids;
key_ids.push_back(std::vector<uint8_t>(
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;

View File

@ -4,8 +4,8 @@
#include "packager/media/codecs/h264_parser.h"
#include <memory>
#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<H264Sps> sps(new H264Sps());
std::unique_ptr<H264Sps> 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<H264Pps> pps(new H264Pps());
std::unique_ptr<H264Pps> pps(new H264Pps());
READ_UE_OR_RETURN(&pps->pic_parameter_set_id);
READ_UE_OR_RETURN(&pps->seq_parameter_set_id);

View File

@ -6,8 +6,8 @@
#include "packager/media/codecs/h265_parser.h"
#include <algorithm>
#include <math.h>
#include <algorithm>
#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<H265Pps> pps(new H265Pps);
std::unique_ptr<H265Pps> 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<H265Sps> sps(new H265Sps);
std::unique_ptr<H265Sps> 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));

View File

@ -8,9 +8,9 @@
#define MEDIA_CODECS_H265_PARSER_H_
#include <map>
#include <memory>
#include <vector>
#include "packager/base/memory/scoped_ptr.h"
#include "packager/media/codecs/h26x_bit_reader.h"
namespace shaka {

View File

@ -6,8 +6,8 @@
#include "packager/media/event/hls_notify_muxer_listener.h"
#include <memory>
#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"

View File

@ -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<MediaInfo> media_info(new MediaInfo());
std::unique_ptr<MediaInfo> 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, &notification_id_);
} else {
media_info_ = media_info.Pass();
media_info_ = std::move(media_info);
}
}

View File

@ -10,10 +10,10 @@
#define MEDIA_EVENT_MPD_NOTIFY_MUXER_LISTENER_H_
#include <list>
#include <memory>
#include <vector>
#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<MediaInfo> media_info_;
std::unique_ptr<MediaInfo> media_info_;
bool is_encrypted_;
// Storage for values passed to OnEncryptionInfoReady().

View File

@ -90,8 +90,8 @@ class MpdNotifyMuxerListenerTest : public ::testing::Test {
params.file_size);
}
scoped_ptr<MpdNotifyMuxerListener> listener_;
scoped_ptr<MockMpdNotifier> notifier_;
std::unique_ptr<MpdNotifyMuxerListener> listener_;
std::unique_ptr<MockMpdNotifier> notifier_;
};
MATCHER_P(ExpectMediaInfoEq, expected_text_format, "") {

View File

@ -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 <memory>
#include <string>
#include <vector>
#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<MediaInfo> media_info_;
std::unique_ptr<MediaInfo> media_info_;
bool is_encrypted_;
// Storage for values passed to OnEncryptionInfoReady().

View File

@ -9,8 +9,8 @@
#include <vector>
#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<VodMediaInfoDumpMuxerListener> listener_;
std::unique_ptr<VodMediaInfoDumpMuxerListener> listener_;
private:
DISALLOW_COPY_AND_ASSIGN(VodMediaInfoDumpMuxerListenerTest);

View File

@ -8,14 +8,13 @@
#include <gflags/gflags.h>
#include <algorithm>
#include <memory>
#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<File, FileCloser> internal_file(
std::unique_ptr<File, FileCloser> 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<File, FileCloser> internal_file;
std::unique_ptr<File, FileCloser> 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<char[]> buf(new char[kBufferSize]);
std::unique_ptr<char[]> 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<File, FileCloser> output_file(File::Open(to_file_name, "w"));
std::unique_ptr<File, FileCloser> 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<int64_t>::max();
const int64_t kBufferSize = 0x40000; // 256KB.
scoped_ptr<uint8_t[]> buffer(new uint8_t[kBufferSize]);
std::unique_ptr<uint8_t[]> 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);

View File

@ -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.

View File

@ -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 {

View File

@ -91,8 +91,8 @@ class IoCacheTest : public testing::Test {
}
}
scoped_ptr<IoCache> cache_;
scoped_ptr<ClosureThread> writer_thread_;
std::unique_ptr<IoCache> cache_;
std::unique_ptr<ClosureThread> writer_thread_;
uint8_t reference_block_[kBlockSize];
bool cache_closed_;
};

View File

@ -9,9 +9,9 @@
#include <string.h> // for memcpy
#include <map>
#include <memory>
#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<FileSystem> g_file_system_;
static std::unique_ptr<FileSystem> g_file_system_;
std::map<std::string, std::vector<uint8_t> > files_;
DISALLOW_COPY_AND_ASSIGN(FileSystem);
};
scoped_ptr<FileSystem> FileSystem::g_file_system_;
std::unique_ptr<FileSystem> FileSystem::g_file_system_;
} // namespace

View File

@ -3,8 +3,7 @@
// found in the LICENSE file.
#include <gtest/gtest.h>
#include "packager/base/memory/scoped_ptr.h"
#include <memory>
#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<File, FileCloser> writer(File::Open("memory://file1", "w"));
std::unique_ptr<File, FileCloser> 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<File, FileCloser> reader(File::Open("memory://file1", "r"));
std::unique_ptr<File, FileCloser> 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<File, FileCloser> writer(File::Open("memory://file1", "w"));
scoped_ptr<File, FileCloser> reader(File::Open("memory://file2", "w"));
std::unique_ptr<File, FileCloser> writer(File::Open("memory://file1", "w"));
std::unique_ptr<File, FileCloser> 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, FileCloser> file(File::Open("memory://file1", "w"));
std::unique_ptr<File, FileCloser> 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, FileCloser> file(File::Open("memory://file1", "w"));
std::unique_ptr<File, FileCloser> 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, FileCloser> file(File::Open("memory://file1", "w"));
std::unique_ptr<File, FileCloser> 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, FileCloser> file(File::Open("memory://file1", "r"));
std::unique_ptr<File, FileCloser> file(File::Open("memory://file1", "r"));
EXPECT_FALSE(file);
}
TEST_F(MemoryFileTest, WriteExistingFileDeletes) {
scoped_ptr<File, FileCloser> file1(File::Open("memory://file1", "w"));
std::unique_ptr<File, FileCloser> file1(File::Open("memory://file1", "w"));
ASSERT_TRUE(file1);
ASSERT_EQ(kWriteBufferSize, file1->Write(kWriteBuffer, kWriteBufferSize));
scoped_ptr<File, FileCloser> file2(File::Open("memory://file1", "w"));
std::unique_ptr<File, FileCloser> file2(File::Open("memory://file1", "w"));
ASSERT_TRUE(file2);
EXPECT_EQ(0, file2->Size());
}

View File

@ -17,12 +17,12 @@ namespace media {
using base::subtle::NoBarrier_Load;
using base::subtle::NoBarrier_Store;
ThreadedIoFile::ThreadedIoFile(scoped_ptr<File, FileCloser> internal_file,
ThreadedIoFile::ThreadedIoFile(std::unique_ptr<File, FileCloser> 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),

View File

@ -7,8 +7,8 @@
#ifndef PACKAGER_FILE_THREADED_IO_FILE_H_
#define PACKAGER_FILE_THREADED_IO_FILE_H_
#include <memory>
#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<File, FileCloser> internal_file,
ThreadedIoFile(std::unique_ptr<File, FileCloser> 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<File, FileCloser> internal_file_;
std::unique_ptr<File, FileCloser> internal_file_;
const Mode mode_;
IoCache cache_;
std::vector<uint8_t> io_buffer_;

View File

@ -6,11 +6,11 @@
#define MEDIA_FORMATS_MP2T_ES_PARSER_ADTS_H_
#include <list>
#include <memory>
#include <utility>
#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<AudioTimestampHelper> audio_timestamp_helper_;
std::unique_ptr<AudioTimestampHelper> audio_timestamp_helper_;
scoped_refptr<StreamInfo> last_audio_decoder_config_;

View File

@ -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<H26xByteToUnitStreamConverter>(
std::unique_ptr<H26xByteToUnitStreamConverter>(
new H264ByteToUnitStreamConverter()),
pid,
emit_sample_cb),

View File

@ -6,9 +6,8 @@
#define MEDIA_FORMATS_MP2T_ES_PARSER_H264_H_
#include <stdint.h>
#include <memory>
#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<StreamInfo> last_video_decoder_config_;
bool decoder_config_check_pending_;
scoped_ptr<H264Parser> h264_parser_;
std::unique_ptr<H264Parser> h264_parser_;
};
} // namespace mp2t

View File

@ -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<H26xByteToUnitStreamConverter>(
std::unique_ptr<H26xByteToUnitStreamConverter>(
new H265ByteToUnitStreamConverter()),
pid,
emit_sample_cb),

View File

@ -10,11 +10,11 @@
#include <stdint.h>
#include <list>
#include <memory>
#include <utility>
#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<StreamInfo> last_video_decoder_config_;
bool decoder_config_check_pending_;
scoped_ptr<H265Parser> h265_parser_;
std::unique_ptr<H265Parser> h265_parser_;
};
} // namespace mp2t

View File

@ -27,10 +27,9 @@ const int kH265NaluHeaderSize = 2;
} // namespace
EsParserH26x::EsParserH26x(
Nalu::CodecType type,
scoped_ptr<H26xByteToUnitStreamConverter> stream_converter,
std::unique_ptr<H26xByteToUnitStreamConverter> 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) {}

View File

@ -9,10 +9,10 @@
#include <deque>
#include <list>
#include <memory>
#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<H26xByteToUnitStreamConverter> stream_converter,
std::unique_ptr<H26xByteToUnitStreamConverter> 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<media::OffsetByteQueue> es_queue_;
std::unique_ptr<media::OffsetByteQueue> es_queue_;
std::list<std::pair<int64_t, TimingDesc>> timing_desc_list_;
// Parser state.
@ -111,7 +111,7 @@ class EsParserH26x : public EsParser {
std::deque<NaluInfo> access_unit_nalus_;
// Filter to convert H.264/H.265 Annex B byte stream to unit stream.
scoped_ptr<H26xByteToUnitStreamConverter> stream_converter_;
std::unique_ptr<H26xByteToUnitStreamConverter> stream_converter_;
// Frame for which we do not yet have a duration.
scoped_refptr<MediaSample> pending_sample_;

View File

@ -62,7 +62,7 @@ class TestableEsParser : public EsParserH26x {
TestableEsParser(const NewStreamInfoCB& new_stream_info_cb,
const EmitSampleCB& emit_sample_cb)
: EsParserH26x(Nalu::kH265,
scoped_ptr<H26xByteToUnitStreamConverter>(
std::unique_ptr<H26xByteToUnitStreamConverter>(
new FakeByteToUnitStreamConverter()),
0,
emit_sample_cb),

View File

@ -4,8 +4,8 @@
#include "packager/media/formats/mp2t/mp2t_media_parser.h"
#include <memory>
#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<TsSection> section_parser);
PidState(int pid,
PidType pid_type,
std::unique_ptr<TsSection> 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<TsSection> section_parser_;
std::unique_ptr<TsSection> 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<TsSection> section_parser)
PidState::PidState(int pid,
PidType pid_type,
std::unique_ptr<TsSection> 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<TsPacket> ts_packet(TsPacket::Parse(ts_buffer, ts_buffer_size));
std::unique_ptr<TsPacket> 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<TsSection> pat_section_parser(
new TsSectionPat(
base::Bind(&Mp2tMediaParser::RegisterPmt,
base::Unretained(this))));
scoped_ptr<PidState> pat_pid_state(
new PidState(ts_packet->pid(), PidState::kPidPat,
pat_section_parser.Pass()));
std::unique_ptr<TsSection> pat_section_parser(new TsSectionPat(
base::Bind(&Mp2tMediaParser::RegisterPmt, base::Unretained(this))));
std::unique_ptr<PidState> pat_pid_state(new PidState(
ts_packet->pid(), PidState::kPidPat, std::move(pat_section_parser)));
pat_pid_state->Enable();
it = pids_.insert(
std::pair<int, PidState*>(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<TsSection> pmt_section_parser(
new TsSectionPmt(
base::Bind(&Mp2tMediaParser::RegisterPes,
base::Unretained(this), pmt_pid)));
scoped_ptr<PidState> pmt_pid_state(
new PidState(pmt_pid, PidState::kPidPmt, pmt_section_parser.Pass()));
std::unique_ptr<TsSection> pmt_section_parser(new TsSectionPmt(base::Bind(
&Mp2tMediaParser::RegisterPes, base::Unretained(this), pmt_pid)));
std::unique_ptr<PidState> pmt_pid_state(
new PidState(pmt_pid, PidState::kPidPmt, std::move(pmt_section_parser)));
pmt_pid_state->Enable();
pids_.insert(std::pair<int, PidState*>(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<EsParser> es_parser;
std::unique_ptr<EsParser> 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<TsSection> pes_section_parser(
new TsSectionPes(es_parser.Pass()));
std::unique_ptr<TsSection> pes_section_parser(
new TsSectionPes(std::move(es_parser)));
PidState::PidType pid_type =
is_audio ? PidState::kPidAudioPes : PidState::kPidVideoPes;
scoped_ptr<PidState> pes_pid_state(
new PidState(pes_pid, pid_type, pes_section_parser.Pass()));
std::unique_ptr<PidState> pes_pid_state(
new PidState(pes_pid, pid_type, std::move(pes_section_parser)));
pes_pid_state->Enable();
pids_.insert(std::pair<int, PidState*>(pes_pid, pes_pid_state.release()));
}

View File

@ -7,10 +7,9 @@
#include <deque>
#include <map>
#include <memory>
#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"

View File

@ -36,7 +36,7 @@ class Mp2tMediaParserTest : public testing::Test {
protected:
typedef std::map<int, scoped_refptr<StreamInfo> > StreamMap;
scoped_ptr<Mp2tMediaParser> parser_;
std::unique_ptr<Mp2tMediaParser> parser_;
StreamMap stream_map_;
int audio_frame_count_;
int video_frame_count_;

View File

@ -180,9 +180,9 @@ bool PesPacketGenerator::PushSample(scoped_refptr<MediaSample> sample) {
}
bool PesPacketGenerator::SetEncryptionKey(
scoped_ptr<EncryptionKey> encryption_key) {
std::unique_ptr<EncryptionKey> encryption_key) {
if (stream_type_ == kStreamVideo) {
scoped_ptr<AesCbcEncryptor> cbc(
std::unique_ptr<AesCbcEncryptor> 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<PesPacket> PesPacketGenerator::GetNextPesPacket() {
std::unique_ptr<PesPacket> PesPacketGenerator::GetNextPesPacket() {
DCHECK(!pes_packets_.empty());
PesPacket* pes = pes_packets_.front();
pes_packets_.pop_front();
return scoped_ptr<PesPacket>(pes);
return std::unique_ptr<PesPacket>(pes);
}
bool PesPacketGenerator::Flush() {

View File

@ -8,8 +8,8 @@
#define PACKAGER_MEDIA_FORMATS_MP2T_PES_PACKET_GENERATOR_H_
#include <list>
#include <memory>
#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<EncryptionKey> encryption_key);
virtual bool SetEncryptionKey(std::unique_ptr<EncryptionKey> 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<PesPacket> GetNextPesPacket();
virtual std::unique_ptr<PesPacket> GetNextPesPacket();
/// Flush the object.
/// This may increase NumberOfReadyPesPackets().
@ -75,18 +75,18 @@ class PesPacketGenerator {
// timestamps.
double timescale_scale_ = 0.0;
scoped_ptr<NalUnitToByteStreamConverter> converter_;
scoped_ptr<AACAudioSpecificConfig> adts_converter_;
std::unique_ptr<NalUnitToByteStreamConverter> converter_;
std::unique_ptr<AACAudioSpecificConfig> 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<PesPacket> current_processing_pes_;
std::unique_ptr<PesPacket> current_processing_pes_;
std::list<PesPacket*> pes_packets_;
STLElementDeleter<decltype(pes_packets_)> pes_packets_deleter_;
// Current encryption key.
scoped_ptr<AesCryptor> encryptor_;
std::unique_ptr<AesCryptor> encryptor_;
DISALLOW_COPY_AND_ASSIGN(PesPacketGenerator);
};

View File

@ -124,14 +124,14 @@ scoped_refptr<AudioStreamInfo> CreateAudioStreamInfo(Codec codec) {
class PesPacketGeneratorTest : public ::testing::Test {
protected:
void UseMockNalUnitToByteStreamConverter(
scoped_ptr<MockNalUnitToByteStreamConverter>
std::unique_ptr<MockNalUnitToByteStreamConverter>
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<MockAACAudioSpecificConfig> mock) {
generator_.adts_converter_ = mock.Pass();
std::unique_ptr<MockAACAudioSpecificConfig> 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<MockNalUnitToByteStreamConverter> mock(
std::unique_ptr<MockNalUnitToByteStreamConverter> 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<uint8_t> all_zero(16, 0);
scoped_ptr<EncryptionKey> encryption_key(new EncryptionKey());
std::unique_ptr<EncryptionKey> 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<PesPacket> pes_packet = generator_.GetNextPesPacket();
std::unique_ptr<PesPacket> pes_packet = generator_.GetNextPesPacket();
ASSERT_TRUE(pes_packet);
std::vector<uint8_t> expected(expected_output,
@ -197,21 +197,21 @@ class PesPacketGeneratorTest : public ::testing::Test {
scoped_refptr<MediaSample> sample = MediaSample::CopyFrom(
input, input_size, kIsKeyFrame);
scoped_ptr<MockAACAudioSpecificConfig> mock(
std::unique_ptr<MockAACAudioSpecificConfig> mock(
new MockAACAudioSpecificConfig());
EXPECT_CALL(*mock, ConvertToADTS(_)).WillOnce(Return(true));
UseMockAACAudioSpecificConfig(mock.Pass());
UseMockAACAudioSpecificConfig(std::move(mock));
const std::vector<uint8_t> all_zero(16, 0);
scoped_ptr<EncryptionKey> encryption_key(new EncryptionKey());
std::unique_ptr<EncryptionKey> 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<PesPacket> pes_packet = generator_.GetNextPesPacket();
std::unique_ptr<PesPacket> pes_packet = generator_.GetNextPesPacket();
ASSERT_TRUE(pes_packet);
std::vector<uint8_t> expected(expected_output,
@ -266,17 +266,17 @@ TEST_F(PesPacketGeneratorTest, AddVideoSample) {
std::vector<uint8_t> expected_data(kAnyData, kAnyData + arraysize(kAnyData));
scoped_ptr<MockNalUnitToByteStreamConverter> mock(
std::unique_ptr<MockNalUnitToByteStreamConverter> 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<PesPacket> pes_packet = generator_.GetNextPesPacket();
std::unique_ptr<PesPacket> 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<uint8_t> expected_data(kAnyData, kAnyData + arraysize(kAnyData));
scoped_ptr<MockNalUnitToByteStreamConverter> mock(
std::unique_ptr<MockNalUnitToByteStreamConverter> 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<uint8_t> expected_data(kAnyData, kAnyData + arraysize(kAnyData));
scoped_ptr<MockAACAudioSpecificConfig> mock(new MockAACAudioSpecificConfig());
std::unique_ptr<MockAACAudioSpecificConfig> 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<PesPacket> pes_packet = generator_.GetNextPesPacket();
std::unique_ptr<PesPacket> pes_packet = generator_.GetNextPesPacket();
ASSERT_TRUE(pes_packet);
EXPECT_EQ(0u, generator_.NumberOfReadyPesPackets());
@ -346,10 +347,11 @@ TEST_F(PesPacketGeneratorTest, AddAudioSampleFailedToConvert) {
scoped_refptr<MediaSample> sample =
MediaSample::CopyFrom(kAnyData, arraysize(kAnyData), kIsKeyFrame);
scoped_ptr<MockAACAudioSpecificConfig> mock(new MockAACAudioSpecificConfig());
std::unique_ptr<MockAACAudioSpecificConfig> 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<MockNalUnitToByteStreamConverter> mock(
std::unique_ptr<MockNalUnitToByteStreamConverter> 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<PesPacket> pes_packet = generator_.GetNextPesPacket();
std::unique_ptr<PesPacket> pes_packet = generator_.GetNextPesPacket();
ASSERT_TRUE(pes_packet);
EXPECT_EQ(0u, generator_.NumberOfReadyPesPackets());

View File

@ -32,7 +32,7 @@ class TsMuxer : public Muxer {
void FireOnMediaStartEvent();
void FireOnMediaEndEvent();
scoped_ptr<TsSegmenter> segmenter_;
std::unique_ptr<TsSegmenter> segmenter_;
DISALLOW_COPY_AND_ASSIGN(TsMuxer);
};

View File

@ -4,7 +4,7 @@
#include "packager/media/formats/mp2t/ts_packet.h"
#include "packager/base/memory/scoped_ptr.h"
#include <memory>
#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<TsPacket> ts_packet(new TsPacket());
std::unique_ptr<TsPacket> ts_packet(new TsPacket());
bool status = ts_packet->ParseHeader(buf);
if (!status) {
DVLOG(1) << "Parsing header failed";

View File

@ -82,7 +82,7 @@ namespace shaka {
namespace media {
namespace mp2t {
TsSectionPes::TsSectionPes(scoped_ptr<EsParser> es_parser)
TsSectionPes::TsSectionPes(std::unique_ptr<EsParser> es_parser)
: es_parser_(es_parser.release()),
wait_for_pusi_(true),
previous_pts_valid_(false),

View File

@ -6,9 +6,8 @@
#define MEDIA_FORMATS_MP2T_TS_SECTION_PES_H_
#include <stdint.h>
#include <memory>
#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<EsParser> es_parser);
explicit TsSectionPes(std::unique_ptr<EsParser> es_parser);
~TsSectionPes() override;
// TsSection implementation.
@ -46,7 +45,7 @@ class TsSectionPes : public TsSection {
ByteQueue pes_byte_queue_;
// ES parser.
scoped_ptr<EsParser> es_parser_;
std::unique_ptr<EsParser> es_parser_;
// Do not start parsing before getting a unit start indicator.
bool wait_for_pusi_;

View File

@ -45,7 +45,7 @@ Status TsSegmenter::Initialize(const StreamInfo& stream_info,
}
if (encryption_key_source) {
scoped_ptr<EncryptionKey> encryption_key(new EncryptionKey());
std::unique_ptr<EncryptionKey> 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<MediaSample> sample) {
return WritePesPacketsToFile();
}
void TsSegmenter::InjectTsWriterForTesting(scoped_ptr<TsWriter> writer) {
ts_writer_ = writer.Pass();
void TsSegmenter::InjectTsWriterForTesting(std::unique_ptr<TsWriter> writer) {
ts_writer_ = std::move(writer);
}
void TsSegmenter::InjectPesPacketGeneratorForTesting(
scoped_ptr<PesPacketGenerator> generator) {
pes_packet_generator_ = generator.Pass();
std::unique_ptr<PesPacketGenerator> 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<PesPacket> pes_packet =
std::unique_ptr<PesPacket> 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();
}

View File

@ -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 <memory>
#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<MediaSample> sample);
/// Only for testing.
void InjectTsWriterForTesting(scoped_ptr<TsWriter> writer);
void InjectTsWriterForTesting(std::unique_ptr<TsWriter> writer);
/// Only for testing.
void InjectPesPacketGeneratorForTesting(
scoped_ptr<PesPacketGenerator> generator);
std::unique_ptr<PesPacketGenerator> 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<TsWriter> ts_writer_;
std::unique_ptr<TsWriter> ts_writer_;
// Set to true if TsWriter::NewFile() succeeds, set to false after
// TsWriter::FinalizeFile() succeeds.
bool ts_writer_file_opened_ = false;
scoped_ptr<PesPacketGenerator> pes_packet_generator_;
std::unique_ptr<PesPacketGenerator> 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<EncryptionKey> encryption_key_;
std::unique_ptr<EncryptionKey> encryption_key_;
double clear_lead_in_seconds_ = 0;
// The total duration of the segments that it has segmented. This only

View File

@ -55,17 +55,19 @@ class MockPesPacketGenerator : public PesPacketGenerator {
MOCK_METHOD1(Initialize, bool(const StreamInfo& info));
MOCK_METHOD1(PushSample, bool(scoped_refptr<MediaSample> sample));
MOCK_METHOD1(SetEncryptionKeyMock, bool(EncryptionKey* encryption_key));
bool SetEncryptionKey(scoped_ptr<EncryptionKey> encryption_key) override {
bool SetEncryptionKey(
std::unique_ptr<EncryptionKey> 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<PesPacket> GetNextPesPacket() override {
return scoped_ptr<PesPacket>(GetNextPesPacketMock());
std::unique_ptr<PesPacket> GetNextPesPacket() override {
return std::unique_ptr<PesPacket>(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<PesPacket> pes_packet) override {
bool AddPesPacket(std::unique_ptr<PesPacket> 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<MockTsWriter> mock_ts_writer_;
scoped_ptr<MockPesPacketGenerator> mock_pes_packet_generator_;
std::unique_ptr<MockTsWriter> mock_ts_writer_;
std::unique_ptr<MockPesPacketGenerator> 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().

View File

@ -235,7 +235,7 @@ bool TsWriter::FinalizeSegment() {
return current_file_.release()->Close();
}
bool TsWriter::AddPesPacket(scoped_ptr<PesPacket> pes_packet) {
bool TsWriter::AddPesPacket(std::unique_ptr<PesPacket> 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<PesPacket> pes_packet) {
}
void TsWriter::SetProgramMapTableWriterForTesting(
scoped_ptr<ProgramMapTableWriter> table_writer) {
pmt_writer_ = table_writer.Pass();
std::unique_ptr<ProgramMapTableWriter> table_writer) {
pmt_writer_ = std::move(table_writer);
}
} // namespace mp2t

View File

@ -9,9 +9,9 @@
#include <list>
#include <map>
#include <memory>
#include <vector>
#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<PesPacket> pes_packet);
virtual bool AddPesPacket(std::unique_ptr<PesPacket> pes_packet);
/// Only for testing.
void SetProgramMapTableWriterForTesting(
scoped_ptr<ProgramMapTableWriter> table_writer);
std::unique_ptr<ProgramMapTableWriter> 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<ProgramMapTableWriter> pmt_writer_;
std::unique_ptr<ProgramMapTableWriter> pmt_writer_;
scoped_ptr<File, FileCloser> current_file_;
std::unique_ptr<File, FileCloser> current_file_;
DISALLOW_COPY_AND_ASSIGN(TsWriter);
};

View File

@ -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<MockProgramMapTableWriter> mock_pmt_writer(
std::unique_ptr<MockProgramMapTableWriter> 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<MockProgramMapTableWriter> mock_pmt_writer(
std::unique_ptr<MockProgramMapTableWriter> 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<MockProgramMapTableWriter> mock_pmt_writer(
std::unique_ptr<MockProgramMapTableWriter> 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<MockProgramMapTableWriter> mock_pmt_writer(
std::unique_ptr<MockProgramMapTableWriter> 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<MockProgramMapTableWriter> mock_pmt_writer(
std::unique_ptr<MockProgramMapTableWriter> 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<MockProgramMapTableWriter> mock_pmt_writer(
std::unique_ptr<MockProgramMapTableWriter> 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<PesPacket> pes(new PesPacket());
std::unique_ptr<PesPacket> 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<uint8_t> 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<PesPacket> pes(new PesPacket());
std::unique_ptr<PesPacket> pes(new PesPacket());
pes->set_pts(0);
pes->set_dts(0);
// A little over 2 TS Packets (3 TS Packets).
const std::vector<uint8_t> 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<uint8_t> 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<PesPacket> pes(new PesPacket());
std::unique_ptr<PesPacket> 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<uint8_t> 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<PesPacket> pes(new PesPacket());
std::unique_ptr<PesPacket> 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<uint8_t> 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[] = {

View File

@ -7,10 +7,10 @@
#include <gtest/gtest.h>
#include <limits>
#include <memory>
#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<BoxReader> reader(CreateReader());
std::unique_ptr<BoxReader> 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<BoxReader> reader(CreateReader());
std::unique_ptr<BoxReader> reader(CreateReader());
std::vector<VideoSampleEntry> 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<BoxReader> reader(CreateReader());
std::unique_ptr<BoxReader> reader(CreateReader());
std::vector<AudioSampleEntry> 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<BoxReader> reader(CreateReader());
std::unique_ptr<BoxReader> reader(CreateReader());
std::vector<TextSampleEntry> 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<BoxReader> reader(CreateReader());
std::unique_ptr<BoxReader> 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<BoxReader> reader(CreateReader());
std::unique_ptr<BoxReader> 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<BoxReader> reader(CreateReader());
std::unique_ptr<BoxReader> 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<BufferWriter> buffer_;
std::unique_ptr<BufferWriter> buffer_;
};
// GTEST support a maximum of 50 types in the template list, so we have to

View File

@ -7,9 +7,9 @@
#include <inttypes.h>
#include <limits>
#include <memory>
#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<BoxReader> reader(new BoxReader(buf, buf_size));
std::unique_ptr<BoxReader> 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<BoxReader> child(
std::unique_ptr<BoxReader> child(
new BoxReader(&data()[pos()], size() - pos()));
bool err;
if (!child->ReadHeader(&err))

View File

@ -6,8 +6,9 @@
#include <stdint.h>
#include <string.h>
#include <memory>
#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<uint8_t> buf = GetBuf();
bool err;
scoped_ptr<BoxReader> reader(BoxReader::ReadBox(&buf[0], buf.size(), &err));
std::unique_ptr<BoxReader> 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<BoxReader> r(BoxReader::ReadBox(&buf[0], buf.size() - 2, &err));
std::unique_ptr<BoxReader> 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<BoxReader> reader(BoxReader::ReadBox(&buf[0], buf.size(), &err));
std::unique_ptr<BoxReader> 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<uint8_t> buf = GetBuf();
bool err;
scoped_ptr<BoxReader> reader(BoxReader::ReadBox(&buf[0], buf.size(), &err));
std::unique_ptr<BoxReader> 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<BoxReader> reader(BoxReader::ReadBox(&buf[0], buf.size(), &err));
std::unique_ptr<BoxReader> reader(
BoxReader::ReadBox(&buf[0], buf.size(), &err));
std::vector<PsshBox> kids;
EXPECT_TRUE(reader->SkipBytes(16) && reader->ReadAllChildren(&kids));
@ -182,7 +188,8 @@ TEST_F(BoxReaderTest, SkippingBloc) {
std::vector<uint8_t> buf(kData, kData + sizeof(kData));
bool err;
scoped_ptr<BoxReader> reader(BoxReader::ReadBox(&buf[0], buf.size(), &err));
std::unique_ptr<BoxReader> reader(
BoxReader::ReadBox(&buf[0], buf.size(), &err));
EXPECT_FALSE(err);
EXPECT_TRUE(reader);

View File

@ -5,9 +5,8 @@
// https://developers.google.com/open-source/licenses/bsd
#include <gtest/gtest.h>
#include <memory>
#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<ChunkProperty> chunk_info_table_;
SampleToChunk sample_to_chunk_;
scoped_ptr<ChunkInfoIterator> chunk_info_iterator_;
std::unique_ptr<ChunkInfoIterator> chunk_info_iterator_;
private:
DISALLOW_COPY_AND_ASSIGN(ChunkInfoIteratorTest);

View File

@ -5,8 +5,7 @@
// https://developers.google.com/open-source/licenses/bsd
#include <gtest/gtest.h>
#include "packager/base/memory/scoped_ptr.h"
#include <memory>
#include "packager/media/formats/mp4/composition_offset_iterator.h"
namespace shaka {
@ -37,7 +36,7 @@ class CompositionOffsetIteratorTest : public testing::Test {
protected:
std::vector<int64_t> composition_offset_table_;
CompositionTimeToSample composition_time_to_sample_;
scoped_ptr<CompositionOffsetIterator> composition_offset_iterator_;
std::unique_ptr<CompositionOffsetIterator> composition_offset_iterator_;
private:
DISALLOW_COPY_AND_ASSIGN(CompositionOffsetIteratorTest);

View File

@ -5,8 +5,7 @@
// https://developers.google.com/open-source/licenses/bsd
#include <gtest/gtest.h>
#include "packager/base/memory/scoped_ptr.h"
#include <memory>
#include "packager/media/formats/mp4/decoding_time_iterator.h"
namespace shaka {
@ -38,7 +37,7 @@ class DecodingTimeIteratorTest : public testing::Test {
protected:
std::vector<uint32_t> decoding_time_table_;
DecodingTimeToSample decoding_time_to_sample_;
scoped_ptr<DecodingTimeIterator> decoding_time_iterator_;
std::unique_ptr<DecodingTimeIterator> decoding_time_iterator_;
private:
DISALLOW_COPY_AND_ASSIGN(DecodingTimeIteratorTest);

View File

@ -59,13 +59,17 @@ uint8_t GetNaluLengthSize(const StreamInfo& stream_info) {
} // namespace
EncryptingFragmenter::EncryptingFragmenter(
scoped_refptr<StreamInfo> info, TrackFragment* traf,
scoped_ptr<EncryptionKey> encryption_key, int64_t clear_time,
FourCC protection_scheme, uint8_t crypt_byte_block, uint8_t skip_byte_block,
scoped_refptr<StreamInfo> info,
TrackFragment* traf,
std::unique_ptr<EncryptionKey> 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<AesCryptor> encryptor;
std::unique_ptr<AesCryptor> 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<AesCryptor>(new AesCtrEncryptor())));
std::unique_ptr<AesCryptor>(new AesCtrEncryptor())));
break;
case FOURCC_cbcs:
encryptor.reset(new AesPatternCryptor(
crypt_byte_block(), skip_byte_block(),
AesPatternCryptor::kEncryptIfCryptByteBlockRemaining,
AesCryptor::kUseConstantIv,
scoped_ptr<AesCryptor>(new AesCbcEncryptor(kNoPadding))));
std::unique_ptr<AesCryptor>(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;
}

View File

@ -7,8 +7,8 @@
#ifndef MEDIA_FORMATS_MP4_ENCRYPTING_FRAGMENTER_H_
#define MEDIA_FORMATS_MP4_ENCRYPTING_FRAGMENTER_H_
#include <memory>
#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<StreamInfo> info,
TrackFragment* traf,
scoped_ptr<EncryptionKey> encryption_key,
std::unique_ptr<EncryptionKey> 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<EncryptionKey> encryption_key) {
encryption_key_ = encryption_key.Pass();
void set_encryption_key(std::unique_ptr<EncryptionKey> encryption_key) {
encryption_key_ = std::move(encryption_key);
}
private:
@ -86,8 +86,8 @@ class EncryptingFragmenter : public Fragmenter {
bool IsSubsampleEncryptionRequired();
scoped_refptr<StreamInfo> info_;
scoped_ptr<EncryptionKey> encryption_key_;
scoped_ptr<AesCryptor> encryptor_;
std::unique_ptr<EncryptionKey> encryption_key_;
std::unique_ptr<AesCryptor> 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<VPxParser> vpx_parser_;
scoped_ptr<VideoSliceHeaderParser> header_parser_;
std::unique_ptr<VPxParser> vpx_parser_;
std::unique_ptr<VideoSliceHeaderParser> header_parser_;
DISALLOW_COPY_AND_ASSIGN(EncryptingFragmenter);
};

View File

@ -7,11 +7,11 @@
#ifndef MEDIA_FORMATS_MP4_FRAGMENTER_H_
#define MEDIA_FORMATS_MP4_FRAGMENTER_H_
#include <memory>
#include <vector>
#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<BufferWriter> data_;
std::unique_ptr<BufferWriter> data_;
DISALLOW_COPY_AND_ASSIGN(Fragmenter);
};

View File

@ -30,7 +30,7 @@ KeyRotationFragmenter::KeyRotationFragmenter(MovieFragment* moof,
MuxerListener* muxer_listener)
: EncryptingFragmenter(info,
traf,
scoped_ptr<EncryptionKey>(new EncryptionKey()),
std::unique_ptr<EncryptionKey>(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<EncryptionKey> encryption_key(new EncryptionKey());
std::unique_ptr<EncryptionKey> 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;
}

View File

@ -156,7 +156,7 @@ bool MP4MediaParser::Parse(const uint8_t* buf, int size) {
}
bool MP4MediaParser::LoadMoov(const std::string& file_path) {
scoped_ptr<File, FileCloser> file(
std::unique_ptr<File, FileCloser> 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<BoxReader> reader(BoxReader::ReadBox(buf, size, err));
std::unique_ptr<BoxReader> 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<DecryptConfig> decrypt_config = runs_->GetDecryptConfig();
std::unique_ptr<DecryptConfig> decrypt_config = runs_->GetDecryptConfig();
if (!decrypt_config ||
!decryptor_source_->DecryptSampleBuffer(decrypt_config.get(),
stream_sample->writable_data(),

View File

@ -10,13 +10,11 @@
#include <stdint.h>
#include <map>
#include <memory>
#include <vector>
#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<DecryptorSource> decryptor_source_;
std::unique_ptr<DecryptorSource> 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<Movie> moov_;
scoped_ptr<TrackRunIterator> runs_;
std::unique_ptr<Movie> moov_;
std::unique_ptr<TrackRunIterator> runs_;
DISALLOW_COPY_AND_ASSIGN(MP4MediaParser);
};

View File

@ -48,7 +48,7 @@ class MP4MediaParserTest : public testing::Test {
protected:
typedef std::map<int, scoped_refptr<StreamInfo> > StreamMap;
StreamMap stream_map_;
scoped_ptr<MP4MediaParser> parser_;
std::unique_ptr<MP4MediaParser> parser_;
size_t num_streams_;
size_t num_samples_;

View File

@ -85,8 +85,8 @@ MP4Muxer::~MP4Muxer() {}
Status MP4Muxer::Initialize() {
DCHECK(!streams().empty());
scoped_ptr<FileType> ftyp(new FileType);
scoped_ptr<Movie> moov(new Movie);
std::unique_ptr<FileType> ftyp(new FileType);
std::unique_ptr<Movie> 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(

View File

@ -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> segmenter_;
std::unique_ptr<Segmenter> segmenter_;
DISALLOW_COPY_AND_ASSIGN(MP4Muxer);
};

View File

@ -21,9 +21,9 @@ namespace media {
namespace mp4 {
MultiSegmentSegmenter::MultiSegmentSegmenter(const MuxerOptions& options,
scoped_ptr<FileType> ftyp,
scoped_ptr<Movie> moov)
: Segmenter(options, ftyp.Pass(), moov.Pass()),
std::unique_ptr<FileType> ftyp,
std::unique_ptr<Movie> 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<BufferWriter> buffer(new BufferWriter);
std::unique_ptr<BufferWriter> 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<BufferWriter> buffer(new BufferWriter());
std::unique_ptr<BufferWriter> buffer(new BufferWriter());
File* file;
std::string file_name;
if (options().segment_template.empty()) {

View File

@ -31,8 +31,8 @@ struct SegmentType;
class MultiSegmentSegmenter : public Segmenter {
public:
MultiSegmentSegmenter(const MuxerOptions& options,
scoped_ptr<FileType> ftyp,
scoped_ptr<Movie> moov);
std::unique_ptr<FileType> ftyp,
std::unique_ptr<Movie> moov);
~MultiSegmentSegmenter() override;
/// @name Segmenter implementation overrides.
@ -50,7 +50,7 @@ class MultiSegmentSegmenter : public Segmenter {
// Write segment to file.
Status WriteSegment();
scoped_ptr<SegmentType> styp_;
std::unique_ptr<SegmentType> styp_;
uint32_t num_segments_;
DISALLOW_COPY_AND_ASSIGN(MultiSegmentSegmenter);

Some files were not shown because too many files have changed in this diff Show More