Commit graph

102 commits

Author SHA1 Message Date
Thibault Saunier
fe49c80c8d ges: Add all missing Since markers from 1.16 onward
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-editing-services/-/merge_requests/191>
2020-06-19 11:13:24 -04:00
Guillaume Desmottes
a90f9dc257 add missing Since annotations on new API
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-editing-services/-/merge_requests/181>
2020-06-03 09:57:06 +02:00
Henry Wilkes
364c112d66 clip: use time translation for split
The new in-point should be the media position corresponding to the media
position. media_duration_factor is no longer needed.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-editing-services/-/merge_requests/177>
2020-05-25 11:20:38 +01:00
Henry Wilkes
449bc935f1 clip: add methods to convert between time coordinates
Add methods to convert between the timeline time coordinates and the
internal time coordinates of a track element in a clip, taking time
effects into account.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-editing-services/-/merge_requests/177>
2020-05-25 11:20:38 +01:00
Henry Wilkes
571120dcfb effect: Add support for time effects
Allow the user to register a child property of a base effect as a time
property. This can be used by GES to correctly calculate the
duration-limit of a clip when it has time effects on it. The existing
ges_effect_class_register_rate_property is now used to automatically
register such time effects for rate effects.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-editing-services/-/merge_requests/177>
2020-05-22 19:16:04 +01:00
Henry Wilkes
142456d8ba errors: added edit errors
Added more errors to GES_ERROR for when edits fail (other than
programming or usage errors). Also promoted some GST messages if they
related to a usage error.

Also added explanation of timeline overlap rules in user docs.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-editing-services/-/merge_requests/177>
2020-05-22 19:15:57 +01:00
Henry Wilkes
aefc992ef1 timeline-element: stop using edit vmethods
These were all redirecting to essentially ges_timeline_element_edit
anyway.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-editing-services/-/merge_requests/169>
2020-05-07 09:37:15 +01:00
Henry Wilkes
bac0df294e timeline-element: simplify check for being edited
It should be sufficient to set the edit flag only on the toplevel, which
allows all of its children to know they are being edited and should not
move in response.

Also, removed some unnecessary setting/checking of this.

Also, supplied the ges_timeline_element_peak_toplevel, which unlike
ges_timeline_element_get_toplevel_parent, does not add a reference to
the toplevel. Some corresponding leaks in auto-transition have been
fixed by using this instead.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-editing-services/-/merge_requests/169>
2020-05-07 09:37:15 +01:00
Henry Wilkes
39097f5574 timeline-tree: simplify and fix editing
Editing has been simplified by breaking down each edit into a
combination of three basic single-element edits: MOVE, TRIM_START, and
TRIM_END.

Each edit follows these steps:
+ Determine which elements are to be edited and under which basic mode
+ Determine which track elements will move as a result
+ Snap the edit position to one of the edges of the main edited element,
  (or the edge of one of its descendants, in the case of MOVE), avoiding
  moving elements.
  NOTE: in particular, we can *not* snap to the edge of a neighbouring
  element in a roll edit. This was previously possible, even though the
  neighbour was moving!
+ Determine the edit positions for clips (or track elements with no
  parent) using the snapped value. In addition, we replace any edits of
  a group with an edit of its descendant clips. If any value would be
  out of bounds (e.g. negative start) we do not edit.
  NOTE: this is now done *after* checking the snapping. This allows the
  edit to succeed if snapping would cause it to go from being invalid to
  valid!
+ Determine whether the collection of edits would result in a valid
  timeline-configuration which does not break the rules for sources
  overlapping.
+ If all this succeeds, we emit snapping-started on the timeline.
+ We then perform all the edits. At this point they should all succeed.

The simplification/unification should make it easier to make other
changes.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-editing-services/-/issues/97
Fixes https://gitlab.freedesktop.org/gstreamer/gst-editing-services/-/issues/98

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-editing-services/-/merge_requests/169>
2020-05-07 09:37:15 +01:00
Henry Wilkes
ba31a8d6a0 timeline-element: only copy read-write properties
Only copy the properties that can be both read and written, and are not
construct only. Similarly for child properties when a track-element is
deep copied.
2020-04-08 14:35:28 +01:00
Henry Wilkes
fe854bba69 timeline: return sunk element on pasting
Technically, an element can still be floating on the return from
`->paste` (e.g. a clip not in a layer). Since the return of the `_paste`
methods are (return full) a non-floating object is probably expected in
all cases.
2020-04-08 14:35:28 +01:00
Henry Wilkes
269c2d1dc0 timeline: re-handle clip children track selection
The way a clip's track elements are added to tracks was re-handled. This
doesn't affect the normal usage of a simple audio-video timeline, where
the tracks are added before any clips, but usage for multi-track
timelines has improved. The main changes are:

+ We can now handle a track being selected for more than one track,
  including a full copy of their children properties and bindings.
  (Previously broken.)
+ When a clip is split, we copy the new elements directly into the same
  track, avoiding select-tracks-for-object.
+ When a clip is grouped or ungrouped, we avoid moving the elements to
  or from tracks.
+ Added API to allow users to copy the core elements of a clip directly
  into a track, complementing select-tracks-for-object.
+ Enforced the rule that a clip can only contain one core child in a
  track, and all the non-core children must be added to tracks that
  already contains a core child. This extends the previous condition
  that two sources from the same clip should not be added to the same
  track.
+ Made ges_track_add_element check that the newly added track element
  does not break the configuration rules of the timeline.
+ When adding a track to a timeline, we only use
  select-tracks-for-object to check whether track elements should be
  added to the new track, not existing ones.
+ When removing a track from a timeline, we empty it of all the track
  elements that are controlled by a clip. Thus, we ensure that a clip
  only contains elements that are in the tracks of the same timeline, or
  no track. Similarly, when removing a clip from a timeline.
+ We can now avoid unsupported timeline configurations when a layer is
  added to a timeline, and already contains clips.
+ We can now avoid unsupported timeline configurations when a track is
  added to a timeline, and the timeline already contains clips.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-editing-services/-/issues/84
2020-04-08 14:35:28 +01:00
Thibault Saunier
c2287696b1 timeline:element: Refactor the way we 'copy'
Simplifying the implementation and making sure assets are set asap
2020-03-27 17:17:23 -03:00
Thibault Saunier
7ccc7aa7ca element: Add API safe guard against invalid position in edit() 2020-03-25 11:26:29 -03:00
Thibault Saunier
66fb647183 element: Handle using own property as child property
Avoiding ref cycles
2020-03-25 11:26:29 -03:00
Thibault Saunier
bd33ed972c ges: Add API to retrieve the natural framerate of an element 2020-03-25 11:26:27 -03:00
Thibault Saunier
aaf2025c71 ges: Stop using hash_table_steal_extended
This appeard in GLib 2.58

Fixes https://gitlab.freedesktop.org/gstreamer/gst-editing-services/issues/99
2020-03-19 09:15:11 -03:00
Henry Wilkes
eb8e429c80 timeline-element: make start and duration EXPLICIT_NOTIFY
The properties will only have their signal emitted when they change in
value, even when g_object_set, etc, methods are used.

The _set_start method already did this, but start was missing the
EXPLICIT_NOTIFY flag. There should be no need to check that the property
has changed in ->set_start or ->set_duration
2020-03-16 14:19:52 +00:00
Henry Wilkes
658e64432d timeline-element: make max-duration cap in-point
Do not allow the in-point to exceed the max-duration of any timeline
element.
2020-03-16 14:19:52 +00:00
Henry Wilkes
7725e48a80 timeline-element: make in-point and max-duration EXPLICIT_NOTIFY
As such, they only emit a signal if their value changes, either through
their _set_inpoint or _set_max_duration methods, or through
g_object_set, etc.

Also, we now require the ->set_max_duration method to be implemented.
This was added to GESGroup, which will only allow the max-duration to be
set to GST_CLOCK_TIME_NONE.
2020-03-16 14:19:52 +00:00
Henry Wilkes
c63fb5db0e timeline-element: add signals for child properties
Add the child-property-added and child-property-removed signals to
GESTimelineElement.

GESContainer is able to use this to keep their child properties in sync
with their children: if they are added or removed from the child, they
are also added or removed from the container.
2020-03-16 14:19:52 +00:00
Henry Wilkes
91b5a5804a clip: only allow core elements as children
Only allow elements that were created by ges_clip_create_track_elements
(or copied from such an element) to be added to a clip. This prevents
users from adding arbitrary elements to a clip.

As an exception, a user can add GESBaseEffects to clips whose class
supports it, i.e. to a GESSourceClip and a GESBaseEffectClip.

This change also introduces a distinction between the core elements of a
clip (created by ges_clip_create_track_elements) and non-core elements
(currently, only GESBaseEffects, for some classes). In particular,
GESBaseEffectClip will now distinguish between its core elements and
effects added by the user. This means that the core elements will always
have the lowest priority, and will not be listed as top effects. This is
desirable because it brings the behaviour of GESBaseEffectClip in line
with other clip types.
2020-03-16 14:19:51 +00:00
Thibault Saunier
6b7c658b6a ges: Make setting start/duration move or trim generic
We were implementing the logic for moving/trimming elements specific
to SourceClip but this was not correct ass the new timeline tree allows
us to handle that for all element types in a generic and nice way.

This make us need to have groups trimming properly implemented in the
timeline tree, leading to some fixes in the group tests.

This adds tests for the various cases known to not be handled properly
by the previous code.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-editing-services/issues/92
2020-03-09 11:48:37 -03:00
Henry Wilkes
4b3fe5f622 docs: update GESTimelineElement 2020-03-05 16:59:37 -03:00
Thibault Saunier
c802a40a96 ges: Call the right ->set_child_property vmethod
We used to always call the `->set_child_property` virtual method
of the object that `ges_timeline_element_set_child_property` was called
from, but that means that, in the case of referencing GESContainer
children properties from its children, the children wouldn't know
what child property have been set, and the children override wouldn't
be takent into account, in turns, it means that the behaviour could be
different in the setter depending on parent the method was called,
which is totally unexpected.

We now make sure that the vmethod from the element that introduced the
child property is called whatever parent method is called, making the
behaviour more uniform.

Fix the python override to make sure that new behaviour is respected.
2020-02-26 13:36:30 -03:00
Thibault Saunier
38dbfc1c24 ges: Allow setting children property using the set_object_arg format
This make it much simpler for the user to set enum values and should not cause any issue
2020-02-25 17:44:51 -03:00
Thibault Saunier
82159882d7 ges: Ignore deprecation of GParameter
GParameter is part of our API, and for GLib < 2.54 we do not even have
a way around avoiding it (namely `g_object_new_with_properties`).

We should stop using GParameter once we depend on GLib 2.54.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-editing-services/issues/86
2020-02-07 11:58:37 -03:00
Thibault Saunier
000edd268e ges: Use G_DEPRECATE to mark deprecated methods
Cleanup a few things on the way.

And move ges-track-element deprecations to a dedicated header file
2019-12-18 15:48:23 -03:00
Henry Wilkes
7b5f655c9a ges-source-clip: fixed return of duration setter
In general, brought the behaviour of the `start`, `duration` and
`inpoint` setters in line with each other. In particular:
1. fixed return value the GESSourceClip `duration` setter
2. changed the GESClip `start` setter
3. fixed the inpoint callback for GESContainer
4. changed the type of `res` in GESTimelineElement to be gint to
   emphasise that the GES library is using the hack that a return of -1
   from klass->set_duration means no notify signal should be sent out.

Also added a new test for clips to ensure that the setters work for
clips within and outside of timelines, and that the `start`, `inpoint`
and `duration` of a clip will match its children.
2019-12-14 18:12:51 +00:00
Niels De Graef
35d140ad92 Don't pass default GLib marshallers for signals
By passing NULL to `g_signal_new` instead of a marshaller, GLib will
actually internally optimize the signal (if the marshaller is available
in GLib itself) by also setting the valist marshaller. This makes the
signal emission a bit more performant than the regular marshalling,
which still needs to box into `GValue` and call libffi in case of a
generic marshaller.

Note that for custom marshallers, one would use
`g_signal_set_va_marshaller()` with the valist marshaller instead.
2019-10-24 15:19:09 +02:00
Thibault Saunier
5847c6e5ed ges: Implement our own idle_add which uses the thread local maincontext 2019-07-26 13:48:51 -04:00
Thibault Saunier
ded3a5fb2f element: Properly handle the fact that pasting can return NULL
And fix paste annotation
2019-06-05 00:43:48 +00:00
Thibault Saunier
b8c0894f34 docs: Minor documentation fixes 2019-05-23 18:54:42 -04:00
Thibault Saunier
ab2582c97e ges: Minor reorganisation of timeline-element.c 2019-05-23 18:54:42 -04:00
Sebastian Dröge
acf3e31907 timeline-element: Mark edit() as Since: 1.18 2019-05-16 15:09:51 +03:00
Sebastian Dröge
214987bd8a ges: Sprinkle around some Since: 1.16 markers 2019-05-16 15:09:13 +03:00
Thibault Saunier
d87578c843 element: Make return value of setters mean something
Setters return values should return %FALSE **only** when the value
could not be set, not when unchanged or when the subclass handled
it itself!

This patches makes it so the return value is meaningul by allowing
subclasses return anything different than `TRUE` or `FALSE` (convention
is -1) to let the subclass now that it took care of everything and
no signal should be emited.
2019-05-02 12:10:11 -04:00
Thibault Saunier
2ab26ab306 ges: Move ges_container_edit to GESTimelineElement
Now that the notion of layer has been moved down to #GESTimelineElement
(through the new #ges_timeline_element_get_layer_priority method), this
method make much more sense directly in the base class.
2019-05-01 12:24:30 -04:00
Thibault Saunier
a46390ff56 Reimplement the timeline editing API
This is implemented on top of a Tree that represents the whole timeline.

SourceClips can not fully overlap anymore and the tests have been
updated to take that into account. Some new tests were added to verify
that behaviour in greater details
2019-03-15 23:51:55 +00:00
Thibault Saunier
7c5f2d11b2 timeline-element: Add a method to retrieve layer priority
Each timeline element is in a layer (potentially spanning
over several), it is very often useful to retrieve an element
layer priority (from an app perspective more than the element
priority itself as that is a bit of an implementation detail
in the end).

Port tests to it
2019-03-15 23:51:55 +00:00
Thibault Saunier
69456e4f14 ges: Move GESClipFlags to GESTimelineElementFlags
Keeping it internal

And add an internal method to get layer priority for GESTimelineElements
(dirty implementation to make it simple for now)
2019-03-15 23:51:55 +00:00
Seungha Yang
acbd7e7bc5 timeline-element: Chain up to parent impl. on dispose()
... as documented in glib
2018-12-27 00:14:03 +09:00
Tim-Philipp Müller
a7347ca8f7 WIP: ges: fix API export/import and 'inconsistent linkage' on MSVC
Export GES library API in headers when we're building the
library itself, otherwise import the API from the headers.

This fixes linker warnings on Windows when building with MSVC.

Fix up some missing config.h includes when building the lib which
is needed to get the export api define from config.h

Fixes https://gitlab.freedesktop.org/gstreamer/gst-editing-services/issues/42
2018-12-15 00:14:51 +00:00
Víctor Manuel Jáquez Leal
c04342e4f1 timeline-element: Fix compilation errors
There were some code errors introduced in commit 6b738b7a
2018-11-05 13:58:06 +01:00
Corentin Noël
6b738b7aa4 timeline-element: Align virtual methods and invokers prototypes 2018-11-05 11:00:58 +01:00
Thibault Saunier
534855d42e ges: Mark GValue in child property setters as const
We can't change the vmethod at this point so just cast. This makes
the API more explicit so it is better in all cases.
2018-11-02 09:43:50 -03:00
Thibault Saunier
13b8c8554d Update for g_type_class_add_private() deprecation in recent GLib 2018-09-05 22:57:27 -03:00
Thibault Saunier
15782c6ecd ges: Update the media-duration-factor each time a child property is set
Otherwise the changes won't be reflected in the NLE backend.

This makes speed changes working inside ges-launch-1.0

  ges-launch-1.0 +clip /path/to/file i=10 d=5 +effect videorate set-rate 5.0

https://bugzilla.gnome.org/show_bug.cgi?id=794699
2018-03-26 12:39:55 -03:00
Harish Fulara
e944739ca5 Added paste functionality to GESTimeline class
https://bugzilla.gnome.org/show_bug.cgi?id=793820
2018-03-02 08:10:50 -03:00
Edward Hervey
d91cc7e7b6 ges: Fix sizeof() usage
The entries of the array are "gchar *" and not "gchar **"

CID #1427091
CID #1427120
2018-01-11 10:57:30 +01:00