/* rygel-test-video-item.c generated by valac 0.17.4.16-52707, the Vala compiler
 * generated from rygel-test-video-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_VIDEO_ITEM (rygel_test_video_item_get_type ())
#define RYGEL_TEST_VIDEO_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TEST_TYPE_VIDEO_ITEM, RygelTestVideoItem))
#define RYGEL_TEST_VIDEO_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TEST_TYPE_VIDEO_ITEM, RygelTestVideoItemClass))
#define RYGEL_TEST_IS_VIDEO_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TEST_TYPE_VIDEO_ITEM))
#define RYGEL_TEST_IS_VIDEO_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TEST_TYPE_VIDEO_ITEM))
#define RYGEL_TEST_VIDEO_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TEST_TYPE_VIDEO_ITEM, RygelTestVideoItemClass))

typedef struct _RygelTestVideoItem RygelTestVideoItem;
typedef struct _RygelTestVideoItemClass RygelTestVideoItemClass;
typedef struct _RygelTestVideoItemPrivate RygelTestVideoItemPrivate;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

struct _RygelTestVideoItem {
	RygelVideoItem parent_instance;
	RygelTestVideoItemPrivate * priv;
};

struct _RygelTestVideoItemClass {
	RygelVideoItemClass parent_class;
};


static gpointer rygel_test_video_item_parent_class = NULL;

GType rygel_test_video_item_get_type (void) G_GNUC_CONST;
enum  {
	RYGEL_TEST_VIDEO_ITEM_DUMMY_PROPERTY
};
#define RYGEL_TEST_VIDEO_ITEM_TEST_MIMETYPE "video/mpeg"
#define RYGEL_TEST_VIDEO_ITEM_PIPELINE "videotestsrc is-live=1 ! " "ffenc_mpeg2video ! " "mpegtsmux"
RygelTestVideoItem* rygel_test_video_item_new (const gchar* id, RygelMediaContainer* parent, const gchar* title);
RygelTestVideoItem* rygel_test_video_item_construct (GType object_type, const gchar* id, RygelMediaContainer* parent, const gchar* title);
static GstElement* rygel_test_video_item_real_create_stream_source (RygelMediaItem* base, const gchar* host_ip);


RygelTestVideoItem* rygel_test_video_item_construct (GType object_type, const gchar* id, RygelMediaContainer* parent, const gchar* title) {
	RygelTestVideoItem * 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 = (RygelTestVideoItem*) rygel_video_item_construct (object_type, _tmp0_, _tmp1_, _tmp2_, RYGEL_VIDEO_ITEM_UPNP_CLASS);
	_tmp3_ = g_strdup (RYGEL_TEST_VIDEO_ITEM_TEST_MIMETYPE);
	_g_free0 (((RygelMediaItem*) self)->mime_type);
	((RygelMediaItem*) self)->mime_type = _tmp3_;
	return self;
}


RygelTestVideoItem* rygel_test_video_item_new (const gchar* id, RygelMediaContainer* parent, const gchar* title) {
	return rygel_test_video_item_construct (RYGEL_TEST_TYPE_VIDEO_ITEM, id, parent, title);
}


static GstElement* rygel_test_video_item_real_create_stream_source (RygelMediaItem* base, const gchar* host_ip) {
	RygelTestVideoItem * self;
	GstElement* result = NULL;
	GError * _inner_error_ = NULL;
	self = (RygelTestVideoItem*) base;
	{
		GstElement* _tmp0_ = NULL;
		GstElement* _tmp1_;
		_tmp0_ = gst_parse_bin_from_description (RYGEL_TEST_VIDEO_ITEM_PIPELINE, TRUE, &_inner_error_);
		if (_tmp0_ != NULL) {
			gst_object_ref_sink (_tmp0_);
		}
		_tmp1_ = _tmp0_;
		if (_inner_error_ != NULL) {
			goto __catch1_g_error;
		}
		if (_tmp1_ != NULL) {
			gst_object_ref_sink (_tmp1_);
		}
		result = _tmp1_;
		return result;
	}
	goto __finally1;
	__catch1_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-video-item.vala:46: Required plugin missing (%s)", _tmp3_);
		result = NULL;
		_g_error_free0 (err);
		return result;
	}
	__finally1:
	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_video_item_class_init (RygelTestVideoItemClass * klass) {
	rygel_test_video_item_parent_class = g_type_class_peek_parent (klass);
	RYGEL_MEDIA_ITEM_CLASS (klass)->create_stream_source = rygel_test_video_item_real_create_stream_source;
}


static void rygel_test_video_item_instance_init (RygelTestVideoItem * self) {
}


/**
 * Represents Test video item.
 */
GType rygel_test_video_item_get_type (void) {
	static volatile gsize rygel_test_video_item_type_id__volatile = 0;
	if (g_once_init_enter (&rygel_test_video_item_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (RygelTestVideoItemClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rygel_test_video_item_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RygelTestVideoItem), 0, (GInstanceInitFunc) rygel_test_video_item_instance_init, NULL };
		GType rygel_test_video_item_type_id;
		rygel_test_video_item_type_id = g_type_register_static (RYGEL_TYPE_VIDEO_ITEM, "RygelTestVideoItem", &g_define_type_info, 0);
		g_once_init_leave (&rygel_test_video_item_type_id__volatile, rygel_test_video_item_type_id);
	}
	return rygel_test_video_item_type_id__volatile;
}



