Add new control binding GstAppControlBinding
Submitted by Heinrich Fink
Created attachment 295004
GstAppControlBinding is a new GstControlBinding subclass that emits a signal ('update-value') in order to update the value of its bound property. This allows applications to connect to this signal and to set controllable properties along the time-line, without being tied to GstControlSource / GstDirectControlBinding. A patch of a first implementation, including basic unit tests and documentation is provided.
Example use case:
A live mixing application uses compositor/glvideomixer to animate multiple video layers along an application-defined time-line. This is done by setting the properties xpos/ypos/width/height of compositor's sink pads accordingly. Using GstControlSource / GstDirectControlBinding doesn't work here because:
-) 0..1 sources would be mapped to the full property range. That doesn't really make sense for properties using pixel coordinates (e.g. xpos/ypos/width/height).
-) Since this a live mixing application, changes of a video layer's properties (i.e. sink pad's xpos/ypos/width/height properties) need to have immediate effect (e.g. animating a transition based on real-time user input). One could try to just set xpos/ypos/width/height using a single g_object_set call, but since this is not guaranteed to be atomic, this could result in one frame to already have updated xpos/ypos values, but not yet updated width/height values, resulting in undesired animation artefacts. Using GstAppControlBinding, the application simply binds to xpos/ypos/width/height, which results in the signal being emitted before each rendered frame for all bound properties. The application could then make sure that the right xpos/ypos/width/height tuple is used for the requested render time.
(1) Since GstAppControlBinding does have to map GstControlSource's 0..1 value to something useful (like GstDirectControlBinding does), we could support further PARAM_SPEC types (like strings, chars, whatever). However, until a good use case for this comes up, GstAppControlBinding only supports the same types as GstDirectControlBinding.
(2) The performance of the installed signal ('update-value') might be improved by passing more advanced flags to g_signal_new (accumulators, etc). Out of my lacking experience with this, I have only installed a basic signal for now.
(3) If GstAppControlBinding is asked for an array of values, it is currently emitting multiple signals, for each time-sample of the requested array, in order to fill the array. This could be optimized by using another signal that returns an array of GValues instead of just a single GValue.
(4) The GValue instance returned by the 'update-value' signal is currently expected to hold the same type as the bound property. Alternatively, type conversion could be attempted, if supported.
(5) Similar to GstDirectControlBinding, GstAppControlBinding does not set the target property, if the value hasn't changed.
(6) I tried to extend the documentation to document GstAppControlBinding, I hope I haven't missed anything :)
(7) Credits: I have added Stefan Sauer (ensonic) to the license headers, because most of the code was based on his GstDirectControlBinding implementation, and I have also added Sebastian Dröge (slomo), because GstAppControlBinding was his idea.
I am looking forward to your feedback!
Patch 295004, "patch":