diff options
author | Jens Georg <mail@jensge.org> | 2021-07-10 09:12:45 +0200 |
---|---|---|
committer | Jens Georg <mail@jensge.org> | 2022-10-19 22:28:03 +0200 |
commit | e9fb08b74971b87d59f50cd8d11e6ce0422f24da (patch) | |
tree | f23fe1597d05a899a860d8b08ff6e0fbfd1599c0 | |
parent | f5ad8e6dc3bececa622424c32122b2096fc8e2b1 (diff) | |
download | gupnp-av-e9fb08b74971b87d59f50cd8d11e6ce0422f24da.tar.gz |
Add upnp:resExt and resExt::clockSync
-rw-r--r-- | libgupnp-av/gupnp-didl-lite-clocksync-resource.c | 169 | ||||
-rw-r--r-- | libgupnp-av/gupnp-didl-lite-clocksync-resource.h | 32 | ||||
-rw-r--r-- | libgupnp-av/gupnp-didl-lite-extended-resource-private.h | 17 | ||||
-rw-r--r-- | libgupnp-av/gupnp-didl-lite-extended-resource.c | 186 | ||||
-rw-r--r-- | libgupnp-av/gupnp-didl-lite-extended-resource.h | 34 | ||||
-rw-r--r-- | libgupnp-av/meson.build | 3 |
6 files changed, 441 insertions, 0 deletions
diff --git a/libgupnp-av/gupnp-didl-lite-clocksync-resource.c b/libgupnp-av/gupnp-didl-lite-clocksync-resource.c new file mode 100644 index 0000000..430f0a9 --- /dev/null +++ b/libgupnp-av/gupnp-didl-lite-clocksync-resource.c @@ -0,0 +1,169 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later + +#include <config.h> + +#include "gupnp-didl-lite-extended-resource-private.h" +#include "gupnp-didl-lite-clocksync-resource.h" +#include "xml-util.h" + +#include <libxml/tree.h> + +struct _GUPnPDIDLLiteClocksyncResource { + GUPnPDIDLLiteExtendedResource parent; +}; + +G_DEFINE_TYPE (GUPnPDIDLLiteClocksyncResource, + gupnp_didl_lite_clocksync_resource, + GUPNP_TYPE_DIDL_LITE_EXTENDED_RESOURCE) + +enum +{ + PROP_0, + PROP_DEVICE_CLOCK_ID, + PROP_SUPPORTED_TIMESTAMPS_ID, + PROP_COUNT +}; + +static GParamSpec *pspecs[PROP_COUNT]; + +static void +gupnp_didl_lite_clocksync_resource_init (GUPnPDIDLLiteClocksyncResource *self) +{ + // Nothing +} + +static void +set_properties (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + GUPnPDIDLLiteClocksyncResource *self = + GUPNP_DIDL_LITE_CLOCKSYNC_RESOURCE (object); + + switch (property_id) { + case PROP_DEVICE_CLOCK_ID: + gupnp_didl_lite_clocksync_resource_set_device_clock_id ( + self, + g_value_get_string (value)); + break; + case PROP_SUPPORTED_TIMESTAMPS_ID: + gupnp_didl_lite_clocksync_resource_set_timestamps_id ( + self, + g_value_get_string (value)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +get_properties (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + GUPnPDIDLLiteClocksyncResource *self = + GUPNP_DIDL_LITE_CLOCKSYNC_RESOURCE (object); + + switch (property_id) { + case PROP_DEVICE_CLOCK_ID: + g_value_set_string ( + value, + gupnp_didl_lite_clocksync_resource_get_device_clock_id ( + self)); + break; + case PROP_SUPPORTED_TIMESTAMPS_ID: + g_value_set_string ( + value, + gupnp_didl_lite_clocksync_resource_get_timestamps_id ( + self)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +gupnp_didl_lite_clocksync_resource_class_init ( + GUPnPDIDLLiteClocksyncResourceClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->set_property = set_properties; + object_class->get_property = get_properties; + + pspecs[PROP_DEVICE_CLOCK_ID] = g_param_spec_string ( + "device-clock-id", + "device clock id", + "The clock Id to use for this resource", + NULL, + G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + + pspecs[PROP_SUPPORTED_TIMESTAMPS_ID] = g_param_spec_string ( + "supported-timestamps-id", + "supported timestamps id", + "The timestamp id from feature list", + NULL, + G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, PROP_COUNT, pspecs); +} + +const char * +gupnp_didl_lite_clocksync_resource_get_device_clock_id ( + GUPnPDIDLLiteClocksyncResource *self) +{ + g_return_val_if_fail (GUPNP_IS_DIDL_LITE_CLOCKSYNC_RESOURCE (self), + NULL); + + GUPnPDIDLLiteExtendedResource *res = + GUPNP_DIDL_LITE_EXTENDED_RESOURCE (self); + xmlNodePtr node = gupnp_didl_lite_extended_resource_get_xml_node (res); + return av_xml_util_get_attribute_content (node, "deviceClockInfoID"); +} + +void +gupnp_didl_lite_clocksync_resource_set_device_clock_id ( + GUPnPDIDLLiteClocksyncResource *self, + const char *id) +{ + g_return_if_fail (GUPNP_IS_DIDL_LITE_CLOCKSYNC_RESOURCE (self)); + GUPnPDIDLLiteExtendedResource *res = + GUPNP_DIDL_LITE_EXTENDED_RESOURCE (self); + xmlNodePtr node = gupnp_didl_lite_extended_resource_get_xml_node (res); + + if (id == NULL) { + xmlUnsetProp (node, BAD_CAST "deviceClockInfoID"); + } else { + xmlSetProp (node, BAD_CAST "deviceClockInfoID", BAD_CAST id); + } +} + +const char * +gupnp_didl_lite_clocksync_resource_get_timestamps_id (GUPnPDIDLLiteClocksyncResource *self) +{ + g_return_val_if_fail (GUPNP_IS_DIDL_LITE_CLOCKSYNC_RESOURCE (self), + NULL); + GUPnPDIDLLiteExtendedResource *res = + GUPNP_DIDL_LITE_EXTENDED_RESOURCE (self); + xmlNodePtr node = gupnp_didl_lite_extended_resource_get_xml_node (res); + return av_xml_util_get_attribute_content (node, "supportedTimestampsID"); +} + +void +gupnp_didl_lite_clocksync_resource_set_timestamps_id (GUPnPDIDLLiteClocksyncResource *self, const char *id) +{ + g_return_if_fail (GUPNP_IS_DIDL_LITE_CLOCKSYNC_RESOURCE (self)); + GUPnPDIDLLiteExtendedResource *res = + GUPNP_DIDL_LITE_EXTENDED_RESOURCE (self); + xmlNodePtr node = gupnp_didl_lite_extended_resource_get_xml_node (res); + + if (id == NULL) { + xmlUnsetProp (node, BAD_CAST "supportedTimestampsID"); + } else { + xmlSetProp (node, BAD_CAST "supportedTimestampsID", BAD_CAST id); + } +} diff --git a/libgupnp-av/gupnp-didl-lite-clocksync-resource.h b/libgupnp-av/gupnp-didl-lite-clocksync-resource.h new file mode 100644 index 0000000..8cb4a7e --- /dev/null +++ b/libgupnp-av/gupnp-didl-lite-clocksync-resource.h @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later +#pragma once + +#include "gupnp-didl-lite-extended-resource.h" + +#include <glib-object.h> +#include <glib.h> + +G_BEGIN_DECLS + +G_DECLARE_FINAL_TYPE (GUPnPDIDLLiteClocksyncResource, + gupnp_didl_lite_clocksync_resource, + GUPNP, + DIDL_LITE_CLOCKSYNC_RESOURCE, + GUPnPDIDLLiteExtendedResource) + +#define GUPNP_TYPE_DIDL_LITE_CLOCKSYNC_RESOURCE \ + (gupnp_didl_lite_clocksync_resource_get_type ()) + +const char * +gupnp_didl_lite_clocksync_resource_get_device_clock_id (GUPnPDIDLLiteClocksyncResource *self); + +void +gupnp_didl_lite_clocksync_resource_set_device_clock_id (GUPnPDIDLLiteClocksyncResource *self, const char *id); + +const char * +gupnp_didl_lite_clocksync_resource_get_timestamps_id (GUPnPDIDLLiteClocksyncResource *self); + +void +gupnp_didl_lite_clocksync_resource_set_timestamps_id (GUPnPDIDLLiteClocksyncResource *self, const char *id); + +G_END_DECLS diff --git a/libgupnp-av/gupnp-didl-lite-extended-resource-private.h b/libgupnp-av/gupnp-didl-lite-extended-resource-private.h new file mode 100644 index 0000000..91d8523 --- /dev/null +++ b/libgupnp-av/gupnp-didl-lite-extended-resource-private.h @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later +#pragma once + +#include "gupnp-didl-lite-extended-resource.h" + +#include <glib-object.h> +#include <glib.h> + +#include <libxml/tree.h> + +G_BEGIN_DECLS + +G_GNUC_INTERNAL xmlNode * +gupnp_didl_lite_extended_resource_get_xml_node ( + GUPnPDIDLLiteExtendedResource *self); + +G_END_DECLS diff --git a/libgupnp-av/gupnp-didl-lite-extended-resource.c b/libgupnp-av/gupnp-didl-lite-extended-resource.c new file mode 100644 index 0000000..d42ed1d --- /dev/null +++ b/libgupnp-av/gupnp-didl-lite-extended-resource.c @@ -0,0 +1,186 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later + +#include <config.h> + +#include "gupnp-didl-lite-extended-resource.h" +#include "gupnp-didl-lite-extended-resource-private.h" +#include "xml-util.h" + +#include <libxml/tree.h> + +typedef struct _GUPnPDIDLLiteExtendedResourcePrivate { + xmlNode *xml_node; + xmlDoc *xml_doc; +} GUPnPDIDLLiteExtendedResourcePrivate; + +G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GUPnPDIDLLiteExtendedResource, + gupnp_didl_lite_extended_resource, + G_TYPE_OBJECT) + +enum +{ + PROP_0, + PROP_XML_NODE, + PROP_XML_DOC, + PROP_ID +}; + +static void +gupnp_didl_lite_extended_resource_init (GUPnPDIDLLiteExtendedResource *self) +{ + // Nothing +} + +static void +gupnp_didl_lite_extended_resource_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + GUPnPDIDLLiteExtendedResource *self = + GUPNP_DIDL_LITE_EXTENDED_RESOURCE (object); + GUPnPDIDLLiteExtendedResourcePrivate *priv; + + priv = gupnp_didl_lite_extended_resource_get_instance_private (self); + + switch (property_id) { + case PROP_XML_NODE: + priv->xml_node = g_value_get_pointer (value); + break; + case PROP_XML_DOC: + priv->xml_doc = g_value_dup_boxed (value); + break; + case PROP_ID: + gupnp_didl_lite_extended_resource_set_id ( + self, + g_value_get_string (value)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +gupnp_didl_lite_extended_resource_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + GUPnPDIDLLiteExtendedResource *self = + GUPNP_DIDL_LITE_EXTENDED_RESOURCE (object); + GUPnPDIDLLiteExtendedResourcePrivate *priv; + + priv = gupnp_didl_lite_extended_resource_get_instance_private (self); + + switch (property_id) { + case PROP_XML_NODE: + g_value_set_pointer (value, priv->xml_node); + break; + case PROP_ID: + g_value_set_string ( + value, + gupnp_didl_lite_extended_resource_get_id (self)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +gupnp_didl_lite_extended_resource_class_init ( + GUPnPDIDLLiteExtendedResourceClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->set_property = + gupnp_didl_lite_extended_resource_set_property; + object_class->get_property = + gupnp_didl_lite_extended_resource_get_property; + + /** + * GUPnPDIDLLiteExtendedResource:xml-node: + * + * The pointer to object node in XML document. + **/ + g_object_class_install_property ( + object_class, + PROP_XML_NODE, + g_param_spec_pointer ("xml-node", + "XMLNode", + "The pointer to object node in XML" + " document.", + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS)); + + /** + * GUPnPDIDLLiteExtendedResource:xml-doc: + * + * The reference to XML document containing this object. + * + * Internal property. + * + * Stability: Private + **/ + g_object_class_install_property ( + object_class, + PROP_XML_DOC, + g_param_spec_boxed ("xml-doc", + "XMLDoc", + "The reference to XML document" + " containing this object.", + av_xml_doc_get_type (), + G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS)); + + /** + * GUPnPDIDLLiteExtendedResource:id: + * + * The ID of this object. + **/ + g_object_class_install_property ( + object_class, + PROP_ID, + g_param_spec_string ("id", + "ID", + "The ID of this object.", + NULL, + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS)); +} + +const char * +gupnp_didl_lite_extended_resource_get_id (GUPnPDIDLLiteExtendedResource *self) +{ + g_return_val_if_fail (GUPNP_IS_DIDL_LITE_EXTENDED_RESOURCE (self), + NULL); + GUPnPDIDLLiteExtendedResourcePrivate *priv; + priv = gupnp_didl_lite_extended_resource_get_instance_private (self); + + return av_xml_util_get_attribute_content (priv->xml_node, "id"); +} + +void +gupnp_didl_lite_extended_resource_set_id (GUPnPDIDLLiteExtendedResource *self, + const char *id) +{ + g_return_if_fail (GUPNP_IS_DIDL_LITE_EXTENDED_RESOURCE (self)); + GUPnPDIDLLiteExtendedResourcePrivate *priv; + priv = gupnp_didl_lite_extended_resource_get_instance_private (self); + + xmlSetProp (priv->xml_node, BAD_CAST "id", BAD_CAST id); + + g_object_notify (G_OBJECT (self), "id"); +} + +xmlNode * +gupnp_didl_lite_extended_resource_get_xml_node ( + GUPnPDIDLLiteExtendedResource *self) +{ + GUPnPDIDLLiteExtendedResourcePrivate *priv; + priv = gupnp_didl_lite_extended_resource_get_instance_private (self); + + return priv->xml_node; +} diff --git a/libgupnp-av/gupnp-didl-lite-extended-resource.h b/libgupnp-av/gupnp-didl-lite-extended-resource.h new file mode 100644 index 0000000..e13524a --- /dev/null +++ b/libgupnp-av/gupnp-didl-lite-extended-resource.h @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later +#pragma once + +#include <glib-object.h> +#include <glib.h> + +G_BEGIN_DECLS + +G_DECLARE_DERIVABLE_TYPE (GUPnPDIDLLiteExtendedResource, + gupnp_didl_lite_extended_resource, + GUPNP, + DIDL_LITE_EXTENDED_RESOURCE, + GObject) + +struct _GUPnPDIDLLiteExtendedResourceClass { + GObjectClass parent_class; + + gpointer padding[12]; +}; + +#define GUPNP_TYPE_DIDL_LITE_EXTENDED_RESOURCE \ + (gupnp_didl_lite_extended_resource_get_type ()) + +const char * +gupnp_didl_lite_extended_resource_get_id ( + GUPnPDIDLLiteExtendedResource *resource); + +void +gupnp_didl_lite_extended_resource_set_id ( + GUPnPDIDLLiteExtendedResource *resource, + const char *id); + +G_END_DECLS + diff --git a/libgupnp-av/meson.build b/libgupnp-av/meson.build index 307cbfe..89cc927 100644 --- a/libgupnp-av/meson.build +++ b/libgupnp-av/meson.build @@ -5,8 +5,10 @@ introspection_sources = [ 'gupnp-cds-last-change-parser.c', 'gupnp-didl-lite-container.c', 'gupnp-didl-lite-contributor.c', + 'gupnp-didl-lite-clocksync-resource.c', 'gupnp-didl-lite-createclass.c', 'gupnp-didl-lite-descriptor.c', + 'gupnp-didl-lite-extended-resource.c', 'gupnp-didl-lite-item.c', 'gupnp-didl-lite-object.c', 'gupnp-didl-lite-parser.c', @@ -65,6 +67,7 @@ public_headers = [ 'gupnp-didl-lite-container.h', 'gupnp-didl-lite-contributor.h', 'gupnp-didl-lite-createclass.h', + 'gupnp-didl-lite-extended-resource.h', 'gupnp-didl-lite-descriptor.h', 'gupnp-didl-lite-item.h', 'gupnp-didl-lite-object.h', |