• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "gstmpdurltypenode.h"
22 #include "gstmpdparser.h"
23 
24 G_DEFINE_TYPE (GstMPDURLTypeNode, gst_mpd_url_type_node, GST_TYPE_MPD_NODE);
25 
26 /* GObject VMethods */
27 
28 static void
gst_mpd_url_type_node_finalize(GObject * object)29 gst_mpd_url_type_node_finalize (GObject * object)
30 {
31   GstMPDURLTypeNode *self = GST_MPD_URL_TYPE_NODE (object);
32 
33   if (self->sourceURL)
34     xmlFree (self->sourceURL);
35   g_slice_free (GstXMLRange, self->range);
36   g_free (self->node_name);
37 
38   G_OBJECT_CLASS (gst_mpd_url_type_node_parent_class)->finalize (object);
39 }
40 
41 /* Base class */
42 
43 static xmlNodePtr
gst_mpd_url_type_get_xml_node(GstMPDNode * node)44 gst_mpd_url_type_get_xml_node (GstMPDNode * node)
45 {
46   xmlNodePtr url_type_xml_node = NULL;
47   GstMPDURLTypeNode *self = GST_MPD_URL_TYPE_NODE (node);
48 
49   url_type_xml_node = xmlNewNode (NULL, (xmlChar *) self->node_name);
50 
51   gst_xml_helper_set_prop_string (url_type_xml_node, "sourceURL",
52       self->sourceURL);
53   gst_xml_helper_set_prop_range (url_type_xml_node, "range", self->range);
54 
55   return url_type_xml_node;
56 }
57 
58 static void
gst_mpd_url_type_node_class_init(GstMPDURLTypeNodeClass * klass)59 gst_mpd_url_type_node_class_init (GstMPDURLTypeNodeClass * klass)
60 {
61   GObjectClass *object_class;
62   GstMPDNodeClass *m_klass;
63 
64   object_class = G_OBJECT_CLASS (klass);
65   m_klass = GST_MPD_NODE_CLASS (klass);
66 
67   object_class->finalize = gst_mpd_url_type_node_finalize;
68 
69   m_klass->get_xml_node = gst_mpd_url_type_get_xml_node;
70 }
71 
72 static void
gst_mpd_url_type_node_init(GstMPDURLTypeNode * self)73 gst_mpd_url_type_node_init (GstMPDURLTypeNode * self)
74 {
75   self->node_name = NULL;
76   self->sourceURL = NULL;
77   self->range = NULL;
78 }
79 
80 GstMPDURLTypeNode *
gst_mpd_url_type_node_new(const gchar * name)81 gst_mpd_url_type_node_new (const gchar * name)
82 {
83   GstMPDURLTypeNode *self = g_object_new (GST_TYPE_MPD_URL_TYPE_NODE, NULL);
84   self->node_name = g_strdup (name);
85   return self;
86 }
87 
88 void
gst_mpd_url_type_node_free(GstMPDURLTypeNode * self)89 gst_mpd_url_type_node_free (GstMPDURLTypeNode * self)
90 {
91   if (self)
92     gst_object_unref (self);
93 }
94 
95 GstMPDURLTypeNode *
gst_mpd_url_type_node_clone(GstMPDURLTypeNode * url)96 gst_mpd_url_type_node_clone (GstMPDURLTypeNode * url)
97 {
98 
99   GstMPDURLTypeNode *clone = NULL;
100 
101   if (url) {
102     clone = gst_mpd_url_type_node_new (url->node_name);
103     if (url->sourceURL) {
104       clone->sourceURL = xmlMemStrdup (url->sourceURL);
105     }
106     clone->range = gst_xml_helper_clone_range (url->range);
107   }
108 
109   return clone;
110 }
111