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-profile.h"
25 * SECTION:gupnp-dlna-profile
26 * @short_description: Object representing a DLNA profile
28 * The #GUPnPDLNADiscoverer object provides a few APIs that return
29 * #GUPnPDLNAProfile objects. These represent a single DLNA profile. Each
30 * #GUPnPDLNAProfile has a name (the name of the DLNA profile), the
31 * corresponding MIME type, and a #GstEncodingProfile which represents the
32 * various audio/video/container restrictions specified for that DLNA profile.
34 G_DEFINE_TYPE (GUPnPDLNAProfile, gupnp_dlna_profile, G_TYPE_OBJECT)
36 #define GET_PRIVATE(o) \
37 (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
38 GUPNP_TYPE_DLNA_PROFILE, \
39 GUPnPDLNAProfilePrivate))
41 typedef struct _GUPnPDLNAProfilePrivate GUPnPDLNAProfilePrivate;
43 struct _GUPnPDLNAProfilePrivate {
46 GstEncodingProfile *enc_profile;
54 PROP_ENCODING_PROFILE,
59 gupnp_dlna_profile_get_property (GObject *object,
64 GUPnPDLNAProfile *self = GUPNP_DLNA_PROFILE (object);
65 GUPnPDLNAProfilePrivate *priv = GET_PRIVATE (self);
67 switch (property_id) {
69 g_value_set_string (value, priv->name);
73 g_value_set_string (value, priv->mime);
76 case PROP_ENCODING_PROFILE:
77 g_value_set_boxed (value, priv->enc_profile);
80 case PROP_DLNA_EXTENDED:
81 g_value_set_boolean (value, priv->extended);
85 G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
93 gupnp_dlna_profile_set_property (GObject *object,
98 GUPnPDLNAProfile *self = GUPNP_DLNA_PROFILE (object);
99 GUPnPDLNAProfilePrivate *priv = GET_PRIVATE (self);
101 switch (property_id) {
104 priv->name = g_value_dup_string (value);
109 priv->mime = g_value_dup_string (value);
112 case PROP_ENCODING_PROFILE:
113 if (priv->enc_profile)
114 gst_encoding_profile_free (priv->enc_profile);
115 priv->enc_profile = g_value_dup_boxed (value);
118 case PROP_DLNA_EXTENDED:
119 priv->extended = g_value_get_boolean (value);
123 G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
130 gupnp_dlna_profile_finalize (GObject *object)
132 GUPnPDLNAProfile *self = GUPNP_DLNA_PROFILE (object);
133 GUPnPDLNAProfilePrivate *priv = GET_PRIVATE (self);
137 if (priv->enc_profile)
138 gst_encoding_profile_free (priv->enc_profile);
140 G_OBJECT_CLASS (gupnp_dlna_profile_parent_class)->finalize (object);
144 gupnp_dlna_profile_class_init (GUPnPDLNAProfileClass *klass)
146 GObjectClass *object_class = G_OBJECT_CLASS (klass);
149 g_type_class_add_private (klass, sizeof (GUPnPDLNAProfilePrivate));
151 object_class->get_property = gupnp_dlna_profile_get_property;
152 object_class->set_property = gupnp_dlna_profile_set_property;
153 object_class->finalize = gupnp_dlna_profile_finalize;
155 pspec = g_param_spec_string ("name",
157 "The name of the DLNA profile ",
159 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
160 g_object_class_install_property (object_class, PROP_DLNA_NAME, pspec);
162 pspec = g_param_spec_string ("mime",
163 "DLNA profile MIME type",
164 "The MIME type of the DLNA profile",
166 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
167 g_object_class_install_property (object_class, PROP_DLNA_MIME, pspec);
169 pspec = g_param_spec_boxed ("encoding-profile",
170 "Encoding profile for the DLNA profile",
171 "GstEncodingProfile object corresponding "
172 "to the DLNA profile",
173 GST_TYPE_ENCODING_PROFILE,
174 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
175 g_object_class_install_property (object_class,
176 PROP_ENCODING_PROFILE,
179 pspec = g_param_spec_boolean ("extended",
180 "Extended mode property",
181 "Indicates that this profile is not "
182 "part of the DLNA specification",
184 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
185 g_object_class_install_property (object_class,
192 gupnp_dlna_profile_init (GUPnPDLNAProfile *self)
194 GUPnPDLNAProfilePrivate *priv = GET_PRIVATE (self);
198 priv->enc_profile = NULL;
199 priv->extended = FALSE;
203 * gupnp_dlna_profile_new:
205 * Creates a new #GUPnPDLNAProfile object.
207 * Returns: A new #GUPnPDLNAProfile object.
210 gupnp_dlna_profile_new (gchar *name,
212 GstEncodingProfile *enc_profile,
215 return g_object_new (GUPNP_TYPE_DLNA_PROFILE,
218 "encoding-profile", enc_profile,
219 "extended", extended,
224 * gupnp_dlna_profile_get_name:
225 * @self: The #GUPnPDLNAProfile object
227 * Returns: the name of the DLNA profile represented by @self
230 gupnp_dlna_profile_get_name (GUPnPDLNAProfile *self)
232 GUPnPDLNAProfilePrivate *priv = GET_PRIVATE (self);
237 * gupnp_dlna_profile_get_mime:
238 * @self: The #GUPnPDLNAProfile object
240 * Returns: the DLNA MIME type of the DLNA profile represented by @self
243 gupnp_dlna_profile_get_mime (GUPnPDLNAProfile *self)
245 GUPnPDLNAProfilePrivate *priv = GET_PRIVATE (self);
250 * gupnp_dlna_profile_get_encoding_profile:
251 * @self: The #GUPnPDLNAProfile object
253 * Returns: a #GstEncodingProfile object that, in a future version, can be used
254 * to transcode a given stream to match the DLNA profile represented
257 const GstEncodingProfile *
258 gupnp_dlna_profile_get_encoding_profile (GUPnPDLNAProfile *self)
260 GUPnPDLNAProfilePrivate *priv = GET_PRIVATE (self);
261 return priv->enc_profile;
265 * gupnp_dlna_profile_get_extended:
266 * @self: The #GUPnPDLNAProfile object
268 * Returns: true if application is using extended mode and false otherwise
271 gupnp_dlna_profile_get_extended (GUPnPDLNAProfile *self)
273 GUPnPDLNAProfilePrivate *priv = GET_PRIVATE (self);
274 return priv->extended;