Skip to main content

Setup video stream overview

Video stream is a real-time communication protocol, setting up a video stream is the first step to manage video calls. This section covers everything you need to do to set up a video stream.

Video stream API

// Initialize stream to listen for events:
const stream = await userAlice.initStream([CONSTANTS.STREAM.VIDEO]);

// Listen for video events
// Import { TYPES, CONSTANTS } from @pushprotocol/restapi
stream.on(CONSTANTS.STREAM.VIDEO, async (data: TYPES.VIDEO.EVENT) => {
if (data.event === CONSTANTS.VIDEO.EVENT.REQUEST) {
// handle call request
}

if (data.event === CONSTANTS.VIDEO.EVENT.APPROVE) {
// handle call approve
}

if (data.event === CONSTANTS.VIDEO.EVENT.DENY) {
// handle call denied
}

if (data.event === CONSTANTS.VIDEO.EVENT.CONNECT) {
// handle call connected
}

if (data.event === CONSTANTS.VIDEO.EVENT.DISCONNECT) {
// handle call disconnected
}
});

// Connect stream, Important to setup up listen first
stream.connect();

// stream supports other products as well, such as CONSTANTS.STREAM.NOTIF, CONSTANTS.STREAM.CHAT
// more info can be found at push.org/docs

Video stream parameters

ParamTypeSub-TypeDefaultRemarks
listenconstant--can be CONSTANTS.STREAM.VIDEO, CONSTANTS.STREAM.CHAT, CONSTANTS.STREAM.CHAT_OPS, CONSTANTS.STREAM.NOTIF, CONSTANTS.STREAM.CONNECT, CONSTANTS.STREAM.DISCONNECT
optionsPushStreamInitializeProps--Optional configuration properties for initializing the stream.
-options.filterobject-Option to configure to enable listening to only certain chats or notifications.
-options.filter.channelsarray of strings['*']pass list of channels over here to only listen to notifications coming from them.
-options.filter.chatsarray of strings['*']pass list of chatids over here to only listen to chats coming from them.
-options.connectionobject-Option to configure the connection settings of the stream
-options.connection.retriesnumber3Number of automatic retries incase of error
-options.rawbooleanfalseIf enabled, will also respond with meta data useful in verifying the integrity of incoming chats or notifications among other things.

Note: Parameters in this style are mandatory.

Stream video listen events

Listen eventsWhen is it triggered?
CONSTANTS.STREAM.VIDEOWhenever a video call operation is received.
CONSTANTS.STREAM.CHATWhenever a chat is received.
CONSTANTS.STREAM.CHAT_OPSWhenever a chat operation is received.
CONSTANTS.STREAM.CONNECTWhenever the stream establishes connection.
CONSTANTS.STREAM.DISCONNECTWhenever the stream gets disconnected.
Expected response (CONSTANTS.STREAM.VIDEO - Video Request Stream)
{
"event": "video.request",
"origin": "other",
"timestamp": "2024-01-12T10:58:12.000Z",
"peerInfo": {
"address": "0xb73923eCcfbd6975BFd66CD1C76FA6b883E30365",
"signal": {
"type": "offer",
"sdp": "v=0\r\no=- 508831357760638057 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE 0 1 2\r\na=extmap-allow-mixed\r\na=msid-semantic: WMS d5d7d3af-1896-4fa6-8137-4af932498981\r\nm=audio 10571 UDP/TLS/RTP/SAVPF 111 63 9 0 8 13 110 126\r\nc=IN IP4 54.210.214.72\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=candidate:3030853203 1 udp 2122194687 192.168.29.84 57992 typ host generation 0 network-id 1 network-cost 10\r\na=candidate:3571041920 1 udp 2122262783 2405:201:e05d:901f:758d:b62b:c688:3bfc 59792 typ host generation 0 network-id 2 network-cost 10\r\na=candidate:2617153118 1 tcp 1518214911 192.168.29.84 9 typ host tcptype active generation 0 network-id 1 network-cost 10\r\na=candidate:4219500173 1 tcp 1518283007 2405:201:e05d:901f:758d:b62b:c688:3bfc 9 typ host tcptype active generation 0 network-id 2 network-cost 10\r\na=candidate:206483833 1 udp 1685987071 49.47.243.192 57992 typ srflx raddr 192.168.29.84 rport 57992 generation 0 network-id 1 network-cost 10\r\na=candidate:2447486818 1 udp 41820671 54.210.214.72 10571 typ relay raddr 49.47.243.192 rport 57992 generation 0 network-id 1 network-cost 10\r\na=ice-ufrag:sv6b\r\na=ice-pwd:iem1/y+PIDOHi+aDlh9edOvJ\r\na=fingerprint:sha-256 41:39:A8:9C:80:63:62:C2:42:66:FA:93:F4:8B:80:00:E3:92:A7:A6:DF:22:C5:A0:CE:86:9A:74:A9:3A:A1:32\r\na=setup:actpass\r\na=mid:0\r\na=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level\r\na=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\na=extmap:3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01\r\na=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid\r\na=sendrecv\r\na=msid:d5d7d3af-1896-4fa6-8137-4af932498981 2c78691d-8950-4f0e-9978-675ab79cf25e\r\na=rtcp-mux\r\na=rtpmap:111 opus/48000/2\r\na=rtcp-fb:111 transport-cc\r\na=fmtp:111 minptime=10;useinbandfec=1\r\na=rtpmap:63 red/48000/2\r\na=fmtp:63 111/111\r\na=rtpmap:9 G722/8000\r\na=rtpmap:0 PCMU/8000\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:13 CN/8000\r\na=rtpmap:110 telephone-event/48000\r\na=rtpmap:126 telephone-event/8000\r\na=ssrc:1869951379 cname:WDDGNefJaEGMBgRU\r\na=ssrc:1869951379 msid:d5d7d3af-1896-4fa6-8137-4af932498981 2c78691d-8950-4f0e-9978-675ab79cf25e\r\nm=video 13688 UDP/TLS/RTP/SAVPF 96 97 102 103 104 105 106 107 108 109 127 125 39 40 45 46 98 99 100 101 112 113 116 117 118\r\nc=IN IP4 54.210.214.72\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=candidate:3030853203 1 udp 2122194687 192.168.29.84 50411 typ host generation 0 network-id 1 network-cost 10\r\na=candidate:3571041920 1 udp 2122262783 2405:201:e05d:901f:758d:b62b:c688:3bfc 58921 typ host generation 0 network-id 2 network-cost 10\r\na=candidate:2617153118 1 tcp 1518214911 192.168.29.84 9 typ host tcptype active generation 0 network-id 1 network-cost 10\r\na=candidate:4219500173 1 tcp 1518283007 2405:201:e05d:901f:758d:b62b:c688:3bfc 9 typ host tcptype active generation 0 network-id 2 network-cost 10\r\na=candidate:206483833 1 udp 1685987071 49.47.243.192 50411 typ srflx raddr 192.168.29.84 rport 50411 generation 0 network-id 1 network-cost 10\r\na=candidate:2447486818 1 udp 41820671 54.210.214.72 13688 typ relay raddr 49.47.243.192 rport 50411 generation 0 network-id 1 network-cost 10\r\na=ice-ufrag:sv6b\r\na=ice-pwd:iem1/y+PIDOHi+aDlh9edOvJ\r\na=fingerprint:sha-256 41:39:A8:9C:80:63:62:C2:42:66:FA:93:F4:8B:80:00:E3:92:A7:A6:DF:22:C5:A0:CE:86:9A:74:A9:3A:A1:32\r\na=setup:actpass\r\na=mid:1\r\na=extmap:14 urn:ietf:params:rtp-hdrext:toffset\r\na=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\na=extmap:13 urn:3gpp:video-orientation\r\na=extmap:3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01\r\na=extmap:5 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay\r\na=extmap:6 http://www.webrtc.org/experiments/rtp-hdrext/video-content-type\r\na=extmap:7 http://www.webrtc.org/experiments/rtp-hdrext/video-timing\r\na=extmap:8 http://www.webrtc.org/experiments/rtp-hdrext/color-space\r\na=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid\r\na=extmap:10 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id\r\na=extmap:11 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id\r\na=sendrecv\r\na=msid:d5d7d3af-1896-4fa6-8137-4af932498981 d5eecad5-c5db-474c-914f-43e316c0785f\r\na=rtcp-mux\r\na=rtcp-rsize\r\na=rtpmap:96 VP8/90000\r\na=rtcp-fb:96 goog-remb\r\na=rtcp-fb:96 transport-cc\r\na=rtcp-fb:96 ccm fir\r\na=rtcp-fb:96 nack\r\na=rtcp-fb:96 nack pli\r\na=rtpmap:97 rtx/90000\r\na=fmtp:97 apt=96\r\na=rtpmap:102 H264/90000\r\na=rtcp-fb:102 goog-remb\r\na=rtcp-fb:102 transport-cc\r\na=rtcp-fb:102 ccm fir\r\na=rtcp-fb:102 nack\r\na=rtcp-fb:102 nack pli\r\na=fmtp:102 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f\r\na=rtpmap:103 rtx/90000\r\na=fmtp:103 apt=102\r\na=rtpmap:104 H264/90000\r\na=rtcp-fb:104 goog-remb\r\na=rtcp-fb:104 transport-cc\r\na=rtcp-fb:104 ccm fir\r\na=rtcp-fb:104 nack\r\na=rtcp-fb:104 nack pli\r\na=fmtp:104 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42001f\r\na=rtpmap:105 rtx/90000\r\na=fmtp:105 apt=104\r\na=rtpmap:106 H264/90000\r\na=rtcp-fb:106 goog-remb\r\na=rtcp-fb:106 transport-cc\r\na=rtcp-fb:106 ccm fir\r\na=rtcp-fb:106 nack\r\na=rtcp-fb:106 nack pli\r\na=fmtp:106 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f\r\na=rtpmap:107 rtx/90000\r\na=fmtp:107 apt=106\r\na=rtpmap:108 H264/90000\r\na=rtcp-fb:108 goog-remb\r\na=rtcp-fb:108 transport-cc\r\na=rtcp-fb:108 ccm fir\r\na=rtcp-fb:108 nack\r\na=rtcp-fb:108 nack pli\r\na=fmtp:108 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42e01f\r\na=rtpmap:109 rtx/90000\r\na=fmtp:109 apt=108\r\na=rtpmap:127 H264/90000\r\na=rtcp-fb:127 goog-remb\r\na=rtcp-fb:127 transport-cc\r\na=rtcp-fb:127 ccm fir\r\na=rtcp-fb:127 nack\r\na=rtcp-fb:127 nack pli\r\na=fmtp:127 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=4d001f\r\na=rtpmap:125 rtx/90000\r\na=fmtp:125 apt=127\r\na=rtpmap:39 H264/90000\r\na=rtcp-fb:39 goog-remb\r\na=rtcp-fb:39 transport-cc\r\na=rtcp-fb:39 ccm fir\r\na=rtcp-fb:39 nack\r\na=rtcp-fb:39 nack pli\r\na=fmtp:39 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=4d001f\r\na=rtpmap:40 rtx/90000\r\na=fmtp:40 apt=39\r\na=rtpmap:45 AV1/90000\r\na=rtcp-fb:45 goog-remb\r\na=rtcp-fb:45 transport-cc\r\na=rtcp-fb:45 ccm fir\r\na=rtcp-fb:45 nack\r\na=rtcp-fb:45 nack pli\r\na=rtpmap:46 rtx/90000\r\na=fmtp:46 apt=45\r\na=rtpmap:98 VP9/90000\r\na=rtcp-fb:98 goog-remb\r\na=rtcp-fb:98 transport-cc\r\na=rtcp-fb:98 ccm fir\r\na=rtcp-fb:98 nack\r\na=rtcp-fb:98 nack pli\r\na=fmtp:98 profile-id=0\r\na=rtpmap:99 rtx/90000\r\na=fmtp:99 apt=98\r\na=rtpmap:100 VP9/90000\r\na=rtcp-fb:100 goog-remb\r\na=rtcp-fb:100 transport-cc\r\na=rtcp-fb:100 ccm fir\r\na=rtcp-fb:100 nack\r\na=rtcp-fb:100 nack pli\r\na=fmtp:100 profile-id=2\r\na=rtpmap:101 rtx/90000\r\na=fmtp:101 apt=100\r\na=rtpmap:112 H264/90000\r\na=rtcp-fb:112 goog-remb\r\na=rtcp-fb:112 transport-cc\r\na=rtcp-fb:112 ccm fir\r\na=rtcp-fb:112 nack\r\na=rtcp-fb:112 nack pli\r\na=fmtp:112 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=64001f\r\na=rtpmap:113 rtx/90000\r\na=fmtp:113 apt=112\r\na=rtpmap:116 red/90000\r\na=rtpmap:117 rtx/90000\r\na=fmtp:117 apt=116\r\na=rtpmap:118 ulpfec/90000\r\na=ssrc-group:FID 1049379659 118274336\r\na=ssrc:1049379659 cname:WDDGNefJaEGMBgRU\r\na=ssrc:1049379659 msid:d5d7d3af-1896-4fa6-8137-4af932498981 d5eecad5-c5db-474c-914f-43e316c0785f\r\na=ssrc:118274336 cname:WDDGNefJaEGMBgRU\r\na=ssrc:118274336 msid:d5d7d3af-1896-4fa6-8137-4af932498981 d5eecad5-c5db-474c-914f-43e316c0785f\r\nm=application 17668 UDP/DTLS/SCTP webrtc-datachannel\r\nc=IN IP4 54.210.214.72\r\na=candidate:3030853203 1 udp 2122194687 192.168.29.84 62444 typ host generation 0 network-id 1 network-cost 10\r\na=candidate:3571041920 1 udp 2122262783 2405:201:e05d:901f:758d:b62b:c688:3bfc 59695 typ host generation 0 network-id 2 network-cost 10\r\na=candidate:2617153118 1 tcp 1518214911 192.168.29.84 9 typ host tcptype active generation 0 network-id 1 network-cost 10\r\na=candidate:4219500173 1 tcp 1518283007 2405:201:e05d:901f:758d:b62b:c688:3bfc 9 typ host tcptype active generation 0 network-id 2 network-cost 10\r\na=candidate:206483833 1 udp 1685987071 49.47.243.192 62444 typ srflx raddr 192.168.29.84 rport 62444 generation 0 network-id 1 network-cost 10\r\na=candidate:2447486818 1 udp 41820671 54.210.214.72 17668 typ relay raddr 49.47.243.192 rport 62444 generation 0 network-id 1 network-cost 10\r\na=ice-ufrag:sv6b\r\na=ice-pwd:iem1/y+PIDOHi+aDlh9edOvJ\r\na=fingerprint:sha-256 41:39:A8:9C:80:63:62:C2:42:66:FA:93:F4:8B:80:00:E3:92:A7:A6:DF:22:C5:A0:CE:86:9A:74:A9:3A:A1:32\r\na=setup:actpass\r\na=mid:2\r\na=sctp-port:5000\r\na=max-message-size:262144\r\n"
},
"meta": {
"rules": {
"access": {
"type": "PUSH_CHAT",
"data": {
"chatId": "252395e6b5d0ae0796e05e648240f7950f7a50a80906cdf6accdf7079e311dea"
}
}
}
}
}
}
Expected response (CONSTANTS.STREAM.VIDEO - Video Approve stream)
{
"event": "video.approve",
"origin": "other",
"timestamp": "2024-01-12T10:58:44.000Z",
"peerInfo": {
"address": "0xb44a29524433dBC639C35124459c741bC241d4f4",
"signal": {
"type": "answer",
"sdp": "v=0\r\no=- 4890233625711630293 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE 0 1 2\r\na=extmap-allow-mixed\r\na=msid-semantic: WMS ac50711a-009a-42d5-a527-f065ae2faaef\r\nm=audio 53579 UDP/TLS/RTP/SAVPF 111 63 9 0 8 13 110 126\r\nc=IN IP4 192.168.29.84\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=candidate:4017045755 1 udp 2122194687 192.168.29.84 53579 typ host generation 0 network-id 1 network-cost 10\r\na=candidate:3849344033 1 udp 2122262783 2405:201:e05d:901f:758d:b62b:c688:3bfc 50437 typ host generation 0 network-id 2 network-cost 10\r\na=ice-ufrag:1dK6\r\na=ice-pwd:s4lG7GOmyMrRLhF2tqX548xP\r\na=fingerprint:sha-256 E5:A1:B8:F3:A0:E1:2B:BA:A5:FD:B3:DD:B0:BB:92:7D:81:BA:1D:86:52:E2:F3:36:E5:8B:3D:0B:82:66:54:DF\r\na=setup:active\r\na=mid:0\r\na=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level\r\na=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\na=extmap:3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01\r\na=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid\r\na=sendrecv\r\na=msid:ac50711a-009a-42d5-a527-f065ae2faaef 6949f858-c219-4a2d-bedc-d8a111c16782\r\na=rtcp-mux\r\na=rtpmap:111 opus/48000/2\r\na=rtcp-fb:111 transport-cc\r\na=fmtp:111 minptime=10;useinbandfec=1\r\na=rtpmap:63 red/48000/2\r\na=fmtp:63 111/111\r\na=rtpmap:9 G722/8000\r\na=rtpmap:0 PCMU/8000\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:13 CN/8000\r\na=rtpmap:110 telephone-event/48000\r\na=rtpmap:126 telephone-event/8000\r\na=ssrc:3092021940 cname:PDD1jDS90ch8+37T\r\nm=video 9 UDP/TLS/RTP/SAVPF 96 97 102 103 104 105 106 107 108 109 127 125 39 40 45 46 98 99 100 101 112 113 116 117 118\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=ice-ufrag:1dK6\r\na=ice-pwd:s4lG7GOmyMrRLhF2tqX548xP\r\na=fingerprint:sha-256 E5:A1:B8:F3:A0:E1:2B:BA:A5:FD:B3:DD:B0:BB:92:7D:81:BA:1D:86:52:E2:F3:36:E5:8B:3D:0B:82:66:54:DF\r\na=setup:active\r\na=mid:1\r\na=extmap:14 urn:ietf:params:rtp-hdrext:toffset\r\na=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\na=extmap:13 urn:3gpp:video-orientation\r\na=extmap:3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01\r\na=extmap:5 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay\r\na=extmap:6 http://www.webrtc.org/experiments/rtp-hdrext/video-content-type\r\na=extmap:7 http://www.webrtc.org/experiments/rtp-hdrext/video-timing\r\na=extmap:8 http://www.webrtc.org/experiments/rtp-hdrext/color-space\r\na=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid\r\na=extmap:10 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id\r\na=extmap:11 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id\r\na=sendrecv\r\na=msid:ac50711a-009a-42d5-a527-f065ae2faaef 61434e8d-db1e-47c3-b7bb-c1c99844ed65\r\na=rtcp-mux\r\na=rtcp-rsize\r\na=rtpmap:96 VP8/90000\r\na=rtcp-fb:96 goog-remb\r\na=rtcp-fb:96 transport-cc\r\na=rtcp-fb:96 ccm fir\r\na=rtcp-fb:96 nack\r\na=rtcp-fb:96 nack pli\r\na=rtpmap:97 rtx/90000\r\na=fmtp:97 apt=96\r\na=rtpmap:102 H264/90000\r\na=rtcp-fb:102 goog-remb\r\na=rtcp-fb:102 transport-cc\r\na=rtcp-fb:102 ccm fir\r\na=rtcp-fb:102 nack\r\na=rtcp-fb:102 nack pli\r\na=fmtp:102 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f\r\na=rtpmap:103 rtx/90000\r\na=fmtp:103 apt=102\r\na=rtpmap:104 H264/90000\r\na=rtcp-fb:104 goog-remb\r\na=rtcp-fb:104 transport-cc\r\na=rtcp-fb:104 ccm fir\r\na=rtcp-fb:104 nack\r\na=rtcp-fb:104 nack pli\r\na=fmtp:104 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42001f\r\na=rtpmap:105 rtx/90000\r\na=fmtp:105 apt=104\r\na=rtpmap:106 H264/90000\r\na=rtcp-fb:106 goog-remb\r\na=rtcp-fb:106 transport-cc\r\na=rtcp-fb:106 ccm fir\r\na=rtcp-fb:106 nack\r\na=rtcp-fb:106 nack pli\r\na=fmtp:106 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f\r\na=rtpmap:107 rtx/90000\r\na=fmtp:107 apt=106\r\na=rtpmap:108 H264/90000\r\na=rtcp-fb:108 goog-remb\r\na=rtcp-fb:108 transport-cc\r\na=rtcp-fb:108 ccm fir\r\na=rtcp-fb:108 nack\r\na=rtcp-fb:108 nack pli\r\na=fmtp:108 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42e01f\r\na=rtpmap:109 rtx/90000\r\na=fmtp:109 apt=108\r\na=rtpmap:127 H264/90000\r\na=rtcp-fb:127 goog-remb\r\na=rtcp-fb:127 transport-cc\r\na=rtcp-fb:127 ccm fir\r\na=rtcp-fb:127 nack\r\na=rtcp-fb:127 nack pli\r\na=fmtp:127 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=4d001f\r\na=rtpmap:125 rtx/90000\r\na=fmtp:125 apt=127\r\na=rtpmap:39 H264/90000\r\na=rtcp-fb:39 goog-remb\r\na=rtcp-fb:39 transport-cc\r\na=rtcp-fb:39 ccm fir\r\na=rtcp-fb:39 nack\r\na=rtcp-fb:39 nack pli\r\na=fmtp:39 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=4d001f\r\na=rtpmap:40 rtx/90000\r\na=fmtp:40 apt=39\r\na=rtpmap:45 AV1/90000\r\na=rtcp-fb:45 goog-remb\r\na=rtcp-fb:45 transport-cc\r\na=rtcp-fb:45 ccm fir\r\na=rtcp-fb:45 nack\r\na=rtcp-fb:45 nack pli\r\na=rtpmap:46 rtx/90000\r\na=fmtp:46 apt=45\r\na=rtpmap:98 VP9/90000\r\na=rtcp-fb:98 goog-remb\r\na=rtcp-fb:98 transport-cc\r\na=rtcp-fb:98 ccm fir\r\na=rtcp-fb:98 nack\r\na=rtcp-fb:98 nack pli\r\na=fmtp:98 profile-id=0\r\na=rtpmap:99 rtx/90000\r\na=fmtp:99 apt=98\r\na=rtpmap:100 VP9/90000\r\na=rtcp-fb:100 goog-remb\r\na=rtcp-fb:100 transport-cc\r\na=rtcp-fb:100 ccm fir\r\na=rtcp-fb:100 nack\r\na=rtcp-fb:100 nack pli\r\na=fmtp:100 profile-id=2\r\na=rtpmap:101 rtx/90000\r\na=fmtp:101 apt=100\r\na=rtpmap:112 H264/90000\r\na=rtcp-fb:112 goog-remb\r\na=rtcp-fb:112 transport-cc\r\na=rtcp-fb:112 ccm fir\r\na=rtcp-fb:112 nack\r\na=rtcp-fb:112 nack pli\r\na=fmtp:112 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=64001f\r\na=rtpmap:113 rtx/90000\r\na=fmtp:113 apt=112\r\na=rtpmap:116 red/90000\r\na=rtpmap:117 rtx/90000\r\na=fmtp:117 apt=116\r\na=rtpmap:118 ulpfec/90000\r\na=ssrc-group:FID 1292528629 79104058\r\na=ssrc:1292528629 cname:PDD1jDS90ch8+37T\r\na=ssrc:79104058 cname:PDD1jDS90ch8+37T\r\nm=application 9 UDP/DTLS/SCTP webrtc-datachannel\r\nc=IN IP4 0.0.0.0\r\na=ice-ufrag:1dK6\r\na=ice-pwd:s4lG7GOmyMrRLhF2tqX548xP\r\na=fingerprint:sha-256 E5:A1:B8:F3:A0:E1:2B:BA:A5:FD:B3:DD:B0:BB:92:7D:81:BA:1D:86:52:E2:F3:36:E5:8B:3D:0B:82:66:54:DF\r\na=setup:active\r\na=mid:2\r\na=sctp-port:5000\r\na=max-message-size:262144\r\n"
},
"meta": {
"rules": {
"access": {
"type": "PUSH_CHAT",
"data": {
"chatId": "252395e6b5d0ae0796e05e648240f7950f7a50a80906cdf6accdf7079e311dea"
}
}
}
}
}
}
Expected response (CONSTANTS.STREAM.VIDEO - Video Connect stream)
{
"event": "video.connect",
"origin": "other",
"timestamp": "2024-01-12T10:58:45.000Z",
"peerInfo": {
"address": "0xb73923eCcfbd6975BFd66CD1C76FA6b883E30365",
"signal": {
"type": "answer",
"sdp": "v=0\r\no=- 4890233625711630293 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE 0 1 2\r\na=extmap-allow-mixed\r\na=msid-semantic: WMS ac50711a-009a-42d5-a527-f065ae2faaef\r\nm=audio 53579 UDP/TLS/RTP/SAVPF 111 63 9 0 8 13 110 126\r\nc=IN IP4 192.168.29.84\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=candidate:4017045755 1 udp 2122194687 192.168.29.84 53579 typ host generation 0 network-id 1 network-cost 10\r\na=candidate:3849344033 1 udp 2122262783 2405:201:e05d:901f:758d:b62b:c688:3bfc 50437 typ host generation 0 network-id 2 network-cost 10\r\na=ice-ufrag:1dK6\r\na=ice-pwd:s4lG7GOmyMrRLhF2tqX548xP\r\na=fingerprint:sha-256 E5:A1:B8:F3:A0:E1:2B:BA:A5:FD:B3:DD:B0:BB:92:7D:81:BA:1D:86:52:E2:F3:36:E5:8B:3D:0B:82:66:54:DF\r\na=setup:active\r\na=mid:0\r\na=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level\r\na=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\na=extmap:3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01\r\na=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid\r\na=sendrecv\r\na=msid:ac50711a-009a-42d5-a527-f065ae2faaef 6949f858-c219-4a2d-bedc-d8a111c16782\r\na=rtcp-mux\r\na=rtpmap:111 opus/48000/2\r\na=rtcp-fb:111 transport-cc\r\na=fmtp:111 minptime=10;useinbandfec=1\r\na=rtpmap:63 red/48000/2\r\na=fmtp:63 111/111\r\na=rtpmap:9 G722/8000\r\na=rtpmap:0 PCMU/8000\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:13 CN/8000\r\na=rtpmap:110 telephone-event/48000\r\na=rtpmap:126 telephone-event/8000\r\na=ssrc:3092021940 cname:PDD1jDS90ch8+37T\r\nm=video 9 UDP/TLS/RTP/SAVPF 96 97 102 103 104 105 106 107 108 109 127 125 39 40 45 46 98 99 100 101 112 113 116 117 118\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=ice-ufrag:1dK6\r\na=ice-pwd:s4lG7GOmyMrRLhF2tqX548xP\r\na=fingerprint:sha-256 E5:A1:B8:F3:A0:E1:2B:BA:A5:FD:B3:DD:B0:BB:92:7D:81:BA:1D:86:52:E2:F3:36:E5:8B:3D:0B:82:66:54:DF\r\na=setup:active\r\na=mid:1\r\na=extmap:14 urn:ietf:params:rtp-hdrext:toffset\r\na=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\na=extmap:13 urn:3gpp:video-orientation\r\na=extmap:3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01\r\na=extmap:5 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay\r\na=extmap:6 http://www.webrtc.org/experiments/rtp-hdrext/video-content-type\r\na=extmap:7 http://www.webrtc.org/experiments/rtp-hdrext/video-timing\r\na=extmap:8 http://www.webrtc.org/experiments/rtp-hdrext/color-space\r\na=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid\r\na=extmap:10 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id\r\na=extmap:11 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id\r\na=sendrecv\r\na=msid:ac50711a-009a-42d5-a527-f065ae2faaef 61434e8d-db1e-47c3-b7bb-c1c99844ed65\r\na=rtcp-mux\r\na=rtcp-rsize\r\na=rtpmap:96 VP8/90000\r\na=rtcp-fb:96 goog-remb\r\na=rtcp-fb:96 transport-cc\r\na=rtcp-fb:96 ccm fir\r\na=rtcp-fb:96 nack\r\na=rtcp-fb:96 nack pli\r\na=rtpmap:97 rtx/90000\r\na=fmtp:97 apt=96\r\na=rtpmap:102 H264/90000\r\na=rtcp-fb:102 goog-remb\r\na=rtcp-fb:102 transport-cc\r\na=rtcp-fb:102 ccm fir\r\na=rtcp-fb:102 nack\r\na=rtcp-fb:102 nack pli\r\na=fmtp:102 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f\r\na=rtpmap:103 rtx/90000\r\na=fmtp:103 apt=102\r\na=rtpmap:104 H264/90000\r\na=rtcp-fb:104 goog-remb\r\na=rtcp-fb:104 transport-cc\r\na=rtcp-fb:104 ccm fir\r\na=rtcp-fb:104 nack\r\na=rtcp-fb:104 nack pli\r\na=fmtp:104 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42001f\r\na=rtpmap:105 rtx/90000\r\na=fmtp:105 apt=104\r\na=rtpmap:106 H264/90000\r\na=rtcp-fb:106 goog-remb\r\na=rtcp-fb:106 transport-cc\r\na=rtcp-fb:106 ccm fir\r\na=rtcp-fb:106 nack\r\na=rtcp-fb:106 nack pli\r\na=fmtp:106 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f\r\na=rtpmap:107 rtx/90000\r\na=fmtp:107 apt=106\r\na=rtpmap:108 H264/90000\r\na=rtcp-fb:108 goog-remb\r\na=rtcp-fb:108 transport-cc\r\na=rtcp-fb:108 ccm fir\r\na=rtcp-fb:108 nack\r\na=rtcp-fb:108 nack pli\r\na=fmtp:108 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42e01f\r\na=rtpmap:109 rtx/90000\r\na=fmtp:109 apt=108\r\na=rtpmap:127 H264/90000\r\na=rtcp-fb:127 goog-remb\r\na=rtcp-fb:127 transport-cc\r\na=rtcp-fb:127 ccm fir\r\na=rtcp-fb:127 nack\r\na=rtcp-fb:127 nack pli\r\na=fmtp:127 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=4d001f\r\na=rtpmap:125 rtx/90000\r\na=fmtp:125 apt=127\r\na=rtpmap:39 H264/90000\r\na=rtcp-fb:39 goog-remb\r\na=rtcp-fb:39 transport-cc\r\na=rtcp-fb:39 ccm fir\r\na=rtcp-fb:39 nack\r\na=rtcp-fb:39 nack pli\r\na=fmtp:39 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=4d001f\r\na=rtpmap:40 rtx/90000\r\na=fmtp:40 apt=39\r\na=rtpmap:45 AV1/90000\r\na=rtcp-fb:45 goog-remb\r\na=rtcp-fb:45 transport-cc\r\na=rtcp-fb:45 ccm fir\r\na=rtcp-fb:45 nack\r\na=rtcp-fb:45 nack pli\r\na=rtpmap:46 rtx/90000\r\na=fmtp:46 apt=45\r\na=rtpmap:98 VP9/90000\r\na=rtcp-fb:98 goog-remb\r\na=rtcp-fb:98 transport-cc\r\na=rtcp-fb:98 ccm fir\r\na=rtcp-fb:98 nack\r\na=rtcp-fb:98 nack pli\r\na=fmtp:98 profile-id=0\r\na=rtpmap:99 rtx/90000\r\na=fmtp:99 apt=98\r\na=rtpmap:100 VP9/90000\r\na=rtcp-fb:100 goog-remb\r\na=rtcp-fb:100 transport-cc\r\na=rtcp-fb:100 ccm fir\r\na=rtcp-fb:100 nack\r\na=rtcp-fb:100 nack pli\r\na=fmtp:100 profile-id=2\r\na=rtpmap:101 rtx/90000\r\na=fmtp:101 apt=100\r\na=rtpmap:112 H264/90000\r\na=rtcp-fb:112 goog-remb\r\na=rtcp-fb:112 transport-cc\r\na=rtcp-fb:112 ccm fir\r\na=rtcp-fb:112 nack\r\na=rtcp-fb:112 nack pli\r\na=fmtp:112 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=64001f\r\na=rtpmap:113 rtx/90000\r\na=fmtp:113 apt=112\r\na=rtpmap:116 red/90000\r\na=rtpmap:117 rtx/90000\r\na=fmtp:117 apt=116\r\na=rtpmap:118 ulpfec/90000\r\na=ssrc-group:FID 1292528629 79104058\r\na=ssrc:1292528629 cname:PDD1jDS90ch8+37T\r\na=ssrc:79104058 cname:PDD1jDS90ch8+37T\r\nm=application 9 UDP/DTLS/SCTP webrtc-datachannel\r\nc=IN IP4 0.0.0.0\r\na=ice-ufrag:1dK6\r\na=ice-pwd:s4lG7GOmyMrRLhF2tqX548xP\r\na=fingerprint:sha-256 E5:A1:B8:F3:A0:E1:2B:BA:A5:FD:B3:DD:B0:BB:92:7D:81:BA:1D:86:52:E2:F3:36:E5:8B:3D:0B:82:66:54:DF\r\na=setup:active\r\na=mid:2\r\na=sctp-port:5000\r\na=max-message-size:262144\r\n"
},
"meta": {
"rules": {
"access": {
"type": "PUSH_CHAT",
"data": {
"chatId": "252395e6b5d0ae0796e05e648240f7950f7a50a80906cdf6accdf7079e311dea"
}
}
}
}
}
}
Expected response (CONSTANTS.STREAM.VIDEO - Video Disconnect stream)
{
"event": "video.disconnect",
"origin": "other",
"timestamp": "2024-01-12T11:00:12.000Z",
"peerInfo": {
"address": "0xb73923eCcfbd6975BFd66CD1C76FA6b883E30365",
"signal": null,
"meta": {
"rules": {
"access": {
"type": "PUSH_CHAT",
"data": {
"chatId": "252395e6b5d0ae0796e05e648240f7950f7a50a80906cdf6accdf7079e311dea"
}
}
}
}
}
}
Expected response (CONSTANTS.STREAM.VIDEO - Video Deny stream)
{
"event": "video.deny",
"origin": "other",
"timestamp": "2024-01-12T11:00:12.000Z",
"peerInfo": {
"address": "0xb73923eCcfbd6975BFd66CD1C76FA6b883E30365",
"signal": null,
"meta": {
"rules": {
"access": {
"type": "PUSH_CHAT",
"data": {
"chatId": "252395e6b5d0ae0796e05e648240f7950f7a50a80906cdf6accdf7079e311dea"
}
}
}
}
}
}

Re-initialize video stream

To reinstate a video stream. Useful for updating an already initialized stream objects to add / remove listen events or filter options.

// await stream.reinit(listen, {newOptions?})
const newStream = await stream.reinit([
CONSTANTS.STREAM.VIDEO, // Listen for video events
CONSTANTS.STREAM.CONNECT, // Listen for connection events
CONSTANTS.STREAM.DISCONNECT, // Listen for disconnection events
]);

Reinit Stream Video parameters

ParamTypeSub-TypeDefaultRemarks
listenconstant--Choose from various streams:CONSTANTS.STREAM.VIDEO, CONSTANTS.STREAM.SPACE, CONSTANTS.STREAM.SPACE_OPS, CONSTANTS.STREAM.CHAT, CONSTANTS.STREAM.CHAT_OPS, CONSTANTS.STREAM.NOTIF, CONSTANTS.STREAM.CONNECT, CONSTANTS.STREAM.DISCONNECT
newOptionsPushStreamInitializeProps--Optional configuration properties for initializing the stream.
-newOptions.filterobject-Configure to listen to specific chats or notifications.
-newOptions.filter.channelsarray of strings['*']Pass list of channels over here to only listen to notifications coming from them.
-newOptions.filter.chatsarray of strings['*']Pass list of chatids over here to only listen to chats coming from them.
-newOptions.connectionobject-Option to configure the connection settings of the stream
-newOptions.connection.retriesnumber3Number of automatic retries incase of error
-newOptions.rawbooleanfalseIf enabled, respond with metadata useful in verifying the integrity of incoming chats or notifications among other things.

Note: Parameters in this style are mandatory.

Stream info API

To get the info of the current stream.

// stream.info()
const streamInfo = await stream.info();
Expected response
{
options: { raw: false, connection: { auto: true, retries: 3 }, env: 'prod' },
listen: [ 'STREAM.VIDEO', 'STREAM.CONNECT', 'STREAM.DISCONNECT' ]
}

Stream status API

To get the connection status of the current stream.

// stream.connected()
const streamStatus = await stream.connected();
Expected response

typescript true // if connected, else false