Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
ab7ee8ea
提交
ab7ee8ea
authored
5月 17, 2016
作者:
Iñaki Baz Castillo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
worker: Improve binary notifications
上级
3886e49b
显示空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
31 行增加
和
19 行删除
+31
-19
Channel.js
lib/Channel.js
+3
-6
RtpReceiver.js
lib/RtpReceiver.js
+2
-2
Notifier.h
worker/include/Channel/Notifier.h
+1
-1
RtpParameters.h
worker/include/RTC/RtpParameters.h
+3
-0
Notifier.cpp
worker/src/Channel/Notifier.cpp
+15
-2
RtpCodecParameters.cpp
worker/src/RTC/RtpParameters/RtpCodecParameters.cpp
+6
-4
RtpReceiver.cpp
worker/src/RTC/RtpReceiver.cpp
+1
-4
没有找到文件。
lib/Channel.js
浏览文件 @
ab7ee8ea
...
@@ -132,7 +132,7 @@ class Channel extends EventEmitter
...
@@ -132,7 +132,7 @@ class Channel extends EventEmitter
// Reset
// Reset
this
.
_lastBinaryNotification
=
null
;
this
.
_lastBinaryNotification
=
null
;
// Emit
// Emit
this
.
emit
(
msg
.
targetId
,
msg
.
event
,
nsPayload
);
this
.
emit
(
msg
.
targetId
,
msg
.
event
,
msg
.
data
,
nsPayload
);
}
}
// Remove the read payload from the recvBuffer
// Remove the read payload from the recvBuffer
...
@@ -192,7 +192,6 @@ class Channel extends EventEmitter
...
@@ -192,7 +192,6 @@ class Channel extends EventEmitter
let
request
=
{
id
,
method
,
internal
,
data
};
let
request
=
{
id
,
method
,
internal
,
data
};
let
ns
=
netstring
.
nsWrite
(
JSON
.
stringify
(
request
));
let
ns
=
netstring
.
nsWrite
(
JSON
.
stringify
(
request
));
let
promise
;
if
(
Buffer
.
byteLength
(
ns
)
>
NS_MAX_SIZE
)
if
(
Buffer
.
byteLength
(
ns
)
>
NS_MAX_SIZE
)
return
Promise
.
reject
(
new
Error
(
'request too big'
));
return
Promise
.
reject
(
new
Error
(
'request too big'
));
...
@@ -207,7 +206,7 @@ class Channel extends EventEmitter
...
@@ -207,7 +206,7 @@ class Channel extends EventEmitter
return
Promise
.
reject
(
error
);
return
Promise
.
reject
(
error
);
}
}
promise
=
new
Promise
((
pResolve
,
pReject
)
=>
return
new
Promise
((
pResolve
,
pReject
)
=>
{
{
let
sent
=
let
sent
=
{
{
...
@@ -247,8 +246,6 @@ class Channel extends EventEmitter
...
@@ -247,8 +246,6 @@ class Channel extends EventEmitter
// Add sent stuff to the Map
// Add sent stuff to the Map
this
.
_pendingSent
.
set
(
id
,
sent
);
this
.
_pendingSent
.
set
(
id
,
sent
);
});
});
return
promise
;
}
}
_processMessage
(
msg
)
_processMessage
(
msg
)
...
@@ -281,7 +278,7 @@ class Channel extends EventEmitter
...
@@ -281,7 +278,7 @@ class Channel extends EventEmitter
{
{
// If a binary notification, keep this message until the binary
// If a binary notification, keep this message until the binary
// data arrives
// data arrives
if
(
msg
.
data
&&
msg
.
data
.
binary
)
if
(
msg
.
binary
)
{
{
this
.
_lastBinaryNotification
=
msg
;
this
.
_lastBinaryNotification
=
msg
;
...
...
lib/RtpReceiver.js
浏览文件 @
ab7ee8ea
...
@@ -37,7 +37,7 @@ class RtpReceiver extends EventEmitter
...
@@ -37,7 +37,7 @@ class RtpReceiver extends EventEmitter
this
.
_closed
=
false
;
this
.
_closed
=
false
;
// Subscribe to notifications
// Subscribe to notifications
this
.
_channel
.
on
(
this
.
_internal
.
rtpReceiverId
,
(
event
,
data
)
=>
this
.
_channel
.
on
(
this
.
_internal
.
rtpReceiverId
,
(
event
,
data
,
buffer
)
=>
{
{
switch
(
event
)
switch
(
event
)
{
{
...
@@ -49,7 +49,7 @@ class RtpReceiver extends EventEmitter
...
@@ -49,7 +49,7 @@ class RtpReceiver extends EventEmitter
case
'rtp'
:
case
'rtp'
:
{
{
this
.
emit
(
'rtp'
,
data
);
this
.
emit
(
'rtp'
,
buffer
);
break
;
break
;
}
}
...
...
worker/include/Channel/Notifier.h
浏览文件 @
ab7ee8ea
...
@@ -18,7 +18,7 @@ namespace Channel
...
@@ -18,7 +18,7 @@ namespace Channel
void
Emit
(
uint32_t
targetId
,
std
::
string
event
);
void
Emit
(
uint32_t
targetId
,
std
::
string
event
);
void
Emit
(
uint32_t
targetId
,
std
::
string
event
,
Json
::
Value
&
data
);
void
Emit
(
uint32_t
targetId
,
std
::
string
event
,
Json
::
Value
&
data
);
void
Emit
(
const
uint8_t
*
data
,
size_t
len
);
void
Emit
WithBinary
(
uint32_t
targetId
,
std
::
string
event
,
Json
::
Value
&
data
,
const
uint8_t
*
binary_data
,
size_t
binary_
len
);
public
:
public
:
// Passed by argument.
// Passed by argument.
...
...
worker/include/RTC/RtpParameters.h
浏览文件 @
ab7ee8ea
...
@@ -68,6 +68,9 @@ namespace RTC
...
@@ -68,6 +68,9 @@ namespace RTC
DTMF
DTMF
};
};
private
:
static
std
::
unordered_map
<
std
::
string
,
RtpCodecParameters
::
Subtype
>
string2Subtype
;
public
:
public
:
RtpCodecParameters
(
RTC
::
RtpKind
kind
,
Json
::
Value
&
data
);
RtpCodecParameters
(
RTC
::
RtpKind
kind
,
Json
::
Value
&
data
);
virtual
~
RtpCodecParameters
();
virtual
~
RtpCodecParameters
();
...
...
worker/src/Channel/Notifier.cpp
浏览文件 @
ab7ee8ea
...
@@ -58,10 +58,23 @@ namespace Channel
...
@@ -58,10 +58,23 @@ namespace Channel
this
->
channel
->
Send
(
json
);
this
->
channel
->
Send
(
json
);
}
}
void
Notifier
::
Emit
(
const
uint8_t
*
data
,
size_t
len
)
void
Notifier
::
Emit
WithBinary
(
uint32_t
targetId
,
std
::
string
event
,
Json
::
Value
&
data
,
const
uint8_t
*
binary_data
,
size_t
binary_
len
)
{
{
MS_TRACE
();
MS_TRACE
();
this
->
channel
->
SendBinary
(
data
,
len
);
static
const
Json
::
StaticString
k_targetId
(
"targetId"
);
static
const
Json
::
StaticString
k_event
(
"event"
);
static
const
Json
::
StaticString
k_data
(
"data"
);
static
const
Json
::
StaticString
k_binary
(
"binary"
);
Json
::
Value
json
(
Json
::
objectValue
);
json
[
k_targetId
]
=
(
Json
::
UInt
)
targetId
;
json
[
k_event
]
=
event
;
json
[
k_data
]
=
data
;
json
[
k_binary
]
=
true
;
this
->
channel
->
Send
(
json
);
this
->
channel
->
SendBinary
(
binary_data
,
binary_len
);
}
}
}
}
worker/src/RTC/RtpParameters/RtpCodecParameters.cpp
浏览文件 @
ab7ee8ea
...
@@ -6,7 +6,9 @@
...
@@ -6,7 +6,9 @@
namespace
RTC
namespace
RTC
{
{
static
std
::
unordered_map
<
std
::
string
,
RtpCodecParameters
::
Subtype
>
string2Subtype
=
/* Class variables. */
std
::
unordered_map
<
std
::
string
,
RtpCodecParameters
::
Subtype
>
RtpCodecParameters
::
string2Subtype
=
{
{
{
"rtx"
,
RtpCodecParameters
::
Subtype
::
RTX
},
{
"rtx"
,
RtpCodecParameters
::
Subtype
::
RTX
},
{
"RTX"
,
RtpCodecParameters
::
Subtype
::
RTX
},
{
"RTX"
,
RtpCodecParameters
::
Subtype
::
RTX
},
...
@@ -50,15 +52,15 @@ namespace RTC
...
@@ -50,15 +52,15 @@ namespace RTC
else
if
(
kind
==
RTC
::
RtpKind
::
VIDEO
&&
this
->
name
.
compare
(
0
,
6
,
"video/"
)
==
0
)
else
if
(
kind
==
RTC
::
RtpKind
::
VIDEO
&&
this
->
name
.
compare
(
0
,
6
,
"video/"
)
==
0
)
this
->
type
=
RTC
::
RtpKind
::
VIDEO
;
this
->
type
=
RTC
::
RtpKind
::
VIDEO
;
else
else
MS_THROW_ERROR
(
"invalid `RtpCodecParameters.name` MIME type [name:%s"
,
this
->
name
.
c_str
());
MS_THROW_ERROR
(
"invalid `RtpCodecParameters.name` MIME type [name:%s
]
"
,
this
->
name
.
c_str
());
// Get name MIME subtype.
// Get name MIME subtype.
std
::
string
subtype
=
this
->
name
.
substr
(
6
);
std
::
string
subtype
=
this
->
name
.
substr
(
6
);
if
(
string2Subtype
.
find
(
subtype
)
==
string2Subtype
.
end
())
if
(
RtpCodecParameters
::
string2Subtype
.
find
(
subtype
)
==
RtpCodecParameters
::
string2Subtype
.
end
())
this
->
subtype
=
Subtype
::
MEDIA
;
this
->
subtype
=
Subtype
::
MEDIA
;
else
else
this
->
subtype
=
string2Subtype
[
subtype
];
this
->
subtype
=
RtpCodecParameters
::
string2Subtype
[
subtype
];
// `payloadType` is mandatory.
// `payloadType` is mandatory.
if
(
!
data
[
k_payloadType
].
isUInt
())
if
(
!
data
[
k_payloadType
].
isUInt
())
...
...
worker/src/RTC/RtpReceiver.cpp
浏览文件 @
ab7ee8ea
...
@@ -195,16 +195,13 @@ namespace RTC
...
@@ -195,16 +195,13 @@ namespace RTC
// Send a JSON event followed by binary data (the RTP packet).
// Send a JSON event followed by binary data (the RTP packet).
static
const
Json
::
StaticString
k_class
(
"class"
);
static
const
Json
::
StaticString
k_class
(
"class"
);
static
const
Json
::
StaticString
k_binary
(
"binary"
);
Json
::
Value
event_data
(
Json
::
objectValue
);
Json
::
Value
event_data
(
Json
::
objectValue
);
// Notify binary event.
// Notify binary event.
event_data
[
k_class
]
=
"RtpReceiver"
;
event_data
[
k_class
]
=
"RtpReceiver"
;
event_data
[
k_binary
]
=
true
;
this
->
notifier
->
Emit
(
this
->
rtpReceiverId
,
"rtp"
,
event_data
);
this
->
notifier
->
Emit
(
packet
->
GetRaw
(),
packet
->
GetLength
());
this
->
notifier
->
Emit
WithBinary
(
this
->
rtpReceiverId
,
"rtp"
,
event_data
,
packet
->
GetRaw
(),
packet
->
GetLength
());
}
}
}
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论