/* rygel-media-export-dvd-track.c generated by valac 0.42.2, 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;
enum  {
	RYGEL_MEDIA_EXPORT_DVD_TRACK_0_PROPERTY,
	RYGEL_MEDIA_EXPORT_DVD_TRACK_NODE_PROPERTY,
	RYGEL_MEDIA_EXPORT_DVD_TRACK_TRACK_PROPERTY,
	RYGEL_MEDIA_EXPORT_DVD_TRACK_NUM_PROPERTIES
};
static GParamSpec* rygel_media_export_dvd_track_properties[RYGEL_MEDIA_EXPORT_DVD_TRACK_NUM_PROPERTIES];
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_;
	GTask* _async_result;
	GAsyncReadyCallback _callback_;
	gboolean _task_complete_;
	RygelMediaExportDVDTrack* self;
	gboolean override_guarded;
	xmlNode* _tmp0_;
	GError * _inner_error_;
};


static gint RygelMediaExportDVDTrack_private_offset;
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_UPNP_CLASS RYGEL_VIDEO_ITEM_UPNP_CLASS ".dvdTrack"
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_async_ready_wrapper (GObject *source_object,
                                                                          GAsyncResult *res,
                                                                          void *user_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);


static inline gpointer
rygel_media_export_dvd_track_get_instance_private (RygelMediaExportDVDTrack* self)
{
	return G_STRUCT_MEMBER_P (self, RygelMediaExportDVDTrack_private_offset);
}


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;
	g_return_val_if_fail (id != NULL, NULL);
	g_return_val_if_fail (parent != NULL, NULL);
	g_return_val_if_fail (title != NULL, NULL);
	self = (RygelMediaExportDVDTrack*) g_object_new (object_type, "id", id, "parent", parent, "node", node, "title", title, "track", track, "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;
	gdouble _tmp0_;
	g_return_val_if_fail (str != NULL, 0.0);
	_tmp0_ = g_ascii_strtod (str, NULL);
	result = _tmp0_;
	return result;
}


static void
___lambda4_ (Block6Data* _data6_,
             GObject* obj,
             GAsyncResult* res)
{
	RygelMediaExportDVDTrack* self;
	GeeList* added_resources = NULL;
	RygelMediaEngine* _tmp0_;
	GeeList* _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	GeeList* _tmp6_;
	GeeList* _tmp7_;
	self = _data6_->self;
	g_return_if_fail (res != NULL);
	_tmp0_ = _data6_->media_engine;
	_tmp1_ = rygel_media_engine_get_resources_for_item_finish (_tmp0_, res);
	added_resources = _tmp1_;
	_tmp2_ = gee_collection_get_size ((GeeCollection*) added_resources);
	_tmp3_ = _tmp2_;
	_tmp4_ = rygel_media_object_get_primary_uri ((RygelMediaObject*) self);
	_tmp5_ = _tmp4_;
	g_debug ("rygel-media-export-dvd-track.vala:78: Adding %d resources to this sour" \
"ce %s", _tmp3_, _tmp5_);
	_g_free0 (_tmp5_);
	_tmp6_ = rygel_media_object_get_resource_list ((RygelMediaObject*) self);
	_tmp7_ = _tmp6_;
	gee_collection_add_all ((GeeCollection*) _tmp7_, (GeeCollection*) added_resources);
	_g_object_unref0 (_tmp7_);
	_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_;
	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_;
		RygelMediaContainer* _tmp2_;
		gchar* _tmp3_;
		gchar* _tmp4_;
		SoupURI* _tmp5_;
		SoupURI* _tmp6_;
		SoupURI* _tmp7_;
		SoupURI* _tmp8_;
		gint _tmp9_;
		gchar* _tmp10_;
		gchar* _tmp11_;
		SoupURI* _tmp12_;
		gchar* _tmp13_;
		gchar* _tmp14_;
		xmlNode* it = NULL;
		xmlNode* _tmp15_;
		xmlNode* _tmp16_;
		RygelMediaEngine* _tmp46_;
		RygelMediaEngine* _tmp47_;
		_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_;
			xmlNode* _tmp18_;
			const gchar* _tmp19_;
			xmlNode* _tmp44_;
			xmlNode* _tmp45_;
			_tmp17_ = it;
			if (!(_tmp17_ != NULL)) {
				break;
			}
			_tmp18_ = it;
			_tmp19_ = _tmp18_->name;
			if (g_strcmp0 (_tmp19_, "length") == 0) {
				xmlNode* _tmp20_;
				xmlNode* _tmp21_;
				const gchar* _tmp22_;
				_tmp20_ = it;
				_tmp21_ = _tmp20_->children;
				_tmp22_ = _tmp21_->content;
				rygel_audio_item_set_duration ((RygelAudioItem*) self, (glong) ((gint) double_parse (_tmp22_)));
			} else {
				xmlNode* _tmp23_;
				const gchar* _tmp24_;
				_tmp23_ = it;
				_tmp24_ = _tmp23_->name;
				if (g_strcmp0 (_tmp24_, "width") == 0) {
					xmlNode* _tmp25_;
					xmlNode* _tmp26_;
					const gchar* _tmp27_;
					_tmp25_ = it;
					_tmp26_ = _tmp25_->children;
					_tmp27_ = _tmp26_->content;
					rygel_visual_item_set_width ((RygelVisualItem*) self, atoi (_tmp27_));
				} else {
					xmlNode* _tmp28_;
					const gchar* _tmp29_;
					_tmp28_ = it;
					_tmp29_ = _tmp28_->name;
					if (g_strcmp0 (_tmp29_, "height") == 0) {
						xmlNode* _tmp30_;
						xmlNode* _tmp31_;
						const gchar* _tmp32_;
						_tmp30_ = it;
						_tmp31_ = _tmp30_->children;
						_tmp32_ = _tmp31_->content;
						rygel_visual_item_set_height ((RygelVisualItem*) self, atoi (_tmp32_));
					} else {
						xmlNode* _tmp33_;
						const gchar* _tmp34_;
						_tmp33_ = it;
						_tmp34_ = _tmp33_->name;
						if (g_strcmp0 (_tmp34_, "format") == 0) {
							const gchar* _tmp35_;
							const gchar* _tmp36_;
							xmlNode* _tmp37_;
							xmlNode* _tmp38_;
							const gchar* _tmp39_;
							gchar* _tmp40_;
							gchar* _tmp41_;
							gchar* _tmp42_;
							gchar* _tmp43_;
							_tmp35_ = rygel_media_file_item_get_dlna_profile ((RygelMediaFileItem*) self);
							_tmp36_ = _tmp35_;
							_tmp37_ = it;
							_tmp38_ = _tmp37_->children;
							_tmp39_ = _tmp38_->content;
							_tmp40_ = g_strconcat ("_", _tmp39_, NULL);
							_tmp41_ = _tmp40_;
							_tmp42_ = g_strconcat (_tmp36_, _tmp41_, NULL);
							_tmp43_ = _tmp42_;
							rygel_media_file_item_set_dlna_profile ((RygelMediaFileItem*) self, _tmp43_);
							_g_free0 (_tmp43_);
							_g_free0 (_tmp41_);
						}
					}
				}
			}
			_tmp44_ = it;
			_tmp45_ = _tmp44_->next;
			it = _tmp45_;
		}
		_tmp46_ = rygel_media_engine_get_default ();
		_data6_->media_engine = _tmp46_;
		_tmp47_ = _data6_->media_engine;
		rygel_media_engine_get_resources_for_item (_tmp47_, (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_;
	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 void
rygel_media_export_dvd_track_real_commit_custom_async_ready_wrapper (GObject *source_object,
                                                                     GAsyncResult *res,
                                                                     void *user_data)
{
	RygelMediaExportDvdTrackCommitCustomData* _task_data_;
	_task_data_ = g_task_get_task_data (G_TASK (res));
	if (_task_data_->_callback_ != NULL) {
		_task_data_->_callback_ (source_object, res, user_data);
	}
	_task_data_->_task_complete_ = TRUE;
}


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_;
	self = (RygelMediaExportDVDTrack*) base;
	_data_ = g_slice_new0 (RygelMediaExportDvdTrackCommitCustomData);
	_data_->_callback_ = _callback_;
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, rygel_media_export_dvd_track_real_commit_custom_async_ready_wrapper, _user_data_);
	if (_callback_ == NULL) {
		_data_->_task_complete_ = TRUE;
	}
	g_task_set_task_data (_data_->_async_result, _data_, rygel_media_export_dvd_track_real_commit_custom_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->override_guarded = override_guarded;
	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_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}


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_;
	_data_->_task_complete_ = TRUE;
	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_ = _data_->self->priv->_node;
	if (_data_->_tmp0_ == NULL) {
		_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_->override_guarded, 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_task_return_error (_data_->_async_result, _data_->_inner_error_);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
	}
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (_data_->_task_complete_ != TRUE) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}


static xmlNode*
rygel_media_export_dvd_track_get_node (RygelMediaExportDVDTrack* self)
{
	xmlNode* result;
	xmlNode* _tmp0_;
	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)
{
	g_return_if_fail (self != NULL);
	if (rygel_media_export_dvd_track_get_node (self) != value) {
		self->priv->_node = value;
		g_object_notify_by_pspec ((GObject *) self, rygel_media_export_dvd_track_properties[RYGEL_MEDIA_EXPORT_DVD_TRACK_NODE_PROPERTY]);
	}
}


static gint
rygel_media_export_dvd_track_get_track (RygelMediaExportDVDTrack* self)
{
	gint result;
	gint _tmp0_;
	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)
{
	g_return_if_fail (self != NULL);
	if (rygel_media_export_dvd_track_get_track (self) != value) {
		self->priv->_track = value;
		g_object_notify_by_pspec ((GObject *) self, rygel_media_export_dvd_track_properties[RYGEL_MEDIA_EXPORT_DVD_TRACK_TRACK_PROPERTY]);
	}
}


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_adjust_private_offset (klass, &RygelMediaExportDVDTrack_private_offset);
	((GObjectClass *) klass)->constructed = (void (*) (GObject *)) rygel_media_export_dvd_track_real_constructed;
	((RygelMediaFileItemClass *) klass)->get_primary_resource = (RygelMediaResource* (*) (RygelMediaFileItem *)) rygel_media_export_dvd_track_real_get_primary_resource;
	((RygelMediaExportVideoItemClass *) klass)->commit_custom = (void (*) (RygelMediaExportVideoItem *, gboolean, GAsyncReadyCallback, gpointer)) rygel_media_export_dvd_track_real_commit_custom;
	((RygelMediaExportVideoItemClass *) klass)->commit_custom_finish = (void (*) (RygelMediaExportVideoItem *, GAsyncResult*, GError**)) 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_PROPERTY, rygel_media_export_dvd_track_properties[RYGEL_MEDIA_EXPORT_DVD_TRACK_NODE_PROPERTY] = g_param_spec_pointer ("node", "node", "node", G_PARAM_STATIC_STRINGS | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
	g_object_class_install_property (G_OBJECT_CLASS (klass), RYGEL_MEDIA_EXPORT_DVD_TRACK_TRACK_PROPERTY, rygel_media_export_dvd_track_properties[RYGEL_MEDIA_EXPORT_DVD_TRACK_TRACK_PROPERTY] = g_param_spec_int ("track", "track", "track", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | 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_instance_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);
		RygelMediaExportDVDTrack_private_offset = g_type_add_instance_private (rygel_media_export_dvd_track_type_id, sizeof (RygelMediaExportDVDTrackPrivate));
		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_PROPERTY:
		g_value_set_pointer (value, rygel_media_export_dvd_track_get_node (self));
		break;
		case RYGEL_MEDIA_EXPORT_DVD_TRACK_TRACK_PROPERTY:
		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_PROPERTY:
		rygel_media_export_dvd_track_set_node (self, g_value_get_pointer (value));
		break;
		case RYGEL_MEDIA_EXPORT_DVD_TRACK_TRACK_PROPERTY:
		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;
	}
}



