WebRTC: Features, History, and Main APIs

webRTC
 
1
what feature does webrtc want to achieve?
-
Acquiring audio and video
-
Communicating audio and video
-
Communicating arbitrary data
2
little history(at the past)
-
corporate and complex
-
need expensive licenses to develop in-house
-
integreate RTC with other services is difficult and time-consuming
-
particularly on the web
-
google buy GIPS(Global IP Solution) and open sourced the
technology
-
engage the webRTC standard with IETF
-
W3C to ensure the industry consensus
3
three main API
-
MediaStream (aka getUserMedia)
-
RTCPeerConnection
-
w
e
 
w
i
l
l
 
c
a
l
l
 
i
t
 
p
c
 
i
n
s
t
e
a
d
 
o
f
 
R
T
C
P
e
e
r
C
o
n
n
e
c
t
i
o
n
-
RTCDataChannel
4
MediaStream
-
get the stream from browser
-
Obtain a MediaStream with `navigator.getUserMedia()`
-
may contain multi tracks
5
RTCPeerConnection
-
Signal processing
-
Codec handling
-
P2P communcation
-
Security
-
Bandwitdth management
-
6
RTCPeerConnection
-
browser 提供簡單 api
簡化建立 p2p
connection 過程
-
connection and
ice 協商
-
media encoding
-
需要設定的項目
-
協商傳輸的通道
-
影音 stream 來源
-
除了提供協商通道和傳
輸資料,剩下的操作被
包裝在 browser
7
How to establish RTCPeerconnection
-
initialize
-
signaling
-
傳輸信令的通道(XMPP, WebSocket…)
-
constraints
-
media stream 的限制(寬, 高...)
-
pc(peer connection)
-
RTCPeerConnection’s instance
https://w3c.github.io/webrtc-pc/#example-9
8
How to establish RTCPeerconnection
-
4 main callback
-
onnegotiationneeded
-
設定 local 的 sdp
offer
-
等價於
`pc.setLocalDescriptio
n(await
pc.createOffer())`
-
onicecandidate
-
送出 local 可行網路的
sdp
-
onTrack: 設定傳回的 track
用途
https://w3c.github.io/webrtc-pc/#example-9
9
How to establish RTCPeerconnection
-
4 main callback
-
onMessage
-
接收 sdp offer 儲存到
pc 並產生 sdp answer
回傳給傳遞 offer 的
user
-
pc.localDescription
是傳遞 offer 的
user 的 sdp answer
-
把 candidate 加入到 pc
讓瀏覽器底層進行協商
https://w3c.github.io/webrtc-pc/#example-9
10
r
e
m
o
t
e
 
d
e
s
c
r
i
p
t
i
o
n
r
e
m
o
t
e
 
c
a
n
i
d
i
a
t
e
webRTC’s behavior
Alice(Caller)
Signaling Server
Bob(callee)
1.
 crate pc
2.
 add local
stream’s track
to pc
send offer and set
local offer(pc)
trigger
negotiation
event
Forward video-
offer to Bob
1.
 create pc
2.
 set
pc.remoteDescri
ption by “video-
offer”
3.
 add local
stream to pc
4.
create sdp-
answer
5.
 set local-sdp
6.
send sdp-
answer to Alice
set
pc.RemoteDescript
ion
Forward video-
offer to Bob
ice layer start sending
candidates to Alice
trigger message event
trigger Message event
trigger
icecandidate event
trigger
icecandidate event
11
web app
browser
web app
browser
ICE’s behavior
Alice(Caller)
Signaling Server
Bob(callee)
send to ice
candidate to peer
trigger
message event
Forward candidate
to Bob
1.
RTCIceCandidate
(message)
2.
 add canadate to
pc
Forward video-
offer to Bob
ice layer start
sending candidates
to Alice
trigger message event
trigger icecandidate
event
trigger message
event
1.
RTCIceCandidate
(message)
2.
add the
RTCIceCandidate
to pc
12
web app
browser
web app
browser
demo
13
demo 架構
14
Sign
import root
CA
access web server
before start demo
-
get into the server(user is “your_name”, passwd is “test”)
-
jerry.lab.test.ncnu.org
-
branko.lab.test.ncnu.org
-
chofinn.lab.test.ncnu.org
-
angela.lab.test.ncnu.org
-
phoebe.lab.test.ncnu.org
-
henry.lab.test.ncnu.org
-
edger.lab.test.ncnu.org
-
solomon.lab.test.ncnu.org
-
clone the repo
-
`git clone --recursive 
https://github.com/efficacy38/webRTC_pearl.git
`
-
replace some setting
-
`perl -i -pe "s/lab.test.ncnu.org/${USER}.lab.test.ncnu.org/g" ./webrtc/index.html ./docker-
compose.yml ./ssl.ca/new-server-cert.sh`
-
`cd ./webrtc`
15
web 架構
-
使用 ssl
-
ssl/privkey.key
-
ssl/server.crt
-
向另一方傳送資料 
-
sdp candidate
-
sdp answer/offer
16
-
build our’s server
inage
-
`docker build -t
webrtc-demo . `
self sign certificate
-
install the certificate helper
-
`cd ../ssl.ca && ./install.sh`
-
generate ssl workspace
-
`mkdir ../ssl && cd ../ssl`
-
generate ssl root certificate
-
`new-root-certificate`
-
generate ssl server certificate
-
`new-server-cert {YOUR_NAME}.lab.test.ncnu.org`
-
use root certificate to sign the server’s certificate
-
`sign-server-cert {YOUR_NAME}.lab.test.ncnu.org`
17
import self sign certficate(ubuntu, chrome)
-
retrieve the root CA certificate
-
`scp {YOUR_NAME}@{YOUR_NAME}.lab.test.ncnu.org:~/webRTC_pearl/ssl/ca.crt .`
-
import the root CA
-
chrome://settings/security
18
check whether CA is imported
-
restart the chrome
-
`chrome://restart`
-
check whether CA(org-National Chi Nan University) is imported
-
goto `chrome://settings/certificates`
-
find “org-National Chi Nan University”
19
all done, let’s go
-
there should have following file
-
ssl/ca.crt
-
ssl/jerry.lab.test.ncnu.org.crt
-
ssl/jerry.lab.test.ncnu.org.key
-
and one server image(`docker image ls`)
-
webrtc-demo
-
let’s go
-
`docker-compose -f docker-compose.yml up`
20
reference
https://medium.com/the-developer-journal/the-amazing-things-about-webrtc-and-
why-you-should-adopt-it-4504b85fc1b8
https://www.html5rocks.com/en/tutorials/webrtc/basics/
https://bloggeek.me/what-is-webrtc/
21
Slide Note
Embed
Share

WebRTC, a technology enabling real-time communication over the web, aims to facilitate acquiring audio and video streams, communicating data, and integrating RTC with other services. Originating in corporate environments with expensive licenses, WebRTC was championed by Google and standardized by IETF and W3C. The technology revolves around three main APIs - MediaStream, RTCPeerConnection, and RTCDataChannel - each serving crucial functions in establishing peer-to-peer connections and managing media streams.

  • WebRTC
  • Real-time communication
  • MediaStream
  • RTCPeerConnection
  • RTCDataChannel

Uploaded on Oct 05, 2024 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. webRTC 1

  2. what feature does webrtc want to achieve? - - - Acquiring audio and video Communicating audio and video Communicating arbitrary data 2

  3. little history(at the past) - corporate and complex - need expensive licenses to develop in-house integreate RTC with other services is difficult and time-consuming - particularly on the web google buy GIPS(Global IP Solution) and open sourced the technology - engage the webRTC standard with IETF - W3C to ensure the industry consensus - - 3

  4. three main API - - MediaStream (aka getUserMedia) RTCPeerConnection - we will call it pc instead of RTCPeerConnection RTCDataChannel - 4

  5. MediaStream - - - get the stream from browser Obtain a MediaStream with `navigator.getUserMedia()` may contain multi tracks 5

  6. RTCPeerConnection - - - - - - Signal processing Codec handling P2P communcation Security Bandwitdth management 6

  7. RTCPeerConnection - browser api p2p connection - connection and ice - media encoding - - stream browser - - 7

  8. How to establish RTCPeerconnection - initialize - signaling - (XMPP, WebSocket ) constraints - media stream ( , ...) pc(peer connection) - RTCPeerConnection s instance - - 8 https://w3c.github.io/webrtc-pc/#example-9

  9. How to establish RTCPeerconnection - 4 main callback - onnegotiationneeded - local sdp offer - `pc.setLocalDescription(a wait pc.createOffer())` - onicecandidate - local sdp - onTrack: track 9 https://w3c.github.io/webrtc-pc/#example-9

  10. How to establish RTCPeerconnection - 4 main callback - onMessage - remote description sdp offer pc sdp answer offer user - pc.localDescription offer user sdp answer candidate pc remote canidiate - 10 https://w3c.github.io/webrtc-pc/#example-9

  11. webRTCs behavior 11 Alice(Caller) Signaling Server Bob(callee) web app browser browser web app 1. crate pc 2. add local stream s track to pc ready to negotiate, so ask caller to start do so 1. create pc 2. set pc.remoteDescri ption by video- offer 3. add local stream to pc 4.create sdp- answer 5. set local-sdp 6.send sdp- answer to Alice trigger negotiation event send offer and set local offer(pc) Forward video- offer to Bob trigger message event data: video-offer data: video-offer ice layer start sending candidates to Bob trigger icecandidate event set pc.RemoteDescript ion Forward video- offer to Bob data: video-answer data: video-answer trigger Message event ice layer start sending candidates to Alice trigger icecandidate event

  12. ICEs behavior 12 Alice(Caller) Signaling Server Bob(callee) web app browser browser web app Generate an ICE candidate(represented by an SDP) 1. RTCIceCandidate (message) 2. add canadate to pc trigger message event send to ice candidate to peer Forward candidate to Bob trigger message event data: candidate data: candidate 1. Generate an ICE candidate(represented by an SDP) RTCIceCandidate (message) 2.add the RTCIceCandidate to pc Forward video- offer to Bob data: candidate data: candidate trigger message event ice layer start sending candidates to Alice trigger icecandidate event

  13. demo 13

  14. demo self sign certificate root CA server s certificate root CA s key server s key Sign import root CA server s certificate root CA s certificate user root CA s certificate docker-compose webRTC demo server browser access web server 14

  15. before start demo - get into the server(user is your_name , passwd is test ) - jerry.lab.test.ncnu.org - branko.lab.test.ncnu.org - chofinn.lab.test.ncnu.org - angela.lab.test.ncnu.org - phoebe.lab.test.ncnu.org - henry.lab.test.ncnu.org - edger.lab.test.ncnu.org - solomon.lab.test.ncnu.org clone the repo - `git clone --recursive https://github.com/efficacy38/webRTC_pearl.git` replace some setting - `perl -i -pe "s/lab.test.ncnu.org/${USER}.lab.test.ncnu.org/g" ./webrtc/index.html ./docker- compose.yml ./ssl.ca/new-server-cert.sh` `cd ./webrtc` - - - 15

  16. web - ssl - - - sdp candidate - sdp answer/offer ssl/privkey.key ssl/server.crt - - build our s server inage - `docker build -t webrtc-demo . ` 16

  17. self sign certificate - install the certificate helper - `cd ../ssl.ca && ./install.sh` generate ssl workspace - `mkdir ../ssl && cd ../ssl` generate ssl root certificate - `new-root-certificate` generate ssl server certificate - `new-server-cert {YOUR_NAME}.lab.test.ncnu.org` use root certificate to sign the server s certificate - `sign-server-cert {YOUR_NAME}.lab.test.ncnu.org` - - - - 17

  18. import self sign certficate(ubuntu, chrome) - retrieve the root CA certificate - `scp {YOUR_NAME}@{YOUR_NAME}.lab.test.ncnu.org:~/webRTC_pearl/ssl/ca.crt .` import the root CA - chrome://settings/security - 18

  19. check whether CA is imported - restart the chrome - `chrome://restart` check whether CA(org-National Chi Nan University) is imported - goto `chrome://settings/certificates` - find org-National Chi Nan University - 19

  20. all done, lets go - there should have following file - ssl/ca.crt - ssl/jerry.lab.test.ncnu.org.crt - ssl/jerry.lab.test.ncnu.org.key and one server image(`docker image ls`) - webrtc-demo let s go - `docker-compose -f docker-compose.yml up` - - 20

  21. reference https://medium.com/the-developer-journal/the-amazing-things-about-webrtc-and- why-you-should-adopt-it-4504b85fc1b8 https://www.html5rocks.com/en/tutorials/webrtc/basics/ https://bloggeek.me/what-is-webrtc/ 21

More Related Content

giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#