相关文章:
- Ubuntu环境安装OWT Server[Open WebRTC Toolkit]
- Docker环境安装OWT Server[Open WebRTC Toolkit]
- OWT Server整体架构分析 [Open WebRTC Toolkit]
- OWT Server信令分析 (上) [Open WebRTC Toolkit]
- OWT Server信令分析 (下) [Open WebRTC Toolkit]
- OWT Server进程结构和JS代码处理流程 [Open WebRTC Toolkit]
- OWT Server REST API
A POST /tokens/
A SocketIO connect
A SocketIO login
A SocketIO publish
A SocketIO soac offer
A SocketIO soac candidate
Portal SocketIO soac answer
B POST /tokens/
B SocketIO connect
B SocketIO login
B SocketIO subscribe
B SocketIO soac offer
B SocketIO soac candidate
Portal SocketIO soac answer
SocketIO logout
window.onload = function() {
var simulcast = getParameterByName('simulcast') || false;
var shareScreen = getParameterByName('screen') || false;
myRoom = getParameterByName('room');
var isHttps = (location.protocol === 'https:');
var mediaUrl = getParameterByName('url');
var isPublish = getParameterByName('publish');
createToken(myRoom, 'user', 'presenter', function(response) {
var token = response;
conference.join(token).then(resp => {
...
}, function(err) {
...
});
}, serverUrlBase);
};
{
"token":"eyJ0b2tlbklkIjoiNjM2OWMyNGI1MTI2YWMzZTM0NjFiMzdjIiwiaG9zdCI6IjUyLjgxLjIwMS4xOTA6ODA4MCIsInNlY3VyZSI6dHJ1ZSwic2lnbmF0dXJlIjoiWW1JeU56SXdaakJsWkdJMU16VmlPV1ExT0RSa1l6Um1NREk0WTJWak1tTmlZbU14TnpZME1ETmtZVEV3TkRrek9ERXhZMlJoTkdReFpqRTJNR0UxTXc9PSJ9",
"userAgent":{
"sdk":{
"version":"5.0",
"type":"JavaScript"
}
},
"protocol":"1.2"
}
{
"user":"user",
"role":"presenter",
"permission":{
"publish":{
"video":true,
"audio":true
},
"subscribe":{
"video":true,
"audio":true
}
},
"room":{
"id":"62b95bd27ff8054480cbb73a",
"views":[
"common"
],
"participants":[
{
"id":"IqCKvfpG402ooz_oAAAZ",
"user":"user",
"role":"presenter"
}
],
"streams":[
{
"id":"62b95bd27ff8054480cbb73a-common",
"type":"mixed",
"media":{
"tracks":[
{
"type":"audio",
"format":{
"codec":"opus",
"sampleRate":48000,
"channelNum":2
},
"optional":{
"format":[
{
"codec":"isac",
"sampleRate":16000
},
{
"codec":"isac",
"sampleRate":32000
},
{
"codec":"g722",
"sampleRate":16000,
"channelNum":1
},
{
"codec":"pcma"
},
{
"codec":"pcmu"
},
{
"codec":"aac",
"sampleRate":48000,
"channelNum":2
},
{
"codec":"ac3"
},
{
"codec":"nellymoser"
},
{
"codec":"ilbc"
}
]
},
"status":"active"
},
{
"type":"video",
"format":{
"codec":"vp8"
},
"parameters":{
"resolution":{
"width":640,
"height":480
},
"framerate":24,
"keyFrameInterval":100
},
"optional":{
"format":[
{
"codec":"h264",
"profile":"CB"
},
{
"codec":"h264",
"profile":"B"
},
{
"codec":"vp9"
}
],
"parameters":{
"resolution":[
{
"width":480,
"height":360
},
{
"width":426,
"height":320
},
{
"width":320,
"height":240
},
{
"width":212,
"height":160
},
{
"width":160,
"height":120
},
{
"width":352,
"height":288
}
],
"bitrate":[
"x0.8",
"x0.6",
"x0.4",
"x0.2"
],
"framerate":[
6,
12,
15
],
"keyFrameInterval":[
100,
30,
5,
2,
1
]
}
},
"status":"active"
}
]
},
"data":null,
"info":{
"label":"common",
"activeInput":"unknown",
"layout":[
],
"origin":{
"isp":"isp",
"region":"region"
}
}
}
]
},
"id":"IqCKvfpG402ooz_oAAAZ",
"reconnectionTicket":"eyJwYXJ0aWNpcGFudElkIjoiSXFDS3ZmcEc0MDJvb3pfb0FBQVoiLCJ0aWNrZXRJZCI6IjJmdmdqYm52NW82Iiwibm90QmVmb3JlIjoxNjY3ODc1NDAzNjkwLCJub3RBZnRlciI6MTY2Nzg3NjAwMzY5MCwic2lnbmF0dXJlIjoiTWpZeVlqbGpNMk5sWXpkalpERmxOV0k1TkdNNFlXVmpPREpsWW1FM09UQTNZemcxWW1Sak9EWmpaR1E0TnpCalpERXdZV0l4TW1ZMlpUTTFNV0l4TUE9PSJ9"
}
/**
* @function connect
* @instance
* @desc Connect to a portal.
* @memberof Oms.Conference.SioSignaling
* @return {Promise
connect(host, isSecured, loginInfo) {
return new Promise((resolve, reject) => {
const opts = {
'reconnection': true,
'reconnectionAttempts': reconnectionAttempts,
'force new connection': true,
};
this._socket = io(host, opts);
...
//SocketIO连接成功后,客户端需要主动发送login事件
this._socket.emit('login', loginInfo, (status, data) => {
if (status === 'ok') {
this._loggedIn = true;
this._onReconnectionTicket(data.reconnectionTicket);
this._socket.on('connect', () => {
// re-login with reconnection ticket.
this._socket.emit('relogin', this._reconnectionTicket, (status,
data) => {
if (status === 'ok') {
this._reconnectTimes = 0;
this._onReconnectionTicket(data);
} else {
this.dispatchEvent(new EventModule.OwtEvent('disconnect'));
}
});
});
}
handleResponse(status, data, resolve, reject);
});
});
}
位置:socket.on函数在source/portal/socketIOServer.js中。
SocketIO服务器的逻辑在socketIOServer.js和v11Client.js(除了v11Client,还有v10Client和legacyClient,用于老版本的兼容)中。
socketIOServer监听login、relogin、refreshReconnectionTicket、logout、disconnect和connection这6个事件。
在处理login和relogin事件时,会根据protocol字段的取值来决定使用的Client版本(V10和V11)
socket.on('login', function(login_info, callback) {
...
client_id = socket.id + '';
var client;
if (login_info.protocol === undefined) {
protocol_version = 'legacy';
client = new LegacyClient(client_id, that, portal);
} else if (login_info.protocol === '1.0' ||
login_info.protocol === '1.1' ||
login_info.protocol === '1.2') {
//FIXME: Reject connection from 3.5 client
if (login_info.userAgent && login_info.userAgent.sdk &&
login_info.userAgent.sdk.version === '3.5') {
safeCall(callback, 'error', 'Deprecated client version');
return socket.disconnect();
}
protocol_version = login_info.protocol;
client = new Client(client_id, that, portal, protocol_version);
} else {
safeCall(callback, 'error', 'Unknown client protocol');
return socket.disconnect();
}
return validateUserAgent(login_info.userAgent)
.then((reconnEnabled) => {
reconnection.enabled = reconnEnabled;
return new Promise(function(resolve){
resolve(JSON.parse((Buffer.from(login_info.token, 'base64')).toString()));
});
}).then((token) => {
return client.join(token);
}).then((result) => {
...
});
});
source/portal/socketIOServer.js socket.on('login', function(login_info, ... =>
source/portal/v11Client.js that.join = (token) =>
source/portal/portal.js that.join = function(participantId, token) =>
source/portal/rpcRequest.js that.join = function(controller, roomId, participant) =>
source/agent/conference/conference.js that.join = function(roomId, participantInfo, callback) =>
source/agent/conference/conference.js initRoom = function(roomId, origin) => //保存房间信息,创建roomController、accessController
source/agent/conference/conference.js addParticipant = function(participantInfo, permission) => //保存用户信息
{
"media":{
"tracks":[
{
"type":"audio",
"mid":"2",
"source":"mic"
},
{
"type":"video",
"mid":"3",
"source":"camera"
}
]
},
"transport":{
"id":"cbeae5478b684b5e8f639fa84aafde9b",
"type":"webrtc"
}
}
{
"id":"55aa9331e2b741338639d282f0bffa0d",
"transportId":"eceda0bafe3e4a1eab1a75056ede3cd8"
}
async publish(stream, options, videoCodecs) {
...
return this._signaling.sendSignalingMessage('publish', {
media: {tracks: trackOptions},
attributes: stream.attributes,
transport: {id: this._id, type: 'webrtc'},
}).catch((e) => {
// Send SDP even when failed to get Answer.
this._signaling.sendSignalingMessage('soac', {
id: this._id,
signaling: localDesc,
});
throw e;
});
}).then((data) => {
...
this._signaling.sendSignalingMessage('soac', {
id: this._id,
signaling: localDesc,
});
}).catch((e) => {
...
}
src/samples/conference/public/scripts/index.js conference.publish(localStream, ... =>
src/sdk/conference/client.js this.publish =>
src/sdk/conference/channel.js async publish =>
src/sdk/conference/channel.js _signaling.sendSignalingMessage('publish', =>
socket.on('publish', function(pubReq, callback) {
if(!that.inRoom){
return safeCall(callback, 'error', 'Illegal request');
}
//FIXME: move the id assignment to conference
var stream_id = uuidWithoutDash();
var transportId;
return adapter.translateReq(ReqType.Pub, pubReq)
.then((req) => {
if (req.transport && req.transport.type == 'quic') {
req.type = 'quic';
if (!req.transport.id) {
req.transport.id = uuidWithoutDash();
}
transportId = req.transport.id;
} else {
req.type = 'webrtc'; //FIXME: For backend compatibility with v3.4 clients.
if (!req.transport || !req.transport.id) {
req.transport = { type : 'webrtc', id : stream_id };
}
}
transportId = req.transport.id;
return portal.publish(clientId, stream_id, req);
}).then((result) => {
safeCall(callback, 'ok', {id: stream_id, transportId});
}).catch(onError('publish', callback));
});
source/portal/v11Client.js socket.on('publish', function(pubReq,
source/portal/portal.js that.publish = = function(participantId, streamId, pubInfo) =>
source/portal/rpcRequest.js that.publish = function(controller, participantId, streamId, Options) =>
source/agent/conference/conference.js that.publish = function(participantId, streamId, pubInfo, callback) =>
source/agent/conference/accessController.js that.initiate = function(participantId, sessionId, direction, origin, sessionOptions, ... =>
source/agent/conference/rpcRequest.js that.getWorkerNode = function(clusterManager, purpose, ... => //发起RPC,拿到WebRTC Agent的nodeId
source/agent/conference/rpcRequest.js that.initiate = function(accessNode, sessionId, ... => //向WebRTC Agent的node发起publish RPC
source/agent/conference/rpcRequest.js that.initiate = function(accessNode, sessionId, ... => //向WebRTC Agent的node发起publish RPC
source/agent/webrtc/index.js that.publish = function (operationId, connectionType, ... =>
source/agent/webrtc/index.js createWebRTCConnection = function (transportId, ... => //创建WrtcConnection(`webrtc/wrtcConnection.js`),它负责和C++ 代码进行交互
/*
* Given a WebRtcConnection waits for the state CANDIDATES_GATHERED for set remote SDP.
*/
var initWebRtcConnection = function (wrtc) {
wrtc.on('status_event', (evt, status) => {
if (evt.type === 'answer') {
processAnswer(evt.sdp);
const message = localSdp.toString();
log.debug('Answer SDP', message);
on_status({type: 'answer', sdp: message});
} else if (evt.type === 'candidate') {
let message = evt.candidate;
networkInterfaces.forEach((i) => {
if (i.ip_address && i.replaced_ip_address) {
message = message.replace(new RegExp(i.ip_address, 'g'), i.replaced_ip_address);
}
});
on_status({type: 'candidate', candidate: message});
} else if (evt.type === 'failed') {
log.warn('ICE failed, ', status, wrtc.id);
on_status({type: 'failed', reason: 'Ice procedure failed.'});
} else if (evt.type === 'ready') {
log.debug('Connection ready, ', wrtc.wrtcId);
on_status({
type: 'ready'
});
}
});
wrtc.init(wrtcId);
};
{
"id":"eceda0bafe3e4a1eab1a75056ede3cd8",
"signaling":{
"type":"offer",
"sdp":"v=0
o=- 7416128173695703170 3 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE 0 1 2 3
a=extmap-allow-mixed
a=msid-semantic: WMS
m=audio 60916 UDP/TLS/RTP/SAVPF 111 63 103 104 9 0 8 106 105 13 110 112 113 126
c=IN IP4 10.110.133.203
a=rtcp:9 IN IP4 0.0.0.0
a=candidate:2722325311 1 udp 2122265343 fc00:2::e19b:dc32:443d:dd84 55478 typ host generation 0 network-id 2
a=candidate:3962993534 1 udp 2122194687 10.110.133.203 60916 typ host generation 0 network-id 1
a=ice-ufrag:gdMS
a=ice-pwd:1yWra8IAyw4YqqXE6JLbrfDI
a=ice-options:trickle
a=fingerprint:sha-256 07:95:5D:7A:A8:FD:53:D3:B9:8B:CC:8C:29:54:08:89:83:63:5E:CE:A6:DE:01:EF:5F:0A:06:96:ED:E1:8A:9F
a=setup:actpass
a=mid:0
a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level
a=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=extmap:3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01
a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid
a=recvonly
a=rtcp-mux
a=rtpmap:111 opus/48000/2
a=rtcp-fb:111 transport-cc
a=fmtp:111 minptime=10;useinbandfec=1
a=rtpmap:63 red/48000/2
a=fmtp:63 111/111
a=rtpmap:103 ISAC/16000
a=rtpmap:104 ISAC/32000
a=rtpmap:9 G722/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:106 CN/32000
a=rtpmap:105 CN/16000
a=rtpmap:13 CN/8000
a=rtpmap:110 telephone-event/48000
a=rtpmap:112 telephone-event/32000
a=rtpmap:113 telephone-event/16000
a=rtpmap:126 telephone-event/8000
m=video 9 UDP/TLS/RTP/SAVPF 96 97 98 99 100 101 35 36 37 38 102 122 127 121 125 107 108 109 124 120 39 40 41 42 43 44 45 46 47 48 123 119 114 115 116 49
c=IN IP4 0.0.0.0
a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:gdMS
a=ice-pwd:1yWra8IAyw4YqqXE6JLbrfDI
a=ice-options:trickle
a=fingerprint:sha-256 07:95:5D:7A:A8:FD:53:D3:B9:8B:CC:8C:29:54:08:89:83:63:5E:CE:A6:DE:01:EF:5F:0A:06:96:ED:E1:8A:9F
a=setup:actpass
a=mid:1
a=extmap:14 urn:ietf:params:rtp-hdrext:toffset
a=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=extmap:13 urn:3gpp:video-orientation
a=extmap:3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01
a=extmap:5 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay
a=extmap:6 http://www.webrtc.org/experiments/rtp-hdrext/video-content-type
a=extmap:7 http://www.webrtc.org/experiments/rtp-hdrext/video-timing
a=extmap:8 http://www.webrtc.org/experiments/rtp-hdrext/color-space
a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid
a=extmap:10 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id
a=extmap:11 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id
a=recvonly
a=rtcp-mux
a=rtcp-rsize
a=rtpmap:96 VP8/90000
a=rtcp-fb:96 goog-remb
a=rtcp-fb:96 transport-cc
a=rtcp-fb:96 ccm fir
a=rtcp-fb:96 nack
a=rtcp-fb:96 nack pli
a=rtpmap:97 rtx/90000
a=fmtp:97 apt=96
a=rtpmap:98 VP9/90000
a=rtcp-fb:98 goog-remb
a=rtcp-fb:98 transport-cc
a=rtcp-fb:98 ccm fir
a=rtcp-fb:98 nack
a=rtcp-fb:98 nack pli
a=fmtp:98 profile-id=0
a=rtpmap:99 rtx/90000
a=fmtp:99 apt=98
a=rtpmap:100 VP9/90000
a=rtcp-fb:100 goog-remb
a=rtcp-fb:100 transport-cc
a=rtcp-fb:100 ccm fir
a=rtcp-fb:100 nack
a=rtcp-fb:100 nack pli
a=fmtp:100 profile-id=2
a=rtpmap:101 rtx/90000
a=fmtp:101 apt=100
a=rtpmap:35 VP9/90000
a=rtcp-fb:35 goog-remb
a=rtcp-fb:35 transport-cc
a=rtcp-fb:35 ccm fir
a=rtcp-fb:35 nack
a=rtcp-fb:35 nack pli
a=fmtp:35 profile-id=1
a=rtpmap:36 rtx/90000
a=fmtp:36 apt=35
a=rtpmap:37 VP9/90000
a=rtcp-fb:37 goog-remb
a=rtcp-fb:37 transport-cc
a=rtcp-fb:37 ccm fir
a=rtcp-fb:37 nack
a=rtcp-fb:37 nack pli
a=fmtp:37 profile-id=3
a=rtpmap:38 rtx/90000
a=fmtp:38 apt=37
a=rtpmap:102 H264/90000
a=rtcp-fb:102 goog-remb
a=rtcp-fb:102 transport-cc
a=rtcp-fb:102 ccm fir
a=rtcp-fb:102 nack
a=rtcp-fb:102 nack pli
a=fmtp:102 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f
a=rtpmap:122 rtx/90000
a=fmtp:122 apt=102
a=rtpmap:127 H264/90000
a=rtcp-fb:127 goog-remb
a=rtcp-fb:127 transport-cc
a=rtcp-fb:127 ccm fir
a=rtcp-fb:127 nack
a=rtcp-fb:127 nack pli
a=fmtp:127 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42001f
a=rtpmap:121 rtx/90000
a=fmtp:121 apt=127
a=rtpmap:125 H264/90000
a=rtcp-fb:125 goog-remb
a=rtcp-fb:125 transport-cc
a=rtcp-fb:125 ccm fir
a=rtcp-fb:125 nack
a=rtcp-fb:125 nack pli
a=fmtp:125 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f
a=rtpmap:107 rtx/90000
a=fmtp:107 apt=125
a=rtpmap:108 H264/90000
a=rtcp-fb:108 goog-remb
a=rtcp-fb:108 transport-cc
a=rtcp-fb:108 ccm fir
a=rtcp-fb:108 nack
a=rtcp-fb:108 nack pli
a=fmtp:108 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42e01f
a=rtpmap:109 rtx/90000
a=fmtp:109 apt=108
a=rtpmap:124 H264/90000
a=rtcp-fb:124 goog-remb
a=rtcp-fb:124 transport-cc
a=rtcp-fb:124 ccm fir
a=rtcp-fb:124 nack
a=rtcp-fb:124 nack pli
a=fmtp:124 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=4d001f
a=rtpmap:120 rtx/90000
a=fmtp:120 apt=124
a=rtpmap:39 H264/90000
a=rtcp-fb:39 goog-remb
a=rtcp-fb:39 transport-cc
a=rtcp-fb:39 ccm fir
a=rtcp-fb:39 nack
a=rtcp-fb:39 nack pli
a=fmtp:39 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=4d001f
a=rtpmap:40 rtx/90000
a=fmtp:40 apt=39
a=rtpmap:41 H264/90000
a=rtcp-fb:41 goog-remb
a=rtcp-fb:41 transport-cc
a=rtcp-fb:41 ccm fir
a=rtcp-fb:41 nack
a=rtcp-fb:41 nack pli
a=fmtp:41 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=f4001f
a=rtpmap:42 rtx/90000
a=fmtp:42 apt=41
a=rtpmap:43 H264/90000
a=rtcp-fb:43 goog-remb
a=rtcp-fb:43 transport-cc
a=rtcp-fb:43 ccm fir
a=rtcp-fb:43 nack
a=rtcp-fb:43 nack pli
a=fmtp:43 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=f4001f
a=rtpmap:44 rtx/90000
a=fmtp:44 apt=43
a=rtpmap:45 AV1/90000
a=rtcp-fb:45 goog-remb
a=rtcp-fb:45 transport-cc
a=rtcp-fb:45 ccm fir
a=rtcp-fb:45 nack
a=rtcp-fb:45 nack pli
a=rtpmap:46 rtx/90000
a=fmtp:46 apt=45
a=rtpmap:47 AV1/90000
a=rtcp-fb:47 goog-remb
a=rtcp-fb:47 transport-cc
a=rtcp-fb:47 ccm fir
a=rtcp-fb:47 nack
a=rtcp-fb:47 nack pli
a=fmtp:47 profile=1
a=rtpmap:48 rtx/90000
a=fmtp:48 apt=47
a=rtpmap:123 H264/90000
a=rtcp-fb:123 goog-remb
a=rtcp-fb:123 transport-cc
a=rtcp-fb:123 ccm fir
a=rtcp-fb:123 nack
a=rtcp-fb:123 nack pli
a=fmtp:123 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=64001f
a=rtpmap:119 rtx/90000
a=fmtp:119 apt=123
a=rtpmap:114 red/90000
a=rtpmap:115 rtx/90000
a=fmtp:115 apt=114
a=rtpmap:116 ulpfec/90000
a=rtpmap:49 flexfec-03/90000
a=rtcp-fb:49 goog-remb
a=rtcp-fb:49 transport-cc
a=fmtp:49 repair-window=10000000
m=audio 9 UDP/TLS/RTP/SAVPF 111 63 103 104 9 0 8 106 105 13 110 112 113 126
c=IN IP4 0.0.0.0
a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:gdMS
a=ice-pwd:1yWra8IAyw4YqqXE6JLbrfDI
a=ice-options:trickle
a=fingerprint:sha-256 07:95:5D:7A:A8:FD:53:D3:B9:8B:CC:8C:29:54:08:89:83:63:5E:CE:A6:DE:01:EF:5F:0A:06:96:ED:E1:8A:9F
a=setup:actpass
a=mid:2
a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level
a=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=extmap:3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01
a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid
a=sendonly
a=msid:fbiSmx6n3xm4yA1FQtKj8zH9yGBv7vmGoVai b2bbec5a-1452-4840-9171-30a10d300741
a=rtcp-mux
a=rtpmap:111 opus/48000/2
a=rtcp-fb:111 transport-cc
a=fmtp:111 minptime=10;useinbandfec=1
a=rtpmap:63 red/48000/2
a=fmtp:63 111/111
a=rtpmap:103 ISAC/16000
a=rtpmap:104 ISAC/32000
a=rtpmap:9 G722/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:106 CN/32000
a=rtpmap:105 CN/16000
a=rtpmap:13 CN/8000
a=rtpmap:110 telephone-event/48000
a=rtpmap:112 telephone-event/32000
a=rtpmap:113 telephone-event/16000
a=rtpmap:126 telephone-event/8000
a=ssrc:3856090643 cname:L8DTZMOJip3IXAHs
a=ssrc:3856090643 msid:fbiSmx6n3xm4yA1FQtKj8zH9yGBv7vmGoVai b2bbec5a-1452-4840-9171-30a10d300741
m=video 9 UDP/TLS/RTP/SAVPF 96 97 102 122 127 121 125 107 108 109 124 120 39 40 45 46 98 99 100 101 123 119 114 115 116
c=IN IP4 0.0.0.0
a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:gdMS
a=ice-pwd:1yWra8IAyw4YqqXE6JLbrfDI
a=ice-options:trickle
a=fingerprint:sha-256 07:95:5D:7A:A8:FD:53:D3:B9:8B:CC:8C:29:54:08:89:83:63:5E:CE:A6:DE:01:EF:5F:0A:06:96:ED:E1:8A:9F
a=setup:actpass
a=mid:3
a=extmap:14 urn:ietf:params:rtp-hdrext:toffset
a=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=extmap:13 urn:3gpp:video-orientation
a=extmap:3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01
a=extmap:5 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay
a=extmap:6 http://www.webrtc.org/experiments/rtp-hdrext/video-content-type
a=extmap:7 http://www.webrtc.org/experiments/rtp-hdrext/video-timing
a=extmap:8 http://www.webrtc.org/experiments/rtp-hdrext/color-space
a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid
a=extmap:10 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id
a=extmap:11 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id
a=sendonly
a=msid:fbiSmx6n3xm4yA1FQtKj8zH9yGBv7vmGoVai 1327213e-5d74-461f-be50-ed78ede6a453
a=rtcp-mux
a=rtcp-rsize
a=rtpmap:96 VP8/90000
a=rtcp-fb:96 goog-remb
a=rtcp-fb:96 transport-cc
a=rtcp-fb:96 ccm fir
a=rtcp-fb:96 nack
a=rtcp-fb:96 nack pli
a=rtpmap:97 rtx/90000
a=fmtp:97 apt=96
a=rtpmap:102 H264/90000
a=rtcp-fb:102 goog-remb
a=rtcp-fb:102 transport-cc
a=rtcp-fb:102 ccm fir
a=rtcp-fb:102 nack
a=rtcp-fb:102 nack pli
a=fmtp:102 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f
a=rtpmap:122 rtx/90000
a=fmtp:122 apt=102
a=rtpmap:127 H264/90000
a=rtcp-fb:127 goog-remb
a=rtcp-fb:127 transport-cc
a=rtcp-fb:127 ccm fir
a=rtcp-fb:127 nack
a=rtcp-fb:127 nack pli
a=fmtp:127 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42001f
a=rtpmap:121 rtx/90000
a=fmtp:121 apt=127
a=rtpmap:125 H264/90000
a=rtcp-fb:125 goog-remb
a=rtcp-fb:125 transport-cc
a=rtcp-fb:125 ccm fir
a=rtcp-fb:125 nack
a=rtcp-fb:125 nack pli
a=fmtp:125 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f
a=rtpmap:107 rtx/90000
a=fmtp:107 apt=125
a=rtpmap:108 H264/90000
a=rtcp-fb:108 goog-remb
a=rtcp-fb:108 transport-cc
a=rtcp-fb:108 ccm fir
a=rtcp-fb:108 nack
a=rtcp-fb:108 nack pli
a=fmtp:108 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42e01f
a=rtpmap:109 rtx/90000
a=fmtp:109 apt=108
a=rtpmap:124 H264/90000
a=rtcp-fb:124 goog-remb
a=rtcp-fb:124 transport-cc
a=rtcp-fb:124 ccm fir
a=rtcp-fb:124 nack
a=rtcp-fb:124 nack pli
a=fmtp:124 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=4d001f
a=rtpmap:120 rtx/90000
a=fmtp:120 apt=124
a=rtpmap:39 H264/90000
a=rtcp-fb:39 goog-remb
a=rtcp-fb:39 transport-cc
a=rtcp-fb:39 ccm fir
a=rtcp-fb:39 nack
a=rtcp-fb:39 nack pli
a=fmtp:39 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=4d001f
a=rtpmap:40 rtx/90000
a=fmtp:40 apt=39
a=rtpmap:45 AV1/90000
a=rtcp-fb:45 goog-remb
a=rtcp-fb:45 transport-cc
a=rtcp-fb:45 ccm fir
a=rtcp-fb:45 nack
a=rtcp-fb:45 nack pli
a=rtpmap:46 rtx/90000
a=fmtp:46 apt=45
a=rtpmap:98 VP9/90000
a=rtcp-fb:98 goog-remb
a=rtcp-fb:98 transport-cc
a=rtcp-fb:98 ccm fir
a=rtcp-fb:98 nack
a=rtcp-fb:98 nack pli
a=fmtp:98 profile-id=0
a=rtpmap:99 rtx/90000
a=fmtp:99 apt=98
a=rtpmap:100 VP9/90000
a=rtcp-fb:100 goog-remb
a=rtcp-fb:100 transport-cc
a=rtcp-fb:100 ccm fir
a=rtcp-fb:100 nack
a=rtcp-fb:100 nack pli
a=fmtp:100 profile-id=2
a=rtpmap:101 rtx/90000
a=fmtp:101 apt=100
a=rtpmap:123 H264/90000
a=rtcp-fb:123 goog-remb
a=rtcp-fb:123 transport-cc
a=rtcp-fb:123 ccm fir
a=rtcp-fb:123 nack
a=rtcp-fb:123 nack pli
a=fmtp:123 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=64001f
a=rtpmap:119 rtx/90000
a=fmtp:119 apt=123
a=rtpmap:114 red/90000
a=rtpmap:115 rtx/90000
a=fmtp:115 apt=114
a=rtpmap:116 ulpfec/90000
a=ssrc-group:FID 3686128283 1675289484
a=ssrc:3686128283 cname:L8DTZMOJip3IXAHs
a=ssrc:3686128283 msid:fbiSmx6n3xm4yA1FQtKj8zH9yGBv7vmGoVai 1327213e-5d74-461f-be50-ed78ede6a453
a=ssrc:1675289484 cname:L8DTZMOJip3IXAHs
a=ssrc:1675289484 msid:fbiSmx6n3xm4yA1FQtKj8zH9yGBv7vmGoVai 1327213e-5d74-461f-be50-ed78ede6a453
"
}
}
{
"id":"eceda0bafe3e4a1eab1a75056ede3cd8",
"signaling":{
"type":"candidate",
"candidate":{
"candidate":"a=candidate:2722325311 1 udp 2122265343 fc00:2::e19b:dc32:443d:dd84 55478 typ host generation 0 ufrag gdMS network-id 2",
"sdpMid":"0",
"sdpMLineIndex":0
}
}
}
async publish(stream, options, videoCodecs) {
...
return this._signaling.sendSignalingMessage('publish', {
media: {tracks: trackOptions},
attributes: stream.attributes,
transport: {id: this._id, type: 'webrtc'},
}).catch((e) => {
// Send SDP even when failed to get Answer.
this._signaling.sendSignalingMessage('soac', {
id: this._id,
signaling: localDesc,
});
throw e;
});
}).then((data) => {
...
this._signaling.sendSignalingMessage('soac', {
id: this._id,
signaling: localDesc,
});
}).catch((e) => {
...
}
src/samples/conference/public/scripts/index.js conference.publish(localStream, ... =>
src/sdk/conference/client.js this.publish =>
src/sdk/conference/channel.js async publish =>
src/sdk/conference/channel.js _signaling.sendSignalingMessage('soac', =>
socket.on('soac', function(SOAC, callback) {
if(!that.inRoom){
return safeCall(callback, 'error', 'Illegal request');
}
return validateSOAC(SOAC)
.then((soac) => {
return portal.onSessionSignaling(clientId, soac.id, soac.signaling);
}).then((result) => {
safeCall(callback, 'ok');
}).catch(onError('soac', callback));
});
};
source/portal/v11Client.js socket.on('soac', function(SOAC, callback) =>
source/portal/portal.js that.onSessionSignaling = function(participantId, ... =>
source/portal/rpcRequest.js that.onSessionSignaling = function(controller, sessionId, ... =>
source/agent/conference/conference.js that.onSessionSignaling = function(sessionId, signaling, ... =>
source/agent/conference/rtcController.js onClientTransportSignaling(transportId, signaling) =>
source/agent/conference/rpcRequest.js that.onTransportSignaling = function(accessNode, ... =>
source/agent/webrtc/index.js that.onTransportSignaling = function (connectionId, msg, callback) =>
source/agent/webrtc/wrtcConnection.js that.onSignalling = function (msg, operationId) =>
that.onSignalling = function (msg, operationId) {
var processSignalling = function () {
if (msg.type === 'offer') {
log.debug('on offer:', msg.sdp);
processOffer(msg.sdp);
} else if (msg.type === 'candidate') {
wrtc.addRemoteCandidate(msg.candidate);
} else if (msg.type === 'removed-candidates') {
wrtc.removeRemoteCandidates(msg.candidates);
}
};
if (wrtc) {
processSignalling();
} else {
// should not reach here
log.error('wrtc is not ready');
}
};
[
{
"id":"62b95bd27ff8054480cbb73a",
"status":"soac",
"data":{
"type":"answer",
"sdp":"v=0\ro=- 7416128173695703170 3 IN IP4 127.0.0.1s=\r-t=0 0...省略"
}
}
]
{
"media":{
"tracks":[
{
"type":"audio",
"mid":"0",
"from":"62b95bd27ff8054480cbb73a-common"
},
{
"type":"video",
"mid":"1",
"from":"62b95bd27ff8054480cbb73a-common"
}
]
},
"transport":{
"type":"webrtc"
}
}
{
"id":"55aa9331e2b741338639d282f0bffa0d"
}
window.onload = function() {
var simulcast = getParameterByName('simulcast') || false;
var shareScreen = getParameterByName('screen') || false;
myRoom = getParameterByName('room');
var isHttps = (location.protocol === 'https:');
var mediaUrl = getParameterByName('url');
var isPublish = getParameterByName('publish');
createToken(myRoom, 'user', 'presenter', function(response) {
var token = response;
conference.join(token).then(resp => {
...
var streams = resp.remoteStreams;
for (const stream of streams) {
if(!subscribeForward){
if (stream.source.audio === 'mixed' || stream.source.video ===
'mixed') {
subscribeAndRenderVideo(stream);
}
} else if (stream.source.audio !== 'mixed') {
subscribeAndRenderVideo(stream);
}
}
console.log('Streams in conference:', streams.length);
var participants = resp.participants;
console.log('Participants in conference: ' + participants.length);
});
}, serverUrlBase);
};
src/samples/conference/public/scripts/index.js subscribeAndRenderVideo(stream) =>
src/samples/conference/public/scripts/index.js conference.subscribe(stream) =>
src/sdk/conference/client.js this.subscribe =>
src/sdk/conference/channel.js async subscribe(stream, options)
src/sdk/conference/channel.js _signaling.sendSignalingMessage('subscribe', =>
socket.on('subscribe', function(subReq, callback) {
if(!that.inRoom){
return safeCall(callback, 'error', 'Illegal request');
}
var subscription_id = Math.round(Math.random() * 1000000000000000000) + '';
return validateSubReq(subReq)
.then((req) => {
req.type = 'webrtc';//FIXME: For backend compatibility with v3.4 clients.
return portal.subscribe(clientId, subscription_id, req);
}).then((result) => {
safeCall(callback, 'ok', {id: subscription_id});
}).catch(onError('subscribe', callback));
});
source/portal/v11Client.js socket.on('subscribe', function(subReq, =>
source/portal/portal.js that.subscribe = function(participantId, ... =>
source/portal/rpcRequest.js that.publish = function(controller, participantId, streamId, Options) =>
source/agent/conference/conference.js that.subscribe = function(controller, participantId, ... =>
source/agent/conference/rtcController.js initiate(ownerId, sessionId, direction, origin, ... =>
source/agent/conference/rpcRequest.js that.initiate = function(accessNode, sessionId, ... => //向WebRTC Agent的node发起publish RPC
source/agent/conference/rpcRequest.js that.initiate = function(accessNode, sessionId, ... => //向WebRTC Agent的node发起publish RPC
source/agent/webrtc/index.js that.subscribe = function (operationId, connectionType, ... =>
source/agent/webrtc/index.js createWebRTCConnection = function (transportId, ... => //创建WrtcConnection(`webrtc/wrtcConnection.js`),它负责和C++ 代码进行交互
/*
* Given a WebRtcConnection waits for the state CANDIDATES_GATHERED for set remote SDP.
*/
var initWebRtcConnection = function (wrtc) {
wrtc.on('status_event', (evt, status) => {
if (evt.type === 'answer') {
processAnswer(evt.sdp);
const message = localSdp.toString();
log.debug('Answer SDP', message);
on_status({type: 'answer', sdp: message});
} else if (evt.type === 'candidate') {
let message = evt.candidate;
networkInterfaces.forEach((i) => {
if (i.ip_address && i.replaced_ip_address) {
message = message.replace(new RegExp(i.ip_address, 'g'), i.replaced_ip_address);
}
});
on_status({type: 'candidate', candidate: message});
} else if (evt.type === 'failed') {
log.warn('ICE failed, ', status, wrtc.id);
on_status({type: 'failed', reason: 'Ice procedure failed.'});
} else if (evt.type === 'ready') {
log.debug('Connection ready, ', wrtc.wrtcId);
on_status({
type: 'ready'
});
}
});
wrtc.init(wrtcId);
};
{
"action":"join",
"data":{
"id":"1d6pEzr67tkUhEJeAAAn",
"user":"user",
"role":"presenter"
}
}
source/portal/socketIOServer.js socket.on('login', function(login_info, ... =>
source/portal/v11Client.js that.join = (token) =>
source/portal/portal.js that.join = function(participantId, token) =>
source/portal/rpcRequest.js that.join = function(controller, roomId, participant) =>
source/agent/conference/conference.js that.join = function(roomId, participantInfo, callback) =>
source/agent/conference/conference.js initRoom = function(roomId, origin) => //保存房间信息,创建roomController、accessController
source/agent/conference/conference.js addParticipant = function(participantInfo, permission) => //保存用户信息
{
"id":"55aa9331e2b741338639d282f0bffa0d",
"status":"add",
"data":{
"id":"55aa9331e2b741338639d282f0bffa0d",
"type":"forward",
"media":{
},
"info":{
"owner":"kYmJHa8XsioNXhKUAAAJ",
"type":"webrtc",
"inViews":[
]
}
}
}
{
"action":"leave",
"data":"I-Fv7fQ8Qe9_9qa2AAAG"
}
{
"action":"leave",
"data":"kYmJHa8XsioNXhKUAAAJ"
}
/**
* @function leave
* @memberOf Owt.Conference.ConferenceClient
* @instance
* @desc Leave a conference.
* @return {Promise} Returned promise will be resolved with undefined once the connection is disconnected.
*/
this.leave = function() {
return signaling.disconnect().then(() => {
clean();
signalingState = SignalingState.READY;
});
};
/**
* @function disconnect
* @instance
* @desc Disconnect from a portal.
* @memberof Oms.Conference.SioSignaling
* @return {Promise
disconnect() {
if (!this._socket || this._socket.disconnected) {
return Promise.reject(new ConferenceError(
'Portal is not connected.'));
}
return new Promise((resolve, reject) => {
this._socket.emit('logout', (status, data) => {
// Maximize the reconnect times to disable reconnection.
this._reconnectTimes = reconnectionAttempts;
this._socket.disconnect();
handleResponse(status, data, resolve, reject);
});
});
}
src/samples/conference/public/scripts/index.js window.onbeforeunload = function(... =>
src/sdk/conference/client.js this.leave = function() =>
src/sdk/conference/signaling.js disconnect()
socket.on('logout', function(callback){
reconnection.enabled = false;
state = 'initialized';
if (client_id) {
forceClientLeave();
safeCall(callback, okWord());
} else {
return safeCall(callback, 'error', 'Illegal request');
}
});
source/portal/socketIOServer.js socket.on('logout', function(callback) =>
source/portal/socketIOServer.js forceClientLeave = () =>
source/portal/v11Client.js that.leave = () =>
source/portal/portal.js that.leave = function(participantId) =>
source/portal/rpcRequest.js that.leave = function(controller, participantId) =>
source/agent/conference/conference.js that.leave = function(participantId, callback) =>
[
"ok",
"<新的reconnectionTicket>"
]
[
{
"id": "XHDK7_8QXJjazcwuAAAx",
"user": "user",
"role": "presenter",
"permission": {
"publish": {
"video": true,
"audio": true
},
"subscribe": {
"video": true,
"audio": true
}
}
},
{
"id": "nOqTKNJrCgHEUAlaAAAz",
"user": "user",
"role": "presenter",
"permission": {
"publish": {
"video": true,
"audio": true
},
"subscribe": {
"video": true,
"audio": true
}
}
}
]
[
{
"id":"62b95bd27ff8054480cbb73a-common",
"type":"mixed",
"media":{
"audio":{
"status":"active",
"format":{
"codec":"opus",
"sampleRate":48000,
"channelNum":2
},
"optional":{
"format":[
{
"codec":"isac",
"sampleRate":16000
},
{
"codec":"isac",
"sampleRate":32000
},
{
"codec":"g722",
"sampleRate":16000,
"channelNum":1
},
{
"codec":"pcma"
},
{
"codec":"pcmu"
},
{
"codec":"aac",
"sampleRate":48000,
"channelNum":2
},
{
"codec":"ac3"
},
{
"codec":"nellymoser"
},
{
"codec":"ilbc"
}
]
}
},
"video":{
"status":"active",
"optional":{
"format":[
{
"codec":"h264",
"profile":"CB"
},
{
"codec":"h264",
"profile":"B"
},
{
"codec":"vp9"
}
],
"parameters":{
"resolution":[
{
"width":480,
"height":360
},
{
"width":426,
"height":320
},
{
"width":320,
"height":240
},
{
"width":212,
"height":160
},
{
"width":160,
"height":120
},
{
"width":352,
"height":288
}
],
"bitrate":[
"x0.8",
"x0.6",
"x0.4",
"x0.2"
],
"framerate":[
6,
12,
15
],
"keyFrameInterval":[
100,
30,
5,
2,
1
]
}
},
"format":{
"codec":"vp8"
},
"parameters":{
"resolution":{
"width":640,
"height":480
},
"framerate":24,
"keyFrameInterval":100
}
}
},
"data":null,
"info":{
"label":"common",
"activeInput":"961f75a4fac8435f9a54506d25150784",
"layout":[
{
"stream":"961f75a4fac8435f9a54506d25150784",
"region":{
"id":"1",
"shape":"rectangle",
"area":{
"left":"0/1",
"top":"0/1",
"width":"1/1",
"height":"1/1"
}
}
}
],
"origin":{
"isp":"isp",
"region":"region"
}
}
},
{
"id":"961f75a4fac8435f9a54506d25150784",
"type":"forward",
"media":{
"audio":{
"status":"active",
"source":"mic",
"format":{
"codec":"opus",
"sampleRate":48000,
"channelNum":2
},
"optional":{
"format":[
{
"codec":"isac",
"sampleRate":16000
},
{
"codec":"isac",
"sampleRate":32000
},
{
"codec":"g722",
"sampleRate":16000,
"channelNum":1
},
{
"codec":"pcma"
},
{
"codec":"pcmu"
},
{
"codec":"aac",
"sampleRate":48000,
"channelNum":2
},
{
"codec":"ac3"
},
{
"codec":"nellymoser"
},
{
"codec":"ilbc"
}
]
}
},
"video":{
"status":"active",
"source":"camera",
"optional":{
"format":[
{
"codec":"h264",
"profile":"CB"
},
{
"codec":"h264",
"profile":"B"
},
{
"codec":"vp9"
}
],
"parameters":{
"resolution":[
{
"width":480,
"height":360
},
{
"width":426,
"height":320
},
{
"width":320,
"height":240
},
{
"width":212,
"height":160
},
{
"width":160,
"height":120
},
{
"width":352,
"height":288
}
],
"bitrate":[
"x0.8",
"x0.6",
"x0.4",
"x0.2"
],
"framerate":[
6,
12,
15,
24
],
"keyFrameInterval":[
100,
30,
5,
2,
1
]
}
},
"format":{
"codec":"vp8"
},
"parameters":{
"resolution":{
"width":640,
"height":480
}
}
}
},
"info":{
"owner":"XHDK7_8QXJjazcwuAAAx",
"type":"webrtc",
"inViews":[
"common"
]
}
}
]