/* rygel-media-export-dvd-track.c generated by valac 0.56.19, 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 "rygel-server.h"
#include "rygel-media-export.h"
#include <glib-object.h>
#include <gio/gio.h>
#include <glib.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_DVD_TRACK_UPNP_CLASS RYGEL_VIDEO_ITEM_UPNP_CLASS ".dvdTrack"
#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

#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 _g_uri_unref0(var) ((var == NULL) ? NULL : (var = (g_uri_unref (var), NULL)))
typedef struct _RygelMediaExportDvdTrackCommitCustomData RygelMediaExportDvdTrackCommitCustomData;

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;
	RygelMediaExportDVDTrack* self;
	gboolean override_guarded;
	xmlNode* _tmp0_;
	GError* _inner_error0_;
};

static gint RygelMediaExportDVDTrack_private_offset;
static gpointer rygel_media_export_dvd_track_parent_class = NULL;

VALA_EXTERN GType rygel_media_export_video_item_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType rygel_media_export_dvd_track_get_type (void) G_GNUC_CONST ;
VALA_EXTERN void rygel_media_export_video_item_commit_custom (RygelMediaExportVideoItem* self,
                                                  gboolean override_guarded,
                                                  GAsyncReadyCallback _callback_,
                                                  gpointer _user_data_);
VALA_EXTERN void rygel_media_export_video_item_commit_custom_finish (RygelMediaExportVideoItem* self,
                                                         GAsyncResult* _res_,
                                                         GError** error);
VALA_EXTERN RygelMediaExportDVDTrack* rygel_media_export_dvd_track_new (const gchar* id,
                                                            RygelMediaContainer* parent,
                                                            const gchar* title,
                                                            gint track,
                                                            xmlNode* node);
VALA_EXTERN 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 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_);
static void rygel_media_export_dvd_track_commit_custom_ready (GObject* source_object,
                                                       GAsyncResult* _res_,
                                                       gpointer _user_data_);
VALA_EXTERN void rygel_media_export_dvd_track_set_node (RygelMediaExportDVDTrack* self,
                                            xmlNode* value);
VALA_EXTERN void rygel_media_export_dvd_track_set_track (RygelMediaExportDVDTrack* self,
                                             gint value);
static void rygel_media_export_dvd_track_finalize (GObject * obj);
static GType rygel_media_export_dvd_track_get_type_once (void);
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;
	g_return_val_if_fail (str != NULL, -1.0);
	result = g_ascii_strtod (str, NULL);
	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:86: 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
rygel_media_export_dvd_track_real_constructed (GObject* base)
{
	RygelMediaExportDVDTrack * self;
	xmlNode* _tmp0_;
	GError* _inner_error0_ = 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_;
		GUri* uri = NULL;
		GUri* _tmp9_;
		gint _tmp10_;
		gchar* _tmp11_;
		gchar* _tmp12_;
		GUri* _tmp13_;
		GUri* _tmp14_;
		gchar* _tmp15_;
		gchar* _tmp16_;
		xmlNode* it = NULL;
		xmlNode* _tmp17_;
		xmlNode* _tmp18_;
		RygelMediaEngine* _tmp48_;
		RygelMediaEngine* _tmp49_;
		_data6_ = g_slice_new0 (Block6Data);
		_data6_->_ref_count_ = 1;
		_data6_->self = g_object_ref (self);
		{
			GUri* _tmp1_ = NULL;
			RygelMediaContainer* _tmp2_;
			RygelMediaContainer* _tmp3_;
			gchar* _tmp4_;
			gchar* _tmp5_;
			GUri* _tmp6_;
			GUri* _tmp7_;
			GUri* _tmp8_;
			_tmp2_ = rygel_media_object_get_parent ((RygelMediaObject*) self);
			_tmp3_ = _tmp2_;
			_tmp4_ = rygel_media_object_get_primary_uri ((RygelMediaObject*) _tmp3_);
			_tmp5_ = _tmp4_;
			_tmp6_ = g_uri_parse (_tmp5_, G_URI_FLAGS_NONE, &_inner_error0_);
			_tmp7_ = _tmp6_;
			_g_free0 (_tmp5_);
			_tmp1_ = _tmp7_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
			_tmp8_ = _tmp1_;
			_tmp1_ = NULL;
			_g_uri_unref0 (uri);
			uri = _tmp8_;
			_g_uri_unref0 (_tmp1_);
		}
		goto __finally0;
		__catch0_g_error:
		{
			g_clear_error (&_inner_error0_);
			g_assert_not_reached ();
		}
		__finally0:
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_uri_unref0 (uri);
			block6_data_unref (_data6_);
			_data6_ = NULL;
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return;
		}
		_tmp9_ = uri;
		_tmp10_ = self->priv->_track;
		_tmp11_ = g_strdup_printf ("title=%d", _tmp10_ + 1);
		_tmp12_ = _tmp11_;
		_tmp13_ = soup_uri_copy (_tmp9_, SOUP_URI_SCHEME, "dvd", SOUP_URI_QUERY, _tmp12_, SOUP_URI_NONE, SOUP_URI_NONE);
		_g_uri_unref0 (uri);
		uri = _tmp13_;
		_g_free0 (_tmp12_);
		_tmp14_ = uri;
		_tmp15_ = g_uri_to_string (_tmp14_);
		_tmp16_ = _tmp15_;
		rygel_media_object_add_uri ((RygelMediaObject*) self, _tmp16_);
		_g_free0 (_tmp16_);
		rygel_media_file_item_set_dlna_profile ((RygelMediaFileItem*) self, "MPEG_PS");
		rygel_media_file_item_set_mime_type ((RygelMediaFileItem*) self, "video/mpeg");
		_tmp17_ = self->priv->_node;
		_tmp18_ = _tmp17_->children;
		it = _tmp18_;
		while (TRUE) {
			xmlNode* _tmp19_;
			xmlNode* _tmp20_;
			const gchar* _tmp21_;
			xmlNode* _tmp46_;
			xmlNode* _tmp47_;
			_tmp19_ = it;
			if (!(_tmp19_ != NULL)) {
				break;
			}
			_tmp20_ = it;
			_tmp21_ = _tmp20_->name;
			if (g_strcmp0 (_tmp21_, "length") == 0) {
				xmlNode* _tmp22_;
				xmlNode* _tmp23_;
				const gchar* _tmp24_;
				_tmp22_ = it;
				_tmp23_ = _tmp22_->children;
				_tmp24_ = _tmp23_->content;
				rygel_audio_item_set_duration ((RygelAudioItem*) self, (glong) ((gint) double_parse (_tmp24_)));
			} else {
				xmlNode* _tmp25_;
				const gchar* _tmp26_;
				_tmp25_ = it;
				_tmp26_ = _tmp25_->name;
				if (g_strcmp0 (_tmp26_, "width") == 0) {
					xmlNode* _tmp27_;
					xmlNode* _tmp28_;
					const gchar* _tmp29_;
					_tmp27_ = it;
					_tmp28_ = _tmp27_->children;
					_tmp29_ = _tmp28_->content;
					rygel_visual_item_set_width ((RygelVisualItem*) self, atoi (_tmp29_));
				} else {
					xmlNode* _tmp30_;
					const gchar* _tmp31_;
					_tmp30_ = it;
					_tmp31_ = _tmp30_->name;
					if (g_strcmp0 (_tmp31_, "height") == 0) {
						xmlNode* _tmp32_;
						xmlNode* _tmp33_;
						const gchar* _tmp34_;
						_tmp32_ = it;
						_tmp33_ = _tmp32_->children;
						_tmp34_ = _tmp33_->content;
						rygel_visual_item_set_height ((RygelVisualItem*) self, atoi (_tmp34_));
					} else {
						xmlNode* _tmp35_;
						const gchar* _tmp36_;
						_tmp35_ = it;
						_tmp36_ = _tmp35_->name;
						if (g_strcmp0 (_tmp36_, "format") == 0) {
							const gchar* _tmp37_;
							const gchar* _tmp38_;
							xmlNode* _tmp39_;
							xmlNode* _tmp40_;
							const gchar* _tmp41_;
							gchar* _tmp42_;
							gchar* _tmp43_;
							gchar* _tmp44_;
							gchar* _tmp45_;
							_tmp37_ = rygel_media_file_item_get_dlna_profile ((RygelMediaFileItem*) self);
							_tmp38_ = _tmp37_;
							_tmp39_ = it;
							_tmp40_ = _tmp39_->children;
							_tmp41_ = _tmp40_->content;
							_tmp42_ = g_strconcat ("_", _tmp41_, NULL);
							_tmp43_ = _tmp42_;
							_tmp44_ = g_strconcat (_tmp38_, _tmp43_, NULL);
							_tmp45_ = _tmp44_;
							rygel_media_file_item_set_dlna_profile ((RygelMediaFileItem*) self, _tmp45_);
							_g_free0 (_tmp45_);
							_g_free0 (_tmp43_);
						}
					}
				}
			}
			_tmp46_ = it;
			_tmp47_ = _tmp46_->next;
			it = _tmp47_;
		}
		_tmp48_ = rygel_media_engine_get_default ();
		_data6_->media_engine = _tmp48_;
		_tmp49_ = _data6_->media_engine;
		rygel_media_engine_get_resources_for_item (_tmp49_, (RygelMediaObject*) self, ____lambda4__gasync_ready_callback, block6_data_ref (_data6_));
		_g_uri_unref0 (uri);
		block6_data_unref (_data6_);
		_data6_ = NULL;
	}
}

static RygelMediaResource*
rygel_media_export_dvd_track_real_get_primary_resource (RygelMediaFileItem* base)
{
	RygelMediaExportDVDTrack * self;
	RygelMediaResource* res = NULL;
	RygelMediaResource* _tmp0_;
	RygelMediaResource* result;
	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_;
	self = (RygelMediaExportDVDTrack*) base;
	_data_ = g_slice_new0 (RygelMediaExportDvdTrackCommitCustomData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	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_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_;
	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_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
	}
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			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)
{
	xmlNode* old_value;
	g_return_if_fail (self != NULL);
	old_value = rygel_media_export_dvd_track_get_node (self);
	if (old_value != 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;
	g_return_val_if_fail (self != NULL, -1);
	result = self->priv->_track;
	return result;
}

void
rygel_media_export_dvd_track_set_track (RygelMediaExportDVDTrack* self,
                                        gint value)
{
	gint old_value;
	g_return_if_fail (self != NULL);
	old_value = rygel_media_export_dvd_track_get_track (self);
	if (old_value != 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,
                                         gpointer klass_data)
{
	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_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,
                                            gpointer klass)
{
	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);
}

 G_GNUC_NO_INLINE static GType
rygel_media_export_dvd_track_get_type_once (void)
{
	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));
	return rygel_media_export_dvd_track_type_id;
}

GType
rygel_media_export_dvd_track_get_type (void)
{
	static volatile gsize rygel_media_export_dvd_track_type_id__once = 0;
	if (g_once_init_enter (&rygel_media_export_dvd_track_type_id__once)) {
		GType rygel_media_export_dvd_track_type_id;
		rygel_media_export_dvd_track_type_id = rygel_media_export_dvd_track_get_type_once ();
		g_once_init_leave (&rygel_media_export_dvd_track_type_id__once, rygel_media_export_dvd_track_type_id);
	}
	return rygel_media_export_dvd_track_type_id__once;
}

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;
	}
}

