/* rygel-gst-launch-item.c generated by valac 0.15.1.36-84b2b, the Vala compiler
 * generated from rygel-gst-launch-item.vala, do not modify */

/*
 * Copyright (C) 2009 Thijs Vermeir <thijsvermeir@gmail.com>
 * Copyright (C) 2010 Nokia Corporation.
 *
 * Author: Thijs Vermeir <thijsvermeir@gmail.com>
 * 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 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.h>
#include <stdlib.h>
#include <string.h>
#include <gst/gst.h>


#define RYGEL_GST_LAUNCH_TYPE_ITEM (rygel_gst_launch_item_get_type ())
#define RYGEL_GST_LAUNCH_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_GST_LAUNCH_TYPE_ITEM, RygelGstLaunchItem))
#define RYGEL_GST_LAUNCH_IS_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_GST_LAUNCH_TYPE_ITEM))
#define RYGEL_GST_LAUNCH_ITEM_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), RYGEL_GST_LAUNCH_TYPE_ITEM, RygelGstLaunchItemIface))

typedef struct _RygelGstLaunchItem RygelGstLaunchItem;
typedef struct _RygelGstLaunchItemIface RygelGstLaunchItemIface;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

struct _RygelGstLaunchItemIface {
	GTypeInterface parent_iface;
	const gchar* (*get_launch_line) (RygelGstLaunchItem* self);
	void (*set_launch_line) (RygelGstLaunchItem* self, const gchar* value);
};



GType rygel_gst_launch_item_get_type (void) G_GNUC_CONST;
GstElement* rygel_gst_launch_item_create_source (RygelGstLaunchItem* self);
const gchar* rygel_gst_launch_item_get_launch_line (RygelGstLaunchItem* self);
void rygel_gst_launch_item_set_launch_line (RygelGstLaunchItem* self, const gchar* value);


GstElement* rygel_gst_launch_item_create_source (RygelGstLaunchItem* self) {
	GstElement* result = NULL;
	GError * _inner_error_ = NULL;
	{
		const gchar* _tmp0_;
		const gchar* _tmp1_;
		GstElement* _tmp2_ = NULL;
		GstElement* _tmp3_;
		_tmp0_ = rygel_gst_launch_item_get_launch_line (self);
		_tmp1_ = _tmp0_;
		_tmp2_ = gst_parse_bin_from_description (_tmp1_, TRUE, &_inner_error_);
		gst_object_ref_sink (_tmp2_);
		_tmp3_ = _tmp2_;
		if (_inner_error_ != NULL) {
			goto __catch2_g_error;
		}
		gst_object_ref_sink (_tmp3_);
		result = _tmp3_;
		return result;
	}
	goto __finally2;
	__catch2_g_error:
	{
		GError* err = NULL;
		GError* _tmp4_;
		const gchar* _tmp5_;
		err = _inner_error_;
		_inner_error_ = NULL;
		_tmp4_ = err;
		_tmp5_ = _tmp4_->message;
		g_warning ("rygel-gst-launch-item.vala:38: parse launchline failed: %s", _tmp5_);
		result = NULL;
		_g_error_free0 (err);
		return result;
	}
	__finally2:
	g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
	g_clear_error (&_inner_error_);
	return NULL;
}


const gchar* rygel_gst_launch_item_get_launch_line (RygelGstLaunchItem* self) {
	g_return_val_if_fail (self != NULL, NULL);
	return RYGEL_GST_LAUNCH_ITEM_GET_INTERFACE (self)->get_launch_line (self);
}


void rygel_gst_launch_item_set_launch_line (RygelGstLaunchItem* self, const gchar* value) {
	g_return_if_fail (self != NULL);
	RYGEL_GST_LAUNCH_ITEM_GET_INTERFACE (self)->set_launch_line (self, value);
}


static void rygel_gst_launch_item_base_init (RygelGstLaunchItemIface * iface) {
	static gboolean initialized = FALSE;
	if (!initialized) {
		initialized = TRUE;
		g_object_interface_install_property (iface, g_param_spec_string ("launch-line", "launch-line", "launch-line", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	}
}


/**
 * Item that serves data from a gst-launch commandline.
 */
GType rygel_gst_launch_item_get_type (void) {
	static volatile gsize rygel_gst_launch_item_type_id__volatile = 0;
	if (g_once_init_enter (&rygel_gst_launch_item_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (RygelGstLaunchItemIface), (GBaseInitFunc) rygel_gst_launch_item_base_init, (GBaseFinalizeFunc) NULL, (GClassInitFunc) NULL, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
		GType rygel_gst_launch_item_type_id;
		rygel_gst_launch_item_type_id = g_type_register_static (G_TYPE_INTERFACE, "RygelGstLaunchItem", &g_define_type_info, 0);
		g_type_interface_add_prerequisite (rygel_gst_launch_item_type_id, RYGEL_TYPE_MEDIA_ITEM);
		g_once_init_leave (&rygel_gst_launch_item_type_id__volatile, rygel_gst_launch_item_type_id);
	}
	return rygel_gst_launch_item_type_id__volatile;
}



