| 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 "gstmpdsegmenttemplatenode.h" |
| 22 |
#include "gstmpdparser.h" |
| 23 |
|
| 24 |
G_DEFINE_TYPE (GstMPDSegmentTemplateNode2, gst_mpd_segment_template_node, |
| 25 |
GST_TYPE_MPD_MULT_SEGMENT_BASE_NODE); |
| 26 |
|
| 27 |
enum |
| 28 |
{ |
| 29 |
PROP_MPD_SEGMENT_TEMPLATE_0, |
| 30 |
PROP_MPD_SEGMENT_TEMPLATE_MEDIA, |
| 31 |
PROP_MPD_SEGMENT_TEMPLATE_INDEX, |
| 32 |
PROP_MPD_SEGMENT_TEMPLATE_INITIALIZATION, |
| 33 |
PROP_MPD_SEGMENT_TEMPLATE_BITSTREAM_SWITCHING, |
| 34 |
}; |
| 35 |
|
| 36 |
/* GObject VMethods */ |
| 37 |
|
| 38 |
static void |
| 39 |
gst_mpd_segment_template_node_set_property (GObject * object, guint prop_id, |
| 40 |
const GValue * value, GParamSpec * pspec) |
| 41 |
{ |
| 42 |
GstMPDSegmentTemplateNode *self = GST_MPD_SEGMENT_TEMPLATE_NODE (object); |
| 43 |
switch (prop_id) { |
| 44 |
case PROP_MPD_SEGMENT_TEMPLATE_MEDIA: |
| 45 |
g_free (self->media); |
| 46 |
self->media = g_value_dup_string (value); |
| 47 |
break; |
| 48 |
case PROP_MPD_SEGMENT_TEMPLATE_INDEX: |
| 49 |
g_free (self->index); |
| 50 |
self->index = g_value_dup_string (value); |
| 51 |
break; |
| 52 |
case PROP_MPD_SEGMENT_TEMPLATE_INITIALIZATION: |
| 53 |
g_free (self->initialization); |
| 54 |
self->initialization = g_value_dup_string (value); |
| 55 |
break; |
| 56 |
case PROP_MPD_SEGMENT_TEMPLATE_BITSTREAM_SWITCHING: |
| 57 |
g_free (self->bitstreamSwitching); |
| 58 |
self->bitstreamSwitching = g_value_dup_string (value); |
| 59 |
break; |
| 60 |
default: |
| 61 |
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
| 62 |
break; |
| 63 |
} |
| 64 |
} |
| 65 |
|
| 66 |
static void |
| 67 |
gst_mpd_segment_template_node_get_property (GObject * object, guint prop_id, |
| 68 |
GValue * value, GParamSpec * pspec) |
| 69 |
{ |
| 70 |
GstMPDSegmentTemplateNode *self = GST_MPD_SEGMENT_TEMPLATE_NODE (object); |
| 71 |
switch (prop_id) { |
| 72 |
case PROP_MPD_SEGMENT_TEMPLATE_MEDIA: |
| 73 |
g_value_set_string (value, self->media); |
| 74 |
break; |
| 75 |
case PROP_MPD_SEGMENT_TEMPLATE_INDEX: |
| 76 |
g_value_set_string (value, self->index); |
| 77 |
break; |
| 78 |
case PROP_MPD_SEGMENT_TEMPLATE_INITIALIZATION: |
| 79 |
g_value_set_string (value, self->initialization); |
| 80 |
break; |
| 81 |
case PROP_MPD_SEGMENT_TEMPLATE_BITSTREAM_SWITCHING: |
| 82 |
g_value_set_string (value, self->bitstreamSwitching); |
| 83 |
break; |
| 84 |
default: |
| 85 |
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
| 86 |
break; |
| 87 |
} |
| 88 |
} |
| 89 |
|
| 90 |
static void |
| 91 |
gst_mpd_segment_template_node_finalize (GObject * object) |
| 92 |
{ |
| 93 |
GstMPDSegmentTemplateNode *self = GST_MPD_SEGMENT_TEMPLATE_NODE (object); |
| 94 |
|
| 95 |
g_free (self->media); |
| 96 |
g_free (self->index); |
| 97 |
g_free (self->initialization); |
| 98 |
g_free (self->bitstreamSwitching); |
| 99 |
|
| 100 |
G_OBJECT_CLASS (gst_mpd_segment_template_node_parent_class)->finalize |
| 101 |
(object); |
| 102 |
} |
| 103 |
|
| 104 |
/* Base class */ |
| 105 |
|
| 106 |
static xmlNodePtr |
| 107 |
gst_mpd_segment_template_get_xml_node (GstMPDNode * node) |
| 108 |
{ |
| 109 |
xmlNodePtr segment_template_xml_node = NULL; |
| 110 |
GstMPDSegmentTemplateNode *self = GST_MPD_SEGMENT_TEMPLATE_NODE (node); |
| 111 |
|
| 112 |
segment_template_xml_node = xmlNewNode (NULL, (xmlChar *) "SegmentTemplate"); |
| 113 |
|
| 114 |
if (self->media) |
| 115 |
gst_xml_helper_set_prop_string (segment_template_xml_node, "media", |
| 116 |
self->media); |
| 117 |
|
| 118 |
if (self->index) |
| 119 |
gst_xml_helper_set_prop_string (segment_template_xml_node, "index", |
| 120 |
self->index); |
| 121 |
|
| 122 |
if (self->initialization) |
| 123 |
gst_xml_helper_set_prop_string (segment_template_xml_node, "initialization", |
| 124 |
self->initialization); |
| 125 |
|
| 126 |
if (self->bitstreamSwitching) |
| 127 |
gst_xml_helper_set_prop_string (segment_template_xml_node, |
| 128 |
"bitstreamSwitching", self->bitstreamSwitching); |
| 129 |
|
| 130 |
return segment_template_xml_node; |
| 131 |
} |
| 132 |
|
| 133 |
static void |
| 134 |
gst_mpd_segment_template_node_class_init (GstMPDSegmentTemplateNodeClass * |
| 135 |
klass) |
| 136 |
{ |
| 137 |
GObjectClass *object_class; |
| 138 |
GstMPDNodeClass *m_klass; |
| 139 |
|
| 140 |
object_class = G_OBJECT_CLASS (klass); |
| 141 |
m_klass = GST_MPD_NODE_CLASS (klass); |
| 142 |
|
| 143 |
object_class->finalize = gst_mpd_segment_template_node_finalize; |
| 144 |
object_class->set_property = gst_mpd_segment_template_node_set_property; |
| 145 |
object_class->get_property = gst_mpd_segment_template_node_get_property; |
| 146 |
|
| 147 |
m_klass->get_xml_node = gst_mpd_segment_template_get_xml_node; |
| 148 |
|
| 149 |
g_object_class_install_property (object_class, |
| 150 |
PROP_MPD_SEGMENT_TEMPLATE_MEDIA, g_param_spec_string ("media", |
| 151 |
"media", "media", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); |
| 152 |
g_object_class_install_property (object_class, |
| 153 |
PROP_MPD_SEGMENT_TEMPLATE_INDEX, g_param_spec_string ("index", |
| 154 |
"index", "index", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); |
| 155 |
g_object_class_install_property (object_class, |
| 156 |
PROP_MPD_SEGMENT_TEMPLATE_INITIALIZATION, |
| 157 |
g_param_spec_string ("initialization", "initialization", "initialization", |
| 158 |
NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); |
| 159 |
g_object_class_install_property (object_class, |
| 160 |
PROP_MPD_SEGMENT_TEMPLATE_BITSTREAM_SWITCHING, |
| 161 |
g_param_spec_string ("bitstream-switching", "bitstream switching", |
| 162 |
"bitstream switching", NULL, |
| 163 |
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); |
| 164 |
} |
| 165 |
|
| 166 |
static void |
| 167 |
gst_mpd_segment_template_node_init (GstMPDSegmentTemplateNode * self) |
| 168 |
{ |
| 169 |
self->media = NULL; |
| 170 |
self->index = NULL; |
| 171 |
self->initialization = NULL; |
| 172 |
self->bitstreamSwitching = NULL; |
| 173 |
} |
| 174 |
|
| 175 |
GstMPDSegmentTemplateNode * |
| 176 |
gst_mpd_segment_template_node_new (void) |
| 177 |
{ |
| 178 |
return g_object_new (GST_TYPE_MPD_SEGMENT_TEMPLATE_NODE, NULL); |
| 179 |
} |
| 180 |
|
| 181 |
void |
| 182 |
gst_mpd_segment_template_node_free (GstMPDSegmentTemplateNode * self) |
| 183 |
{ |
| 184 |
if (self) |
| 185 |
gst_object_unref (self); |
| 186 |
} |