/* rygel-sink-connection-manager.c generated by valac 0.24.0.112-bbf5, the Vala compiler
 * generated from rygel-sink-connection-manager.vala, do not modify */

/*
 * Copyright (C) 2008 OpenedHand Ltd.
 * Copyright (C) 2009 Nokia Corporation.
 *
 * Author: Jorn Baayen <jorn@openedhand.com>
 *         Zeeshan Ali (Khattak) <zeeshanak@gnome.org>
 *                               <zeeshan.ali@nokia.com>
 *
 * 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 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 program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

#include <glib.h>
#include <glib-object.h>
#include <rygel-core.h>
#include <libgupnp/gupnp.h>
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include <math.h>


#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;
typedef struct _RygelSinkConnectionManagerPrivate RygelSinkConnectionManagerPrivate;
#define _g_free0(var) (var = (g_free (var), NULL))

#define RYGEL_TYPE_MEDIA_RENDERER_PLUGIN (rygel_media_renderer_plugin_get_type ())
#define RYGEL_MEDIA_RENDERER_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_MEDIA_RENDERER_PLUGIN, RygelMediaRendererPlugin))
#define RYGEL_MEDIA_RENDERER_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_MEDIA_RENDERER_PLUGIN, RygelMediaRendererPluginClass))
#define RYGEL_IS_MEDIA_RENDERER_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_MEDIA_RENDERER_PLUGIN))
#define RYGEL_IS_MEDIA_RENDERER_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_MEDIA_RENDERER_PLUGIN))
#define RYGEL_MEDIA_RENDERER_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_MEDIA_RENDERER_PLUGIN, RygelMediaRendererPluginClass))

typedef struct _RygelMediaRendererPlugin RygelMediaRendererPlugin;
typedef struct _RygelMediaRendererPluginClass RygelMediaRendererPluginClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define RYGEL_TYPE_MEDIA_PLAYER (rygel_media_player_get_type ())
#define RYGEL_MEDIA_PLAYER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_MEDIA_PLAYER, RygelMediaPlayer))
#define RYGEL_IS_MEDIA_PLAYER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_MEDIA_PLAYER))
#define RYGEL_MEDIA_PLAYER_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), RYGEL_TYPE_MEDIA_PLAYER, RygelMediaPlayerIface))

typedef struct _RygelMediaPlayer RygelMediaPlayer;
typedef struct _RygelMediaPlayerIface RygelMediaPlayerIface;

struct _RygelSinkConnectionManager {
	RygelConnectionManager parent_instance;
	RygelSinkConnectionManagerPrivate * priv;
};

struct _RygelSinkConnectionManagerClass {
	RygelConnectionManagerClass parent_class;
};

struct _RygelMediaPlayerIface {
	GTypeInterface parent_iface;
	gboolean (*seek) (RygelMediaPlayer* self, gint64 time);
	gboolean (*seek_bytes) (RygelMediaPlayer* self, gint64 bytes);
	gchar** (*get_protocols) (RygelMediaPlayer* self, int* result_length1);
	gchar** (*get_mime_types) (RygelMediaPlayer* self, int* result_length1);
	gchar* (*get_playback_state) (RygelMediaPlayer* self);
	void (*set_playback_state) (RygelMediaPlayer* self, const gchar* value);
	gchar** (*get_allowed_playback_speeds) (RygelMediaPlayer* self, int* result_length1);
	gchar* (*get_playback_speed) (RygelMediaPlayer* self);
	void (*set_playback_speed) (RygelMediaPlayer* self, const gchar* value);
	gchar* (*get_uri) (RygelMediaPlayer* self);
	void (*set_uri) (RygelMediaPlayer* self, const gchar* value);
	gdouble (*get_volume) (RygelMediaPlayer* self);
	void (*set_volume) (RygelMediaPlayer* self, gdouble value);
	gint64 (*get_duration) (RygelMediaPlayer* self);
	gint64 (*get_size) (RygelMediaPlayer* self);
	gchar* (*get_metadata) (RygelMediaPlayer* self);
	void (*set_metadata) (RygelMediaPlayer* self, const gchar* value);
	gchar* (*get_mime_type) (RygelMediaPlayer* self);
	void (*set_mime_type) (RygelMediaPlayer* self, const gchar* value);
	gboolean (*get_can_seek) (RygelMediaPlayer* self);
	gboolean (*get_can_seek_bytes) (RygelMediaPlayer* self);
	gchar* (*get_content_features) (RygelMediaPlayer* self);
	void (*set_content_features) (RygelMediaPlayer* self, const gchar* value);
	gint64 (*get_position) (RygelMediaPlayer* self);
	gint64 (*get_byte_position) (RygelMediaPlayer* self);
};


static gpointer rygel_sink_connection_manager_parent_class = NULL;

GType rygel_sink_connection_manager_get_type (void) G_GNUC_CONST;
enum  {
	RYGEL_SINK_CONNECTION_MANAGER_DUMMY_PROPERTY
};
static void rygel_sink_connection_manager_real_constructed (GObject* base);
GType rygel_media_renderer_plugin_get_type (void) G_GNUC_CONST;
gchar* rygel_media_renderer_plugin_get_protocol_info (RygelMediaRendererPlugin* self);
static gchar* rygel_sink_connection_manager_real_get_current_protocol_info (RygelConnectionManager* base);
GType rygel_media_player_get_type (void) G_GNUC_CONST;
RygelMediaPlayer* rygel_media_renderer_plugin_get_player (RygelMediaRendererPlugin* self);
gchar* rygel_media_player_get_protocol_info (RygelMediaPlayer* self);
RygelSinkConnectionManager* rygel_sink_connection_manager_new (void);
RygelSinkConnectionManager* rygel_sink_connection_manager_construct (GType object_type);


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


static void rygel_sink_connection_manager_real_constructed (GObject* base) {
	RygelSinkConnectionManager * self;
	gchar* _tmp0_ = NULL;
	RygelMediaRendererPlugin* plugin = NULL;
	GUPnPRootDevice* _tmp1_ = NULL;
	GUPnPRootDevice* _tmp2_ = NULL;
	GUPnPRootDevice* _tmp3_ = NULL;
	GUPnPResourceFactory* _tmp4_ = NULL;
	GUPnPResourceFactory* _tmp5_ = NULL;
	RygelMediaRendererPlugin* _tmp6_ = NULL;
	RygelMediaRendererPlugin* _tmp7_ = NULL;
	gchar* _tmp8_ = NULL;
	self = (RygelSinkConnectionManager*) base;
	G_OBJECT_CLASS (rygel_sink_connection_manager_parent_class)->constructed ((GObject*) G_TYPE_CHECK_INSTANCE_CAST (self, RYGEL_TYPE_CONNECTION_MANAGER, RygelConnectionManager));
	((RygelConnectionManager*) self)->rcs_id = 0;
	((RygelConnectionManager*) self)->av_transport_id = 0;
	_tmp0_ = g_strdup ("Input");
	_g_free0 (((RygelConnectionManager*) self)->direction);
	((RygelConnectionManager*) self)->direction = _tmp0_;
	g_object_get ((GUPnPService*) self, "root-device", &_tmp1_, NULL);
	_tmp2_ = _tmp1_;
	_tmp3_ = _tmp2_;
	_tmp4_ = gupnp_device_info_get_resource_factory ((GUPnPDeviceInfo*) _tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp5_, RYGEL_TYPE_MEDIA_RENDERER_PLUGIN) ? ((RygelMediaRendererPlugin*) _tmp5_) : NULL);
	_tmp7_ = _tmp6_;
	_g_object_unref0 (_tmp3_);
	plugin = _tmp7_;
	_tmp8_ = rygel_media_renderer_plugin_get_protocol_info (plugin);
	_g_free0 (((RygelConnectionManager*) self)->sink_protocol_info);
	((RygelConnectionManager*) self)->sink_protocol_info = _tmp8_;
	_g_object_unref0 (plugin);
}


static gchar* rygel_sink_connection_manager_real_get_current_protocol_info (RygelConnectionManager* base) {
	RygelSinkConnectionManager * self;
	gchar* result = NULL;
	RygelMediaRendererPlugin* plugin = NULL;
	GUPnPRootDevice* _tmp0_ = NULL;
	GUPnPRootDevice* _tmp1_ = NULL;
	GUPnPRootDevice* _tmp2_ = NULL;
	GUPnPResourceFactory* _tmp3_ = NULL;
	GUPnPResourceFactory* _tmp4_ = NULL;
	RygelMediaRendererPlugin* _tmp5_ = NULL;
	RygelMediaRendererPlugin* _tmp6_ = NULL;
	RygelMediaPlayer* player = NULL;
	RygelMediaPlayer* _tmp7_ = NULL;
	gchar* _tmp8_ = NULL;
	gchar* _tmp9_ = NULL;
	self = (RygelSinkConnectionManager*) base;
	g_object_get ((GUPnPService*) self, "root-device", &_tmp0_, NULL);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_;
	_tmp3_ = gupnp_device_info_get_resource_factory ((GUPnPDeviceInfo*) _tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp4_, RYGEL_TYPE_MEDIA_RENDERER_PLUGIN) ? ((RygelMediaRendererPlugin*) _tmp4_) : NULL);
	_tmp6_ = _tmp5_;
	_g_object_unref0 (_tmp2_);
	plugin = _tmp6_;
	_tmp7_ = rygel_media_renderer_plugin_get_player (plugin);
	player = _tmp7_;
	_tmp8_ = rygel_media_player_get_protocol_info (player);
	_tmp9_ = _tmp8_;
	result = _tmp9_;
	_g_object_unref0 (player);
	_g_object_unref0 (plugin);
	return result;
}


RygelSinkConnectionManager* rygel_sink_connection_manager_construct (GType object_type) {
	RygelSinkConnectionManager * self = NULL;
	self = (RygelSinkConnectionManager*) rygel_connection_manager_construct (object_type);
	return self;
}


RygelSinkConnectionManager* rygel_sink_connection_manager_new (void) {
	return rygel_sink_connection_manager_construct (RYGEL_TYPE_SINK_CONNECTION_MANAGER);
}


static void rygel_sink_connection_manager_class_init (RygelSinkConnectionManagerClass * klass) {
	rygel_sink_connection_manager_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->constructed = rygel_sink_connection_manager_real_constructed;
	RYGEL_CONNECTION_MANAGER_CLASS (klass)->get_current_protocol_info = rygel_sink_connection_manager_real_get_current_protocol_info;
}


static void rygel_sink_connection_manager_instance_init (RygelSinkConnectionManager * self) {
}


GType rygel_sink_connection_manager_get_type (void) {
	static volatile gsize rygel_sink_connection_manager_type_id__volatile = 0;
	if (g_once_init_enter (&rygel_sink_connection_manager_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (RygelSinkConnectionManagerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rygel_sink_connection_manager_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RygelSinkConnectionManager), 0, (GInstanceInitFunc) rygel_sink_connection_manager_instance_init, NULL };
		GType rygel_sink_connection_manager_type_id;
		rygel_sink_connection_manager_type_id = g_type_register_static (RYGEL_TYPE_CONNECTION_MANAGER, "RygelSinkConnectionManager", &g_define_type_info, 0);
		g_once_init_leave (&rygel_sink_connection_manager_type_id__volatile, rygel_sink_connection_manager_type_id);
	}
	return rygel_sink_connection_manager_type_id__volatile;
}



