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