Commit graph

142 commits

Author SHA1 Message Date
Sebastian Dröge 8d77759834 ptp: Initial implementation of a PTP clock
GstPtpClock implements a PTP (IEEE1588:2008) ordinary clock in
slave-only mode, that allows a GStreamer pipeline to synchronize
to a PTP network clock in some specific domain.

The PTP subsystem can be initialized with gst_ptp_init(), which then
starts a helper process to do the actual communication via the PTP
ports. This is required as PTP listens on ports < 1024 and thus
requires special privileges. Once this helper process is started, the
main process will synchronize to all PTP domains that are detected on
the selected interfaces.

gst_ptp_clock_new() then allows to create a GstClock that provides the
PTP time from a master clock inside a specific PTP domain. This clock
will only return valid timestamps once the timestamps in the PTP domain
are known. To check this, the GstPtpClock::internal-clock property and
the related notify::clock signal can be used. Once the internal clock
is not NULL, the PTP domain's time is known. Alternatively you can wait
for this with gst_ptp_clock_wait_ready().

To gather statistics about the PTP clock synchronization,
gst_ptp_statistics_callback_add() can be used. This gives the
application the possibility to collect all kinds of statistics
from the clock synchronization.

https://bugzilla.gnome.org/show_bug.cgi?id=749391
2015-06-03 13:55:28 +02:00
Tim-Philipp Müller d71f5c7d73 net: keep GCancellable fd around instead of re-creating it constantly
Just create the cancellable fd once and keep it around instead
of creating/closing it for every single packet. Since we spend
most time waiting for packets, an fd is alloced and in use pretty
much all the time anyway.
2015-05-19 14:34:04 +01:00
Tim-Philipp Müller 8e6561be91 Remove obsolete Android build cruft
This is not needed any longer.
2015-04-26 17:49:44 +01:00
Edward Hervey e4d07e161d introspection: Don't use g-ir-scanner cache at compile time
It pollutes user directories and we don't need to cache it

https://bugzilla.gnome.org/show_bug.cgi?id=747095
2015-03-31 11:16:09 +02:00
William Manley fc765592a1 meta: Add GstNetControlMessageMeta
GstNetAddress can be used to store ancillary data which was received with
or is to be sent alongside the buffer data.  When used with socket sinks
and sources which understand this meta it allows sending and receiving
ancillary data such as unix credentials (See `GUnixCredentialsMessage`)
and Unix file descriptions (See `GUnixFDMessage`).

This will be useful for implementing protocols which use file-descriptor
passing in payloaders/depayloaders without having to re-implement all the
socket handling code already present in elements such as multisocketsink,
etc.  This, in turn, will be useful for implementing zero-copy video IPC.

This meta uses the platform independent `GSocketControlMessage` API
provided by GLib as a part of GIO.  As a result this new meta does not
require any new dependencies or any conditional compliation for
portablility, although it is unlikely to do anything useful on non-UNIX
platforms.
2015-03-14 13:54:51 +01:00
Jan Schmidt f0e3b7f904 netclock: Don't update the clock when it desynch
Add a hold off when the clock calibration suddenly loses synch,
as it may be a glitch, but also make sure we update if it stays
desynched for more than a few seconds
2015-02-07 04:41:52 +11:00
Jan Schmidt 824b821caa netclock: Make the RTT average ignore large values more forcefully.
Smooth larger RTTs a little harder, so excessively large values
perturb the average a bit less, and therefore get filtered out
more strongly
2015-02-07 04:38:42 +11:00
Jan Schmidt aeca7eb480 netclock: Fix docs typo. Clock bus messages are GST_MESSAGE_ELEMENT 2015-01-21 22:44:59 +11:00
Jan Schmidt 27997cb8a3 netclock: Implement rate limits for polling and fix up skew limits
Add the minimum-update-interval property to the clock, with a default
of 50ms and don't send polling requests faster than that. That helps to
ensure we spread the initial observations out a little - startup takes
a little longer, but tracking is more stable.

Move the discont skew limiting code inside an if statement, so that
it's only done when the linear regression succeeds and the clock
parameters might actually change.
2015-01-21 22:27:18 +11:00
Jan Schmidt 1c9c9847fd netclock: Implement sending statistic bus messages and discont limits
Allow setting a GstBus on the network clock client
via a new 'bus' object property. If a bus is set, the
clock will output an element message containing statistics
about new clock observations and the clock correlation.

When the local clock is synchronised with the remote, limit the
maximum jump in the clock at any point to be one average RTT to
the server. Also, publish in the bus message whether we are
synched with the remote or not.
2015-01-21 22:27:18 +11:00
Sebastian Rasmussen 863ba1a598 docs: Fix documentation typos and inconsistencies
* GstGlobalDeviceMonitor was renamed to GstDeviceMonitor
 * Expand GST_MESSAGE_DEVICE to the full enum value names
 * Correct the incorrect references to the GstDeviceProvider interfaces
 * Describe caps arguments for gstcheck interface
 * Add missing docs for GstNetAddressMeta and its add function
 * Add docs for toc helper macros
 * Avoid refering to GstValueList type as done elsewhere

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=732786
2014-07-09 09:22:11 +02:00
Edward Hervey bf9018b77c nettimeprovider: Use non-freed variable
address is only used temporarily. Use the proper variable instead.

CID #1212189
2014-05-09 14:46:59 +02:00
Tim-Philipp Müller 6eb6d9ec38 docs: remove outdated and pointless 'Last reviewed' lines from docs
They are very confusing for people, and more often than not
also just not very accurate. Seeing 'last reviewed: 2005' in
your docs is not very confidence-inspiring. Let's just remove
those comments.
2014-04-26 21:21:51 +01:00
Antoine Jacoutot 3e24bbefba libs: g-ir-scanner: do not hardcode libtool path
https://bugzilla.gnome.org/show_bug.cgi?id=726571
2014-04-17 09:26:20 +01:00
Tim-Philipp Müller 2ddbe8df49 nettimeprovider: remove unnecessary NULL check
Error is never NULL when we break out of the loop.

COVERITY CID 1037151
2013-12-30 16:10:08 +00:00
Tim-Philipp Müller 0735c052e1 Revert "nettimeprovider: Remove dead code"
This reverts commit 9649cd4ca1.

This is not right, and it's also not what coverity
is complaining about.
2013-12-30 16:07:08 +00:00
Edward Hervey 9649cd4ca1 nettimeprovider: Remove dead code
err is always NULL by the point we reach this line

COVERITY CID 1037151
2013-12-30 16:51:01 +01:00
Sebastian Rasmussen 53ae1b2c9c docs: Fix typos in function/object descriptions
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=720029
2013-12-07 17:11:12 +00:00
Jan Schmidt 73a58cb0a2 netclock: Fix docstring for round-trip-limit and uninit access warning.
Fix a typo in a doc string - the property is round-trip-limit, not
roundtrip-limit.

Remove a bogus GST_WARNING that can print an uninitialised variable
and is redundant anyway.
2013-11-27 18:32:22 +11:00
Carlos Rafael Giani 1ce704d45d netclock: Add round-trip-limit parameter
Sometimes, packets might take a very long time to return. Such packets
usually are way too late and destabilize the regression with their
obsolete data. On Wi-Fi, round-trips of over 7 seconds have been observed.

If the limit is set to a nonzero value, packets with a round-trip period
larger than the limit are ignored.

Signed-off-by: Carlos Rafael Giani <dv@pseudoterminal.org>

https://bugzilla.gnome.org/show_bug.cgi?id=712385
2013-11-27 18:15:20 +11:00
Jan Schmidt 75aa78ca70 netclock: Fix C99 comment 2013-11-26 02:43:54 +11:00
Jan Schmidt 5b2df52c6a netclock: Implement rolling-average filter on observations.
Keep a rolling average of the round trip time for network clock
observations, favouring shorter round trips as being more accurate.

Don't pass any clock observation to the clock slaving if it has a
round-trip time greater than 2 times the average.

Actual shifts in the network topology will be noticed after some
time, as the rolling average incorporates the new round trip times.
2013-11-26 02:20:14 +11:00
Philip Withnall 3c8424d9ae net: Constify a parameter to gst_net_client_clock_new()
Even though this parameter is not used, it should be const to fit in with the
coding standards for other similar parameters. Client code already passes in
const strings under the expectation that they won’t be modified.

https://bugzilla.gnome.org/show_bug.cgi?id=710442
2013-10-18 09:59:25 +01:00
Tim-Philipp Müller 98c1342614 timeprovider: g-i: allow None as address for gst_net_time_provider_new() 2013-07-16 14:48:18 +01:00
Sebastian Dröge d420686764 netclock: Add support for IPv6 2013-04-24 15:59:45 +02:00
Wim Taymans 2541ddf123 nettimeprovider: notify of changed bound address
Notify when the bound address is known, just like the port.
2013-04-11 14:04:45 +01:00
Tim-Philipp Müller 6e5405e9ce netclientclock: bind socket before querying local address
Fails on windows otherwise.

https://bugzilla.gnome.org/show_bug.cgi?id=697608
2013-04-09 19:38:59 +01:00
Tim-Philipp Müller 64eee27ebc Use GST_*_1_0 environment variables everywhere
The _1_0 suffixed environment variables override the
non-suffixed ones, so if we're in an environment that
sets the _1_0 suffixed ones, such as jhbuild, we need
to set those to make sure ours actually always get
used.
2013-01-15 13:47:32 +00:00
Sebastian Dröge e58dabc750 libs: Use foo/foo.h as single-include header consistently everywhere
https://bugzilla.gnome.org/show_bug.cgi?id=688785
2012-12-12 16:44:14 +00:00
Evan Nemerson 1afb1f12ef libs: Add missing single include headers and use them in GIRs 2012-11-21 11:00:40 +01:00
Tim-Philipp Müller 666c8c11c6 Fix FSF address
https://bugzilla.gnome.org/show_bug.cgi?id=687520
2012-11-03 20:44:48 +00:00
Tim-Philipp Müller 073c09afe0 g-i: fix "can't resolve libraries to shared libraries: gstcheck-1.0" build error
Revert --library=libfoo-1.0.la -> --library=foo-1.0 change made
in previous commit. Turns out that was wrong, despite what the
man page says.

https://bugzilla.gnome.org/show_bug.cgi?id=603710
2012-10-29 13:27:55 +00:00
Tim-Philipp Müller 21a74a6b79 libs: g-i: avoid multiple libraries in the shared-library tag
Using multiple libraries causes problems for the C# bindings and
will for similiar languages such as Java when there are bindings
for them.

Also change --library=libgstfoo-X.la to --library=gstfoo-X as
the man page suggests it should be done.

https://bugzilla.gnome.org/show_bug.cgi?id=679315
2012-10-28 17:20:10 +00:00
Wim Taymans ed19974e25 meta: do metadata registration threadsafe
We need to use g_once to register the metadata implementations
only once.

See https://bugzilla.gnome.org/show_bug.cgi?id=685332
2012-10-03 13:45:22 +02:00
Tim-Philipp Müller ca90ea6e55 Remove GST_USE_UNSTABLE_API guard and defines 2012-09-17 13:35:26 +01:00
Tim-Philipp Müller df2312fd6a netclientclock: fix printf format in debug message 2012-08-10 15:00:09 +01:00
Tim-Philipp Müller fe082cbe24 netclientclock: simplify by using g_socket_condition_timed_wait()
No need to use a custom main context and custom timeout sources,
just use g_socket_condition_timed_wait() instead, which was added
for exactly this case.

Also seems to help with the unit test deadlocking with glib 2.33.x

https://bugzilla.gnome.org/show_bug.cgi?id=681575
2012-08-10 09:31:31 +01:00
Evan Nemerson 0c70754282 nettimepacket: add missing array annotation to gst_net_time_packet_new 2012-07-17 09:38:03 +02:00
Wim Taymans ac54190c29 nettimepacket: make boxed 2012-06-20 09:22:40 +02:00
Evan Nemerson cf304d2748 net: fix some argument names in documentation 2012-06-19 19:55:30 -07:00
Sebastian Dröge b0d89da6b6 gst: Change versioning
Remove GST_MAJORMINOR and replace it by GST_API_VERSION
Also set GST_VERSION_{MAJOR,MINOR,MICRO,NANO} explicitely
now.

All versions are at 1.0.0 now for the release soon but
API/ABI can still change until the 1.0.0 release.

Next release versions until 1.0.0 will be 0.10.9X and
these will be release candidates. GST_VERSION_* will
nonetheless stay at 1.0.0.0.
2012-04-04 14:28:55 +02:00
Wim Taymans e80296cf46 meta: split registration of API and implementation
Split out the registration of the metadata API and its implementation. Make a
GType for each metadata API. This allows us to store extra information with the
API type such as the tags.
Change the buffer API so that we can get the metadata using the API GType.
Change the query API so that we use the metadata API GType in the allocation
query instead of a string.
Update netaddress and unit tests
2012-02-29 17:37:09 +01:00
Wim Taymans f0105dd81f meta: add return vale to transform
Add a boolean return value so that we can see when a transform fails.
2012-02-28 16:17:47 +01:00
Wim Taymans 166cfadb71 meta: add support to tagging the metadata
Add support for adding tags to the metadata. with some standard keys, this
should make it possible to describe what the metadata refers to. We should be
able to use this information to decide if a transformation destroys the metadata
or not.
2012-02-28 11:34:48 +01:00
Wim Taymans eb84682e92 clock: make more stuff private
Expose methods to get and set the timeout because subclasses uses this.
2012-02-27 09:11:36 +01:00
Wim Taymans 6b22a63f1b meta: flesh out the metadata transform
Flesh out the transform method. Add a type and extra info to the transform
function so that implementation can transform the metadata.
Remove the copy function and replace with the more generic transform.
2012-02-24 10:28:56 +01:00
Matej Knopp 7b16febb0d nettimepacket: fix printf format warning in debug message
https://bugzilla.gnome.org/show_bug.cgi?id=664491
2012-02-19 12:46:21 +00:00
Tim-Philipp Müller 13d91d1f6c Use recent GLib API unconditionally now that we depend on the latest GLib 2012-01-22 01:25:22 +00:00
Tim-Philipp Müller 4d27e79429 configure: remove some socket cruft 2012-01-18 01:22:52 +00:00
Tim-Philipp Müller 80f2eb6108 net: port to use gio's networking API
Some warts still, but it's a start.
2012-01-18 01:22:43 +00:00