| 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 "gstmpdmetricsnode.h" |
| 22 |
#include "gstmpdparser.h" |
| 23 |
|
| 24 |
G_DEFINE_TYPE (GstMPDMetricsNode2, gst_mpd_metrics_node, GST_TYPE_MPD_NODE); |
| 25 |
|
| 26 |
/* GObject VMethods */ |
| 27 |
|
| 28 |
static void |
| 29 |
gst_mpd_metrics_node_finalize (GObject * object) |
| 30 |
{ |
| 31 |
GstMPDMetricsNode *self = GST_MPD_METRICS_NODE (object); |
| 32 |
|
| 33 |
g_free (self->metrics); |
| 34 |
g_list_free_full (self->MetricsRanges, |
| 35 |
(GDestroyNotify) gst_mpd_metrics_range_node_free); |
| 36 |
|
| 37 |
G_OBJECT_CLASS (gst_mpd_metrics_node_parent_class)->finalize (object); |
| 38 |
} |
| 39 |
|
| 40 |
/* Base class */ |
| 41 |
|
| 42 |
static xmlNodePtr |
| 43 |
gst_mpd_metrics_get_xml_node (GstMPDNode * node) |
| 44 |
{ |
| 45 |
xmlNodePtr metrics_xml_node = NULL; |
| 46 |
GstMPDMetricsNode *self = GST_MPD_METRICS_NODE (node); |
| 47 |
|
| 48 |
metrics_xml_node = xmlNewNode (NULL, (xmlChar *) "Metrics"); |
| 49 |
|
| 50 |
if (self->metrics) |
| 51 |
gst_xml_helper_set_prop_string (metrics_xml_node, "metrics", self->metrics); |
| 52 |
|
| 53 |
g_list_foreach (self->Reportings, gst_mpd_node_get_list_item, |
| 54 |
metrics_xml_node); |
| 55 |
g_list_foreach (self->MetricsRanges, gst_mpd_node_get_list_item, |
| 56 |
metrics_xml_node); |
| 57 |
|
| 58 |
return metrics_xml_node; |
| 59 |
} |
| 60 |
|
| 61 |
static void |
| 62 |
gst_mpd_metrics_node_class_init (GstMPDMetricsNodeClass * klass) |
| 63 |
{ |
| 64 |
GObjectClass *object_class; |
| 65 |
GstMPDNodeClass *m_klass; |
| 66 |
|
| 67 |
object_class = G_OBJECT_CLASS (klass); |
| 68 |
m_klass = GST_MPD_NODE_CLASS (klass); |
| 69 |
|
| 70 |
object_class->finalize = gst_mpd_metrics_node_finalize; |
| 71 |
|
| 72 |
m_klass->get_xml_node = gst_mpd_metrics_get_xml_node; |
| 73 |
} |
| 74 |
|
| 75 |
static void |
| 76 |
gst_mpd_metrics_node_init (GstMPDMetricsNode * self) |
| 77 |
{ |
| 78 |
self->metrics = NULL; |
| 79 |
self->MetricsRanges = NULL; |
| 80 |
self->Reportings = NULL; |
| 81 |
} |
| 82 |
|
| 83 |
GstMPDMetricsNode * |
| 84 |
gst_mpd_metrics_node_new (void) |
| 85 |
{ |
| 86 |
return g_object_new (GST_TYPE_MPD_METRICS_NODE, NULL); |
| 87 |
} |
| 88 |
|
| 89 |
void |
| 90 |
gst_mpd_metrics_node_free (GstMPDMetricsNode * self) |
| 91 |
{ |
| 92 |
if (self) |
| 93 |
gst_object_unref (self); |
| 94 |
} |