/* rygel-gst-media-engine.c generated by valac 0.25.1.16-16e7a, the Vala compiler
 * generated from rygel-gst-media-engine.vala, do not modify */

/*
 * Copyright (C) 2012 Intel Corporation.
 *
 * Author: Jens Georg <jensg@openismus.com>
 *
 * 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 <rygel-server.h>
#include <rygel-core.h>
#include <gst/gst.h>
#include <libgupnp-dlna/gupnp-dlna.h>
#include <gee.h>
#include <glib/gi18n-lib.h>


#define RYGEL_TYPE_GST_MEDIA_ENGINE (rygel_gst_media_engine_get_type ())
#define RYGEL_GST_MEDIA_ENGINE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_GST_MEDIA_ENGINE, RygelGstMediaEngine))
#define RYGEL_GST_MEDIA_ENGINE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_GST_MEDIA_ENGINE, RygelGstMediaEngineClass))
#define RYGEL_IS_GST_MEDIA_ENGINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_GST_MEDIA_ENGINE))
#define RYGEL_IS_GST_MEDIA_ENGINE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_GST_MEDIA_ENGINE))
#define RYGEL_GST_MEDIA_ENGINE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_GST_MEDIA_ENGINE, RygelGstMediaEngineClass))

typedef struct _RygelGstMediaEngine RygelGstMediaEngine;
typedef struct _RygelGstMediaEngineClass RygelGstMediaEngineClass;
typedef struct _RygelGstMediaEnginePrivate RygelGstMediaEnginePrivate;
#define __g_list_free__rygel_dlna_profile_unref0_0(var) ((var == NULL) ? NULL : (var = (_g_list_free__rygel_dlna_profile_unref0_ (var), NULL)))
#define __g_list_free__g_object_unref0_0(var) ((var == NULL) ? NULL : (var = (_g_list_free__g_object_unref0_ (var), NULL)))
#define _rygel_dlna_profile_unref0(var) ((var == NULL) ? NULL : (var = (rygel_dlna_profile_unref (var), NULL)))
#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 RYGEL_TYPE_GST_TRANSCODER (rygel_gst_transcoder_get_type ())
#define RYGEL_GST_TRANSCODER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_GST_TRANSCODER, RygelGstTranscoder))
#define RYGEL_GST_TRANSCODER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_GST_TRANSCODER, RygelGstTranscoderClass))
#define RYGEL_IS_GST_TRANSCODER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_GST_TRANSCODER))
#define RYGEL_IS_GST_TRANSCODER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_GST_TRANSCODER))
#define RYGEL_GST_TRANSCODER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_GST_TRANSCODER, RygelGstTranscoderClass))

typedef struct _RygelGstTranscoder RygelGstTranscoder;
typedef struct _RygelGstTranscoderClass RygelGstTranscoderClass;

#define RYGEL_TYPE_AUDIO_TRANSCODER (rygel_audio_transcoder_get_type ())
#define RYGEL_AUDIO_TRANSCODER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_AUDIO_TRANSCODER, RygelAudioTranscoder))
#define RYGEL_AUDIO_TRANSCODER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_AUDIO_TRANSCODER, RygelAudioTranscoderClass))
#define RYGEL_IS_AUDIO_TRANSCODER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_AUDIO_TRANSCODER))
#define RYGEL_IS_AUDIO_TRANSCODER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_AUDIO_TRANSCODER))
#define RYGEL_AUDIO_TRANSCODER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_AUDIO_TRANSCODER, RygelAudioTranscoderClass))

typedef struct _RygelAudioTranscoder RygelAudioTranscoder;
typedef struct _RygelAudioTranscoderClass RygelAudioTranscoderClass;

#define RYGEL_TYPE_L16_TRANSCODER (rygel_l16_transcoder_get_type ())
#define RYGEL_L16_TRANSCODER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_L16_TRANSCODER, RygelL16Transcoder))
#define RYGEL_L16_TRANSCODER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_L16_TRANSCODER, RygelL16TranscoderClass))
#define RYGEL_IS_L16_TRANSCODER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_L16_TRANSCODER))
#define RYGEL_IS_L16_TRANSCODER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_L16_TRANSCODER))
#define RYGEL_L16_TRANSCODER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_L16_TRANSCODER, RygelL16TranscoderClass))

typedef struct _RygelL16Transcoder RygelL16Transcoder;
typedef struct _RygelL16TranscoderClass RygelL16TranscoderClass;

#define RYGEL_TYPE_MP3_TRANSCODER (rygel_mp3_transcoder_get_type ())
#define RYGEL_MP3_TRANSCODER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_MP3_TRANSCODER, RygelMP3Transcoder))
#define RYGEL_MP3_TRANSCODER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_MP3_TRANSCODER, RygelMP3TranscoderClass))
#define RYGEL_IS_MP3_TRANSCODER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_MP3_TRANSCODER))
#define RYGEL_IS_MP3_TRANSCODER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_MP3_TRANSCODER))
#define RYGEL_MP3_TRANSCODER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_MP3_TRANSCODER, RygelMP3TranscoderClass))

typedef struct _RygelMP3Transcoder RygelMP3Transcoder;
typedef struct _RygelMP3TranscoderClass RygelMP3TranscoderClass;

#define RYGEL_TYPE_MP2_TS_PROFILE (rygel_mp2_ts_profile_get_type ())

#define RYGEL_TYPE_VIDEO_TRANSCODER (rygel_video_transcoder_get_type ())
#define RYGEL_VIDEO_TRANSCODER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_VIDEO_TRANSCODER, RygelVideoTranscoder))
#define RYGEL_VIDEO_TRANSCODER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_VIDEO_TRANSCODER, RygelVideoTranscoderClass))
#define RYGEL_IS_VIDEO_TRANSCODER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_VIDEO_TRANSCODER))
#define RYGEL_IS_VIDEO_TRANSCODER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_VIDEO_TRANSCODER))
#define RYGEL_VIDEO_TRANSCODER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_VIDEO_TRANSCODER, RygelVideoTranscoderClass))

typedef struct _RygelVideoTranscoder RygelVideoTranscoder;
typedef struct _RygelVideoTranscoderClass RygelVideoTranscoderClass;

#define RYGEL_TYPE_MP2_TS_TRANSCODER (rygel_mp2_ts_transcoder_get_type ())
#define RYGEL_MP2_TS_TRANSCODER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_MP2_TS_TRANSCODER, RygelMP2TSTranscoder))
#define RYGEL_MP2_TS_TRANSCODER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_MP2_TS_TRANSCODER, RygelMP2TSTranscoderClass))
#define RYGEL_IS_MP2_TS_TRANSCODER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_MP2_TS_TRANSCODER))
#define RYGEL_IS_MP2_TS_TRANSCODER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_MP2_TS_TRANSCODER))
#define RYGEL_MP2_TS_TRANSCODER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_MP2_TS_TRANSCODER, RygelMP2TSTranscoderClass))

typedef struct _RygelMP2TSTranscoder RygelMP2TSTranscoder;
typedef struct _RygelMP2TSTranscoderClass RygelMP2TSTranscoderClass;

#define RYGEL_TYPE_WMV_TRANSCODER (rygel_wmv_transcoder_get_type ())
#define RYGEL_WMV_TRANSCODER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_WMV_TRANSCODER, RygelWMVTranscoder))
#define RYGEL_WMV_TRANSCODER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_WMV_TRANSCODER, RygelWMVTranscoderClass))
#define RYGEL_IS_WMV_TRANSCODER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_WMV_TRANSCODER))
#define RYGEL_IS_WMV_TRANSCODER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_WMV_TRANSCODER))
#define RYGEL_WMV_TRANSCODER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_WMV_TRANSCODER, RygelWMVTranscoderClass))

typedef struct _RygelWMVTranscoder RygelWMVTranscoder;
typedef struct _RygelWMVTranscoderClass RygelWMVTranscoderClass;

#define RYGEL_TYPE_AAC_TRANSCODER (rygel_aac_transcoder_get_type ())
#define RYGEL_AAC_TRANSCODER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_AAC_TRANSCODER, RygelAACTranscoder))
#define RYGEL_AAC_TRANSCODER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_AAC_TRANSCODER, RygelAACTranscoderClass))
#define RYGEL_IS_AAC_TRANSCODER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_AAC_TRANSCODER))
#define RYGEL_IS_AAC_TRANSCODER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_AAC_TRANSCODER))
#define RYGEL_AAC_TRANSCODER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_AAC_TRANSCODER, RygelAACTranscoderClass))

typedef struct _RygelAACTranscoder RygelAACTranscoder;
typedef struct _RygelAACTranscoderClass RygelAACTranscoderClass;

#define RYGEL_TYPE_AVC_TRANSCODER (rygel_avc_transcoder_get_type ())
#define RYGEL_AVC_TRANSCODER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_AVC_TRANSCODER, RygelAVCTranscoder))
#define RYGEL_AVC_TRANSCODER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_AVC_TRANSCODER, RygelAVCTranscoderClass))
#define RYGEL_IS_AVC_TRANSCODER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_AVC_TRANSCODER))
#define RYGEL_IS_AVC_TRANSCODER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_AVC_TRANSCODER))
#define RYGEL_AVC_TRANSCODER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_AVC_TRANSCODER, RygelAVCTranscoderClass))

typedef struct _RygelAVCTranscoder RygelAVCTranscoder;
typedef struct _RygelAVCTranscoderClass RygelAVCTranscoderClass;
#define _g_free0(var) (var = (g_free (var), NULL))

#define RYGEL_TYPE_GST_DATA_SOURCE (rygel_gst_data_source_get_type ())
#define RYGEL_GST_DATA_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_GST_DATA_SOURCE, RygelGstDataSource))
#define RYGEL_GST_DATA_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_GST_DATA_SOURCE, RygelGstDataSourceClass))
#define RYGEL_IS_GST_DATA_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_GST_DATA_SOURCE))
#define RYGEL_IS_GST_DATA_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_GST_DATA_SOURCE))
#define RYGEL_GST_DATA_SOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_GST_DATA_SOURCE, RygelGstDataSourceClass))

typedef struct _RygelGstDataSource RygelGstDataSource;
typedef struct _RygelGstDataSourceClass RygelGstDataSourceClass;

struct _RygelGstMediaEngine {
	RygelMediaEngine parent_instance;
	RygelGstMediaEnginePrivate * priv;
};

struct _RygelGstMediaEngineClass {
	RygelMediaEngineClass parent_class;
};

struct _RygelGstMediaEnginePrivate {
	GList* dlna_profiles;
	GList* transcoders;
};

typedef enum  {
	RYGEL_MP2_TS_PROFILE_SD_EU = 0,
	RYGEL_MP2_TS_PROFILE_SD_NA,
	RYGEL_MP2_TS_PROFILE_HD_NA
} RygelMP2TSProfile;


static gpointer rygel_gst_media_engine_parent_class = NULL;

gboolean gst_preset_set_app_dir (const gchar* app_dir);
GType rygel_gst_media_engine_get_type (void) G_GNUC_CONST;
#define RYGEL_GST_MEDIA_ENGINE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RYGEL_TYPE_GST_MEDIA_ENGINE, RygelGstMediaEnginePrivate))
enum  {
	RYGEL_GST_MEDIA_ENGINE_DUMMY_PROPERTY
};
static void _rygel_dlna_profile_unref0_ (gpointer var);
static void _g_list_free__rygel_dlna_profile_unref0_ (GList* self);
static void _g_object_unref0_ (gpointer var);
static void _g_list_free__g_object_unref0_ (GList* self);
RygelGstMediaEngine* rygel_gst_media_engine_new (void);
RygelGstMediaEngine* rygel_gst_media_engine_construct (GType object_type);
RygelL16Transcoder* rygel_l16_transcoder_new (void);
RygelL16Transcoder* rygel_l16_transcoder_construct (GType object_type);
GType rygel_gst_transcoder_get_type (void) G_GNUC_CONST;
GType rygel_audio_transcoder_get_type (void) G_GNUC_CONST;
GType rygel_l16_transcoder_get_type (void) G_GNUC_CONST;
RygelMP3Transcoder* rygel_mp3_transcoder_new (void);
RygelMP3Transcoder* rygel_mp3_transcoder_construct (GType object_type);
GType rygel_mp3_transcoder_get_type (void) G_GNUC_CONST;
GType rygel_mp2_ts_profile_get_type (void) G_GNUC_CONST;
RygelMP2TSTranscoder* rygel_mp2_ts_transcoder_new (RygelMP2TSProfile profile);
RygelMP2TSTranscoder* rygel_mp2_ts_transcoder_construct (GType object_type, RygelMP2TSProfile profile);
GType rygel_video_transcoder_get_type (void) G_GNUC_CONST;
GType rygel_mp2_ts_transcoder_get_type (void) G_GNUC_CONST;
RygelWMVTranscoder* rygel_wmv_transcoder_new (void);
RygelWMVTranscoder* rygel_wmv_transcoder_construct (GType object_type);
GType rygel_wmv_transcoder_get_type (void) G_GNUC_CONST;
RygelAACTranscoder* rygel_aac_transcoder_new (void);
RygelAACTranscoder* rygel_aac_transcoder_construct (GType object_type);
GType rygel_aac_transcoder_get_type (void) G_GNUC_CONST;
RygelAVCTranscoder* rygel_avc_transcoder_new (void);
RygelAVCTranscoder* rygel_avc_transcoder_construct (GType object_type);
GType rygel_avc_transcoder_get_type (void) G_GNUC_CONST;
static GList* rygel_gst_media_engine_real_get_dlna_profiles (RygelMediaEngine* base);
static GList* rygel_gst_media_engine_real_get_transcoders (RygelMediaEngine* base);
static RygelDataSource* rygel_gst_media_engine_real_create_data_source (RygelMediaEngine* base, const gchar* uri);
GType rygel_gst_data_source_get_type (void) G_GNUC_CONST;
RygelGstDataSource* rygel_gst_data_source_new (const gchar* uri, GError** error);
RygelGstDataSource* rygel_gst_data_source_construct (GType object_type, const gchar* uri, GError** error);
RygelDataSource* rygel_gst_media_engine_create_data_source_from_element (RygelGstMediaEngine* self, GstElement* element);
RygelGstDataSource* rygel_gst_data_source_new_from_element (GstElement* element);
RygelGstDataSource* rygel_gst_data_source_construct_from_element (GType object_type, GstElement* element);
static void rygel_gst_media_engine_finalize (GObject* obj);
RygelMediaEngine* module_get_instance (void);


static void _rygel_dlna_profile_unref0_ (gpointer var) {
	(var == NULL) ? NULL : (var = (rygel_dlna_profile_unref (var), NULL));
}


static void _g_list_free__rygel_dlna_profile_unref0_ (GList* self) {
	g_list_foreach (self, (GFunc) _rygel_dlna_profile_unref0_, NULL);
	g_list_free (self);
}


static void _g_object_unref0_ (gpointer var) {
	(var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
}


static void _g_list_free__g_object_unref0_ (GList* self) {
	g_list_foreach (self, (GFunc) _g_object_unref0_, NULL);
	g_list_free (self);
}


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


static gpointer _rygel_dlna_profile_ref0 (gpointer self) {
	return self ? rygel_dlna_profile_ref (self) : NULL;
}


RygelGstMediaEngine* rygel_gst_media_engine_construct (GType object_type) {
	RygelGstMediaEngine * self = NULL;
	gchar** args = NULL;
	gint args_length1 = 0;
	gint _args_size_ = 0;
	GUPnPDLNAProfileGuesser* discoverer = NULL;
	GUPnPDLNAProfileGuesser* _tmp0_ = NULL;
	GUPnPDLNAProfileGuesser* _tmp1_ = NULL;
	GList* _tmp2_ = NULL;
	RygelDLNAProfile* _tmp13_ = NULL;
	gboolean transcoding = FALSE;
	GeeArrayList* transcoder_list = NULL;
	GeeArrayList* _tmp14_ = NULL;
	RygelMetaConfig* config = NULL;
	RygelMetaConfig* _tmp15_ = NULL;
	gboolean _tmp23_ = FALSE;
	GError * _inner_error_ = NULL;
	self = (RygelGstMediaEngine*) rygel_media_engine_construct (object_type);
	args = NULL;
	args_length1 = 0;
	_args_size_ = args_length1;
	gst_init (&args_length1, &args);
	gst_preset_set_app_dir (PRESET_DIR);
	_tmp0_ = gupnp_dlna_profile_guesser_new (TRUE, FALSE);
	discoverer = _tmp0_;
	_tmp1_ = discoverer;
	_tmp2_ = gupnp_dlna_profile_guesser_list_profiles (_tmp1_);
	{
		GList* profile_collection = NULL;
		GList* profile_it = NULL;
		profile_collection = _tmp2_;
		for (profile_it = profile_collection; profile_it != NULL; profile_it = profile_it->next) {
			GUPnPDLNAProfile* _tmp3_ = NULL;
			GUPnPDLNAProfile* profile = NULL;
			_tmp3_ = _g_object_ref0 ((GUPnPDLNAProfile*) profile_it->data);
			profile = _tmp3_;
			{
				RygelDLNAProfile* p = NULL;
				GUPnPDLNAProfile* _tmp4_ = NULL;
				const gchar* _tmp5_ = NULL;
				const gchar* _tmp6_ = NULL;
				GUPnPDLNAProfile* _tmp7_ = NULL;
				const gchar* _tmp8_ = NULL;
				const gchar* _tmp9_ = NULL;
				RygelDLNAProfile* _tmp10_ = NULL;
				RygelDLNAProfile* _tmp11_ = NULL;
				RygelDLNAProfile* _tmp12_ = NULL;
				_tmp4_ = profile;
				_tmp5_ = gupnp_dlna_profile_get_name (_tmp4_);
				_tmp6_ = _tmp5_;
				_tmp7_ = profile;
				_tmp8_ = gupnp_dlna_profile_get_mime (_tmp7_);
				_tmp9_ = _tmp8_;
				_tmp10_ = rygel_dlna_profile_new (_tmp6_, _tmp9_);
				p = _tmp10_;
				_tmp11_ = p;
				_tmp12_ = _rygel_dlna_profile_ref0 (_tmp11_);
				self->priv->dlna_profiles = g_list_prepend (self->priv->dlna_profiles, _tmp12_);
				_rygel_dlna_profile_unref0 (p);
				_g_object_unref0 (profile);
			}
		}
	}
	_tmp13_ = rygel_dlna_profile_new ("DIDL_S", "text/xml");
	self->priv->dlna_profiles = g_list_prepend (self->priv->dlna_profiles, _tmp13_);
	self->priv->dlna_profiles = g_list_reverse (self->priv->dlna_profiles);
	transcoding = TRUE;
	_tmp14_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL, NULL, NULL);
	transcoder_list = _tmp14_;
	_tmp15_ = rygel_meta_config_get_default ();
	config = _tmp15_;
	{
		gboolean _tmp16_ = FALSE;
		RygelMetaConfig* _tmp17_ = NULL;
		gboolean _tmp18_ = FALSE;
		GeeArrayList* _tmp19_ = NULL;
		RygelMetaConfig* _tmp20_ = NULL;
		GeeArrayList* _tmp21_ = NULL;
		GeeArrayList* _tmp22_ = NULL;
		_tmp17_ = config;
		_tmp18_ = rygel_configuration_get_transcoding ((RygelConfiguration*) _tmp17_, &_inner_error_);
		_tmp16_ = _tmp18_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch0_g_error;
		}
		transcoding = _tmp16_;
		_tmp20_ = config;
		_tmp21_ = rygel_configuration_get_string_list ((RygelConfiguration*) _tmp20_, "GstMediaEngine", "transcoders", &_inner_error_);
		_tmp19_ = _tmp21_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp22_ = _tmp19_;
		_tmp19_ = NULL;
		_g_object_unref0 (transcoder_list);
		transcoder_list = _tmp22_;
		_g_object_unref0 (_tmp19_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* err = NULL;
		err = _inner_error_;
		_inner_error_ = NULL;
		_g_error_free0 (err);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		_g_object_unref0 (config);
		_g_object_unref0 (transcoder_list);
		_g_object_unref0 (discoverer);
		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;
	}
	_tmp23_ = transcoding;
	if (_tmp23_) {
		{
			GeeArrayList* _transcoder_list = NULL;
			GeeArrayList* _tmp24_ = NULL;
			GeeArrayList* _tmp25_ = NULL;
			gint _transcoder_size = 0;
			GeeArrayList* _tmp26_ = NULL;
			gint _tmp27_ = 0;
			gint _tmp28_ = 0;
			gint _transcoder_index = 0;
			_tmp24_ = transcoder_list;
			_tmp25_ = _g_object_ref0 (_tmp24_);
			_transcoder_list = _tmp25_;
			_tmp26_ = _transcoder_list;
			_tmp27_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp26_);
			_tmp28_ = _tmp27_;
			_transcoder_size = _tmp28_;
			_transcoder_index = -1;
			while (TRUE) {
				gint _tmp29_ = 0;
				gint _tmp30_ = 0;
				gint _tmp31_ = 0;
				gchar* transcoder = NULL;
				GeeArrayList* _tmp32_ = NULL;
				gint _tmp33_ = 0;
				gpointer _tmp34_ = NULL;
				const gchar* _tmp35_ = NULL;
				const gchar* _tmp36_ = NULL;
				GQuark _tmp38_ = 0U;
				static GQuark _tmp37_label0 = 0;
				static GQuark _tmp37_label1 = 0;
				static GQuark _tmp37_label2 = 0;
				static GQuark _tmp37_label3 = 0;
				static GQuark _tmp37_label4 = 0;
				static GQuark _tmp37_label5 = 0;
				_tmp29_ = _transcoder_index;
				_transcoder_index = _tmp29_ + 1;
				_tmp30_ = _transcoder_index;
				_tmp31_ = _transcoder_size;
				if (!(_tmp30_ < _tmp31_)) {
					break;
				}
				_tmp32_ = _transcoder_list;
				_tmp33_ = _transcoder_index;
				_tmp34_ = gee_abstract_list_get ((GeeAbstractList*) _tmp32_, _tmp33_);
				transcoder = (gchar*) _tmp34_;
				_tmp35_ = transcoder;
				_tmp36_ = _tmp35_;
				_tmp38_ = (NULL == _tmp36_) ? 0 : g_quark_from_string (_tmp36_);
				if (_tmp38_ == ((0 != _tmp37_label0) ? _tmp37_label0 : (_tmp37_label0 = g_quark_from_static_string ("lpcm")))) {
					switch (0) {
						default:
						{
							RygelL16Transcoder* _tmp39_ = NULL;
							_tmp39_ = rygel_l16_transcoder_new ();
							self->priv->transcoders = g_list_prepend (self->priv->transcoders, (RygelTranscoder*) _tmp39_);
							break;
						}
					}
				} else if (_tmp38_ == ((0 != _tmp37_label1) ? _tmp37_label1 : (_tmp37_label1 = g_quark_from_static_string ("mp3")))) {
					switch (0) {
						default:
						{
							RygelMP3Transcoder* _tmp40_ = NULL;
							_tmp40_ = rygel_mp3_transcoder_new ();
							self->priv->transcoders = g_list_prepend (self->priv->transcoders, (RygelTranscoder*) _tmp40_);
							break;
						}
					}
				} else if (_tmp38_ == ((0 != _tmp37_label2) ? _tmp37_label2 : (_tmp37_label2 = g_quark_from_static_string ("mp2ts")))) {
					switch (0) {
						default:
						{
							RygelMP2TSTranscoder* _tmp41_ = NULL;
							RygelMP2TSTranscoder* _tmp42_ = NULL;
							RygelMP2TSTranscoder* _tmp43_ = NULL;
							_tmp41_ = rygel_mp2_ts_transcoder_new (RYGEL_MP2_TS_PROFILE_SD_EU);
							self->priv->transcoders = g_list_prepend (self->priv->transcoders, (RygelTranscoder*) _tmp41_);
							_tmp42_ = rygel_mp2_ts_transcoder_new (RYGEL_MP2_TS_PROFILE_SD_NA);
							self->priv->transcoders = g_list_prepend (self->priv->transcoders, (RygelTranscoder*) _tmp42_);
							_tmp43_ = rygel_mp2_ts_transcoder_new (RYGEL_MP2_TS_PROFILE_HD_NA);
							self->priv->transcoders = g_list_prepend (self->priv->transcoders, (RygelTranscoder*) _tmp43_);
							break;
						}
					}
				} else if (_tmp38_ == ((0 != _tmp37_label3) ? _tmp37_label3 : (_tmp37_label3 = g_quark_from_static_string ("wmv")))) {
					switch (0) {
						default:
						{
							RygelWMVTranscoder* _tmp44_ = NULL;
							_tmp44_ = rygel_wmv_transcoder_new ();
							self->priv->transcoders = g_list_prepend (self->priv->transcoders, (RygelTranscoder*) _tmp44_);
							break;
						}
					}
				} else if (_tmp38_ == ((0 != _tmp37_label4) ? _tmp37_label4 : (_tmp37_label4 = g_quark_from_static_string ("aac")))) {
					switch (0) {
						default:
						{
							RygelAACTranscoder* _tmp45_ = NULL;
							_tmp45_ = rygel_aac_transcoder_new ();
							self->priv->transcoders = g_list_prepend (self->priv->transcoders, (RygelTranscoder*) _tmp45_);
							break;
						}
					}
				} else if (_tmp38_ == ((0 != _tmp37_label5) ? _tmp37_label5 : (_tmp37_label5 = g_quark_from_static_string ("avc")))) {
					switch (0) {
						default:
						{
							RygelAVCTranscoder* _tmp46_ = NULL;
							_tmp46_ = rygel_avc_transcoder_new ();
							self->priv->transcoders = g_list_prepend (self->priv->transcoders, (RygelTranscoder*) _tmp46_);
							break;
						}
					}
				} else {
					switch (0) {
						default:
						{
							const gchar* _tmp47_ = NULL;
							_tmp47_ = transcoder;
							g_debug ("rygel-gst-media-engine.vala:102: Unsupported transcoder \"%s\"", _tmp47_);
							break;
						}
					}
				}
				_g_free0 (transcoder);
			}
			_g_object_unref0 (_transcoder_list);
		}
		self->priv->transcoders = g_list_reverse (self->priv->transcoders);
	}
	_g_object_unref0 (config);
	_g_object_unref0 (transcoder_list);
	_g_object_unref0 (discoverer);
	return self;
}


RygelGstMediaEngine* rygel_gst_media_engine_new (void) {
	return rygel_gst_media_engine_construct (RYGEL_TYPE_GST_MEDIA_ENGINE);
}


static GList* rygel_gst_media_engine_real_get_dlna_profiles (RygelMediaEngine* base) {
	RygelGstMediaEngine * self;
	GList* result = NULL;
	GList* _tmp0_ = NULL;
	self = (RygelGstMediaEngine*) base;
	_tmp0_ = self->priv->dlna_profiles;
	result = _tmp0_;
	return result;
}


static GList* rygel_gst_media_engine_real_get_transcoders (RygelMediaEngine* base) {
	RygelGstMediaEngine * self;
	GList* result = NULL;
	GList* _tmp0_ = NULL;
	self = (RygelGstMediaEngine*) base;
	_tmp0_ = self->priv->transcoders;
	result = _tmp0_;
	return result;
}


static RygelDataSource* rygel_gst_media_engine_real_create_data_source (RygelMediaEngine* base, const gchar* uri) {
	RygelGstMediaEngine * self;
	RygelDataSource* result = NULL;
	GError * _inner_error_ = NULL;
	self = (RygelGstMediaEngine*) base;
	g_return_val_if_fail (uri != NULL, NULL);
	{
		RygelGstDataSource* _tmp0_ = NULL;
		const gchar* _tmp1_ = NULL;
		RygelGstDataSource* _tmp2_ = NULL;
		RygelGstDataSource* _tmp3_ = NULL;
		_tmp1_ = uri;
		_tmp2_ = rygel_gst_data_source_new (_tmp1_, &_inner_error_);
		_tmp0_ = _tmp2_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch1_g_error;
		}
		_tmp3_ = _tmp0_;
		_tmp0_ = NULL;
		result = (RygelDataSource*) _tmp3_;
		_g_object_unref0 (_tmp0_);
		return result;
	}
	goto __finally1;
	__catch1_g_error:
	{
		GError* _error_ = NULL;
		const gchar* _tmp4_ = NULL;
		const gchar* _tmp5_ = NULL;
		GError* _tmp6_ = NULL;
		const gchar* _tmp7_ = NULL;
		_error_ = _inner_error_;
		_inner_error_ = NULL;
		_tmp4_ = _ ("Failed to create GStreamer data source for %s: %s");
		_tmp5_ = uri;
		_tmp6_ = _error_;
		_tmp7_ = _tmp6_->message;
		g_warning (_tmp4_, _tmp5_, _tmp7_);
		result = NULL;
		_g_error_free0 (_error_);
		return result;
	}
	__finally1:
	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;
}


RygelDataSource* rygel_gst_media_engine_create_data_source_from_element (RygelGstMediaEngine* self, GstElement* element) {
	RygelDataSource* result = NULL;
	GstElement* _tmp0_ = NULL;
	RygelGstDataSource* _tmp1_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (element != NULL, NULL);
	_tmp0_ = element;
	_tmp1_ = rygel_gst_data_source_new_from_element (_tmp0_);
	result = (RygelDataSource*) _tmp1_;
	return result;
}


static void rygel_gst_media_engine_class_init (RygelGstMediaEngineClass * klass) {
	rygel_gst_media_engine_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (RygelGstMediaEnginePrivate));
	((RygelMediaEngineClass *) klass)->get_dlna_profiles = rygel_gst_media_engine_real_get_dlna_profiles;
	((RygelMediaEngineClass *) klass)->get_transcoders = rygel_gst_media_engine_real_get_transcoders;
	((RygelMediaEngineClass *) klass)->create_data_source = rygel_gst_media_engine_real_create_data_source;
	G_OBJECT_CLASS (klass)->finalize = rygel_gst_media_engine_finalize;
}


static void rygel_gst_media_engine_instance_init (RygelGstMediaEngine * self) {
	self->priv = RYGEL_GST_MEDIA_ENGINE_GET_PRIVATE (self);
	self->priv->dlna_profiles = NULL;
	self->priv->transcoders = NULL;
}


static void rygel_gst_media_engine_finalize (GObject* obj) {
	RygelGstMediaEngine * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_TYPE_GST_MEDIA_ENGINE, RygelGstMediaEngine);
	__g_list_free__rygel_dlna_profile_unref0_0 (self->priv->dlna_profiles);
	__g_list_free__g_object_unref0_0 (self->priv->transcoders);
	G_OBJECT_CLASS (rygel_gst_media_engine_parent_class)->finalize (obj);
}


GType rygel_gst_media_engine_get_type (void) {
	static volatile gsize rygel_gst_media_engine_type_id__volatile = 0;
	if (g_once_init_enter (&rygel_gst_media_engine_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (RygelGstMediaEngineClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rygel_gst_media_engine_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RygelGstMediaEngine), 0, (GInstanceInitFunc) rygel_gst_media_engine_instance_init, NULL };
		GType rygel_gst_media_engine_type_id;
		rygel_gst_media_engine_type_id = g_type_register_static (RYGEL_TYPE_MEDIA_ENGINE, "RygelGstMediaEngine", &g_define_type_info, 0);
		g_once_init_leave (&rygel_gst_media_engine_type_id__volatile, rygel_gst_media_engine_type_id);
	}
	return rygel_gst_media_engine_type_id__volatile;
}


RygelMediaEngine* module_get_instance (void) {
	RygelMediaEngine* result = NULL;
	RygelGstMediaEngine* _tmp0_ = NULL;
	_tmp0_ = rygel_gst_media_engine_new ();
	result = (RygelMediaEngine*) _tmp0_;
	return result;
}



