[gupnp-av] Add support for pv:subtitleFileUri and Type



commit 46d6f94113490fac3b2b72f6d84ee077cdadbedf
Author: Jens Georg <mail jensge org>
Date:   Sat Oct 19 11:15:54 2013 +0200

    Add support for pv:subtitleFileUri and Type
    
    https://bugzilla.gnome.org/show_bug.cgi?id=695990

 doc/gupnp-av-sections.txt                      |    7 +
 libgupnp-av/gupnp-didl-lite-object-private.h   |    3 +-
 libgupnp-av/gupnp-didl-lite-object.c           |   60 +++++++-
 libgupnp-av/gupnp-didl-lite-object.h           |    3 +
 libgupnp-av/gupnp-didl-lite-parser.c           |   18 ++-
 libgupnp-av/gupnp-didl-lite-resource-private.h |    3 +-
 libgupnp-av/gupnp-didl-lite-resource.c         |  211 +++++++++++++++++++++++-
 libgupnp-av/gupnp-didl-lite-resource.h         |   21 +++
 libgupnp-av/gupnp-didl-lite-writer.c           |   20 ++-
 libgupnp-av/gupnp-didl-lite-writer.h           |    1 +
 vala/GUPnPAV-1.0.metadata                      |    4 +
 11 files changed, 336 insertions(+), 15 deletions(-)
---
diff --git a/doc/gupnp-av-sections.txt b/doc/gupnp-av-sections.txt
index 83235de..2d1580e 100644
--- a/doc/gupnp-av-sections.txt
+++ b/doc/gupnp-av-sections.txt
@@ -8,6 +8,7 @@ gupnp_didl_lite_object_get_xml_node
 gupnp_didl_lite_object_get_upnp_namespace
 gupnp_didl_lite_object_get_dc_namespace
 gupnp_didl_lite_object_get_dlna_namespace
+gupnp_didl_lite_object_get_pv_namespace
 gupnp_didl_lite_object_get_properties
 gupnp_didl_lite_object_get_id
 gupnp_didl_lite_object_get_parent_id
@@ -181,6 +182,7 @@ GUPNP_DIDL_LITE_WRITER_GET_CLASS
 GUPNP_DIDL_LITE_WRITER_NAMESPACE_DC
 GUPNP_DIDL_LITE_WRITER_NAMESPACE_UPNP
 GUPNP_DIDL_LITE_WRITER_NAMESPACE_DLNA
+GUPNP_DIDL_LITE_WRITER_NAMESPACE_PV
 <SUBSECTION Private>
 GUPnPDIDLLiteWriterPrivate
 gupnp_didl_lite_writer_get_type
@@ -222,6 +224,7 @@ gupnp_didl_lite_resource_get_color_depth
 gupnp_didl_lite_resource_get_xml_node
 gupnp_didl_lite_resource_get_cleartext_size
 gupnp_didl_lite_resource_get_dlna_namespace
+gupnp_didl_lite_resource_get_pv_namespace
 gupnp_didl_lite_resource_get_update_count
 gupnp_didl_lite_resource_set_update_count
 gupnp_didl_lite_resource_unset_update_count
@@ -230,6 +233,10 @@ gupnp_didl_lite_resource_get_track_total
 gupnp_didl_lite_resource_set_track_total
 gupnp_didl_lite_resource_track_total_is_set
 gupnp_didl_lite_resource_unset_track_total
+gupnp_didl_lite_resource_get_subtitle_file_type
+gupnp_didl_lite_resource_get_subtitle_file_uri
+gupnp_didl_lite_resource_set_subtitle_file_type
+gupnp_didl_lite_resource_set_subtitle_file_uri
 <SUBSECTION Standard>
 GUPNP_TYPE_DIDL_LITE_RESOURCE
 GUPNP_DIDL_LITE_RESOURCE
diff --git a/libgupnp-av/gupnp-didl-lite-object-private.h b/libgupnp-av/gupnp-didl-lite-object-private.h
index 5a01b20..4371ba1 100644
--- a/libgupnp-av/gupnp-didl-lite-object-private.h
+++ b/libgupnp-av/gupnp-didl-lite-object-private.h
@@ -35,7 +35,8 @@ gupnp_didl_lite_object_new_from_xml     (xmlNode     *xml_node,
                                          GUPnPXMLDoc *xml_doc,
                                          xmlNs       *upnp_ns,
                                          xmlNs       *dc_ns,
-                                         xmlNs       *dlna_ns);
+                                         xmlNs       *dlna_ns,
+                                         xmlNs       *pv_ns);
 
 G_GNUC_INTERNAL GUPnPXMLDoc *
 gupnp_didl_lite_object_get_gupnp_xml_doc
diff --git a/libgupnp-av/gupnp-didl-lite-object.c b/libgupnp-av/gupnp-didl-lite-object.c
index 43d78f5..7b0e75f 100644
--- a/libgupnp-av/gupnp-didl-lite-object.c
+++ b/libgupnp-av/gupnp-didl-lite-object.c
@@ -54,6 +54,7 @@ struct _GUPnPDIDLLiteObjectPrivate {
         xmlNs *upnp_ns;
         xmlNs *dc_ns;
         xmlNs *dlna_ns;
+        xmlNs *pv_ns;
 };
 
 static XSDData *didl_lite_xsd;
@@ -65,6 +66,7 @@ enum {
         PROP_UPNP_NAMESPACE,
         PROP_DC_NAMESPACE,
         PROP_DLNA_NAMESPACE,
+        PROP_PV_NAMESPACE,
         PROP_ID,
         PROP_PARENT_ID,
         PROP_RESTRICTED,
@@ -133,6 +135,9 @@ gupnp_didl_lite_object_set_property (GObject      *object,
         case PROP_DLNA_NAMESPACE:
                 didl_object->priv->dlna_ns = g_value_get_pointer (value);
                 break;
+        case PROP_PV_NAMESPACE:
+                didl_object->priv->pv_ns = g_value_get_pointer (value);
+                break;
         case PROP_ID:
                 gupnp_didl_lite_object_set_id (didl_object,
                                                g_value_get_string (value));
@@ -257,6 +262,12 @@ gupnp_didl_lite_object_get_property (GObject    *object,
                          gupnp_didl_lite_object_get_dlna_namespace
                                 (didl_object));
                 break;
+        case PROP_PV_NAMESPACE:
+                g_value_set_pointer
+                        (value,
+                         gupnp_didl_lite_object_get_pv_namespace
+                                (didl_object));
+                break;
         case PROP_ID:
                 g_value_set_string
                         (value,
@@ -483,6 +494,25 @@ gupnp_didl_lite_object_class_init (GUPnPDIDLLiteObjectClass *klass)
                                        G_PARAM_STATIC_BLURB));
 
         /**
+         * GUPnPDIDLLiteObject:pv-namespace:
+         *
+         * Pointer to the PV metadata namespace registered with the XML
+         * document containing this object.
+         *
+         **/
+        g_object_class_install_property
+                (object_class,
+                 PROP_PV_NAMESPACE,
+                 g_param_spec_pointer ("pv-namespace",
+                                       "XML namespace",
+                                       "Pointer to the PV metadata namespace "
+                                       "registered with the XML document "
+                                       "containing this object.",
+                                       G_PARAM_READWRITE |
+                                       G_PARAM_CONSTRUCT_ONLY |
+                                       G_PARAM_STATIC_STRINGS));
+
+        /**
          * GUPnPDIDLLiteObject:id:
          *
          * The ID of this object.
@@ -914,6 +944,7 @@ unset_contributors_by_name (GUPnPDIDLLiteObject *object, const char *name)
  * @upnp_ns: The pointer to 'upnp' namespace in XML document
  * @dc_ns: The pointer to 'dc' namespace in XML document
  * @dlna_ns: The pointer to 'dlna' namespace in XML document
+ * @pv_ns: The pointer to 'pv' namespace in XML document
  *
  * Creates a new #GUPnPDIDLLiteObject for the @xml_node.
  *
@@ -924,7 +955,8 @@ gupnp_didl_lite_object_new_from_xml (xmlNode     *xml_node,
                                      GUPnPXMLDoc *xml_doc,
                                      xmlNs       *upnp_ns,
                                      xmlNs       *dc_ns,
-                                     xmlNs       *dlna_ns)
+                                     xmlNs       *dlna_ns,
+                                     xmlNs       *pv_ns)
 {
         g_return_val_if_fail (xml_node != NULL, NULL);
         g_return_val_if_fail (xml_node->name != NULL, NULL);
@@ -939,6 +971,7 @@ gupnp_didl_lite_object_new_from_xml (xmlNode     *xml_node,
                                      "upnp-namespace", upnp_ns,
                                      "dc-namespace", dc_ns,
                                      "dlna-namespace", dlna_ns,
+                                     "pv-namespace", pv_ns,
                                      NULL);
         else if (g_ascii_strcasecmp ((char *) xml_node->name, "item") == 0)
                 return g_object_new (GUPNP_TYPE_DIDL_LITE_ITEM,
@@ -947,6 +980,7 @@ gupnp_didl_lite_object_new_from_xml (xmlNode     *xml_node,
                                      "upnp-namespace", upnp_ns,
                                      "dc-namespace", dc_ns,
                                      "dlna-namespace", dlna_ns,
+                                     "pv-namespace", pv_ns,
                                      NULL);
         else
                 return NULL;
@@ -1053,6 +1087,24 @@ gupnp_didl_lite_object_get_dlna_namespace (GUPnPDIDLLiteObject *object)
 }
 
 /**
+ * gupnp_didl_lite_object_get_pv_namespace:
+ * @object: The #GUPnPDIDLLiteObject
+ *
+ * Get the pointer to the PV metadata namespace registered with the XML
+ * document containing this object.
+ *
+ * Returns: (transfer none): The pointer to PV namespace in XML document.
+ **/
+xmlNsPtr
+gupnp_didl_lite_object_get_pv_namespace (GUPnPDIDLLiteObject *object)
+{
+        g_return_val_if_fail (GUPNP_IS_DIDL_LITE_OBJECT (object), NULL);
+
+        return object->priv->pv_ns;
+}
+
+
+/**
  * gupnp_didl_lite_object_get_id:
  * @object: #GUPnPDIDLLiteObject
  *
@@ -1514,7 +1566,8 @@ gupnp_didl_lite_object_get_resources (GUPnPDIDLLiteObject *object)
                 resource = gupnp_didl_lite_resource_new_from_xml
                                         (res_node,
                                          object->priv->xml_doc,
-                                         object->priv->dlna_ns);
+                                         object->priv->dlna_ns,
+                                         object->priv->pv_ns);
 
                 ret = g_list_append (ret, resource);
         }
@@ -2136,7 +2189,8 @@ gupnp_didl_lite_object_add_resource (GUPnPDIDLLiteObject *object)
 
         return gupnp_didl_lite_resource_new_from_xml (res_node,
                                                       object->priv->xml_doc,
-                                                      object->priv->dlna_ns);
+                                                      object->priv->dlna_ns,
+                                                      object->priv->pv_ns);
 }
 
 /**
diff --git a/libgupnp-av/gupnp-didl-lite-object.h b/libgupnp-av/gupnp-didl-lite-object.h
index 872f26b..d7937df 100644
--- a/libgupnp-av/gupnp-didl-lite-object.h
+++ b/libgupnp-av/gupnp-didl-lite-object.h
@@ -94,6 +94,9 @@ xmlNsPtr
 gupnp_didl_lite_object_get_dlna_namespace
                                         (GUPnPDIDLLiteObject *object);
 
+xmlNsPtr
+gupnp_didl_lite_object_get_pv_namespace
+                                        (GUPnPDIDLLiteObject *object);
 const char *
 gupnp_didl_lite_object_get_upnp_class   (GUPnPDIDLLiteObject *object);
 
diff --git a/libgupnp-av/gupnp-didl-lite-parser.c b/libgupnp-av/gupnp-didl-lite-parser.c
index bbf5c25..3fbfdf1 100644
--- a/libgupnp-av/gupnp-didl-lite-parser.c
+++ b/libgupnp-av/gupnp-didl-lite-parser.c
@@ -83,6 +83,7 @@ parse_elements (GUPnPDIDLLiteParser *parser,
                 xmlNs               *upnp_ns,
                 xmlNs               *dc_ns,
                 xmlNs               *dlna_ns,
+                xmlNs               *pv_ns,
                 gboolean             recursive,
                 GError             **error);
 
@@ -230,7 +231,8 @@ gupnp_didl_lite_parser_parse_didl_recursive (GUPnPDIDLLiteParser *parser,
         xmlNs       **ns_list;
         xmlNs        *upnp_ns = NULL;
         xmlNs        *dc_ns   = NULL;
-        xmlNs        *dlna_ns   = NULL;
+        xmlNs        *dlna_ns = NULL;
+        xmlNs        *pv_ns   = NULL;
         GUPnPXMLDoc  *xml_doc;
         gboolean      result;
 
@@ -292,6 +294,9 @@ gupnp_didl_lite_parser_parse_didl_recursive (GUPnPDIDLLiteParser *parser,
                         else if (! dlna_ns &&
                                  g_ascii_strcasecmp (prefix, "dlna") == 0)
                                 dlna_ns = ns_list[i];
+                        else if (! pv_ns &&
+                                g_ascii_strcasecmp (prefix, "pv") == 0)
+                                pv_ns = ns_list[i];
                 }
 
                 xmlFree (ns_list);
@@ -316,6 +321,12 @@ gupnp_didl_lite_parser_parse_didl_recursive (GUPnPDIDLLiteParser *parser,
                                     "urn:schemas-dlna-org:metadata-2-0/",
                                     (unsigned char *)
                                     GUPNP_DIDL_LITE_WRITER_NAMESPACE_DLNA);
+        if (! pv_ns)
+                dlna_ns = xmlNewNs (xmlDocGetRootElement (doc),
+                                    (unsigned char *)
+                                    "http://www.pv.com/pvns/";,
+                                    (unsigned char *)
+                                    GUPNP_DIDL_LITE_WRITER_NAMESPACE_PV);
 
         xml_doc = gupnp_xml_doc_new (doc);
 
@@ -325,6 +336,7 @@ gupnp_didl_lite_parser_parse_didl_recursive (GUPnPDIDLLiteParser *parser,
                                  upnp_ns,
                                  dc_ns,
                                  dlna_ns,
+                                 pv_ns,
                                  recursive,
                                  error);
         g_object_unref (xml_doc);
@@ -339,6 +351,7 @@ parse_elements (GUPnPDIDLLiteParser *parser,
                 xmlNs               *upnp_ns,
                 xmlNs               *dc_ns,
                 xmlNs               *dlna_ns,
+                xmlNs               *pv_ns,
                 gboolean             recursive,
                 GError             **error)
 {
@@ -349,7 +362,7 @@ parse_elements (GUPnPDIDLLiteParser *parser,
 
                 object = gupnp_didl_lite_object_new_from_xml (element, xml_doc,
                                                               upnp_ns, dc_ns,
-                                                              dlna_ns);
+                                                              dlna_ns, pv_ns);
 
                 if (object == NULL)
                         continue;
@@ -366,6 +379,7 @@ parse_elements (GUPnPDIDLLiteParser *parser,
                                              upnp_ns,
                                              dc_ns,
                                              dlna_ns,
+                                             pv_ns,
                                              recursive,
                                              error)) {
                                 g_object_unref (object);
diff --git a/libgupnp-av/gupnp-didl-lite-resource-private.h b/libgupnp-av/gupnp-didl-lite-resource-private.h
index afd366a..e787710 100644
--- a/libgupnp-av/gupnp-didl-lite-resource-private.h
+++ b/libgupnp-av/gupnp-didl-lite-resource-private.h
@@ -32,7 +32,8 @@ G_BEGIN_DECLS
 GUPnPDIDLLiteResource *
 gupnp_didl_lite_resource_new_from_xml   (xmlNode     *xml_node,
                                          GUPnPXMLDoc *xml_doc,
-                                         xmlNs       *dlna_ns);
+                                         xmlNs       *dlna_ns,
+                                         xmlNs       *pv_ns);
 
 G_END_DECLS
 
diff --git a/libgupnp-av/gupnp-didl-lite-resource.c b/libgupnp-av/gupnp-didl-lite-resource.c
index 398ed64..143a3d1 100644
--- a/libgupnp-av/gupnp-didl-lite-resource.c
+++ b/libgupnp-av/gupnp-didl-lite-resource.c
@@ -47,6 +47,7 @@ struct _GUPnPDIDLLiteResourcePrivate {
         xmlNode     *xml_node;
         GUPnPXMLDoc *xml_doc;
         xmlNs       *dlna_ns;
+        xmlNs       *pv_ns;
 
         GUPnPProtocolInfo *protocol_info;
 };
@@ -55,10 +56,11 @@ enum {
         PROP_0,
         PROP_XML_NODE,
         PROP_XML_DOC,
+        PROP_DLNA_NAMESPACE,
+        PROP_PV_NAMESPACE,
 
         PROP_URI,
         PROP_IMPORT_URI,
-        PROP_DLNA_NAMESPACE,
         PROP_PROTOCOL_INFO,
 
         PROP_SIZE,
@@ -77,7 +79,10 @@ enum {
         PROP_COLOR_DEPTH,
 
         PROP_UPDATE_COUNT,
-        PROP_TRACK_TOTAL
+        PROP_TRACK_TOTAL,
+
+        PROP_SUBTITLE_FILE_TYPE,
+        PROP_SUBTITLE_FILE_URI
 };
 
 static void
@@ -170,6 +175,9 @@ gupnp_didl_lite_resource_set_property (GObject      *object,
         case PROP_DLNA_NAMESPACE:
                 resource->priv->dlna_ns = g_value_get_pointer (value);
                 break;
+        case PROP_PV_NAMESPACE:
+                resource->priv->pv_ns = g_value_get_pointer (value);
+                break;
         case PROP_CLEAR_TEXT_SIZE:
                 gupnp_didl_lite_resource_set_cleartext_size (resource,
                                                      g_value_get_int64 (value));
@@ -226,6 +234,16 @@ gupnp_didl_lite_resource_set_property (GObject      *object,
                                         (resource,
                                          g_value_get_uint (value));
                 break;
+        case PROP_SUBTITLE_FILE_TYPE:
+                gupnp_didl_lite_resource_set_subtitle_file_type
+                                        (resource,
+                                         g_value_get_string (value));
+                break;
+        case PROP_SUBTITLE_FILE_URI:
+                gupnp_didl_lite_resource_set_subtitle_file_uri
+                                        (resource,
+                                         g_value_get_string (value));
+                break;
         default:
                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
                 break;
@@ -276,6 +294,11 @@ gupnp_didl_lite_resource_get_property (GObject    *object,
                         (value,
                          gupnp_didl_lite_resource_get_dlna_namespace (resource));
                 break;
+        case PROP_PV_NAMESPACE:
+                g_value_set_pointer
+                        (value,
+                         gupnp_didl_lite_resource_get_pv_namespace (resource));
+                break;
         case PROP_CLEAR_TEXT_SIZE:
                 g_value_set_int64
                          (value,
@@ -337,6 +360,18 @@ gupnp_didl_lite_resource_get_property (GObject    *object,
                          (value,
                           gupnp_didl_lite_resource_get_track_total (resource));
                 break;
+        case PROP_SUBTITLE_FILE_TYPE:
+                g_value_set_string
+                         (value,
+                          gupnp_didl_lite_resource_get_subtitle_file_type
+                                                (resource));
+                break;
+        case PROP_SUBTITLE_FILE_URI:
+                g_value_set_string
+                         (value,
+                          gupnp_didl_lite_resource_get_subtitle_file_uri
+                                                (resource));
+                break;
         default:
                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
                 break;
@@ -550,6 +585,24 @@ gupnp_didl_lite_resource_class_init (GUPnPDIDLLiteResourceClass *klass)
                                        G_PARAM_STATIC_BLURB));
 
         /**
+         * GUPnPDIDLLiteResource:pv-namespace:
+         *
+         * Pointer to the PV metadata namespace registered with the
+         * resource object.
+         *
+         **/
+        g_object_class_install_property
+                (object_class,
+                 PROP_PV_NAMESPACE,
+                 g_param_spec_pointer ("pv-namespace",
+                                       "XML namespace",
+                                       "Pointer to the PV metadata namespace "
+                                       "registered with the resource.",
+                                       G_PARAM_READWRITE |
+                                       G_PARAM_CONSTRUCT_ONLY |
+                                       G_PARAM_STATIC_STRINGS));
+
+        /**
          * GUPnPDIDLLiteResource:duration:
          *
          * The duration (in seconds) of this resource.
@@ -757,6 +810,38 @@ gupnp_didl_lite_resource_class_init (GUPnPDIDLLiteResourceClass *klass)
                                            0,
                                            G_PARAM_READWRITE |
                                            G_PARAM_STATIC_STRINGS));
+
+        /**
+         * GUPnPDIDLLiteResource:subtitle-file-type:
+         *
+         * Type of external subtitle file. Usually SRT or SMI.
+         **/
+        g_object_class_install_property
+                        (object_class,
+                         PROP_SUBTITLE_FILE_TYPE,
+                         g_param_spec_string ("subtitle-file-type",
+                                              "Subtitle file type",
+                                              "Type of the external subtitle "
+                                              "file",
+                                              NULL,
+                                              G_PARAM_READWRITE |
+                                              G_PARAM_STATIC_STRINGS));
+
+        /**
+         * GUPnPDIDLLiteResource:subtitle-file-uri:
+         *
+         * Uri to external subtitle file.
+         **/
+        g_object_class_install_property
+                        (object_class,
+                         PROP_SUBTITLE_FILE_TYPE,
+                         g_param_spec_string ("subtitle-file-uri",
+                                              "Subtitle file uri",
+                                              "Uri of the external subtitle "
+                                              "file",
+                                              NULL,
+                                              G_PARAM_READWRITE |
+                                              G_PARAM_STATIC_STRINGS));
 }
 
 /**
@@ -771,7 +856,8 @@ gupnp_didl_lite_resource_class_init (GUPnPDIDLLiteResourceClass *klass)
 GUPnPDIDLLiteResource *
 gupnp_didl_lite_resource_new_from_xml (xmlNode     *xml_node,
                                        GUPnPXMLDoc *xml_doc,
-                                       xmlNs       *dlna_ns)
+                                       xmlNs       *dlna_ns,
+                                       xmlNs       *pv_ns)
 {
         GUPnPDIDLLiteResource *resource;
 
@@ -779,6 +865,7 @@ gupnp_didl_lite_resource_new_from_xml (xmlNode     *xml_node,
                              "xml-node", xml_node,
                              "xml-doc", xml_doc,
                              "dlna-namespace", dlna_ns,
+                             "pv-namespace", pv_ns,
                              NULL);
 
         return resource;
@@ -818,6 +905,24 @@ gupnp_didl_lite_resource_get_dlna_namespace (GUPnPDIDLLiteResource *resource)
 }
 
 /**
+ * gupnp_didl_lite_resource_get_pv_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.
+ **/
+xmlNsPtr
+gupnp_didl_lite_resource_get_pv_namespace (GUPnPDIDLLiteResource *resource)
+{
+        g_return_val_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource), NULL);
+
+        return resource->priv->pv_ns;
+}
+
+
+/**
  * gupnp_didl_lite_resource_get_uri:
  * @resource: A #GUPnPDIDLLiteResource
  *
@@ -1680,7 +1785,7 @@ gupnp_didl_lite_resource_set_update_count (GUPnPDIDLLiteResource *resource,
         g_object_notify (G_OBJECT (resource), "update-count");
 }
 
-/*
+/**
  * gupnp_didl_lite_resource_set_track_total:
  * @resource: A #GUPnPDIDLLiteResource
  * @track_total: The total number of tracks in this resource
@@ -1746,3 +1851,101 @@ gupnp_didl_lite_resource_unset_track_total (GUPnPDIDLLiteResource *resource)
 
         g_object_notify (G_OBJECT (resource), "track-total");
 }
+
+/**
+ * gupnp_didl_lite_resource_get_subtitle_file_uri:
+ * @resource: A #GUPnPDIDLLiteResource
+ *
+ * Returns: The content of the subtitleFileUri property or %NULL when not set.
+ *
+ * Since: 0.12.4
+ **/
+const char *
+gupnp_didl_lite_resource_get_subtitle_file_uri
+                                        (GUPnPDIDLLiteResource *resource)
+{
+        g_return_val_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource), NULL);
+
+        return xml_util_get_attribute_content (resource->priv->xml_node,
+                                               "subtitleFileUri");
+}
+
+/**
+ * gupnp_didl_lite_resource_get_subtitle_file_type:
+ * @resource: A #GUPnPDIDLLiteResource
+ *
+ * Returns: The content of the subtitleFileType property or %NULL
+ *
+ * Since: 0.12.4
+ **/
+const char *
+gupnp_didl_lite_resource_get_subtitle_file_type
+                                        (GUPnPDIDLLiteResource *resource)
+{
+        g_return_val_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource), NULL);
+
+        return xml_util_get_attribute_content (resource->priv->xml_node,
+                                               "subtitleFileType");
+}
+
+/**
+ * gupnp_didl_lite_resource_set_subtitle_file_uri:
+ * @resource: A #GUPnPDIDLLiteResource
+ * @uri: (allow-none):  An URI to an external subtitle file or %NULL to remove.
+ *
+ * Set the URI of an external subtitle file to be used with this resource.
+ * When @uri is %NULL the value is removed.
+ *
+ * Since: 0.12.4
+ **/
+void
+gupnp_didl_lite_resource_set_subtitle_file_uri
+                                        (GUPnPDIDLLiteResource *resource,
+                                         const char            *uri)
+{
+        g_return_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource));
+
+        if (uri == NULL)
+                xmlUnsetNsProp (resource->priv->xml_node,
+                                resource->priv->pv_ns,
+                                (unsigned char *) "subtitleFileUri");
+        else
+                xmlSetNsProp (resource->priv->xml_node,
+                              resource->priv->pv_ns,
+                              (unsigned char *) "subtitleFileUri",
+                              uri);
+
+        g_object_notify (G_OBJECT (resource), "subtitle-file-uri");
+}
+
+/**
+ * gupnp_didl_lite_resource_set_subtitle_file_type:
+ * @resource: A #GUPnPDIDLLiteResource
+ * @type: (allow-none): An URI to an external subtitle file
+ *
+ * Set the type of an external subtitle file, specified via
+ * pv:subtitleFileUri using gupnp_didl_lite_resource_set_subtitle_file_uri().
+ *
+ * When @type is %NULL the value is removed.
+ *
+ * Since: 0.12.4
+ **/
+void
+gupnp_didl_lite_resource_set_subtitle_file_type
+                                        (GUPnPDIDLLiteResource *resource,
+                                         const char            *type)
+{
+        g_return_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource));
+
+        if (type == NULL)
+                xmlUnsetNsProp (resource->priv->xml_node,
+                                resource->priv->pv_ns,
+                                (unsigned char *) "subtitleFileUri");
+        else
+                xmlSetNsProp (resource->priv->xml_node,
+                              resource->priv->pv_ns,
+                              (unsigned char *) "subtitleFileType",
+                              type);
+
+        g_object_notify (G_OBJECT (resource), "subtitle-file-type");
+}
diff --git a/libgupnp-av/gupnp-didl-lite-resource.h b/libgupnp-av/gupnp-didl-lite-resource.h
index 854c031..cec572c 100644
--- a/libgupnp-av/gupnp-didl-lite-resource.h
+++ b/libgupnp-av/gupnp-didl-lite-resource.h
@@ -164,6 +164,16 @@ void
 gupnp_didl_lite_resource_unset_update_count
                                         (GUPnPDIDLLiteResource *resource);
 
+void
+gupnp_didl_lite_resource_set_subtitle_file_uri
+                                        (GUPnPDIDLLiteResource *resource,
+                                         const char            *uri);
+
+void
+gupnp_didl_lite_resource_set_subtitle_file_type
+                                        (GUPnPDIDLLiteResource *resource,
+                                         const char            *type);
+
 xmlNode *
 gupnp_didl_lite_resource_get_xml_node   (GUPnPDIDLLiteResource *resource);
 
@@ -171,6 +181,10 @@ xmlNsPtr
 gupnp_didl_lite_resource_get_dlna_namespace
                                         (GUPnPDIDLLiteResource *resource);
 
+xmlNsPtr
+gupnp_didl_lite_resource_get_pv_namespace
+                                        (GUPnPDIDLLiteResource *resource);
+
 const char *
 gupnp_didl_lite_resource_get_uri        (GUPnPDIDLLiteResource *resource);
 
@@ -238,6 +252,13 @@ gboolean
 gupnp_didl_lite_resource_track_total_is_set
                                         (GUPnPDIDLLiteResource *resource);
 
+const char *
+gupnp_didl_lite_resource_get_subtitle_file_uri
+                                        (GUPnPDIDLLiteResource *resource);
+
+const char *
+gupnp_didl_lite_resource_get_subtitle_file_type
+                                        (GUPnPDIDLLiteResource *resource);
 G_END_DECLS
 
 #endif /* __GUPNP_DIDL_LITE_RESOURCE_H__ */
diff --git a/libgupnp-av/gupnp-didl-lite-writer.c b/libgupnp-av/gupnp-didl-lite-writer.c
index 5b0291f..558eb47 100644
--- a/libgupnp-av/gupnp-didl-lite-writer.c
+++ b/libgupnp-av/gupnp-didl-lite-writer.c
@@ -49,6 +49,7 @@ struct _GUPnPDIDLLiteWriterPrivate {
         xmlNs       *upnp_ns;
         xmlNs       *dc_ns;
         xmlNs       *dlna_ns;
+        xmlNs       *pv_ns;
 
         char        *language;
 
@@ -416,6 +417,11 @@ gupnp_didl_lite_writer_constructed (GObject *object)
                                   "urn:schemas-dlna-org:metadata-1-0/",
                                   (unsigned char *)
                                   GUPNP_DIDL_LITE_WRITER_NAMESPACE_DLNA);
+        priv->pv_ns = xmlNewNs (priv->xml_node,
+                                 (unsigned char *)
+                                 "http://www.pv.com/pvns/";,
+                                 (unsigned char *)
+                                 GUPNP_DIDL_LITE_WRITER_NAMESPACE_PV);
         xmlNewNs (priv->xml_node,
                   (unsigned char *)
                   "urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/",
@@ -520,7 +526,10 @@ gupnp_didl_lite_writer_class_init (GUPnPDIDLLiteWriterClass *klass)
 
 /**
  * gupnp_didl_lite_writer_new:
- * @language: (allow-none):The language the DIDL-Lite fragment is in, or NULL
+ * @language: (allow-none):The language the DIDL-Lite fragment is in, or %NULL
+ *
+ * Note: @language should always be set to %NULL, DLNA does not support the
+ * language parameter.
  *
  * Return value: A new #GUPnPDIDLLiteWriter object.
  **/
@@ -557,7 +566,8 @@ gupnp_didl_lite_writer_add_item (GUPnPDIDLLiteWriter *writer)
                                                       writer->priv->xml_doc,
                                                       writer->priv->upnp_ns,
                                                       writer->priv->dc_ns,
-                                                      writer->priv->dlna_ns);
+                                                      writer->priv->dlna_ns,
+                                                      writer->priv->pv_ns);
         return GUPNP_DIDL_LITE_ITEM (object);
 }
 
@@ -594,7 +604,8 @@ gupnp_didl_lite_writer_add_container_child_item
                                                       writer->priv->xml_doc,
                                                       writer->priv->upnp_ns,
                                                       writer->priv->dc_ns,
-                                                      writer->priv->dlna_ns);
+                                                      writer->priv->dlna_ns,
+                                                      writer->priv->pv_ns);
         return GUPNP_DIDL_LITE_ITEM (object);
 }
 
@@ -623,7 +634,8 @@ gupnp_didl_lite_writer_add_container (GUPnPDIDLLiteWriter *writer)
                                                       writer->priv->xml_doc,
                                                       writer->priv->upnp_ns,
                                                       writer->priv->dc_ns,
-                                                      writer->priv->dlna_ns);
+                                                      writer->priv->dlna_ns,
+                                                      writer->priv->pv_ns);
         return GUPNP_DIDL_LITE_CONTAINER (object);
 }
 
diff --git a/libgupnp-av/gupnp-didl-lite-writer.h b/libgupnp-av/gupnp-didl-lite-writer.h
index 33da37f..0ec82f1 100644
--- a/libgupnp-av/gupnp-didl-lite-writer.h
+++ b/libgupnp-av/gupnp-didl-lite-writer.h
@@ -80,6 +80,7 @@ typedef struct {
 #define GUPNP_DIDL_LITE_WRITER_NAMESPACE_DC   "dc"
 #define GUPNP_DIDL_LITE_WRITER_NAMESPACE_UPNP "upnp"
 #define GUPNP_DIDL_LITE_WRITER_NAMESPACE_DLNA "dlna"
+#define GUPNP_DIDL_LITE_WRITER_NAMESPACE_PV "pv"
 
 GUPnPDIDLLiteWriter *
 gupnp_didl_lite_writer_new              (const char *language);
diff --git a/vala/GUPnPAV-1.0.metadata b/vala/GUPnPAV-1.0.metadata
index 4990b1e..0f6b360 100644
--- a/vala/GUPnPAV-1.0.metadata
+++ b/vala/GUPnPAV-1.0.metadata
@@ -1,6 +1,10 @@
 GUPnPAV cheader_filename="libgupnp-av/gupnp-av.h"
 *.get_*_namespace type="Xml.Ns*"
 *.xml_node type="Xml.Node*"
+*.dlna_namespace type="Xml.Ns*"
+*.pv_namespace type="Xml.Ns*"
+*.dc_namespace type="Xml.Ns*"
+*.upnp_namespace type="Xml.Ns*"
 DIDL_LITE_WRITER_NAMESPACE_* skip
 *.gupnp_reserved skip
 SearchCriteriaParserError skip


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]