提交 a7bbfb25 authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

Don't require a RTCSessionDescription in webrtc methods (but a RTCSessionDescription dictionary)

上级 044b882c
......@@ -16,8 +16,6 @@ const SIGNALING_STATE =
};
const NEGOTIATION_NEEDED_DELAY = 1000;
let fakePort = 10000;
class RTCPeerConnection extends EventEmitter
{
/**
......@@ -202,8 +200,8 @@ class RTCPeerConnection extends EventEmitter
let self = this;
let newSignalingState;
if (!(desc instanceof RTCSessionDescription))
return Promise.reject(new TypeError('desc must be a RTCSessionDescription instance'));
if (!RTCSessionDescription.isDescription(desc))
return Promise.reject(new TypeError('invalid RTCSessionDescription'));
if (this._busy)
return Promise.reject(new InvalidStateError('busy'));
......@@ -646,8 +644,8 @@ class RTCPeerConnection extends EventEmitter
let newSignalingState;
if (!(desc instanceof RTCSessionDescription))
return Promise.reject(new TypeError('desc must be a RTCSessionDescription instance'));
if (!RTCSessionDescription.isDescription(desc))
return Promise.reject(new TypeError('invalid RTCSessionDescription'));
switch (desc.type)
{
......@@ -935,7 +933,7 @@ class RTCPeerConnection extends EventEmitter
netType : 'IN',
sessionId : this._sdpFields.id,
sessionVersion : this._sdpFields.version,
username : 'mediasoup-webrtc'
username : 'mediasoup'
};
obj.name = '-';
obj.timing = { start: 0, stop: 0 };
......@@ -986,9 +984,7 @@ class RTCPeerConnection extends EventEmitter
// m= line.
objMedia.type = rtpHandler.kind;
objMedia.port = fakePort++; // Fuck you SDP
if (fakePort > 60000)
fakePort = 10000;
objMedia.port = 7;
objMedia.protocol = 'RTP/SAVPF';
// If closed or not available sender, set port 0.
......@@ -996,7 +992,7 @@ class RTCPeerConnection extends EventEmitter
objMedia.port = 0;
// c= line.
objMedia.connection = { ip: '0.0.0.0', version: 4 }; // Fuck you SDP
objMedia.connection = { ip: '127.0.0.1', version: 4 };
// mid.
objMedia.mid = rtpHandler.rtpParameters.muxId;
......@@ -1267,7 +1263,7 @@ class RTCPeerConnection extends EventEmitter
netType : 'IN',
sessionId : this._sdpFields.id,
sessionVersion : this._sdpFields.version,
username : 'mediasoup-webrtc'
username : 'mediasoup'
};
obj.name = '-';
obj.timing = { start: 0, stop: 0 };
......@@ -1384,13 +1380,11 @@ class RTCPeerConnection extends EventEmitter
// m= line.
objMedia.type = kind;
objMedia.port = fakePort++; // Fuck you SDP
if (fakePort > 60000)
fakePort = 10000;
objMedia.port = 7;
objMedia.protocol = 'RTP/SAVPF';
// c= line.
objMedia.connection = { ip: '0.0.0.0', version: 4 }; // Fuck you SDP
objMedia.connection = { ip: '127.0.0.1', version: 4 };
// mid.
objMedia.mid = mid;
......
......@@ -2,6 +2,15 @@
class RTCSessionDescription
{
static isDescription(obj)
{
return (
obj &&
typeof obj.type === 'string' &&
typeof obj.sdp === 'string'
);
}
/**
* RTCSessionDescription constructor.
* @param {object} [options]
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论