/* extract-frames-post-processor.c generated by valac 0.56.17, the Vala compiler
 * generated from extract-frames-post-processor.vala, do not modify */

/*
Peek Copyright (c) 2017 by Philipp Wolfer <ph.wolfer@gmail.com>

This file is part of Peek.

This software is licensed under the GNU General Public License
(version 3 or later). See the LICENSE file in this distribution.
*/

#include "../../application.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gio/gio.h>
#include <glob.h>
#include <stdio.h>
#include <glib-object.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

enum  {
	PEEK_POST_PROCESSING_EXTRACT_FRAMES_POST_PROCESSOR_0_PROPERTY,
	PEEK_POST_PROCESSING_EXTRACT_FRAMES_POST_PROCESSOR_NUM_PROPERTIES
};
static GParamSpec* peek_post_processing_extract_frames_post_processor_properties[PEEK_POST_PROCESSING_EXTRACT_FRAMES_POST_PROCESSOR_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_array_unref0(var) ((var == NULL) ? NULL : (var = (g_array_unref (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _PeekPostProcessingExtractFramesPostProcessorProcessAsyncData PeekPostProcessingExtractFramesPostProcessorProcessAsyncData;
typedef struct _PeekPostProcessingExtractFramesPostProcessorRemoveOutputFilesData PeekPostProcessingExtractFramesPostProcessorRemoveOutputFilesData;

struct _PeekPostProcessingExtractFramesPostProcessorPrivate {
	gchar* executable;
};

struct _PeekPostProcessingExtractFramesPostProcessorProcessAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	PeekPostProcessingExtractFramesPostProcessor* self;
	GArray* files;
	GArray* result;
	GFile* input_file;
	GFile* _tmp0_;
	GFile* _tmp1_;
	gchar** args;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	GFile* _tmp5_;
	gchar* _tmp6_;
	GFile* _tmp7_;
	gchar* _tmp8_;
	gchar** _tmp9_;
	gint args_length1;
	gint _args_size_;
	gchar** _tmp10_;
	gint _tmp10__length1;
	GError* e;
	GFile* _tmp11_;
	GError* _tmp12_;
	GError* _tmp13_;
	GArray* output;
	GFile* _tmp14_;
	GArray* _tmp15_;
	GError* _inner_error0_;
};

struct _PeekPostProcessingExtractFramesPostProcessorRemoveOutputFilesData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GFile* input_file;
	GArray* output;
	GArray* _tmp0_;
	GArray* _tmp1_;
	gpointer* _tmp2_;
	gint _tmp2__length1;
	GFile** file_collection;
	gint file_collection_length1;
	gint _file_collection_size_;
	gint file_it;
	GFile* _tmp3_;
	GFile* file;
	GFile* _tmp4_;
	GError* e;
	FILE* _tmp5_;
	GFile* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	GError* _tmp9_;
	const gchar* _tmp10_;
	GError* _inner_error0_;
};

static gint PeekPostProcessingExtractFramesPostProcessor_private_offset;
static gpointer peek_post_processing_extract_frames_post_processor_parent_class = NULL;
static glob_t peek_post_processing_extract_frames_post_processor_glob;
static glob_t peek_post_processing_extract_frames_post_processor_glob = {0};

static void peek_post_processing_extract_frames_post_processor_real_process_async_data_free (gpointer _data);
static void peek_post_processing_extract_frames_post_processor_real_process_async (PeekPostProcessingCliPostProcessor* base,
                                                                            GArray* files,
                                                                            GAsyncReadyCallback _callback_,
                                                                            gpointer _user_data_);
static gboolean peek_post_processing_extract_frames_post_processor_real_process_async_co (PeekPostProcessingExtractFramesPostProcessorProcessAsyncData* _data_);
static gchar* peek_post_processing_extract_frames_post_processor_find_executable (PeekPostProcessingExtractFramesPostProcessor* self);
static gchar* peek_post_processing_extract_frames_post_processor_get_png_filename_pattern (GFile* input_file,
                                                                                    const gchar* replacement);
static void peek_post_processing_extract_frames_post_processor_process_async_ready (GObject* source_object,
                                                                             GAsyncResult* _res_,
                                                                             gpointer _user_data_);
static void peek_post_processing_extract_frames_post_processor_remove_output_files (GFile* input_file,
                                                                             GAsyncReadyCallback _callback_,
                                                                             gpointer _user_data_);
static void peek_post_processing_extract_frames_post_processor_remove_output_files_finish (GAsyncResult* _res_);
static void _g_object_unref0_ (gpointer var);
static void _vala_GFile_free_function_content_of (gpointer data);
static void peek_post_processing_extract_frames_post_processor_remove_output_files_data_free (gpointer _data);
static gboolean peek_post_processing_extract_frames_post_processor_remove_output_files_co (PeekPostProcessingExtractFramesPostProcessorRemoveOutputFilesData* _data_);
static void peek_post_processing_extract_frames_post_processor_remove_output_files_ready (GObject* source_object,
                                                                                   GAsyncResult* _res_,
                                                                                   gpointer _user_data_);
static void peek_post_processing_extract_frames_post_processor_finalize (GObject * obj);
static GType peek_post_processing_extract_frames_post_processor_get_type_once (void);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static gssize _vala_array_length (gpointer array);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
peek_post_processing_extract_frames_post_processor_get_instance_private (PeekPostProcessingExtractFramesPostProcessor* self)
{
	return G_STRUCT_MEMBER_P (self, PeekPostProcessingExtractFramesPostProcessor_private_offset);
}

static void
peek_post_processing_extract_frames_post_processor_real_process_async_data_free (gpointer _data)
{
	PeekPostProcessingExtractFramesPostProcessorProcessAsyncData* _data_;
	_data_ = _data;
	_g_array_unref0 (_data_->files);
	_g_array_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (PeekPostProcessingExtractFramesPostProcessorProcessAsyncData, _data_);
}

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

static gpointer
_g_array_ref0 (gpointer self)
{
	return self ? g_array_ref (self) : NULL;
}

static void
peek_post_processing_extract_frames_post_processor_real_process_async (PeekPostProcessingCliPostProcessor* base,
                                                                       GArray* files,
                                                                       GAsyncReadyCallback _callback_,
                                                                       gpointer _user_data_)
{
	PeekPostProcessingExtractFramesPostProcessor * self;
	PeekPostProcessingExtractFramesPostProcessorProcessAsyncData* _data_;
	PeekPostProcessingExtractFramesPostProcessor* _tmp0_;
	GArray* _tmp1_;
	g_return_if_fail (files != NULL);
	self = (PeekPostProcessingExtractFramesPostProcessor*) base;
	_data_ = g_slice_new0 (PeekPostProcessingExtractFramesPostProcessorProcessAsyncData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, peek_post_processing_extract_frames_post_processor_real_process_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_array_ref0 (files);
	_g_array_unref0 (_data_->files);
	_data_->files = _tmp1_;
	peek_post_processing_extract_frames_post_processor_real_process_async_co (_data_);
}

static GArray*
peek_post_processing_extract_frames_post_processor_process_finish (PeekPostProcessingCliPostProcessor* base,
                                                                   GAsyncResult* _res_,
                                                                   GError** error)
{
	GArray* result;
	PeekPostProcessingExtractFramesPostProcessorProcessAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return NULL;
	}
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static void
peek_post_processing_extract_frames_post_processor_process_async_ready (GObject* source_object,
                                                                        GAsyncResult* _res_,
                                                                        gpointer _user_data_)
{
	PeekPostProcessingExtractFramesPostProcessorProcessAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	peek_post_processing_extract_frames_post_processor_real_process_async_co (_data_);
}

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

static gboolean
peek_post_processing_extract_frames_post_processor_real_process_async_co (PeekPostProcessingExtractFramesPostProcessorProcessAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = g_array_index (_data_->files, GFile*, (guint) 0);
	_data_->_tmp1_ = _g_object_ref0 (_data_->_tmp0_);
	_data_->input_file = _data_->_tmp1_;
	_data_->_tmp2_ = peek_post_processing_extract_frames_post_processor_find_executable (_data_->self);
	_data_->_tmp3_ = g_strdup ("-y");
	_data_->_tmp4_ = g_strdup ("-i");
	_data_->_tmp5_ = _data_->input_file;
	_data_->_tmp6_ = g_file_get_path (_data_->_tmp5_);
	_data_->_tmp7_ = _data_->input_file;
	_data_->_tmp8_ = peek_post_processing_extract_frames_post_processor_get_png_filename_pattern (_data_->_tmp7_, "%04d");
	_data_->_tmp9_ = g_new0 (gchar*, 5 + 1);
	_data_->_tmp9_[0] = _data_->_tmp2_;
	_data_->_tmp9_[1] = _data_->_tmp3_;
	_data_->_tmp9_[2] = _data_->_tmp4_;
	_data_->_tmp9_[3] = _data_->_tmp6_;
	_data_->_tmp9_[4] = _data_->_tmp8_;
	_data_->args = _data_->_tmp9_;
	_data_->args_length1 = 5;
	_data_->_args_size_ = _data_->args_length1;
	{
		_data_->_tmp10_ = _data_->args;
		_data_->_tmp10__length1 = _data_->args_length1;
		_data_->_state_ = 1;
		peek_post_processing_cli_post_processor_spawn_command_async ((PeekPostProcessingCliPostProcessor*) _data_->self, _data_->_tmp10_, (gint) _data_->_tmp10__length1, peek_post_processing_extract_frames_post_processor_process_async_ready, _data_);
		return FALSE;
		_state_1:
		peek_post_processing_cli_post_processor_spawn_command_finish ((PeekPostProcessingCliPostProcessor*) _data_->self, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			if (_data_->_inner_error0_->domain == PEEK_RECORDING_ERROR) {
				goto __catch0_peek_recording_error;
			}
			_data_->args = (_vala_array_free (_data_->args, _data_->args_length1, (GDestroyNotify) g_free), NULL);
			_g_object_unref0 (_data_->input_file);
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
			g_clear_error (&_data_->_inner_error0_);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
	}
	goto __finally0;
	__catch0_peek_recording_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp11_ = _data_->input_file;
		_data_->_state_ = 2;
		peek_post_processing_extract_frames_post_processor_remove_output_files (_data_->_tmp11_, peek_post_processing_extract_frames_post_processor_process_async_ready, _data_);
		return FALSE;
		_state_2:
		peek_post_processing_extract_frames_post_processor_remove_output_files_finish (_data_->_res_);
		_data_->_tmp12_ = _data_->e;
		_data_->_tmp13_ = _g_error_copy0 (_data_->_tmp12_);
		_data_->_inner_error0_ = _data_->_tmp13_;
		_g_error_free0 (_data_->e);
		goto __finally0;
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		if (_data_->_inner_error0_->domain == PEEK_RECORDING_ERROR) {
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_data_->args = (_vala_array_free (_data_->args, _data_->args_length1, (GDestroyNotify) g_free), NULL);
			_g_object_unref0 (_data_->input_file);
			g_object_unref (_data_->_async_result);
			return FALSE;
		} else {
			_data_->args = (_vala_array_free (_data_->args, _data_->args_length1, (GDestroyNotify) g_free), NULL);
			_g_object_unref0 (_data_->input_file);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
			g_clear_error (&_data_->_inner_error0_);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
	}
	_data_->_tmp14_ = _data_->input_file;
	_data_->_tmp15_ = peek_post_processing_extract_frames_post_processor_get_png_output_files (_data_->_tmp14_);
	_data_->output = _data_->_tmp15_;
	_data_->result = _data_->output;
	_data_->args = (_vala_array_free (_data_->args, _data_->args_length1, (GDestroyNotify) g_free), NULL);
	_g_object_unref0 (_data_->input_file);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static gchar*
peek_post_processing_extract_frames_post_processor_get_png_filename_pattern (GFile* input_file,
                                                                             const gchar* replacement)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* result;
	g_return_val_if_fail (input_file != NULL, NULL);
	g_return_val_if_fail (replacement != NULL, NULL);
	_tmp0_ = g_file_get_path (input_file);
	_tmp1_ = _tmp0_;
	_tmp2_ = g_strconcat (_tmp1_, ".", NULL);
	_tmp3_ = _tmp2_;
	_tmp4_ = g_strconcat (_tmp3_, replacement, NULL);
	_tmp5_ = _tmp4_;
	_tmp6_ = g_strconcat (_tmp5_, ".png", NULL);
	_tmp7_ = _tmp6_;
	_g_free0 (_tmp5_);
	_g_free0 (_tmp3_);
	_g_free0 (_tmp1_);
	result = _tmp7_;
	return result;
}

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

static void
_vala_GFile_free_function_content_of (gpointer data)
{
	GFile* self;
	self = *((GFile**) data);
	_g_object_unref0_ (self);
}

GArray*
peek_post_processing_extract_frames_post_processor_get_png_output_files (GFile* input_file)
{
	gchar* png_file_pattern = NULL;
	gchar* _tmp0_;
	const gchar* _tmp1_;
	GArray* output = NULL;
	GArray* _tmp2_;
	glob_t _tmp3_;
	gchar** _tmp4_;
	gint _tmp4__length1;
	GArray* result;
	g_return_val_if_fail (input_file != NULL, NULL);
	_tmp0_ = peek_post_processing_extract_frames_post_processor_get_png_filename_pattern (input_file, "*");
	png_file_pattern = _tmp0_;
	_tmp1_ = png_file_pattern;
	glob (_tmp1_, 0, NULL, &peek_post_processing_extract_frames_post_processor_glob);
	_tmp2_ = g_array_new (TRUE, TRUE, sizeof (GFile*));
	g_array_set_clear_func (_tmp2_, (GDestroyNotify) _vala_GFile_free_function_content_of);
	output = _tmp2_;
	_tmp3_ = peek_post_processing_extract_frames_post_processor_glob;
	_tmp4_ = _tmp3_.gl_pathv;
	_tmp4__length1 = _vala_array_length (_tmp3_.gl_pathv);
	{
		gchar** png_file_path_collection = NULL;
		gint png_file_path_collection_length1 = 0;
		gint _png_file_path_collection_size_ = 0;
		gint png_file_path_it = 0;
		png_file_path_collection = _tmp4_;
		png_file_path_collection_length1 = _tmp4__length1;
		for (png_file_path_it = 0; png_file_path_it < png_file_path_collection_length1; png_file_path_it = png_file_path_it + 1) {
			gchar* _tmp5_;
			gchar* png_file_path = NULL;
			_tmp5_ = g_strdup (png_file_path_collection[png_file_path_it]);
			png_file_path = _tmp5_;
			{
				GFile* file = NULL;
				const gchar* _tmp6_;
				GFile* _tmp7_;
				GArray* _tmp8_;
				GFile* _tmp9_;
				GFile* _tmp10_;
				_tmp6_ = png_file_path;
				_tmp7_ = g_file_new_for_path (_tmp6_);
				file = _tmp7_;
				_tmp8_ = output;
				_tmp9_ = file;
				_tmp10_ = _g_object_ref0 (_tmp9_);
				g_array_append_val (_tmp8_, _tmp10_);
				_g_object_unref0 (file);
				_g_free0 (png_file_path);
			}
		}
	}
	result = output;
	_g_free0 (png_file_pattern);
	return result;
}

static void
peek_post_processing_extract_frames_post_processor_remove_output_files_data_free (gpointer _data)
{
	PeekPostProcessingExtractFramesPostProcessorRemoveOutputFilesData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->input_file);
	g_slice_free (PeekPostProcessingExtractFramesPostProcessorRemoveOutputFilesData, _data_);
}

static void
peek_post_processing_extract_frames_post_processor_remove_output_files (GFile* input_file,
                                                                        GAsyncReadyCallback _callback_,
                                                                        gpointer _user_data_)
{
	PeekPostProcessingExtractFramesPostProcessorRemoveOutputFilesData* _data_;
	GFile* _tmp0_;
	g_return_if_fail (input_file != NULL);
	_data_ = g_slice_new0 (PeekPostProcessingExtractFramesPostProcessorRemoveOutputFilesData);
	_data_->_async_result = g_task_new (NULL, NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, peek_post_processing_extract_frames_post_processor_remove_output_files_data_free);
	_tmp0_ = _g_object_ref0 (input_file);
	_g_object_unref0 (_data_->input_file);
	_data_->input_file = _tmp0_;
	peek_post_processing_extract_frames_post_processor_remove_output_files_co (_data_);
}

static void
peek_post_processing_extract_frames_post_processor_remove_output_files_finish (GAsyncResult* _res_)
{
	PeekPostProcessingExtractFramesPostProcessorRemoveOutputFilesData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
peek_post_processing_extract_frames_post_processor_remove_output_files_ready (GObject* source_object,
                                                                              GAsyncResult* _res_,
                                                                              gpointer _user_data_)
{
	PeekPostProcessingExtractFramesPostProcessorRemoveOutputFilesData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	peek_post_processing_extract_frames_post_processor_remove_output_files_co (_data_);
}

static gboolean
peek_post_processing_extract_frames_post_processor_remove_output_files_co (PeekPostProcessingExtractFramesPostProcessorRemoveOutputFilesData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = peek_post_processing_extract_frames_post_processor_get_png_output_files (_data_->input_file);
	_data_->output = _data_->_tmp0_;
	_data_->_tmp1_ = _data_->output;
	_data_->_tmp2_ = _data_->_tmp1_->data;
	_data_->_tmp2__length1 = _data_->_tmp1_->len;
	{
		_data_->file_collection_length1 = 0;
		_data_->_file_collection_size_ = 0;
		_data_->file_collection = _data_->_tmp2_;
		_data_->file_collection_length1 = _data_->_tmp2__length1;
		for (_data_->file_it = 0; _data_->file_it < _data_->file_collection_length1; _data_->file_it = _data_->file_it + 1) {
			_data_->_tmp3_ = _g_object_ref0 (_data_->file_collection[_data_->file_it]);
			_data_->file = _data_->_tmp3_;
			{
				{
					_data_->_tmp4_ = _data_->file;
					_data_->_state_ = 1;
					g_file_delete_async (_data_->_tmp4_, G_PRIORITY_DEFAULT, NULL, peek_post_processing_extract_frames_post_processor_remove_output_files_ready, _data_);
					return FALSE;
					_state_1:
					g_file_delete_finish (_data_->_tmp4_, _data_->_res_, &_data_->_inner_error0_);
					if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
						goto __catch0_g_error;
					}
				}
				goto __finally0;
				__catch0_g_error:
				{
					_data_->e = _data_->_inner_error0_;
					_data_->_inner_error0_ = NULL;
					_data_->_tmp5_ = stderr;
					_data_->_tmp6_ = _data_->file;
					_data_->_tmp7_ = g_file_get_path (_data_->_tmp6_);
					_data_->_tmp8_ = _data_->_tmp7_;
					_data_->_tmp9_ = _data_->e;
					_data_->_tmp10_ = _data_->_tmp9_->message;
					fprintf (_data_->_tmp5_, "Error deleting temporary file %s: %s\n", _data_->_tmp8_, _data_->_tmp10_);
					_g_free0 (_data_->_tmp8_);
					_g_error_free0 (_data_->e);
				}
				__finally0:
				if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
					_g_object_unref0 (_data_->file);
					_g_array_unref0 (_data_->output);
					g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
					g_clear_error (&_data_->_inner_error0_);
					g_object_unref (_data_->_async_result);
					return FALSE;
				}
				_g_object_unref0 (_data_->file);
			}
		}
	}
	_g_array_unref0 (_data_->output);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static gchar*
peek_post_processing_extract_frames_post_processor_find_executable (PeekPostProcessingExtractFramesPostProcessor* self)
{
	const gchar* _tmp0_;
	const gchar* _tmp9_;
	const gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->executable;
	if (_tmp0_ == NULL) {
		gchar** tools = NULL;
		gchar* _tmp1_;
		gchar* _tmp2_;
		gchar** _tmp3_;
		gint tools_length1;
		gint _tools_size_;
		gchar** _tmp4_;
		gint _tmp4__length1;
		_tmp1_ = g_strdup ("ffmpeg");
		_tmp2_ = g_strdup ("avconv");
		_tmp3_ = g_new0 (gchar*, 2 + 1);
		_tmp3_[0] = _tmp1_;
		_tmp3_[1] = _tmp2_;
		tools = _tmp3_;
		tools_length1 = 2;
		_tools_size_ = tools_length1;
		_tmp4_ = tools;
		_tmp4__length1 = tools_length1;
		{
			gchar** tool_collection = NULL;
			gint tool_collection_length1 = 0;
			gint _tool_collection_size_ = 0;
			gint tool_it = 0;
			tool_collection = _tmp4_;
			tool_collection_length1 = _tmp4__length1;
			for (tool_it = 0; tool_it < tool_collection_length1; tool_it = tool_it + 1) {
				gchar* _tmp5_;
				gchar* tool = NULL;
				_tmp5_ = g_strdup (tool_collection[tool_it]);
				tool = _tmp5_;
				{
					const gchar* _tmp6_;
					_tmp6_ = tool;
					if (peek_utils_check_for_executable (_tmp6_)) {
						const gchar* _tmp7_;
						gchar* _tmp8_;
						_tmp7_ = tool;
						_tmp8_ = g_strdup (_tmp7_);
						_g_free0 (self->priv->executable);
						self->priv->executable = _tmp8_;
						_g_free0 (tool);
						break;
					}
					_g_free0 (tool);
				}
			}
		}
		tools = (_vala_array_free (tools, tools_length1, (GDestroyNotify) g_free), NULL);
	}
	_tmp9_ = self->priv->executable;
	g_debug ("extract-frames-post-processor.vala:76: ExtractFramesPostProcessor uses" \
" %s", _tmp9_);
	_tmp10_ = self->priv->executable;
	_tmp11_ = g_strdup (_tmp10_);
	result = _tmp11_;
	return result;
}

PeekPostProcessingExtractFramesPostProcessor*
peek_post_processing_extract_frames_post_processor_construct (GType object_type)
{
	PeekPostProcessingExtractFramesPostProcessor * self = NULL;
	self = (PeekPostProcessingExtractFramesPostProcessor*) peek_post_processing_cli_post_processor_construct (object_type);
	return self;
}

PeekPostProcessingExtractFramesPostProcessor*
peek_post_processing_extract_frames_post_processor_new (void)
{
	return peek_post_processing_extract_frames_post_processor_construct (PEEK_POST_PROCESSING_TYPE_EXTRACT_FRAMES_POST_PROCESSOR);
}

static void
peek_post_processing_extract_frames_post_processor_class_init (PeekPostProcessingExtractFramesPostProcessorClass * klass,
                                                               gpointer klass_data)
{
	peek_post_processing_extract_frames_post_processor_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &PeekPostProcessingExtractFramesPostProcessor_private_offset);
	((PeekPostProcessingCliPostProcessorClass *) klass)->process_async = (void (*) (PeekPostProcessingCliPostProcessor*, GArray*, GAsyncReadyCallback, gpointer)) peek_post_processing_extract_frames_post_processor_real_process_async;
	((PeekPostProcessingCliPostProcessorClass *) klass)->process_finish = (GArray* (*) (PeekPostProcessingCliPostProcessor*, GAsyncResult*, GError**)) peek_post_processing_extract_frames_post_processor_process_finish;
	G_OBJECT_CLASS (klass)->finalize = peek_post_processing_extract_frames_post_processor_finalize;
	memset (&peek_post_processing_extract_frames_post_processor_glob, 0, sizeof (glob_t));
	peek_post_processing_extract_frames_post_processor_glob = peek_post_processing_extract_frames_post_processor_glob;
}

static void
peek_post_processing_extract_frames_post_processor_instance_init (PeekPostProcessingExtractFramesPostProcessor * self,
                                                                  gpointer klass)
{
	self->priv = peek_post_processing_extract_frames_post_processor_get_instance_private (self);
	self->priv->executable = NULL;
}

static void
peek_post_processing_extract_frames_post_processor_finalize (GObject * obj)
{
	PeekPostProcessingExtractFramesPostProcessor * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PEEK_POST_PROCESSING_TYPE_EXTRACT_FRAMES_POST_PROCESSOR, PeekPostProcessingExtractFramesPostProcessor);
	_g_free0 (self->priv->executable);
	G_OBJECT_CLASS (peek_post_processing_extract_frames_post_processor_parent_class)->finalize (obj);
}

/**
  * Uses ffmpeg to generate PNG images for each frame.
  */
static GType
peek_post_processing_extract_frames_post_processor_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (PeekPostProcessingExtractFramesPostProcessorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) peek_post_processing_extract_frames_post_processor_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (PeekPostProcessingExtractFramesPostProcessor), 0, (GInstanceInitFunc) peek_post_processing_extract_frames_post_processor_instance_init, NULL };
	GType peek_post_processing_extract_frames_post_processor_type_id;
	peek_post_processing_extract_frames_post_processor_type_id = g_type_register_static (PEEK_POST_PROCESSING_TYPE_CLI_POST_PROCESSOR, "PeekPostProcessingExtractFramesPostProcessor", &g_define_type_info, 0);
	PeekPostProcessingExtractFramesPostProcessor_private_offset = g_type_add_instance_private (peek_post_processing_extract_frames_post_processor_type_id, sizeof (PeekPostProcessingExtractFramesPostProcessorPrivate));
	return peek_post_processing_extract_frames_post_processor_type_id;
}

GType
peek_post_processing_extract_frames_post_processor_get_type (void)
{
	static volatile gsize peek_post_processing_extract_frames_post_processor_type_id__once = 0;
	if (g_once_init_enter (&peek_post_processing_extract_frames_post_processor_type_id__once)) {
		GType peek_post_processing_extract_frames_post_processor_type_id;
		peek_post_processing_extract_frames_post_processor_type_id = peek_post_processing_extract_frames_post_processor_get_type_once ();
		g_once_init_leave (&peek_post_processing_extract_frames_post_processor_type_id__once, peek_post_processing_extract_frames_post_processor_type_id);
	}
	return peek_post_processing_extract_frames_post_processor_type_id__once;
}

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

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

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

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;
}

