Commit graph

26 commits

Author SHA1 Message Date
Robert Ayrapetyan bac5845be1 webrtc: add support for insecure tls connections
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1553>
2024-05-16 19:34:57 +00:00
Robert Ayrapetyan 972b9e5474 doc: add docstrings for signaller object
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1419>
2024-02-01 19:31:58 +00:00
Robert Ayrapetyan 7a72b2fc25 webrtcsink-signalling: add headers support
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1419>
2024-02-01 19:31:58 +00:00
François Laignel 91bfd0f7c3 webrtc: signallers: attempt to close the ws when an error occurs
This commit discards the early error returns in the send tasks to log the error
and attempt to close the websocket.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1435>
2024-02-01 18:08:41 +01:00
François Laignel f54d714afd webrtc: only use close() to close websockets
In the signaller clients and servers, the following sequence is used to close
the websocket (in the [send task]):

```rust
    ws_sink.send(WsMessage::Close(None)).await?;
    ws_sink.close().await?;
```

tungstenite's [`WebSocket::close()` doc] states:

> Calling this function is the same as calling `write(Message::Close(..))``

So we might think they are redundant and either could be used for this purpose
(`send()` calls `write()`, then `flush()`).

The result is actually is bit different as `write()` starts by checking the
state of the connection and [returns `SendAfterClosing`] if the socket is no
longer active, which is the case when a closing request has been received from
the peer via a [call to `do_close()`]). Note that `do_close()` also enqueues a
`Close` frame.

This behaviour is visible from the server's logs:

```
1. tungstenite::protocol: Received close frame: None
2. tungstenite::protocol: Replying to close with Frame { header: FrameHeader { .., opcode: Control(Close), .. }, payload: [] }
3. gst_plugin_webrtc_signalling::server: Received message Ok(Close(None))
4. gst_plugin_webrtc_signalling::server: connection closed: None this_id=cb13892f-b4d5-4d59-95e2-b3873a7bd319
5. remove_peer{peer_id="cb13892f-b4d5-4d59-95e2-b3873a7bd319"}: gst_plugin_webrtc_signalling::server: close time.busy=285µs time.idle=55.5µs
6. async_tungstenite: websocket start_send error: WebSocket protocol error: Sending after closing is not allowed
```

1: The server's websocket receives the peer's `Close(None)`.
2: `do_close()` enqueues a `Close` frame.
3: The incoming `Close(None)` is handled by the server.
4 & 5: perform session closing.
6: `ws_sink.send(WsMessage::Close(None))` attempts to `write()` while the ws
   is no longer active. The error causes an early return, which means that
   the enqueued `Close` frame is not flushed.

Depending on the peer's shutdown sequence, this can result in the following
error, which can bubble up as a `Message` on the application's bus:

```
ERROR: from element /GstPipeline:pipeline0/GstWebRTCSrc:webrtcsrc0: GStreamer encountered a general stream error.
Additional debug info:
net/webrtc/src/webrtcsrc/imp.rs(625): gstrswebrtc::webrtcsrc:👿:BaseWebRTCSrc::connect_signaller::{{closure}}::{{closure}} (): /GstPipeline:pipeline0/GstWebRTCSrc:webrtcsrc0:
Signalling error: Error receiving: WebSocket protocol error: Connection reset without closing handshake
```

On the other hand, [`close()` ensures the ws is active] before attempting to
write a `Close` frame. If it's not, it only flushes the stream.

Thus, when we want to be able to close the websocket and/or to honor the closing
handshake in response to the peer `Close` message, the `ws_sink.close()`
variant is preferable.

This can be verified in the resulting server's logs:

```
tungstenite::protocol: Received close frame: None
tungstenite::protocol: Replying to close with Frame { header: FrameHeader { is_final: true, rsv1: false, rsv2: false, rsv3: false, opcode: Control(Close), mask: None}, payload: [] }
gst_plugin_webrtc_signalling::server: Received message Ok(Close(None))
gst_plugin_webrtc_signalling::server: connection closed: None this_id=192ed7ff-3b9d-45c5-be66-872cbe67d190
remove_peer{peer_id="192ed7ff-3b9d-45c5-be66-872cbe67d190"}: gst_plugin_webrtc_signalling::server: close time.busy=22.7µs time.idle=37.4µs
tungstenite::protocol: Sending pong/close
```

We now get the notification `Sending pong/close` (the closing handshake) instead
of `websocket start_send error` from step 6 with previous variant.

The `Connection reset without closing handshake` was not observed after this
change.

[send task]: 63b568f4a0/net/webrtc/signalling/src/server/mod.rs (L165)
[`WebSocket::close()` doc]: https://docs.rs/tungstenite/0.21.0/tungstenite/protocol/struct.WebSocket.html#method.close
[returns `SendAfterClosing`]: 85463b264e/src/protocol/mod.rs (L437)
[call to `do_close()`]: 85463b264e/src/protocol/mod.rs (L601)
[`close()` ensures the ws is active]: 85463b264e/src/protocol/mod.rs (L531)

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1435>
2024-02-01 18:08:41 +01:00
Sebastian Dröge 4ad101b53b Use once_cell crate directly again
The glib crate does not depend on it anymore and also does not re-export
it anymore.

Also switch some usages of OnceCell to OnceLock from std.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1441>
2024-01-31 18:07:57 +02:00
Eva Pace 80b58f3b45 net/webrtc/janusvr: add JanusVRWebRTCSink plugin/signaller
The JanusVRWebRTCSink is a new plugin that integrates with the Video
Room plugin of the Janus Gateway, which simplifies WebRTC communication.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1362>
2024-01-17 20:33:57 +00:00
Loïc Le Page e5e3dc6e19 net/webrtc/signaller: add property to get the connection client ID
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1296>
2023-08-10 17:30:21 +02:00
Loïc Le Page 7af2ff0843 net/webrtc/signaller: advertise running producers in Listener mode
When starting a webrtcsrc-signaller client in Listener mode, only the producers
started after the client connection were advertised. All currently
running producers were ignored unlike the gstwebrtc-api behavior. This
commit now lists all running producers when the client Listener connects
and advertises them through the "producer-added" signal.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1296>
2023-08-10 17:30:21 +02:00
Bilal Elmoussaoui dd2d7d9215 Use re-exported once_cell
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1268>
2023-07-06 17:50:49 +03:00
Matthew Waters 2ac560975c webrtc/signaller: emit the relevant signals instead of the interface vtable
In order to support the use case of an external user providing their own
signalling mechanism, we want the signals to be used and only if nothing
is connected, fallback to the default handling.  Calling the interface
vtable directly will bypass the signal emission entirely.

Also ensure that the signals are defined properly for this case. i.e.
1. Signals the the application/external code is expected to emit are
   marked as an action signal.
2. Add accumulators to avoid calling the default class handler if
   another signal handler is connected.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1141>
2023-04-07 09:58:13 +10:00
Thibault Saunier 8236f3e5e7 webrtcsink: Port to the 'webrtcsrc' signaller object/interface
With contributions from:
Matthew Waters <matthew@centricular.com>

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1141>
2023-04-07 09:03:47 +10:00
Mathieu Duponchelle 584392049c net/webrtc: implement AWS KVS signaller
And expose a wrapper webrtcsink variant, aws-kvs-webrtcsink.

This adds support in webrtcsink for processing a consumer offer, instead
of producing one.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1114>
2023-03-09 15:39:09 +00:00
Thibault Saunier 0ae637f531 webrtcsink: Move RUNTIME to the crate so it can be reused
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/932>
2023-02-28 17:57:14 -03:00
Sebastian Dröge 4582ae91ab Move remaining plugins to ParamSpec builders
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1054>
2023-01-21 18:34:55 +02:00
Zhao, Gang 9fa838e366 webrtc: Fix rustfmt errors
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1019>
2022-12-27 11:12:54 +02:00
Zhao, Gang 877a9bd7f3 webrtc: Share runtime between webrtcsink and signaller crates
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1019>
2022-12-26 23:10:40 +00:00
Zhao, Gang 1ffeb4d44d webrtc: Move from async-std to tokio
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1019>
2022-12-26 23:10:40 +00:00
Sebastian Dröge 9a68f6e221 Move from imp.instance() to imp.obj()
It's doing the same thing and is shorter.
2022-10-23 23:08:46 +03:00
François Laignel 86776be58c Remove & for obj in log macros
This is no longer necessary.

See https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1137
2022-10-23 21:22:31 +02:00
Sebastian Dröge f045099fc1 Fix GObject type names, GStreamer debug category names and element factory names
Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/issues/198
2022-10-23 20:46:08 +03:00
Thibault Saunier 71ed04d89b webrtc: Rename signaller and protocol crates 2022-10-20 13:32:31 +02:00
Thibault Saunier 4942a916a8 webrtc: Uniformise GType names 2022-10-20 13:32:31 +02:00
Thibault Saunier 0f0dec7fa9 webrtc: Fix fmt issues 2022-10-20 11:51:59 +02:00
Thibault Saunier 5ab7be6124 webrtc: Add SDPX license header on every file 2022-10-20 11:51:58 +02:00
Thibault Saunier 39c0dcb0d4 Plug webrtc in 2022-10-20 11:51:58 +02:00
Renamed from net/webrtc/plugins/src/signaller/imp.rs (Browse further)