Commit graph

64 commits

Author SHA1 Message Date
Thibault Saunier b8767fa18f sink: Move the homegrown congestion controller in it own file 2022-08-05 03:13:05 +02:00
Thibault Saunier c399b1f0c6 Use rtprtxsend stuffing when available and congestion control is enabled
Depends on https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2273/
2022-08-05 03:13:05 +02:00
Thibault Saunier 64f664c859 plugin: Implement bandwidth estimator based on the Google Congestion Control algorithm
See https://datatracker.ietf.org/doc/html/draft-ietf-rmcat-gcc-02

This commit implements the bandwidth estimation as a GStreamer element
that is then used in webrtcbin through the new `request-bandwidth-estimator`
signal.

This keeps our Homegrown congestion controller but removes the possibility
to switch CC algorithm at runtime.
2022-08-05 03:13:05 +02:00
Thibault Saunier 287e76847a plugin: Fix some clippy issues
And minor reformat
2022-08-05 03:13:05 +02:00
Thibault Saunier c53e5b8bb2 Allow passing free form metadatas about consumers/producers/listenners
In some applications people might need to be able to pass more metadata
than the only "display-name" this commit allow that by adding a field in
all signalling structure where it is free form json and removing the
"display-name" as the free form `meta` field allows application to pass
this kind of information without any problem.

On the "webrtcsink" side this commit adds a `meta` property as a
gst::Structure which will be passed as a json string to the signalling
server so we enforce data to be structured.
2022-07-27 16:57:20 +02:00
Mathieu Duponchelle ec46b706e9 webrtcsink: don't use framerate halving as mitigation when 0/1
Fixes #65
2022-06-08 01:35:21 +02:00
Mathieu Duponchelle d40b804952 webrtcsink: implement per-transceiver navigation support 2022-06-03 00:14:41 +02:00
Mathieu Duponchelle 42f2ae7c2b vpxenc: don't set resize-allowed to true
It wasn't clear what the purpose of setting it was in the first
place, and it was causing libvpx to print warnings at runtime ..
2022-06-02 23:22:24 +02:00
Thibault Saunier f6f079f3a8 Use StreamConsumer from gstreamer itself
Merged in https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1022
2022-05-23 13:52:39 +02:00
Jimmi Holst Christensen c02a0d8757 vp9enc takes target-bitrate as a i32 and not u32 2022-05-10 12:02:31 +03:00
Vivienne Watermeier f091e90b24 Depend on gstreamer-rs main to add a feature for v1_22 2022-05-09 22:49:24 +02:00
machenmusik ee950499d5 start_bitrate property, to allow specifying initial (video) bitrate 2022-05-05 22:28:23 +02:00
Thibault Saunier 075a625305 Make our "loss based control" algorithm closer to what is defined in [GCC]
As specified in Google Congestion Control we should run the packet loss
estimation algorithm "every time feedback from the receiver is
received".

And, also as defined by GCC, we now have 2 different estimated bitrates,
one for the delay-based controller value and one for the loss-based one,
and we use the minimum value between those 2 as our current estimation.

[GCC]: https://datatracker.ietf.org/doc/html/draft-ietf-rmcat-gcc-02
2022-05-03 15:21:20 +02:00
Nils Kattenbeck 3c81afa7b2 Set constant bitrate rate-control for VAAPI encoder 2022-04-28 18:55:41 +02:00
Nils Kattenbeck e4846d0d53 Add support for VAAPI VP8 encoder 2022-04-28 18:55:41 +02:00
Nils Kattenbeck 843875e95d Add support for VAAPI h264 encoder 2022-04-28 18:55:41 +02:00
Nils Kattenbeck 3b04a3c06d Remove is_video field from Codec struct
Instead add it as a function and get the value from the encoder type.
This removes the necessity for any manual bookkeeping.
2022-04-28 16:02:09 +02:00
Mathieu Duponchelle b51cdb9de0 webrtcsink: call recalculate_latency on LATENCY messages 2022-04-23 02:03:42 +02:00
Raphael Dürscheid ee200326ef Implemente clippy suggestions 2022-04-22 20:01:56 +03:00
Raphael Dürscheid b66db922d8 Remove erranous unwrap() on use_clock 2022-04-22 20:01:56 +03:00
Raphael Dürscheid 3e5fa04379 Consumer pipeline should use_clock 2022-04-22 18:37:46 +03:00
Thibault Saunier f11260aeb5 webrtcsink: Fix a race starting the signaller
1. Working scenario:

T1 -> Caps event (all caps have been received)
T1     -> Start discovering
T2 -> Change state to Playing
T2        -> The signaller is not started as:
                - Sink current_state() == Paused as it will be set to
                  playing after the change_state vmethod returns
                - Discovery is not done anyway
T1 -> Discovery is done
        => The signaller is started, and **everything works well**.

2. Failing scenario:

T1 -> Caps event (all caps have been received)
T1     -> Start discovering
T1 -> Discovery is done
T1        -> The signaller is not started as:
                - Current state == Paused (it will be set to playing
                  after the change_state vmethod returns)
                - Discovery is not done anyway
T2 -> Change state to Playing
T2        -> The signaller is not started as:
                - Sink current_state == Paused  as it will be set to
                  playing after the we return from the change_state
                  vmethod

In that case the signaller never starts.
2022-04-20 18:47:24 +02:00
Thibault Saunier 03430a9571 sink: Force data channel priority to high
Low latency is very important for user interaction
2022-04-14 23:21:01 +02:00
Thibault Saunier 9285798210 Do not reset caps when they do not change
Otherwise a useless renegotiation will be triggered by capsfilter
2022-04-14 23:13:17 +02:00
Mathieu Duponchelle f6eb967cbe webrtcsink: address Sebastian's latest comments
+ refactor encoder-setup signal emission
+ document unused fields in navigation event handler
2022-03-26 00:16:29 +01:00
Mathieu Duponchelle b80cf1fb8e webrtcsink: turn NavigationEventHandler into a tuple wrapper
More elegant way of not bumping into the unused fields warning
than prefixing with _
2022-03-25 02:46:45 +01:00
Mathieu Duponchelle 983fcf2fbd webrtcsink: expose signal for initial encoder configuration
+ Update README
2022-03-25 02:34:53 +01:00
Mathieu Duponchelle b5443c5966 webrtcsink: don't set msid-appdata on transceivers
The change was merged inadvertently alongside the display-name
API extension, we will probably eventually expose API on webrtcsink
pads to control that, but we won't just set it to pad.name() anyway.

Fixes #33
2022-03-24 17:46:51 +01:00
Mathieu Duponchelle 70e6227c9a webrtcsink: reduce latency with vpx encoders
The lag-in-frames property needs to be explicitly set to 0
2022-03-23 02:44:25 +01:00
Mathieu Duponchelle bd560fa9f9 protocol: allow registering with a display name
While the signalling server will allocate unique identifiers for
each peer, users may want to also pass their own identifiers.
2022-03-23 01:35:10 +01:00
Mathieu Duponchelle bd88395859 signalling: update protocol, reimplement in rust 2022-03-17 18:31:54 +01:00
Mathieu Duponchelle 7f000ea42b webrtcsink: trigger negotiation manually
We no longer connect to on-negotiation-needed, this in order to call the
consumer-added signal without holding the state lock:

Going to Ready triggers synchronous emission of the on-negotiation-needed
signal, during which time the application may add a data channel, causing
renegotiation, which we do not support at this time.

This is completely safe, as we know that at that point all conditions are
gathered: webrtcbin is in the Ready state, and all its transceivers have
codec_preferences.
2022-03-01 02:32:50 +01:00
Mathieu Duponchelle 3a5e05f2ab webrtcsink: emit consumer-added with webrtcbin in the Ready state
In order for applications to potentially create data channels at
the correct moment
2022-03-01 02:32:50 +01:00
machenmusik 9e7406cec0 change x264enc default bitrate to match nvh264enc
Assume default bitrate should be the same for a given codec (here, H264 is 2048u32) regardless of which encoder is used (x264enc, nvh264enc).
2022-02-09 01:37:13 +01:00
Thibault Saunier 51c2f35909 Reformat code with 'cargo fmt' 2022-02-08 15:12:45 +01:00
Thibault Saunier 22205c235d Release 'state' lock before emitting signals 2022-02-08 15:12:45 +01:00
Thibault Saunier 794df19122 Add a new 'get-consumers' action signal
So user can get the list of currently avalaible consumers (by ID).
2022-02-08 15:12:45 +01:00
Thibault Saunier 4e0e8d1cc3 Rename the new-webrtcbin signal to consumer-added
For symmetry with the new  `consumer-removed` signal.
2022-02-08 15:12:45 +01:00
Thibault Saunier 36eb00121c Add a consumer-removed signal to notify the application 2022-02-08 15:12:45 +01:00
Mathieu Duponchelle b185819140 webrtcsink: don't add video elements to audio discovery pipeline 2022-01-20 20:37:27 +01:00
Thibault Saunier 689bd93055 Implement the GstNavigation interface using a dedicated DataChannel protocol
This allows interacting with the source element from within the browser
very easily
2022-01-03 22:30:44 +01:00
Thibault Saunier cf176bdd93 Update plugins/src/webrtcsink/imp.rs
Co-authored-by: Sebastian Dröge <slomo@coaxion.net>
2022-01-03 18:29:45 +01:00
Thibault Saunier 300adda41b Dot 'caps inspection' pipelines 2022-01-03 18:29:45 +01:00
Thibault Saunier 85fd7175de Add support for cuda and GL memory
This way we don't need to download/upload when unnecessary
2022-01-03 18:29:45 +01:00
Sebastian Dröge d6ba009742 Fix various clippy warnings 2021-12-28 18:28:09 +01:00
Thibault Saunier da0a934307 nvh264enc: Do not wrongly set vbv-buffer-size and use the cbr-ld-hq rc-mode
vbv-buffer-size which is in kbits can't be set while playing so we
can't really use it for our use case.
2021-12-23 17:02:50 +01:00
Mathieu Duponchelle 8128c14fa9 API: refactor error signalling
* Expect Box<dyn Error> from custom signaller

* Use thiserror to define the error codes returned to custom
  signallers
2021-12-21 23:37:29 +01:00
Mathieu Duponchelle a4df10b112 webrtcsink: reset default values when disabling congestion control 2021-12-10 03:33:02 +01:00
Mathieu Duponchelle d230345d90 webrtcsink: make sure we always scale to multiple of 2 dimensions
Some encoders do not like odd widths or heights
2021-12-10 01:16:10 +01:00
Mathieu Duponchelle 1826111278 Implement support for FEC / retransmission 2021-12-10 01:12:19 +01:00