Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
189bcb6d
提交
189bcb6d
authored
5月 27, 2016
作者:
Iñaki Baz Castillo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improve RtpParameters for RtpReceiver and RtpSender.
上级
9c7c2f48
隐藏空白字符变更
内嵌
并排
正在显示
16 个修改的文件
包含
223 行增加
和
181 行删除
+223
-181
gulpfile.js
gulpfile.js
+2
-1
Peer.js
lib/Peer.js
+5
-5
Room.js
lib/Room.js
+1
-1
RtpSender.js
lib/RtpSender.js
+3
-3
test_scene_1.js
test/test_scene_1.js
+2
-2
RtpPacket.h
worker/include/RTC/RtpPacket.h
+1
-2
RtpParameters.h
worker/include/RTC/RtpParameters.h
+26
-6
RtpReceiver.h
worker/include/RTC/RtpReceiver.h
+15
-3
RtpSender.h
worker/include/RTC/RtpSender.h
+2
-3
Peer.cpp
worker/src/RTC/Peer.cpp
+4
-6
Room.cpp
worker/src/RTC/Room.cpp
+9
-17
RtpListener.cpp
worker/src/RTC/RtpListener.cpp
+2
-2
RtpCodecParameters.cpp
worker/src/RTC/RtpParameters/RtpCodecParameters.cpp
+2
-2
RtpParameters.cpp
worker/src/RTC/RtpParameters/RtpParameters.cpp
+124
-125
RtpReceiver.cpp
worker/src/RTC/RtpReceiver.cpp
+25
-0
RtpSender.cpp
worker/src/RTC/RtpSender.cpp
+0
-3
没有找到文件。
gulpfile.js
浏览文件 @
189bcb6d
...
...
@@ -15,7 +15,8 @@ let tests =
'test/test_Transport.js'
,
'test/test_RtpReceiver.js'
,
'test/test_extra.js'
,
'test/test_scene_1.js'
// NOTE: Unable his test until fixed
// 'test/test_scene_1.js'
];
gulp
.
task
(
'lint'
,
()
=>
...
...
lib/Peer.js
浏览文件 @
189bcb6d
...
...
@@ -274,23 +274,23 @@ class Peer extends EventEmitter
// Ensure `kind` is 'audio' / 'video'.
if
([
'audio'
,
'video'
].
indexOf
(
kind
)
===
-
1
)
throw
new
TypeError
(
'
`kind`
must be "audio" or "video"'
);
throw
new
TypeError
(
'
kind
must be "audio" or "video"'
);
// Ensure `transport` is given.
if
(
!
transport
)
throw
new
TypeError
(
'
`transport`
not given'
);
throw
new
TypeError
(
'
transport
not given'
);
// Ensure `transport` is a Transport.
if
(
!
(
transport
instanceof
Transport
))
throw
new
TypeError
(
'
`transport`
must be a instance of Transport'
);
throw
new
TypeError
(
'
transport
must be a instance of Transport'
);
// Ensure `transport` is not closed.
if
(
transport
.
closed
)
throw
new
errors
.
InvalidStateError
(
'
`transport`
is closed'
);
throw
new
errors
.
InvalidStateError
(
'
transport
is closed'
);
// Ensure `transport` belongs to this Peer.
if
(
!
this
.
_transports
.
has
(
transport
))
throw
new
Error
(
'
`transport`
not found'
);
throw
new
Error
(
'
transport
not found'
);
let
internal
=
{
...
...
lib/Room.js
浏览文件 @
189bcb6d
...
...
@@ -144,7 +144,7 @@ class Room extends EventEmitter
throw
new
errors
.
InvalidStateError
(
'Room closed'
);
if
(
!
peerName
||
typeof
peerName
!==
'string'
)
throw
new
TypeError
(
'
`peerName`
must be a string'
);
throw
new
TypeError
(
'
peerName
must be a string'
);
if
(
this
.
_peers
.
has
(
peerName
))
throw
new
Error
(
`peer already exists [peerName:"
${
peerName
}
"]`
);
...
...
lib/RtpSender.js
浏览文件 @
189bcb6d
...
...
@@ -157,15 +157,15 @@ class RtpSender extends EventEmitter
// Ensure `transport` is given.
if
(
!
transport
)
return
Promise
.
reject
(
new
TypeError
(
'
`transport`
not given'
));
return
Promise
.
reject
(
new
TypeError
(
'
transport
not given'
));
// Ensure `transport` is a Transport.
if
(
!
(
transport
instanceof
Transport
))
return
Promise
.
reject
(
new
TypeError
(
'
`transport`
must be a instance of Transport'
));
return
Promise
.
reject
(
new
TypeError
(
'
transport
must be a instance of Transport'
));
// Ensure `transport` is not closed.
if
(
transport
.
closed
)
return
Promise
.
reject
(
new
errors
.
InvalidStateError
(
'
`transport`
is closed'
));
return
Promise
.
reject
(
new
errors
.
InvalidStateError
(
'
transport
is closed'
));
let
internal
=
utils
.
cloneObject
(
this
.
_internal
);
...
...
test/test_scene_1.js
浏览文件 @
189bcb6d
...
...
@@ -431,7 +431,7 @@ tap.test('alice, bob and carol create RtpReceivers and expect RtpSenders', { tim
})
.
then
(()
=>
{
return
t
.
test
(
'
close aliceAudioReceiv
er'
,
{
timeout
:
1000
},
(
t2
)
=>
return
t
.
test
(
'
aliceAudioReceiver.close() must also close bobAudioSend
er'
,
{
timeout
:
1000
},
(
t2
)
=>
{
t2
.
plan
(
2
);
...
...
@@ -473,7 +473,7 @@ tap.test('alice, bob and carol create RtpReceivers and expect RtpSenders', { tim
})
.
then
(()
=>
{
return
t
.
test
(
'
close bob
'
,
{
timeout
:
1000
},
(
t2
)
=>
return
t
.
test
(
'
bob.close() must also close aliceVideoSender
'
,
{
timeout
:
1000
},
(
t2
)
=>
{
t2
.
plan
(
4
);
...
...
worker/include/RTC/RtpPacket.h
浏览文件 @
189bcb6d
...
...
@@ -154,11 +154,10 @@ namespace RTC
return
(
uint32_t
)
ntohl
(
this
->
header
->
ssrc
);
}
// TODO temp
inline
void
RtpPacket
::
SetSsrc
(
uint32_t
ssrc
)
{
this
->
header
->
ssrc
=
htonl
(
ssrc
);
this
->
header
->
ssrc
=
(
uint32_t
)
htonl
(
ssrc
);
}
inline
...
...
worker/include/RTC/RtpParameters.h
浏览文件 @
189bcb6d
...
...
@@ -30,10 +30,25 @@ namespace RTC
virtual
~
CustomParameterValue
();
Json
::
Value
toJson
();
bool
IsBoolean
()
{
return
this
->
type
==
Type
::
BOOLEAN
;
}
bool
IsInteger
()
{
return
this
->
type
==
Type
::
INTEGER
;
}
bool
IsDouble
()
{
return
this
->
type
==
Type
::
DOUBLE
;
}
bool
IsString
()
{
return
this
->
type
==
Type
::
STRING
;
}
bool
IsBoolean
()
{
return
this
->
type
==
Type
::
BOOLEAN
;
}
bool
IsInteger
()
{
return
this
->
type
==
Type
::
INTEGER
;
}
bool
IsPositiveInteger
()
{
return
this
->
type
==
Type
::
INTEGER
&&
this
->
integerValue
>=
0
;
}
bool
IsDouble
()
{
return
this
->
type
==
Type
::
DOUBLE
;
}
bool
IsString
(){
return
this
->
type
==
Type
::
STRING
;
}
public
:
Type
type
;
...
...
@@ -185,12 +200,17 @@ namespace RTC
static
void
FillCustomParameters
(
CustomParameters
&
parameters
,
Json
::
Value
&
data
);
public
:
// Constructor for receiver's parameters.
RtpParameters
(
RTC
::
RtpKind
kind
,
Json
::
Value
&
data
);
// Constructor for sender's parameters.
RtpParameters
(
const
RtpParameters
*
RtpParameters
);
virtual
~
RtpParameters
();
Json
::
Value
toJson
();
void
AutoFill
();
private
:
void
ValidateCodecs
();
void
ValidateEncodings
();
public
:
std
::
string
muxId
;
...
...
@@ -201,7 +221,7 @@ namespace RTC
bool
hasRtcp
=
false
;
Json
::
Value
userParameters
;
p
ublic
:
p
rivate
:
RTC
::
RtpKind
kind
;
};
}
...
...
worker/include/RTC/RtpReceiver.h
浏览文件 @
189bcb6d
...
...
@@ -8,6 +8,7 @@
#include "Channel/Request.h"
#include "Channel/Notifier.h"
#include <string>
#include <unordered_map>
#include <json/json.h>
namespace
RTC
...
...
@@ -40,8 +41,10 @@ namespace RTC
void
SetTransport
(
RTC
::
Transport
*
transport
);
RTC
::
Transport
*
GetTransport
();
void
RemoveTransport
(
RTC
::
Transport
*
transport
);
RTC
::
RtpParameters
*
GetRtpParameters
();
RTC
::
RtpParameters
*
GetPreviousRtpParameters
();
RTC
::
RtpParameters
*
GetParameters
();
RTC
::
RtpParameters
*
GetSenderParameters
();
void
SetPayloadMapping
();
// TODO
void
CreateSenderParameters
();
// TODO
void
ReceiveRtpPacket
(
RTC
::
RtpPacket
*
packet
);
public
:
...
...
@@ -57,9 +60,12 @@ namespace RTC
RTC
::
Transport
*
transport
=
nullptr
;
// Allocated by this.
RTC
::
RtpParameters
*
rtpParameters
=
nullptr
;
RTC
::
RtpParameters
*
senderRtpParameters
=
nullptr
;
// Others.
bool
rtpRawEventEnabled
=
false
;
bool
rtpObjectEventEnabled
=
false
;
std
::
unordered_map
<
uint8_t
,
uint8_t
>
mapPayloadTypes
;
std
::
unordered_map
<
uint32_t
,
uint32_t
>
mapSsrcs
;
};
/* Inline methods. */
...
...
@@ -84,10 +90,16 @@ namespace RTC
}
inline
RTC
::
RtpParameters
*
RtpReceiver
::
Get
Rtp
Parameters
()
RTC
::
RtpParameters
*
RtpReceiver
::
GetParameters
()
{
return
this
->
rtpParameters
;
}
inline
RTC
::
RtpParameters
*
RtpReceiver
::
GetSenderParameters
()
{
return
this
->
senderRtpParameters
;
}
}
#endif
worker/include/RTC/RtpSender.h
浏览文件 @
189bcb6d
...
...
@@ -35,7 +35,7 @@ namespace RTC
void
Send
(
RTC
::
RtpParameters
*
rtpParameters
);
void
SetTransport
(
RTC
::
Transport
*
transport
);
void
RemoveTransport
(
RTC
::
Transport
*
transport
);
RTC
::
RtpParameters
*
Get
Rtp
Parameters
();
RTC
::
RtpParameters
*
GetParameters
();
void
SendRtpPacket
(
RTC
::
RtpPacket
*
packet
);
public
:
...
...
@@ -48,7 +48,6 @@ namespace RTC
Listener
*
listener
=
nullptr
;
Channel
::
Notifier
*
notifier
=
nullptr
;
RTC
::
Transport
*
transport
=
nullptr
;
// Externally allocated but handled by this.
RTC
::
RtpParameters
*
rtpParameters
=
nullptr
;
};
...
...
@@ -68,7 +67,7 @@ namespace RTC
}
inline
RTC
::
RtpParameters
*
RtpSender
::
Get
Rtp
Parameters
()
RTC
::
RtpParameters
*
RtpSender
::
GetParameters
()
{
return
this
->
rtpParameters
;
}
...
...
worker/src/RTC/Peer.cpp
浏览文件 @
189bcb6d
...
...
@@ -404,7 +404,7 @@ namespace RTC
MS_ASSERT
(
this
->
rtpSenders
.
find
(
rtpSender
->
rtpSenderId
)
==
this
->
rtpSenders
.
end
(),
"given RtpSender already exists in this Peer"
);
MS_ASSERT
(
rtpSender
->
Get
Rtp
Parameters
(),
"given RtpSender does not have RtpParameters"
);
MS_ASSERT
(
rtpSender
->
GetParameters
(),
"given RtpSender does not have RtpParameters"
);
// Store it.
this
->
rtpSenders
[
rtpSender
->
rtpSenderId
]
=
rtpSender
;
...
...
@@ -423,7 +423,7 @@ namespace RTC
event_data
[
k_kind
]
=
v_video
;
break
;
}
event_data
[
k_rtpParameters
]
=
rtpSender
->
Get
Rtp
Parameters
()
->
toJson
();
event_data
[
k_rtpParameters
]
=
rtpSender
->
GetParameters
()
->
toJson
();
event_data
[
k_peerName
]
=
peerName
;
this
->
notifier
->
Emit
(
this
->
peerId
,
"newrtpsender"
,
event_data
);
...
...
@@ -548,10 +548,8 @@ namespace RTC
if
(
transport
)
transport
->
AddRtpReceiver
(
rtpReceiver
);
// Auto-fill missing RTP parameters.
auto
rtpParameters
=
rtpReceiver
->
GetRtpParameters
();
rtpParameters
->
AutoFill
();
// TODO
rtpReceiver
->
CreateSenderParameters
();
// Notify the listener (Room).
this
->
listener
->
onPeerRtpReceiverParametersDone
(
this
,
rtpReceiver
);
...
...
worker/src/RTC/Room.cpp
浏览文件 @
189bcb6d
...
...
@@ -208,7 +208,7 @@ namespace RTC
for
(
auto
rtpReceiver
:
receiver_peer
->
GetRtpReceivers
())
{
// Skip if the RtpReceiver has not parameters.
if
(
!
rtpReceiver
->
Get
Rtp
Parameters
())
if
(
!
rtpReceiver
->
GetParameters
())
continue
;
uint32_t
rtpSenderId
=
Utils
::
Crypto
::
GetRandomUInt
(
10000000
,
99999999
);
...
...
@@ -217,10 +217,8 @@ namespace RTC
// Store into the map.
this
->
mapRtpReceiverRtpSenders
[
rtpReceiver
].
insert
(
rtpSender
);
// Clone receiver RtpParameters.
RTC
::
RtpParameters
*
rtpSenderParameters
=
new
RTC
::
RtpParameters
(
rtpReceiver
->
GetRtpParameters
());
rtpSender
->
Send
(
rtpSenderParameters
);
// Take the sneder parameters of the receiver.
rtpSender
->
Send
(
rtpReceiver
->
GetSenderParameters
());
// Attach the RtpSender to peer.
peer
->
AddRtpSender
(
rtpSender
,
receiver_peer
->
peerName
);
...
...
@@ -320,7 +318,7 @@ namespace RTC
{
MS_TRACE
();
// auto rtpParameters = rtpReceiver->Get
Rtp
Parameters();
// auto rtpParameters = rtpReceiver->GetParameters();
// TODO: Check codecs availability and, optionally, uniqueness of PTs.
// If it fails throw.
...
...
@@ -330,7 +328,7 @@ namespace RTC
{
MS_TRACE
();
MS_ASSERT
(
rtpReceiver
->
Get
RtpParameters
(),
"rtpReceiver->GetRtp
Parameters() returns no RtpParameters"
);
MS_ASSERT
(
rtpReceiver
->
Get
Parameters
(),
"rtpReceiver->Get
Parameters() returns no RtpParameters"
);
// If this is a new RtpReceiver, iterate all the peers but this one and
// create a RtpSender associated to this RtpReceiver for each Peer.
...
...
@@ -354,11 +352,8 @@ namespace RTC
// Store into the map.
this
->
mapRtpReceiverRtpSenders
[
rtpReceiver
].
insert
(
rtpSender
);
// Clone RtpParameters.
RTC
::
RtpParameters
*
rtpSenderParameters
=
new
RTC
::
RtpParameters
(
rtpReceiver
->
GetRtpParameters
());
// Assign cloned parameters to the RtpSender.
rtpSender
->
Send
(
rtpSenderParameters
);
// Take the sneder parameters of the receiver.
rtpSender
->
Send
(
rtpReceiver
->
GetSenderParameters
());
// Attach the RtpSender to sender_peer.
sender_peer
->
AddRtpSender
(
rtpSender
,
peer
->
peerName
);
...
...
@@ -370,11 +365,8 @@ namespace RTC
{
for
(
auto
rtpSender
:
this
->
mapRtpReceiverRtpSenders
[
rtpReceiver
])
{
// Clone RtpParameters.
RTC
::
RtpParameters
*
rtpSenderParameters
=
new
RTC
::
RtpParameters
(
rtpReceiver
->
GetRtpParameters
());
// Assign cloned parameters to the RtpSender.
rtpSender
->
Send
(
rtpSenderParameters
);
// Take the sneder parameters of the receiver.
rtpSender
->
Send
(
rtpReceiver
->
GetSenderParameters
());
}
}
}
...
...
worker/src/RTC/RtpListener.cpp
浏览文件 @
189bcb6d
...
...
@@ -58,7 +58,7 @@ namespace RTC
{
MS_TRACE
();
auto
rtpParameters
=
rtpReceiver
->
Get
Rtp
Parameters
();
auto
rtpParameters
=
rtpReceiver
->
GetParameters
();
MS_ASSERT
(
rtpParameters
,
"no RtpParameters"
);
...
...
@@ -268,7 +268,7 @@ namespace RTC
if
(
it
!=
this
->
ssrcTable
.
end
())
{
auto
rtpReceiver
=
it
->
second
;
auto
rtpParameters
=
rtpReceiver
->
Get
Rtp
Parameters
();
auto
rtpParameters
=
rtpReceiver
->
GetParameters
();
// Ensure the RTP PT is present in RtpParameters.
...
...
worker/src/RTC/RtpParameters/RtpCodecParameters.cpp
浏览文件 @
189bcb6d
...
...
@@ -105,7 +105,7 @@ namespace RTC
// Validate codec.
switch
(
this
->
subtype
)
{
// A RTX codec must have 'apt' parameter
pointing to a media codec
.
// A RTX codec must have 'apt' parameter.
case
Subtype
:
:
RTX
:
{
auto
it
=
this
->
parameters
.
find
(
"apt"
);
...
...
@@ -115,7 +115,7 @@ namespace RTC
auto
&
apt
=
it
->
second
;
if
(
!
apt
.
IsInteger
())
if
(
!
apt
.
Is
Positive
Integer
())
MS_THROW_ERROR
(
"invalid apt parameter in RTX RtpCodecParameters"
);
}
...
...
worker/src/RTC/RtpParameters/RtpParameters.cpp
浏览文件 @
189bcb6d
...
...
@@ -145,134 +145,17 @@ namespace RTC
else
this
->
userParameters
=
Json
::
objectValue
;
// Validate codecs.
{
// Must be at least one codec.
if
(
this
->
codecs
.
size
()
==
0
)
MS_THROW_ERROR
(
"empty RtpParameters.codecs"
);
// Validate each codec.
for
(
auto
&
codec
:
this
->
codecs
)
{
switch
(
codec
.
subtype
)
{
// A RTX codec must have 'apt' parameter pointing to a media codec.
case
RtpCodecParameters
:
:
Subtype
::
RTX
:
{
// NOTE: RtpCodecParameters already asserted that there is 'apt' parameter.
auto
it
=
codec
.
parameters
.
find
(
"apt"
);
int32_t
apt
=
it
->
second
.
integerValue
;
auto
it2
=
this
->
codecs
.
begin
();
for
(;
it2
!=
this
->
codecs
.
end
();
++
it2
)
{
auto
codec
=
*
it2
;
if
((
int32_t
)
codec
.
payloadType
==
apt
)
{
if
(
codec
.
subtype
==
RtpCodecParameters
::
Subtype
::
MEDIA
)
break
;
else
MS_THROW_ERROR
(
"apt in RTX codec points to a non media codec"
);
}
}
if
(
it2
==
this
->
codecs
.
end
())
MS_THROW_ERROR
(
"apt in RTX codec points to a non existing codec"
);
}
default
:
;
}
}
}
// Validate encodings.
{
// If there are no encodings create one with `codecPayloadType` pointing to
// the first media codec.
if
(
this
->
encodings
.
size
()
==
0
)
{
RtpEncodingParameters
encoding
;
auto
it
=
this
->
codecs
.
begin
();
for
(;
it
!=
this
->
codecs
.
end
();
++
it
)
{
auto
codec
=
*
it
;
// Must be a media codec.
if
(
codec
.
subtype
==
RtpCodecParameters
::
Subtype
::
MEDIA
)
{
encoding
.
codecPayloadType
=
codec
.
payloadType
;
encoding
.
hasCodecPayloadType
=
true
;
break
;
}
}
if
(
it
==
this
->
codecs
.
end
())
MS_THROW_ERROR
(
"no media codecs in RtpParameters.codecs"
);
// Insert into the encodings vector.
this
->
encodings
.
push_back
(
encoding
);
}
// If there are one encoding and does not have `codecPayloadType` do the same
// as above.
else
if
(
this
->
encodings
.
size
()
==
1
&&
!
this
->
encodings
[
0
].
hasCodecPayloadType
)
{
auto
it
=
this
->
codecs
.
begin
();
for
(;
it
!=
this
->
codecs
.
end
();
++
it
)
{
auto
codec
=
*
it
;
auto
&
encoding
=
this
->
encodings
[
0
];
// Must be a media codec.
if
(
codec
.
subtype
==
RtpCodecParameters
::
Subtype
::
MEDIA
)
{
encoding
.
codecPayloadType
=
codec
.
payloadType
;
encoding
.
hasCodecPayloadType
=
true
;
break
;
}
}
if
(
it
==
this
->
codecs
.
end
())
MS_THROW_ERROR
(
"no media codecs in RtpParameters.codecs"
);
}
// Otherwise all the encodings must point to a valid media codec.
else
{
for
(
auto
&
encoding
:
this
->
encodings
)
{
if
(
!
encoding
.
hasCodecPayloadType
)
MS_THROW_ERROR
(
"missing RTpEncodingParameters.codecPayloadType"
);
auto
it
=
this
->
codecs
.
begin
();
for
(;
it
!=
this
->
codecs
.
end
();
++
it
)
{
auto
codec
=
*
it
;
// Validate RTP parameters.
if
(
codec
.
payloadType
==
encoding
.
codecPayloadType
)
{
// Must be a media codec.
if
(
codec
.
subtype
==
RtpCodecParameters
::
Subtype
::
MEDIA
)
break
;
else
MS_THROW_ERROR
(
"invalid RtpEncodingParameters.codecPayloadType"
);
}
}
if
(
it
==
this
->
codecs
.
end
())
MS_THROW_ERROR
(
"unknown RtpEncodingParameters.codecPayloadType"
);
}
}
}
ValidateCodecs
();
ValidateEncodings
();
}
RtpParameters
::
RtpParameters
(
const
RtpParameters
*
rtpParameters
)
{
MS_TRACE
();
this
->
kind
=
rtpParameters
->
kind
;
this
->
muxId
=
rtpParameters
->
muxId
;
this
->
codecs
=
rtpParameters
->
codecs
;
this
->
encodings
=
rtpParameters
->
encodings
;
...
...
@@ -280,8 +163,6 @@ namespace RTC
this
->
rtcp
=
rtpParameters
->
rtcp
;
this
->
hasRtcp
=
rtpParameters
->
hasRtcp
;
this
->
userParameters
=
rtpParameters
->
userParameters
;
this
->
kind
=
rtpParameters
->
kind
;
}
RtpParameters
::~
RtpParameters
()
...
...
@@ -349,10 +230,128 @@ namespace RTC
return
json
;
}
void
RtpParameters
::
AutoFill
()
void
RtpParameters
::
ValidateCodecs
()
{
MS_TRACE
();
// TODO
// Must be at least one codec.
if
(
this
->
codecs
.
size
()
==
0
)
MS_THROW_ERROR
(
"empty RtpParameters.codecs"
);
// Validate each codec.
for
(
auto
&
codec
:
this
->
codecs
)
{
switch
(
codec
.
subtype
)
{
// A RTX codec must have 'apt' parameter pointing to a non RTX codec.
case
RtpCodecParameters
:
:
Subtype
::
RTX
:
{
// NOTE: RtpCodecParameters already asserted that there is 'apt' parameter.
auto
it
=
codec
.
parameters
.
find
(
"apt"
);
int32_t
apt
=
it
->
second
.
integerValue
;
auto
it2
=
this
->
codecs
.
begin
();
for
(;
it2
!=
this
->
codecs
.
end
();
++
it2
)
{
auto
codec
=
*
it2
;
if
((
int32_t
)
codec
.
payloadType
==
apt
)
{
if
(
codec
.
subtype
!=
RtpCodecParameters
::
Subtype
::
RTX
)
break
;
else
MS_THROW_ERROR
(
"apt in RTX codec points to RTX codec"
);
}
}
if
(
it2
==
this
->
codecs
.
end
())
MS_THROW_ERROR
(
"apt in RTX codec points to a non existing codec"
);
}
default
:
;
}
}
}
void
RtpParameters
::
ValidateEncodings
()
{
// If there are no encodings create one with `codecPayloadType` pointing to
// the first media codec.
if
(
this
->
encodings
.
size
()
==
0
)
{
RtpEncodingParameters
encoding
;
auto
it
=
this
->
codecs
.
begin
();
for
(;
it
!=
this
->
codecs
.
end
();
++
it
)
{
auto
codec
=
*
it
;
// Must be a media codec.
if
(
codec
.
subtype
==
RtpCodecParameters
::
Subtype
::
MEDIA
)
{
encoding
.
codecPayloadType
=
codec
.
payloadType
;
encoding
.
hasCodecPayloadType
=
true
;
break
;
}
}
if
(
it
==
this
->
codecs
.
end
())
MS_THROW_ERROR
(
"no media codecs in RtpParameters.codecs"
);
// Insert into the encodings vector.
this
->
encodings
.
push_back
(
encoding
);
}
// If there are one encoding and does not have `codecPayloadType` do the same
// as above.
else
if
(
this
->
encodings
.
size
()
==
1
&&
!
this
->
encodings
[
0
].
hasCodecPayloadType
)
{
auto
it
=
this
->
codecs
.
begin
();
for
(;
it
!=
this
->
codecs
.
end
();
++
it
)
{
auto
codec
=
*
it
;
auto
&
encoding
=
this
->
encodings
[
0
];
// Must be a media codec.
if
(
codec
.
subtype
==
RtpCodecParameters
::
Subtype
::
MEDIA
)
{
encoding
.
codecPayloadType
=
codec
.
payloadType
;
encoding
.
hasCodecPayloadType
=
true
;
break
;
}
}
if
(
it
==
this
->
codecs
.
end
())
MS_THROW_ERROR
(
"no media codecs in RtpParameters.codecs"
);
}
// Otherwise all the encodings must point to a valid media codec.
else
{
for
(
auto
&
encoding
:
this
->
encodings
)
{
if
(
!
encoding
.
hasCodecPayloadType
)
MS_THROW_ERROR
(
"missing RTpEncodingParameters.codecPayloadType"
);
auto
it
=
this
->
codecs
.
begin
();
for
(;
it
!=
this
->
codecs
.
end
();
++
it
)
{
auto
codec
=
*
it
;
if
(
codec
.
payloadType
==
encoding
.
codecPayloadType
)
{
// Must be a media codec.
if
(
codec
.
subtype
==
RtpCodecParameters
::
Subtype
::
MEDIA
)
break
;
else
MS_THROW_ERROR
(
"invalid RtpEncodingParameters.codecPayloadType"
);
}
}
if
(
it
==
this
->
codecs
.
end
())
MS_THROW_ERROR
(
"unknown RtpEncodingParameters.codecPayloadType"
);
}
}
}
}
worker/src/RTC/RtpReceiver.cpp
浏览文件 @
189bcb6d
#define MS_CLASS "RTC::RtpReceiver"
#include "RTC/RtpReceiver.h"
#include "Utils.h"
#include "MediaSoupError.h"
#include "Logger.h"
...
...
@@ -39,6 +40,9 @@ namespace RTC
if
(
this
->
rtpParameters
)
delete
this
->
rtpParameters
;
if
(
this
->
senderRtpParameters
)
delete
this
->
senderRtpParameters
;
// Notify.
event_data
[
k_class
]
=
"RtpReceiver"
;
this
->
notifier
->
Emit
(
this
->
rtpReceiverId
,
"close"
,
event_data
);
...
...
@@ -248,4 +252,25 @@ namespace RTC
this
->
notifier
->
EmitWithBinary
(
this
->
rtpReceiverId
,
"rtpobject"
,
event_data
,
packet
->
GetPayload
(),
packet
->
GetPayloadLength
());
}
}
void
RtpReceiver
::
SetPayloadMapping
()
{
MS_TRACE
();
// TODO
}
void
RtpReceiver
::
CreateSenderParameters
()
{
MS_TRACE
();
// Clone receiver parameters.
this
->
senderRtpParameters
=
new
RTC
::
RtpParameters
(
this
->
rtpParameters
);
// TODO: Must override payloadType/ssrc values in senderRtpParameters and
// override muxId, rtcp, etc.
// Set a random muxId.
this
->
senderRtpParameters
->
muxId
=
Utils
::
Crypto
::
GetRandomString
(
8
);
}
}
worker/src/RTC/RtpSender.cpp
浏览文件 @
189bcb6d
...
...
@@ -30,9 +30,6 @@ namespace RTC
Json
::
Value
event_data
(
Json
::
objectValue
);
if
(
this
->
rtpParameters
)
delete
this
->
rtpParameters
;
// Notify.
event_data
[
k_class
]
=
"RtpSender"
;
this
->
notifier
->
Emit
(
this
->
rtpSenderId
,
"close"
,
event_data
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论