/* rygel-media-export-dvd-track.c generated by valac 0.32.0.15-114e9, the Vala compiler
 * generated from rygel-media-export-dvd-track.vala, do not modify */

/*
 * Copyright (C) 2015 Jens Georg <mail@jensge.org>
 *
 * Author: Jens Georg <mail@jensge.org>
 *
 * 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 <gio/gio.h>
#include <libxml/tree.h>
#include <stdlib.h>
#include <string.h>
#include <libsoup/soup.h>
#include <float.h>
#include <math.h>
#include <gee.h>
#include <libgupnp-av/gupnp-av.h>


#define RYGEL_MEDIA_EXPORT_TYPE_UPDATABLE_OBJECT (rygel_media_export_updatable_object_get_type ())
#define RYGEL_MEDIA_EXPORT_UPDATABLE_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_UPDATABLE_OBJECT, RygelMediaExportUpdatableObject))
#define RYGEL_MEDIA_EXPORT_IS_UPDATABLE_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_UPDATABLE_OBJECT))
#define RYGEL_MEDIA_EXPORT_UPDATABLE_OBJECT_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), RYGEL_MEDIA_EXPORT_TYPE_UPDATABLE_OBJECT, RygelMediaExportUpdatableObjectIface))

typedef struct _RygelMediaExportUpdatableObject RygelMediaExportUpdatableObject;
typedef struct _RygelMediaExportUpdatableObjectIface RygelMediaExportUpdatableObjectIface;

#define RYGEL_MEDIA_EXPORT_TYPE_VIDEO_ITEM (rygel_media_export_video_item_get_type ())
#define RYGEL_MEDIA_EXPORT_VIDEO_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_VIDEO_ITEM, RygelMediaExportVideoItem))
#define RYGEL_MEDIA_EXPORT_VIDEO_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_VIDEO_ITEM, RygelMediaExportVideoItemClass))
#define RYGEL_MEDIA_EXPORT_IS_VIDEO_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_VIDEO_ITEM))
#define RYGEL_MEDIA_EXPORT_IS_VIDEO_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_VIDEO_ITEM))
#define RYGEL_MEDIA_EXPORT_VIDEO_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_VIDEO_ITEM, RygelMediaExportVideoItemClass))

typedef struct _RygelMediaExportVideoItem RygelMediaExportVideoItem;
typedef struct _RygelMediaExportVideoItemClass RygelMediaExportVideoItemClass;
typedef struct _RygelMediaExportVideoItemPrivate RygelMediaExportVideoItemPrivate;

#define RYGEL_MEDIA_EXPORT_TYPE_DVD_TRACK (rygel_media_export_dvd_track_get_type ())
#define RYGEL_MEDIA_EXPORT_DVD_TRACK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_DVD_TRACK, RygelMediaExportDVDTrack))
#define RYGEL_MEDIA_EXPORT_DVD_TRACK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_DVD_TRACK, RygelMediaExportDVDTrackClass))
#define RYGEL_MEDIA_EXPORT_IS_DVD_TRACK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_DVD_TRACK))
#define RYGEL_MEDIA_EXPORT_IS_DVD_TRACK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_DVD_TRACK))
#define RYGEL_MEDIA_EXPORT_DVD_TRACK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_DVD_TRACK, RygelMediaExportDVDTrackClass))

typedef struct _RygelMediaExportDVDTrack RygelMediaExportDVDTrack;
typedef struct _RygelMediaExportDVDTrackClass RygelMediaExportDVDTrackClass;
typedef struct _RygelMediaExportDVDTrackPrivate RygelMediaExportDVDTrackPrivate;
typedef struct _Block6Data Block6Data;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define __vala_SoupURI_free0(var) ((var == NULL) ? NULL : (var = (_vala_SoupURI_free (var), NULL)))
typedef struct _RygelMediaExportDvdTrackCommitCustomData RygelMediaExportDvdTrackCommitCustomData;

struct _RygelMediaExportUpdatableObjectIface {
	GTypeInterface parent_iface;
	void (*commit_custom) (RygelMediaExportUpdatableObject* self, gboolean override_guarded, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*commit_custom_finish) (RygelMediaExportUpdatableObject* self, GAsyncResult* _res_, GError** error);
};

struct _RygelMediaExportVideoItem {
	RygelVideoItem parent_instance;
	RygelMediaExportVideoItemPrivate * priv;
};

struct _RygelMediaExportVideoItemClass {
	RygelVideoItemClass parent_class;
	void (*commit_custom) (RygelMediaExportVideoItem* self, gboolean override_guarded, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*commit_custom_finish) (RygelMediaExportVideoItem* self, GAsyncResult* _res_, GError** error);
};

struct _RygelMediaExportDVDTrack {
	RygelMediaExportVideoItem parent_instance;
	RygelMediaExportDVDTrackPrivate * priv;
};

struct _RygelMediaExportDVDTrackClass {
	RygelMediaExportVideoItemClass parent_class;
};

struct _RygelMediaExportDVDTrackPrivate {
	xmlNode* _node;
	gint _track;
};

struct _Block6Data {
	int _ref_count_;
	RygelMediaExportDVDTrack* self;
	RygelMediaEngine* media_engine;
};

struct _RygelMediaExportDvdTrackCommitCustomData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	RygelMediaExportDVDTrack* self;
	gboolean override_guarded;
	xmlNode* _tmp0_;
	gboolean _tmp1_;
	GError * _inner_error_;
};


static gpointer rygel_media_export_dvd_track_parent_class = NULL;

GType rygel_media_export_updatable_object_get_type (void) G_GNUC_CONST;
GType rygel_media_export_video_item_get_type (void) G_GNUC_CONST;
GType rygel_media_export_dvd_track_get_type (void) G_GNUC_CONST;
#define RYGEL_MEDIA_EXPORT_DVD_TRACK_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RYGEL_MEDIA_EXPORT_TYPE_DVD_TRACK, RygelMediaExportDVDTrackPrivate))
enum  {
	RYGEL_MEDIA_EXPORT_DVD_TRACK_DUMMY_PROPERTY,
	RYGEL_MEDIA_EXPORT_DVD_TRACK_NODE,
	RYGEL_MEDIA_EXPORT_DVD_TRACK_TRACK
};
RygelMediaExportDVDTrack* rygel_media_export_dvd_track_new (const gchar* id, RygelMediaContainer* parent, const gchar* title, gint track, xmlNode* node);
RygelMediaExportDVDTrack* rygel_media_export_dvd_track_construct (GType object_type, const gchar* id, RygelMediaContainer* parent, const gchar* title, gint track, xmlNode* node);
static void rygel_media_export_dvd_track_real_constructed (GObject* base);
static xmlNode* rygel_media_export_dvd_track_get_node (RygelMediaExportDVDTrack* self);
static Block6Data* block6_data_ref (Block6Data* _data6_);
static void block6_data_unref (void * _userdata_);
static gint rygel_media_export_dvd_track_get_track (RygelMediaExportDVDTrack* self);
static void ___lambda4_ (Block6Data* _data6_, GObject* obj, GAsyncResult* res);
static void ____lambda4__gasync_ready_callback (GObject* source_object, GAsyncResult* res, gpointer self);
static void _vala_SoupURI_free (SoupURI* self);
static RygelMediaResource* rygel_media_export_dvd_track_real_get_primary_resource (RygelMediaFileItem* base);
static void rygel_media_export_dvd_track_real_commit_custom_data_free (gpointer _data);
static void rygel_media_export_dvd_track_real_commit_custom (RygelMediaExportVideoItem* base, gboolean override_guarded, GAsyncReadyCallback _callback_, gpointer _user_data_);
static gboolean rygel_media_export_dvd_track_real_commit_custom_co (RygelMediaExportDvdTrackCommitCustomData* _data_);
void rygel_media_export_video_item_commit_custom (RygelMediaExportVideoItem* self, gboolean override_guarded, GAsyncReadyCallback _callback_, gpointer _user_data_);
void rygel_media_export_video_item_commit_custom_finish (RygelMediaExportVideoItem* self, GAsyncResult* _res_, GError** error);
static void rygel_media_export_dvd_track_commit_custom_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
void rygel_media_export_dvd_track_set_node (RygelMediaExportDVDTrack* self, xmlNode* value);
void rygel_media_export_dvd_track_set_track (RygelMediaExportDVDTrack* self, gint value);
static void rygel_media_export_dvd_track_finalize (GObject* obj);
static void _vala_rygel_media_export_dvd_track_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_rygel_media_export_dvd_track_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);


RygelMediaExportDVDTrack* rygel_media_export_dvd_track_construct (GType object_type, const gchar* id, RygelMediaContainer* parent, const gchar* title, gint track, xmlNode* node) {
	RygelMediaExportDVDTrack * self = NULL;
	const gchar* _tmp0_ = NULL;
	RygelMediaContainer* _tmp1_ = NULL;
	xmlNode* _tmp2_ = NULL;
	const gchar* _tmp3_ = NULL;
	gint _tmp4_ = 0;
	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_ = node;
	_tmp3_ = title;
	_tmp4_ = track;
	self = (RygelMediaExportDVDTrack*) g_object_new (object_type, "id", _tmp0_, "parent", _tmp1_, "node", _tmp2_, "title", _tmp3_, "track", _tmp4_, "upnp-class", RYGEL_VIDEO_ITEM_UPNP_CLASS, NULL);
	return self;
}


RygelMediaExportDVDTrack* rygel_media_export_dvd_track_new (const gchar* id, RygelMediaContainer* parent, const gchar* title, gint track, xmlNode* node) {
	return rygel_media_export_dvd_track_construct (RYGEL_MEDIA_EXPORT_TYPE_DVD_TRACK, id, parent, title, track, node);
}


static Block6Data* block6_data_ref (Block6Data* _data6_) {
	g_atomic_int_inc (&_data6_->_ref_count_);
	return _data6_;
}


static void block6_data_unref (void * _userdata_) {
	Block6Data* _data6_;
	_data6_ = (Block6Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data6_->_ref_count_)) {
		RygelMediaExportDVDTrack* self;
		self = _data6_->self;
		_g_object_unref0 (_data6_->media_engine);
		_g_object_unref0 (self);
		g_slice_free (Block6Data, _data6_);
	}
}


static gdouble double_parse (const gchar* str) {
	gdouble result = 0.0;
	const gchar* _tmp0_ = NULL;
	gdouble _tmp1_ = 0.0;
	g_return_val_if_fail (str != NULL, 0.0);
	_tmp0_ = str;
	_tmp1_ = g_ascii_strtod (_tmp0_, NULL);
	result = _tmp1_;
	return result;
}


static void ___lambda4_ (Block6Data* _data6_, GObject* obj, GAsyncResult* res) {
	RygelMediaExportDVDTrack* self;
	GeeList* added_resources = NULL;
	RygelMediaEngine* _tmp0_ = NULL;
	GAsyncResult* _tmp1_ = NULL;
	GeeList* _tmp2_ = NULL;
	gint _tmp3_ = 0;
	gint _tmp4_ = 0;
	gchar* _tmp5_ = NULL;
	gchar* _tmp6_ = NULL;
	GeeList* _tmp7_ = NULL;
	GeeList* _tmp8_ = NULL;
	self = _data6_->self;
	g_return_if_fail (res != NULL);
	_tmp0_ = _data6_->media_engine;
	_tmp1_ = res;
	_tmp2_ = rygel_media_engine_get_resources_for_item_finish (_tmp0_, _tmp1_);
	added_resources = _tmp2_;
	_tmp3_ = gee_collection_get_size ((GeeCollection*) added_resources);
	_tmp4_ = _tmp3_;
	_tmp5_ = rygel_media_object_get_primary_uri ((RygelMediaObject*) self);
	_tmp6_ = _tmp5_;
	g_debug ("rygel-media-export-dvd-track.vala:76: Adding %d resources to this sour" \
"ce %s", _tmp4_, _tmp6_);
	_g_free0 (_tmp6_);
	_tmp7_ = rygel_media_object_get_resource_list ((RygelMediaObject*) self);
	_tmp8_ = _tmp7_;
	gee_collection_add_all ((GeeCollection*) _tmp8_, (GeeCollection*) added_resources);
	_g_object_unref0 (_tmp8_);
	_g_object_unref0 (added_resources);
}


static void ____lambda4__gasync_ready_callback (GObject* source_object, GAsyncResult* res, gpointer self) {
	___lambda4_ (self, source_object, res);
	block6_data_unref (self);
}


static void _vala_SoupURI_free (SoupURI* self) {
	g_boxed_free (soup_uri_get_type (), self);
}


static void rygel_media_export_dvd_track_real_constructed (GObject* base) {
	RygelMediaExportDVDTrack * self;
	xmlNode* _tmp0_ = NULL;
	self = (RygelMediaExportDVDTrack*) base;
	G_OBJECT_CLASS (rygel_media_export_dvd_track_parent_class)->constructed ((GObject*) G_TYPE_CHECK_INSTANCE_CAST (self, RYGEL_MEDIA_EXPORT_TYPE_VIDEO_ITEM, RygelMediaExportVideoItem));
	_tmp0_ = self->priv->_node;
	if (_tmp0_ != NULL) {
		Block6Data* _data6_;
		SoupURI* uri = NULL;
		RygelMediaContainer* _tmp1_ = NULL;
		RygelMediaContainer* _tmp2_ = NULL;
		gchar* _tmp3_ = NULL;
		gchar* _tmp4_ = NULL;
		SoupURI* _tmp5_ = NULL;
		SoupURI* _tmp6_ = NULL;
		SoupURI* _tmp7_ = NULL;
		SoupURI* _tmp8_ = NULL;
		gint _tmp9_ = 0;
		gchar* _tmp10_ = NULL;
		gchar* _tmp11_ = NULL;
		SoupURI* _tmp12_ = NULL;
		gchar* _tmp13_ = NULL;
		gchar* _tmp14_ = NULL;
		xmlNode* it = NULL;
		xmlNode* _tmp15_ = NULL;
		xmlNode* _tmp16_ = NULL;
		RygelMediaEngine* _tmp49_ = NULL;
		RygelMediaEngine* _tmp50_ = NULL;
		_data6_ = g_slice_new0 (Block6Data);
		_data6_->_ref_count_ = 1;
		_data6_->self = g_object_ref (self);
		_tmp1_ = rygel_media_object_get_parent ((RygelMediaObject*) self);
		_tmp2_ = _tmp1_;
		_tmp3_ = rygel_media_object_get_primary_uri ((RygelMediaObject*) _tmp2_);
		_tmp4_ = _tmp3_;
		_tmp5_ = soup_uri_new (_tmp4_);
		_tmp6_ = _tmp5_;
		_g_free0 (_tmp4_);
		uri = _tmp6_;
		_tmp7_ = uri;
		soup_uri_set_scheme (_tmp7_, "dvd");
		_tmp8_ = uri;
		_tmp9_ = self->priv->_track;
		_tmp10_ = g_strdup_printf ("title=%d", _tmp9_ + 1);
		_tmp11_ = _tmp10_;
		soup_uri_set_query (_tmp8_, _tmp11_);
		_g_free0 (_tmp11_);
		_tmp12_ = uri;
		_tmp13_ = soup_uri_to_string (_tmp12_, FALSE);
		_tmp14_ = _tmp13_;
		rygel_media_object_add_uri ((RygelMediaObject*) self, _tmp14_);
		_g_free0 (_tmp14_);
		rygel_media_file_item_set_dlna_profile ((RygelMediaFileItem*) self, "MPEG_PS");
		rygel_media_file_item_set_mime_type ((RygelMediaFileItem*) self, "video/mpeg");
		_tmp15_ = self->priv->_node;
		_tmp16_ = _tmp15_->children;
		it = _tmp16_;
		while (TRUE) {
			xmlNode* _tmp17_ = NULL;
			xmlNode* _tmp18_ = NULL;
			const gchar* _tmp19_ = NULL;
			xmlNode* _tmp47_ = NULL;
			xmlNode* _tmp48_ = NULL;
			_tmp17_ = it;
			if (!(_tmp17_ != NULL)) {
				break;
			}
			_tmp18_ = it;
			_tmp19_ = _tmp18_->name;
			if (g_strcmp0 (_tmp19_, "length") == 0) {
				xmlNode* _tmp20_ = NULL;
				xmlNode* _tmp21_ = NULL;
				const gchar* _tmp22_ = NULL;
				gdouble _tmp23_ = 0.0;
				_tmp20_ = it;
				_tmp21_ = _tmp20_->children;
				_tmp22_ = _tmp21_->content;
				_tmp23_ = double_parse (_tmp22_);
				rygel_audio_item_set_duration ((RygelAudioItem*) self, (glong) ((gint) _tmp23_));
			} else {
				xmlNode* _tmp24_ = NULL;
				const gchar* _tmp25_ = NULL;
				_tmp24_ = it;
				_tmp25_ = _tmp24_->name;
				if (g_strcmp0 (_tmp25_, "width") == 0) {
					xmlNode* _tmp26_ = NULL;
					xmlNode* _tmp27_ = NULL;
					const gchar* _tmp28_ = NULL;
					gint _tmp29_ = 0;
					_tmp26_ = it;
					_tmp27_ = _tmp26_->children;
					_tmp28_ = _tmp27_->content;
					_tmp29_ = atoi (_tmp28_);
					rygel_visual_item_set_width ((RygelVisualItem*) self, _tmp29_);
				} else {
					xmlNode* _tmp30_ = NULL;
					const gchar* _tmp31_ = NULL;
					_tmp30_ = it;
					_tmp31_ = _tmp30_->name;
					if (g_strcmp0 (_tmp31_, "height") == 0) {
						xmlNode* _tmp32_ = NULL;
						xmlNode* _tmp33_ = NULL;
						const gchar* _tmp34_ = NULL;
						gint _tmp35_ = 0;
						_tmp32_ = it;
						_tmp33_ = _tmp32_->children;
						_tmp34_ = _tmp33_->content;
						_tmp35_ = atoi (_tmp34_);
						rygel_visual_item_set_height ((RygelVisualItem*) self, _tmp35_);
					} else {
						xmlNode* _tmp36_ = NULL;
						const gchar* _tmp37_ = NULL;
						_tmp36_ = it;
						_tmp37_ = _tmp36_->name;
						if (g_strcmp0 (_tmp37_, "format") == 0) {
							const gchar* _tmp38_ = NULL;
							const gchar* _tmp39_ = NULL;
							xmlNode* _tmp40_ = NULL;
							xmlNode* _tmp41_ = NULL;
							const gchar* _tmp42_ = NULL;
							gchar* _tmp43_ = NULL;
							gchar* _tmp44_ = NULL;
							gchar* _tmp45_ = NULL;
							gchar* _tmp46_ = NULL;
							_tmp38_ = rygel_media_file_item_get_dlna_profile ((RygelMediaFileItem*) self);
							_tmp39_ = _tmp38_;
							_tmp40_ = it;
							_tmp41_ = _tmp40_->children;
							_tmp42_ = _tmp41_->content;
							_tmp43_ = g_strconcat ("_", _tmp42_, NULL);
							_tmp44_ = _tmp43_;
							_tmp45_ = g_strconcat (_tmp39_, _tmp44_, NULL);
							_tmp46_ = _tmp45_;
							rygel_media_file_item_set_dlna_profile ((RygelMediaFileItem*) self, _tmp46_);
							_g_free0 (_tmp46_);
							_g_free0 (_tmp44_);
						}
					}
				}
			}
			_tmp47_ = it;
			_tmp48_ = _tmp47_->next;
			it = _tmp48_;
		}
		_tmp49_ = rygel_media_engine_get_default ();
		_data6_->media_engine = _tmp49_;
		_tmp50_ = _data6_->media_engine;
		rygel_media_engine_get_resources_for_item (_tmp50_, (RygelMediaObject*) self, ____lambda4__gasync_ready_callback, block6_data_ref (_data6_));
		__vala_SoupURI_free0 (uri);
		block6_data_unref (_data6_);
		_data6_ = NULL;
	}
}


static RygelMediaResource* rygel_media_export_dvd_track_real_get_primary_resource (RygelMediaFileItem* base) {
	RygelMediaExportDVDTrack * self;
	RygelMediaResource* result = NULL;
	RygelMediaResource* res = NULL;
	RygelMediaResource* _tmp0_ = NULL;
	self = (RygelMediaExportDVDTrack*) base;
	_tmp0_ = RYGEL_MEDIA_FILE_ITEM_CLASS (rygel_media_export_dvd_track_parent_class)->get_primary_resource ((RygelMediaFileItem*) G_TYPE_CHECK_INSTANCE_CAST (self, RYGEL_MEDIA_EXPORT_TYPE_VIDEO_ITEM, RygelMediaExportVideoItem));
	res = _tmp0_;
	rygel_media_resource_set_dlna_operation (res, GUPNP_DLNA_OPERATION_TIMESEEK);
	rygel_media_resource_set_extension (res, "mpg");
	result = res;
	return result;
}


static void rygel_media_export_dvd_track_real_commit_custom_data_free (gpointer _data) {
	RygelMediaExportDvdTrackCommitCustomData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (RygelMediaExportDvdTrackCommitCustomData, _data_);
}


static gpointer _g_object_ref0 (gpointer self) {
	return self ? g_object_ref (self) : NULL;
}


static void rygel_media_export_dvd_track_real_commit_custom (RygelMediaExportVideoItem* base, gboolean override_guarded, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	RygelMediaExportDVDTrack * self;
	RygelMediaExportDvdTrackCommitCustomData* _data_;
	RygelMediaExportDVDTrack* _tmp0_ = NULL;
	gboolean _tmp1_ = FALSE;
	self = (RygelMediaExportDVDTrack*) base;
	_data_ = g_slice_new0 (RygelMediaExportDvdTrackCommitCustomData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, rygel_media_export_dvd_track_real_commit_custom);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, rygel_media_export_dvd_track_real_commit_custom_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = override_guarded;
	_data_->override_guarded = _tmp1_;
	rygel_media_export_dvd_track_real_commit_custom_co (_data_);
}


static void rygel_media_export_dvd_track_real_commit_custom_finish (RygelMediaExportVideoItem* base, GAsyncResult* _res_, GError** error) {
	RygelMediaExportDvdTrackCommitCustomData* _data_;
	if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (_res_), error)) {
		return;
	}
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
}


static void rygel_media_export_dvd_track_commit_custom_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
	RygelMediaExportDvdTrackCommitCustomData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	rygel_media_export_dvd_track_real_commit_custom_co (_data_);
}


static gboolean rygel_media_export_dvd_track_real_commit_custom_co (RygelMediaExportDvdTrackCommitCustomData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = NULL;
	_data_->_tmp0_ = _data_->self->priv->_node;
	if (_data_->_tmp0_ == NULL) {
		_data_->_tmp1_ = FALSE;
		_data_->_tmp1_ = _data_->override_guarded;
		_data_->_state_ = 1;
		RYGEL_MEDIA_EXPORT_VIDEO_ITEM_CLASS (rygel_media_export_dvd_track_parent_class)->commit_custom (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, RYGEL_MEDIA_EXPORT_TYPE_VIDEO_ITEM, RygelMediaExportVideoItem), _data_->_tmp1_, rygel_media_export_dvd_track_commit_custom_ready, _data_);
		return FALSE;
		_state_1:
		RYGEL_MEDIA_EXPORT_VIDEO_ITEM_CLASS (rygel_media_export_dvd_track_parent_class)->commit_custom_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, RYGEL_MEDIA_EXPORT_TYPE_VIDEO_ITEM, RygelMediaExportVideoItem), _data_->_res_, &_data_->_inner_error_);
		if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
			g_simple_async_result_set_from_error (_data_->_async_result, _data_->_inner_error_);
			g_error_free (_data_->_inner_error_);
			if (_data_->_state_ == 0) {
				g_simple_async_result_complete_in_idle (_data_->_async_result);
			} else {
				g_simple_async_result_complete (_data_->_async_result);
			}
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
	}
	if (_data_->_state_ == 0) {
		g_simple_async_result_complete_in_idle (_data_->_async_result);
	} else {
		g_simple_async_result_complete (_data_->_async_result);
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}


static xmlNode* rygel_media_export_dvd_track_get_node (RygelMediaExportDVDTrack* self) {
	xmlNode* result;
	xmlNode* _tmp0_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_node;
	result = _tmp0_;
	return result;
}


void rygel_media_export_dvd_track_set_node (RygelMediaExportDVDTrack* self, xmlNode* value) {
	xmlNode* _tmp0_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	self->priv->_node = _tmp0_;
	g_object_notify ((GObject *) self, "node");
}


static gint rygel_media_export_dvd_track_get_track (RygelMediaExportDVDTrack* self) {
	gint result;
	gint _tmp0_ = 0;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = self->priv->_track;
	result = _tmp0_;
	return result;
}


void rygel_media_export_dvd_track_set_track (RygelMediaExportDVDTrack* self, gint value) {
	gint _tmp0_ = 0;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	self->priv->_track = _tmp0_;
	g_object_notify ((GObject *) self, "track");
}


static void rygel_media_export_dvd_track_class_init (RygelMediaExportDVDTrackClass * klass) {
	rygel_media_export_dvd_track_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (RygelMediaExportDVDTrackPrivate));
	((GObjectClass *) klass)->constructed = rygel_media_export_dvd_track_real_constructed;
	((RygelMediaFileItemClass *) klass)->get_primary_resource = rygel_media_export_dvd_track_real_get_primary_resource;
	((RygelMediaExportVideoItemClass *) klass)->commit_custom = rygel_media_export_dvd_track_real_commit_custom;
	((RygelMediaExportVideoItemClass *) klass)->commit_custom_finish = rygel_media_export_dvd_track_real_commit_custom_finish;
	G_OBJECT_CLASS (klass)->get_property = _vala_rygel_media_export_dvd_track_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_rygel_media_export_dvd_track_set_property;
	G_OBJECT_CLASS (klass)->finalize = rygel_media_export_dvd_track_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), RYGEL_MEDIA_EXPORT_DVD_TRACK_NODE, g_param_spec_pointer ("node", "node", "node", G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
	g_object_class_install_property (G_OBJECT_CLASS (klass), RYGEL_MEDIA_EXPORT_DVD_TRACK_TRACK, g_param_spec_int ("track", "track", "track", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
}


static void rygel_media_export_dvd_track_instance_init (RygelMediaExportDVDTrack * self) {
	self->priv = RYGEL_MEDIA_EXPORT_DVD_TRACK_GET_PRIVATE (self);
}


static void rygel_media_export_dvd_track_finalize (GObject* obj) {
	RygelMediaExportDVDTrack * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_MEDIA_EXPORT_TYPE_DVD_TRACK, RygelMediaExportDVDTrack);
	G_OBJECT_CLASS (rygel_media_export_dvd_track_parent_class)->finalize (obj);
}


GType rygel_media_export_dvd_track_get_type (void) {
	static volatile gsize rygel_media_export_dvd_track_type_id__volatile = 0;
	if (g_once_init_enter (&rygel_media_export_dvd_track_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (RygelMediaExportDVDTrackClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rygel_media_export_dvd_track_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RygelMediaExportDVDTrack), 0, (GInstanceInitFunc) rygel_media_export_dvd_track_instance_init, NULL };
		GType rygel_media_export_dvd_track_type_id;
		rygel_media_export_dvd_track_type_id = g_type_register_static (RYGEL_MEDIA_EXPORT_TYPE_VIDEO_ITEM, "RygelMediaExportDVDTrack", &g_define_type_info, 0);
		g_once_init_leave (&rygel_media_export_dvd_track_type_id__volatile, rygel_media_export_dvd_track_type_id);
	}
	return rygel_media_export_dvd_track_type_id__volatile;
}


static void _vala_rygel_media_export_dvd_track_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	RygelMediaExportDVDTrack * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, RYGEL_MEDIA_EXPORT_TYPE_DVD_TRACK, RygelMediaExportDVDTrack);
	switch (property_id) {
		case RYGEL_MEDIA_EXPORT_DVD_TRACK_NODE:
		g_value_set_pointer (value, rygel_media_export_dvd_track_get_node (self));
		break;
		case RYGEL_MEDIA_EXPORT_DVD_TRACK_TRACK:
		g_value_set_int (value, rygel_media_export_dvd_track_get_track (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_rygel_media_export_dvd_track_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	RygelMediaExportDVDTrack * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, RYGEL_MEDIA_EXPORT_TYPE_DVD_TRACK, RygelMediaExportDVDTrack);
	switch (property_id) {
		case RYGEL_MEDIA_EXPORT_DVD_TRACK_NODE:
		rygel_media_export_dvd_track_set_node (self, g_value_get_pointer (value));
		break;
		case RYGEL_MEDIA_EXPORT_DVD_TRACK_TRACK:
		rygel_media_export_dvd_track_set_track (self, g_value_get_int (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}



