Commit d3029a47 authored by Craig Pratt's avatar Craig Pratt

Merged in cbl_master/odid (pull request #1)

Bug fixes found while developing on the Rygel cbl_master/odid branch need to be put into plugfest36
parents db1bc88f f0b48e4e
......@@ -1513,7 +1513,8 @@ gupnp_didl_lite_object_get_resources (GUPnPDIDLLiteObject *object)
/* Create a resource struct out of DIDLLite XML */
resource = gupnp_didl_lite_resource_new_from_xml
(res_node,
object->priv->xml_doc);
object->priv->xml_doc,
object->priv->dlna_ns);
ret = g_list_append (ret, resource);
}
......@@ -2134,7 +2135,8 @@ gupnp_didl_lite_object_add_resource (GUPnPDIDLLiteObject *object)
NULL);
return gupnp_didl_lite_resource_new_from_xml (res_node,
object->priv->xml_doc);
object->priv->xml_doc,
object->priv->dlna_ns);
}
/**
......
......@@ -27,11 +27,13 @@
#include <glib-object.h>
#include <libxml/tree.h>
#include "gupnp-didl-lite-resource.h"
G_BEGIN_DECLS
GUPnPDIDLLiteResource *
gupnp_didl_lite_resource_new_from_xml (xmlNode *xml_node,
GUPnPXMLDoc *xml_doc);
GUPnPXMLDoc *xml_doc,
xmlNs *dlna_ns);
G_END_DECLS
......
......@@ -34,8 +34,10 @@
#include <string.h>
#include "gupnp-didl-lite-resource.h"
#include "gupnp-didl-lite-resource-private.h"
#include "xml-util.h"
#include "time-utils.h"
#include "xsd-data.h"
G_DEFINE_TYPE (GUPnPDIDLLiteResource,
gupnp_didl_lite_resource,
......@@ -44,7 +46,8 @@ G_DEFINE_TYPE (GUPnPDIDLLiteResource,
struct _GUPnPDIDLLiteResourcePrivate {
xmlNode *xml_node;
GUPnPXMLDoc *xml_doc;
xmlNs *dlna_ns;
GUPnPProtocolInfo *protocol_info;
};
......@@ -55,11 +58,12 @@ enum {
PROP_URI,
PROP_IMPORT_URI,
PROP_DLNA_NAMESPACE,
PROP_PROTOCOL_INFO,
PROP_SIZE,
PROP_SIZE64,
PROP_CLEAR_TEXT_SIZE,
PROP_DURATION,
PROP_BITRATE,
PROP_SAMPLE_FREQ,
......@@ -162,6 +166,13 @@ gupnp_didl_lite_resource_set_property (GObject *object,
gupnp_didl_lite_resource_set_size64 (resource,
g_value_get_int64 (value));
break;
case PROP_DLNA_NAMESPACE:
resource->priv->dlna_ns = g_value_get_pointer (value);
break;
case PROP_CLEAR_TEXT_SIZE:
gupnp_didl_lite_resource_set_clear_text_size (resource,
g_value_get_int64 (value));
break;
case PROP_DURATION:
gupnp_didl_lite_resource_set_duration
(resource,
......@@ -254,6 +265,16 @@ gupnp_didl_lite_resource_get_property (GObject *object,
g_value_set_int64 (value,
gupnp_didl_lite_resource_get_size64 (resource));
break;
case PROP_DLNA_NAMESPACE:
g_value_set_pointer
(value,
gupnp_didl_lite_resource_get_dlna_namespace (resource));
break;
case PROP_CLEAR_TEXT_SIZE:
g_value_set_int64
(value,
gupnp_didl_lite_resource_get_clear_text_size (resource));
break;
case PROP_DURATION:
g_value_set_long
(value,
......@@ -478,6 +499,45 @@ gupnp_didl_lite_resource_class_init (GUPnPDIDLLiteResourceClass *klass)
G_PARAM_STATIC_NICK |
G_PARAM_STATIC_BLURB));
/**
* GUPnPDIDLLiteResource:clearTextsize:
*
* The size (in bytes) of this resource.
**/
g_object_class_install_property
(object_class,
PROP_CLEAR_TEXT_SIZE,
g_param_spec_int64 ("cleartextSize",
"ClearTextSize",
"The clear text size (in bytes) of this resource.",
-1,
G_MAXLONG,
-1,
G_PARAM_READWRITE |
G_PARAM_STATIC_NAME |
G_PARAM_STATIC_NICK |
G_PARAM_STATIC_BLURB));
/**
* GUPnPDIDLLiteResource:dlna-namespace:
*
* Pointer to the DLNA metadata namespace registered with the
* resource object.
*
**/
g_object_class_install_property
(object_class,
PROP_DLNA_NAMESPACE,
g_param_spec_pointer ("dlna-namespace",
"XML namespace",
"Pointer to the DLNA metadata namespace "
"registered with the resource.",
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_NAME |
G_PARAM_STATIC_NICK |
G_PARAM_STATIC_BLURB));
/**
* GUPnPDIDLLiteResource:duration:
*
......@@ -682,13 +742,15 @@ gupnp_didl_lite_resource_class_init (GUPnPDIDLLiteResourceClass *klass)
**/
GUPnPDIDLLiteResource *
gupnp_didl_lite_resource_new_from_xml (xmlNode *xml_node,
GUPnPXMLDoc *xml_doc)
GUPnPXMLDoc *xml_doc,
xmlNs *dlna_ns)
{
GUPnPDIDLLiteResource *resource;
return g_object_new (GUPNP_TYPE_DIDL_LITE_RESOURCE,
"xml-node", xml_node,
"xml-doc", xml_doc,
"dlna-namespace", dlna_ns,
NULL);
return resource;
......@@ -710,6 +772,23 @@ gupnp_didl_lite_resource_get_xml_node (GUPnPDIDLLiteResource *resource)
return resource->priv->xml_node;
}
/**
* gupnp_didl_lite_resource_get_dlna_namespace:
* @resource: The #GUPnPDIDLLiteObject
*
* Get the pointer to the DLNA metadata namespace registered with the XML
* document containing this object.
*
* Returns: (transfer none): The pointer to DLNA namespace in XML document.
**/
xmlNs *
gupnp_didl_lite_resource_get_dlna_namespace (GUPnPDIDLLiteResource *resource)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource), NULL);
return resource->priv->dlna_ns;
}
/**
* gupnp_didl_lite_resource_get_uri:
* @resource: A #GUPnPDIDLLiteResource
......@@ -819,6 +898,23 @@ gupnp_didl_lite_resource_get_size64 (GUPnPDIDLLiteResource *resource)
-1);
}
/**
* gupnp_didl_lite_resource_get_clear_text_size:
* @resource: A #GUPnPDIDLLiteResource
*
* Get the size (in bytes) of the @resource.
*
* Return value: The size (in bytes) of the @resource or -1.
**/
gint64
gupnp_didl_lite_resource_get_clear_text_size (GUPnPDIDLLiteResource *resource)
{
g_return_val_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource), -1);
return xml_util_get_int64_attribute (resource->priv->xml_node,
"cleartextSize",
-1);
}
/**
* gupnp_didl_lite_resource_get_duration:
......@@ -1170,6 +1266,38 @@ gupnp_didl_lite_resource_set_size64 (GUPnPDIDLLiteResource *resource,
g_object_notify (G_OBJECT (resource), "size");
}
/**
* gupnp_didl_lite_resource_set_clear_text_size:
* @resource: A #GUPnPDIDLLiteResource
* @clear_text_size: The size (in bytes)
*
* Set the size (in bytes) of the @resource. Passing a negative number will
* unset this property.
*
* Return value: None.
**/
void
gupnp_didl_lite_resource_set_clear_text_size (GUPnPDIDLLiteResource *resource,
gint64 clear_text_size)
{
g_return_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource));
if (clear_text_size < 0)
xmlUnsetNsProp (resource->priv->xml_node,
resource->priv->dlna_ns,
(unsigned char *) "cleartextSize");
else {
char *str;
str = g_strdup_printf ("%" G_GINT64_FORMAT, clear_text_size);
xmlSetNsProp (resource->priv->xml_node,
resource->priv->dlna_ns,
(unsigned char *) "cleartextSize",
(unsigned char *) str);
g_free (str);
}
g_object_notify (G_OBJECT (resource), "cleartextSize");
}
/**
* gupnp_didl_lite_resource_set_duration:
......
......@@ -80,6 +80,7 @@ typedef struct {
void (* _gupnp_reserved4) (void);
} GUPnPDIDLLiteResourceClass;
void
gupnp_didl_lite_resource_set_uri (GUPnPDIDLLiteResource *resource,
const char *uri);
......@@ -101,6 +102,11 @@ void
gupnp_didl_lite_resource_set_size64 (GUPnPDIDLLiteResource *resource,
gint64 size);
void
gupnp_didl_lite_resource_set_clear_text_size
(GUPnPDIDLLiteResource *resource,
gint64 clear_text_size);
void
gupnp_didl_lite_resource_set_duration (GUPnPDIDLLiteResource *resource,
glong duration);
......@@ -153,6 +159,10 @@ gupnp_didl_lite_resource_unset_update_count
xmlNode *
gupnp_didl_lite_resource_get_xml_node (GUPnPDIDLLiteResource *resource);
xmlNs *
gupnp_didl_lite_resource_get_dlna_namespace
(GUPnPDIDLLiteResource *resource);
const char *
gupnp_didl_lite_resource_get_uri (GUPnPDIDLLiteResource *resource);
......@@ -169,6 +179,10 @@ gupnp_didl_lite_resource_get_size (GUPnPDIDLLiteResource *resource);
gint64
gupnp_didl_lite_resource_get_size64 (GUPnPDIDLLiteResource *resource);
gint64
gupnp_didl_lite_resource_get_clear_text_size
(GUPnPDIDLLiteResource *resource);
long
gupnp_didl_lite_resource_get_duration (GUPnPDIDLLiteResource *resource);
......
......@@ -51,6 +51,8 @@ struct _GUPnPDIDLLiteWriterPrivate {
xmlNs *dlna_ns;
char *language;
gboolean dlna_attr_present;
};
enum {
......@@ -205,6 +207,21 @@ filter_attributes (xmlNode *node,
g_list_free (forbidden);
}
static void
check_dlna_attr (xmlNode *node,
GUPnPDIDLLiteWriter *writer)
{
xmlAttr *attr;
/* check if dlna prefix is present for a node */
for (attr = node->properties; attr != NULL; attr = attr->next) {
if (attr->ns && g_strcmp0 (attr->ns->prefix, "dlna") == 0) {
g_debug ("dlna prefix present for %s ",attr->name);
writer->priv->dlna_attr_present = TRUE;
}
}
}
static void
filter_node (xmlNode *node,
GList *allowed,
......@@ -220,6 +237,10 @@ filter_node (xmlNode *node,
if (!tags_only)
filter_attributes (node, allowed);
// Check if dlna namespace attribute is present
if (!writer->priv->dlna_attr_present)
check_dlna_attr (node, writer);
if (strcmp ((const char *) node->name, "container") == 0) {
is_container = TRUE;
container_class = xml_util_get_child_element_content (node,
......@@ -278,8 +299,12 @@ apply_filter (GUPnPDIDLLiteWriter *writer,
g_return_if_fail (GUPNP_IS_DIDL_LITE_WRITER (writer));
g_return_if_fail (filter != NULL);
if (filter[0] == '*')
return; /* Wildcard */
if (filter[0] == '*') {
xmlNewNs (writer->priv->xml_node,
writer->priv->dlna_ns->href,
writer->priv->dlna_ns->prefix);
return; /* Wildcard */
}
tokens = g_strsplit (filter, ",", -1);
g_return_if_fail (tokens != NULL);
......@@ -292,6 +317,12 @@ apply_filter (GUPnPDIDLLiteWriter *writer,
node = node->next)
filter_node (node, allowed, writer, tags_only);
if (writer->priv->dlna_attr_present) {
xmlNewNs (writer->priv->xml_node,
writer->priv->dlna_ns->href,
writer->priv->dlna_ns->prefix);
}
g_list_free (allowed);
g_strfreev (tokens);
}
......@@ -378,7 +409,10 @@ gupnp_didl_lite_writer_constructed (GObject *object)
"urn:schemas-upnp-org:metadata-1-0/upnp/",
(unsigned char *)
GUPNP_DIDL_LITE_WRITER_NAMESPACE_UPNP);
priv->dlna_ns = xmlNewNs (priv->xml_node,
// Not adding dlna namespace declaration to any node yet.
// Add the namespace to Didl-Lite element only if any of the child
// nodes have dlna namespace prefix attributes
priv->dlna_ns = xmlNewNs (NULL,
(unsigned char *)
"urn:schemas-dlna-org:metadata-1-0/",
(unsigned char *)
......@@ -393,6 +427,8 @@ gupnp_didl_lite_writer_constructed (GObject *object)
(unsigned char *) "lang",
(unsigned char *) priv->language);
priv->dlna_attr_present = FALSE;
object_class = G_OBJECT_CLASS (gupnp_didl_lite_writer_parent_class);
if (object_class->constructed != NULL)
object_class->constructed (object);
......
......@@ -119,6 +119,15 @@ gupnp_dlna_flags_get_type (void)
{ GUPNP_DLNA_FLAGS_DLNA_V15,
"GUPNP_DLNA_FLAGS_DLNA_V15",
"dlna-v15" },
{ GUPNP_DLNA_FLAGS_LINK_PROTECTED_CONTENT,
"GUPNP_DLNA_FLAGS_LINK_PROTECTED_CONTENT",
"link-protected-content" },
{ GUPNP_DLNA_FLAGS_CLEAR_TEXT_BYTE_SEEK_FULL,
"GUPNP_DLNA_FLAGS_CLEAR_TEXT_BYTE_SEEK_FULL",
"cleartext-byteseek-full" },
{ GUPNP_DLNA_FLAGS_LOP_CLEAR_TEXT_BYTE_SEEK,
"GUPNP_DLNA_FLAGS_LOP_CLEAR_TEXT_BYTE_SEEK",
"lop-cleartext-byteseek" },
{ 0, NULL, NULL }
};
......
......@@ -88,11 +88,18 @@ gupnp_dlna_flags_get_type (void) G_GNUC_CONST;
* supported
* @GUPNP_DLNA_FLAGS_CONNECTION_STALL: No content transfer when paused.
* @GUPNP_DLNA_FLAGS_DLNA_V15: DLNAv1.5 version flag
* @GUPNP_DLNA_FLAGS_LINK_PROTECTED_CONTENT: The content is protected.
* @GUPNP_DLNA_FLAGS_CLEAR_TEXT_BYTE_SEEK_FULL: Full byte seek on cleartext
* domain is supported.
* @GUPNP_DLNA_FLAGS_LOP_CLEAR_TEXT_BYTE_SEEK: Limited operations on
* byte seek in cleartext domain.
*
* The miscellaneous operations supported by a resource. For details on these
* flags please refer to section 7.3.37.2 of DLNA Networked Device
* Interoperability Guidelines Volume 1, October 2006.
*
* Updated DTCP Flags based on 2011 Guidelines, section 7.4.1.3.23.2
*
**/
typedef enum {
GUPNP_DLNA_FLAGS_NONE = 0,
......@@ -107,7 +114,10 @@ typedef enum {
GUPNP_DLNA_FLAGS_INTERACTIVE_TRANSFER_MODE = (1 << 23),
GUPNP_DLNA_FLAGS_BACKGROUND_TRANSFER_MODE = (1 << 22),
GUPNP_DLNA_FLAGS_CONNECTION_STALL = (1 << 21),
GUPNP_DLNA_FLAGS_DLNA_V15 = (1 << 20)
GUPNP_DLNA_FLAGS_DLNA_V15 = (1 << 20),
GUPNP_DLNA_FLAGS_LINK_PROTECTED_CONTENT = (1 << 16),
GUPNP_DLNA_FLAGS_CLEAR_TEXT_BYTE_SEEK_FULL = (1 << 15),
GUPNP_DLNA_FLAGS_LOP_CLEAR_TEXT_BYTE_SEEK = (1 << 14)
} GUPnPDLNAFlags;
/**
......
......@@ -259,7 +259,7 @@ add_dlna_info (GString *str,
if (speeds != NULL) {
int i;
g_string_append_printf (str, "DLNA.ORG_PS=;");
g_string_append (str, "DLNA.ORG_PS=");
for (i = 0; speeds[i]; i++) {
g_string_append (str, speeds[i]);
......@@ -267,6 +267,7 @@ add_dlna_info (GString *str,
if (speeds[i + 1])
g_string_append_c (str, ',');
}
g_string_append_c (str, ';');
}
conversion = gupnp_protocol_info_get_dlna_conversion (info);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment