• 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 "gstmpdsegmentbasenode.h"
22 #include "gstmpdparser.h"
23 
24 G_DEFINE_TYPE (GstMPDSegmentBaseNode, gst_mpd_segment_base_node,
25     GST_TYPE_MPD_NODE);
26 
27 /* GObject VMethods */
28 
29 static void
gst_mpd_segment_base_node_finalize(GObject * object)30 gst_mpd_segment_base_node_finalize (GObject * object)
31 {
32   GstMPDSegmentBaseNode *self = GST_MPD_SEGMENT_BASE_NODE (object);
33 
34   if (self->indexRange)
35     g_slice_free (GstXMLRange, self->indexRange);
36   gst_mpd_url_type_node_free (self->Initialization);
37   gst_mpd_url_type_node_free (self->RepresentationIndex);
38 
39   G_OBJECT_CLASS (gst_mpd_segment_base_node_parent_class)->finalize (object);
40 }
41 
42 /* Base class */
43 
44 static xmlNodePtr
gst_mpd_segment_base_get_xml_node(GstMPDNode * node)45 gst_mpd_segment_base_get_xml_node (GstMPDNode * node)
46 {
47   xmlNodePtr segment_base_xml_node = NULL;
48   GstMPDSegmentBaseNode *self = GST_MPD_SEGMENT_BASE_NODE (node);
49 
50   segment_base_xml_node = xmlNewNode (NULL, (xmlChar *) "SegmentBase");
51 
52   if (self->timescale)
53     gst_xml_helper_set_prop_uint (segment_base_xml_node, "timescale",
54         self->timescale);
55   if (self->presentationTimeOffset)
56     gst_xml_helper_set_prop_uint64 (segment_base_xml_node,
57         "presentationTimeOffset", self->presentationTimeOffset);
58   if (self->indexRange) {
59     gst_xml_helper_set_prop_range (segment_base_xml_node, "indexRange",
60         self->indexRange);
61     gst_xml_helper_set_prop_boolean (segment_base_xml_node, "indexRangeExact",
62         self->indexRangeExact);
63   }
64   if (self->Initialization)
65     gst_mpd_node_add_child_node (GST_MPD_NODE (self->Initialization),
66         segment_base_xml_node);
67   if (self->RepresentationIndex)
68     gst_mpd_node_add_child_node (GST_MPD_NODE (self->RepresentationIndex),
69         segment_base_xml_node);
70 
71   return segment_base_xml_node;
72 }
73 
74 static void
gst_mpd_segment_base_node_class_init(GstMPDSegmentBaseNodeClass * klass)75 gst_mpd_segment_base_node_class_init (GstMPDSegmentBaseNodeClass * 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_segment_base_node_finalize;
84 
85   m_klass->get_xml_node = gst_mpd_segment_base_get_xml_node;
86 }
87 
88 static void
gst_mpd_segment_base_node_init(GstMPDSegmentBaseNode * self)89 gst_mpd_segment_base_node_init (GstMPDSegmentBaseNode * self)
90 {
91   self->timescale = 0;
92   self->presentationTimeOffset = 0;
93   self->indexRange = NULL;
94   self->indexRangeExact = FALSE;
95   /* Initialization node */
96   self->Initialization = NULL;
97   /* RepresentationIndex node */
98   self->RepresentationIndex = NULL;
99 }
100 
101 GstMPDSegmentBaseNode *
gst_mpd_segment_base_node_new(void)102 gst_mpd_segment_base_node_new (void)
103 {
104   return g_object_new (GST_TYPE_MPD_SEGMENT_BASE_NODE, NULL);
105 }
106 
107 void
gst_mpd_segment_base_node_free(GstMPDSegmentBaseNode * self)108 gst_mpd_segment_base_node_free (GstMPDSegmentBaseNode * self)
109 {
110   if (self)
111     gst_object_unref (self);
112 }
113