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/mpd/base/content_protection_element.h"
19 #include "packager/mpd/base/media_info.pb.h"
20 #include "packager/mpd/base/xml/scoped_xml_ptr.h"
21 
22 namespace edash_packager {
23 
24 struct SegmentInfo;
25 
26 namespace xml {
27 
31 class XmlNode {
32  public:
35  explicit XmlNode(const char* name);
36  virtual ~XmlNode();
37 
42  bool AddChild(scoped_xml_ptr<xmlNode> child);
43 
45  bool AddElements(const std::vector<Element>& elements);
46 
50  void SetStringAttribute(const char* attribute_name,
51  const std::string& attribute);
52 
56  void SetIntegerAttribute(const char* attribute_name, uint64_t number);
57 
61  void SetFloatingPointAttribute(const char* attribute_name, double number);
62 
65  void SetId(uint32_t id);
66 
73  void SetContent(const std::string& content);
74 
78  scoped_xml_ptr<xmlNode> PassScopedPtr();
79 
82  xmlNodePtr Release();
83 
85  xmlNodePtr GetRawPtr();
86 
87  private:
88  scoped_xml_ptr<xmlNode> node_;
89 
90  DISALLOW_COPY_AND_ASSIGN(XmlNode);
91 };
92 
97  public:
98  ~RepresentationBaseXmlNode() override;
99  bool AddContentProtectionElements(
100  const std::list<ContentProtectionElement>& content_protection_elements);
101 
102  protected:
103  explicit RepresentationBaseXmlNode(const char* name);
104 
105  private:
106  bool AddContentProtectionElement(
107  const ContentProtectionElement& content_protection_element);
108 
109  DISALLOW_COPY_AND_ASSIGN(RepresentationBaseXmlNode);
110 };
111 
114  public:
116  ~AdaptationSetXmlNode() override;
117 
120  void AddRoleElement(const std::string& scheme_id_uri,
121  const std::string& value);
122 
123  private:
124  DISALLOW_COPY_AND_ASSIGN(AdaptationSetXmlNode);
125 };
126 
129  public:
131  ~RepresentationXmlNode() override;
132 
140  bool AddVideoInfo(const MediaInfo::VideoInfo& video_info,
141  bool set_width,
142  bool set_height,
143  bool set_frame_rate);
144 
149  bool AddAudioInfo(const MediaInfo::AudioInfo& audio_info);
150 
155  bool AddVODOnlyInfo(const MediaInfo& media_info);
156 
159  bool AddLiveOnlyInfo(const MediaInfo& media_info,
160  const std::list<SegmentInfo>& segment_infos,
161  uint32_t start_number);
162 
163  private:
164  // Add AudioChannelConfiguration element. Note that it is a required element
165  // for audio Representations.
166  bool AddAudioChannelInfo(const MediaInfo::AudioInfo& audio_info);
167 
168  // Add audioSamplingRate attribute to this element, if present.
169  void AddAudioSamplingRateInfo(const MediaInfo::AudioInfo& audio_info);
170 
171  DISALLOW_COPY_AND_ASSIGN(RepresentationXmlNode);
172 };
173 
174 } // namespace xml
175 } // namespace edash_packager
176 #endif // MPD_BASE_XML_XML_NODE_H_
bool AddVODOnlyInfo(const MediaInfo &media_info)
Definition: xml_node.cc:251
bool AddLiveOnlyInfo(const MediaInfo &media_info, const std::list< SegmentInfo > &segment_infos, uint32_t start_number)
Definition: xml_node.cc:298
void SetStringAttribute(const char *attribute_name, const std::string &attribute)
Definition: xml_node.cc:104
void SetFloatingPointAttribute(const char *attribute_name, double number)
Definition: xml_node.cc:119
bool AddAudioInfo(const MediaInfo::AudioInfo &audio_info)
Definition: xml_node.cc:243
void SetId(uint32_t id)
Definition: xml_node.cc:128
bool AddChild(scoped_xml_ptr< xmlNode > child)
Definition: xml_node.cc:62
XmlNode(const char *name)
Definition: xml_node.cc:55
void SetIntegerAttribute(const char *attribute_name, uint64_t number)
Definition: xml_node.cc:111
bool AddElements(const std::vector< Element > &elements)
Adds Elements to this node using the Element struct.
Definition: xml_node.cc:74
RepresentationType in MPD.
Definition: xml_node.h:128
scoped_xml_ptr< xmlNode > PassScopedPtr()
Definition: xml_node.cc:137
void SetContent(const std::string &content)
Definition: xml_node.cc:132
bool AddVideoInfo(const MediaInfo::VideoInfo &video_info, bool set_width, bool set_height, bool set_frame_rate)
Definition: xml_node.cc:216
void AddRoleElement(const std::string &scheme_id_uri, const std::string &value)
Definition: xml_node.cc:204
AdaptationSetType specified in MPD.
Definition: xml_node.h:113