一,对象创建流程
connection.js 封装并调用了rtcConn.node;
wrtcConnection.js 封装并调用了rtcFrame.node;
oem@svr1804:~/git/owt-server/dist-debug$ ll -h webrtc_agent/rtcFrame/build/Release/rtcFrame.node
-rwxrwxr-x 1 oem oem 7.7M 5月 14 22:57 webrtc_agent/rtcFrame/build/Release/rtcFrame.node*
oem@svr1804:~/git/owt-server/dist-debug$ ll -h webrtc_agent/rtcConn/build/Release/rtcConn.node
-rwxrwxr-x 1 oem oem 25M 5月 14 22:57 webrtc_agent/rtcConn/build/Release/rtcConn.node*
/home/oem/git/owt-server/dist-debug/webrtc_agent/webrtc/index.js
var addon = require('../rtcConn/build/Release/rtcConn.node');
(只调用了addon.ThreadPool)
/home/oem/git/owt-server/dist-debug/webrtc_agent/webrtc/connection.js
const addon = require('../rtcConn/build/Release/rtcConn');
_createWrtc() {
var wrtc = new addon.WebRtcConnection(
this.threadPool, this.ioThreadPool, this.id,
global.config.webrtc.stunserver,
global.config.webrtc.stunport,
global.config.webrtc.minport,
global.config.webrtc.maxport,
false, //this.trickleIce,
this._getMediaConfiguration(this.mediaConfiguration),
'', //networkinterface
this.ipAddresses
);
_createMediaStream(id, options = {}, isPublisher = true) {
log.debug(`message: _createMediaStream, connectionId: ${this.id}, ` +
`mediaStreamId: ${id}, isPublisher: ${isPublisher}`);
const mediaStream = new addon.MediaStream(this.threadPool, this.wrtc, id,
options.label, this._getMediaConfiguration(this.mediaConfiguration), isPublisher);
/home/oem/git/owt-server/dist-debug/webrtc_agent/webrtc/wrtcConnection.js
const {
AudioFrameConstructor,
AudioFramePacketizer,
VideoFrameConstructor,
VideoFramePacketizer,
CallBase,
} = require('../rtcFrame/build/Release/rtcFrame.node');
收到that.publish()调用,创建WebRTC对象
CALL STACK(从下往上调用):
Connection (/home/oem/git/owt-server/dist-debug/webrtc_agent/webrtc/connection.js:69)
class Connection extends EventEmitter {
constructor (id, threadPool, ioThreadPool, options = {}) {
super();
log.info(`message: Connection, id: ${id}`);
this.wrtc = this._createWrtc();
}
_createWrtc() {
var wrtc = new addon.WebRtcConnection(
module.exports (/home/oem/git/owt-server/dist-debug/webrtc_agent/webrtc/wrtcConnection.js:635)
wrtc = new Connection(wrtcId, threadPool, ioThreadPool, { ipAddresses });
wrtc.callBase = new CallBase();
// wrtc.addMediaStream(wrtcId, {label: ''}, direction === 'in');
initWebRtcConnection(wrtc);
createWebRTCConnection (/home/oem/git/owt-server/dist-debug/webrtc_agent/webrtc/index.js:137)
var createWebRTCConnection = function (transportId, controller, owner) {
var connection = new WrtcConnection({
connectionId: transportId,
threadPool: threadPoo