/* rygel-media-export-metadata-extractor.c generated by valac 0.32.1, the Vala compiler
 * generated from rygel-media-export-metadata-extractor.vala, do not modify */

/*
 * Copyright (C) 2008 Zeeshan Ali (Khattak) <zeeshanak@gnome.org>.
 * Copyright (C) 2009 Jens Georg <mail@jensge.org>.
 *
 * Author: Zeeshan Ali (Khattak) <zeeshanak@gnome.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.1 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 library; 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 <gio/gunixoutputstream.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <rygel-core.h>
#include <glib/gi18n-lib.h>
#include <fcntl.h>
#include <gio/gunixinputstream.h>


#define RYGEL_MEDIA_EXPORT_TYPE_METADATA_EXTRACTOR (rygel_media_export_metadata_extractor_get_type ())
#define RYGEL_MEDIA_EXPORT_METADATA_EXTRACTOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_METADATA_EXTRACTOR, RygelMediaExportMetadataExtractor))
#define RYGEL_MEDIA_EXPORT_METADATA_EXTRACTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_METADATA_EXTRACTOR, RygelMediaExportMetadataExtractorClass))
#define RYGEL_MEDIA_EXPORT_IS_METADATA_EXTRACTOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_METADATA_EXTRACTOR))
#define RYGEL_MEDIA_EXPORT_IS_METADATA_EXTRACTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_METADATA_EXTRACTOR))
#define RYGEL_MEDIA_EXPORT_METADATA_EXTRACTOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_METADATA_EXTRACTOR, RygelMediaExportMetadataExtractorClass))

typedef struct _RygelMediaExportMetadataExtractor RygelMediaExportMetadataExtractor;
typedef struct _RygelMediaExportMetadataExtractorClass RygelMediaExportMetadataExtractorClass;
typedef struct _RygelMediaExportMetadataExtractorPrivate RygelMediaExportMetadataExtractorPrivate;
#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_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _RygelMediaExportMetadataExtractorRunData RygelMediaExportMetadataExtractorRunData;
#define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL)))
typedef struct _Block4Data Block4Data;
#define _g_variant_type_free0(var) ((var == NULL) ? NULL : (var = (g_variant_type_free (var), NULL)))

typedef enum  {
	METADATA_EXTRACTOR_ERROR_GENERAL,
	METADATA_EXTRACTOR_ERROR_BLACKLIST
} MetadataExtractorError;
#define METADATA_EXTRACTOR_ERROR metadata_extractor_error_quark ()
struct _RygelMediaExportMetadataExtractor {
	GObject parent_instance;
	RygelMediaExportMetadataExtractorPrivate * priv;
};

struct _RygelMediaExportMetadataExtractorClass {
	GObjectClass parent_class;
};

struct _RygelMediaExportMetadataExtractorPrivate {
	gboolean extract_metadata;
	GUnixOutputStream* input_stream;
	GDataInputStream* output_stream;
	GCancellable* child_io_cancellable;
	GSubprocessLauncher* launcher;
	gchar* error_uri;
	gchar** MX_EXTRACT_ARGV;
	gint MX_EXTRACT_ARGV_length1;
	gint _MX_EXTRACT_ARGV_size_;
};

struct _RygelMediaExportMetadataExtractorRunData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	RygelMediaExportMetadataExtractor* self;
	gint* pipe_in;
	gint* _tmp0_;
	gint pipe_in_length1;
	gint _pipe_in_size_;
	gint* pipe_out;
	gint* _tmp1_;
	gint pipe_out_length1;
	gint _pipe_out_size_;
	gboolean restart;
	gboolean _tmp2_;
	gboolean _tmp3_;
	gint* _tmp4_;
	gint _tmp4__length1;
	gint* _tmp5_;
	gint _tmp5__length1;
	GSubprocessLauncher* _tmp6_;
	GSubprocessLauncher* _tmp7_;
	gint* _tmp8_;
	gint _tmp8__length1;
	gint _tmp9_;
	GSubprocessLauncher* _tmp10_;
	gint* _tmp11_;
	gint _tmp11__length1;
	gint _tmp12_;
	gint* _tmp13_;
	gint _tmp13__length1;
	gint _tmp14_;
	GUnixOutputStream* _tmp15_;
	gint* _tmp16_;
	gint _tmp16__length1;
	gint _tmp17_;
	GUnixInputStream* _tmp18_;
	GUnixInputStream* _tmp19_;
	GDataInputStream* _tmp20_;
	GCancellable* _tmp21_;
	GDataInputStream* _tmp22_;
	GCancellable* _tmp23_;
	gboolean _tmp24_;
	gchar** _tmp25_;
	gint _tmp25__length1;
	gchar* _tmp26_;
	gchar* _tmp27_;
	gchar** _tmp28_;
	gint _tmp28__length1;
	gchar* _tmp29_;
	GSubprocess* subprocess;
	GSubprocessLauncher* _tmp30_;
	gchar** _tmp31_;
	gint _tmp31__length1;
	GSubprocess* _tmp32_;
	GSubprocess* _tmp33_;
	GError* _error_;
	const gchar* _tmp34_;
	GError* _tmp35_;
	const gchar* _tmp36_;
	GCancellable* _tmp37_;
	gchar* msg;
	const gchar* _tmp38_;
	gchar* _tmp39_;
	const gchar* _tmp40_;
	GFile* _tmp41_;
	GFile* _tmp42_;
	const gchar* _tmp43_;
	const gchar* _tmp44_;
	GError* _tmp45_;
	GError* _tmp46_;
	GError* _vala1__error_;
	const gchar* _tmp47_;
	GError* _tmp48_;
	const gchar* _tmp49_;
	GError * _inner_error_;
};

struct _Block4Data {
	int _ref_count_;
	RygelMediaExportMetadataExtractor* self;
	GFile* file;
	gchar* content_type;
};


static gpointer rygel_media_export_metadata_extractor_parent_class = NULL;
static GVariantType* rygel_media_export_metadata_extractor_SERIALIZED_DATA_TYPE;
static GVariantType* rygel_media_export_metadata_extractor_SERIALIZED_DATA_TYPE = NULL;

GQuark metadata_extractor_error_quark (void);
GType rygel_media_export_metadata_extractor_get_type (void) G_GNUC_CONST;
#define RYGEL_MEDIA_EXPORT_METADATA_EXTRACTOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RYGEL_MEDIA_EXPORT_TYPE_METADATA_EXTRACTOR, RygelMediaExportMetadataExtractorPrivate))
enum  {
	RYGEL_MEDIA_EXPORT_METADATA_EXTRACTOR_DUMMY_PROPERTY
};
gboolean g_unix_open_pipe (gint* fds, gint flags, GError** error);
RygelMediaExportMetadataExtractor* rygel_media_export_metadata_extractor_new (void);
RygelMediaExportMetadataExtractor* rygel_media_export_metadata_extractor_construct (GType object_type);
static void rygel_media_export_metadata_extractor_on_config_changed (RygelMediaExportMetadataExtractor* self, RygelConfiguration* config, const gchar* section, const gchar* key);
static void _rygel_media_export_metadata_extractor_on_config_changed_rygel_configuration_setting_changed (RygelConfiguration* _sender, const gchar* section, const gchar* key, gpointer self);
#define RYGEL_MEDIA_EXPORT_PLUGIN_NAME "MediaExport"
void rygel_media_export_metadata_extractor_stop (RygelMediaExportMetadataExtractor* self);
static void rygel_media_export_metadata_extractor_run_data_free (gpointer _data);
void rygel_media_export_metadata_extractor_run (RygelMediaExportMetadataExtractor* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
void rygel_media_export_metadata_extractor_run_finish (RygelMediaExportMetadataExtractor* self, GAsyncResult* _res_);
static gboolean rygel_media_export_metadata_extractor_run_co (RygelMediaExportMetadataExtractorRunData* _data_);
static void rygel_media_export_metadata_extractor_on_input (RygelMediaExportMetadataExtractor* self, GObject* object, GAsyncResult* _result_);
static void _rygel_media_export_metadata_extractor_on_input_gasync_ready_callback (GObject* source_object, GAsyncResult* res, gpointer self);
static void rygel_media_export_metadata_extractor_run_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
void rygel_media_export_metadata_extractor_extract (RygelMediaExportMetadataExtractor* self, GFile* file, const gchar* content_type);
static Block4Data* block4_data_ref (Block4Data* _data4_);
static void block4_data_unref (void * _userdata_);
static gboolean ___lambda7_ (Block4Data* _data4_);
static gboolean ____lambda7__gsource_func (gpointer self);
static void g_cclosure_user_marshal_VOID__OBJECT_VARIANT (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data);
static void g_cclosure_user_marshal_VOID__OBJECT_POINTER (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data);
static void rygel_media_export_metadata_extractor_finalize (GObject* obj);
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
static gint _vala_array_length (gpointer array);


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


static void _rygel_media_export_metadata_extractor_on_config_changed_rygel_configuration_setting_changed (RygelConfiguration* _sender, const gchar* section, const gchar* key, gpointer self) {
	rygel_media_export_metadata_extractor_on_config_changed ((RygelMediaExportMetadataExtractor*) self, _sender, section, key);
}


RygelMediaExportMetadataExtractor* rygel_media_export_metadata_extractor_construct (GType object_type) {
	RygelMediaExportMetadataExtractor * self = NULL;
	GCancellable* _tmp0_ = NULL;
	RygelMetaConfig* config = NULL;
	RygelMetaConfig* _tmp1_ = NULL;
	self = (RygelMediaExportMetadataExtractor*) g_object_new (object_type, NULL);
	_tmp0_ = g_cancellable_new ();
	_g_object_unref0 (self->priv->child_io_cancellable);
	self->priv->child_io_cancellable = _tmp0_;
	_tmp1_ = rygel_meta_config_get_default ();
	config = _tmp1_;
	g_signal_connect_object ((RygelConfiguration*) config, "setting-changed", (GCallback) _rygel_media_export_metadata_extractor_on_config_changed_rygel_configuration_setting_changed, self, 0);
	rygel_media_export_metadata_extractor_on_config_changed (self, (RygelConfiguration*) config, RYGEL_MEDIA_EXPORT_PLUGIN_NAME, "extract-metadata");
	_g_object_unref0 (config);
	return self;
}


RygelMediaExportMetadataExtractor* rygel_media_export_metadata_extractor_new (void) {
	return rygel_media_export_metadata_extractor_construct (RYGEL_MEDIA_EXPORT_TYPE_METADATA_EXTRACTOR);
}


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 rygel_media_export_metadata_extractor_stop (RygelMediaExportMetadataExtractor* self) {
	GCancellable* _tmp0_ = NULL;
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->child_io_cancellable;
	g_cancellable_cancel (_tmp0_);
	{
		gchar* s = NULL;
		gchar* _tmp1_ = NULL;
		GUnixOutputStream* _tmp2_ = NULL;
		const gchar* _tmp3_ = NULL;
		guint8* _tmp4_ = NULL;
		gint _tmp4__length1 = 0;
		guint8* _tmp5_ = NULL;
		gint _tmp5__length1 = 0;
		GUnixOutputStream* _tmp6_ = NULL;
		_tmp1_ = g_strdup ("QUIT\n");
		s = _tmp1_;
		_tmp2_ = self->priv->input_stream;
		_tmp3_ = s;
		_tmp4_ = string_get_data (_tmp3_, &_tmp4__length1);
		_tmp5_ = _tmp4_;
		_tmp5__length1 = _tmp4__length1;
		g_output_stream_write_all ((GOutputStream*) _tmp2_, _tmp5_, (gsize) _tmp5__length1, NULL, NULL, &_inner_error_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			_g_free0 (s);
			goto __catch25_g_error;
		}
		_tmp6_ = self->priv->input_stream;
		g_output_stream_flush ((GOutputStream*) _tmp6_, NULL, &_inner_error_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			_g_free0 (s);
			goto __catch25_g_error;
		}
		_g_free0 (s);
	}
	goto __finally25;
	__catch25_g_error:
	{
		GError* _error_ = NULL;
		const gchar* _tmp7_ = NULL;
		_error_ = _inner_error_;
		_inner_error_ = NULL;
		_tmp7_ = _ ("Failed to gracefully stop the process. Using KILL");
		g_warning ("rygel-media-export-metadata-extractor.vala:104: %s", _tmp7_);
		_g_error_free0 (_error_);
	}
	__finally25:
	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;
	}
}


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


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


void rygel_media_export_metadata_extractor_run (RygelMediaExportMetadataExtractor* self, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	RygelMediaExportMetadataExtractorRunData* _data_;
	RygelMediaExportMetadataExtractor* _tmp0_ = NULL;
	_data_ = g_slice_new0 (RygelMediaExportMetadataExtractorRunData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, rygel_media_export_metadata_extractor_run);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, rygel_media_export_metadata_extractor_run_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	rygel_media_export_metadata_extractor_run_co (_data_);
}


void rygel_media_export_metadata_extractor_run_finish (RygelMediaExportMetadataExtractor* self, GAsyncResult* _res_) {
	RygelMediaExportMetadataExtractorRunData* _data_;
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
}


static void _rygel_media_export_metadata_extractor_on_input_gasync_ready_callback (GObject* source_object, GAsyncResult* res, gpointer self) {
	rygel_media_export_metadata_extractor_on_input ((RygelMediaExportMetadataExtractor*) self, source_object, res);
	g_object_unref (self);
}


static void rygel_media_export_metadata_extractor_run_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
	RygelMediaExportMetadataExtractorRunData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	rygel_media_export_metadata_extractor_run_co (_data_);
}


static gboolean rygel_media_export_metadata_extractor_run_co (RygelMediaExportMetadataExtractorRunData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = NULL;
	_data_->_tmp0_ = g_new0 (gint, 2);
	_data_->_tmp0_[0] = 0;
	_data_->_tmp0_[1] = 0;
	_data_->pipe_in_length1 = 0;
	_data_->_pipe_in_size_ = 0;
	_data_->pipe_in = _data_->_tmp0_;
	_data_->pipe_in_length1 = 2;
	_data_->_pipe_in_size_ = _data_->pipe_in_length1;
	_data_->_tmp1_ = NULL;
	_data_->_tmp1_ = g_new0 (gint, 2);
	_data_->_tmp1_[0] = 0;
	_data_->_tmp1_[1] = 0;
	_data_->pipe_out_length1 = 0;
	_data_->_pipe_out_size_ = 0;
	_data_->pipe_out = _data_->_tmp1_;
	_data_->pipe_out_length1 = 2;
	_data_->_pipe_out_size_ = _data_->pipe_out_length1;
	_data_->restart = FALSE;
	{
		_data_->_tmp2_ = TRUE;
		while (TRUE) {
			if (!_data_->_tmp2_) {
				_data_->_tmp3_ = FALSE;
				_data_->_tmp3_ = _data_->restart;
				if (!_data_->_tmp3_) {
					break;
				}
			}
			_data_->_tmp2_ = FALSE;
			_data_->restart = FALSE;
			{
				_data_->_tmp4_ = NULL;
				_data_->_tmp4__length1 = 0;
				_data_->_tmp4_ = _data_->pipe_in;
				_data_->_tmp4__length1 = _data_->pipe_in_length1;
				g_unix_open_pipe (_data_->_tmp4_, FD_CLOEXEC, &_data_->_inner_error_);
				if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
					goto __catch26_g_error;
				}
				_data_->_tmp5_ = NULL;
				_data_->_tmp5__length1 = 0;
				_data_->_tmp5_ = _data_->pipe_out;
				_data_->_tmp5__length1 = _data_->pipe_out_length1;
				g_unix_open_pipe (_data_->_tmp5_, FD_CLOEXEC, &_data_->_inner_error_);
				if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
					goto __catch26_g_error;
				}
				_data_->_tmp6_ = NULL;
				_data_->_tmp6_ = g_subprocess_launcher_new (G_SUBPROCESS_FLAGS_NONE);
				_g_object_unref0 (_data_->self->priv->launcher);
				_data_->self->priv->launcher = _data_->_tmp6_;
				_data_->_tmp7_ = NULL;
				_data_->_tmp7_ = _data_->self->priv->launcher;
				_data_->_tmp8_ = NULL;
				_data_->_tmp8__length1 = 0;
				_data_->_tmp8_ = _data_->pipe_in;
				_data_->_tmp8__length1 = _data_->pipe_in_length1;
				_data_->_tmp9_ = 0;
				_data_->_tmp9_ = _data_->_tmp8_[0];
				g_subprocess_launcher_take_fd (_data_->_tmp7_, _data_->_tmp9_, 3);
				_data_->_tmp10_ = NULL;
				_data_->_tmp10_ = _data_->self->priv->launcher;
				_data_->_tmp11_ = NULL;
				_data_->_tmp11__length1 = 0;
				_data_->_tmp11_ = _data_->pipe_out;
				_data_->_tmp11__length1 = _data_->pipe_out_length1;
				_data_->_tmp12_ = 0;
				_data_->_tmp12_ = _data_->_tmp11_[1];
				g_subprocess_launcher_take_fd (_data_->_tmp10_, _data_->_tmp12_, 4);
				_data_->_tmp13_ = NULL;
				_data_->_tmp13__length1 = 0;
				_data_->_tmp13_ = _data_->pipe_in;
				_data_->_tmp13__length1 = _data_->pipe_in_length1;
				_data_->_tmp14_ = 0;
				_data_->_tmp14_ = _data_->_tmp13_[1];
				_data_->_tmp15_ = NULL;
				_data_->_tmp15_ = (GUnixOutputStream*) g_unix_output_stream_new (_data_->_tmp14_, TRUE);
				_g_object_unref0 (_data_->self->priv->input_stream);
				_data_->self->priv->input_stream = _data_->_tmp15_;
				_data_->_tmp16_ = NULL;
				_data_->_tmp16__length1 = 0;
				_data_->_tmp16_ = _data_->pipe_out;
				_data_->_tmp16__length1 = _data_->pipe_out_length1;
				_data_->_tmp17_ = 0;
				_data_->_tmp17_ = _data_->_tmp16_[0];
				_data_->_tmp18_ = NULL;
				_data_->_tmp18_ = (GUnixInputStream*) g_unix_input_stream_new (_data_->_tmp17_, TRUE);
				_data_->_tmp19_ = NULL;
				_data_->_tmp19_ = _data_->_tmp18_;
				_data_->_tmp20_ = NULL;
				_data_->_tmp20_ = g_data_input_stream_new ((GInputStream*) _data_->_tmp19_);
				_g_object_unref0 (_data_->self->priv->output_stream);
				_data_->self->priv->output_stream = _data_->_tmp20_;
				_g_object_unref0 (_data_->_tmp19_);
				_data_->_tmp21_ = NULL;
				_data_->_tmp21_ = g_cancellable_new ();
				_g_object_unref0 (_data_->self->priv->child_io_cancellable);
				_data_->self->priv->child_io_cancellable = _data_->_tmp21_;
				_data_->_tmp22_ = NULL;
				_data_->_tmp22_ = _data_->self->priv->output_stream;
				_data_->_tmp23_ = NULL;
				_data_->_tmp23_ = _data_->self->priv->child_io_cancellable;
				g_data_input_stream_read_line_async (_data_->_tmp22_, G_PRIORITY_DEFAULT, _data_->_tmp23_, _rygel_media_export_metadata_extractor_on_input_gasync_ready_callback, g_object_ref (_data_->self));
				_g_free0 (_data_->self->priv->error_uri);
				_data_->self->priv->error_uri = NULL;
				_data_->_tmp24_ = FALSE;
				_data_->_tmp24_ = _data_->self->priv->extract_metadata;
				if (_data_->_tmp24_) {
					_data_->_tmp25_ = NULL;
					_data_->_tmp25__length1 = 0;
					_data_->_tmp25_ = _data_->self->priv->MX_EXTRACT_ARGV;
					_data_->_tmp25__length1 = _data_->self->priv->MX_EXTRACT_ARGV_length1;
					_data_->_tmp26_ = NULL;
					_data_->_tmp26_ = g_strdup ("--extract-metadata");
					_g_free0 (_data_->_tmp25_[4]);
					_data_->_tmp25_[4] = _data_->_tmp26_;
					_data_->_tmp27_ = NULL;
					_data_->_tmp27_ = _data_->_tmp25_[4];
				} else {
					_data_->_tmp28_ = NULL;
					_data_->_tmp28__length1 = 0;
					_data_->_tmp28_ = _data_->self->priv->MX_EXTRACT_ARGV;
					_data_->_tmp28__length1 = _data_->self->priv->MX_EXTRACT_ARGV_length1;
					_g_free0 (_data_->_tmp28_[4]);
					_data_->_tmp28_[4] = NULL;
					_data_->_tmp29_ = NULL;
					_data_->_tmp29_ = _data_->_tmp28_[4];
				}
				_data_->_tmp30_ = NULL;
				_data_->_tmp30_ = _data_->self->priv->launcher;
				_data_->_tmp31_ = NULL;
				_data_->_tmp31__length1 = 0;
				_data_->_tmp31_ = _data_->self->priv->MX_EXTRACT_ARGV;
				_data_->_tmp31__length1 = _data_->self->priv->MX_EXTRACT_ARGV_length1;
				_data_->_tmp32_ = NULL;
				_data_->_tmp32_ = g_subprocess_launcher_spawnv (_data_->_tmp30_, _data_->_tmp31_, &_data_->_inner_error_);
				_data_->subprocess = _data_->_tmp32_;
				if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
					goto __catch26_g_error;
				}
				{
					_data_->_tmp33_ = NULL;
					_data_->_tmp33_ = _data_->subprocess;
					_data_->_state_ = 1;
					g_subprocess_wait_check_async (_data_->_tmp33_, NULL, rygel_media_export_metadata_extractor_run_ready, _data_);
					return FALSE;
					_state_1:
					g_subprocess_wait_check_finish (_data_->_tmp33_, _data_->_res_, &_data_->_inner_error_);
					if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
						goto __catch27_g_error;
					}
				}
				goto __finally27;
				__catch27_g_error:
				{
					_data_->_error_ = _data_->_inner_error_;
					_data_->_inner_error_ = NULL;
					_data_->_tmp34_ = NULL;
					_data_->_tmp34_ = _ ("Process check_async failed: %s");
					_data_->_tmp35_ = NULL;
					_data_->_tmp35_ = _data_->_error_;
					_data_->_tmp36_ = NULL;
					_data_->_tmp36_ = _data_->_tmp35_->message;
					g_warning (_data_->_tmp34_, _data_->_tmp36_);
					_data_->restart = TRUE;
					_data_->_tmp37_ = NULL;
					_data_->_tmp37_ = _data_->self->priv->child_io_cancellable;
					g_cancellable_cancel (_data_->_tmp37_);
					_data_->_tmp38_ = NULL;
					_data_->_tmp38_ = _ ("Process died while handling URI %s");
					_data_->_tmp39_ = NULL;
					_data_->_tmp39_ = g_strdup (_data_->_tmp38_);
					_data_->msg = _data_->_tmp39_;
					_data_->_tmp40_ = NULL;
					_data_->_tmp40_ = _data_->self->priv->error_uri;
					_data_->_tmp41_ = NULL;
					_data_->_tmp41_ = g_file_new_for_uri (_data_->_tmp40_);
					_data_->_tmp42_ = NULL;
					_data_->_tmp42_ = _data_->_tmp41_;
					_data_->_tmp43_ = NULL;
					_data_->_tmp43_ = _data_->msg;
					_data_->_tmp44_ = NULL;
					_data_->_tmp44_ = _data_->self->priv->error_uri;
					_data_->_tmp45_ = NULL;
					_data_->_tmp45_ = g_error_new (METADATA_EXTRACTOR_ERROR, METADATA_EXTRACTOR_ERROR_BLACKLIST, _data_->_tmp43_, _data_->_tmp44_);
					_data_->_tmp46_ = NULL;
					_data_->_tmp46_ = _data_->_tmp45_;
					g_signal_emit_by_name (_data_->self, "error", _data_->_tmp42_, _data_->_tmp46_);
					_g_error_free0 (_data_->_tmp46_);
					_g_object_unref0 (_data_->_tmp42_);
					_g_free0 (_data_->msg);
					_g_error_free0 (_data_->_error_);
				}
				__finally27:
				if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
					_g_object_unref0 (_data_->subprocess);
					goto __catch26_g_error;
				}
				_g_object_unref0 (_data_->subprocess);
			}
			goto __finally26;
			__catch26_g_error:
			{
				_data_->_vala1__error_ = _data_->_inner_error_;
				_data_->_inner_error_ = NULL;
				_data_->_tmp47_ = NULL;
				_data_->_tmp47_ = _ ("Setting up extraction subprocess failed: %s");
				_data_->_tmp48_ = NULL;
				_data_->_tmp48_ = _data_->_vala1__error_;
				_data_->_tmp49_ = NULL;
				_data_->_tmp49_ = _data_->_tmp48_->message;
				g_warning (_data_->_tmp47_, _data_->_tmp49_);
				_g_error_free0 (_data_->_vala1__error_);
			}
			__finally26:
			if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
				_data_->pipe_out = (g_free (_data_->pipe_out), NULL);
				_data_->pipe_in = (g_free (_data_->pipe_in), 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;
			}
		}
	}
	g_debug ("rygel-media-export-metadata-extractor.vala:169: Metadata extractor fin" \
"ished.");
	_data_->pipe_out = (g_free (_data_->pipe_out), NULL);
	_data_->pipe_in = (g_free (_data_->pipe_in), NULL);
	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 guint64 uint64_parse (const gchar* str) {
	guint64 result = 0ULL;
	const gchar* _tmp0_ = NULL;
	guint64 _tmp1_ = 0ULL;
	g_return_val_if_fail (str != NULL, 0ULL);
	_tmp0_ = str;
	_tmp1_ = g_ascii_strtoull (_tmp0_, NULL, (guint) 0);
	result = _tmp1_;
	return result;
}


static void rygel_media_export_metadata_extractor_on_input (RygelMediaExportMetadataExtractor* self, GObject* object, GAsyncResult* _result_) {
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (_result_ != NULL);
	{
		GDataInputStream* stream = NULL;
		GObject* _tmp0_ = NULL;
		GDataInputStream* _tmp1_ = NULL;
		gchar* str = NULL;
		GDataInputStream* _tmp2_ = NULL;
		GAsyncResult* _tmp3_ = NULL;
		gchar* _tmp4_ = NULL;
		GDataInputStream* _tmp61_ = NULL;
		GCancellable* _tmp62_ = NULL;
		_tmp0_ = object;
		_tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, G_TYPE_DATA_INPUT_STREAM) ? ((GDataInputStream*) _tmp0_) : NULL);
		stream = _tmp1_;
		_tmp2_ = stream;
		_tmp3_ = _result_;
		_tmp4_ = g_data_input_stream_read_line_finish (_tmp2_, _tmp3_, NULL, &_inner_error_);
		str = _tmp4_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			_g_object_unref0 (stream);
			goto __catch28_g_error;
		}
		{
			gboolean _tmp5_ = FALSE;
			_tmp5_ = TRUE;
			while (TRUE) {
				const gchar* _tmp6_ = NULL;
				gboolean _tmp7_ = FALSE;
				gboolean _tmp8_ = FALSE;
				const gchar* _tmp9_ = NULL;
				gboolean _tmp10_ = FALSE;
				gchar** parts = NULL;
				const gchar* _tmp17_ = NULL;
				gchar** _tmp18_ = NULL;
				gchar** _tmp19_ = NULL;
				gint parts_length1 = 0;
				gint _parts_size_ = 0;
				gchar** _tmp20_ = NULL;
				gint _tmp20__length1 = 0;
				gchar** _tmp23_ = NULL;
				gint _tmp23__length1 = 0;
				const gchar* _tmp24_ = NULL;
				gchar* uri = NULL;
				gchar** _tmp33_ = NULL;
				gint _tmp33__length1 = 0;
				const gchar* _tmp34_ = NULL;
				gchar* _tmp35_ = NULL;
				guint64 length = 0ULL;
				gchar** _tmp36_ = NULL;
				gint _tmp36__length1 = 0;
				const gchar* _tmp37_ = NULL;
				guint64 _tmp38_ = 0ULL;
				gchar** _tmp39_ = NULL;
				gint _tmp39__length1 = 0;
				const gchar* _tmp40_ = NULL;
				const gchar* _tmp45_ = NULL;
				guint8* buf = NULL;
				guint64 _tmp46_ = 0ULL;
				guint8* _tmp47_ = NULL;
				gint buf_length1 = 0;
				gint _buf_size_ = 0;
				gsize bytes = 0UL;
				GDataInputStream* _tmp48_ = NULL;
				guint8* _tmp49_ = NULL;
				gint _tmp49__length1 = 0;
				GCancellable* _tmp50_ = NULL;
				gsize _tmp51_ = 0UL;
				guint64 _tmp52_ = 0ULL;
				gsize _tmp53_ = 0UL;
				GVariant* v = NULL;
				const GVariantType* _tmp54_ = NULL;
				guint8* _tmp55_ = NULL;
				gint _tmp55__length1 = 0;
				GVariant* _tmp56_ = NULL;
				const gchar* _tmp57_ = NULL;
				GFile* _tmp58_ = NULL;
				GFile* _tmp59_ = NULL;
				GVariant* _tmp60_ = NULL;
				if (!_tmp5_) {
					if (!FALSE) {
						break;
					}
				}
				_tmp5_ = FALSE;
				_tmp6_ = str;
				if (_tmp6_ == NULL) {
					break;
				}
				_tmp9_ = str;
				_tmp10_ = g_str_has_prefix (_tmp9_, "RESULT|");
				if (!_tmp10_) {
					const gchar* _tmp11_ = NULL;
					gboolean _tmp12_ = FALSE;
					_tmp11_ = str;
					_tmp12_ = g_str_has_prefix (_tmp11_, "ERROR|");
					_tmp8_ = !_tmp12_;
				} else {
					_tmp8_ = FALSE;
				}
				if (_tmp8_) {
					const gchar* _tmp13_ = NULL;
					gboolean _tmp14_ = FALSE;
					_tmp13_ = str;
					_tmp14_ = g_str_has_prefix (_tmp13_, "SKIP|");
					_tmp7_ = !_tmp14_;
				} else {
					_tmp7_ = FALSE;
				}
				if (_tmp7_) {
					const gchar* _tmp15_ = NULL;
					const gchar* _tmp16_ = NULL;
					_tmp15_ = _ ("Received invalid string from child: %s");
					_tmp16_ = str;
					g_warning (_tmp15_, _tmp16_);
					break;
				}
				_tmp17_ = str;
				_tmp19_ = _tmp18_ = g_strsplit (_tmp17_, "|", 0);
				parts = _tmp19_;
				parts_length1 = _vala_array_length (_tmp18_);
				_parts_size_ = parts_length1;
				_tmp20_ = parts;
				_tmp20__length1 = parts_length1;
				if (_tmp20__length1 != 4) {
					const gchar* _tmp21_ = NULL;
					const gchar* _tmp22_ = NULL;
					_tmp21_ = _ ("Received ill-formed response string %s from child…");
					_tmp22_ = str;
					g_warning (_tmp21_, _tmp22_);
					parts = (_vala_array_free (parts, parts_length1, (GDestroyNotify) g_free), NULL);
					break;
				}
				_tmp23_ = parts;
				_tmp23__length1 = parts_length1;
				_tmp24_ = _tmp23_[0];
				if (g_strcmp0 (_tmp24_, "ERROR") == 0) {
					gchar** _tmp25_ = NULL;
					gint _tmp25__length1 = 0;
					const gchar* _tmp26_ = NULL;
					GFile* _tmp27_ = NULL;
					GFile* _tmp28_ = NULL;
					gchar** _tmp29_ = NULL;
					gint _tmp29__length1 = 0;
					const gchar* _tmp30_ = NULL;
					GError* _tmp31_ = NULL;
					GError* _tmp32_ = NULL;
					_tmp25_ = parts;
					_tmp25__length1 = parts_length1;
					_tmp26_ = _tmp25_[1];
					_tmp27_ = g_file_new_for_uri (_tmp26_);
					_tmp28_ = _tmp27_;
					_tmp29_ = parts;
					_tmp29__length1 = parts_length1;
					_tmp30_ = _tmp29_[3];
					_tmp31_ = g_error_new_literal (METADATA_EXTRACTOR_ERROR, METADATA_EXTRACTOR_ERROR_GENERAL, _tmp30_);
					_tmp32_ = _tmp31_;
					g_signal_emit_by_name (self, "error", _tmp28_, _tmp32_);
					_g_error_free0 (_tmp32_);
					_g_object_unref0 (_tmp28_);
					parts = (_vala_array_free (parts, parts_length1, (GDestroyNotify) g_free), NULL);
					break;
				}
				_tmp33_ = parts;
				_tmp33__length1 = parts_length1;
				_tmp34_ = _tmp33_[1];
				_tmp35_ = g_strdup (_tmp34_);
				uri = _tmp35_;
				_tmp36_ = parts;
				_tmp36__length1 = parts_length1;
				_tmp37_ = _tmp36_[2];
				_tmp38_ = uint64_parse (_tmp37_);
				length = _tmp38_;
				_tmp39_ = parts;
				_tmp39__length1 = parts_length1;
				_tmp40_ = _tmp39_[0];
				if (g_strcmp0 (_tmp40_, "SKIP") == 0) {
					const gchar* _tmp41_ = NULL;
					const gchar* _tmp42_ = NULL;
					GFile* _tmp43_ = NULL;
					GFile* _tmp44_ = NULL;
					_tmp41_ = uri;
					g_debug ("rygel-media-export-metadata-extractor.vala:210: Extractor binary told " \
"us to skip %s", _tmp41_);
					_tmp42_ = uri;
					_tmp43_ = g_file_new_for_uri (_tmp42_);
					_tmp44_ = _tmp43_;
					g_signal_emit_by_name (self, "extraction-done", _tmp44_, NULL);
					_g_object_unref0 (_tmp44_);
					_g_free0 (uri);
					parts = (_vala_array_free (parts, parts_length1, (GDestroyNotify) g_free), NULL);
					break;
				}
				_tmp45_ = uri;
				g_debug ("rygel-media-export-metadata-extractor.vala:217: Found serialized data " \
"for uri %s", _tmp45_);
				_tmp46_ = length;
				_tmp47_ = g_new0 (guint8, _tmp46_);
				buf = _tmp47_;
				buf_length1 = _tmp46_;
				_buf_size_ = buf_length1;
				_tmp48_ = self->priv->output_stream;
				_tmp49_ = buf;
				_tmp49__length1 = buf_length1;
				_tmp50_ = self->priv->child_io_cancellable;
				g_input_stream_read_all ((GInputStream*) _tmp48_, _tmp49_, (gsize) _tmp49__length1, &_tmp51_, _tmp50_, &_inner_error_);
				bytes = _tmp51_;
				if (G_UNLIKELY (_inner_error_ != NULL)) {
					buf = (g_free (buf), NULL);
					_g_free0 (uri);
					parts = (_vala_array_free (parts, parts_length1, (GDestroyNotify) g_free), NULL);
					_g_free0 (str);
					_g_object_unref0 (stream);
					goto __catch28_g_error;
				}
				_tmp52_ = length;
				_tmp53_ = bytes;
				g_debug ("Expected %" G_GSIZE_FORMAT " bytes, got %" G_GSIZE_FORMAT, _tmp52_, _tmp53_);
				_tmp54_ = rygel_media_export_metadata_extractor_SERIALIZED_DATA_TYPE;
				_tmp55_ = buf;
				_tmp55__length1 = buf_length1;
				_tmp56_ = g_variant_new_from_data (_tmp54_, (guchar*) _tmp55_, (_tmp55__length1 * sizeof (guint8)) / sizeof (guchar), TRUE, NULL, NULL);
				g_variant_ref_sink (_tmp56_);
				v = _tmp56_;
				_tmp57_ = uri;
				_tmp58_ = g_file_new_for_uri (_tmp57_);
				_tmp59_ = _tmp58_;
				_tmp60_ = v;
				g_signal_emit_by_name (self, "extraction-done", _tmp59_, _tmp60_);
				_g_object_unref0 (_tmp59_);
				_g_variant_unref0 (v);
				buf = (g_free (buf), NULL);
				_g_free0 (uri);
				parts = (_vala_array_free (parts, parts_length1, (GDestroyNotify) g_free), NULL);
			}
		}
		_tmp61_ = self->priv->output_stream;
		_tmp62_ = self->priv->child_io_cancellable;
		g_data_input_stream_read_line_async (_tmp61_, G_PRIORITY_DEFAULT, _tmp62_, _rygel_media_export_metadata_extractor_on_input_gasync_ready_callback, g_object_ref (self));
		_g_free0 (str);
		_g_object_unref0 (stream);
	}
	goto __finally28;
	__catch28_g_error:
	{
		GError* _error_ = NULL;
		GError* _tmp63_ = NULL;
		_error_ = _inner_error_;
		_inner_error_ = NULL;
		_tmp63_ = _error_;
		if (g_error_matches (_tmp63_, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
			g_debug ("rygel-media-export-metadata-extractor.vala:239: Read was cancelled, pr" \
"ocess probably died…");
		} else {
			const gchar* _tmp64_ = NULL;
			GError* _tmp65_ = NULL;
			const gchar* _tmp66_ = NULL;
			const gchar* _tmp67_ = NULL;
			GFile* _tmp68_ = NULL;
			GFile* _tmp69_ = NULL;
			GError* _tmp70_ = NULL;
			GError* _tmp71_ = NULL;
			_tmp64_ = _ ("Read from child failed: %s");
			_tmp65_ = _error_;
			_tmp66_ = _tmp65_->message;
			g_warning (_tmp64_, _tmp66_);
			_tmp67_ = self->priv->error_uri;
			_tmp68_ = g_file_new_for_uri (_tmp67_);
			_tmp69_ = _tmp68_;
			_tmp70_ = g_error_new_literal (METADATA_EXTRACTOR_ERROR, METADATA_EXTRACTOR_ERROR_GENERAL, "Failed");
			_tmp71_ = _tmp70_;
			g_signal_emit_by_name (self, "error", _tmp69_, _tmp71_);
			_g_error_free0 (_tmp71_);
			_g_object_unref0 (_tmp69_);
		}
		_g_error_free0 (_error_);
	}
	__finally28:
	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;
	}
}


static Block4Data* block4_data_ref (Block4Data* _data4_) {
	g_atomic_int_inc (&_data4_->_ref_count_);
	return _data4_;
}


static void block4_data_unref (void * _userdata_) {
	Block4Data* _data4_;
	_data4_ = (Block4Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data4_->_ref_count_)) {
		RygelMediaExportMetadataExtractor* self;
		self = _data4_->self;
		_g_object_unref0 (_data4_->file);
		_g_free0 (_data4_->content_type);
		_g_object_unref0 (self);
		g_slice_free (Block4Data, _data4_);
	}
}


static gboolean ___lambda7_ (Block4Data* _data4_) {
	RygelMediaExportMetadataExtractor* self;
	gboolean result = FALSE;
	GFile* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	self = _data4_->self;
	_tmp0_ = _data4_->file;
	_tmp1_ = _data4_->content_type;
	rygel_media_export_metadata_extractor_extract (self, _tmp0_, _tmp1_);
	result = FALSE;
	return result;
}


static gboolean ____lambda7__gsource_func (gpointer self) {
	gboolean result;
	result = ___lambda7_ (self);
	return result;
}


void rygel_media_export_metadata_extractor_extract (RygelMediaExportMetadataExtractor* self, GFile* file, const gchar* content_type) {
	Block4Data* _data4_;
	GFile* _tmp0_ = NULL;
	GFile* _tmp1_ = NULL;
	const gchar* _tmp2_ = NULL;
	gchar* _tmp3_ = NULL;
	GCancellable* _tmp4_ = NULL;
	gboolean _tmp5_ = FALSE;
	GFile* _tmp6_ = NULL;
	gchar* _tmp7_ = NULL;
	gchar* s = NULL;
	GFile* _tmp8_ = NULL;
	gchar* _tmp9_ = NULL;
	gchar* _tmp10_ = NULL;
	const gchar* _tmp11_ = NULL;
	gchar* _tmp12_ = NULL;
	gchar* _tmp13_ = NULL;
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (file != NULL);
	g_return_if_fail (content_type != NULL);
	_data4_ = g_slice_new0 (Block4Data);
	_data4_->_ref_count_ = 1;
	_data4_->self = g_object_ref (self);
	_tmp0_ = file;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (_data4_->file);
	_data4_->file = _tmp1_;
	_tmp2_ = content_type;
	_tmp3_ = g_strdup (_tmp2_);
	_g_free0 (_data4_->content_type);
	_data4_->content_type = _tmp3_;
	_tmp4_ = self->priv->child_io_cancellable;
	_tmp5_ = g_cancellable_is_cancelled (_tmp4_);
	if (_tmp5_) {
		g_debug ("rygel-media-export-metadata-extractor.vala:253: Child apparently alrea" \
"dy died, scheduling command for later");
		g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, ____lambda7__gsource_func, block4_data_ref (_data4_), block4_data_unref);
		block4_data_unref (_data4_);
		_data4_ = NULL;
		return;
	}
	_tmp6_ = _data4_->file;
	_tmp7_ = g_file_get_uri (_tmp6_);
	_g_free0 (self->priv->error_uri);
	self->priv->error_uri = _tmp7_;
	_tmp8_ = _data4_->file;
	_tmp9_ = g_file_get_uri (_tmp8_);
	_tmp10_ = _tmp9_;
	_tmp11_ = _data4_->content_type;
	_tmp12_ = g_strdup_printf ("EXTRACT %s|%s\n", _tmp10_, _tmp11_);
	_tmp13_ = _tmp12_;
	_g_free0 (_tmp10_);
	s = _tmp13_;
	{
		GUnixOutputStream* _tmp14_ = NULL;
		const gchar* _tmp15_ = NULL;
		guint8* _tmp16_ = NULL;
		gint _tmp16__length1 = 0;
		guint8* _tmp17_ = NULL;
		gint _tmp17__length1 = 0;
		GCancellable* _tmp18_ = NULL;
		GUnixOutputStream* _tmp19_ = NULL;
		const gchar* _tmp20_ = NULL;
		_tmp14_ = self->priv->input_stream;
		_tmp15_ = s;
		_tmp16_ = string_get_data (_tmp15_, &_tmp16__length1);
		_tmp17_ = _tmp16_;
		_tmp17__length1 = _tmp16__length1;
		_tmp18_ = self->priv->child_io_cancellable;
		g_output_stream_write_all ((GOutputStream*) _tmp14_, _tmp17_, (gsize) _tmp17__length1, NULL, _tmp18_, &_inner_error_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch29_g_error;
		}
		_tmp19_ = self->priv->input_stream;
		g_output_stream_flush ((GOutputStream*) _tmp19_, NULL, &_inner_error_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch29_g_error;
		}
		_tmp20_ = s;
		g_debug ("rygel-media-export-metadata-extractor.vala:268: Sent command to extrac" \
"tor process: %s", _tmp20_);
	}
	goto __finally29;
	__catch29_g_error:
	{
		GError* _error_ = NULL;
		const gchar* _tmp21_ = NULL;
		GError* _tmp22_ = NULL;
		const gchar* _tmp23_ = NULL;
		_error_ = _inner_error_;
		_inner_error_ = NULL;
		_tmp21_ = _ ("Failed to send command to child: %s");
		_tmp22_ = _error_;
		_tmp23_ = _tmp22_->message;
		g_warning (_tmp21_, _tmp23_);
		_g_error_free0 (_error_);
	}
	__finally29:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		_g_free0 (s);
		block4_data_unref (_data4_);
		_data4_ = 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;
	}
	_g_free0 (s);
	block4_data_unref (_data4_);
	_data4_ = NULL;
}


static gchar* bool_to_string (gboolean self) {
	gchar* result = NULL;
	if (self) {
		gchar* _tmp0_ = NULL;
		_tmp0_ = g_strdup ("true");
		result = _tmp0_;
		return result;
	} else {
		gchar* _tmp1_ = NULL;
		_tmp1_ = g_strdup ("false");
		result = _tmp1_;
		return result;
	}
}


static void rygel_media_export_metadata_extractor_on_config_changed (RygelMediaExportMetadataExtractor* self, RygelConfiguration* config, const gchar* section, const gchar* key) {
	gboolean _tmp0_ = FALSE;
	const gchar* _tmp1_ = NULL;
	gboolean _tmp6_ = FALSE;
	GUnixOutputStream* _tmp7_ = NULL;
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (config != NULL);
	g_return_if_fail (section != NULL);
	g_return_if_fail (key != NULL);
	_tmp1_ = section;
	if (g_strcmp0 (_tmp1_, RYGEL_MEDIA_EXPORT_PLUGIN_NAME) != 0) {
		_tmp0_ = TRUE;
	} else {
		const gchar* _tmp2_ = NULL;
		_tmp2_ = key;
		_tmp0_ = g_strcmp0 (_tmp2_, "extract-metadata") != 0;
	}
	if (_tmp0_) {
		return;
	}
	{
		gboolean _tmp3_ = FALSE;
		RygelConfiguration* _tmp4_ = NULL;
		gboolean _tmp5_ = FALSE;
		_tmp4_ = config;
		_tmp5_ = rygel_configuration_get_bool (_tmp4_, RYGEL_MEDIA_EXPORT_PLUGIN_NAME, "extract-metadata", &_inner_error_);
		_tmp3_ = _tmp5_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch30_g_error;
		}
		self->priv->extract_metadata = _tmp3_;
	}
	goto __finally30;
	__catch30_g_error:
	{
		GError* _error_ = NULL;
		_error_ = _inner_error_;
		_inner_error_ = NULL;
		self->priv->extract_metadata = TRUE;
		_g_error_free0 (_error_);
	}
	__finally30:
	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;
	}
	_tmp7_ = self->priv->input_stream;
	if (_tmp7_ != NULL) {
		GCancellable* _tmp8_ = NULL;
		gboolean _tmp9_ = FALSE;
		_tmp8_ = self->priv->child_io_cancellable;
		_tmp9_ = g_cancellable_is_cancelled (_tmp8_);
		_tmp6_ = !_tmp9_;
	} else {
		_tmp6_ = FALSE;
	}
	if (_tmp6_) {
		{
			gchar* s = NULL;
			gboolean _tmp10_ = FALSE;
			gchar* _tmp11_ = NULL;
			gchar* _tmp12_ = NULL;
			gchar* _tmp13_ = NULL;
			gchar* _tmp14_ = NULL;
			GUnixOutputStream* _tmp15_ = NULL;
			const gchar* _tmp16_ = NULL;
			guint8* _tmp17_ = NULL;
			gint _tmp17__length1 = 0;
			guint8* _tmp18_ = NULL;
			gint _tmp18__length1 = 0;
			GUnixOutputStream* _tmp19_ = NULL;
			const gchar* _tmp20_ = NULL;
			_tmp10_ = self->priv->extract_metadata;
			_tmp11_ = bool_to_string (_tmp10_);
			_tmp12_ = _tmp11_;
			_tmp13_ = g_strdup_printf ("METADATA %s\n", _tmp12_);
			_tmp14_ = _tmp13_;
			_g_free0 (_tmp12_);
			s = _tmp14_;
			_tmp15_ = self->priv->input_stream;
			_tmp16_ = s;
			_tmp17_ = string_get_data (_tmp16_, &_tmp17__length1);
			_tmp18_ = _tmp17_;
			_tmp18__length1 = _tmp17__length1;
			g_output_stream_write_all ((GOutputStream*) _tmp15_, _tmp18_, (gsize) _tmp18__length1, NULL, NULL, &_inner_error_);
			if (G_UNLIKELY (_inner_error_ != NULL)) {
				_g_free0 (s);
				goto __catch31_g_error;
			}
			_tmp19_ = self->priv->input_stream;
			g_output_stream_flush ((GOutputStream*) _tmp19_, NULL, &_inner_error_);
			if (G_UNLIKELY (_inner_error_ != NULL)) {
				_g_free0 (s);
				goto __catch31_g_error;
			}
			_tmp20_ = s;
			g_debug ("rygel-media-export-metadata-extractor.vala:298: Sent config change to " \
"child: %s", _tmp20_);
			_g_free0 (s);
		}
		goto __finally31;
		__catch31_g_error:
		{
			GError* _error_ = NULL;
			GError* _tmp21_ = NULL;
			const gchar* _tmp22_ = NULL;
			_error_ = _inner_error_;
			_inner_error_ = NULL;
			_tmp21_ = _error_;
			_tmp22_ = _tmp21_->message;
			g_debug ("rygel-media-export-metadata-extractor.vala:300: Failed to set meta-dat" \
"a extraction state: %s", _tmp22_);
			_g_error_free0 (_error_);
		}
		__finally31:
		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;
		}
	}
}


static void g_cclosure_user_marshal_VOID__OBJECT_VARIANT (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data) {
	typedef void (*GMarshalFunc_VOID__OBJECT_VARIANT) (gpointer data1, gpointer arg_1, gpointer arg_2, gpointer data2);
	register GMarshalFunc_VOID__OBJECT_VARIANT callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	cc = (GCClosure *) closure;
	g_return_if_fail (n_param_values == 3);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_VOID__OBJECT_VARIANT) (marshal_data ? marshal_data : cc->callback);
	callback (data1, g_value_get_object (param_values + 1), g_value_get_variant (param_values + 2), data2);
}


static void g_cclosure_user_marshal_VOID__OBJECT_POINTER (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data) {
	typedef void (*GMarshalFunc_VOID__OBJECT_POINTER) (gpointer data1, gpointer arg_1, gpointer arg_2, gpointer data2);
	register GMarshalFunc_VOID__OBJECT_POINTER callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	cc = (GCClosure *) closure;
	g_return_if_fail (n_param_values == 3);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_VOID__OBJECT_POINTER) (marshal_data ? marshal_data : cc->callback);
	callback (data1, g_value_get_object (param_values + 1), g_value_get_pointer (param_values + 2), data2);
}


static void rygel_media_export_metadata_extractor_class_init (RygelMediaExportMetadataExtractorClass * klass) {
	GVariantType* _tmp0_ = NULL;
	rygel_media_export_metadata_extractor_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (RygelMediaExportMetadataExtractorPrivate));
	G_OBJECT_CLASS (klass)->finalize = rygel_media_export_metadata_extractor_finalize;
	g_signal_new ("extraction_done", RYGEL_MEDIA_EXPORT_TYPE_METADATA_EXTRACTOR, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__OBJECT_VARIANT, G_TYPE_NONE, 2, G_TYPE_FILE, G_TYPE_VARIANT);
	/**
	     * Signalize that an error occured during metadata extraction
	     */
	g_signal_new ("error", RYGEL_MEDIA_EXPORT_TYPE_METADATA_EXTRACTOR, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__OBJECT_POINTER, G_TYPE_NONE, 2, G_TYPE_FILE, G_TYPE_POINTER);
	_tmp0_ = g_variant_type_new ("a{sv}");
	_g_variant_type_free0 (rygel_media_export_metadata_extractor_SERIALIZED_DATA_TYPE);
	rygel_media_export_metadata_extractor_SERIALIZED_DATA_TYPE = _tmp0_;
}


static void rygel_media_export_metadata_extractor_instance_init (RygelMediaExportMetadataExtractor * self) {
	gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	gchar* _tmp3_ = NULL;
	gchar** _tmp4_ = NULL;
	self->priv = RYGEL_MEDIA_EXPORT_METADATA_EXTRACTOR_GET_PRIVATE (self);
	self->priv->error_uri = NULL;
	_tmp0_ = g_strdup (MX_EXTRACT_PATH);
	_tmp1_ = g_strdup ("--input-fd=3");
	_tmp2_ = g_strdup ("--output-fd=4");
	_tmp3_ = g_strdup ("--extract-metadata");
	_tmp4_ = g_new0 (gchar*, 5 + 1);
	_tmp4_[0] = _tmp0_;
	_tmp4_[1] = _tmp1_;
	_tmp4_[2] = _tmp2_;
	_tmp4_[3] = _tmp3_;
	_tmp4_[4] = NULL;
	self->priv->MX_EXTRACT_ARGV = _tmp4_;
	self->priv->MX_EXTRACT_ARGV_length1 = 5;
	self->priv->_MX_EXTRACT_ARGV_size_ = self->priv->MX_EXTRACT_ARGV_length1;
}


static void rygel_media_export_metadata_extractor_finalize (GObject* obj) {
	RygelMediaExportMetadataExtractor * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_MEDIA_EXPORT_TYPE_METADATA_EXTRACTOR, RygelMediaExportMetadataExtractor);
	_g_object_unref0 (self->priv->input_stream);
	_g_object_unref0 (self->priv->output_stream);
	_g_object_unref0 (self->priv->child_io_cancellable);
	_g_object_unref0 (self->priv->launcher);
	_g_free0 (self->priv->error_uri);
	self->priv->MX_EXTRACT_ARGV = (_vala_array_free (self->priv->MX_EXTRACT_ARGV, self->priv->MX_EXTRACT_ARGV_length1, (GDestroyNotify) g_free), NULL);
	G_OBJECT_CLASS (rygel_media_export_metadata_extractor_parent_class)->finalize (obj);
}


/**
 * Metadata extractor based on Gstreamer. Just set the URI of the media on the
 * uri property, it will extact the metadata for you and emit signal
 * metadata_available for each key/value pair extracted.
 */
GType rygel_media_export_metadata_extractor_get_type (void) {
	static volatile gsize rygel_media_export_metadata_extractor_type_id__volatile = 0;
	if (g_once_init_enter (&rygel_media_export_metadata_extractor_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (RygelMediaExportMetadataExtractorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rygel_media_export_metadata_extractor_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RygelMediaExportMetadataExtractor), 0, (GInstanceInitFunc) rygel_media_export_metadata_extractor_instance_init, NULL };
		GType rygel_media_export_metadata_extractor_type_id;
		rygel_media_export_metadata_extractor_type_id = g_type_register_static (G_TYPE_OBJECT, "RygelMediaExportMetadataExtractor", &g_define_type_info, 0);
		g_once_init_leave (&rygel_media_export_metadata_extractor_type_id__volatile, rygel_media_export_metadata_extractor_type_id);
	}
	return rygel_media_export_metadata_extractor_type_id__volatile;
}


static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	if ((array != NULL) && (destroy_func != NULL)) {
		int i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}


static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}


static gint _vala_array_length (gpointer array) {
	int length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}



