/* rygel-media-export-extract.c generated by valac 0.29.2, the Vala compiler
 * generated from rygel-media-export-extract.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 <stdlib.h>
#include <string.h>
#include <gio/gio.h>
#include <gst/pbutils/pbutils.h>
#include <libgupnp-dlna/gupnp-dlna.h>
#include <unistd.h>
#include <glib/gi18n-lib.h>
#include <gst/gst.h>
#include <libgupnp-dlna/gupnp-dlna-gst-utils.h>
#include <signal.h>
#include <gio/gunixinputstream.h>
#include <gio/gunixoutputstream.h>


#define RYGEL_TYPE_INFO_SERIALIZER (rygel_info_serializer_get_type ())
#define RYGEL_INFO_SERIALIZER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_INFO_SERIALIZER, RygelInfoSerializer))
#define RYGEL_INFO_SERIALIZER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_INFO_SERIALIZER, RygelInfoSerializerClass))
#define RYGEL_IS_INFO_SERIALIZER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_INFO_SERIALIZER))
#define RYGEL_IS_INFO_SERIALIZER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_INFO_SERIALIZER))
#define RYGEL_INFO_SERIALIZER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_INFO_SERIALIZER, RygelInfoSerializerClass))

typedef struct _RygelInfoSerializer RygelInfoSerializer;
typedef struct _RygelInfoSerializerClass RygelInfoSerializerClass;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _RunData RunData;
#define _g_bytes_unref0(var) ((var == NULL) ? NULL : (var = (g_bytes_unref (var), NULL)))
typedef struct _OnDiscoveredData OnDiscoveredData;
#define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL)))
typedef struct _ExtractBasicInformationData ExtractBasicInformationData;
#define _g_option_context_free0(var) ((var == NULL) ? NULL : (var = (g_option_context_free (var), NULL)))
#define _rygel_info_serializer_unref0(var) ((var == NULL) ? NULL : (var = (rygel_info_serializer_unref (var), NULL)))
#define _g_main_loop_unref0(var) ((var == NULL) ? NULL : (var = (g_main_loop_unref (var), NULL)))

typedef enum  {
	METADATA_EXTRACTOR_ERROR_GENERAL
} MetadataExtractorError;
#define METADATA_EXTRACTOR_ERROR metadata_extractor_error_quark ()
struct _RunData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	gchar* line;
	GDataInputStream* _tmp0_;
	gchar* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gboolean _tmp4_;
	const gchar* _tmp5_;
	gchar* uri;
	const gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	GstDiscovererInfo* info;
	const gchar* _tmp11_;
	gint _tmp12_;
	gint _tmp13_;
	const gchar* _tmp14_;
	const gchar* _tmp15_;
	gint _tmp16_;
	gint _tmp17_;
	GstDiscovererInfo* _tmp18_;
	GstDiscoverer* _tmp19_;
	const gchar* _tmp20_;
	GstDiscovererInfo* _tmp21_;
	GstDiscovererInfo* _tmp22_;
	const gchar* _tmp23_;
	GstDiscovererInfo* _tmp24_;
	GError* _error_;
	const gchar* _tmp25_;
	const gchar* _tmp26_;
	GError* _tmp27_;
	const gchar* _tmp28_;
	const gchar* _tmp29_;
	GFile* _tmp30_;
	GFile* _tmp31_;
	GError* _tmp32_;
	GstDiscoverer* _tmp33_;
	GstDiscoverer* _tmp34_;
	GstDiscoverer* _tmp35_;
	const gchar* _tmp36_;
	gboolean _tmp37_;
	GError* _vala1__error_;
	const gchar* _tmp38_;
	GError* _tmp39_;
	const gchar* _tmp40_;
	GMainLoop* _tmp41_;
	GError * _inner_error_;
};

struct _OnDiscoveredData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	GstDiscovererInfo* info;
	GstDiscovererInfo* _tmp0_;
	const gchar* _tmp1_;
	GFile* file;
	GstDiscovererInfo* _tmp2_;
	const gchar* _tmp3_;
	GFile* _tmp4_;
	gboolean _tmp5_;
	gboolean _tmp6_;
	GstDiscovererInfo* _tmp7_;
	GstDiscovererResult _tmp8_;
	GstDiscovererInfo* _tmp9_;
	GstDiscovererResult _tmp10_;
	GstDiscovererInfo* _tmp11_;
	GstDiscovererResult _tmp12_;
	GstDiscovererInfo* _tmp13_;
	GstDiscovererResult _tmp14_;
	GstDiscovererInfo* _tmp15_;
	const gchar* _tmp16_;
	GFile* _tmp17_;
	gchar* _tmp18_;
	gchar* _tmp19_;
	GFile* _tmp20_;
	GUPnPDLNAInformation* dlna_info;
	GstDiscovererInfo* _tmp21_;
	GUPnPDLNAInformation* _tmp22_;
	GUPnPDLNAProfile* dlna;
	GUPnPDLNAProfileGuesser* _tmp23_;
	GUPnPDLNAInformation* _tmp24_;
	GUPnPDLNAProfile* _tmp25_;
	GUPnPDLNAProfile* _tmp26_;
	GFile* _tmp27_;
	GstDiscovererInfo* _tmp28_;
	GUPnPDLNAProfile* _tmp29_;
};

struct _ExtractBasicInformationData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	GFile* file;
	GstDiscovererInfo* info;
	GUPnPDLNAProfile* dlna;
	GFileInfo* file_info;
	GFileInfo* _tmp0_;
	GFile* _tmp1_;
	GFileInfo* _tmp2_;
	GFileInfo* _tmp3_;
	GError* _error_;
	gchar* uri;
	GFile* _tmp4_;
	gchar* _tmp5_;
	const gchar* _tmp6_;
	const gchar* _tmp7_;
	GError* _tmp8_;
	const gchar* _tmp9_;
	GFile* _tmp10_;
	GError* _tmp11_;
	GVariant* _tmp12_;
	RygelInfoSerializer* _tmp13_;
	GFile* _tmp14_;
	GFileInfo* _tmp15_;
	GstDiscovererInfo* _tmp16_;
	GUPnPDLNAProfile* _tmp17_;
	GVariant* _tmp18_;
	GFile* _tmp19_;
	GError* _vala1__error_;
	GFile* _tmp20_;
	GError* _tmp21_;
	GError * _inner_error_;
};


extern gint in_fd;
gint in_fd = 0;
extern gint out_fd;
gint out_fd = 1;
extern gint err_fd;
gint err_fd = 2;
extern GMainLoop* loop;
GMainLoop* loop = NULL;
extern GDataInputStream* input_stream;
GDataInputStream* input_stream = NULL;
extern GOutputStream* output_stream;
GOutputStream* output_stream = NULL;
extern GOutputStream* error_stream;
GOutputStream* error_stream = NULL;
extern RygelInfoSerializer* serializer;
RygelInfoSerializer* serializer = NULL;
extern GstDiscoverer* discoverer;
GstDiscoverer* discoverer = NULL;
extern GUPnPDLNAProfileGuesser* guesser;
GUPnPDLNAProfileGuesser* guesser = NULL;
extern guint8 last_uri_data[4096];
guint8 last_uri_data[4096] = {0};
extern gsize last_uri_data_length;
gsize last_uri_data_length = 0UL;

#define UPNP_CLASS_PHOTO "object.item.imageItem.photo"
#define UPNP_CLASS_MUSIC "object.item.audioItem.musicTrack"
#define UPNP_CLASS_VIDEO "object.item.videoItem"
#define UPNP_CLASS_PLAYLIST "object.item.playlistItem"
#define STATUS_LINE_TEMPLATE "RESULT|%s|%" G_GSIZE_FORMAT "|%s\n"
#define ERROR_LINE_TEMPLATE "ERROR|%s|%d|%s\n"
#define FATAL_ERROR_PREFIX "FATAL_ERROR|"
#define FATAL_ERROR_SUFFIX "\n"
gpointer rygel_info_serializer_ref (gpointer instance);
void rygel_info_serializer_unref (gpointer instance);
GParamSpec* rygel_param_spec_info_serializer (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void rygel_value_set_info_serializer (GValue* value, gpointer v_object);
void rygel_value_take_info_serializer (GValue* value, gpointer v_object);
gpointer rygel_value_get_info_serializer (const GValue* value);
GType rygel_info_serializer_get_type (void) G_GNUC_CONST;
GQuark metadata_extractor_error_quark (void);
void segv_handler (gint signal);
static void run_data_free (gpointer _data);
void run (GAsyncReadyCallback _callback_, gpointer _user_data_);
void run_finish (GAsyncResult* _res_);
static gboolean run_co (RunData* _data_);
static void run_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
void on_discovered (GstDiscovererInfo* info, GAsyncReadyCallback _callback_, gpointer _user_data_);
void on_discovered_finish (GAsyncResult* _res_);
void send_error (GFile* file, GError* err);
void send_extraction_done (GFile* file, GVariant* v, GError** error);
static void on_discovered_data_free (gpointer _data);
static gboolean on_discovered_co (OnDiscoveredData* _data_);
void extract_basic_information (GFile* file, GstDiscovererInfo* info, GUPnPDLNAProfile* dlna, GAsyncReadyCallback _callback_, gpointer _user_data_);
void extract_basic_information_finish (GAsyncResult* _res_);
static void on_discovered_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
static void extract_basic_information_data_free (gpointer _data);
static gboolean extract_basic_information_co (ExtractBasicInformationData* _data_);
static void extract_basic_information_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
GVariant* rygel_info_serializer_serialize (RygelInfoSerializer* self, GFile* file, GFileInfo* file_info, GstDiscovererInfo* info, GUPnPDLNAProfile* dlna_profile, GError** error);
gint _vala_main (gchar** args, int args_length1);
RygelInfoSerializer* rygel_info_serializer_new (void);
RygelInfoSerializer* rygel_info_serializer_construct (GType object_type);
static void _segv_handler_sighandler_t (gint signal);

const GOptionEntry options[4] = {{"input-fd", 'i', 0, G_OPTION_ARG_INT, &in_fd, "File descriptor used for input", NULL}, {"output-fd", 'o', 0, G_OPTION_ARG_INT, &out_fd, "File descriptor used for output", NULL}, {"error-fd", 'e', 0, G_OPTION_ARG_INT, &err_fd, "File descriptor used for severe errors", NULL}, {NULL}};

GQuark metadata_extractor_error_quark (void) {
	return g_quark_from_static_string ("metadata_extractor_error-quark");
}


void segv_handler (gint signal) {
	gint _tmp0_ = 0;
	gsize _tmp1_ = 0UL;
	gint _tmp2_ = 0;
	gint _tmp3_ = 0;
	_tmp0_ = err_fd;
	_tmp1_ = last_uri_data_length;
	write (_tmp0_, (void*) last_uri_data, _tmp1_);
	_tmp2_ = err_fd;
	write (_tmp2_, (void*) FATAL_ERROR_SUFFIX, (gsize) 1);
	_tmp3_ = err_fd;
	fsync (_tmp3_);
	exit (-1);
}


static void run_data_free (gpointer _data) {
	RunData* _data_;
	_data_ = _data;
	g_slice_free (RunData, _data_);
}


void run (GAsyncReadyCallback _callback_, gpointer _user_data_) {
	RunData* _data_;
	_data_ = g_slice_new0 (RunData);
	_data_->_async_result = g_simple_async_result_new (NULL, _callback_, _user_data_, run);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, run_data_free);
	run_co (_data_);
}


void run_finish (GAsyncResult* _res_) {
	RunData* _data_;
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
}


static void run_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
	RunData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	run_co (_data_);
}


static gchar* string_replace (const gchar* self, const gchar* old, const gchar* replacement) {
	gchar* result = NULL;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (old != NULL, NULL);
	g_return_val_if_fail (replacement != NULL, NULL);
	{
		GRegex* regex = NULL;
		const gchar* _tmp0_ = NULL;
		gchar* _tmp1_ = NULL;
		gchar* _tmp2_ = NULL;
		GRegex* _tmp3_ = NULL;
		GRegex* _tmp4_ = NULL;
		gchar* _tmp5_ = NULL;
		GRegex* _tmp6_ = NULL;
		const gchar* _tmp7_ = NULL;
		gchar* _tmp8_ = NULL;
		gchar* _tmp9_ = NULL;
		_tmp0_ = old;
		_tmp1_ = g_regex_escape_string (_tmp0_, -1);
		_tmp2_ = _tmp1_;
		_tmp3_ = g_regex_new (_tmp2_, 0, 0, &_inner_error_);
		_tmp4_ = _tmp3_;
		_g_free0 (_tmp2_);
		regex = _tmp4_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			if (_inner_error_->domain == G_REGEX_ERROR) {
				goto __catch1_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return NULL;
		}
		_tmp6_ = regex;
		_tmp7_ = replacement;
		_tmp8_ = g_regex_replace_literal (_tmp6_, self, (gssize) -1, 0, _tmp7_, 0, &_inner_error_);
		_tmp5_ = _tmp8_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			_g_regex_unref0 (regex);
			if (_inner_error_->domain == G_REGEX_ERROR) {
				goto __catch1_g_regex_error;
			}
			_g_regex_unref0 (regex);
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return NULL;
		}
		_tmp9_ = _tmp5_;
		_tmp5_ = NULL;
		result = _tmp9_;
		_g_free0 (_tmp5_);
		_g_regex_unref0 (regex);
		return result;
	}
	goto __finally1;
	__catch1_g_regex_error:
	{
		GError* e = NULL;
		e = _inner_error_;
		_inner_error_ = NULL;
		g_assert_not_reached ();
		_g_error_free0 (e);
	}
	__finally1:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return NULL;
	}
}


static gchar* string_strip (const gchar* self) {
	gchar* result = NULL;
	gchar* _result_ = NULL;
	gchar* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup (self);
	_result_ = _tmp0_;
	_tmp1_ = _result_;
	g_strstrip (_tmp1_);
	result = _result_;
	return result;
}


static gboolean run_co (RunData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	while (TRUE) {
		{
			_data_->_tmp0_ = NULL;
			_data_->_tmp0_ = input_stream;
			_data_->_state_ = 1;
			g_data_input_stream_read_line_async (_data_->_tmp0_, G_PRIORITY_DEFAULT, NULL, run_ready, _data_);
			return FALSE;
			_state_1:
			_data_->_tmp1_ = NULL;
			_data_->_tmp1_ = g_data_input_stream_read_line_finish (_data_->_tmp0_, _data_->_res_, NULL, &_data_->_inner_error_);
			_data_->line = _data_->_tmp1_;
			if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
				goto __catch0_g_error;
			}
			_data_->_tmp2_ = NULL;
			_data_->_tmp2_ = _data_->line;
			if (_data_->_tmp2_ == NULL) {
				_g_free0 (_data_->line);
				break;
			}
			_data_->_tmp3_ = NULL;
			_data_->_tmp3_ = _data_->line;
			_data_->_tmp4_ = FALSE;
			_data_->_tmp4_ = g_str_has_prefix (_data_->_tmp3_, "EXTRACT ");
			if (_data_->_tmp4_) {
				_data_->_tmp5_ = NULL;
				_data_->_tmp5_ = _data_->line;
				g_debug ("rygel-media-export-extract.vala:83: Got command to extract file: %s", _data_->_tmp5_);
				_data_->_tmp6_ = NULL;
				_data_->_tmp6_ = _data_->line;
				_data_->_tmp7_ = NULL;
				_data_->_tmp7_ = string_replace (_data_->_tmp6_, "EXTRACT ", "");
				_data_->_tmp8_ = NULL;
				_data_->_tmp8_ = _data_->_tmp7_;
				_data_->_tmp9_ = NULL;
				_data_->_tmp9_ = string_strip (_data_->_tmp8_);
				_data_->_tmp10_ = NULL;
				_data_->_tmp10_ = _data_->_tmp9_;
				_g_free0 (_data_->_tmp8_);
				_data_->uri = _data_->_tmp10_;
				_data_->info = NULL;
				{
					_data_->_tmp11_ = NULL;
					_data_->_tmp11_ = _data_->uri;
					_data_->_tmp12_ = 0;
					_data_->_tmp12_ = strlen (_data_->_tmp11_);
					_data_->_tmp13_ = 0;
					_data_->_tmp13_ = _data_->_tmp12_;
					last_uri_data_length = (gsize) _data_->_tmp13_;
					memset (last_uri_data, 0, (gsize) 4096);
					_data_->_tmp14_ = NULL;
					_data_->_tmp14_ = _data_->uri;
					_data_->_tmp15_ = NULL;
					_data_->_tmp15_ = _data_->uri;
					_data_->_tmp16_ = 0;
					_data_->_tmp16_ = strlen (_data_->_tmp15_);
					_data_->_tmp17_ = 0;
					_data_->_tmp17_ = _data_->_tmp16_;
					memcpy (last_uri_data, (void*) _data_->_tmp14_, (gsize) _data_->_tmp17_);
					_data_->_tmp19_ = NULL;
					_data_->_tmp19_ = discoverer;
					_data_->_tmp20_ = NULL;
					_data_->_tmp20_ = _data_->uri;
					_data_->_tmp21_ = NULL;
					_data_->_tmp21_ = gst_discoverer_discover_uri (_data_->_tmp19_, _data_->_tmp20_, &_data_->_inner_error_);
					_data_->_tmp18_ = _data_->_tmp21_;
					if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
						goto __catch2_g_error;
					}
					_data_->_tmp22_ = NULL;
					_data_->_tmp22_ = _data_->_tmp18_;
					_data_->_tmp18_ = NULL;
					_g_object_unref0 (_data_->info);
					_data_->info = _data_->_tmp22_;
					_data_->_tmp23_ = NULL;
					_data_->_tmp23_ = _data_->uri;
					g_debug ("rygel-media-export-extract.vala:94: Finished discover on uri %s", _data_->_tmp23_);
					_data_->_tmp24_ = NULL;
					_data_->_tmp24_ = _data_->info;
					_data_->_state_ = 2;
					on_discovered (_data_->_tmp24_, run_ready, _data_);
					return FALSE;
					_state_2:
					on_discovered_finish (_data_->_res_);
					_g_object_unref0 (_data_->_tmp18_);
				}
				goto __finally2;
				__catch2_g_error:
				{
					_data_->_error_ = _data_->_inner_error_;
					_data_->_inner_error_ = NULL;
					_data_->_tmp25_ = NULL;
					_data_->_tmp25_ = _ ("Failed to discover uri %s: %s");
					_data_->_tmp26_ = NULL;
					_data_->_tmp26_ = _data_->uri;
					_data_->_tmp27_ = NULL;
					_data_->_tmp27_ = _data_->_error_;
					_data_->_tmp28_ = NULL;
					_data_->_tmp28_ = _data_->_tmp27_->message;
					g_warning (_data_->_tmp25_, _data_->_tmp26_, _data_->_tmp28_);
					_data_->_tmp29_ = NULL;
					_data_->_tmp29_ = _data_->uri;
					_data_->_tmp30_ = NULL;
					_data_->_tmp30_ = g_file_new_for_uri (_data_->_tmp29_);
					_data_->_tmp31_ = NULL;
					_data_->_tmp31_ = _data_->_tmp30_;
					_data_->_tmp32_ = NULL;
					_data_->_tmp32_ = _data_->_error_;
					send_error (_data_->_tmp31_, _data_->_tmp32_);
					_g_object_unref0 (_data_->_tmp31_);
					_data_->_tmp34_ = NULL;
					_data_->_tmp34_ = gst_discoverer_new ((GstClockTime) (10 * GST_SECOND), &_data_->_inner_error_);
					_data_->_tmp33_ = _data_->_tmp34_;
					if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
						_g_error_free0 (_data_->_error_);
						goto __finally2;
					}
					_data_->_tmp35_ = NULL;
					_data_->_tmp35_ = _data_->_tmp33_;
					_data_->_tmp33_ = NULL;
					_g_object_unref0 (discoverer);
					discoverer = _data_->_tmp35_;
					_g_object_unref0 (_data_->_tmp33_);
					_g_error_free0 (_data_->_error_);
				}
				__finally2:
				if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
					_g_object_unref0 (_data_->info);
					_g_free0 (_data_->uri);
					_g_free0 (_data_->line);
					goto __catch0_g_error;
				}
				_g_object_unref0 (_data_->info);
				_g_free0 (_data_->uri);
			} else {
				_data_->_tmp36_ = NULL;
				_data_->_tmp36_ = _data_->line;
				_data_->_tmp37_ = FALSE;
				_data_->_tmp37_ = g_str_has_prefix (_data_->_tmp36_, "QUIT");
				if (_data_->_tmp37_) {
					_g_free0 (_data_->line);
					break;
				}
			}
			_g_free0 (_data_->line);
		}
		goto __finally0;
		__catch0_g_error:
		{
			_data_->_vala1__error_ = _data_->_inner_error_;
			_data_->_inner_error_ = NULL;
			_data_->_tmp38_ = NULL;
			_data_->_tmp38_ = _ ("Failed to read from pipe: %s");
			_data_->_tmp39_ = NULL;
			_data_->_tmp39_ = _data_->_vala1__error_;
			_data_->_tmp40_ = NULL;
			_data_->_tmp40_ = _data_->_tmp39_->message;
			g_warning (_data_->_tmp38_, _data_->_tmp40_);
			_g_error_free0 (_data_->_vala1__error_);
			break;
		}
		__finally0:
		if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error_->message, g_quark_to_string (_data_->_inner_error_->domain), _data_->_inner_error_->code);
			g_clear_error (&_data_->_inner_error_);
			return FALSE;
		}
	}
	_data_->_tmp41_ = NULL;
	_data_->_tmp41_ = loop;
	g_main_loop_quit (_data_->_tmp41_);
	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 guint8* string_get_data (const gchar* self, int* result_length1) {
	guint8* result;
	guint8* res = NULL;
	gint res_length1 = 0;
	gint _res_size_ = 0;
	gint _tmp0_ = 0;
	gint _tmp1_ = 0;
	gint _tmp2_ = 0;
	guint8* _tmp3_ = NULL;
	gint _tmp3__length1 = 0;
	guint8* _tmp4_ = NULL;
	gint _tmp4__length1 = 0;
	g_return_val_if_fail (self != NULL, NULL);
	res = (guint8*) self;
	res_length1 = -1;
	_res_size_ = res_length1;
	_tmp0_ = strlen (self);
	_tmp1_ = _tmp0_;
	res_length1 = (gint) _tmp1_;
	_tmp2_ = res_length1;
	_tmp3_ = res;
	_tmp3__length1 = res_length1;
	_tmp4_ = _tmp3_;
	_tmp4__length1 = _tmp3__length1;
	if (result_length1) {
		*result_length1 = _tmp4__length1;
	}
	result = _tmp4_;
	return result;
}


void send_extraction_done (GFile* file, GVariant* v, GError** error) {
	GBytes* data = NULL;
	GVariant* _tmp0_ = NULL;
	GBytes* _tmp1_ = NULL;
	gsize bytes_written = 0UL;
	gchar* status = NULL;
	GFile* _tmp2_ = NULL;
	gchar* _tmp3_ = NULL;
	gchar* _tmp4_ = NULL;
	GBytes* _tmp5_ = NULL;
	gsize _tmp6_ = 0UL;
	GFile* _tmp7_ = NULL;
	gchar* _tmp8_ = NULL;
	gchar* _tmp9_ = NULL;
	gchar* _tmp10_ = NULL;
	gchar* _tmp11_ = NULL;
	GOutputStream* _tmp12_ = NULL;
	const gchar* _tmp13_ = NULL;
	guint8* _tmp14_ = NULL;
	gint _tmp14__length1 = 0;
	guint8* _tmp15_ = NULL;
	gint _tmp15__length1 = 0;
	gsize _tmp16_ = 0UL;
	GOutputStream* _tmp17_ = NULL;
	GBytes* _tmp18_ = NULL;
	gsize _tmp19_;
	guint8* _tmp20_ = NULL;
	gsize _tmp21_ = 0UL;
	GError * _inner_error_ = NULL;
	g_return_if_fail (file != NULL);
	g_return_if_fail (v != NULL);
	_tmp0_ = v;
	_tmp1_ = g_variant_get_data_as_bytes (_tmp0_);
	data = _tmp1_;
	bytes_written = (gsize) 0;
	_tmp2_ = file;
	_tmp3_ = g_file_get_uri (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = data;
	_tmp6_ = g_bytes_get_size (_tmp5_);
	_tmp7_ = file;
	_tmp8_ = g_file_get_uri (_tmp7_);
	_tmp9_ = _tmp8_;
	_tmp10_ = g_strdup_printf (STATUS_LINE_TEMPLATE, _tmp4_, _tmp6_, _tmp9_);
	_tmp11_ = _tmp10_;
	_g_free0 (_tmp9_);
	_g_free0 (_tmp4_);
	status = _tmp11_;
	_tmp12_ = output_stream;
	_tmp13_ = status;
	_tmp14_ = string_get_data (_tmp13_, &_tmp14__length1);
	_tmp15_ = _tmp14_;
	_tmp15__length1 = _tmp14__length1;
	g_output_stream_write_all (_tmp12_, _tmp15_, (gsize) _tmp15__length1, &_tmp16_, NULL, &_inner_error_);
	bytes_written = _tmp16_;
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_propagate_error (error, _inner_error_);
		_g_free0 (status);
		_g_bytes_unref0 (data);
		return;
	}
	_tmp17_ = output_stream;
	_tmp18_ = data;
	_tmp20_ = g_bytes_get_data (_tmp18_, &_tmp19_);
	g_output_stream_write_all (_tmp17_, _tmp20_, (gsize) _tmp19_, &_tmp21_, NULL, &_inner_error_);
	bytes_written = _tmp21_;
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_propagate_error (error, _inner_error_);
		_g_free0 (status);
		_g_bytes_unref0 (data);
		return;
	}
	_g_free0 (status);
	_g_bytes_unref0 (data);
}


void send_error (GFile* file, GError* err) {
	gsize bytes_written = 0UL;
	gchar* status = NULL;
	GFile* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	GError* _tmp3_ = NULL;
	gint _tmp4_ = 0;
	GError* _tmp5_ = NULL;
	const gchar* _tmp6_ = NULL;
	gchar* _tmp7_ = NULL;
	gchar* _tmp8_ = NULL;
	GError * _inner_error_ = NULL;
	g_return_if_fail (file != NULL);
	bytes_written = (gsize) 0;
	_tmp0_ = file;
	_tmp1_ = g_file_get_uri (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = err;
	_tmp4_ = _tmp3_->code;
	_tmp5_ = err;
	_tmp6_ = _tmp5_->message;
	_tmp7_ = g_strdup_printf (ERROR_LINE_TEMPLATE, _tmp2_, _tmp4_, _tmp6_);
	_tmp8_ = _tmp7_;
	_g_free0 (_tmp2_);
	status = _tmp8_;
	{
		GOutputStream* _tmp9_ = NULL;
		guint8* _tmp10_ = NULL;
		gint _tmp10__length1 = 0;
		guint8* _tmp11_ = NULL;
		gint _tmp11__length1 = 0;
		gsize _tmp12_ = 0UL;
		_tmp9_ = output_stream;
		_tmp10_ = string_get_data (status, &_tmp10__length1);
		_tmp11_ = _tmp10_;
		_tmp11__length1 = _tmp10__length1;
		g_output_stream_write_all (_tmp9_, _tmp11_, (gsize) _tmp11__length1, &_tmp12_, NULL, &_inner_error_);
		bytes_written = _tmp12_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch3_g_error;
		}
	}
	goto __finally3;
	__catch3_g_error:
	{
		GError* _error_ = NULL;
		const gchar* _tmp13_ = NULL;
		GError* _tmp14_ = NULL;
		const gchar* _tmp15_ = NULL;
		_error_ = _inner_error_;
		_inner_error_ = NULL;
		_tmp13_ = _ ("Failed to send error to parent: %s");
		_tmp14_ = _error_;
		_tmp15_ = _tmp14_->message;
		g_warning (_tmp13_, _tmp15_);
		_g_error_free0 (_error_);
	}
	__finally3:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		_g_free0 (status);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return;
	}
	_g_free0 (status);
}


static void on_discovered_data_free (gpointer _data) {
	OnDiscoveredData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->info);
	g_slice_free (OnDiscoveredData, _data_);
}


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


void on_discovered (GstDiscovererInfo* info, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	OnDiscoveredData* _data_;
	GstDiscovererInfo* _tmp0_ = NULL;
	GstDiscovererInfo* _tmp1_ = NULL;
	_data_ = g_slice_new0 (OnDiscoveredData);
	_data_->_async_result = g_simple_async_result_new (NULL, _callback_, _user_data_, on_discovered);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, on_discovered_data_free);
	_tmp0_ = info;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (_data_->info);
	_data_->info = _tmp1_;
	on_discovered_co (_data_);
}


void on_discovered_finish (GAsyncResult* _res_) {
	OnDiscoveredData* _data_;
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
}


static void on_discovered_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
	OnDiscoveredData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	on_discovered_co (_data_);
}


static gboolean on_discovered_co (OnDiscoveredData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = NULL;
	_data_->_tmp0_ = _data_->info;
	_data_->_tmp1_ = NULL;
	_data_->_tmp1_ = gst_discoverer_info_get_uri (_data_->_tmp0_);
	g_debug ("rygel-media-export-extract.vala:143: Discovered %s", _data_->_tmp1_);
	_data_->_tmp2_ = NULL;
	_data_->_tmp2_ = _data_->info;
	_data_->_tmp3_ = NULL;
	_data_->_tmp3_ = gst_discoverer_info_get_uri (_data_->_tmp2_);
	_data_->_tmp4_ = NULL;
	_data_->_tmp4_ = g_file_new_for_uri (_data_->_tmp3_);
	_data_->file = _data_->_tmp4_;
	_data_->_tmp7_ = NULL;
	_data_->_tmp7_ = _data_->info;
	_data_->_tmp8_ = 0;
	_data_->_tmp8_ = gst_discoverer_info_get_result (_data_->_tmp7_);
	if (_data_->_tmp8_ == GST_DISCOVERER_TIMEOUT) {
		_data_->_tmp6_ = TRUE;
	} else {
		_data_->_tmp9_ = NULL;
		_data_->_tmp9_ = _data_->info;
		_data_->_tmp10_ = 0;
		_data_->_tmp10_ = gst_discoverer_info_get_result (_data_->_tmp9_);
		_data_->_tmp6_ = _data_->_tmp10_ == GST_DISCOVERER_BUSY;
	}
	if (_data_->_tmp6_) {
		_data_->_tmp5_ = TRUE;
	} else {
		_data_->_tmp11_ = NULL;
		_data_->_tmp11_ = _data_->info;
		_data_->_tmp12_ = 0;
		_data_->_tmp12_ = gst_discoverer_info_get_result (_data_->_tmp11_);
		_data_->_tmp5_ = _data_->_tmp12_ == GST_DISCOVERER_MISSING_PLUGINS;
	}
	if (_data_->_tmp5_) {
		_data_->_tmp13_ = NULL;
		_data_->_tmp13_ = _data_->info;
		_data_->_tmp14_ = 0;
		_data_->_tmp14_ = gst_discoverer_info_get_result (_data_->_tmp13_);
		if (_data_->_tmp14_ == GST_DISCOVERER_MISSING_PLUGINS) {
			_data_->_tmp15_ = NULL;
			_data_->_tmp15_ = _data_->info;
			_data_->_tmp16_ = NULL;
			_data_->_tmp16_ = gst_discoverer_info_get_uri (_data_->_tmp15_);
			g_debug ("rygel-media-export-extract.vala:149: Plugins are missing for extractio" \
"n of file %s", _data_->_tmp16_);
		} else {
			_data_->_tmp17_ = NULL;
			_data_->_tmp17_ = _data_->file;
			_data_->_tmp18_ = NULL;
			_data_->_tmp18_ = g_file_get_uri (_data_->_tmp17_);
			_data_->_tmp19_ = NULL;
			_data_->_tmp19_ = _data_->_tmp18_;
			g_debug ("rygel-media-export-extract.vala:152: Extraction timed out on %s", _data_->_tmp19_);
			_g_free0 (_data_->_tmp19_);
		}
		_data_->_tmp20_ = NULL;
		_data_->_tmp20_ = _data_->file;
		_data_->_state_ = 1;
		extract_basic_information (_data_->_tmp20_, NULL, NULL, on_discovered_ready, _data_);
		return FALSE;
		_state_1:
		extract_basic_information_finish (_data_->_res_);
		_g_object_unref0 (_data_->file);
		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;
	}
	_data_->_tmp21_ = NULL;
	_data_->_tmp21_ = _data_->info;
	_data_->_tmp22_ = NULL;
	_data_->_tmp22_ = gupnp_dlna_gst_utils_information_from_discoverer_info (_data_->_tmp21_);
	_data_->dlna_info = _data_->_tmp22_;
	_data_->_tmp23_ = NULL;
	_data_->_tmp23_ = guesser;
	_data_->_tmp24_ = NULL;
	_data_->_tmp24_ = _data_->dlna_info;
	_data_->_tmp25_ = NULL;
	_data_->_tmp25_ = gupnp_dlna_profile_guesser_guess_profile_from_info (_data_->_tmp23_, _data_->_tmp24_);
	_data_->_tmp26_ = NULL;
	_data_->_tmp26_ = _g_object_ref0 (_data_->_tmp25_);
	_data_->dlna = _data_->_tmp26_;
	_data_->_tmp27_ = NULL;
	_data_->_tmp27_ = _data_->file;
	_data_->_tmp28_ = NULL;
	_data_->_tmp28_ = _data_->info;
	_data_->_tmp29_ = NULL;
	_data_->_tmp29_ = _data_->dlna;
	_data_->_state_ = 2;
	extract_basic_information (_data_->_tmp27_, _data_->_tmp28_, _data_->_tmp29_, on_discovered_ready, _data_);
	return FALSE;
	_state_2:
	extract_basic_information_finish (_data_->_res_);
	_g_object_unref0 (_data_->dlna);
	_g_object_unref0 (_data_->dlna_info);
	_g_object_unref0 (_data_->file);
	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 void extract_basic_information_data_free (gpointer _data) {
	ExtractBasicInformationData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->file);
	_g_object_unref0 (_data_->info);
	_g_object_unref0 (_data_->dlna);
	g_slice_free (ExtractBasicInformationData, _data_);
}


void extract_basic_information (GFile* file, GstDiscovererInfo* info, GUPnPDLNAProfile* dlna, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	ExtractBasicInformationData* _data_;
	GFile* _tmp0_ = NULL;
	GFile* _tmp1_ = NULL;
	GstDiscovererInfo* _tmp2_ = NULL;
	GstDiscovererInfo* _tmp3_ = NULL;
	GUPnPDLNAProfile* _tmp4_ = NULL;
	GUPnPDLNAProfile* _tmp5_ = NULL;
	_data_ = g_slice_new0 (ExtractBasicInformationData);
	_data_->_async_result = g_simple_async_result_new (NULL, _callback_, _user_data_, extract_basic_information);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, extract_basic_information_data_free);
	_tmp0_ = file;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (_data_->file);
	_data_->file = _tmp1_;
	_tmp2_ = info;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	_g_object_unref0 (_data_->info);
	_data_->info = _tmp3_;
	_tmp4_ = dlna;
	_tmp5_ = _g_object_ref0 (_tmp4_);
	_g_object_unref0 (_data_->dlna);
	_data_->dlna = _tmp5_;
	extract_basic_information_co (_data_);
}


void extract_basic_information_finish (GAsyncResult* _res_) {
	ExtractBasicInformationData* _data_;
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
}


static void extract_basic_information_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
	ExtractBasicInformationData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	extract_basic_information_co (_data_);
}


static gboolean extract_basic_information_co (ExtractBasicInformationData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	{
		_data_->_tmp1_ = NULL;
		_data_->_tmp1_ = _data_->file;
		_data_->_state_ = 1;
		g_file_query_info_async (_data_->_tmp1_, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE "," G_FILE_ATTRIBUTE_STANDARD_SIZE "," G_FILE_ATTRIBUTE_TIME_MODIFIED "," G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME, G_FILE_QUERY_INFO_NONE, G_PRIORITY_DEFAULT, NULL, extract_basic_information_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp2_ = NULL;
		_data_->_tmp2_ = g_file_query_info_finish (_data_->_tmp1_, _data_->_res_, &_data_->_inner_error_);
		_data_->_tmp0_ = _data_->_tmp2_;
		if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
			goto __catch4_g_error;
		}
		_data_->_tmp3_ = NULL;
		_data_->_tmp3_ = _data_->_tmp0_;
		_data_->_tmp0_ = NULL;
		_g_object_unref0 (_data_->file_info);
		_data_->file_info = _data_->_tmp3_;
		_g_object_unref0 (_data_->_tmp0_);
	}
	goto __finally4;
	__catch4_g_error:
	{
		_data_->_error_ = _data_->_inner_error_;
		_data_->_inner_error_ = NULL;
		_data_->_tmp4_ = NULL;
		_data_->_tmp4_ = _data_->file;
		_data_->_tmp5_ = NULL;
		_data_->_tmp5_ = g_file_get_uri (_data_->_tmp4_);
		_data_->uri = _data_->_tmp5_;
		_data_->_tmp6_ = NULL;
		_data_->_tmp6_ = _ ("Failed to extract basic metadata from %s: %s");
		_data_->_tmp7_ = NULL;
		_data_->_tmp7_ = _data_->uri;
		_data_->_tmp8_ = NULL;
		_data_->_tmp8_ = _data_->_error_;
		_data_->_tmp9_ = NULL;
		_data_->_tmp9_ = _data_->_tmp8_->message;
		g_warning (_data_->_tmp6_, _data_->_tmp7_, _data_->_tmp9_);
		_data_->_tmp10_ = NULL;
		_data_->_tmp10_ = _data_->file;
		_data_->_tmp11_ = NULL;
		_data_->_tmp11_ = _data_->_error_;
		send_error (_data_->_tmp10_, _data_->_tmp11_);
		_g_free0 (_data_->uri);
		_g_error_free0 (_data_->_error_);
		_g_object_unref0 (_data_->file_info);
		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;
	}
	__finally4:
	if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
		_g_object_unref0 (_data_->file_info);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error_->message, g_quark_to_string (_data_->_inner_error_->domain), _data_->_inner_error_->code);
		g_clear_error (&_data_->_inner_error_);
		return FALSE;
	}
	{
		_data_->_tmp13_ = NULL;
		_data_->_tmp13_ = serializer;
		_data_->_tmp14_ = NULL;
		_data_->_tmp14_ = _data_->file;
		_data_->_tmp15_ = NULL;
		_data_->_tmp15_ = _data_->file_info;
		_data_->_tmp16_ = NULL;
		_data_->_tmp16_ = _data_->info;
		_data_->_tmp17_ = NULL;
		_data_->_tmp17_ = _data_->dlna;
		_data_->_tmp18_ = NULL;
		_data_->_tmp18_ = rygel_info_serializer_serialize (_data_->_tmp13_, _data_->_tmp14_, _data_->_tmp15_, _data_->_tmp16_, _data_->_tmp17_, &_data_->_inner_error_);
		_data_->_tmp12_ = _data_->_tmp18_;
		if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
			goto __catch5_g_error;
		}
		_data_->_tmp19_ = NULL;
		_data_->_tmp19_ = _data_->file;
		send_extraction_done (_data_->_tmp19_, _data_->_tmp12_, &_data_->_inner_error_);
		if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
			_g_variant_unref0 (_data_->_tmp12_);
			goto __catch5_g_error;
		}
		_g_variant_unref0 (_data_->_tmp12_);
	}
	goto __finally5;
	__catch5_g_error:
	{
		_data_->_vala1__error_ = _data_->_inner_error_;
		_data_->_inner_error_ = NULL;
		_data_->_tmp20_ = NULL;
		_data_->_tmp20_ = _data_->file;
		_data_->_tmp21_ = NULL;
		_data_->_tmp21_ = _data_->_vala1__error_;
		send_error (_data_->_tmp20_, _data_->_tmp21_);
		_g_error_free0 (_data_->_vala1__error_);
	}
	__finally5:
	if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
		_g_object_unref0 (_data_->file_info);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error_->message, g_quark_to_string (_data_->_inner_error_->domain), _data_->_inner_error_->code);
		g_clear_error (&_data_->_inner_error_);
		return FALSE;
	}
	_g_object_unref0 (_data_->file_info);
	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 void _segv_handler_sighandler_t (gint signal) {
	segv_handler (signal);
}


gint _vala_main (gchar** args, int args_length1) {
	gint result = 0;
	GOptionContext* ctx = NULL;
	const gchar* _tmp0_ = NULL;
	GOptionContext* _tmp1_ = NULL;
	GOptionContext* _tmp2_ = NULL;
	GOptionContext* _tmp3_ = NULL;
	GOptionGroup* _tmp4_ = NULL;
	RygelInfoSerializer* _tmp9_ = NULL;
	struct sigaction action = {0};
	struct sigaction _tmp10_ = {0};
	struct sigaction _tmp11_ = {0};
	gint _tmp12_ = 0;
	gint _tmp13_ = 0;
	gint _tmp14_ = 0;
	gint _tmp15_ = 0;
	GUnixInputStream* _tmp16_ = NULL;
	GUnixInputStream* _tmp17_ = NULL;
	GDataInputStream* _tmp18_ = NULL;
	gint _tmp19_ = 0;
	GUnixOutputStream* _tmp20_ = NULL;
	gint _tmp21_ = 0;
	GUnixOutputStream* _tmp22_ = NULL;
	GMainLoop* _tmp23_ = NULL;
	GUPnPDLNAProfileGuesser* _tmp30_ = NULL;
	GMainLoop* _tmp31_ = NULL;
	GError * _inner_error_ = NULL;
	_tmp0_ = _ ("- helper binary for Rygel to extract meta-data");
	_tmp1_ = g_option_context_new (_tmp0_);
	ctx = _tmp1_;
	_tmp2_ = ctx;
	g_option_context_add_main_entries (_tmp2_, options, NULL);
	_tmp3_ = ctx;
	_tmp4_ = gst_init_get_option_group ();
	g_option_context_add_group (_tmp3_, _tmp4_);
	{
		GOptionContext* _tmp5_ = NULL;
		_tmp5_ = ctx;
		g_option_context_parse (_tmp5_, &args_length1, &args, &_inner_error_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch6_g_error;
		}
	}
	goto __finally6;
	__catch6_g_error:
	{
		GError* _error_ = NULL;
		const gchar* _tmp6_ = NULL;
		GError* _tmp7_ = NULL;
		const gchar* _tmp8_ = NULL;
		_error_ = _inner_error_;
		_inner_error_ = NULL;
		_tmp6_ = _ ("Failed to parse commandline args: %s");
		_tmp7_ = _error_;
		_tmp8_ = _tmp7_->message;
		g_warning (_tmp6_, _tmp8_);
		result = EXIT_FAILURE;
		_g_error_free0 (_error_);
		_g_option_context_free0 (ctx);
		return result;
	}
	__finally6:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		_g_option_context_free0 (ctx);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return 0;
	}
	_tmp9_ = rygel_info_serializer_new ();
	_rygel_info_serializer_unref0 (serializer);
	serializer = _tmp9_;
	nice (19);
	memset (&action, 0, sizeof (struct sigaction));
	action.sa_handler = _segv_handler_sighandler_t;
	_tmp10_ = action;
	sigaction (SIGSEGV, &_tmp10_, NULL);
	_tmp11_ = action;
	sigaction (SIGABRT, &_tmp11_, NULL);
	_tmp12_ = in_fd;
	_tmp13_ = out_fd;
	_tmp14_ = err_fd;
	g_message ("rygel-media-export-extract.vala:218: Started with descriptors %d %d %d", _tmp12_, _tmp13_, _tmp14_);
	_tmp15_ = in_fd;
	_tmp16_ = (GUnixInputStream*) g_unix_input_stream_new (_tmp15_, FALSE);
	_tmp17_ = _tmp16_;
	_tmp18_ = g_data_input_stream_new ((GInputStream*) _tmp17_);
	_g_object_unref0 (input_stream);
	input_stream = _tmp18_;
	_g_object_unref0 (_tmp17_);
	_tmp19_ = out_fd;
	_tmp20_ = (GUnixOutputStream*) g_unix_output_stream_new (_tmp19_, FALSE);
	_g_object_unref0 (output_stream);
	output_stream = (GOutputStream*) _tmp20_;
	_tmp21_ = err_fd;
	_tmp22_ = (GUnixOutputStream*) g_unix_output_stream_new (_tmp21_, FALSE);
	_g_object_unref0 (error_stream);
	error_stream = (GOutputStream*) _tmp22_;
	_tmp23_ = g_main_loop_new (NULL, FALSE);
	_g_main_loop_unref0 (loop);
	loop = _tmp23_;
	{
		GstDiscoverer* _tmp24_ = NULL;
		GstDiscoverer* _tmp25_ = NULL;
		GstDiscoverer* _tmp26_ = NULL;
		_tmp25_ = gst_discoverer_new ((GstClockTime) (10 * GST_SECOND), &_inner_error_);
		_tmp24_ = _tmp25_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch7_g_error;
		}
		_tmp26_ = _tmp24_;
		_tmp24_ = NULL;
		_g_object_unref0 (discoverer);
		discoverer = _tmp26_;
		_g_object_unref0 (_tmp24_);
	}
	goto __finally7;
	__catch7_g_error:
	{
		GError* _error_ = NULL;
		const gchar* _tmp27_ = NULL;
		GError* _tmp28_ = NULL;
		const gchar* _tmp29_ = NULL;
		_error_ = _inner_error_;
		_inner_error_ = NULL;
		_tmp27_ = _ ("Failed to start meta-data discoverer: %s");
		_tmp28_ = _error_;
		_tmp29_ = _tmp28_->message;
		g_warning (_tmp27_, _tmp29_);
		_g_error_free0 (_error_);
	}
	__finally7:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		_g_option_context_free0 (ctx);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return 0;
	}
	_tmp30_ = gupnp_dlna_profile_guesser_new (TRUE, TRUE);
	_g_object_unref0 (guesser);
	guesser = _tmp30_;
	run (NULL, NULL);
	_tmp31_ = loop;
	g_main_loop_run (_tmp31_);
	result = 0;
	_g_option_context_free0 (ctx);
	return result;
}


int main (int argc, char ** argv) {
#if !GLIB_CHECK_VERSION (2,35,0)
	g_type_init ();
#endif
	return _vala_main (argv, argc);
}



