Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
73373aed
提交
73373aed
authored
12月 21, 2016
作者:
Iñaki Baz Castillo
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'rtpstream'
上级
a09fc2ce
e06b8136
隐藏空白字符变更
内嵌
并排
正在显示
15 个修改的文件
包含
451 行增加
和
232 行删除
+451
-232
options.js
test/data/options.js
+30
-0
test_RtpReceiver.js
test/test_RtpReceiver.js
+11
-6
RtpBuffer.h
worker/include/RTC/RtpBuffer.h
+0
-34
RtpDictionaries.h
worker/include/RTC/RtpDictionaries.h
+2
-16
RtpReceiver.h
worker/include/RTC/RtpReceiver.h
+3
-4
RtpStream.h
worker/include/RTC/RtpStream.h
+59
-0
mediasoup-worker.gyp
worker/mediasoup-worker.gyp
+2
-3
RtpBuffer.cpp
worker/src/RTC/RtpBuffer.cpp
+0
-45
RTCRtpCodecRtxParameters.cpp
worker/src/RTC/RtpDictionaries/RTCRtpCodecRtxParameters.cpp
+0
-50
RtpCodecMime.cpp
worker/src/RTC/RtpDictionaries/RtpCodecMime.cpp
+2
-0
RtpCodecParameters.cpp
worker/src/RTC/RtpDictionaries/RtpCodecParameters.cpp
+22
-26
RtpParameters.cpp
worker/src/RTC/RtpDictionaries/RtpParameters.cpp
+36
-9
RtpListener.cpp
worker/src/RTC/RtpListener.cpp
+1
-29
RtpReceiver.cpp
worker/src/RTC/RtpReceiver.cpp
+16
-10
RtpStream.cpp
worker/src/RTC/RtpStream.cpp
+267
-0
没有找到文件。
test/data/options.js
浏览文件 @
73373aed
...
@@ -71,6 +71,16 @@ module.exports =
...
@@ -71,6 +71,16 @@ module.exports =
payloadType
:
101
,
payloadType
:
101
,
clockRate
:
90000
clockRate
:
90000
},
},
{
kind
:
'video'
,
name
:
'video/rtx'
,
payloadType
:
96
,
clockRate
:
90000
,
parameters
:
{
apt
:
101
}
},
{
{
kind
:
'video'
,
kind
:
'video'
,
name
:
'video/H264'
,
name
:
'video/H264'
,
...
@@ -81,6 +91,16 @@ module.exports =
...
@@ -81,6 +91,16 @@ module.exports =
packetizationMode
:
0
packetizationMode
:
0
}
}
},
},
{
kind
:
'video'
,
name
:
'video/rtx'
,
payloadType
:
97
,
clockRate
:
90000
,
parameters
:
{
apt
:
102
}
},
{
{
kind
:
'video'
,
kind
:
'video'
,
name
:
'video/H264'
,
name
:
'video/H264'
,
...
@@ -90,6 +110,16 @@ module.exports =
...
@@ -90,6 +110,16 @@ module.exports =
{
{
packetizationMode
:
1
packetizationMode
:
1
}
}
},
{
kind
:
'video'
,
name
:
'video/rtx'
,
payloadType
:
98
,
clockRate
:
90000
,
parameters
:
{
apt
:
103
}
}
}
]
]
}
}
...
...
test/test_RtpReceiver.js
浏览文件 @
73373aed
...
@@ -146,13 +146,8 @@ tap.test('rtpReceiver.receive() with full rtpParameters must succeed', { timeout
...
@@ -146,13 +146,8 @@ tap.test('rtpReceiver.receive() with full rtpParameters must succeed', { timeout
maxptime
:
80
,
maxptime
:
80
,
ptime
:
60
,
ptime
:
60
,
numChannels
:
2
,
numChannels
:
2
,
// TODO: uncomment when RT
X and RTCP
implemented
// TODO: uncomment when RT
CP is
implemented
rtcpFeedback
:
[],
rtcpFeedback
:
[],
// rtx :
// {
// payloadType : 96,
// rtxTime : 500
// },
// rtcpFeedback :
// rtcpFeedback :
// [
// [
// { type: 'ccm', parameter: 'fir' },
// { type: 'ccm', parameter: 'fir' },
...
@@ -171,6 +166,16 @@ tap.test('rtpReceiver.receive() with full rtpParameters must succeed', { timeout
...
@@ -171,6 +166,16 @@ tap.test('rtpReceiver.receive() with full rtpParameters must succeed', { timeout
lol
:
-
456.789
,
lol
:
-
456.789
,
ids
:
[
123
,
2
,
3
]
ids
:
[
123
,
2
,
3
]
}
}
},
{
name
:
'video/rtx'
,
payloadType
:
96
,
clockRate
:
90000
,
parameters
:
{
apt
:
101
,
rtxTime
:
500
}
}
}
],
],
encodings
:
encodings
:
...
...
worker/include/RTC/RtpBuffer.h
deleted
100644 → 0
浏览文件 @
a09fc2ce
#ifndef MS_RTC_RTP_BUFFER_H
#define MS_RTC_RTP_BUFFER_H
#include "common.h"
#include "RTC/RtpPacket.h"
#include <vector>
#define MS_RTP_PACKET_MAX_SIZE 65536
namespace
RTC
{
class
RtpBuffer
{
public
:
struct
Item
{
uint8_t
raw
[
MS_RTP_PACKET_MAX_SIZE
];
RTC
::
RtpPacket
*
packet
=
nullptr
;
};
public
:
RtpBuffer
(
size_t
capability
);
virtual
~
RtpBuffer
();
void
Add
(
RTC
::
RtpPacket
*
packet
);
private
:
std
::
vector
<
Item
>
items
;
size_t
pos
=
0
;
bool
full
=
false
;
};
}
#endif
worker/include/RTC/RtpDictionaries.h
浏览文件 @
73373aed
...
@@ -67,7 +67,8 @@ namespace RTC
...
@@ -67,7 +67,8 @@ namespace RTC
CN
=
300
,
CN
=
300
,
TELEPHONE_EVENT
,
TELEPHONE_EVENT
,
// Feature codecs:
// Feature codecs:
ULPFEC
=
400
,
RTX
=
400
,
ULPFEC
,
FLEXFEC
,
FLEXFEC
,
RED
RED
};
};
...
@@ -121,19 +122,6 @@ namespace RTC
...
@@ -121,19 +122,6 @@ namespace RTC
std
::
string
name
;
std
::
string
name
;
};
};
class
RTCRtpCodecRtxParameters
{
public
:
RTCRtpCodecRtxParameters
()
{};
RTCRtpCodecRtxParameters
(
Json
::
Value
&
data
);
Json
::
Value
toJson
();
public
:
uint8_t
payloadType
=
0
;
uint32_t
rtxTime
=
0
;
};
class
RtcpFeedback
class
RtcpFeedback
{
{
public
:
public
:
...
@@ -171,8 +159,6 @@ namespace RTC
...
@@ -171,8 +159,6 @@ namespace RTC
uint32_t
ptime
=
0
;
uint32_t
ptime
=
0
;
uint32_t
numChannels
=
1
;
uint32_t
numChannels
=
1
;
RTC
::
Parameters
parameters
;
RTC
::
Parameters
parameters
;
RTCRtpCodecRtxParameters
rtx
;
bool
hasRtx
=
false
;
std
::
vector
<
RtcpFeedback
>
rtcpFeedback
;
std
::
vector
<
RtcpFeedback
>
rtcpFeedback
;
};
};
...
...
worker/include/RTC/RtpReceiver.h
浏览文件 @
73373aed
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
#include "common.h"
#include "common.h"
#include "RTC/RtpDictionaries.h"
#include "RTC/RtpDictionaries.h"
#include "RTC/RtpPacket.h"
#include "RTC/RtpPacket.h"
#include "RTC/Rtp
Buffer
.h"
#include "RTC/Rtp
Stream
.h"
#include "RTC/RTCP/ReceiverReport.h"
#include "RTC/RTCP/ReceiverReport.h"
#include "RTC/RTCP/Feedback.h"
#include "RTC/RTCP/Feedback.h"
#include "Channel/Request.h"
#include "Channel/Request.h"
...
@@ -66,12 +66,11 @@ namespace RTC
...
@@ -66,12 +66,11 @@ namespace RTC
RTC
::
Transport
*
transport
=
nullptr
;
RTC
::
Transport
*
transport
=
nullptr
;
// Allocated by this.
// Allocated by this.
RTC
::
RtpParameters
*
rtpParameters
=
nullptr
;
RTC
::
RtpParameters
*
rtpParameters
=
nullptr
;
RTC
::
Rtp
Buffer
*
rtpBuffer
=
nullptr
;
RTC
::
Rtp
Stream
*
rtpStream
=
nullptr
;
// Others.
// Others.
bool
rtpRawEventEnabled
=
false
;
bool
rtpRawEventEnabled
=
false
;
bool
rtpObjectEventEnabled
=
false
;
bool
rtpObjectEventEnabled
=
false
;
// Receiver Report holding the RTP stats.
// Receiver Report holding the RTP stats
std
::
auto_ptr
<
RTC
::
RTCP
::
ReceiverReport
>
receiverReport
;
std
::
auto_ptr
<
RTC
::
RTCP
::
ReceiverReport
>
receiverReport
;
};
};
...
...
worker/include/RTC/RtpStream.h
0 → 100644
浏览文件 @
73373aed
#ifndef MS_RTC_RTP_STREAM_H
#define MS_RTC_RTP_STREAM_H
#include "common.h"
#include "RTC/RtpPacket.h"
#include <vector>
#include <list>
namespace
RTC
{
class
RtpStream
{
private
:
struct
StorageItem
{
uint8_t
store
[
65536
];
};
private
:
struct
BufferItem
{
uint32_t
seq32
=
0
;
// RTP seq in 32 bytes plus 16 bits cycles.
RTC
::
RtpPacket
*
packet
=
nullptr
;
};
public
:
RtpStream
(
size_t
bufferSize
);
~
RtpStream
();
bool
ReceivePacket
(
RTC
::
RtpPacket
*
packet
);
private
:
void
InitSeq
(
uint16_t
seq
);
bool
UpdateSeq
(
uint16_t
seq
);
void
CleanBuffer
();
void
StorePacket
(
RTC
::
RtpPacket
*
packet
);
void
Dump
();
private
:
bool
started
=
false
;
// Whether at least a RTP packet has been received.
// https://tools.ietf.org/html/rfc3550#appendix-A.1 stuff.
uint16_t
max_seq
=
0
;
// Highest seq. number seen.
uint32_t
cycles
=
0
;
// Shifted count of seq. number cycles.
uint32_t
base_seq
=
0
;
// Base seq number.
uint32_t
bad_seq
=
0
;
// Last 'bad' seq number + 1.
uint32_t
probation
=
0
;
// Seq. packets till source is valid.
uint32_t
received
=
0
;
// Packets received.
uint32_t
expected_prior
=
0
;
// Packet expected at last interval.
uint32_t
received_prior
=
0
;
// Packet received at last interval.
uint32_t
transit
=
0
;
// Relative trans time for prev pkt.
uint32_t
jitter
=
0
;
// Estimated jitter.
// Others.
std
::
vector
<
StorageItem
>
storage
;
typedef
std
::
list
<
BufferItem
>
Buffer
;
Buffer
buffer
;
};
}
#endif
worker/mediasoup-worker.gyp
浏览文件 @
73373aed
...
@@ -31,11 +31,11 @@
...
@@ -31,11 +31,11 @@
'src/RTC/IceServer.cpp',
'src/RTC/IceServer.cpp',
'src/RTC/Peer.cpp',
'src/RTC/Peer.cpp',
'src/RTC/Room.cpp',
'src/RTC/Room.cpp',
'src/RTC/RtpBuffer.cpp',
'src/RTC/RtpListener.cpp',
'src/RTC/RtpListener.cpp',
'src/RTC/RtpPacket.cpp',
'src/RTC/RtpPacket.cpp',
'src/RTC/RtpReceiver.cpp',
'src/RTC/RtpReceiver.cpp',
'src/RTC/RtpSender.cpp',
'src/RTC/RtpSender.cpp',
'src/RTC/RtpStream.cpp',
'src/RTC/SrtpSession.cpp',
'src/RTC/SrtpSession.cpp',
'src/RTC/StunMessage.cpp',
'src/RTC/StunMessage.cpp',
'src/RTC/TcpConnection.cpp',
'src/RTC/TcpConnection.cpp',
...
@@ -45,7 +45,6 @@
...
@@ -45,7 +45,6 @@
'src/RTC/UdpSocket.cpp',
'src/RTC/UdpSocket.cpp',
'src/RTC/RtpDictionaries/Media.cpp',
'src/RTC/RtpDictionaries/Media.cpp',
'src/RTC/RtpDictionaries/Parameters.cpp',
'src/RTC/RtpDictionaries/Parameters.cpp',
'src/RTC/RtpDictionaries/RTCRtpCodecRtxParameters.cpp',
'src/RTC/RtpDictionaries/RtcpFeedback.cpp',
'src/RTC/RtpDictionaries/RtcpFeedback.cpp',
'src/RTC/RtpDictionaries/RtcpParameters.cpp',
'src/RTC/RtpDictionaries/RtcpParameters.cpp',
'src/RTC/RtpDictionaries/RtpCapabilities.cpp',
'src/RTC/RtpDictionaries/RtpCapabilities.cpp',
...
@@ -108,12 +107,12 @@
...
@@ -108,12 +107,12 @@
'include/RTC/Parameters.h',
'include/RTC/Parameters.h',
'include/RTC/Peer.h',
'include/RTC/Peer.h',
'include/RTC/Room.h',
'include/RTC/Room.h',
'include/RTC/RtpBuffer.h',
'include/RTC/RtpDictionaries.h',
'include/RTC/RtpDictionaries.h',
'include/RTC/RtpListener.h',
'include/RTC/RtpListener.h',
'include/RTC/RtpPacket.h',
'include/RTC/RtpPacket.h',
'include/RTC/RtpReceiver.h',
'include/RTC/RtpReceiver.h',
'include/RTC/RtpSender.h',
'include/RTC/RtpSender.h',
'include/RTC/RtpStream.h',
'include/RTC/SrtpSession.h',
'include/RTC/SrtpSession.h',
'include/RTC/StunMessage.h',
'include/RTC/StunMessage.h',
'include/RTC/TcpConnection.h',
'include/RTC/TcpConnection.h',
...
...
worker/src/RTC/RtpBuffer.cpp
deleted
100644 → 0
浏览文件 @
a09fc2ce
#define MS_CLASS "RTC::RtpBuffer"
#include "RTC/RtpBuffer.h"
#include "Logger.h"
namespace
RTC
{
/* Instance methods. */
RtpBuffer
::
RtpBuffer
(
size_t
capability
)
:
items
(
capability
)
{
MS_TRACE
();
}
RtpBuffer
::~
RtpBuffer
()
{
MS_TRACE
();
// Delete cloned packets.
for
(
auto
&
item
:
this
->
items
)
{
if
(
item
.
packet
)
delete
item
.
packet
;
}
}
void
RtpBuffer
::
Add
(
RTC
::
RtpPacket
*
packet
)
{
MS_TRACE
();
Item
*
item
=
std
::
addressof
(
this
->
items
[
this
->
pos
]);
// Delete previous RTP packet (if any).
if
(
item
->
packet
)
delete
item
->
packet
;
// Clone the given RTP packet and store it.
item
->
packet
=
packet
->
Clone
(
item
->
raw
);
this
->
pos
=
(
this
->
pos
+
1
)
%
this
->
items
.
size
();
if
(
!
this
->
full
&&
this
->
pos
==
0
)
this
->
full
=
true
;
}
}
worker/src/RTC/RtpDictionaries/RTCRtpCodecRtxParameters.cpp
deleted
100644 → 0
浏览文件 @
a09fc2ce
#define MS_CLASS "RTC::RTCRtpCodecRtxParameters"
#include "RTC/RtpDictionaries.h"
#include "MediaSoupError.h"
#include "Logger.h"
namespace
RTC
{
/* Instance methods. */
RTCRtpCodecRtxParameters
::
RTCRtpCodecRtxParameters
(
Json
::
Value
&
data
)
{
MS_TRACE
();
static
const
Json
::
StaticString
k_payloadType
(
"payloadType"
);
static
const
Json
::
StaticString
k_rtxTime
(
"rtxTime"
);
if
(
!
data
.
isObject
())
MS_THROW_ERROR
(
"RTCRtpCodecRtxParameters is not an object"
);
// `payloadType` is mandatory.
if
(
!
data
[
k_payloadType
].
isUInt
())
MS_THROW_ERROR
(
"missing RTCRtpCodecRtxParameters.payloadType"
);
this
->
payloadType
=
(
uint8_t
)
data
[
k_payloadType
].
asUInt
();
// `rtxTime` is optional.
if
(
data
[
k_rtxTime
].
isUInt
())
this
->
rtxTime
=
(
uint32_t
)
data
[
k_rtxTime
].
asUInt
();
}
Json
::
Value
RTCRtpCodecRtxParameters
::
toJson
()
{
MS_TRACE
();
static
const
Json
::
StaticString
k_payloadType
(
"payloadType"
);
static
const
Json
::
StaticString
k_rtxTime
(
"rtxTime"
);
Json
::
Value
json
(
Json
::
objectValue
);
// Add `payloadType`.
json
[
k_payloadType
]
=
(
Json
::
UInt
)
this
->
payloadType
;
// Add `rtxTime`.
if
(
this
->
rtxTime
)
json
[
k_rtxTime
]
=
(
Json
::
UInt
)
this
->
rtxTime
;
return
json
;
}
}
worker/src/RTC/RtpDictionaries/RtpCodecMime.cpp
浏览文件 @
73373aed
...
@@ -35,6 +35,7 @@ namespace RTC
...
@@ -35,6 +35,7 @@ namespace RTC
{
"h264"
,
RtpCodecMime
::
Subtype
::
H264
},
{
"h264"
,
RtpCodecMime
::
Subtype
::
H264
},
{
"h265"
,
RtpCodecMime
::
Subtype
::
H265
},
{
"h265"
,
RtpCodecMime
::
Subtype
::
H265
},
// Feature codecs:
// Feature codecs:
{
"rtx"
,
RtpCodecMime
::
Subtype
::
RTX
},
{
"ulpfec"
,
RtpCodecMime
::
Subtype
::
ULPFEC
},
{
"ulpfec"
,
RtpCodecMime
::
Subtype
::
ULPFEC
},
{
"flexfec"
,
RtpCodecMime
::
Subtype
::
FLEXFEC
},
{
"flexfec"
,
RtpCodecMime
::
Subtype
::
FLEXFEC
},
{
"red"
,
RtpCodecMime
::
Subtype
::
RED
},
{
"red"
,
RtpCodecMime
::
Subtype
::
RED
},
...
@@ -56,6 +57,7 @@ namespace RTC
...
@@ -56,6 +57,7 @@ namespace RTC
{
RtpCodecMime
::
Subtype
::
H264
,
"H264"
},
{
RtpCodecMime
::
Subtype
::
H264
,
"H264"
},
{
RtpCodecMime
::
Subtype
::
H265
,
"H265"
},
{
RtpCodecMime
::
Subtype
::
H265
,
"H265"
},
// Feature codecs:
// Feature codecs:
{
RtpCodecMime
::
Subtype
::
RTX
,
"rtx"
},
{
RtpCodecMime
::
Subtype
::
ULPFEC
,
"ulpfec"
},
{
RtpCodecMime
::
Subtype
::
ULPFEC
,
"ulpfec"
},
{
RtpCodecMime
::
Subtype
::
FLEXFEC
,
"flexfec"
},
{
RtpCodecMime
::
Subtype
::
FLEXFEC
,
"flexfec"
},
{
RtpCodecMime
::
Subtype
::
RED
,
"red"
},
{
RtpCodecMime
::
Subtype
::
RED
,
"red"
},
...
...
worker/src/RTC/RtpDictionaries/RtpCodecParameters.cpp
浏览文件 @
73373aed
...
@@ -21,13 +21,13 @@ namespace RTC
...
@@ -21,13 +21,13 @@ namespace RTC
static
const
Json
::
StaticString
k_ptime
(
"ptime"
);
static
const
Json
::
StaticString
k_ptime
(
"ptime"
);
static
const
Json
::
StaticString
k_numChannels
(
"numChannels"
);
static
const
Json
::
StaticString
k_numChannels
(
"numChannels"
);
static
const
Json
::
StaticString
k_parameters
(
"parameters"
);
static
const
Json
::
StaticString
k_parameters
(
"parameters"
);
static
const
Json
::
StaticString
k_rtx
(
"rtx"
);
static
const
Json
::
StaticString
k_rtcpFeedback
(
"rtcpFeedback"
);
static
const
Json
::
StaticString
k_rtcpFeedback
(
"rtcpFeedback"
);
if
(
!
data
.
isObject
())
if
(
!
data
.
isObject
())
MS_THROW_ERROR
(
"RtpCodecParameters is not an object"
);
MS_THROW_ERROR
(
"RtpCodecParameters is not an object"
);
if
(
this
->
scope
==
RTC
::
Scope
::
ROOM_CAPABILITY
||
if
(
this
->
scope
==
RTC
::
Scope
::
ROOM_CAPABILITY
||
this
->
scope
==
RTC
::
Scope
::
PEER_CAPABILITY
)
this
->
scope
==
RTC
::
Scope
::
PEER_CAPABILITY
)
{
{
// `kind` is mandatory.
// `kind` is mandatory.
...
@@ -56,7 +56,8 @@ namespace RTC
...
@@ -56,7 +56,8 @@ namespace RTC
this
->
hasPayloadType
=
true
;
this
->
hasPayloadType
=
true
;
}
}
if
(
this
->
scope
==
RTC
::
Scope
::
PEER_CAPABILITY
||
if
(
this
->
scope
==
RTC
::
Scope
::
PEER_CAPABILITY
||
this
->
scope
==
RTC
::
Scope
::
RECEIVE
)
this
->
scope
==
RTC
::
Scope
::
RECEIVE
)
{
{
if
(
!
this
->
hasPayloadType
)
if
(
!
this
->
hasPayloadType
)
...
@@ -85,17 +86,8 @@ namespace RTC
...
@@ -85,17 +86,8 @@ namespace RTC
if
(
data
[
k_parameters
].
isObject
())
if
(
data
[
k_parameters
].
isObject
())
this
->
parameters
.
Set
(
data
[
k_parameters
]);
this
->
parameters
.
Set
(
data
[
k_parameters
]);
// if (this->scope == RTC::Scope::RECEIVE)
if
(
// {
this
->
scope
==
RTC
::
Scope
::
PEER_CAPABILITY
||
// // `rtx` is optional.
// if (data[k_rtx].isObject())
// {
// this->rtx = RTC::RTCRtpCodecRtxParameters(data[k_rtx]);
// this->hasRtx = true;
// }
// }
if
(
this
->
scope
==
RTC
::
Scope
::
PEER_CAPABILITY
||
this
->
scope
==
RTC
::
Scope
::
RECEIVE
)
this
->
scope
==
RTC
::
Scope
::
RECEIVE
)
{
{
// `rtcpFeedback` is optional.
// `rtcpFeedback` is optional.
...
@@ -129,12 +121,12 @@ namespace RTC
...
@@ -129,12 +121,12 @@ namespace RTC
static
const
Json
::
StaticString
k_ptime
(
"ptime"
);
static
const
Json
::
StaticString
k_ptime
(
"ptime"
);
static
const
Json
::
StaticString
k_numChannels
(
"numChannels"
);
static
const
Json
::
StaticString
k_numChannels
(
"numChannels"
);
static
const
Json
::
StaticString
k_parameters
(
"parameters"
);
static
const
Json
::
StaticString
k_parameters
(
"parameters"
);
static
const
Json
::
StaticString
k_rtx
(
"rtx"
);
static
const
Json
::
StaticString
k_rtcpFeedback
(
"rtcpFeedback"
);
static
const
Json
::
StaticString
k_rtcpFeedback
(
"rtcpFeedback"
);
Json
::
Value
json
(
Json
::
objectValue
);
Json
::
Value
json
(
Json
::
objectValue
);
if
(
this
->
scope
==
RTC
::
Scope
::
ROOM_CAPABILITY
||
if
(
this
->
scope
==
RTC
::
Scope
::
ROOM_CAPABILITY
||
this
->
scope
==
RTC
::
Scope
::
PEER_CAPABILITY
)
this
->
scope
==
RTC
::
Scope
::
PEER_CAPABILITY
)
{
{
// Add `kind`.
// Add `kind`.
...
@@ -168,14 +160,8 @@ namespace RTC
...
@@ -168,14 +160,8 @@ namespace RTC
// Add `parameters`.
// Add `parameters`.
json
[
k_parameters
]
=
this
->
parameters
.
toJson
();
json
[
k_parameters
]
=
this
->
parameters
.
toJson
();
if
(
this
->
scope
==
RTC
::
Scope
::
RECEIVE
)
if
(
{
this
->
scope
==
RTC
::
Scope
::
PEER_CAPABILITY
||
// Add `rtx`
if
(
this
->
hasRtx
)
json
[
k_rtx
]
=
this
->
rtx
.
toJson
();
}
if
(
this
->
scope
==
RTC
::
Scope
::
PEER_CAPABILITY
||
this
->
scope
==
RTC
::
Scope
::
RECEIVE
)
this
->
scope
==
RTC
::
Scope
::
RECEIVE
)
{
{
// Add `rtcpFeedback`.
// Add `rtcpFeedback`.
...
@@ -206,7 +192,6 @@ namespace RTC
...
@@ -206,7 +192,6 @@ namespace RTC
return
false
;
return
false
;
}
}
// Clock rate must match.
// Clock rate must match.
if
(
this
->
clockRate
!=
codec
.
clockRate
)
if
(
this
->
clockRate
!=
codec
.
clockRate
)
return
false
;
return
false
;
...
@@ -232,7 +217,8 @@ namespace RTC
...
@@ -232,7 +217,8 @@ namespace RTC
{
{
case
RTC
:
:
RtpCodecMime
::
Subtype
::
H264
:
case
RTC
:
:
RtpCodecMime
::
Subtype
::
H264
:
{
{
if
(
this
->
parameters
.
GetInteger
(
k_packetizationMode
)
!=
if
(
this
->
parameters
.
GetInteger
(
k_packetizationMode
)
!=
codec
.
parameters
.
GetInteger
(
k_packetizationMode
))
codec
.
parameters
.
GetInteger
(
k_packetizationMode
))
{
{
return
false
;
return
false
;
...
@@ -253,12 +239,22 @@ namespace RTC
...
@@ -253,12 +239,22 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
static
std
::
string
k_apt
=
"apt"
;
static
std
::
string
k_packetizationMode
=
"packetizationMode"
;
static
std
::
string
k_packetizationMode
=
"packetizationMode"
;
// Check per MIME parameters and set default values.
// Check per MIME parameters and set default values.
switch
(
this
->
mime
.
subtype
)
switch
(
this
->
mime
.
subtype
)
{
{
// A RTX codec must have 'apt' parameter.
case
RTC
:
:
RtpCodecMime
::
Subtype
::
RTX
:
{
if
(
!
this
->
parameters
.
HasInteger
(
k_apt
))
MS_THROW_ERROR
(
"missing apt parameter in RTX RtpCodecParameters"
);
break
;
}
case
RTC
:
:
RtpCodecMime
::
Subtype
::
OPUS
:
case
RTC
:
:
RtpCodecMime
::
Subtype
::
OPUS
:
{
{
// Opus default numChannels is 2.
// Opus default numChannels is 2.
...
...
worker/src/RTC/RtpDictionaries/RtpParameters.cpp
浏览文件 @
73373aed
...
@@ -163,12 +163,12 @@ namespace RTC
...
@@ -163,12 +163,12 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
static
std
::
string
k_apt
=
"apt"
;
// Must be at least one codec.
// Must be at least one codec.
if
(
this
->
codecs
.
size
()
==
0
)
if
(
this
->
codecs
.
size
()
==
0
)
MS_THROW_ERROR
(
"empty RtpParameters.codecs"
);
MS_THROW_ERROR
(
"empty RtpParameters.codecs"
);
// Payload types must be unique.
std
::
unordered_set
<
uint8_t
>
payloadTypes
;
std
::
unordered_set
<
uint8_t
>
payloadTypes
;
for
(
auto
&
codec
:
this
->
codecs
)
for
(
auto
&
codec
:
this
->
codecs
)
...
@@ -177,14 +177,41 @@ namespace RTC
...
@@ -177,14 +177,41 @@ namespace RTC
MS_THROW_ERROR
(
"duplicated codec.payloadType"
);
MS_THROW_ERROR
(
"duplicated codec.payloadType"
);
else
else
payloadTypes
.
insert
(
codec
.
payloadType
);
payloadTypes
.
insert
(
codec
.
payloadType
);
}
for
(
auto
&
codec
:
this
->
codecs
)
switch
(
codec
.
mime
.
subtype
)
{
{
if
(
codec
.
hasRtx
&&
payloadTypes
.
find
(
codec
.
rtx
.
payloadType
)
!=
payloadTypes
.
end
())
// A RTX codec must have 'apt' parameter pointing to a non RTX codec.
MS_THROW_ERROR
(
"duplicated codec.rtx.payloadType"
);
case
RTC
:
:
RtpCodecMime
::
Subtype
::
RTX
:
else
{
payloadTypes
.
insert
(
codec
.
rtx
.
payloadType
);
// NOTE: RtpCodecParameters already asserted that there is 'apt' parameter.
int32_t
apt
=
codec
.
parameters
.
GetInteger
(
k_apt
);
auto
it
=
this
->
codecs
.
begin
();
for
(;
it
!=
this
->
codecs
.
end
();
++
it
)
{
auto
codec
=
*
it
;
if
((
int32_t
)
codec
.
payloadType
==
apt
)
{
if
(
codec
.
mime
.
subtype
==
RTC
::
RtpCodecMime
::
Subtype
::
RTX
)
MS_THROW_ERROR
(
"apt in RTX codec points to a RTX codec"
);
else
if
(
codec
.
mime
.
subtype
==
RTC
::
RtpCodecMime
::
Subtype
::
ULPFEC
)
MS_THROW_ERROR
(
"apt in RTX codec points to a ULPFEC codec"
);
else
if
(
codec
.
mime
.
subtype
==
RTC
::
RtpCodecMime
::
Subtype
::
FLEXFEC
)
MS_THROW_ERROR
(
"apt in RTX codec points to a FLEXFEC codec"
);
else
break
;
}
if
(
it
==
this
->
codecs
.
end
())
MS_THROW_ERROR
(
"apt in RTX codec points to a non existing codec"
);
}
break
;
}
default
:
;
}
}
}
}
}
...
...
worker/src/RTC/RtpListener.cpp
浏览文件 @
73373aed
...
@@ -225,27 +225,6 @@ namespace RTC
...
@@ -225,27 +225,6 @@ namespace RTC
MS_THROW_ERROR
(
"payloadType already exists in RTP listener [payloadType:%"
PRIu8
"]"
,
payloadType
);
MS_THROW_ERROR
(
"payloadType already exists in RTP listener [payloadType:%"
PRIu8
"]"
,
payloadType
);
}
}
}
}
// Also for RTX payloads.
for
(
auto
&
codec
:
rtpParameters
->
codecs
)
{
if
(
!
codec
.
hasRtx
)
continue
;
uint8_t
payloadType
=
codec
.
rtx
.
payloadType
;
if
(
!
this
->
HasPayloadType
(
payloadType
,
rtpReceiver
))
{
this
->
ptTable
[
payloadType
]
=
rtpReceiver
;
}
else
{
RemoveRtpReceiver
(
rtpReceiver
);
RollbackRtpReceiver
(
rtpReceiver
,
previousSsrcs
,
previousMuxId
,
previousPayloadTypes
);
MS_THROW_ERROR
(
"RTX payloadType already exists in RTP listener [payloadType:%"
PRIu8
"]"
,
payloadType
);
}
}
}
}
}
}
}
}
...
@@ -298,16 +277,9 @@ namespace RTC
...
@@ -298,16 +277,9 @@ namespace RTC
// Ensure the RTP PT is present in RtpParameters.
// Ensure the RTP PT is present in RtpParameters.
for
(
auto
&
codec
:
rtpParameters
->
codecs
)
for
(
auto
&
codec
:
rtpParameters
->
codecs
)
{
{
// Check
codec
s.
// Check
payload
s.
if
(
codec
.
payloadType
==
packet
->
GetPayloadType
())
if
(
codec
.
payloadType
==
packet
->
GetPayloadType
())
{
return
rtpReceiver
;
return
rtpReceiver
;
}
// Also check RTX payloads.
else
if
(
codec
.
hasRtx
&&
codec
.
rtx
.
payloadType
==
packet
->
GetPayloadType
())
{
return
rtpReceiver
;
}
}
}
// RTP PT not present.
// RTP PT not present.
...
...
worker/src/RTC/RtpReceiver.cpp
浏览文件 @
73373aed
...
@@ -6,8 +6,6 @@
...
@@ -6,8 +6,6 @@
#include "MediaSoupError.h"
#include "MediaSoupError.h"
#include "Logger.h"
#include "Logger.h"
#define RTP_BUFFER_SIZE 100
namespace
RTC
namespace
RTC
{
{
/* Instance methods. */
/* Instance methods. */
...
@@ -20,8 +18,9 @@ namespace RTC
...
@@ -20,8 +18,9 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
// Create the RtpBuffer instance.
// Create an RtpStream instance if video.
this
->
rtpBuffer
=
new
RTC
::
RtpBuffer
(
RTP_BUFFER_SIZE
);
if
(
kind
==
RTC
::
Media
::
Kind
::
VIDEO
)
this
->
rtpStream
=
new
RTC
::
RtpStream
(
50
);
// TODO: Set a proper size.
}
}
RtpReceiver
::~
RtpReceiver
()
RtpReceiver
::~
RtpReceiver
()
...
@@ -40,8 +39,8 @@ namespace RTC
...
@@ -40,8 +39,8 @@ namespace RTC
if
(
this
->
rtpParameters
)
if
(
this
->
rtpParameters
)
delete
this
->
rtpParameters
;
delete
this
->
rtpParameters
;
if
(
this
->
rtp
Buffer
)
if
(
this
->
rtp
Stream
)
delete
this
->
rtp
Buffer
;
delete
this
->
rtp
Stream
;
// Notify.
// Notify.
event_data
[
k_class
]
=
"RtpReceiver"
;
event_data
[
k_class
]
=
"RtpReceiver"
;
...
@@ -217,6 +216,17 @@ namespace RTC
...
@@ -217,6 +216,17 @@ namespace RTC
// TODO: Check if stopped, etc (not yet done)
// TODO: Check if stopped, etc (not yet done)
// Store in the buffer
// TODO: Must check what kind of packet we are storing, right?
// TODO: RtpStream.ReceivePacket() should return true if the packet is valid and
// false if it must be ignored.
if
(
this
->
kind
==
RTC
::
Media
::
Kind
::
VIDEO
)
{
// TODO: Enable when properly implemented.
if
(
!
this
->
rtpStream
->
ReceivePacket
(
packet
))
return
;
}
// Notify the listener.
// Notify the listener.
this
->
listener
->
onRtpPacket
(
this
,
packet
);
this
->
listener
->
onRtpPacket
(
this
,
packet
);
...
@@ -248,10 +258,6 @@ namespace RTC
...
@@ -248,10 +258,6 @@ namespace RTC
this
->
notifier
->
EmitWithBinary
(
this
->
rtpReceiverId
,
"rtpobject"
,
event_data
,
packet
->
GetPayload
(),
packet
->
GetPayloadLength
());
this
->
notifier
->
EmitWithBinary
(
this
->
rtpReceiverId
,
"rtpobject"
,
event_data
,
packet
->
GetPayload
(),
packet
->
GetPayloadLength
());
}
}
// Store in the buffer
// TODO: Must check what kind of packet we are storing, right?
this
->
rtpBuffer
->
Add
(
packet
);
}
}
void
RtpReceiver
::
FillRtpParameters
()
void
RtpReceiver
::
FillRtpParameters
()
...
...
worker/src/RTC/RtpStream.cpp
0 → 100644
浏览文件 @
73373aed
// TODO: https://tools.ietf.org/html/rfc3550#appendix-A.1
#define MS_CLASS "RTC::RtpStream"
#include "RTC/RtpStream.h"
#include "Logger.h"
#define MIN_SEQUENTIAL 2
#define MAX_DROPOUT 3000
#define MAX_MISORDER 100
#define RTP_SEQ_MOD (1<<16)
namespace
RTC
{
/* Instance methods. */
RtpStream
::
RtpStream
(
size_t
bufferSize
)
:
storage
(
bufferSize
)
{
MS_TRACE
();
}
RtpStream
::~
RtpStream
()
{
MS_TRACE
();
// Clear buffer.
CleanBuffer
();
}
bool
RtpStream
::
ReceivePacket
(
RTC
::
RtpPacket
*
packet
)
{
MS_TRACE
();
uint16_t
seq
=
packet
->
GetSequenceNumber
();
// If this is the first packet seen, initialize stuff.
if
(
!
this
->
started
)
{
this
->
started
=
true
;
InitSeq
(
seq
);
this
->
max_seq
=
seq
-
1
;
this
->
probation
=
MIN_SEQUENTIAL
;
}
// If not a valid packet ignore it.
if
(
!
UpdateSeq
(
seq
))
{
// TODO: remove
MS_WARN
(
"invalid packet [seq:%"
PRIu16
"]"
,
packet
->
GetSequenceNumber
());
return
false
;
}
// Store the packet into the buffer.
StorePacket
(
packet
);
// TODO: TMP
Dump
();
return
true
;
}
void
RtpStream
::
InitSeq
(
uint16_t
seq
)
{
MS_TRACE
();
// Initialize/reset RTP counters.
this
->
base_seq
=
seq
;
this
->
max_seq
=
seq
;
this
->
bad_seq
=
RTP_SEQ_MOD
+
1
;
// So seq == bad_seq is false.
this
->
cycles
=
0
;
this
->
received
=
0
;
this
->
received_prior
=
0
;
this
->
expected_prior
=
0
;
// Clean buffer.
CleanBuffer
();
}
bool
RtpStream
::
UpdateSeq
(
uint16_t
seq
)
{
MS_TRACE
();
uint16_t
udelta
=
seq
-
this
->
max_seq
;
/*
* Source is not valid until MIN_SEQUENTIAL packets with
* sequential sequence numbers have been received.
*/
if
(
this
->
probation
)
{
// Packet is in sequence.
if
(
seq
==
this
->
max_seq
+
1
)
{
this
->
probation
--
;
this
->
max_seq
=
seq
;
if
(
this
->
probation
==
0
)
{
InitSeq
(
seq
);
this
->
received
++
;
return
true
;
}
}
else
{
this
->
probation
=
MIN_SEQUENTIAL
-
1
;
this
->
max_seq
=
seq
;
}
return
false
;
}
else
if
(
udelta
<
MAX_DROPOUT
)
{
// In order, with permissible gap.
if
(
seq
<
this
->
max_seq
)
{
// Sequence number wrapped: count another 64K cycle.
this
->
cycles
+=
RTP_SEQ_MOD
;
}
this
->
max_seq
=
seq
;
}
else
if
(
udelta
<=
RTP_SEQ_MOD
-
MAX_MISORDER
)
{
// The sequence number made a very large jump.
if
(
seq
==
this
->
bad_seq
)
{
/*
* Two sequential packets -- assume that the other side
* restarted without telling us so just re-sync
* (i.e., pretend this was the first packet).
*/
InitSeq
(
seq
);
}
else
{
this
->
bad_seq
=
(
seq
+
1
)
&
(
RTP_SEQ_MOD
-
1
);
return
false
;
}
}
else
{
// Duplicate or reordered packet.
// NOTE: This would never happen because libsrtp rejects duplicated packets.
}
this
->
received
++
;
return
true
;
}
void
RtpStream
::
CleanBuffer
()
{
MS_TRACE
();
// Delete cloned packets.
for
(
auto
&
buffer_item
:
this
->
buffer
)
{
delete
buffer_item
.
packet
;
}
// Clear list.
this
->
buffer
.
clear
();
}
inline
void
RtpStream
::
StorePacket
(
RTC
::
RtpPacket
*
packet
)
{
MS_TRACE
();
// Sum the packet seq number and the number of 16 bits cycles.
uint32_t
packet_seq32
=
(
uint32_t
)
packet
->
GetSequenceNumber
()
+
this
->
cycles
;
BufferItem
buffer_item
;
buffer_item
.
seq32
=
packet_seq32
;
// If empty do it easy.
if
(
this
->
buffer
.
size
()
==
0
)
{
auto
store
=
this
->
storage
[
0
].
store
;
buffer_item
.
packet
=
packet
->
Clone
(
store
);
this
->
buffer
.
push_back
(
buffer_item
);
return
;
}
// Otherwise, do the stuff.
Buffer
::
iterator
new_buffer_it
;
uint8_t
*
store
=
nullptr
;
// Iterate the buffer in reverse order and find the proper place to store the
// packet.
auto
buffer_it_r
=
this
->
buffer
.
rbegin
();
for
(;
buffer_it_r
!=
this
->
buffer
.
rend
();
buffer_it_r
++
)
{
auto
current_seq32
=
(
*
buffer_it_r
).
seq32
;
if
(
packet_seq32
>
current_seq32
)
{
// Get a forward iterator pointing to the same element.
auto
it
=
buffer_it_r
.
base
();
new_buffer_it
=
this
->
buffer
.
insert
(
it
,
buffer_item
);
// Exit the loop.
break
;
}
}
// If the packet was older than anything in the buffer, just ignore it.
// NOTE: This should never happen.
if
(
buffer_it_r
==
this
->
buffer
.
rend
())
{
MS_WARN
(
"packet is older than anything in the buffer, ignoring it"
);
return
;
}
// If the storage is not full use its next free store.
if
(
this
->
buffer
.
size
()
-
1
<
this
->
storage
.
size
())
{
store
=
this
->
storage
[
this
->
buffer
.
size
()
-
1
].
store
;
}
// Otherwise remove the first packet of the buffer and replace its storage area.
else
{
auto
&
first_buffer_item
=
*
(
this
->
buffer
.
begin
());
auto
first_packet
=
first_buffer_item
.
packet
;
// Store points to the store used by the first packet.
store
=
(
uint8_t
*
)
first_packet
->
GetRaw
();
// Free the first packet.
delete
first_packet
;
// Remove the first element in the list.
this
->
buffer
.
pop_front
();
}
// Update the new buffer item so it points to the cloned packed.
(
*
new_buffer_it
).
packet
=
packet
->
Clone
(
store
);
}
// TODO: TMP
void
RtpStream
::
Dump
()
{
MS_TRACE
();
MS_WARN
(
"<DUMP>"
);
MS_WARN
(
" [buffer.size:%zu, storage.size:%zu]"
,
this
->
buffer
.
size
(),
this
->
storage
.
size
());
for
(
auto
&
buffer_item
:
this
->
buffer
)
{
auto
packet
=
buffer_item
.
packet
;
MS_WARN
(
" packet [seq:%"
PRIu16
", seq32:%"
PRIu32
"]"
,
packet
->
GetSequenceNumber
(),
buffer_item
.
seq32
);
}
MS_WARN
(
"</DUMP>"
);
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论