Initial commit
[fillmore] / src / marina / marina / import.c
1 /* import.c generated by valac, the Vala compiler
2  * generated from import.vala, do not modify */
3
4 /* Copyright 2009-2010 Yorba Foundation
5  *
6  * This software is licensed under the GNU Lesser General Public License
7  * (version 2.1 or later).  See the COPYING file in this distribution. 
8  */
9
10 #include <glib.h>
11 #include <glib-object.h>
12 #include <stdlib.h>
13 #include <string.h>
14 #include <gst/gst.h>
15 #include <gee.h>
16 #include <float.h>
17 #include <math.h>
18 #include <gdk-pixbuf/gdk-pixdata.h>
19 #include <glib/gstdio.h>
20
21
22 #define TYPE_MULTI_FILE_PROGRESS_INTERFACE (multi_file_progress_interface_get_type ())
23 #define MULTI_FILE_PROGRESS_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MULTI_FILE_PROGRESS_INTERFACE, MultiFileProgressInterface))
24 #define IS_MULTI_FILE_PROGRESS_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MULTI_FILE_PROGRESS_INTERFACE))
25 #define MULTI_FILE_PROGRESS_INTERFACE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TYPE_MULTI_FILE_PROGRESS_INTERFACE, MultiFileProgressInterfaceIface))
26
27 typedef struct _MultiFileProgressInterface MultiFileProgressInterface;
28 typedef struct _MultiFileProgressInterfaceIface MultiFileProgressInterfaceIface;
29
30 #define MODEL_TYPE_CLIP_IMPORTER (model_clip_importer_get_type ())
31 #define MODEL_CLIP_IMPORTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MODEL_TYPE_CLIP_IMPORTER, ModelClipImporter))
32 #define MODEL_CLIP_IMPORTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MODEL_TYPE_CLIP_IMPORTER, ModelClipImporterClass))
33 #define MODEL_IS_CLIP_IMPORTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MODEL_TYPE_CLIP_IMPORTER))
34 #define MODEL_IS_CLIP_IMPORTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MODEL_TYPE_CLIP_IMPORTER))
35 #define MODEL_CLIP_IMPORTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MODEL_TYPE_CLIP_IMPORTER, ModelClipImporterClass))
36
37 typedef struct _ModelClipImporter ModelClipImporter;
38 typedef struct _ModelClipImporterClass ModelClipImporterClass;
39 typedef struct _ModelClipImporterPrivate ModelClipImporterPrivate;
40
41 #define MODEL_CLIP_IMPORTER_TYPE_IMPORT_STATE (model_clip_importer_import_state_get_type ())
42
43 #define MODEL_TYPE_FETCHER (model_fetcher_get_type ())
44 #define MODEL_FETCHER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MODEL_TYPE_FETCHER, ModelFetcher))
45 #define MODEL_FETCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MODEL_TYPE_FETCHER, ModelFetcherClass))
46 #define MODEL_IS_FETCHER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MODEL_TYPE_FETCHER))
47 #define MODEL_IS_FETCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MODEL_TYPE_FETCHER))
48 #define MODEL_FETCHER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MODEL_TYPE_FETCHER, ModelFetcherClass))
49
50 typedef struct _ModelFetcher ModelFetcher;
51 typedef struct _ModelFetcherClass ModelFetcherClass;
52
53 #define MODEL_TYPE_CLIP_FETCHER (model_clip_fetcher_get_type ())
54 #define MODEL_CLIP_FETCHER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MODEL_TYPE_CLIP_FETCHER, ModelClipFetcher))
55 #define MODEL_CLIP_FETCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MODEL_TYPE_CLIP_FETCHER, ModelClipFetcherClass))
56 #define MODEL_IS_CLIP_FETCHER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MODEL_TYPE_CLIP_FETCHER))
57 #define MODEL_IS_CLIP_FETCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MODEL_TYPE_CLIP_FETCHER))
58 #define MODEL_CLIP_FETCHER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MODEL_TYPE_CLIP_FETCHER, ModelClipFetcherClass))
59
60 typedef struct _ModelClipFetcher ModelClipFetcher;
61 typedef struct _ModelClipFetcherClass ModelClipFetcherClass;
62 #define _g_free0(var) (var = (g_free (var), NULL))
63 #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
64 #define _gst_object_unref0(var) ((var == NULL) ? NULL : (var = (gst_object_unref (var), NULL)))
65
66 #define LOGGING_TYPE_FACILITY (logging_facility_get_type ())
67
68 #define LOGGING_TYPE_LEVEL (logging_level_get_type ())
69 typedef struct _ModelFetcherPrivate ModelFetcherPrivate;
70
71 #define MODEL_TYPE_CLIP_FILE (model_clip_file_get_type ())
72 #define MODEL_CLIP_FILE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MODEL_TYPE_CLIP_FILE, ModelClipFile))
73 #define MODEL_CLIP_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MODEL_TYPE_CLIP_FILE, ModelClipFileClass))
74 #define MODEL_IS_CLIP_FILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MODEL_TYPE_CLIP_FILE))
75 #define MODEL_IS_CLIP_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MODEL_TYPE_CLIP_FILE))
76 #define MODEL_CLIP_FILE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MODEL_TYPE_CLIP_FILE, ModelClipFileClass))
77
78 typedef struct _ModelClipFile ModelClipFile;
79 typedef struct _ModelClipFileClass ModelClipFileClass;
80 typedef struct _ModelClipFilePrivate ModelClipFilePrivate;
81 #define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
82
83 #define MODEL_TYPE_MEDIA_TYPE (model_media_type_get_type ())
84
85 #define TYPE_SINGLE_DECODE_BIN (single_decode_bin_get_type ())
86 #define SINGLE_DECODE_BIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_SINGLE_DECODE_BIN, SingleDecodeBin))
87 #define SINGLE_DECODE_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_SINGLE_DECODE_BIN, SingleDecodeBinClass))
88 #define IS_SINGLE_DECODE_BIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_SINGLE_DECODE_BIN))
89 #define IS_SINGLE_DECODE_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_SINGLE_DECODE_BIN))
90 #define SINGLE_DECODE_BIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_SINGLE_DECODE_BIN, SingleDecodeBinClass))
91
92 typedef struct _SingleDecodeBin SingleDecodeBin;
93 typedef struct _SingleDecodeBinClass SingleDecodeBinClass;
94 #define _gst_caps_unref0(var) ((var == NULL) ? NULL : (var = (gst_caps_unref (var), NULL)))
95
96 #define MODEL_TYPE_LIBRARY_IMPORTER (model_library_importer_get_type ())
97 #define MODEL_LIBRARY_IMPORTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MODEL_TYPE_LIBRARY_IMPORTER, ModelLibraryImporter))
98 #define MODEL_LIBRARY_IMPORTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MODEL_TYPE_LIBRARY_IMPORTER, ModelLibraryImporterClass))
99 #define MODEL_IS_LIBRARY_IMPORTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MODEL_TYPE_LIBRARY_IMPORTER))
100 #define MODEL_IS_LIBRARY_IMPORTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MODEL_TYPE_LIBRARY_IMPORTER))
101 #define MODEL_LIBRARY_IMPORTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MODEL_TYPE_LIBRARY_IMPORTER, ModelLibraryImporterClass))
102
103 typedef struct _ModelLibraryImporter ModelLibraryImporter;
104 typedef struct _ModelLibraryImporterClass ModelLibraryImporterClass;
105 typedef struct _ModelLibraryImporterPrivate ModelLibraryImporterPrivate;
106
107 #define MODEL_TYPE_PROJECT (model_project_get_type ())
108 #define MODEL_PROJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MODEL_TYPE_PROJECT, ModelProject))
109 #define MODEL_PROJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MODEL_TYPE_PROJECT, ModelProjectClass))
110 #define MODEL_IS_PROJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MODEL_TYPE_PROJECT))
111 #define MODEL_IS_PROJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MODEL_TYPE_PROJECT))
112 #define MODEL_PROJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MODEL_TYPE_PROJECT, ModelProjectClass))
113
114 typedef struct _ModelProject ModelProject;
115 typedef struct _ModelProjectClass ModelProjectClass;
116
117 #define MODEL_TYPE_TIMELINE_IMPORTER (model_timeline_importer_get_type ())
118 #define MODEL_TIMELINE_IMPORTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MODEL_TYPE_TIMELINE_IMPORTER, ModelTimelineImporter))
119 #define MODEL_TIMELINE_IMPORTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MODEL_TYPE_TIMELINE_IMPORTER, ModelTimelineImporterClass))
120 #define MODEL_IS_TIMELINE_IMPORTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MODEL_TYPE_TIMELINE_IMPORTER))
121 #define MODEL_IS_TIMELINE_IMPORTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MODEL_TYPE_TIMELINE_IMPORTER))
122 #define MODEL_TIMELINE_IMPORTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MODEL_TYPE_TIMELINE_IMPORTER, ModelTimelineImporterClass))
123
124 typedef struct _ModelTimelineImporter ModelTimelineImporter;
125 typedef struct _ModelTimelineImporterClass ModelTimelineImporterClass;
126 typedef struct _ModelTimelineImporterPrivate ModelTimelineImporterPrivate;
127
128 #define MODEL_TYPE_TRACK (model_track_get_type ())
129 #define MODEL_TRACK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MODEL_TYPE_TRACK, ModelTrack))
130 #define MODEL_TRACK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MODEL_TYPE_TRACK, ModelTrackClass))
131 #define MODEL_IS_TRACK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MODEL_TYPE_TRACK))
132 #define MODEL_IS_TRACK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MODEL_TYPE_TRACK))
133 #define MODEL_TRACK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MODEL_TYPE_TRACK, ModelTrackClass))
134
135 typedef struct _ModelTrack ModelTrack;
136 typedef struct _ModelTrackClass ModelTrackClass;
137
138 #define MODEL_TYPE_VIDEO_TRACK (model_video_track_get_type ())
139 #define MODEL_VIDEO_TRACK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MODEL_TYPE_VIDEO_TRACK, ModelVideoTrack))
140 #define MODEL_VIDEO_TRACK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MODEL_TYPE_VIDEO_TRACK, ModelVideoTrackClass))
141 #define MODEL_IS_VIDEO_TRACK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MODEL_TYPE_VIDEO_TRACK))
142 #define MODEL_IS_VIDEO_TRACK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MODEL_TYPE_VIDEO_TRACK))
143 #define MODEL_VIDEO_TRACK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MODEL_TYPE_VIDEO_TRACK, ModelVideoTrackClass))
144
145 typedef struct _ModelVideoTrack ModelVideoTrack;
146 typedef struct _ModelVideoTrackClass ModelVideoTrackClass;
147
148 #define MODEL_TYPE_AUDIO_TRACK (model_audio_track_get_type ())
149 #define MODEL_AUDIO_TRACK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MODEL_TYPE_AUDIO_TRACK, ModelAudioTrack))
150 #define MODEL_AUDIO_TRACK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MODEL_TYPE_AUDIO_TRACK, ModelAudioTrackClass))
151 #define MODEL_IS_AUDIO_TRACK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MODEL_TYPE_AUDIO_TRACK))
152 #define MODEL_IS_AUDIO_TRACK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MODEL_TYPE_AUDIO_TRACK))
153 #define MODEL_AUDIO_TRACK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MODEL_TYPE_AUDIO_TRACK, ModelAudioTrackClass))
154
155 typedef struct _ModelAudioTrack ModelAudioTrack;
156 typedef struct _ModelAudioTrackClass ModelAudioTrackClass;
157
158 #define MODEL_TYPE_TEMPO_INFORMATION (model_tempo_information_get_type ())
159 #define MODEL_TEMPO_INFORMATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MODEL_TYPE_TEMPO_INFORMATION, ModelTempoInformation))
160 #define MODEL_IS_TEMPO_INFORMATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MODEL_TYPE_TEMPO_INFORMATION))
161 #define MODEL_TEMPO_INFORMATION_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), MODEL_TYPE_TEMPO_INFORMATION, ModelTempoInformationIface))
162
163 typedef struct _ModelTempoInformation ModelTempoInformation;
164 typedef struct _ModelTempoInformationIface ModelTempoInformationIface;
165
166 #define TYPE_FRACTION (fraction_get_type ())
167 typedef struct _Fraction Fraction;
168 typedef struct _ModelProjectPrivate ModelProjectPrivate;
169
170 #define TYPE_TIME_CODE (time_code_get_type ())
171 typedef struct _TimeCode TimeCode;
172
173 #define VIEW_TYPE_MEDIA_ENGINE (view_media_engine_get_type ())
174 #define VIEW_MEDIA_ENGINE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VIEW_TYPE_MEDIA_ENGINE, ViewMediaEngine))
175 #define VIEW_MEDIA_ENGINE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VIEW_TYPE_MEDIA_ENGINE, ViewMediaEngineClass))
176 #define VIEW_IS_MEDIA_ENGINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VIEW_TYPE_MEDIA_ENGINE))
177 #define VIEW_IS_MEDIA_ENGINE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VIEW_TYPE_MEDIA_ENGINE))
178 #define VIEW_MEDIA_ENGINE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VIEW_TYPE_MEDIA_ENGINE, ViewMediaEngineClass))
179
180 typedef struct _ViewMediaEngine ViewMediaEngine;
181 typedef struct _ViewMediaEngineClass ViewMediaEngineClass;
182
183 #define MODEL_TYPE_PROJECT_LOADER (model_project_loader_get_type ())
184 #define MODEL_PROJECT_LOADER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MODEL_TYPE_PROJECT_LOADER, ModelProjectLoader))
185 #define MODEL_PROJECT_LOADER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MODEL_TYPE_PROJECT_LOADER, ModelProjectLoaderClass))
186 #define MODEL_IS_PROJECT_LOADER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MODEL_TYPE_PROJECT_LOADER))
187 #define MODEL_IS_PROJECT_LOADER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MODEL_TYPE_PROJECT_LOADER))
188 #define MODEL_PROJECT_LOADER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MODEL_TYPE_PROJECT_LOADER, ModelProjectLoaderClass))
189
190 typedef struct _ModelProjectLoader ModelProjectLoader;
191 typedef struct _ModelProjectLoaderClass ModelProjectLoaderClass;
192
193 #define MODEL_TYPE_UNDO_MANAGER (model_undo_manager_get_type ())
194 #define MODEL_UNDO_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MODEL_TYPE_UNDO_MANAGER, ModelUndoManager))
195 #define MODEL_UNDO_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MODEL_TYPE_UNDO_MANAGER, ModelUndoManagerClass))
196 #define MODEL_IS_UNDO_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MODEL_TYPE_UNDO_MANAGER))
197 #define MODEL_IS_UNDO_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MODEL_TYPE_UNDO_MANAGER))
198 #define MODEL_UNDO_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MODEL_TYPE_UNDO_MANAGER, ModelUndoManagerClass))
199
200 typedef struct _ModelUndoManager ModelUndoManager;
201 typedef struct _ModelUndoManagerClass ModelUndoManagerClass;
202
203 struct _MultiFileProgressInterfaceIface {
204         GTypeInterface parent_iface;
205         void (*cancel) (MultiFileProgressInterface* self);
206         void (*complete) (MultiFileProgressInterface* self);
207 };
208
209 struct _ModelClipImporter {
210         GObject parent_instance;
211         ModelClipImporterPrivate * priv;
212 };
213
214 struct _ModelClipImporterClass {
215         GObjectClass parent_class;
216 };
217
218 typedef enum  {
219         MODEL_CLIP_IMPORTER_IMPORT_STATE_FETCHING,
220         MODEL_CLIP_IMPORTER_IMPORT_STATE_IMPORTING,
221         MODEL_CLIP_IMPORTER_IMPORT_STATE_CANCELLED
222 } ModelClipImporterImportState;
223
224 struct _ModelClipImporterPrivate {
225         char* import_directory;
226         ModelClipImporterImportState import_state;
227         gboolean import_done;
228         gboolean all_done;
229         ModelClipFetcher* our_fetcher;
230         GstPad* video_pad;
231         GstPad* audio_pad;
232         GstPipeline* pipeline;
233         GstElement* filesink;
234         GstElement* video_convert;
235         GstElement* audio_convert;
236         GstElement* mux;
237         GstBin* video_decoder;
238         GstBin* audio_decoder;
239         gint current_file_importing;
240         gint64 current_time;
241         gint64 total_time;
242         gint64 previous_time;
243         GeeArrayList* filenames;
244         GeeArrayList* queued_fetchers;
245         GeeArrayList* queued_filenames;
246         GeeArrayList* no_import_formats;
247 };
248
249 typedef enum  {
250         LOGGING_FACILITY_SIGNAL_HANDLERS,
251         LOGGING_FACILITY_DEVELOPER_WARNINGS,
252         LOGGING_FACILITY_GRAPH,
253         LOGGING_FACILITY_LOADING,
254         LOGGING_FACILITY_IMPORT,
255         LOGGING_FACILITY_SINGLEDECODEBIN
256 } LoggingFacility;
257
258 typedef enum  {
259         LOGGING_LEVEL_CRITICAL,
260         LOGGING_LEVEL_HIGH,
261         LOGGING_LEVEL_MEDIUM,
262         LOGGING_LEVEL_LOW,
263         LOGGING_LEVEL_INFO,
264         LOGGING_LEVEL_VERBOSE
265 } LoggingLevel;
266
267 struct _ModelFetcher {
268         GObject parent_instance;
269         ModelFetcherPrivate * priv;
270         GstElement* filesrc;
271         GstElement* decodebin;
272         GstPipeline* pipeline;
273         ModelClipFile* clipfile;
274         char* error_string;
275 };
276
277 struct _ModelFetcherClass {
278         GObjectClass parent_class;
279         void (*on_pad_added) (ModelFetcher* self, GstPad* pad);
280         void (*on_state_change) (ModelFetcher* self, GstBus* bus, GstMessage* message);
281 };
282
283 struct _ModelClipFile {
284         GObject parent_instance;
285         ModelClipFilePrivate * priv;
286         char* filename;
287         GstCaps* video_caps;
288         GstCaps* audio_caps;
289         GdkPixbuf* thumbnail;
290 };
291
292 struct _ModelClipFileClass {
293         GObjectClass parent_class;
294 };
295
296 typedef enum  {
297         MODEL_MEDIA_TYPE_AUDIO,
298         MODEL_MEDIA_TYPE_VIDEO
299 } ModelMediaType;
300
301 struct _ModelLibraryImporter {
302         GObject parent_instance;
303         ModelLibraryImporterPrivate * priv;
304         ModelProject* project;
305         ModelClipImporter* importer;
306 };
307
308 struct _ModelLibraryImporterClass {
309         GObjectClass parent_class;
310         void (*append_existing_clipfile) (ModelLibraryImporter* self, ModelClipFile* f);
311         void (*on_clip_complete) (ModelLibraryImporter* self, ModelClipFile* f);
312 };
313
314 struct _ModelTimelineImporter {
315         ModelLibraryImporter parent_instance;
316         ModelTimelineImporterPrivate * priv;
317 };
318
319 struct _ModelTimelineImporterClass {
320         ModelLibraryImporterClass parent_class;
321 };
322
323 struct _ModelTimelineImporterPrivate {
324         ModelTrack* track;
325         gint64 time_to_add;
326         gboolean both_tracks;
327 };
328
329 struct _Fraction {
330         gint numerator;
331         gint denominator;
332 };
333
334 struct _ModelTempoInformationIface {
335         GTypeInterface parent_iface;
336         void (*get_time_signature) (ModelTempoInformation* self, Fraction* result);
337         gint (*get_bpm) (ModelTempoInformation* self);
338 };
339
340 struct _TimeCode {
341         gint hour;
342         gint minute;
343         gint second;
344         gint frame;
345         gboolean drop_code;
346 };
347
348 struct _ModelProject {
349         GObject parent_instance;
350         ModelProjectPrivate * priv;
351         GeeArrayList* tracks;
352         GeeArrayList* inactive_tracks;
353         GeeArrayList* clipfiles;
354         ViewMediaEngine* media_engine;
355         char* project_file;
356         ModelProjectLoader* loader;
357         ModelUndoManager* undo_manager;
358         ModelLibraryImporter* importer;
359         Fraction default_framerate;
360         gboolean click_during_play;
361         gboolean click_during_record;
362         double click_volume;
363         gboolean library_visible;
364         gint library_width;
365         gboolean snap_to_clip;
366 };
367
368 struct _ModelProjectClass {
369         GObjectClass parent_class;
370         void (*get_clip_time) (ModelProject* self, ModelClipFile* f, TimeCode* result);
371         char* (*get_project_file) (ModelProject* self);
372         void (*do_append) (ModelProject* self, ModelTrack* track, ModelClipFile* clipfile, const char* name, gint64 insert_time);
373         void (*add_track) (ModelProject* self, ModelTrack* track);
374         void (*insert_track) (ModelProject* self, gint index, ModelTrack* track);
375         void (*load) (ModelProject* self, const char* fname);
376         void (*save) (ModelProject* self, const char* filename);
377         char* (*get_app_name) (ModelProject* self);
378         void (*load_complete) (ModelProject* self);
379 };
380
381
382 static gpointer model_clip_importer_parent_class = NULL;
383 static MultiFileProgressInterfaceIface* model_clip_importer_multi_file_progress_interface_parent_iface = NULL;
384 static gpointer model_library_importer_parent_class = NULL;
385 static gpointer model_timeline_importer_parent_class = NULL;
386
387 GType multi_file_progress_interface_get_type (void);
388 GType model_clip_importer_get_type (void);
389 static GType model_clip_importer_import_state_get_type (void) G_GNUC_UNUSED;
390 GType model_fetcher_get_type (void);
391 GType model_clip_fetcher_get_type (void);
392 #define MODEL_CLIP_IMPORTER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), MODEL_TYPE_CLIP_IMPORTER, ModelClipImporterPrivate))
393 enum  {
394         MODEL_CLIP_IMPORTER_DUMMY_PROPERTY
395 };
396 ModelClipImporter* model_clip_importer_new (void);
397 ModelClipImporter* model_clip_importer_construct (GType object_type);
398 void model_clip_importer_add_filename (ModelClipImporter* self, const char* filename);
399 static gboolean model_clip_importer_on_timer_callback (ModelClipImporter* self);
400 static gboolean _model_clip_importer_on_timer_callback_gsource_func (gpointer self);
401 static void model_clip_importer_start_import (ModelClipImporter* self);
402 static void model_clip_importer_real_cancel (MultiFileProgressInterface* base);
403 static void model_clip_importer_process_curr_file (ModelClipImporter* self, GError** error);
404 void model_clip_importer_start (ModelClipImporter* self, GError** error);
405 GType logging_facility_get_type (void);
406 GType logging_level_get_type (void);
407 void logging_emit (GObject* object, LoggingFacility facility, LoggingLevel level, const char* message);
408 ModelClipFetcher* model_clip_fetcher_new (const char* filename, GError** error);
409 ModelClipFetcher* model_clip_fetcher_construct (GType object_type, const char* filename, GError** error);
410 static void model_clip_importer_on_fetcher_ready (ModelClipImporter* self, ModelFetcher* f);
411 static void _model_clip_importer_on_fetcher_ready_model_fetcher_ready (ModelFetcher* _sender, ModelFetcher* fetcher, gpointer self);
412 static void model_clip_importer_do_import (ModelClipImporter* self, ModelClipFetcher* f, GError** error);
413 static void model_clip_importer_real_complete (MultiFileProgressInterface* base);
414 char* append_extension (const char* path, const char* extension);
415 GType model_clip_file_get_type (void);
416 gint64 model_clip_file_get_length (ModelClipFile* self);
417 static void model_clip_importer_do_import_complete (ModelClipImporter* self, GError** error);
418 static gboolean model_clip_importer_need_to_import (ModelClipImporter* self, ModelFetcher* f);
419 gboolean md5_checksum_on_file (const char* filename, char** checksum);
420 char* isolate_filename (const char* path);
421 gboolean get_file_md5_checksum (const char* filename, char** checksum);
422 void save_file_md5_checksum (const char* filename, const char* checksum);
423 static void model_clip_importer_on_state_changed (ModelClipImporter* self, GstBus* b, GstMessage* m);
424 static void _model_clip_importer_on_state_changed_gst_bus_message (GstBus* _sender, GstMessage* message, gpointer self);
425 static void model_clip_importer_on_eos (ModelClipImporter* self);
426 static void _model_clip_importer_on_eos_gst_bus_message (GstBus* _sender, GstMessage* message, gpointer self);
427 static void model_clip_importer_on_error (ModelClipImporter* self, GstBus* bus, GstMessage* message);
428 static void _model_clip_importer_on_error_gst_bus_message (GstBus* _sender, GstMessage* message, gpointer self);
429 static void model_clip_importer_on_warning (ModelClipImporter* self, GstBus* bus, GstMessage* message);
430 static void _model_clip_importer_on_warning_gst_bus_message (GstBus* _sender, GstMessage* message, gpointer self);
431 GstElement* make_element (const char* name, GError** error);
432 GType model_media_type_get_type (void);
433 gboolean model_clip_file_is_of_type (ModelClipFile* self, ModelMediaType t);
434 SingleDecodeBin* single_decode_bin_new (GstCaps* caps, const char* name, const char* uri, GError** error);
435 SingleDecodeBin* single_decode_bin_construct (GType object_type, GstCaps* caps, const char* name, const char* uri, GError** error);
436 GType single_decode_bin_get_type (void);
437 static void model_clip_importer_on_pad_added (ModelClipImporter* self, GstPad* p);
438 static void _model_clip_importer_on_pad_added_gst_element_pad_added (GstElement* _sender, GstPad* pad, gpointer self);
439 static void model_clip_importer_finalize (GObject* obj);
440 GType model_library_importer_get_type (void);
441 GType model_project_get_type (void);
442 enum  {
443         MODEL_LIBRARY_IMPORTER_DUMMY_PROPERTY
444 };
445 void model_library_importer_on_clip_complete (ModelLibraryImporter* self, ModelClipFile* f);
446 static void _model_library_importer_on_clip_complete_model_clip_importer_clip_complete (ModelClipImporter* _sender, ModelClipFile* f, gpointer self);
447 static void model_library_importer_on_error_occurred (ModelLibraryImporter* self, const char* _error_);
448 static void _model_library_importer_on_error_occurred_model_clip_importer_error_occurred (ModelClipImporter* _sender, const char* _error_, gpointer self);
449 static void model_library_importer_on_importer_started (ModelLibraryImporter* self, ModelClipImporter* i, gint num);
450 static void _model_library_importer_on_importer_started_model_clip_importer_importing_started (ModelClipImporter* _sender, gint num_clips, gpointer self);
451 ModelLibraryImporter* model_library_importer_new (ModelProject* p);
452 ModelLibraryImporter* model_library_importer_construct (GType object_type, ModelProject* p);
453 void model_library_importer_append_existing_clipfile (ModelLibraryImporter* self, ModelClipFile* f);
454 static void model_library_importer_real_append_existing_clipfile (ModelLibraryImporter* self, ModelClipFile* f);
455 ModelClipFile* model_project_find_clipfile (ModelProject* self, const char* filename);
456 void model_project_add_clipfile (ModelProject* self, ModelClipFile* clipfile);
457 static void model_library_importer_real_on_clip_complete (ModelLibraryImporter* self, ModelClipFile* f);
458 void model_library_importer_add_file (ModelLibraryImporter* self, const char* filename, GError** error);
459 void model_library_importer_start (ModelLibraryImporter* self, GError** error);
460 static void model_library_importer_finalize (GObject* obj);
461 GType model_timeline_importer_get_type (void);
462 GType model_track_get_type (void);
463 #define MODEL_TIMELINE_IMPORTER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), MODEL_TYPE_TIMELINE_IMPORTER, ModelTimelineImporterPrivate))
464 enum  {
465         MODEL_TIMELINE_IMPORTER_DUMMY_PROPERTY
466 };
467 ModelTimelineImporter* model_timeline_importer_new (ModelTrack* track, ModelProject* p, gint64 time_to_add, gboolean both_tracks);
468 ModelTimelineImporter* model_timeline_importer_construct (GType object_type, ModelTrack* track, ModelProject* p, gint64 time_to_add, gboolean both_tracks);
469 GType model_video_track_get_type (void);
470 GType model_audio_track_get_type (void);
471 ModelAudioTrack* model_project_find_audio_track (ModelProject* self);
472 ModelVideoTrack* model_project_find_video_track (ModelProject* self);
473 void model_project_add (ModelProject* self, ModelTrack* track, ModelClipFile* clipfile, gint64 time);
474 static void model_timeline_importer_add_to_both (ModelTimelineImporter* self, ModelClipFile* clip_file);
475 GType fraction_get_type (void);
476 Fraction* fraction_dup (const Fraction* self);
477 void fraction_free (Fraction* self);
478 GType model_tempo_information_get_type (void);
479 GType time_code_get_type (void);
480 TimeCode* time_code_dup (const TimeCode* self);
481 void time_code_free (TimeCode* self);
482 GType view_media_engine_get_type (void);
483 GType model_project_loader_get_type (void);
484 gpointer model_undo_manager_ref (gpointer instance);
485 void model_undo_manager_unref (gpointer instance);
486 GParamSpec* model_param_spec_undo_manager (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
487 void model_value_set_undo_manager (GValue* value, gpointer v_object);
488 void model_value_take_undo_manager (GValue* value, gpointer v_object);
489 gpointer model_value_get_undo_manager (const GValue* value);
490 GType model_undo_manager_get_type (void);
491 void model_undo_manager_start_transaction (ModelUndoManager* self, const char* description);
492 void model_undo_manager_end_transaction (ModelUndoManager* self, const char* description);
493 static void model_timeline_importer_real_append_existing_clipfile (ModelLibraryImporter* base, ModelClipFile* f);
494 static void model_timeline_importer_real_on_clip_complete (ModelLibraryImporter* base, ModelClipFile* f);
495 static void model_timeline_importer_finalize (GObject* obj);
496 static int _vala_strcmp0 (const char * str1, const char * str2);
497
498
499 static void g_cclosure_user_marshal_VOID__OBJECT_INT (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data);
500
501 static GType model_clip_importer_import_state_get_type (void) {
502         static volatile gsize model_clip_importer_import_state_type_id__volatile = 0;
503         if (g_once_init_enter (&model_clip_importer_import_state_type_id__volatile)) {
504                 static const GEnumValue values[] = {{MODEL_CLIP_IMPORTER_IMPORT_STATE_FETCHING, "MODEL_CLIP_IMPORTER_IMPORT_STATE_FETCHING", "fetching"}, {MODEL_CLIP_IMPORTER_IMPORT_STATE_IMPORTING, "MODEL_CLIP_IMPORTER_IMPORT_STATE_IMPORTING", "importing"}, {MODEL_CLIP_IMPORTER_IMPORT_STATE_CANCELLED, "MODEL_CLIP_IMPORTER_IMPORT_STATE_CANCELLED", "cancelled"}, {0, NULL, NULL}};
505                 GType model_clip_importer_import_state_type_id;
506                 model_clip_importer_import_state_type_id = g_enum_register_static ("ModelClipImporterImportState", values);
507                 g_once_init_leave (&model_clip_importer_import_state_type_id__volatile, model_clip_importer_import_state_type_id);
508         }
509         return model_clip_importer_import_state_type_id__volatile;
510 }
511
512
513 #line 52 "import.vala"
514 ModelClipImporter* model_clip_importer_construct (GType object_type) {
515 #line 516 "import.c"
516         ModelClipImporter * self;
517         char* _tmp0_;
518         char* _tmp1_;
519 #line 52 "import.vala"
520         self = (ModelClipImporter*) g_object_new (object_type, NULL);
521 #line 53 "import.vala"
522         self->priv->import_directory = (_tmp0_ = g_strdup (g_get_home_dir ()), _g_free0 (self->priv->import_directory), _tmp0_);
523 #line 54 "import.vala"
524         self->priv->import_directory = (_tmp1_ = g_strconcat (self->priv->import_directory, "/.lombard_fillmore_import/", NULL), _g_free0 (self->priv->import_directory), _tmp1_);
525 #line 56 "import.vala"
526         g_mkdir (self->priv->import_directory, 0777);
527 #line 58 "import.vala"
528         gee_abstract_collection_add (GEE_ABSTRACT_COLLECTION (self->priv->no_import_formats), "YUY2");
529 #line 59 "import.vala"
530         gee_abstract_collection_add (GEE_ABSTRACT_COLLECTION (self->priv->no_import_formats), "Y41B");
531 #line 61 "import.vala"
532         self->priv->import_state = MODEL_CLIP_IMPORTER_IMPORT_STATE_FETCHING;
533 #line 534 "import.c"
534         return self;
535 }
536
537
538 #line 52 "import.vala"
539 ModelClipImporter* model_clip_importer_new (void) {
540 #line 52 "import.vala"
541         return model_clip_importer_construct (MODEL_TYPE_CLIP_IMPORTER);
542 #line 543 "import.c"
543 }
544
545
546 #line 64 "import.vala"
547 void model_clip_importer_add_filename (ModelClipImporter* self, const char* filename) {
548 #line 64 "import.vala"
549         g_return_if_fail (MODEL_IS_CLIP_IMPORTER (self));
550 #line 64 "import.vala"
551         g_return_if_fail (filename != NULL);
552 #line 65 "import.vala"
553         gee_abstract_collection_add (GEE_ABSTRACT_COLLECTION (self->priv->filenames), filename);
554 #line 555 "import.c"
555 }
556
557
558 #line 68 "import.vala"
559 static gboolean model_clip_importer_on_timer_callback (ModelClipImporter* self) {
560 #line 561 "import.c"
561         gboolean result = FALSE;
562         gint64 time = 0LL;
563         GstFormat format;
564         gboolean _tmp0_ = FALSE;
565 #line 68 "import.vala"
566         g_return_val_if_fail (MODEL_IS_CLIP_IMPORTER (self), FALSE);
567 #line 70 "import.vala"
568         format = GST_FORMAT_TIME;
569 #line 72 "import.vala"
570         if (self->priv->all_done) {
571 #line 572 "import.c"
572                 result = FALSE;
573 #line 73 "import.vala"
574                 return result;
575 #line 576 "import.c"
576         }
577 #line 75 "import.vala"
578         if (gst_element_query_position (GST_ELEMENT (self->priv->pipeline), &format, &time)) {
579 #line 76 "import.vala"
580                 _tmp0_ = format == GST_FORMAT_TIME;
581 #line 582 "import.c"
582         } else {
583 #line 75 "import.vala"
584                 _tmp0_ = FALSE;
585 #line 586 "import.c"
586         }
587 #line 75 "import.vala"
588         if (_tmp0_) {
589 #line 77 "import.vala"
590                 if (time > self->priv->previous_time) {
591 #line 78 "import.vala"
592                         self->priv->current_time = self->priv->current_time + (time - self->priv->previous_time);
593 #line 594 "import.c"
594                 }
595 #line 79 "import.vala"
596                 self->priv->previous_time = time;
597 #line 80 "import.vala"
598                 if (self->priv->current_time >= self->priv->total_time) {
599 #line 81 "import.vala"
600                         g_signal_emit_by_name (MULTI_FILE_PROGRESS_INTERFACE (self), "fraction-updated", 1.0);
601 #line 602 "import.c"
602                         result = FALSE;
603 #line 82 "import.vala"
604                         return result;
605 #line 606 "import.c"
606                 } else {
607 #line 84 "import.vala"
608                         g_signal_emit_by_name (MULTI_FILE_PROGRESS_INTERFACE (self), "fraction-updated", self->priv->current_time / ((double) self->priv->total_time));
609 #line 610 "import.c"
610                 }
611         }
612         result = TRUE;
613 #line 86 "import.vala"
614         return result;
615 #line 616 "import.c"
616 }
617
618
619 #line 68 "import.vala"
620 static gboolean _model_clip_importer_on_timer_callback_gsource_func (gpointer self) {
621 #line 622 "import.c"
622         gboolean result;
623         result = model_clip_importer_on_timer_callback (self);
624         return result;
625 }
626
627
628 #line 89 "import.vala"
629 static void model_clip_importer_start_import (ModelClipImporter* self) {
630 #line 89 "import.vala"
631         g_return_if_fail (MODEL_IS_CLIP_IMPORTER (self));
632 #line 90 "import.vala"
633         self->priv->import_state = MODEL_CLIP_IMPORTER_IMPORT_STATE_IMPORTING;
634 #line 91 "import.vala"
635         self->priv->current_file_importing = 0;
636 #line 92 "import.vala"
637         g_signal_emit_by_name (self, "importing-started", gee_collection_get_size (GEE_COLLECTION (self->priv->queued_fetchers)));
638 #line 93 "import.vala"
639         g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 50, _model_clip_importer_on_timer_callback_gsource_func, g_object_ref (self), g_object_unref);
640 #line 641 "import.c"
641 }
642
643
644 #line 96 "import.vala"
645 static void model_clip_importer_real_cancel (MultiFileProgressInterface* base) {
646 #line 647 "import.c"
647         ModelClipImporter * self;
648         self = MODEL_CLIP_IMPORTER (base);
649 #line 97 "import.vala"
650         self->priv->all_done = TRUE;
651 #line 98 "import.vala"
652         self->priv->import_state = MODEL_CLIP_IMPORTER_IMPORT_STATE_CANCELLED;
653 #line 99 "import.vala"
654         if (self->priv->pipeline != NULL) {
655 #line 100 "import.vala"
656                 gst_element_set_state (GST_ELEMENT (self->priv->pipeline), GST_STATE_NULL);
657 #line 658 "import.c"
658         }
659 }
660
661
662 #line 104 "import.vala"
663 void model_clip_importer_start (ModelClipImporter* self, GError** error) {
664 #line 665 "import.c"
665         GError * _inner_error_;
666 #line 104 "import.vala"
667         g_return_if_fail (MODEL_IS_CLIP_IMPORTER (self));
668 #line 669 "import.c"
669         _inner_error_ = NULL;
670 #line 105 "import.vala"
671         model_clip_importer_process_curr_file (self, &_inner_error_);
672 #line 673 "import.c"
673         if (_inner_error_ != NULL) {
674                 g_propagate_error (error, _inner_error_);
675                 return;
676         }
677 }
678
679
680 #line 173 "import.vala"
681 static void _model_clip_importer_on_fetcher_ready_model_fetcher_ready (ModelFetcher* _sender, ModelFetcher* fetcher, gpointer self) {
682 #line 683 "import.c"
683         model_clip_importer_on_fetcher_ready (self, fetcher);
684 }
685
686
687 #line 108 "import.vala"
688 static void model_clip_importer_process_curr_file (ModelClipImporter* self, GError** error) {
689 #line 690 "import.c"
690         GError * _inner_error_;
691 #line 108 "import.vala"
692         g_return_if_fail (MODEL_IS_CLIP_IMPORTER (self));
693 #line 694 "import.c"
694         _inner_error_ = NULL;
695 #line 109 "import.vala"
696         if (self->priv->import_state == MODEL_CLIP_IMPORTER_IMPORT_STATE_FETCHING) {
697 #line 110 "import.vala"
698                 if (self->priv->current_file_importing == gee_collection_get_size (GEE_COLLECTION (self->priv->filenames))) {
699 #line 111 "import.vala"
700                         if (gee_collection_get_size (GEE_COLLECTION (self->priv->queued_fetchers)) == 0) {
701 #line 112 "import.vala"
702                                 g_signal_emit_by_name (MULTI_FILE_PROGRESS_INTERFACE (self), "done");
703 #line 704 "import.c"
704                         } else {
705 #line 114 "import.vala"
706                                 model_clip_importer_start_import (self);
707 #line 708 "import.c"
708                         }
709                 } else {
710                         char* _tmp1_;
711                         char* _tmp0_;
712                         char* _tmp2_;
713                         ModelClipFetcher* _tmp3_;
714                         ModelClipFetcher* _tmp4_;
715                         ModelClipFetcher* _tmp5_;
716 #line 116 "import.vala"
717                         logging_emit (G_OBJECT (self), LOGGING_FACILITY_IMPORT, LOGGING_LEVEL_VERBOSE, _tmp1_ = g_strdup_printf ("fetching %s", _tmp0_ = (char*) gee_abstract_list_get (GEE_ABSTRACT_LIST (self->priv->filenames), self->priv->current_file_importing)));
718 #line 719 "import.c"
719                         _g_free0 (_tmp1_);
720                         _g_free0 (_tmp0_);
721 #line 118 "import.vala"
722                         _tmp4_ = (_tmp3_ = model_clip_fetcher_new (_tmp2_ = (char*) gee_abstract_list_get (GEE_ABSTRACT_LIST (self->priv->filenames), self->priv->current_file_importing), &_inner_error_), _g_free0 (_tmp2_), _tmp3_);
723 #line 724 "import.c"
724                         if (_inner_error_ != NULL) {
725                                 g_propagate_error (error, _inner_error_);
726                                 return;
727                         }
728 #line 118 "import.vala"
729                         self->priv->our_fetcher = (_tmp5_ = _tmp4_, _g_object_unref0 (self->priv->our_fetcher), _tmp5_);
730 #line 119 "import.vala"
731                         g_signal_connect_object (MODEL_FETCHER (self->priv->our_fetcher), "ready", (GCallback) _model_clip_importer_on_fetcher_ready_model_fetcher_ready, self, 0);
732 #line 733 "import.c"
733                 }
734         }
735 #line 123 "import.vala"
736         if (self->priv->import_state == MODEL_CLIP_IMPORTER_IMPORT_STATE_IMPORTING) {
737 #line 124 "import.vala"
738                 if (self->priv->current_file_importing == gee_collection_get_size (GEE_COLLECTION (self->priv->queued_fetchers))) {
739 #line 125 "import.vala"
740                         g_signal_emit_by_name (MULTI_FILE_PROGRESS_INTERFACE (self), "fraction-updated", 1.0);
741 #line 126 "import.vala"
742                         self->priv->all_done = TRUE;
743 #line 744 "import.c"
744                 } else {
745                         ModelClipFetcher* _tmp6_;
746 #line 128 "import.vala"
747                         model_clip_importer_do_import (self, _tmp6_ = (ModelClipFetcher*) gee_abstract_list_get (GEE_ABSTRACT_LIST (self->priv->queued_fetchers), self->priv->current_file_importing), &_inner_error_);
748 #line 749 "import.c"
749                         _g_object_unref0 (_tmp6_);
750                         if (_inner_error_ != NULL) {
751                                 g_propagate_error (error, _inner_error_);
752                                 return;
753                         }
754                 }
755         }
756 }
757
758
759 #line 133 "import.vala"
760 static void model_clip_importer_real_complete (MultiFileProgressInterface* base) {
761 #line 762 "import.c"
762         ModelClipImporter * self;
763         self = MODEL_CLIP_IMPORTER (base);
764 #line 134 "import.vala"
765         self->priv->all_done = TRUE;
766 #line 767 "import.c"
767 }
768
769
770 #line 137 "import.vala"
771 static void model_clip_importer_do_import_complete (ModelClipImporter* self, GError** error) {
772 #line 773 "import.c"
773         GError * _inner_error_;
774 #line 137 "import.vala"
775         g_return_if_fail (MODEL_IS_CLIP_IMPORTER (self));
776 #line 777 "import.c"
777         _inner_error_ = NULL;
778 #line 138 "import.vala"
779         if (self->priv->import_state == MODEL_CLIP_IMPORTER_IMPORT_STATE_IMPORTING) {
780 #line 781 "import.c"
781                 char* _tmp2_;
782                 char* *_tmp1_;
783                 char* _tmp0_;
784 #line 139 "import.vala"
785                 _tmp1_ = &MODEL_FETCHER (self->priv->our_fetcher)->clipfile->filename;
786 #line 139 "import.vala"
787                 (*_tmp1_) = (_tmp2_ = append_extension (_tmp0_ = (char*) gee_abstract_list_get (GEE_ABSTRACT_LIST (self->priv->queued_filenames), self->priv->current_file_importing), "mov"), _g_free0 ((*_tmp1_)), _tmp2_);
788 #line 789 "import.c"
789                 _g_free0 (_tmp0_);
790 #line 141 "import.vala"
791                 g_signal_emit_by_name (self, "clip-complete", MODEL_FETCHER (self->priv->our_fetcher)->clipfile);
792 #line 793 "import.c"
793         } else {
794 #line 143 "import.vala"
795                 self->priv->total_time = self->priv->total_time + model_clip_file_get_length (MODEL_FETCHER (self->priv->our_fetcher)->clipfile);
796 #line 797 "import.c"
797         }
798 #line 145 "import.vala"
799         self->priv->current_file_importing++;
800 #line 147 "import.vala"
801         if (self->priv->current_file_importing <= gee_collection_get_size (GEE_COLLECTION (self->priv->filenames))) {
802 #line 148 "import.vala"
803                 model_clip_importer_process_curr_file (self, &_inner_error_);
804 #line 805 "import.c"
805                 if (_inner_error_ != NULL) {
806                         g_propagate_error (error, _inner_error_);
807                         return;
808                 }
809         } else {
810                 char* _tmp3_;
811 #line 150 "import.vala"
812                 g_warning ("import.vala:150: %s", _tmp3_ = g_strdup_printf ("do_import_complete: current_file_importing out of bounds! %d %d", self->priv->current_file_importing, gee_collection_get_size (GEE_COLLECTION (self->priv->filenames))));
813 #line 814 "import.c"
814                 _g_free0 (_tmp3_);
815         }
816 }
817
818
819 #line 154 "import.vala"
820 static gboolean model_clip_importer_need_to_import (ModelClipImporter* self, ModelFetcher* f) {
821 #line 822 "import.c"
822         gboolean result = FALSE;
823 #line 154 "import.vala"
824         g_return_val_if_fail (MODEL_IS_CLIP_IMPORTER (self), FALSE);
825 #line 154 "import.vala"
826         g_return_val_if_fail (MODEL_IS_FETCHER (f), FALSE);
827 #line 828 "import.c"
828         result = FALSE;
829 #line 156 "import.vala"
830         return result;
831 #line 832 "import.c"
832 }
833
834
835 #line 173 "import.vala"
836 static void model_clip_importer_on_fetcher_ready (ModelClipImporter* self, ModelFetcher* f) {
837 #line 838 "import.c"
838         GError * _inner_error_;
839 #line 173 "import.vala"
840         g_return_if_fail (MODEL_IS_CLIP_IMPORTER (self));
841 #line 173 "import.vala"
842         g_return_if_fail (MODEL_IS_FETCHER (f));
843 #line 844 "import.c"
844         _inner_error_ = NULL;
845 #line 174 "import.vala"
846         logging_emit (G_OBJECT (self), LOGGING_FACILITY_SIGNAL_HANDLERS, LOGGING_LEVEL_INFO, "on_fetcher_ready");
847 #line 848 "import.c"
848         {
849 #line 176 "import.vala"
850                 if (f->error_string != NULL) {
851 #line 177 "import.vala"
852                         g_signal_emit_by_name (self, "error-occurred", f->error_string);
853 #line 178 "import.vala"
854                         model_clip_importer_do_import_complete (self, &_inner_error_);
855 #line 856 "import.c"
856                         if (_inner_error_ != NULL) {
857                                 goto __catch7_g_error;
858                         }
859 #line 179 "import.vala"
860                         return;
861 #line 862 "import.c"
862                 }
863 #line 182 "import.vala"
864                 if (model_clip_importer_need_to_import (self, f)) {
865 #line 866 "import.c"
866                         char* checksum;
867                         char* _tmp2_;
868                         gboolean _tmp1_;
869                         char* _tmp0_ = NULL;
870                         checksum = NULL;
871 #line 184 "import.vala"
872                         if ((_tmp1_ = md5_checksum_on_file (f->clipfile->filename, &_tmp0_), checksum = (_tmp2_ = _tmp0_, _g_free0 (checksum), _tmp2_), _tmp1_)) {
873 #line 874 "import.c"
874                                 char* _tmp3_;
875                                 char* _tmp4_;
876                                 char* base_filename;
877                                 gint index;
878                                 char* new_filename;
879 #line 185 "import.vala"
880                                 base_filename = (_tmp4_ = g_strconcat (self->priv->import_directory, _tmp3_ = isolate_filename (f->clipfile->filename), NULL), _g_free0 (_tmp3_), _tmp4_);
881 #line 187 "import.vala"
882                                 index = 0;
883 #line 188 "import.vala"
884                                 new_filename = g_strdup (base_filename);
885 #line 189 "import.vala"
886                                 while (TRUE) {
887 #line 888 "import.c"
888                                         char* existing_checksum;
889                                         char* _tmp7_;
890                                         gboolean _tmp6_;
891                                         char* _tmp5_ = NULL;
892                                         existing_checksum = NULL;
893 #line 191 "import.vala"
894                                         if ((_tmp6_ = get_file_md5_checksum (new_filename, &_tmp5_), existing_checksum = (_tmp7_ = _tmp5_, _g_free0 (existing_checksum), _tmp7_), _tmp6_)) {
895 #line 896 "import.c"
896                                                 char* _tmp10_;
897                                                 char* _tmp9_;
898 #line 192 "import.vala"
899                                                 if (_vala_strcmp0 (checksum, existing_checksum) == 0) {
900 #line 901 "import.c"
901                                                         char* _tmp8_;
902 #line 194 "import.vala"
903                                                         gee_abstract_list_set (GEE_ABSTRACT_LIST (self->priv->filenames), self->priv->current_file_importing, _tmp8_ = append_extension (new_filename, "mov"));
904 #line 905 "import.c"
905                                                         _g_free0 (_tmp8_);
906 #line 196 "import.vala"
907                                                         self->priv->current_file_importing--;
908 #line 197 "import.vala"
909                                                         self->priv->total_time = self->priv->total_time - model_clip_file_get_length (f->clipfile);
910 #line 911 "import.c"
911                                                         _g_free0 (existing_checksum);
912 #line 198 "import.vala"
913                                                         break;
914 #line 915 "import.c"
915                                                 }
916 #line 200 "import.vala"
917                                                 index++;
918 #line 201 "import.vala"
919                                                 new_filename = (_tmp10_ = g_strconcat (base_filename, _tmp9_ = g_strdup_printf ("%i", index), NULL), _g_free0 (new_filename), _tmp10_);
920 #line 921 "import.c"
921                                                 _g_free0 (_tmp9_);
922                                         } else {
923                                                 ModelFetcher* _tmp11_;
924 #line 204 "import.vala"
925                                                 save_file_md5_checksum (new_filename, checksum);
926 #line 205 "import.vala"
927                                                 gee_abstract_collection_add (GEE_ABSTRACT_COLLECTION (self->priv->queued_filenames), new_filename);
928 #line 206 "import.vala"
929                                                 gee_abstract_collection_add (GEE_ABSTRACT_COLLECTION (self->priv->queued_fetchers), (_tmp11_ = f, MODEL_IS_CLIP_FETCHER (_tmp11_) ? ((ModelClipFetcher*) _tmp11_) : NULL));
930 #line 931 "import.c"
931                                                 _g_free0 (existing_checksum);
932 #line 207 "import.vala"
933                                                 break;
934 #line 935 "import.c"
935                                         }
936                                         _g_free0 (existing_checksum);
937                                 }
938                                 _g_free0 (base_filename);
939                                 _g_free0 (new_filename);
940                         } else {
941 #line 211 "import.vala"
942                                 g_error ("import.vala:211: Cannot get md5 checksum for file %s!", f->clipfile->filename);
943 #line 944 "import.c"
944                         }
945                         _g_free0 (checksum);
946                 } else {
947 #line 213 "import.vala"
948                         g_signal_emit_by_name (self, "clip-complete", f->clipfile);
949 #line 950 "import.c"
950                 }
951 #line 215 "import.vala"
952                 model_clip_importer_do_import_complete (self, &_inner_error_);
953 #line 954 "import.c"
954                 if (_inner_error_ != NULL) {
955                         goto __catch7_g_error;
956                 }
957         }
958         goto __finally7;
959         __catch7_g_error:
960         {
961                 GError * e;
962                 e = _inner_error_;
963                 _inner_error_ = NULL;
964                 {
965 #line 217 "import.vala"
966                         g_signal_emit_by_name (self, "error-occurred", e->message);
967 #line 968 "import.c"
968                         _g_error_free0 (e);
969                 }
970         }
971         __finally7:
972         if (_inner_error_ != NULL) {
973                 g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
974                 g_clear_error (&_inner_error_);
975                 return;
976         }
977 }
978
979
980 static gpointer _g_object_ref0 (gpointer self) {
981         return self ? g_object_ref (self) : NULL;
982 }
983
984
985 #line 325 "import.vala"
986 static void _model_clip_importer_on_state_changed_gst_bus_message (GstBus* _sender, GstMessage* message, gpointer self) {
987 #line 988 "import.c"
988         model_clip_importer_on_state_changed (self, _sender, message);
989 }
990
991
992 #line 369 "import.vala"
993 static void _model_clip_importer_on_eos_gst_bus_message (GstBus* _sender, GstMessage* message, gpointer self) {
994 #line 995 "import.c"
995         model_clip_importer_on_eos (self);
996 }
997
998
999 #line 308 "import.vala"
1000 static void _model_clip_importer_on_error_gst_bus_message (GstBus* _sender, GstMessage* message, gpointer self) {
1001 #line 1002 "import.c"
1002         model_clip_importer_on_error (self, _sender, message);
1003 }
1004
1005
1006 #line 317 "import.vala"
1007 static void _model_clip_importer_on_warning_gst_bus_message (GstBus* _sender, GstMessage* message, gpointer self) {
1008 #line 1009 "import.c"
1009         model_clip_importer_on_warning (self, _sender, message);
1010 }
1011
1012
1013 static gpointer _gst_object_ref0 (gpointer self) {
1014         return self ? gst_object_ref (self) : NULL;
1015 }
1016
1017
1018 #line 285 "import.vala"
1019 static void _model_clip_importer_on_pad_added_gst_element_pad_added (GstElement* _sender, GstPad* pad, gpointer self) {
1020 #line 1021 "import.c"
1021         model_clip_importer_on_pad_added (self, pad);
1022 }
1023
1024
1025 #line 221 "import.vala"
1026 static void model_clip_importer_do_import (ModelClipImporter* self, ModelClipFetcher* f, GError** error) {
1027 #line 1028 "import.c"
1028         GError * _inner_error_;
1029         ModelClipFetcher* _tmp0_;
1030         GstPipeline* _tmp1_;
1031         GstBus* bus;
1032         GstElement* _tmp2_;
1033         GstElement* _tmp3_;
1034         GstElement* _tmp4_;
1035         GstElement* _tmp5_;
1036         char* _tmp7_;
1037         char* _tmp6_;
1038         char* _tmp21_;
1039         char* _tmp20_;
1040 #line 221 "import.vala"
1041         g_return_if_fail (MODEL_IS_CLIP_IMPORTER (self));
1042 #line 221 "import.vala"
1043         g_return_if_fail (MODEL_IS_CLIP_FETCHER (f));
1044 #line 1045 "import.c"
1045         _inner_error_ = NULL;
1046 #line 222 "import.vala"
1047         g_signal_emit_by_name (MULTI_FILE_PROGRESS_INTERFACE (self), "file-updated", MODEL_FETCHER (f)->clipfile->filename, self->priv->current_file_importing);
1048 #line 223 "import.vala"
1049         self->priv->previous_time = (gint64) 0;
1050 #line 225 "import.vala"
1051         self->priv->our_fetcher = (_tmp0_ = _g_object_ref0 (f), _g_object_unref0 (self->priv->our_fetcher), _tmp0_);
1052 #line 226 "import.vala"
1053         self->priv->import_done = FALSE;
1054 #line 227 "import.vala"
1055         self->priv->pipeline = (_tmp1_ = (GstPipeline*) gst_pipeline_new ("pipeline"), _gst_object_unref0 (self->priv->pipeline), _tmp1_);
1056 #line 228 "import.vala"
1057         gst_pipeline_set_auto_flush_bus (self->priv->pipeline, FALSE);
1058 #line 230 "import.vala"
1059         bus = gst_pipeline_get_bus (self->priv->pipeline);
1060 #line 231 "import.vala"
1061         gst_bus_add_signal_watch (bus);
1062 #line 233 "import.vala"
1063         g_signal_connect_object (bus, "message::state-changed", (GCallback) _model_clip_importer_on_state_changed_gst_bus_message, self, 0);
1064 #line 234 "import.vala"
1065         g_signal_connect_object (bus, "message::eos", (GCallback) _model_clip_importer_on_eos_gst_bus_message, self, 0);
1066 #line 235 "import.vala"
1067         g_signal_connect_object (bus, "message::error", (GCallback) _model_clip_importer_on_error_gst_bus_message, self, 0);
1068 #line 236 "import.vala"
1069         g_signal_connect_object (bus, "message::warning", (GCallback) _model_clip_importer_on_warning_gst_bus_message, self, 0);
1070 #line 238 "import.vala"
1071         _tmp2_ = make_element ("qtmux", &_inner_error_);
1072 #line 1073 "import.c"
1073         if (_inner_error_ != NULL) {
1074                 g_propagate_error (error, _inner_error_);
1075                 _gst_object_unref0 (bus);
1076                 return;
1077         }
1078 #line 238 "import.vala"
1079         self->priv->mux = (_tmp3_ = _tmp2_, _gst_object_unref0 (self->priv->mux), _tmp3_);
1080 #line 240 "import.vala"
1081         _tmp4_ = make_element ("filesink", &_inner_error_);
1082 #line 1083 "import.c"
1083         if (_inner_error_ != NULL) {
1084                 g_propagate_error (error, _inner_error_);
1085                 _gst_object_unref0 (bus);
1086                 return;
1087         }
1088 #line 240 "import.vala"
1089         self->priv->filesink = (_tmp5_ = _tmp4_, _gst_object_unref0 (self->priv->filesink), _tmp5_);
1090 #line 241 "import.vala"
1091         g_object_set (G_OBJECT (self->priv->filesink), "location", _tmp7_ = append_extension (_tmp6_ = (char*) gee_abstract_list_get (GEE_ABSTRACT_LIST (self->priv->queued_filenames), self->priv->current_file_importing), "mov"), NULL);
1092 #line 1093 "import.c"
1093         _g_free0 (_tmp7_);
1094         _g_free0 (_tmp6_);
1095 #line 243 "import.vala"
1096         gst_bin_add_many (GST_BIN (self->priv->pipeline), _gst_object_ref0 (self->priv->mux), _gst_object_ref0 (self->priv->filesink), NULL);
1097 #line 245 "import.vala"
1098         if (model_clip_file_is_of_type (MODEL_FETCHER (f)->clipfile, MODEL_MEDIA_TYPE_VIDEO)) {
1099 #line 1100 "import.c"
1100                 GstElement* _tmp8_;
1101                 GstElement* _tmp9_;
1102                 GstCaps* _tmp10_;
1103                 SingleDecodeBin* _tmp11_;
1104                 SingleDecodeBin* _tmp12_;
1105                 GstBin* _tmp13_;
1106 #line 246 "import.vala"
1107                 _tmp8_ = make_element ("ffmpegcolorspace", &_inner_error_);
1108 #line 1109 "import.c"
1109                 if (_inner_error_ != NULL) {
1110                         g_propagate_error (error, _inner_error_);
1111                         _gst_object_unref0 (bus);
1112                         return;
1113                 }
1114 #line 246 "import.vala"
1115                 self->priv->video_convert = (_tmp9_ = _tmp8_, _gst_object_unref0 (self->priv->video_convert), _tmp9_);
1116 #line 247 "import.vala"
1117                 gst_bin_add (GST_BIN (self->priv->pipeline), _gst_object_ref0 (self->priv->video_convert));
1118 #line 249 "import.vala"
1119                 _tmp12_ = (_tmp11_ = single_decode_bin_new (_tmp10_ = gst_caps_from_string ("video/x-raw-yuv"), "videodecodebin", MODEL_FETCHER (f)->clipfile->filename, &_inner_error_), _gst_caps_unref0 (_tmp10_), _tmp11_);
1120 #line 1121 "import.c"
1121                 if (_inner_error_ != NULL) {
1122                         g_propagate_error (error, _inner_error_);
1123                         _gst_object_unref0 (bus);
1124                         return;
1125                 }
1126 #line 249 "import.vala"
1127                 self->priv->video_decoder = (_tmp13_ = GST_BIN (_tmp12_), _gst_object_unref0 (self->priv->video_decoder), _tmp13_);
1128 #line 253 "import.vala"
1129                 g_signal_connect_object (GST_ELEMENT (self->priv->video_decoder), "pad-added", (GCallback) _model_clip_importer_on_pad_added_gst_element_pad_added, self, 0);
1130 #line 255 "import.vala"
1131                 gst_bin_add (GST_BIN (self->priv->pipeline), _gst_object_ref0 (GST_ELEMENT (self->priv->video_decoder)));
1132 #line 257 "import.vala"
1133                 if (!gst_element_link (self->priv->video_convert, self->priv->mux)) {
1134 #line 258 "import.vala"
1135                         g_error ("import.vala:258: do_import: Cannot link video converter to mux!");
1136 #line 1137 "import.c"
1137                 }
1138         }
1139 #line 260 "import.vala"
1140         if (model_clip_file_is_of_type (MODEL_FETCHER (f)->clipfile, MODEL_MEDIA_TYPE_AUDIO)) {
1141 #line 1142 "import.c"
1142                 GstElement* _tmp14_;
1143                 GstElement* _tmp15_;
1144                 GstCaps* _tmp16_;
1145                 SingleDecodeBin* _tmp17_;
1146                 SingleDecodeBin* _tmp18_;
1147                 GstBin* _tmp19_;
1148 #line 261 "import.vala"
1149                 _tmp14_ = make_element ("audioconvert", &_inner_error_);
1150 #line 1151 "import.c"
1151                 if (_inner_error_ != NULL) {
1152                         g_propagate_error (error, _inner_error_);
1153                         _gst_object_unref0 (bus);
1154                         return;
1155                 }
1156 #line 261 "import.vala"
1157                 self->priv->audio_convert = (_tmp15_ = _tmp14_, _gst_object_unref0 (self->priv->audio_convert), _tmp15_);
1158 #line 262 "import.vala"
1159                 gst_bin_add (GST_BIN (self->priv->pipeline), _gst_object_ref0 (self->priv->audio_convert));
1160 #line 266 "import.vala"
1161                 _tmp18_ = (_tmp17_ = single_decode_bin_new (_tmp16_ = gst_caps_from_string ("audio/x-raw-int"), "audiodecodebin", MODEL_FETCHER (f)->clipfile->filename, &_inner_error_), _gst_caps_unref0 (_tmp16_), _tmp17_);
1162 #line 1163 "import.c"
1163                 if (_inner_error_ != NULL) {
1164                         g_propagate_error (error, _inner_error_);
1165                         _gst_object_unref0 (bus);
1166                         return;
1167                 }
1168 #line 266 "import.vala"
1169                 self->priv->audio_decoder = (_tmp19_ = GST_BIN (_tmp18_), _gst_object_unref0 (self->priv->audio_decoder), _tmp19_);
1170 #line 269 "import.vala"
1171                 g_signal_connect_object (GST_ELEMENT (self->priv->audio_decoder), "pad-added", (GCallback) _model_clip_importer_on_pad_added_gst_element_pad_added, self, 0);
1172 #line 271 "import.vala"
1173                 gst_bin_add (GST_BIN (self->priv->pipeline), _gst_object_ref0 (GST_ELEMENT (self->priv->audio_decoder)));
1174 #line 273 "import.vala"
1175                 if (!gst_element_link (self->priv->audio_convert, self->priv->mux)) {
1176 #line 274 "import.vala"
1177                         g_error ("import.vala:274: do_import: Cannot link audio convert to mux!");
1178 #line 1179 "import.c"
1179                 }
1180         }
1181 #line 277 "import.vala"
1182         if (!gst_element_link (self->priv->mux, self->priv->filesink)) {
1183 #line 278 "import.vala"
1184                 g_error ("import.vala:278: do_import: Cannot link mux to filesink!");
1185 #line 1186 "import.c"
1186         }
1187 #line 280 "import.vala"
1188         logging_emit (G_OBJECT (self), LOGGING_FACILITY_IMPORT, LOGGING_LEVEL_VERBOSE, _tmp21_ = g_strdup_printf ("Starting import to %s...", _tmp20_ = (char*) gee_abstract_list_get (GEE_ABSTRACT_LIST (self->priv->queued_filenames), self->priv->current_file_importing)));
1189 #line 1190 "import.c"
1190         _g_free0 (_tmp21_);
1191         _g_free0 (_tmp20_);
1192 #line 282 "import.vala"
1193         gst_element_set_state (GST_ELEMENT (self->priv->pipeline), GST_STATE_PLAYING);
1194 #line 1195 "import.c"
1195         _gst_object_unref0 (bus);
1196 }
1197
1198
1199 #line 285 "import.vala"
1200 static void model_clip_importer_on_pad_added (ModelClipImporter* self, GstPad* p) {
1201 #line 1202 "import.c"
1202         GstCaps* _tmp1_;
1203         GstCaps* _tmp0_ = NULL;
1204         char* _tmp2_;
1205         char* str;
1206         GstPad* sink;
1207 #line 285 "import.vala"
1208         g_return_if_fail (MODEL_IS_CLIP_IMPORTER (self));
1209 #line 285 "import.vala"
1210         g_return_if_fail (GST_IS_PAD (p));
1211 #line 286 "import.vala"
1212         logging_emit (G_OBJECT (self), LOGGING_FACILITY_SIGNAL_HANDLERS, LOGGING_LEVEL_INFO, "on_pad_added");
1213 #line 288 "import.vala"
1214         str = (_tmp2_ = gst_caps_to_string (_tmp1_ = (g_object_get (p, "caps", &_tmp0_, NULL), _tmp0_)), _gst_caps_unref0 (_tmp1_), _tmp2_);
1215 #line 289 "import.vala"
1216         sink = NULL;
1217 #line 291 "import.vala"
1218         if (g_str_has_prefix (str, "video")) {
1219 #line 1220 "import.c"
1220                 GstPad* _tmp3_;
1221                 GstPad* _tmp6_;
1222                 GstCaps* _tmp5_;
1223                 GstCaps* _tmp4_ = NULL;
1224 #line 292 "import.vala"
1225                 self->priv->video_pad = (_tmp3_ = _gst_object_ref0 (p), _gst_object_unref0 (self->priv->video_pad), _tmp3_);
1226 #line 293 "import.vala"
1227                 sink = (_tmp6_ = gst_element_get_compatible_pad (self->priv->video_convert, p, _tmp5_ = (g_object_get (p, "caps", &_tmp4_, NULL), _tmp4_)), _gst_object_unref0 (sink), _tmp6_);
1228 #line 1229 "import.c"
1229                 _gst_caps_unref0 (_tmp5_);
1230         } else {
1231 #line 294 "import.vala"
1232                 if (g_str_has_prefix (str, "audio")) {
1233 #line 1234 "import.c"
1234                         GstPad* _tmp7_;
1235                         GstPad* _tmp10_;
1236                         GstCaps* _tmp9_;
1237                         GstCaps* _tmp8_ = NULL;
1238 #line 295 "import.vala"
1239                         self->priv->audio_pad = (_tmp7_ = _gst_object_ref0 (p), _gst_object_unref0 (self->priv->audio_pad), _tmp7_);
1240 #line 296 "import.vala"
1241                         sink = (_tmp10_ = gst_element_get_compatible_pad (self->priv->audio_convert, p, _tmp9_ = (g_object_get (p, "caps", &_tmp8_, NULL), _tmp8_)), _gst_object_unref0 (sink), _tmp10_);
1242 #line 1243 "import.c"
1243                         _gst_caps_unref0 (_tmp9_);
1244                 } else {
1245                         char* _tmp11_;
1246 #line 299 "import.vala"
1247                         g_warning ("import.vala:299: %s", _tmp11_ = g_strdup_printf ("Unrecognized prefix %s", str));
1248 #line 1249 "import.c"
1249                         _g_free0 (_tmp11_);
1250                         _g_free0 (str);
1251                         _gst_object_unref0 (sink);
1252 #line 300 "import.vala"
1253                         return;
1254 #line 1255 "import.c"
1255                 }
1256         }
1257 #line 303 "import.vala"
1258         if (gst_pad_link (p, sink) != GST_PAD_LINK_OK) {
1259 #line 304 "import.vala"
1260                 g_error ("import.vala:304: Cannot link pad in importer!");
1261 #line 1262 "import.c"
1262         }
1263         _g_free0 (str);
1264         _gst_object_unref0 (sink);
1265 }
1266
1267
1268 #line 308 "import.vala"
1269 static void model_clip_importer_on_error (ModelClipImporter* self, GstBus* bus, GstMessage* message) {
1270 #line 1271 "import.c"
1271         GError* e;
1272         char* text;
1273         char* _tmp3_;
1274         char* _tmp2_ = NULL;
1275         GError* _tmp1_;
1276         GError* _tmp0_ = NULL;
1277 #line 308 "import.vala"
1278         g_return_if_fail (MODEL_IS_CLIP_IMPORTER (self));
1279 #line 308 "import.vala"
1280         g_return_if_fail (GST_IS_BUS (bus));
1281 #line 308 "import.vala"
1282         g_return_if_fail (GST_IS_MESSAGE (message));
1283 #line 309 "import.vala"
1284         logging_emit (G_OBJECT (self), LOGGING_FACILITY_SIGNAL_HANDLERS, LOGGING_LEVEL_INFO, "on_error");
1285 #line 1286 "import.c"
1286         e = NULL;
1287         text = NULL;
1288 #line 312 "import.vala"
1289         (gst_message_parse_error (message, &_tmp0_, &_tmp2_), e = (_tmp1_ = _tmp0_, _g_error_free0 (e), _tmp1_));
1290 #line 312 "import.vala"
1291         text = (_tmp3_ = _tmp2_, _g_free0 (text), _tmp3_);
1292 #line 313 "import.vala"
1293         g_warning ("import.vala:313: %s\n", text);
1294 #line 314 "import.vala"
1295         g_signal_emit_by_name (self, "error-occurred", text);
1296 #line 1297 "import.c"
1297         _g_error_free0 (e);
1298         _g_free0 (text);
1299 }
1300
1301
1302 #line 317 "import.vala"
1303 static void model_clip_importer_on_warning (ModelClipImporter* self, GstBus* bus, GstMessage* message) {
1304 #line 1305 "import.c"
1305         GError* e;
1306         char* text;
1307         char* _tmp3_;
1308         char* _tmp2_ = NULL;
1309         GError* _tmp1_;
1310         GError* _tmp0_ = NULL;
1311 #line 317 "import.vala"
1312         g_return_if_fail (MODEL_IS_CLIP_IMPORTER (self));
1313 #line 317 "import.vala"
1314         g_return_if_fail (GST_IS_BUS (bus));
1315 #line 317 "import.vala"
1316         g_return_if_fail (GST_IS_MESSAGE (message));
1317 #line 318 "import.vala"
1318         logging_emit (G_OBJECT (self), LOGGING_FACILITY_SIGNAL_HANDLERS, LOGGING_LEVEL_INFO, "on_warning");
1319 #line 1320 "import.c"
1320         e = NULL;
1321         text = NULL;
1322 #line 321 "import.vala"
1323         (gst_message_parse_warning (message, &_tmp0_, &_tmp2_), e = (_tmp1_ = _tmp0_, _g_error_free0 (e), _tmp1_));
1324 #line 321 "import.vala"
1325         text = (_tmp3_ = _tmp2_, _g_free0 (text), _tmp3_);
1326 #line 322 "import.vala"
1327         g_warning ("import.vala:322: %s", text);
1328 #line 1329 "import.c"
1329         _g_error_free0 (e);
1330         _g_free0 (text);
1331 }
1332
1333
1334 #line 325 "import.vala"
1335 static void model_clip_importer_on_state_changed (ModelClipImporter* self, GstBus* b, GstMessage* m) {
1336 #line 1337 "import.c"
1337         GError * _inner_error_;
1338         GstState old_state = 0;
1339         GstState new_state = 0;
1340         GstState pending = 0;
1341         char* _tmp0_;
1342 #line 325 "import.vala"
1343         g_return_if_fail (MODEL_IS_CLIP_IMPORTER (self));
1344 #line 325 "import.vala"
1345         g_return_if_fail (GST_IS_BUS (b));
1346 #line 325 "import.vala"
1347         g_return_if_fail (GST_IS_MESSAGE (m));
1348 #line 1349 "import.c"
1349         _inner_error_ = NULL;
1350 #line 326 "import.vala"
1351         logging_emit (G_OBJECT (self), LOGGING_FACILITY_SIGNAL_HANDLERS, LOGGING_LEVEL_INFO, "on_state_changed");
1352 #line 327 "import.vala"
1353         if (m->src != GST_OBJECT (self->priv->pipeline)) {
1354 #line 328 "import.vala"
1355                 return;
1356 #line 1357 "import.c"
1357         }
1358 #line 334 "import.vala"
1359         gst_message_parse_state_changed (m, &old_state, &new_state, &pending);
1360 #line 336 "import.vala"
1361         if (old_state == new_state) {
1362 #line 337 "import.vala"
1363                 return;
1364 #line 1365 "import.c"
1365         }
1366 #line 339 "import.vala"
1367         logging_emit (G_OBJECT (self), LOGGING_FACILITY_IMPORT, LOGGING_LEVEL_VERBOSE, _tmp0_ = g_strdup_printf ("Import State in %s", gst_element_state_get_name (new_state)));
1368 #line 1369 "import.c"
1369         _g_free0 (_tmp0_);
1370 #line 341 "import.vala"
1371         if (new_state == GST_STATE_PAUSED) {
1372 #line 342 "import.vala"
1373                 if (!self->priv->import_done) {
1374 #line 1375 "import.c"
1375                         char* _tmp7_;
1376 #line 343 "import.vala"
1377                         if (self->priv->video_pad != NULL) {
1378 #line 1379 "import.c"
1379                                 GstCaps* _tmp3_;
1380                                 GstCaps* *_tmp2_;
1381                                 GstCaps* _tmp1_ = NULL;
1382 #line 344 "import.vala"
1383                                 _tmp2_ = &MODEL_FETCHER (self->priv->our_fetcher)->clipfile->video_caps;
1384 #line 344 "import.vala"
1385                                 (*_tmp2_) = (_tmp3_ = (g_object_get (self->priv->video_pad, "caps", &_tmp1_, NULL), _tmp1_), _gst_caps_unref0 ((*_tmp2_)), _tmp3_);
1386 #line 1387 "import.c"
1387                         }
1388 #line 346 "import.vala"
1389                         if (self->priv->audio_pad != NULL) {
1390 #line 1391 "import.c"
1391                                 GstCaps* _tmp6_;
1392                                 GstCaps* *_tmp5_;
1393                                 GstCaps* _tmp4_ = NULL;
1394 #line 347 "import.vala"
1395                                 _tmp5_ = &MODEL_FETCHER (self->priv->our_fetcher)->clipfile->audio_caps;
1396 #line 347 "import.vala"
1397                                 (*_tmp5_) = (_tmp6_ = (g_object_get (self->priv->audio_pad, "caps", &_tmp4_, NULL), _tmp4_), _gst_caps_unref0 ((*_tmp5_)), _tmp6_);
1398 #line 1399 "import.c"
1399                         }
1400 #line 349 "import.vala"
1401                         logging_emit (G_OBJECT (self), LOGGING_FACILITY_IMPORT, LOGGING_LEVEL_VERBOSE, _tmp7_ = g_strdup_printf ("Got clipfile info for: %s", MODEL_FETCHER (self->priv->our_fetcher)->clipfile->filename));
1402 #line 1403 "import.c"
1403                         _g_free0 (_tmp7_);
1404                 }
1405         } else {
1406 #line 352 "import.vala"
1407                 if (new_state == GST_STATE_NULL) {
1408 #line 353 "import.vala"
1409                         if (self->priv->import_state == MODEL_CLIP_IMPORTER_IMPORT_STATE_CANCELLED) {
1410 #line 1411 "import.c"
1411                                 char* _tmp9_;
1412                                 char* _tmp8_;
1413                                 char* _tmp11_;
1414                                 char* _tmp10_;
1415 #line 354 "import.vala"
1416                                 g_remove (_tmp9_ = append_extension (_tmp8_ = (char*) gee_abstract_list_get (GEE_ABSTRACT_LIST (self->priv->queued_filenames), self->priv->current_file_importing), "mov"));
1417 #line 1418 "import.c"
1418                                 _g_free0 (_tmp9_);
1419                                 _g_free0 (_tmp8_);
1420 #line 356 "import.vala"
1421                                 g_remove (_tmp11_ = append_extension (_tmp10_ = (char*) gee_abstract_list_get (GEE_ABSTRACT_LIST (self->priv->queued_filenames), self->priv->current_file_importing), "md5"));
1422 #line 1423 "import.c"
1423                                 _g_free0 (_tmp11_);
1424                                 _g_free0 (_tmp10_);
1425                         } else {
1426 #line 359 "import.vala"
1427                                 if (self->priv->import_done) {
1428 #line 1429 "import.c"
1429                                         {
1430 #line 361 "import.vala"
1431                                                 model_clip_importer_do_import_complete (self, &_inner_error_);
1432 #line 1433 "import.c"
1433                                                 if (_inner_error_ != NULL) {
1434                                                         goto __catch8_g_error;
1435                                                 }
1436                                         }
1437                                         goto __finally8;
1438                                         __catch8_g_error:
1439                                         {
1440                                                 GError * e;
1441                                                 e = _inner_error_;
1442                                                 _inner_error_ = NULL;
1443                                                 {
1444 #line 363 "import.vala"
1445                                                         g_signal_emit_by_name (self, "error-occurred", e->message);
1446 #line 1447 "import.c"
1447                                                         _g_error_free0 (e);
1448                                                 }
1449                                         }
1450                                         __finally8:
1451                                         if (_inner_error_ != NULL) {
1452                                                 g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
1453                                                 g_clear_error (&_inner_error_);
1454                                                 return;
1455                                         }
1456                                 }
1457                         }
1458                 }
1459         }
1460 }
1461
1462
1463 #line 369 "import.vala"
1464 static void model_clip_importer_on_eos (ModelClipImporter* self) {
1465 #line 369 "import.vala"
1466         g_return_if_fail (MODEL_IS_CLIP_IMPORTER (self));
1467 #line 370 "import.vala"
1468         logging_emit (G_OBJECT (self), LOGGING_FACILITY_SIGNAL_HANDLERS, LOGGING_LEVEL_INFO, "on_eos");
1469 #line 371 "import.vala"
1470         self->priv->import_done = TRUE;
1471 #line 372 "import.vala"
1472         gst_element_set_state (GST_ELEMENT (self->priv->pipeline), GST_STATE_NULL);
1473 #line 1474 "import.c"
1474 }
1475
1476
1477 static void model_clip_importer_class_init (ModelClipImporterClass * klass) {
1478         model_clip_importer_parent_class = g_type_class_peek_parent (klass);
1479         g_type_class_add_private (klass, sizeof (ModelClipImporterPrivate));
1480         G_OBJECT_CLASS (klass)->finalize = model_clip_importer_finalize;
1481         g_signal_new ("clip_complete", MODEL_TYPE_CLIP_IMPORTER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, MODEL_TYPE_CLIP_FILE);
1482         g_signal_new ("importing_started", MODEL_TYPE_CLIP_IMPORTER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
1483         g_signal_new ("error_occurred", MODEL_TYPE_CLIP_IMPORTER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
1484 }
1485
1486
1487 static void model_clip_importer_multi_file_progress_interface_interface_init (MultiFileProgressInterfaceIface * iface) {
1488         model_clip_importer_multi_file_progress_interface_parent_iface = g_type_interface_peek_parent (iface);
1489         iface->cancel = model_clip_importer_real_cancel;
1490         iface->complete = model_clip_importer_real_complete;
1491 }
1492
1493
1494 static void model_clip_importer_instance_init (ModelClipImporter * self) {
1495         self->priv = MODEL_CLIP_IMPORTER_GET_PRIVATE (self);
1496         self->priv->pipeline = NULL;
1497         self->priv->current_file_importing = 0;
1498         self->priv->filenames = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL);
1499         self->priv->queued_fetchers = gee_array_list_new (MODEL_TYPE_CLIP_FETCHER, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL);
1500         self->priv->queued_filenames = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL);
1501         self->priv->no_import_formats = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL);
1502 }
1503
1504
1505 static void model_clip_importer_finalize (GObject* obj) {
1506         ModelClipImporter * self;
1507         self = MODEL_CLIP_IMPORTER (obj);
1508         _g_free0 (self->priv->import_directory);
1509         _g_object_unref0 (self->priv->our_fetcher);
1510         _gst_object_unref0 (self->priv->video_pad);
1511         _gst_object_unref0 (self->priv->audio_pad);
1512         _gst_object_unref0 (self->priv->pipeline);
1513         _gst_object_unref0 (self->priv->filesink);
1514         _gst_object_unref0 (self->priv->video_convert);
1515         _gst_object_unref0 (self->priv->audio_convert);
1516         _gst_object_unref0 (self->priv->mux);
1517         _gst_object_unref0 (self->priv->video_decoder);
1518         _gst_object_unref0 (self->priv->audio_decoder);
1519         _g_object_unref0 (self->priv->filenames);
1520         _g_object_unref0 (self->priv->queued_fetchers);
1521         _g_object_unref0 (self->priv->queued_filenames);
1522         _g_object_unref0 (self->priv->no_import_formats);
1523         G_OBJECT_CLASS (model_clip_importer_parent_class)->finalize (obj);
1524 }
1525
1526
1527 GType model_clip_importer_get_type (void) {
1528         static volatile gsize model_clip_importer_type_id__volatile = 0;
1529         if (g_once_init_enter (&model_clip_importer_type_id__volatile)) {
1530                 static const GTypeInfo g_define_type_info = { sizeof (ModelClipImporterClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) model_clip_importer_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ModelClipImporter), 0, (GInstanceInitFunc) model_clip_importer_instance_init, NULL };
1531                 static const GInterfaceInfo multi_file_progress_interface_info = { (GInterfaceInitFunc) model_clip_importer_multi_file_progress_interface_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
1532                 GType model_clip_importer_type_id;
1533                 model_clip_importer_type_id = g_type_register_static (G_TYPE_OBJECT, "ModelClipImporter", &g_define_type_info, 0);
1534                 g_type_add_interface_static (model_clip_importer_type_id, TYPE_MULTI_FILE_PROGRESS_INTERFACE, &multi_file_progress_interface_info);
1535                 g_once_init_leave (&model_clip_importer_type_id__volatile, model_clip_importer_type_id);
1536         }
1537         return model_clip_importer_type_id__volatile;
1538 }
1539
1540
1541 #line 406 "import.vala"
1542 static void _model_library_importer_on_clip_complete_model_clip_importer_clip_complete (ModelClipImporter* _sender, ModelClipFile* f, gpointer self) {
1543 #line 1544 "import.c"
1544         model_library_importer_on_clip_complete (self, f);
1545 }
1546
1547
1548 #line 396 "import.vala"
1549 static void _model_library_importer_on_error_occurred_model_clip_importer_error_occurred (ModelClipImporter* _sender, const char* _error_, gpointer self) {
1550 #line 1551 "import.c"
1551         model_library_importer_on_error_occurred (self, _error_);
1552 }
1553
1554
1555 #line 391 "import.vala"
1556 static void _model_library_importer_on_importer_started_model_clip_importer_importing_started (ModelClipImporter* _sender, gint num_clips, gpointer self) {
1557 #line 1558 "import.c"
1558         model_library_importer_on_importer_started (self, _sender, num_clips);
1559 }
1560
1561
1562 #line 382 "import.vala"
1563 ModelLibraryImporter* model_library_importer_construct (GType object_type, ModelProject* p) {
1564 #line 1565 "import.c"
1565         ModelLibraryImporter * self;
1566         ModelProject* _tmp0_;
1567         ModelClipImporter* _tmp1_;
1568 #line 382 "import.vala"
1569         g_return_val_if_fail (MODEL_IS_PROJECT (p), NULL);
1570 #line 382 "import.vala"
1571         self = (ModelLibraryImporter*) g_object_new (object_type, NULL);
1572 #line 383 "import.vala"
1573         self->project = (_tmp0_ = _g_object_ref0 (p), _g_object_unref0 (self->project), _tmp0_);
1574 #line 385 "import.vala"
1575         self->importer = (_tmp1_ = model_clip_importer_new (), _g_object_unref0 (self->importer), _tmp1_);
1576 #line 386 "import.vala"
1577         g_signal_connect_object (self->importer, "clip-complete", (GCallback) _model_library_importer_on_clip_complete_model_clip_importer_clip_complete, self, 0);
1578 #line 387 "import.vala"
1579         g_signal_connect_object (self->importer, "error-occurred", (GCallback) _model_library_importer_on_error_occurred_model_clip_importer_error_occurred, self, 0);
1580 #line 388 "import.vala"
1581         g_signal_connect_object (self->importer, "importing-started", (GCallback) _model_library_importer_on_importer_started_model_clip_importer_importing_started, self, 0);
1582 #line 1583 "import.c"
1583         return self;
1584 }
1585
1586
1587 #line 382 "import.vala"
1588 ModelLibraryImporter* model_library_importer_new (ModelProject* p) {
1589 #line 382 "import.vala"
1590         return model_library_importer_construct (MODEL_TYPE_LIBRARY_IMPORTER, p);
1591 #line 1592 "import.c"
1592 }
1593
1594
1595 #line 391 "import.vala"
1596 static void model_library_importer_on_importer_started (ModelLibraryImporter* self, ModelClipImporter* i, gint num) {
1597 #line 391 "import.vala"
1598         g_return_if_fail (MODEL_IS_LIBRARY_IMPORTER (self));
1599 #line 391 "import.vala"
1600         g_return_if_fail (MODEL_IS_CLIP_IMPORTER (i));
1601 #line 392 "import.vala"
1602         logging_emit (G_OBJECT (self), LOGGING_FACILITY_SIGNAL_HANDLERS, LOGGING_LEVEL_INFO, "on_importer_started");
1603 #line 393 "import.vala"
1604         g_signal_emit_by_name (self, "started", i, num);
1605 #line 1606 "import.c"
1606 }
1607
1608
1609 #line 396 "import.vala"
1610 static void model_library_importer_on_error_occurred (ModelLibraryImporter* self, const char* _error_) {
1611 #line 396 "import.vala"
1612         g_return_if_fail (MODEL_IS_LIBRARY_IMPORTER (self));
1613 #line 396 "import.vala"
1614         g_return_if_fail (_error_ != NULL);
1615 #line 397 "import.vala"
1616         logging_emit (G_OBJECT (self), LOGGING_FACILITY_SIGNAL_HANDLERS, LOGGING_LEVEL_INFO, "on_error_occurred");
1617 #line 398 "import.vala"
1618         logging_emit (G_OBJECT (self), LOGGING_FACILITY_DEVELOPER_WARNINGS, LOGGING_LEVEL_INFO, _error_);
1619 #line 399 "import.vala"
1620         g_signal_emit_by_name (self->project, "error-occurred", "Error importing", "An error occurred importing this file.");
1621 #line 1622 "import.c"
1622 }
1623
1624
1625 #line 402 "import.vala"
1626 static void model_library_importer_real_append_existing_clipfile (ModelLibraryImporter* self, ModelClipFile* f) {
1627 #line 402 "import.vala"
1628         g_return_if_fail (MODEL_IS_LIBRARY_IMPORTER (self));
1629 #line 402 "import.vala"
1630         g_return_if_fail (MODEL_IS_CLIP_FILE (f));
1631 #line 1632 "import.c"
1632 }
1633
1634
1635 #line 402 "import.vala"
1636 void model_library_importer_append_existing_clipfile (ModelLibraryImporter* self, ModelClipFile* f) {
1637 #line 402 "import.vala"
1638         MODEL_LIBRARY_IMPORTER_GET_CLASS (self)->append_existing_clipfile (self, f);
1639 #line 1640 "import.c"
1640 }
1641
1642
1643 #line 406 "import.vala"
1644 static void model_library_importer_real_on_clip_complete (ModelLibraryImporter* self, ModelClipFile* f) {
1645 #line 1646 "import.c"
1646         ModelClipFile* cf;
1647 #line 406 "import.vala"
1648         g_return_if_fail (MODEL_IS_LIBRARY_IMPORTER (self));
1649 #line 406 "import.vala"
1650         g_return_if_fail (MODEL_IS_CLIP_FILE (f));
1651 #line 407 "import.vala"
1652         logging_emit (G_OBJECT (self), LOGGING_FACILITY_SIGNAL_HANDLERS, LOGGING_LEVEL_INFO, "on_clip_complete");
1653 #line 408 "import.vala"
1654         cf = model_project_find_clipfile (self->project, f->filename);
1655 #line 409 "import.vala"
1656         if (cf == NULL) {
1657 #line 410 "import.vala"
1658                 model_project_add_clipfile (self->project, f);
1659 #line 1660 "import.c"
1660         }
1661         _g_object_unref0 (cf);
1662 }
1663
1664
1665 #line 406 "import.vala"
1666 void model_library_importer_on_clip_complete (ModelLibraryImporter* self, ModelClipFile* f) {
1667 #line 406 "import.vala"
1668         MODEL_LIBRARY_IMPORTER_GET_CLASS (self)->on_clip_complete (self, f);
1669 #line 1670 "import.c"
1670 }
1671
1672
1673 #line 414 "import.vala"
1674 void model_library_importer_add_file (ModelLibraryImporter* self, const char* filename, GError** error) {
1675 #line 1676 "import.c"
1676         ModelClipFile* cf;
1677 #line 414 "import.vala"
1678         g_return_if_fail (MODEL_IS_LIBRARY_IMPORTER (self));
1679 #line 414 "import.vala"
1680         g_return_if_fail (filename != NULL);
1681 #line 415 "import.vala"
1682         cf = model_project_find_clipfile (self->project, filename);
1683 #line 417 "import.vala"
1684         if (cf != NULL) {
1685 #line 418 "import.vala"
1686                 model_library_importer_append_existing_clipfile (self, cf);
1687 #line 1688 "import.c"
1688         } else {
1689 #line 420 "import.vala"
1690                 model_clip_importer_add_filename (self->importer, filename);
1691 #line 1692 "import.c"
1692         }
1693         _g_object_unref0 (cf);
1694 }
1695
1696
1697 #line 423 "import.vala"
1698 void model_library_importer_start (ModelLibraryImporter* self, GError** error) {
1699 #line 1700 "import.c"
1700         GError * _inner_error_;
1701 #line 423 "import.vala"
1702         g_return_if_fail (MODEL_IS_LIBRARY_IMPORTER (self));
1703 #line 1704 "import.c"
1704         _inner_error_ = NULL;
1705 #line 424 "import.vala"
1706         model_clip_importer_start (self->importer, &_inner_error_);
1707 #line 1708 "import.c"
1708         if (_inner_error_ != NULL) {
1709                 g_propagate_error (error, _inner_error_);
1710                 return;
1711         }
1712 }
1713
1714
1715 static void model_library_importer_class_init (ModelLibraryImporterClass * klass) {
1716         model_library_importer_parent_class = g_type_class_peek_parent (klass);
1717         MODEL_LIBRARY_IMPORTER_CLASS (klass)->append_existing_clipfile = model_library_importer_real_append_existing_clipfile;
1718         MODEL_LIBRARY_IMPORTER_CLASS (klass)->on_clip_complete = model_library_importer_real_on_clip_complete;
1719         G_OBJECT_CLASS (klass)->finalize = model_library_importer_finalize;
1720         g_signal_new ("started", MODEL_TYPE_LIBRARY_IMPORTER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__OBJECT_INT, G_TYPE_NONE, 2, MODEL_TYPE_CLIP_IMPORTER, G_TYPE_INT);
1721 }
1722
1723
1724 static void model_library_importer_instance_init (ModelLibraryImporter * self) {
1725 }
1726
1727
1728 static void model_library_importer_finalize (GObject* obj) {
1729         ModelLibraryImporter * self;
1730         self = MODEL_LIBRARY_IMPORTER (obj);
1731         _g_object_unref0 (self->project);
1732         _g_object_unref0 (self->importer);
1733         G_OBJECT_CLASS (model_library_importer_parent_class)->finalize (obj);
1734 }
1735
1736
1737 GType model_library_importer_get_type (void) {
1738         static volatile gsize model_library_importer_type_id__volatile = 0;
1739         if (g_once_init_enter (&model_library_importer_type_id__volatile)) {
1740                 static const GTypeInfo g_define_type_info = { sizeof (ModelLibraryImporterClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) model_library_importer_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ModelLibraryImporter), 0, (GInstanceInitFunc) model_library_importer_instance_init, NULL };
1741                 GType model_library_importer_type_id;
1742                 model_library_importer_type_id = g_type_register_static (G_TYPE_OBJECT, "ModelLibraryImporter", &g_define_type_info, 0);
1743                 g_once_init_leave (&model_library_importer_type_id__volatile, model_library_importer_type_id);
1744         }
1745         return model_library_importer_type_id__volatile;
1746 }
1747
1748
1749 #line 433 "import.vala"
1750 ModelTimelineImporter* model_timeline_importer_construct (GType object_type, ModelTrack* track, ModelProject* p, gint64 time_to_add, gboolean both_tracks) {
1751 #line 1752 "import.c"
1752         ModelTimelineImporter * self;
1753         ModelTrack* _tmp0_;
1754 #line 433 "import.vala"
1755         g_return_val_if_fail (MODEL_IS_TRACK (track), NULL);
1756 #line 433 "import.vala"
1757         g_return_val_if_fail (MODEL_IS_PROJECT (p), NULL);
1758 #line 434 "import.vala"
1759         self = (ModelTimelineImporter*) model_library_importer_construct (object_type, p);
1760 #line 435 "import.vala"
1761         self->priv->track = (_tmp0_ = _g_object_ref0 (track), _g_object_unref0 (self->priv->track), _tmp0_);
1762 #line 436 "import.vala"
1763         self->priv->time_to_add = time_to_add;
1764 #line 437 "import.vala"
1765         self->priv->both_tracks = both_tracks;
1766 #line 1767 "import.c"
1767         return self;
1768 }
1769
1770
1771 #line 433 "import.vala"
1772 ModelTimelineImporter* model_timeline_importer_new (ModelTrack* track, ModelProject* p, gint64 time_to_add, gboolean both_tracks) {
1773 #line 433 "import.vala"
1774         return model_timeline_importer_construct (MODEL_TYPE_TIMELINE_IMPORTER, track, p, time_to_add, both_tracks);
1775 #line 1776 "import.c"
1776 }
1777
1778
1779 #line 440 "import.vala"
1780 static void model_timeline_importer_add_to_both (ModelTimelineImporter* self, ModelClipFile* clip_file) {
1781 #line 440 "import.vala"
1782         g_return_if_fail (MODEL_IS_TIMELINE_IMPORTER (self));
1783 #line 440 "import.vala"
1784         g_return_if_fail (MODEL_IS_CLIP_FILE (clip_file));
1785 #line 441 "import.vala"
1786         if (self->priv->both_tracks) {
1787 #line 1788 "import.c"
1788                 ModelTrack* other_track;
1789                 other_track = NULL;
1790 #line 443 "import.vala"
1791                 if (MODEL_IS_VIDEO_TRACK (self->priv->track)) {
1792 #line 1793 "import.c"
1793                         ModelTrack* _tmp0_;
1794 #line 444 "import.vala"
1795                         other_track = (_tmp0_ = MODEL_TRACK (model_project_find_audio_track (MODEL_LIBRARY_IMPORTER (self)->project)), _g_object_unref0 (other_track), _tmp0_);
1796 #line 1797 "import.c"
1797                 } else {
1798                         ModelTrack* _tmp1_;
1799 #line 446 "import.vala"
1800                         other_track = (_tmp1_ = MODEL_TRACK (model_project_find_video_track (MODEL_LIBRARY_IMPORTER (self)->project)), _g_object_unref0 (other_track), _tmp1_);
1801 #line 1802 "import.c"
1802                 }
1803 #line 448 "import.vala"
1804                 if (other_track != NULL) {
1805 #line 449 "import.vala"
1806                         model_project_add (MODEL_LIBRARY_IMPORTER (self)->project, other_track, clip_file, self->priv->time_to_add);
1807 #line 1808 "import.c"
1808                 }
1809                 _g_object_unref0 (other_track);
1810         }
1811 }
1812
1813
1814 #line 454 "import.vala"
1815 static void model_timeline_importer_real_append_existing_clipfile (ModelLibraryImporter* base, ModelClipFile* f) {
1816 #line 1817 "import.c"
1817         ModelTimelineImporter * self;
1818         self = MODEL_TIMELINE_IMPORTER (base);
1819 #line 454 "import.vala"
1820         g_return_if_fail (MODEL_IS_CLIP_FILE (f));
1821 #line 455 "import.vala"
1822         model_undo_manager_start_transaction (MODEL_LIBRARY_IMPORTER (self)->project->undo_manager, "Create Clip");
1823 #line 456 "import.vala"
1824         model_project_add (MODEL_LIBRARY_IMPORTER (self)->project, self->priv->track, f, self->priv->time_to_add);
1825 #line 457 "import.vala"
1826         model_timeline_importer_add_to_both (self, f);
1827 #line 458 "import.vala"
1828         model_undo_manager_end_transaction (MODEL_LIBRARY_IMPORTER (self)->project->undo_manager, "Create Clip");
1829 #line 1830 "import.c"
1830 }
1831
1832
1833 #line 461 "import.vala"
1834 static void model_timeline_importer_real_on_clip_complete (ModelLibraryImporter* base, ModelClipFile* f) {
1835 #line 1836 "import.c"
1836         ModelTimelineImporter * self;
1837         self = MODEL_TIMELINE_IMPORTER (base);
1838 #line 461 "import.vala"
1839         g_return_if_fail (MODEL_IS_CLIP_FILE (f));
1840 #line 462 "import.vala"
1841         model_undo_manager_start_transaction (MODEL_LIBRARY_IMPORTER (self)->project->undo_manager, "Create Clip");
1842 #line 463 "import.vala"
1843         MODEL_LIBRARY_IMPORTER_CLASS (model_timeline_importer_parent_class)->on_clip_complete (MODEL_LIBRARY_IMPORTER (self), f);
1844 #line 464 "import.vala"
1845         model_project_add (MODEL_LIBRARY_IMPORTER (self)->project, self->priv->track, f, self->priv->time_to_add);
1846 #line 465 "import.vala"
1847         model_timeline_importer_add_to_both (self, f);
1848 #line 466 "import.vala"
1849         model_undo_manager_end_transaction (MODEL_LIBRARY_IMPORTER (self)->project->undo_manager, "Create Clip");
1850 #line 1851 "import.c"
1851 }
1852
1853
1854 static void model_timeline_importer_class_init (ModelTimelineImporterClass * klass) {
1855         model_timeline_importer_parent_class = g_type_class_peek_parent (klass);
1856         g_type_class_add_private (klass, sizeof (ModelTimelineImporterPrivate));
1857         MODEL_LIBRARY_IMPORTER_CLASS (klass)->append_existing_clipfile = model_timeline_importer_real_append_existing_clipfile;
1858         MODEL_LIBRARY_IMPORTER_CLASS (klass)->on_clip_complete = model_timeline_importer_real_on_clip_complete;
1859         G_OBJECT_CLASS (klass)->finalize = model_timeline_importer_finalize;
1860 }
1861
1862
1863 static void model_timeline_importer_instance_init (ModelTimelineImporter * self) {
1864         self->priv = MODEL_TIMELINE_IMPORTER_GET_PRIVATE (self);
1865 }
1866
1867
1868 static void model_timeline_importer_finalize (GObject* obj) {
1869         ModelTimelineImporter * self;
1870         self = MODEL_TIMELINE_IMPORTER (obj);
1871         _g_object_unref0 (self->priv->track);
1872         G_OBJECT_CLASS (model_timeline_importer_parent_class)->finalize (obj);
1873 }
1874
1875
1876 GType model_timeline_importer_get_type (void) {
1877         static volatile gsize model_timeline_importer_type_id__volatile = 0;
1878         if (g_once_init_enter (&model_timeline_importer_type_id__volatile)) {
1879                 static const GTypeInfo g_define_type_info = { sizeof (ModelTimelineImporterClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) model_timeline_importer_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ModelTimelineImporter), 0, (GInstanceInitFunc) model_timeline_importer_instance_init, NULL };
1880                 GType model_timeline_importer_type_id;
1881                 model_timeline_importer_type_id = g_type_register_static (MODEL_TYPE_LIBRARY_IMPORTER, "ModelTimelineImporter", &g_define_type_info, 0);
1882                 g_once_init_leave (&model_timeline_importer_type_id__volatile, model_timeline_importer_type_id);
1883         }
1884         return model_timeline_importer_type_id__volatile;
1885 }
1886
1887
1888 static int _vala_strcmp0 (const char * str1, const char * str2) {
1889         if (str1 == NULL) {
1890                 return -(str1 != str2);
1891         }
1892         if (str2 == NULL) {
1893                 return str1 != str2;
1894         }
1895         return strcmp (str1, str2);
1896 }
1897
1898
1899
1900 static void g_cclosure_user_marshal_VOID__OBJECT_INT (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data) {
1901         typedef void (*GMarshalFunc_VOID__OBJECT_INT) (gpointer data1, gpointer arg_1, gint arg_2, gpointer data2);
1902         register GMarshalFunc_VOID__OBJECT_INT callback;
1903         register GCClosure * cc;
1904         register gpointer data1, data2;
1905         cc = (GCClosure *) closure;
1906         g_return_if_fail (n_param_values == 3);
1907         if (G_CCLOSURE_SWAP_DATA (closure)) {
1908                 data1 = closure->data;
1909                 data2 = param_values->data[0].v_pointer;
1910         } else {
1911                 data1 = param_values->data[0].v_pointer;
1912                 data2 = closure->data;
1913         }
1914         callback = (GMarshalFunc_VOID__OBJECT_INT) (marshal_data ? marshal_data : cc->callback);
1915         callback (data1, g_value_get_object (param_values + 1), g_value_get_int (param_values + 2), data2);
1916 }
1917
1918
1919