|
Packit |
712bc5 |
/*
|
|
Packit |
712bc5 |
* Copyright (C) 2009 Nokia Corporation.
|
|
Packit |
712bc5 |
* Copyright (C) 2007, 2008 OpenedHand Ltd.
|
|
Packit |
712bc5 |
*
|
|
Packit |
712bc5 |
* Authors: Zeeshan Ali (Khattak) <zeeshan.ali@nokia.com>
|
|
Packit |
712bc5 |
* <zeeshanak@gnome.org>
|
|
Packit |
712bc5 |
* Jorn Baayen <jorn@openedhand.com>
|
|
Packit |
712bc5 |
*
|
|
Packit |
712bc5 |
* This library is free software; you can redistribute it and/or
|
|
Packit |
712bc5 |
* modify it under the terms of the GNU Library General Public
|
|
Packit |
712bc5 |
* License as published by the Free Software Foundation; either
|
|
Packit |
712bc5 |
* version 2 of the License, or (at your option) any later version.
|
|
Packit |
712bc5 |
*
|
|
Packit |
712bc5 |
* This library is distributed in the hope that it will be useful,
|
|
Packit |
712bc5 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
712bc5 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
712bc5 |
* Library General Public License for more details.
|
|
Packit |
712bc5 |
*
|
|
Packit |
712bc5 |
* You should have received a copy of the GNU Library General Public
|
|
Packit |
712bc5 |
* License along with this library; if not, write to the
|
|
Packit |
712bc5 |
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
Packit |
712bc5 |
* Boston, MA 02110-1301, USA.
|
|
Packit |
712bc5 |
*/
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
/**
|
|
Packit |
712bc5 |
* SECTION:gupnp-protocol-info
|
|
Packit |
712bc5 |
* @short_description: UPnP AV ProtocolInfo
|
|
Packit |
712bc5 |
*
|
|
Packit |
712bc5 |
* #GUPnPProtocolInfo provides a convenient API to deal with ProtocolInfo
|
|
Packit |
712bc5 |
* strings used in UPnP AV specifications.
|
|
Packit |
712bc5 |
*/
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
#include <string.h>
|
|
Packit |
712bc5 |
#include <stdlib.h>
|
|
Packit |
712bc5 |
#include "gupnp-protocol-info.h"
|
|
Packit |
712bc5 |
#include "gupnp-av-error.h"
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
G_DEFINE_TYPE (GUPnPProtocolInfo,
|
|
Packit |
712bc5 |
gupnp_protocol_info,
|
|
Packit |
712bc5 |
G_TYPE_OBJECT);
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
struct _GUPnPProtocolInfoPrivate {
|
|
Packit |
712bc5 |
char *protocol;
|
|
Packit |
712bc5 |
char *network;
|
|
Packit |
712bc5 |
char *mime_type;
|
|
Packit |
712bc5 |
char *dlna_profile;
|
|
Packit |
712bc5 |
char **play_speeds;
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
GUPnPDLNAConversion dlna_conversion;
|
|
Packit |
712bc5 |
GUPnPDLNAOperation dlna_operation;
|
|
Packit |
712bc5 |
GUPnPDLNAFlags dlna_flags;
|
|
Packit |
712bc5 |
};
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
enum {
|
|
Packit |
712bc5 |
PROP_0,
|
|
Packit |
712bc5 |
PROP_PROTOCOL,
|
|
Packit |
712bc5 |
PROP_NETWORK,
|
|
Packit |
712bc5 |
PROP_MIME_TYPE,
|
|
Packit |
712bc5 |
PROP_DLNA_PROFILE,
|
|
Packit |
712bc5 |
PROP_PLAY_SPEEDS,
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
PROP_DLNA_CONVERSION,
|
|
Packit |
712bc5 |
PROP_DLNA_OPERATION,
|
|
Packit |
712bc5 |
PROP_DLNA_FLAGS
|
|
Packit |
712bc5 |
};
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
static void
|
|
Packit |
712bc5 |
parse_additional_info (const char *additional_info,
|
|
Packit |
712bc5 |
GUPnPProtocolInfo *info)
|
|
Packit |
712bc5 |
{
|
|
Packit |
712bc5 |
char **tokens = NULL;
|
|
Packit |
712bc5 |
short i;
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
if (strcmp (additional_info, "*") == 0)
|
|
Packit |
712bc5 |
return;
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
tokens = g_strsplit (additional_info, ";", -1);
|
|
Packit |
712bc5 |
if (tokens == NULL) {
|
|
Packit |
712bc5 |
g_warning ("Invalid additional info in DIDL-Lite info: %s",
|
|
Packit |
712bc5 |
additional_info);
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
return;
|
|
Packit |
712bc5 |
}
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
for (i = 0; tokens[i]; i++) {
|
|
Packit |
712bc5 |
char *p;
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
p = g_strstr_len (tokens[i],
|
|
Packit |
712bc5 |
strlen (tokens[i]),
|
|
Packit |
712bc5 |
"DLNA.ORG_PN=");
|
|
Packit |
712bc5 |
if (p != NULL) {
|
|
Packit |
712bc5 |
p += 12; /* end of "DLNA.ORG_PN=" */
|
|
Packit |
712bc5 |
gupnp_protocol_info_set_dlna_profile (info, p);
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
continue;
|
|
Packit |
712bc5 |
}
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
p = g_strstr_len (tokens[i],
|
|
Packit |
712bc5 |
strlen (tokens[i]),
|
|
Packit |
712bc5 |
"DLNA.ORG_PS=");
|
|
Packit |
712bc5 |
if (p != NULL) {
|
|
Packit |
712bc5 |
char **play_speeds;
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
p += 12; /* end of "DLNA.ORG_PS=" */
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
play_speeds = g_strsplit (p, ",", -1);
|
|
Packit |
712bc5 |
gupnp_protocol_info_set_play_speeds
|
|
Packit |
712bc5 |
(info,
|
|
Packit |
712bc5 |
(const char **) play_speeds);
|
|
Packit |
712bc5 |
g_strfreev (play_speeds);
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
continue;
|
|
Packit |
712bc5 |
}
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
p = g_strstr_len (tokens[i],
|
|
Packit |
712bc5 |
strlen (tokens[i]),
|
|
Packit |
712bc5 |
"DLNA.ORG_CI=");
|
|
Packit |
712bc5 |
if (p != NULL) {
|
|
Packit |
712bc5 |
p += 12; /* end of "DLNA.ORG_CI=" */
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
gupnp_protocol_info_set_dlna_conversion (info,
|
|
Packit |
712bc5 |
atoi (p));
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
continue;
|
|
Packit |
712bc5 |
}
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
p = g_strstr_len (tokens[i],
|
|
Packit |
712bc5 |
strlen (tokens[i]),
|
|
Packit |
712bc5 |
"DLNA.ORG_OP=");
|
|
Packit |
712bc5 |
if (p != NULL) {
|
|
Packit |
712bc5 |
p += 12; /* end of "DLNA.ORG_OP=" */
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
gupnp_protocol_info_set_dlna_operation
|
|
Packit |
712bc5 |
(info,
|
|
Packit |
712bc5 |
strtoul (p, NULL, 16));
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
continue;
|
|
Packit |
712bc5 |
}
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
p = g_strstr_len (tokens[i],
|
|
Packit |
712bc5 |
strlen (tokens[i]),
|
|
Packit |
712bc5 |
"DLNA.ORG_FLAGS=");
|
|
Packit |
712bc5 |
if (p != NULL) {
|
|
Packit |
712bc5 |
p += 15; /* end of "DLNA.ORG_FLAGS=" */
|
|
Packit |
712bc5 |
if (strlen (p) > 8)
|
|
Packit |
712bc5 |
p[8] = '\0';
|
|
Packit |
712bc5 |
gupnp_protocol_info_set_dlna_flags
|
|
Packit |
712bc5 |
(info,
|
|
Packit |
712bc5 |
strtoul (p, NULL, 16));
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
continue;
|
|
Packit |
712bc5 |
}
|
|
Packit |
712bc5 |
}
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
g_strfreev (tokens);
|
|
Packit |
712bc5 |
}
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
static gboolean
|
|
Packit |
712bc5 |
is_transport_compat (GUPnPProtocolInfo *info1,
|
|
Packit |
712bc5 |
GUPnPProtocolInfo *info2)
|
|
Packit |
712bc5 |
{
|
|
Packit |
712bc5 |
const char *protocol1;
|
|
Packit |
712bc5 |
const char *protocol2;
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
protocol1 = gupnp_protocol_info_get_protocol (info1);
|
|
Packit |
712bc5 |
protocol2 = gupnp_protocol_info_get_protocol (info2);
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
if (protocol1[0] != '*' &&
|
|
Packit |
712bc5 |
protocol2[0] != '*' &&
|
|
Packit |
712bc5 |
g_ascii_strcasecmp (protocol1, protocol2) != 0)
|
|
Packit |
712bc5 |
return FALSE;
|
|
Packit |
712bc5 |
else if (g_ascii_strcasecmp ("internal", protocol1) == 0 &&
|
|
Packit |
712bc5 |
strcmp (gupnp_protocol_info_get_network (info1),
|
|
Packit |
712bc5 |
gupnp_protocol_info_get_network (info2)) != 0)
|
|
Packit |
712bc5 |
/* Host must be the same in case of INTERNAL protocol */
|
|
Packit |
712bc5 |
return FALSE;
|
|
Packit |
712bc5 |
else
|
|
Packit |
712bc5 |
return TRUE;
|
|
Packit |
712bc5 |
}
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
static gboolean
|
|
Packit |
712bc5 |
is_content_format_compat (GUPnPProtocolInfo *info1,
|
|
Packit |
712bc5 |
GUPnPProtocolInfo *info2)
|
|
Packit |
712bc5 |
{
|
|
Packit |
712bc5 |
const char *mime_type1;
|
|
Packit |
712bc5 |
const char *mime_type2;
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
mime_type1 = gupnp_protocol_info_get_mime_type (info1);
|
|
Packit |
712bc5 |
mime_type2 = gupnp_protocol_info_get_mime_type (info2);
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
if (mime_type1 [0] != '*' &&
|
|
Packit |
712bc5 |
mime_type2 [0] != '*' &&
|
|
Packit |
712bc5 |
g_ascii_strcasecmp (mime_type1, mime_type2) != 0 &&
|
|
Packit |
712bc5 |
/* Handle special case for LPCM: It is the only content type that
|
|
Packit |
712bc5 |
* make use of mime-type parameters that we know of.
|
|
Packit |
712bc5 |
*
|
|
Packit |
712bc5 |
* Example: audio/L16;rate=44100;channels=2
|
|
Packit |
712bc5 |
*/
|
|
Packit |
712bc5 |
!((g_ascii_strcasecmp (mime_type1, "audio/L16") == 0 &&
|
|
Packit |
712bc5 |
g_ascii_strncasecmp (mime_type2, "audio/L16", 9) == 0) ||
|
|
Packit |
712bc5 |
(g_ascii_strcasecmp (mime_type2, "audio/L16") == 0 &&
|
|
Packit |
712bc5 |
g_ascii_strncasecmp (mime_type1, "audio/L16", 9) == 0)))
|
|
Packit |
712bc5 |
return FALSE;
|
|
Packit |
712bc5 |
else
|
|
Packit |
712bc5 |
return TRUE;
|
|
Packit |
712bc5 |
}
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
static gboolean
|
|
Packit |
712bc5 |
is_additional_info_compat (GUPnPProtocolInfo *info1,
|
|
Packit |
712bc5 |
GUPnPProtocolInfo *info2)
|
|
Packit |
712bc5 |
{
|
|
Packit |
712bc5 |
const char *profile1;
|
|
Packit |
712bc5 |
const char *profile2;
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
profile1 = gupnp_protocol_info_get_dlna_profile (info1);
|
|
Packit |
712bc5 |
profile2 = gupnp_protocol_info_get_dlna_profile (info2);
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
if (profile1 == NULL ||
|
|
Packit |
712bc5 |
profile2 == NULL ||
|
|
Packit |
712bc5 |
profile1 [0] == '*' ||
|
|
Packit |
712bc5 |
profile2 [0] == '*' ||
|
|
Packit |
712bc5 |
g_ascii_strcasecmp (profile1, profile2) == 0)
|
|
Packit |
712bc5 |
return TRUE;
|
|
Packit |
712bc5 |
else
|
|
Packit |
712bc5 |
return FALSE;
|
|
Packit |
712bc5 |
}
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
static void
|
|
Packit |
712bc5 |
add_dlna_info (GString *str,
|
|
Packit |
712bc5 |
GUPnPProtocolInfo *info)
|
|
Packit |
712bc5 |
{
|
|
Packit |
712bc5 |
const char *dlna_profile;
|
|
Packit |
712bc5 |
const char **speeds;
|
|
Packit |
712bc5 |
GUPnPDLNAConversion conversion;
|
|
Packit |
712bc5 |
GUPnPDLNAOperation operation;
|
|
Packit |
712bc5 |
GUPnPDLNAFlags flags;
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
dlna_profile = gupnp_protocol_info_get_dlna_profile (info);
|
|
Packit |
712bc5 |
if (dlna_profile == NULL) {
|
|
Packit |
712bc5 |
g_string_append_printf (str, ":");
|
|
Packit |
712bc5 |
} else {
|
|
Packit |
712bc5 |
g_string_append_printf (str, ":DLNA.ORG_PN=%s;", dlna_profile);
|
|
Packit |
712bc5 |
}
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
operation = gupnp_protocol_info_get_dlna_operation (info);
|
|
Packit |
712bc5 |
if (operation != GUPNP_DLNA_OPERATION_NONE &&
|
|
Packit |
712bc5 |
/* the OP parameter is only allowed for the "http-get"
|
|
Packit |
712bc5 |
* and "rtsp-rtp-udp" protocols
|
|
Packit |
712bc5 |
*/
|
|
Packit |
712bc5 |
(strcmp (gupnp_protocol_info_get_protocol (info),
|
|
Packit |
712bc5 |
"http-get") == 0 ||
|
|
Packit |
712bc5 |
strcmp (gupnp_protocol_info_get_protocol (info),
|
|
Packit |
712bc5 |
"rtsp-rtp-udp") == 0))
|
|
Packit |
712bc5 |
g_string_append_printf (str, "DLNA.ORG_OP=%.2x;", operation);
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
/* Specify PS parameter if list of play speeds is provided */
|
|
Packit |
712bc5 |
speeds = gupnp_protocol_info_get_play_speeds (info);
|
|
Packit |
712bc5 |
if (speeds != NULL) {
|
|
Packit |
712bc5 |
int i;
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
g_string_append (str, "DLNA.ORG_PS=");
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
for (i = 0; speeds[i]; i++) {
|
|
Packit |
712bc5 |
g_string_append (str, speeds[i]);
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
if (speeds[i + 1])
|
|
Packit |
712bc5 |
g_string_append_c (str, ',');
|
|
Packit |
712bc5 |
}
|
|
Packit |
712bc5 |
g_string_append_c (str, ';');
|
|
Packit |
712bc5 |
}
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
conversion = gupnp_protocol_info_get_dlna_conversion (info);
|
|
Packit |
712bc5 |
/* omit the CI parameter for non-converted content */
|
|
Packit |
712bc5 |
if (conversion != GUPNP_DLNA_CONVERSION_NONE)
|
|
Packit |
712bc5 |
g_string_append_printf (str, "DLNA.ORG_CI=%d;", conversion);
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
flags = gupnp_protocol_info_get_dlna_flags (info);
|
|
Packit |
712bc5 |
/* Omit the FLAGS parameter if no or DLNA profile are set */
|
|
Packit |
712bc5 |
if (flags != GUPNP_DLNA_FLAGS_NONE && dlna_profile != NULL) {
|
|
Packit |
712bc5 |
g_string_append_printf (str, "DLNA.ORG_FLAGS=%.8x", flags);
|
|
Packit |
712bc5 |
/* append 24 reserved hex-digits */
|
|
Packit |
712bc5 |
g_string_append_printf (str,
|
|
Packit |
712bc5 |
"0000" "0000" "0000"
|
|
Packit |
712bc5 |
"0000" "0000" "0000");
|
|
Packit |
712bc5 |
}
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
/* if nothing of the above was set, use the "match all" rule */
|
|
Packit |
712bc5 |
switch (str->str[str->len - 1]) {
|
|
Packit |
712bc5 |
case ':':
|
|
Packit |
712bc5 |
g_string_append_c (str, '*');
|
|
Packit |
712bc5 |
break;
|
|
Packit |
712bc5 |
case ';':
|
|
Packit |
712bc5 |
g_string_erase (str, str->len - 1, 1);
|
|
Packit |
712bc5 |
break;
|
|
Packit |
712bc5 |
default:
|
|
Packit |
712bc5 |
break;
|
|
Packit |
712bc5 |
}
|
|
Packit |
712bc5 |
}
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
static void
|
|
Packit |
712bc5 |
gupnp_protocol_info_init (GUPnPProtocolInfo *info)
|
|
Packit |
712bc5 |
{
|
|
Packit |
712bc5 |
info->priv = G_TYPE_INSTANCE_GET_PRIVATE
|
|
Packit |
712bc5 |
(info,
|
|
Packit |
712bc5 |
GUPNP_TYPE_PROTOCOL_INFO,
|
|
Packit |
712bc5 |
GUPnPProtocolInfoPrivate);
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
info->priv->dlna_conversion = GUPNP_DLNA_CONVERSION_NONE;
|
|
Packit |
712bc5 |
info->priv->dlna_operation = GUPNP_DLNA_OPERATION_NONE;
|
|
Packit |
712bc5 |
info->priv->dlna_flags = GUPNP_DLNA_FLAGS_NONE;
|
|
Packit |
712bc5 |
}
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
static void
|
|
Packit |
712bc5 |
gupnp_protocol_info_set_property (GObject *object,
|
|
Packit |
712bc5 |
guint property_id,
|
|
Packit |
712bc5 |
const GValue *value,
|
|
Packit |
712bc5 |
GParamSpec *pspec)
|
|
Packit |
712bc5 |
{
|
|
Packit |
712bc5 |
GUPnPProtocolInfo *info;
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
info = GUPNP_PROTOCOL_INFO (object);
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
switch (property_id) {
|
|
Packit |
712bc5 |
case PROP_PROTOCOL:
|
|
Packit |
712bc5 |
gupnp_protocol_info_set_protocol (info,
|
|
Packit |
712bc5 |
g_value_get_string (value));
|
|
Packit |
712bc5 |
break;
|
|
Packit |
712bc5 |
case PROP_NETWORK:
|
|
Packit |
712bc5 |
gupnp_protocol_info_set_network (info,
|
|
Packit |
712bc5 |
g_value_get_string (value));
|
|
Packit |
712bc5 |
break;
|
|
Packit |
712bc5 |
case PROP_MIME_TYPE:
|
|
Packit |
712bc5 |
gupnp_protocol_info_set_mime_type (info,
|
|
Packit |
712bc5 |
g_value_get_string (value));
|
|
Packit |
712bc5 |
break;
|
|
Packit |
712bc5 |
case PROP_DLNA_PROFILE:
|
|
Packit |
712bc5 |
gupnp_protocol_info_set_dlna_profile
|
|
Packit |
712bc5 |
(info,
|
|
Packit |
712bc5 |
g_value_get_string (value));
|
|
Packit |
712bc5 |
break;
|
|
Packit |
712bc5 |
case PROP_PLAY_SPEEDS:
|
|
Packit |
712bc5 |
gupnp_protocol_info_set_play_speeds (info,
|
|
Packit |
712bc5 |
g_value_get_boxed (value));
|
|
Packit |
712bc5 |
break;
|
|
Packit |
712bc5 |
case PROP_DLNA_CONVERSION:
|
|
Packit |
712bc5 |
gupnp_protocol_info_set_dlna_conversion
|
|
Packit |
712bc5 |
(info,
|
|
Packit |
712bc5 |
g_value_get_flags (value));
|
|
Packit |
712bc5 |
break;
|
|
Packit |
712bc5 |
case PROP_DLNA_OPERATION:
|
|
Packit |
712bc5 |
gupnp_protocol_info_set_dlna_operation
|
|
Packit |
712bc5 |
(info,
|
|
Packit |
712bc5 |
g_value_get_flags (value));
|
|
Packit |
712bc5 |
break;
|
|
Packit |
712bc5 |
case PROP_DLNA_FLAGS:
|
|
Packit |
712bc5 |
gupnp_protocol_info_set_dlna_flags
|
|
Packit |
712bc5 |
(info,
|
|
Packit |
712bc5 |
g_value_get_flags (value));
|
|
Packit |
712bc5 |
break;
|
|
Packit |
712bc5 |
default:
|
|
Packit |
712bc5 |
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
Packit |
712bc5 |
break;
|
|
Packit |
712bc5 |
}
|
|
Packit |
712bc5 |
}
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
static void
|
|
Packit |
712bc5 |
gupnp_protocol_info_get_property (GObject *object,
|
|
Packit |
712bc5 |
guint property_id,
|
|
Packit |
712bc5 |
GValue *value,
|
|
Packit |
712bc5 |
GParamSpec *pspec)
|
|
Packit |
712bc5 |
{
|
|
Packit |
712bc5 |
GUPnPProtocolInfo *info;
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
info = GUPNP_PROTOCOL_INFO (object);
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
switch (property_id) {
|
|
Packit |
712bc5 |
case PROP_PROTOCOL:
|
|
Packit |
712bc5 |
g_value_set_string (value,
|
|
Packit |
712bc5 |
gupnp_protocol_info_get_protocol (info));
|
|
Packit |
712bc5 |
break;
|
|
Packit |
712bc5 |
case PROP_NETWORK:
|
|
Packit |
712bc5 |
g_value_set_string (value,
|
|
Packit |
712bc5 |
gupnp_protocol_info_get_network (info));
|
|
Packit |
712bc5 |
break;
|
|
Packit |
712bc5 |
case PROP_MIME_TYPE:
|
|
Packit |
712bc5 |
g_value_set_string (value,
|
|
Packit |
712bc5 |
gupnp_protocol_info_get_mime_type (info));
|
|
Packit |
712bc5 |
break;
|
|
Packit |
712bc5 |
case PROP_DLNA_PROFILE:
|
|
Packit |
712bc5 |
g_value_set_string
|
|
Packit |
712bc5 |
(value,
|
|
Packit |
712bc5 |
gupnp_protocol_info_get_dlna_profile (info));
|
|
Packit |
712bc5 |
break;
|
|
Packit |
712bc5 |
case PROP_PLAY_SPEEDS:
|
|
Packit |
712bc5 |
g_value_set_boxed (value,
|
|
Packit |
712bc5 |
gupnp_protocol_info_get_play_speeds (info));
|
|
Packit |
712bc5 |
break;
|
|
Packit |
712bc5 |
case PROP_DLNA_CONVERSION:
|
|
Packit |
712bc5 |
g_value_set_flags
|
|
Packit |
712bc5 |
(value,
|
|
Packit |
712bc5 |
gupnp_protocol_info_get_dlna_conversion
|
|
Packit |
712bc5 |
(info));
|
|
Packit |
712bc5 |
break;
|
|
Packit |
712bc5 |
case PROP_DLNA_OPERATION:
|
|
Packit |
712bc5 |
g_value_set_flags
|
|
Packit |
712bc5 |
(value,
|
|
Packit |
712bc5 |
gupnp_protocol_info_get_dlna_operation (info));
|
|
Packit |
712bc5 |
break;
|
|
Packit |
712bc5 |
case PROP_DLNA_FLAGS:
|
|
Packit |
712bc5 |
g_value_set_flags (value,
|
|
Packit |
712bc5 |
gupnp_protocol_info_get_dlna_flags (info));
|
|
Packit |
712bc5 |
break;
|
|
Packit |
712bc5 |
default:
|
|
Packit |
712bc5 |
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
Packit |
712bc5 |
break;
|
|
Packit |
712bc5 |
}
|
|
Packit |
712bc5 |
}
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
static void
|
|
Packit |
712bc5 |
gupnp_protocol_info_finalize (GObject *object)
|
|
Packit |
712bc5 |
{
|
|
Packit |
712bc5 |
GObjectClass *object_class;
|
|
Packit |
712bc5 |
GUPnPProtocolInfoPrivate *priv;
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
priv = GUPNP_PROTOCOL_INFO (object)->priv;
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
if (priv->protocol)
|
|
Packit |
712bc5 |
g_free (priv->protocol);
|
|
Packit |
712bc5 |
if (priv->network)
|
|
Packit |
712bc5 |
g_free (priv->network);
|
|
Packit |
712bc5 |
if (priv->mime_type)
|
|
Packit |
712bc5 |
g_free (priv->mime_type);
|
|
Packit |
712bc5 |
if (priv->dlna_profile)
|
|
Packit |
712bc5 |
g_free (priv->dlna_profile);
|
|
Packit |
712bc5 |
if (priv->play_speeds)
|
|
Packit |
712bc5 |
g_strfreev (priv->play_speeds);
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
object_class = G_OBJECT_CLASS (gupnp_protocol_info_parent_class);
|
|
Packit |
712bc5 |
object_class->finalize (object);
|
|
Packit |
712bc5 |
}
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
static void
|
|
Packit |
712bc5 |
gupnp_protocol_info_class_init (GUPnPProtocolInfoClass *klass)
|
|
Packit |
712bc5 |
{
|
|
Packit |
712bc5 |
GObjectClass *object_class;
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
object_class = G_OBJECT_CLASS (klass);
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
object_class->set_property = gupnp_protocol_info_set_property;
|
|
Packit |
712bc5 |
object_class->get_property = gupnp_protocol_info_get_property;
|
|
Packit |
712bc5 |
object_class->finalize = gupnp_protocol_info_finalize;
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
g_type_class_add_private (klass, sizeof (GUPnPProtocolInfoPrivate));
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
/**
|
|
Packit |
712bc5 |
* GUPnPProtocolInfo:protocol:
|
|
Packit |
712bc5 |
*
|
|
Packit |
712bc5 |
* The protocol of this info.
|
|
Packit |
712bc5 |
**/
|
|
Packit |
712bc5 |
g_object_class_install_property
|
|
Packit |
712bc5 |
(object_class,
|
|
Packit |
712bc5 |
PROP_PROTOCOL,
|
|
Packit |
712bc5 |
g_param_spec_string ("protocol",
|
|
Packit |
712bc5 |
"Protocol",
|
|
Packit |
712bc5 |
"The protocol of this info.",
|
|
Packit |
712bc5 |
NULL,
|
|
Packit |
712bc5 |
G_PARAM_READWRITE |
|
|
Packit |
712bc5 |
G_PARAM_STATIC_NAME |
|
|
Packit |
712bc5 |
G_PARAM_STATIC_NICK |
|
|
Packit |
712bc5 |
G_PARAM_STATIC_BLURB));
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
/**
|
|
Packit |
712bc5 |
* GUPnPProtocolInfo:network:
|
|
Packit |
712bc5 |
*
|
|
Packit |
712bc5 |
* The network this info is associated with.
|
|
Packit |
712bc5 |
**/
|
|
Packit |
712bc5 |
g_object_class_install_property
|
|
Packit |
712bc5 |
(object_class,
|
|
Packit |
712bc5 |
PROP_NETWORK,
|
|
Packit |
712bc5 |
g_param_spec_string ("network",
|
|
Packit |
712bc5 |
"Network",
|
|
Packit |
712bc5 |
"The network this info is associated"
|
|
Packit |
712bc5 |
" with.",
|
|
Packit |
712bc5 |
NULL,
|
|
Packit |
712bc5 |
G_PARAM_READWRITE |
|
|
Packit |
712bc5 |
G_PARAM_STATIC_NAME |
|
|
Packit |
712bc5 |
G_PARAM_STATIC_NICK |
|
|
Packit |
712bc5 |
G_PARAM_STATIC_BLURB));
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
/**
|
|
Packit |
712bc5 |
* GUPnPProtocolInfo:mime-type:
|
|
Packit |
712bc5 |
*
|
|
Packit |
712bc5 |
* The MIME-type of this info.
|
|
Packit |
712bc5 |
**/
|
|
Packit |
712bc5 |
g_object_class_install_property
|
|
Packit |
712bc5 |
(object_class,
|
|
Packit |
712bc5 |
PROP_MIME_TYPE,
|
|
Packit |
712bc5 |
g_param_spec_string ("mime-type",
|
|
Packit |
712bc5 |
"MIMEType",
|
|
Packit |
712bc5 |
"The MIME-type of this info.",
|
|
Packit |
712bc5 |
NULL,
|
|
Packit |
712bc5 |
G_PARAM_READWRITE |
|
|
Packit |
712bc5 |
G_PARAM_STATIC_NAME |
|
|
Packit |
712bc5 |
G_PARAM_STATIC_NICK |
|
|
Packit |
712bc5 |
G_PARAM_STATIC_BLURB));
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
/**
|
|
Packit |
712bc5 |
* GUPnPProtocolInfo:dlna-profile:
|
|
Packit |
712bc5 |
*
|
|
Packit |
712bc5 |
* The DLNA profile of this info.
|
|
Packit |
712bc5 |
**/
|
|
Packit |
712bc5 |
g_object_class_install_property
|
|
Packit |
712bc5 |
(object_class,
|
|
Packit |
712bc5 |
PROP_DLNA_PROFILE,
|
|
Packit |
712bc5 |
g_param_spec_string ("dlna-profile",
|
|
Packit |
712bc5 |
"DLNAProfile",
|
|
Packit |
712bc5 |
"The DLNA profile of this info.",
|
|
Packit |
712bc5 |
NULL,
|
|
Packit |
712bc5 |
G_PARAM_READWRITE |
|
|
Packit |
712bc5 |
G_PARAM_STATIC_NAME |
|
|
Packit |
712bc5 |
G_PARAM_STATIC_NICK |
|
|
Packit |
712bc5 |
G_PARAM_STATIC_BLURB));
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
/**
|
|
Packit |
712bc5 |
* GUPnPProtocolInfo:play-speeds:
|
|
Packit |
712bc5 |
*
|
|
Packit |
712bc5 |
* The allowed play speeds on this info in the form of array of
|
|
Packit |
712bc5 |
* strings.
|
|
Packit |
712bc5 |
**/
|
|
Packit |
712bc5 |
g_object_class_install_property
|
|
Packit |
712bc5 |
(object_class,
|
|
Packit |
712bc5 |
PROP_PLAY_SPEEDS,
|
|
Packit |
712bc5 |
g_param_spec_boxed ("play-speeds",
|
|
Packit |
712bc5 |
"PlaySpeeds",
|
|
Packit |
712bc5 |
"The allowed play speeds on this"
|
|
Packit |
712bc5 |
" info in the form of array of"
|
|
Packit |
712bc5 |
" strings.",
|
|
Packit |
712bc5 |
G_TYPE_STRV,
|
|
Packit |
712bc5 |
G_PARAM_READWRITE |
|
|
Packit |
712bc5 |
G_PARAM_STATIC_NAME |
|
|
Packit |
712bc5 |
G_PARAM_STATIC_NICK |
|
|
Packit |
712bc5 |
G_PARAM_STATIC_BLURB));
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
/**
|
|
Packit |
712bc5 |
* GUPnPProtocolInfo:dlna-conversion:
|
|
Packit |
712bc5 |
*
|
|
Packit |
712bc5 |
* The DLNA conversion flags.
|
|
Packit |
712bc5 |
**/
|
|
Packit |
712bc5 |
g_object_class_install_property
|
|
Packit |
712bc5 |
(object_class,
|
|
Packit |
712bc5 |
PROP_DLNA_CONVERSION,
|
|
Packit |
712bc5 |
g_param_spec_flags ("dlna-conversion",
|
|
Packit |
712bc5 |
"DLNAConversion",
|
|
Packit |
712bc5 |
"The DLNA conversion flags.",
|
|
Packit |
712bc5 |
GUPNP_TYPE_DLNA_CONVERSION,
|
|
Packit |
712bc5 |
GUPNP_DLNA_CONVERSION_NONE,
|
|
Packit |
712bc5 |
G_PARAM_READWRITE |
|
|
Packit |
712bc5 |
G_PARAM_STATIC_NAME |
|
|
Packit |
712bc5 |
G_PARAM_STATIC_NICK |
|
|
Packit |
712bc5 |
G_PARAM_STATIC_BLURB));
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
/**
|
|
Packit |
712bc5 |
* GUPnPProtocolInfo:dlna-operation:
|
|
Packit |
712bc5 |
*
|
|
Packit |
712bc5 |
* The DLNA operation flags.
|
|
Packit |
712bc5 |
**/
|
|
Packit |
712bc5 |
g_object_class_install_property
|
|
Packit |
712bc5 |
(object_class,
|
|
Packit |
712bc5 |
PROP_DLNA_OPERATION,
|
|
Packit |
712bc5 |
g_param_spec_flags ("dlna-operation",
|
|
Packit |
712bc5 |
"DLNAOperation",
|
|
Packit |
712bc5 |
"The DLNA operation flags.",
|
|
Packit |
712bc5 |
GUPNP_TYPE_DLNA_OPERATION,
|
|
Packit |
712bc5 |
GUPNP_DLNA_OPERATION_NONE,
|
|
Packit |
712bc5 |
G_PARAM_READWRITE |
|
|
Packit |
712bc5 |
G_PARAM_STATIC_NAME |
|
|
Packit |
712bc5 |
G_PARAM_STATIC_NICK |
|
|
Packit |
712bc5 |
G_PARAM_STATIC_BLURB));
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
/**
|
|
Packit |
712bc5 |
* GUPnPProtocolInfo:dlna-flags:
|
|
Packit |
712bc5 |
*
|
|
Packit |
712bc5 |
* Various generic DLNA flags.
|
|
Packit |
712bc5 |
**/
|
|
Packit |
712bc5 |
g_object_class_install_property
|
|
Packit |
712bc5 |
(object_class,
|
|
Packit |
712bc5 |
PROP_DLNA_FLAGS,
|
|
Packit |
712bc5 |
g_param_spec_flags ("dlna-flags",
|
|
Packit |
712bc5 |
"DLNAFlags",
|
|
Packit |
712bc5 |
"Various generic DLNA flags.",
|
|
Packit |
712bc5 |
GUPNP_TYPE_DLNA_FLAGS,
|
|
Packit |
712bc5 |
GUPNP_DLNA_FLAGS_NONE,
|
|
Packit |
712bc5 |
G_PARAM_READWRITE |
|
|
Packit |
712bc5 |
G_PARAM_STATIC_NAME |
|
|
Packit |
712bc5 |
G_PARAM_STATIC_NICK |
|
|
Packit |
712bc5 |
G_PARAM_STATIC_BLURB));
|
|
Packit |
712bc5 |
}
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
/**
|
|
Packit |
712bc5 |
* gupnp_protocol_info_new:
|
|
Packit |
712bc5 |
*
|
|
Packit |
712bc5 |
* Return value: A new #GUPnPProtocolInfo object. Unref after usage.
|
|
Packit |
712bc5 |
**/
|
|
Packit |
712bc5 |
GUPnPProtocolInfo *
|
|
Packit |
712bc5 |
gupnp_protocol_info_new (void)
|
|
Packit |
712bc5 |
{
|
|
Packit |
712bc5 |
return g_object_new (GUPNP_TYPE_PROTOCOL_INFO,
|
|
Packit |
712bc5 |
NULL);
|
|
Packit |
712bc5 |
}
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
/**
|
|
Packit |
712bc5 |
* gupnp_protocol_info_new_from_string:
|
|
Packit |
712bc5 |
* @protocol_info: The protocol info string
|
|
Packit |
712bc5 |
* @error: The location where to store any error, or NULL
|
|
Packit |
712bc5 |
*
|
|
Packit |
712bc5 |
* Parses the @protocol_info string and creates a new #GUPnPProtocolInfo object
|
|
Packit |
712bc5 |
* as a result.
|
|
Packit |
712bc5 |
*
|
|
Packit |
712bc5 |
* Return value: A new #GUPnPProtocolInfo object. Unref after usage.
|
|
Packit |
712bc5 |
**/
|
|
Packit |
712bc5 |
GUPnPProtocolInfo *
|
|
Packit |
712bc5 |
gupnp_protocol_info_new_from_string (const char *protocol_info,
|
|
Packit |
712bc5 |
GError **error)
|
|
Packit |
712bc5 |
{
|
|
Packit |
712bc5 |
GUPnPProtocolInfo *info;
|
|
Packit |
712bc5 |
char **tokens;
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
g_return_val_if_fail (protocol_info != NULL, NULL);
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
tokens = g_strsplit (protocol_info, ":", 4);
|
|
Packit |
712bc5 |
if (tokens[0] == NULL ||
|
|
Packit |
712bc5 |
tokens[1] == NULL ||
|
|
Packit |
712bc5 |
tokens[2] == NULL ||
|
|
Packit |
712bc5 |
tokens[3] == NULL) {
|
|
Packit |
712bc5 |
g_set_error (error,
|
|
Packit |
712bc5 |
GUPNP_PROTOCOL_ERROR,
|
|
Packit |
712bc5 |
GUPNP_PROTOCOL_ERROR_INVALID_SYNTAX,
|
|
Packit |
712bc5 |
"Failed to parse protocolInfo string: \n%s",
|
|
Packit |
712bc5 |
protocol_info);
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
g_strfreev (tokens);
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
return NULL;
|
|
Packit |
712bc5 |
}
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
info = gupnp_protocol_info_new ();
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
gupnp_protocol_info_set_protocol (info, tokens[0]);
|
|
Packit |
712bc5 |
gupnp_protocol_info_set_network (info, tokens[1]);
|
|
Packit |
712bc5 |
gupnp_protocol_info_set_mime_type (info, tokens[2]);
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
parse_additional_info (tokens[3], info);
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
g_strfreev (tokens);
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
return info;
|
|
Packit |
712bc5 |
}
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
/**
|
|
Packit |
712bc5 |
* gupnp_protocol_info_to_string:
|
|
Packit |
712bc5 |
* @info: The #GUPnPProtocolInfo
|
|
Packit |
712bc5 |
*
|
|
Packit |
712bc5 |
* Provides the string representation of @info.
|
|
Packit |
712bc5 |
*
|
|
Packit |
712bc5 |
* Return value: String representation of @info. #g_free after usage.
|
|
Packit |
712bc5 |
**/
|
|
Packit |
712bc5 |
char *
|
|
Packit |
712bc5 |
gupnp_protocol_info_to_string (GUPnPProtocolInfo *info)
|
|
Packit |
712bc5 |
{
|
|
Packit |
712bc5 |
GString *str;
|
|
Packit |
712bc5 |
const char *protocol;
|
|
Packit |
712bc5 |
const char *mime_type;
|
|
Packit |
712bc5 |
const char *network;
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
g_return_val_if_fail (GUPNP_IS_PROTOCOL_INFO (info), NULL);
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
protocol = gupnp_protocol_info_get_protocol (info);
|
|
Packit |
712bc5 |
mime_type = gupnp_protocol_info_get_mime_type (info);
|
|
Packit |
712bc5 |
network = gupnp_protocol_info_get_network (info);
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
g_return_val_if_fail (protocol != NULL, NULL);
|
|
Packit |
712bc5 |
g_return_val_if_fail (mime_type != NULL, NULL);
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
str = g_string_new ("");
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
g_string_append (str, protocol);
|
|
Packit |
712bc5 |
g_string_append_c (str, ':');
|
|
Packit |
712bc5 |
if (network != NULL)
|
|
Packit |
712bc5 |
g_string_append (str, network);
|
|
Packit |
712bc5 |
else
|
|
Packit |
712bc5 |
g_string_append_c (str, '*');
|
|
Packit |
712bc5 |
g_string_append_c (str, ':');
|
|
Packit |
712bc5 |
g_string_append (str, mime_type);
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
add_dlna_info (str, info);
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
return g_string_free (str, FALSE);
|
|
Packit |
712bc5 |
}
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
/**
|
|
Packit |
712bc5 |
* gupnp_protocol_info_get_protocol:
|
|
Packit |
712bc5 |
* @info: A #GUPnPProtocolInfo
|
|
Packit |
712bc5 |
*
|
|
Packit |
712bc5 |
* Get the protocol of this info.
|
|
Packit |
712bc5 |
*
|
|
Packit |
712bc5 |
* Return value: The protocol of this info or %NULL. This string should not
|
|
Packit |
712bc5 |
* be freed.
|
|
Packit |
712bc5 |
**/
|
|
Packit |
712bc5 |
const char *
|
|
Packit |
712bc5 |
gupnp_protocol_info_get_protocol (GUPnPProtocolInfo *info)
|
|
Packit |
712bc5 |
{
|
|
Packit |
712bc5 |
g_return_val_if_fail (GUPNP_IS_PROTOCOL_INFO (info), NULL);
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
return info->priv->protocol;
|
|
Packit |
712bc5 |
}
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
/**
|
|
Packit |
712bc5 |
* gupnp_protocol_info_get_network:
|
|
Packit |
712bc5 |
* @info: A #GUPnPProtocolInfo
|
|
Packit |
712bc5 |
*
|
|
Packit |
712bc5 |
* Get the network this info is associated with.
|
|
Packit |
712bc5 |
*
|
|
Packit |
712bc5 |
* Return value: The network string or %NULL. This string should not be freed.
|
|
Packit |
712bc5 |
**/
|
|
Packit |
712bc5 |
const char *
|
|
Packit |
712bc5 |
gupnp_protocol_info_get_network (GUPnPProtocolInfo *info)
|
|
Packit |
712bc5 |
{
|
|
Packit |
712bc5 |
g_return_val_if_fail (GUPNP_IS_PROTOCOL_INFO (info), NULL);
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
return info->priv->network;
|
|
Packit |
712bc5 |
}
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
/**
|
|
Packit |
712bc5 |
* gupnp_protocol_info_get_mime_type:
|
|
Packit |
712bc5 |
* @info: A #GUPnPProtocolInfo
|
|
Packit |
712bc5 |
*
|
|
Packit |
712bc5 |
* Get the MIME-type of this info.
|
|
Packit |
712bc5 |
*
|
|
Packit |
712bc5 |
* Return value: The MIME-type of this info or %NULL. This string should not
|
|
Packit |
712bc5 |
* be freed.
|
|
Packit |
712bc5 |
**/
|
|
Packit |
712bc5 |
const char *
|
|
Packit |
712bc5 |
gupnp_protocol_info_get_mime_type (GUPnPProtocolInfo *info)
|
|
Packit |
712bc5 |
{
|
|
Packit |
712bc5 |
g_return_val_if_fail (GUPNP_IS_PROTOCOL_INFO (info), NULL);
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
return info->priv->mime_type;
|
|
Packit |
712bc5 |
}
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
/**
|
|
Packit |
712bc5 |
* gupnp_protocol_info_get_dlna_profile:
|
|
Packit |
712bc5 |
* @info: A #GUPnPProtocolInfo
|
|
Packit |
712bc5 |
*
|
|
Packit |
712bc5 |
* Get the DLNA profile of this info.
|
|
Packit |
712bc5 |
*
|
|
Packit |
712bc5 |
* Return value: The DLNA profile of this info or %NULL. This string should
|
|
Packit |
712bc5 |
* not be freed.
|
|
Packit |
712bc5 |
**/
|
|
Packit |
712bc5 |
const char *
|
|
Packit |
712bc5 |
gupnp_protocol_info_get_dlna_profile (GUPnPProtocolInfo *info)
|
|
Packit |
712bc5 |
{
|
|
Packit |
712bc5 |
g_return_val_if_fail (GUPNP_IS_PROTOCOL_INFO (info), NULL);
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
return info->priv->dlna_profile;
|
|
Packit |
712bc5 |
}
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
/**
|
|
Packit |
712bc5 |
* gupnp_protocol_info_get_play_speeds:
|
|
Packit |
712bc5 |
* @info: A #GUPnPProtocolInfo
|
|
Packit |
712bc5 |
*
|
|
Packit |
712bc5 |
* Get the allowed play speeds on this info in the form of array of strings.
|
|
Packit |
712bc5 |
*
|
|
Packit |
712bc5 |
* Returns: (transfer none): The allowed play speeds as array of strings or %NULL. This
|
|
Packit |
712bc5 |
* return array and it's content must not be modified or freed.
|
|
Packit |
712bc5 |
**/
|
|
Packit |
712bc5 |
const char **
|
|
Packit |
712bc5 |
gupnp_protocol_info_get_play_speeds (GUPnPProtocolInfo *info)
|
|
Packit |
712bc5 |
{
|
|
Packit |
712bc5 |
g_return_val_if_fail (GUPNP_IS_PROTOCOL_INFO (info), NULL);
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
return (const char **) info->priv->play_speeds;
|
|
Packit |
712bc5 |
}
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
/**
|
|
Packit |
712bc5 |
* gupnp_protocol_info_get_dlna_conversion:
|
|
Packit |
712bc5 |
* @info: A #GUPnPProtocolInfo
|
|
Packit |
712bc5 |
*
|
|
Packit |
712bc5 |
* Get the DLNA conversion flags.
|
|
Packit |
712bc5 |
*
|
|
Packit |
712bc5 |
* Return value: The DLNA conversion flags.
|
|
Packit |
712bc5 |
**/
|
|
Packit |
712bc5 |
GUPnPDLNAConversion
|
|
Packit |
712bc5 |
gupnp_protocol_info_get_dlna_conversion (GUPnPProtocolInfo *info)
|
|
Packit |
712bc5 |
{
|
|
Packit |
712bc5 |
g_return_val_if_fail (GUPNP_IS_PROTOCOL_INFO (info),
|
|
Packit |
712bc5 |
GUPNP_DLNA_CONVERSION_NONE);
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
return info->priv->dlna_conversion;
|
|
Packit |
712bc5 |
}
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
/**
|
|
Packit |
712bc5 |
* gupnp_protocol_info_get_dlna_operation:
|
|
Packit |
712bc5 |
* @info: A #GUPnPProtocolInfo
|
|
Packit |
712bc5 |
*
|
|
Packit |
712bc5 |
* Get the DLNA operation flags.
|
|
Packit |
712bc5 |
*
|
|
Packit |
712bc5 |
* Return value: The DLNA operation flags.
|
|
Packit |
712bc5 |
**/
|
|
Packit |
712bc5 |
GUPnPDLNAOperation
|
|
Packit |
712bc5 |
gupnp_protocol_info_get_dlna_operation (GUPnPProtocolInfo *info)
|
|
Packit |
712bc5 |
{
|
|
Packit |
712bc5 |
g_return_val_if_fail (GUPNP_IS_PROTOCOL_INFO (info),
|
|
Packit |
712bc5 |
GUPNP_DLNA_OPERATION_NONE);
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
return info->priv->dlna_operation;
|
|
Packit |
712bc5 |
}
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
/**
|
|
Packit |
712bc5 |
* gupnp_protocol_info_get_dlna_flags:
|
|
Packit |
712bc5 |
* @info: A #GUPnPProtocolInfo
|
|
Packit |
712bc5 |
*
|
|
Packit |
712bc5 |
* Get the gereric DLNA flags.
|
|
Packit |
712bc5 |
*
|
|
Packit |
712bc5 |
* Return value: The generic DLNA flags.
|
|
Packit |
712bc5 |
**/
|
|
Packit |
712bc5 |
GUPnPDLNAFlags
|
|
Packit |
712bc5 |
gupnp_protocol_info_get_dlna_flags (GUPnPProtocolInfo *info)
|
|
Packit |
712bc5 |
{
|
|
Packit |
712bc5 |
g_return_val_if_fail (GUPNP_IS_PROTOCOL_INFO (info),
|
|
Packit |
712bc5 |
GUPNP_DLNA_FLAGS_NONE);
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
return info->priv->dlna_flags;
|
|
Packit |
712bc5 |
}
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
/**
|
|
Packit |
712bc5 |
* gupnp_protocol_info_set_protocol:
|
|
Packit |
712bc5 |
* @info: A #GUPnPProtocolInfo
|
|
Packit |
712bc5 |
* @protocol: The protocol string
|
|
Packit |
712bc5 |
*
|
|
Packit |
712bc5 |
* Set the protocol of this info.
|
|
Packit |
712bc5 |
**/
|
|
Packit |
712bc5 |
void
|
|
Packit |
712bc5 |
gupnp_protocol_info_set_protocol (GUPnPProtocolInfo *info,
|
|
Packit |
712bc5 |
const char *protocol)
|
|
Packit |
712bc5 |
{
|
|
Packit |
712bc5 |
g_return_if_fail (GUPNP_IS_PROTOCOL_INFO (info));
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
if (info->priv->protocol)
|
|
Packit |
712bc5 |
g_free (info->priv->protocol);
|
|
Packit |
712bc5 |
info->priv->protocol = g_strdup (protocol);
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
g_object_notify (G_OBJECT (info), "protocol");
|
|
Packit |
712bc5 |
}
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
/**
|
|
Packit |
712bc5 |
* gupnp_protocol_info_set_network:
|
|
Packit |
712bc5 |
* @info: A #GUPnPProtocolInfo
|
|
Packit |
712bc5 |
* @network: The network string
|
|
Packit |
712bc5 |
*
|
|
Packit |
712bc5 |
* Set the network this info is associated with.
|
|
Packit |
712bc5 |
**/
|
|
Packit |
712bc5 |
void
|
|
Packit |
712bc5 |
gupnp_protocol_info_set_network (GUPnPProtocolInfo *info,
|
|
Packit |
712bc5 |
const char *network)
|
|
Packit |
712bc5 |
{
|
|
Packit |
712bc5 |
g_return_if_fail (GUPNP_IS_PROTOCOL_INFO (info));
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
if (info->priv->network)
|
|
Packit |
712bc5 |
g_free (info->priv->network);
|
|
Packit |
712bc5 |
info->priv->network = g_strdup (network);
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
g_object_notify (G_OBJECT (info), "network");
|
|
Packit |
712bc5 |
}
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
/**
|
|
Packit |
712bc5 |
* gupnp_protocol_info_set_mime_type:
|
|
Packit |
712bc5 |
* @info: A #GUPnPProtocolInfo
|
|
Packit |
712bc5 |
* @mime_type: The MIME-type string
|
|
Packit |
712bc5 |
*
|
|
Packit |
712bc5 |
* Set the MIME-type of this info.
|
|
Packit |
712bc5 |
**/
|
|
Packit |
712bc5 |
void
|
|
Packit |
712bc5 |
gupnp_protocol_info_set_mime_type (GUPnPProtocolInfo *info,
|
|
Packit |
712bc5 |
const char *mime_type)
|
|
Packit |
712bc5 |
{
|
|
Packit |
712bc5 |
g_return_if_fail (GUPNP_IS_PROTOCOL_INFO (info));
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
if (info->priv->mime_type)
|
|
Packit |
712bc5 |
g_free (info->priv->mime_type);
|
|
Packit |
712bc5 |
info->priv->mime_type = g_strdup (mime_type);
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
g_object_notify (G_OBJECT (info), "mime-type");
|
|
Packit |
712bc5 |
}
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
/**
|
|
Packit |
712bc5 |
* gupnp_protocol_info_set_dlna_profile:
|
|
Packit |
712bc5 |
* @info: A #GUPnPProtocolInfo
|
|
Packit |
712bc5 |
* @profile: The DLNA profile string
|
|
Packit |
712bc5 |
*
|
|
Packit |
712bc5 |
* Set the DLNA profile of this info.
|
|
Packit |
712bc5 |
**/
|
|
Packit |
712bc5 |
void
|
|
Packit |
712bc5 |
gupnp_protocol_info_set_dlna_profile (GUPnPProtocolInfo *info,
|
|
Packit |
712bc5 |
const char *profile)
|
|
Packit |
712bc5 |
{
|
|
Packit |
712bc5 |
g_return_if_fail (GUPNP_IS_PROTOCOL_INFO (info));
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
if (info->priv->dlna_profile)
|
|
Packit |
712bc5 |
g_free (info->priv->dlna_profile);
|
|
Packit |
712bc5 |
info->priv->dlna_profile = g_strdup (profile);
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
g_object_notify (G_OBJECT (info), "dlna-profile");
|
|
Packit |
712bc5 |
}
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
/**
|
|
Packit |
712bc5 |
* gupnp_protocol_info_set_play_speeds:
|
|
Packit |
712bc5 |
* @info: A #GUPnPProtocolInfo
|
|
Packit |
712bc5 |
* @speeds: The allowed play speeds
|
|
Packit |
712bc5 |
*
|
|
Packit |
712bc5 |
* Set the allowed play speeds on this info in the form of array of strings.
|
|
Packit |
712bc5 |
**/
|
|
Packit |
712bc5 |
void
|
|
Packit |
712bc5 |
gupnp_protocol_info_set_play_speeds (GUPnPProtocolInfo *info,
|
|
Packit |
712bc5 |
const char **speeds)
|
|
Packit |
712bc5 |
{
|
|
Packit |
712bc5 |
g_return_if_fail (GUPNP_IS_PROTOCOL_INFO (info));
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
if (info->priv->play_speeds)
|
|
Packit |
712bc5 |
g_strfreev (info->priv->play_speeds);
|
|
Packit |
712bc5 |
info->priv->play_speeds = (char **) g_boxed_copy (G_TYPE_STRV, speeds);
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
g_object_notify (G_OBJECT (info), "play-speeds");
|
|
Packit |
712bc5 |
}
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
/**
|
|
Packit |
712bc5 |
* gupnp_protocol_info_set_dlna_conversion:
|
|
Packit |
712bc5 |
* @info: A #GUPnPProtocolInfo
|
|
Packit |
712bc5 |
* @conversion: The bitwise OR of one or more DLNA conversion flags
|
|
Packit |
712bc5 |
*
|
|
Packit |
712bc5 |
* Set the DLNA conversion flags.
|
|
Packit |
712bc5 |
**/
|
|
Packit |
712bc5 |
void
|
|
Packit |
712bc5 |
gupnp_protocol_info_set_dlna_conversion (GUPnPProtocolInfo *info,
|
|
Packit |
712bc5 |
GUPnPDLNAConversion conversion)
|
|
Packit |
712bc5 |
{
|
|
Packit |
712bc5 |
g_return_if_fail (GUPNP_IS_PROTOCOL_INFO (info));
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
info->priv->dlna_conversion = conversion;
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
g_object_notify (G_OBJECT (info), "dlna-conversion");
|
|
Packit |
712bc5 |
}
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
/**
|
|
Packit |
712bc5 |
* gupnp_protocol_info_set_dlna_operation:
|
|
Packit |
712bc5 |
* @info: A #GUPnPProtocolInfo
|
|
Packit |
712bc5 |
* @operation: The bitwise OR of one or more DLNA operation flags
|
|
Packit |
712bc5 |
*
|
|
Packit |
712bc5 |
* Set the DLNA operation flags.
|
|
Packit |
712bc5 |
**/
|
|
Packit |
712bc5 |
void
|
|
Packit |
712bc5 |
gupnp_protocol_info_set_dlna_operation (GUPnPProtocolInfo *info,
|
|
Packit |
712bc5 |
GUPnPDLNAOperation operation)
|
|
Packit |
712bc5 |
{
|
|
Packit |
712bc5 |
g_return_if_fail (GUPNP_IS_PROTOCOL_INFO (info));
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
info->priv->dlna_operation = operation;
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
g_object_notify (G_OBJECT (info), "dlna-operation");
|
|
Packit |
712bc5 |
}
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
/**
|
|
Packit |
712bc5 |
* gupnp_protocol_info_set_dlna_flags:
|
|
Packit |
712bc5 |
* @info: A #GUPnPProtocolInfo
|
|
Packit |
712bc5 |
* @flags: The bitwise OR of one or more generic DLNA flags
|
|
Packit |
712bc5 |
*
|
|
Packit |
712bc5 |
* Set the gereric DLNA flags.
|
|
Packit |
712bc5 |
**/
|
|
Packit |
712bc5 |
void
|
|
Packit |
712bc5 |
gupnp_protocol_info_set_dlna_flags (GUPnPProtocolInfo *info,
|
|
Packit |
712bc5 |
GUPnPDLNAFlags flags)
|
|
Packit |
712bc5 |
{
|
|
Packit |
712bc5 |
g_return_if_fail (GUPNP_IS_PROTOCOL_INFO (info));
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
info->priv->dlna_flags = flags;
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
g_object_notify (G_OBJECT (info), "dlna-flags");
|
|
Packit |
712bc5 |
}
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
/**
|
|
Packit |
712bc5 |
* gupnp_protocol_info_is_compatible:
|
|
Packit |
712bc5 |
* @info1: The first #GUPnPProtocolInfo
|
|
Packit |
712bc5 |
* @info2: The second #GUPnPProtocolInfo
|
|
Packit |
712bc5 |
*
|
|
Packit |
712bc5 |
* Checks if the given protocolInfo string is compatible with @info.
|
|
Packit |
712bc5 |
*
|
|
Packit |
712bc5 |
* Return value: #TRUE if @protocol_info is compatible with @info, otherwise
|
|
Packit |
712bc5 |
* #FALSE.
|
|
Packit |
712bc5 |
**/
|
|
Packit |
712bc5 |
gboolean
|
|
Packit |
712bc5 |
gupnp_protocol_info_is_compatible (GUPnPProtocolInfo *info1,
|
|
Packit |
712bc5 |
GUPnPProtocolInfo *info2)
|
|
Packit |
712bc5 |
{
|
|
Packit |
712bc5 |
g_return_val_if_fail (GUPNP_IS_PROTOCOL_INFO (info1), FALSE);
|
|
Packit |
712bc5 |
g_return_val_if_fail (GUPNP_IS_PROTOCOL_INFO (info2), FALSE);
|
|
Packit |
712bc5 |
|
|
Packit |
712bc5 |
return is_transport_compat (info1, info2) &&
|
|
Packit |
712bc5 |
is_content_format_compat (info1, info2) &&
|
|
Packit |
712bc5 |
is_additional_info_compat (info1, info2);
|
|
Packit |
712bc5 |
}
|
|
Packit |
712bc5 |
|