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 "gstmpdsubsetnode.h"
22 #include "gstmpdparser.h"
23
24 G_DEFINE_TYPE (GstMPDSubsetNode, gst_mpd_subset_node, GST_TYPE_MPD_NODE);
25
26 /* GObject VMethods */
27
28 static void
gst_mpd_subset_node_finalize(GObject * object)29 gst_mpd_subset_node_finalize (GObject * object)
30 {
31 GstMPDSubsetNode *self = GST_MPD_SUBSET_NODE (object);
32
33 if (self->contains)
34 xmlFree (self->contains);
35
36 G_OBJECT_CLASS (gst_mpd_subset_node_parent_class)->finalize (object);
37 }
38
39 /* Base class */
40
41 static xmlNodePtr
gst_mpd_subset_get_xml_node(GstMPDNode * node)42 gst_mpd_subset_get_xml_node (GstMPDNode * node)
43 {
44 xmlNodePtr subset_xml_node = NULL;
45 GstMPDSubsetNode *self = GST_MPD_SUBSET_NODE (node);
46
47 subset_xml_node = xmlNewNode (NULL, (xmlChar *) "Subset");
48
49 if (self->contains)
50 gst_xml_helper_set_prop_uint_vector_type (subset_xml_node, "contains",
51 self->contains, self->contains_size);
52
53 return subset_xml_node;
54 }
55
56 static void
gst_mpd_subset_node_class_init(GstMPDSubsetNodeClass * klass)57 gst_mpd_subset_node_class_init (GstMPDSubsetNodeClass * klass)
58 {
59 GObjectClass *object_class;
60 GstMPDNodeClass *m_klass;
61
62 object_class = G_OBJECT_CLASS (klass);
63 m_klass = GST_MPD_NODE_CLASS (klass);
64
65 object_class->finalize = gst_mpd_subset_node_finalize;
66
67 m_klass->get_xml_node = gst_mpd_subset_get_xml_node;
68 }
69
70 static void
gst_mpd_subset_node_init(GstMPDSubsetNode * self)71 gst_mpd_subset_node_init (GstMPDSubsetNode * self)
72 {
73 self->contains_size = 0;
74 self->contains = NULL;
75 }
76
77 GstMPDSubsetNode *
gst_mpd_subset_node_new(void)78 gst_mpd_subset_node_new (void)
79 {
80 return g_object_new (GST_TYPE_MPD_SUBSET_NODE, NULL);
81 }
82
83 void
gst_mpd_subset_node_free(GstMPDSubsetNode * self)84 gst_mpd_subset_node_free (GstMPDSubsetNode * self)
85 {
86 if (self)
87 gst_object_unref (self);
88 }
89