Shaka Packager SDK
Loading...
Searching...
No Matches
mpd_utils.h
1// Copyright 2014 Google LLC. All rights reserved.
2//
3// Use of this source code is governed by a BSD-style
4// license that can be found in the LICENSE file or at
5// https://developers.google.com/open-source/licenses/bsd
6//
7// Funtions used by MpdBuilder class to generate an MPD file.
8
9#ifndef MPD_BASE_MPD_UTILS_H_
10#define MPD_BASE_MPD_UTILS_H_
11
12#include <cstdint>
13#include <list>
14#include <string>
15
16#include <libxml/tree.h>
17
18namespace shaka {
19
20class AdaptationSet;
21class MediaInfo;
22class Representation;
23struct ContentProtectionElement;
24struct SegmentInfo;
25
26const char kEncryptedMp4Scheme[] = "urn:mpeg:dash:mp4protection:2011";
27const char kPsshElementName[] = "cenc:pssh";
28const char kMsproElementName[] = "mspr:pro";
29const uint32_t kTransferFunctionPQ = 16;
30const uint32_t kTransferFunctionHLG = 18;
31
32bool HasVODOnlyFields(const MediaInfo& media_info);
33
34bool HasLiveOnlyFields(const MediaInfo& media_info);
35
36// If |content_protection_element| has 'value' or 'schemeIdUri' set but it's
37// also in the map, then this removes them from the map.
38// |content_protection_element| cannot be NULL.
39void RemoveDuplicateAttributes(
40 ContentProtectionElement* content_protection_element);
41
42// Returns a language in ISO-639 shortest form. May be blank for video.
43std::string GetLanguage(const MediaInfo& media_info);
44
45// Returns a 'codecs' string that has all the video and audio codecs joined with
46// comma.
47std::string GetCodecs(const MediaInfo& media_info);
48
49std::string GetSupplementalCodecs(const MediaInfo& media_info);
50
51std::string GetSupplementalProfiles(const MediaInfo& media_info);
52
53// Returns a codec string without variants. For example, "mp4a" instead of
54// "mp4a.40.2". May return a format for text streams.
55std::string GetBaseCodec(const MediaInfo& media_info);
56
57// Returns a key made from the characteristics that separate AdaptationSets.
58std::string GetAdaptationSetKey(const MediaInfo& media_info, bool ignore_codec);
59
60std::string FloatToXmlString(double number);
61
62std::string SecondsToXmlDuration(double seconds);
63
64// Tries to get "duration" attribute from |node|. On success |duration| is set.
65bool GetDurationAttribute(xmlNodePtr node, float* duration);
66
67bool MoreThanOneTrue(bool b1, bool b2, bool b3);
68bool AtLeastOneTrue(bool b1, bool b2, bool b3);
69bool OnlyOneTrue(bool b1, bool b2, bool b3);
70
74bool HexToUUID(const std::string& data, std::string* uuid_format);
75
76// Update the <cenc:pssh> element for |drm_uuid| ContentProtection element.
77// If the element does not exist, this will add one.
78void UpdateContentProtectionPsshHelper(
79 const std::string& drm_uuid,
80 const std::string& pssh,
81 std::list<ContentProtectionElement>* content_protection_elements);
82
89void AddContentProtectionElements(const MediaInfo& media_info,
90 Representation* parent);
91
97void AddContentProtectionElements(const MediaInfo& media_info,
98 AdaptationSet* parent);
99
100} // namespace shaka
101
102#endif // MPD_BASE_MPD_UTILS_H_
All the methods that are virtual are virtual for mocking.
bool HexToUUID(const std::string &data, std::string *uuid_format)
Definition mpd_utils.cc:290
void AddContentProtectionElements(const MediaInfo &media_info, Representation *parent)
Definition mpd_utils.cc:523