| 1 |
/* GStreamer |
| 2 |
* |
| 3 |
* Copyright (C) 2019 Collabora Ltd. |
| 4 |
* Author: Stéphane Cerveau <[email protected]> |
| 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 "gstmpdsegmenttimelinenode.h" |
| 22 |
#include "gstmpdparser.h" |
| 23 |
|
| 24 |
G_DEFINE_TYPE (GstMPDSegmentTimelineNode2, gst_mpd_segment_timeline_node, |
| 25 |
GST_TYPE_MPD_NODE); |
| 26 |
|
| 27 |
/* GObject VMethods */ |
| 28 |
|
| 29 |
static void |
| 30 |
gst_mpd_segment_timeline_node_finalize (GObject * object) |
| 31 |
{ |
| 32 |
GstMPDSegmentTimelineNode *self = GST_MPD_SEGMENT_TIMELINE_NODE (object); |
| 33 |
|
| 34 |
g_queue_foreach (&self->S, (GFunc) gst_mpd_s_node_free, NULL); |
| 35 |
g_queue_clear (&self->S); |
| 36 |
|
| 37 |
G_OBJECT_CLASS (gst_mpd_segment_timeline_node_parent_class)->finalize |
| 38 |
(object); |
| 39 |
} |
| 40 |
|
| 41 |
/* Base class */ |
| 42 |
|
| 43 |
static xmlNodePtr |
| 44 |
gst_mpd_segment_timeline_get_xml_node (GstMPDNode * node) |
| 45 |
{ |
| 46 |
xmlNodePtr segment_timeline_xml_node = NULL; |
| 47 |
GstMPDSegmentTimelineNode *self = GST_MPD_SEGMENT_TIMELINE_NODE (node); |
| 48 |
|
| 49 |
segment_timeline_xml_node = xmlNewNode (NULL, (xmlChar *) "SegmentTimeline"); |
| 50 |
|
| 51 |
g_queue_foreach (&self->S, (GFunc) gst_mpd_node_get_list_item, |
| 52 |
segment_timeline_xml_node); |
| 53 |
|
| 54 |
return segment_timeline_xml_node; |
| 55 |
} |
| 56 |
|
| 57 |
static void |
| 58 |
gst_mpd_segment_timeline_node_class_init (GstMPDSegmentTimelineNodeClass * |
| 59 |
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_segment_timeline_node_finalize; |
| 68 |
|
| 69 |
m_klass->get_xml_node = gst_mpd_segment_timeline_get_xml_node; |
| 70 |
} |
| 71 |
|
| 72 |
static void |
| 73 |
gst_mpd_segment_timeline_node_init (GstMPDSegmentTimelineNode * self) |
| 74 |
{ |
| 75 |
g_queue_init (&self->S); |
| 76 |
} |
| 77 |
|
| 78 |
GstMPDSegmentTimelineNode * |
| 79 |
gst_mpd_segment_timeline_node_new (void) |
| 80 |
{ |
| 81 |
return g_object_new (GST_TYPE_MPD_SEGMENT_TIMELINE_NODE, NULL); |
| 82 |
} |
| 83 |
|
| 84 |
void |
| 85 |
gst_mpd_segment_timeline_node_free (GstMPDSegmentTimelineNode * self) |
| 86 |
{ |
| 87 |
if (self) |
| 88 |
gst_object_unref (self); |
| 89 |
} |
| 90 |
|
| 91 |
GstMPDSegmentTimelineNode * |
| 92 |
gst_mpd_segment_timeline_node_clone (GstMPDSegmentTimelineNode * |
| 93 |
segment_timeline) |
| 94 |
{ |
| 95 |
GstMPDSegmentTimelineNode *clone = NULL; |
| 96 |
GList *list; |
| 97 |
|
| 98 |
if (segment_timeline) { |
| 99 |
clone = gst_mpd_segment_timeline_node_new (); |
| 100 |
for (list = g_queue_peek_head_link (&segment_timeline->S); list; |
| 101 |
list = g_list_next (list)) { |
| 102 |
GstMPDSNode *s_node; |
| 103 |
s_node = (GstMPDSNode *) list->data; |
| 104 |
if (s_node) { |
| 105 |
g_queue_push_tail (&clone->S, gst_mpd_s_node_clone (s_node)); |
| 106 |
} |
| 107 |
} |
| 108 |
} |
| 109 |
|
| 110 |
return clone; |
| 111 |
} |