/* rygel-gst-utils.c generated by valac 0.17.4.16-52707, the Vala compiler
 * generated from rygel-gst-utils.vala, do not modify */

/*
 * Copyright (C) 2009 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 <stdlib.h>
#include <string.h>
#include <gst/gst.h>
#include <stdio.h>
#include <gobject/gvaluecollector.h>


#define RYGEL_TYPE_GST_UTILS (rygel_gst_utils_get_type ())
#define RYGEL_GST_UTILS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_GST_UTILS, RygelGstUtils))
#define RYGEL_GST_UTILS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_GST_UTILS, RygelGstUtilsClass))
#define RYGEL_IS_GST_UTILS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_GST_UTILS))
#define RYGEL_IS_GST_UTILS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_GST_UTILS))
#define RYGEL_GST_UTILS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_GST_UTILS, RygelGstUtilsClass))

typedef struct _RygelGstUtils RygelGstUtils;
typedef struct _RygelGstUtilsClass RygelGstUtilsClass;
typedef struct _RygelGstUtilsPrivate RygelGstUtilsPrivate;
typedef struct _RygelParamSpecGstUtils RygelParamSpecGstUtils;

typedef enum  {
	RYGEL_GST_ERROR_MISSING_PLUGIN,
	RYGEL_GST_ERROR_LINK
} RygelGstError;
#define RYGEL_GST_ERROR rygel_gst_error_quark ()
struct _RygelGstUtils {
	GTypeInstance parent_instance;
	volatile int ref_count;
	RygelGstUtilsPrivate * priv;
};

struct _RygelGstUtilsClass {
	GTypeClass parent_class;
	void (*finalize) (RygelGstUtils *self);
};

struct _RygelParamSpecGstUtils {
	GParamSpec parent_instance;
};


static gpointer rygel_gst_utils_parent_class = NULL;

GQuark rygel_gst_error_quark (void);
gpointer rygel_gst_utils_ref (gpointer instance);
void rygel_gst_utils_unref (gpointer instance);
GParamSpec* rygel_param_spec_gst_utils (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void rygel_value_set_gst_utils (GValue* value, gpointer v_object);
void rygel_value_take_gst_utils (GValue* value, gpointer v_object);
gpointer rygel_value_get_gst_utils (const GValue* value);
GType rygel_gst_utils_get_type (void) G_GNUC_CONST;
enum  {
	RYGEL_GST_UTILS_DUMMY_PROPERTY
};
GstClockTime rygel_gst_utils_time_from_string (const gchar* str);
gchar* rygel_gst_utils_time_to_string (GstClockTime time);
RygelGstUtils* rygel_gst_utils_construct (GType object_type);
static void rygel_gst_utils_finalize (RygelGstUtils* obj);


GQuark rygel_gst_error_quark (void) {
	return g_quark_from_static_string ("rygel_gst_error-quark");
}


GstClockTime rygel_gst_utils_time_from_string (const gchar* str) {
	GstClockTime result = 0ULL;
	guint64 hours = 0ULL;
	guint64 minutes = 0ULL;
	guint64 seconds = 0ULL;
	const gchar* _tmp0_;
#line 32 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	g_return_val_if_fail (str != NULL, 0ULL);
#line 35 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	_tmp0_ = str;
#line 35 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	sscanf (_tmp0_, "%llu:%2llu:%2llu%*s", &hours, &minutes, &seconds);
#line 37 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	result = (GstClockTime) ((((hours * 3600) + (minutes * 60)) + seconds) * GST_SECOND);
#line 37 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	return result;
#line 110 "rygel-gst-utils.c"
}


gchar* rygel_gst_utils_time_to_string (GstClockTime time) {
	gchar* result = NULL;
	guint64 hours = 0ULL;
	guint64 minutes = 0ULL;
	guint64 seconds = 0ULL;
	GstClockTime _tmp0_;
	GstClockTime _tmp1_;
	guint64 _tmp2_;
	guint64 _tmp3_;
	guint64 _tmp4_;
	gchar* _tmp5_ = NULL;
#line 44 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	_tmp0_ = time;
#line 44 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	hours = (guint64) ((_tmp0_ / GST_SECOND) / 3600);
#line 45 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	_tmp1_ = time;
#line 45 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	seconds = (guint64) ((_tmp1_ / GST_SECOND) % 3600);
#line 46 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	_tmp2_ = seconds;
#line 46 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	minutes = _tmp2_ / 60;
#line 47 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	_tmp3_ = seconds;
#line 47 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	seconds = _tmp3_ % 60;
#line 49 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	_tmp4_ = seconds;
#line 49 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	_tmp5_ = g_strdup_printf ("%llu:%.2llu:%.2llu", hours, minutes, _tmp4_);
#line 49 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	result = _tmp5_;
#line 49 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	return result;
#line 149 "rygel-gst-utils.c"
}


RygelGstUtils* rygel_gst_utils_construct (GType object_type) {
	RygelGstUtils* self = NULL;
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	self = (RygelGstUtils*) g_type_create_instance (object_type);
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	return self;
#line 159 "rygel-gst-utils.c"
}


static void rygel_value_gst_utils_init (GValue* value) {
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	value->data[0].v_pointer = NULL;
#line 166 "rygel-gst-utils.c"
}


static void rygel_value_gst_utils_free_value (GValue* value) {
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	if (value->data[0].v_pointer) {
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
		rygel_gst_utils_unref (value->data[0].v_pointer);
#line 175 "rygel-gst-utils.c"
	}
}


static void rygel_value_gst_utils_copy_value (const GValue* src_value, GValue* dest_value) {
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	if (src_value->data[0].v_pointer) {
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
		dest_value->data[0].v_pointer = rygel_gst_utils_ref (src_value->data[0].v_pointer);
#line 185 "rygel-gst-utils.c"
	} else {
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
		dest_value->data[0].v_pointer = NULL;
#line 189 "rygel-gst-utils.c"
	}
}


static gpointer rygel_value_gst_utils_peek_pointer (const GValue* value) {
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	return value->data[0].v_pointer;
#line 197 "rygel-gst-utils.c"
}


static gchar* rygel_value_gst_utils_collect_value (GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	if (collect_values[0].v_pointer) {
#line 204 "rygel-gst-utils.c"
		RygelGstUtils* object;
		object = collect_values[0].v_pointer;
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
		if (object->parent_instance.g_class == NULL) {
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
#line 211 "rygel-gst-utils.c"
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
#line 215 "rygel-gst-utils.c"
		}
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
		value->data[0].v_pointer = rygel_gst_utils_ref (object);
#line 219 "rygel-gst-utils.c"
	} else {
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
		value->data[0].v_pointer = NULL;
#line 223 "rygel-gst-utils.c"
	}
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	return NULL;
#line 227 "rygel-gst-utils.c"
}


static gchar* rygel_value_gst_utils_lcopy_value (const GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
	RygelGstUtils** object_p;
	object_p = collect_values[0].v_pointer;
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	if (!object_p) {
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
#line 238 "rygel-gst-utils.c"
	}
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	if (!value->data[0].v_pointer) {
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
		*object_p = NULL;
#line 244 "rygel-gst-utils.c"
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
		*object_p = value->data[0].v_pointer;
#line 248 "rygel-gst-utils.c"
	} else {
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
		*object_p = rygel_gst_utils_ref (value->data[0].v_pointer);
#line 252 "rygel-gst-utils.c"
	}
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	return NULL;
#line 256 "rygel-gst-utils.c"
}


GParamSpec* rygel_param_spec_gst_utils (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags) {
	RygelParamSpecGstUtils* spec;
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	g_return_val_if_fail (g_type_is_a (object_type, RYGEL_TYPE_GST_UTILS), NULL);
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	G_PARAM_SPEC (spec)->value_type = object_type;
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	return G_PARAM_SPEC (spec);
#line 270 "rygel-gst-utils.c"
}


gpointer rygel_value_get_gst_utils (const GValue* value) {
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, RYGEL_TYPE_GST_UTILS), NULL);
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	return value->data[0].v_pointer;
#line 279 "rygel-gst-utils.c"
}


void rygel_value_set_gst_utils (GValue* value, gpointer v_object) {
	RygelGstUtils* old;
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, RYGEL_TYPE_GST_UTILS));
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	old = value->data[0].v_pointer;
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	if (v_object) {
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, RYGEL_TYPE_GST_UTILS));
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
		value->data[0].v_pointer = v_object;
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
		rygel_gst_utils_ref (value->data[0].v_pointer);
#line 299 "rygel-gst-utils.c"
	} else {
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
		value->data[0].v_pointer = NULL;
#line 303 "rygel-gst-utils.c"
	}
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	if (old) {
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
		rygel_gst_utils_unref (old);
#line 309 "rygel-gst-utils.c"
	}
}


void rygel_value_take_gst_utils (GValue* value, gpointer v_object) {
	RygelGstUtils* old;
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, RYGEL_TYPE_GST_UTILS));
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	old = value->data[0].v_pointer;
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	if (v_object) {
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, RYGEL_TYPE_GST_UTILS));
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
		value->data[0].v_pointer = v_object;
#line 328 "rygel-gst-utils.c"
	} else {
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
		value->data[0].v_pointer = NULL;
#line 332 "rygel-gst-utils.c"
	}
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	if (old) {
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
		rygel_gst_utils_unref (old);
#line 338 "rygel-gst-utils.c"
	}
}


static void rygel_gst_utils_class_init (RygelGstUtilsClass * klass) {
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	rygel_gst_utils_parent_class = g_type_class_peek_parent (klass);
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	RYGEL_GST_UTILS_CLASS (klass)->finalize = rygel_gst_utils_finalize;
#line 348 "rygel-gst-utils.c"
}


static void rygel_gst_utils_instance_init (RygelGstUtils * self) {
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	self->ref_count = 1;
#line 355 "rygel-gst-utils.c"
}


static void rygel_gst_utils_finalize (RygelGstUtils* obj) {
	RygelGstUtils * self;
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_TYPE_GST_UTILS, RygelGstUtils);
#line 363 "rygel-gst-utils.c"
}


GType rygel_gst_utils_get_type (void) {
	static volatile gsize rygel_gst_utils_type_id__volatile = 0;
	if (g_once_init_enter (&rygel_gst_utils_type_id__volatile)) {
		static const GTypeValueTable g_define_type_value_table = { rygel_value_gst_utils_init, rygel_value_gst_utils_free_value, rygel_value_gst_utils_copy_value, rygel_value_gst_utils_peek_pointer, "p", rygel_value_gst_utils_collect_value, "p", rygel_value_gst_utils_lcopy_value };
		static const GTypeInfo g_define_type_info = { sizeof (RygelGstUtilsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rygel_gst_utils_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RygelGstUtils), 0, (GInstanceInitFunc) rygel_gst_utils_instance_init, &g_define_type_value_table };
		static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
		GType rygel_gst_utils_type_id;
		rygel_gst_utils_type_id = g_type_register_fundamental (g_type_fundamental_next (), "RygelGstUtils", &g_define_type_info, &g_define_type_fundamental_info, G_TYPE_FLAG_ABSTRACT);
		g_once_init_leave (&rygel_gst_utils_type_id__volatile, rygel_gst_utils_type_id);
	}
	return rygel_gst_utils_type_id__volatile;
}


gpointer rygel_gst_utils_ref (gpointer instance) {
	RygelGstUtils* self;
	self = instance;
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	g_atomic_int_inc (&self->ref_count);
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	return instance;
#line 388 "rygel-gst-utils.c"
}


void rygel_gst_utils_unref (gpointer instance) {
	RygelGstUtils* self;
	self = instance;
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
		RYGEL_GST_UTILS_GET_CLASS (self)->finalize (self);
#line 31 "/home/jens/Source/rygel/src/librygel-renderer/rygel-gst-utils.vala"
		g_type_free_instance ((GTypeInstance *) self);
#line 401 "rygel-gst-utils.c"
	}
}



