• 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 "gstmpdsegmentlistnode.h"
22 #include "gstmpdparser.h"
23 
24 G_DEFINE_TYPE (GstMPDSegmentListNode, gst_mpd_segment_list_node,
25     GST_TYPE_MPD_MULT_SEGMENT_BASE_NODE);
26 
27 /* GObject VMethods */
28 
29 static void
gst_mpd_segment_list_node_finalize(GObject * object)30 gst_mpd_segment_list_node_finalize (GObject * object)
31 {
32   GstMPDSegmentListNode *self = GST_MPD_SEGMENT_LIST_NODE (object);
33 
34   g_list_free_full (self->SegmentURL,
35       (GDestroyNotify) gst_mpd_segment_url_node_free);
36   if (self->xlink_href)
37     xmlFree (self->xlink_href);
38 
39   G_OBJECT_CLASS (gst_mpd_segment_list_node_parent_class)->finalize (object);
40 }
41 
42 /* Base class */
43 
44 static xmlNodePtr
gst_mpd_segment_list_get_xml_node(GstMPDNode * node)45 gst_mpd_segment_list_get_xml_node (GstMPDNode * node)
46 {
47   xmlNodePtr segment_list_xml_node = NULL;
48   GstMPDSegmentListNode *self = GST_MPD_SEGMENT_LIST_NODE (node);
49 
50   segment_list_xml_node = xmlNewNode (NULL, (xmlChar *) "SegmentList");
51 
52   g_list_foreach (self->SegmentURL, gst_mpd_node_get_list_item,
53       segment_list_xml_node);
54 
55   if (self->xlink_href)
56     gst_xml_helper_set_prop_string (segment_list_xml_node, "xlink_href",
57         self->xlink_href);
58 
59   return segment_list_xml_node;
60 }
61 
62 static void
gst_mpd_segment_list_node_class_init(GstMPDSegmentListNodeClass * klass)63 gst_mpd_segment_list_node_class_init (GstMPDSegmentListNodeClass * klass)
64 {
65   GObjectClass *object_class;
66   GstMPDNodeClass *m_klass;
67 
68   object_class = G_OBJECT_CLASS (klass);
69   m_klass = GST_MPD_NODE_CLASS (klass);
70 
71   object_class->finalize = gst_mpd_segment_list_node_finalize;
72 
73   m_klass->get_xml_node = gst_mpd_segment_list_get_xml_node;
74 }
75 
76 static void
gst_mpd_segment_list_node_init(GstMPDSegmentListNode * self)77 gst_mpd_segment_list_node_init (GstMPDSegmentListNode * self)
78 {
79   self->SegmentURL = NULL;
80   self->xlink_href = NULL;
81   self->actuate = GST_MPD_XLINK_ACTUATE_ON_REQUEST;
82 }
83 
84 GstMPDSegmentListNode *
gst_mpd_segment_list_node_new(void)85 gst_mpd_segment_list_node_new (void)
86 {
87   return g_object_new (GST_TYPE_MPD_SEGMENT_LIST_NODE, NULL);
88 }
89 
90 void
gst_mpd_segment_list_node_free(GstMPDSegmentListNode * self)91 gst_mpd_segment_list_node_free (GstMPDSegmentListNode * self)
92 {
93   if (self)
94     gst_object_unref (self);
95 }
96 
97 void
gst_mpd_segment_list_node_add_segment(GstMPDSegmentListNode * self,GstMPDSegmentURLNode * segment_url)98 gst_mpd_segment_list_node_add_segment (GstMPDSegmentListNode * self,
99     GstMPDSegmentURLNode * segment_url)
100 {
101   g_return_if_fail (self != NULL);
102 
103   self->SegmentURL = g_list_append (self->SegmentURL, segment_url);
104 }
105