Deprecate STLDeleter and string_as_array
1. Replace STLDeleter with unique_ptr in container, which is supported in C++11 2. Replace string_as_array with &string[0] which is guaranteed to work in C++11 Change-Id: I7f39c0e51fc8a3fcbb41313094a0ca6b33db7bf3
This commit is contained in:
parent
ba2a649c00
commit
c3d1dc1733
|
@ -21,7 +21,6 @@
|
||||||
#include "packager/base/files/file_path.h"
|
#include "packager/base/files/file_path.h"
|
||||||
#include "packager/base/logging.h"
|
#include "packager/base/logging.h"
|
||||||
#include "packager/base/path_service.h"
|
#include "packager/base/path_service.h"
|
||||||
#include "packager/base/stl_util.h"
|
|
||||||
#include "packager/base/strings/string_split.h"
|
#include "packager/base/strings/string_split.h"
|
||||||
#include "packager/base/strings/stringprintf.h"
|
#include "packager/base/strings/stringprintf.h"
|
||||||
#include "packager/base/threading/simple_thread.h"
|
#include "packager/base/threading/simple_thread.h"
|
||||||
|
@ -167,12 +166,10 @@ class RemuxJob : public base::SimpleThread {
|
||||||
RemuxJob(std::unique_ptr<Demuxer> demuxer)
|
RemuxJob(std::unique_ptr<Demuxer> demuxer)
|
||||||
: SimpleThread("RemuxJob"), demuxer_(std::move(demuxer)) {}
|
: SimpleThread("RemuxJob"), demuxer_(std::move(demuxer)) {}
|
||||||
|
|
||||||
~RemuxJob() override {
|
~RemuxJob() override {}
|
||||||
STLDeleteElements(&muxers_);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AddMuxer(std::unique_ptr<Muxer> mux) {
|
void AddMuxer(std::unique_ptr<Muxer> mux) {
|
||||||
muxers_.push_back(mux.release());
|
muxers_.push_back(std::move(mux));
|
||||||
}
|
}
|
||||||
|
|
||||||
Demuxer* demuxer() { return demuxer_.get(); }
|
Demuxer* demuxer() { return demuxer_.get(); }
|
||||||
|
@ -185,7 +182,7 @@ class RemuxJob : public base::SimpleThread {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Demuxer> demuxer_;
|
std::unique_ptr<Demuxer> demuxer_;
|
||||||
std::vector<Muxer*> muxers_;
|
std::vector<std::unique_ptr<Muxer>> muxers_;
|
||||||
Status status_;
|
Status status_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(RemuxJob);
|
DISALLOW_COPY_AND_ASSIGN(RemuxJob);
|
||||||
|
@ -248,7 +245,7 @@ bool CreateRemuxJobs(const StreamDescriptorList& stream_descriptors,
|
||||||
KeySource* key_source,
|
KeySource* key_source,
|
||||||
MpdNotifier* mpd_notifier,
|
MpdNotifier* mpd_notifier,
|
||||||
hls::HlsNotifier* hls_notifier,
|
hls::HlsNotifier* hls_notifier,
|
||||||
std::vector<RemuxJob*>* remux_jobs) {
|
std::vector<std::unique_ptr<RemuxJob>>* remux_jobs) {
|
||||||
// No notifiers OR (mpd_notifier XOR hls_notifier); which is NAND.
|
// No notifiers OR (mpd_notifier XOR hls_notifier); which is NAND.
|
||||||
DCHECK(!(mpd_notifier && hls_notifier));
|
DCHECK(!(mpd_notifier && hls_notifier));
|
||||||
DCHECK(remux_jobs);
|
DCHECK(remux_jobs);
|
||||||
|
@ -326,7 +323,7 @@ bool CreateRemuxJobs(const StreamDescriptorList& stream_descriptors,
|
||||||
if (stream_iter->output.empty())
|
if (stream_iter->output.empty())
|
||||||
continue; // just need stream info.
|
continue; // just need stream info.
|
||||||
}
|
}
|
||||||
remux_jobs->push_back(new RemuxJob(std::move(demuxer)));
|
remux_jobs->emplace_back(new RemuxJob(std::move(demuxer)));
|
||||||
previous_input = stream_iter->input;
|
previous_input = stream_iter->input;
|
||||||
}
|
}
|
||||||
DCHECK(!remux_jobs->empty());
|
DCHECK(!remux_jobs->empty());
|
||||||
|
@ -391,29 +388,24 @@ bool CreateRemuxJobs(const StreamDescriptorList& stream_descriptors,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status RunRemuxJobs(const std::vector<RemuxJob*>& remux_jobs) {
|
Status RunRemuxJobs(const std::vector<std::unique_ptr<RemuxJob>>& remux_jobs) {
|
||||||
// Start the job threads.
|
// Start the job threads.
|
||||||
for (std::vector<RemuxJob*>::const_iterator job_iter = remux_jobs.begin();
|
for (const std::unique_ptr<RemuxJob>& job : remux_jobs)
|
||||||
job_iter != remux_jobs.end();
|
job->Start();
|
||||||
++job_iter) {
|
|
||||||
(*job_iter)->Start();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Wait for all jobs to complete or an error occurs.
|
// Wait for all jobs to complete or an error occurs.
|
||||||
Status status;
|
Status status;
|
||||||
bool all_joined;
|
bool all_joined;
|
||||||
do {
|
do {
|
||||||
all_joined = true;
|
all_joined = true;
|
||||||
for (std::vector<RemuxJob*>::const_iterator job_iter = remux_jobs.begin();
|
for (const std::unique_ptr<RemuxJob>& job : remux_jobs) {
|
||||||
job_iter != remux_jobs.end();
|
if (job->HasBeenJoined()) {
|
||||||
++job_iter) {
|
status = job->status();
|
||||||
if ((*job_iter)->HasBeenJoined()) {
|
|
||||||
status = (*job_iter)->status();
|
|
||||||
if (!status.ok())
|
if (!status.ok())
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
all_joined = false;
|
all_joined = false;
|
||||||
(*job_iter)->Join();
|
job->Join();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (!all_joined && status.ok());
|
} while (!all_joined && status.ok());
|
||||||
|
@ -496,8 +488,7 @@ bool RunPackager(const StreamDescriptorList& stream_descriptors) {
|
||||||
master_playlist_name.AsUTF8Unsafe()));
|
master_playlist_name.AsUTF8Unsafe()));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<RemuxJob*> remux_jobs;
|
std::vector<std::unique_ptr<RemuxJob>> remux_jobs;
|
||||||
STLElementDeleter<std::vector<RemuxJob*> > scoped_jobs_deleter(&remux_jobs);
|
|
||||||
FakeClock fake_clock;
|
FakeClock fake_clock;
|
||||||
if (!CreateRemuxJobs(stream_descriptors, muxer_options, &fake_clock,
|
if (!CreateRemuxJobs(stream_descriptors, muxer_options, &fake_clock,
|
||||||
encryption_key_source.get(), mpd_notifier.get(),
|
encryption_key_source.get(), mpd_notifier.get(),
|
||||||
|
|
|
@ -36,7 +36,7 @@ DEFINE_bool(dump_stream_info, false, "Dump demuxed stream info.");
|
||||||
namespace shaka {
|
namespace shaka {
|
||||||
namespace media {
|
namespace media {
|
||||||
|
|
||||||
void DumpStreamInfo(const std::vector<MediaStream*>& streams) {
|
void DumpStreamInfo(const std::vector<std::unique_ptr<MediaStream>>& streams) {
|
||||||
printf("Found %zu stream(s).\n", streams.size());
|
printf("Found %zu stream(s).\n", streams.size());
|
||||||
for (size_t i = 0; i < streams.size(); ++i)
|
for (size_t i = 0; i < streams.size(); ++i)
|
||||||
printf("Stream [%zu] %s\n", i, streams[i]->info()->ToString().c_str());
|
printf("Stream [%zu] %s\n", i, streams[i]->info()->ToString().c_str());
|
||||||
|
@ -180,29 +180,31 @@ bool GetMpdOptions(MpdOptions* mpd_options) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
MediaStream* FindFirstStreamOfType(const std::vector<MediaStream*>& streams,
|
MediaStream* FindFirstStreamOfType(
|
||||||
StreamType stream_type) {
|
const std::vector<std::unique_ptr<MediaStream>>& streams,
|
||||||
typedef std::vector<MediaStream*>::const_iterator StreamIterator;
|
StreamType stream_type) {
|
||||||
for (StreamIterator it = streams.begin(); it != streams.end(); ++it) {
|
for (const std::unique_ptr<MediaStream>& stream : streams) {
|
||||||
if ((*it)->info()->stream_type() == stream_type)
|
if (stream->info()->stream_type() == stream_type)
|
||||||
return *it;
|
return stream.get();
|
||||||
}
|
}
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
MediaStream* FindFirstVideoStream(const std::vector<MediaStream*>& streams) {
|
MediaStream* FindFirstVideoStream(
|
||||||
|
const std::vector<std::unique_ptr<MediaStream>>& streams) {
|
||||||
return FindFirstStreamOfType(streams, kStreamVideo);
|
return FindFirstStreamOfType(streams, kStreamVideo);
|
||||||
}
|
}
|
||||||
MediaStream* FindFirstAudioStream(const std::vector<MediaStream*>& streams) {
|
MediaStream* FindFirstAudioStream(
|
||||||
|
const std::vector<std::unique_ptr<MediaStream>>& streams) {
|
||||||
return FindFirstStreamOfType(streams, kStreamAudio);
|
return FindFirstStreamOfType(streams, kStreamAudio);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AddStreamToMuxer(const std::vector<MediaStream*>& streams,
|
bool AddStreamToMuxer(const std::vector<std::unique_ptr<MediaStream>>& streams,
|
||||||
const std::string& stream_selector,
|
const std::string& stream_selector,
|
||||||
const std::string& language_override,
|
const std::string& language_override,
|
||||||
Muxer* muxer) {
|
Muxer* muxer) {
|
||||||
DCHECK(muxer);
|
DCHECK(muxer);
|
||||||
|
|
||||||
MediaStream* stream = NULL;
|
MediaStream* stream = nullptr;
|
||||||
if (stream_selector == "video") {
|
if (stream_selector == "video") {
|
||||||
stream = FindFirstVideoStream(streams);
|
stream = FindFirstVideoStream(streams);
|
||||||
} else if (stream_selector == "audio") {
|
} else if (stream_selector == "audio") {
|
||||||
|
@ -217,7 +219,7 @@ bool AddStreamToMuxer(const std::vector<MediaStream*>& streams,
|
||||||
<< streams.size() - 1 << "].";
|
<< streams.size() - 1 << "].";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
stream = streams[stream_id];
|
stream = streams[stream_id].get();
|
||||||
DCHECK(stream);
|
DCHECK(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ class Muxer;
|
||||||
struct MuxerOptions;
|
struct MuxerOptions;
|
||||||
|
|
||||||
/// Print all the stream info for the provided strings to standard output.
|
/// Print all the stream info for the provided strings to standard output.
|
||||||
void DumpStreamInfo(const std::vector<MediaStream*>& streams);
|
void DumpStreamInfo(const std::vector<std::unique_ptr<MediaStream>>& streams);
|
||||||
|
|
||||||
/// Create KeySource based on provided command line options for content
|
/// Create KeySource based on provided command line options for content
|
||||||
/// encryption. Also fetches keys.
|
/// encryption. Also fetches keys.
|
||||||
|
@ -60,7 +60,7 @@ bool GetMpdOptions(MpdOptions* mpd_options);
|
||||||
/// @param language_override is a string which, if non-empty, overrides the
|
/// @param language_override is a string which, if non-empty, overrides the
|
||||||
/// stream's language metadata.
|
/// stream's language metadata.
|
||||||
/// @return true if successful, false otherwise.
|
/// @return true if successful, false otherwise.
|
||||||
bool AddStreamToMuxer(const std::vector<MediaStream*>& streams,
|
bool AddStreamToMuxer(const std::vector<std::unique_ptr<MediaStream>>& streams,
|
||||||
const std::string& stream_selector,
|
const std::string& stream_selector,
|
||||||
const std::string& language_override,
|
const std::string& language_override,
|
||||||
Muxer* muxer);
|
Muxer* muxer);
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include "packager/base/logging.h"
|
#include "packager/base/logging.h"
|
||||||
#include "packager/base/strings/stringprintf.h"
|
#include "packager/base/strings/stringprintf.h"
|
||||||
|
@ -125,14 +126,11 @@ MediaPlaylist::MediaPlaylist(MediaPlaylistType type,
|
||||||
const std::string& file_name,
|
const std::string& file_name,
|
||||||
const std::string& name,
|
const std::string& name,
|
||||||
const std::string& group_id)
|
const std::string& group_id)
|
||||||
: file_name_(file_name),
|
: file_name_(file_name), name_(name), group_id_(group_id), type_(type) {
|
||||||
name_(name),
|
|
||||||
group_id_(group_id),
|
|
||||||
type_(type),
|
|
||||||
entries_deleter_(&entries_) {
|
|
||||||
LOG_IF(WARNING, type != MediaPlaylistType::kVod)
|
LOG_IF(WARNING, type != MediaPlaylistType::kVod)
|
||||||
<< "Non VOD Media Playlist is not supported.";
|
<< "Non VOD Media Playlist is not supported.";
|
||||||
}
|
}
|
||||||
|
|
||||||
MediaPlaylist::~MediaPlaylist() {}
|
MediaPlaylist::~MediaPlaylist() {}
|
||||||
|
|
||||||
void MediaPlaylist::SetStreamTypeForTesting(
|
void MediaPlaylist::SetStreamTypeForTesting(
|
||||||
|
@ -174,7 +172,7 @@ void MediaPlaylist::AddSegment(const std::string& file_name,
|
||||||
LOG(WARNING) << "Timescale is not set and the duration for " << duration
|
LOG(WARNING) << "Timescale is not set and the duration for " << duration
|
||||||
<< " cannot be calculated. The output will be wrong.";
|
<< " cannot be calculated. The output will be wrong.";
|
||||||
|
|
||||||
entries_.push_back(new SegmentInfoEntry(file_name, 0.0));
|
entries_.emplace_back(new SegmentInfoEntry(file_name, 0.0));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,7 +184,8 @@ void MediaPlaylist::AddSegment(const std::string& file_name,
|
||||||
const int kBitsInByte = 8;
|
const int kBitsInByte = 8;
|
||||||
const uint64_t bitrate = kBitsInByte * size / segment_duration_seconds;
|
const uint64_t bitrate = kBitsInByte * size / segment_duration_seconds;
|
||||||
max_bitrate_ = std::max(max_bitrate_, bitrate);
|
max_bitrate_ = std::max(max_bitrate_, bitrate);
|
||||||
entries_.push_back(new SegmentInfoEntry(file_name, segment_duration_seconds));
|
entries_.emplace_back(
|
||||||
|
new SegmentInfoEntry(file_name, segment_duration_seconds));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(rkuroiwa): This works for single key format but won't work for multiple
|
// TODO(rkuroiwa): This works for single key format but won't work for multiple
|
||||||
|
@ -200,12 +199,12 @@ void MediaPlaylist::AddSegment(const std::string& file_name,
|
||||||
// Note that when erasing std::list iterators, only the deleted iterators are
|
// Note that when erasing std::list iterators, only the deleted iterators are
|
||||||
// invalidated.
|
// invalidated.
|
||||||
void MediaPlaylist::RemoveOldestSegment() {
|
void MediaPlaylist::RemoveOldestSegment() {
|
||||||
static_assert(std::is_same<decltype(entries_), std::list<HlsEntry*>>::value,
|
static_assert(std::is_same<decltype(entries_),
|
||||||
|
std::list<std::unique_ptr<HlsEntry>>>::value,
|
||||||
"This algorithm assumes std::list.");
|
"This algorithm assumes std::list.");
|
||||||
if (entries_.empty())
|
if (entries_.empty())
|
||||||
return;
|
return;
|
||||||
if (entries_.front()->type() == HlsEntry::EntryType::kExtInf) {
|
if (entries_.front()->type() == HlsEntry::EntryType::kExtInf) {
|
||||||
delete entries_.front();
|
|
||||||
entries_.pop_front();
|
entries_.pop_front();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -223,10 +222,8 @@ void MediaPlaylist::RemoveOldestSegment() {
|
||||||
auto entries_itr = entries_.begin();
|
auto entries_itr = entries_.begin();
|
||||||
++entries_itr;
|
++entries_itr;
|
||||||
if ((*entries_itr)->type() == HlsEntry::EntryType::kExtKey) {
|
if ((*entries_itr)->type() == HlsEntry::EntryType::kExtKey) {
|
||||||
delete entries_.front();
|
|
||||||
entries_.pop_front();
|
entries_.pop_front();
|
||||||
} else {
|
} else {
|
||||||
delete *entries_itr;
|
|
||||||
entries_.erase(entries_itr);
|
entries_.erase(entries_itr);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -235,8 +232,7 @@ void MediaPlaylist::RemoveOldestSegment() {
|
||||||
auto entries_itr = entries_.begin();
|
auto entries_itr = entries_.begin();
|
||||||
++entries_itr;
|
++entries_itr;
|
||||||
if ((*entries_itr)->type() == HlsEntry::EntryType::kExtInf) {
|
if ((*entries_itr)->type() == HlsEntry::EntryType::kExtInf) {
|
||||||
DCHECK((*entries_itr)->type() == HlsEntry::EntryType::kExtInf);
|
DCHECK_EQ((*entries_itr)->type(), HlsEntry::EntryType::kExtInf);
|
||||||
delete *entries_itr;
|
|
||||||
entries_.erase(entries_itr);
|
entries_.erase(entries_itr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -244,10 +240,8 @@ void MediaPlaylist::RemoveOldestSegment() {
|
||||||
++entries_itr;
|
++entries_itr;
|
||||||
// This assumes that there is a segment between 2 EXT-X-KEY entries.
|
// This assumes that there is a segment between 2 EXT-X-KEY entries.
|
||||||
// Which should be the case due to logic in AddEncryptionInfo().
|
// Which should be the case due to logic in AddEncryptionInfo().
|
||||||
DCHECK((*entries_itr)->type() == HlsEntry::EntryType::kExtInf);
|
DCHECK_EQ((*entries_itr)->type(), HlsEntry::EntryType::kExtInf);
|
||||||
delete *entries_itr;
|
|
||||||
entries_.erase(entries_itr);
|
entries_.erase(entries_itr);
|
||||||
delete entries_.front();
|
|
||||||
entries_.pop_front();
|
entries_.pop_front();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,9 +256,8 @@ void MediaPlaylist::AddEncryptionInfo(MediaPlaylist::EncryptionMethod method,
|
||||||
if (entries_.back()->type() == HlsEntry::EntryType::kExtKey)
|
if (entries_.back()->type() == HlsEntry::EntryType::kExtKey)
|
||||||
entries_.pop_back();
|
entries_.pop_back();
|
||||||
}
|
}
|
||||||
entries_.push_back(
|
entries_.emplace_back(new EncryptionInfoEntry(method, url, iv, key_format,
|
||||||
new EncryptionInfoEntry(
|
key_format_versions));
|
||||||
method, url, iv, key_format, key_format_versions));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MediaPlaylist::WriteToFile(media::File* file) {
|
bool MediaPlaylist::WriteToFile(media::File* file) {
|
||||||
|
|
|
@ -8,10 +8,10 @@
|
||||||
#define PACKAGER_HLS_BASE_MEDIA_PLAYLIST_H_
|
#define PACKAGER_HLS_BASE_MEDIA_PLAYLIST_H_
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "packager/base/macros.h"
|
#include "packager/base/macros.h"
|
||||||
#include "packager/base/stl_util.h"
|
|
||||||
#include "packager/mpd/base/media_info.pb.h"
|
#include "packager/mpd/base/media_info.pb.h"
|
||||||
|
|
||||||
namespace shaka {
|
namespace shaka {
|
||||||
|
@ -169,8 +169,7 @@ class MediaPlaylist {
|
||||||
bool target_duration_set_ = false;
|
bool target_duration_set_ = false;
|
||||||
uint32_t target_duration_ = 0;
|
uint32_t target_duration_ = 0;
|
||||||
|
|
||||||
std::list<HlsEntry*> entries_;
|
std::list<std::unique_ptr<HlsEntry>> entries_;
|
||||||
STLElementDeleter<decltype(entries_)> entries_deleter_;
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(MediaPlaylist);
|
DISALLOW_COPY_AND_ASSIGN(MediaPlaylist);
|
||||||
};
|
};
|
||||||
|
|
|
@ -131,8 +131,7 @@ SimpleHlsNotifier::SimpleHlsNotifier(HlsProfile profile,
|
||||||
prefix_(prefix),
|
prefix_(prefix),
|
||||||
output_dir_(output_dir),
|
output_dir_(output_dir),
|
||||||
media_playlist_factory_(new MediaPlaylistFactory()),
|
media_playlist_factory_(new MediaPlaylistFactory()),
|
||||||
master_playlist_(new MasterPlaylist(master_playlist_name)),
|
master_playlist_(new MasterPlaylist(master_playlist_name)) {}
|
||||||
media_playlist_map_deleter_(&media_playlist_map_) {}
|
|
||||||
|
|
||||||
SimpleHlsNotifier::~SimpleHlsNotifier() {}
|
SimpleHlsNotifier::~SimpleHlsNotifier() {}
|
||||||
|
|
||||||
|
@ -174,7 +173,7 @@ bool SimpleHlsNotifier::NotifyNewStream(const MediaInfo& media_info,
|
||||||
base::AutoLock auto_lock(lock_);
|
base::AutoLock auto_lock(lock_);
|
||||||
master_playlist_->AddMediaPlaylist(media_playlist.get());
|
master_playlist_->AddMediaPlaylist(media_playlist.get());
|
||||||
media_playlist_map_.insert(
|
media_playlist_map_.insert(
|
||||||
std::make_pair(*stream_id, media_playlist.release()));
|
std::make_pair(*stream_id, std::move(media_playlist)));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
#include "packager/base/atomic_sequence_num.h"
|
#include "packager/base/atomic_sequence_num.h"
|
||||||
#include "packager/base/macros.h"
|
#include "packager/base/macros.h"
|
||||||
#include "packager/base/stl_util.h"
|
|
||||||
#include "packager/base/synchronization/lock.h"
|
#include "packager/base/synchronization/lock.h"
|
||||||
#include "packager/hls/base/hls_notifier.h"
|
#include "packager/hls/base/hls_notifier.h"
|
||||||
#include "packager/hls/base/master_playlist.h"
|
#include "packager/hls/base/master_playlist.h"
|
||||||
|
@ -82,8 +81,7 @@ class SimpleHlsNotifier : public HlsNotifier {
|
||||||
|
|
||||||
std::unique_ptr<MediaPlaylistFactory> media_playlist_factory_;
|
std::unique_ptr<MediaPlaylistFactory> media_playlist_factory_;
|
||||||
std::unique_ptr<MasterPlaylist> master_playlist_;
|
std::unique_ptr<MasterPlaylist> master_playlist_;
|
||||||
std::map<uint32_t, MediaPlaylist*> media_playlist_map_;
|
std::map<uint32_t, std::unique_ptr<MediaPlaylist>> media_playlist_map_;
|
||||||
STLValueDeleter<decltype(media_playlist_map_)> media_playlist_map_deleter_;
|
|
||||||
|
|
||||||
base::AtomicSequenceNumber sequence_number_;
|
base::AtomicSequenceNumber sequence_number_;
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,8 @@ class SimpleHlsNotifierTest : public ::testing::Test {
|
||||||
notifier->master_playlist_ = std::move(playlist);
|
notifier->master_playlist_ = std::move(playlist);
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::map<uint32_t, MediaPlaylist*>& GetMediaPlaylistMap() {
|
const std::map<uint32_t, std::unique_ptr<MediaPlaylist>>&
|
||||||
|
GetMediaPlaylistMap() {
|
||||||
return notifier_.media_playlist_map_;
|
return notifier_.media_playlist_map_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,15 +6,14 @@
|
||||||
|
|
||||||
#include "packager/media/base/aes_cryptor.h"
|
#include "packager/media/base/aes_cryptor.h"
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include <openssl/aes.h>
|
#include <openssl/aes.h>
|
||||||
#include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
#include <openssl/rand.h>
|
#include <openssl/rand.h>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "packager/base/logging.h"
|
#include "packager/base/logging.h"
|
||||||
#include "packager/base/stl_util.h"
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -58,8 +57,7 @@ bool AesCryptor::Crypt(const std::string& text, std::string* crypt_text) {
|
||||||
crypt_text->resize(text_size + NumPaddingBytes(text_size));
|
crypt_text->resize(text_size + NumPaddingBytes(text_size));
|
||||||
size_t crypt_text_size = crypt_text->size();
|
size_t crypt_text_size = crypt_text->size();
|
||||||
if (!Crypt(reinterpret_cast<const uint8_t*>(text.data()), text_size,
|
if (!Crypt(reinterpret_cast<const uint8_t*>(text.data()), text_size,
|
||||||
reinterpret_cast<uint8_t*>(string_as_array(crypt_text)),
|
reinterpret_cast<uint8_t*>(&(*crypt_text)[0]), &crypt_text_size))
|
||||||
&crypt_text_size))
|
|
||||||
return false;
|
return false;
|
||||||
DCHECK_LE(crypt_text_size, crypt_text->size());
|
DCHECK_LE(crypt_text_size, crypt_text->size());
|
||||||
crypt_text->resize(crypt_text_size);
|
crypt_text->resize(crypt_text_size);
|
||||||
|
@ -132,5 +130,3 @@ size_t AesCryptor::NumPaddingBytes(size_t size) const {
|
||||||
|
|
||||||
} // namespace media
|
} // namespace media
|
||||||
} // namespace shaka
|
} // namespace shaka
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
#include "packager/media/base/decryptor_source.h"
|
#include "packager/media/base/decryptor_source.h"
|
||||||
|
|
||||||
#include "packager/base/logging.h"
|
#include "packager/base/logging.h"
|
||||||
#include "packager/base/stl_util.h"
|
|
||||||
#include "packager/media/base/aes_decryptor.h"
|
#include "packager/media/base/aes_decryptor.h"
|
||||||
#include "packager/media/base/aes_pattern_cryptor.h"
|
#include "packager/media/base/aes_pattern_cryptor.h"
|
||||||
|
|
||||||
|
@ -18,9 +17,7 @@ DecryptorSource::DecryptorSource(KeySource* key_source)
|
||||||
: key_source_(key_source) {
|
: key_source_(key_source) {
|
||||||
CHECK(key_source);
|
CHECK(key_source);
|
||||||
}
|
}
|
||||||
DecryptorSource::~DecryptorSource() {
|
DecryptorSource::~DecryptorSource() {}
|
||||||
STLDeleteValues(&decryptor_map_);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DecryptorSource::DecryptSampleBuffer(const DecryptConfig* decrypt_config,
|
bool DecryptorSource::DecryptSampleBuffer(const DecryptConfig* decrypt_config,
|
||||||
uint8_t* buffer,
|
uint8_t* buffer,
|
||||||
|
@ -29,7 +26,7 @@ bool DecryptorSource::DecryptSampleBuffer(const DecryptConfig* decrypt_config,
|
||||||
DCHECK(buffer);
|
DCHECK(buffer);
|
||||||
|
|
||||||
// Get the decryptor object.
|
// Get the decryptor object.
|
||||||
AesCryptor* decryptor;
|
AesCryptor* decryptor = nullptr;
|
||||||
auto found = decryptor_map_.find(decrypt_config->key_id());
|
auto found = decryptor_map_.find(decrypt_config->key_id());
|
||||||
if (found == decryptor_map_.end()) {
|
if (found == decryptor_map_.end()) {
|
||||||
// Create new AesDecryptor based on decryption mode.
|
// Create new AesDecryptor based on decryption mode.
|
||||||
|
@ -74,10 +71,10 @@ bool DecryptorSource::DecryptSampleBuffer(const DecryptConfig* decrypt_config,
|
||||||
LOG(ERROR) << "Failed to initialize AesDecryptor for decryption.";
|
LOG(ERROR) << "Failed to initialize AesDecryptor for decryption.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
decryptor = aes_decryptor.release();
|
decryptor = aes_decryptor.get();
|
||||||
decryptor_map_[decrypt_config->key_id()] = decryptor;
|
decryptor_map_[decrypt_config->key_id()] = std::move(aes_decryptor);
|
||||||
} else {
|
} else {
|
||||||
decryptor = found->second;
|
decryptor = found->second.get();
|
||||||
}
|
}
|
||||||
if (!decryptor->SetIv(decrypt_config->iv())) {
|
if (!decryptor->SetIv(decrypt_config->iv())) {
|
||||||
LOG(ERROR) << "Invalid initialization vector.";
|
LOG(ERROR) << "Invalid initialization vector.";
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#define MEDIA_BASE_DECRYPTOR_SOURCE_H_
|
#define MEDIA_BASE_DECRYPTOR_SOURCE_H_
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "packager/media/base/aes_decryptor.h"
|
#include "packager/media/base/aes_decryptor.h"
|
||||||
|
@ -29,7 +30,7 @@ class DecryptorSource {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
KeySource* key_source_;
|
KeySource* key_source_;
|
||||||
std::map<std::vector<uint8_t>, AesCryptor*> decryptor_map_;
|
std::map<std::vector<uint8_t>, std::unique_ptr<AesCryptor>> decryptor_map_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(DecryptorSource);
|
DISALLOW_COPY_AND_ASSIGN(DecryptorSource);
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
|
|
||||||
#include "packager/base/bind.h"
|
#include "packager/base/bind.h"
|
||||||
#include "packager/base/logging.h"
|
#include "packager/base/logging.h"
|
||||||
#include "packager/base/stl_util.h"
|
|
||||||
#include "packager/media/base/decryptor_source.h"
|
#include "packager/media/base/decryptor_source.h"
|
||||||
#include "packager/media/base/key_source.h"
|
#include "packager/media/base/key_source.h"
|
||||||
#include "packager/media/base/media_sample.h"
|
#include "packager/media/base/media_sample.h"
|
||||||
|
@ -46,7 +45,6 @@ Demuxer::Demuxer(const std::string& file_name)
|
||||||
Demuxer::~Demuxer() {
|
Demuxer::~Demuxer() {
|
||||||
if (media_file_)
|
if (media_file_)
|
||||||
media_file_->Close();
|
media_file_->Close();
|
||||||
STLDeleteElements(&streams_);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Demuxer::SetKeySource(std::unique_ptr<KeySource> key_source) {
|
void Demuxer::SetKeySource(std::unique_ptr<KeySource> key_source) {
|
||||||
|
@ -121,13 +119,10 @@ Status Demuxer::Initialize() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Demuxer::ParserInitEvent(
|
void Demuxer::ParserInitEvent(
|
||||||
const std::vector<scoped_refptr<StreamInfo> >& streams) {
|
const std::vector<scoped_refptr<StreamInfo>>& stream_infos) {
|
||||||
init_event_received_ = true;
|
init_event_received_ = true;
|
||||||
|
for (const scoped_refptr<StreamInfo>& stream_info : stream_infos)
|
||||||
std::vector<scoped_refptr<StreamInfo> >::const_iterator it = streams.begin();
|
streams_.emplace_back(new MediaStream(stream_info, this));
|
||||||
for (; it != streams.end(); ++it) {
|
|
||||||
streams_.push_back(new MediaStream(*it, this));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Demuxer::QueuedSample::QueuedSample(uint32_t local_track_id,
|
Demuxer::QueuedSample::QueuedSample(uint32_t local_track_id,
|
||||||
|
@ -157,10 +152,9 @@ bool Demuxer::NewSampleEvent(uint32_t track_id,
|
||||||
|
|
||||||
bool Demuxer::PushSample(uint32_t track_id,
|
bool Demuxer::PushSample(uint32_t track_id,
|
||||||
const scoped_refptr<MediaSample>& sample) {
|
const scoped_refptr<MediaSample>& sample) {
|
||||||
std::vector<MediaStream*>::iterator it = streams_.begin();
|
for (const std::unique_ptr<MediaStream>& stream : streams_) {
|
||||||
for (; it != streams_.end(); ++it) {
|
if (track_id == stream->info()->track_id()) {
|
||||||
if (track_id == (*it)->info()->track_id()) {
|
Status status = stream->PushSample(sample);
|
||||||
Status status = (*it)->PushSample(sample);
|
|
||||||
if (!status.ok())
|
if (!status.ok())
|
||||||
LOG(ERROR) << "Demuxer::PushSample failed with " << status;
|
LOG(ERROR) << "Demuxer::PushSample failed with " << status;
|
||||||
return status.ok();
|
return status.ok();
|
||||||
|
@ -176,10 +170,8 @@ Status Demuxer::Run() {
|
||||||
LOG(INFO) << "Demuxer::Run() on file '" << file_name_ << "'.";
|
LOG(INFO) << "Demuxer::Run() on file '" << file_name_ << "'.";
|
||||||
|
|
||||||
// Start the streams.
|
// Start the streams.
|
||||||
for (std::vector<MediaStream*>::iterator it = streams_.begin();
|
for (const std::unique_ptr<MediaStream>& stream : streams_) {
|
||||||
it != streams_.end();
|
status = stream->Start(MediaStream::kPush);
|
||||||
++it) {
|
|
||||||
status = (*it)->Start(MediaStream::kPush);
|
|
||||||
if (!status.ok())
|
if (!status.ok())
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -193,10 +185,8 @@ Status Demuxer::Run() {
|
||||||
if (status.error_code() == error::END_OF_STREAM) {
|
if (status.error_code() == error::END_OF_STREAM) {
|
||||||
// Push EOS sample to muxer to indicate end of stream.
|
// Push EOS sample to muxer to indicate end of stream.
|
||||||
const scoped_refptr<MediaSample>& sample = MediaSample::CreateEOSBuffer();
|
const scoped_refptr<MediaSample>& sample = MediaSample::CreateEOSBuffer();
|
||||||
for (std::vector<MediaStream*>::iterator it = streams_.begin();
|
for (const std::unique_ptr<MediaStream>& stream : streams_) {
|
||||||
it != streams_.end();
|
status = stream->PushSample(sample);
|
||||||
++it) {
|
|
||||||
status = (*it)->PushSample(sample);
|
|
||||||
if (!status.ok())
|
if (!status.ok())
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,9 @@ class Demuxer {
|
||||||
/// add or remove streams from the returned vector, but the caller is
|
/// add or remove streams from the returned vector, but the caller is
|
||||||
/// allowed to change the internal state of the streams in the vector
|
/// allowed to change the internal state of the streams in the vector
|
||||||
/// through MediaStream APIs.
|
/// through MediaStream APIs.
|
||||||
const std::vector<MediaStream*>& streams() { return streams_; }
|
const std::vector<std::unique_ptr<MediaStream>>& streams() {
|
||||||
|
return streams_;
|
||||||
|
}
|
||||||
|
|
||||||
/// @return Container name (type). Value is CONTAINER_UNKNOWN if the demuxer
|
/// @return Container name (type). Value is CONTAINER_UNKNOWN if the demuxer
|
||||||
/// is not initialized.
|
/// is not initialized.
|
||||||
|
@ -97,7 +99,7 @@ class Demuxer {
|
||||||
// Queued samples received in NewSampleEvent() before ParserInitEvent().
|
// Queued samples received in NewSampleEvent() before ParserInitEvent().
|
||||||
std::deque<QueuedSample> queued_samples_;
|
std::deque<QueuedSample> queued_samples_;
|
||||||
std::unique_ptr<MediaParser> parser_;
|
std::unique_ptr<MediaParser> parser_;
|
||||||
std::vector<MediaStream*> streams_;
|
std::vector<std::unique_ptr<MediaStream>> streams_;
|
||||||
MediaContainerName container_name_;
|
MediaContainerName container_name_;
|
||||||
std::unique_ptr<uint8_t[]> buffer_;
|
std::unique_ptr<uint8_t[]> buffer_;
|
||||||
std::unique_ptr<KeySource> key_source_;
|
std::unique_ptr<KeySource> key_source_;
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
|
|
||||||
#include "packager/base/logging.h"
|
#include "packager/base/logging.h"
|
||||||
#include "packager/base/sha1.h"
|
#include "packager/base/sha1.h"
|
||||||
#include "packager/base/stl_util.h"
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -112,10 +111,8 @@ bool RsaPrivateKey::Decrypt(const std::string& encrypted_message,
|
||||||
|
|
||||||
decrypted_message->resize(rsa_size);
|
decrypted_message->resize(rsa_size);
|
||||||
int decrypted_size = RSA_private_decrypt(
|
int decrypted_size = RSA_private_decrypt(
|
||||||
rsa_size,
|
rsa_size, reinterpret_cast<const uint8_t*>(encrypted_message.data()),
|
||||||
reinterpret_cast<const uint8_t*>(encrypted_message.data()),
|
reinterpret_cast<uint8_t*>(&(*decrypted_message)[0]), rsa_key_,
|
||||||
reinterpret_cast<uint8_t*>(string_as_array(decrypted_message)),
|
|
||||||
rsa_key_,
|
|
||||||
RSA_PKCS1_OAEP_PADDING);
|
RSA_PKCS1_OAEP_PADDING);
|
||||||
|
|
||||||
if (decrypted_size == -1) {
|
if (decrypted_size == -1) {
|
||||||
|
@ -141,12 +138,9 @@ bool RsaPrivateKey::GenerateSignature(const std::string& message,
|
||||||
size_t rsa_size = RSA_size(rsa_key_);
|
size_t rsa_size = RSA_size(rsa_key_);
|
||||||
std::vector<uint8_t> padded_digest(rsa_size);
|
std::vector<uint8_t> padded_digest(rsa_size);
|
||||||
if (!RSA_padding_add_PKCS1_PSS_mgf1(
|
if (!RSA_padding_add_PKCS1_PSS_mgf1(
|
||||||
rsa_key_,
|
rsa_key_, &padded_digest[0],
|
||||||
&padded_digest[0],
|
reinterpret_cast<uint8_t*>(&message_digest[0]), EVP_sha1(),
|
||||||
reinterpret_cast<uint8_t*>(string_as_array(&message_digest)),
|
EVP_sha1(), kPssSaltLength)) {
|
||||||
EVP_sha1(),
|
|
||||||
EVP_sha1(),
|
|
||||||
kPssSaltLength)) {
|
|
||||||
LOG(ERROR) << "RSA padding failure: " << ERR_error_string(ERR_get_error(),
|
LOG(ERROR) << "RSA padding failure: " << ERR_error_string(ERR_get_error(),
|
||||||
NULL);
|
NULL);
|
||||||
return false;
|
return false;
|
||||||
|
@ -155,11 +149,8 @@ bool RsaPrivateKey::GenerateSignature(const std::string& message,
|
||||||
// Encrypt PSS padded digest.
|
// Encrypt PSS padded digest.
|
||||||
signature->resize(rsa_size);
|
signature->resize(rsa_size);
|
||||||
int signature_size = RSA_private_encrypt(
|
int signature_size = RSA_private_encrypt(
|
||||||
padded_digest.size(),
|
padded_digest.size(), &padded_digest[0],
|
||||||
&padded_digest[0],
|
reinterpret_cast<uint8_t*>(&(*signature)[0]), rsa_key_, RSA_NO_PADDING);
|
||||||
reinterpret_cast<uint8_t*>(string_as_array(signature)),
|
|
||||||
rsa_key_,
|
|
||||||
RSA_NO_PADDING);
|
|
||||||
|
|
||||||
if (signature_size != static_cast<int>(rsa_size)) {
|
if (signature_size != static_cast<int>(rsa_size)) {
|
||||||
LOG(ERROR) << "RSA private encrypt failure: " << ERR_error_string(
|
LOG(ERROR) << "RSA private encrypt failure: " << ERR_error_string(
|
||||||
|
@ -192,12 +183,11 @@ bool RsaPublicKey::Encrypt(const std::string& clear_message,
|
||||||
|
|
||||||
size_t rsa_size = RSA_size(rsa_key_);
|
size_t rsa_size = RSA_size(rsa_key_);
|
||||||
encrypted_message->resize(rsa_size);
|
encrypted_message->resize(rsa_size);
|
||||||
int encrypted_size = RSA_public_encrypt(
|
int encrypted_size =
|
||||||
clear_message.size(),
|
RSA_public_encrypt(clear_message.size(),
|
||||||
reinterpret_cast<const uint8_t*>(clear_message.data()),
|
reinterpret_cast<const uint8_t*>(clear_message.data()),
|
||||||
reinterpret_cast<uint8_t*>(string_as_array(encrypted_message)),
|
reinterpret_cast<uint8_t*>(&(*encrypted_message)[0]),
|
||||||
rsa_key_,
|
rsa_key_, RSA_PKCS1_OAEP_PADDING);
|
||||||
RSA_PKCS1_OAEP_PADDING);
|
|
||||||
|
|
||||||
if (encrypted_size != static_cast<int>(rsa_size)) {
|
if (encrypted_size != static_cast<int>(rsa_size)) {
|
||||||
LOG(ERROR) << "RSA public encrypt failure: " << ERR_error_string(
|
LOG(ERROR) << "RSA public encrypt failure: " << ERR_error_string(
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
#include "packager/media/base/video_stream_info.h"
|
#include "packager/media/base/video_stream_info.h"
|
||||||
|
|
||||||
#include "packager/base/logging.h"
|
#include "packager/base/logging.h"
|
||||||
#include "packager/base/stl_util.h"
|
|
||||||
#include "packager/base/strings/string_number_conversions.h"
|
#include "packager/base/strings/string_number_conversions.h"
|
||||||
#include "packager/base/strings/string_util.h"
|
#include "packager/base/strings/string_util.h"
|
||||||
#include "packager/base/strings/stringprintf.h"
|
#include "packager/base/strings/stringprintf.h"
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
#include "packager/base/json/json_reader.h"
|
#include "packager/base/json/json_reader.h"
|
||||||
#include "packager/base/json/json_writer.h"
|
#include "packager/base/json/json_writer.h"
|
||||||
#include "packager/base/memory/ref_counted.h"
|
#include "packager/base/memory/ref_counted.h"
|
||||||
#include "packager/base/stl_util.h"
|
|
||||||
#include "packager/media/base/fixed_key_source.h"
|
#include "packager/media/base/fixed_key_source.h"
|
||||||
#include "packager/media/base/http_key_fetcher.h"
|
#include "packager/media/base/http_key_fetcher.h"
|
||||||
#include "packager/media/base/producer_consumer_queue.h"
|
#include "packager/media/base/producer_consumer_queue.h"
|
||||||
|
@ -120,14 +119,12 @@ class WidevineKeySource::RefCountedEncryptionKeyMap
|
||||||
encryption_key_map_.swap(*encryption_key_map);
|
encryption_key_map_.swap(*encryption_key_map);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<KeySource::TrackType, EncryptionKey*>& map() {
|
const EncryptionKeyMap& map() { return encryption_key_map_; }
|
||||||
return encryption_key_map_;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class base::RefCountedThreadSafe<RefCountedEncryptionKeyMap>;
|
friend class base::RefCountedThreadSafe<RefCountedEncryptionKeyMap>;
|
||||||
|
|
||||||
~RefCountedEncryptionKeyMap() { STLDeleteValues(&encryption_key_map_); }
|
~RefCountedEncryptionKeyMap() {}
|
||||||
|
|
||||||
EncryptionKeyMap encryption_key_map_;
|
EncryptionKeyMap encryption_key_map_;
|
||||||
|
|
||||||
|
@ -159,7 +156,6 @@ WidevineKeySource::~WidevineKeySource() {
|
||||||
start_key_production_.Signal();
|
start_key_production_.Signal();
|
||||||
key_production_thread_.Join();
|
key_production_thread_.Join();
|
||||||
}
|
}
|
||||||
STLDeleteValues(&encryption_key_map_);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Status WidevineKeySource::FetchKeys(const std::vector<uint8_t>& content_id,
|
Status WidevineKeySource::FetchKeys(const std::vector<uint8_t>& content_id,
|
||||||
|
@ -243,12 +239,9 @@ Status WidevineKeySource::GetKey(TrackType track_type, EncryptionKey* key) {
|
||||||
Status WidevineKeySource::GetKey(const std::vector<uint8_t>& key_id,
|
Status WidevineKeySource::GetKey(const std::vector<uint8_t>& key_id,
|
||||||
EncryptionKey* key) {
|
EncryptionKey* key) {
|
||||||
DCHECK(key);
|
DCHECK(key);
|
||||||
for (std::map<TrackType, EncryptionKey*>::iterator iter =
|
for (const auto& pair : encryption_key_map_) {
|
||||||
encryption_key_map_.begin();
|
if (pair.second->key_id == key_id) {
|
||||||
iter != encryption_key_map_.end();
|
*key = *pair.second;
|
||||||
++iter) {
|
|
||||||
if (iter->second->key_id == key_id) {
|
|
||||||
*key = *iter->second;
|
|
||||||
return Status::OK;
|
return Status::OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -307,12 +300,13 @@ Status WidevineKeySource::GetKeyInternal(uint32_t crypto_period_index,
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
EncryptionKeyMap& encryption_key_map = ref_counted_encryption_key_map->map();
|
const EncryptionKeyMap& encryption_key_map =
|
||||||
|
ref_counted_encryption_key_map->map();
|
||||||
if (encryption_key_map.find(track_type) == encryption_key_map.end()) {
|
if (encryption_key_map.find(track_type) == encryption_key_map.end()) {
|
||||||
return Status(error::INTERNAL_ERROR,
|
return Status(error::INTERNAL_ERROR,
|
||||||
"Cannot find key of type " + TrackTypeToString(track_type));
|
"Cannot find key of type " + TrackTypeToString(track_type));
|
||||||
}
|
}
|
||||||
*key = *encryption_key_map[track_type];
|
*key = *encryption_key_map.at(track_type);
|
||||||
return Status::OK;
|
return Status::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -568,7 +562,7 @@ bool WidevineKeySource::ExtractEncryptionKey(
|
||||||
|
|
||||||
encryption_key->key_system_info.push_back(info);
|
encryption_key->key_system_info.push_back(info);
|
||||||
}
|
}
|
||||||
encryption_key_map[track_type] = encryption_key.release();
|
encryption_key_map[track_type] = std::move(encryption_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the flag exists, create a common system ID PSSH box that contains the
|
// If the flag exists, create a common system ID PSSH box that contains the
|
||||||
|
@ -594,7 +588,7 @@ bool WidevineKeySource::ExtractEncryptionKey(
|
||||||
|
|
||||||
DCHECK(!encryption_key_map.empty());
|
DCHECK(!encryption_key_map.empty());
|
||||||
if (!enable_key_rotation) {
|
if (!enable_key_rotation) {
|
||||||
encryption_key_map_ = encryption_key_map;
|
encryption_key_map_.swap(encryption_key_map);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return PushToKeyPool(&encryption_key_map);
|
return PushToKeyPool(&encryption_key_map);
|
||||||
|
|
|
@ -67,7 +67,7 @@ class WidevineKeySource : public KeySource {
|
||||||
ClosureThread key_production_thread_;
|
ClosureThread key_production_thread_;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::map<TrackType, EncryptionKey*> EncryptionKeyMap;
|
typedef std::map<TrackType, std::unique_ptr<EncryptionKey>> EncryptionKeyMap;
|
||||||
class RefCountedEncryptionKeyMap;
|
class RefCountedEncryptionKeyMap;
|
||||||
typedef ProducerConsumerQueue<scoped_refptr<RefCountedEncryptionKeyMap> >
|
typedef ProducerConsumerQueue<scoped_refptr<RefCountedEncryptionKeyMap> >
|
||||||
EncryptionKeyQueue;
|
EncryptionKeyQueue;
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include "packager/base/logging.h"
|
#include "packager/base/logging.h"
|
||||||
#include "packager/base/stl_util.h"
|
|
||||||
#include "packager/media/base/buffer_reader.h"
|
#include "packager/media/base/buffer_reader.h"
|
||||||
|
|
||||||
namespace shaka {
|
namespace shaka {
|
||||||
|
@ -184,17 +183,14 @@ static_assert(arraysize(kTableSarWidth) == arraysize(kTableSarHeight),
|
||||||
|
|
||||||
H264Parser::H264Parser() {}
|
H264Parser::H264Parser() {}
|
||||||
|
|
||||||
H264Parser::~H264Parser() {
|
H264Parser::~H264Parser() {}
|
||||||
STLDeleteValues(&active_SPSes_);
|
|
||||||
STLDeleteValues(&active_PPSes_);
|
|
||||||
}
|
|
||||||
|
|
||||||
const H264Pps* H264Parser::GetPps(int pps_id) {
|
const H264Pps* H264Parser::GetPps(int pps_id) {
|
||||||
return active_PPSes_[pps_id];
|
return active_PPSes_[pps_id].get();
|
||||||
}
|
}
|
||||||
|
|
||||||
const H264Sps* H264Parser::GetSps(int sps_id) {
|
const H264Sps* H264Parser::GetSps(int sps_id) {
|
||||||
return active_SPSes_[sps_id];
|
return active_SPSes_[sps_id].get();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default scaling lists (per spec).
|
// Default scaling lists (per spec).
|
||||||
|
@ -702,8 +698,7 @@ H264Parser::Result H264Parser::ParseSps(const Nalu& nalu, int* sps_id) {
|
||||||
|
|
||||||
// If an SPS with the same id already exists, replace it.
|
// If an SPS with the same id already exists, replace it.
|
||||||
*sps_id = sps->seq_parameter_set_id;
|
*sps_id = sps->seq_parameter_set_id;
|
||||||
delete active_SPSes_[*sps_id];
|
active_SPSes_[*sps_id] = std::move(sps);
|
||||||
active_SPSes_[*sps_id] = sps.release();
|
|
||||||
|
|
||||||
return kOk;
|
return kOk;
|
||||||
}
|
}
|
||||||
|
@ -776,8 +771,7 @@ H264Parser::Result H264Parser::ParsePps(const Nalu& nalu, int* pps_id) {
|
||||||
|
|
||||||
// If a PPS with the same id already exists, replace it.
|
// If a PPS with the same id already exists, replace it.
|
||||||
*pps_id = pps->pic_parameter_set_id;
|
*pps_id = pps->pic_parameter_set_id;
|
||||||
delete active_PPSes_[*pps_id];
|
active_PPSes_[*pps_id] = std::move(pps);
|
||||||
active_PPSes_[*pps_id] = pps.release();
|
|
||||||
|
|
||||||
return kOk;
|
return kOk;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include "packager/media/codecs/h26x_bit_reader.h"
|
#include "packager/media/codecs/h26x_bit_reader.h"
|
||||||
#include "packager/media/codecs/nalu_reader.h"
|
#include "packager/media/codecs/nalu_reader.h"
|
||||||
|
@ -324,8 +325,8 @@ class H264Parser {
|
||||||
Result ParseDecRefPicMarking(H26xBitReader* br, H264SliceHeader* shdr);
|
Result ParseDecRefPicMarking(H26xBitReader* br, H264SliceHeader* shdr);
|
||||||
|
|
||||||
// PPSes and SPSes stored for future reference.
|
// PPSes and SPSes stored for future reference.
|
||||||
typedef std::map<int, H264Sps*> SpsById;
|
typedef std::map<int, std::unique_ptr<H264Sps>> SpsById;
|
||||||
typedef std::map<int, H264Pps*> PpsById;
|
typedef std::map<int, std::unique_ptr<H264Pps>> PpsById;
|
||||||
SpsById active_SPSes_;
|
SpsById active_SPSes_;
|
||||||
PpsById active_PPSes_;
|
PpsById active_PPSes_;
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "packager/base/logging.h"
|
#include "packager/base/logging.h"
|
||||||
#include "packager/base/stl_util.h"
|
|
||||||
#include "packager/media/base/macros.h"
|
#include "packager/media/base/macros.h"
|
||||||
#include "packager/media/codecs/nalu_reader.h"
|
#include "packager/media/codecs/nalu_reader.h"
|
||||||
|
|
||||||
|
@ -179,10 +178,7 @@ H265SliceHeader::H265SliceHeader() {}
|
||||||
H265SliceHeader::~H265SliceHeader() {}
|
H265SliceHeader::~H265SliceHeader() {}
|
||||||
|
|
||||||
H265Parser::H265Parser() {}
|
H265Parser::H265Parser() {}
|
||||||
H265Parser::~H265Parser() {
|
H265Parser::~H265Parser() {}
|
||||||
STLDeleteValues(&active_spses_);
|
|
||||||
STLDeleteValues(&active_ppses_);
|
|
||||||
}
|
|
||||||
|
|
||||||
H265Parser::Result H265Parser::ParseSliceHeader(const Nalu& nalu,
|
H265Parser::Result H265Parser::ParseSliceHeader(const Nalu& nalu,
|
||||||
H265SliceHeader* slice_header) {
|
H265SliceHeader* slice_header) {
|
||||||
|
@ -504,8 +500,7 @@ H265Parser::Result H265Parser::ParsePps(const Nalu& nalu, int* pps_id) {
|
||||||
|
|
||||||
// This will replace any existing PPS instance.
|
// This will replace any existing PPS instance.
|
||||||
*pps_id = pps->pic_parameter_set_id;
|
*pps_id = pps->pic_parameter_set_id;
|
||||||
delete active_ppses_[*pps_id];
|
active_ppses_[*pps_id] = std::move(pps);
|
||||||
active_ppses_[*pps_id] = pps.release();
|
|
||||||
|
|
||||||
return kOk;
|
return kOk;
|
||||||
}
|
}
|
||||||
|
@ -621,18 +616,17 @@ H265Parser::Result H265Parser::ParseSps(const Nalu& nalu, int* sps_id) {
|
||||||
|
|
||||||
// This will replace any existing SPS instance.
|
// This will replace any existing SPS instance.
|
||||||
*sps_id = sps->seq_parameter_set_id;
|
*sps_id = sps->seq_parameter_set_id;
|
||||||
delete active_spses_[*sps_id];
|
active_spses_[*sps_id] = std::move(sps);
|
||||||
active_spses_[*sps_id] = sps.release();
|
|
||||||
|
|
||||||
return kOk;
|
return kOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
const H265Pps* H265Parser::GetPps(int pps_id) {
|
const H265Pps* H265Parser::GetPps(int pps_id) {
|
||||||
return active_ppses_[pps_id];
|
return active_ppses_[pps_id].get();
|
||||||
}
|
}
|
||||||
|
|
||||||
const H265Sps* H265Parser::GetSps(int sps_id) {
|
const H265Sps* H265Parser::GetSps(int sps_id) {
|
||||||
return active_spses_[sps_id];
|
return active_spses_[sps_id].get();
|
||||||
}
|
}
|
||||||
|
|
||||||
H265Parser::Result H265Parser::ParseVuiParameters(int max_num_sub_layers_minus1,
|
H265Parser::Result H265Parser::ParseVuiParameters(int max_num_sub_layers_minus1,
|
||||||
|
|
|
@ -342,8 +342,8 @@ class H265Parser {
|
||||||
bool sub_pic_hdr_params_present_flag,
|
bool sub_pic_hdr_params_present_flag,
|
||||||
H26xBitReader* br);
|
H26xBitReader* br);
|
||||||
|
|
||||||
typedef std::map<int, H265Sps*> SpsById;
|
typedef std::map<int, std::unique_ptr<H265Sps>> SpsById;
|
||||||
typedef std::map<int, H265Pps*> PpsById;
|
typedef std::map<int, std::unique_ptr<H265Pps>> PpsById;
|
||||||
|
|
||||||
SpsById active_spses_;
|
SpsById active_spses_;
|
||||||
PpsById active_ppses_;
|
PpsById active_ppses_;
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include "packager/base/bind.h"
|
#include "packager/base/bind.h"
|
||||||
#include "packager/base/stl_util.h"
|
|
||||||
#include "packager/media/base/media_sample.h"
|
#include "packager/media/base/media_sample.h"
|
||||||
#include "packager/media/base/stream_info.h"
|
#include "packager/media/base/stream_info.h"
|
||||||
#include "packager/media/formats/mp2t/es_parser.h"
|
#include "packager/media/formats/mp2t/es_parser.h"
|
||||||
|
@ -153,9 +152,7 @@ Mp2tMediaParser::Mp2tMediaParser()
|
||||||
is_initialized_(false) {
|
is_initialized_(false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Mp2tMediaParser::~Mp2tMediaParser() {
|
Mp2tMediaParser::~Mp2tMediaParser() {}
|
||||||
STLDeleteValues(&pids_);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Mp2tMediaParser::Init(
|
void Mp2tMediaParser::Init(
|
||||||
const InitCB& init_cb,
|
const InitCB& init_cb,
|
||||||
|
@ -174,14 +171,13 @@ bool Mp2tMediaParser::Flush() {
|
||||||
DVLOG(1) << "Mp2tMediaParser::Flush";
|
DVLOG(1) << "Mp2tMediaParser::Flush";
|
||||||
|
|
||||||
// Flush the buffers and reset the pids.
|
// Flush the buffers and reset the pids.
|
||||||
for (std::map<int, PidState*>::iterator it = pids_.begin();
|
for (const auto& pair : pids_) {
|
||||||
it != pids_.end(); ++it) {
|
DVLOG(1) << "Flushing PID: " << pair.first;
|
||||||
DVLOG(1) << "Flushing PID: " << it->first;
|
PidState* pid_state = pair.second.get();
|
||||||
PidState* pid_state = it->second;
|
|
||||||
pid_state->Flush();
|
pid_state->Flush();
|
||||||
}
|
}
|
||||||
bool result = EmitRemainingSamples();
|
bool result = EmitRemainingSamples();
|
||||||
STLDeleteValues(&pids_);
|
pids_.clear();
|
||||||
|
|
||||||
// Remove any bytes left in the TS buffer.
|
// Remove any bytes left in the TS buffer.
|
||||||
// (i.e. any partial TS packet => less than 188 bytes).
|
// (i.e. any partial TS packet => less than 188 bytes).
|
||||||
|
@ -224,7 +220,8 @@ bool Mp2tMediaParser::Parse(const uint8_t* buf, int size) {
|
||||||
<< " start_unit=" << ts_packet->payload_unit_start_indicator();
|
<< " start_unit=" << ts_packet->payload_unit_start_indicator();
|
||||||
|
|
||||||
// Parse the section.
|
// Parse the section.
|
||||||
std::map<int, PidState*>::iterator it = pids_.find(ts_packet->pid());
|
std::map<int, std::unique_ptr<PidState>>::iterator it =
|
||||||
|
pids_.find(ts_packet->pid());
|
||||||
if (it == pids_.end() &&
|
if (it == pids_.end() &&
|
||||||
ts_packet->pid() == TsSection::kPidPat) {
|
ts_packet->pid() == TsSection::kPidPat) {
|
||||||
// Create the PAT state here if needed.
|
// Create the PAT state here if needed.
|
||||||
|
@ -233,9 +230,10 @@ bool Mp2tMediaParser::Parse(const uint8_t* buf, int size) {
|
||||||
std::unique_ptr<PidState> pat_pid_state(new PidState(
|
std::unique_ptr<PidState> pat_pid_state(new PidState(
|
||||||
ts_packet->pid(), PidState::kPidPat, std::move(pat_section_parser)));
|
ts_packet->pid(), PidState::kPidPat, std::move(pat_section_parser)));
|
||||||
pat_pid_state->Enable();
|
pat_pid_state->Enable();
|
||||||
it = pids_.insert(
|
it = pids_
|
||||||
std::pair<int, PidState*>(ts_packet->pid(),
|
.insert(std::pair<int, std::unique_ptr<PidState>>(
|
||||||
pat_pid_state.release())).first;
|
ts_packet->pid(), std::move(pat_pid_state)))
|
||||||
|
.first;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (it != pids_.end()) {
|
if (it != pids_.end()) {
|
||||||
|
@ -260,11 +258,9 @@ void Mp2tMediaParser::RegisterPmt(int program_number, int pmt_pid) {
|
||||||
|
|
||||||
// Only one TS program is allowed. Ignore the incoming program map table,
|
// Only one TS program is allowed. Ignore the incoming program map table,
|
||||||
// if there is already one registered.
|
// if there is already one registered.
|
||||||
for (std::map<int, PidState*>::iterator it = pids_.begin();
|
for (const auto& pair : pids_) {
|
||||||
it != pids_.end(); ++it) {
|
if (pair.second->pid_type() == PidState::kPidPmt) {
|
||||||
PidState* pid_state = it->second;
|
DVLOG_IF(1, pmt_pid != pair.first) << "More than one program is defined";
|
||||||
if (pid_state->pid_type() == PidState::kPidPmt) {
|
|
||||||
DVLOG_IF(1, pmt_pid != it->first) << "More than one program is defined";
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -276,7 +272,8 @@ void Mp2tMediaParser::RegisterPmt(int program_number, int pmt_pid) {
|
||||||
std::unique_ptr<PidState> pmt_pid_state(
|
std::unique_ptr<PidState> pmt_pid_state(
|
||||||
new PidState(pmt_pid, PidState::kPidPmt, std::move(pmt_section_parser)));
|
new PidState(pmt_pid, PidState::kPidPmt, std::move(pmt_section_parser)));
|
||||||
pmt_pid_state->Enable();
|
pmt_pid_state->Enable();
|
||||||
pids_.insert(std::pair<int, PidState*>(pmt_pid, pmt_pid_state.release()));
|
pids_.insert(std::pair<int, std::unique_ptr<PidState>>(
|
||||||
|
pmt_pid, std::move(pmt_pid_state)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mp2tMediaParser::RegisterPes(int pmt_pid,
|
void Mp2tMediaParser::RegisterPes(int pmt_pid,
|
||||||
|
@ -285,7 +282,7 @@ void Mp2tMediaParser::RegisterPes(int pmt_pid,
|
||||||
DVLOG(1) << "RegisterPes:"
|
DVLOG(1) << "RegisterPes:"
|
||||||
<< " pes_pid=" << pes_pid
|
<< " pes_pid=" << pes_pid
|
||||||
<< " stream_type=" << std::hex << stream_type << std::dec;
|
<< " stream_type=" << std::hex << stream_type << std::dec;
|
||||||
std::map<int, PidState*>::iterator it = pids_.find(pes_pid);
|
std::map<int, std::unique_ptr<PidState>>::iterator it = pids_.find(pes_pid);
|
||||||
if (it != pids_.end())
|
if (it != pids_.end())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -331,7 +328,8 @@ void Mp2tMediaParser::RegisterPes(int pmt_pid,
|
||||||
std::unique_ptr<PidState> pes_pid_state(
|
std::unique_ptr<PidState> pes_pid_state(
|
||||||
new PidState(pes_pid, pid_type, std::move(pes_section_parser)));
|
new PidState(pes_pid, pid_type, std::move(pes_section_parser)));
|
||||||
pes_pid_state->Enable();
|
pes_pid_state->Enable();
|
||||||
pids_.insert(std::pair<int, PidState*>(pes_pid, pes_pid_state.release()));
|
pids_.insert(std::pair<int, std::unique_ptr<PidState>>(
|
||||||
|
pes_pid, std::move(pes_pid_state)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mp2tMediaParser::OnNewStreamInfo(
|
void Mp2tMediaParser::OnNewStreamInfo(
|
||||||
|
|
|
@ -42,7 +42,7 @@ class Mp2tMediaParser : public MediaParser {
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::map<int, PidState*> PidMap;
|
typedef std::map<int, std::unique_ptr<PidState>> PidMap;
|
||||||
|
|
||||||
// Callback invoked to register a Program Map Table.
|
// Callback invoked to register a Program Map Table.
|
||||||
// Note: Does nothing if the PID is already registered.
|
// Note: Does nothing if the PID is already registered.
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include "packager/media/base/aes_encryptor.h"
|
#include "packager/media/base/aes_encryptor.h"
|
||||||
#include "packager/media/base/aes_pattern_cryptor.h"
|
#include "packager/media/base/aes_pattern_cryptor.h"
|
||||||
|
@ -86,12 +87,11 @@ bool EncryptAacSample(AesCryptor* encryptor,
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
PesPacketGenerator::PesPacketGenerator()
|
PesPacketGenerator::PesPacketGenerator() {}
|
||||||
: pes_packets_deleter_(&pes_packets_) {}
|
|
||||||
PesPacketGenerator::~PesPacketGenerator() {}
|
PesPacketGenerator::~PesPacketGenerator() {}
|
||||||
|
|
||||||
bool PesPacketGenerator::Initialize(const StreamInfo& stream_info) {
|
bool PesPacketGenerator::Initialize(const StreamInfo& stream_info) {
|
||||||
STLDeleteElements(&pes_packets_);
|
pes_packets_.clear();
|
||||||
stream_type_ = stream_info.stream_type();
|
stream_type_ = stream_info.stream_type();
|
||||||
|
|
||||||
if (stream_type_ == kStreamVideo) {
|
if (stream_type_ == kStreamVideo) {
|
||||||
|
@ -148,7 +148,7 @@ bool PesPacketGenerator::PushSample(scoped_refptr<MediaSample> sample) {
|
||||||
}
|
}
|
||||||
current_processing_pes_->mutable_data()->swap(byte_stream);
|
current_processing_pes_->mutable_data()->swap(byte_stream);
|
||||||
current_processing_pes_->set_stream_id(kVideoStreamId);
|
current_processing_pes_->set_stream_id(kVideoStreamId);
|
||||||
pes_packets_.push_back(current_processing_pes_.release());
|
pes_packets_.push_back(std::move(current_processing_pes_));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
DCHECK_EQ(stream_type_, kStreamAudio);
|
DCHECK_EQ(stream_type_, kStreamAudio);
|
||||||
|
@ -175,7 +175,7 @@ bool PesPacketGenerator::PushSample(scoped_refptr<MediaSample> sample) {
|
||||||
// packets.
|
// packets.
|
||||||
current_processing_pes_->mutable_data()->swap(aac_frame);
|
current_processing_pes_->mutable_data()->swap(aac_frame);
|
||||||
current_processing_pes_->set_stream_id(kAudioStreamId);
|
current_processing_pes_->set_stream_id(kAudioStreamId);
|
||||||
pes_packets_.push_back(current_processing_pes_.release());
|
pes_packets_.push_back(std::move(current_processing_pes_));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,9 +209,9 @@ size_t PesPacketGenerator::NumberOfReadyPesPackets() {
|
||||||
|
|
||||||
std::unique_ptr<PesPacket> PesPacketGenerator::GetNextPesPacket() {
|
std::unique_ptr<PesPacket> PesPacketGenerator::GetNextPesPacket() {
|
||||||
DCHECK(!pes_packets_.empty());
|
DCHECK(!pes_packets_.empty());
|
||||||
PesPacket* pes = pes_packets_.front();
|
std::unique_ptr<PesPacket> pes = std::move(pes_packets_.front());
|
||||||
pes_packets_.pop_front();
|
pes_packets_.pop_front();
|
||||||
return std::unique_ptr<PesPacket>(pes);
|
return pes;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PesPacketGenerator::Flush() {
|
bool PesPacketGenerator::Flush() {
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "packager/base/stl_util.h"
|
|
||||||
#include "packager/media/base/aes_cryptor.h"
|
#include "packager/media/base/aes_cryptor.h"
|
||||||
#include "packager/media/base/key_source.h"
|
#include "packager/media/base/key_source.h"
|
||||||
#include "packager/media/base/media_sample.h"
|
#include "packager/media/base/media_sample.h"
|
||||||
|
@ -82,8 +81,7 @@ class PesPacketGenerator {
|
||||||
// This can be used to create a PES from multiple audio samples.
|
// This can be used to create a PES from multiple audio samples.
|
||||||
std::unique_ptr<PesPacket> current_processing_pes_;
|
std::unique_ptr<PesPacket> current_processing_pes_;
|
||||||
|
|
||||||
std::list<PesPacket*> pes_packets_;
|
std::list<std::unique_ptr<PesPacket>> pes_packets_;
|
||||||
STLElementDeleter<decltype(pes_packets_)> pes_packets_deleter_;
|
|
||||||
|
|
||||||
// Current encryption key.
|
// Current encryption key.
|
||||||
std::unique_ptr<AesCryptor> encryptor_;
|
std::unique_ptr<AesCryptor> encryptor_;
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "packager/base/logging.h"
|
#include "packager/base/logging.h"
|
||||||
#include "packager/base/stl_util.h"
|
|
||||||
#include "packager/media/base/aes_cryptor.h"
|
#include "packager/media/base/aes_cryptor.h"
|
||||||
#include "packager/media/base/buffer_writer.h"
|
#include "packager/media/base/buffer_writer.h"
|
||||||
#include "packager/media/base/key_source.h"
|
#include "packager/media/base/key_source.h"
|
||||||
|
@ -161,7 +160,7 @@ Segmenter::Segmenter(const MuxerOptions& options,
|
||||||
accumulated_progress_(0),
|
accumulated_progress_(0),
|
||||||
sample_duration_(0u) {}
|
sample_duration_(0u) {}
|
||||||
|
|
||||||
Segmenter::~Segmenter() { STLDeleteElements(&fragmenters_); }
|
Segmenter::~Segmenter() {}
|
||||||
|
|
||||||
Status Segmenter::Initialize(const std::vector<MediaStream*>& streams,
|
Status Segmenter::Initialize(const std::vector<MediaStream*>& streams,
|
||||||
MuxerListener* muxer_listener,
|
MuxerListener* muxer_listener,
|
||||||
|
@ -191,7 +190,8 @@ Status Segmenter::Initialize(const std::vector<MediaStream*>& streams,
|
||||||
sidx_->reference_id = i + 1;
|
sidx_->reference_id = i + 1;
|
||||||
}
|
}
|
||||||
if (!encryption_key_source) {
|
if (!encryption_key_source) {
|
||||||
fragmenters_[i] = new Fragmenter(streams[i]->info(), &moof_->tracks[i]);
|
fragmenters_[i].reset(
|
||||||
|
new Fragmenter(streams[i]->info(), &moof_->tracks[i]));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,13 +220,13 @@ Status Segmenter::Initialize(const std::vector<MediaStream*>& streams,
|
||||||
encryption_key.iv, encryption_key.key_system_info);
|
encryption_key.iv, encryption_key.key_system_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
fragmenters_[i] = new KeyRotationFragmenter(
|
fragmenters_[i].reset(new KeyRotationFragmenter(
|
||||||
moof_.get(), streams[i]->info(), &moof_->tracks[i],
|
moof_.get(), streams[i]->info(), &moof_->tracks[i],
|
||||||
encryption_key_source, track_type,
|
encryption_key_source, track_type,
|
||||||
crypto_period_duration_in_seconds * streams[i]->info()->time_scale(),
|
crypto_period_duration_in_seconds * streams[i]->info()->time_scale(),
|
||||||
clear_lead_in_seconds * streams[i]->info()->time_scale(),
|
clear_lead_in_seconds * streams[i]->info()->time_scale(),
|
||||||
protection_scheme, pattern.crypt_byte_block, pattern.skip_byte_block,
|
protection_scheme, pattern.crypt_byte_block, pattern.skip_byte_block,
|
||||||
muxer_listener_);
|
muxer_listener_));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,11 +258,11 @@ Status Segmenter::Initialize(const std::vector<MediaStream*>& streams,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fragmenters_[i] = new EncryptingFragmenter(
|
fragmenters_[i].reset(new EncryptingFragmenter(
|
||||||
streams[i]->info(), &moof_->tracks[i], std::move(encryption_key),
|
streams[i]->info(), &moof_->tracks[i], std::move(encryption_key),
|
||||||
clear_lead_in_seconds * streams[i]->info()->time_scale(),
|
clear_lead_in_seconds * streams[i]->info()->time_scale(),
|
||||||
protection_scheme, pattern.crypt_byte_block, pattern.skip_byte_block,
|
protection_scheme, pattern.crypt_byte_block, pattern.skip_byte_block,
|
||||||
muxer_listener_);
|
muxer_listener_));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options_.mp4_use_decoding_timestamp_in_timeline) {
|
if (options_.mp4_use_decoding_timestamp_in_timeline) {
|
||||||
|
@ -294,10 +294,8 @@ Status Segmenter::Initialize(const std::vector<MediaStream*>& streams,
|
||||||
}
|
}
|
||||||
|
|
||||||
Status Segmenter::Finalize() {
|
Status Segmenter::Finalize() {
|
||||||
for (std::vector<Fragmenter*>::iterator it = fragmenters_.begin();
|
for (const std::unique_ptr<Fragmenter>& fragmenter : fragmenters_) {
|
||||||
it != fragmenters_.end();
|
Status status = FinalizeFragment(true, fragmenter.get());
|
||||||
++it) {
|
|
||||||
Status status = FinalizeFragment(true, *it);
|
|
||||||
if (!status.ok())
|
if (!status.ok())
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -325,7 +323,7 @@ Status Segmenter::AddSample(const MediaStream* stream,
|
||||||
DCHECK(stream);
|
DCHECK(stream);
|
||||||
DCHECK(stream_map_.find(stream) != stream_map_.end());
|
DCHECK(stream_map_.find(stream) != stream_map_.end());
|
||||||
uint32_t stream_id = stream_map_[stream];
|
uint32_t stream_id = stream_map_[stream];
|
||||||
Fragmenter* fragmenter = fragmenters_[stream_id];
|
Fragmenter* fragmenter = fragmenters_[stream_id].get();
|
||||||
|
|
||||||
// Set default sample duration if it has not been set yet.
|
// Set default sample duration if it has not been set yet.
|
||||||
if (moov_->extends.tracks[stream_id].default_sample_duration == 0) {
|
if (moov_->extends.tracks[stream_id].default_sample_duration == 0) {
|
||||||
|
@ -429,10 +427,8 @@ Status Segmenter::FinalizeFragment(bool finalize_segment,
|
||||||
fragmenter->FinalizeFragment();
|
fragmenter->FinalizeFragment();
|
||||||
|
|
||||||
// Check if all tracks are ready for fragmentation.
|
// Check if all tracks are ready for fragmentation.
|
||||||
for (std::vector<Fragmenter*>::iterator it = fragmenters_.begin();
|
for (const std::unique_ptr<Fragmenter>& fragmenter : fragmenters_) {
|
||||||
it != fragmenters_.end();
|
if (!fragmenter->fragment_finalized())
|
||||||
++it) {
|
|
||||||
if (!(*it)->fragment_finalized())
|
|
||||||
return Status::OK;
|
return Status::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -470,7 +466,7 @@ Status Segmenter::FinalizeFragment(bool finalize_segment,
|
||||||
// Write the fragment to buffer.
|
// Write the fragment to buffer.
|
||||||
moof_->Write(fragment_buffer_.get());
|
moof_->Write(fragment_buffer_.get());
|
||||||
mdat.WriteHeader(fragment_buffer_.get());
|
mdat.WriteHeader(fragment_buffer_.get());
|
||||||
for (Fragmenter* fragmenter : fragmenters_)
|
for (const std::unique_ptr<Fragmenter>& fragmenter : fragmenters_)
|
||||||
fragment_buffer_->AppendBuffer(*fragmenter->data());
|
fragment_buffer_->AppendBuffer(*fragmenter->data());
|
||||||
|
|
||||||
// Increase sequence_number for next fragment.
|
// Increase sequence_number for next fragment.
|
||||||
|
|
|
@ -134,7 +134,7 @@ class Segmenter {
|
||||||
std::unique_ptr<MovieFragment> moof_;
|
std::unique_ptr<MovieFragment> moof_;
|
||||||
std::unique_ptr<BufferWriter> fragment_buffer_;
|
std::unique_ptr<BufferWriter> fragment_buffer_;
|
||||||
std::unique_ptr<SegmentIndex> sidx_;
|
std::unique_ptr<SegmentIndex> sidx_;
|
||||||
std::vector<Fragmenter*> fragmenters_;
|
std::vector<std::unique_ptr<Fragmenter>> fragmenters_;
|
||||||
std::vector<uint64_t> segment_durations_;
|
std::vector<uint64_t> segment_durations_;
|
||||||
std::map<const MediaStream*, uint32_t> stream_map_;
|
std::map<const MediaStream*, uint32_t> stream_map_;
|
||||||
MuxerListener* muxer_listener_;
|
MuxerListener* muxer_listener_;
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
#include "packager/media/formats/webm/webm_content_encodings_client.h"
|
#include "packager/media/formats/webm/webm_content_encodings_client.h"
|
||||||
|
|
||||||
#include "packager/base/logging.h"
|
#include "packager/base/logging.h"
|
||||||
#include "packager/base/stl_util.h"
|
|
||||||
#include "packager/media/formats/webm/webm_constants.h"
|
#include "packager/media/formats/webm/webm_constants.h"
|
||||||
|
|
||||||
namespace shaka {
|
namespace shaka {
|
||||||
|
@ -14,9 +13,7 @@ namespace media {
|
||||||
WebMContentEncodingsClient::WebMContentEncodingsClient()
|
WebMContentEncodingsClient::WebMContentEncodingsClient()
|
||||||
: content_encryption_encountered_(false), content_encodings_ready_(false) {}
|
: content_encryption_encountered_(false), content_encodings_ready_(false) {}
|
||||||
|
|
||||||
WebMContentEncodingsClient::~WebMContentEncodingsClient() {
|
WebMContentEncodingsClient::~WebMContentEncodingsClient() {}
|
||||||
STLDeleteElements(&content_encodings_);
|
|
||||||
}
|
|
||||||
|
|
||||||
const ContentEncodings& WebMContentEncodingsClient::content_encodings() const {
|
const ContentEncodings& WebMContentEncodingsClient::content_encodings() const {
|
||||||
DCHECK(content_encodings_ready_);
|
DCHECK(content_encodings_ready_);
|
||||||
|
@ -27,7 +24,7 @@ WebMParserClient* WebMContentEncodingsClient::OnListStart(int id) {
|
||||||
if (id == kWebMIdContentEncodings) {
|
if (id == kWebMIdContentEncodings) {
|
||||||
DCHECK(!cur_content_encoding_.get());
|
DCHECK(!cur_content_encoding_.get());
|
||||||
DCHECK(!content_encryption_encountered_);
|
DCHECK(!content_encryption_encountered_);
|
||||||
STLDeleteElements(&content_encodings_);
|
content_encodings_.clear();
|
||||||
content_encodings_ready_ = false;
|
content_encodings_ready_ = false;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -102,14 +99,14 @@ bool WebMContentEncodingsClient::OnListEnd(int id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enforce mandatory elements without default values.
|
// Enforce mandatory elements without default values.
|
||||||
DCHECK(cur_content_encoding_->type() == ContentEncoding::kTypeEncryption);
|
DCHECK_EQ(cur_content_encoding_->type(), ContentEncoding::kTypeEncryption);
|
||||||
if (!content_encryption_encountered_) {
|
if (!content_encryption_encountered_) {
|
||||||
LOG(ERROR) << "ContentEncodingType is encryption but"
|
LOG(ERROR) << "ContentEncodingType is encryption but"
|
||||||
<< " ContentEncryption is missing.";
|
<< " ContentEncryption is missing.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
content_encodings_.push_back(cur_content_encoding_.release());
|
content_encodings_.push_back(std::move(cur_content_encoding_));
|
||||||
content_encryption_encountered_ = false;
|
content_encryption_encountered_ = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,14 +9,13 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "packager/base/callback.h"
|
#include "packager/base/callback.h"
|
||||||
#include "packager/base/compiler_specific.h"
|
|
||||||
#include "packager/media/formats/webm/webm_content_encodings.h"
|
#include "packager/media/formats/webm/webm_content_encodings.h"
|
||||||
#include "packager/media/formats/webm/webm_parser.h"
|
#include "packager/media/formats/webm/webm_parser.h"
|
||||||
|
|
||||||
namespace shaka {
|
namespace shaka {
|
||||||
namespace media {
|
namespace media {
|
||||||
|
|
||||||
typedef std::vector<ContentEncoding*> ContentEncodings;
|
typedef std::vector<std::unique_ptr<ContentEncoding>> ContentEncodings;
|
||||||
|
|
||||||
/// Parser for WebM ContentEncodings element.
|
/// Parser for WebM ContentEncodings element.
|
||||||
class WebMContentEncodingsClient : public WebMParserClient {
|
class WebMContentEncodingsClient : public WebMParserClient {
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
#include "packager/media/formats/webm/webm_video_client.h"
|
#include "packager/media/formats/webm/webm_video_client.h"
|
||||||
|
|
||||||
#include "packager/base/logging.h"
|
#include "packager/base/logging.h"
|
||||||
#include "packager/base/stl_util.h"
|
|
||||||
#include "packager/media/codecs/vp_codec_configuration_record.h"
|
#include "packager/media/codecs/vp_codec_configuration_record.h"
|
||||||
#include "packager/media/formats/webm/webm_constants.h"
|
#include "packager/media/formats/webm/webm_constants.h"
|
||||||
|
|
||||||
|
|
|
@ -57,19 +57,21 @@ const char kKeyHex[] = "6fc96fe628a265b13aeddec0bc421f4d";
|
||||||
const double kClearLeadInSeconds = 1.5;
|
const double kClearLeadInSeconds = 1.5;
|
||||||
const double kCryptoDurationInSeconds = 0; // Key rotation is disabled.
|
const double kCryptoDurationInSeconds = 0; // Key rotation is disabled.
|
||||||
|
|
||||||
MediaStream* FindFirstStreamOfType(const std::vector<MediaStream*>& streams,
|
MediaStream* FindFirstStreamOfType(
|
||||||
StreamType stream_type) {
|
const std::vector<std::unique_ptr<MediaStream>>& streams,
|
||||||
typedef std::vector<MediaStream*>::const_iterator StreamIterator;
|
StreamType stream_type) {
|
||||||
for (StreamIterator it = streams.begin(); it != streams.end(); ++it) {
|
for (const std::unique_ptr<MediaStream>& stream : streams) {
|
||||||
if ((*it)->info()->stream_type() == stream_type)
|
if (stream->info()->stream_type() == stream_type)
|
||||||
return *it;
|
return stream.get();
|
||||||
}
|
}
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
MediaStream* FindFirstVideoStream(const std::vector<MediaStream*>& streams) {
|
MediaStream* FindFirstVideoStream(
|
||||||
|
const std::vector<std::unique_ptr<MediaStream>>& streams) {
|
||||||
return FindFirstStreamOfType(streams, kStreamVideo);
|
return FindFirstStreamOfType(streams, kStreamVideo);
|
||||||
}
|
}
|
||||||
MediaStream* FindFirstAudioStream(const std::vector<MediaStream*>& streams) {
|
MediaStream* FindFirstAudioStream(
|
||||||
|
const std::vector<std::unique_ptr<MediaStream>>& streams) {
|
||||||
return FindFirstStreamOfType(streams, kStreamAudio);
|
return FindFirstStreamOfType(streams, kStreamAudio);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include "packager/mpd/base/dash_iop_mpd_notifier.h"
|
#include "packager/mpd/base/dash_iop_mpd_notifier.h"
|
||||||
|
|
||||||
|
#include "packager/base/stl_util.h"
|
||||||
#include "packager/mpd/base/media_info.pb.h"
|
#include "packager/mpd/base/media_info.pb.h"
|
||||||
#include "packager/mpd/base/mpd_notifier_util.h"
|
#include "packager/mpd/base/mpd_notifier_util.h"
|
||||||
#include "packager/mpd/base/mpd_utils.h"
|
#include "packager/mpd/base/mpd_utils.h"
|
||||||
|
|
|
@ -401,7 +401,6 @@ class RepresentationStateChangeListenerImpl
|
||||||
MpdBuilder::MpdBuilder(MpdType type, const MpdOptions& mpd_options)
|
MpdBuilder::MpdBuilder(MpdType type, const MpdOptions& mpd_options)
|
||||||
: type_(type),
|
: type_(type),
|
||||||
mpd_options_(mpd_options),
|
mpd_options_(mpd_options),
|
||||||
adaptation_sets_deleter_(&adaptation_sets_),
|
|
||||||
clock_(new base::DefaultClock()) {}
|
clock_(new base::DefaultClock()) {}
|
||||||
|
|
||||||
MpdBuilder::~MpdBuilder() {}
|
MpdBuilder::~MpdBuilder() {}
|
||||||
|
@ -416,8 +415,8 @@ AdaptationSet* MpdBuilder::AddAdaptationSet(const std::string& lang) {
|
||||||
type_, &representation_counter_));
|
type_, &representation_counter_));
|
||||||
|
|
||||||
DCHECK(adaptation_set);
|
DCHECK(adaptation_set);
|
||||||
adaptation_sets_.push_back(adaptation_set.get());
|
adaptation_sets_.push_back(std::move(adaptation_set));
|
||||||
return adaptation_set.release();
|
return adaptation_sets_.back().get();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MpdBuilder::WriteMpdToFile(media::File* output_file) {
|
bool MpdBuilder::WriteMpdToFile(media::File* output_file) {
|
||||||
|
@ -464,10 +463,9 @@ xmlDocPtr MpdBuilder::GenerateMpd() {
|
||||||
// at the moment, just use a constant.
|
// at the moment, just use a constant.
|
||||||
// Required for 'dynamic' MPDs.
|
// Required for 'dynamic' MPDs.
|
||||||
period.SetId(0);
|
period.SetId(0);
|
||||||
std::list<AdaptationSet*>::iterator adaptation_sets_it =
|
for (const std::unique_ptr<AdaptationSet>& adaptation_set :
|
||||||
adaptation_sets_.begin();
|
adaptation_sets_) {
|
||||||
for (; adaptation_sets_it != adaptation_sets_.end(); ++adaptation_sets_it) {
|
xml::scoped_xml_ptr<xmlNode> child(adaptation_set->GetXml());
|
||||||
xml::scoped_xml_ptr<xmlNode> child((*adaptation_sets_it)->GetXml());
|
|
||||||
if (!child.get() || !period.AddChild(std::move(child)))
|
if (!child.get() || !period.AddChild(std::move(child)))
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -627,11 +625,10 @@ bool MpdBuilder::GetEarliestTimestamp(double* timestamp_seconds) {
|
||||||
DCHECK(timestamp_seconds);
|
DCHECK(timestamp_seconds);
|
||||||
|
|
||||||
double earliest_timestamp(-1);
|
double earliest_timestamp(-1);
|
||||||
for (std::list<AdaptationSet*>::const_iterator iter =
|
for (const std::unique_ptr<AdaptationSet>& adaptation_set :
|
||||||
adaptation_sets_.begin();
|
adaptation_sets_) {
|
||||||
iter != adaptation_sets_.end(); ++iter) {
|
|
||||||
double timestamp;
|
double timestamp;
|
||||||
if ((*iter)->GetEarliestTimestamp(×tamp) &&
|
if (adaptation_set->GetEarliestTimestamp(×tamp) &&
|
||||||
((earliest_timestamp < 0) || (timestamp < earliest_timestamp))) {
|
((earliest_timestamp < 0) || (timestamp < earliest_timestamp))) {
|
||||||
earliest_timestamp = timestamp;
|
earliest_timestamp = timestamp;
|
||||||
}
|
}
|
||||||
|
@ -676,8 +673,7 @@ AdaptationSet::AdaptationSet(uint32_t adaptation_set_id,
|
||||||
const MpdOptions& mpd_options,
|
const MpdOptions& mpd_options,
|
||||||
MpdBuilder::MpdType mpd_type,
|
MpdBuilder::MpdType mpd_type,
|
||||||
base::AtomicSequenceNumber* counter)
|
base::AtomicSequenceNumber* counter)
|
||||||
: representations_deleter_(&representations_),
|
: representation_counter_(counter),
|
||||||
representation_counter_(counter),
|
|
||||||
id_(adaptation_set_id),
|
id_(adaptation_set_id),
|
||||||
lang_(lang),
|
lang_(lang),
|
||||||
mpd_options_(mpd_options),
|
mpd_options_(mpd_options),
|
||||||
|
@ -730,8 +726,8 @@ Representation* AdaptationSet::AddRepresentation(const MediaInfo& media_info) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
representations_.push_back(representation.get());
|
representations_.push_back(std::move(representation));
|
||||||
return representation.release();
|
return representations_.back().get();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdaptationSet::AddContentProtectionElement(
|
void AdaptationSet::AddContentProtectionElement(
|
||||||
|
@ -818,7 +814,8 @@ xml::scoped_xml_ptr<xmlNode> AdaptationSet::GetXml() {
|
||||||
for (AdaptationSet::Role role : roles_)
|
for (AdaptationSet::Role role : roles_)
|
||||||
adaptation_set.AddRoleElement("urn:mpeg:dash:role:2011", RoleToText(role));
|
adaptation_set.AddRoleElement("urn:mpeg:dash:role:2011", RoleToText(role));
|
||||||
|
|
||||||
for (Representation* representation : representations_) {
|
for (const std::unique_ptr<Representation>& representation :
|
||||||
|
representations_) {
|
||||||
if (suppress_representation_width)
|
if (suppress_representation_width)
|
||||||
representation->SuppressOnce(Representation::kSuppressWidth);
|
representation->SuppressOnce(Representation::kSuppressWidth);
|
||||||
if (suppress_representation_height)
|
if (suppress_representation_height)
|
||||||
|
@ -876,11 +873,10 @@ bool AdaptationSet::GetEarliestTimestamp(double* timestamp_seconds) {
|
||||||
DCHECK(timestamp_seconds);
|
DCHECK(timestamp_seconds);
|
||||||
|
|
||||||
double earliest_timestamp(-1);
|
double earliest_timestamp(-1);
|
||||||
for (std::list<Representation*>::const_iterator iter =
|
for (const std::unique_ptr<Representation>& representation :
|
||||||
representations_.begin();
|
representations_) {
|
||||||
iter != representations_.end(); ++iter) {
|
|
||||||
double timestamp;
|
double timestamp;
|
||||||
if ((*iter)->GetEarliestTimestamp(×tamp) &&
|
if (representation->GetEarliestTimestamp(×tamp) &&
|
||||||
((earliest_timestamp < 0) || (timestamp < earliest_timestamp))) {
|
((earliest_timestamp < 0) || (timestamp < earliest_timestamp))) {
|
||||||
earliest_timestamp = timestamp;
|
earliest_timestamp = timestamp;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
#include "packager/base/atomic_sequence_num.h"
|
#include "packager/base/atomic_sequence_num.h"
|
||||||
#include "packager/base/callback.h"
|
#include "packager/base/callback.h"
|
||||||
#include "packager/base/gtest_prod_util.h"
|
#include "packager/base/gtest_prod_util.h"
|
||||||
#include "packager/base/stl_util.h"
|
|
||||||
#include "packager/base/time/clock.h"
|
#include "packager/base/time/clock.h"
|
||||||
#include "packager/base/time/time.h"
|
#include "packager/base/time/time.h"
|
||||||
#include "packager/mpd/base/bandwidth_estimator.h"
|
#include "packager/mpd/base/bandwidth_estimator.h"
|
||||||
|
@ -146,8 +145,7 @@ class MpdBuilder {
|
||||||
|
|
||||||
MpdType type_;
|
MpdType type_;
|
||||||
MpdOptions mpd_options_;
|
MpdOptions mpd_options_;
|
||||||
std::list<AdaptationSet*> adaptation_sets_;
|
std::list<std::unique_ptr<AdaptationSet>> adaptation_sets_;
|
||||||
STLElementDeleter<std::list<AdaptationSet*> > adaptation_sets_deleter_;
|
|
||||||
|
|
||||||
std::list<std::string> base_urls_;
|
std::list<std::string> base_urls_;
|
||||||
std::string availability_start_time_;
|
std::string availability_start_time_;
|
||||||
|
@ -341,8 +339,7 @@ class AdaptationSet {
|
||||||
void RecordFrameRate(uint32_t frame_duration, uint32_t timescale);
|
void RecordFrameRate(uint32_t frame_duration, uint32_t timescale);
|
||||||
|
|
||||||
std::list<ContentProtectionElement> content_protection_elements_;
|
std::list<ContentProtectionElement> content_protection_elements_;
|
||||||
std::list<Representation*> representations_;
|
std::list<std::unique_ptr<Representation>> representations_;
|
||||||
STLElementDeleter<std::list<Representation*> > representations_deleter_;
|
|
||||||
|
|
||||||
base::AtomicSequenceNumber* const representation_counter_;
|
base::AtomicSequenceNumber* const representation_counter_;
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "packager/mpd/base/simple_mpd_notifier.h"
|
#include "packager/mpd/base/simple_mpd_notifier.h"
|
||||||
|
|
||||||
#include "packager/base/logging.h"
|
#include "packager/base/logging.h"
|
||||||
|
#include "packager/base/stl_util.h"
|
||||||
#include "packager/mpd/base/mpd_builder.h"
|
#include "packager/mpd/base/mpd_builder.h"
|
||||||
#include "packager/mpd/base/mpd_notifier_util.h"
|
#include "packager/mpd/base/mpd_notifier_util.h"
|
||||||
#include "packager/mpd/base/mpd_utils.h"
|
#include "packager/mpd/base/mpd_utils.h"
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
|
|
||||||
#include "packager/base/logging.h"
|
#include "packager/base/logging.h"
|
||||||
#include "packager/base/macros.h"
|
#include "packager/base/macros.h"
|
||||||
#include "packager/base/stl_util.h"
|
|
||||||
#include "packager/base/strings/string_number_conversions.h"
|
#include "packager/base/strings/string_number_conversions.h"
|
||||||
#include "packager/base/sys_byteorder.h"
|
#include "packager/base/sys_byteorder.h"
|
||||||
#include "packager/mpd/base/media_info.pb.h"
|
#include "packager/mpd/base/media_info.pb.h"
|
||||||
|
|
Loading…
Reference in New Issue