2 * Copyright (C) 2010 Nokia Corporation.
4 * Authors: Arun Raghavan <arun.raghavan@collabora.co.uk>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
22 #include "gupnp-dlna-information.h"
23 #include <gst/gstminiobject.h>
26 * SECTION:gupnp-dlna-information
27 * @short_description: Object containing metadata information returned by the
28 * #GUPnPDLNADiscoverer API
30 * The GUPnPDLNAInformation object holds metadata information discovered by the
31 * GUPnPDiscoverer API. The DLNA profile name and MIME type have their own
32 * fields, and other metadata is held in a GstDiscovererInfo structure.
33 * All fields are read-only.
36 G_DEFINE_TYPE (GUPnPDLNAInformation, gupnp_dlna_information, G_TYPE_OBJECT)
38 #define GET_PRIVATE(o) \
39 (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
40 GUPNP_TYPE_DLNA_INFORMATION, \
41 GUPnPDLNAInformationPrivate))
43 typedef struct _GUPnPDLNAInformationPrivate GUPnPDLNAInformationPrivate;
45 struct _GUPnPDLNAInformationPrivate {
46 GstDiscovererInfo *info;
59 gupnp_dlna_information_get_property (GObject *object,
64 GUPnPDLNAInformation *self = GUPNP_DLNA_INFORMATION (object);
65 GUPnPDLNAInformationPrivate *priv = GET_PRIVATE (self);
67 switch (property_id) {
69 g_value_set_string (value, priv->name);
74 g_value_set_string (value, priv->mime);
78 case PROP_DISCOVERER_INFO:
79 gst_value_set_mini_object (value,
80 GST_MINI_OBJECT(priv->info));
85 G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
94 gupnp_dlna_information_set_property (GObject *object,
99 GUPnPDLNAInformation *self = GUPNP_DLNA_INFORMATION (object);
100 GUPnPDLNAInformationPrivate *priv = GET_PRIVATE (self);
102 switch (property_id) {
105 priv->name = g_value_dup_string (value);
111 priv->mime = g_value_dup_string (value);
115 case PROP_DISCOVERER_INFO:
117 gst_discoverer_info_unref (priv->info);
118 priv->info = GST_DISCOVERER_INFO
119 (gst_value_dup_mini_object (value));
124 G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
134 gupnp_dlna_information_finalize (GObject *object)
136 GUPnPDLNAInformation *self = GUPNP_DLNA_INFORMATION (object);
137 GUPnPDLNAInformationPrivate *priv = GET_PRIVATE (self);
142 gst_discoverer_info_unref (priv->info);
144 G_OBJECT_CLASS (gupnp_dlna_information_parent_class)->finalize (object);
148 gupnp_dlna_information_class_init (GUPnPDLNAInformationClass *klass)
150 GObjectClass *object_class = G_OBJECT_CLASS (klass);
153 g_type_class_add_private (klass, sizeof (GUPnPDLNAInformationPrivate));
155 object_class->get_property = gupnp_dlna_information_get_property;
156 object_class->set_property = gupnp_dlna_information_set_property;
157 object_class->finalize = gupnp_dlna_information_finalize;
159 pspec = g_param_spec_string ("name",
161 "The name of the DLNA profile "
162 "corresponding to the strream",
165 G_PARAM_CONSTRUCT_ONLY);
166 g_object_class_install_property (object_class, PROP_DLNA_NAME, pspec);
168 pspec = g_param_spec_string ("mime",
169 "DLNA profile MIME type corresponding "
171 "The DLNA MIME type of the stream",
174 G_PARAM_CONSTRUCT_ONLY);
175 g_object_class_install_property (object_class, PROP_DLNA_MIME, pspec);
177 pspec = gst_param_spec_mini_object ("info",
179 "Metadata of the stream in a "
180 "GstDiscovererInfo structure",
181 GST_TYPE_DISCOVERER_INFO,
183 G_PARAM_CONSTRUCT_ONLY);
184 g_object_class_install_property (object_class,
185 PROP_DISCOVERER_INFO,
190 gupnp_dlna_information_init (GUPnPDLNAInformation *self)
192 GUPnPDLNAInformationPrivate *priv = GET_PRIVATE (self);
200 * gupnp_dlna_information_new:
201 * @name: DLNA media profile name corresponding to the media
202 * @mime: DLNA MIME type for the media
203 * @info: #GstDiscovererInfo type with additional metadata about the
206 * Creates a new #GUPnPDLNAInformation object with the given properties.
208 * Returns: A newly created #GUPnPDLNAInformation object.
210 GUPnPDLNAInformation*
211 gupnp_dlna_information_new (gchar *name,
213 GstDiscovererInfo *info)
215 return g_object_new (GUPNP_TYPE_DLNA_INFORMATION,
223 * gupnp_dlna_information_get_name:
224 * @self: The #GUPnPDLNAInformation object
226 * Returns: the DLNA profile name of the stream represented by @self. Do not
230 gupnp_dlna_information_get_name (GUPnPDLNAInformation *self)
232 GUPnPDLNAInformationPrivate *priv = GET_PRIVATE (self);
238 * gupnp_dlna_information_get_mime:
239 * @self: The #GUPnPDLNAInformation object
241 * Returns: the DLNA MIME type of the stream represented by @self. Do not
245 gupnp_dlna_information_get_mime (GUPnPDLNAInformation *self)
247 GUPnPDLNAInformationPrivate *priv = GET_PRIVATE (self);
253 * gupnp_dlna_information_get_info:
254 * @self: The #GUPnPDLNAInformation object
256 * Returns: additional stream metadata for @self in the form of a
257 * #GstDiscovererInfo structure. Do not free this structure.
259 const GstDiscovererInfo *
260 gupnp_dlna_information_get_info (GUPnPDLNAInformation *self)
262 GUPnPDLNAInformationPrivate *priv = GET_PRIVATE (self);