diff --git a/libgupnp-av/gupnp-didl-lite-object.c b/libgupnp-av/gupnp-didl-lite-object.c
index 35a55fd..43d78f5 100644
--- a/libgupnp-av/gupnp-didl-lite-object.c
+++ b/libgupnp-av/gupnp-didl-lite-object.c
@@ -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);
 }
 
 /**
diff --git a/libgupnp-av/gupnp-didl-lite-resource-private.h b/libgupnp-av/gupnp-didl-lite-resource-private.h
index eff4518..958993e 100644
--- a/libgupnp-av/gupnp-didl-lite-resource-private.h
+++ b/libgupnp-av/gupnp-didl-lite-resource-private.h
@@ -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
 
diff --git a/libgupnp-av/gupnp-didl-lite-resource.c b/libgupnp-av/gupnp-didl-lite-resource.c
index 754548d..5ce9bf7 100644
--- a/libgupnp-av/gupnp-didl-lite-resource.c
+++ b/libgupnp-av/gupnp-didl-lite-resource.c
@@ -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,
@@ -479,6 +500,45 @@ gupnp_didl_lite_resource_class_init (GUPnPDIDLLiteResourceClass *klass)
                                      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:
          *
          * The duration (in seconds) of this resource.
@@ -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;
@@ -711,6 +773,23 @@ gupnp_didl_lite_resource_get_xml_node (GUPnPDIDLLiteResource *resource)
 }
 
 /**
+ * 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:
diff --git a/libgupnp-av/gupnp-didl-lite-resource.h b/libgupnp-av/gupnp-didl-lite-resource.h
index 2c257b7..3d93868 100644
--- a/libgupnp-av/gupnp-didl-lite-resource.h
+++ b/libgupnp-av/gupnp-didl-lite-resource.h
@@ -80,6 +80,7 @@ typedef struct {
         void (* _gupnp_reserved4) (void);
 } GUPnPDIDLLiteResourceClass;
 
+
 void
 gupnp_didl_lite_resource_set_uri        (GUPnPDIDLLiteResource *resource,
                                          const char            *uri);
@@ -102,6 +103,11 @@ 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);
 
diff --git a/libgupnp-av/gupnp-didl-lite-writer.c b/libgupnp-av/gupnp-didl-lite-writer.c
index bd57138..4a46ec2 100644
--- a/libgupnp-av/gupnp-didl-lite-writer.c
+++ b/libgupnp-av/gupnp-didl-lite-writer.c
@@ -51,6 +51,8 @@ struct _GUPnPDIDLLiteWriterPrivate {
         xmlNs       *dlna_ns;
 
         char        *language;
+
+        gboolean    dlna_attr_present;
 };
 
 enum {
@@ -206,6 +208,21 @@ filter_attributes (xmlNode             *node,
 }
 
 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,
              GUPnPDIDLLiteWriter *writer,
@@ -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);
