/* tag-parser.c generated by valac 0.56.19, the Vala compiler
 * generated from tag-parser.vala, do not modify */

#include <gio/gio.h>
#include <gst/gst.h>
#include <glib.h>
#include <string.h>
#include <gst/tag/tag.h>
#include "gst-ext.h"
#include <stdlib.h>
#include <glib-object.h>
#include <float.h>
#include <math.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _gst_buffer_unref0(var) ((var == NULL) ? NULL : (var = (gst_buffer_unref (var), NULL)))
#define _gst_tag_list_unref0(var) ((var == NULL) ? NULL : (var = (gst_tag_list_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)))
#define _gst_date_time_unref0(var) ((var == NULL) ? NULL : (var = (gst_date_time_unref (var), NULL)))
#define _gst_sample_unref0(var) ((var == NULL) ? NULL : (var = (gst_sample_unref (var), NULL)))
#define _gst_message_unref0(var) ((var == NULL) ? NULL : (var = (gst_message_unref (var), NULL)))
#define __vala_GValue_free0(var) ((var == NULL) ? NULL : (var = (_vala_GValue_free (var), NULL)))
#define _gst_caps_unref0(var) ((var == NULL) ? NULL : (var = (gst_caps_unref (var), NULL)))

VALA_EXTERN GstTagList* g4_parse_gst_tags (GFile* file);
VALA_EXTERN void g4_read_full (GBufferedInputStream* stream,
                   guint8* buffer,
                   gint buffer_length1,
                   GError** error);
VALA_EXTERN guint8* g4_new_uint8_array (guint size,
                            gint* result_length1,
                            GError** error);
VALA_EXTERN GstTagList* g4_merge_tags (GstTagList* tags,
                           GstTagList* tags2,
                           GstTagMergeMode mode);
VALA_EXTERN void g4_seek_full (GBufferedInputStream* stream,
                   gint64 offset,
                   GSeekType type,
                   GError** error);
VALA_EXTERN guint32 g4_read_uint32_le (guint8* data,
                           gint data_length1,
                           guint pos);
VALA_EXTERN GstTagList* g4_parse_flac_tags (GBufferedInputStream* stream,
                                GError** error);
VALA_EXTERN GstTagList* g4_parse_ogg_tags (GBufferedInputStream* stream,
                               GError** error);
VALA_EXTERN GstTagList* g4_parse_mp4_tags (GBufferedInputStream* stream);
VALA_EXTERN gboolean g4_tags_has_text (GstTagList* tags);
VALA_EXTERN gboolean g4_tags_has_image (GstTagList* tags);
VALA_EXTERN GstTagList* g4_parse_end_tags (GBufferedInputStream* stream,
                               GError** error);
VALA_EXTERN gchar* g4_get_demux_name_by_content (guint8* head,
                                     gint head_length1);
VALA_EXTERN GstTagList* g4_parse_demux_tags (GBufferedInputStream* stream,
                                 const gchar* demux_name,
                                 GError** error);
VALA_EXTERN guint32 g4_read_uint32_be (guint8* data,
                           gint data_length1,
                           guint pos);
VALA_EXTERN guint32 g4_read_decimal_uint (guint8* data,
                              gint data_length1);
VALA_EXTERN GstTagList* g4_parse_lyrics200_tags (guint8* data,
                                     gint data_length1);
static guint8* _vala_array_dup5 (guint8* self,
                          gssize length);
static guint8* _vala_array_dup6 (guint8* self,
                          gssize length);
VALA_EXTERN void g4_parse_mp4_date_value (guint8* data,
                              gint data_length1,
                              const gchar* tag,
                              GstTagList* tags,
                              GError** error);
VALA_EXTERN gchar* g4_parse_mp4_string (guint8* data,
                            gint data_length1,
                            GError** error);
VALA_EXTERN void g4_parse_mp4_image_value (guint8* data,
                               gint data_length1,
                               const gchar* tag,
                               GstTagList* tags,
                               GError** error);
static guint8* _vala_array_dup7 (guint8* self,
                          gssize length);
VALA_EXTERN void g4_parse_mp4_number_value (guint8* data,
                                gint data_length1,
                                const gchar* tag1,
                                const gchar* tag2,
                                GstTagList* tags,
                                GError** error);
static guint8* _vala_array_dup8 (guint8* self,
                          gssize length);
VALA_EXTERN void g4_parse_mp4_string_value (guint8* data,
                                gint data_length1,
                                const gchar* tag,
                                GstTagList* tags,
                                GError** error);
VALA_EXTERN guint g4_find_mp4_data_child (guint8* buffer,
                              gint buffer_length1,
                              guint pos,
                              guint end,
                              guint32 fourcc);
VALA_EXTERN void g4_parse_mp4_ilst_box (guint8* buffer,
                            gint buffer_length1,
                            GstTagList* tags,
                            GError** error);
static guint8* _vala_array_dup9 (guint8* self,
                          gssize length);
VALA_EXTERN void g4_parse_mp4_box (GBufferedInputStream* stream,
                       GstTagList* tags,
                       GError** error);
static guint8* _vala_array_dup10 (guint8* self,
                           gssize length);
static GstStateChangeReturn* _gst_state_change_return_dup (GstStateChangeReturn* self);
static gboolean _gst_state_change_return_equal (const GstStateChangeReturn * s1,
                                         const GstStateChangeReturn * s2);
VALA_EXTERN void g4_get_one_tag (GstTagList* tags,
                     const gchar* tag,
                     GPtrArray* values);
static GValue* _g_value_dup (GValue* self);
static void _vala_GValue_free (GValue* self);
VALA_EXTERN GstSample* g4_parse_image_from_tag_list (GstTagList* tags);
static GType* _g_type_dup (GType* self);
static gboolean _g_type_equal (const GType * s1,
                        const GType * s2);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

const gchar* G4_ID3_TAG_ENCODINGS[4] = {"GST_ID3V1_TAG_ENCODING", "GST_ID3_TAG_ENCODING", "GST_TAG_ENCODING", (const gchar*) NULL};
const gchar* G4_MP4_TAG_ENCODINGS[3] = {"GST_QT_TAG_ENCODING", "GST_TAG_ENCODING", (const gchar*) NULL};
const gchar* G4_OGG_TAG_IDS[5] = {"\x03vorbis", "\x81kate\0\0\0\0", "\x81theora", "OpusTags", "OVP80\x02 "};

GstTagList*
g4_parse_gst_tags (GFile* file)
{
	GFileInputStream* fis = NULL;
	GstTagList* tags = NULL;
	GBufferedInputStream* stream = NULL;
	GFileInputStream* _tmp3_;
	GBufferedInputStream* _tmp4_;
	guint8* head = NULL;
	guint8* _tmp5_;
	gint head_length1;
	gint _head_size_;
	gboolean _tmp76_ = FALSE;
	GstTagList* _tmp77_;
	GstTagList* _tmp88_;
	GError* _inner_error0_ = NULL;
	GstTagList* result;
	g_return_val_if_fail (file != NULL, NULL);
	fis = NULL;
	{
		GFileInputStream* _tmp0_ = NULL;
		GFileInputStream* _tmp1_;
		GFileInputStream* _tmp2_;
		_tmp1_ = g_file_read (file, NULL, &_inner_error0_);
		_tmp0_ = _tmp1_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp2_ = _tmp0_;
		_tmp0_ = NULL;
		_g_object_unref0 (fis);
		fis = _tmp2_;
		_g_object_unref0 (_tmp0_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
		result = NULL;
		_g_object_unref0 (fis);
		return result;
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_object_unref0 (fis);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return NULL;
	}
	tags = NULL;
	_tmp3_ = fis;
	_tmp4_ = (GBufferedInputStream*) g_buffered_input_stream_new ((GInputStream*) G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, g_file_input_stream_get_type (), GFileInputStream));
	stream = _tmp4_;
	_tmp5_ = g_new0 (guint8, 16);
	head = _tmp5_;
	head_length1 = 16;
	_head_size_ = head_length1;
	while (TRUE) {
		{
			GBufferedInputStream* _tmp6_;
			guint8* _tmp7_;
			gint _tmp7__length1;
			guint8* _tmp8_;
			gint _tmp8__length1;
			_tmp6_ = stream;
			_tmp7_ = head;
			_tmp7__length1 = head_length1;
			g4_read_full (_tmp6_, _tmp7_, (gint) _tmp7__length1, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				goto __catch1_g_error;
			}
			_tmp8_ = head;
			_tmp8__length1 = head_length1;
			if (memcmp (_tmp8_, "ID3", (gsize) 3) == 0) {
				GstBuffer* buffer = NULL;
				guint8* _tmp9_;
				gint _tmp9__length1;
				guint8* _tmp10_;
				gint _tmp10__length1;
				GstBuffer* _tmp11_;
				guint size = 0U;
				GstBuffer* _tmp12_;
				guint8* _tmp13_;
				gint _tmp13__length1;
				_tmp9_ = head;
				_tmp9__length1 = head_length1;
				_tmp10_ = head;
				_tmp10__length1 = head_length1;
				_tmp11_ = gst_buffer_new_wrapped_full (0, _tmp9_, (gsize) _tmp9__length1, (gsize) 0, (gsize) _tmp10__length1, NULL, NULL);
				buffer = _tmp11_;
				_tmp12_ = buffer;
				size = gst_tag_get_id3v2_tag_size (_tmp12_);
				_tmp13_ = head;
				_tmp13__length1 = head_length1;
				if (size > ((guint) _tmp13__length1)) {
					guint8* data = NULL;
					gint _tmp14_ = 0;
					guint8* _tmp15_;
					gint data_length1;
					gint _data_size_;
					guint8* _tmp16_;
					gint _tmp16__length1;
					guint8* _tmp17_;
					gint _tmp17__length1;
					guint8* _tmp18_;
					gint _tmp18__length1;
					GBufferedInputStream* _tmp19_;
					guint8* _tmp20_;
					gint _tmp20__length1;
					guint8* _tmp21_;
					gint _tmp21__length1;
					guint8* _tmp22_;
					gint _tmp22__length1;
					GstBuffer* buffer2 = NULL;
					guint8* _tmp23_;
					gint _tmp23__length1;
					guint8* _tmp24_;
					gint _tmp24__length1;
					GstBuffer* _tmp25_;
					GstTagList* tags2 = NULL;
					GstBuffer* _tmp26_;
					GstTagList* _tmp27_;
					GstTagList* _tmp28_;
					GstTagList* _tmp29_;
					GstTagList* _tmp30_;
					_tmp15_ = g4_new_uint8_array (size, &_tmp14_, &_inner_error0_);
					data = _tmp15_;
					data_length1 = _tmp14_;
					_data_size_ = data_length1;
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						_gst_buffer_unref0 (buffer);
						goto __catch1_g_error;
					}
					_tmp16_ = data;
					_tmp16__length1 = data_length1;
					_tmp17_ = head;
					_tmp17__length1 = head_length1;
					_tmp18_ = head;
					_tmp18__length1 = head_length1;
					memcpy (_tmp16_, _tmp17_, (gsize) _tmp18__length1);
					_tmp19_ = stream;
					_tmp20_ = data;
					_tmp20__length1 = data_length1;
					_tmp21_ = head;
					_tmp21__length1 = head_length1;
					_tmp22_ = data;
					_tmp22__length1 = data_length1;
					g4_read_full (_tmp19_, _tmp22_ + _tmp21__length1, (gint) (_tmp22__length1 - _tmp21__length1), &_inner_error0_);
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						data = (g_free (data), NULL);
						_gst_buffer_unref0 (buffer);
						goto __catch1_g_error;
					}
					_tmp23_ = data;
					_tmp23__length1 = data_length1;
					_tmp24_ = data;
					_tmp24__length1 = data_length1;
					_tmp25_ = gst_buffer_new_wrapped_full (0, _tmp23_, (gsize) _tmp23__length1, (gsize) 0, (gsize) _tmp24__length1, NULL, NULL);
					buffer2 = _tmp25_;
					_tmp26_ = buffer2;
					_tmp27_ = gst_tag_list_from_id3v2_tag (_tmp26_);
					tags2 = _tmp27_;
					_tmp28_ = tags;
					_tmp29_ = tags2;
					_tmp30_ = g4_merge_tags (_tmp28_, _tmp29_, GST_TAG_MERGE_KEEP);
					_gst_tag_list_unref0 (tags);
					tags = _tmp30_;
					_gst_tag_list_unref0 (tags2);
					_gst_buffer_unref0 (buffer2);
					data = (g_free (data), NULL);
				}
				_gst_buffer_unref0 (buffer);
			} else {
				guint8* _tmp31_;
				gint _tmp31__length1;
				_tmp31_ = head;
				_tmp31__length1 = head_length1;
				if (memcmp (_tmp31_, "APETAGEX", (gsize) 8) == 0) {
					GBufferedInputStream* _tmp32_;
					guint32 size = 0U;
					guint8* _tmp33_;
					gint _tmp33__length1;
					guint8* data = NULL;
					gint _tmp34_ = 0;
					guint8* _tmp35_;
					gint data_length1;
					gint _data_size_;
					guint8* _tmp36_;
					gint _tmp36__length1;
					guint8* _tmp37_;
					gint _tmp37__length1;
					guint8* _tmp38_;
					gint _tmp38__length1;
					GBufferedInputStream* _tmp39_;
					guint8* _tmp40_;
					gint _tmp40__length1;
					guint8* _tmp41_;
					gint _tmp41__length1;
					guint8* _tmp42_;
					gint _tmp42__length1;
					GstTagList* tags2 = NULL;
					guint8* _tmp43_;
					gint _tmp43__length1;
					GstTagList* _tmp44_;
					GstTagList* _tmp45_;
					GstTagList* _tmp46_;
					GstTagList* _tmp47_;
					_tmp32_ = stream;
					g4_seek_full (_tmp32_, (gint64) 0, G_SEEK_SET, &_inner_error0_);
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						goto __catch1_g_error;
					}
					_tmp33_ = head;
					_tmp33__length1 = head_length1;
					size = g4_read_uint32_le (_tmp33_, (gint) _tmp33__length1, (guint) 12) + 32;
					_tmp35_ = g4_new_uint8_array ((guint) size, &_tmp34_, &_inner_error0_);
					data = _tmp35_;
					data_length1 = _tmp34_;
					_data_size_ = data_length1;
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						goto __catch1_g_error;
					}
					_tmp36_ = data;
					_tmp36__length1 = data_length1;
					_tmp37_ = head;
					_tmp37__length1 = head_length1;
					_tmp38_ = head;
					_tmp38__length1 = head_length1;
					memcpy (_tmp36_, _tmp37_, (gsize) _tmp38__length1);
					_tmp39_ = stream;
					_tmp40_ = data;
					_tmp40__length1 = data_length1;
					_tmp41_ = head;
					_tmp41__length1 = head_length1;
					_tmp42_ = data;
					_tmp42__length1 = data_length1;
					g4_read_full (_tmp39_, _tmp42_ + _tmp41__length1, (gint) (_tmp42__length1 - _tmp41__length1), &_inner_error0_);
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						data = (g_free (data), NULL);
						goto __catch1_g_error;
					}
					_tmp43_ = data;
					_tmp43__length1 = data_length1;
					_tmp44_ = ape_demux_parse_tags (_tmp43_, (gsize) _tmp43__length1);
					tags2 = _tmp44_;
					_tmp45_ = tags;
					_tmp46_ = tags2;
					_tmp47_ = g4_merge_tags (_tmp45_, _tmp46_, GST_TAG_MERGE_KEEP);
					_gst_tag_list_unref0 (tags);
					tags = _tmp47_;
					_gst_tag_list_unref0 (tags2);
					data = (g_free (data), NULL);
				} else {
					guint8* _tmp48_;
					gint _tmp48__length1;
					_tmp48_ = head;
					_tmp48__length1 = head_length1;
					if (memcmp (_tmp48_, "fLaC", (gsize) 4) == 0) {
						GBufferedInputStream* _tmp49_;
						guint8* _tmp50_;
						gint _tmp50__length1;
						GstTagList* tags2 = NULL;
						GBufferedInputStream* _tmp51_;
						GstTagList* _tmp52_;
						GstTagList* _tmp53_;
						GstTagList* _tmp54_;
						GstTagList* _tmp55_;
						_tmp49_ = stream;
						_tmp50_ = head;
						_tmp50__length1 = head_length1;
						g4_seek_full (_tmp49_, (gint64) (-_tmp50__length1), G_SEEK_CUR, &_inner_error0_);
						if (G_UNLIKELY (_inner_error0_ != NULL)) {
							goto __catch1_g_error;
						}
						_tmp51_ = stream;
						_tmp52_ = g4_parse_flac_tags (_tmp51_, &_inner_error0_);
						tags2 = _tmp52_;
						if (G_UNLIKELY (_inner_error0_ != NULL)) {
							goto __catch1_g_error;
						}
						_tmp53_ = tags;
						_tmp54_ = tags2;
						_tmp55_ = g4_merge_tags (_tmp53_, _tmp54_, GST_TAG_MERGE_KEEP);
						_gst_tag_list_unref0 (tags);
						tags = _tmp55_;
						_gst_tag_list_unref0 (tags2);
					} else {
						guint8* _tmp56_;
						gint _tmp56__length1;
						_tmp56_ = head;
						_tmp56__length1 = head_length1;
						if (memcmp (_tmp56_, "OggS", (gsize) 4) == 0) {
							GBufferedInputStream* _tmp57_;
							guint8* _tmp58_;
							gint _tmp58__length1;
							GstTagList* tags2 = NULL;
							GBufferedInputStream* _tmp59_;
							GstTagList* _tmp60_;
							GstTagList* _tmp61_;
							GstTagList* _tmp62_;
							GstTagList* _tmp63_;
							_tmp57_ = stream;
							_tmp58_ = head;
							_tmp58__length1 = head_length1;
							g4_seek_full (_tmp57_, (gint64) (-_tmp58__length1), G_SEEK_CUR, &_inner_error0_);
							if (G_UNLIKELY (_inner_error0_ != NULL)) {
								goto __catch1_g_error;
							}
							_tmp59_ = stream;
							_tmp60_ = g4_parse_ogg_tags (_tmp59_, &_inner_error0_);
							tags2 = _tmp60_;
							if (G_UNLIKELY (_inner_error0_ != NULL)) {
								goto __catch1_g_error;
							}
							_tmp61_ = tags;
							_tmp62_ = tags2;
							_tmp63_ = g4_merge_tags (_tmp61_, _tmp62_, GST_TAG_MERGE_KEEP);
							_gst_tag_list_unref0 (tags);
							tags = _tmp63_;
							_gst_tag_list_unref0 (tags2);
						} else {
							guint8* _tmp64_;
							gint _tmp64__length1;
							_tmp64_ = head;
							_tmp64__length1 = head_length1;
							if (memcmp (_tmp64_ + ((guint8) 4), "ftyp", (gsize) 4) == 0) {
								GBufferedInputStream* _tmp65_;
								guint8* _tmp66_;
								gint _tmp66__length1;
								GstTagList* tags2 = NULL;
								GBufferedInputStream* _tmp67_;
								GstTagList* _tmp68_;
								GstTagList* _tmp69_;
								GstTagList* _tmp70_;
								GstTagList* _tmp71_;
								_tmp65_ = stream;
								_tmp66_ = head;
								_tmp66__length1 = head_length1;
								g4_seek_full (_tmp65_, (gint64) (-_tmp66__length1), G_SEEK_CUR, &_inner_error0_);
								if (G_UNLIKELY (_inner_error0_ != NULL)) {
									goto __catch1_g_error;
								}
								_tmp67_ = stream;
								_tmp68_ = g4_parse_mp4_tags (_tmp67_);
								tags2 = _tmp68_;
								_tmp69_ = tags;
								_tmp70_ = tags2;
								_tmp71_ = g4_merge_tags (_tmp69_, _tmp70_, GST_TAG_MERGE_KEEP);
								_gst_tag_list_unref0 (tags);
								tags = _tmp71_;
								_gst_tag_list_unref0 (tags2);
							}
						}
					}
					break;
				}
			}
		}
		goto __finally1;
		__catch1_g_error:
		{
			GError* e = NULL;
			gchar* _tmp72_;
			gchar* _tmp73_;
			GError* _tmp74_;
			const gchar* _tmp75_;
			e = _inner_error0_;
			_inner_error0_ = NULL;
			_tmp72_ = g_file_get_parse_name (file);
			_tmp73_ = _tmp72_;
			_tmp74_ = e;
			_tmp75_ = _tmp74_->message;
			g_print ("Parse begin tag %s: %s\n", _tmp73_, _tmp75_);
			_g_free0 (_tmp73_);
			_g_error_free0 (e);
			break;
		}
		__finally1:
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			head = (g_free (head), NULL);
			_g_object_unref0 (stream);
			_gst_tag_list_unref0 (tags);
			_g_object_unref0 (fis);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
	}
	_tmp77_ = tags;
	if (g4_tags_has_text (_tmp77_)) {
		_tmp76_ = TRUE;
	} else {
		GstTagList* _tmp78_;
		_tmp78_ = tags;
		_tmp76_ = g4_tags_has_image (_tmp78_);
	}
	if (_tmp76_) {
		result = tags;
		head = (g_free (head), NULL);
		_g_object_unref0 (stream);
		_g_object_unref0 (fis);
		return result;
	}
	{
		GstTagList* tags2 = NULL;
		GBufferedInputStream* _tmp79_;
		GstTagList* _tmp80_;
		GstTagList* _tmp81_;
		GstTagList* _tmp82_;
		GstTagList* _tmp83_;
		_tmp79_ = stream;
		_tmp80_ = g4_parse_end_tags (_tmp79_, &_inner_error0_);
		tags2 = _tmp80_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch2_g_error;
		}
		_tmp81_ = tags;
		_tmp82_ = tags2;
		_tmp83_ = g4_merge_tags (_tmp81_, _tmp82_, GST_TAG_MERGE_KEEP);
		_gst_tag_list_unref0 (tags);
		tags = _tmp83_;
		_gst_tag_list_unref0 (tags2);
	}
	goto __finally2;
	__catch2_g_error:
	{
		GError* e = NULL;
		gchar* _tmp84_;
		gchar* _tmp85_;
		GError* _tmp86_;
		const gchar* _tmp87_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp84_ = g_file_get_parse_name (file);
		_tmp85_ = _tmp84_;
		_tmp86_ = e;
		_tmp87_ = _tmp86_->message;
		g_print ("Parse end tag %s: %s\n", _tmp85_, _tmp87_);
		_g_free0 (_tmp85_);
		_g_error_free0 (e);
	}
	__finally2:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		head = (g_free (head), NULL);
		_g_object_unref0 (stream);
		_gst_tag_list_unref0 (tags);
		_g_object_unref0 (fis);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return NULL;
	}
	_tmp88_ = tags;
	if (_tmp88_ != NULL) {
		result = tags;
		head = (g_free (head), NULL);
		_g_object_unref0 (stream);
		_g_object_unref0 (fis);
		return result;
	}
	{
		gchar* demux_name = NULL;
		guint8* _tmp89_;
		gint _tmp89__length1;
		gchar* _tmp90_;
		const gchar* _tmp91_;
		_tmp89_ = head;
		_tmp89__length1 = head_length1;
		_tmp90_ = g4_get_demux_name_by_content (_tmp89_, (gint) _tmp89__length1);
		demux_name = _tmp90_;
		_tmp91_ = demux_name;
		if (_tmp91_ != NULL) {
			GBufferedInputStream* _tmp92_;
			GstTagList* _tmp93_ = NULL;
			GBufferedInputStream* _tmp94_;
			const gchar* _tmp95_;
			GstTagList* _tmp96_;
			GstTagList* _tmp97_;
			_tmp92_ = stream;
			g4_seek_full (_tmp92_, (gint64) 0, G_SEEK_SET, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				_g_free0 (demux_name);
				goto __catch3_g_error;
			}
			_tmp94_ = stream;
			_tmp95_ = demux_name;
			_tmp96_ = g4_parse_demux_tags (_tmp94_, (const gchar*) _tmp95_, &_inner_error0_);
			_tmp93_ = _tmp96_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				_g_free0 (demux_name);
				goto __catch3_g_error;
			}
			_tmp97_ = _tmp93_;
			_tmp93_ = NULL;
			_gst_tag_list_unref0 (tags);
			tags = _tmp97_;
			_gst_tag_list_unref0 (_tmp93_);
		}
		_g_free0 (demux_name);
	}
	goto __finally3;
	__catch3_g_error:
	{
		g_clear_error (&_inner_error0_);
	}
	__finally3:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		head = (g_free (head), NULL);
		_g_object_unref0 (stream);
		_gst_tag_list_unref0 (tags);
		_g_object_unref0 (fis);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return NULL;
	}
	result = tags;
	head = (g_free (head), NULL);
	_g_object_unref0 (stream);
	_g_object_unref0 (fis);
	return result;
}

static gpointer
_gst_tag_list_ref0 (gpointer self)
{
	return self ? gst_tag_list_ref (self) : NULL;
}

gboolean
g4_tags_has_image (GstTagList* tags)
{
	GstTagList* t = NULL;
	GstTagList* _tmp0_;
	gboolean _tmp1_ = FALSE;
	GstTagList* _tmp2_;
	gboolean result;
	if (tags == NULL) {
		result = FALSE;
		return result;
	}
	_tmp0_ = _gst_tag_list_ref0 ((GstTagList*) tags);
	t = _tmp0_;
	_tmp2_ = t;
	if (gst_tag_list_get_tag_size (_tmp2_, GST_TAG_IMAGE) > ((guint) 0)) {
		_tmp1_ = TRUE;
	} else {
		GstTagList* _tmp3_;
		_tmp3_ = t;
		_tmp1_ = gst_tag_list_get_tag_size (_tmp3_, GST_TAG_PREVIEW_IMAGE) > ((guint) 0);
	}
	result = _tmp1_;
	_gst_tag_list_unref0 (t);
	return result;
}

gboolean
g4_tags_has_text (GstTagList* tags)
{
	GstTagList* t = NULL;
	GstTagList* _tmp0_;
	gboolean _tmp1_ = FALSE;
	GstTagList* _tmp2_;
	gboolean result;
	if (tags == NULL) {
		result = FALSE;
		return result;
	}
	_tmp0_ = _gst_tag_list_ref0 ((GstTagList*) tags);
	t = _tmp0_;
	_tmp2_ = t;
	if (gst_tag_list_get_tag_size (_tmp2_, GST_TAG_ARTIST) > ((guint) 0)) {
		_tmp1_ = TRUE;
	} else {
		GstTagList* _tmp3_;
		_tmp3_ = t;
		_tmp1_ = gst_tag_list_get_tag_size (_tmp3_, GST_TAG_TITLE) > ((guint) 0);
	}
	result = _tmp1_;
	_gst_tag_list_unref0 (t);
	return result;
}

inline guint8*
g4_new_uint8_array (guint size,
                    gint* result_length1,
                    GError** error)
{
	gboolean _tmp0_ = FALSE;
	guint8* _tmp2_;
	guint8* _tmp3_;
	gint _tmp3__length1;
	GError* _inner_error0_ = NULL;
	guint8* result;
	if (((gint) size) <= 0) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = size > ((guint) 0xfffffff);
	}
	if (_tmp0_) {
		GError* _tmp1_;
		_tmp1_ = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT, "invalid size");
		_inner_error0_ = _tmp1_;
		g_propagate_error (error, _inner_error0_);
		return NULL;
	}
	_tmp2_ = g_new0 (guint8, size);
	_tmp3_ = _tmp2_;
	_tmp3__length1 = size;
	if (result_length1) {
		*result_length1 = _tmp3__length1;
	}
	result = _tmp3_;
	return result;
}

inline void
g4_read_full (GBufferedInputStream* stream,
              guint8* buffer,
              gint buffer_length1,
              GError** error)
{
	gsize bytes = 0UL;
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	gsize _tmp2_ = 0UL;
	gboolean _tmp3_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (stream != NULL);
	bytes = (gsize) 0;
	_tmp3_ = g_input_stream_read_all ((GInputStream*) stream, buffer, (gsize) buffer_length1, &_tmp2_, NULL, &_inner_error0_);
	bytes = _tmp2_;
	_tmp1_ = _tmp3_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		return;
	}
	if (!_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = bytes != ((gsize) buffer_length1);
	}
	if (_tmp0_) {
		GError* _tmp4_;
		_tmp4_ = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_FAILED, "read_all");
		_inner_error0_ = _tmp4_;
		g_propagate_error (error, _inner_error0_);
		return;
	}
}

inline void
g4_seek_full (GBufferedInputStream* stream,
              gint64 offset,
              GSeekType type,
              GError** error)
{
	gboolean _tmp0_ = FALSE;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (stream != NULL);
	_tmp0_ = g_seekable_seek ((GSeekable*) stream, offset, type, NULL, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		return;
	}
	if (!_tmp0_) {
		GError* _tmp1_;
		_tmp1_ = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_FAILED, "seek");
		_inner_error0_ = _tmp1_;
		g_propagate_error (error, _inner_error0_);
		return;
	}
}

inline guint32
g4_read_uint32_be (guint8* data,
                   gint data_length1,
                   guint pos)
{
	guint8 _tmp0_;
	guint8 _tmp1_;
	guint8 _tmp2_;
	guint8 _tmp3_;
	guint32 result;
	_tmp0_ = data[pos + 3];
	_tmp1_ = data[pos + 2];
	_tmp2_ = data[pos + 1];
	_tmp3_ = data[pos];
	result = (guint32) (((_tmp0_ | (((guint32) _tmp1_) << 8)) | (((guint32) _tmp2_) << 16)) | (((guint32) _tmp3_) << 24));
	return result;
}

inline guint32
g4_read_uint32_le (guint8* data,
                   gint data_length1,
                   guint pos)
{
	guint8 _tmp0_;
	guint8 _tmp1_;
	guint8 _tmp2_;
	guint8 _tmp3_;
	guint32 result;
	_tmp0_ = data[pos];
	_tmp1_ = data[pos + 1];
	_tmp2_ = data[pos + 2];
	_tmp3_ = data[pos + 3];
	result = (guint32) (((_tmp0_ | (((guint32) _tmp1_) << 8)) | (((guint32) _tmp2_) << 16)) | (((guint32) _tmp3_) << 24));
	return result;
}

inline guint32
g4_read_decimal_uint (guint8* data,
                      gint data_length1)
{
	guint32 n = 0U;
	guint32 result;
	n = (guint32) 0;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				guint8 _tmp2_;
				if (!_tmp0_) {
					gint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				if (!(i < data_length1)) {
					break;
				}
				_tmp2_ = data[i];
				n = (n * 10) + (_tmp2_ - '0');
			}
		}
	}
	result = n;
	return result;
}

GstTagList*
g4_merge_tags (GstTagList* tags,
               GstTagList* tags2,
               GstTagMergeMode mode)
{
	GstTagList* _tmp0_ = NULL;
	GstTagList* _tmp6_;
	GstTagList* result;
	if (tags != NULL) {
		GstTagList* _tmp1_ = NULL;
		GstTagList* _tmp2_ = NULL;
		GstTagList* _tmp4_;
		_tmp1_ = tags;
		_tmp2_ = NULL;
		if (_tmp1_ != NULL) {
			GstTagList* _tmp3_;
			_tmp3_ = gst_tag_list_merge ((GstTagList*) _tmp1_, tags2, mode);
			_gst_tag_list_unref0 (_tmp2_);
			_tmp2_ = _tmp3_;
		}
		_tmp4_ = _tmp2_;
		_tmp2_ = NULL;
		_gst_tag_list_unref0 (_tmp0_);
		_tmp0_ = _tmp4_;
		_gst_tag_list_unref0 (_tmp2_);
	} else {
		GstTagList* _tmp5_;
		_tmp5_ = _gst_tag_list_ref0 (tags2);
		_gst_tag_list_unref0 (_tmp0_);
		_tmp0_ = _tmp5_;
	}
	_tmp6_ = _tmp0_;
	_tmp0_ = NULL;
	result = _tmp6_;
	_gst_tag_list_unref0 (_tmp0_);
	return result;
}

static gpointer
_g_error_copy0 (gpointer self)
{
	return self ? g_error_copy (self) : NULL;
}

GstTagList*
g4_parse_end_tags (GBufferedInputStream* stream,
                   GError** error)
{
	gboolean apev2_found = FALSE;
	guint8* foot = NULL;
	guint8* _tmp0_;
	gint foot_length1;
	gint _foot_size_;
	GstTagList* tags = NULL;
	GError* _inner_error0_ = NULL;
	GstTagList* result;
	g_return_val_if_fail (stream != NULL, NULL);
	apev2_found = FALSE;
	_tmp0_ = g_new0 (guint8, 128);
	foot = _tmp0_;
	foot_length1 = 128;
	_foot_size_ = foot_length1;
	tags = NULL;
	g4_seek_full (stream, (gint64) 0, G_SEEK_END, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_gst_tag_list_unref0 (tags);
		foot = (g_free (foot), NULL);
		return NULL;
	}
	while (TRUE) {
		{
			guint8* _tmp1_;
			gint _tmp1__length1;
			guint8* _tmp2_;
			gint _tmp2__length1;
			g4_seek_full (stream, (gint64) -128, G_SEEK_CUR, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
			_tmp1_ = foot;
			_tmp1__length1 = foot_length1;
			g4_read_full (stream, _tmp1_, (gint) _tmp1__length1, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
			_tmp2_ = foot;
			_tmp2__length1 = foot_length1;
			if (memcmp (_tmp2_, "TAG", (gsize) 3) == 0) {
				GstTagList* tags2 = NULL;
				guint8* _tmp3_;
				gint _tmp3__length1;
				GstTagList* _tmp4_;
				GstTagList* _tmp5_;
				GstTagList* _tmp6_;
				GstTagList* _tmp7_;
				_tmp3_ = foot;
				_tmp3__length1 = foot_length1;
				_tmp4_ = gst_tag_list_new_from_id3v1 (_tmp3_);
				tags2 = _tmp4_;
				_tmp5_ = tags;
				_tmp6_ = tags2;
				_tmp7_ = g4_merge_tags (_tmp5_, _tmp6_, GST_TAG_MERGE_KEEP);
				_gst_tag_list_unref0 (tags);
				tags = _tmp7_;
				g4_seek_full (stream, (gint64) -128, G_SEEK_CUR, &_inner_error0_);
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					_gst_tag_list_unref0 (tags2);
					goto __catch0_g_error;
				}
				_gst_tag_list_unref0 (tags2);
			} else {
				guint8* _tmp8_;
				gint _tmp8__length1;
				guint8* _tmp9_;
				gint _tmp9__length1;
				_tmp8_ = foot;
				_tmp8__length1 = foot_length1;
				_tmp9_ = foot;
				_tmp9__length1 = foot_length1;
				if (memcmp (_tmp9_ + (128 - 32), "APETAGEX", (gsize) 8) == 0) {
					guint32 size = 0U;
					guint8* _tmp10_;
					gint _tmp10__length1;
					guint8* data = NULL;
					gint _tmp11_ = 0;
					guint8* _tmp12_;
					gint data_length1;
					gint _data_size_;
					guint8* _tmp13_;
					gint _tmp13__length1;
					GstTagList* tags2 = NULL;
					guint8* _tmp14_;
					gint _tmp14__length1;
					GstTagList* _tmp15_;
					GstTagList* _tmp16_;
					GstTagList* _tmp17_;
					GstTagList* _tmp18_;
					GstTagList* _tmp19_;
					_tmp10_ = foot;
					_tmp10__length1 = foot_length1;
					size = g4_read_uint32_le (_tmp10_, (gint) _tmp10__length1, (guint) ((128 - 32) + 12)) + 32;
					g4_seek_full (stream, (gint64) (-((gint) size)), G_SEEK_CUR, &_inner_error0_);
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						goto __catch0_g_error;
					}
					_tmp12_ = g4_new_uint8_array ((guint) size, &_tmp11_, &_inner_error0_);
					data = _tmp12_;
					data_length1 = _tmp11_;
					_data_size_ = data_length1;
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						goto __catch0_g_error;
					}
					_tmp13_ = data;
					_tmp13__length1 = data_length1;
					g4_read_full (stream, _tmp13_, (gint) _tmp13__length1, &_inner_error0_);
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						data = (g_free (data), NULL);
						goto __catch0_g_error;
					}
					_tmp14_ = data;
					_tmp14__length1 = data_length1;
					_tmp15_ = ape_demux_parse_tags (_tmp14_, (gsize) _tmp14__length1);
					tags2 = _tmp15_;
					_tmp16_ = tags;
					_tmp17_ = tags2;
					_tmp18_ = g4_merge_tags (_tmp16_, _tmp17_, GST_TAG_MERGE_REPLACE);
					_gst_tag_list_unref0 (tags);
					tags = _tmp18_;
					_tmp19_ = tags2;
					apev2_found = !gst_tag_list_is_empty (_tmp19_);
					g4_seek_full (stream, (gint64) (-((gint) size)), G_SEEK_CUR, &_inner_error0_);
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						_gst_tag_list_unref0 (tags2);
						data = (g_free (data), NULL);
						goto __catch0_g_error;
					}
					_gst_tag_list_unref0 (tags2);
					data = (g_free (data), NULL);
				} else {
					guint8* _tmp20_;
					gint _tmp20__length1;
					guint8* _tmp21_;
					gint _tmp21__length1;
					_tmp20_ = foot;
					_tmp20__length1 = foot_length1;
					_tmp21_ = foot;
					_tmp21__length1 = foot_length1;
					if (memcmp (_tmp21_ + (128 - 9), "LYRICS200", (gsize) 9) == 0) {
						guint32 size = 0U;
						guint8* _tmp22_;
						gint _tmp22__length1;
						guint8* data = NULL;
						gint _tmp23_ = 0;
						guint8* _tmp24_;
						gint data_length1;
						gint _data_size_;
						guint8* _tmp25_;
						gint _tmp25__length1;
						GstTagList* tags2 = NULL;
						guint8* _tmp26_;
						gint _tmp26__length1;
						GstTagList* _tmp27_;
						GstTagMergeMode _tmp28_ = 0;
						GstTagList* _tmp29_;
						GstTagList* _tmp30_;
						GstTagList* _tmp31_;
						_tmp22_ = foot;
						_tmp22__length1 = foot_length1;
						size = g4_read_decimal_uint (_tmp22_ + (128 - 15), (gint) ((128 - 9) - (128 - 15)));
						g4_seek_full (stream, (gint64) (-((gint) (size + 15))), G_SEEK_CUR, &_inner_error0_);
						if (G_UNLIKELY (_inner_error0_ != NULL)) {
							goto __catch0_g_error;
						}
						_tmp24_ = g4_new_uint8_array ((guint) size, &_tmp23_, &_inner_error0_);
						data = _tmp24_;
						data_length1 = _tmp23_;
						_data_size_ = data_length1;
						if (G_UNLIKELY (_inner_error0_ != NULL)) {
							goto __catch0_g_error;
						}
						_tmp25_ = data;
						_tmp25__length1 = data_length1;
						g4_read_full (stream, _tmp25_, (gint) _tmp25__length1, &_inner_error0_);
						if (G_UNLIKELY (_inner_error0_ != NULL)) {
							data = (g_free (data), NULL);
							goto __catch0_g_error;
						}
						_tmp26_ = data;
						_tmp26__length1 = data_length1;
						_tmp27_ = g4_parse_lyrics200_tags (_tmp26_, (gint) _tmp26__length1);
						tags2 = _tmp27_;
						if (apev2_found) {
							_tmp28_ = GST_TAG_MERGE_KEEP;
						} else {
							_tmp28_ = GST_TAG_MERGE_REPLACE;
						}
						_tmp29_ = tags;
						_tmp30_ = tags2;
						_tmp31_ = g4_merge_tags (_tmp29_, _tmp30_, _tmp28_);
						_gst_tag_list_unref0 (tags);
						tags = _tmp31_;
						g4_seek_full (stream, (gint64) (-((gint) (size + 15))), G_SEEK_CUR, &_inner_error0_);
						if (G_UNLIKELY (_inner_error0_ != NULL)) {
							_gst_tag_list_unref0 (tags2);
							data = (g_free (data), NULL);
							goto __catch0_g_error;
						}
						_gst_tag_list_unref0 (tags2);
						data = (g_free (data), NULL);
					} else {
						break;
					}
				}
			}
		}
		goto __finally0;
		__catch0_g_error:
		{
			GError* e = NULL;
			GstTagList* _tmp32_;
			e = _inner_error0_;
			_inner_error0_ = NULL;
			_tmp32_ = tags;
			if (_tmp32_ == NULL) {
				GError* _tmp33_;
				GError* _tmp34_;
				_tmp33_ = e;
				_tmp34_ = _g_error_copy0 (_tmp33_);
				_inner_error0_ = _tmp34_;
				_g_error_free0 (e);
				goto __finally0;
			}
			_g_error_free0 (e);
			break;
		}
		__finally0:
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			g_propagate_error (error, _inner_error0_);
			_gst_tag_list_unref0 (tags);
			foot = (g_free (foot), NULL);
			return NULL;
		}
	}
	result = tags;
	foot = (g_free (foot), NULL);
	return result;
}

GstTagList*
g4_parse_flac_tags (GBufferedInputStream* stream,
                    GError** error)
{
	guint8* head = NULL;
	guint8* _tmp0_;
	gint head_length1;
	gint _head_size_;
	guint8* _tmp1_;
	gint _tmp1__length1;
	guint8* _tmp2_;
	gint _tmp2__length1;
	gint flags = 0;
	GstTagList* tags = NULL;
	GError* _inner_error0_ = NULL;
	GstTagList* result;
	g_return_val_if_fail (stream != NULL, NULL);
	_tmp0_ = g_new0 (guint8, 4);
	head = _tmp0_;
	head_length1 = 4;
	_head_size_ = head_length1;
	_tmp1_ = head;
	_tmp1__length1 = head_length1;
	g4_read_full (stream, _tmp1_, (gint) _tmp1__length1, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		head = (g_free (head), NULL);
		return NULL;
	}
	_tmp2_ = head;
	_tmp2__length1 = head_length1;
	if (memcmp (_tmp2_, "fLaC", (gsize) 4) != 0) {
		result = NULL;
		head = (g_free (head), NULL);
		return result;
	}
	flags = 0;
	tags = NULL;
	{
		gboolean _tmp3_ = FALSE;
		_tmp3_ = TRUE;
		while (TRUE) {
			if (!_tmp3_) {
				if (!((flags & 0x03) != 0x03)) {
					break;
				}
			}
			_tmp3_ = FALSE;
			{
				guint8* _tmp4_;
				gint _tmp4__length1;
				guint8 type = 0U;
				guint8* _tmp5_;
				gint _tmp5__length1;
				guint8 _tmp6_;
				guint32 size = 0U;
				guint8* _tmp7_;
				gint _tmp7__length1;
				guint8 _tmp8_;
				guint8* _tmp9_;
				gint _tmp9__length1;
				guint8 _tmp10_;
				guint8* _tmp11_;
				gint _tmp11__length1;
				guint8 _tmp12_;
				_tmp4_ = head;
				_tmp4__length1 = head_length1;
				g4_read_full (stream, _tmp4_, (gint) _tmp4__length1, &_inner_error0_);
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					goto __catch0_g_error;
				}
				_tmp5_ = head;
				_tmp5__length1 = head_length1;
				_tmp6_ = _tmp5_[0];
				type = _tmp6_ & 0x7f;
				_tmp7_ = head;
				_tmp7__length1 = head_length1;
				_tmp8_ = _tmp7_[1];
				_tmp9_ = head;
				_tmp9__length1 = head_length1;
				_tmp10_ = _tmp9_[2];
				_tmp11_ = head;
				_tmp11__length1 = head_length1;
				_tmp12_ = _tmp11_[3];
				size = ((((guint32) _tmp8_) << 16) | (((guint32) _tmp10_) << 8)) | _tmp12_;
				if (((gint) type) == 4) {
					guint8* data = NULL;
					gint _tmp13_ = 0;
					guint8* _tmp14_;
					gint data_length1;
					gint _data_size_;
					guint8* _tmp15_;
					gint _tmp15__length1;
					guint8* _tmp16_;
					gint _tmp16__length1;
					guint8* _tmp17_;
					gint _tmp17__length1;
					guint8* _tmp18_;
					gint _tmp18__length1;
					guint8* _tmp19_;
					gint _tmp19__length1;
					GstTagList* tags2 = NULL;
					guint8* _tmp20_;
					gint _tmp20__length1;
					guint8* _tmp21_;
					gint _tmp21__length1;
					GstTagList* _tmp22_;
					GstTagList* _tmp23_;
					GstTagList* _tmp24_;
					GstTagList* _tmp25_;
					_tmp14_ = g4_new_uint8_array ((guint) (size + 4), &_tmp13_, &_inner_error0_);
					data = _tmp14_;
					data_length1 = _tmp13_;
					_data_size_ = data_length1;
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						goto __catch0_g_error;
					}
					_tmp15_ = data;
					_tmp15__length1 = data_length1;
					_tmp16_ = data;
					_tmp16__length1 = data_length1;
					g4_read_full (stream, _tmp16_ + 4, (gint) (_tmp16__length1 - 4), &_inner_error0_);
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						data = (g_free (data), NULL);
						goto __catch0_g_error;
					}
					_tmp17_ = head;
					_tmp17__length1 = head_length1;
					_tmp17_[0] &= (guint8) (~0x80);
					_tmp18_ = data;
					_tmp18__length1 = data_length1;
					_tmp19_ = head;
					_tmp19__length1 = head_length1;
					memcpy (_tmp18_, _tmp19_, (gsize) 4);
					_tmp20_ = data;
					_tmp20__length1 = data_length1;
					_tmp21_ = head;
					_tmp21__length1 = head_length1;
					_tmp22_ = gst_tag_list_from_vorbiscomment (_tmp20_, (gsize) _tmp20__length1, _tmp21_, (guint) _tmp21__length1, NULL);
					tags2 = _tmp22_;
					_tmp23_ = tags;
					_tmp24_ = tags2;
					_tmp25_ = g4_merge_tags (_tmp23_, _tmp24_, GST_TAG_MERGE_KEEP);
					_gst_tag_list_unref0 (tags);
					tags = _tmp25_;
					flags |= 0x01;
					_gst_tag_list_unref0 (tags2);
					data = (g_free (data), NULL);
				} else {
					if (((gint) type) == 6) {
						guint8* data = NULL;
						gint _tmp26_ = 0;
						guint8* _tmp27_;
						gint data_length1;
						gint _data_size_;
						guint8* _tmp28_;
						gint _tmp28__length1;
						guint pos = 0U;
						guint32 img_type = 0U;
						guint8* _tmp29_;
						gint _tmp29__length1;
						guint32 img_mimetype_len = 0U;
						guint8* _tmp30_;
						gint _tmp30__length1;
						guint32 img_description_len = 0U;
						guint8* _tmp31_;
						gint _tmp31__length1;
						guint32 img_len = 0U;
						guint8* _tmp32_;
						gint _tmp32__length1;
						GstTagList* _tmp33_ = NULL;
						GstTagList* _tmp34_;
						GstTagList* _tmp35_;
						GstTagList* _tmp37_;
						GstTagList* _tmp38_;
						guint8* _tmp39_;
						gint _tmp39__length1;
						_tmp27_ = g4_new_uint8_array ((guint) size, &_tmp26_, &_inner_error0_);
						data = _tmp27_;
						data_length1 = _tmp26_;
						_data_size_ = data_length1;
						if (G_UNLIKELY (_inner_error0_ != NULL)) {
							goto __catch0_g_error;
						}
						_tmp28_ = data;
						_tmp28__length1 = data_length1;
						g4_read_full (stream, _tmp28_, (gint) _tmp28__length1, &_inner_error0_);
						if (G_UNLIKELY (_inner_error0_ != NULL)) {
							data = (g_free (data), NULL);
							goto __catch0_g_error;
						}
						pos = (guint) 0;
						_tmp29_ = data;
						_tmp29__length1 = data_length1;
						img_type = g4_read_uint32_be (_tmp29_, (gint) _tmp29__length1, pos);
						pos += (guint) 4;
						_tmp30_ = data;
						_tmp30__length1 = data_length1;
						img_mimetype_len = g4_read_uint32_be (_tmp30_, (gint) _tmp30__length1, pos);
						pos += (guint) (4 + img_mimetype_len);
						if ((pos + 4) > ((guint) size)) {
							data = (g_free (data), NULL);
							break;
						}
						_tmp31_ = data;
						_tmp31__length1 = data_length1;
						img_description_len = g4_read_uint32_be (_tmp31_, (gint) _tmp31__length1, pos);
						pos += (guint) (4 + img_description_len);
						pos += (guint) (4 * 4);
						if ((pos + 4) > ((guint) size)) {
							data = (g_free (data), NULL);
							break;
						}
						_tmp32_ = data;
						_tmp32__length1 = data_length1;
						img_len = g4_read_uint32_be (_tmp32_, (gint) _tmp32__length1, pos);
						pos += (guint) 4;
						if ((pos + img_len) > ((guint) size)) {
							data = (g_free (data), NULL);
							break;
						}
						_tmp34_ = tags;
						_tmp35_ = _gst_tag_list_ref0 (_tmp34_);
						_tmp33_ = _tmp35_;
						if (_tmp33_ == NULL) {
							GstTagList* _tmp36_;
							_tmp36_ = gst_tag_list_new_empty ();
							_gst_tag_list_unref0 (_tmp33_);
							_tmp33_ = _tmp36_;
						}
						_tmp37_ = _tmp33_;
						_tmp33_ = NULL;
						_gst_tag_list_unref0 (tags);
						tags = (GstTagList*) _tmp37_;
						_tmp38_ = tags;
						_tmp39_ = data;
						_tmp39__length1 = data_length1;
						gst_tag_list_add_id3_image ((GstTagList*) _tmp38_, _tmp39_ + ((gint) pos), (guint) (((gint) (pos + img_len)) - ((gint) pos)), (guint) img_type);
						flags |= 0x02;
						_gst_tag_list_unref0 (_tmp33_);
						data = (g_free (data), NULL);
					} else {
						g4_seek_full (stream, (gint64) size, G_SEEK_CUR, &_inner_error0_);
						if (G_UNLIKELY (_inner_error0_ != NULL)) {
							goto __catch0_g_error;
						}
					}
				}
			}
			goto __finally0;
			__catch0_g_error:
			{
				GError* e = NULL;
				GstTagList* _tmp40_;
				e = _inner_error0_;
				_inner_error0_ = NULL;
				_tmp40_ = tags;
				if (_tmp40_ == NULL) {
					GError* _tmp41_;
					GError* _tmp42_;
					_tmp41_ = e;
					_tmp42_ = _g_error_copy0 (_tmp41_);
					_inner_error0_ = _tmp42_;
					_g_error_free0 (e);
					goto __finally0;
				}
				_g_error_free0 (e);
				break;
			}
			__finally0:
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				g_propagate_error (error, _inner_error0_);
				_gst_tag_list_unref0 (tags);
				head = (g_free (head), NULL);
				return NULL;
			}
		}
	}
	result = tags;
	head = (g_free (head), NULL);
	return result;
}

static guint8*
_vala_array_dup5 (guint8* self,
                  gssize length)
{
	if (length > 0) {
		return _vala_memdup2 (self, length * sizeof (guint8));
	}
	return NULL;
}

static guint8*
_vala_array_dup6 (guint8* self,
                  gssize length)
{
	if (length > 0) {
		return _vala_memdup2 (self, length * sizeof (guint8));
	}
	return NULL;
}

GstTagList*
g4_parse_lyrics200_tags (guint8* data,
                         gint data_length1)
{
	GstTagList* tags = NULL;
	GstTagList* _tmp0_;
	gint length = 0;
	gint pos = 0;
	GstTagList* result;
	_tmp0_ = gst_tag_list_new_empty ();
	tags = _tmp0_;
	if (memcmp (data, "LYRICSBEGIN", (gsize) 11) != 0) {
		result = tags;
		return result;
	}
	length = data_length1;
	pos = 11;
	while (TRUE) {
		guint8* id = NULL;
		guint8* _tmp1_;
		gint _tmp1__length1;
		gint id_length1;
		gint _id_size_;
		guint32 len = 0U;
		guint8* str = NULL;
		guint8* _tmp2_;
		gint _tmp2__length1;
		gint str_length1;
		gint _str_size_;
		gchar* tag = NULL;
		guint8* _tmp3_;
		gint _tmp3__length1;
		const gchar* _tmp11_;
		if (!((pos + 8) < length)) {
			break;
		}
		_tmp1_ = (data != NULL) ? _vala_array_dup5 (data + pos, (pos + 3) - pos) : data;
		_tmp1__length1 = (pos + 3) - pos;
		id = _tmp1_;
		id_length1 = _tmp1__length1;
		_id_size_ = id_length1;
		pos += 3;
		len = g4_read_decimal_uint (data + pos, (gint) ((pos + 5) - pos));
		pos += 5;
		if ((pos + len) > ((guint32) length)) {
			id = (g_free (id), NULL);
			break;
		}
		_tmp2_ = (data != NULL) ? _vala_array_dup6 (data + pos, ((gint) (pos + len)) - pos) : data;
		_tmp2__length1 = ((gint) (pos + len)) - pos;
		str = _tmp2_;
		str_length1 = _tmp2__length1;
		_str_size_ = str_length1;
		pos += (gint) len;
		tag = NULL;
		_tmp3_ = id;
		_tmp3__length1 = id_length1;
		if (memcmp (_tmp3_, "EAL", (gsize) 3) == 0) {
			gchar* _tmp4_;
			_tmp4_ = g_strdup (GST_TAG_ALBUM);
			_g_free0 (tag);
			tag = _tmp4_;
		} else {
			guint8* _tmp5_;
			gint _tmp5__length1;
			_tmp5_ = id;
			_tmp5__length1 = id_length1;
			if (memcmp (_tmp5_, "EAR", (gsize) 3) == 0) {
				gchar* _tmp6_;
				_tmp6_ = g_strdup (GST_TAG_ARTIST);
				_g_free0 (tag);
				tag = _tmp6_;
			} else {
				guint8* _tmp7_;
				gint _tmp7__length1;
				_tmp7_ = id;
				_tmp7__length1 = id_length1;
				if (memcmp (_tmp7_, "ETT", (gsize) 3) == 0) {
					gchar* _tmp8_;
					_tmp8_ = g_strdup (GST_TAG_TITLE);
					_g_free0 (tag);
					tag = _tmp8_;
				} else {
					guint8* _tmp9_;
					gint _tmp9__length1;
					_tmp9_ = id;
					_tmp9__length1 = id_length1;
					if (memcmp (_tmp9_, "LYR", (gsize) 3) == 0) {
						gchar* _tmp10_;
						_tmp10_ = g_strdup (GST_TAG_LYRICS);
						_g_free0 (tag);
						tag = _tmp10_;
					}
				}
			}
		}
		_tmp11_ = tag;
		if (_tmp11_ != NULL) {
			gchar* value = NULL;
			guint8* _tmp12_;
			gint _tmp12__length1;
			gchar* _tmp13_;
			gboolean _tmp14_ = FALSE;
			const gchar* _tmp15_;
			_tmp12_ = str;
			_tmp12__length1 = str_length1;
			_tmp13_ = gst_tag_freeform_string_to_utf8 ((gchar*) _tmp12_, (gint) ((_tmp12__length1 * sizeof (guint8)) / sizeof (gchar)), G4_ID3_TAG_ENCODINGS);
			value = _tmp13_;
			_tmp15_ = value;
			if (g_strcmp0 (_tmp15_, (const gchar*) NULL) != 0) {
				const gchar* _tmp16_;
				gint _tmp17_;
				gint _tmp18_;
				_tmp16_ = value;
				_tmp17_ = strlen (_tmp16_);
				_tmp18_ = _tmp17_;
				_tmp14_ = _tmp18_ > 0;
			} else {
				_tmp14_ = FALSE;
			}
			if (_tmp14_) {
				GstTagList* _tmp19_;
				const gchar* _tmp20_;
				const gchar* _tmp21_;
				_tmp19_ = tags;
				_tmp20_ = tag;
				_tmp21_ = value;
				gst_tag_list_add (_tmp19_, GST_TAG_MERGE_REPLACE, (const gchar*) _tmp20_, _tmp21_, NULL);
			}
			_g_free0 (value);
		}
		_g_free0 (tag);
		str = (g_free (str), NULL);
		id = (g_free (id), NULL);
	}
	result = tags;
	return result;
}

void
g4_parse_mp4_date_value (guint8* data,
                         gint data_length1,
                         const gchar* tag,
                         GstTagList* tags,
                         GError** error)
{
	gchar* str = NULL;
	gchar* _tmp0_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (tag != NULL);
	g_return_if_fail (tags != NULL);
	_tmp0_ = g4_parse_mp4_string (data, (gint) data_length1, &_inner_error0_);
	str = _tmp0_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		return;
	}
	if (str != NULL) {
		GstDateTime* date = NULL;
		GstDateTime* _tmp1_;
		GstDateTime* _tmp2_;
		_tmp1_ = gst_date_time_new_from_iso8601_string ((const gchar*) str);
		date = _tmp1_;
		_tmp2_ = date;
		gst_tag_list_add (tags, GST_TAG_MERGE_REPLACE, tag, _tmp2_, NULL);
		_gst_date_time_unref0 (date);
	} else {
		const gchar* _tmp3_ = NULL;
		_tmp3_ = str;
		if (_tmp3_ == NULL) {
			_tmp3_ = "";
		}
		g_print ("MP4: unknown date type: %s\n", (const gchar*) _tmp3_);
	}
	_g_free0 (str);
}

static guint8*
_vala_array_dup7 (guint8* self,
                  gssize length)
{
	if (length > 0) {
		return _vala_memdup2 (self, length * sizeof (guint8));
	}
	return NULL;
}

void
g4_parse_mp4_image_value (guint8* data,
                          gint data_length1,
                          const gchar* tag,
                          GstTagList* tags,
                          GError** error)
{
	gint len = 0;
	g_return_if_fail (tag != NULL);
	g_return_if_fail (tags != NULL);
	len = data_length1;
	if (len > 16) {
		guint32 type = 0U;
		gboolean _tmp0_ = FALSE;
		type = g4_read_uint32_be (data, (gint) data_length1, (guint) 8);
		if (type == ((guint32) 0x0000000d)) {
			_tmp0_ = TRUE;
		} else {
			_tmp0_ = type == ((guint32) 0x0000000e);
		}
		if (_tmp0_) {
			guint8* image_data = NULL;
			guint8* _tmp1_;
			gint _tmp1__length1;
			gint image_data_length1;
			gint _image_data_size_;
			GstTagImageType image_type = 0;
			GstSample* sample = NULL;
			guint8* _tmp2_;
			gint _tmp2__length1;
			GstSample* _tmp3_;
			GstSample* _tmp4_;
			_tmp1_ = (data != NULL) ? _vala_array_dup7 (data + 16, len - 16) : data;
			_tmp1__length1 = len - 16;
			image_data = _tmp1_;
			image_data_length1 = _tmp1__length1;
			_image_data_size_ = image_data_length1;
			if (gst_tag_list_get_tag_size (tags, GST_TAG_IMAGE) == ((guint) 0)) {
				image_type = GST_TAG_IMAGE_TYPE_FRONT_COVER;
			} else {
				image_type = GST_TAG_IMAGE_TYPE_NONE;
			}
			_tmp2_ = image_data;
			_tmp2__length1 = image_data_length1;
			_tmp3_ = gst_tag_image_data_to_image_sample (_tmp2_, (guint) _tmp2__length1, image_type);
			sample = _tmp3_;
			_tmp4_ = sample;
			if (_tmp4_ != ((GstSample*) NULL)) {
				GstSample* _tmp5_;
				_tmp5_ = sample;
				gst_tag_list_add (tags, GST_TAG_MERGE_REPLACE, tag, _tmp5_, NULL);
			}
			_gst_sample_unref0 (sample);
			image_data = (g_free (image_data), NULL);
		}
	} else {
		g_print ("MP4: unknown image type\n");
	}
}

void
g4_parse_mp4_number_value (guint8* data,
                           gint data_length1,
                           const gchar* tag1,
                           const gchar* tag2,
                           GstTagList* tags,
                           GError** error)
{
	gint len = 0;
	g_return_if_fail (tag1 != NULL);
	g_return_if_fail (tag2 != NULL);
	g_return_if_fail (tags != NULL);
	len = data_length1;
	if (len >= 22) {
		guint32 type = 0U;
		type = g4_read_uint32_be (data, (gint) data_length1, (guint) 8);
		if (type == ((guint32) 0x00000000)) {
			guint32 n = 0U;
			guint32 n1 = 0U;
			guint32 n2 = 0U;
			n = g4_read_uint32_be (data, (gint) data_length1, (guint) 18);
			n1 = n >> 16;
			n2 = n & 0xffff;
			if (n1 > ((guint32) 0)) {
				gst_tag_list_add (tags, GST_TAG_MERGE_REPLACE, tag1, n1, NULL);
			}
			if (n2 > ((guint32) 0)) {
				gst_tag_list_add (tags, GST_TAG_MERGE_REPLACE, tag2, n2, NULL);
			}
		}
	} else {
		g_print ("MP4: unknown number type\n");
	}
}

static guint8*
_vala_array_dup8 (guint8* self,
                  gssize length)
{
	if (length > 0) {
		return _vala_memdup2 (self, length * sizeof (guint8));
	}
	return NULL;
}

gchar*
g4_parse_mp4_string (guint8* data,
                     gint data_length1,
                     GError** error)
{
	gint len = 0;
	gchar* result;
	len = data_length1;
	if (len > 16) {
		guint32 type = 0U;
		type = g4_read_uint32_be (data, (gint) data_length1, (guint) 8);
		if (type == ((guint32) 0x00000001)) {
			guint8* str_data = NULL;
			guint8* _tmp0_;
			gint _tmp0__length1;
			gint str_data_length1;
			gint _str_data_size_;
			guint8* _tmp1_;
			gint _tmp1__length1;
			gchar* _tmp2_;
			_tmp0_ = (data != NULL) ? _vala_array_dup8 (data + 16, len - 16) : data;
			_tmp0__length1 = len - 16;
			str_data = _tmp0_;
			str_data_length1 = _tmp0__length1;
			_str_data_size_ = str_data_length1;
			_tmp1_ = str_data;
			_tmp1__length1 = str_data_length1;
			_tmp2_ = gst_tag_freeform_string_to_utf8 ((gchar*) _tmp1_, (gint) ((_tmp1__length1 * sizeof (guint8)) / sizeof (gchar)), G4_MP4_TAG_ENCODINGS);
			result = (gchar*) _tmp2_;
			str_data = (g_free (str_data), NULL);
			return result;
		}
	}
	result = NULL;
	return result;
}

void
g4_parse_mp4_string_value (guint8* data,
                           gint data_length1,
                           const gchar* tag,
                           GstTagList* tags,
                           GError** error)
{
	gchar* str = NULL;
	gchar* _tmp0_;
	gboolean _tmp1_ = FALSE;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (tag != NULL);
	g_return_if_fail (tags != NULL);
	_tmp0_ = g4_parse_mp4_string (data, (gint) data_length1, &_inner_error0_);
	str = _tmp0_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		return;
	}
	if (str != NULL) {
		gint _tmp2_;
		gint _tmp3_;
		_tmp2_ = strlen ((const gchar*) str);
		_tmp3_ = _tmp2_;
		_tmp1_ = _tmp3_ > 0;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		gchar* value = NULL;
		gchar* _tmp4_;
		const gchar* _tmp5_;
		_tmp4_ = g_strdup ((const gchar*) str);
		value = _tmp4_;
		_tmp5_ = value;
		gst_tag_list_add (tags, GST_TAG_MERGE_REPLACE, tag, _tmp5_, NULL);
		_g_free0 (value);
	} else {
		g_print ("MP4: unknown string type\n");
	}
	_g_free0 (str);
}

guint
g4_find_mp4_data_child (guint8* buffer,
                        gint buffer_length1,
                        guint pos,
                        guint end,
                        guint32 fourcc)
{
	guint result;
	while (TRUE) {
		guint32 box_size = 0U;
		guint32 box_type = 0U;
		if (!((pos + 8) < end)) {
			break;
		}
		box_size = g4_read_uint32_be (buffer, (gint) buffer_length1, pos);
		box_type = g4_read_uint32_be (buffer, (gint) buffer_length1, pos + 4);
		if (box_type == fourcc) {
			result = pos;
			return result;
		}
		pos = pos + box_size;
	}
	result = end;
	return result;
}

static guint8*
_vala_array_dup9 (guint8* self,
                  gssize length)
{
	if (length > 0) {
		return _vala_memdup2 (self, length * sizeof (guint8));
	}
	return NULL;
}

void
g4_parse_mp4_ilst_box (guint8* buffer,
                       gint buffer_length1,
                       GstTagList* tags,
                       GError** error)
{
	gint size = 0;
	guint pos = 0U;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (tags != NULL);
	size = buffer_length1;
	pos = (guint) 0;
	while (TRUE) {
		guint32 box_size = 0U;
		guint32 box_type = 0U;
		guint box_end = 0U;
		guint data_pos = 0U;
		gboolean _tmp0_ = FALSE;
		if (!((pos + 8) < ((guint) size))) {
			break;
		}
		box_size = g4_read_uint32_be (buffer, (gint) buffer_length1, pos);
		box_type = g4_read_uint32_be (buffer, (gint) buffer_length1, pos + 4);
		box_end = pos + box_size;
		data_pos = g4_find_mp4_data_child (buffer, (gint) buffer_length1, pos + 8, box_end, (guint32) 0x64617461);
		if (box_size > ((guint32) 16)) {
			_tmp0_ = data_pos != box_end;
		} else {
			_tmp0_ = FALSE;
		}
		if (_tmp0_) {
			guint32 data_size = 0U;
			guint8* data = NULL;
			guint8* _tmp1_;
			gint _tmp1__length1;
			gint data_length1;
			gint _data_size_;
			data_size = g4_read_uint32_be (buffer, (gint) buffer_length1, data_pos);
			_tmp1_ = (buffer != NULL) ? _vala_array_dup9 (buffer + ((gint) data_pos), ((gint) (data_pos + data_size)) - ((gint) data_pos)) : buffer;
			_tmp1__length1 = ((gint) (data_pos + data_size)) - ((gint) data_pos);
			data = _tmp1_;
			data_length1 = _tmp1__length1;
			_data_size_ = data_length1;
			switch (box_type) {
				case 0xa96e616dU:
				case 0x7469746cU:
				{
					guint8* _tmp2_;
					gint _tmp2__length1;
					_tmp2_ = data;
					_tmp2__length1 = data_length1;
					g4_parse_mp4_string_value (_tmp2_, (gint) _tmp2__length1, GST_TAG_TITLE, tags, &_inner_error0_);
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						g_propagate_error (error, _inner_error0_);
						data = (g_free (data), NULL);
						return;
					}
					break;
				}
				case 0xa9415254U:
				case 0x70657266U:
				{
					guint8* _tmp3_;
					gint _tmp3__length1;
					_tmp3_ = data;
					_tmp3__length1 = data_length1;
					g4_parse_mp4_string_value (_tmp3_, (gint) _tmp3__length1, GST_TAG_ARTIST, tags, &_inner_error0_);
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						g_propagate_error (error, _inner_error0_);
						data = (g_free (data), NULL);
						return;
					}
					break;
				}
				case 0xa9616c62U:
				case 0x616c626dU:
				{
					guint8* _tmp4_;
					gint _tmp4__length1;
					_tmp4_ = data;
					_tmp4__length1 = data_length1;
					g4_parse_mp4_string_value (_tmp4_, (gint) _tmp4__length1, GST_TAG_ALBUM, tags, &_inner_error0_);
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						g_propagate_error (error, _inner_error0_);
						data = (g_free (data), NULL);
						return;
					}
					break;
				}
				case 0xa9777274U:
				case 0x61757468U:
				{
					guint8* _tmp5_;
					gint _tmp5__length1;
					_tmp5_ = data;
					_tmp5__length1 = data_length1;
					g4_parse_mp4_string_value (_tmp5_, (gint) _tmp5__length1, GST_TAG_COMPOSER, tags, &_inner_error0_);
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						g_propagate_error (error, _inner_error0_);
						data = (g_free (data), NULL);
						return;
					}
					break;
				}
				case 0xa9636d74U:
				case 0xa9696e66U:
				{
					guint8* _tmp6_;
					gint _tmp6__length1;
					_tmp6_ = data;
					_tmp6__length1 = data_length1;
					g4_parse_mp4_string_value (_tmp6_, (gint) _tmp6__length1, GST_TAG_COMMENT, tags, &_inner_error0_);
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						g_propagate_error (error, _inner_error0_);
						data = (g_free (data), NULL);
						return;
					}
					break;
				}
				case 0xa96c7972U:
				{
					guint8* _tmp7_;
					gint _tmp7__length1;
					_tmp7_ = data;
					_tmp7__length1 = data_length1;
					g4_parse_mp4_string_value (_tmp7_, (gint) _tmp7__length1, GST_TAG_LYRICS, tags, &_inner_error0_);
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						g_propagate_error (error, _inner_error0_);
						data = (g_free (data), NULL);
						return;
					}
					break;
				}
				case 0xa9646179U:
				case 0x79727263U:
				{
					guint8* _tmp8_;
					gint _tmp8__length1;
					_tmp8_ = data;
					_tmp8__length1 = data_length1;
					g4_parse_mp4_date_value (_tmp8_, (gint) _tmp8__length1, GST_TAG_DATE_TIME, tags, &_inner_error0_);
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						g_propagate_error (error, _inner_error0_);
						data = (g_free (data), NULL);
						return;
					}
					break;
				}
				case 0x636f7672U:
				{
					guint8* _tmp9_;
					gint _tmp9__length1;
					_tmp9_ = data;
					_tmp9__length1 = data_length1;
					g4_parse_mp4_image_value (_tmp9_, (gint) _tmp9__length1, GST_TAG_IMAGE, tags, &_inner_error0_);
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						g_propagate_error (error, _inner_error0_);
						data = (g_free (data), NULL);
						return;
					}
					break;
				}
				case 0x64697363U:
				case 0x6469736bU:
				{
					guint8* _tmp10_;
					gint _tmp10__length1;
					_tmp10_ = data;
					_tmp10__length1 = data_length1;
					g4_parse_mp4_number_value (_tmp10_, (gint) _tmp10__length1, GST_TAG_ALBUM_VOLUME_NUMBER, GST_TAG_ALBUM_VOLUME_COUNT, tags, &_inner_error0_);
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						g_propagate_error (error, _inner_error0_);
						data = (g_free (data), NULL);
						return;
					}
					break;
				}
				case 0x74726b6eU:
				{
					guint8* _tmp11_;
					gint _tmp11__length1;
					_tmp11_ = data;
					_tmp11__length1 = data_length1;
					g4_parse_mp4_number_value (_tmp11_, (gint) _tmp11__length1, GST_TAG_TRACK_NUMBER, GST_TAG_TRACK_COUNT, tags, &_inner_error0_);
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						g_propagate_error (error, _inner_error0_);
						data = (g_free (data), NULL);
						return;
					}
					break;
				}
				default:
				{
					break;
				}
			}
			data = (g_free (data), NULL);
		}
		pos = box_end;
	}
}

void
g4_parse_mp4_box (GBufferedInputStream* stream,
                  GstTagList* tags,
                  GError** error)
{
	guint8* box_head = NULL;
	guint8* _tmp0_;
	gint box_head_length1;
	gint _box_head_size_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (stream != NULL);
	g_return_if_fail (tags != NULL);
	_tmp0_ = g_new0 (guint8, 8);
	box_head = _tmp0_;
	box_head_length1 = 8;
	_box_head_size_ = box_head_length1;
	while (TRUE) {
		guint8* _tmp1_;
		gint _tmp1__length1;
		guint32 box_size = 0U;
		guint8* _tmp2_;
		gint _tmp2__length1;
		guint32 box_type = 0U;
		guint8* _tmp3_;
		gint _tmp3__length1;
		if (!gst_tag_list_is_empty (tags)) {
			break;
		}
		_tmp1_ = box_head;
		_tmp1__length1 = box_head_length1;
		g4_read_full (stream, _tmp1_, (gint) _tmp1__length1, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			g_propagate_error (error, _inner_error0_);
			box_head = (g_free (box_head), NULL);
			return;
		}
		_tmp2_ = box_head;
		_tmp2__length1 = box_head_length1;
		box_size = g4_read_uint32_be (_tmp2_, (gint) _tmp2__length1, (guint) 0);
		_tmp3_ = box_head;
		_tmp3__length1 = box_head_length1;
		box_type = g4_read_uint32_be (_tmp3_, (gint) _tmp3__length1, (guint) 4);
		if (box_size <= ((guint32) 8)) {
			continue;
		} else {
			if (box_type == ((guint32) 0x6d6f6f76)) {
				g4_parse_mp4_box (stream, tags, &_inner_error0_);
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					g_propagate_error (error, _inner_error0_);
					box_head = (g_free (box_head), NULL);
					return;
				}
			} else {
				if (box_type == ((guint32) 0x75647461)) {
					g4_parse_mp4_box (stream, tags, &_inner_error0_);
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						g_propagate_error (error, _inner_error0_);
						box_head = (g_free (box_head), NULL);
						return;
					}
				} else {
					gboolean _tmp4_ = FALSE;
					if (box_type == ((guint32) 0x6d657461)) {
						_tmp4_ = box_size > ((guint32) 16);
					} else {
						_tmp4_ = FALSE;
					}
					if (_tmp4_) {
						guint8* _tmp5_;
						gint _tmp5__length1;
						guint32 v1 = 0U;
						guint8* _tmp6_;
						gint _tmp6__length1;
						guint32 v2 = 0U;
						guint8* _tmp7_;
						gint _tmp7__length1;
						_tmp5_ = box_head;
						_tmp5__length1 = box_head_length1;
						g4_read_full (stream, _tmp5_, (gint) _tmp5__length1, &_inner_error0_);
						if (G_UNLIKELY (_inner_error0_ != NULL)) {
							g_propagate_error (error, _inner_error0_);
							box_head = (g_free (box_head), NULL);
							return;
						}
						_tmp6_ = box_head;
						_tmp6__length1 = box_head_length1;
						v1 = g4_read_uint32_be (_tmp6_, (gint) _tmp6__length1, (guint) 0);
						_tmp7_ = box_head;
						_tmp7__length1 = box_head_length1;
						v2 = g4_read_uint32_be (_tmp7_, (gint) _tmp7__length1, (guint) 4);
						if (v2 == ((guint32) 0x68646c72)) {
							g4_seek_full (stream, (gint64) -8, G_SEEK_CUR, &_inner_error0_);
							if (G_UNLIKELY (_inner_error0_ != NULL)) {
								g_propagate_error (error, _inner_error0_);
								box_head = (g_free (box_head), NULL);
								return;
							}
							g4_parse_mp4_box (stream, tags, &_inner_error0_);
							if (G_UNLIKELY (_inner_error0_ != NULL)) {
								g_propagate_error (error, _inner_error0_);
								box_head = (g_free (box_head), NULL);
								return;
							}
						} else {
							if (v1 == ((guint32) 0)) {
								g4_seek_full (stream, (gint64) -4, G_SEEK_CUR, &_inner_error0_);
								if (G_UNLIKELY (_inner_error0_ != NULL)) {
									g_propagate_error (error, _inner_error0_);
									box_head = (g_free (box_head), NULL);
									return;
								}
								g4_parse_mp4_box (stream, tags, &_inner_error0_);
								if (G_UNLIKELY (_inner_error0_ != NULL)) {
									g_propagate_error (error, _inner_error0_);
									box_head = (g_free (box_head), NULL);
									return;
								}
							}
						}
					} else {
						if (box_type == ((guint32) 0x696c7374)) {
							guint8* buffer = NULL;
							gint _tmp8_ = 0;
							guint8* _tmp9_;
							gint buffer_length1;
							gint _buffer_size_;
							guint8* _tmp10_;
							gint _tmp10__length1;
							guint8* _tmp11_;
							gint _tmp11__length1;
							_tmp9_ = g4_new_uint8_array ((guint) (box_size - 8), &_tmp8_, &_inner_error0_);
							buffer = _tmp9_;
							buffer_length1 = _tmp8_;
							_buffer_size_ = buffer_length1;
							if (G_UNLIKELY (_inner_error0_ != NULL)) {
								g_propagate_error (error, _inner_error0_);
								box_head = (g_free (box_head), NULL);
								return;
							}
							_tmp10_ = buffer;
							_tmp10__length1 = buffer_length1;
							g4_read_full (stream, _tmp10_, (gint) _tmp10__length1, &_inner_error0_);
							if (G_UNLIKELY (_inner_error0_ != NULL)) {
								g_propagate_error (error, _inner_error0_);
								buffer = (g_free (buffer), NULL);
								box_head = (g_free (box_head), NULL);
								return;
							}
							_tmp11_ = buffer;
							_tmp11__length1 = buffer_length1;
							g4_parse_mp4_ilst_box (_tmp11_, (gint) _tmp11__length1, tags, &_inner_error0_);
							if (G_UNLIKELY (_inner_error0_ != NULL)) {
								g_propagate_error (error, _inner_error0_);
								buffer = (g_free (buffer), NULL);
								box_head = (g_free (box_head), NULL);
								return;
							}
							buffer = (g_free (buffer), NULL);
						} else {
							g4_seek_full (stream, (gint64) (box_size - 8), G_SEEK_CUR, &_inner_error0_);
							if (G_UNLIKELY (_inner_error0_ != NULL)) {
								g_propagate_error (error, _inner_error0_);
								box_head = (g_free (box_head), NULL);
								return;
							}
						}
					}
				}
			}
		}
	}
	box_head = (g_free (box_head), NULL);
}

GstTagList*
g4_parse_mp4_tags (GBufferedInputStream* stream)
{
	GstTagList* tags = NULL;
	GstTagList* _tmp0_;
	GstTagList* _tmp3_ = NULL;
	GstTagList* _tmp4_;
	GError* _inner_error0_ = NULL;
	GstTagList* result;
	g_return_val_if_fail (stream != NULL, NULL);
	_tmp0_ = gst_tag_list_new_empty ();
	tags = _tmp0_;
	{
		g4_parse_mp4_box (stream, tags, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp1_;
		const gchar* _tmp2_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp1_ = e;
		_tmp2_ = _tmp1_->message;
		g_print ("Parse MP4 Error %s\n", _tmp2_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_gst_tag_list_unref0 (tags);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return NULL;
	}
	if (gst_tag_list_is_empty (tags)) {
		_tmp3_ = (GstTagList*) NULL;
	} else {
		_tmp3_ = tags;
	}
	_tmp4_ = _gst_tag_list_ref0 (_tmp3_);
	result = _tmp4_;
	_gst_tag_list_unref0 (tags);
	return result;
}

static guint8*
_vala_array_dup10 (guint8* self,
                   gssize length)
{
	if (length > 0) {
		return _vala_memdup2 (self, length * sizeof (guint8));
	}
	return NULL;
}

static guint8*
string_get_data (const gchar* self,
                 gint* result_length1)
{
	guint8* result;
	guint8* res = NULL;
	gint res_length1;
	gint _res_size_;
	gint _tmp0_;
	gint _tmp1_;
	guint8* _tmp2_;
	gint _tmp2__length1;
	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;
	_tmp2__length1 = res_length1;
	if (result_length1) {
		*result_length1 = _tmp2__length1;
	}
	result = _tmp2_;
	return result;
}

GstTagList*
g4_parse_ogg_tags (GBufferedInputStream* stream,
                   GError** error)
{
	guint8* head = NULL;
	guint8* _tmp0_;
	gint head_length1;
	gint _head_size_;
	GMemoryOutputStream* mos = NULL;
	GReallocFunc _tmp1_;
	GDestroyNotify _tmp2_;
	GMemoryOutputStream* _tmp3_;
	GError* _inner_error0_ = NULL;
	GstTagList* result;
	g_return_val_if_fail (stream != NULL, NULL);
	_tmp0_ = g_new0 (guint8, 27);
	head = _tmp0_;
	head_length1 = 27;
	_head_size_ = head_length1;
	_tmp1_ = g_realloc;
	_tmp2_ = g_free;
	_tmp3_ = (GMemoryOutputStream*) g_memory_output_stream_new (NULL, 0, _tmp1_, _tmp2_);
	mos = _tmp3_;
	while (TRUE) {
		guint8* _tmp4_;
		gint _tmp4__length1;
		guint seg_count = 0U;
		guint8* _tmp5_;
		gint _tmp5__length1;
		guint8 _tmp6_;
		gboolean last_page = FALSE;
		gsize size = 0UL;
		gboolean _tmp21_ = FALSE;
		_tmp4_ = head;
		_tmp4__length1 = head_length1;
		g4_read_full (stream, _tmp4_, (gint) _tmp4__length1, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			g_propagate_error (error, _inner_error0_);
			_g_object_unref0 (mos);
			head = (g_free (head), NULL);
			return NULL;
		}
		_tmp5_ = head;
		_tmp5__length1 = head_length1;
		_tmp6_ = _tmp5_[26];
		seg_count = (guint) _tmp6_;
		last_page = seg_count == ((guint) 0);
		if (seg_count > ((guint) 0)) {
			guint8* segments = NULL;
			gint _tmp7_ = 0;
			guint8* _tmp8_;
			gint segments_length1;
			gint _segments_size_;
			guint8* _tmp9_;
			gint _tmp9__length1;
			guint page_size = 0U;
			guint8* buffer = NULL;
			gint _tmp14_ = 0;
			guint8* _tmp15_;
			gint buffer_length1;
			gint _buffer_size_;
			guint8* _tmp16_;
			gint _tmp16__length1;
			GMemoryOutputStream* _tmp17_;
			guint8* _tmp18_;
			gint _tmp18__length1;
			guint8* _tmp19_;
			gint _tmp19__length1;
			guint8 _tmp20_;
			_tmp8_ = g4_new_uint8_array (seg_count, &_tmp7_, &_inner_error0_);
			segments = _tmp8_;
			segments_length1 = _tmp7_;
			_segments_size_ = segments_length1;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				g_propagate_error (error, _inner_error0_);
				_g_object_unref0 (mos);
				head = (g_free (head), NULL);
				return NULL;
			}
			_tmp9_ = segments;
			_tmp9__length1 = segments_length1;
			g4_read_full (stream, _tmp9_, (gint) _tmp9__length1, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				g_propagate_error (error, _inner_error0_);
				segments = (g_free (segments), NULL);
				_g_object_unref0 (mos);
				head = (g_free (head), NULL);
				return NULL;
			}
			page_size = (guint) 0;
			{
				gint i = 0;
				i = 0;
				{
					gboolean _tmp10_ = FALSE;
					_tmp10_ = TRUE;
					while (TRUE) {
						guint8* _tmp12_;
						gint _tmp12__length1;
						guint8 _tmp13_;
						if (!_tmp10_) {
							gint _tmp11_;
							_tmp11_ = i;
							i = _tmp11_ + 1;
						}
						_tmp10_ = FALSE;
						if (!(((guint) i) < seg_count)) {
							break;
						}
						_tmp12_ = segments;
						_tmp12__length1 = segments_length1;
						_tmp13_ = _tmp12_[i];
						page_size += (guint) _tmp13_;
					}
				}
			}
			_tmp15_ = g4_new_uint8_array (page_size, &_tmp14_, &_inner_error0_);
			buffer = _tmp15_;
			buffer_length1 = _tmp14_;
			_buffer_size_ = buffer_length1;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				g_propagate_error (error, _inner_error0_);
				segments = (g_free (segments), NULL);
				_g_object_unref0 (mos);
				head = (g_free (head), NULL);
				return NULL;
			}
			_tmp16_ = buffer;
			_tmp16__length1 = buffer_length1;
			g4_read_full (stream, _tmp16_, (gint) _tmp16__length1, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				g_propagate_error (error, _inner_error0_);
				buffer = (g_free (buffer), NULL);
				segments = (g_free (segments), NULL);
				_g_object_unref0 (mos);
				head = (g_free (head), NULL);
				return NULL;
			}
			_tmp17_ = mos;
			_tmp18_ = buffer;
			_tmp18__length1 = buffer_length1;
			g_output_stream_write ((GOutputStream*) _tmp17_, _tmp18_, (gsize) _tmp18__length1, NULL, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				g_propagate_error (error, _inner_error0_);
				buffer = (g_free (buffer), NULL);
				segments = (g_free (segments), NULL);
				_g_object_unref0 (mos);
				head = (g_free (head), NULL);
				return NULL;
			}
			_tmp19_ = segments;
			_tmp19__length1 = segments_length1;
			_tmp20_ = _tmp19_[seg_count - 1];
			last_page = ((gint) _tmp20_) != 255;
			buffer = (g_free (buffer), NULL);
			segments = (g_free (segments), NULL);
		}
		size = (gsize) 0;
		if (last_page) {
			GMemoryOutputStream* _tmp22_;
			_tmp22_ = mos;
			size = g_memory_output_stream_get_data_size (_tmp22_);
			_tmp21_ = size > ((gsize) 0);
		} else {
			_tmp21_ = FALSE;
		}
		if (_tmp21_) {
			guint8* data = NULL;
			GMemoryOutputStream* _tmp23_;
			guint8* _tmp24_;
			guint8* _tmp25_;
			gint _tmp25__length1;
			gint data_length1;
			gint _data_size_;
			GReallocFunc _tmp41_;
			GDestroyNotify _tmp42_;
			GMemoryOutputStream* _tmp43_;
			_tmp23_ = mos;
			_tmp24_ = g_memory_output_stream_get_data (_tmp23_);
			_tmp25_ = (_tmp24_ != NULL) ? _vala_array_dup10 (_tmp24_ + 0, ((gint) size) - 0) : _tmp24_;
			_tmp25__length1 = ((gint) size) - 0;
			data = _tmp25_;
			data_length1 = _tmp25__length1;
			_data_size_ = data_length1;
			{
				const gchar** id_collection = NULL;
				gint id_collection_length1 = 0;
				gint _id_collection_size_ = 0;
				gint id_it = 0;
				id_collection = G4_OGG_TAG_IDS;
				id_collection_length1 = G_N_ELEMENTS (G4_OGG_TAG_IDS);
				for (id_it = 0; id_it < id_collection_length1; id_it = id_it + 1) {
					const gchar* id = NULL;
					id = id_collection[id_it];
					{
						gboolean _tmp26_ = FALSE;
						const gchar* _tmp27_;
						gint _tmp28_;
						gint _tmp29_;
						_tmp27_ = id;
						_tmp28_ = strlen (_tmp27_);
						_tmp29_ = _tmp28_;
						if (size > ((gsize) _tmp29_)) {
							guint8* _tmp30_;
							gint _tmp30__length1;
							const gchar* _tmp31_;
							const gchar* _tmp32_;
							gint _tmp33_;
							gint _tmp34_;
							_tmp30_ = data;
							_tmp30__length1 = data_length1;
							_tmp31_ = id;
							_tmp32_ = id;
							_tmp33_ = strlen (_tmp32_);
							_tmp34_ = _tmp33_;
							_tmp26_ = memcmp (_tmp30_, _tmp31_, (gsize) _tmp34_) == 0;
						} else {
							_tmp26_ = FALSE;
						}
						if (_tmp26_) {
							guint8* _tmp35_;
							gint _tmp35__length1;
							const gchar* _tmp36_;
							guint8* _tmp37_;
							gint _tmp37__length1;
							gint _tmp38_ = 0;
							guint8* _tmp39_;
							gint _tmp39__length1;
							GstTagList* _tmp40_;
							_tmp35_ = data;
							_tmp35__length1 = data_length1;
							_tmp36_ = id;
							_tmp37_ = string_get_data (_tmp36_, &_tmp38_);
							_tmp37__length1 = _tmp38_;
							_tmp39_ = _tmp37_;
							_tmp39__length1 = _tmp37__length1;
							_tmp40_ = gst_tag_list_from_vorbiscomment (_tmp35_, (gsize) _tmp35__length1, _tmp39_, (guint) _tmp39__length1, NULL);
							result = _tmp40_;
							data = (g_free (data), NULL);
							_g_object_unref0 (mos);
							head = (g_free (head), NULL);
							return result;
						}
					}
				}
			}
			_tmp41_ = g_realloc;
			_tmp42_ = g_free;
			_tmp43_ = (GMemoryOutputStream*) g_memory_output_stream_new (NULL, 0, _tmp41_, _tmp42_);
			_g_object_unref0 (mos);
			mos = _tmp43_;
			data = (g_free (data), NULL);
		}
		if (seg_count == ((guint) 0)) {
			break;
		}
	}
	result = NULL;
	_g_object_unref0 (mos);
	head = (g_free (head), NULL);
	return result;
}

static const gchar*
string_to_string (const gchar* self)
{
	const gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = self;
	return result;
}

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

static GstStateChangeReturn*
_gst_state_change_return_dup (GstStateChangeReturn* self)
{
	GstStateChangeReturn* dup;
	dup = g_new0 (GstStateChangeReturn, 1);
	memcpy (dup, self, sizeof (GstStateChangeReturn));
	return dup;
}

static gpointer
__gst_state_change_return_dup0 (gpointer self)
{
	return self ? _gst_state_change_return_dup (self) : NULL;
}

static gboolean
_gst_state_change_return_equal (const GstStateChangeReturn * s1,
                                const GstStateChangeReturn * s2)
{
	if (s1 == s2) {
		return TRUE;
	}
	if (s1 == NULL) {
		return FALSE;
	}
	if (s2 == NULL) {
		return FALSE;
	}
	return (*s1) == (*s2);
}

static gpointer
_gst_message_ref0 (gpointer self)
{
	return self ? gst_message_ref (self) : NULL;
}

GstTagList*
g4_parse_demux_tags (GBufferedInputStream* stream,
                     const gchar* demux_name,
                     GError** error)
{
	gchar* str = NULL;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	GstElement* _tmp2_ = NULL;
	const gchar* _tmp3_;
	GstElement* _tmp4_;
	GstPipeline* pipeline = NULL;
	GstPipeline* _tmp5_;
	GstPipeline* _tmp6_ = NULL;
	GstPipeline* _tmp7_;
	GstElement* _tmp8_ = NULL;
	GstElement* src = NULL;
	GstElement* _tmp10_;
	GstElement* _tmp11_;
	GstPipeline* _tmp12_ = NULL;
	GstPipeline* _tmp13_;
	GstStateChangeReturn* _tmp14_ = NULL;
	GstStateChangeReturn _tmp17_;
	GstPipeline* _tmp19_ = NULL;
	GstPipeline* _tmp20_;
	GstBus* _tmp21_ = NULL;
	GstBus* bus = NULL;
	GstBus* _tmp23_;
	gboolean quit = FALSE;
	GstTagList* tags = NULL;
	GstPipeline* _tmp51_ = NULL;
	GstPipeline* _tmp52_;
	GstStateChangeReturn* _tmp53_ = NULL;
	GError* _inner_error0_ = NULL;
	GstTagList* result;
	g_return_val_if_fail (stream != NULL, NULL);
	g_return_val_if_fail (demux_name != NULL, NULL);
	_tmp0_ = string_to_string (demux_name);
	_tmp1_ = g_strconcat ("giostreamsrc name=src ! ", _tmp0_, " ! fakesink sync=false", NULL);
	str = _tmp1_;
	_tmp3_ = str;
	_tmp4_ = gst_parse_launch_full (_tmp3_, NULL, GST_PARSE_FLAG_NONE, &_inner_error0_);
	if (_tmp4_ != NULL) {
		g_object_ref_sink (_tmp4_);
	}
	_tmp2_ = _tmp4_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_free0 (str);
		return NULL;
	}
	_tmp5_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp2_, gst_pipeline_get_type ()) ? ((GstPipeline*) _tmp2_) : NULL);
	pipeline = _tmp5_;
	_tmp7_ = pipeline;
	_tmp6_ = _tmp7_;
	_tmp8_ = NULL;
	if (_tmp6_ != NULL) {
		GstElement* _tmp9_;
		_tmp9_ = gst_bin_get_by_name ((GstBin*) G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, gst_pipeline_get_type (), GstPipeline), "src");
		_g_object_unref0 (_tmp8_);
		_tmp8_ = _tmp9_;
	}
	_tmp10_ = _tmp8_;
	_tmp8_ = NULL;
	src = _tmp10_;
	_tmp11_ = src;
	g_object_set (G_TYPE_CHECK_INSTANCE_CAST (_tmp11_, gst_element_get_type (), GstElement), "stream", stream, NULL);
	_tmp13_ = pipeline;
	_tmp12_ = _tmp13_;
	_tmp14_ = NULL;
	if (_tmp12_ != NULL) {
		GstStateChangeReturn _tmp15_;
		GstStateChangeReturn* _tmp16_;
		_tmp15_ = gst_element_set_state ((GstElement*) G_TYPE_CHECK_INSTANCE_CAST (_tmp12_, gst_pipeline_get_type (), GstPipeline), GST_STATE_PLAYING);
		_tmp16_ = __gst_state_change_return_dup0 (&_tmp15_);
		_g_free0 (_tmp14_);
		_tmp14_ = _tmp16_;
	}
	_tmp17_ = GST_STATE_CHANGE_FAILURE;
	if (_gst_state_change_return_equal (_tmp14_, &_tmp17_) == TRUE) {
		GError* _tmp18_;
		_tmp18_ = g_error_new_literal (G_URI_ERROR, G_URI_ERROR_FAILED, "change state failed");
		_inner_error0_ = _tmp18_;
		g_propagate_error (error, _inner_error0_);
		_g_free0 (_tmp14_);
		_g_object_unref0 (src);
		_g_object_unref0 (_tmp8_);
		_g_object_unref0 (pipeline);
		_g_object_unref0 (_tmp2_);
		_g_free0 (str);
		return NULL;
	}
	_tmp20_ = pipeline;
	_tmp19_ = _tmp20_;
	_tmp21_ = NULL;
	if (_tmp19_ != NULL) {
		GstBus* _tmp22_;
		_tmp22_ = gst_pipeline_get_bus (G_TYPE_CHECK_INSTANCE_CAST (_tmp19_, gst_pipeline_get_type (), GstPipeline));
		_g_object_unref0 (_tmp21_);
		_tmp21_ = _tmp22_;
	}
	_tmp23_ = _tmp21_;
	_tmp21_ = NULL;
	bus = _tmp23_;
	quit = FALSE;
	tags = NULL;
	{
		gboolean _tmp24_ = FALSE;
		_tmp24_ = TRUE;
		while (TRUE) {
			GstBus* _tmp25_ = NULL;
			GstBus* _tmp26_;
			GstMessage* _tmp27_ = NULL;
			GstMessage* message = NULL;
			GstMessage* _tmp29_;
			GstMessage* _tmp30_;
			GstMessage* msg = NULL;
			GstMessage* _tmp31_;
			GstMessage* _tmp32_;
			GstMessage* _tmp33_;
			if (!_tmp24_) {
				if (!(!quit)) {
					break;
				}
			}
			_tmp24_ = FALSE;
			_tmp26_ = bus;
			_tmp25_ = _tmp26_;
			_tmp27_ = NULL;
			if (_tmp25_ != NULL) {
				GstMessage* _tmp28_;
				_tmp28_ = gst_bus_timed_pop (G_TYPE_CHECK_INSTANCE_CAST (_tmp25_, gst_bus_get_type (), GstBus), (GstClockTime) (GST_SECOND * 5));
				_gst_message_unref0 (_tmp27_);
				_tmp27_ = _tmp28_;
			}
			_tmp29_ = _tmp27_;
			_tmp27_ = NULL;
			message = _tmp29_;
			_tmp30_ = message;
			if (_tmp30_ == NULL) {
				_gst_message_unref0 (message);
				_gst_message_unref0 (_tmp27_);
				break;
			}
			_tmp31_ = message;
			_tmp32_ = _gst_message_ref0 ((GstMessage*) _tmp31_);
			msg = _tmp32_;
			_tmp33_ = msg;
			switch (_tmp33_->type) {
				case GST_MESSAGE_TAG:
				{
					GstTagList* _tmp34_;
					gboolean _tmp42_ = FALSE;
					GstTagList* _tmp43_;
					_tmp34_ = tags;
					if (_tmp34_ != NULL) {
						GstTagList* tags2 = NULL;
						GstMessage* _tmp35_;
						GstTagList* _tmp36_ = NULL;
						GstTagList* _tmp37_;
						GstTagList* _tmp38_;
						GstTagList* _tmp39_;
						tags2 = NULL;
						_tmp35_ = msg;
						gst_message_parse_tag (_tmp35_, &_tmp36_);
						_gst_tag_list_unref0 (tags2);
						tags2 = _tmp36_;
						_tmp37_ = tags;
						_tmp38_ = tags2;
						_tmp39_ = g4_merge_tags (_tmp37_, _tmp38_, GST_TAG_MERGE_KEEP);
						_gst_tag_list_unref0 (tags);
						tags = _tmp39_;
						_gst_tag_list_unref0 (tags2);
					} else {
						GstMessage* _tmp40_;
						GstTagList* _tmp41_ = NULL;
						_tmp40_ = msg;
						gst_message_parse_tag (_tmp40_, &_tmp41_);
						_gst_tag_list_unref0 (tags);
						tags = _tmp41_;
					}
					_tmp43_ = tags;
					if (g4_tags_has_text (_tmp43_)) {
						_tmp42_ = TRUE;
					} else {
						GstTagList* _tmp44_;
						_tmp44_ = tags;
						_tmp42_ = g4_tags_has_image (_tmp44_);
					}
					if (_tmp42_) {
						quit = TRUE;
					}
					break;
				}
				case GST_MESSAGE_ERROR:
				{
					GError* err = NULL;
					gchar* debug = NULL;
					GstMessage* _tmp45_;
					GError* _tmp46_ = NULL;
					gchar* _tmp47_ = NULL;
					GError* _tmp48_;
					const gchar* _tmp49_;
					const gchar* _tmp50_;
					_tmp45_ = msg;
					gst_message_parse_error ((GstMessage*) _tmp45_, &_tmp46_, &_tmp47_);
					_g_error_free0 (err);
					err = _tmp46_;
					_g_free0 (debug);
					debug = _tmp47_;
					_tmp48_ = err;
					_tmp49_ = _tmp48_->message;
					_tmp50_ = debug;
					g_print ("Parse error: %s, %s\n", _tmp49_, _tmp50_);
					quit = TRUE;
					_g_free0 (debug);
					_g_error_free0 (err);
					break;
				}
				case GST_MESSAGE_EOS:
				{
					quit = TRUE;
					break;
				}
				default:
				{
					break;
				}
			}
			_gst_message_unref0 (msg);
			_gst_message_unref0 (message);
			_gst_message_unref0 (_tmp27_);
		}
	}
	_tmp52_ = pipeline;
	_tmp51_ = _tmp52_;
	_tmp53_ = NULL;
	if (_tmp51_ != NULL) {
		GstStateChangeReturn _tmp54_;
		GstStateChangeReturn* _tmp55_;
		_tmp54_ = gst_element_set_state ((GstElement*) G_TYPE_CHECK_INSTANCE_CAST (_tmp51_, gst_pipeline_get_type (), GstPipeline), GST_STATE_NULL);
		_tmp55_ = __gst_state_change_return_dup0 (&_tmp54_);
		_g_free0 (_tmp53_);
		_tmp53_ = _tmp55_;
	}
	result = tags;
	_g_free0 (_tmp53_);
	_g_object_unref0 (bus);
	_g_object_unref0 (_tmp21_);
	_g_free0 (_tmp14_);
	_g_object_unref0 (src);
	_g_object_unref0 (_tmp8_);
	_g_object_unref0 (pipeline);
	_g_object_unref0 (_tmp2_);
	_g_free0 (str);
	return result;
}

gchar*
g4_get_demux_name_by_content (guint8* head,
                              gint head_length1)
{
	guint8* p = NULL;
	gboolean _tmp0_ = FALSE;
	guint8* _tmp1_;
	gchar* result;
	p = head;
	_tmp1_ = p;
	if (memcmp (_tmp1_, "FORM", (gsize) 4) == 0) {
		gboolean _tmp2_ = FALSE;
		guint8* _tmp3_;
		_tmp3_ = p;
		if (memcmp (_tmp3_ + 8, "AIFF", (gsize) 4) == 0) {
			_tmp2_ = TRUE;
		} else {
			guint8* _tmp4_;
			_tmp4_ = p;
			_tmp2_ = memcmp (_tmp4_ + 8, "AIFC", (gsize) 4) == 0;
		}
		_tmp0_ = _tmp2_;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		gchar* _tmp5_;
		_tmp5_ = g_strdup ("aiffparse");
		result = _tmp5_;
		return result;
	} else {
		if (g4_read_uint32_be (head, (gint) head_length1, (guint) 0) == ((guint32) 0x1A45DFA3)) {
			gchar* _tmp6_;
			_tmp6_ = g_strdup ("matroskademux");
			result = _tmp6_;
			return result;
		} else {
			gboolean _tmp7_ = FALSE;
			guint8* _tmp8_;
			_tmp8_ = p;
			if (memcmp (_tmp8_, "RIFF", (gsize) 4) == 0) {
				guint8* _tmp9_;
				_tmp9_ = p;
				_tmp7_ = memcmp (_tmp9_ + 8, "WAVE", (gsize) 4) == 0;
			} else {
				_tmp7_ = FALSE;
			}
			if (_tmp7_) {
				gchar* _tmp10_;
				_tmp10_ = g_strdup ("wavparse");
				result = _tmp10_;
				return result;
			} else {
				guint8* _tmp11_;
				_tmp11_ = p;
				if (memcmp (_tmp11_, "\x30\x26\xB2\x75\x8E\x66\xCF\x11\xA6\xD9\x00\xAA\x00\x62\xCE\x6C", (gsize) 16) == 0) {
					gchar* _tmp12_;
					_tmp12_ = g_strdup ("asfparse");
					result = _tmp12_;
					return result;
				}
			}
		}
	}
	result = NULL;
	return result;
}

static GValue*
_g_value_dup (GValue* self)
{
	return g_boxed_copy (G_TYPE_VALUE, self);
}

static gpointer
__g_value_dup0 (gpointer self)
{
	return self ? _g_value_dup (self) : NULL;
}

static gchar*
double_to_string (gdouble self)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	gint _tmp1__length1;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* result;
	_tmp0_ = g_new0 (gchar, G_ASCII_DTOSTR_BUF_SIZE);
	_tmp1_ = _tmp0_;
	_tmp1__length1 = G_ASCII_DTOSTR_BUF_SIZE;
	_tmp2_ = g_ascii_dtostr (_tmp1_, (gint) G_ASCII_DTOSTR_BUF_SIZE, self);
	_tmp3_ = g_strdup (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp1_ = (g_free (_tmp1_), NULL);
	result = _tmp4_;
	return result;
}

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

static gpointer
_gst_date_time_ref0 (gpointer self)
{
	return self ? gst_date_time_ref (self) : NULL;
}

static void
_vala_GValue_free (GValue* self)
{
	g_boxed_free (G_TYPE_VALUE, self);
}

void
g4_get_one_tag (GstTagList* tags,
                const gchar* tag,
                GPtrArray* values)
{
	guint size = 0U;
	g_return_if_fail (tags != NULL);
	g_return_if_fail (tag != NULL);
	g_return_if_fail (values != NULL);
	size = gst_tag_list_get_tag_size (tags, tag);
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				GValue* val = NULL;
				GValue* _tmp2_;
				GValue* _tmp3_;
				if (!_tmp0_) {
					gint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				if (!(((guint) i) < size)) {
					break;
				}
				_tmp2_ = __g_value_dup0 (gst_tag_list_get_value_index (tags, tag, (guint) i));
				val = _tmp2_;
				_tmp3_ = val;
				if (((gpointer) _tmp3_) != NULL) {
					GValue value = {0};
					GValue* _tmp4_;
					GValue _tmp5_;
					GValue _tmp6_ = {0};
					_tmp4_ = val;
					_tmp5_ = (GValue) (*_tmp4_);
					if (G_IS_VALUE (&_tmp5_)) {
						g_value_init (&_tmp6_, G_VALUE_TYPE (&_tmp5_));
						g_value_copy (&_tmp5_, &_tmp6_);
					} else {
						_tmp6_ = _tmp5_;
					}
					value = _tmp6_;
					if (G_VALUE_HOLDS (&value, G_TYPE_STRING)) {
						const gchar* _tmp7_;
						gchar* _tmp8_;
						_tmp7_ = g_value_get_string (&value);
						_tmp8_ = g_strdup (_tmp7_);
						g_ptr_array_add (values, _tmp8_);
					} else {
						if (G_VALUE_HOLDS (&value, G_TYPE_UINT)) {
							gchar* _tmp9_;
							_tmp9_ = g_strdup_printf ("%u", g_value_get_uint (&value));
							g_ptr_array_add (values, _tmp9_);
						} else {
							if (G_VALUE_HOLDS (&value, G_TYPE_DOUBLE)) {
								gchar* _tmp10_;
								_tmp10_ = double_to_string (g_value_get_double (&value));
								g_ptr_array_add (values, _tmp10_);
							} else {
								if (G_VALUE_HOLDS (&value, G_TYPE_BOOLEAN)) {
									gchar* _tmp11_;
									_tmp11_ = bool_to_string (g_value_get_boolean (&value));
									g_ptr_array_add (values, _tmp11_);
								} else {
									if (G_VALUE_HOLDS (&value, gst_date_time_get_type ())) {
										GstDateTime* date = NULL;
										void* _tmp12_;
										GstDateTime* _tmp13_;
										gchar* _tmp14_ = NULL;
										GstDateTime* _tmp15_;
										gchar* _tmp16_;
										gchar* _tmp18_;
										_tmp12_ = g_value_get_boxed (&value);
										_tmp13_ = _gst_date_time_ref0 ((GstDateTime*) _tmp12_);
										date = _tmp13_;
										_tmp15_ = date;
										_tmp16_ = gst_date_time_to_iso8601_string (_tmp15_);
										_tmp14_ = _tmp16_;
										if (_tmp14_ == NULL) {
											gchar* _tmp17_;
											_tmp17_ = g_strdup ("");
											_g_free0 (_tmp14_);
											_tmp14_ = _tmp17_;
										}
										_tmp18_ = _tmp14_;
										_tmp14_ = NULL;
										g_ptr_array_add (values, (gchar*) _tmp18_);
										_g_free0 (_tmp14_);
										_gst_date_time_unref0 (date);
									}
								}
							}
						}
					}
					G_IS_VALUE (&value) ? (g_value_unset (&value), NULL) : NULL;
				}
				__vala_GValue_free0 (val);
			}
		}
	}
}

static GType*
_g_type_dup (GType* self)
{
	GType* dup;
	dup = g_new0 (GType, 1);
	memcpy (dup, self, sizeof (GType));
	return dup;
}

static gpointer
__g_type_dup0 (gpointer self)
{
	return self ? _g_type_dup (self) : NULL;
}

static gboolean
_g_type_equal (const GType * s1,
               const GType * s2)
{
	if (s1 == s2) {
		return TRUE;
	}
	if (s1 == NULL) {
		return FALSE;
	}
	if (s2 == NULL) {
		return FALSE;
	}
	return (*s1) == (*s2);
}

static gpointer
_gst_caps_ref0 (gpointer self)
{
	return self ? gst_caps_ref (self) : NULL;
}

GstSample*
g4_parse_image_from_tag_list (GstTagList* tags)
{
	GstSample* sample = NULL;
	GstSample* _tmp0_ = NULL;
	gboolean _tmp1_;
	GstSample* _tmp2_ = NULL;
	gboolean _tmp3_;
	GstSample* result;
	g_return_val_if_fail (tags != NULL, NULL);
	sample = NULL;
	_tmp1_ = gst_tag_list_get_sample (tags, GST_TAG_IMAGE, &_tmp0_);
	_gst_sample_unref0 (sample);
	sample = _tmp0_;
	if (_tmp1_) {
		result = sample;
		return result;
	}
	_tmp3_ = gst_tag_list_get_sample (tags, GST_TAG_PREVIEW_IMAGE, &_tmp2_);
	_gst_sample_unref0 (sample);
	sample = _tmp2_;
	if (_tmp3_) {
		result = sample;
		return result;
	}
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp4_ = FALSE;
			_tmp4_ = TRUE;
			while (TRUE) {
				gchar* tag = NULL;
				const gchar* _tmp6_;
				gchar* _tmp7_;
				GValue* value = NULL;
				const gchar* _tmp8_;
				GValue* _tmp9_;
				gboolean _tmp10_ = FALSE;
				GValue* _tmp11_ = NULL;
				GValue* _tmp12_;
				GType* _tmp13_ = NULL;
				GType _tmp17_;
				if (!_tmp4_) {
					gint _tmp5_;
					_tmp5_ = i;
					i = _tmp5_ + 1;
				}
				_tmp4_ = FALSE;
				if (!(i < gst_tag_list_n_tags (tags))) {
					break;
				}
				_tmp6_ = gst_tag_list_nth_tag_name (tags, (guint) i);
				_tmp7_ = g_strdup (_tmp6_);
				tag = _tmp7_;
				_tmp8_ = tag;
				_tmp9_ = __g_value_dup0 (gst_tag_list_get_value_index (tags, _tmp8_, (guint) 0));
				value = _tmp9_;
				_gst_sample_unref0 (sample);
				sample = NULL;
				_tmp12_ = value;
				_tmp11_ = _tmp12_;
				_tmp13_ = NULL;
				if (((gpointer) _tmp11_) != NULL) {
					GValue _tmp14_;
					GType _tmp15_;
					GType* _tmp16_;
					_tmp14_ = (GValue) (*_tmp11_);
					_tmp15_ = G_VALUE_TYPE (&_tmp14_);
					_tmp16_ = __g_type_dup0 (&_tmp15_);
					_g_free0 (_tmp13_);
					_tmp13_ = _tmp16_;
				}
				_tmp17_ = gst_sample_get_type ();
				if (_g_type_equal (_tmp13_, &_tmp17_) == TRUE) {
					const gchar* _tmp18_;
					GstSample* _tmp19_ = NULL;
					gboolean _tmp20_;
					_tmp18_ = tag;
					_tmp20_ = gst_tag_list_get_sample (tags, _tmp18_, &_tmp19_);
					_gst_sample_unref0 (sample);
					sample = _tmp19_;
					_tmp10_ = _tmp20_;
				} else {
					_tmp10_ = FALSE;
				}
				if (_tmp10_) {
					GstSample* _tmp21_ = NULL;
					GstSample* _tmp22_;
					GstCaps* _tmp23_ = NULL;
					GstCaps* caps = NULL;
					GstCaps* _tmp25_;
					GstCaps* _tmp26_;
					_tmp22_ = sample;
					_tmp21_ = _tmp22_;
					_tmp23_ = NULL;
					if (_tmp21_ != NULL) {
						GstCaps* _tmp24_;
						_tmp24_ = gst_sample_get_caps ((GstSample*) _tmp21_);
						_tmp23_ = _tmp24_;
					}
					_tmp25_ = _gst_caps_ref0 (_tmp23_);
					caps = _tmp25_;
					_tmp26_ = caps;
					if (_tmp26_ != NULL) {
						result = sample;
						_gst_caps_unref0 (caps);
						_g_free0 (_tmp13_);
						__vala_GValue_free0 (value);
						_g_free0 (tag);
						return result;
					}
					_gst_caps_unref0 (caps);
				}
				_g_free0 (_tmp13_);
				__vala_GValue_free0 (value);
				_g_free0 (tag);
			}
		}
	}
	result = NULL;
	_gst_sample_unref0 (sample);
	return result;
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

