/* rygel-test-audio-item.c generated by valac 0.16.1, the Vala compiler
 * generated from rygel-test-audio-item.vala, do not modify */

/*
 * Copyright (C) 2008 Zeeshan Ali (Khattak) <zeeshanak@gnome.org>.
 * Copyright (C) 2008 Nokia 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 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-server.h>
#include <stdlib.h>
#include <string.h>
#include <gst/gst.h>


#define RYGEL_TEST_TYPE_AUDIO_ITEM (rygel_test_audio_item_get_type ())
#define RYGEL_TEST_AUDIO_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TEST_TYPE_AUDIO_ITEM, RygelTestAudioItem))
#define RYGEL_TEST_AUDIO_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TEST_TYPE_AUDIO_ITEM, RygelTestAudioItemClass))
#define RYGEL_TEST_IS_AUDIO_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TEST_TYPE_AUDIO_ITEM))
#define RYGEL_TEST_IS_AUDIO_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TEST_TYPE_AUDIO_ITEM))
#define RYGEL_TEST_AUDIO_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TEST_TYPE_AUDIO_ITEM, RygelTestAudioItemClass))

typedef struct _RygelTestAudioItem RygelTestAudioItem;
typedef struct _RygelTestAudioItemClass RygelTestAudioItemClass;
typedef struct _RygelTestAudioItemPrivate RygelTestAudioItemPrivate;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

struct _RygelTestAudioItem {
	RygelAudioItem parent_instance;
	RygelTestAudioItemPrivate * priv;
};

struct _RygelTestAudioItemClass {
	RygelAudioItemClass parent_class;
};


static gpointer rygel_test_audio_item_parent_class = NULL;

GType rygel_test_audio_item_get_type (void) G_GNUC_CONST;
enum  {
	RYGEL_TEST_AUDIO_ITEM_DUMMY_PROPERTY
};
#define RYGEL_TEST_AUDIO_ITEM_TEST_MIMETYPE "audio/x-wav"
#define RYGEL_TEST_AUDIO_ITEM_PIPELINE "audiotestsrc is-live=1 ! wavenc"
RygelTestAudioItem* rygel_test_audio_item_new (const gchar* id, RygelMediaContainer* parent, const gchar* title);
RygelTestAudioItem* rygel_test_audio_item_construct (GType object_type, const gchar* id, RygelMediaContainer* parent, const gchar* title);
static GstElement* rygel_test_audio_item_real_create_stream_source (RygelMediaItem* base, const gchar* host_ip);


RygelTestAudioItem* rygel_test_audio_item_construct (GType object_type, const gchar* id, RygelMediaContainer* parent, const gchar* title) {
	RygelTestAudioItem * self = NULL;
	const gchar* _tmp0_;
	RygelMediaContainer* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	g_return_val_if_fail (id != NULL, NULL);
	g_return_val_if_fail (parent != NULL, NULL);
	g_return_val_if_fail (title != NULL, NULL);
	_tmp0_ = id;
	_tmp1_ = parent;
	_tmp2_ = title;
	self = (RygelTestAudioItem*) rygel_audio_item_construct (object_type, _tmp0_, _tmp1_, _tmp2_, RYGEL_AUDIO_ITEM_UPNP_CLASS);
	_tmp3_ = g_strdup (RYGEL_TEST_AUDIO_ITEM_TEST_MIMETYPE);
	_g_free0 (((RygelMediaItem*) self)->mime_type);
	((RygelMediaItem*) self)->mime_type = _tmp3_;
	return self;
}


RygelTestAudioItem* rygel_test_audio_item_new (const gchar* id, RygelMediaContainer* parent, const gchar* title) {
	return rygel_test_audio_item_construct (RYGEL_TEST_TYPE_AUDIO_ITEM, id, parent, title);
}


static GstElement* rygel_test_audio_item_real_create_stream_source (RygelMediaItem* base, const gchar* host_ip) {
	RygelTestAudioItem * self;
	GstElement* result = NULL;
	GError * _inner_error_ = NULL;
	self = (RygelTestAudioItem*) base;
	{
		GstElement* _tmp0_ = NULL;
		GstElement* _tmp1_;
		_tmp0_ = gst_parse_bin_from_description (RYGEL_TEST_AUDIO_ITEM_PIPELINE, TRUE, &_inner_error_);
		gst_object_ref_sink (_tmp0_);
		_tmp1_ = _tmp0_;
		if (_inner_error_ != NULL) {
			goto __catch0_g_error;
		}
		gst_object_ref_sink (_tmp1_);
		result = _tmp1_;
		return result;
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* err = NULL;
		GError* _tmp2_;
		const gchar* _tmp3_;
		err = _inner_error_;
		_inner_error_ = NULL;
		_tmp2_ = err;
		_tmp3_ = _tmp2_->message;
		g_warning ("rygel-test-audio-item.vala:44: Required plugin missing (%s)", _tmp3_);
		result = NULL;
		_g_error_free0 (err);
		return result;
	}
	__finally0:
	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;
}


static void rygel_test_audio_item_class_init (RygelTestAudioItemClass * klass) {
	rygel_test_audio_item_parent_class = g_type_class_peek_parent (klass);
	RYGEL_MEDIA_ITEM_CLASS (klass)->create_stream_source = rygel_test_audio_item_real_create_stream_source;
}


static void rygel_test_audio_item_instance_init (RygelTestAudioItem * self) {
}


/**
 * Represents Test audio item.
 */
GType rygel_test_audio_item_get_type (void) {
	static volatile gsize rygel_test_audio_item_type_id__volatile = 0;
	if (g_once_init_enter (&rygel_test_audio_item_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (RygelTestAudioItemClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rygel_test_audio_item_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RygelTestAudioItem), 0, (GInstanceInitFunc) rygel_test_audio_item_instance_init, NULL };
		GType rygel_test_audio_item_type_id;
		rygel_test_audio_item_type_id = g_type_register_static (RYGEL_TYPE_AUDIO_ITEM, "RygelTestAudioItem", &g_define_type_info, 0);
		g_once_init_leave (&rygel_test_audio_item_type_id__volatile, rygel_test_audio_item_type_id);
	}
	return rygel_test_audio_item_type_id__volatile;
}



