一 信令服务:启动py服务器
ssl必须额外指定
# Usage: ./server.py [[host:]port] [SSL certificate file]
文档给出了服务的启动命令: python3 -m http.server --bind 127.0.0.1 8080
- 直接运行:
python的信令服务
#!/usr/bin/env python
#
# Python signaling server example for libdatachannel
# Copyright (c) 2020 Paul-Louis Ageneau
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
import sys
import ssl
import json
import asyncio
import logging
import websockets
logger = logging.getLogger('websockets')
logger.setLevel(logging.INFO)
logger.addHandler(logging.StreamHandler(sys.stdout))
clients = {}
async def handle_websocket(websocket, path):
client_id = None
try:
splitted = path.split('/')
splitted.pop(0)
client_id = splitted.pop(0)
print('Client {} connected'.format(client_id))
clients[client_id] = websocket
while True:
data = await websocket.recv()
print('Client {} << {}'.format(client_id, data))
message = json.loads(data)
destination_id = message['id']
destination_websocket = clients.get(destination_id)
if destination_websocket:
message['id'] = client_id
data = json.dumps(message)
print('Client {} >> {}'.format(destination_id, data))
await destination_websocket.send(data)
else:
print('Client {} not found'.format(destination_id))
except Exception as e:
print(e)
finally:
if client_id:
del clients[client_id]
print('Client {} disconnected'.format(client_id))
async def main():
# Usage: ./server.py [[host:]port] [SSL certificate file]
endpoint_or_port = sys.argv[1] if len(sys.argv) > 1 else "8000"
ssl_cert = sys.argv[2] if len(sys.argv) > 2 else None
endpoint = endpoint_or_port if ':' in endpoint_or_port else "127.0.0.1:" + endpoint_or_port
if ssl_cert:
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
ssl_context.load_cert_chain(ssl_cert)
else:
ssl_context = None
print('Listening on {}'.format(endpoint))
host, port = endpoint.rsplit(':', 1)
server = await websockets.serve(handle_websocket, host, int(port), ssl=ssl_context)
await server.wait_closed()
if __name__ == '__main__':
asyncio.run(main())
pycharm运行
-不知道一直在下载啥:
二.发送测:启动streamer进程
更改配置路径
streamer启动
开俩进程,都链接ok了。
三. python启动8080http服务器
http://127.0.0.1:8080/
js客户端?
- C:\ProgramData\anaconda3
-m http.server --bind 127.0.0.1 8080
PS D:\XTRANS\thunderbolt\ayame\ZHB_LIB_DATACHANNEL\project\libdc\dcConsoleApp> C:\ProgramData\anaconda3\python.exe -m http.server --bind 127.0.0.1 8080
Serving HTTP on 127.0.0.1 port 8080 (http://127.0.0.1:8080/) ...
启动js客户端
运行
C:\ProgramData\anaconda3\python.exe D:\XTRANS\pythonProject\main.py
Hi, PyCharm
Listening on 127.0.0.1:8000
server listening on 127.0.0.1:8000
connection open
Client server connected
connection open
Client server connected
connection open
Client rm8U77FRtq connected
Client rm8U77FRtq << {"id":"server","type":"request"}
Client server >> {"id": "rm8U77FRtq", "type": "request"}
Client server << {"id":"rm8U77FRtq","sdp":"v=0\r\no=rtc 4114583284 0 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE video-stream
audio-stream 0\r\na=group:LS video-stream audio-stream\r\na=msid-semantic:WMS *\r\na=setup:actpass\r\na=ice-ufrag:D5ZJ\r\na=ice-pwd:pXxLOzaQ05ilA/PRQcZ6Wm\r\na=ice-options:trickle\r\na=fingerprint:sha-256 71:64:22:09:B5:1D:D0:74:9F:F8:14:92:EB:B6:C1:51:5A:E2:DE:39:15:C8:14:70:94:67:D3:4C:52:D7:A4:DB\r\nm=video 20689 UDP/TLS/RTP/SAVPF 102\r\nc=IN IP4 192.168.50.65\r\na=mid:video-stream\r\na=sendonly\r\na=ssrc:1 cname:video-stream\r\na=ssrc:1 msid:stream1 video-stream\r\na=rtcp-mux\r\na=rtpmap:102 H264/90000\r\na=rtcp-fb:102 nack\r\na=rtcp-fb:102 nack pli\r\na=rtcp-fb:102 goog-remb\r\na=fmtp:102 profile-level-id=42e01f;packetization-mode=1;level-asymmetry-allowed=1\r\na=candidate:1 1 UDP 2015363327 192.168.50.65 20689 typ host\r\na=candidate:2 1 UDP 2015363583 fe80::3432:91e9:b456:fecf 24609 typ host\r\na=candidate:3 1 UDP 1679819007 121.33.115.242 20689 typ srflx raddr 192.168.50.65 rport 20689\r\na=end-of-candidates\r\nm=audio 20689 UDP/TLS/RTP/SAVPF 111\r\nc=IN IP4 192.168.50.65\r\na=mid:audio-stream\r\na=sendonly\r\na=ssrc:2 cname:audio-stream\r\na=ssrc:2 msid:stream1 audio-stream\r\na=rtcp-mux\r\na=rtpmap:111 OPUS/48000/2\r\na=fmtp:111 minptime=10;maxaveragebitrate=96000;stereo=1;sprop-stereo=1;useinbandfec=1\r\nm=application 20689 UDP/DTLS/SCTP webrtc-datachannel\r\nc=IN IP4 192.168.50.65\r\na=mid:0\r\na=sendrecv\r\na=sctp-port:5000\r\na=max-message-size:262144\r\n","type":"offer"}
Client rm8U77FRtq >> {"id": "server", "sdp": "v=0\r\no=rtc 4114583284 0 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE video-stream audio-stream 0\r\na=group:LS video-stream audio-stream\r\na=msid-semantic:WMS *\r\na=setup:actpass\r\na=ice-ufrag:D5ZJ\r\na=ice-pwd:pXxLOzaQ05ilA/PRQcZ6Wm\r\na=ice-options:trickle\r\na=fingerprint:sha-256 71:64:22:09:B5:1D:D0:74:9F:F8:14:92:EB:B6:C1:51:5A:E2:DE:39:15:C8:14:70:94:67:D3:4C:52:D7:A4:DB\r\nm=video 20689 UDP/TLS/RTP/SAVPF 102\r\nc=IN IP4 192.168.50.65\r\na=mid:video-stream\r\na=sendonly\r\na=ssrc:1 cname:video-stream\r\na=ssrc:1 msid:stream1 video-stream\r\na=rtcp-mux\r\na=rtpmap:102 H264/90000\r\na=rtcp-fb:102 nack\r\na=rtcp-fb:102 nack pli\r\na=rtcp-fb:102 goog-remb\r\na=fmtp:102 profile-level-id=42e01f;packetization-mode=1;level-asymmetry-allowed=1\r\na=candidate:1 1 UDP 2015363327 192.168.50.65 20689 typ host\r\na=candidate:2 1 UDP 2015363583 fe80::3432:91e9:b456:fecf 24609 typ host\r\na=candidate:3 1 UDP 1679819007 121.33.115.242 20689 typ srflx raddr 192.168.50.65 rport 20689\r\na=end-of-candidates\r\nm=audio 20689 UDP/TLS/RTP/SAVPF 111\r\nc=IN IP4 192.168.50.65\r\na=mid:audio-stream\r\na=sendonly\r\na=ssrc:2 cname:audio-stream\r\na=ssrc:2 msid:stream1 audio-stream\r\na=rtcp-mux\r\na=rtpmap:111 OPUS/48000/2\r\na=fmtp:111 minptime=10;maxaveragebitrate=96000;stereo=1;sprop-stereo=1;useinbandfec=1\r\nm=application 20689 UDP/DTLS/SCTP webrtc-datachannel\r\nc=IN IP4 192.168.50.65\r\na=mid:0\r\na=sendrecv\r\na=sctp-port:5000\r\na=max-message-size:262144\r\n", "type": "offer"}
Client rm8U77FRtq << {"id":"server","type":"answer","sdp":"v=0\r\no=- 1779483509754603469 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE video-stream audio-stream 0\r\na=msid-semantic: WMS\r\nm=video 9 UDP/TLS/RTP/SAVPF 102\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=candidate:3099956911 1 udp 2113937151 9d61f606-07c9-418b-bce4-ca5b9f831974.local 60327 typ host generation 0 network-cost 999\r\na=ice-ufrag:gcQq\r\na=ice-pwd:OrO4kMLd7aNCvYnsX9gk4eoN\r\na=ice-options:trickle\r\na=fingerprint:sha-256 3D:C2:6A:AE:10:D2:35:2B:E0:3E:20:59:C6:E4:88:EB:21:75:FC:6B:93:39:EF:B0:AA:DC:15:07:55:66:A9:BC\r\na=setup:active\r\na=mid:video-stream\r\na=recvonly\r\na=rtcp-mux\r\na=rtpmap:102 H264/90000\r\na=rtcp-fb:102 goog-remb\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=42e01f\r\nm=audio 9 UDP/TLS/RTP/SAVPF 111\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=ice-ufrag:gcQq\r\na=ice-pwd:OrO4kMLd7aNCvYnsX9gk4eoN\r\na=ice-options:trickle\r\na=fingerprint:sha-256 3D:C2:6A:AE:10:D2:35:2B:E0:3E:20:59:C6:E4:88:EB:21:75:FC:6B:93:39:EF:B0:AA:DC:15:07:55:66:A9:BC\r\na=setup:active\r\na=mid:audio-stream\r\na=recvonly\r\na=rtcp-mux\r\na=rtpmap:111 OPUS/48000/2\r\na=fmtp:111 minptime=10;useinbandfec=1\r\nm=application 9 UDP/DTLS/SCTP webrtc-datachannel\r\nc=IN IP4 0.0.0.0\r\na=ice-ufrag:gcQq\r\na=ice-pwd:OrO4kMLd7aNCvYnsX9gk4eoN\r\na=ice-options:trickle\r\na=fingerprint:sha-256 3D:C2:6A:AE:10:D2:35:2B:E0:3E:20:59:C6:E4:88:EB:21:75:FC:6B:93:39:EF:B0:AA:DC:15:07:55:66:A9:BC\r\na=setup:active\r\na=mid:0\r\na=sctp-port:5000\r\na=max-message-size:262144\r\n"}
Client server >> {"id": "rm8U77FRtq", "type": "answer", "sdp": "v=0\r\no=- 1779483509754603469 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE video-stream audio-stream 0\r\na=msid-semantic: WMS\r\nm=video 9 UDP/TLS/RTP/SAVPF 102\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=candidate:3099956911 1 udp 2113937151 9d61f606-07c9-418b-bce4-ca5b9f831974.local 60327 typ host generation 0 network-cost 999\r\na=ice-ufrag:gcQq\r\na=ice-pwd:OrO4kMLd7aNCvYnsX9gk4eoN\r\na=ice-options:trickle\r\na=fingerprint:sha-256 3D:C2:6A:AE:10:D2:35:2B:E0:3E:20:59:C6:E4:88:EB:21:75:FC:6B:93:39:EF:B0:AA:DC:15:07:55:66:A9:BC\r\na=setup:active\r\na=mid:video-stream\r\na=recvonly\r\na=rtcp-mux\r\na=rtpmap:102 H264/90000\r\na=rtcp-fb:102 goog-remb\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=42e01f\r\nm=audio 9 UDP/TLS/RTP/SAVPF 111\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=ice-ufrag:gcQq\r\na=ice-pwd:OrO4kMLd7aNCvYnsX9gk4eoN\r\na=ice-options:trickle\r\na=fingerprint:sha-256 3D:C2:6A:AE:10:D2:35:2B:E0:3E:20:59:C6:E4:88:EB:21:75:FC:6B:93:39:EF:B0:AA:DC:15:07:55:66:A9:BC\r\na=setup:active\r\na=mid:audio-stream\r\na=recvonly\r\na=rtcp-mux\r\na=rtpmap:111 OPUS/48000/2\r\na=fmtp:111 minptime=10;useinbandfec=1\r\nm=application 9 UDP/DTLS/SCTP webrtc-datachannel\r\nc=IN IP4 0.0.0.0\r\na=ice-ufrag:gcQq\r\na=ice-pwd:OrO4kMLd7aNCvYnsX9gk4eoN\r\na=ice-options:trickle\r\na=fingerprint:sha-256 3D:C2:6A:AE:10:D2:35:2B:E0:3E:20:59:C6:E4:88:EB:21:75:FC:6B:93:39:EF:B0:AA:DC:15:07:55:66:A9:BC\r\na=setup:active\r\na=mid:0\r\na=sctp-port:5000\r\na=max-message-size:262144\r\n"}
js 客户端的
SDP
Offer
v=0
o=rtc 4114583284 0 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE video-stream audio-stream 0
a=group:LS video-stream audio-stream
a=msid-semantic:WMS *
a=setup:actpass
a=ice-ufrag:D5ZJ
a=ice-pwd:pXxLOzaQ05ilA/PRQcZ6Wm
a=ice-options:trickle
a=fingerprint:sha-256 71:64:22:09:B5:1D:D0:74:9F:F8:14:92:EB:B6:C1:51:5A:E2:DE:39:15:C8:14:70:94:67:D3:4C:52:D7:A4:DB
m=video 20689 UDP/TLS/RTP/SAVPF 102
c=IN IP4 192.168.50.65
a=mid:video-stream
a=sendonly
a=ssrc:1 cname:video-stream
a=ssrc:1 msid:stream1 video-stream
a=rtcp-mux
a=rtpmap:102 H264/90000
a=rtcp-fb:102 nack
a=rtcp-fb:102 nack pli
a=rtcp-fb:102 goog-remb
a=fmtp:102 profile-level-id=42e01f;packetization-mode=1;level-asymmetry-allowed=1
a=candidate:1 1 UDP 2015363327 192.168.50.65 20689 typ host
a=candidate:2 1 UDP 2015363583 fe80::3432:91e9:b456:fecf 24609 typ host
a=candidate:3 1 UDP 1679819007 121.33.115.242 20689 typ srflx raddr 192.168.50.65 rport 20689
a=end-of-candidates
m=audio 20689 UDP/TLS/RTP/SAVPF 111
c=IN IP4 192.168.50.65
a=mid:audio-stream
a=sendonly
a=ssrc:2 cname:audio-stream
a=ssrc:2 msid:stream1 audio-stream
a=rtcp-mux
a=rtpmap:111 OPUS/48000/2
a=fmtp:111 minptime=10;maxaveragebitrate=96000;stereo=1;sprop-stereo=1;useinbandfec=1
m=application 20689 UDP/DTLS/SCTP webrtc-datachannel
c=IN IP4 192.168.50.65
a=mid:0
a=sendrecv
a=sctp-port:5000
a=max-message-size:262144
Answer
v=0
o=- 1779483509754603469 2 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE video-stream audio-stream 0
a=msid-semantic: WMS
m=video 9 UDP/TLS/RTP/SAVPF 102
c=IN IP4 0.0.0.0
a=rtcp:9 IN IP4 0.0.0.0
a=candidate:3099956911 1 udp 2113937151 9d61f606-07c9-418b-bce4-ca5b9f831974.local 60327 typ host generation 0 network-cost 999
a=ice-ufrag:gcQq
a=ice-pwd:OrO4kMLd7aNCvYnsX9gk4eoN
a=ice-options:trickle
a=fingerprint:sha-256 3D:C2:6A:AE:10:D2:35:2B:E0:3E:20:59:C6:E4:88:EB:21:75:FC:6B:93:39:EF:B0:AA:DC:15:07:55:66:A9:BC
a=setup:active
a=mid:video-stream
a=recvonly
a=rtcp-mux
a=rtpmap:102 H264/90000
a=rtcp-fb:102 goog-remb
a=rtcp-fb:102 nack
a=rtcp-fb:102 nack pli
a=fmtp:102 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f
m=audio 9 UDP/TLS/RTP/SAVPF 111
c=IN IP4 0.0.0.0
a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:gcQq
a=ice-pwd:OrO4kMLd7aNCvYnsX9gk4eoN
a=ice-options:trickle
a=fingerprint:sha-256 3D:C2:6A:AE:10:D2:35:2B:E0:3E:20:59:C6:E4:88:EB:21:75:FC:6B:93:39:EF:B0:AA:DC:15:07:55:66:A9:BC
a=setup:active
a=mid:audio-stream
a=recvonly
a=rtcp-mux
a=rtpmap:111 OPUS/48000/2
a=fmtp:111 minptime=10;useinbandfec=1
m=application 9 UDP/DTLS/SCTP webrtc-datachannel
c=IN IP4 0.0.0.0
a=ice-ufrag:gcQq
a=ice-pwd:OrO4kMLd7aNCvYnsX9gk4eoN
a=ice-options:trickle
a=fingerprint:sha-256 3D:C2:6A:AE:10:D2:35:2B:E0:3E:20:59:C6:E4:88:EB:21:75:FC:6B:93:39:EF:B0:AA:DC:15:07:55:66:A9:BC
a=setup:active
a=mid:0
a=sctp-port:5000
a=max-message-size:262144
难道是因为打开了俩客户端推流?
- 关闭
js客户端没点击stun server,成功
重来
- 这里打印了Client XbVsVWZICw connected 客户端是we端?
没使用stun server反而有数据了
Data Channel
- open
< Ping
> Pong 0
< Ping
> Pong 1031
< Ping
> Pong 2033
< Ping
> Pong 3036
< Ping
> Pong 4038
< Ping
> Pong 5040
< Ping
> Pong 6044
< Ping
> Pong 7046
< Ping
> Pong 8062
< Ping
> Pong 9063
< Ping
> Pong 10066
< Ping
> Pong 11083
< Ping
> Pong 12085
< Ping
> Pong 13087
< Ping
> Pong 14089
< Ping
> Pong 15091
< Ping
> Pong 16095
< Ping
> Pong 17097
< Ping
> Pong 18098
< Ping
> Pong 19100
< Ping
> Pong 20102
< Ping
> Pong 21105
< Ping
> Pong 22143
< Ping
> Pong 23146
< Ping
> Pong 24148
< Ping
> Pong 25150
< Ping
> Pong 26151
< Ping
> Pong 27153
< Ping
> Pong 28165
< Ping
> Pong 29167
< Ping
> Pong 30170
< Ping
> Pong 31173
< Ping
> Pong 32176
< Ping
> Pong 33179
< Ping
> Pong 34180
< Ping
> Pong 35182
< Ping
> Pong 36184
< Ping
> Pong 37187
< Ping
> Pong 38189
< Ping
> Pong 39191
< Ping
> Pong 40193
< Ping
> Pong 41194
< Ping
> Pong 42196
< Ping
> Pong 43198
< Ping
> Pong 44200
< Ping
> Pong 45203
< Ping
> Pong 46206
< Ping
> Pong 47208
< Ping
> Pong 48211
< Ping
> Pong 49215
< Ping
> Pong 50217
< Ping
> Pong 51219
< Ping
> Pong 52222
< Ping
> Pong 53223
< Ping
> Pong 54225
< Ping
SDP
Offer
v=0
o=rtc 1142322650 0 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE video-stream audio-stream 0
a=group:LS video-stream audio-stream
a=msid-semantic:WMS *
a=setup:actpass
a=ice-ufrag:A9kS
a=ice-pwd:4lW6WTWIEmiHsRWWq7zKDH
a=ice-options:trickle
a=fingerprint:sha-256 A6:79:A1:45:84:A8:B3:11:B9:22:0E:59:43:5B:F5:C7:7A:B1:5F:DD:9B:72:1A:7C:F1:A2:29:AA:06:A9:D1:23
m=video 1064 UDP/TLS/RTP/SAVPF 102
c=IN IP4 192.168.50.65
a=mid:video-stream
a=sendonly
a=ssrc:1 cname:video-stream
a=ssrc:1 msid:stream1 video-stream
a=rtcp-mux
a=rtpmap:102 H264/90000
a=rtcp-fb:102 nack
a=rtcp-fb:102 nack pli
a=rtcp-fb:102 goog-remb
a=fmtp:102 profile-level-id=42e01f;packetization-mode=1;level-asymmetry-allowed=1
a=candidate:1 1 UDP 2015363327 192.168.50.65 1064 typ host
a=candidate:2 1 UDP 2015363583 fe80::3432:91e9:b456:fecf 40075 typ host
a=candidate:3 1 UDP 1679819007 121.33.115.242 1064 typ srflx raddr 192.168.50.65 rport 1064
a=end-of-candidates
m=audio 1064 UDP/TLS/RTP/SAVPF 111
c=IN IP4 192.168.50.65
a=mid:audio-stream
a=sendonly
a=ssrc:2 cname:audio-stream
a=ssrc:2 msid:stream1 audio-stream
a=rtcp-mux
a=rtpmap:111 OPUS/48000/2
a=fmtp:111 minptime=10;maxaveragebitrate=96000;stereo=1;sprop-stereo=1;useinbandfec=1
m=application 1064 UDP/DTLS/SCTP webrtc-datachannel
c=IN IP4 192.168.50.65
a=mid:0
a=sendrecv
a=sctp-port:5000
a=max-message-size:262144
Answer
v=0
o=- 2887559632601353330 2 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE video-stream audio-stream 0
a=msid-semantic: WMS
m=video 9 UDP/TLS/RTP/SAVPF 102
c=IN IP4 0.0.0.0
a=rtcp:9 IN IP4 0.0.0.0
a=candidate:852583563 1 udp 2113937151 0e57e5ad-5c2b-4dd9-8192-25062062de44.local 58840 typ host generation 0 network-cost 999
a=ice-ufrag:Vm7M
a=ice-pwd:GZVDXctKrULT3y1ISUvsYul2
a=ice-options:trickle
a=fingerprint:sha-256 A6:AC:9A:9D:67:FF:B6:62:AF:D0:63:E2:34:5E:23:DC:49:DD:74:3A:8B:36:14:52:CF:5E:7E:0F:A8:86:6A:A2
a=setup:active
a=mid:video-stream
a=recvonly
a=rtcp-mux
a=rtpmap:102 H264/90000
a=rtcp-fb:102 goog-remb
a=rtcp-fb:102 nack
a=rtcp-fb:102 nack pli
a=fmtp:102 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f
m=audio 9 UDP/TLS/RTP/SAVPF 111
c=IN IP4 0.0.0.0
a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:Vm7M
a=ice-pwd:GZVDXctKrULT3y1ISUvsYul2
a=ice-options:trickle
a=fingerprint:sha-256 A6:AC:9A:9D:67:FF:B6:62:AF:D0:63:E2:34:5E:23:DC:49:DD:74:3A:8B:36:14:52:CF:5E:7E:0F:A8:86:6A:A2
a=setup:active
a=mid:audio-stream
a=recvonly
a=rtcp-mux
a=rtpmap:111 OPUS/48000/2
a=fmtp:111 minptime=10;useinbandfec=1
m=application 9 UDP/DTLS/SCTP webrtc-datachannel
c=IN IP4 0.0.0.0
a=ice-ufrag:Vm7M
a=ice-pwd:GZVDXctKrULT3y1ISUvsYul2
a=ice-options:trickle
a=fingerprint:sha-256 A6:AC:9A:9D:67:FF:B6:62:AF:D0:63:E2:34:5E:23:DC:49:DD:74:3A:8B:36:14:52:CF:5E:7E:0F:A8:86:6A:A2
a=setup:active
a=mid:0
a=sctp-port:5000
a=max-message-size:262144
- 一直在推流
- 服务端打印,只交互一次candidate么?
received 1001 (going away); then sent 1001 (going away)
Client rm8U77FRtq disconnected
connection closed
connection open
Client XbVsVWZICw connected
connection open
Client server connected
Client XbVsVWZICw << {"id":"server","type":"request"}
Client server >> {"id": "XbVsVWZICw", "type": "request"}
Client server << {"id":"XbVsVWZICw","sdp":"v=0\r\no=rtc 1142322650 0 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE video-stream audio-stream 0\r\na=group:LS video-stream audio-stream\r\na=msid-semantic:WMS *\r\na=setup:actpass\r\na=ice-ufrag:A9kS\r\na=ice-pwd:4lW6WTWIEmiHsRWWq7zKDH\r\na=ice-options:trickle\r\na=fingerprint:sha-256 A6:79:A1:45:84:A8:B3:11:B9:22:0E:59:43:5B:F5:C7:7A:B1:5F:DD:9B:72:1A:7C:F1:A2:29:AA:06:A9:D1:23\r\nm=video 1064 UDP/TLS/RTP/SAVPF 102\r\nc=IN IP4 192.168.50.65\r\na=mid:video-stream\r\na=sendonly\r\na=ssrc:1 cname:video-stream\r\na=ssrc:1 msid:stream1 video-stream\r\na=rtcp-mux\r\na=rtpmap:102 H264/90000\r\na=rtcp-fb:102 nack\r\na=rtcp-fb:102 nack pli\r\na=rtcp-fb:102 goog-remb\r\na=fmtp:102 profile-level-id=42e01f;packetization-mode=1;level-asymmetry-allowed=1\r\na=candidate:1 1 UDP 2015363327 192.168.50.65 1064 typ host\r\na=candidate:2 1 UDP 2015363583 fe80::3432:91e9:b456:fecf 40075 typ host\r\na=candidate:3 1 UDP 1679819007 121.33.115.242 1064 typ srflx raddr 192.168.50.65 rport 1064\r\na=end-of-candidates\r\nm=audio 1064 UDP/TLS/RTP/SAVPF 111\r\nc=IN IP4 192.168.50.65\r\na=mid:audio-stream\r\na=sendonly\r\na=ssrc:2 cname:audio-stream\r\na=ssrc:2 msid:stream1 audio-stream\r\na=rtcp-mux\r\na=rtpmap:111 OPUS/48000/2\r\na=fmtp:111 minptime=10;maxaveragebitrate=96000;stereo=1;sprop-stereo=1;useinbandfec=1\r\nm=application 1064 UDP/DTLS/SCTP webrtc-datachannel\r\nc=IN IP4 192.168.50.65\r\na=mid:0\r\na=sendrecv\r\na=sctp-port:5000\r\na=max-message-size:262144\r\n","type":"offer"}
Client XbVsVWZICw >> {"id": "server", "sdp": "v=0\r\no=rtc 1142322650 0 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE video-stream audio-stream 0\r\na=group:LS video-stream audio-stream\r\na=msid-semantic:WMS *\r\na=setup:actpass\r\na=ice-ufrag:A9kS\r\na=ice-pwd:4lW6WTWIEmiHsRWWq7zKDH\r\na=ice-options:trickle\r\na=fingerprint:sha-256 A6:79:A1:45:84:A8:B3:11:B9:22:0E:59:43:5B:F5:C7:7A:B1:5F:DD:9B:72:1A:7C:F1:A2:29:AA:06:A9:D1:23\r\nm=video 1064 UDP/TLS/RTP/SAVPF 102\r\nc=IN IP4 192.168.50.65\r\na=mid:video-stream\r\na=sendonly\r\na=ssrc:1 cname:video-stream\r\na=ssrc:1 msid:stream1 video-stream\r\na=rtcp-mux\r\na=rtpmap:102 H264/90000\r\na=rtcp-fb:102 nack\r\na=rtcp-fb:102 nack pli\r\na=rtcp-fb:102 goog-remb\r\na=fmtp:102 profile-level-id=42e01f;packetization-mode=1;level-asymmetry-allowed=1\r\na=candidate:1 1 UDP 2015363327 192.168.50.65 1064 typ host\r\na=candidate:2 1 UDP 2015363583 fe80::3432:91e9:b456:fecf 40075 typ host\r\na=candidate:3 1 UDP 1679819007 121.33.115.242 1064 typ srflx raddr 192.168.50.65 rport 1064\r\na=end-of-candidates\r\nm=audio 1064 UDP/TLS/RTP/SAVPF 111\r\nc=IN IP4 192.168.50.65\r\na=mid:audio-stream\r\na=sendonly\r\na=ssrc:2 cname:audio-stream\r\na=ssrc:2 msid:stream1 audio-stream\r\na=rtcp-mux\r\na=rtpmap:111 OPUS/48000/2\r\na=fmtp:111 minptime=10;maxaveragebitrate=96000;stereo=1;sprop-stereo=1;useinbandfec=1\r\nm=application 1064 UDP/DTLS/SCTP webrtc-datachannel\r\nc=IN IP4 192.168.50.65\r\na=mid:0\r\na=sendrecv\r\na=sctp-port:5000\r\na=max-message-size:262144\r\n", "type": "offer"}
Client XbVsVWZICw << {"id":"server","type":"answer","sdp":"v=0\r\no=- 2887559632601353330 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE video-stream audio-stream 0\r\na=msid-semantic: WMS\r\nm=video 9 UDP/TLS/RTP/SAVPF 102\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=candidate:852583563 1 udp 2113937151 0e57e5ad-5c2b-4dd9-8192-25062062de44.local 58840 typ host generation 0 network-cost 999\r\na=ice-ufrag:Vm7M\r\na=ice-pwd:GZVDXctKrULT3y1ISUvsYul2\r\na=ice-options:trickle\r\na=fingerprint:sha-256 A6:AC:9A:9D:67:FF:B6:62:AF:D0:63:E2:34:5E:23:DC:49:DD:74:3A:8B:36:14:52:CF:5E:7E:0F:A8:86:6A:A2\r\na=setup:active\r\na=mid:video-stream\r\na=recvonly\r\na=rtcp-mux\r\na=rtpmap:102 H264/90000\r\na=rtcp-fb:102 goog-remb\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=42e01f\r\nm=audio 9 UDP/TLS/RTP/SAVPF 111\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=ice-ufrag:Vm7M\r\na=ice-pwd:GZVDXctKrULT3y1ISUvsYul2\r\na=ice-options:trickle\r\na=fingerprint:sha-256 A6:AC:9A:9D:67:FF:B6:62:AF:D0:63:E2:34:5E:23:DC:49:DD:74:3A:8B:36:14:52:CF:5E:7E:0F:A8:86:6A:A2\r\na=setup:active\r\na=mid:audio-stream\r\na=recvonly\r\na=rtcp-mux\r\na=rtpmap:111 OPUS/48000/2\r\na=fmtp:111 minptime=10;useinbandfec=1\r\nm=application 9 UDP/DTLS/SCTP webrtc-datachannel\r\nc=IN IP4 0.0.0.0\r\na=ice-ufrag:Vm7M\r\na=ice-pwd:GZVDXctKrULT3y1ISUvsYul2\r\na=ice-options:trickle\r\na=fingerprint:sha-256 A6:AC:9A:9D:67:FF:B6:62:AF:D0:63:E2:34:5E:23:DC:49:DD:74:3A:8B:36:14:52:CF:5E:7E:0F:A8:86:6A:A2\r\na=setup:active\r\na=mid:0\r\na=sctp-port:5000\r\na=max-message-size:262144\r\n"}
Client server >> {"id": "XbVsVWZICw", "type": "answer", "sdp": "v=0\r\no=- 2887559632601353330 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE video-stream audio-stream 0\r\na=msid-semantic: WMS\r\nm=video 9 UDP/TLS/RTP/SAVPF 102\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=candidate:852583563 1 udp 2113937151 0e57e5ad-5c2b-4dd9-8192-25062062de44.local 58840 typ host generation 0 network-cost 999\r\na=ice-ufrag:Vm7M\r\na=ice-pwd:GZVDXctKrULT3y1ISUvsYul2\r\na=ice-options:trickle\r\na=fingerprint:sha-256 A6:AC:9A:9D:67:FF:B6:62:AF:D0:63:E2:34:5E:23:DC:49:DD:74:3A:8B:36:14:52:CF:5E:7E:0F:A8:86:6A:A2\r\na=setup:active\r\na=mid:video-stream\r\na=recvonly\r\na=rtcp-mux\r\na=rtpmap:102 H264/90000\r\na=rtcp-fb:102 goog-remb\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=42e01f\r\nm=audio 9 UDP/TLS/RTP/SAVPF 111\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=ice-ufrag:Vm7M\r\na=ice-pwd:GZVDXctKrULT3y1ISUvsYul2\r\na=ice-options:trickle\r\na=fingerprint:sha-256 A6:AC:9A:9D:67:FF:B6:62:AF:D0:63:E2:34:5E:23:DC:49:DD:74:3A:8B:36:14:52:CF:5E:7E:0F:A8:86:6A:A2\r\na=setup:active\r\na=mid:audio-stream\r\na=recvonly\r\na=rtcp-mux\r\na=rtpmap:111 OPUS/48000/2\r\na=fmtp:111 minptime=10;useinbandfec=1\r\nm=application 9 UDP/DTLS/SCTP webrtc-datachannel\r\nc=IN IP4 0.0.0.0\r\na=ice-ufrag:Vm7M\r\na=ice-pwd:GZVDXctKrULT3y1ISUvsYul2\r\na=ice-options:trickle\r\na=fingerprint:sha-256 A6:AC:9A:9D:67:FF:B6:62:AF:D0:63:E2:34:5E:23:DC:49:DD:74:3A:8B:36:14:52:CF:5E:7E:0F:A8:86:6A:A2\r\na=setup:active\r\na=mid:0\r\na=sctp-port:5000\r\na=max-message-size:262144\r\n"}
打开stun server 测试
关闭streamer
重新刷新js客户端,所以这个是js客户端id
重新启动streamer
选中使用STUN服务
带STUN服务器也可以
Data Channel
- open
< Ping
> Pong 0
< Ping
> Pong 1002
< Ping
> Pong 2003
< Ping
> Pong 3007
< Ping
> Pong 4009
< Ping
> Pong 5012
< Ping
> Pong 6014
< Ping
> Pong 7016
< Ping
> Pong 8019
< Ping
> Pong 9022
< Ping
> Pong 10025
< Ping
> Pong 11027
< Ping
> Pong 12028
< Ping
> Pong 13031
< Ping
> Pong 14032
< Ping
> Pong 15034
< Ping
> Pong 16036
< Ping
> Pong 17038
< Ping
> Pong 18043
< Ping
> Pong 19044
< Ping
> Pong 20046
< Ping
> Pong 21048
< Ping
> Pong 22050
< Ping
> Pong 23053
< Ping
> Pong 24060
< Ping
> Pong 25062
< Ping
> Pong 26064
< Ping
> Pong 27065
< Ping
> Pong 28067
< Ping
> Pong 29069
< Ping
> Pong 30073
< Ping
> Pong 31077
< Ping
> Pong 32080
< Ping
> Pong 33082
< Ping
> Pong 34084
< Ping
> Pong 35086
< Ping
> Pong 36088
< Ping
> Pong 37090
< Ping
> Pong 38131
< Ping
> Pong 39133
< Ping
> Pong 40135
< Ping
> Pong 41137
< Ping
> Pong 42139
< Ping
> Pong 43147
< Ping
> Pong 44151
< Ping
> Pong 45152
< Ping
> Pong 46155
< Ping
> Pong 47157
< Ping
> Pong 48162
< Ping
SDP
Offer
v=0
o=rtc 387591248 0 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE video-stream audio-stream 0
a=group:LS video-stream audio-stream
a=msid-semantic:WMS *
a=setup:actpass
a=ice-ufrag:IB4l
a=ice-pwd:A4aznKP0dOjp9Bi+TwoPlr
a=ice-options:trickle
a=fingerprint:sha-256 AA:E9:F3:67:AC:D8:1F:EC:C1:BC:3B:B5:E9:EC:D0:87:64:8C:0D:01:99:4C:BB:DF:59:D9:82:A4:8A:7B:C0:7A
m=video 22521 UDP/TLS/RTP/SAVPF 102
c=IN IP4 192.168.50.65
a=mid:video-stream
a=sendonly
a=ssrc:1 cname:video-stream
a=ssrc:1 msid:stream1 video-stream
a=rtcp-mux
a=rtpmap:102 H264/90000
a=rtcp-fb:102 nack
a=rtcp-fb:102 nack pli
a=rtcp-fb:102 goog-remb
a=fmtp:102 profile-level-id=42e01f;packetization-mode=1;level-asymmetry-allowed=1
a=candidate:1 1 UDP 2015363327 192.168.50.65 22521 typ host
a=candidate:2 1 UDP 2015363583 fe80::3432:91e9:b456:fecf 27866 typ host
a=candidate:3 1 UDP 1679819007 121.33.115.242 22521 typ srflx raddr 192.168.50.65 rport 22521
a=end-of-candidates
m=audio 22521 UDP/TLS/RTP/SAVPF 111
c=IN IP4 192.168.50.65
a=mid:audio-stream
a=sendonly
a=ssrc:2 cname:audio-stream
a=ssrc:2 msid:stream1 audio-stream
a=rtcp-mux
a=rtpmap:111 OPUS/48000/2
a=fmtp:111 minptime=10;maxaveragebitrate=96000;stereo=1;sprop-stereo=1;useinbandfec=1
m=application 22521 UDP/DTLS/SCTP webrtc-datachannel
c=IN IP4 192.168.50.65
a=mid:0
a=sendrecv
a=sctp-port:5000
a=max-message-size:262144
Answer
v=0
o=- 2996011111635307684 2 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE video-stream audio-stream 0
a=msid-semantic: WMS
m=video 9 UDP/TLS/RTP/SAVPF 102
c=IN IP4 0.0.0.0
a=rtcp:9 IN IP4 0.0.0.0
a=candidate:2075770023 1 udp 2113937151 927c8399-8f4f-4e82-8cba-952e205505ab.local 53410 typ host generation 0 network-cost 999
a=ice-ufrag:DVfF
a=ice-pwd:FNlbZj2c6moUy6MYW1v870nP
a=ice-options:trickle
a=fingerprint:sha-256 D9:76:B2:58:D9:99:7B:10:30:56:D7:7A:EF:1C:C5:97:C3:28:74:6B:35:9D:50:86:7F:F3:E8:CA:D0:83:39:67
a=setup:active
a=mid:video-stream
a=recvonly
a=rtcp-mux
a=rtpmap:102 H264/90000
a=rtcp-fb:102 goog-remb
a=rtcp-fb:102 nack
a=rtcp-fb:102 nack pli
a=fmtp:102 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f
m=audio 9 UDP/TLS/RTP/SAVPF 111
c=IN IP4 0.0.0.0
a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:DVfF
a=ice-pwd:FNlbZj2c6moUy6MYW1v870nP
a=ice-options:trickle
a=fingerprint:sha-256 D9:76:B2:58:D9:99:7B:10:30:56:D7:7A:EF:1C:C5:97:C3:28:74:6B:35:9D:50:86:7F:F3:E8:CA:D0:83:39:67
a=setup:active
a=mid:audio-stream
a=recvonly
a=rtcp-mux
a=rtpmap:111 OPUS/48000/2
a=fmtp:111 minptime=10;useinbandfec=1
m=application 9 UDP/DTLS/SCTP webrtc-datachannel
c=IN IP4 0.0.0.0
a=ice-ufrag:DVfF
a=ice-pwd:FNlbZj2c6moUy6MYW1v870nP
a=ice-options:trickle
a=fingerprint:sha-256 D9:76:B2:58:D9:99:7B:10:30:56:D7:7A:EF:1C:C5:97:C3:28:74:6B:35:9D:50:86:7F:F3:E8:CA:D0:83:39:67
a=setup:active
a=mid:0
a=sctp-port:5000
a=max-message-size:262144