Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
2f6bf193
提交
2f6bf193
authored
1月 18, 2016
作者:
Iñaki Baz Castillo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Create a separate RtcListener class.
上级
d8b2c529
隐藏空白字符变更
内嵌
并排
正在显示
19 个修改的文件
包含
285 行增加
和
220 行删除
+285
-220
README.md
README.md
+13
-16
Channel.js
lib/Channel.js
+3
-3
server.js
tester/server/server.js
+20
-20
Notifier.h
worker/include/Channel/Notifier.h
+2
-2
RTPPacket.h
worker/include/RTC/RTPPacket.h
+4
-4
RtpListener.h
worker/include/RTC/RtpListener.h
+40
-0
Transport.h
worker/include/RTC/Transport.h
+3
-20
Settings.h
worker/include/Settings.h
+1
-1
common.h
worker/include/common.h
+1
-0
Notifier.cpp
worker/src/Channel/Notifier.cpp
+14
-15
Request.cpp
worker/src/Channel/Request.cpp
+13
-14
ICEServer.cpp
worker/src/RTC/ICEServer.cpp
+0
-1
IceCandidate.cpp
worker/src/RTC/IceCandidate.cpp
+3
-3
RtpListener.cpp
worker/src/RTC/RtpListener.cpp
+117
-0
RtpParameters.cpp
worker/src/RTC/RtpParameters.cpp
+1
-2
RtpReceiver.cpp
worker/src/RTC/RtpReceiver.cpp
+3
-2
Transport.cpp
worker/src/RTC/Transport.cpp
+41
-111
TransportTuple.cpp
worker/src/RTC/TransportTuple.cpp
+5
-5
Timer.cpp
worker/src/handles/Timer.cpp
+1
-1
没有找到文件。
README.md
浏览文件 @
2f6bf193
...
@@ -60,9 +60,6 @@ signalingServer.on('invite', (request) =>
...
@@ -60,9 +60,6 @@ signalingServer.on('invite', (request) =>
});
});
// Set remote DTLS parameters.
// Set remote DTLS parameters.
// `transport.setRemoteDtlsParameters()` returns a Promise that resolves
// with `transport` itself so it can be handled in the next `then()`
// handler.
return
transport
.
setRemoteDtlsParameters
(
return
transport
.
setRemoteDtlsParameters
(
{
{
role
:
request
.
dtlsRole
,
role
:
request
.
dtlsRole
,
...
@@ -71,20 +68,20 @@ signalingServer.on('invite', (request) =>
...
@@ -71,20 +68,20 @@ signalingServer.on('invite', (request) =>
algorithm
:
request
.
remoteFingerprint
.
type
,
algorithm
:
request
.
remoteFingerprint
.
type
,
value
:
request
.
remoteFingerprint
.
hash
value
:
request
.
remoteFingerprint
.
hash
}
}
});
})
})
.
then
(()
=>
.
then
((
transport
)
=>
{
{
// Set our DTLS parameters into the response.
// Set our DTLS parameters into the response.
response
.
dtlsRole
=
transport
.
dtlsLocalParameters
.
role
;
response
.
dtlsRole
=
transport
.
dtlsLocalParameters
.
role
;
response
.
fingerprint
=
response
.
fingerprint
=
{
{
type
:
'sha-512'
,
type
:
'sha-512'
,
hash
:
transport
.
dtlsLocalParameters
.
fingerprints
[
'sha-512'
]
hash
:
transport
.
dtlsLocalParameters
.
fingerprints
[
'sha-512'
]
};
};
// And send the response.
// And send the response.
signalingServer
.
send
(
response
);
signalingServer
.
send
(
response
);
});
});
});
});
});
```
```
...
...
lib/Channel.js
浏览文件 @
2f6bf193
...
@@ -253,13 +253,13 @@ class Channel extends EventEmitter
...
@@ -253,13 +253,13 @@ class Channel extends EventEmitter
}
}
}
}
// If a Notification emit it to the corresponding entity
// If a Notification emit it to the corresponding entity
else
if
(
msg
.
targetId
&&
msg
.
event
Name
)
else
if
(
msg
.
targetId
&&
msg
.
event
)
{
{
let
targetId
=
msg
.
targetId
;
let
targetId
=
msg
.
targetId
;
let
event
Name
=
msg
.
eventName
;
let
event
=
msg
.
event
;
// Emit it
// Emit it
this
.
emit
(
targetId
,
event
Name
,
msg
.
eventD
ata
);
this
.
emit
(
targetId
,
event
,
msg
.
d
ata
);
}
}
// Otherwise unexpected message
// Otherwise unexpected message
else
else
...
...
tester/server/server.js
浏览文件 @
2f6bf193
...
@@ -184,31 +184,31 @@ app.put('/test-transport', function(req)
...
@@ -184,31 +184,31 @@ app.put('/test-transport', function(req)
preferIPv6
:
true
,
preferIPv6
:
true
,
preferTcp
:
true
preferTcp
:
true
})
})
.
then
((
transport
)
=>
.
then
((
transport
)
=>
{
transport
.
on
(
'close'
,
()
=>
{
{
debug
(
'transport "close" event'
);
transport
.
on
(
'close'
,
()
=>
});
{
debug
(
'transport "close" event'
);
});
transport
.
on
(
'iceselectedtuplechange'
,
(
data
)
=>
transport
.
on
(
'iceselectedtuplechange'
,
(
data
)
=>
{
{
debug
(
'transport "iceselectedtuplechange" event [data.iceSelectedTuple:%o, transport.iceSelectedTuple:%o]'
,
data
.
iceSelectedTuple
,
transport
.
iceSelectedTuple
);
debug
(
'transport "iceselectedtuplechange" event [data.iceSelectedTuple:%o, transport.iceSelectedTuple:%o]'
,
data
.
iceSelectedTuple
,
transport
.
iceSelectedTuple
);
});
});
transport
.
on
(
'icestatechange'
,
(
data
)
=>
transport
.
on
(
'icestatechange'
,
(
data
)
=>
{
{
debug
(
'transport "icestatechange" event [data.iceState:%s, transport.iceState:%s]'
,
data
.
iceState
,
transport
.
iceState
);
debug
(
'transport "icestatechange" event [data.iceState:%s, transport.iceState:%s]'
,
data
.
iceState
,
transport
.
iceState
);
});
});
transport
.
on
(
'dtlsstatechange'
,
(
data
)
=>
transport
.
on
(
'dtlsstatechange'
,
(
data
)
=>
{
{
debug
(
'transport "dtlsstatechange" event [data.dtlsState:%s, transport.dtlsState:%s]'
,
data
.
dtlsState
,
transport
.
dtlsState
);
debug
(
'transport "dtlsstatechange" event [data.dtlsState:%s, transport.dtlsState:%s]'
,
data
.
dtlsState
,
transport
.
dtlsState
);
});
});
return
transport
;
return
transport
;
})
})
.
catch
((
error
)
=>
debugerror
(
'SOMETHING FAILED: %s]'
,
error
));
.
catch
((
error
)
=>
debugerror
(
'SOMETHING FAILED: %s]'
,
error
));
// Add the transport promise to the array of promises
// Add the transport promise to the array of promises
transportPromises
.
push
(
promise
);
transportPromises
.
push
(
promise
);
...
...
worker/include/Channel/Notifier.h
浏览文件 @
2f6bf193
...
@@ -16,8 +16,8 @@ namespace Channel
...
@@ -16,8 +16,8 @@ namespace Channel
void
Close
();
void
Close
();
void
Emit
(
uint32_t
targetId
,
std
::
string
event
Name
);
void
Emit
(
uint32_t
targetId
,
std
::
string
event
);
void
Emit
(
uint32_t
targetId
,
std
::
string
event
Name
,
Json
::
Value
&
eventD
ata
);
void
Emit
(
uint32_t
targetId
,
std
::
string
event
,
Json
::
Value
&
d
ata
);
public
:
public
:
// Passed by argument.
// Passed by argument.
...
...
worker/include/RTC/RTPPacket.h
浏览文件 @
2f6bf193
...
@@ -57,7 +57,7 @@ namespace RTC
...
@@ -57,7 +57,7 @@ namespace RTC
uint16_t
GetSequenceNumber
();
uint16_t
GetSequenceNumber
();
uint32_t
GetTimestamp
();
uint32_t
GetTimestamp
();
uint32_t
GetSSRC
();
uint32_t
GetSSRC
();
void
SetSSRC
(
uint32_t
ssrc
);
void
SetSSRC
(
uint32_t
ssrc
);
// TODO: yes?
bool
HasExtensionHeader
();
bool
HasExtensionHeader
();
uint16_t
GetExtensionHeaderId
();
uint16_t
GetExtensionHeaderId
();
size_t
GetExtensionHeaderLength
();
size_t
GetExtensionHeaderLength
();
...
@@ -138,19 +138,19 @@ namespace RTC
...
@@ -138,19 +138,19 @@ namespace RTC
inline
inline
uint16_t
RTPPacket
::
GetSequenceNumber
()
uint16_t
RTPPacket
::
GetSequenceNumber
()
{
{
return
ntohs
(
this
->
header
->
sequence_number
);
return
(
uint16_t
)
ntohs
(
this
->
header
->
sequence_number
);
}
}
inline
inline
uint32_t
RTPPacket
::
GetTimestamp
()
uint32_t
RTPPacket
::
GetTimestamp
()
{
{
return
ntohl
(
this
->
header
->
timestamp
);
return
(
uint32_t
)
ntohl
(
this
->
header
->
timestamp
);
}
}
inline
inline
uint32_t
RTPPacket
::
GetSSRC
()
uint32_t
RTPPacket
::
GetSSRC
()
{
{
return
ntohl
(
this
->
header
->
ssrc
);
return
(
uint32_t
)
ntohl
(
this
->
header
->
ssrc
);
}
}
// TODO temp
// TODO temp
...
...
worker/include/RTC/RtpListener.h
0 → 100644
浏览文件 @
2f6bf193
#ifndef MS_RTC_RTP_LISTENER_H
#define MS_RTC_RTP_LISTENER_H
#include "common.h"
#include "RTC/RTPPacket.h"
#include "RTC/RtpReceiver.h"
#include <unordered_map>
#include <json/json.h>
namespace
RTC
{
class
RtpListener
:
public
RTC
::
RtpReceiver
::
RtpListener
{
public
:
RtpListener
();
~
RtpListener
();
Json
::
Value
toJson
();
private
:
void
RemoveRtpReceiverFromRtpListener
(
RTC
::
RtpReceiver
*
rtpReceiver
);
public
:
/* Pure virtual methods inherited from RTC::RtpReceiver::RtpListener. */
virtual
void
onRtpListenerParameters
(
RTC
::
RtpReceiver
*
rtpReceiver
,
RTC
::
RtpParameters
*
rtpParameters
)
override
;
virtual
void
onRtpReceiverClosed
(
RTC
::
RtpReceiver
*
rtpReceiver
)
override
;
private
:
// Others.
// - Table of SSRC / RtpReceiver pairs.
std
::
unordered_map
<
uint32_t
,
RTC
::
RtpReceiver
*>
ssrcTable
;
// - Table of MID RTP header extension / RtpReceiver pairs.
// std::unordered_map<uint16_t, RTC::RtpReceiver*> midTable;
// - Table of RTP payload type / RtpReceiver pairs.
std
::
unordered_map
<
uint8_t
,
RTC
::
RtpReceiver
*>
ptTable
;
};
}
#endif
worker/include/RTC/Transport.h
浏览文件 @
2f6bf193
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
#define MS_RTC_TRANSPORT_H
#define MS_RTC_TRANSPORT_H
#include "common.h"
#include "common.h"
#include "RTC/RtpListener.h"
#include "RTC/UDPSocket.h"
#include "RTC/UDPSocket.h"
#include "RTC/TCPServer.h"
#include "RTC/TCPServer.h"
#include "RTC/TCPConnection.h"
#include "RTC/TCPConnection.h"
...
@@ -23,12 +24,12 @@
...
@@ -23,12 +24,12 @@
namespace
RTC
namespace
RTC
{
{
class
Transport
:
class
Transport
:
public
RTC
::
RtpListener
,
public
RTC
::
UDPSocket
::
Listener
,
public
RTC
::
UDPSocket
::
Listener
,
public
RTC
::
TCPServer
::
Listener
,
public
RTC
::
TCPServer
::
Listener
,
public
RTC
::
TCPConnection
::
Listener
,
public
RTC
::
TCPConnection
::
Listener
,
public
RTC
::
ICEServer
::
Listener
,
public
RTC
::
ICEServer
::
Listener
,
public
RTC
::
DTLSTransport
::
Listener
,
public
RTC
::
DTLSTransport
::
Listener
public
RTC
::
RtpReceiver
::
RtpListener
{
{
public
:
public
:
class
Listener
class
Listener
...
@@ -37,17 +38,6 @@ namespace RTC
...
@@ -37,17 +38,6 @@ namespace RTC
virtual
void
onTransportClosed
(
RTC
::
Transport
*
transport
)
=
0
;
virtual
void
onTransportClosed
(
RTC
::
Transport
*
transport
)
=
0
;
};
};
private
:
struct
RtpListener
{
// - Table of SSRC / RtpReceiver pairs.
std
::
unordered_map
<
uint32_t
,
RTC
::
RtpReceiver
*>
ssrcTable
;
// - Table of MID RTP header extension / RtpReceiver pairs.
// std::unordered_map<uint16_t, RTC::RtpReceiver*> midTable;
// - Table of RTP payload type / RtpReceiver pairs.
std
::
unordered_map
<
uint8_t
,
RTC
::
RtpReceiver
*>
ptTable
;
};
public
:
public
:
Transport
(
Listener
*
listener
,
Channel
::
Notifier
*
notifier
,
uint32_t
transportId
,
Json
::
Value
&
data
,
Transport
*
rtpTransport
=
nullptr
);
Transport
(
Listener
*
listener
,
Channel
::
Notifier
*
notifier
,
uint32_t
transportId
,
Json
::
Value
&
data
,
Transport
*
rtpTransport
=
nullptr
);
virtual
~
Transport
();
virtual
~
Transport
();
...
@@ -61,7 +51,6 @@ namespace RTC
...
@@ -61,7 +51,6 @@ namespace RTC
private
:
private
:
void
MayRunDTLSTransport
();
void
MayRunDTLSTransport
();
void
RemoveRtpReceiverFromRtpListener
(
RTC
::
RtpReceiver
*
rtpReceiver
);
/* Private methods to unify UDP and TCP behavior. */
/* Private methods to unify UDP and TCP behavior. */
private
:
private
:
...
@@ -100,10 +89,6 @@ namespace RTC
...
@@ -100,10 +89,6 @@ namespace RTC
virtual
void
onOutgoingDTLSData
(
RTC
::
DTLSTransport
*
dtlsTransport
,
const
uint8_t
*
data
,
size_t
len
)
override
;
virtual
void
onOutgoingDTLSData
(
RTC
::
DTLSTransport
*
dtlsTransport
,
const
uint8_t
*
data
,
size_t
len
)
override
;
virtual
void
onDTLSApplicationData
(
RTC
::
DTLSTransport
*
dtlsTransport
,
const
uint8_t
*
data
,
size_t
len
)
override
;
virtual
void
onDTLSApplicationData
(
RTC
::
DTLSTransport
*
dtlsTransport
,
const
uint8_t
*
data
,
size_t
len
)
override
;
/* Pure virtual methods inherited from RTC::RtpReceiver::RtpListener. */
virtual
void
onRtpListenerParameters
(
RTC
::
RtpReceiver
*
rtpReceiver
,
RTC
::
RtpParameters
*
rtpParameters
)
override
;
virtual
void
onRtpReceiverClosed
(
RTC
::
RtpReceiver
*
rtpReceiver
)
override
;
public
:
public
:
// Passed by argument.
// Passed by argument.
uint32_t
transportId
;
uint32_t
transportId
;
...
@@ -132,8 +117,6 @@ namespace RTC
...
@@ -132,8 +117,6 @@ namespace RTC
// Others (DTLS).
// Others (DTLS).
bool
remoteDtlsParametersGiven
=
false
;
bool
remoteDtlsParametersGiven
=
false
;
RTC
::
DTLSTransport
::
Role
dtlsLocalRole
=
RTC
::
DTLSTransport
::
Role
::
AUTO
;
RTC
::
DTLSTransport
::
Role
dtlsLocalRole
=
RTC
::
DTLSTransport
::
Role
::
AUTO
;
// Others (RTP listener).
RtpListener
rtpListener
;
};
};
/* Inline methods. */
/* Inline methods. */
...
...
worker/include/Settings.h
浏览文件 @
2f6bf193
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
#define MS_SETTINGS_H
#define MS_SETTINGS_H
#include "common.h"
#include "common.h"
#include "
l
ogLevel.h"
#include "
L
ogLevel.h"
#include "Channel/Request.h"
#include "Channel/Request.h"
#include <map>
#include <map>
#include <string>
#include <string>
...
...
worker/include/common.h
浏览文件 @
2f6bf193
#ifndef MS_COMMON_H
#ifndef MS_COMMON_H
#define MS_COMMON_H
#define MS_COMMON_H
#include <memory> // std::addressof()
#include <cstddef> // size_t
#include <cstddef> // size_t
#include <cstdint> // uint8_t, etc
#include <cstdint> // uint8_t, etc
#include <cinttypes> // PRIu64, etc
#include <cinttypes> // PRIu64, etc
...
...
worker/src/Channel/Notifier.cpp
浏览文件 @
2f6bf193
...
@@ -5,10 +5,6 @@
...
@@ -5,10 +5,6 @@
namespace
Channel
namespace
Channel
{
{
/* Static variables. */
static
Json
::
Value
empty_data
(
Json
::
objectValue
);
/* Instance methods. */
/* Instance methods. */
Notifier
::
Notifier
(
Channel
::
UnixStreamSocket
*
channel
)
:
Notifier
::
Notifier
(
Channel
::
UnixStreamSocket
*
channel
)
:
...
@@ -29,30 +25,33 @@ namespace Channel
...
@@ -29,30 +25,33 @@ namespace Channel
delete
this
;
delete
this
;
}
}
void
Notifier
::
Emit
(
uint32_t
targetId
,
std
::
string
event
Name
)
void
Notifier
::
Emit
(
uint32_t
targetId
,
std
::
string
event
)
{
{
MS_TRACE
();
MS_TRACE
();
Emit
(
targetId
,
eventName
,
empty_data
);
static
Json
::
Value
empty_data
(
Json
::
objectValue
);
Emit
(
targetId
,
event
,
empty_data
);
}
}
void
Notifier
::
Emit
(
uint32_t
targetId
,
std
::
string
event
Name
,
Json
::
Value
&
eventD
ata
)
void
Notifier
::
Emit
(
uint32_t
targetId
,
std
::
string
event
,
Json
::
Value
&
d
ata
)
{
{
MS_TRACE
();
MS_TRACE
();
static
Json
::
Value
empty_data
(
Json
::
objectValue
);
static
const
Json
::
StaticString
k_targetId
(
"targetId"
);
static
const
Json
::
StaticString
k_targetId
(
"targetId"
);
static
const
Json
::
StaticString
k_event
Name
(
"eventName
"
);
static
const
Json
::
StaticString
k_event
(
"event
"
);
static
const
Json
::
StaticString
k_
eventData
(
"eventD
ata"
);
static
const
Json
::
StaticString
k_
data
(
"d
ata"
);
Json
::
Value
json
;
Json
::
Value
json
(
Json
::
objectValue
)
;
json
[
k_targetId
]
=
targetId
;
json
[
k_targetId
]
=
(
Json
::
UInt
)
targetId
;
json
[
k_event
Name
]
=
eventName
;
json
[
k_event
]
=
event
;
if
(
eventD
ata
.
isObject
())
if
(
d
ata
.
isObject
())
json
[
k_
eventData
]
=
eventD
ata
;
json
[
k_
data
]
=
d
ata
;
else
else
json
[
k_
eventD
ata
]
=
empty_data
;
json
[
k_
d
ata
]
=
empty_data
;
this
->
channel
->
Send
(
json
);
this
->
channel
->
Send
(
json
);
}
}
...
...
worker/src/Channel/Request.cpp
浏览文件 @
2f6bf193
...
@@ -6,10 +6,6 @@
...
@@ -6,10 +6,6 @@
namespace
Channel
namespace
Channel
{
{
/* Static variables. */
static
Json
::
Value
empty_data
(
Json
::
objectValue
);
/* Class variables. */
/* Class variables. */
std
::
unordered_map
<
std
::
string
,
Request
::
MethodId
>
Request
::
string2MethodId
=
std
::
unordered_map
<
std
::
string
,
Request
::
MethodId
>
Request
::
string2MethodId
=
...
@@ -88,6 +84,8 @@ namespace Channel
...
@@ -88,6 +84,8 @@ namespace Channel
{
{
MS_TRACE
();
MS_TRACE
();
static
Json
::
Value
empty_data
(
Json
::
objectValue
);
Accept
(
empty_data
);
Accept
(
empty_data
);
}
}
...
@@ -95,16 +93,17 @@ namespace Channel
...
@@ -95,16 +93,17 @@ namespace Channel
{
{
MS_TRACE
();
MS_TRACE
();
MS_ASSERT
(
!
this
->
replied
,
"Request already replied"
);
static
Json
::
Value
empty_data
(
Json
::
objectValue
);
this
->
replied
=
true
;
static
const
Json
::
StaticString
k_id
(
"id"
);
static
const
Json
::
StaticString
k_id
(
"id"
);
static
const
Json
::
StaticString
k_accepted
(
"accepted"
);
static
const
Json
::
StaticString
k_accepted
(
"accepted"
);
static
const
Json
::
StaticString
k_data
(
"data"
);
static
const
Json
::
StaticString
k_data
(
"data"
);
Json
::
Value
json
;
MS_ASSERT
(
!
this
->
replied
,
"Request already replied"
);
this
->
replied
=
true
;
json
[
k_id
]
=
this
->
id
;
Json
::
Value
json
(
Json
::
objectValue
);
json
[
k_id
]
=
(
Json
::
UInt
)
this
->
id
;
json
[
k_accepted
]
=
true
;
json
[
k_accepted
]
=
true
;
if
(
data
.
isObject
())
if
(
data
.
isObject
())
...
@@ -130,16 +129,16 @@ namespace Channel
...
@@ -130,16 +129,16 @@ namespace Channel
{
{
MS_TRACE
();
MS_TRACE
();
MS_ASSERT
(
!
this
->
replied
,
"Request already replied"
);
this
->
replied
=
true
;
static
const
Json
::
StaticString
k_id
(
"id"
);
static
const
Json
::
StaticString
k_id
(
"id"
);
static
const
Json
::
StaticString
k_rejected
(
"rejected"
);
static
const
Json
::
StaticString
k_rejected
(
"rejected"
);
static
const
Json
::
StaticString
k_reason
(
"reason"
);
static
const
Json
::
StaticString
k_reason
(
"reason"
);
Json
::
Value
json
;
MS_ASSERT
(
!
this
->
replied
,
"Request already replied"
);
this
->
replied
=
true
;
Json
::
Value
json
(
Json
::
objectValue
);
json
[
k_id
]
=
this
->
id
;
json
[
k_id
]
=
(
Json
::
UInt
)
this
->
id
;
json
[
k_rejected
]
=
true
;
json
[
k_rejected
]
=
true
;
if
(
reason
)
if
(
reason
)
...
...
worker/src/RTC/ICEServer.cpp
浏览文件 @
2f6bf193
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
#include "RTC/ICEServer.h"
#include "RTC/ICEServer.h"
#include "Logger.h"
#include "Logger.h"
#include <memory> // std::addressof()
namespace
RTC
namespace
RTC
{
{
...
...
worker/src/RTC/IceCandidate.cpp
浏览文件 @
2f6bf193
...
@@ -39,12 +39,12 @@ namespace RTC
...
@@ -39,12 +39,12 @@ namespace RTC
static
const
Json
::
StaticString
k_tcpType
(
"tcpType"
);
static
const
Json
::
StaticString
k_tcpType
(
"tcpType"
);
static
const
Json
::
StaticString
v_passive
(
"passive"
);
static
const
Json
::
StaticString
v_passive
(
"passive"
);
Json
::
Value
json
;
Json
::
Value
json
(
Json
::
objectValue
)
;
json
[
k_foundation
]
=
this
->
foundation
;
json
[
k_foundation
]
=
this
->
foundation
;
json
[
k_priority
]
=
this
->
priority
;
json
[
k_priority
]
=
(
Json
::
UInt
)
this
->
priority
;
json
[
k_ip
]
=
this
->
ip
;
json
[
k_ip
]
=
this
->
ip
;
json
[
k_port
]
=
this
->
port
;
json
[
k_port
]
=
(
Json
::
UInt
)
this
->
port
;
switch
(
this
->
type
)
switch
(
this
->
type
)
{
{
...
...
worker/src/RTC/RtpListener.cpp
0 → 100644
浏览文件 @
2f6bf193
#define MS_CLASS "RTC::RtpListener"
#include "RTC/RtpListener.h"
#include "Logger.h"
#include <string>
namespace
RTC
{
/* Instance methods. */
RtpListener
::
RtpListener
()
{
MS_TRACE
();
}
RtpListener
::~
RtpListener
()
{
MS_TRACE
();
}
Json
::
Value
RtpListener
::
toJson
()
{
MS_TRACE
();
static
const
Json
::
StaticString
k_ssrcTable
(
"ssrcTable"
);
// static const Json::StaticString k_midTable("midTable"); // TODO
static
const
Json
::
StaticString
k_ptTable
(
"ptTable"
);
Json
::
Value
json
(
Json
::
objectValue
);
// Add `ssrcTable`.
Json
::
Value
json_ssrcTable
(
Json
::
objectValue
);
for
(
auto
&
kv
:
this
->
ssrcTable
)
{
auto
ssrc
=
kv
.
first
;
auto
rtpReceiver
=
kv
.
second
;
json_ssrcTable
[
std
::
to_string
(
ssrc
)]
=
std
::
to_string
(
rtpReceiver
->
rtpReceiverId
);
}
json
[
k_ssrcTable
]
=
json_ssrcTable
;
// TODO: Add `midTable`.
// Add `ptTable`.
Json
::
Value
json_ptTable
(
Json
::
objectValue
);
for
(
auto
&
kv
:
this
->
ptTable
)
{
auto
payloadType
=
kv
.
first
;
auto
rtpReceiver
=
kv
.
second
;
json_ptTable
[
std
::
to_string
(
payloadType
)]
=
std
::
to_string
(
rtpReceiver
->
rtpReceiverId
);
}
json
[
k_ptTable
]
=
json_ptTable
;
return
json
;
}
inline
void
RtpListener
::
RemoveRtpReceiverFromRtpListener
(
RTC
::
RtpReceiver
*
rtpReceiver
)
{
MS_TRACE
();
for
(
auto
it
=
this
->
ssrcTable
.
begin
();
it
!=
this
->
ssrcTable
.
end
();)
{
if
(
it
->
second
==
rtpReceiver
)
it
=
this
->
ssrcTable
.
erase
(
it
);
else
it
++
;
}
// TODO: midTable
for
(
auto
it
=
this
->
ptTable
.
begin
();
it
!=
this
->
ptTable
.
end
();)
{
if
(
it
->
second
==
rtpReceiver
)
it
=
this
->
ptTable
.
erase
(
it
);
else
it
++
;
}
}
void
RtpListener
::
onRtpListenerParameters
(
RTC
::
RtpReceiver
*
rtpReceiver
,
RTC
::
RtpParameters
*
rtpParameters
)
{
MS_TRACE
();
// First remove from the rtpListener all the entries pointing to the given rtpReceiver.
RemoveRtpReceiverFromRtpListener
(
rtpReceiver
);
// Add entries into ssrcTable.
for
(
auto
&
encoding
:
rtpParameters
->
encodings
)
{
// TODO: This should throw if the ssrc already exists in the table,
// and the receive() should Reject() the Request.
if
(
encoding
.
ssrc
)
this
->
ssrcTable
[
encoding
.
ssrc
]
=
rtpReceiver
;
}
// TODO: // Add entries into midTable.
// Add entries into ptTable.
// TODO: This is wrong, pt should not be added if ssrc are added.
for
(
auto
&
codec
:
rtpParameters
->
codecs
)
{
this
->
ptTable
[
codec
.
payloadType
]
=
rtpReceiver
;
}
}
void
RtpListener
::
onRtpReceiverClosed
(
RTC
::
RtpReceiver
*
rtpReceiver
)
{
MS_TRACE
();
// Remove from the rtpListener all the entries pointing to the given rtpReceiver.
RemoveRtpReceiverFromRtpListener
(
rtpReceiver
);
}
}
worker/src/RTC/RtpParameters.cpp
浏览文件 @
2f6bf193
...
@@ -4,7 +4,6 @@
...
@@ -4,7 +4,6 @@
// #include "Utils.h" // TODO: let's see
// #include "Utils.h" // TODO: let's see
#include "MediaSoupError.h"
#include "MediaSoupError.h"
#include "Logger.h"
#include "Logger.h"
#include <memory> // std::addressof()
namespace
RTC
namespace
RTC
{
{
...
@@ -57,7 +56,7 @@ namespace RTC
...
@@ -57,7 +56,7 @@ namespace RTC
static
const
Json
::
StaticString
k_encodings
(
"encodings"
);
static
const
Json
::
StaticString
k_encodings
(
"encodings"
);
static
const
Json
::
StaticString
k_ssrc
(
"ssrc"
);
static
const
Json
::
StaticString
k_ssrc
(
"ssrc"
);
Json
::
Value
json
;
Json
::
Value
json
(
Json
::
objectValue
)
;
// Add `muxId`.
// Add `muxId`.
json
[
k_muxId
]
=
this
->
muxId
;
json
[
k_muxId
]
=
this
->
muxId
;
...
...
worker/src/RTC/RtpReceiver.cpp
浏览文件 @
2f6bf193
...
@@ -45,14 +45,15 @@ namespace RTC
...
@@ -45,14 +45,15 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
static
Json
::
Value
null_data
(
Json
::
nullValue
);
static
const
Json
::
StaticString
k_rtpParameters
(
"rtpParameters"
);
static
const
Json
::
StaticString
k_rtpParameters
(
"rtpParameters"
);
Json
::
Value
json
;
Json
::
Value
json
(
Json
::
objectValue
)
;
if
(
this
->
rtpParameters
)
if
(
this
->
rtpParameters
)
json
[
k_rtpParameters
]
=
this
->
rtpParameters
->
toJson
();
json
[
k_rtpParameters
]
=
this
->
rtpParameters
->
toJson
();
else
else
json
[
k_rtpParameters
]
=
Json
::
nullValue
;
json
[
k_rtpParameters
]
=
null_data
;
return
json
;
return
json
;
}
}
...
...
worker/src/RTC/Transport.cpp
浏览文件 @
2f6bf193
...
@@ -292,11 +292,8 @@ namespace RTC
...
@@ -292,11 +292,8 @@ namespace RTC
static
const
Json
::
StaticString
v_closed
(
"closed"
);
static
const
Json
::
StaticString
v_closed
(
"closed"
);
static
const
Json
::
StaticString
v_failed
(
"failed"
);
static
const
Json
::
StaticString
v_failed
(
"failed"
);
static
const
Json
::
StaticString
k_rtpListener
(
"rtpListener"
);
static
const
Json
::
StaticString
k_rtpListener
(
"rtpListener"
);
static
const
Json
::
StaticString
k_ssrcTable
(
"ssrcTable"
);
// static const Json::StaticString k_midTable("midTable"); // TODO
static
const
Json
::
StaticString
k_ptTable
(
"ptTable"
);
Json
::
Value
json
;
Json
::
Value
json
(
Json
::
objectValue
)
;
// Add `iceRole` (we are always "controlled").
// Add `iceRole` (we are always "controlled").
json
[
k_iceRole
]
=
v_controlled
;
json
[
k_iceRole
]
=
v_controlled
;
...
@@ -378,31 +375,8 @@ namespace RTC
...
@@ -378,31 +375,8 @@ namespace RTC
break
;
break
;
}
}
// Add `rtpListener.ssrcTable`.
// Add `rtpListener`.
Json
::
Value
json_ssrcTable
(
Json
::
objectValue
);
json
[
k_rtpListener
]
=
RTC
::
RtpListener
::
toJson
();
for
(
auto
&
kv
:
this
->
rtpListener
.
ssrcTable
)
{
auto
ssrc
=
kv
.
first
;
auto
rtpReceiver
=
kv
.
second
;
json_ssrcTable
[
std
::
to_string
(
ssrc
)]
=
std
::
to_string
(
rtpReceiver
->
rtpReceiverId
);
}
json
[
k_rtpListener
][
k_ssrcTable
]
=
json_ssrcTable
;
// TODO: Add `midTable`.
// Add `rtpListener.ptTable`.
Json
::
Value
json_ptTable
(
Json
::
objectValue
);
for
(
auto
&
kv
:
this
->
rtpListener
.
ptTable
)
{
auto
payloadType
=
kv
.
first
;
auto
rtpReceiver
=
kv
.
second
;
json_ptTable
[
std
::
to_string
(
payloadType
)]
=
std
::
to_string
(
rtpReceiver
->
rtpReceiverId
);
}
json
[
k_rtpListener
][
k_ptTable
]
=
json_ptTable
;
return
json
;
return
json
;
}
}
...
@@ -511,7 +485,7 @@ namespace RTC
...
@@ -511,7 +485,7 @@ namespace RTC
return
;
return
;
}
}
Json
::
Value
data
;
Json
::
Value
data
(
Json
::
objectValue
)
;
switch
(
this
->
dtlsLocalRole
)
switch
(
this
->
dtlsLocalRole
)
{
{
...
@@ -549,12 +523,12 @@ namespace RTC
...
@@ -549,12 +523,12 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
static
Json
::
Value
null
D
ata
(
Json
::
nullValue
);
static
Json
::
Value
null
_d
ata
(
Json
::
nullValue
);
if
(
this
->
iceServer
->
GetComponent
()
!=
ICEServer
::
IceComponent
::
RTP
)
if
(
this
->
iceServer
->
GetComponent
()
!=
ICEServer
::
IceComponent
::
RTP
)
MS_THROW_ERROR
(
"cannot call CreateAssociatedTransport() on a RTCP Transport"
);
MS_THROW_ERROR
(
"cannot call CreateAssociatedTransport() on a RTCP Transport"
);
return
new
RTC
::
Transport
(
this
->
listener
,
this
->
notifier
,
transportId
,
null
D
ata
,
this
);
return
new
RTC
::
Transport
(
this
->
listener
,
this
->
notifier
,
transportId
,
null
_d
ata
,
this
);
}
}
inline
inline
...
@@ -612,30 +586,6 @@ namespace RTC
...
@@ -612,30 +586,6 @@ namespace RTC
}
}
}
}
inline
void
Transport
::
RemoveRtpReceiverFromRtpListener
(
RTC
::
RtpReceiver
*
rtpReceiver
)
{
MS_TRACE
();
for
(
auto
it
=
this
->
rtpListener
.
ssrcTable
.
begin
();
it
!=
this
->
rtpListener
.
ssrcTable
.
end
();)
{
if
(
it
->
second
==
rtpReceiver
)
it
=
this
->
rtpListener
.
ssrcTable
.
erase
(
it
);
else
it
++
;
}
// TODO: midTable
for
(
auto
it
=
this
->
rtpListener
.
ptTable
.
begin
();
it
!=
this
->
rtpListener
.
ptTable
.
end
();)
{
if
(
it
->
second
==
rtpReceiver
)
it
=
this
->
rtpListener
.
ptTable
.
erase
(
it
);
else
it
++
;
}
}
inline
inline
void
Transport
::
onPacketRecv
(
RTC
::
TransportTuple
*
tuple
,
const
uint8_t
*
data
,
size_t
len
)
void
Transport
::
onPacketRecv
(
RTC
::
TransportTuple
*
tuple
,
const
uint8_t
*
data
,
size_t
len
)
{
{
...
@@ -731,6 +681,7 @@ namespace RTC
...
@@ -731,6 +681,7 @@ namespace RTC
}
}
// Trick for clients performing aggressive ICE regardless we are ICE-Lite.
// Trick for clients performing aggressive ICE regardless we are ICE-Lite.
// TODO: Do this just after validating SRTP and so on.
this
->
iceServer
->
ForceSelectedTuple
(
tuple
);
this
->
iceServer
->
ForceSelectedTuple
(
tuple
);
// TODO
// TODO
...
@@ -744,6 +695,16 @@ namespace RTC
...
@@ -744,6 +695,16 @@ namespace RTC
return
;
return
;
}
}
packet
->
Dump
();
packet
->
Dump
();
// Check the rtpListener tables.
// auto it = this->rtpListener.ssrcTable.find(packet->GetSSRC());
// if (it == this->rtpListener.ssrcTable.end())
// {
// MS_WARN("received RTP packet does not belong to the SSRC table");
// }
delete
packet
;
delete
packet
;
}
}
...
@@ -808,7 +769,7 @@ namespace RTC
...
@@ -808,7 +769,7 @@ namespace RTC
static
const
Json
::
StaticString
k_iceSelectedTuple
(
"iceSelectedTuple"
);
static
const
Json
::
StaticString
k_iceSelectedTuple
(
"iceSelectedTuple"
);
Json
::
Value
event
Data
;
Json
::
Value
event
_data
(
Json
::
objectValue
)
;
/*
/*
* RFC 5245 section 11.2 "Receiving Media":
* RFC 5245 section 11.2 "Receiving Media":
...
@@ -821,8 +782,8 @@ namespace RTC
...
@@ -821,8 +782,8 @@ namespace RTC
this
->
selectedTuple
=
tuple
;
this
->
selectedTuple
=
tuple
;
// Notify.
// Notify.
event
D
ata
[
k_iceSelectedTuple
]
=
tuple
->
toJson
();
event
_d
ata
[
k_iceSelectedTuple
]
=
tuple
->
toJson
();
this
->
notifier
->
Emit
(
this
->
transportId
,
"iceselectedtuplechange"
,
event
D
ata
);
this
->
notifier
->
Emit
(
this
->
transportId
,
"iceselectedtuplechange"
,
event
_d
ata
);
}
}
void
Transport
::
onICEConnected
(
RTC
::
ICEServer
*
iceServer
)
void
Transport
::
onICEConnected
(
RTC
::
ICEServer
*
iceServer
)
...
@@ -832,13 +793,13 @@ namespace RTC
...
@@ -832,13 +793,13 @@ namespace RTC
static
const
Json
::
StaticString
k_iceState
(
"iceState"
);
static
const
Json
::
StaticString
k_iceState
(
"iceState"
);
static
const
Json
::
StaticString
v_connected
(
"connected"
);
static
const
Json
::
StaticString
v_connected
(
"connected"
);
Json
::
Value
event
Data
;
Json
::
Value
event
_data
(
Json
::
objectValue
)
;
MS_DEBUG
(
"ICE connected"
);
MS_DEBUG
(
"ICE connected"
);
// Notify.
// Notify.
event
D
ata
[
k_iceState
]
=
v_connected
;
event
_d
ata
[
k_iceState
]
=
v_connected
;
this
->
notifier
->
Emit
(
this
->
transportId
,
"icestatechange"
,
event
D
ata
);
this
->
notifier
->
Emit
(
this
->
transportId
,
"icestatechange"
,
event
_d
ata
);
// If ready, run the DTLS handler.
// If ready, run the DTLS handler.
MayRunDTLSTransport
();
MayRunDTLSTransport
();
...
@@ -851,13 +812,13 @@ namespace RTC
...
@@ -851,13 +812,13 @@ namespace RTC
static
const
Json
::
StaticString
k_iceState
(
"iceState"
);
static
const
Json
::
StaticString
k_iceState
(
"iceState"
);
static
const
Json
::
StaticString
v_completed
(
"completed"
);
static
const
Json
::
StaticString
v_completed
(
"completed"
);
Json
::
Value
event
Data
;
Json
::
Value
event
_data
(
Json
::
objectValue
)
;
MS_DEBUG
(
"ICE completed"
);
MS_DEBUG
(
"ICE completed"
);
// Notify.
// Notify.
event
D
ata
[
k_iceState
]
=
v_completed
;
event
_d
ata
[
k_iceState
]
=
v_completed
;
this
->
notifier
->
Emit
(
this
->
transportId
,
"icestatechange"
,
event
D
ata
);
this
->
notifier
->
Emit
(
this
->
transportId
,
"icestatechange"
,
event
_d
ata
);
// If ready, run the DTLS handler.
// If ready, run the DTLS handler.
MayRunDTLSTransport
();
MayRunDTLSTransport
();
...
@@ -870,7 +831,7 @@ namespace RTC
...
@@ -870,7 +831,7 @@ namespace RTC
static
const
Json
::
StaticString
k_iceState
(
"iceState"
);
static
const
Json
::
StaticString
k_iceState
(
"iceState"
);
static
const
Json
::
StaticString
v_disconnected
(
"disconnected"
);
static
const
Json
::
StaticString
v_disconnected
(
"disconnected"
);
Json
::
Value
event
Data
;
Json
::
Value
event
_data
(
Json
::
objectValue
)
;
MS_DEBUG
(
"ICE disconnected"
);
MS_DEBUG
(
"ICE disconnected"
);
...
@@ -878,8 +839,8 @@ namespace RTC
...
@@ -878,8 +839,8 @@ namespace RTC
this
->
selectedTuple
=
nullptr
;
this
->
selectedTuple
=
nullptr
;
// Notify.
// Notify.
event
D
ata
[
k_iceState
]
=
v_disconnected
;
event
_d
ata
[
k_iceState
]
=
v_disconnected
;
this
->
notifier
->
Emit
(
this
->
transportId
,
"icestatechange"
,
event
D
ata
);
this
->
notifier
->
Emit
(
this
->
transportId
,
"icestatechange"
,
event
_d
ata
);
// This is a fatal error so close the transport.
// This is a fatal error so close the transport.
Close
();
Close
();
...
@@ -892,13 +853,13 @@ namespace RTC
...
@@ -892,13 +853,13 @@ namespace RTC
static
const
Json
::
StaticString
k_dtlsState
(
"dtlsState"
);
static
const
Json
::
StaticString
k_dtlsState
(
"dtlsState"
);
static
const
Json
::
StaticString
v_connecting
(
"connecting"
);
static
const
Json
::
StaticString
v_connecting
(
"connecting"
);
Json
::
Value
event
Data
;
Json
::
Value
event
_data
(
Json
::
objectValue
)
;
MS_DEBUG
(
"DTLS connecting"
);
MS_DEBUG
(
"DTLS connecting"
);
// Notify.
// Notify.
event
D
ata
[
k_dtlsState
]
=
v_connecting
;
event
_d
ata
[
k_dtlsState
]
=
v_connecting
;
this
->
notifier
->
Emit
(
this
->
transportId
,
"dtlsstatechange"
,
event
D
ata
);
this
->
notifier
->
Emit
(
this
->
transportId
,
"dtlsstatechange"
,
event
_d
ata
);
}
}
void
Transport
::
onDTLSConnected
(
RTC
::
DTLSTransport
*
dtlsTransport
,
RTC
::
SRTPSession
::
SRTPProfile
srtp_profile
,
uint8_t
*
srtp_local_key
,
size_t
srtp_local_key_len
,
uint8_t
*
srtp_remote_key
,
size_t
srtp_remote_key_len
)
void
Transport
::
onDTLSConnected
(
RTC
::
DTLSTransport
*
dtlsTransport
,
RTC
::
SRTPSession
::
SRTPProfile
srtp_profile
,
uint8_t
*
srtp_local_key
,
size_t
srtp_local_key_len
,
uint8_t
*
srtp_remote_key
,
size_t
srtp_remote_key_len
)
...
@@ -908,7 +869,7 @@ namespace RTC
...
@@ -908,7 +869,7 @@ namespace RTC
static
const
Json
::
StaticString
k_dtlsState
(
"dtlsState"
);
static
const
Json
::
StaticString
k_dtlsState
(
"dtlsState"
);
static
const
Json
::
StaticString
v_connected
(
"connected"
);
static
const
Json
::
StaticString
v_connected
(
"connected"
);
Json
::
Value
event
Data
;
Json
::
Value
event
_data
(
Json
::
objectValue
)
;
MS_DEBUG
(
"DTLS connected"
);
MS_DEBUG
(
"DTLS connected"
);
...
@@ -917,8 +878,8 @@ namespace RTC
...
@@ -917,8 +878,8 @@ namespace RTC
// SetRemoteSRTPKey(srtp_profile, srtp_remote_key, srtp_remote_key_len);
// SetRemoteSRTPKey(srtp_profile, srtp_remote_key, srtp_remote_key_len);
// Notify.
// Notify.
event
D
ata
[
k_dtlsState
]
=
v_connected
;
event
_d
ata
[
k_dtlsState
]
=
v_connected
;
this
->
notifier
->
Emit
(
this
->
transportId
,
"dtlsstatechange"
,
event
D
ata
);
this
->
notifier
->
Emit
(
this
->
transportId
,
"dtlsstatechange"
,
event
_d
ata
);
}
}
void
Transport
::
onDTLSFailed
(
RTC
::
DTLSTransport
*
dtlsTransport
)
void
Transport
::
onDTLSFailed
(
RTC
::
DTLSTransport
*
dtlsTransport
)
...
@@ -928,13 +889,13 @@ namespace RTC
...
@@ -928,13 +889,13 @@ namespace RTC
static
const
Json
::
StaticString
k_dtlsState
(
"dtlsState"
);
static
const
Json
::
StaticString
k_dtlsState
(
"dtlsState"
);
static
const
Json
::
StaticString
v_failed
(
"failed"
);
static
const
Json
::
StaticString
v_failed
(
"failed"
);
Json
::
Value
event
Data
;
Json
::
Value
event
_data
(
Json
::
objectValue
)
;
MS_DEBUG
(
"DTLS failed"
);
MS_DEBUG
(
"DTLS failed"
);
// Notify.
// Notify.
event
D
ata
[
k_dtlsState
]
=
v_failed
;
event
_d
ata
[
k_dtlsState
]
=
v_failed
;
this
->
notifier
->
Emit
(
this
->
transportId
,
"dtlsstatechange"
,
event
D
ata
);
this
->
notifier
->
Emit
(
this
->
transportId
,
"dtlsstatechange"
,
event
_d
ata
);
// This is a fatal error so close the transport.
// This is a fatal error so close the transport.
Close
();
Close
();
...
@@ -947,13 +908,13 @@ namespace RTC
...
@@ -947,13 +908,13 @@ namespace RTC
static
const
Json
::
StaticString
k_dtlsState
(
"dtlsState"
);
static
const
Json
::
StaticString
k_dtlsState
(
"dtlsState"
);
static
const
Json
::
StaticString
v_closed
(
"closed"
);
static
const
Json
::
StaticString
v_closed
(
"closed"
);
Json
::
Value
event
Data
;
Json
::
Value
event
_data
(
Json
::
objectValue
)
;
MS_DEBUG
(
"DTLS remotely closed"
);
MS_DEBUG
(
"DTLS remotely closed"
);
// Notify.
// Notify.
event
D
ata
[
k_dtlsState
]
=
v_closed
;
event
_d
ata
[
k_dtlsState
]
=
v_closed
;
this
->
notifier
->
Emit
(
this
->
transportId
,
"dtlsstatechange"
,
event
D
ata
);
this
->
notifier
->
Emit
(
this
->
transportId
,
"dtlsstatechange"
,
event
_d
ata
);
// This is a fatal error so close the transport.
// This is a fatal error so close the transport.
Close
();
Close
();
...
@@ -985,35 +946,4 @@ namespace RTC
...
@@ -985,35 +946,4 @@ namespace RTC
// TMP
// TMP
MS_DEBUG
(
"data: %s"
,
std
::
string
((
char
*
)
data
,
len
).
c_str
());
MS_DEBUG
(
"data: %s"
,
std
::
string
((
char
*
)
data
,
len
).
c_str
());
}
}
void
Transport
::
onRtpListenerParameters
(
RTC
::
RtpReceiver
*
rtpReceiver
,
RTC
::
RtpParameters
*
rtpParameters
)
{
MS_TRACE
();
// First remove from the rtpListener all the entries pointing to the given rtpReceiver.
RemoveRtpReceiverFromRtpListener
(
rtpReceiver
);
// Add entries into rtpListener.ssrcTable.
for
(
auto
&
encoding
:
rtpParameters
->
encodings
)
{
if
(
encoding
.
ssrc
)
this
->
rtpListener
.
ssrcTable
[
encoding
.
ssrc
]
=
rtpReceiver
;
}
// TODO: // Add entries into rtpListener.midTable.
// Add entries into rtpListener.ptTable.
for
(
auto
&
codec
:
rtpParameters
->
codecs
)
{
this
->
rtpListener
.
ptTable
[
codec
.
payloadType
]
=
rtpReceiver
;
}
}
void
Transport
::
onRtpReceiverClosed
(
RTC
::
RtpReceiver
*
rtpReceiver
)
{
MS_TRACE
();
// Remove from the rtpListener all the entries pointing to the given rtpReceiver.
RemoveRtpReceiverFromRtpListener
(
rtpReceiver
);
}
}
}
worker/src/RTC/TransportTuple.cpp
浏览文件 @
2f6bf193
...
@@ -21,16 +21,16 @@ namespace RTC
...
@@ -21,16 +21,16 @@ namespace RTC
static
const
Json
::
StaticString
v_udp
(
"udp"
);
static
const
Json
::
StaticString
v_udp
(
"udp"
);
static
const
Json
::
StaticString
v_tcp
(
"tcp"
);
static
const
Json
::
StaticString
v_tcp
(
"tcp"
);
Json
::
Value
json
;
Json
::
Value
json
(
Json
::
objectValue
)
;
Json
::
Value
json_local
;
Json
::
Value
json_local
(
Json
::
objectValue
)
;
Json
::
Value
json_remote
;
Json
::
Value
json_remote
(
Json
::
objectValue
)
;
int
ip_family
;
int
ip_family
;
std
::
string
ip
;
std
::
string
ip
;
uint16_t
port
;
uint16_t
port
;
Utils
::
IP
::
GetAddressInfo
(
this
->
GetLocalAddress
(),
&
ip_family
,
ip
,
&
port
);
Utils
::
IP
::
GetAddressInfo
(
this
->
GetLocalAddress
(),
&
ip_family
,
ip
,
&
port
);
json_local
[
k_ip
]
=
ip
;
json_local
[
k_ip
]
=
ip
;
json_local
[
k_port
]
=
port
;
json_local
[
k_port
]
=
(
Json
::
UInt
)
port
;
if
(
this
->
GetProtocol
()
==
RTC
::
TransportTuple
::
Protocol
::
UDP
)
if
(
this
->
GetProtocol
()
==
RTC
::
TransportTuple
::
Protocol
::
UDP
)
json_local
[
k_protocol
]
=
v_udp
;
json_local
[
k_protocol
]
=
v_udp
;
else
else
...
@@ -38,7 +38,7 @@ namespace RTC
...
@@ -38,7 +38,7 @@ namespace RTC
Utils
::
IP
::
GetAddressInfo
(
this
->
GetRemoteAddress
(),
&
ip_family
,
ip
,
&
port
);
Utils
::
IP
::
GetAddressInfo
(
this
->
GetRemoteAddress
(),
&
ip_family
,
ip
,
&
port
);
json_remote
[
k_ip
]
=
ip
;
json_remote
[
k_ip
]
=
ip
;
json_remote
[
k_port
]
=
port
;
json_remote
[
k_port
]
=
(
Json
::
UInt
)
port
;
if
(
this
->
GetProtocol
()
==
RTC
::
TransportTuple
::
Protocol
::
UDP
)
if
(
this
->
GetProtocol
()
==
RTC
::
TransportTuple
::
Protocol
::
UDP
)
json_remote
[
k_protocol
]
=
v_udp
;
json_remote
[
k_protocol
]
=
v_udp
;
else
else
...
...
worker/src/handles/Timer.cpp
浏览文件 @
2f6bf193
...
@@ -56,7 +56,7 @@ void Timer::Start(uint64_t timeout)
...
@@ -56,7 +56,7 @@ void Timer::Start(uint64_t timeout)
int
err
;
int
err
;
err
=
uv_timer_start
(
this
->
uvHandle
,
(
uv_timer_cb
)
on_timer
,
(
uint64_t
)
timeout
,
0
);
err
=
uv_timer_start
(
this
->
uvHandle
,
(
uv_timer_cb
)
on_timer
,
timeout
,
0
);
if
(
err
)
if
(
err
)
MS_THROW_ERROR
(
"uv_timer_start() failed: %s"
,
uv_strerror
(
err
));
MS_THROW_ERROR
(
"uv_timer_start() failed: %s"
,
uv_strerror
(
err
));
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论