Example of streamer for Android
This streamer can be used to publish WebRTC video stream on Web Call Server.
On the screenshot below the example is displayed when a stream is being published.
In the URL specified in the input field
- 192.168.2.104 is the address of the WCS server
- test is the stream name
Two videos are played
- left - video from the camera
- right - the published video stream as received from the server
Work with code of the example
1. Initialization of the API. line 67
For initialization, object Сontext is passed to the init() method.
2. Connection to server.
Session for connection to server is created when Start button is clicked. line 106
Session is created with method createSession(), to which object SessionOptions (line 99) with the following parameters is passed
- URL of WCS server
- SurfaceViewRenderer, which will be used to display video from the camera
- SurfaceViewRenderer, which will be used to play the published video stream
Callback functions for session events are added (line 111)
- onConnected() - will be called when connection is successfully established
- onDisconnection() - will be called when connection is closed
Method Session.connect() is called to establish connection with WCS server. line 222
3. Video streaming.
Callback function for processing stream statuses is added. (line 141)
Method Stream.publish() is called to publish the stream. line 194
4. Playback of video stream.
Callback function for processing stream statuses is added. (line 163)
Method Stream.play() is called to play the stream. line 181
5. Disconnection. line 234
Method Session.disconnect() is called to close connection to the server.