2 * Copyright (C) 2012 Smart TV Alliance
3 * Author: Thiago Sousa Santos <thiago.sousa.santos@collabora.com>, Collabora Ltd.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
25 #include <libxml/parser.h>
26 #include <libxml/tree.h>
28 #include "gstmssmanifest.h"
30 struct _GstMssManifestStream
35 struct _GstMssManifest
38 xmlNodePtr xmlrootnode;
44 gst_mss_manifest_new (const GstBuffer * data)
46 GstMssManifest *manifest;
50 manifest = g_malloc0 (sizeof (GstMssManifest));
52 manifest->xml = xmlReadMemory ((const gchar *) GST_BUFFER_DATA (data),
53 GST_BUFFER_SIZE (data), "manifest", NULL, 0);
54 root = manifest->xmlrootnode = xmlDocGetRootElement (manifest->xml);
56 for (nodeiter = root->children; nodeiter; nodeiter = nodeiter->next) {
57 if (nodeiter->type == XML_ELEMENT_NODE
58 && (strcmp ((const char *) nodeiter->name, "StreamIndex") == 0)) {
59 GstMssManifestStream *stream = g_new0 (GstMssManifestStream, 1);
61 manifest->streams = g_slist_append (manifest->streams, stream);
62 stream->xmlnode = nodeiter;
70 gst_mss_manifest_free (GstMssManifest * manifest)
72 g_return_if_fail (manifest != NULL);
74 g_slist_free_full (manifest->streams, g_free);
76 xmlFreeDoc (manifest->xml);
81 gst_mss_manifest_get_streams (GstMssManifest * manifest)
83 return manifest->streams;
86 GstMssManifestStreamType
87 gst_mss_manifest_stream_get_type (GstMssManifestStream * stream)
89 gchar *prop = (gchar *) xmlGetProp (stream->xmlnode, (xmlChar *) "Type");
90 GstMssManifestStreamType ret = MSS_STREAM_TYPE_UNKNOWN;
92 if (strcmp (prop, "video") == 0) {
93 ret = MSS_STREAM_TYPE_VIDEO;
94 } else if (strcmp (prop, "audio") == 0) {
95 ret = MSS_STREAM_TYPE_AUDIO;
102 gst_mss_manifest_stream_type_name (GstMssManifestStreamType streamtype)
104 switch (streamtype) {
105 case MSS_STREAM_TYPE_VIDEO:
107 case MSS_STREAM_TYPE_AUDIO:
109 case MSS_STREAM_TYPE_UNKNOWN: