7 #include "packager/mpd/base/simple_mpd_notifier.h"
9 #include "packager/base/logging.h"
10 #include "packager/mpd/base/mpd_builder.h"
11 #include "packager/mpd/base/mpd_notifier_util.h"
12 #include "packager/mpd/base/mpd_utils.h"
14 namespace edash_packager {
16 SimpleMpdNotifier::SimpleMpdNotifier(DashProfile dash_profile,
17 const MpdOptions& mpd_options,
18 const std::vector<std::string>& base_urls,
19 const std::string& output_path)
20 : MpdNotifier(dash_profile),
21 output_path_(output_path),
22 mpd_builder_(new MpdBuilder(dash_profile == kLiveProfile
23 ? MpdBuilder::kDynamic
24 : MpdBuilder::kStatic,
26 DCHECK(dash_profile == kLiveProfile || dash_profile == kOnDemandProfile);
27 for (
size_t i = 0; i < base_urls.size(); ++i)
28 mpd_builder_->AddBaseUrl(base_urls[i]);
31 SimpleMpdNotifier::~SimpleMpdNotifier() {
39 uint32_t* container_id) {
43 if (content_type == kContentTypeUnknown)
46 base::AutoLock auto_lock(lock_);
50 if (media_info.has_audio_info()) {
51 lang = media_info.audio_info().language();
52 }
else if (media_info.has_text_info()) {
53 lang = media_info.text_info().language();
55 AdaptationSet** adaptation_set = &adaptation_set_map_[content_type][lang];
56 if (*adaptation_set == NULL)
57 *adaptation_set = mpd_builder_->AddAdaptationSet(lang);
59 DCHECK(*adaptation_set);
60 MediaInfo adjusted_media_info(media_info);
63 (*adaptation_set)->AddRepresentation(adjusted_media_info);
64 if (representation == NULL)
70 *container_id = representation->
id();
71 DCHECK(!ContainsKey(representation_map_, representation->
id()));
72 representation_map_[representation->
id()] = representation;
77 uint32_t sample_duration) {
78 base::AutoLock auto_lock(lock_);
79 RepresentationMap::iterator it = representation_map_.find(container_id);
80 if (it == representation_map_.end()) {
81 LOG(ERROR) <<
"Unexpected container_id: " << container_id;
84 it->second->SetSampleDuration(sample_duration);
92 base::AutoLock auto_lock(lock_);
93 RepresentationMap::iterator it = representation_map_.find(container_id);
94 if (it == representation_map_.end()) {
95 LOG(ERROR) <<
"Unexpected container_id: " << container_id;
98 it->second->AddNewSegment(start_time, duration, size);
103 uint32_t container_id,
104 const std::string& drm_uuid,
105 const std::vector<uint8_t>& new_key_id,
106 const std::vector<uint8_t>& new_pssh) {
107 base::AutoLock auto_lock(lock_);
108 RepresentationMap::iterator it = representation_map_.find(container_id);
109 if (it == representation_map_.end()) {
110 LOG(ERROR) <<
"Unexpected container_id: " << container_id;
113 it->second->UpdateContentProtectionPssh(drm_uuid,
119 uint32_t container_id,
121 base::AutoLock auto_lock(lock_);
122 RepresentationMap::iterator it = representation_map_.find(container_id);
123 if (it == representation_map_.end()) {
124 LOG(ERROR) <<
"Unexpected container_id: " << container_id;
127 it->second->AddContentProtectionElement(content_protection_element);
bool NotifyEncryptionUpdate(uint32_t container_id, const std::string &drm_uuid, const std::vector< uint8_t > &new_key_id, const std::vector< uint8_t > &new_pssh) override
bool AddContentProtectionElement(uint32_t id, const ContentProtectionElement &content_protection_element) override
void AddContentProtectionElements(const MediaInfo &media_info, Representation *parent)
bool NotifySampleDuration(uint32_t container_id, uint32_t sample_duration) override
static void MakePathsRelativeToMpd(const std::string &mpd_path, MediaInfo *media_info)
bool NotifyNewContainer(const MediaInfo &media_info, uint32_t *id) override
bool NotifyNewSegment(uint32_t id, uint64_t start_time, uint64_t duration, uint64_t size) override
std::string Uint8VectorToBase64(const std::vector< uint8_t > &input)
Converts uint8 vector into base64 encoded string.
bool WriteMpdToFile(const std::string &output_path, MpdBuilder *mpd_builder)
ContentType GetContentType(const MediaInfo &media_info)