2012-11-08 19:06:44 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2012 Smart TV Alliance
|
|
|
|
* Author: Thiago Sousa Santos <thiago.sousa.santos@collabora.com>, Collabora Ltd.
|
|
|
|
*
|
|
|
|
* gstmssmanifest.c:
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <glib.h>
|
2012-11-09 19:47:54 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <libxml/parser.h>
|
|
|
|
#include <libxml/tree.h>
|
2012-11-08 19:06:44 +00:00
|
|
|
|
|
|
|
#include "gstmssmanifest.h"
|
|
|
|
|
2012-11-09 19:47:54 +00:00
|
|
|
struct _GstMssManifestStream
|
|
|
|
{
|
|
|
|
xmlNodePtr xmlnode;
|
|
|
|
};
|
|
|
|
|
2012-11-08 19:06:44 +00:00
|
|
|
struct _GstMssManifest
|
|
|
|
{
|
2012-11-09 19:47:54 +00:00
|
|
|
xmlDocPtr xml;
|
|
|
|
xmlNodePtr xmlrootnode;
|
|
|
|
|
|
|
|
GSList *streams;
|
2012-11-08 19:06:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
GstMssManifest *
|
2012-11-09 19:47:54 +00:00
|
|
|
gst_mss_manifest_new (const GstBuffer * data)
|
2012-11-08 19:06:44 +00:00
|
|
|
{
|
|
|
|
GstMssManifest *manifest;
|
2012-11-09 19:47:54 +00:00
|
|
|
xmlNodePtr root;
|
|
|
|
xmlNodePtr nodeiter;
|
2012-11-08 19:06:44 +00:00
|
|
|
|
|
|
|
manifest = g_malloc0 (sizeof (GstMssManifest));
|
|
|
|
|
2012-11-09 19:47:54 +00:00
|
|
|
manifest->xml = xmlReadMemory ((const gchar *) GST_BUFFER_DATA (data),
|
|
|
|
GST_BUFFER_SIZE (data), "manifest", NULL, 0);
|
|
|
|
root = manifest->xmlrootnode = xmlDocGetRootElement (manifest->xml);
|
|
|
|
|
|
|
|
for (nodeiter = root->children; nodeiter; nodeiter = nodeiter->next) {
|
|
|
|
if (nodeiter->type == XML_ELEMENT_NODE
|
|
|
|
&& (strcmp ((const char *) nodeiter->name, "StreamIndex") == 0)) {
|
|
|
|
GstMssManifestStream *stream = g_new0 (GstMssManifestStream, 1);
|
|
|
|
|
|
|
|
manifest->streams = g_slist_append (manifest->streams, stream);
|
|
|
|
stream->xmlnode = nodeiter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-08 19:06:44 +00:00
|
|
|
return manifest;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gst_mss_manifest_free (GstMssManifest * manifest)
|
|
|
|
{
|
|
|
|
g_return_if_fail (manifest != NULL);
|
2012-11-09 19:47:54 +00:00
|
|
|
|
|
|
|
g_slist_free_full (manifest->streams, g_free);
|
|
|
|
|
|
|
|
xmlFreeDoc (manifest->xml);
|
2012-11-08 19:06:44 +00:00
|
|
|
g_free (manifest);
|
|
|
|
}
|
2012-11-09 19:47:54 +00:00
|
|
|
|
|
|
|
GSList *
|
|
|
|
gst_mss_manifest_get_streams (GstMssManifest * manifest)
|
|
|
|
{
|
|
|
|
return manifest->streams;
|
|
|
|
}
|
|
|
|
|
|
|
|
GstMssManifestStreamType
|
|
|
|
gst_mss_manifest_stream_get_type (GstMssManifestStream * stream)
|
|
|
|
{
|
|
|
|
gchar *prop = (gchar *) xmlGetProp (stream->xmlnode, (xmlChar *) "Type");
|
|
|
|
GstMssManifestStreamType ret = MSS_STREAM_TYPE_UNKNOWN;
|
|
|
|
|
|
|
|
if (strcmp (prop, "video") == 0) {
|
|
|
|
ret = MSS_STREAM_TYPE_VIDEO;
|
|
|
|
} else if (strcmp (prop, "audio") == 0) {
|
|
|
|
ret = MSS_STREAM_TYPE_AUDIO;
|
|
|
|
}
|
|
|
|
xmlFree (prop);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
const gchar *
|
|
|
|
gst_mss_manifest_stream_type_name (GstMssManifestStreamType streamtype)
|
|
|
|
{
|
|
|
|
switch (streamtype) {
|
|
|
|
case MSS_STREAM_TYPE_VIDEO:
|
|
|
|
return "video";
|
|
|
|
case MSS_STREAM_TYPE_AUDIO:
|
|
|
|
return "audio";
|
|
|
|
case MSS_STREAM_TYPE_UNKNOWN:
|
|
|
|
default:
|
|
|
|
return "unknown";
|
|
|
|
}
|
|
|
|
}
|