Commit graph

43 commits

Author SHA1 Message Date
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 fba267926f group: let timeline-tree handle layer priority
Since a group can only have its priority set whilst it is part of a
timeline, we can simply let the timeline-tree handle the move, which it
can already do, whilst checking that the move would be legal (not break
the timeline configuration). All the group has to do now if update its
priority value if the priority of any of its children changes. It
doesn't even need to keep track of the layer priority offsets.

Also, added a check to ensure added children belong to the same
timeline.

Also moved the sigids from the GObject data to a g_hash_table, which is
clearer.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-editing-services/-/merge_requests/169>
2020-05-07 09:37:15 +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 a6b13ce619 group: fix priority setting
Stop moving the group if a child clip is being edited by timeline-tree,
a child group is updating its own priority, or a layer that a clip is in
has changed priority. A group should only move if a descendant moves
layers outside of a timeline-tree edit, or the priority of the group is
set by the user.

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

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-editing-services/-/merge_requests/169>
2020-05-07 09:37:15 +01:00
Henry Wilkes 6617d76710 container: keep start and duration up to date
Simplified keeping the start and the duration of a container/group up to
date with the earliest start of the children and the last end of the
children. The previous logic was spread between ges-group and
ges-container, now all the position handling is in ges-container.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-editing-services/-/merge_requests/169>
2020-05-07 09:37:15 +01:00
Thibault Saunier 8f4688811f ges: Always check return value of ges_container_add
Making coverity happy

CIDs: 1461460, 1461461, 1461462, 1461463, 1461464, 1461465, 1461466, 1461468,
2020-04-10 11:12:12 -04:00
Henry Wilkes ef1c0f0faa group: tidied timeline membership in copy-paste
Previously, the GESContainer ->paste method and GESGroup ->paste methods
were unnecessarily setting the timeline of groups, even though this is
handled by the GESGroup ->child_added method. This could result in the
group being added multiple times.
2020-04-08 14:35:28 +01:00
Thibault Saunier ffc11daa40 ges: Use assets to instantiate track elements/group
And deprecate all GESTrackElement constructors, but the GESEffect one.
Those should **never** be created by users and should become internal
in the future.

Stop having docstring for the constructors that were internal.
2020-03-27 17:17:23 -03: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 74ae0ba5df container: freeze notifies during add and remove
Hold the notify signals for the container and the children until after
the child has been fully added or removed.

After the previous commit, this was used to ensure that the
notify::priority signal was sent for children of a clip *after* the
child-removed signal. This stopped being the case when the code in
->child_removed was moved to ->remove_child (the latter is called before
the child-removed signal is emitted, whilst the former is called
afterwards). Rather than undo this move of code, which was necessary to
ensure that ->add_child was always reversed, the notify::priority signal
is now simply delayed until after removing the child has completed. This
was done for all notify signals, as well as in the add method, to ensure
consistency.

This allows the test_clips.py test_signal_order_when_removing_effect to
pass.

Also make subclasses take a copy of the list of the children before
setting the start and duration, since this can potentially re-order the
children (if they have the SET_SIMPLE flag set).
2020-03-16 14:19:52 +00:00
Thibault Saunier b66290d1be group: Update priority when a child is removed
Fixes https://gitlab.freedesktop.org/gstreamer/gst-editing-services/issues/93
2020-03-06 18:18:28 +00:00
Henry Wilkes b76e7db461 group: fix memory leak in child layer callback
We were leaking the sigids->layer argument because gst_clip_get_layer
returns a new reference.
2020-03-05 17:04:51 -03:00
Henry Wilkes 11d93367a9 group: fix max layer priority
The maximum priority is `height - prio - 1`. Previously missing the -1.

Related to, but does not completely fix,
https://gitlab.freedesktop.org/gstreamer/gst-editing-services/issues/91
2020-03-05 17:04:51 -03:00
Henry Wilkes 427d541f58 docs: update GESGroup 2020-03-05 16:59:37 -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 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 9748b963b6 Fix segfault when adding clips to group outside a timeline
Making sure that objects are inside a timeline before adding/removing them from it

Fixes https://gitlab.freedesktop.org/gstreamer/gst-editing-services/issues/35
2019-01-30 20:04:04 +00: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
Thibault Saunier 13b8c8554d Update for g_type_class_add_private() deprecation in recent GLib 2018-09-05 22:57:27 -03:00
Thibault Saunier 6e5e263306 group: Handle clips that get readded to a layer and inside a group 2018-07-01 12:42:18 -04:00
Thibault Saunier 31e7ca2ef7 group: Handle clips being removed from their layers 2018-03-14 21:05:33 -03:00
Thibault Saunier 35256b47ff docs: Port all docstring to gtk-doc markdown 2017-03-08 18:13:48 -03:00
Alexandru Băluț a63c754222 timeline: Make get_groups public
Had to separate timeline_emit_group_added from timeline_add_group
to avoid emitting group-added when the project is being loaded.

Reviewed-by: Thibault Saunier <thibault.saunier@collabora.com>
Differential Revision: https://phabricator.freedesktop.org/D1302
2016-09-13 16:47:24 -03:00
Aurélien Zanelli 813c4b4fb7 ges: add some g-i annotations according to documentation
Mainly (transfer xxx) and (nullable). Also fix some typo.

https://bugzilla.gnome.org/show_bug.cgi?id=766459
2016-05-14 20:36:07 -03:00
Thibault Saunier 8718b01595 ges: Remove timeline_emit_group_removed which slipped in the API by mistake
This is formally an API break but I am sure no one ever used that and
we should make sure the method is removed as soon as possible because
it has no reason to be exposed.
2016-05-06 18:27:56 -03:00
Thibault Saunier 8ce2b97a93 ges: Don't emit timeline::group-removed when ungrouping outside a timeline 2016-03-11 17:29:08 +01:00
Fabian Orccon 6a97b50b4b group-added and group-removed signals added
Differential Revision: https://phabricator.freedesktop.org/D619
2016-02-23 20:40:21 +01:00
Thibault Saunier 2fae9ee50d group: Make deep copying actually copy deep
Allowing pasting groups paste exactly what had been copied

And not the new version of the contained objects

This technically breaks the C API but this is a new API and I believe
and hope nobody is using it right now.

Reviewed-by: Thibault Saunier <thibault.saunier@collabora.com>
Differential Revision: https://phabricator.freedesktop.org/D616
2016-01-17 09:23:35 +01:00
Thibault Saunier 5885f58c14 element: Implement a paste method
Allowing user to copy paste clips very easily
2015-07-03 14:06:54 +02:00
Thibault Saunier 73e4e3bb0a group: Disconnect from old layer notify::priority when a clip is moved to a NULL layer
This means we need to properly track the layer a clip was in. We now
keep track of the various signal IDs in a dedicated structure and
keep a ref on the layer an object is in.

http://phabricator.freedesktop.org/T88
2015-06-05 22:52:43 +02:00
Thibault Saunier 78913931b2 ges: Recompute Group priority when one of its clip.layer change priority
And add a unit test for that case where it was previously failing
2014-12-06 10:34:18 +01:00
Thibault Saunier 5665e3abb1 xml-formatter: Serialize groups
They were not serialized until now.

That implies several changes:

* Override GESTimelineElement [start, inpoint, duration] properties in
  GESGroup to ensure that those properties are not serialized as they
  should not be.

* Rename GESBaseXmlContainer->clips field to
  GESBaseXmlContainer->containers as the hashtable now contains Groups

https://bugzilla.gnome.org/show_bug.cgi?id=709148
2014-11-10 16:22:43 +01:00
Christoph Reiter a66e674649 Include class related section documentation in the gir file.
g-ir-scanner includes section docs as class/interface docs if the section name is equal to the lowercase type name.
Since all the documentation is in section blocks, rename them to match the type names.

https://bugzilla.gnome.org/show_bug.cgi?id=727776
2014-04-07 22:13:25 +02:00
Sebastian Dröge f88cc0f433 ges-group: Properly check for integer underflows
error: comparison of unsigned expression < 0 is always false
2014-02-08 20:19:53 +01:00
Thibault Saunier c4c26f8748 ges: Handle trimming in groups
This was broken, clips where moving all around, make it behave properly.
2013-09-07 12:55:58 -04:00
Thibault Saunier cc9391319e group: Add an empty group constructor
As it is more intuitive for users.

API:
  ges_group_new
2013-07-12 11:56:59 -04:00
Mathieu Duponchelle 2723ef561e container/group/clip: Allow creating an empty group.
This is a legitimate use case.
2013-07-11 23:47:36 +02:00
Mathieu Duponchelle 96204ac1d2 container: Add a 'recursive' argument to the get_children method
API:
  - ges_container_get_children (GESContainer *container);
  + ges_container_get_children (GESContainer *container, gboolean recurse);
2013-07-10 23:25:12 -04:00
Mathieu Duponchelle ff21ea7f92 group: set priv->setting_value to TRUE when moving ourselves in _child_removed 2013-07-10 23:18:41 -04:00
Thibault Saunier a933d9540d ges: Implement a GESGroup class, subclass of GESContainer
The GESGroup class is used to group various GESContainer
together, it can contain either GESClips or GESGroup or both.
2013-07-09 16:47:00 -04:00