static void
gupnp_protocol_info_set_property (GObject      *object,
                                  guint         property_id,
                                  const GValue *value,
                                  GParamSpec   *pspec)
{
        GUPnPProtocolInfo *info;

        info = GUPNP_PROTOCOL_INFO (object);

        switch (property_id) {
        case PROP_PROTOCOL:
                gupnp_protocol_info_set_protocol (info,
                                                  g_value_get_string (value));
                break;
        case PROP_NETWORK:
                gupnp_protocol_info_set_network (info,
                                                 g_value_get_string (value));
                break;
        case PROP_MIME_TYPE:
                gupnp_protocol_info_set_mime_type (info,
                                                   g_value_get_string (value));
                break;
        case PROP_DLNA_PROFILE:
                gupnp_protocol_info_set_dlna_profile
                                        (info,
                                         g_value_get_string (value));
                break;
        case PROP_PLAY_SPEEDS:
                gupnp_protocol_info_set_play_speeds (info,
                                                     g_value_get_boxed (value));
                break;
        case PROP_DLNA_CONVERSION:
                gupnp_protocol_info_set_dlna_conversion
                                        (info,
                                         g_value_get_flags (value));
                break;
        case PROP_DLNA_OPERATION:
                gupnp_protocol_info_set_dlna_operation
                                        (info,
                                         g_value_get_flags (value));
                break;
        case PROP_DLNA_FLAGS:
                gupnp_protocol_info_set_dlna_flags
                                        (info,
                                         g_value_get_flags (value));
                break;
        default:
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
                break;
        }
}
Example #2
0
/**
 * korva_upnp_host_data_get_protocol_info:
 *
 * Get the UPnP-AV/DLNA protocol info string for the :file. The transport is
 * always "http-get". The ci-param is "0" (original source) and op-param is "01"
 * (byte seek only). If :meta-data contains a DLNA profile it will be added as
 * well as the the file's content type.
 *
 * The function lazy-creates the string when used for the first time.
 *
 * @self: An instance of #KorvaUPnPHostData
 *
 * Returns: (transfer none): A protocol info string.
 */
const char *
korva_upnp_host_data_get_protocol_info (KorvaUPnPHostData *self)
{
    if (self->priv->protocol_info == NULL) {
        GVariant *value;
        const char *dlna_profile;
        GUPnPProtocolInfo *info;

        info = gupnp_protocol_info_new_from_string ("http-get:*:*:DLNA.ORG_CI=0;DLNA.ORG_OP=01", NULL);
        gupnp_protocol_info_set_mime_type (info,
                                           korva_upnp_host_data_get_content_type (self));

        value = g_hash_table_lookup (self->priv->meta_data, "DLNAProfile");
        if (value != NULL) {
            dlna_profile = g_variant_get_string (value, NULL);
            gupnp_protocol_info_set_dlna_profile (info, dlna_profile);
        }

        self->priv->protocol_info = gupnp_protocol_info_to_string (info);
        g_object_unref (info);
    }

    return self->priv->protocol_info;
}
static void
parse_additional_info (const char        *additional_info,
                       GUPnPProtocolInfo *info)
{
        char **tokens = NULL;
        short i;

        if (strcmp (additional_info, "*") == 0)
                return;

        tokens = g_strsplit (additional_info, ";", -1);
        if (tokens == NULL) {
                g_warning ("Invalid additional info in DIDL-Lite info: %s",
                           additional_info);

                return;
        }

        for (i = 0; tokens[i]; i++) {
                char *p;

                p = g_strstr_len (tokens[i],
                                  strlen (tokens[i]),
                                  "DLNA.ORG_PN=");
                if (p != NULL) {
                        p += 12; /* end of "DLNA.ORG_PN=" */
                        gupnp_protocol_info_set_dlna_profile (info, p);

                        continue;
                }

                p = g_strstr_len (tokens[i],
                                  strlen (tokens[i]),
                                  "DLNA.ORG_PS=");
                if (p != NULL) {
                        char **play_speeds;

                        p += 12; /* end of "DLNA.ORG_PS=" */

                        play_speeds = g_strsplit (p, ",", -1);
                        gupnp_protocol_info_set_play_speeds
                                                (info,
                                                 (const char **) play_speeds);
                        g_strfreev (play_speeds);

                        continue;
                }

                p = g_strstr_len (tokens[i],
                                  strlen (tokens[i]),
                                  "DLNA.ORG_CI=");
                if (p != NULL) {
                        p += 12; /* end of "DLNA.ORG_CI=" */

                        gupnp_protocol_info_set_dlna_conversion (info,
                                                                 atoi (p));

                        continue;
                }

                p = g_strstr_len (tokens[i],
                                  strlen (tokens[i]),
                                  "DLNA.ORG_OP=");
                if (p != NULL) {
                        p += 12; /* end of "DLNA.ORG_OP=" */

                        gupnp_protocol_info_set_dlna_operation
                                                        (info,
                                                         strtoul (p, NULL, 16));

                        continue;
                }

                p = g_strstr_len (tokens[i],
                                  strlen (tokens[i]),
                                  "DLNA.ORG_FLAGS=");
                if (p != NULL) {
                        p += 15; /* end of "DLNA.ORG_FLAGS=" */
                        if (strlen (p) > 8)
                                p[8] = '\0';
                        gupnp_protocol_info_set_dlna_flags
                                                        (info,
                                                         strtoul (p, NULL, 16));

                        continue;
                }
        }

        g_strfreev (tokens);
}