Skip to content

v4_EN_WebRTC

winlin edited this page Aug 7, 2021 · 15 revisions

HOME > EN > RTC

WebRTC

https://github.com/ossrs/srs/issues/307

Config: Candidate

The play will definitely fail if the CANDIDATE of config is not correct, because it's the RTP server address(IP and port) in SDP, the IP is CANDIDATE:

type: answer, sdp: v=0
a=candidate:0 1 udp 2130706431 192.168.3.6 8000 typ host generation 0

So the CANDIDATE is 192.168.3.6 here, which is the IP of server. We could config it by:

  • Use plaintext IP directly, such as candidate 192.168.3.6;
  • Use command ifconfig to retrieve IP of network interface, pass it by ENV, such as candidate $CANDIDATE;
  • Try to read the intranet IP from network interface, for example, candidate *;
  • Read from query string of stream URL, such as webrtc://192.168.3.6/live/livestream?eip=192.168.3.6

Use command ifconfig to retrieve the IP:

# For macOS
ifconfig en0 inet| grep 'inet '|awk '{print $2}'

# For CentOS
ifconfig eth0|grep 'inet '|awk '{print $2}'

Pass it to SRS by ENV:

# For macOS
env CANDIDATE=$(ifconfig en0 inet| grep 'inet '|awk '{print $2}') \
./objs/srs -c conf/rtc.conf

For example, to run SRS in docker, and setup the CANDIDATE:

docker run --rm --env CANDIDATE=$(ifconfig en0 inet| grep 'inet '|awk '{print $2}') \
  -p 1935:1935 -p 8080:8080 -p 1985:1985 -p 8000:8000/udp \
  registry.cn-hangzhou.aliyuncs.com/ossrs/srs:4 \
  objs/srs -c conf/rtc.conf

Note:About the usage of srs-docker, please read srs-docker.

Winlin 2020.02

Welcome to SRS wiki!

SRS 5.0 wiki

Please select your language:

SRS 4.0 wiki

Please select your language:

SRS 3.0 wiki

Please select your language:

SRS 2.0 wiki

Please select your language:

SRS 1.0 wiki

Please select your language:

Clone this wiki locally