DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
xml_node.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 // Classes to wrap XML operations. XmlNode is a generic wrapper class for
8 // XmlNode in libxml2. There are also MPD XML specific classes as well.
9 
10 #ifndef MPD_BASE_XML_XML_NODE_H_
11 #define MPD_BASE_XML_XML_NODE_H_
12 
13 #include <libxml/tree.h>
14 #include <stdint.h>
15 
16 #include <list>
17 
18 #include "packager/base/macros.h"
19 #include "packager/mpd/base/content_protection_element.h"
20 #include "packager/mpd/base/media_info.pb.h"
21 #include "packager/mpd/base/xml/scoped_xml_ptr.h"
22 
23 namespace shaka {
24 
25 struct SegmentInfo;
26 
27 namespace xml {
28 
32 class XmlNode {
33  public:
36  explicit XmlNode(const char* name);
37  virtual ~XmlNode();
38 
43  bool AddChild(scoped_xml_ptr<xmlNode> child);
44 
46  bool AddElements(const std::vector<Element>& elements);
47 
51  void SetStringAttribute(const char* attribute_name,
52  const std::string& attribute);
53 
57  void SetIntegerAttribute(const char* attribute_name, uint64_t number);
58 
62  void SetFloatingPointAttribute(const char* attribute_name, double number);
63 
66  void SetId(uint32_t id);
67 
74  void SetContent(const std::string& content);
75 
79  scoped_xml_ptr<xmlNode> PassScopedPtr();
80 
83  xmlNodePtr Release();
84 
86  xmlNodePtr GetRawPtr();
87 
88  private:
89  scoped_xml_ptr<xmlNode> node_;
90 
91  DISALLOW_COPY_AND_ASSIGN(XmlNode);
92 };
93 
98  public:
99  ~RepresentationBaseXmlNode() override;
100  bool AddContentProtectionElements(
101  const std::list<ContentProtectionElement>& content_protection_elements);
102 
105  void AddSupplementalProperty(const std::string& scheme_id_uri,
106  const std::string& value);
107 
108  protected:
109  explicit RepresentationBaseXmlNode(const char* name);
110 
111  private:
112  bool AddContentProtectionElement(
113  const ContentProtectionElement& content_protection_element);
114 
115  DISALLOW_COPY_AND_ASSIGN(RepresentationBaseXmlNode);
116 };
117 
120  public:
122  ~AdaptationSetXmlNode() override;
123 
126  void AddRoleElement(const std::string& scheme_id_uri,
127  const std::string& value);
128 
129  private:
130  DISALLOW_COPY_AND_ASSIGN(AdaptationSetXmlNode);
131 };
132 
135  public:
137  ~RepresentationXmlNode() override;
138 
146  bool AddVideoInfo(const MediaInfo::VideoInfo& video_info,
147  bool set_width,
148  bool set_height,
149  bool set_frame_rate);
150 
155  bool AddAudioInfo(const MediaInfo::AudioInfo& audio_info);
156 
161  bool AddVODOnlyInfo(const MediaInfo& media_info);
162 
165  bool AddLiveOnlyInfo(const MediaInfo& media_info,
166  const std::list<SegmentInfo>& segment_infos,
167  uint32_t start_number);
168 
169  private:
170  // Add AudioChannelConfiguration element. Note that it is a required element
171  // for audio Representations.
172  bool AddAudioChannelInfo(const MediaInfo::AudioInfo& audio_info);
173 
174  // Add audioSamplingRate attribute to this element, if present.
175  void AddAudioSamplingRateInfo(const MediaInfo::AudioInfo& audio_info);
176 
177  DISALLOW_COPY_AND_ASSIGN(RepresentationXmlNode);
178 };
179 
180 } // namespace xml
181 } // namespace shaka
182 #endif // MPD_BASE_XML_XML_NODE_H_
bool AddVideoInfo(const MediaInfo::VideoInfo &video_info, bool set_width, bool set_height, bool set_frame_rate)
Definition: xml_node.cc:224
RepresentationType in MPD.
Definition: xml_node.h:134
void SetFloatingPointAttribute(const char *attribute_name, double number)
Definition: xml_node.cc:119
AdaptationSetType specified in MPD.
Definition: xml_node.h:119
scoped_xml_ptr< xmlNode > PassScopedPtr()
Definition: xml_node.cc:136
XmlNode(const char *name)
Definition: xml_node.cc:55
bool AddVODOnlyInfo(const MediaInfo &media_info)
Definition: xml_node.cc:259
void SetStringAttribute(const char *attribute_name, const std::string &attribute)
Definition: xml_node.cc:104
bool AddChild(scoped_xml_ptr< xmlNode > child)
Definition: xml_node.cc:62
xmlNodePtr Release()
Definition: xml_node.cc:142
bool AddLiveOnlyInfo(const MediaInfo &media_info, const std::list< SegmentInfo > &segment_infos, uint32_t start_number)
Definition: xml_node.cc:300
void SetId(uint32_t id)
Definition: xml_node.cc:127
bool AddElements(const std::vector< Element > &elements)
Adds Elements to this node using the Element struct.
Definition: xml_node.cc:74
void AddSupplementalProperty(const std::string &scheme_id_uri, const std::string &value)
Definition: xml_node.cc:169
void SetIntegerAttribute(const char *attribute_name, uint64_t number)
Definition: xml_node.cc:111
void AddRoleElement(const std::string &scheme_id_uri, const std::string &value)
Definition: xml_node.cc:212
void SetContent(const std::string &content)
Definition: xml_node.cc:131
bool AddAudioInfo(const MediaInfo::AudioInfo &audio_info)
Definition: xml_node.cc:251
xmlNodePtr GetRawPtr()
Definition: xml_node.cc:148