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 DEFAULT_FRAMERATE_N 30
65 #define DEFAULT_FRAMERATE_D 1
66 #define DEFAULT_WIDTH 1280
67 #define DEFAULT_HEIGHT 720
69 #define GES_TIMELINE_ELEMENT_FORMAT \
71 " [ %" GST_TIME_FORMAT \
72 " (%" GST_TIME_FORMAT \
73 ") - %" GST_TIME_FORMAT "(%" GST_TIME_FORMAT") layer: %" G_GINT32_FORMAT "] "
75 #define GES_TIMELINE_ELEMENT_ARGS(element) \
76 GES_TIMELINE_ELEMENT_NAME(element), element, \
77 GST_TIME_ARGS(GES_TIMELINE_ELEMENT_START(element)), \
78 GST_TIME_ARGS(GES_TIMELINE_ELEMENT_INPOINT(element)), \
79 GST_TIME_ARGS(GES_TIMELINE_ELEMENT_DURATION(element)), \
80 GST_TIME_ARGS(GES_TIMELINE_ELEMENT_MAX_DURATION(element)), \
81 GES_TIMELINE_ELEMENT_LAYER_PRIORITY(element)
83 #define GES_FORMAT GES_TIMELINE_ELEMENT_FORMAT
84 #define GES_ARGS GES_TIMELINE_ELEMENT_ARGS
86 #define GES_TRACK_ELEMENT_IS_CORE(child) \
87 (ges_track_element_get_creators (GES_TRACK_ELEMENT (child)) != NULL)
89 #define SUPRESS_UNUSED_WARNING(a) (void)a
91 G_GNUC_INTERNAL gboolean
92 timeline_ripple_object (GESTimeline *timeline, GESTimelineElement *obj,
93 gint new_layer_priority,
94 GList * layers, GESEdge edge,
97 G_GNUC_INTERNAL gboolean
98 timeline_slide_object (GESTimeline *timeline, GESTrackElement *obj,
99 GList * layers, GESEdge edge, guint64 position);
101 G_GNUC_INTERNAL gboolean
102 timeline_roll_object (GESTimeline *timeline, GESTimelineElement *obj,
103 GList * layers, GESEdge edge, guint64 position);
105 G_GNUC_INTERNAL gboolean
106 timeline_trim_object (GESTimeline *timeline, GESTimelineElement * object,
107 guint32 new_layer_priority, GList * layers, GESEdge edge,
109 G_GNUC_INTERNAL gboolean
110 ges_timeline_trim_object_simple (GESTimeline * timeline, GESTimelineElement * obj,
111 guint32 new_layer_priority, GList * layers, GESEdge edge,
112 guint64 position, gboolean snapping);
114 G_GNUC_INTERNAL gboolean
115 ges_timeline_move_object_simple (GESTimeline * timeline, GESTimelineElement * object,
116 GList * layers, GESEdge edge, guint64 position);
118 G_GNUC_INTERNAL gboolean
119 timeline_move_object (GESTimeline *timeline, GESTimelineElement * object,
120 guint32 new_layer_priority, GList * layers, GESEdge edge,
124 timeline_add_group (GESTimeline *timeline,
127 timeline_remove_group (GESTimeline *timeline,
130 timeline_emit_group_added (GESTimeline *timeline,
133 timeline_emit_group_removed (GESTimeline * timeline,
134 GESGroup * group, GPtrArray * array);
138 timeline_add_element (GESTimeline *timeline,
139 GESTimelineElement *element);
142 timeline_remove_element (GESTimeline *timeline,
143 GESTimelineElement *element);
147 timeline_get_tree (GESTimeline *timeline);
151 timeline_update_transition (GESTimeline *timeline);
155 timeline_fill_gaps (GESTimeline *timeline);
158 timeline_create_transitions (GESTimeline * timeline, GESTrackElement * track_element);
160 G_GNUC_INTERNAL void timeline_get_framerate(GESTimeline *self, gint *fps_n,
163 ges_timeline_set_moving_track_elements (GESTimeline * timeline, gboolean moving);
165 G_GNUC_INTERNAL gboolean
166 ges_timeline_add_clip (GESTimeline * timeline, GESClip * clip);
169 ges_timeline_remove_clip (GESTimeline * timeline, GESClip * clip);
173 track_resort_and_fill_gaps (GESTrack *track);
177 track_disable_last_gap (GESTrack *track, gboolean disabled);
180 ges_asset_cache_init (void);
183 ges_asset_cache_deinit (void);
186 ges_asset_set_id (GESAsset *asset, const gchar *id);
189 ges_asset_cache_put (GESAsset * asset, GTask *task);
191 G_GNUC_INTERNAL gboolean
192 ges_asset_cache_set_loaded(GType extractable_type, const gchar * id, GError *error);
194 /* FIXME: marked as GES_API just so they can be used in tests! */
197 ges_asset_cache_lookup(GType extractable_type, const gchar * id);
200 ges_asset_try_proxy (GESAsset *asset, const gchar *new_id);
202 G_GNUC_INTERNAL gboolean
203 ges_asset_finish_proxy (GESAsset * proxy);
205 G_GNUC_INTERNAL gboolean
206 ges_asset_request_id_update (GESAsset *asset, gchar **proposed_id,
208 G_GNUC_INTERNAL gchar *
209 ges_effect_assect_id_get_type_and_bindesc (const char *id,
210 GESTrackType *track_type,
213 G_GNUC_INTERNAL void _ges_uri_asset_cleanup (void);
215 G_GNUC_INTERNAL gboolean _ges_uri_asset_ensure_setup (gpointer uriasset_class);
217 /* GESExtractable internall methods
219 * FIXME Check if that should be public later
221 G_GNUC_INTERNAL GType
222 ges_extractable_type_get_asset_type (GType type);
224 G_GNUC_INTERNAL gchar *
225 ges_extractable_type_check_id (GType type, const gchar *id, GError **error);
227 G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
228 G_GNUC_INTERNAL GParameter *
229 ges_extractable_type_get_parameters_from_id (GType type, const gchar *id,
231 G_GNUC_END_IGNORE_DEPRECATIONS;
233 G_GNUC_INTERNAL GType
234 ges_extractable_get_real_extractable_type_for_id (GType type, const gchar * id);
236 G_GNUC_INTERNAL gboolean
237 ges_extractable_register_metas (GType extractable_type, GESAsset *asset);
239 /************************************************
241 * GESFormatter internal methods *
243 ************************************************/
245 ges_formatter_set_project (GESFormatter *formatter,
246 GESProject *project);
247 G_GNUC_INTERNAL GESProject *
248 ges_formatter_get_project (GESFormatter *formatter);
249 G_GNUC_INTERNAL GESAsset *
250 _find_formatter_asset_for_id (const gchar *id);
254 /************************************************
256 * GESProject internal methods *
258 ************************************************/
260 /* FIXME This should probably become public, but we need to make sure it
261 * is the right API before doing so */
262 G_GNUC_INTERNAL gboolean ges_project_set_loaded (GESProject * project,
263 GESFormatter *formatter,
265 G_GNUC_INTERNAL gchar * ges_project_try_updating_id (GESProject *self,
268 G_GNUC_INTERNAL void ges_project_add_loading_asset (GESProject *project,
269 GType extractable_type,
271 G_GNUC_INTERNAL gchar* ges_uri_asset_try_update_id (GError *error, GESAsset *wrong_asset);
272 /************************************************
274 * GESBaseXmlFormatter internal methods *
276 ************************************************/
278 /* FIXME GESBaseXmlFormatter is all internal for now, the API is not stable
279 * fo now, so do not expose it */
280 G_GNUC_INTERNAL void ges_base_xml_formatter_add_clip (GESBaseXmlFormatter * self,
282 const char *asset_id,
285 GstClockTime inpoint,
286 GstClockTime duration,
288 GESTrackType track_types,
289 GstStructure *properties,
290 GstStructure * children_properties,
291 const gchar *metadatas,
293 G_GNUC_INTERNAL void ges_base_xml_formatter_add_asset (GESBaseXmlFormatter * self,
295 GType extractable_type,
296 GstStructure *properties,
297 const gchar *metadatas,
298 const gchar *proxy_id,
300 G_GNUC_INTERNAL void ges_base_xml_formatter_add_layer (GESBaseXmlFormatter *self,
301 GType extractable_type,
303 GstStructure *properties,
304 const gchar *metadatas,
305 gchar **deactivated_tracks,
307 G_GNUC_INTERNAL void ges_base_xml_formatter_add_track (GESBaseXmlFormatter *self,
308 GESTrackType track_type,
311 GstStructure *properties,
312 const gchar *metadatas,
314 G_GNUC_INTERNAL void ges_base_xml_formatter_add_encoding_profile(GESBaseXmlFormatter * self,
318 const gchar * description,
320 const gchar * preset,
321 GstStructure * preset_properties,
322 const gchar * preset_name,
325 GstCaps * restriction,
327 gboolean variableframerate,
328 GstStructure * properties,
331 G_GNUC_INTERNAL void ges_base_xml_formatter_add_track_element (GESBaseXmlFormatter *self,
333 const gchar *asset_id,
334 const gchar * track_id,
335 const gchar *timeline_obj_id,
336 GstStructure *children_properties,
337 GstStructure *properties,
338 const gchar *metadatas,
341 G_GNUC_INTERNAL void ges_base_xml_formatter_add_source (GESBaseXmlFormatter *self,
342 const gchar * track_id,
343 GstStructure *children_properties,
344 GstStructure *properties);
346 G_GNUC_INTERNAL void ges_base_xml_formatter_add_group (GESBaseXmlFormatter *self,
348 const gchar *properties,
349 const gchar *metadatas);
351 G_GNUC_INTERNAL void ges_base_xml_formatter_last_group_add_child(GESBaseXmlFormatter *self,
355 G_GNUC_INTERNAL void ges_base_xml_formatter_add_control_binding (GESBaseXmlFormatter * self,
356 const gchar * binding_type,
357 const gchar * source_type,
358 const gchar * property_name,
360 const gchar *track_id,
361 GSList * timed_values);
363 G_GNUC_INTERNAL void ges_base_xml_formatter_set_timeline_properties(GESBaseXmlFormatter * self,
364 GESTimeline *timeline,
365 const gchar *properties,
366 const gchar *metadatas);
367 G_GNUC_INTERNAL void ges_xml_formatter_deinit (void);
369 G_GNUC_INTERNAL gboolean set_property_foreach (GQuark field_id,
370 const GValue * value,
373 G_GNUC_INTERNAL GstElement * get_element_for_encoding_profile (GstEncodingProfile *prof,
374 GstElementFactoryListType type);
376 /* Function to initialise GES */
377 G_GNUC_INTERNAL void _init_standard_transition_assets (void);
378 G_GNUC_INTERNAL void _init_formatter_assets (void);
379 G_GNUC_INTERNAL void _deinit_formatter_assets (void);
382 G_GNUC_INTERNAL gint element_start_compare (GESTimelineElement * a,
383 GESTimelineElement * b);
384 G_GNUC_INTERNAL gint element_end_compare (GESTimelineElement * a,
385 GESTimelineElement * b);
386 G_GNUC_INTERNAL GstElementFactory *
387 ges_get_compositor_factory (void);
390 ges_idle_add (GSourceFunc func, gpointer udata, GDestroyNotify notify);
392 G_GNUC_INTERNAL gboolean
393 ges_util_structure_get_clocktime (GstStructure *structure, const gchar *name,
394 GstClockTime *val, GESFrameNumber *frames);
397 /****************************************************
399 ****************************************************/
400 G_GNUC_INTERNAL void _ges_container_sort_children (GESContainer *container);
401 G_GNUC_INTERNAL void _ges_container_sort_children_by_end (GESContainer *container);
402 G_GNUC_INTERNAL void _ges_container_set_height (GESContainer * container,
404 G_GNUC_INTERNAL gint _ges_container_get_priority_offset (GESContainer * container,
405 GESTimelineElement *elem);
406 G_GNUC_INTERNAL void _ges_container_set_priority_offset (GESContainer * container,
407 GESTimelineElement *elem,
408 gint32 priority_offset);
411 /****************************************************
413 ****************************************************/
414 G_GNUC_INTERNAL void ges_clip_set_layer (GESClip *clip, GESLayer *layer);
415 G_GNUC_INTERNAL gboolean ges_clip_is_moving_from_layer (GESClip *clip);
416 G_GNUC_INTERNAL void ges_clip_set_moving_from_layer (GESClip *clip, gboolean is_moving);
417 G_GNUC_INTERNAL GESTrackElement* ges_clip_create_track_element (GESClip *clip, GESTrackType type);
418 G_GNUC_INTERNAL GList* ges_clip_create_track_elements (GESClip *clip, GESTrackType type);
419 G_GNUC_INTERNAL gboolean ges_clip_can_set_inpoint_of_child (GESClip * clip, GESTimelineElement * child, GstClockTime inpoint);
420 G_GNUC_INTERNAL gboolean ges_clip_can_set_track_of_child (GESClip * clip, GESTrackElement * child, GESTrack * tack);
421 G_GNUC_INTERNAL void ges_clip_empty_from_track (GESClip * clip, GESTrack * track);
423 /****************************************************
425 ****************************************************/
426 G_GNUC_INTERNAL gboolean ges_layer_resync_priorities (GESLayer * layer);
427 G_GNUC_INTERNAL void layer_set_priority (GESLayer * layer, guint priority, gboolean emit);
429 /****************************************************
431 ****************************************************/
432 #define NLE_OBJECT_TRACK_ELEMENT_QUARK (g_quark_from_string ("nle_object_track_element_quark"))
433 G_GNUC_INTERNAL gboolean ges_track_element_set_track (GESTrackElement * object, GESTrack * track);
434 G_GNUC_INTERNAL void ges_track_element_copy_properties (GESTimelineElement * element,
435 GESTimelineElement * elementcopy);
436 G_GNUC_INTERNAL void ges_track_element_set_layer_active (GESTrackElement *element, gboolean active);
438 G_GNUC_INTERNAL void ges_track_element_copy_bindings (GESTrackElement *element,
439 GESTrackElement *new_element,
442 G_GNUC_INTERNAL void ges_track_element_add_creator (GESTrackElement * self,
444 G_GNUC_INTERNAL void ges_track_element_clear_creators (GESTrackElement * self);
445 /* NOTE: Returned element is only valid for **pointer comparison** */
446 G_GNUC_INTERNAL GList * ges_track_element_get_creators (GESTrackElement * self);
448 G_GNUC_INTERNAL GstElement* ges_source_create_topbin(const gchar* bin_name, GstElement* sub_element, GPtrArray* elements);
449 G_GNUC_INTERNAL void ges_track_set_caps(GESTrack* track,
450 const GstCaps* caps);
451 G_GNUC_INTERNAL GstElement * ges_track_get_composition (GESTrack *track);
454 /*********************************************
455 * GESTrackElement subclasses contructores *
456 ********************************************/
457 G_GNUC_INTERNAL GESAudioTestSource * ges_audio_test_source_new (void);
458 G_GNUC_INTERNAL GESAudioUriSource * ges_audio_uri_source_new (gchar *uri);
459 G_GNUC_INTERNAL GESVideoUriSource * ges_video_uri_source_new (gchar *uri);
460 G_GNUC_INTERNAL GESImageSource * ges_image_source_new (gchar *uri);
461 G_GNUC_INTERNAL GESTitleSource * ges_title_source_new (void);
462 G_GNUC_INTERNAL GESVideoTestSource * ges_video_test_source_new (void);
464 /****************************************************
465 * GESTimelineElement *
466 ****************************************************/
469 GES_CLIP_IS_MOVING = (1 << 0),
470 GES_TIMELINE_ELEMENT_SET_SIMPLE = (1 << 1),
471 } GESTimelineElementFlags;
473 G_GNUC_INTERNAL gdouble ges_timeline_element_get_media_duration_factor(GESTimelineElement *self);
474 G_GNUC_INTERNAL GESTimelineElement * ges_timeline_element_get_copied_from (GESTimelineElement *self);
475 G_GNUC_INTERNAL GESTimelineElementFlags ges_timeline_element_flags (GESTimelineElement *self);
476 G_GNUC_INTERNAL void ges_timeline_element_set_flags (GESTimelineElement *self, GESTimelineElementFlags flags);
477 G_GNUC_INTERNAL gboolean ges_timeline_element_add_child_property_full (GESTimelineElement *self,
478 GESTimelineElement *owner,
482 G_GNUC_INTERNAL GObject * ges_timeline_element_get_child_from_child_property (GESTimelineElement * self,
484 G_GNUC_INTERNAL GParamSpec ** ges_timeline_element_get_children_properties (GESTimelineElement * self,
485 guint * n_properties);
487 #define ELEMENT_FLAGS(obj) (ges_timeline_element_flags (GES_TIMELINE_ELEMENT(obj)))
488 #define ELEMENT_SET_FLAG(obj,flag) (ges_timeline_element_set_flags(GES_TIMELINE_ELEMENT(obj), (ELEMENT_FLAGS(obj) | (flag))))
489 #define ELEMENT_UNSET_FLAG(obj,flag) (ges_timeline_element_set_flags(GES_TIMELINE_ELEMENT(obj), (ELEMENT_FLAGS(obj) & ~(flag))))
490 #define ELEMENT_FLAG_IS_SET(obj,flag) ((ELEMENT_FLAGS (obj) & (flag)) == (flag))
492 /******************************
493 * GESMultiFile internal API *
494 ******************************/
495 typedef struct GESMultiFileURI
502 G_GNUC_INTERNAL GESMultiFileURI * ges_multi_file_uri_new (const gchar * uri);
504 /******************************
505 * GESUriSource internal API *
506 ******************************/
507 G_GNUC_INTERNAL gboolean
508 ges_video_uri_source_get_natural_size(GESVideoSource* source, gint* width, gint* height);
510 /**********************************
511 * GESTestClipAsset internal API *
512 **********************************/
513 G_GNUC_INTERNAL gboolean ges_test_clip_asset_get_natural_size(GESAsset *self,
517 /************************
518 * Our property masks *
519 ************************/
520 #define GES_PARAM_NO_SERIALIZATION (1 << (G_PARAM_USER_SHIFT + 1))
522 /*******************************
523 * GESMarkerList serialization *
524 *******************************/
527 G_GNUC_INTERNAL gchar * ges_marker_list_serialize (const GValue * v);
528 G_GNUC_INTERNAL gboolean ges_marker_list_deserialize (GValue *dest, const gchar *s);
530 /********************
532 ********************/
534 G_GNUC_INTERNAL gboolean ges_nle_composition_add_object (GstElement *comp, GstElement *object);
535 G_GNUC_INTERNAL gboolean ges_nle_composition_remove_object (GstElement *comp, GstElement *object);
536 G_GNUC_INTERNAL gboolean ges_nle_object_commit (GstElement * nlesource, gboolean recurse);