/* rygel-media-renderer-plugin.c generated by valac 0.56.19, the Vala compiler
 * generated from rygel-media-renderer-plugin.vala, do not modify */

/*
 * Copyright (C) 2008,2010 Nokia Corporation.
 * Copyright (C) 2012 Intel Corporation.
 *
 * Author: Zeeshan Ali (Khattak) <zeeshanak@gnome.org>
 *                               <zeeshan.ali@nokia.com>
 *
 * This file is part of Rygel.
 *
 * Rygel is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * Rygel is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

#include "rygel-renderer.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include "rygel-core.h"
#include <glib-object.h>
#include "config.h"
#include <libgupnp/gupnp.h>

#define RYGEL_MEDIA_RENDERER_PLUGIN_MEDIA_RENDERER_DESC_PATH DATA_DIR "/xml/MediaRenderer2.xml"
#define RYGEL_MEDIA_RENDERER_PLUGIN_DMR "urn:schemas-upnp-org:device:MediaRenderer"
#define RYGEL_AV_TRANSPORT_UPNP_ID "urn:upnp-org:serviceId:AVTransport"
#define RYGEL_AV_TRANSPORT_UPNP_TYPE "urn:schemas-upnp-org:service:AVTransport:2"
#define RYGEL_AV_TRANSPORT_DESCRIPTION_PATH "xml/AVTransport2.xml"
#define RYGEL_RENDERING_CONTROL_UPNP_ID "urn:upnp-org:serviceId:RenderingControl"
#define RYGEL_RENDERING_CONTROL_UPNP_TYPE "urn:schemas-upnp-org:service:RenderingControl:2"
#define RYGEL_RENDERING_CONTROL_DESCRIPTION_PATH "xml/RenderingControl2.xml"
#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

enum  {
	RYGEL_MEDIA_RENDERER_PLUGIN_0_PROPERTY,
	RYGEL_MEDIA_RENDERER_PLUGIN_SUPPORTED_PROFILES_PROPERTY,
	RYGEL_MEDIA_RENDERER_PLUGIN_NUM_PROPERTIES
};
static GParamSpec* rygel_media_renderer_plugin_properties[RYGEL_MEDIA_RENDERER_PLUGIN_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define RYGEL_TYPE_SINK_CONNECTION_MANAGER (rygel_sink_connection_manager_get_type ())
#define RYGEL_SINK_CONNECTION_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_SINK_CONNECTION_MANAGER, RygelSinkConnectionManager))
#define RYGEL_SINK_CONNECTION_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_SINK_CONNECTION_MANAGER, RygelSinkConnectionManagerClass))
#define RYGEL_IS_SINK_CONNECTION_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_SINK_CONNECTION_MANAGER))
#define RYGEL_IS_SINK_CONNECTION_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_SINK_CONNECTION_MANAGER))
#define RYGEL_SINK_CONNECTION_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_SINK_CONNECTION_MANAGER, RygelSinkConnectionManagerClass))

typedef struct _RygelSinkConnectionManager RygelSinkConnectionManager;
typedef struct _RygelSinkConnectionManagerClass RygelSinkConnectionManagerClass;

#define RYGEL_TYPE_AV_TRANSPORT (rygel_av_transport_get_type ())
#define RYGEL_AV_TRANSPORT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_AV_TRANSPORT, RygelAVTransport))
#define RYGEL_AV_TRANSPORT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_AV_TRANSPORT, RygelAVTransportClass))
#define RYGEL_IS_AV_TRANSPORT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_AV_TRANSPORT))
#define RYGEL_IS_AV_TRANSPORT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_AV_TRANSPORT))
#define RYGEL_AV_TRANSPORT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_AV_TRANSPORT, RygelAVTransportClass))

typedef struct _RygelAVTransport RygelAVTransport;
typedef struct _RygelAVTransportClass RygelAVTransportClass;
#define _rygel_resource_info_unref0(var) ((var == NULL) ? NULL : (var = (rygel_resource_info_unref (var), NULL)))

#define RYGEL_TYPE_RENDERING_CONTROL (rygel_rendering_control_get_type ())
#define RYGEL_RENDERING_CONTROL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_RENDERING_CONTROL, RygelRenderingControl))
#define RYGEL_RENDERING_CONTROL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_RENDERING_CONTROL, RygelRenderingControlClass))
#define RYGEL_IS_RENDERING_CONTROL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_RENDERING_CONTROL))
#define RYGEL_IS_RENDERING_CONTROL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_RENDERING_CONTROL))
#define RYGEL_RENDERING_CONTROL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_RENDERING_CONTROL, RygelRenderingControlClass))

typedef struct _RygelRenderingControl RygelRenderingControl;
typedef struct _RygelRenderingControlClass RygelRenderingControlClass;

#define RYGEL_TYPE_DEFAULT_PLAYER_CONTROLLER (rygel_default_player_controller_get_type ())
#define RYGEL_DEFAULT_PLAYER_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_DEFAULT_PLAYER_CONTROLLER, RygelDefaultPlayerController))
#define RYGEL_DEFAULT_PLAYER_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_DEFAULT_PLAYER_CONTROLLER, RygelDefaultPlayerControllerClass))
#define RYGEL_IS_DEFAULT_PLAYER_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_DEFAULT_PLAYER_CONTROLLER))
#define RYGEL_IS_DEFAULT_PLAYER_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_DEFAULT_PLAYER_CONTROLLER))
#define RYGEL_DEFAULT_PLAYER_CONTROLLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_DEFAULT_PLAYER_CONTROLLER, RygelDefaultPlayerControllerClass))

typedef struct _RygelDefaultPlayerController RygelDefaultPlayerController;
typedef struct _RygelDefaultPlayerControllerClass RygelDefaultPlayerControllerClass;
#define _rygel_dlna_profile_unref0(var) ((var == NULL) ? NULL : (var = (rygel_dlna_profile_unref (var), NULL)))

struct _RygelMediaRendererPluginPrivate {
	gchar* sink_protocol_info;
	RygelPlayerController* controller;
	GList* _supported_profiles;
};

static gint RygelMediaRendererPlugin_private_offset;
static gpointer rygel_media_renderer_plugin_parent_class = NULL;

VALA_EXTERN RygelPlayerController* rygel_media_renderer_plugin_get_controller (RygelMediaRendererPlugin* self);
static void _rygel_dlna_profile_unref0_ (gpointer var);
static inline void _g_list_free__rygel_dlna_profile_unref0_ (GList* self);
static void rygel_media_renderer_plugin_real_constructed (GObject* base);
VALA_EXTERN GType rygel_sink_connection_manager_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType rygel_av_transport_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType rygel_rendering_control_get_type (void) G_GNUC_CONST ;
static RygelMediaPlayer* rygel_media_renderer_plugin_real_get_player (RygelMediaRendererPlugin* self);
static RygelPlayerController* rygel_media_renderer_plugin_real_get_controller (RygelMediaRendererPlugin* self);
VALA_EXTERN RygelDefaultPlayerController* rygel_default_player_controller_new (RygelMediaPlayer* player,
                                                                   const gchar* protocol_info);
VALA_EXTERN RygelDefaultPlayerController* rygel_default_player_controller_construct (GType object_type,
                                                                         RygelMediaPlayer* player,
                                                                         const gchar* protocol_info);
VALA_EXTERN GType rygel_default_player_controller_get_type (void) G_GNUC_CONST ;
static void rygel_media_renderer_plugin_real_apply_hacks (RygelPlugin* base,
                                                   RygelRootDevice* device,
                                                   const gchar* description_path,
                                                   GError** error);
static void _vala_array_add1 (gchar** * array,
                       gint* length,
                       gint* size,
                       gchar* value);
static void _vala_array_add2 (gchar** * array,
                       gint* length,
                       gint* size,
                       gchar* value);
static void _vala_array_add3 (gchar** * array,
                       gint* length,
                       gint* size,
                       gchar* value);
static void _vala_array_add4 (gchar** * array,
                       gint* length,
                       gint* size,
                       gchar* value);
static void rygel_media_renderer_plugin_finalize (GObject * obj);
static GType rygel_media_renderer_plugin_get_type_once (void);
static void _vala_rygel_media_renderer_plugin_get_property (GObject * object,
                                                     guint property_id,
                                                     GValue * value,
                                                     GParamSpec * pspec);
static void _vala_rygel_media_renderer_plugin_set_property (GObject * object,
                                                     guint property_id,
                                                     const GValue * value,
                                                     GParamSpec * pspec);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);

static inline gpointer
rygel_media_renderer_plugin_get_instance_private (RygelMediaRendererPlugin* self)
{
	return G_STRUCT_MEMBER_P (self, RygelMediaRendererPlugin_private_offset);
}

static void
_rygel_dlna_profile_unref0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (rygel_dlna_profile_unref (var), NULL));
}

static inline void
_g_list_free__rygel_dlna_profile_unref0_ (GList* self)
{
	g_list_free_full (self, (GDestroyNotify) _rygel_dlna_profile_unref0_);
}

/**
     * Create an instance of the plugin.
     *
     * @param name The non-human-readable name for the plugin and its renderer, used in UPnP messages and in the Rygel configuration file.
     * @param title An optional human-readable name (friendlyName) of the UPnP renderer provided by the plugin. If the title is empty then the name will be used.
     * @param description An optional human-readable description (modelDescription) of the UPnP renderer provided by the plugin.
     */
RygelMediaRendererPlugin*
rygel_media_renderer_plugin_construct (GType object_type,
                                       const gchar* name,
                                       const gchar* title,
                                       const gchar* description,
                                       RygelPluginCapabilities capabilities)
{
	RygelMediaRendererPlugin * self = NULL;
	g_return_val_if_fail (name != NULL, NULL);
	self = (RygelMediaRendererPlugin*) g_object_new (object_type, "desc-path", RYGEL_MEDIA_RENDERER_PLUGIN_MEDIA_RENDERER_DESC_PATH, "name", name, "title", title, "description", description, "capabilities", capabilities, NULL);
	return self;
}

RygelMediaRendererPlugin*
rygel_media_renderer_plugin_new (const gchar* name,
                                 const gchar* title,
                                 const gchar* description,
                                 RygelPluginCapabilities capabilities)
{
	return rygel_media_renderer_plugin_construct (RYGEL_TYPE_MEDIA_RENDERER_PLUGIN, name, title, description, capabilities);
}

static void
rygel_media_renderer_plugin_real_constructed (GObject* base)
{
	RygelMediaRendererPlugin * self;
	RygelResourceInfo* resource = NULL;
	RygelResourceInfo* _tmp0_;
	RygelResourceInfo* _tmp1_;
	RygelResourceInfo* _tmp2_;
	RygelResourceInfo* _tmp3_;
	RygelResourceInfo* _tmp4_;
	RygelResourceInfo* _tmp5_;
	self = (RygelMediaRendererPlugin*) base;
	G_OBJECT_CLASS (rygel_media_renderer_plugin_parent_class)->constructed ((GObject*) G_TYPE_CHECK_INSTANCE_CAST (self, RYGEL_TYPE_PLUGIN, RygelPlugin));
	_tmp0_ = rygel_resource_info_new (RYGEL_CONNECTION_MANAGER_UPNP_ID, RYGEL_CONNECTION_MANAGER_UPNP_TYPE, RYGEL_CONNECTION_MANAGER_DESCRIPTION_PATH, RYGEL_TYPE_SINK_CONNECTION_MANAGER);
	resource = _tmp0_;
	_tmp1_ = resource;
	rygel_plugin_add_resource ((RygelPlugin*) self, _tmp1_);
	_tmp2_ = rygel_resource_info_new (RYGEL_AV_TRANSPORT_UPNP_ID, RYGEL_AV_TRANSPORT_UPNP_TYPE, RYGEL_AV_TRANSPORT_DESCRIPTION_PATH, RYGEL_TYPE_AV_TRANSPORT);
	_rygel_resource_info_unref0 (resource);
	resource = _tmp2_;
	_tmp3_ = resource;
	rygel_plugin_add_resource ((RygelPlugin*) self, _tmp3_);
	_tmp4_ = rygel_resource_info_new (RYGEL_RENDERING_CONTROL_UPNP_ID, RYGEL_RENDERING_CONTROL_UPNP_TYPE, RYGEL_RENDERING_CONTROL_DESCRIPTION_PATH, RYGEL_TYPE_RENDERING_CONTROL);
	_rygel_resource_info_unref0 (resource);
	resource = _tmp4_;
	_tmp5_ = resource;
	rygel_plugin_add_resource ((RygelPlugin*) self, _tmp5_);
	_rygel_resource_info_unref0 (resource);
}

static RygelMediaPlayer*
rygel_media_renderer_plugin_real_get_player (RygelMediaRendererPlugin* self)
{
	RygelMediaPlayer* result;
	result = NULL;
	return result;
}

RygelMediaPlayer*
rygel_media_renderer_plugin_get_player (RygelMediaRendererPlugin* self)
{
	RygelMediaRendererPluginClass* _klass_;
	g_return_val_if_fail (self != NULL, NULL);
	_klass_ = RYGEL_MEDIA_RENDERER_PLUGIN_GET_CLASS (self);
	if (_klass_->get_player) {
		return _klass_->get_player (self);
	}
	return NULL;
}

static gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

static RygelPlayerController*
rygel_media_renderer_plugin_real_get_controller (RygelMediaRendererPlugin* self)
{
	RygelPlayerController* _tmp0_;
	RygelPlayerController* _tmp6_;
	RygelPlayerController* _tmp7_;
	RygelPlayerController* result;
	_tmp0_ = self->priv->controller;
	if (_tmp0_ == NULL) {
		RygelMediaPlayer* _tmp1_;
		RygelMediaPlayer* _tmp2_;
		gchar* _tmp3_;
		gchar* _tmp4_;
		RygelDefaultPlayerController* _tmp5_;
		_tmp1_ = rygel_media_renderer_plugin_get_player (self);
		_tmp2_ = _tmp1_;
		_tmp3_ = rygel_media_renderer_plugin_get_protocol_info (self);
		_tmp4_ = _tmp3_;
		_tmp5_ = rygel_default_player_controller_new (_tmp2_, _tmp4_);
		_g_object_unref0 (self->priv->controller);
		self->priv->controller = (RygelPlayerController*) _tmp5_;
		_g_free0 (_tmp4_);
		_g_object_unref0 (_tmp2_);
	}
	_tmp6_ = self->priv->controller;
	_tmp7_ = _g_object_ref0 (_tmp6_);
	result = _tmp7_;
	return result;
}

RygelPlayerController*
rygel_media_renderer_plugin_get_controller (RygelMediaRendererPlugin* self)
{
	RygelMediaRendererPluginClass* _klass_;
	g_return_val_if_fail (self != NULL, NULL);
	_klass_ = RYGEL_MEDIA_RENDERER_PLUGIN_GET_CLASS (self);
	if (_klass_->get_controller) {
		return _klass_->get_controller (self);
	}
	return NULL;
}

static void
rygel_media_renderer_plugin_real_apply_hacks (RygelPlugin* base,
                                              RygelRootDevice* device,
                                              const gchar* description_path,
                                              GError** error)
{
	RygelMediaRendererPlugin * self;
	gchar** services = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar** _tmp3_;
	gint services_length1;
	gint _services_size_;
	RygelV1Hacks* v1_hacks = NULL;
	gchar** _tmp4_;
	gint _tmp4__length1;
	RygelV1Hacks* _tmp5_;
	RygelV1Hacks* _tmp6_;
	RygelDlna150Hacks* dlna150_hacks = NULL;
	RygelDlna150Hacks* _tmp7_;
	RygelDlna150Hacks* _tmp8_;
	RygelV1Hacks* _tmp9_;
	const gchar* _tmp10_;
	GError* _inner_error0_ = NULL;
	self = (RygelMediaRendererPlugin*) base;
	g_return_if_fail (device != NULL);
	g_return_if_fail (description_path != NULL);
	_tmp0_ = g_strdup (RYGEL_AV_TRANSPORT_UPNP_TYPE);
	_tmp1_ = g_strdup (RYGEL_RENDERING_CONTROL_UPNP_TYPE);
	_tmp2_ = g_strdup (RYGEL_CONNECTION_MANAGER_UPNP_TYPE);
	_tmp3_ = g_new0 (gchar*, 3 + 1);
	_tmp3_[0] = _tmp0_;
	_tmp3_[1] = _tmp1_;
	_tmp3_[2] = _tmp2_;
	services = _tmp3_;
	services_length1 = 3;
	_services_size_ = services_length1;
	_tmp4_ = services;
	_tmp4__length1 = services_length1;
	_tmp5_ = rygel_v1_hacks_new (RYGEL_MEDIA_RENDERER_PLUGIN_DMR, _tmp4_, _tmp4__length1);
	v1_hacks = _tmp5_;
	_tmp6_ = v1_hacks;
	rygel_v1_hacks_apply_on_device (_tmp6_, device, description_path, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (v1_hacks);
		services = (_vala_array_free (services, services_length1, (GDestroyNotify) g_free), NULL);
		return;
	}
	_tmp7_ = rygel_dlna150_hacks_new ();
	dlna150_hacks = _tmp7_;
	_tmp8_ = dlna150_hacks;
	_tmp9_ = v1_hacks;
	_tmp10_ = _tmp9_->description_path;
	rygel_dlna150_hacks_apply_on_device (_tmp8_, device, _tmp10_, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (dlna150_hacks);
		_g_object_unref0 (v1_hacks);
		services = (_vala_array_free (services, services_length1, (GDestroyNotify) g_free), NULL);
		return;
	}
	_g_object_unref0 (dlna150_hacks);
	_g_object_unref0 (v1_hacks);
	services = (_vala_array_free (services, services_length1, (GDestroyNotify) g_free), NULL);
}

static gpointer
_rygel_dlna_profile_ref0 (gpointer self)
{
	return self ? rygel_dlna_profile_ref (self) : NULL;
}

static void
_vala_array_add1 (gchar** * array,
                  gint* length,
                  gint* size,
                  gchar* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gchar*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add2 (gchar** * array,
                  gint* length,
                  gint* size,
                  gchar* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gchar*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add3 (gchar** * array,
                  gint* length,
                  gint* size,
                  gchar* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gchar*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add4 (gchar** * array,
                  gint* length,
                  gint* size,
                  gchar* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gchar*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

gchar*
rygel_media_renderer_plugin_get_protocol_info (RygelMediaRendererPlugin* self)
{
	RygelMediaPlayer* player = NULL;
	RygelMediaPlayer* _tmp0_;
	RygelMediaPlayer* _tmp1_;
	const gchar* _tmp3_;
	const gchar* _tmp72_;
	gchar* _tmp73_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = rygel_media_renderer_plugin_get_player (self);
	player = _tmp0_;
	_tmp1_ = player;
	if (_tmp1_ == NULL) {
		gchar* _tmp2_;
		_tmp2_ = g_strdup ("");
		result = _tmp2_;
		_g_object_unref0 (player);
		return result;
	}
	_tmp3_ = self->priv->sink_protocol_info;
	if (_tmp3_ == NULL) {
		gchar* _tmp4_;
		gchar** protocols = NULL;
		RygelMediaPlayer* _tmp5_;
		gint _tmp6_ = 0;
		gchar** _tmp7_;
		gint protocols_length1;
		gint _protocols_size_;
		gchar** _tmp8_;
		gint _tmp8__length1;
		gchar** mime_types = NULL;
		RygelMediaPlayer* _tmp39_;
		gint _tmp40_ = 0;
		gchar** _tmp41_;
		gint mime_types_length1;
		gint _mime_types_size_;
		gchar* _tmp42_;
		gchar* _tmp43_;
		gchar* _tmp44_;
		gchar* _tmp45_;
		gchar** _tmp46_;
		gint _tmp46__length1;
		_tmp4_ = g_strdup ("");
		_g_free0 (self->priv->sink_protocol_info);
		self->priv->sink_protocol_info = _tmp4_;
		_tmp5_ = player;
		_tmp7_ = rygel_media_player_get_protocols (_tmp5_, &_tmp6_);
		protocols = _tmp7_;
		protocols_length1 = _tmp6_;
		_protocols_size_ = protocols_length1;
		_tmp8_ = protocols;
		_tmp8__length1 = protocols_length1;
		{
			gchar** protocol_collection = NULL;
			gint protocol_collection_length1 = 0;
			gint _protocol_collection_size_ = 0;
			gint protocol_it = 0;
			protocol_collection = _tmp8_;
			protocol_collection_length1 = _tmp8__length1;
			for (protocol_it = 0; protocol_it < protocol_collection_length1; protocol_it = protocol_it + 1) {
				gchar* _tmp9_;
				gchar* protocol = NULL;
				_tmp9_ = g_strdup (protocol_collection[protocol_it]);
				protocol = _tmp9_;
				{
					gchar** _tmp10_;
					gint _tmp10__length1;
					const gchar* _tmp11_;
					const gchar* _tmp12_;
					GList* _tmp15_;
					GList* _tmp16_;
					_tmp10_ = protocols;
					_tmp10__length1 = protocols_length1;
					_tmp11_ = _tmp10_[0];
					_tmp12_ = protocol;
					if (g_strcmp0 (_tmp11_, _tmp12_) != 0) {
						const gchar* _tmp13_;
						gchar* _tmp14_;
						_tmp13_ = self->priv->sink_protocol_info;
						_tmp14_ = g_strconcat (_tmp13_, ",", NULL);
						_g_free0 (self->priv->sink_protocol_info);
						self->priv->sink_protocol_info = _tmp14_;
					}
					_tmp15_ = rygel_media_renderer_plugin_get_supported_profiles (self);
					_tmp16_ = _tmp15_;
					{
						GList* profile_collection = NULL;
						GList* profile_it = NULL;
						profile_collection = _tmp16_;
						for (profile_it = profile_collection; profile_it != NULL; profile_it = profile_it->next) {
							RygelDLNAProfile* _tmp17_;
							RygelDLNAProfile* profile = NULL;
							_tmp17_ = _rygel_dlna_profile_ref0 ((RygelDLNAProfile*) profile_it->data);
							profile = _tmp17_;
							{
								GList* _tmp18_;
								GList* _tmp19_;
								gconstpointer _tmp20_;
								RygelDLNAProfile* _tmp21_;
								const gchar* _tmp24_;
								const gchar* _tmp25_;
								gchar* _tmp26_;
								gchar* _tmp27_;
								RygelDLNAProfile* _tmp28_;
								const gchar* _tmp29_;
								gchar* _tmp30_;
								gchar* _tmp31_;
								gchar* _tmp32_;
								gchar* _tmp33_;
								RygelDLNAProfile* _tmp34_;
								const gchar* _tmp35_;
								gchar* _tmp36_;
								gchar* _tmp37_;
								gchar* _tmp38_;
								_tmp18_ = rygel_media_renderer_plugin_get_supported_profiles (self);
								_tmp19_ = _tmp18_;
								_tmp20_ = _tmp19_->data;
								_tmp21_ = profile;
								if (((RygelDLNAProfile*) _tmp20_) != _tmp21_) {
									const gchar* _tmp22_;
									gchar* _tmp23_;
									_tmp22_ = self->priv->sink_protocol_info;
									_tmp23_ = g_strconcat (_tmp22_, ",", NULL);
									_g_free0 (self->priv->sink_protocol_info);
									self->priv->sink_protocol_info = _tmp23_;
								}
								_tmp24_ = self->priv->sink_protocol_info;
								_tmp25_ = protocol;
								_tmp26_ = g_strconcat (_tmp25_, ":*:", NULL);
								_tmp27_ = _tmp26_;
								_tmp28_ = profile;
								_tmp29_ = _tmp28_->mime;
								_tmp30_ = g_strconcat (_tmp27_, _tmp29_, NULL);
								_tmp31_ = _tmp30_;
								_tmp32_ = g_strconcat (_tmp31_, ":DLNA.ORG_PN=", NULL);
								_tmp33_ = _tmp32_;
								_tmp34_ = profile;
								_tmp35_ = _tmp34_->name;
								_tmp36_ = g_strconcat (_tmp33_, _tmp35_, NULL);
								_tmp37_ = _tmp36_;
								_tmp38_ = g_strconcat (_tmp24_, _tmp37_, NULL);
								_g_free0 (self->priv->sink_protocol_info);
								self->priv->sink_protocol_info = _tmp38_;
								_g_free0 (_tmp37_);
								_g_free0 (_tmp33_);
								_g_free0 (_tmp31_);
								_g_free0 (_tmp27_);
								_rygel_dlna_profile_unref0 (profile);
							}
						}
					}
					_g_free0 (protocol);
				}
			}
		}
		_tmp39_ = player;
		_tmp41_ = rygel_media_player_get_mime_types (_tmp39_, &_tmp40_);
		mime_types = _tmp41_;
		mime_types_length1 = _tmp40_;
		_mime_types_size_ = mime_types_length1;
		_tmp42_ = g_strdup ("audio/mpegurl");
		_vala_array_add1 (&mime_types, &mime_types_length1, &_mime_types_size_, _tmp42_);
		_tmp43_ = g_strdup ("audio/x-mpegurl");
		_vala_array_add2 (&mime_types, &mime_types_length1, &_mime_types_size_, _tmp43_);
		_tmp44_ = g_strdup ("video/mpegurl");
		_vala_array_add3 (&mime_types, &mime_types_length1, &_mime_types_size_, _tmp44_);
		_tmp45_ = g_strdup ("video/x-mpegurl");
		_vala_array_add4 (&mime_types, &mime_types_length1, &_mime_types_size_, _tmp45_);
		_tmp46_ = protocols;
		_tmp46__length1 = protocols_length1;
		{
			gchar** protocol_collection = NULL;
			gint protocol_collection_length1 = 0;
			gint _protocol_collection_size_ = 0;
			gint protocol_it = 0;
			protocol_collection = _tmp46_;
			protocol_collection_length1 = _tmp46__length1;
			for (protocol_it = 0; protocol_it < protocol_collection_length1; protocol_it = protocol_it + 1) {
				gchar* _tmp47_;
				gchar* protocol = NULL;
				_tmp47_ = g_strdup (protocol_collection[protocol_it]);
				protocol = _tmp47_;
				{
					gboolean _tmp48_ = FALSE;
					gchar** _tmp49_;
					gint _tmp49__length1;
					const gchar* _tmp50_;
					const gchar* _tmp51_;
					gchar** _tmp55_;
					gint _tmp55__length1;
					_tmp49_ = protocols;
					_tmp49__length1 = protocols_length1;
					_tmp50_ = _tmp49_[0];
					_tmp51_ = protocol;
					if (g_strcmp0 (_tmp50_, _tmp51_) != 0) {
						_tmp48_ = TRUE;
					} else {
						const gchar* _tmp52_;
						_tmp52_ = self->priv->sink_protocol_info;
						_tmp48_ = g_strcmp0 (_tmp52_, "") != 0;
					}
					if (_tmp48_) {
						const gchar* _tmp53_;
						gchar* _tmp54_;
						_tmp53_ = self->priv->sink_protocol_info;
						_tmp54_ = g_strconcat (_tmp53_, ",", NULL);
						_g_free0 (self->priv->sink_protocol_info);
						self->priv->sink_protocol_info = _tmp54_;
					}
					_tmp55_ = mime_types;
					_tmp55__length1 = mime_types_length1;
					{
						gchar** mime_type_collection = NULL;
						gint mime_type_collection_length1 = 0;
						gint _mime_type_collection_size_ = 0;
						gint mime_type_it = 0;
						mime_type_collection = _tmp55_;
						mime_type_collection_length1 = _tmp55__length1;
						for (mime_type_it = 0; mime_type_it < mime_type_collection_length1; mime_type_it = mime_type_it + 1) {
							gchar* _tmp56_;
							gchar* mime_type = NULL;
							_tmp56_ = g_strdup (mime_type_collection[mime_type_it]);
							mime_type = _tmp56_;
							{
								gchar** _tmp57_;
								gint _tmp57__length1;
								const gchar* _tmp58_;
								const gchar* _tmp59_;
								const gchar* _tmp62_;
								const gchar* _tmp63_;
								gchar* _tmp64_;
								gchar* _tmp65_;
								const gchar* _tmp66_;
								gchar* _tmp67_;
								gchar* _tmp68_;
								gchar* _tmp69_;
								gchar* _tmp70_;
								gchar* _tmp71_;
								_tmp57_ = mime_types;
								_tmp57__length1 = mime_types_length1;
								_tmp58_ = _tmp57_[0];
								_tmp59_ = mime_type;
								if (g_strcmp0 (_tmp58_, _tmp59_) != 0) {
									const gchar* _tmp60_;
									gchar* _tmp61_;
									_tmp60_ = self->priv->sink_protocol_info;
									_tmp61_ = g_strconcat (_tmp60_, ",", NULL);
									_g_free0 (self->priv->sink_protocol_info);
									self->priv->sink_protocol_info = _tmp61_;
								}
								_tmp62_ = self->priv->sink_protocol_info;
								_tmp63_ = protocol;
								_tmp64_ = g_strconcat (_tmp63_, ":*:", NULL);
								_tmp65_ = _tmp64_;
								_tmp66_ = mime_type;
								_tmp67_ = g_strconcat (_tmp65_, _tmp66_, NULL);
								_tmp68_ = _tmp67_;
								_tmp69_ = g_strconcat (_tmp68_, ":*", NULL);
								_tmp70_ = _tmp69_;
								_tmp71_ = g_strconcat (_tmp62_, _tmp70_, NULL);
								_g_free0 (self->priv->sink_protocol_info);
								self->priv->sink_protocol_info = _tmp71_;
								_g_free0 (_tmp70_);
								_g_free0 (_tmp68_);
								_g_free0 (_tmp65_);
								_g_free0 (mime_type);
							}
						}
					}
					_g_free0 (protocol);
				}
			}
		}
		mime_types = (_vala_array_free (mime_types, mime_types_length1, (GDestroyNotify) g_free), NULL);
		protocols = (_vala_array_free (protocols, protocols_length1, (GDestroyNotify) g_free), NULL);
	}
	_tmp72_ = self->priv->sink_protocol_info;
	_tmp73_ = g_strdup (_tmp72_);
	result = _tmp73_;
	_g_object_unref0 (player);
	return result;
}

GList*
rygel_media_renderer_plugin_get_supported_profiles (RygelMediaRendererPlugin* self)
{
	GList* result;
	GList* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_supported_profiles;
	result = _tmp0_;
	return result;
}

void
rygel_media_renderer_plugin_set_supported_profiles (RygelMediaRendererPlugin* self,
                                                    GList* value)
{
	g_return_if_fail (self != NULL);
	(self->priv->_supported_profiles == NULL) ? NULL : (self->priv->_supported_profiles = (_g_list_free__rygel_dlna_profile_unref0_ (self->priv->_supported_profiles), NULL));
	self->priv->_supported_profiles = NULL;
	if (value != NULL) {
		RygelDLNAProfile* _tmp3_;
		{
			GList* profile_collection = NULL;
			GList* profile_it = NULL;
			profile_collection = value;
			for (profile_it = profile_collection; profile_it != NULL; profile_it = profile_it->next) {
				RygelDLNAProfile* _tmp0_;
				RygelDLNAProfile* profile = NULL;
				_tmp0_ = _rygel_dlna_profile_ref0 ((RygelDLNAProfile*) profile_it->data);
				profile = _tmp0_;
				{
					RygelDLNAProfile* _tmp1_;
					RygelDLNAProfile* _tmp2_;
					_tmp1_ = profile;
					_tmp2_ = _rygel_dlna_profile_ref0 (_tmp1_);
					self->priv->_supported_profiles = g_list_prepend (self->priv->_supported_profiles, _tmp2_);
					_rygel_dlna_profile_unref0 (profile);
				}
			}
		}
		_tmp3_ = rygel_dlna_profile_new ("DIDL_S", "text/xml");
		self->priv->_supported_profiles = g_list_prepend (self->priv->_supported_profiles, _tmp3_);
		self->priv->_supported_profiles = g_list_reverse (self->priv->_supported_profiles);
	}
	g_object_notify_by_pspec ((GObject *) self, rygel_media_renderer_plugin_properties[RYGEL_MEDIA_RENDERER_PLUGIN_SUPPORTED_PROFILES_PROPERTY]);
}

static void
rygel_media_renderer_plugin_class_init (RygelMediaRendererPluginClass * klass,
                                        gpointer klass_data)
{
	rygel_media_renderer_plugin_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &RygelMediaRendererPlugin_private_offset);
	((GObjectClass *) klass)->constructed = (void (*) (GObject*)) rygel_media_renderer_plugin_real_constructed;
	((RygelMediaRendererPluginClass *) klass)->get_player = (RygelMediaPlayer* (*) (RygelMediaRendererPlugin*)) rygel_media_renderer_plugin_real_get_player;
	((RygelMediaRendererPluginClass *) klass)->get_controller = (RygelPlayerController* (*) (RygelMediaRendererPlugin*)) rygel_media_renderer_plugin_real_get_controller;
	((RygelPluginClass *) klass)->apply_hacks = (void (*) (RygelPlugin*, RygelRootDevice*, const gchar*, GError**)) rygel_media_renderer_plugin_real_apply_hacks;
	G_OBJECT_CLASS (klass)->get_property = _vala_rygel_media_renderer_plugin_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_rygel_media_renderer_plugin_set_property;
	G_OBJECT_CLASS (klass)->finalize = rygel_media_renderer_plugin_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), RYGEL_MEDIA_RENDERER_PLUGIN_SUPPORTED_PROFILES_PROPERTY, rygel_media_renderer_plugin_properties[RYGEL_MEDIA_RENDERER_PLUGIN_SUPPORTED_PROFILES_PROPERTY] = g_param_spec_pointer ("supported-profiles", "supported-profiles", "supported-profiles", G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
}

static void
rygel_media_renderer_plugin_instance_init (RygelMediaRendererPlugin * self,
                                           gpointer klass)
{
	self->priv = rygel_media_renderer_plugin_get_instance_private (self);
}

static void
rygel_media_renderer_plugin_finalize (GObject * obj)
{
	RygelMediaRendererPlugin * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_TYPE_MEDIA_RENDERER_PLUGIN, RygelMediaRendererPlugin);
	_g_free0 (self->priv->sink_protocol_info);
	_g_object_unref0 (self->priv->controller);
	(self->priv->_supported_profiles == NULL) ? NULL : (self->priv->_supported_profiles = (_g_list_free__rygel_dlna_profile_unref0_ (self->priv->_supported_profiles), NULL));
	G_OBJECT_CLASS (rygel_media_renderer_plugin_parent_class)->finalize (obj);
}

/**
 * This is the base class for every Rygel UPnP renderer plugin.
 *
 * This class is useful when implementing Rygel renderer plugins.
 *
 * Renderer plugins should also implement their own #RygelMediaPlayer
 * and return an instance of it from their get_player() implementation.
 */
 G_GNUC_NO_INLINE static GType
rygel_media_renderer_plugin_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (RygelMediaRendererPluginClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rygel_media_renderer_plugin_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RygelMediaRendererPlugin), 0, (GInstanceInitFunc) rygel_media_renderer_plugin_instance_init, NULL };
	GType rygel_media_renderer_plugin_type_id;
	rygel_media_renderer_plugin_type_id = g_type_register_static (RYGEL_TYPE_PLUGIN, "RygelMediaRendererPlugin", &g_define_type_info, 0);
	RygelMediaRendererPlugin_private_offset = g_type_add_instance_private (rygel_media_renderer_plugin_type_id, sizeof (RygelMediaRendererPluginPrivate));
	return rygel_media_renderer_plugin_type_id;
}

GType
rygel_media_renderer_plugin_get_type (void)
{
	static volatile gsize rygel_media_renderer_plugin_type_id__once = 0;
	if (g_once_init_enter (&rygel_media_renderer_plugin_type_id__once)) {
		GType rygel_media_renderer_plugin_type_id;
		rygel_media_renderer_plugin_type_id = rygel_media_renderer_plugin_get_type_once ();
		g_once_init_leave (&rygel_media_renderer_plugin_type_id__once, rygel_media_renderer_plugin_type_id);
	}
	return rygel_media_renderer_plugin_type_id__once;
}

static void
_vala_rygel_media_renderer_plugin_get_property (GObject * object,
                                                guint property_id,
                                                GValue * value,
                                                GParamSpec * pspec)
{
	RygelMediaRendererPlugin * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, RYGEL_TYPE_MEDIA_RENDERER_PLUGIN, RygelMediaRendererPlugin);
	switch (property_id) {
		case RYGEL_MEDIA_RENDERER_PLUGIN_SUPPORTED_PROFILES_PROPERTY:
		g_value_set_pointer (value, rygel_media_renderer_plugin_get_supported_profiles (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_rygel_media_renderer_plugin_set_property (GObject * object,
                                                guint property_id,
                                                const GValue * value,
                                                GParamSpec * pspec)
{
	RygelMediaRendererPlugin * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, RYGEL_TYPE_MEDIA_RENDERER_PLUGIN, RygelMediaRendererPlugin);
	switch (property_id) {
		case RYGEL_MEDIA_RENDERER_PLUGIN_SUPPORTED_PROFILES_PROPERTY:
		rygel_media_renderer_plugin_set_supported_profiles (self, g_value_get_pointer (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

