|
| 1 | +# WebRTC SDK Connection Process |
| 2 | + |
| 3 | +This document outlines the sequential steps that occur during the WebRTC connection process with Kinesis Video Streams, based on detailed logs from a successful connection. |
| 4 | + |
| 5 | +## 1. Initial Setup |
| 6 | +- Application initializes with channel name `demo-channel` |
| 7 | +- Loads certificates from specified paths (`certificate.pem`, `private.key`, `cacert.pem`) |
| 8 | + |
| 9 | +## 2. Credential Setup |
| 10 | +- Creates IoT credential provider with endpoint: `c3mh3f5xs9l81c.credentials.iot.us-east-1.amazonaws.com` |
| 11 | +- Uses role alias `webrtc_iot_role_alias` and thing name `webrtc_iot_thing` |
| 12 | +- Fetches IoT credentials via HTTPS request to the credentials endpoint |
| 13 | + - Getting IoT credential with URL: `https://c3mh3f5xs9l81c.credentials.iot.us-east-1.amazonaws.com/role-aliases/webrtc_iot_role_alias/credentials` |
| 14 | +- Receives credentials with expiration time (valid for 1 hour) |
| 15 | + |
| 16 | +## 3. Media Source Initialization |
| 17 | +- Discovers sample H.264 video frames from the samples directory |
| 18 | +- Initializes WebRTC and SRTP security components |
| 19 | + |
| 20 | +## 4. Signaling Client Creation |
| 21 | +- Initializes signaling client in "New" state |
| 22 | +- Transitions to "Get Security Credentials" state using the IoT credentials fetched earlier |
| 23 | +- Control plane URL is generated: `https://kinesisvideo.us-east-1.amazonaws.com` |
| 24 | + |
| 25 | +## 5. Channel Description |
| 26 | +- Transitions to "Describe Channel" state |
| 27 | +- Sends API request to: `https://kinesisvideo.us-east-1.amazonaws.com/describeSignalingChannel` |
| 28 | +- Request body: |
| 29 | + ```json |
| 30 | + { |
| 31 | + "ChannelName": "demo-channel" |
| 32 | + } |
| 33 | + ``` |
| 34 | +- API Response: |
| 35 | + ```json |
| 36 | + { |
| 37 | + "ChannelInfo": { |
| 38 | + "ChannelARN": "arn:aws:kinesisvideo:us-east-1:995678934610:channel/demo-channel/1712136149494", |
| 39 | + "ChannelName": "demo-channel", |
| 40 | + "ChannelStatus": "ACTIVE", |
| 41 | + "ChannelType": "SINGLE_MASTER", |
| 42 | + "CreationTime": 1.712136149494E9, |
| 43 | + "FullMeshConfiguration": null, |
| 44 | + "SingleMasterConfiguration": { |
| 45 | + "MessageTtlSeconds": 60 |
| 46 | + }, |
| 47 | + "Version": "3Ikjs9sOSk6Q4Alisl0d" |
| 48 | + } |
| 49 | + } |
| 50 | + ``` |
| 51 | + |
| 52 | +## 6. Channel Endpoint Retrieval |
| 53 | +- Transitions to "Get Channel Endpoint" state |
| 54 | +- Sends API request to: `https://kinesisvideo.us-east-1.amazonaws.com/getSignalingChannelEndpoint` |
| 55 | +- Request body: |
| 56 | + ```json |
| 57 | + { |
| 58 | + "ChannelARN": "arn:aws:kinesisvideo:us-east-1:995678934610:channel/demo-channel/1712136149494", |
| 59 | + "SingleMasterChannelEndpointConfiguration": { |
| 60 | + "Protocols": ["WSS", "HTTPS"], |
| 61 | + "Role": "MASTER" |
| 62 | + } |
| 63 | + } |
| 64 | + ``` |
| 65 | +- API Response: |
| 66 | + ```json |
| 67 | + { |
| 68 | + "ResourceEndpointList": [ |
| 69 | + { |
| 70 | + "Protocol": "HTTPS", |
| 71 | + "ResourceEndpoint": "https://r-c50d6457.kinesisvideo.us-east-1.amazonaws.com" |
| 72 | + }, |
| 73 | + { |
| 74 | + "Protocol": "WSS", |
| 75 | + "ResourceEndpoint": "wss://m-b94e17e0.kinesisvideo.us-east-1.amazonaws.com" |
| 76 | + } |
| 77 | + ] |
| 78 | + } |
| 79 | + ``` |
| 80 | + |
| 81 | +## 7. ICE Server Configuration |
| 82 | +- Transitions to "Get ICE Server Configuration" state |
| 83 | +- Sends API request to: `https://r-c50d6457.kinesisvideo.us-east-1.amazonaws.com/v1/get-ice-server-config` |
| 84 | +- Request body: |
| 85 | + ```json |
| 86 | + { |
| 87 | + "ChannelARN": "arn:aws:kinesisvideo:us-east-1:995678934610:channel/demo-channel/1712136149494", |
| 88 | + "ClientId": "ProducerMaster", |
| 89 | + "Service": "TURN" |
| 90 | + } |
| 91 | + ``` |
| 92 | +- API Response: |
| 93 | + ```json |
| 94 | + { |
| 95 | + "IceServerList": [ |
| 96 | + { |
| 97 | + "Password": "nhgUYYY0TKW5knkHAU92JI9whmOO058qbmxRvyIY2Rg=", |
| 98 | + "Ttl": 300, |
| 99 | + "Uris": [ |
| 100 | + "turn:13-217-27-141.t-99577840.kinesisvideo.us-east-1.amazonaws.com:443?transport=udp", |
| 101 | + "turns:13-217-27-141.t-99577840.kinesisvideo.us-east-1.amazonaws.com:443?transport=udp", |
| 102 | + "turns:13-217-27-141.t-99577840.kinesisvideo.us-east-1.amazonaws.com:443?transport=tcp" |
| 103 | + ], |
| 104 | + "Username": "1743506463:djE6YXJuOmF3czpraW5lc2lzdmlkZW86dXMtZWFzdC0xOjk5NTY3ODkzNDYxMDpjaGFubmVsL2RlbW8tY2hhbm5lbC8xNzEyMTM2MTQ5NDk0" |
| 105 | + }, |
| 106 | + { |
| 107 | + "Password": "O1ABsajTCFta+wj/9tTp8yF5aOFoiG6k/sWL3F+QT6w=", |
| 108 | + "Ttl": 300, |
| 109 | + "Uris": [ |
| 110 | + "turn:54-159-217-207.t-99577840.kinesisvideo.us-east-1.amazonaws.com:443?transport=udp", |
| 111 | + "turns:54-159-217-207.t-99577840.kinesisvideo.us-east-1.amazonaws.com:443?transport=udp", |
| 112 | + "turns:54-159-217-207.t-99577840.kinesisvideo.us-east-1.amazonaws.com:443?transport=tcp" |
| 113 | + ], |
| 114 | + "Username": "1743506463:djE6YXJuOmF3czpraW5lc2lzdmlkZW86dXMtZWFzdC0xOjk5NTY3ODkzNDYxMDpjaGFubmVsL2RlbW8tY2hhbm5lbC8xNzEyMTM2MTQ5NDk0" |
| 115 | + } |
| 116 | + ] |
| 117 | + } |
| 118 | + ``` |
| 119 | + |
| 120 | +## 8. Signaling Connection |
| 121 | +- Transitions to "Ready" state once all configurations are obtained |
| 122 | +- Begins connection to the WSS endpoint: `wss://m-b94e17e0.kinesisvideo.us-east-1.amazonaws.com` |
| 123 | +- Fully qualified URL example: `wss://m-07e4d66a.kinesisvideo.us-east-1.amazonaws.com?X-Amz-ChannelARN=arn:aws:kinesisvideo:us-east-1:995678934610:channel/demo-channel/1689337250341` |
| 124 | +- Successfully establishes WebSocket connection |
| 125 | +- Transitions to "Connected" state when the connection is established |
| 126 | + |
| 127 | +## 9. WebRTC Peer Connection (After Connected State) |
| 128 | +- Once connected, the signaling client can exchange SDP offers/answers and ICE candidates |
| 129 | +- WebRTC peer connection is established using the acquired ICE server configurations |
| 130 | +- Media streaming begins after successful connection |
0 commit comments