/* rygel-media-export-metadata-extractor.c generated by valac 0.20.1.2-ca5c2, 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 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 <gst/pbutils/codec-utils.h>
#include <gst/pbutils/descriptions.h>
#include <gst/pbutils/encoding-profile.h>
#include <gst/pbutils/encoding-target.h>
#include <gst/pbutils/gstdiscoverer.h>
#include <gst/pbutils/gstpluginsbaseversion.h>
#include <gst/pbutils/install-plugins.h>
#include <gst/pbutils/missing-plugins.h>
#include <gst/pbutils/pbutils-enumtypes.h>
#include <gst/pbutils/pbutils.h>
#include <libgupnp-dlna/gupnp-dlna.h>
#include <gee.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.h>
#include <rygel-core.h>
#include <gst/gst.h>
#include <libgupnp-dlna/gupnp-dlna-gst-utils.h>
#include <glib/gi18n-lib.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_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

struct _RygelMediaExportMetadataExtractor {
	GObject parent_instance;
	RygelMediaExportMetadataExtractorPrivate * priv;
};

struct _RygelMediaExportMetadataExtractorClass {
	GObjectClass parent_class;
};

struct _RygelMediaExportMetadataExtractorPrivate {
	GstDiscoverer* discoverer;
	GUPnPDLNAProfileGuesser* guesser;
	GeeHashMap* file_hash;
	guint timeout;
	gboolean extract_metadata;
};


static gpointer rygel_media_export_metadata_extractor_parent_class = NULL;

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
};
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_extract (RygelMediaExportMetadataExtractor* self, GFile* file, const gchar* content_type);
static void rygel_media_export_metadata_extractor_extract_basic_information (RygelMediaExportMetadataExtractor* self, GFile* file, GstDiscovererInfo* info, GUPnPDLNAProfile* dlna);
static void rygel_media_export_metadata_extractor_on_done (RygelMediaExportMetadataExtractor* self, GstDiscovererInfo* info, GError* err);
static void _rygel_media_export_metadata_extractor_on_done_gst_pb_utils_discoverer_discovered (GstDiscoverer* _sender, GstDiscovererInfo* info, GError* err, gpointer self);
static void g_cclosure_user_marshal_VOID__OBJECT_OBJECT_OBJECT_OBJECT (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 _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 (self, _sender, section, key);
}


RygelMediaExportMetadataExtractor* rygel_media_export_metadata_extractor_construct (GType object_type) {
	RygelMediaExportMetadataExtractor * self = NULL;
	GeeHashMap* _tmp0_;
	RygelMetaConfig* _tmp1_ = NULL;
	RygelMetaConfig* config;
	self = (RygelMediaExportMetadataExtractor*) g_object_new (object_type, NULL);
	_tmp0_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, G_TYPE_FILE, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->file_hash);
	self->priv->file_hash = _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 void _rygel_media_export_metadata_extractor_on_done_gst_pb_utils_discoverer_discovered (GstDiscoverer* _sender, GstDiscovererInfo* info, GError* err, gpointer self) {
	rygel_media_export_metadata_extractor_on_done (self, info, err);
}


void rygel_media_export_metadata_extractor_extract (RygelMediaExportMetadataExtractor* self, GFile* file, const gchar* content_type) {
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_;
	gboolean _tmp4_;
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (file != NULL);
	g_return_if_fail (content_type != NULL);
	_tmp1_ = self->priv->extract_metadata;
	if (_tmp1_) {
		const gchar* _tmp2_;
		gboolean _tmp3_ = FALSE;
		_tmp2_ = content_type;
		_tmp3_ = g_str_has_prefix (_tmp2_, "text/");
		_tmp0_ = !_tmp3_;
	} else {
		_tmp0_ = FALSE;
	}
	_tmp4_ = _tmp0_;
	if (_tmp4_) {
		GFile* _tmp5_;
		gchar* _tmp6_ = NULL;
		gchar* uri;
		GeeHashMap* _tmp12_;
		const gchar* _tmp13_;
		GFile* _tmp14_;
		GstDiscoverer* _tmp15_;
		GstDiscoverer* _tmp16_;
		GstDiscoverer* _tmp17_;
		const gchar* _tmp18_;
		GUPnPDLNAProfileGuesser* _tmp19_;
		_tmp5_ = file;
		_tmp6_ = g_file_get_uri (_tmp5_);
		uri = _tmp6_;
		{
			guint _tmp7_;
			GstClockTime gst_timeout;
			GstClockTime _tmp8_;
			GstDiscoverer* _tmp9_;
			GstDiscoverer* _tmp10_;
			_tmp7_ = self->priv->timeout;
			gst_timeout = (GstClockTime) (_tmp7_ * GST_SECOND);
			_tmp8_ = gst_timeout;
			_tmp9_ = gst_discoverer_new (_tmp8_, &_inner_error_);
			_tmp10_ = _tmp9_;
			if (_inner_error_ != NULL) {
				goto __catch31_g_error;
			}
			_g_object_unref0 (self->priv->discoverer);
			self->priv->discoverer = _tmp10_;
		}
		goto __finally31;
		__catch31_g_error:
		{
			GError* _error_ = NULL;
			GFile* _tmp11_;
			_error_ = _inner_error_;
			_inner_error_ = NULL;
			g_debug ("rygel-media-export-metadata-extractor.vala:78: Failed to create a disc" \
"overer. Doing basic extraction.");
			_tmp11_ = file;
			rygel_media_export_metadata_extractor_extract_basic_information (self, _tmp11_, NULL, NULL);
			_g_error_free0 (_error_);
			_g_free0 (uri);
			return;
		}
		__finally31:
		if (_inner_error_ != NULL) {
			_g_free0 (uri);
			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;
		}
		_tmp12_ = self->priv->file_hash;
		_tmp13_ = uri;
		_tmp14_ = file;
		gee_abstract_map_set ((GeeAbstractMap*) _tmp12_, _tmp13_, _tmp14_);
		_tmp15_ = self->priv->discoverer;
		g_signal_connect_object (_tmp15_, "discovered", (GCallback) _rygel_media_export_metadata_extractor_on_done_gst_pb_utils_discoverer_discovered, self, 0);
		_tmp16_ = self->priv->discoverer;
		gst_discoverer_start (_tmp16_);
		_tmp17_ = self->priv->discoverer;
		_tmp18_ = uri;
		gst_discoverer_discover_uri_async (_tmp17_, _tmp18_);
		_tmp19_ = gupnp_dlna_profile_guesser_new (TRUE, TRUE);
		_g_object_unref0 (self->priv->guesser);
		self->priv->guesser = _tmp19_;
		_g_free0 (uri);
	} else {
		GFile* _tmp20_;
		_tmp20_ = file;
		rygel_media_export_metadata_extractor_extract_basic_information (self, _tmp20_, NULL, NULL);
	}
}


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


static void rygel_media_export_metadata_extractor_on_done (RygelMediaExportMetadataExtractor* self, GstDiscovererInfo* info, GError* err) {
	GeeHashMap* _tmp0_;
	GstDiscovererInfo* _tmp1_;
	const gchar* _tmp2_ = NULL;
	gpointer _tmp3_ = NULL;
	GFile* file;
	GFile* _tmp4_;
	GeeHashMap* _tmp7_;
	GstDiscovererInfo* _tmp8_;
	const gchar* _tmp9_ = NULL;
	GstDiscovererInfo* _tmp10_;
	GstDiscovererResult _tmp11_ = 0;
	GstDiscovererInfo* _tmp20_;
	GUPnPDLNAInformation* _tmp21_ = NULL;
	GUPnPDLNAInformation* dlna_info;
	GUPnPDLNAProfileGuesser* _tmp22_;
	GUPnPDLNAInformation* _tmp23_;
	GUPnPDLNAProfile* _tmp24_ = NULL;
	GUPnPDLNAProfile* _tmp25_;
	GUPnPDLNAProfile* dlna;
	GFile* _tmp26_;
	GstDiscovererInfo* _tmp27_;
	GUPnPDLNAProfile* _tmp28_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (info != NULL);
	_g_object_unref0 (self->priv->discoverer);
	self->priv->discoverer = NULL;
	_tmp0_ = self->priv->file_hash;
	_tmp1_ = info;
	_tmp2_ = gst_discoverer_info_get_uri (_tmp1_);
	_tmp3_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp0_, _tmp2_);
	file = (GFile*) _tmp3_;
	_tmp4_ = file;
	if (_tmp4_ == NULL) {
		GstDiscovererInfo* _tmp5_;
		const gchar* _tmp6_ = NULL;
		_tmp5_ = info;
		_tmp6_ = gst_discoverer_info_get_uri (_tmp5_);
		g_warning ("rygel-media-export-metadata-extractor.vala:97: File %s already handled" \
", ignoring event", _tmp6_);
		_g_object_unref0 (file);
		return;
	}
	_tmp7_ = self->priv->file_hash;
	_tmp8_ = info;
	_tmp9_ = gst_discoverer_info_get_uri (_tmp8_);
	gee_abstract_map_unset ((GeeAbstractMap*) _tmp7_, _tmp9_, NULL);
	_tmp10_ = info;
	_tmp11_ = gst_discoverer_info_get_result (_tmp10_);
	if ((_tmp11_ & GST_DISCOVERER_TIMEOUT) != 0) {
		GFile* _tmp12_;
		gchar* _tmp13_ = NULL;
		gchar* _tmp14_;
		GFile* _tmp15_;
		_tmp12_ = file;
		_tmp13_ = g_file_get_uri (_tmp12_);
		_tmp14_ = _tmp13_;
		g_debug ("rygel-media-export-metadata-extractor.vala:106: Extraction timed out o" \
"n %s", _tmp14_);
		_g_free0 (_tmp14_);
		_tmp15_ = file;
		rygel_media_export_metadata_extractor_extract_basic_information (self, _tmp15_, NULL, NULL);
		_g_object_unref0 (file);
		return;
	} else {
		GstDiscovererInfo* _tmp16_;
		GstDiscovererResult _tmp17_ = 0;
		_tmp16_ = info;
		_tmp17_ = gst_discoverer_info_get_result (_tmp16_);
		if ((_tmp17_ & GST_DISCOVERER_ERROR) != 0) {
			GFile* _tmp18_;
			GError* _tmp19_;
			_tmp18_ = file;
			_tmp19_ = err;
			g_signal_emit_by_name (self, "error", _tmp18_, _tmp19_);
			_g_object_unref0 (file);
			return;
		}
	}
	_tmp20_ = info;
	_tmp21_ = gupnp_dlna_gst_utils_information_from_discoverer_info (_tmp20_);
	dlna_info = _tmp21_;
	_tmp22_ = self->priv->guesser;
	_tmp23_ = dlna_info;
	_tmp24_ = gupnp_dlna_profile_guesser_guess_profile_from_info (_tmp22_, _tmp23_);
	_tmp25_ = _g_object_ref0 (_tmp24_);
	dlna = _tmp25_;
	_tmp26_ = file;
	_tmp27_ = info;
	_tmp28_ = dlna;
	rygel_media_export_metadata_extractor_extract_basic_information (self, _tmp26_, _tmp27_, _tmp28_);
	_g_object_unref0 (dlna);
	_g_object_unref0 (dlna_info);
	_g_object_unref0 (file);
}


static void rygel_media_export_metadata_extractor_extract_basic_information (RygelMediaExportMetadataExtractor* self, GFile* file, GstDiscovererInfo* info, GUPnPDLNAProfile* dlna) {
	GFileInfo* file_info = NULL;
	GFile* _tmp12_;
	GstDiscovererInfo* _tmp13_;
	GUPnPDLNAProfile* _tmp14_;
	GFileInfo* _tmp15_;
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (file != NULL);
	{
		GFile* _tmp0_;
		GFileInfo* _tmp1_ = NULL;
		GFileInfo* _tmp2_;
		_tmp0_ = file;
		_tmp1_ = g_file_query_info (_tmp0_, 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, NULL, &_inner_error_);
		_tmp2_ = _tmp1_;
		if (_inner_error_ != NULL) {
			goto __catch32_g_error;
		}
		_g_object_unref0 (file_info);
		file_info = _tmp2_;
	}
	goto __finally32;
	__catch32_g_error:
	{
		GError* _error_ = NULL;
		GFile* _tmp3_;
		gchar* _tmp4_ = NULL;
		gchar* uri;
		const gchar* _tmp5_ = NULL;
		const gchar* _tmp6_;
		const gchar* _tmp7_;
		GError* _tmp8_;
		const gchar* _tmp9_;
		GFile* _tmp10_;
		GError* _tmp11_;
		_error_ = _inner_error_;
		_inner_error_ = NULL;
		_tmp3_ = file;
		_tmp4_ = g_file_get_uri (_tmp3_);
		uri = _tmp4_;
		_tmp5_ = _ ("Failed to query content type for '%s'");
		_tmp6_ = uri;
		g_warning (_tmp5_, _tmp6_);
		_tmp7_ = uri;
		_tmp8_ = _error_;
		_tmp9_ = _tmp8_->message;
		g_debug ("rygel-media-export-metadata-extractor.vala:140: Failed to extract basi" \
"c metadata from %s: %s", _tmp7_, _tmp9_);
		_tmp10_ = file;
		_tmp11_ = _error_;
		g_signal_emit_by_name (self, "error", _tmp10_, _tmp11_);
		_g_free0 (uri);
		_g_error_free0 (_error_);
		_g_object_unref0 (file_info);
		return;
	}
	__finally32:
	if (_inner_error_ != NULL) {
		_g_object_unref0 (file_info);
		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;
	}
	_tmp12_ = file;
	_tmp13_ = info;
	_tmp14_ = dlna;
	_tmp15_ = file_info;
	g_signal_emit_by_name (self, "extraction-done", _tmp12_, _tmp13_, _tmp14_, _tmp15_);
	_g_object_unref0 (file_info);
}


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_;
	gboolean _tmp3_;
	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_;
		_tmp2_ = key;
		_tmp0_ = g_strcmp0 (_tmp2_, "extract-metadata") != 0;
	}
	_tmp3_ = _tmp0_;
	if (_tmp3_) {
		return;
	}
	{
		RygelConfiguration* _tmp4_;
		gboolean _tmp5_ = FALSE;
		gboolean _tmp6_;
		_tmp4_ = config;
		_tmp5_ = rygel_configuration_get_bool (_tmp4_, RYGEL_MEDIA_EXPORT_PLUGIN_NAME, "extract-metadata", &_inner_error_);
		_tmp6_ = _tmp5_;
		if (_inner_error_ != NULL) {
			goto __catch33_g_error;
		}
		self->priv->extract_metadata = _tmp6_;
	}
	goto __finally33;
	__catch33_g_error:
	{
		GError* _error_ = NULL;
		_error_ = _inner_error_;
		_inner_error_ = NULL;
		self->priv->extract_metadata = TRUE;
		_g_error_free0 (_error_);
	}
	__finally33:
	if (_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_OBJECT_OBJECT_OBJECT (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data) {
	typedef void (*GMarshalFunc_VOID__OBJECT_OBJECT_OBJECT_OBJECT) (gpointer data1, gpointer arg_1, gpointer arg_2, gpointer arg_3, gpointer arg_4, gpointer data2);
	register GMarshalFunc_VOID__OBJECT_OBJECT_OBJECT_OBJECT callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	cc = (GCClosure *) closure;
	g_return_if_fail (n_param_values == 5);
	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_OBJECT_OBJECT_OBJECT) (marshal_data ? marshal_data : cc->callback);
	callback (data1, g_value_get_object (param_values + 1), g_value_get_object (param_values + 2), g_value_get_object (param_values + 3), g_value_get_object (param_values + 4), 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) {
	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_OBJECT_OBJECT_OBJECT, G_TYPE_NONE, 4, G_TYPE_FILE, gst_discoverer_info_get_type (), gupnp_dlna_profile_get_type (), g_file_info_get_type ());
	/**
	     * 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);
}


static void rygel_media_export_metadata_extractor_instance_init (RygelMediaExportMetadataExtractor * self) {
	self->priv = RYGEL_MEDIA_EXPORT_METADATA_EXTRACTOR_GET_PRIVATE (self);
	self->priv->timeout = (guint) 10;
}


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->discoverer);
	_g_object_unref0 (self->priv->guesser);
	_g_object_unref0 (self->priv->file_hash);
	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;
}



