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 "gstmpdcontentcomponentnode.h"
22 #include "gstmpdparser.h"
23
24 G_DEFINE_TYPE (GstMPDContentComponentNode, gst_mpd_content_component_node,
25 GST_TYPE_MPD_NODE);
26
27 /* GObject VMethods */
28
29 static void
gst_mpd_content_component_node_finalize(GObject * object)30 gst_mpd_content_component_node_finalize (GObject * object)
31 {
32 GstMPDContentComponentNode *self = GST_MPD_CONTENT_COMPONENT_NODE (object);
33
34 if (self->lang)
35 xmlFree (self->lang);
36 if (self->contentType)
37 xmlFree (self->contentType);
38 g_slice_free (GstXMLRatio, self->par);
39 g_list_free_full (self->Accessibility,
40 (GDestroyNotify) gst_mpd_descriptor_type_node_free);
41 g_list_free_full (self->Role,
42 (GDestroyNotify) gst_mpd_descriptor_type_node_free);
43 g_list_free_full (self->Rating,
44 (GDestroyNotify) gst_mpd_descriptor_type_node_free);
45 g_list_free_full (self->Viewpoint,
46 (GDestroyNotify) gst_mpd_descriptor_type_node_free);
47
48 G_OBJECT_CLASS (gst_mpd_content_component_node_parent_class)->finalize
49 (object);
50 }
51
52 /* Base class */
53
54 static xmlNodePtr
gst_mpd_content_component_get_xml_node(GstMPDNode * node)55 gst_mpd_content_component_get_xml_node (GstMPDNode * node)
56 {
57 xmlNodePtr content_component_xml_node = NULL;
58 GstMPDContentComponentNode *self = GST_MPD_CONTENT_COMPONENT_NODE (node);
59 content_component_xml_node =
60 xmlNewNode (NULL, (xmlChar *) "ContentComponent");
61
62 gst_xml_helper_set_prop_uint (content_component_xml_node, "id", self->id);
63 gst_xml_helper_set_prop_string (content_component_xml_node, "lang",
64 self->lang);
65 gst_xml_helper_set_prop_string (content_component_xml_node, "contentType",
66 self->contentType);
67 gst_xml_helper_set_prop_ratio (content_component_xml_node, "par", self->par);
68
69 g_list_foreach (self->Accessibility, gst_mpd_node_get_list_item,
70 content_component_xml_node);
71 g_list_foreach (self->Role, gst_mpd_node_get_list_item,
72 content_component_xml_node);
73 g_list_foreach (self->Rating, gst_mpd_node_get_list_item,
74 content_component_xml_node);
75 g_list_foreach (self->Viewpoint, gst_mpd_node_get_list_item,
76 content_component_xml_node);
77
78 return content_component_xml_node;
79 }
80
81 static void
gst_mpd_content_component_node_class_init(GstMPDContentComponentNodeClass * klass)82 gst_mpd_content_component_node_class_init (GstMPDContentComponentNodeClass *
83 klass)
84 {
85 GObjectClass *object_class;
86 GstMPDNodeClass *m_klass;
87
88 object_class = G_OBJECT_CLASS (klass);
89 m_klass = GST_MPD_NODE_CLASS (klass);
90
91 object_class->finalize = gst_mpd_content_component_node_finalize;
92
93 m_klass->get_xml_node = gst_mpd_content_component_get_xml_node;
94 }
95
96 static void
gst_mpd_content_component_node_init(GstMPDContentComponentNode * self)97 gst_mpd_content_component_node_init (GstMPDContentComponentNode * self)
98 {
99 self->id = 0;
100 self->lang = NULL;
101 self->contentType = NULL;
102 self->par = 0;
103 self->Accessibility = 0;
104 self->Role = NULL;
105 self->Rating = NULL;
106 self->Viewpoint = NULL;
107 }
108
109 GstMPDContentComponentNode *
gst_mpd_content_component_node_new(void)110 gst_mpd_content_component_node_new (void)
111 {
112 return g_object_new (GST_TYPE_MPD_CONTENT_COMPONENT_NODE, NULL);
113 }
114
115 void
gst_mpd_content_component_node_free(GstMPDContentComponentNode * self)116 gst_mpd_content_component_node_free (GstMPDContentComponentNode * self)
117 {
118 if (self)
119 gst_object_unref (self);
120 }
121