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