| 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 "gstmpddescriptortypenode.h" |
| 22 |
#include "gstmpdparser.h" |
| 23 |
|
| 24 |
G_DEFINE_TYPE (GstMPDDescriptorTypeNode2, gst_mpd_descriptor_type_node, |
| 25 |
GST_TYPE_MPD_NODE); |
| 26 |
|
| 27 |
/* GObject VMethods */ |
| 28 |
|
| 29 |
static void |
| 30 |
gst_mpd_descriptor_type_node_finalize (GObject * object) |
| 31 |
{ |
| 32 |
GstMPDDescriptorTypeNode *self = GST_MPD_DESCRIPTOR_TYPE_NODE (object); |
| 33 |
|
| 34 |
if (self->schemeIdUri) |
| 35 |
xmlFree (self->schemeIdUri); |
| 36 |
if (self->value) |
| 37 |
xmlFree (self->value); |
| 38 |
g_free (self->node_name); |
| 39 |
|
| 40 |
G_OBJECT_CLASS (gst_mpd_descriptor_type_node_parent_class)->finalize (object); |
| 41 |
} |
| 42 |
|
| 43 |
/* Base class */ |
| 44 |
|
| 45 |
static xmlNodePtr |
| 46 |
gst_mpd_descriptor_type_get_xml_node (GstMPDNode * node) |
| 47 |
{ |
| 48 |
xmlNodePtr descriptor_type_xml_node = NULL; |
| 49 |
GstMPDDescriptorTypeNode *self = GST_MPD_DESCRIPTOR_TYPE_NODE (node); |
| 50 |
|
| 51 |
descriptor_type_xml_node = xmlNewNode (NULL, (xmlChar *) self->node_name); |
| 52 |
|
| 53 |
gst_xml_helper_set_prop_string (descriptor_type_xml_node, "schemeIdUri", |
| 54 |
self->schemeIdUri); |
| 55 |
|
| 56 |
gst_xml_helper_set_prop_string (descriptor_type_xml_node, "value", |
| 57 |
self->value); |
| 58 |
|
| 59 |
return descriptor_type_xml_node; |
| 60 |
} |
| 61 |
|
| 62 |
static void |
| 63 |
gst_mpd_descriptor_type_node_class_init (GstMPDDescriptorTypeNodeClass * 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_descriptor_type_node_finalize; |
| 72 |
|
| 73 |
m_klass->get_xml_node = gst_mpd_descriptor_type_get_xml_node; |
| 74 |
} |
| 75 |
|
| 76 |
static void |
| 77 |
gst_mpd_descriptor_type_node_init (GstMPDDescriptorTypeNode * self) |
| 78 |
{ |
| 79 |
if (self->schemeIdUri) |
| 80 |
xmlFree (self->schemeIdUri); |
| 81 |
if (self->value) |
| 82 |
xmlFree (self->value); |
| 83 |
} |
| 84 |
|
| 85 |
GstMPDDescriptorTypeNode * |
| 86 |
gst_mpd_descriptor_type_node_new (const gchar * name) |
| 87 |
{ |
| 88 |
GstMPDDescriptorTypeNode *self = |
| 89 |
g_object_new (GST_TYPE_MPD_DESCRIPTOR_TYPE_NODE, NULL); |
| 90 |
self->node_name = g_strdup (name); |
| 91 |
return self; |
| 92 |
} |
| 93 |
|
| 94 |
void |
| 95 |
gst_mpd_descriptor_type_node_free (GstMPDDescriptorTypeNode * self) |
| 96 |
{ |
| 97 |
if (self) |
| 98 |
gst_object_unref (self); |
| 99 |
} |