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 std::string key = GetAdaptationSetKey(media_info);
51 std::string lang = GetLanguage(media_info);
53 if (*adaptation_set == NULL)
54 *adaptation_set = mpd_builder_->AddAdaptationSet(lang);
56 DCHECK(*adaptation_set);
57 MediaInfo adjusted_media_info(media_info);
60 (*adaptation_set)->AddRepresentation(adjusted_media_info);
61 if (representation == NULL)
67 *container_id = representation->
id();
68 DCHECK(!ContainsKey(representation_map_, representation->
id()));
69 representation_map_[representation->
id()] = representation;
74 uint32_t sample_duration) {
75 base::AutoLock auto_lock(lock_);
76 RepresentationMap::iterator it = representation_map_.find(container_id);
77 if (it == representation_map_.end()) {
78 LOG(ERROR) <<
"Unexpected container_id: " << container_id;
81 it->second->SetSampleDuration(sample_duration);
89 base::AutoLock auto_lock(lock_);
90 RepresentationMap::iterator it = representation_map_.find(container_id);
91 if (it == representation_map_.end()) {
92 LOG(ERROR) <<
"Unexpected container_id: " << container_id;
95 it->second->AddNewSegment(start_time, duration, size);
100 uint32_t container_id,
101 const std::string& drm_uuid,
102 const std::vector<uint8_t>& new_key_id,
103 const std::vector<uint8_t>& new_pssh) {
104 base::AutoLock auto_lock(lock_);
105 RepresentationMap::iterator it = representation_map_.find(container_id);
106 if (it == representation_map_.end()) {
107 LOG(ERROR) <<
"Unexpected container_id: " << container_id;
110 it->second->UpdateContentProtectionPssh(drm_uuid,
116 uint32_t container_id,
118 base::AutoLock auto_lock(lock_);
119 RepresentationMap::iterator it = representation_map_.find(container_id);
120 if (it == representation_map_.end()) {
121 LOG(ERROR) <<
"Unexpected container_id: " << container_id;
124 it->second->AddContentProtectionElement(content_protection_element);
129 base::AutoLock auto_lock(lock_);
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)