/* rygel-playbin-plugin.c generated by valac 0.56.1, the Vala compiler
 * generated from rygel-playbin-plugin.vala, do not modify */

/*
 * Copyright (C) 2008 Zeeshan Ali (Khattak) <zeeshanak@gnome.org>.
 * Copyright (C) 2008 Nokia Corporation.
 * Copyright (C) 2012 Openismus GmbH.
 * Copyright (C) 2012 Intel Corporation.
 *
 * Author: Zeeshan Ali (Khattak) <zeeshanak@gnome.org>
 *                               <zeeshan.ali@nokia.com>
 *         Jens Georg <jensg@openismus.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 <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <glib/gi18n-lib.h>
#include "rygel-core.h"
#include "rygel-renderer-gst.h"
#include "rygel-playbin.h"

#define RYGEL_PLAYBIN_PLUGIN_NAME "Playbin"

#define RYGEL_TYPE_PLAYBIN_PLUGIN (rygel_playbin_plugin_get_type ())
#define RYGEL_PLAYBIN_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_PLAYBIN_PLUGIN, RygelPlaybinPlugin))
#define RYGEL_PLAYBIN_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_PLAYBIN_PLUGIN, RygelPlaybinPluginClass))
#define RYGEL_IS_PLAYBIN_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_PLAYBIN_PLUGIN))
#define RYGEL_IS_PLAYBIN_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_PLAYBIN_PLUGIN))
#define RYGEL_PLAYBIN_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_PLAYBIN_PLUGIN, RygelPlaybinPluginClass))

typedef struct _RygelPlaybinPlugin RygelPlaybinPlugin;
typedef struct _RygelPlaybinPluginClass RygelPlaybinPluginClass;
typedef struct _RygelPlaybinPluginPrivate RygelPlaybinPluginPrivate;
enum  {
	RYGEL_PLAYBIN_PLUGIN_0_PROPERTY,
	RYGEL_PLAYBIN_PLUGIN_NUM_PROPERTIES
};
static GParamSpec* rygel_playbin_plugin_properties[RYGEL_PLAYBIN_PLUGIN_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _RygelPlaybinPlugin {
	RygelMediaRendererPlugin parent_instance;
	RygelPlaybinPluginPrivate * priv;
};

struct _RygelPlaybinPluginClass {
	RygelMediaRendererPluginClass parent_class;
};

static gpointer rygel_playbin_plugin_parent_class = NULL;

VALA_EXTERN GType rygel_playbin_plugin_get_type (void) G_GNUC_CONST ;
VALA_EXTERN RygelPlaybinPlugin* rygel_playbin_plugin_new (GError** error);
VALA_EXTERN RygelPlaybinPlugin* rygel_playbin_plugin_construct (GType object_type,
                                                    GError** error);
static RygelMediaPlayer* rygel_playbin_plugin_real_get_player (RygelMediaRendererPlugin* base);
static GType rygel_playbin_plugin_get_type_once (void);

RygelPlaybinPlugin*
rygel_playbin_plugin_construct (GType object_type,
                                GError** error)
{
	RygelPlaybinPlugin * self = NULL;
	RygelPlaybinPlayer* _tmp0_ = NULL;
	RygelPlaybinPlayer* _tmp1_;
	GList* _tmp2_;
	GList* _tmp3_;
	GError* _inner_error0_ = NULL;
	self = (RygelPlaybinPlugin*) rygel_media_renderer_plugin_construct (object_type, RYGEL_PLAYBIN_PLUGIN_NAME, _ ("GStreamer Player"), NULL, RYGEL_PLUGIN_CAPABILITIES_NONE);
	_tmp1_ = rygel_playbin_player_instance (&_inner_error0_);
	_tmp0_ = _tmp1_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (self);
		return NULL;
	}
	_tmp2_ = rygel_playbin_player_get_supported_profiles (_tmp0_);
	_tmp3_ = _tmp2_;
	rygel_media_renderer_plugin_set_supported_profiles ((RygelMediaRendererPlugin*) self, _tmp3_);
	_g_object_unref0 (_tmp0_);
	return self;
}

RygelPlaybinPlugin*
rygel_playbin_plugin_new (GError** error)
{
	return rygel_playbin_plugin_construct (RYGEL_TYPE_PLAYBIN_PLUGIN, error);
}

static RygelMediaPlayer*
rygel_playbin_plugin_real_get_player (RygelMediaRendererPlugin* base)
{
	RygelPlaybinPlugin * self;
	GError* _inner_error0_ = NULL;
	RygelMediaPlayer* result;
	self = (RygelPlaybinPlugin*) base;
	{
		RygelPlaybinPlayer* _tmp0_ = NULL;
		RygelPlaybinPlayer* _tmp1_;
		RygelPlaybinPlayer* _tmp2_;
		_tmp1_ = rygel_playbin_player_instance (&_inner_error0_);
		_tmp0_ = _tmp1_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp2_ = _tmp0_;
		_tmp0_ = NULL;
		result = (RygelMediaPlayer*) _tmp2_;
		_g_object_unref0 (_tmp0_);
		return result;
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
		g_warning ("rygel-playbin-plugin.vala:43: %s", _ ("Could not create GStreamer player"));
		result = NULL;
		return result;
	}
	__finally0:
	g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
	g_clear_error (&_inner_error0_);
	return NULL;
}

static void
rygel_playbin_plugin_class_init (RygelPlaybinPluginClass * klass,
                                 gpointer klass_data)
{
	rygel_playbin_plugin_parent_class = g_type_class_peek_parent (klass);
	((RygelMediaRendererPluginClass *) klass)->get_player = (RygelMediaPlayer* (*) (RygelMediaRendererPlugin*)) rygel_playbin_plugin_real_get_player;
}

static void
rygel_playbin_plugin_instance_init (RygelPlaybinPlugin * self,
                                    gpointer klass)
{
}

static GType
rygel_playbin_plugin_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (RygelPlaybinPluginClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rygel_playbin_plugin_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RygelPlaybinPlugin), 0, (GInstanceInitFunc) rygel_playbin_plugin_instance_init, NULL };
	GType rygel_playbin_plugin_type_id;
	rygel_playbin_plugin_type_id = g_type_register_static (RYGEL_TYPE_MEDIA_RENDERER_PLUGIN, "RygelPlaybinPlugin", &g_define_type_info, 0);
	return rygel_playbin_plugin_type_id;
}

GType
rygel_playbin_plugin_get_type (void)
{
	static volatile gsize rygel_playbin_plugin_type_id__once = 0;
	if (g_once_init_enter (&rygel_playbin_plugin_type_id__once)) {
		GType rygel_playbin_plugin_type_id;
		rygel_playbin_plugin_type_id = rygel_playbin_plugin_get_type_once ();
		g_once_init_leave (&rygel_playbin_plugin_type_id__once, rygel_playbin_plugin_type_id);
	}
	return rygel_playbin_plugin_type_id__once;
}

