1 /* GStreamer
2 *
3 * Copyright (C) 2019 Collabora Ltd.
4 * Author: Stéphane Cerveau <scerveau@collabora.com>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 */
21 #include "gstmpdprograminformationnode.h"
22 #include "gstmpdparser.h"
23
24 G_DEFINE_TYPE (GstMPDProgramInformationNode, gst_mpd_program_information_node,
25 GST_TYPE_MPD_NODE);
26
27 /* GObject VMethods */
28
29 static void
gst_mpd_program_information_node_finalize(GObject * object)30 gst_mpd_program_information_node_finalize (GObject * object)
31 {
32 GstMPDProgramInformationNode *self =
33 GST_MPD_PROGRAM_INFORMATION_NODE (object);
34
35 if (self->lang)
36 xmlFree (self->lang);
37 if (self->moreInformationURL)
38 xmlFree (self->moreInformationURL);
39 if (self->Title)
40 xmlFree (self->Title);
41 if (self->Source)
42 xmlFree (self->Source);
43 if (self->Copyright)
44 xmlFree (self->Copyright);
45
46 G_OBJECT_CLASS (gst_mpd_program_information_node_parent_class)->finalize
47 (object);
48 }
49
50 /* Base class */
51
52 static xmlNodePtr
gst_mpd_program_information_get_xml_node(GstMPDNode * node)53 gst_mpd_program_information_get_xml_node (GstMPDNode * node)
54 {
55 xmlNodePtr program_info_xml_node = NULL;
56 xmlNodePtr child_node = NULL;
57 GstMPDProgramInformationNode *self = GST_MPD_PROGRAM_INFORMATION_NODE (node);
58
59 program_info_xml_node = xmlNewNode (NULL, (xmlChar *) "ProgramInformation");
60
61 if (self->lang)
62 gst_xml_helper_set_prop_string (program_info_xml_node, "lang", self->lang);
63
64 if (self->moreInformationURL)
65 gst_xml_helper_set_prop_string (program_info_xml_node, "moreInformationURL",
66 self->moreInformationURL);
67
68 if (self->Title) {
69 child_node = xmlNewNode (NULL, (xmlChar *) "Title");
70 gst_xml_helper_set_content (child_node, self->Title);
71 xmlAddChild (program_info_xml_node, child_node);
72 }
73
74 if (self->Source) {
75 child_node = xmlNewNode (NULL, (xmlChar *) "Source");
76 gst_xml_helper_set_content (child_node, self->Source);
77 xmlAddChild (program_info_xml_node, child_node);
78 }
79
80 if (self->Copyright) {
81 child_node = xmlNewNode (NULL, (xmlChar *) "Copyright");
82 gst_xml_helper_set_content (child_node, self->Copyright);
83 xmlAddChild (program_info_xml_node, child_node);
84 }
85
86 return program_info_xml_node;
87 }
88
89 static void
gst_mpd_program_information_node_class_init(GstMPDProgramInformationNodeClass * klass)90 gst_mpd_program_information_node_class_init (GstMPDProgramInformationNodeClass *
91 klass)
92 {
93 GObjectClass *object_class;
94 GstMPDNodeClass *m_klass;
95
96 object_class = G_OBJECT_CLASS (klass);
97 m_klass = GST_MPD_NODE_CLASS (klass);
98
99 object_class->finalize = gst_mpd_program_information_node_finalize;
100
101 m_klass->get_xml_node = gst_mpd_program_information_get_xml_node;
102 }
103
104 static void
gst_mpd_program_information_node_init(GstMPDProgramInformationNode * self)105 gst_mpd_program_information_node_init (GstMPDProgramInformationNode * self)
106 {
107 self->lang = NULL;
108 self->moreInformationURL = NULL;
109 self->Title = NULL;
110 self->Source = NULL;
111 self->Copyright = NULL;
112 }
113
114 GstMPDProgramInformationNode *
gst_mpd_program_information_node_new(void)115 gst_mpd_program_information_node_new (void)
116 {
117 return g_object_new (GST_TYPE_MPD_PROGRAM_INFORMATION_NODE, NULL);
118 }
119
120 void
gst_mpd_program_information_node_free(GstMPDProgramInformationNode * self)121 gst_mpd_program_information_node_free (GstMPDProgramInformationNode * self)
122 {
123 if (self)
124 gst_object_unref (self);
125 }
126