041976a4104499478866222c6945b1cbbd5d3225
[profile/ivi/GUPnP-AV.git] / libgupnp-av / gupnp-didl-lite-resource.c
1 /*
2  * Copyright (C) 2009 Nokia Corporation.
3  * Copyright (C) 2007, 2008 OpenedHand Ltd.
4  * Copyright (C) 2012 Intel Corporation
5  *
6  * Authors: Zeeshan Ali (Khattak) <zeeshan.ali@nokia.com>
7  *                                <zeeshanak@gnome.org>
8  *          Jorn Baayen <jorn@openedhand.com>
9  *          Krzesimir Nowak <krnowak@openismus.com>
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Library General Public
13  * License as published by the Free Software Foundation; either
14  * version 2 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  * Library General Public License for more details.
20  *
21  * You should have received a copy of the GNU Library General Public
22  * License along with this library; if not, write to the
23  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24  * Boston, MA 02110-1301, USA.
25  */
26
27 /**
28  * SECTION:gupnp-didl-lite-resource
29  * @short_description: DIDL-Lite Resource
30  *
31  * #GUPnPDIDLLiteResource respresent a DIDL-Lite resource (res) element.
32  */
33
34 #include <string.h>
35
36 #include "gupnp-didl-lite-resource.h"
37 #include "xml-util.h"
38 #include "time-utils.h"
39
40 G_DEFINE_TYPE (GUPnPDIDLLiteResource,
41                gupnp_didl_lite_resource,
42                G_TYPE_OBJECT);
43
44 struct _GUPnPDIDLLiteResourcePrivate {
45         xmlNode     *xml_node;
46         GUPnPXMLDoc *xml_doc;
47
48         GUPnPProtocolInfo *protocol_info;
49 };
50
51 enum {
52         PROP_0,
53         PROP_XML_NODE,
54         PROP_XML_DOC,
55
56         PROP_URI,
57         PROP_IMPORT_URI,
58
59         PROP_PROTOCOL_INFO,
60
61         PROP_SIZE,
62         PROP_SIZE64,
63         PROP_DURATION,
64         PROP_BITRATE,
65         PROP_SAMPLE_FREQ,
66         PROP_BITS_PER_SAMPLE,
67         PROP_PROTECTION,
68
69         PROP_AUDIO_CHANNELS,
70
71         PROP_WIDTH,
72         PROP_HEIGHT,
73         PROP_COLOR_DEPTH,
74
75         PROP_UPDATE_COUNT
76 };
77
78 static void
79 get_resolution_info (GUPnPDIDLLiteResource *resource,
80                      int                   *width,
81                      int                   *height)
82 {
83         const char *resolution;
84         char **tokens;
85
86         resolution = xml_util_get_attribute_content (resource->priv->xml_node,
87                                                      "resolution");
88         if (resolution == NULL)
89                 return;
90
91         tokens = g_strsplit (resolution, "x", -1);
92         if (tokens == NULL || tokens[0] == NULL || tokens[1] == NULL) {
93                 g_warning ("Failed to resolution string '%s'\n", resolution);
94
95                 goto return_point;
96         }
97
98         if (width)
99                 *width = atoi (tokens[0]);
100         if (height)
101                 *height = atoi (tokens[1]);
102
103 return_point:
104         g_strfreev (tokens);
105 }
106
107 static void
108 on_protocol_info_changed (GUPnPProtocolInfo *info,
109                           GParamSpec        *pspec,
110                           gpointer           user_data)
111 {
112         GUPnPDIDLLiteResource *resource = GUPNP_DIDL_LITE_RESOURCE (user_data);
113
114         gupnp_didl_lite_resource_set_protocol_info (resource, info);
115 }
116
117 static void
118 gupnp_didl_lite_resource_init (GUPnPDIDLLiteResource *resource)
119 {
120         resource->priv = G_TYPE_INSTANCE_GET_PRIVATE
121                                         (resource,
122                                          GUPNP_TYPE_DIDL_LITE_RESOURCE,
123                                          GUPnPDIDLLiteResourcePrivate);
124 }
125
126 static void
127 gupnp_didl_lite_resource_set_property (GObject      *object,
128                                        guint         property_id,
129                                        const GValue *value,
130                                        GParamSpec   *pspec)
131 {
132         GUPnPDIDLLiteResource *resource;
133
134         resource = GUPNP_DIDL_LITE_RESOURCE (object);
135
136         switch (property_id) {
137         case PROP_XML_NODE:
138                 resource->priv->xml_node = g_value_get_pointer (value);
139                 break;
140         case PROP_XML_DOC:
141                 resource->priv->xml_doc = g_value_dup_object (value);
142                 break;
143         case PROP_URI:
144                 gupnp_didl_lite_resource_set_uri (resource,
145                                                   g_value_get_string (value));
146                 break;
147         case PROP_IMPORT_URI:
148                 gupnp_didl_lite_resource_set_import_uri
149                                 (resource,
150                                  g_value_get_string (value));
151                 break;
152         case PROP_PROTOCOL_INFO:
153                 gupnp_didl_lite_resource_set_protocol_info
154                                 (resource,
155                                  g_value_get_object (value));
156                 break;
157         case PROP_SIZE:
158                 gupnp_didl_lite_resource_set_size (resource,
159                                                    g_value_get_long (value));
160                 break;
161         case PROP_SIZE64:
162                 gupnp_didl_lite_resource_set_size64 (resource,
163                                                      g_value_get_int64 (value));
164                 break;
165         case PROP_DURATION:
166                 gupnp_didl_lite_resource_set_duration
167                                 (resource,
168                                  g_value_get_long (value));
169                 break;
170         case PROP_BITRATE:
171                 gupnp_didl_lite_resource_set_bitrate (resource,
172                                                       g_value_get_int (value));
173                 break;
174         case PROP_SAMPLE_FREQ:
175                 gupnp_didl_lite_resource_set_sample_freq
176                                 (resource,
177                                  g_value_get_int (value));
178                 break;
179         case PROP_BITS_PER_SAMPLE:
180                 gupnp_didl_lite_resource_set_bits_per_sample
181                                 (resource,
182                                  g_value_get_int (value));
183                 break;
184         case PROP_PROTECTION:
185                 gupnp_didl_lite_resource_set_protection
186                                 (resource,
187                                  g_value_get_string (value));
188                 break;
189         case PROP_AUDIO_CHANNELS:
190                 gupnp_didl_lite_resource_set_audio_channels
191                                 (resource,
192                                  g_value_get_int (value));
193                 break;
194         case PROP_WIDTH:
195                 gupnp_didl_lite_resource_set_width (resource,
196                                                     g_value_get_int (value));
197                 break;
198         case PROP_HEIGHT:
199                 gupnp_didl_lite_resource_set_height (resource,
200                                                      g_value_get_int (value));
201                 break;
202         case PROP_COLOR_DEPTH:
203                 gupnp_didl_lite_resource_set_color_depth
204                                 (resource,
205                                  g_value_get_int (value));
206                 break;
207         case PROP_UPDATE_COUNT:
208                 gupnp_didl_lite_resource_set_update_count
209                                         (resource,
210                                          g_value_get_uint (value));
211                 break;
212         default:
213                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
214                 break;
215         }
216 }
217
218 static void
219 gupnp_didl_lite_resource_get_property (GObject    *object,
220                                        guint       property_id,
221                                        GValue     *value,
222                                        GParamSpec *pspec)
223 {
224         GUPnPDIDLLiteResource *resource;
225
226         resource = GUPNP_DIDL_LITE_RESOURCE (object);
227
228         switch (property_id) {
229         case PROP_XML_NODE:
230                 g_value_set_pointer
231                         (value,
232                          gupnp_didl_lite_resource_get_xml_node (resource));
233                 break;
234         case PROP_URI:
235                 g_value_set_string
236                         (value,
237                          gupnp_didl_lite_resource_get_uri (resource));
238                 break;
239         case PROP_IMPORT_URI:
240                 g_value_set_string
241                         (value,
242                          gupnp_didl_lite_resource_get_import_uri (resource));
243                 break;
244         case PROP_PROTOCOL_INFO:
245                 g_value_set_object
246                         (value,
247                          gupnp_didl_lite_resource_get_protocol_info (resource));
248                 break;
249         case PROP_SIZE:
250                 g_value_set_long (value,
251                                   gupnp_didl_lite_resource_get_size (resource));
252                 break;
253         case PROP_SIZE64:
254                 g_value_set_int64 (value,
255                                    gupnp_didl_lite_resource_get_size64 (resource));
256                 break;
257         case PROP_DURATION:
258                 g_value_set_long
259                         (value,
260                          gupnp_didl_lite_resource_get_duration (resource));
261                 break;
262         case PROP_BITRATE:
263                 g_value_set_int
264                         (value,
265                          gupnp_didl_lite_resource_get_bitrate (resource));
266                 break;
267         case PROP_BITS_PER_SAMPLE:
268                 g_value_set_int
269                         (value,
270                          gupnp_didl_lite_resource_get_bits_per_sample
271                                                                 (resource));
272                 break;
273         case PROP_SAMPLE_FREQ:
274                 g_value_set_int
275                         (value,
276                          gupnp_didl_lite_resource_get_sample_freq (resource));
277                 break;
278         case PROP_PROTECTION:
279                 g_value_set_string
280                         (value,
281                          gupnp_didl_lite_resource_get_protection (resource));
282                 break;
283         case PROP_AUDIO_CHANNELS:
284                 g_value_set_int
285                         (value,
286                          gupnp_didl_lite_resource_get_audio_channels
287                                                                 (resource));
288                 break;
289         case PROP_WIDTH:
290                 g_value_set_int (value,
291                                  gupnp_didl_lite_resource_get_width (resource));
292                 break;
293         case PROP_HEIGHT:
294                 g_value_set_int
295                         (value,
296                          gupnp_didl_lite_resource_get_height (resource));
297                 break;
298         case PROP_COLOR_DEPTH:
299                 g_value_set_int
300                         (value,
301                          gupnp_didl_lite_resource_get_color_depth (resource));
302                 break;
303         case PROP_UPDATE_COUNT:
304                 g_value_set_uint
305                          (value,
306                           gupnp_didl_lite_resource_get_update_count (resource));
307                 break;
308         default:
309                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
310                 break;
311         }
312 }
313
314 static void
315 gupnp_didl_lite_resource_dispose (GObject *object)
316 {
317         GObjectClass                 *object_class;
318         GUPnPDIDLLiteResourcePrivate *priv;
319
320         priv = GUPNP_DIDL_LITE_RESOURCE (object)->priv;
321
322         if (priv->xml_doc) {
323                 g_object_unref (priv->xml_doc);
324                 priv->xml_doc = NULL;
325         }
326
327         if (priv->protocol_info != NULL) {
328                 g_object_unref (priv->protocol_info);
329                 priv->protocol_info = NULL;
330         }
331
332         object_class = G_OBJECT_CLASS (gupnp_didl_lite_resource_parent_class);
333         object_class->dispose (object);
334 }
335
336 static void
337 gupnp_didl_lite_resource_class_init (GUPnPDIDLLiteResourceClass *klass)
338 {
339         GObjectClass *object_class;
340
341         object_class = G_OBJECT_CLASS (klass);
342
343         object_class->set_property = gupnp_didl_lite_resource_set_property;
344         object_class->get_property = gupnp_didl_lite_resource_get_property;
345         object_class->dispose = gupnp_didl_lite_resource_dispose;
346
347         g_type_class_add_private (klass, sizeof (GUPnPDIDLLiteResourcePrivate));
348
349         /**
350          * GUPnPDIDLLiteResource:xml-node:
351          *
352          * The pointer to res node in XML document.
353          **/
354         g_object_class_install_property
355                 (object_class,
356                  PROP_XML_NODE,
357                  g_param_spec_pointer ("xml-node",
358                                        "XMLNode",
359                                        "The pointer to res node in XML"
360                                        " document.",
361                                        G_PARAM_READWRITE |
362                                        G_PARAM_CONSTRUCT_ONLY |
363                                        G_PARAM_STATIC_NAME |
364                                        G_PARAM_STATIC_NICK |
365                                        G_PARAM_STATIC_BLURB));
366
367         /**
368          * GUPnPDIDLLiteResource:xml-doc:
369          *
370          * The reference to XML document containing this object.
371          *
372          * Internal property.
373          *
374          * Stability: Private
375          **/
376         g_object_class_install_property
377                 (object_class,
378                  PROP_XML_DOC,
379                  g_param_spec_object ("xml-doc",
380                                       "XMLDoc",
381                                       "The reference to XML document"
382                                       " containing this object.",
383                                       GUPNP_TYPE_XML_DOC,
384                                       G_PARAM_WRITABLE |
385                                       G_PARAM_CONSTRUCT_ONLY |
386                                       G_PARAM_STATIC_NAME |
387                                       G_PARAM_STATIC_NICK |
388                                       G_PARAM_STATIC_BLURB));
389
390         /**
391          * GUPnPDIDLLiteResource:uri:
392          *
393          * The URI associated with this resource.
394          **/
395         g_object_class_install_property
396                 (object_class,
397                  PROP_URI,
398                  g_param_spec_string ("uri",
399                                       "URI",
400                                       "The URI associated with this resource",
401                                       NULL,
402                                       G_PARAM_READWRITE |
403                                       G_PARAM_STATIC_NAME |
404                                       G_PARAM_STATIC_NICK |
405                                       G_PARAM_STATIC_BLURB));
406
407         /**
408          * GUPnPDIDLLiteResource:import-uri:
409          *
410          * The Import URI associated with this resource.
411          **/
412         g_object_class_install_property
413                 (object_class,
414                  PROP_IMPORT_URI,
415                  g_param_spec_string ("import-uri",
416                                       "ImportURI",
417                                       "The import URI associated with this"
418                                       " resource",
419                                       NULL,
420                                       G_PARAM_READWRITE |
421                                       G_PARAM_STATIC_NAME |
422                                       G_PARAM_STATIC_NICK |
423                                       G_PARAM_STATIC_BLURB));
424
425         /**
426          * GUPnPDIDLLiteResource:protocol-info:
427          *
428          * The protocol info associated with this resource.
429          **/
430         g_object_class_install_property
431                 (object_class,
432                  PROP_PROTOCOL_INFO,
433                  g_param_spec_object ("protocol-info",
434                                       "ProtocolInfo",
435                                       "The protocol info associated with this"
436                                       " resource",
437                                       GUPNP_TYPE_PROTOCOL_INFO,
438                                       G_PARAM_READWRITE |
439                                       G_PARAM_STATIC_NAME |
440                                       G_PARAM_STATIC_NICK |
441                                       G_PARAM_STATIC_BLURB));
442
443         /**
444          * GUPnPDIDLLiteResource:size:
445          *
446          * The size (in bytes) of this resource.
447          **/
448         g_object_class_install_property
449                 (object_class,
450                  PROP_SIZE,
451                  g_param_spec_long ("size",
452                                     "Size",
453                                     "The size (in bytes) of this resource.",
454                                     -1,
455                                     G_MAXLONG,
456                                     -1,
457                                     G_PARAM_READWRITE |
458                                     G_PARAM_STATIC_NAME |
459                                     G_PARAM_STATIC_NICK |
460                                     G_PARAM_STATIC_BLURB));
461
462         /**
463          * GUPnPDIDLLiteResource:size64:
464          *
465          * The size (in bytes) of this resource.
466          **/
467         g_object_class_install_property
468                 (object_class,
469                  PROP_SIZE64,
470                  g_param_spec_int64 ("size64",
471                                      "Size64",
472                                      "The size (in bytes) of this resource.",
473                                      -1,
474                                      G_MAXINT64,
475                                      -1,
476                                      G_PARAM_READWRITE |
477                                      G_PARAM_STATIC_NAME |
478                                      G_PARAM_STATIC_NICK |
479                                      G_PARAM_STATIC_BLURB));
480
481         /**
482          * GUPnPDIDLLiteResource:duration:
483          *
484          * The duration (in seconds) of this resource.
485          **/
486         g_object_class_install_property
487                 (object_class,
488                  PROP_DURATION,
489                  g_param_spec_long ("duration",
490                                     "Duration",
491                                     "The duration (in seconds) of this"
492                                     " resource.",
493                                     -1,
494                                     G_MAXLONG,
495                                     -1,
496                                     G_PARAM_READWRITE |
497                                     G_PARAM_STATIC_NAME |
498                                     G_PARAM_STATIC_NICK |
499                                     G_PARAM_STATIC_BLURB));
500
501         /**
502          * GUPnPDIDLLiteResource:bitrate:
503          *
504          * The bitrate of this resource.
505          **/
506         g_object_class_install_property
507                 (object_class,
508                  PROP_BITRATE,
509                  g_param_spec_int ("bitrate",
510                                    "Bitrate",
511                                    "The bitrate of this resource.",
512                                    -1,
513                                    G_MAXINT,
514                                    -1,
515                                    G_PARAM_READWRITE |
516                                    G_PARAM_STATIC_NAME |
517                                    G_PARAM_STATIC_NICK |
518                                    G_PARAM_STATIC_BLURB));
519
520         /**
521          * GUPnPDIDLLiteResource:sample-freq:
522          *
523          * The sample frequency of this resource.
524          **/
525         g_object_class_install_property
526                 (object_class,
527                  PROP_SAMPLE_FREQ,
528                  g_param_spec_int ("sample-freq",
529                                    "SampleFrequency",
530                                    "The sample frequency of this resource.",
531                                    -1,
532                                    G_MAXINT,
533                                    -1,
534                                    G_PARAM_READWRITE |
535                                    G_PARAM_STATIC_NAME |
536                                    G_PARAM_STATIC_NICK |
537                                    G_PARAM_STATIC_BLURB));
538
539         /**
540          * GUPnPDIDLLiteResource:bits-per-sample:
541          *
542          * The sample size of this resource.
543          **/
544         g_object_class_install_property
545                 (object_class,
546                  PROP_BITS_PER_SAMPLE,
547                  g_param_spec_int ("bits-per-sample",
548                                    "BitsPerSample",
549                                    "The sample size of this resource.",
550                                    -1,
551                                    G_MAXINT,
552                                    -1,
553                                    G_PARAM_READWRITE |
554                                    G_PARAM_STATIC_NAME |
555                                    G_PARAM_STATIC_NICK |
556                                    G_PARAM_STATIC_BLURB));
557
558         /**
559          * GUPnPDIDLLiteResource:protection:
560          *
561          * The protection system used for this resource.
562          **/
563         g_object_class_install_property
564                 (object_class,
565                  PROP_PROTECTION,
566                  g_param_spec_string ("protection",
567                                       "Protection",
568                                       "The protection system used by this"
569                                       " resource.",
570                                       NULL,
571                                       G_PARAM_READWRITE |
572                                       G_PARAM_STATIC_NAME |
573                                       G_PARAM_STATIC_NICK |
574                                       G_PARAM_STATIC_BLURB));
575
576         /**
577          * GUPnPDIDLLiteResource:audio-channels:
578          *
579          * The number of audio channels in this resource.
580          **/
581         g_object_class_install_property
582                 (object_class,
583                  PROP_AUDIO_CHANNELS,
584                  g_param_spec_int ("audio-channels",
585                                    "AudioChannels",
586                                    "The number of audio channels in this"
587                                    " resource.",
588                                    -1,
589                                    G_MAXINT,
590                                    -1,
591                                    G_PARAM_READWRITE |
592                                    G_PARAM_STATIC_NAME |
593                                    G_PARAM_STATIC_NICK |
594                                    G_PARAM_STATIC_BLURB));
595
596         /**
597          * GUPnPDIDLLiteResource:width:
598          *
599          * The width of this image/video resource.
600          **/
601         g_object_class_install_property
602                 (object_class,
603                  PROP_WIDTH,
604                  g_param_spec_int ("width",
605                                    "Width",
606                                    "The width of this image/video resource.",
607                                    -1,
608                                    G_MAXINT,
609                                    -1,
610                                    G_PARAM_READWRITE |
611                                    G_PARAM_STATIC_NAME |
612                                    G_PARAM_STATIC_NICK |
613                                    G_PARAM_STATIC_BLURB));
614
615         /**
616          * GUPnPDIDLLiteResource:height:
617          *
618          * The height of this image/video resource.
619          **/
620         g_object_class_install_property
621                 (object_class,
622                  PROP_HEIGHT,
623                  g_param_spec_int ("height",
624                                    "Height",
625                                    "The height of this image/video resource.",
626                                    -1,
627                                    G_MAXINT,
628                                    -1,
629                                    G_PARAM_READWRITE |
630                                    G_PARAM_STATIC_NAME |
631                                    G_PARAM_STATIC_NICK |
632                                    G_PARAM_STATIC_BLURB));
633
634         /**
635          * GUPnPDIDLLiteResource:color-depth:
636          *
637          * The color-depth of this image/video resource.
638          **/
639         g_object_class_install_property
640                 (object_class,
641                  PROP_COLOR_DEPTH,
642                  g_param_spec_int ("color-depth",
643                                    "ColorDepth",
644                                    "The color-depth of this image/video"
645                                    " resource.",
646                                    -1,
647                                    G_MAXINT,
648                                    -1,
649                                    G_PARAM_READWRITE |
650                                    G_PARAM_STATIC_NAME |
651                                    G_PARAM_STATIC_NICK |
652                                    G_PARAM_STATIC_BLURB));
653
654         /**
655          * GUPnPDIDLLiteResource:update_count:
656          *
657          * The update count of this resource.
658          **/
659         g_object_class_install_property
660                        (object_class,
661                         PROP_UPDATE_COUNT,
662                         g_param_spec_uint ("update-count",
663                                            "UpdateCount",
664                                            "The update count of this resource.",
665                                            0,
666                                            G_MAXUINT,
667                                            0,
668                                            G_PARAM_READWRITE |
669                                            G_PARAM_STATIC_NAME |
670                                            G_PARAM_STATIC_NICK |
671                                            G_PARAM_STATIC_BLURB));
672 }
673
674 /**
675  * gupnp_didl_lite_resource_new_from_xml:
676  * @xml_node: The pointer to 'res' node in XML document
677  * @xml_doc: The reference to XML document containing this resource
678  *
679  * Creates a new #GUPnPDIDLLiteResource for the @xml_node.
680  *
681  * Return value: A new #GUPnPDIDLLiteResource object. Unref after usage.
682  **/
683 GUPnPDIDLLiteResource *
684 gupnp_didl_lite_resource_new_from_xml (xmlNode     *xml_node,
685                                        GUPnPXMLDoc *xml_doc)
686 {
687         GUPnPDIDLLiteResource *resource;
688
689         return g_object_new (GUPNP_TYPE_DIDL_LITE_RESOURCE,
690                              "xml-node", xml_node,
691                              "xml-doc", xml_doc,
692                              NULL);
693
694         return resource;
695 }
696
697 /**
698  * gupnp_didl_lite_resource_get_xml_node:
699  * @resource: The #GUPnPDIDLLiteResource
700  *
701  * Get the pointer to res node in XML document.
702  *
703  * Returns: (transfer none): The pointer to res node in XML document.
704  **/
705 xmlNode *
706 gupnp_didl_lite_resource_get_xml_node (GUPnPDIDLLiteResource *resource)
707 {
708         g_return_val_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource), NULL);
709
710         return resource->priv->xml_node;
711 }
712
713 /**
714  * gupnp_didl_lite_resource_get_uri:
715  * @resource: A #GUPnPDIDLLiteResource
716  *
717  * Get the URI associated with the @resource.
718  *
719  * Return value: The of URI the @resource or %NULL.
720  **/
721 const char *
722 gupnp_didl_lite_resource_get_uri (GUPnPDIDLLiteResource *resource)
723 {
724         g_return_val_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource), NULL);
725
726         if (G_UNLIKELY (resource->priv->xml_node->children == NULL))
727                 return NULL;
728
729         return (const char *) resource->priv->xml_node->children->content;
730 }
731
732 /**
733  * gupnp_didl_lite_resource_get_import_uri:
734  * @resource: A #GUPnPDIDLLiteResource
735  *
736  * Get the import URI associated with the @resource.
737  *
738  * Return value: The import URI or %NULL.
739  **/
740 const char *
741 gupnp_didl_lite_resource_get_import_uri (GUPnPDIDLLiteResource *resource)
742 {
743         g_return_val_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource), NULL);
744
745         return xml_util_get_attribute_content (resource->priv->xml_node,
746                                                "importUri");
747 }
748
749 /**
750  * gupnp_didl_lite_resource_get_protocol_info:
751  * @resource: A #GUPnPDIDLLiteResource
752  *
753  * Get the protocol info associated with the @resource.
754  *
755  * Returns: (transfer none): The protocol info associated with the @resource or %NULL. The
756  * returned object must not be unrefed.
757  **/
758 GUPnPProtocolInfo *
759 gupnp_didl_lite_resource_get_protocol_info (GUPnPDIDLLiteResource *resource)
760 {
761         GUPnPProtocolInfo *info;
762         const char *protocol_info;
763         GError *error;
764
765         g_return_val_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource), NULL);
766
767         if (resource->priv->protocol_info != NULL)
768                 return resource->priv->protocol_info;
769
770         protocol_info = xml_util_get_attribute_content
771                                         (resource->priv->xml_node,
772                                          "protocolInfo");
773         g_return_val_if_fail (protocol_info != NULL, NULL);
774
775         error = NULL;
776         info = gupnp_protocol_info_new_from_string (protocol_info, &error);
777         if (info == NULL) {
778                 g_warning ("Error parsing protocolInfo '%s': %s",
779                            protocol_info,
780                            error->message);
781
782                 g_error_free (error);
783         }
784
785         resource->priv->protocol_info = info;
786
787         return info;
788 }
789
790 /**
791  * gupnp_didl_lite_resource_get_size:
792  * @resource: A #GUPnPDIDLLiteResource
793  *
794  * Get the size (in bytes) of the @resource.
795  *
796  * Return value: The size (in bytes) of the @resource or -1.
797  **/
798 glong
799 gupnp_didl_lite_resource_get_size (GUPnPDIDLLiteResource *resource)
800 {
801     return (glong) gupnp_didl_lite_resource_get_size64 (resource);
802 }
803
804 /**
805  * gupnp_didl_lite_resource_get_size64:
806  * @resource: A #GUPnPDIDLLiteResource
807  *
808  * Get the size (in bytes) of the @resource.
809  *
810  * Return value: The size (in bytes) of the @resource or -1.
811  **/
812 gint64
813 gupnp_didl_lite_resource_get_size64 (GUPnPDIDLLiteResource *resource)
814 {
815         g_return_val_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource), -1);
816
817         return xml_util_get_int64_attribute (resource->priv->xml_node,
818                                              "size",
819                                              -1);
820 }
821
822
823 /**
824  * gupnp_didl_lite_resource_get_duration:
825  * @resource: A #GUPnPDIDLLiteResource
826  *
827  * Get the duration (in seconds) of the @resource.
828  *
829  * Return value: The duration (in seconds) of the @resource or -1.
830  **/
831 glong
832 gupnp_didl_lite_resource_get_duration (GUPnPDIDLLiteResource *resource)
833 {
834         const char *duration_str;
835         long duration;
836
837         g_return_val_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource), -1);
838
839         duration_str = xml_util_get_attribute_content (resource->priv->xml_node,
840                                                        "duration");
841         duration = seconds_from_time (duration_str);
842
843         return duration;
844 }
845
846 /**
847  * gupnp_didl_lite_resource_get_bitrate:
848  * @resource: A #GUPnPDIDLLiteResource
849  *
850  * Get the bitrate (in bytes per second) of the @resource.
851  *
852  * Return value: The bitrate (in bytes per second) of the @resource or -1.
853  **/
854 int
855 gupnp_didl_lite_resource_get_bitrate (GUPnPDIDLLiteResource *resource)
856 {
857         g_return_val_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource), -1);
858
859         return xml_util_get_long_attribute (resource->priv->xml_node,
860                                             "bitrate",
861                                             -1);
862 }
863
864 /**
865  * gupnp_didl_lite_resource_get_sample_freq:
866  * @resource: A #GUPnPDIDLLiteResource
867  *
868  * Get the sample frequency of the @resource.
869  *
870  * Return value: The sample frequency of the @resource or -1.
871  **/
872 int
873 gupnp_didl_lite_resource_get_sample_freq (GUPnPDIDLLiteResource *resource)
874 {
875         g_return_val_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource), -1);
876
877         return xml_util_get_long_attribute (resource->priv->xml_node,
878                                             "sampleFrequency",
879                                             -1);
880 }
881
882 /**
883  * gupnp_didl_lite_resource_get_bits_per_sample:
884  * @resource: A #GUPnPDIDLLiteResource
885  *
886  * Get the sample size of the @resource.
887  *
888  * Return value: The number of bits per sample of the @resource or -1.
889  **/
890 int
891 gupnp_didl_lite_resource_get_bits_per_sample (GUPnPDIDLLiteResource *resource)
892 {
893         g_return_val_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource), -1);
894
895         return xml_util_get_long_attribute (resource->priv->xml_node,
896                                             "bitsPerSample",
897                                             -1);
898 }
899
900 /**
901  * gupnp_didl_lite_resource_get_protection:
902  * @resource: A #GUPnPDIDLLiteResource
903  *
904  * Get the protection system used by the @resource.
905  *
906  * Return value: The protection system in use by the @resource or %NULL.
907  **/
908 const char *
909 gupnp_didl_lite_resource_get_protection (GUPnPDIDLLiteResource *resource)
910 {
911         g_return_val_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource), NULL);
912
913         return xml_util_get_attribute_content (resource->priv->xml_node,
914                                                "protection");
915 }
916
917 /**
918  * gupnp_didl_lite_resource_get_audio_channels:
919  * @resource: A #GUPnPDIDLLiteResource
920  *
921  * Get the number of audio channels in the @resource.
922  *
923  * Return value: The number of audio channels in the @resource or -1.
924  **/
925 int
926 gupnp_didl_lite_resource_get_audio_channels (GUPnPDIDLLiteResource *resource)
927 {
928         g_return_val_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource), -1);
929
930         return xml_util_get_long_attribute (resource->priv->xml_node,
931                                             "nrAudioChannels",
932                                             -1);
933 }
934
935 /**
936  * gupnp_didl_lite_resource_get_width:
937  * @resource: A #GUPnPDIDLLiteResource
938  *
939  * Get the width of this image/video resource.
940  *
941  * Return value: The width of this image/video resource or -1.
942  **/
943 int
944 gupnp_didl_lite_resource_get_width (GUPnPDIDLLiteResource *resource)
945 {
946         int width = -1;
947
948         g_return_val_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource), -1);
949
950         get_resolution_info (resource, &width, NULL);
951
952         return width;
953 }
954
955 /**
956  * gupnp_didl_lite_resource_get_height:
957  * @resource: A #GUPnPDIDLLiteResource
958  *
959  * Get the height of this image/video resource.
960  *
961  * Return value: The height of the @resource or -1.
962  **/
963 int
964 gupnp_didl_lite_resource_get_height (GUPnPDIDLLiteResource *resource)
965 {
966         int height = -1;
967
968         g_return_val_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource), -1);
969
970         get_resolution_info (resource, NULL, &height);
971
972         return height;
973 }
974
975 /**
976  * gupnp_didl_lite_resource_get_color_depth:
977  * @resource: A #GUPnPDIDLLiteResource
978  *
979  * Get the color-depth of this image/video resource.
980  *
981  * Return value: The color depth of the @resource or -1.
982  **/
983 int
984 gupnp_didl_lite_resource_get_color_depth (GUPnPDIDLLiteResource *resource)
985 {
986         g_return_val_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource), -1);
987
988         return xml_util_get_long_attribute (resource->priv->xml_node,
989                                             "colorDepth",
990                                             -1);
991 }
992
993 /**
994  * gupnp_didl_lite_resource_get_update_count:
995  * @resource: A #GUPnPDIDLLiteResource
996  *
997  * Get the update count of this resource.
998  *
999  * Return value: The update count of the @resource.
1000  **/
1001 guint
1002 gupnp_didl_lite_resource_get_update_count (GUPnPDIDLLiteResource *resource)
1003 {
1004         g_return_val_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource), 0);
1005
1006         return xml_util_get_uint_attribute (resource->priv->xml_node,
1007                                             "updateCount",
1008                                             -1);
1009 }
1010
1011 /**
1012  * gupnp_didl_lite_resource_update_count_is_set:
1013  * @resource: A #GUPnPDIDLLiteResource
1014  *
1015  * Check whether the update count property of this resource is set.
1016  *
1017  * Return value: %TRUE if set, otherwise %FALSE.
1018  **/
1019 gboolean
1020 gupnp_didl_lite_resource_update_count_is_set (GUPnPDIDLLiteResource *resource)
1021 {
1022         const char *content;
1023
1024         g_return_val_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource), FALSE);
1025
1026         content = xml_util_get_attribute_content (resource->priv->xml_node,
1027                                                   "updateCount");
1028         return content != NULL;
1029 }
1030
1031 /**
1032  * gupnp_didl_lite_resource_set_uri:
1033  * @resource: A #GUPnPDIDLLiteResource
1034  * @uri: The URI as string
1035  *
1036  * Set the URI associated with the @resource.
1037  *
1038  * Return value: None.
1039  **/
1040 void
1041 gupnp_didl_lite_resource_set_uri (GUPnPDIDLLiteResource *resource,
1042                                   const char            *uri)
1043 {
1044         xmlChar *escaped;
1045
1046         g_return_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource));
1047         g_return_if_fail (uri != NULL);
1048
1049         escaped = xmlEncodeSpecialChars (resource->priv->xml_doc->doc,
1050                                          (const unsigned char *) uri);
1051         xmlNodeSetContent (resource->priv->xml_node, escaped);
1052         xmlFree (escaped);
1053
1054         g_object_notify (G_OBJECT (resource), "uri");
1055 }
1056
1057 /**
1058  * gupnp_didl_lite_resource_set_import_uri:
1059  * @resource: A #GUPnPDIDLLiteResource
1060  * @import_uri: The URI as string
1061  *
1062  * Set the import URI associated with the @resource.
1063  *
1064  * Return value: None.
1065  **/
1066 void
1067 gupnp_didl_lite_resource_set_import_uri (GUPnPDIDLLiteResource *resource,
1068                                          const char            *import_uri)
1069 {
1070         g_return_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource));
1071
1072         xmlSetProp (resource->priv->xml_node,
1073                     (unsigned char *) "importUri",
1074                     (unsigned char *) import_uri);
1075
1076         g_object_notify (G_OBJECT (resource), "import-uri");
1077 }
1078
1079 /**
1080  * gupnp_didl_lite_resource_set_protocol_info:
1081  * @resource: A #GUPnPDIDLLiteResource
1082  * @info: The protocol string
1083  *
1084  * Set the protocol info associated with the @resource.
1085  *
1086  * Return value: None.
1087  **/
1088 void
1089 gupnp_didl_lite_resource_set_protocol_info (GUPnPDIDLLiteResource *resource,
1090                                             GUPnPProtocolInfo     *info)
1091 {
1092         char *str;
1093
1094         g_return_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource));
1095         g_return_if_fail (GUPNP_IS_PROTOCOL_INFO (info));
1096
1097         str = gupnp_protocol_info_to_string (info);
1098         xmlSetProp (resource->priv->xml_node,
1099                     (unsigned char *) "protocolInfo",
1100                     (unsigned char *) str);
1101         g_free (str);
1102
1103         /* Get a ref first in case it's the same object that we already have */
1104         g_object_ref (info);
1105         if (resource->priv->protocol_info != NULL)
1106                 g_object_unref (resource->priv->protocol_info);
1107         resource->priv->protocol_info = info;
1108
1109         /* We need to listen to changes to properties so we update the
1110          * corresponding xml property.
1111          */
1112         g_signal_handlers_disconnect_by_func (info,
1113                                               on_protocol_info_changed,
1114                                               resource);
1115         g_signal_connect (info,
1116                           "notify",
1117                           G_CALLBACK (on_protocol_info_changed),
1118                           resource);
1119
1120         g_object_notify (G_OBJECT (resource), "protocol-info");
1121 }
1122
1123 /**
1124  * gupnp_didl_lite_resource_set_size:
1125  * @resource: A #GUPnPDIDLLiteResource
1126  * @size: The size (in bytes)
1127  *
1128  * Set the size (in bytes) of the @resource. Passing a negative number will
1129  * unset this property.
1130  *
1131  * Return value: None.
1132  **/
1133 void
1134 gupnp_didl_lite_resource_set_size (GUPnPDIDLLiteResource *resource,
1135                                    glong                  size)
1136 {
1137         gupnp_didl_lite_resource_set_size64 (resource, size);
1138 }
1139
1140 /**
1141  * gupnp_didl_lite_resource_set_size64:
1142  * @resource: A #GUPnPDIDLLiteResource
1143  * @size: The size (in bytes)
1144  *
1145  * Set the size (in bytes) of the @resource. Passing a negative number will
1146  * unset this property.
1147  *
1148  * Return value: None.
1149  **/
1150 void
1151 gupnp_didl_lite_resource_set_size64 (GUPnPDIDLLiteResource *resource,
1152                                      gint64                 size)
1153 {
1154         g_return_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource));
1155
1156         if (size < 0)
1157                 xmlUnsetProp (resource->priv->xml_node,
1158                               (unsigned char *) "size");
1159         else {
1160                 char *str;
1161
1162                 str = g_strdup_printf ("%" G_GINT64_FORMAT, size);
1163                 xmlSetProp (resource->priv->xml_node,
1164                             (unsigned char *) "size",
1165                             (unsigned char *) str);
1166                 g_free (str);
1167         }
1168
1169         g_object_notify (G_OBJECT (resource), "size64");
1170         g_object_notify (G_OBJECT (resource), "size");
1171 }
1172
1173
1174 /**
1175  * gupnp_didl_lite_resource_set_duration:
1176  * @resource: A #GUPnPDIDLLiteResource
1177  * @duration: The duration (in seconds)
1178  *
1179  * Set the duration (in seconds) of the @resource. Passing a negative number
1180  * will unset this property.
1181  *
1182  * Return value: None.
1183  **/
1184 void
1185 gupnp_didl_lite_resource_set_duration (GUPnPDIDLLiteResource *resource,
1186                                        glong                  duration)
1187 {
1188         g_return_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource));
1189
1190         if (duration < 0)
1191                 xmlUnsetProp (resource->priv->xml_node,
1192                               (unsigned char *) "duration");
1193         else {
1194                 char *str;
1195
1196                 str = seconds_to_time (duration);
1197                 xmlSetProp (resource->priv->xml_node,
1198                             (unsigned char *) "duration",
1199                             (unsigned char *) str);
1200                 g_free (str);
1201         }
1202
1203         g_object_notify (G_OBJECT (resource), "duration");
1204 }
1205
1206 /**
1207  * gupnp_didl_lite_resource_set_bitrate:
1208  * @resource: A #GUPnPDIDLLiteResource
1209  * @bitrate: The bitrate
1210  *
1211  * Set the bitrate (in bytes per second) of the @resource. Passing a negative
1212  * number will unset this property.
1213  *
1214  * Return value: None.
1215  **/
1216 void
1217 gupnp_didl_lite_resource_set_bitrate (GUPnPDIDLLiteResource *resource,
1218                                       int                    bitrate)
1219 {
1220         g_return_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource));
1221
1222         if (bitrate < 0)
1223                 xmlUnsetProp (resource->priv->xml_node,
1224                               (unsigned char *) "bitrate");
1225         else {
1226                 char *str;
1227
1228                 str = g_strdup_printf ("%d", bitrate);
1229                 xmlSetProp (resource->priv->xml_node,
1230                             (unsigned char *) "bitrate",
1231                             (unsigned char *) str);
1232                 g_free (str);
1233         }
1234
1235         g_object_notify (G_OBJECT (resource), "bitrate");
1236 }
1237
1238 /**
1239  * gupnp_didl_lite_resource_set_sample_freq:
1240  * @resource: A #GUPnPDIDLLiteResource
1241  * @sample_freq: The sample frequency
1242  *
1243  * Set the sample frequency of the @resource. Passing a negative number will
1244  * unset this property.
1245  *
1246  * Return value: None.
1247  **/
1248 void
1249 gupnp_didl_lite_resource_set_sample_freq (GUPnPDIDLLiteResource *resource,
1250                                           int                    sample_freq)
1251 {
1252         g_return_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource));
1253
1254         if (sample_freq < 0)
1255                 xmlUnsetProp (resource->priv->xml_node,
1256                               (unsigned char *) "sampleFrequency");
1257         else {
1258                 char *str;
1259
1260                 str = g_strdup_printf ("%d", sample_freq);
1261                 xmlSetProp (resource->priv->xml_node,
1262                             (unsigned char *) "sampleFrequency",
1263                             (unsigned char *) str);
1264                 g_free (str);
1265         }
1266
1267         g_object_notify (G_OBJECT (resource), "sample-freq");
1268 }
1269
1270 /**
1271  * gupnp_didl_lite_resource_set_bits_per_sample:
1272  * @resource: A #GUPnPDIDLLiteResource
1273  * @sample_size: The number of bits per sample
1274  *
1275  * Set the sample size of the @resource. Passing a negative number will unset
1276  * this property.
1277  *
1278  * Return value: None.
1279  **/
1280 void
1281 gupnp_didl_lite_resource_set_bits_per_sample
1282                                         (GUPnPDIDLLiteResource *resource,
1283                                          int                    sample_size)
1284 {
1285         g_return_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource));
1286
1287         if (sample_size < 0)
1288                 xmlUnsetProp (resource->priv->xml_node,
1289                               (unsigned char *) "bitsPerSample");
1290         else {
1291                 char *str;
1292
1293                 str = g_strdup_printf ("%d", sample_size);
1294                 xmlSetProp (resource->priv->xml_node,
1295                             (unsigned char *) "bitsPerSample",
1296                             (unsigned char *) str);
1297                 g_free (str);
1298         }
1299
1300         g_object_notify (G_OBJECT (resource), "bits-per-sample");
1301 }
1302
1303 /**
1304  * gupnp_didl_lite_resource_set_protection:
1305  * @resource: A #GUPnPDIDLLiteResource
1306  * @protection: The protection system identifier as string
1307  *
1308  * Set the protection system used by the @resource. Passing a negative number
1309  * will unset this property.
1310  *
1311  * Return value: None.
1312  **/
1313 void
1314 gupnp_didl_lite_resource_set_protection (GUPnPDIDLLiteResource *resource,
1315                                          const char            *protection)
1316 {
1317         g_return_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource));
1318
1319         xmlSetProp (resource->priv->xml_node,
1320                     (unsigned char *) "protection",
1321                     (unsigned char *) protection);
1322
1323         g_object_notify (G_OBJECT (resource), "protection");
1324 }
1325
1326 /**
1327  * gupnp_didl_lite_resource_set_audio_channels:
1328  * @resource: A #GUPnPDIDLLiteResource
1329  * @n_channels: The number of channels
1330  *
1331  * Set the number of audio channels in the @resource. Passing a negative number
1332  * will unset this property.
1333  *
1334  * Return value: The number of audio channels in the @resource or -1.
1335  **/
1336 void
1337 gupnp_didl_lite_resource_set_audio_channels (GUPnPDIDLLiteResource *resource,
1338                                              int                    n_channels)
1339 {
1340         g_return_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource));
1341
1342         if (n_channels < 0)
1343                 xmlUnsetProp (resource->priv->xml_node,
1344                               (unsigned char *) "nrAudioChannels");
1345         else {
1346                 char *str;
1347
1348                 str = g_strdup_printf ("%d", n_channels);
1349                 xmlSetProp (resource->priv->xml_node,
1350                             (unsigned char *) "nrAudioChannels",
1351                             (unsigned char *) str);
1352                 g_free (str);
1353         }
1354
1355         g_object_notify (G_OBJECT (resource), "audio-channels");
1356 }
1357
1358 /**
1359  * gupnp_didl_lite_resource_set_width:
1360  * @resource: A #GUPnPDIDLLiteResource
1361  * @width: The width
1362  *
1363  * Set the width of this image/video resource. Setting both width and height to
1364  * a negative number will unset the resolution property.
1365  *
1366  * Return value: None.
1367  **/
1368 void
1369 gupnp_didl_lite_resource_set_width (GUPnPDIDLLiteResource *resource,
1370                                      int                   width)
1371 {
1372         char *resolution;
1373         int height = -1;
1374
1375         g_return_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource));
1376
1377         get_resolution_info (resource, NULL, &height);
1378
1379         if (width < 0 && height < 0)
1380                 xmlUnsetProp (resource->priv->xml_node,
1381                               (unsigned char *) "resolution");
1382         else {
1383                 resolution = g_strdup_printf ("%dx%d", width, height);
1384                 xmlSetProp (resource->priv->xml_node,
1385                             (unsigned char *) "resolution",
1386                             (unsigned char *) resolution);
1387                 g_free (resolution);
1388         }
1389
1390         g_object_notify (G_OBJECT (resource), "width");
1391 }
1392
1393 /**
1394  * gupnp_didl_lite_resource_set_height:
1395  * @resource: A #GUPnPDIDLLiteResource
1396  * @height: The height
1397  *
1398  * Set the height of this image/video resource. Setting both width and height to
1399  * a negative number will unset the resolution property.
1400  *
1401  * Return value: None.
1402  **/
1403 void
1404 gupnp_didl_lite_resource_set_height (GUPnPDIDLLiteResource *resource,
1405                                      int                    height)
1406 {
1407         int width = -1;
1408
1409         g_return_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource));
1410
1411         get_resolution_info (resource, &width, NULL);
1412
1413         if (width < 0 && height < 0)
1414                 xmlUnsetProp (resource->priv->xml_node,
1415                               (unsigned char *) "resolution");
1416         else {
1417                 char *resolution;
1418
1419                 resolution = g_strdup_printf ("%dx%d", width, height);
1420                 xmlSetProp (resource->priv->xml_node,
1421                                 (unsigned char *) "resolution",
1422                                 (unsigned char *) resolution);
1423                 g_free (resolution);
1424         }
1425
1426         g_object_notify (G_OBJECT (resource), "height");
1427 }
1428
1429 /**
1430  * gupnp_didl_lite_resource_set_color_depth:
1431  * @resource: A #GUPnPDIDLLiteResource
1432  * @color_depth: The color-depth
1433  *
1434  * Set the color-depth of this image/video resource. Passing a negative number
1435  * will unset this property.
1436  *
1437  * Return value: None.
1438  **/
1439 void
1440 gupnp_didl_lite_resource_set_color_depth (GUPnPDIDLLiteResource *resource,
1441                                           int                    color_depth)
1442 {
1443         g_return_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource));
1444
1445         if (color_depth < 0)
1446                 xmlUnsetProp (resource->priv->xml_node,
1447                               (unsigned char *) "colorDepth");
1448         else {
1449                 char *str;
1450
1451                 str = g_strdup_printf ("%d", color_depth);
1452                 xmlSetProp (resource->priv->xml_node,
1453                             (unsigned char *) "colorDepth",
1454                             (unsigned char *) str);
1455                 g_free (str);
1456         }
1457
1458         g_object_notify (G_OBJECT (resource), "color-depth");
1459 }
1460
1461 /**
1462  * gupnp_didl_lite_resource_set_update_count:
1463  * @resource: A #GUPnPDIDLLiteResource
1464  * @update_count: The update_count
1465  *
1466  * Set the update count of this resource.
1467  *
1468  * Return value: None.
1469  **/
1470 void
1471 gupnp_didl_lite_resource_set_update_count (GUPnPDIDLLiteResource *resource,
1472                                           guint                  update_count)
1473 {
1474         char *str;
1475
1476         g_return_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource));
1477
1478         str = g_strdup_printf ("%u", update_count);
1479         xmlSetProp (resource->priv->xml_node,
1480                     (unsigned char *) "updateCount",
1481                     (unsigned char *) str);
1482         g_free (str);
1483
1484         g_object_notify (G_OBJECT (resource), "update-count");
1485 }
1486
1487 /**
1488  * gupnp_didl_lite_resource_unset_update_count:
1489  * @resource: A #GUPnPDIDLLiteResource
1490  *
1491  * Unset the update count of this resource.
1492  *
1493  * Return value: None.
1494  **/
1495 void
1496 gupnp_didl_lite_resource_unset_update_count (GUPnPDIDLLiteResource *resource)
1497 {
1498         g_return_if_fail (GUPNP_IS_DIDL_LITE_RESOURCE (resource));
1499
1500         xmlUnsetProp (resource->priv->xml_node,
1501                       (unsigned char *) "updateCount");
1502
1503         g_object_notify (G_OBJECT (resource), "update-count");
1504 }