Shaka Packager SDK
mpd_utils.h
1 // Copyright 2014 Google Inc. 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 <libxml/tree.h>
13 
14 #include <list>
15 #include <string>
16 
17 namespace shaka {
18 
19 class AdaptationSet;
20 class MediaInfo;
21 class Representation;
22 struct ContentProtectionElement;
23 struct SegmentInfo;
24 
25 const char kEncryptedMp4Scheme[] = "urn:mpeg:dash:mp4protection:2011";
26 const char kPsshElementName[] = "cenc:pssh";
27 
28 bool HasVODOnlyFields(const MediaInfo& media_info);
29 
30 bool HasLiveOnlyFields(const MediaInfo& media_info);
31 
32 // If |content_protection_element| has 'value' or 'schemeIdUri' set but it's
33 // also in the map, then this removes them from the map.
34 // |content_protection_element| cannot be NULL.
35 void RemoveDuplicateAttributes(
36  ContentProtectionElement* content_protection_element);
37 
38 // Returns a language in ISO-639 shortest form. May be blank for video.
39 std::string GetLanguage(const MediaInfo& media_info);
40 
41 // Returns a 'codecs' string that has all the video and audio codecs joined with
42 // comma.
43 std::string GetCodecs(const MediaInfo& media_info);
44 
45 // Returns a codec string without variants. For example, "mp4a" instead of
46 // "mp4a.40.2". May return a format for text streams.
47 std::string GetBaseCodec(const MediaInfo& media_info);
48 
49 // Returns a key made from the characteristics that separate AdaptationSets.
50 std::string GetAdaptationSetKey(const MediaInfo& media_info);
51 
52 std::string SecondsToXmlDuration(double seconds);
53 
54 // Tries to get "duration" attribute from |node|. On success |duration| is set.
55 bool GetDurationAttribute(xmlNodePtr node, float* duration);
56 
57 bool MoreThanOneTrue(bool b1, bool b2, bool b3);
58 bool AtLeastOneTrue(bool b1, bool b2, bool b3);
59 bool OnlyOneTrue(bool b1, bool b2, bool b3);
60 
64 bool HexToUUID(const std::string& data, std::string* uuid_format);
65 
66 // Update the <cenc:pssh> element for |drm_uuid| ContentProtection element.
67 // If the element does not exist, this will add one.
68 void UpdateContentProtectionPsshHelper(
69  const std::string& drm_uuid,
70  const std::string& pssh,
71  std::list<ContentProtectionElement>* content_protection_elements);
72 
79 void AddContentProtectionElements(const MediaInfo& media_info,
80  Representation* parent);
81 
87 void AddContentProtectionElements(const MediaInfo& media_info,
88  AdaptationSet* parent);
89 
90 } // namespace shaka
91 
92 #endif // MPD_BASE_MPD_UTILS_H_
All the methods that are virtual are virtual for mocking.
void AddContentProtectionElements(const MediaInfo &media_info, Representation *parent)
Definition: mpd_utils.cc:436
bool HexToUUID(const std::string &data, std::string *uuid_format)
Definition: mpd_utils.cc:228