Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
0f23804e
提交
0f23804e
authored
1月 25, 2017
作者:
Iñaki Baz Castillo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Working #54
上级
04ec0b82
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
366 行增加
和
39 行删除
+366
-39
RtpReceiver.js
lib/RtpReceiver.js
+0
-10
RtpSender.js
lib/RtpSender.js
+0
-10
RTCDictionaries.js
lib/webrtc/RTCDictionaries.js
+23
-0
RTCPeerConnectionPlanB.js
lib/webrtc/RTCPeerConnection/RTCPeerConnectionPlanB.js
+0
-0
RTCPeerConnectionUnifiedPlan.js
lib/webrtc/RTCPeerConnection/RTCPeerConnectionUnifiedPlan.js
+27
-0
index.js
lib/webrtc/RTCPeerConnection/index.js
+30
-0
RTCRtpTransceiver.js
lib/webrtc/RTCRtpTransceiver.js
+207
-0
RTCSessionDescription.js
lib/webrtc/RTCSessionDescription.js
+79
-19
没有找到文件。
lib/RtpReceiver.js
浏览文件 @
0f23804e
...
@@ -245,16 +245,6 @@ class RtpReceiver extends EventEmitter
...
@@ -245,16 +245,6 @@ class RtpReceiver extends EventEmitter
});
});
}
}
isRtpReceiver
()
{
return
true
;
}
isRtpSender
()
{
return
false
;
}
/**
/**
* Start receiving media.
* Start receiving media.
*
*
...
...
lib/RtpSender.js
浏览文件 @
0f23804e
...
@@ -137,16 +137,6 @@ class RtpSender extends EventEmitter
...
@@ -137,16 +137,6 @@ class RtpSender extends EventEmitter
});
});
}
}
isRtpSender
()
{
return
true
;
}
isRtpReceiver
()
{
return
false
;
}
/**
/**
* Assign Transport.
* Assign Transport.
*
*
...
...
lib/webrtc/RTCDictionaries.js
0 → 100644
浏览文件 @
0f23804e
'use strict'
;
module
.
exports
=
{
RTCSdpType
:
{
offer
:
'offer'
,
answer
:
'answer'
},
RTCSignalingState
:
{
stable
:
'stable'
,
haveLocalOffer
:
'have-local-offer'
,
haveRemoteOffer
:
'have-remote-offer'
},
RTCRtpTransceiverDirection
:
{
sendrecv
:
'sendrecv'
,
sendonly
:
'sendonly'
,
recvonly
:
'recvonly'
,
inactive
:
'inactive'
}
};
lib/webrtc/RTCPeerConnection.js
→
lib/webrtc/RTCPeerConnection
/RTCPeerConnectionPlanB
.js
浏览文件 @
0f23804e
差异被折叠。
点击展开。
lib/webrtc/RTCPeerConnection/RTCPeerConnectionUnifiedPlan.js
0 → 100644
浏览文件 @
0f23804e
'use strict'
;
const
EventEmitter
=
require
(
'events'
).
EventEmitter
;
// const sdpTransform = require('sdp-transform');
// const randomString = require('random-string');
const
logger
=
require
(
'../../logger'
);
// const extra = require('../../extra');
// const InvalidStateError = require('../../errors').InvalidStateError;
// const RTCDictionaries = require('../RTCDictionaries');
// const RTCSessionDescription = require('../RTCSessionDescription');
// const RTCRtpTransceiver = require('../RTCRtpTransceiver');
// const NEGOTIATION_NEEDED_DELAY = 1000;
class
RTCPeerConnectionUnifiedPlan
extends
EventEmitter
{
constructor
(
room
,
peerName
,
options
)
{
super
();
this
.
setMaxListeners
(
Infinity
);
this
.
_logger
=
logger
(
`webrtc:RTCPeerConnectionUnifiedPlan:
${
peerName
}
`
);
this
.
_logger
.
debug
(
'constructor() [options:%o]'
,
options
);
}
}
module
.
exports
=
RTCPeerConnectionUnifiedPlan
;
lib/webrtc/RTCPeerConnection/index.js
0 → 100644
浏览文件 @
0f23804e
'use strict'
;
const
RTCPeerConnectionUnifiedPlan
=
require
(
'./RTCPeerConnectionUnifiedPlan'
);
const
RTCPeerConnectionPlanB
=
require
(
'./RTCPeerConnectionPlanB'
);
class
RTCPeerConnection
{
/**
* RTCPeerConnection constructor.
* @param {Room} room
* @param {string} peerName
* @param {object} [options]
* @param {object} [options.transportOptions] - Options for Transport.
* @param {boolean} [options.usePlanB] - Use Plan-B rather than Unified-Plan.
* @param {object} [options.bandwidth]
* @param {number} [options.bandwidth.audio] - Maximum bandwidth for audio streams.
* @param {number} [options.bandwidth.video] - Maximum bandwidth for video streams.
*/
constructor
(
room
,
peerName
,
options
)
{
options
=
options
||
{};
if
(
!
options
.
usePlanB
)
return
new
RTCPeerConnectionUnifiedPlan
(
room
,
peerName
,
options
);
else
return
new
RTCPeerConnectionPlanB
(
room
,
peerName
,
options
);
}
}
module
.
exports
=
RTCPeerConnection
;
lib/webrtc/RTCRtpTransceiver.js
0 → 100644
浏览文件 @
0f23804e
'use strict'
;
const
RTCDictionaries
=
require
(
'./RTCDictionaries'
);
class
RTCRtpTransceiver
{
constructor
(
kind
)
{
// kind attribute.
this
.
_kind
=
kind
;
// mid attribute.
this
.
_mid
=
null
;
// RtpReceiver instance.
this
.
_receiver
=
null
;
// RtpSender instance.
this
.
_sender
=
null
;
// stopped attribute.
this
.
_stopped
=
false
;
// direction attribute.
this
.
_direction
=
RTCDictionaries
.
RTCRtpTransceiverDirection
.
inactive
;
// Bind events.
this
.
_onReceiverClose
=
this
.
_onReceiverClose
.
bind
(
this
);
this
.
_onSenderClose
=
this
.
_onSenderClose
.
bind
(
this
);
// TODO: Add more.
}
get
kind
()
{
return
this
.
_kind
;
}
get
mid
()
{
return
this
.
_mid
;
}
set
mid
(
mid
)
{
if
(
this
.
_stopped
)
return
;
this
.
_mid
=
mid
;
// TODO: pass it to the receiver and sender.
}
get
receiver
()
{
return
this
.
_receiver
;
}
set
receiver
(
receiver
)
{
if
(
this
.
_stopped
)
return
;
if
(
this
.
_receiver
)
this
.
_unhandleReceiverEvents
(
this
.
_receiver
);
if
(
receiver
)
{
this
.
_receiver
=
receiver
;
this
.
_handleReceiverEvents
(
receiver
);
// Update direction.
switch
(
this
.
_direction
)
{
case
RTCDictionaries
.
RTCRtpTransceiverDirection
.
inactive
:
this
.
_direction
=
RTCDictionaries
.
RTCRtpTransceiverDirection
.
recvonly
;
break
;
case
RTCDictionaries
.
RTCRtpTransceiverDirection
.
sendonly
:
this
.
_direction
=
RTCDictionaries
.
RTCRtpTransceiverDirection
.
sendrecv
;
break
;
}
// TODO: set mid?
}
else
{
this
.
_receiver
=
null
;
// Update direction.
switch
(
this
.
_direction
)
{
case
RTCDictionaries
.
RTCRtpTransceiverDirection
.
recvonly
:
this
.
_direction
=
RTCDictionaries
.
RTCRtpTransceiverDirection
.
inactive
;
break
;
case
RTCDictionaries
.
RTCRtpTransceiverDirection
.
sendrecv
:
this
.
_direction
=
RTCDictionaries
.
RTCRtpTransceiverDirection
.
sendonly
;
break
;
}
}
}
get
sender
()
{
return
this
.
_sender
;
}
set
sender
(
sender
)
{
if
(
this
.
_stopped
)
return
;
if
(
this
.
_sender
)
this
.
_unhandleSenderEvents
(
this
.
_sender
);
if
(
sender
)
{
this
.
_sender
=
sender
;
this
.
_handleSenderEvents
(
sender
);
// Update direction.
switch
(
this
.
_direction
)
{
case
RTCDictionaries
.
RTCRtpTransceiverDirection
.
inactive
:
this
.
_direction
=
RTCDictionaries
.
RTCRtpTransceiverDirection
.
sendonly
;
break
;
case
RTCDictionaries
.
RTCRtpTransceiverDirection
.
recvonly
:
this
.
_direction
=
RTCDictionaries
.
RTCRtpTransceiverDirection
.
sendrecv
;
break
;
}
// TODO: set mid.
}
else
{
this
.
_sender
=
null
;
// Update direction.
switch
(
this
.
_direction
)
{
case
RTCDictionaries
.
RTCRtpTransceiverDirection
.
sendonly
:
this
.
_direction
=
RTCDictionaries
.
RTCRtpTransceiverDirection
.
inactive
;
break
;
case
RTCDictionaries
.
RTCRtpTransceiverDirection
.
sendrecv
:
this
.
_direction
=
RTCDictionaries
.
RTCRtpTransceiverDirection
.
recvonly
;
break
;
}
}
}
get
stopped
()
{
return
this
.
_stopped
;
}
get
direction
()
{
return
this
.
_direction
;
}
stop
()
{
if
(
this
.
_stopped
)
return
;
// Close receiver.
if
(
this
.
_receiver
)
this
.
_receiver
.
close
();
// Close sender.
if
(
this
.
_sender
)
this
.
_sender
.
close
();
// Finally set stopped flag.
this
.
_stopped
=
true
;
}
_handleReceiverEvents
(
receiver
)
{
receiver
.
on
(
'close'
,
this
.
_onReceiverClose
);
}
_unhandleReceiverEvents
(
receiver
)
{
receiver
.
removeListener
(
'close'
,
this
.
_onReceiverClose
);
}
_handleSenderEvents
(
sender
)
{
sender
.
on
(
'close'
,
this
.
_onSenderClose
);
}
_unhandleSenderEvents
(
sender
)
{
sender
.
removeListener
(
'close'
,
this
.
_onSenderClose
);
}
_onReceiverClose
()
{
this
.
receiver
=
null
;
}
_onSenderClose
()
{
this
.
sender
=
null
;
}
}
module
.
exports
=
RTCRtpTransceiver
;
lib/webrtc/RTCSessionDescription.js
浏览文件 @
0f23804e
'use strict'
;
'use strict'
;
const
sdpTransform
=
require
(
'sdp-transform'
);
const
RTCDictionaries
=
require
(
'./RTCDictionaries'
);
class
RTCSessionDescription
class
RTCSessionDescription
{
{
static
isDescription
(
obj
)
{
return
(
obj
&&
typeof
obj
.
type
===
'string'
&&
typeof
obj
.
sdp
===
'string'
);
}
/**
/**
* RTCSessionDescription constructor.
* RTCSessionDescription constructor.
* @param
{object} [options
]
* @param
{object} [descriptionInitDict
]
* @param
{string} [options
.type] - "offer" / "answer".
* @param
{string} [descriptionInitDict
.type] - "offer" / "answer".
* @param
{string} [options.sdp] - SDP
.
* @param
{string|object} [descriptionInitDict.sdp] - SDP string or sdp-transform object
.
*/
*/
constructor
(
descriptionInitDict
)
constructor
(
descriptionInitDict
)
{
{
let
type
=
descriptionInitDict
.
type
;
let
type
=
descriptionInitDict
.
type
;
if
([
'offer'
,
'answer'
].
indexOf
(
type
)
===
-
1
)
switch
(
type
)
throw
new
TypeError
(
`invalid type "
${
type
}
"`
);
{
case
RTCDictionaries
.
RTCSdpType
.
offer
:
break
;
case
RTCDictionaries
.
RTCSdpType
.
answer
:
break
;
default
:
throw
new
TypeError
(
`invalid type "
${
type
}
"`
);
}
let
sdp
=
descriptionInitDict
.
sdp
;
let
sdp
=
descriptionInitDict
.
sdp
;
let
parsed
;
switch
(
typeof
sdp
)
{
case
'string'
:
{
try
{
parsed
=
sdpTransform
.
parse
(
sdp
);
}
catch
(
error
)
{
throw
new
Error
(
`invalid sdp:
${
error
}
`
);
}
break
;
}
case
'object'
:
{
parsed
=
sdp
;
try
{
sdp
=
sdpTransform
.
write
(
parsed
);
}
catch
(
error
)
{
throw
new
Error
(
`invalid sdp-transform object:
${
error
}
`
);
}
break
;
}
default
:
{
throw
new
TypeError
(
'sdp must be a string or a sdp-transform object'
);
}
}
// Private attributes.
this
.
_type
=
type
;
this
.
_sdp
=
sdp
;
this
.
_parsed
=
parsed
;
}
get
type
()
{
return
this
.
_type
;
}
get
sdp
()
{
return
this
.
_sdp
;
}
if
(
typeof
sdp
!==
'string'
)
get
parsed
()
throw
new
TypeError
(
'sdp must be a string'
);
{
return
this
.
_parsed
;
}
// Public r/w properties.
serialize
()
this
.
type
=
type
;
{
this
.
sdp
=
sdp
;
return
{
type
:
this
.
_type
,
sdp
:
this
.
_sdp
};
}
}
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论