2014-02-14 23:21:05 +00:00
|
|
|
// Copyright 2014 Google Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
// 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
|
|
|
|
//
|
2013-11-18 23:39:20 +00:00
|
|
|
// Funtions used by MpdBuilder class to generate an MPD file.
|
2014-02-14 23:21:05 +00:00
|
|
|
|
2013-11-18 23:39:20 +00:00
|
|
|
#ifndef MPD_BASE_MPD_UTILS_H_
|
|
|
|
#define MPD_BASE_MPD_UTILS_H_
|
|
|
|
|
2014-08-28 18:35:15 +00:00
|
|
|
#include <libxml/tree.h>
|
|
|
|
|
2015-08-26 20:25:29 +00:00
|
|
|
#include <list>
|
2013-11-18 23:39:20 +00:00
|
|
|
#include <string>
|
|
|
|
|
2016-05-20 21:19:33 +00:00
|
|
|
namespace shaka {
|
2013-11-18 23:39:20 +00:00
|
|
|
|
2017-12-13 01:26:37 +00:00
|
|
|
class AdaptationSet;
|
2014-05-22 02:16:17 +00:00
|
|
|
class MediaInfo;
|
2017-12-13 01:26:37 +00:00
|
|
|
class Representation;
|
2014-03-21 17:26:49 +00:00
|
|
|
struct ContentProtectionElement;
|
2014-05-22 02:16:17 +00:00
|
|
|
struct SegmentInfo;
|
2013-11-18 23:39:20 +00:00
|
|
|
|
2015-08-26 20:25:29 +00:00
|
|
|
const char kEncryptedMp4Scheme[] = "urn:mpeg:dash:mp4protection:2011";
|
|
|
|
const char kPsshElementName[] = "cenc:pssh";
|
|
|
|
|
2013-11-18 23:39:20 +00:00
|
|
|
bool HasVODOnlyFields(const MediaInfo& media_info);
|
|
|
|
|
|
|
|
bool HasLiveOnlyFields(const MediaInfo& media_info);
|
|
|
|
|
|
|
|
// If |content_protection_element| has 'value' or 'schemeIdUri' set but it's
|
|
|
|
// also in the map, then this removes them from the map.
|
|
|
|
// |content_protection_element| cannot be NULL.
|
|
|
|
void RemoveDuplicateAttributes(
|
|
|
|
ContentProtectionElement* content_protection_element);
|
|
|
|
|
2018-04-05 01:27:57 +00:00
|
|
|
// Returns a language in ISO-639 shortest form. May be blank for video.
|
2016-03-08 19:19:12 +00:00
|
|
|
std::string GetLanguage(const MediaInfo& media_info);
|
|
|
|
|
2013-11-18 23:39:20 +00:00
|
|
|
// Returns a 'codecs' string that has all the video and audio codecs joined with
|
|
|
|
// comma.
|
|
|
|
std::string GetCodecs(const MediaInfo& media_info);
|
|
|
|
|
2016-03-08 19:19:12 +00:00
|
|
|
// Returns a codec string without variants. For example, "mp4a" instead of
|
|
|
|
// "mp4a.40.2". May return a format for text streams.
|
|
|
|
std::string GetBaseCodec(const MediaInfo& media_info);
|
|
|
|
|
|
|
|
// Returns a key made from the characteristics that separate AdaptationSets.
|
|
|
|
std::string GetAdaptationSetKey(const MediaInfo& media_info);
|
|
|
|
|
2014-05-22 02:16:17 +00:00
|
|
|
std::string SecondsToXmlDuration(double seconds);
|
2013-11-18 23:39:20 +00:00
|
|
|
|
|
|
|
// Tries to get "duration" attribute from |node|. On success |duration| is set.
|
2014-01-03 00:59:16 +00:00
|
|
|
bool GetDurationAttribute(xmlNodePtr node, float* duration);
|
2013-11-18 23:39:20 +00:00
|
|
|
|
2014-06-06 08:52:06 +00:00
|
|
|
bool MoreThanOneTrue(bool b1, bool b2, bool b3);
|
|
|
|
bool AtLeastOneTrue(bool b1, bool b2, bool b3);
|
|
|
|
bool OnlyOneTrue(bool b1, bool b2, bool b3);
|
|
|
|
|
2015-08-26 20:25:29 +00:00
|
|
|
/// Converts hex data to UUID format. Hex data must be size 16.
|
|
|
|
/// @param data input hex data.
|
|
|
|
/// @param uuid_format is the UUID format of the input.
|
|
|
|
bool HexToUUID(const std::string& data, std::string* uuid_format);
|
|
|
|
|
2015-09-24 22:03:52 +00:00
|
|
|
// Update the <cenc:pssh> element for |drm_uuid| ContentProtection element.
|
2015-08-26 20:25:29 +00:00
|
|
|
// If the element does not exist, this will add one.
|
|
|
|
void UpdateContentProtectionPsshHelper(
|
2015-09-24 22:03:52 +00:00
|
|
|
const std::string& drm_uuid,
|
2015-08-26 20:25:29 +00:00
|
|
|
const std::string& pssh,
|
2015-09-24 22:03:52 +00:00
|
|
|
std::list<ContentProtectionElement>* content_protection_elements);
|
2015-08-26 20:25:29 +00:00
|
|
|
|
|
|
|
/// Adds <ContentProtection> elements specified by @a media_info to
|
|
|
|
/// @a adaptation_set.
|
|
|
|
/// Note that this will add the elements as direct chlidren of AdaptationSet.
|
|
|
|
/// @param media_info may or may not have protected_content field.
|
|
|
|
/// @param adaptation_set is the parent element that owns the ContentProtection
|
|
|
|
/// elements.
|
|
|
|
void AddContentProtectionElements(const MediaInfo& media_info,
|
|
|
|
Representation* parent);
|
|
|
|
|
|
|
|
/// Adds <ContentProtection> elements specified by @a media_info to
|
|
|
|
/// @a representation.
|
|
|
|
/// @param media_info may or may not have protected_content field.
|
|
|
|
/// @param representation is the parent element that owns the ContentProtection
|
|
|
|
/// elements.
|
|
|
|
void AddContentProtectionElements(const MediaInfo& media_info,
|
|
|
|
AdaptationSet* parent);
|
|
|
|
|
2016-05-20 21:19:33 +00:00
|
|
|
} // namespace shaka
|
2013-11-18 23:39:20 +00:00
|
|
|
|
|
|
|
#endif // MPD_BASE_MPD_UTILS_H_
|