c3ba7dcbe415780e55e6cfef1fda949a80179b02
[platform/upstream/gst-editing-services.git] / ges / ges-internal.h
1 /* GStreamer Editing Services
2  * Copyright (C) 2009 Edward Hervey <edward.hervey@collabora.co.uk>
3  *               2009 Nokia Corporation
4  *
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.
9  *
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.
14  *
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.
19  */
20
21 #ifndef __GES_INTERNAL_H__
22 #define __GES_INTERNAL_H__
23 #include <gst/gst.h>
24 #include <gst/pbutils/encoding-profile.h>
25 #include <gio/gio.h>
26
27 #include "ges-timeline.h"
28 #include "ges-track-element.h"
29 #include "ges-timeline-element.h"
30
31 #include "ges-asset.h"
32 #include "ges-base-xml-formatter.h"
33 #include "ges-timeline-tree.h"
34
35 G_BEGIN_DECLS
36
37 GST_DEBUG_CATEGORY_EXTERN (_ges_debug);
38 #ifndef GST_CAT_DEFAULT
39 #define GST_CAT_DEFAULT _ges_debug
40 #endif
41
42 /*  The first 2 NLE priorities are used for:
43  *    0- The Mixing element
44  *    1- The Gaps
45  */
46 #define MIN_NLE_PRIO 2
47 #define LAYER_HEIGHT 1000
48
49 #define _START(obj) GES_TIMELINE_ELEMENT_START (obj)
50 #define _INPOINT(obj) GES_TIMELINE_ELEMENT_INPOINT (obj)
51 #define _DURATION(obj) GES_TIMELINE_ELEMENT_DURATION (obj)
52 #define _MAXDURATION(obj) GES_TIMELINE_ELEMENT_MAX_DURATION (obj)
53 #define _PRIORITY(obj) GES_TIMELINE_ELEMENT_PRIORITY (obj)
54 #ifndef _END
55 #define _END(obj) (_START (obj) + _DURATION (obj))
56 #endif
57 #define _set_start0 ges_timeline_element_set_start
58 #define _set_inpoint0 ges_timeline_element_set_inpoint
59 #define _set_duration0 ges_timeline_element_set_duration
60 #define _set_priority0 ges_timeline_element_set_priority
61
62 #define GES_TIMELINE_ELEMENT_FORMAT \
63     "s<%p>" \
64     " [ %" GST_TIME_FORMAT \
65     " (%" GST_TIME_FORMAT \
66     ") - %" GST_TIME_FORMAT "(%" GST_TIME_FORMAT") layer: %" G_GINT32_FORMAT "] "
67
68 #define GES_TIMELINE_ELEMENT_ARGS(element) \
69     GES_TIMELINE_ELEMENT_NAME(element), element, \
70     GST_TIME_ARGS(GES_TIMELINE_ELEMENT_START(element)), \
71     GST_TIME_ARGS(GES_TIMELINE_ELEMENT_INPOINT(element)), \
72     GST_TIME_ARGS(GES_TIMELINE_ELEMENT_DURATION(element)), \
73     GST_TIME_ARGS(GES_TIMELINE_ELEMENT_MAX_DURATION(element)), \
74     GES_TIMELINE_ELEMENT_LAYER_PRIORITY(element)
75
76 #define GES_FORMAT GES_TIMELINE_ELEMENT_FORMAT
77 #define GES_ARGS GES_TIMELINE_ELEMENT_ARGS
78
79 G_GNUC_INTERNAL gboolean
80 timeline_ripple_object         (GESTimeline *timeline, GESTimelineElement *obj,
81                                 gint new_layer_priority,
82                                 GList * layers, GESEdge edge,
83                                 guint64 position);
84
85 G_GNUC_INTERNAL gboolean
86 timeline_slide_object          (GESTimeline *timeline, GESTrackElement *obj,
87                                     GList * layers, GESEdge edge, guint64 position);
88
89 G_GNUC_INTERNAL gboolean
90 timeline_roll_object           (GESTimeline *timeline, GESTimelineElement *obj,
91                                 GList * layers, GESEdge edge, guint64 position);
92
93 G_GNUC_INTERNAL gboolean
94 timeline_trim_object           (GESTimeline *timeline, GESTimelineElement * object,
95                                 guint32 new_layer_priority, GList * layers, GESEdge edge,
96                                 guint64 position);
97 G_GNUC_INTERNAL gboolean
98 ges_timeline_trim_object_simple (GESTimeline * timeline, GESTimelineElement * obj,
99                                  guint32 new_layer_priority, GList * layers, GESEdge edge,
100                                  guint64 position, gboolean snapping);
101
102 G_GNUC_INTERNAL gboolean
103 ges_timeline_move_object_simple (GESTimeline * timeline, GESTimelineElement * object,
104                                  GList * layers, GESEdge edge, guint64 position);
105
106 G_GNUC_INTERNAL gboolean
107 timeline_move_object           (GESTimeline *timeline, GESTimelineElement * object,
108                                 guint32 new_layer_priority, GList * layers, GESEdge edge,
109                                 guint64 position);
110
111 G_GNUC_INTERNAL void
112 timeline_add_group             (GESTimeline *timeline,
113                                 GESGroup *group);
114 G_GNUC_INTERNAL void
115 timeline_remove_group          (GESTimeline *timeline,
116                                 GESGroup *group);
117 G_GNUC_INTERNAL void
118 timeline_emit_group_added      (GESTimeline *timeline,
119                                 GESGroup *group);
120 G_GNUC_INTERNAL void
121 timeline_emit_group_removed    (GESTimeline * timeline,
122                                 GESGroup * group, GPtrArray * array);
123
124 G_GNUC_INTERNAL
125 gboolean
126 timeline_add_element           (GESTimeline *timeline,
127                                 GESTimelineElement *element);
128 G_GNUC_INTERNAL
129 gboolean
130 timeline_remove_element       (GESTimeline *timeline,
131                                GESTimelineElement *element);
132
133 G_GNUC_INTERNAL
134 GNode *
135 timeline_get_tree           (GESTimeline *timeline);
136
137 G_GNUC_INTERNAL
138 void
139 timeline_update_transition (GESTimeline *timeline);
140
141 G_GNUC_INTERNAL
142 void
143 timeline_fill_gaps            (GESTimeline *timeline);
144
145 G_GNUC_INTERNAL void
146 timeline_create_transitions (GESTimeline * timeline, GESTrackElement * track_element);
147
148 G_GNUC_INTERNAL
149 void
150 track_resort_and_fill_gaps    (GESTrack *track);
151
152 G_GNUC_INTERNAL
153 void
154 track_disable_last_gap        (GESTrack *track, gboolean disabled);
155
156 G_GNUC_INTERNAL void
157 ges_asset_cache_init (void);
158
159 G_GNUC_INTERNAL void
160 ges_asset_cache_deinit (void);
161
162 G_GNUC_INTERNAL void
163 ges_asset_set_id (GESAsset *asset, const gchar *id);
164
165 G_GNUC_INTERNAL void
166 ges_asset_cache_put (GESAsset * asset, GTask *task);
167
168 G_GNUC_INTERNAL gboolean
169 ges_asset_cache_set_loaded(GType extractable_type, const gchar * id, GError *error);
170
171 GES_API GESAsset*
172 ges_asset_cache_lookup(GType extractable_type, const gchar * id);
173
174 GES_API gboolean
175 ges_asset_try_proxy (GESAsset *asset, const gchar *new_id);
176
177 G_GNUC_INTERNAL gboolean
178 ges_asset_request_id_update (GESAsset *asset, gchar **proposed_id,
179     GError *error);
180 G_GNUC_INTERNAL gchar *
181 ges_effect_assect_id_get_type_and_bindesc (const char    *id,
182                                            GESTrackType  *track_type,
183                                            GError       **error);
184
185 G_GNUC_INTERNAL void _ges_uri_asset_cleanup (void);
186
187 G_GNUC_INTERNAL gboolean _ges_uri_asset_ensure_setup (gpointer uriasset_class);
188
189 /* GESExtractable internall methods
190  *
191  * FIXME Check if that should be public later
192  */
193 G_GNUC_INTERNAL GType
194 ges_extractable_type_get_asset_type              (GType type);
195
196 G_GNUC_INTERNAL gchar *
197 ges_extractable_type_check_id                    (GType type, const gchar *id, GError **error);
198
199 G_GNUC_INTERNAL GParameter *
200 ges_extractable_type_get_parameters_from_id      (GType type, const gchar *id,
201                                                   guint *n_params);
202 G_GNUC_INTERNAL GType
203 ges_extractable_get_real_extractable_type_for_id (GType type, const gchar * id);
204
205 G_GNUC_INTERNAL gboolean
206 ges_extractable_register_metas                   (GType extractable_type, GESAsset *asset);
207
208 /************************************************
209  *                                              *
210  *        GESFormatter internal methods         *
211  *                                              *
212  ************************************************/
213 G_GNUC_INTERNAL void
214 ges_formatter_set_project                        (GESFormatter *formatter,
215                                                   GESProject *project);
216 G_GNUC_INTERNAL GESProject *
217 ges_formatter_get_project                        (GESFormatter *formatter);
218 G_GNUC_INTERNAL  GESAsset *
219 _find_formatter_asset_for_id                     (const gchar *id);
220
221
222
223 /************************************************
224  *                                              *
225  *        GESProject internal methods           *
226  *                                              *
227  ************************************************/
228
229 /* FIXME This should probably become public, but we need to make sure it
230  * is the right API before doing so */
231 G_GNUC_INTERNAL  gboolean ges_project_set_loaded                  (GESProject * project,
232                                                                    GESFormatter *formatter,
233                                                                    GError *error);
234 G_GNUC_INTERNAL  gchar * ges_project_try_updating_id              (GESProject *self,
235                                                                    GESAsset *asset,
236                                                                    GError *error);
237 G_GNUC_INTERNAL  void ges_project_add_loading_asset               (GESProject *project,
238                                                                    GType extractable_type,
239                                                                    const gchar *id);
240 G_GNUC_INTERNAL  gchar* ges_uri_asset_try_update_id               (GError *error, GESAsset *wrong_asset);
241 /************************************************
242  *                                              *
243  *   GESBaseXmlFormatter internal methods       *
244  *                                              *
245  ************************************************/
246
247 /* FIXME GESBaseXmlFormatter is all internal for now, the API is not stable
248  * fo now, so do not expose it */
249 G_GNUC_INTERNAL void ges_base_xml_formatter_add_clip (GESBaseXmlFormatter * self,
250                                                                  const gchar *id,
251                                                                  const char *asset_id,
252                                                                  GType type,
253                                                                  GstClockTime start,
254                                                                  GstClockTime inpoint,
255                                                                  GstClockTime duration,
256                                                                  guint layer_prio,
257                                                                  GESTrackType track_types,
258                                                                  GstStructure *properties,
259                                                                  GstStructure * children_properties,
260                                                                  const gchar *metadatas,
261                                                                  GError **error);
262 G_GNUC_INTERNAL void ges_base_xml_formatter_add_asset        (GESBaseXmlFormatter * self,
263                                                                  const gchar * id,
264                                                                  GType extractable_type,
265                                                                  GstStructure *properties,
266                                                                  const gchar *metadatas,
267                                                                  const gchar *proxy_id,
268                                                                  GError **error);
269 G_GNUC_INTERNAL void ges_base_xml_formatter_add_layer           (GESBaseXmlFormatter *self,
270                                                                  GType extractable_type,
271                                                                  guint priority,
272                                                                  GstStructure *properties,
273                                                                  const gchar *metadatas,
274                                                                  GError **error);
275 G_GNUC_INTERNAL void ges_base_xml_formatter_add_track           (GESBaseXmlFormatter *self,
276                                                                  GESTrackType track_type,
277                                                                  GstCaps *caps,
278                                                                  const gchar *id,
279                                                                  GstStructure *properties,
280                                                                  const gchar *metadatas,
281                                                                  GError **error);
282 G_GNUC_INTERNAL void ges_base_xml_formatter_add_encoding_profile(GESBaseXmlFormatter * self,
283                                                                  const gchar *type,
284                                                                  const gchar *parent,
285                                                                  const gchar * name,
286                                                                  const gchar * description,
287                                                                  GstCaps * format,
288                                                                  const gchar * preset,
289                                                                  GstStructure * preset_properties,
290                                                                  const gchar * preset_name,
291                                                                  guint id,
292                                                                  guint presence,
293                                                                  GstCaps * restriction,
294                                                                  guint pass,
295                                                                  gboolean variableframerate,
296                                                                  GstStructure * properties,
297                                                                  gboolean enabled,
298                                                                  GError ** error);
299 G_GNUC_INTERNAL void ges_base_xml_formatter_add_track_element   (GESBaseXmlFormatter *self,
300                                                                  GType effect_type,
301                                                                  const gchar *asset_id,
302                                                                  const gchar * track_id,
303                                                                  const gchar *timeline_obj_id,
304                                                                  GstStructure *children_properties,
305                                                                  GstStructure *properties,
306                                                                  const gchar *metadatas,
307                                                                  GError **error);
308
309 G_GNUC_INTERNAL void ges_base_xml_formatter_add_source          (GESBaseXmlFormatter *self,
310                                                                  const gchar * track_id,
311                                                                  GstStructure *children_properties);
312
313 G_GNUC_INTERNAL void ges_base_xml_formatter_add_group           (GESBaseXmlFormatter *self,
314                                                                  const gchar *name,
315                                                                  const gchar *properties,
316                                                                  const gchar *metadatas);
317
318 G_GNUC_INTERNAL void ges_base_xml_formatter_last_group_add_child(GESBaseXmlFormatter *self,
319                                                                  const gchar * id,
320                                                                  const gchar * name);
321
322 G_GNUC_INTERNAL void ges_base_xml_formatter_add_control_binding (GESBaseXmlFormatter * self,
323                                                                   const gchar * binding_type,
324                                                                   const gchar * source_type,
325                                                                   const gchar * property_name,
326                                                                   gint mode,
327                                                                   const gchar *track_id,
328                                                                   GSList * timed_values);
329
330 G_GNUC_INTERNAL void ges_base_xml_formatter_set_timeline_properties(GESBaseXmlFormatter * self,
331                                                                     GESTimeline *timeline,
332                                                                     const gchar *properties,
333                                                                     const gchar *metadatas);
334 G_GNUC_INTERNAL void ges_xml_formatter_deinit                       (void);
335
336 G_GNUC_INTERNAL gboolean set_property_foreach                   (GQuark field_id,
337                                                                  const GValue * value,
338                                                                  GObject * object);
339
340 G_GNUC_INTERNAL GstElement * get_element_for_encoding_profile   (GstEncodingProfile *prof,
341                                                                  GstElementFactoryListType type);
342
343 /* Function to initialise GES */
344 G_GNUC_INTERNAL void _init_standard_transition_assets        (void);
345 G_GNUC_INTERNAL void _init_formatter_assets                  (void);
346 G_GNUC_INTERNAL void _deinit_formatter_assets                (void);
347
348 /* Utilities */
349 G_GNUC_INTERNAL gint element_start_compare                (GESTimelineElement * a,
350                                                            GESTimelineElement * b);
351 G_GNUC_INTERNAL gint element_end_compare                  (GESTimelineElement * a,
352                                                            GESTimelineElement * b);
353 G_GNUC_INTERNAL GstElementFactory *
354 ges_get_compositor_factory                                (void);
355
356 G_GNUC_INTERNAL void
357 ges_idle_add (GSourceFunc func, gpointer udata, GDestroyNotify notify);
358
359
360 /****************************************************
361  *              GESContainer                        *
362  ****************************************************/
363 G_GNUC_INTERNAL void _ges_container_sort_children         (GESContainer *container);
364 G_GNUC_INTERNAL void _ges_container_sort_children_by_end  (GESContainer *container);
365 G_GNUC_INTERNAL void _ges_container_set_height            (GESContainer * container,
366                                                            guint32 height);
367 G_GNUC_INTERNAL gint  _ges_container_get_priority_offset  (GESContainer * container,
368                                                            GESTimelineElement *elem);
369 G_GNUC_INTERNAL void _ges_container_set_priority_offset   (GESContainer * container,
370                                                            GESTimelineElement *elem,
371                                                            gint32 priority_offset);
372
373
374 /****************************************************
375  *                  GESClip                         *
376  ****************************************************/
377 G_GNUC_INTERNAL void              ges_clip_set_layer              (GESClip *clip, GESLayer  *layer);
378 G_GNUC_INTERNAL gboolean          ges_clip_is_moving_from_layer   (GESClip *clip);
379 G_GNUC_INTERNAL void              ges_clip_set_moving_from_layer  (GESClip *clip, gboolean is_moving);
380 G_GNUC_INTERNAL GESTrackElement*  ges_clip_create_track_element   (GESClip *clip, GESTrackType type);
381 G_GNUC_INTERNAL GList*            ges_clip_create_track_elements  (GESClip *clip, GESTrackType type);
382
383 /****************************************************
384  *              GESLayer                            *
385  ****************************************************/
386 G_GNUC_INTERNAL gboolean ges_layer_resync_priorities (GESLayer * layer);
387 G_GNUC_INTERNAL void layer_set_priority               (GESLayer * layer, guint priority, gboolean emit);
388
389 /****************************************************
390  *              GESTrackElement                     *
391  ****************************************************/
392 #define         NLE_OBJECT_TRACK_ELEMENT_QUARK                  (g_quark_from_string ("nle_object_track_element_quark"))
393 G_GNUC_INTERNAL gboolean  ges_track_element_set_track           (GESTrackElement * object, GESTrack * track);
394 G_GNUC_INTERNAL void ges_track_element_copy_properties          (GESTimelineElement * element,
395                                                                  GESTimelineElement * elementcopy);
396
397 G_GNUC_INTERNAL void ges_track_element_copy_bindings (GESTrackElement *element,
398                                                        GESTrackElement *new_element,
399                                                        guint64 position);
400
401 G_GNUC_INTERNAL GstElement *ges_source_create_topbin (const gchar * bin_name, GstElement * sub_element, ...);
402 G_GNUC_INTERNAL void ges_track_set_caps                (GESTrack *track,
403                                                         const GstCaps *caps);
404 G_GNUC_INTERNAL GstElement * ges_track_get_composition (GESTrack *track);
405
406
407 /*********************************************
408  *  GESTrackElement subclasses contructores  *
409  ********************************************/
410 G_GNUC_INTERNAL GESAudioTestSource * ges_audio_test_source_new (void);
411 G_GNUC_INTERNAL GESAudioUriSource  * ges_audio_uri_source_new  (gchar *uri);
412 G_GNUC_INTERNAL GESVideoUriSource  * ges_video_uri_source_new  (gchar *uri);
413 G_GNUC_INTERNAL GESImageSource     * ges_image_source_new      (gchar *uri);
414 G_GNUC_INTERNAL GESTitleSource     * ges_title_source_new      (void);
415 G_GNUC_INTERNAL GESVideoTestSource * ges_video_test_source_new (void);
416
417 /****************************************************
418  *              GESTimelineElement                  *
419  ****************************************************/
420 typedef enum
421 {
422   GES_CLIP_IS_MOVING = (1 << 0),
423   GES_TIMELINE_ELEMENT_SET_SIMPLE = (1 << 1),
424 } GESTimelineElementFlags;
425
426 G_GNUC_INTERNAL gdouble ges_timeline_element_get_media_duration_factor(GESTimelineElement *self);
427 G_GNUC_INTERNAL GESTimelineElement * ges_timeline_element_get_copied_from (GESTimelineElement *self);
428 G_GNUC_INTERNAL GESTimelineElementFlags ges_timeline_element_flags (GESTimelineElement *self);
429 G_GNUC_INTERNAL void                ges_timeline_element_set_flags (GESTimelineElement *self, GESTimelineElementFlags flags);
430
431 #define ELEMENT_FLAGS(obj)             (ges_timeline_element_flags (GES_TIMELINE_ELEMENT(obj)))
432 #define ELEMENT_SET_FLAG(obj,flag)     (ges_timeline_element_set_flags(GES_TIMELINE_ELEMENT(obj), (ELEMENT_FLAGS(obj) | (flag))))
433 #define ELEMENT_UNSET_FLAG(obj,flag)   (ges_timeline_element_set_flags(GES_TIMELINE_ELEMENT(obj), (ELEMENT_FLAGS(obj) & ~(flag))))
434 #define ELEMENT_FLAG_IS_SET(obj,flag)  ((ELEMENT_FLAGS (obj) & (flag)) == (flag))
435
436 /******************************
437  *  GESMultiFile internal API *
438  ******************************/
439 typedef struct GESMultiFileURI
440 {
441   gchar *location;
442   gint start;
443   gint end;
444 } GESMultiFileURI;
445
446 G_GNUC_INTERNAL GESMultiFileURI * ges_multi_file_uri_new (const gchar * uri);
447
448 /************************
449  * Our property masks   *
450  ************************/
451 #define GES_PARAM_NO_SERIALIZATION (1 << (G_PARAM_USER_SHIFT + 1))
452
453 /********************
454  *  Gnonlin helpers *
455  ********************/
456
457 G_GNUC_INTERNAL gboolean ges_nle_composition_add_object (GstElement *comp, GstElement *object);
458 G_GNUC_INTERNAL gboolean ges_nle_composition_remove_object (GstElement *comp, GstElement *object);
459 G_GNUC_INTERNAL gboolean ges_nle_object_commit (GstElement * nlesource, gboolean recurse);
460
461 G_END_DECLS
462
463 #endif /* __GES_INTERNAL_H__ */