Video Communication LifeCycle
What does a video communication lifecycle look like?
Before starting coding... let's walk through the main concepts, methods and classes used during a Conversation lifecycle.
- First, each run of a client application instantiates one
UserAgentrepresenting the local individual,
Sessionmust be opened with ApiRTC's servers to create a
Conversationto which individuals can join,
- In a
Conversation, individuals can chat, watch, listen and/or share real-time audio, video, data, screen...,
Streamis audio, and/or video captured from sources available from browser and published on a
As the entry point to ApiRTC,
UserAgentis instantiated using the apiKey associated to your enterprise account on https://cloud.apirtc.com.
UserAgent.createStream(options)is called, a popup opens in the browser to request user acceptance for using media devices. The returned
Promiseresolves with an instance of
Stream, which carries media stream from computer device through the browser.
Stream.attachToElement(domElement)binds the media stream to a DOM
<video>element in order to display it in the web page.
To use ApiRTC's connected features, a
userAgentmust register to get a session. This can be done with or without authentication.
UserAgent.register()without authentication details registers a
userAgentwith ApiRTC's servers without authentication.
sessiongrants access to connected features such as conversations.
An instance of
Conversationis obtained from
userAgentused to create the
Sessionused to create this instance of
Session) join the conversation.
Once a conversation joined, a
userAgentcan publish a stream using
Subscribing to peer streams shall be implemented as followed:
- Listen on
'streamListChanged'event to get notified of streams published to the conversation. The data provided by the event is a
StreamInfo: It gives information on streams published in the conversation such as the id (
StreamInfo.streamId) of the stream.
StreamInfo.listEventTypeproperty tells whether the event is triggered for and addition (value
'added') or a removal.
StreamInfo.streamIdof an added remote stream makes this conversation subscribe to a stream.
- Finally, listening on
'streamAdded'notifies with a remote
Streaminstance which can be attached to web page for display.