2023-12-01 17:32:19 +00:00
|
|
|
// Copyright 2017 Google LLC. All rights reserved.
|
2017-12-14 01:00:11 +00:00
|
|
|
//
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file or at
|
|
|
|
// https://developers.google.com/open-source/licenses/bsd
|
|
|
|
|
2023-12-01 17:32:19 +00:00
|
|
|
#include <packager/mpd/base/period.h>
|
2017-12-14 01:00:11 +00:00
|
|
|
|
2023-12-01 17:32:19 +00:00
|
|
|
#include <absl/log/check.h>
|
|
|
|
#include <absl/log/log.h>
|
|
|
|
|
|
|
|
#include <packager/mpd/base/adaptation_set.h>
|
|
|
|
#include <packager/mpd/base/mpd_options.h>
|
|
|
|
#include <packager/mpd/base/mpd_utils.h>
|
|
|
|
#include <packager/mpd/base/xml/xml_node.h>
|
2017-12-14 01:00:11 +00:00
|
|
|
|
|
|
|
namespace shaka {
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
// The easiest way to check whether two protobufs are equal, is to compare the
|
|
|
|
// serialized version.
|
|
|
|
bool ProtectedContentEq(
|
|
|
|
const MediaInfo::ProtectedContent& content_protection1,
|
|
|
|
const MediaInfo::ProtectedContent& content_protection2) {
|
|
|
|
return content_protection1.SerializeAsString() ==
|
|
|
|
content_protection2.SerializeAsString();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::set<std::string> GetUUIDs(
|
|
|
|
const MediaInfo::ProtectedContent& protected_content) {
|
|
|
|
std::set<std::string> uuids;
|
|
|
|
for (const auto& entry : protected_content.content_protection_entry())
|
|
|
|
uuids.insert(entry.uuid());
|
|
|
|
return uuids;
|
|
|
|
}
|
|
|
|
|
2018-11-20 00:09:24 +00:00
|
|
|
const std::string& GetDefaultAudioLanguage(const MpdOptions& mpd_options) {
|
|
|
|
return mpd_options.mpd_params.default_language;
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::string& GetDefaultTextLanguage(const MpdOptions& mpd_options) {
|
|
|
|
return mpd_options.mpd_params.default_text_language.empty()
|
|
|
|
? mpd_options.mpd_params.default_language
|
|
|
|
: mpd_options.mpd_params.default_text_language;
|
|
|
|
}
|
|
|
|
|
2019-06-13 06:01:16 +00:00
|
|
|
AdaptationSet::Role RoleFromString(const std::string& role_str) {
|
|
|
|
if (role_str == "caption")
|
|
|
|
return AdaptationSet::Role::kRoleCaption;
|
|
|
|
if (role_str == "subtitle")
|
|
|
|
return AdaptationSet::Role::kRoleSubtitle;
|
|
|
|
if (role_str == "main")
|
|
|
|
return AdaptationSet::Role::kRoleMain;
|
|
|
|
if (role_str == "alternate")
|
|
|
|
return AdaptationSet::Role::kRoleAlternate;
|
|
|
|
if (role_str == "supplementary")
|
|
|
|
return AdaptationSet::Role::kRoleSupplementary;
|
|
|
|
if (role_str == "commentary")
|
|
|
|
return AdaptationSet::Role::kRoleCommentary;
|
|
|
|
if (role_str == "dub")
|
|
|
|
return AdaptationSet::Role::kRoleDub;
|
2022-06-02 16:40:34 +00:00
|
|
|
if (role_str == "description")
|
|
|
|
return AdaptationSet::Role::kRoleDescription;
|
2019-06-13 06:01:16 +00:00
|
|
|
return AdaptationSet::Role::kRoleUnknown;
|
|
|
|
}
|
|
|
|
|
2017-12-14 01:00:11 +00:00
|
|
|
} // namespace
|
|
|
|
|
2018-01-03 00:10:54 +00:00
|
|
|
Period::Period(uint32_t period_id,
|
|
|
|
double start_time_in_seconds,
|
|
|
|
const MpdOptions& mpd_options,
|
2018-07-23 22:24:20 +00:00
|
|
|
uint32_t* representation_counter)
|
2018-01-03 00:10:54 +00:00
|
|
|
: id_(period_id),
|
|
|
|
start_time_in_seconds_(start_time_in_seconds),
|
|
|
|
mpd_options_(mpd_options),
|
2017-12-14 01:00:11 +00:00
|
|
|
representation_counter_(representation_counter) {}
|
|
|
|
|
|
|
|
AdaptationSet* Period::GetOrCreateAdaptationSet(
|
|
|
|
const MediaInfo& media_info,
|
|
|
|
bool content_protection_in_adaptation_set) {
|
2018-05-26 00:23:40 +00:00
|
|
|
// Set duration if it is not set. It may be updated later from duration
|
|
|
|
// calculated from segments.
|
|
|
|
if (duration_seconds_ == 0)
|
|
|
|
duration_seconds_ = media_info.media_duration_seconds();
|
|
|
|
|
2020-03-18 02:33:44 +00:00
|
|
|
const std::string key = GetAdaptationSetKey(
|
|
|
|
media_info, mpd_options_.mpd_params.allow_codec_switching);
|
|
|
|
|
2017-12-14 01:00:11 +00:00
|
|
|
std::list<AdaptationSet*>& adaptation_sets = adaptation_set_list_map_[key];
|
2020-03-18 02:33:44 +00:00
|
|
|
|
|
|
|
for (AdaptationSet* adaptation_set : adaptation_sets) {
|
|
|
|
if (protected_adaptation_set_map_.Match(
|
|
|
|
*adaptation_set, media_info, content_protection_in_adaptation_set))
|
|
|
|
return adaptation_set;
|
2017-12-14 01:00:11 +00:00
|
|
|
}
|
2020-03-18 02:33:44 +00:00
|
|
|
|
2017-12-14 01:00:11 +00:00
|
|
|
// None of the adaptation sets match with the new content protection.
|
|
|
|
// Need a new one.
|
2018-01-25 23:04:59 +00:00
|
|
|
const std::string language = GetLanguage(media_info);
|
2017-12-14 01:00:11 +00:00
|
|
|
std::unique_ptr<AdaptationSet> new_adaptation_set =
|
2018-01-25 23:04:59 +00:00
|
|
|
NewAdaptationSet(language, mpd_options_, representation_counter_);
|
2017-12-14 01:00:11 +00:00
|
|
|
if (!SetNewAdaptationSetAttributes(language, media_info, adaptation_sets,
|
2020-03-18 02:33:44 +00:00
|
|
|
content_protection_in_adaptation_set,
|
2017-12-14 01:00:11 +00:00
|
|
|
new_adaptation_set.get())) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (content_protection_in_adaptation_set &&
|
|
|
|
media_info.has_protected_content()) {
|
|
|
|
protected_adaptation_set_map_.Register(*new_adaptation_set, media_info);
|
|
|
|
AddContentProtectionElements(media_info, new_adaptation_set.get());
|
2020-03-18 02:33:44 +00:00
|
|
|
}
|
|
|
|
for (AdaptationSet* adaptation_set : adaptation_sets) {
|
|
|
|
if (protected_adaptation_set_map_.Switchable(*adaptation_set,
|
|
|
|
*new_adaptation_set)) {
|
|
|
|
adaptation_set->AddAdaptationSetSwitching(new_adaptation_set.get());
|
|
|
|
new_adaptation_set->AddAdaptationSetSwitching(adaptation_set);
|
2017-12-14 01:00:11 +00:00
|
|
|
}
|
|
|
|
}
|
2020-03-18 02:33:44 +00:00
|
|
|
|
2018-01-18 18:55:36 +00:00
|
|
|
AdaptationSet* adaptation_set_ptr = new_adaptation_set.get();
|
|
|
|
adaptation_sets.push_back(adaptation_set_ptr);
|
2018-01-25 23:04:59 +00:00
|
|
|
adaptation_sets_.emplace_back(std::move(new_adaptation_set));
|
2018-01-18 18:55:36 +00:00
|
|
|
return adaptation_set_ptr;
|
2017-12-14 01:00:11 +00:00
|
|
|
}
|
|
|
|
|
2023-12-01 17:32:19 +00:00
|
|
|
std::optional<xml::XmlNode> Period::GetXml(bool output_period_duration) {
|
2018-01-25 23:04:59 +00:00
|
|
|
adaptation_sets_.sort(
|
|
|
|
[](const std::unique_ptr<AdaptationSet>& adaptation_set_a,
|
|
|
|
const std::unique_ptr<AdaptationSet>& adaptation_set_b) {
|
|
|
|
if (!adaptation_set_a->has_id())
|
|
|
|
return false;
|
|
|
|
if (!adaptation_set_b->has_id())
|
|
|
|
return true;
|
|
|
|
return adaptation_set_a->id() < adaptation_set_b->id();
|
|
|
|
});
|
|
|
|
|
2017-12-14 01:00:11 +00:00
|
|
|
xml::XmlNode period("Period");
|
|
|
|
|
|
|
|
// Required for 'dynamic' MPDs.
|
2020-11-10 00:32:58 +00:00
|
|
|
if (!period.SetId(id_))
|
2023-12-01 17:32:19 +00:00
|
|
|
return std::nullopt;
|
2021-08-25 15:38:05 +00:00
|
|
|
|
|
|
|
// Required for LL-DASH MPDs.
|
|
|
|
if (mpd_options_.mpd_params.low_latency_dash_mode) {
|
|
|
|
// Create ServiceDescription element.
|
|
|
|
xml::XmlNode service_description_node("ServiceDescription");
|
|
|
|
if (!service_description_node.SetIntegerAttribute("id", id_))
|
2023-12-01 17:32:19 +00:00
|
|
|
return std::nullopt;
|
2021-08-25 15:38:05 +00:00
|
|
|
|
|
|
|
// Insert Latency into ServiceDescription element.
|
|
|
|
xml::XmlNode latency_node("Latency");
|
|
|
|
uint64_t target_latency_ms =
|
|
|
|
mpd_options_.mpd_params.target_latency_seconds * 1000;
|
|
|
|
if (!latency_node.SetIntegerAttribute("target", target_latency_ms))
|
2023-12-01 17:32:19 +00:00
|
|
|
return std::nullopt;
|
2021-08-25 15:38:05 +00:00
|
|
|
if (!service_description_node.AddChild(std::move(latency_node)))
|
2023-12-01 17:32:19 +00:00
|
|
|
return std::nullopt;
|
2021-08-25 15:38:05 +00:00
|
|
|
|
|
|
|
// Insert ServiceDescription into Period element.
|
|
|
|
if (!period.AddChild(std::move(service_description_node)))
|
2023-12-01 17:32:19 +00:00
|
|
|
return std::nullopt;
|
2021-08-25 15:38:05 +00:00
|
|
|
}
|
|
|
|
|
2017-12-14 01:00:11 +00:00
|
|
|
// Iterate thru AdaptationSets and add them to one big Period element.
|
2018-01-25 23:04:59 +00:00
|
|
|
for (const auto& adaptation_set : adaptation_sets_) {
|
2020-11-10 00:32:58 +00:00
|
|
|
auto child = adaptation_set->GetXml();
|
|
|
|
if (!child || !period.AddChild(std::move(*child)))
|
2023-12-01 17:32:19 +00:00
|
|
|
return std::nullopt;
|
2017-12-14 01:00:11 +00:00
|
|
|
}
|
|
|
|
|
2018-01-29 18:37:50 +00:00
|
|
|
if (output_period_duration) {
|
2020-11-10 00:32:58 +00:00
|
|
|
if (!period.SetStringAttribute("duration",
|
|
|
|
SecondsToXmlDuration(duration_seconds_))) {
|
2023-12-01 17:32:19 +00:00
|
|
|
return std::nullopt;
|
2020-11-10 00:32:58 +00:00
|
|
|
}
|
2018-01-29 18:37:50 +00:00
|
|
|
} else if (mpd_options_.mpd_type == MpdType::kDynamic) {
|
2020-11-10 00:32:58 +00:00
|
|
|
if (!period.SetStringAttribute(
|
|
|
|
"start", SecondsToXmlDuration(start_time_in_seconds_))) {
|
2023-12-01 17:32:19 +00:00
|
|
|
return std::nullopt;
|
2020-11-10 00:32:58 +00:00
|
|
|
}
|
2017-12-14 01:00:11 +00:00
|
|
|
}
|
2020-11-10 00:32:58 +00:00
|
|
|
return period;
|
2017-12-14 01:00:11 +00:00
|
|
|
}
|
|
|
|
|
2018-01-05 02:31:27 +00:00
|
|
|
const std::list<AdaptationSet*> Period::GetAdaptationSets() const {
|
|
|
|
std::list<AdaptationSet*> adaptation_sets;
|
2018-01-25 23:04:59 +00:00
|
|
|
for (const auto& adaptation_set : adaptation_sets_) {
|
|
|
|
adaptation_sets.push_back(adaptation_set.get());
|
2017-12-14 01:00:11 +00:00
|
|
|
}
|
2018-01-05 02:31:27 +00:00
|
|
|
return adaptation_sets;
|
2017-12-14 01:00:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<AdaptationSet> Period::NewAdaptationSet(
|
|
|
|
const std::string& language,
|
|
|
|
const MpdOptions& options,
|
2018-07-23 22:24:20 +00:00
|
|
|
uint32_t* representation_counter) {
|
2018-01-25 23:04:59 +00:00
|
|
|
return std::unique_ptr<AdaptationSet>(
|
|
|
|
new AdaptationSet(language, options, representation_counter));
|
2017-12-14 01:00:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Period::SetNewAdaptationSetAttributes(
|
|
|
|
const std::string& language,
|
|
|
|
const MediaInfo& media_info,
|
|
|
|
const std::list<AdaptationSet*>& adaptation_sets,
|
2020-03-18 02:33:44 +00:00
|
|
|
bool content_protection_in_adaptation_set,
|
2017-12-14 01:00:11 +00:00
|
|
|
AdaptationSet* new_adaptation_set) {
|
2019-06-13 06:01:16 +00:00
|
|
|
if (!media_info.dash_roles().empty()) {
|
|
|
|
for (const std::string& role_str : media_info.dash_roles()) {
|
|
|
|
AdaptationSet::Role role = RoleFromString(role_str);
|
|
|
|
if (role == AdaptationSet::kRoleUnknown) {
|
|
|
|
LOG(ERROR) << "Unrecognized role '" << role_str << "'.";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
new_adaptation_set->AddRole(role);
|
|
|
|
}
|
|
|
|
} else if (!language.empty()) {
|
2018-11-20 00:09:24 +00:00
|
|
|
const bool is_main_role =
|
|
|
|
language == (media_info.has_audio_info()
|
|
|
|
? GetDefaultAudioLanguage(mpd_options_)
|
|
|
|
: GetDefaultTextLanguage(mpd_options_));
|
|
|
|
if (is_main_role)
|
|
|
|
new_adaptation_set->AddRole(AdaptationSet::kRoleMain);
|
|
|
|
}
|
2019-06-13 06:01:16 +00:00
|
|
|
for (const std::string& accessibility : media_info.dash_accessibilities()) {
|
|
|
|
size_t pos = accessibility.find('=');
|
|
|
|
if (pos == std::string::npos) {
|
|
|
|
LOG(ERROR)
|
|
|
|
<< "Accessibility should be in scheme=value format, but seeing "
|
|
|
|
<< accessibility;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
new_adaptation_set->AddAccessibility(accessibility.substr(0, pos),
|
|
|
|
accessibility.substr(pos + 1));
|
|
|
|
}
|
2017-12-14 01:00:11 +00:00
|
|
|
|
2020-03-18 02:33:44 +00:00
|
|
|
new_adaptation_set->set_codec(GetBaseCodec(media_info));
|
|
|
|
|
2017-12-14 01:00:11 +00:00
|
|
|
if (media_info.has_video_info()) {
|
|
|
|
// Because 'language' is ignored for videos, |adaptation_sets| must have
|
|
|
|
// all the video AdaptationSets.
|
|
|
|
if (adaptation_sets.size() > 1) {
|
|
|
|
new_adaptation_set->AddRole(AdaptationSet::kRoleMain);
|
|
|
|
} else if (adaptation_sets.size() == 1) {
|
|
|
|
(*adaptation_sets.begin())->AddRole(AdaptationSet::kRoleMain);
|
|
|
|
new_adaptation_set->AddRole(AdaptationSet::kRoleMain);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (media_info.video_info().has_playback_rate()) {
|
2020-03-24 19:15:30 +00:00
|
|
|
std::string trick_play_reference_adaptation_set_key;
|
|
|
|
AdaptationSet* trick_play_reference_adaptation_set =
|
|
|
|
FindMatchingAdaptationSetForTrickPlay(
|
|
|
|
media_info, content_protection_in_adaptation_set,
|
|
|
|
&trick_play_reference_adaptation_set_key);
|
|
|
|
if (trick_play_reference_adaptation_set) {
|
|
|
|
new_adaptation_set->AddTrickPlayReference(
|
|
|
|
trick_play_reference_adaptation_set);
|
|
|
|
} else {
|
|
|
|
trickplay_cache_[trick_play_reference_adaptation_set_key].push_back(
|
|
|
|
new_adaptation_set);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
std::string trick_play_adaptation_set_key;
|
|
|
|
AdaptationSet* trickplay_adaptation_set =
|
|
|
|
FindMatchingAdaptationSetForTrickPlay(
|
|
|
|
media_info, content_protection_in_adaptation_set,
|
|
|
|
&trick_play_adaptation_set_key);
|
|
|
|
if (trickplay_adaptation_set) {
|
|
|
|
trickplay_adaptation_set->AddTrickPlayReference(new_adaptation_set);
|
|
|
|
trickplay_cache_.erase(trick_play_adaptation_set_key);
|
2017-12-14 01:00:11 +00:00
|
|
|
}
|
|
|
|
}
|
2020-03-24 19:15:30 +00:00
|
|
|
|
2023-09-08 21:41:41 +00:00
|
|
|
// Set transfer characteristics.
|
|
|
|
// https://dashif.org/docs/DASH-IF-IOP-v4.3.pdf - 4.2.5.1
|
|
|
|
// ISO/IEC 23001-8 MPEG systems technologies — Part 8: Coding-independent
|
|
|
|
// code points. https://en.wikipedia.org/wiki/Coding-independent_code_points
|
|
|
|
// - Common CCIP values.
|
|
|
|
// Dolby vision:
|
|
|
|
// https://professionalsupport.dolby.com/s/article/How-to-signal-Dolby-Vision-in-MPEG-DASH
|
|
|
|
// Transfer characteristics for Dolby Vision (dvh1 or dvhe) must be PQ
|
|
|
|
// irrespective of value present in SPS VUI.
|
|
|
|
if (new_adaptation_set->codec().find("dvh") == 0) {
|
|
|
|
new_adaptation_set->set_transfer_characteristics(kTransferFunctionPQ);
|
|
|
|
} else if (media_info.video_info().has_transfer_characteristics()) {
|
|
|
|
new_adaptation_set->set_transfer_characteristics(
|
|
|
|
media_info.video_info().transfer_characteristics());
|
|
|
|
}
|
|
|
|
|
2017-12-14 01:00:11 +00:00
|
|
|
} else if (media_info.has_text_info()) {
|
|
|
|
// IOP requires all AdaptationSets to have (sub)segmentAlignment set to
|
|
|
|
// true, so carelessly set it to true.
|
|
|
|
// In practice it doesn't really make sense to adapt between text tracks.
|
|
|
|
new_adaptation_set->ForceSetSegmentAlignment(true);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-03-24 19:15:30 +00:00
|
|
|
AdaptationSet* Period::FindMatchingAdaptationSetForTrickPlay(
|
2020-03-18 02:33:44 +00:00
|
|
|
const MediaInfo& media_info,
|
2020-03-24 19:15:30 +00:00
|
|
|
bool content_protection_in_adaptation_set,
|
|
|
|
std::string* adaptation_set_key) {
|
|
|
|
std::list<AdaptationSet*>* adaptation_sets = nullptr;
|
|
|
|
const bool is_trickplay_adaptation_set =
|
|
|
|
media_info.video_info().has_playback_rate();
|
|
|
|
if (is_trickplay_adaptation_set) {
|
|
|
|
*adaptation_set_key = GetAdaptationSetKeyForTrickPlay(media_info);
|
|
|
|
if (adaptation_set_list_map_.find(*adaptation_set_key) ==
|
|
|
|
adaptation_set_list_map_.end())
|
|
|
|
return nullptr;
|
|
|
|
adaptation_sets = &adaptation_set_list_map_[*adaptation_set_key];
|
|
|
|
} else {
|
|
|
|
*adaptation_set_key = GetAdaptationSetKey(
|
|
|
|
media_info, mpd_options_.mpd_params.allow_codec_switching);
|
|
|
|
if (trickplay_cache_.find(*adaptation_set_key) == trickplay_cache_.end())
|
|
|
|
return nullptr;
|
|
|
|
adaptation_sets = &trickplay_cache_[*adaptation_set_key];
|
|
|
|
}
|
|
|
|
for (AdaptationSet* adaptation_set : *adaptation_sets) {
|
2020-03-18 02:33:44 +00:00
|
|
|
if (protected_adaptation_set_map_.Match(
|
|
|
|
*adaptation_set, media_info,
|
|
|
|
content_protection_in_adaptation_set)) {
|
2018-01-25 23:04:59 +00:00
|
|
|
return adaptation_set;
|
2017-12-14 01:00:11 +00:00
|
|
|
}
|
|
|
|
}
|
2020-03-24 19:15:30 +00:00
|
|
|
|
2018-01-25 23:04:59 +00:00
|
|
|
return nullptr;
|
2017-12-14 01:00:11 +00:00
|
|
|
}
|
|
|
|
|
2020-03-24 19:15:30 +00:00
|
|
|
std::string Period::GetAdaptationSetKeyForTrickPlay(
|
|
|
|
const MediaInfo& media_info) {
|
|
|
|
MediaInfo media_info_no_trickplay = media_info;
|
|
|
|
media_info_no_trickplay.mutable_video_info()->clear_playback_rate();
|
|
|
|
return GetAdaptationSetKey(media_info_no_trickplay,
|
|
|
|
mpd_options_.mpd_params.allow_codec_switching);
|
|
|
|
}
|
|
|
|
|
2017-12-14 01:00:11 +00:00
|
|
|
void Period::ProtectedAdaptationSetMap::Register(
|
|
|
|
const AdaptationSet& adaptation_set,
|
|
|
|
const MediaInfo& media_info) {
|
2023-12-01 17:32:19 +00:00
|
|
|
CHECK(protected_content_map_.find(&adaptation_set) ==
|
|
|
|
protected_content_map_.end());
|
2018-01-25 23:04:59 +00:00
|
|
|
protected_content_map_[&adaptation_set] = media_info.protected_content();
|
2017-12-14 01:00:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Period::ProtectedAdaptationSetMap::Match(
|
|
|
|
const AdaptationSet& adaptation_set,
|
2020-03-18 02:33:44 +00:00
|
|
|
const MediaInfo& media_info,
|
|
|
|
bool content_protection_in_adaptation_set) {
|
|
|
|
if (adaptation_set.codec() != GetBaseCodec(media_info))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!content_protection_in_adaptation_set)
|
|
|
|
return true;
|
|
|
|
|
2017-12-14 01:00:11 +00:00
|
|
|
const auto protected_content_it =
|
2018-01-25 23:04:59 +00:00
|
|
|
protected_content_map_.find(&adaptation_set);
|
2017-12-14 01:00:11 +00:00
|
|
|
// If the AdaptationSet ID is not registered in the map, then it is clear
|
|
|
|
// content.
|
|
|
|
if (protected_content_it == protected_content_map_.end())
|
|
|
|
return !media_info.has_protected_content();
|
|
|
|
if (!media_info.has_protected_content())
|
|
|
|
return false;
|
2020-03-18 02:33:44 +00:00
|
|
|
|
2017-12-14 01:00:11 +00:00
|
|
|
return ProtectedContentEq(protected_content_it->second,
|
|
|
|
media_info.protected_content());
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Period::ProtectedAdaptationSetMap::Switchable(
|
|
|
|
const AdaptationSet& adaptation_set_a,
|
|
|
|
const AdaptationSet& adaptation_set_b) {
|
|
|
|
const auto protected_content_it_a =
|
2018-01-25 23:04:59 +00:00
|
|
|
protected_content_map_.find(&adaptation_set_a);
|
2017-12-14 01:00:11 +00:00
|
|
|
const auto protected_content_it_b =
|
2018-01-25 23:04:59 +00:00
|
|
|
protected_content_map_.find(&adaptation_set_b);
|
2017-12-14 01:00:11 +00:00
|
|
|
|
|
|
|
if (protected_content_it_a == protected_content_map_.end())
|
|
|
|
return protected_content_it_b == protected_content_map_.end();
|
|
|
|
if (protected_content_it_b == protected_content_map_.end())
|
|
|
|
return false;
|
|
|
|
// Get all the UUIDs of the AdaptationSet. If another AdaptationSet has the
|
|
|
|
// same UUIDs then those are switchable.
|
|
|
|
return GetUUIDs(protected_content_it_a->second) ==
|
|
|
|
GetUUIDs(protected_content_it_b->second);
|
|
|
|
}
|
|
|
|
|
2020-03-24 19:15:30 +00:00
|
|
|
Period::~Period() {
|
|
|
|
if (!trickplay_cache_.empty()) {
|
|
|
|
LOG(WARNING) << "Trickplay adaptation set did not get a valid adaptation "
|
|
|
|
"set match. Please check the command line options.";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-14 01:00:11 +00:00
|
|
|
} // namespace shaka
|