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 "gstmpdsubrepresentationnode.h"
22 #include "gstmpdparser.h"
23
24 G_DEFINE_TYPE (GstMPDSubRepresentationNode, gst_mpd_sub_representation_node,
25 GST_TYPE_MPD_REPRESENTATION_BASE_NODE);
26
27 /* GObject VMethods */
28
29 static void
gst_mpd_sub_representation_node_finalize(GObject * object)30 gst_mpd_sub_representation_node_finalize (GObject * object)
31 {
32 GstMPDSubRepresentationNode *self = GST_MPD_SUB_REPRESENTATION_NODE (object);
33
34 if (self->dependencyLevel)
35 xmlFree (self->dependencyLevel);
36 g_strfreev (self->contentComponent);
37
38 G_OBJECT_CLASS (gst_mpd_sub_representation_node_parent_class)->finalize
39 (object);
40 }
41
42 /* Base class */
43
44 static xmlNodePtr
gst_mpd_sub_representation_get_xml_node(GstMPDNode * node)45 gst_mpd_sub_representation_get_xml_node (GstMPDNode * node)
46 {
47 gchar *value = NULL;
48 xmlNodePtr sub_representation_xml_node = NULL;
49 GstMPDSubRepresentationNode *self = GST_MPD_SUB_REPRESENTATION_NODE (node);
50
51 sub_representation_xml_node =
52 xmlNewNode (NULL, (xmlChar *) "SubRepresentation");
53
54 gst_xml_helper_set_prop_uint (sub_representation_xml_node, "level",
55 self->level);
56
57 gst_xml_helper_set_prop_uint_vector_type (sub_representation_xml_node,
58 "dependencyLevel", self->dependencyLevel, self->dependencyLevel_size);
59
60 gst_xml_helper_set_prop_uint (sub_representation_xml_node, "bandwidth",
61 self->level);
62
63 if (self->contentComponent) {
64 value = g_strjoinv (" ", self->contentComponent);
65 gst_xml_helper_set_prop_string (sub_representation_xml_node,
66 "contentComponent", value);
67 g_free (value);
68 }
69
70 return sub_representation_xml_node;
71 }
72
73 static void
gst_mpd_sub_representation_node_class_init(GstMPDSubRepresentationNodeClass * klass)74 gst_mpd_sub_representation_node_class_init (GstMPDSubRepresentationNodeClass *
75 klass)
76 {
77 GObjectClass *object_class;
78 GstMPDNodeClass *m_klass;
79
80 object_class = G_OBJECT_CLASS (klass);
81 m_klass = GST_MPD_NODE_CLASS (klass);
82
83 object_class->finalize = gst_mpd_sub_representation_node_finalize;
84
85 m_klass->get_xml_node = gst_mpd_sub_representation_get_xml_node;
86 }
87
88 static void
gst_mpd_sub_representation_node_init(GstMPDSubRepresentationNode * self)89 gst_mpd_sub_representation_node_init (GstMPDSubRepresentationNode * self)
90 {
91 self->level = 0;
92 self->dependencyLevel = NULL;
93 self->dependencyLevel_size = 0;
94 self->bandwidth = 0;
95 self->contentComponent = NULL;
96 }
97
98 GstMPDSubRepresentationNode *
gst_mpd_sub_representation_node_new(void)99 gst_mpd_sub_representation_node_new (void)
100 {
101 return g_object_new (GST_TYPE_MPD_SUB_REPRESENTATION_NODE, NULL);
102 }
103
104 void
gst_mpd_sub_representation_node_free(GstMPDSubRepresentationNode * self)105 gst_mpd_sub_representation_node_free (GstMPDSubRepresentationNode * self)
106 {
107 if (self)
108 gst_object_unref (self);
109 }
110