View Source Upgrading to v0.14
Version 0.14 removes the concept of peers from the RTC Engine meaning that RTC Engine only operates on Endpoints.
In practice, most changes come down to updating callback names.
Below, there are two PRs that update RTC Engine to the v0.14 in our demos:
- https://github.com/membraneframework/membrane_videoroom/pull/178/files
- https://github.com/membraneframework-labs/membrane_live/pull/187
RTC Engine (Elixir)
Instead of peer_id
or endpoint_id
use id
:
- :ok = Engine.add_endpoint(state.rtc_engine, endpoint, peer_id: peer_id, node: peer_node)
+ :ok = Engine.add_endpoint(state.rtc_engine, endpoint, id: peer_id, node: peer_node)
SDK (JS)
MembraneWebRTC
class was renamed to WebRTCEndpoint
.
It also no longer takes callbacks in the constructor.
Instead, you have to subscribe for events:
- const webrtc = new MembraneWebRTC({callbacks: {}})
+ const webrtc = new WebRTCEndpoint();
callback | event |
---|---|
onSendMediaEvent | webrtc.on("sendMediaEvent") |
onConnectionError | webrtc.on("connectionError") |
onJoinSuccess | webrtc.on("connected") |
onTrackReady | webrtc.on("trackReady") |
onTrackAdded | webrtc.on("trackAdded") |
onTrackRemoved | webrtc.on("trackRemoved") |
onPeerJoined | webrtc.on("endpointAdded") |
onPeerLeft | webrtc.on("endpointRemoved") |
onTrackUpdated | webrtc.on("trackUpdated") |
onTrackEncodingChanged | trackCtx.on("encodingChanged") |
onJoinError | removed |
The process of "connecting" SDK to the RTC Engine endpoint is all about sending
a single message indicating SDK readiness.
Therefore, instead of using onJoinError
, a user is expected to observe its transport status (in most cases WS connection)
and can add tracks as soon as connect
function has been called.
It's important that endpointAdded
event will be emitted for every endpoint added to the engine.
You can filter out endpoints by their type i.e.
webrtc.on("endpointAdded", (endpoint: Endpoint) => {
if (endpoint.type === "webrtc") {
// do something
}
});
Connecting
- webrtc.join(peerMetadata);
+ webrtc.connect(metadata);
Leaving
- webrtc.leave();
+ webrtc.disconnect();