1 /* GStreamer Editing Services
2 * Copyright (C) 2009 Edward Hervey <edward.hervey@collabora.co.uk>
3 * 2009 Nokia Corporation
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
24 #include <gst/pbutils/encoding-profile.h>
29 #ifndef GST_CAT_DEFAULT
30 #define GST_CAT_DEFAULT (_ges_debug ())
33 #include "ges-timeline.h"
34 #include "ges-track-element.h"
35 #include "ges-timeline-element.h"
37 #include "ges-asset.h"
38 #include "ges-base-xml-formatter.h"
39 #include "ges-timeline-tree.h"
42 GstDebugCategory * _ges_debug (void);
44 /* The first 2 NLE priorities are used for:
45 * 0- The Mixing element
48 #define MIN_NLE_PRIO 2
49 #define LAYER_HEIGHT 1000
51 #define _START(obj) GES_TIMELINE_ELEMENT_START (obj)
52 #define _INPOINT(obj) GES_TIMELINE_ELEMENT_INPOINT (obj)
53 #define _DURATION(obj) GES_TIMELINE_ELEMENT_DURATION (obj)
54 #define _MAXDURATION(obj) GES_TIMELINE_ELEMENT_MAX_DURATION (obj)
55 #define _PRIORITY(obj) GES_TIMELINE_ELEMENT_PRIORITY (obj)
57 #define _END(obj) (_START (obj) + _DURATION (obj))
59 #define _set_start0 ges_timeline_element_set_start
60 #define _set_inpoint0 ges_timeline_element_set_inpoint
61 #define _set_duration0 ges_timeline_element_set_duration
62 #define _set_priority0 ges_timeline_element_set_priority
64 #define GES_CLOCK_TIME_IS_LESS(first, second) \
65 (GST_CLOCK_TIME_IS_VALID (first) && (!GST_CLOCK_TIME_IS_VALID (second) \
66 || (first) < (second)))
68 #define DEFAULT_FRAMERATE_N 30
69 #define DEFAULT_FRAMERATE_D 1
70 #define DEFAULT_WIDTH 1280
71 #define DEFAULT_HEIGHT 720
73 #define GES_TIMELINE_ELEMENT_FORMAT \
75 " [ %" GST_TIME_FORMAT \
76 " (%" GST_TIME_FORMAT \
77 ") - %" GST_TIME_FORMAT "(%" GST_TIME_FORMAT") layer: %" G_GINT32_FORMAT "] "
79 #define GES_TIMELINE_ELEMENT_ARGS(element) \
80 GES_TIMELINE_ELEMENT_NAME(element), element, \
81 GST_TIME_ARGS(GES_TIMELINE_ELEMENT_START(element)), \
82 GST_TIME_ARGS(GES_TIMELINE_ELEMENT_INPOINT(element)), \
83 GST_TIME_ARGS(GES_TIMELINE_ELEMENT_DURATION(element)), \
84 GST_TIME_ARGS(GES_TIMELINE_ELEMENT_MAX_DURATION(element)), \
85 GES_TIMELINE_ELEMENT_LAYER_PRIORITY(element)
87 #define GES_FORMAT GES_TIMELINE_ELEMENT_FORMAT
88 #define GES_ARGS GES_TIMELINE_ELEMENT_ARGS
90 #define GES_IS_TIME_EFFECT(element) \
91 (GES_IS_BASE_EFFECT (element) \
92 && ges_base_effect_is_time_effect (GES_BASE_EFFECT (element)))
94 #define GES_TIMELINE_ELEMENT_SET_BEING_EDITED(element) \
96 ges_timeline_element_peak_toplevel (GES_TIMELINE_ELEMENT (element)), \
97 GES_TIMELINE_ELEMENT_SET_SIMPLE)
99 #define GES_TIMELINE_ELEMENT_UNSET_BEING_EDITED(element) \
100 ELEMENT_UNSET_FLAG ( \
101 ges_timeline_element_peak_toplevel (GES_TIMELINE_ELEMENT (element)), \
102 GES_TIMELINE_ELEMENT_SET_SIMPLE)
104 #define GES_TIMELINE_ELEMENT_BEING_EDITED(element) \
105 ELEMENT_FLAG_IS_SET ( \
106 ges_timeline_element_peak_toplevel (GES_TIMELINE_ELEMENT (element)), \
107 GES_TIMELINE_ELEMENT_SET_SIMPLE)
109 #define SUPRESS_UNUSED_WARNING(a) (void)a
112 ges_timeline_freeze_auto_transitions (GESTimeline * timeline, gboolean freeze);
114 G_GNUC_INTERNAL GESAutoTransition *
115 ges_timeline_get_auto_transition_at_end (GESTimeline * timeline, GESTrackElement * source);
117 G_GNUC_INTERNAL gboolean ges_timeline_is_disposed (GESTimeline* timeline);
119 G_GNUC_INTERNAL gboolean
120 ges_timeline_edit (GESTimeline * timeline, GESTimelineElement * element,
121 gint64 new_layer_priority, GESEditMode mode, GESEdge edge,
122 guint64 position, GError ** error);
125 timeline_add_group (GESTimeline *timeline,
128 timeline_remove_group (GESTimeline *timeline,
131 timeline_emit_group_added (GESTimeline *timeline,
134 timeline_emit_group_removed (GESTimeline * timeline,
135 GESGroup * group, GPtrArray * array);
139 timeline_add_element (GESTimeline *timeline,
140 GESTimelineElement *element);
143 timeline_remove_element (GESTimeline *timeline,
144 GESTimelineElement *element);
148 timeline_get_tree (GESTimeline *timeline);
152 timeline_fill_gaps (GESTimeline *timeline);
155 timeline_create_transitions (GESTimeline * timeline, GESTrackElement * track_element);
157 G_GNUC_INTERNAL void timeline_get_framerate(GESTimeline *self, gint *fps_n,
160 ges_timeline_set_moving_track_elements (GESTimeline * timeline, gboolean moving);
162 G_GNUC_INTERNAL gboolean
163 ges_timeline_add_clip (GESTimeline * timeline, GESClip * clip, GError ** error);
166 ges_timeline_remove_clip (GESTimeline * timeline, GESClip * clip);
169 ges_auto_transition_set_previous_source (GESAutoTransition * self, GESTrackElement * source);
175 track_resort_and_fill_gaps (GESTrack *track);
179 track_disable_last_gap (GESTrack *track, gboolean disabled);
182 ges_asset_cache_init (void);
185 ges_asset_cache_deinit (void);
188 ges_asset_set_id (GESAsset *asset, const gchar *id);
191 ges_asset_cache_put (GESAsset * asset, GTask *task);
193 G_GNUC_INTERNAL gboolean
194 ges_asset_cache_set_loaded(GType extractable_type, const gchar * id, GError *error);
196 /* FIXME: marked as GES_API just so they can be used in tests! */
199 ges_asset_cache_lookup(GType extractable_type, const gchar * id);
202 ges_asset_try_proxy (GESAsset *asset, const gchar *new_id);
204 G_GNUC_INTERNAL gboolean
205 ges_asset_finish_proxy (GESAsset * proxy);
207 G_GNUC_INTERNAL gboolean
208 ges_asset_request_id_update (GESAsset *asset, gchar **proposed_id,
210 G_GNUC_INTERNAL gchar *
211 ges_effect_assect_id_get_type_and_bindesc (const char *id,
212 GESTrackType *track_type,
215 G_GNUC_INTERNAL void _ges_uri_asset_cleanup (void);
217 G_GNUC_INTERNAL gboolean _ges_uri_asset_ensure_setup (gpointer uriasset_class);
219 /* GESExtractable internall methods
221 * FIXME Check if that should be public later
223 G_GNUC_INTERNAL GType
224 ges_extractable_type_get_asset_type (GType type);
226 G_GNUC_INTERNAL gchar *
227 ges_extractable_type_check_id (GType type, const gchar *id, GError **error);
229 G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
230 G_GNUC_INTERNAL GParameter *
231 ges_extractable_type_get_parameters_from_id (GType type, const gchar *id,
233 G_GNUC_END_IGNORE_DEPRECATIONS;
235 G_GNUC_INTERNAL GType
236 ges_extractable_get_real_extractable_type_for_id (GType type, const gchar * id);
238 G_GNUC_INTERNAL gboolean
239 ges_extractable_register_metas (GType extractable_type, GESAsset *asset);
241 /************************************************
243 * GESFormatter internal methods *
245 ************************************************/
247 ges_formatter_set_project (GESFormatter *formatter,
248 GESProject *project);
249 G_GNUC_INTERNAL GESProject *
250 ges_formatter_get_project (GESFormatter *formatter);
251 G_GNUC_INTERNAL GESAsset *
252 _find_formatter_asset_for_id (const gchar *id);
256 /************************************************
258 * GESProject internal methods *
260 ************************************************/
262 /* FIXME This should probably become public, but we need to make sure it
263 * is the right API before doing so */
264 G_GNUC_INTERNAL gboolean ges_project_set_loaded (GESProject * project,
265 GESFormatter *formatter,
267 G_GNUC_INTERNAL gchar * ges_project_try_updating_id (GESProject *self,
270 G_GNUC_INTERNAL void ges_project_add_loading_asset (GESProject *project,
271 GType extractable_type,
273 G_GNUC_INTERNAL gchar* ges_uri_asset_try_update_id (GError *error, GESAsset *wrong_asset);
274 /************************************************
276 * GESBaseXmlFormatter internal methods *
278 ************************************************/
280 /* FIXME GESBaseXmlFormatter is all internal for now, the API is not stable
281 * fo now, so do not expose it */
282 G_GNUC_INTERNAL void ges_base_xml_formatter_add_clip (GESBaseXmlFormatter * self,
284 const char *asset_id,
287 GstClockTime inpoint,
288 GstClockTime duration,
290 GESTrackType track_types,
291 GstStructure *properties,
292 GstStructure * children_properties,
293 const gchar *metadatas,
295 G_GNUC_INTERNAL void ges_base_xml_formatter_add_asset (GESBaseXmlFormatter * self,
297 GType extractable_type,
298 GstStructure *properties,
299 const gchar *metadatas,
300 const gchar *proxy_id,
302 G_GNUC_INTERNAL void ges_base_xml_formatter_add_layer (GESBaseXmlFormatter *self,
303 GType extractable_type,
305 GstStructure *properties,
306 const gchar *metadatas,
307 gchar **deactivated_tracks,
309 G_GNUC_INTERNAL void ges_base_xml_formatter_add_track (GESBaseXmlFormatter *self,
310 GESTrackType track_type,
313 GstStructure *properties,
314 const gchar *metadatas,
316 G_GNUC_INTERNAL void ges_base_xml_formatter_add_encoding_profile(GESBaseXmlFormatter * self,
320 const gchar * description,
322 const gchar * preset,
323 GstStructure * preset_properties,
324 const gchar * preset_name,
327 GstCaps * restriction,
329 gboolean variableframerate,
330 GstStructure * properties,
333 G_GNUC_INTERNAL void ges_base_xml_formatter_add_track_element (GESBaseXmlFormatter *self,
335 const gchar *asset_id,
336 const gchar * track_id,
337 const gchar *timeline_obj_id,
338 GstStructure *children_properties,
339 GstStructure *properties,
340 const gchar *metadatas,
343 G_GNUC_INTERNAL void ges_base_xml_formatter_add_source (GESBaseXmlFormatter *self,
344 const gchar * track_id,
345 GstStructure *children_properties,
346 GstStructure *properties);
348 G_GNUC_INTERNAL void ges_base_xml_formatter_add_group (GESBaseXmlFormatter *self,
350 const gchar *properties,
351 const gchar *metadatas);
353 G_GNUC_INTERNAL void ges_base_xml_formatter_last_group_add_child(GESBaseXmlFormatter *self,
357 G_GNUC_INTERNAL void ges_base_xml_formatter_add_control_binding (GESBaseXmlFormatter * self,
358 const gchar * binding_type,
359 const gchar * source_type,
360 const gchar * property_name,
362 const gchar *track_id,
363 GSList * timed_values);
365 G_GNUC_INTERNAL void ges_base_xml_formatter_set_timeline_properties(GESBaseXmlFormatter * self,
366 GESTimeline *timeline,
367 const gchar *properties,
368 const gchar *metadatas);
369 G_GNUC_INTERNAL void ges_xml_formatter_deinit (void);
371 G_GNUC_INTERNAL gboolean set_property_foreach (GQuark field_id,
372 const GValue * value,
375 G_GNUC_INTERNAL GstElement * get_element_for_encoding_profile (GstEncodingProfile *prof,
376 GstElementFactoryListType type);
378 /* Function to initialise GES */
379 G_GNUC_INTERNAL void _init_standard_transition_assets (void);
380 G_GNUC_INTERNAL void _init_formatter_assets (void);
381 G_GNUC_INTERNAL void _deinit_formatter_assets (void);
384 G_GNUC_INTERNAL gint element_start_compare (GESTimelineElement * a,
385 GESTimelineElement * b);
386 G_GNUC_INTERNAL gint element_end_compare (GESTimelineElement * a,
387 GESTimelineElement * b);
388 G_GNUC_INTERNAL GstElementFactory *
389 ges_get_compositor_factory (void);
392 ges_idle_add (GSourceFunc func, gpointer udata, GDestroyNotify notify);
394 G_GNUC_INTERNAL gboolean
395 ges_util_structure_get_clocktime (GstStructure *structure, const gchar *name,
396 GstClockTime *val, GESFrameNumber *frames);
399 /****************************************************
401 ****************************************************/
402 G_GNUC_INTERNAL void _ges_container_sort_children (GESContainer *container);
403 G_GNUC_INTERNAL void _ges_container_set_height (GESContainer * container,
406 /****************************************************
408 ****************************************************/
409 G_GNUC_INTERNAL void ges_clip_set_layer (GESClip *clip, GESLayer *layer);
410 G_GNUC_INTERNAL gboolean ges_clip_is_moving_from_layer (GESClip *clip);
411 G_GNUC_INTERNAL void ges_clip_set_moving_from_layer (GESClip *clip, gboolean is_moving);
412 G_GNUC_INTERNAL GESTrackElement* ges_clip_create_track_element (GESClip *clip, GESTrackType type);
413 G_GNUC_INTERNAL GList* ges_clip_create_track_elements (GESClip *clip, GESTrackType type);
414 G_GNUC_INTERNAL gboolean ges_clip_can_set_inpoint_of_child (GESClip * clip, GESTrackElement * child, GstClockTime inpoint, GError ** error);
415 G_GNUC_INTERNAL gboolean ges_clip_can_set_max_duration_of_child (GESClip * clip, GESTrackElement * child, GstClockTime max_duration, GError ** error);
416 G_GNUC_INTERNAL gboolean ges_clip_can_set_active_of_child (GESClip * clip, GESTrackElement * child, gboolean active, GError ** error);
417 G_GNUC_INTERNAL gboolean ges_clip_can_set_priority_of_child (GESClip * clip, GESTrackElement * child, guint32 priority, GError ** error);
418 G_GNUC_INTERNAL gboolean ges_clip_can_set_track_of_child (GESClip * clip, GESTrackElement * child, GESTrack * tack, GError ** error);
419 G_GNUC_INTERNAL gboolean ges_clip_can_set_time_property_of_child (GESClip * clip, GESTrackElement * child, GObject * prop_object, GParamSpec * pspec, const GValue * value, GError ** error);
420 G_GNUC_INTERNAL void ges_clip_empty_from_track (GESClip * clip, GESTrack * track);
422 /****************************************************
424 ****************************************************/
425 G_GNUC_INTERNAL gboolean ges_layer_resync_priorities (GESLayer * layer);
426 G_GNUC_INTERNAL void layer_set_priority (GESLayer * layer, guint priority, gboolean emit);
428 /****************************************************
430 ****************************************************/
431 #define NLE_OBJECT_TRACK_ELEMENT_QUARK (g_quark_from_string ("nle_object_track_element_quark"))
432 G_GNUC_INTERNAL gboolean ges_track_element_set_track (GESTrackElement * object, GESTrack * track, GError ** error);
433 G_GNUC_INTERNAL void ges_track_element_copy_properties (GESTimelineElement * element,
434 GESTimelineElement * elementcopy);
435 G_GNUC_INTERNAL void ges_track_element_set_layer_active (GESTrackElement *element, gboolean active);
437 G_GNUC_INTERNAL void ges_track_element_copy_bindings (GESTrackElement *element,
438 GESTrackElement *new_element,
442 ges_track_element_set_creator_asset (GESTrackElement * self,
443 GESAsset *creator_asset);
444 G_GNUC_INTERNAL GESAsset *
445 ges_track_element_get_creator_asset (GESTrackElement * self);
448 ges_track_element_set_has_internal_source_is_forbidden (GESTrackElement * element);
450 G_GNUC_INTERNAL GstElement* ges_source_create_topbin(const gchar* bin_name, GstElement* sub_element, GPtrArray* elements);
451 G_GNUC_INTERNAL void ges_track_set_caps(GESTrack* track,
452 const GstCaps* caps);
453 G_GNUC_INTERNAL GstElement * ges_track_get_composition (GESTrack *track);
456 /*********************************************
457 * GESTrackElement subclasses contructores *
458 ********************************************/
459 G_GNUC_INTERNAL GESAudioTestSource * ges_audio_test_source_new (void);
460 G_GNUC_INTERNAL GESAudioUriSource * ges_audio_uri_source_new (gchar *uri);
461 G_GNUC_INTERNAL GESVideoUriSource * ges_video_uri_source_new (gchar *uri);
462 G_GNUC_INTERNAL GESImageSource * ges_image_source_new (gchar *uri);
463 G_GNUC_INTERNAL GESTitleSource * ges_title_source_new (void);
464 G_GNUC_INTERNAL GESVideoTestSource * ges_video_test_source_new (void);
466 /****************************************************
468 ****************************************************/
469 G_GNUC_INTERNAL gchar *
470 ges_base_effect_get_time_property_name (GESBaseEffect * effect,
473 G_GNUC_INTERNAL GHashTable *
474 ges_base_effect_get_time_property_values (GESBaseEffect * effect);
475 G_GNUC_INTERNAL GstClockTime
476 ges_base_effect_translate_source_to_sink_time (GESBaseEffect * effect,
478 GHashTable * time_property_values);
479 G_GNUC_INTERNAL GstClockTime
480 ges_base_effect_translate_sink_to_source_time (GESBaseEffect * effect,
482 GHashTable * time_property_values);
484 /****************************************************
485 * GESTimelineElement *
486 ****************************************************/
489 GES_CLIP_IS_MOVING = (1 << 0),
490 GES_TIMELINE_ELEMENT_SET_SIMPLE = (1 << 1),
491 } GESTimelineElementFlags;
493 G_GNUC_INTERNAL GESTimelineElement * ges_timeline_element_peak_toplevel (GESTimelineElement * self);
494 G_GNUC_INTERNAL gdouble ges_timeline_element_get_media_duration_factor(GESTimelineElement *self);
495 G_GNUC_INTERNAL GESTimelineElement * ges_timeline_element_get_copied_from (GESTimelineElement *self);
496 G_GNUC_INTERNAL GESTimelineElementFlags ges_timeline_element_flags (GESTimelineElement *self);
497 G_GNUC_INTERNAL void ges_timeline_element_set_flags (GESTimelineElement *self, GESTimelineElementFlags flags);
498 G_GNUC_INTERNAL gboolean ges_timeline_element_add_child_property_full (GESTimelineElement *self,
499 GESTimelineElement *owner,
503 G_GNUC_INTERNAL GObject * ges_timeline_element_get_child_from_child_property (GESTimelineElement * self,
505 G_GNUC_INTERNAL GParamSpec ** ges_timeline_element_get_children_properties (GESTimelineElement * self,
506 guint * n_properties);
508 #define ELEMENT_FLAGS(obj) (ges_timeline_element_flags (GES_TIMELINE_ELEMENT(obj)))
509 #define ELEMENT_SET_FLAG(obj,flag) (ges_timeline_element_set_flags(GES_TIMELINE_ELEMENT(obj), (ELEMENT_FLAGS(obj) | (flag))))
510 #define ELEMENT_UNSET_FLAG(obj,flag) (ges_timeline_element_set_flags(GES_TIMELINE_ELEMENT(obj), (ELEMENT_FLAGS(obj) & ~(flag))))
511 #define ELEMENT_FLAG_IS_SET(obj,flag) ((ELEMENT_FLAGS (obj) & (flag)) == (flag))
513 /******************************
514 * GESMultiFile internal API *
515 ******************************/
516 typedef struct GESMultiFileURI
523 G_GNUC_INTERNAL GESMultiFileURI * ges_multi_file_uri_new (const gchar * uri);
525 /******************************
526 * GESUriSource internal API *
527 ******************************/
528 G_GNUC_INTERNAL gboolean
529 ges_video_uri_source_get_natural_size(GESVideoSource* source, gint* width, gint* height);
531 /**********************************
532 * GESTestClipAsset internal API *
533 **********************************/
534 G_GNUC_INTERNAL gboolean ges_test_clip_asset_get_natural_size (GESAsset *self,
537 G_GNUC_INTERNAL gchar *ges_test_source_asset_check_id (GType type, const gchar *id,
540 /************************
541 * Our property masks *
542 ************************/
543 #define GES_PARAM_NO_SERIALIZATION (1 << (G_PARAM_USER_SHIFT + 1))
545 /*******************************
546 * GESMarkerList serialization *
547 *******************************/
550 G_GNUC_INTERNAL gchar * ges_marker_list_serialize (const GValue * v);
551 G_GNUC_INTERNAL gboolean ges_marker_list_deserialize (GValue *dest, const gchar *s);
553 /********************
555 ********************/
557 G_GNUC_INTERNAL gboolean ges_nle_composition_add_object (GstElement *comp, GstElement *object);
558 G_GNUC_INTERNAL gboolean ges_nle_composition_remove_object (GstElement *comp, GstElement *object);
559 G_GNUC_INTERNAL gboolean ges_nle_object_commit (GstElement * nlesource, gboolean recurse);