7 #include "packager/mpd/base/simple_mpd_notifier.h"
9 #include "packager/base/logging.h"
10 #include "packager/base/stl_util.h"
11 #include "packager/mpd/base/mpd_builder.h"
12 #include "packager/mpd/base/mpd_notifier_util.h"
13 #include "packager/mpd/base/mpd_utils.h"
17 SimpleMpdNotifier::SimpleMpdNotifier(DashProfile dash_profile,
18 const MpdOptions& mpd_options,
19 const std::vector<std::string>& base_urls,
20 const std::string& output_path)
21 : MpdNotifier(dash_profile),
22 output_path_(output_path),
23 mpd_builder_(new MpdBuilder(dash_profile == kLiveProfile
24 ? MpdBuilder::kDynamic
25 : MpdBuilder::kStatic,
27 DCHECK(dash_profile == kLiveProfile || dash_profile == kOnDemandProfile);
28 for (
size_t i = 0; i < base_urls.size(); ++i)
29 mpd_builder_->AddBaseUrl(base_urls[i]);
32 SimpleMpdNotifier::~SimpleMpdNotifier() {
40 uint32_t* container_id) {
44 if (content_type == kContentTypeUnknown)
47 base::AutoLock auto_lock(lock_);
51 std::string key = GetAdaptationSetKey(media_info);
52 std::string lang = GetLanguage(media_info);
54 if (*adaptation_set == NULL)
55 *adaptation_set = mpd_builder_->AddAdaptationSet(lang);
57 DCHECK(*adaptation_set);
58 MediaInfo adjusted_media_info(media_info);
61 (*adaptation_set)->AddRepresentation(adjusted_media_info);
62 if (representation == NULL)
68 *container_id = representation->
id();
69 DCHECK(!ContainsKey(representation_map_, representation->
id()));
70 representation_map_[representation->
id()] = representation;
75 uint32_t sample_duration) {
76 base::AutoLock auto_lock(lock_);
77 RepresentationMap::iterator it = representation_map_.find(container_id);
78 if (it == representation_map_.end()) {
79 LOG(ERROR) <<
"Unexpected container_id: " << container_id;
82 it->second->SetSampleDuration(sample_duration);
90 base::AutoLock auto_lock(lock_);
91 RepresentationMap::iterator it = representation_map_.find(container_id);
92 if (it == representation_map_.end()) {
93 LOG(ERROR) <<
"Unexpected container_id: " << container_id;
96 it->second->AddNewSegment(start_time, duration, size);
101 uint32_t container_id,
102 const std::string& drm_uuid,
103 const std::vector<uint8_t>& new_key_id,
104 const std::vector<uint8_t>& new_pssh) {
105 base::AutoLock auto_lock(lock_);
106 RepresentationMap::iterator it = representation_map_.find(container_id);
107 if (it == representation_map_.end()) {
108 LOG(ERROR) <<
"Unexpected container_id: " << container_id;
111 it->second->UpdateContentProtectionPssh(drm_uuid,
117 uint32_t container_id,
119 base::AutoLock auto_lock(lock_);
120 RepresentationMap::iterator it = representation_map_.find(container_id);
121 if (it == representation_map_.end()) {
122 LOG(ERROR) <<
"Unexpected container_id: " << container_id;
125 it->second->AddContentProtectionElement(content_protection_element);
130 base::AutoLock auto_lock(lock_);
bool AddContentProtectionElement(uint32_t id, const ContentProtectionElement &content_protection_element) override
void AddContentProtectionElements(const MediaInfo &media_info, Representation *parent)
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 NotifySampleDuration(uint32_t container_id, uint32_t sample_duration) override
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
static void MakePathsRelativeToMpd(const std::string &mpd_path, MediaInfo *media_info)
ContentType GetContentType(const MediaInfo &media_info)
bool WriteMpdToFile(const std::string &output_path, MpdBuilder *mpd_builder)
bool NotifyNewContainer(const MediaInfo &media_info, uint32_t *id) override