Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
0fdd6356
提交
0fdd6356
authored
9月 14, 2017
作者:
Iñaki Baz Castillo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
- Refactor RTC/Codecs so we have RtpPacket::IsKeyFrame().
- s/fullframe/keyframe/g
上级
3df732bb
隐藏空白字符变更
内嵌
并排
正在显示
19 个修改的文件
包含
130 行增加
和
118 行删除
+130
-118
Codecs.hpp
worker/include/RTC/Codecs/Codecs.hpp
+19
-3
VP8.hpp
worker/include/RTC/Codecs/VP8.hpp
+3
-1
Consumer.hpp
worker/include/RTC/Consumer.hpp
+1
-1
ConsumerListener.hpp
worker/include/RTC/ConsumerListener.hpp
+1
-1
NackGenerator.hpp
worker/include/RTC/NackGenerator.hpp
+1
-1
Producer.hpp
worker/include/RTC/Producer.hpp
+3
-3
Router.hpp
worker/include/RTC/Router.hpp
+1
-1
RtpPacket.hpp
worker/include/RTC/RtpPacket.hpp
+13
-0
RtpStreamRecv.hpp
worker/include/RTC/RtpStreamRecv.hpp
+2
-2
Transport.hpp
worker/include/RTC/Transport.hpp
+1
-1
Codecs.cpp
worker/src/RTC/Codecs/Codecs.cpp
+7
-27
VP8.cpp
worker/src/RTC/Codecs/VP8.cpp
+16
-18
Consumer.cpp
worker/src/RTC/Consumer.cpp
+8
-7
NackGenerator.cpp
worker/src/RTC/NackGenerator.cpp
+3
-3
Producer.cpp
worker/src/RTC/Producer.cpp
+29
-27
Router.cpp
worker/src/RTC/Router.cpp
+2
-2
RtpPacket.cpp
worker/src/RTC/RtpPacket.cpp
+3
-3
RtpStreamRecv.cpp
worker/src/RTC/RtpStreamRecv.cpp
+3
-3
Transport.cpp
worker/src/RTC/Transport.cpp
+14
-14
没有找到文件。
worker/include/RTC/Codecs/Codecs.hpp
浏览文件 @
0fdd6356
...
@@ -3,15 +3,31 @@
...
@@ -3,15 +3,31 @@
#include "common.hpp"
#include "common.hpp"
#include "RTC/Codecs/VP8.hpp"
#include "RTC/Codecs/VP8.hpp"
#include "RTC/RtpDictionaries.hpp"
#include "RTC/RtpPacket.hpp"
#include "RTC/RtpPacket.hpp"
#include "RTC/RtpDictionaries.hpp"
namespace
RTC
namespace
RTC
{
{
namespace
Codecs
namespace
Codecs
{
{
bool
IsKnown
(
const
RTC
::
RtpCodecMimeType
&
mimeType
);
bool
CanBeKeyFrame
(
const
RTC
::
RtpCodecMimeType
&
mimeType
);
bool
IsKeyFrame
(
const
RTC
::
RtpCodecMimeType
&
mimeType
,
const
RTC
::
RtpPacket
*
packet
);
void
ProcessRtpPacket
(
RTC
::
RtpPacket
*
packet
,
const
RTC
::
RtpCodecMimeType
&
mimeType
);
// Inline namespace methods.
inline
bool
CanBeKeyFrame
(
const
RTC
::
RtpCodecMimeType
&
mimeType
)
{
if
(
mimeType
.
type
!=
RTC
::
RtpCodecMimeType
::
Type
::
VIDEO
)
return
false
;
switch
(
mimeType
.
subtype
)
{
case
RTC
:
:
RtpCodecMimeType
::
Subtype
::
VP8
:
return
true
;
default:
return
false
;
}
}
}
// namespace Codecs
}
// namespace Codecs
}
// namespace RTC
}
// namespace RTC
...
...
worker/include/RTC/Codecs/VP8.hpp
浏览文件 @
0fdd6356
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
#define MS_RTC_CODECS_VP8_HPP
#define MS_RTC_CODECS_VP8_HPP
#include "common.hpp"
#include "common.hpp"
#include "RTC/RtpPacket.hpp"
#include "RTC/RtpDictionaries.hpp"
namespace
RTC
namespace
RTC
{
{
...
@@ -10,7 +12,7 @@ namespace RTC
...
@@ -10,7 +12,7 @@ namespace RTC
class
VP8
class
VP8
{
{
public
:
public
:
static
bool
IsKeyFrame
(
const
uint8_t
*
data
,
size_t
len
);
static
void
ProcessRtpPacket
(
RTC
::
RtpPacket
*
packet
);
};
};
}
// namespace Codecs
}
// namespace Codecs
}
// namespace RTC
}
// namespace RTC
...
...
worker/include/RTC/Consumer.hpp
浏览文件 @
0fdd6356
...
@@ -56,7 +56,7 @@ namespace RTC
...
@@ -56,7 +56,7 @@ namespace RTC
void
ReceiveNack
(
RTC
::
RTCP
::
FeedbackRtpNackPacket
*
nackPacket
);
void
ReceiveNack
(
RTC
::
RTCP
::
FeedbackRtpNackPacket
*
nackPacket
);
void
ReceiveRtcpReceiverReport
(
RTC
::
RTCP
::
ReceiverReport
*
report
);
void
ReceiveRtcpReceiverReport
(
RTC
::
RTCP
::
ReceiverReport
*
report
);
uint32_t
GetTransmissionRate
(
uint64_t
now
);
uint32_t
GetTransmissionRate
(
uint64_t
now
);
void
Request
Full
Frame
();
void
Request
Key
Frame
();
private
:
private
:
void
FillSupportedCodecPayloadTypes
();
void
FillSupportedCodecPayloadTypes
();
...
...
worker/include/RTC/ConsumerListener.hpp
浏览文件 @
0fdd6356
...
@@ -13,7 +13,7 @@ namespace RTC
...
@@ -13,7 +13,7 @@ namespace RTC
{
{
public
:
public
:
virtual
void
OnConsumerClosed
(
RTC
::
Consumer
*
consumer
)
=
0
;
virtual
void
OnConsumerClosed
(
RTC
::
Consumer
*
consumer
)
=
0
;
virtual
void
OnConsumer
Full
FrameRequired
(
RTC
::
Consumer
*
consumer
)
=
0
;
virtual
void
OnConsumer
Key
FrameRequired
(
RTC
::
Consumer
*
consumer
)
=
0
;
};
};
}
// namespace RTC
}
// namespace RTC
...
...
worker/include/RTC/NackGenerator.hpp
浏览文件 @
0fdd6356
...
@@ -16,7 +16,7 @@ namespace RTC
...
@@ -16,7 +16,7 @@ namespace RTC
{
{
public
:
public
:
virtual
void
OnNackGeneratorNackRequired
(
const
std
::
vector
<
uint16_t
>&
seqNumbers
)
=
0
;
virtual
void
OnNackGeneratorNackRequired
(
const
std
::
vector
<
uint16_t
>&
seqNumbers
)
=
0
;
virtual
void
OnNackGenerator
Full
FrameRequired
()
=
0
;
virtual
void
OnNackGenerator
Key
FrameRequired
()
=
0
;
};
};
private
:
private
:
...
...
worker/include/RTC/Producer.hpp
浏览文件 @
0fdd6356
...
@@ -72,7 +72,7 @@ namespace RTC
...
@@ -72,7 +72,7 @@ namespace RTC
void
GetRtcp
(
RTC
::
RTCP
::
CompoundPacket
*
packet
,
uint64_t
now
);
void
GetRtcp
(
RTC
::
RTCP
::
CompoundPacket
*
packet
,
uint64_t
now
);
void
ReceiveRtcpFeedback
(
RTC
::
RTCP
::
FeedbackPsPacket
*
packet
)
const
;
void
ReceiveRtcpFeedback
(
RTC
::
RTCP
::
FeedbackPsPacket
*
packet
)
const
;
void
ReceiveRtcpFeedback
(
RTC
::
RTCP
::
FeedbackRtpPacket
*
packet
)
const
;
void
ReceiveRtcpFeedback
(
RTC
::
RTCP
::
FeedbackRtpPacket
*
packet
)
const
;
void
Request
Full
Frame
(
bool
force
=
false
);
void
Request
Key
Frame
(
bool
force
=
false
);
const
std
::
set
<
RTC
::
RtpEncodingParameters
::
Profile
>
GetProfiles
()
const
;
const
std
::
set
<
RTC
::
RtpEncodingParameters
::
Profile
>
GetProfiles
()
const
;
private
:
private
:
...
@@ -111,7 +111,7 @@ namespace RTC
...
@@ -111,7 +111,7 @@ namespace RTC
std
::
map
<
uint32_t
,
RTC
::
RtpStreamRecv
*>
rtpStreams
;
std
::
map
<
uint32_t
,
RTC
::
RtpStreamRecv
*>
rtpStreams
;
std
::
map
<
uint32_t
,
RTC
::
RtpStreamRecv
*>
mapRtxStreams
;
std
::
map
<
uint32_t
,
RTC
::
RtpStreamRecv
*>
mapRtxStreams
;
std
::
map
<
RTC
::
RtpStreamRecv
*
,
std
::
set
<
RTC
::
RtpEncodingParameters
::
Profile
>>
profiles
;
std
::
map
<
RTC
::
RtpStreamRecv
*
,
std
::
set
<
RTC
::
RtpEncodingParameters
::
Profile
>>
profiles
;
Timer
*
full
FrameRequestBlockTimer
{
nullptr
};
Timer
*
key
FrameRequestBlockTimer
{
nullptr
};
// Others.
// Others.
std
::
vector
<
RtpEncodingParameters
>
outputEncodings
;
std
::
vector
<
RtpEncodingParameters
>
outputEncodings
;
struct
RTC
::
Transport
::
HeaderExtensionIds
transportHeaderExtensionIds
;
struct
RTC
::
Transport
::
HeaderExtensionIds
transportHeaderExtensionIds
;
...
@@ -119,7 +119,7 @@ namespace RTC
...
@@ -119,7 +119,7 @@ namespace RTC
bool
paused
{
false
};
bool
paused
{
false
};
bool
rtpRawEventEnabled
{
false
};
bool
rtpRawEventEnabled
{
false
};
bool
rtpObjectEventEnabled
{
false
};
bool
rtpObjectEventEnabled
{
false
};
bool
is
Full
FrameRequested
{
false
};
bool
is
Key
FrameRequested
{
false
};
// Timestamp when last RTCP was sent.
// Timestamp when last RTCP was sent.
uint64_t
lastRtcpSentTime
{
0
};
uint64_t
lastRtcpSentTime
{
0
};
uint16_t
maxRtcpInterval
{
0
};
uint16_t
maxRtcpInterval
{
0
};
...
...
worker/include/RTC/Router.hpp
浏览文件 @
0fdd6356
...
@@ -79,7 +79,7 @@ namespace RTC
...
@@ -79,7 +79,7 @@ namespace RTC
/* Pure virtual methods inherited from RTC::ConsumerListener. */
/* Pure virtual methods inherited from RTC::ConsumerListener. */
public
:
public
:
void
OnConsumerClosed
(
RTC
::
Consumer
*
consumer
)
override
;
void
OnConsumerClosed
(
RTC
::
Consumer
*
consumer
)
override
;
void
OnConsumer
Full
FrameRequired
(
RTC
::
Consumer
*
consumer
)
override
;
void
OnConsumer
Key
FrameRequired
(
RTC
::
Consumer
*
consumer
)
override
;
/* Pure virtual methods inherited from Timer::Listener. */
/* Pure virtual methods inherited from Timer::Listener. */
public
:
public
:
...
...
worker/include/RTC/RtpPacket.hpp
浏览文件 @
0fdd6356
...
@@ -117,6 +117,8 @@ namespace RTC
...
@@ -117,6 +117,8 @@ namespace RTC
bool
ReadRid
(
const
uint8_t
**
data
,
size_t
*
len
)
const
;
bool
ReadRid
(
const
uint8_t
**
data
,
size_t
*
len
)
const
;
uint8_t
*
GetPayload
()
const
;
uint8_t
*
GetPayload
()
const
;
size_t
GetPayloadLength
()
const
;
size_t
GetPayloadLength
()
const
;
void
SetKeyFrame
(
bool
flag
);
bool
IsKeyFrame
()
const
;
void
Serialize
(
uint8_t
*
buffer
);
void
Serialize
(
uint8_t
*
buffer
);
RtpPacket
*
Clone
(
uint8_t
*
buffer
)
const
;
RtpPacket
*
Clone
(
uint8_t
*
buffer
)
const
;
void
RtxEncode
(
uint8_t
payloadType
,
uint32_t
ssrc
,
uint16_t
seq
);
void
RtxEncode
(
uint8_t
payloadType
,
uint32_t
ssrc
,
uint16_t
seq
);
...
@@ -138,6 +140,7 @@ namespace RTC
...
@@ -138,6 +140,7 @@ namespace RTC
uint8_t
payloadPadding
{
0
};
uint8_t
payloadPadding
{
0
};
size_t
size
{
0
};
// Full size of the packet in bytes.
size_t
size
{
0
};
// Full size of the packet in bytes.
uint32_t
seq32
{
0
};
// Extended seq number.
uint32_t
seq32
{
0
};
// Extended seq number.
bool
isKeyFrame
{
false
};
// Whether this packet contains a key frame.
};
};
/* Inline static methods. */
/* Inline static methods. */
...
@@ -362,6 +365,16 @@ namespace RTC
...
@@ -362,6 +365,16 @@ namespace RTC
{
{
return
this
->
payloadLength
;
return
this
->
payloadLength
;
}
}
inline
void
RtpPacket
::
SetKeyFrame
(
bool
flag
)
{
this
->
isKeyFrame
=
flag
;
}
inline
bool
RtpPacket
::
IsKeyFrame
()
const
{
return
this
->
isKeyFrame
;
}
}
// namespace RTC
}
// namespace RTC
#endif
#endif
worker/include/RTC/RtpStreamRecv.hpp
浏览文件 @
0fdd6356
...
@@ -30,7 +30,7 @@ namespace RTC
...
@@ -30,7 +30,7 @@ namespace RTC
RTC
::
RTCP
::
ReceiverReport
*
GetRtcpReceiverReport
();
RTC
::
RTCP
::
ReceiverReport
*
GetRtcpReceiverReport
();
void
ReceiveRtcpSenderReport
(
RTC
::
RTCP
::
SenderReport
*
report
);
void
ReceiveRtcpSenderReport
(
RTC
::
RTCP
::
SenderReport
*
report
);
void
SetRtx
(
uint8_t
payloadType
,
uint32_t
ssrc
);
void
SetRtx
(
uint8_t
payloadType
,
uint32_t
ssrc
);
void
Request
Full
Frame
();
void
Request
Key
Frame
();
uint32_t
GetBitRate
();
uint32_t
GetBitRate
();
private
:
private
:
...
@@ -44,7 +44,7 @@ namespace RTC
...
@@ -44,7 +44,7 @@ namespace RTC
/* Pure virtual methods inherited from RTC::NackGenerator. */
/* Pure virtual methods inherited from RTC::NackGenerator. */
protected
:
protected
:
void
OnNackGeneratorNackRequired
(
const
std
::
vector
<
uint16_t
>&
seqNumbers
)
override
;
void
OnNackGeneratorNackRequired
(
const
std
::
vector
<
uint16_t
>&
seqNumbers
)
override
;
void
OnNackGenerator
Full
FrameRequired
()
override
;
void
OnNackGenerator
Key
FrameRequired
()
override
;
private
:
private
:
// Passed by argument.
// Passed by argument.
...
...
worker/include/RTC/Transport.hpp
浏览文件 @
0fdd6356
...
@@ -176,7 +176,7 @@ namespace RTC
...
@@ -176,7 +176,7 @@ namespace RTC
/* Pure virtual methods inherited from RTC::ConsumerListener. */
/* Pure virtual methods inherited from RTC::ConsumerListener. */
public
:
public
:
void
OnConsumerClosed
(
RTC
::
Consumer
*
consumer
)
override
;
void
OnConsumerClosed
(
RTC
::
Consumer
*
consumer
)
override
;
void
OnConsumer
Full
FrameRequired
(
RTC
::
Consumer
*
consumer
)
override
;
void
OnConsumer
Key
FrameRequired
(
RTC
::
Consumer
*
consumer
)
override
;
/* Pure virtual methods inherited from Timer::Listener. */
/* Pure virtual methods inherited from Timer::Listener. */
public
:
public
:
...
...
worker/src/RTC/Codecs/Codecs.cpp
浏览文件 @
0fdd6356
#define MS_CLASS "RTC::Codecs"
#define MS_CLASS "RTC::Codecs"
#define MS_LOG_DEV
//
#define MS_LOG_DEV
#include "RTC/Codecs/Codecs.hpp"
#include "RTC/Codecs/Codecs.hpp"
#include "Logger.hpp"
#include "Logger.hpp"
...
@@ -9,41 +9,21 @@ namespace RTC
...
@@ -9,41 +9,21 @@ namespace RTC
{
{
namespace
Codecs
namespace
Codecs
{
{
bool
IsKnown
(
const
RTC
::
RtpCodecMimeType
&
mimeType
)
void
ProcessRtpPacket
(
RTC
::
RtpPacket
*
packet
,
const
RTC
::
RtpCodecMimeType
&
mimeType
)
{
{
MS_TRACE
();
MS_TRACE
();
if
(
mimeType
.
type
!=
RTC
::
RtpCodecMimeType
::
Type
::
VIDEO
)
return
false
;
switch
(
mimeType
.
subtype
)
switch
(
mimeType
.
subtype
)
{
{
case
RTC
:
:
RtpCodecMimeType
::
Subtype
::
VP8
:
case
RTC
:
:
RtpCodecMimeType
::
Subtype
::
VP8
:
return
true
;
{
default
:
VP8
::
ProcessRtpPacket
(
packet
);
return
false
;
}
}
bool
IsKeyFrame
(
const
RTC
::
RtpCodecMimeType
&
mimeType
,
const
RTC
::
RtpPacket
*
packet
)
{
MS_TRACE
();
if
(
!
IsKnown
(
mimeType
))
return
false
;
auto
data
=
packet
->
GetPayload
();
auto
len
=
packet
->
GetPayloadLength
();
switch
(
mimeType
.
subtype
)
break
;
{
}
case
RTC
:
:
RtpCodecMimeType
::
Subtype
::
VP8
:
return
VP8
::
IsKeyFrame
(
data
,
len
);
default
:
default
:
MS_DEBUG_TAG
(
;
rtp
,
"requested key frame for an unsupported codec: %s"
,
mimeType
.
GetName
().
c_str
());
return
false
;
}
}
}
}
}
// namespace Codecs
}
// namespace Codecs
...
...
worker/src/RTC/Codecs/VP8.cpp
浏览文件 @
0fdd6356
#define MS_CLASS "RTC::Codecs::VP8"
#define MS_CLASS "RTC::Codecs::VP8"
#define MS_LOG_DEV
//
#define MS_LOG_DEV
#include "RTC/Codecs/VP8.hpp"
#include "RTC/Codecs/VP8.hpp"
#include "Logger.hpp"
#include "Logger.hpp"
...
@@ -9,10 +9,15 @@ namespace RTC
...
@@ -9,10 +9,15 @@ namespace RTC
{
{
namespace
Codecs
namespace
Codecs
{
{
bool
VP8
::
IsKeyFrame
(
const
uint8_t
*
data
,
size_t
len
)
void
VP8
::
ProcessRtpPacket
(
RTC
::
RtpPacket
*
packet
)
{
{
MS_TRACE
();
auto
data
=
packet
->
GetPayload
();
auto
len
=
packet
->
GetPayloadLength
();
if
(
len
<
1
)
if
(
len
<
1
)
return
false
;
return
;
size_t
offset
=
0
;
size_t
offset
=
0
;
uint8_t
byte
=
data
[
offset
++
];
uint8_t
byte
=
data
[
offset
++
];
...
@@ -28,10 +33,8 @@ namespace RTC
...
@@ -28,10 +33,8 @@ namespace RTC
if
(
x
)
if
(
x
)
{
{
{
if
(
len
<
offset
+
1
)
if
(
len
<
offset
+
1
)
return
;
return
false
;
}
byte
=
data
[
offset
++
];
byte
=
data
[
offset
++
];
...
@@ -44,34 +47,29 @@ namespace RTC
...
@@ -44,34 +47,29 @@ namespace RTC
if
(
i
)
if
(
i
)
{
{
if
(
len
<
offset
++
)
if
(
len
<
offset
++
)
{
return
;
return
false
;
}
if
((
byte
>>
7
)
&
0x1
)
if
((
byte
>>
7
)
&
0x1
)
{
{
if
(
len
<
offset
++
)
if
(
len
<
offset
++
)
return
false
;
return
;
}
}
}
}
if
(
l
)
if
(
l
)
{
{
if
(
len
<
offset
++
)
if
(
len
<
offset
++
)
{
return
;
return
false
;
}
}
}
if
(
t
||
k
)
if
(
t
||
k
)
{
{
if
(
len
<
offset
++
)
if
(
len
<
offset
++
)
{
return
;
return
false
;
}
}
}
return
start
&&
pid
==
0
&&
(
!
(
data
[
offset
]
&
0x1
));
if
(
start
&&
pid
==
0
&&
(
!
(
data
[
offset
]
&
0x1
)))
packet
->
SetKeyFrame
(
true
);
}
}
}
// namespace Codecs
}
// namespace Codecs
}
// namespace RTC
}
// namespace RTC
worker/src/RTC/Consumer.cpp
浏览文件 @
0fdd6356
...
@@ -175,7 +175,7 @@ namespace RTC
...
@@ -175,7 +175,7 @@ namespace RTC
MS_DEBUG_DEV
(
"Consumer resumed [consumerId:%"
PRIu32
"]"
,
this
->
consumerId
);
MS_DEBUG_DEV
(
"Consumer resumed [consumerId:%"
PRIu32
"]"
,
this
->
consumerId
);
if
(
IsEnabled
()
&&
!
this
->
sourcePaused
)
if
(
IsEnabled
()
&&
!
this
->
sourcePaused
)
Request
Full
Frame
();
Request
Key
Frame
();
}
}
void
Consumer
::
SourcePause
()
void
Consumer
::
SourcePause
()
...
@@ -209,7 +209,7 @@ namespace RTC
...
@@ -209,7 +209,7 @@ namespace RTC
this
->
notifier
->
Emit
(
this
->
consumerId
,
"sourceresumed"
);
this
->
notifier
->
Emit
(
this
->
consumerId
,
"sourceresumed"
);
if
(
IsEnabled
()
&&
!
this
->
paused
)
if
(
IsEnabled
()
&&
!
this
->
paused
)
Request
Full
Frame
();
Request
Key
Frame
();
}
}
void
Consumer
::
SourceRtpParametersUpdated
()
void
Consumer
::
SourceRtpParametersUpdated
()
...
@@ -337,8 +337,9 @@ namespace RTC
...
@@ -337,8 +337,9 @@ namespace RTC
if
(
this
->
effectiveProfile
!=
this
->
targetProfile
&&
profile
==
this
->
targetProfile
)
if
(
this
->
effectiveProfile
!=
this
->
targetProfile
&&
profile
==
this
->
targetProfile
)
{
{
bool
isKeyFrame
=
false
;
bool
isKeyFrame
=
false
;
bool
canBeKeyFrame
=
Codecs
::
CanBeKeyFrame
(
this
->
rtpStream
->
GetMimeType
());
if
(
Codecs
::
IsKnown
(
this
->
rtpStream
->
GetMimeType
())
&&
Codecs
::
IsKeyFrame
(
this
->
rtpStream
->
GetMimeType
(),
packet
))
if
(
canBeKeyFrame
&&
packet
->
IsKeyFrame
(
))
{
{
isKeyFrame
=
true
;
isKeyFrame
=
true
;
...
@@ -348,7 +349,7 @@ namespace RTC
...
@@ -348,7 +349,7 @@ namespace RTC
RTC
::
RtpEncodingParameters
::
profile2String
[
profile
].
c_str
());
RTC
::
RtpEncodingParameters
::
profile2String
[
profile
].
c_str
());
}
}
if
(
!
Codecs
::
IsKnown
(
this
->
rtpStream
->
GetMimeType
())
||
is
KeyFrame
)
if
(
isKeyFrame
||
!
canBe
KeyFrame
)
{
{
SetEffectiveProfile
(
this
->
targetProfile
);
SetEffectiveProfile
(
this
->
targetProfile
);
...
@@ -549,7 +550,7 @@ namespace RTC
...
@@ -549,7 +550,7 @@ namespace RTC
this
->
rtpStream
->
ReceiveRtcpReceiverReport
(
report
);
this
->
rtpStream
->
ReceiveRtcpReceiverReport
(
report
);
}
}
void
Consumer
::
Request
Full
Frame
()
void
Consumer
::
Request
Key
Frame
()
{
{
MS_TRACE
();
MS_TRACE
();
...
@@ -561,7 +562,7 @@ namespace RTC
...
@@ -561,7 +562,7 @@ namespace RTC
for
(
auto
&
listener
:
this
->
listeners
)
for
(
auto
&
listener
:
this
->
listeners
)
{
{
listener
->
OnConsumer
Full
FrameRequired
(
this
);
listener
->
OnConsumer
Key
FrameRequired
(
this
);
}
}
}
}
...
@@ -727,7 +728,7 @@ namespace RTC
...
@@ -727,7 +728,7 @@ namespace RTC
return
;
return
;
if
(
IsEnabled
()
&&
!
IsPaused
())
if
(
IsEnabled
()
&&
!
IsPaused
())
Request
Full
Frame
();
Request
Key
Frame
();
MS_DEBUG_TAG
(
MS_DEBUG_TAG
(
rtp
,
rtp
,
...
...
worker/src/RTC/NackGenerator.cpp
浏览文件 @
0fdd6356
...
@@ -112,15 +112,15 @@ namespace RTC
...
@@ -112,15 +112,15 @@ namespace RTC
this
->
nackList
.
erase
(
this
->
nackList
.
begin
(),
it
);
this
->
nackList
.
erase
(
this
->
nackList
.
begin
(),
it
);
// If the nack list is too large, clear it and request a
full
frame.
// If the nack list is too large, clear it and request a
key
frame.
uint32_t
numNewNacks
=
seq32End
-
seq32Start
;
uint32_t
numNewNacks
=
seq32End
-
seq32Start
;
if
(
this
->
nackList
.
size
()
+
numNewNacks
>
MaxNackPackets
)
if
(
this
->
nackList
.
size
()
+
numNewNacks
>
MaxNackPackets
)
{
{
MS_DEBUG_TAG
(
rtx
,
"NACK list too large, clearing it and requesting a
full
frame"
);
MS_DEBUG_TAG
(
rtx
,
"NACK list too large, clearing it and requesting a
key
frame"
);
this
->
nackList
.
clear
();
this
->
nackList
.
clear
();
this
->
listener
->
OnNackGenerator
Full
FrameRequired
();
this
->
listener
->
OnNackGenerator
Key
FrameRequired
();
return
;
return
;
}
}
...
...
worker/src/RTC/Producer.cpp
浏览文件 @
0fdd6356
...
@@ -13,8 +13,7 @@ namespace RTC
...
@@ -13,8 +13,7 @@ namespace RTC
{
{
/* Static. */
/* Static. */
// TODO: Set a proper value.
static
constexpr
uint64_t
KeyFrameRequestBlockTimeout
{
1000
};
// In ms.
static
constexpr
uint64_t
FullFrameRequestBlockTimeout
{
1000
};
// In ms.
/* Instance methods. */
/* Instance methods. */
...
@@ -43,8 +42,8 @@ namespace RTC
...
@@ -43,8 +42,8 @@ namespace RTC
else
else
this
->
maxRtcpInterval
=
RTC
::
RTCP
::
MaxAudioIntervalMs
;
this
->
maxRtcpInterval
=
RTC
::
RTCP
::
MaxAudioIntervalMs
;
// Set the RTP
full
frame request block timer.
// Set the RTP
key
frame request block timer.
this
->
full
FrameRequestBlockTimer
=
new
Timer
(
this
);
this
->
key
FrameRequestBlockTimer
=
new
Timer
(
this
);
}
}
Producer
::~
Producer
()
Producer
::~
Producer
()
...
@@ -65,8 +64,8 @@ namespace RTC
...
@@ -65,8 +64,8 @@ namespace RTC
listener
->
OnProducerClosed
(
this
);
listener
->
OnProducerClosed
(
this
);
}
}
// Close the RTP
full
frame request block timer.
// Close the RTP
key
frame request block timer.
this
->
full
FrameRequestBlockTimer
->
Destroy
();
this
->
key
FrameRequestBlockTimer
->
Destroy
();
delete
this
;
delete
this
;
}
}
...
@@ -200,7 +199,7 @@ namespace RTC
...
@@ -200,7 +199,7 @@ namespace RTC
listener
->
OnProducerResumed
(
this
);
listener
->
OnProducerResumed
(
this
);
}
}
Request
Full
Frame
(
true
);
Request
Key
Frame
(
true
);
}
}
void
Producer
::
SetRtpRawEvent
(
bool
enabled
)
void
Producer
::
SetRtpRawEvent
(
bool
enabled
)
...
@@ -221,9 +220,9 @@ namespace RTC
...
@@ -221,9 +220,9 @@ namespace RTC
MS_DEBUG_DEV
(
"Producer rtpraw event disabled [producerId:%"
PRIu32
"]"
,
this
->
producerId
);
MS_DEBUG_DEV
(
"Producer rtpraw event disabled [producerId:%"
PRIu32
"]"
,
this
->
producerId
);
}
}
// If set (and not paused), require a
full
frame.
// If set (and not paused), require a
key
frame.
if
(
this
->
rtpRawEventEnabled
&&
!
this
->
paused
)
if
(
this
->
rtpRawEventEnabled
&&
!
this
->
paused
)
Request
Full
Frame
(
true
);
Request
Key
Frame
(
true
);
}
}
void
Producer
::
SetRtpObjectEvent
(
bool
enabled
)
void
Producer
::
SetRtpObjectEvent
(
bool
enabled
)
...
@@ -244,9 +243,9 @@ namespace RTC
...
@@ -244,9 +243,9 @@ namespace RTC
MS_DEBUG_DEV
(
"Producer rtpobject event disabled [producerId:%"
PRIu32
"]"
,
this
->
producerId
);
MS_DEBUG_DEV
(
"Producer rtpobject event disabled [producerId:%"
PRIu32
"]"
,
this
->
producerId
);
}
}
// If set (and not paused), require a
full
frame.
// If set (and not paused), require a
key
frame.
if
(
this
->
rtpObjectEventEnabled
&&
!
this
->
paused
)
if
(
this
->
rtpObjectEventEnabled
&&
!
this
->
paused
)
Request
Full
Frame
(
true
);
Request
Key
Frame
(
true
);
}
}
void
Producer
::
ReceiveRtpPacket
(
RTC
::
RtpPacket
*
packet
)
void
Producer
::
ReceiveRtpPacket
(
RTC
::
RtpPacket
*
packet
)
...
@@ -301,7 +300,10 @@ namespace RTC
...
@@ -301,7 +300,10 @@ namespace RTC
return
;
return
;
}
}
if
(
Codecs
::
IsKeyFrame
(
rtpStream
->
GetMimeType
(),
packet
))
// Process the packet at codec level.
Codecs
::
ProcessRtpPacket
(
packet
,
rtpStream
->
GetMimeType
());
if
(
packet
->
IsKeyFrame
())
{
{
MS_DEBUG_TAG
(
MS_DEBUG_TAG
(
rtp
,
rtp
,
...
@@ -398,7 +400,7 @@ namespace RTC
...
@@ -398,7 +400,7 @@ namespace RTC
this
->
transport
->
SendRtcpPacket
(
packet
);
this
->
transport
->
SendRtcpPacket
(
packet
);
}
}
void
Producer
::
Request
Full
Frame
(
bool
force
)
void
Producer
::
Request
Key
Frame
(
bool
force
)
{
{
MS_TRACE
();
MS_TRACE
();
...
@@ -408,30 +410,30 @@ namespace RTC
...
@@ -408,30 +410,30 @@ namespace RTC
if
(
force
)
if
(
force
)
{
{
// Stop the timer.
// Stop the timer.
this
->
full
FrameRequestBlockTimer
->
Stop
();
this
->
key
FrameRequestBlockTimer
->
Stop
();
}
}
else
if
(
this
->
full
FrameRequestBlockTimer
->
IsActive
())
else
if
(
this
->
key
FrameRequestBlockTimer
->
IsActive
())
{
{
MS_DEBUG_TAG
(
rtcp
,
"blocking
full
frame request until timer expires"
);
MS_DEBUG_TAG
(
rtcp
,
"blocking
key
frame request until timer expires"
);
// Set flag.
// Set flag.
this
->
is
Full
FrameRequested
=
true
;
this
->
is
Key
FrameRequested
=
true
;
return
;
return
;
}
}
// Run the timer.
// Run the timer.
this
->
fullFrameRequestBlockTimer
->
Start
(
Full
FrameRequestBlockTimeout
);
this
->
keyFrameRequestBlockTimer
->
Start
(
Key
FrameRequestBlockTimeout
);
for
(
auto
&
kv
:
this
->
rtpStreams
)
for
(
auto
&
kv
:
this
->
rtpStreams
)
{
{
auto
rtpStream
=
kv
.
second
;
auto
rtpStream
=
kv
.
second
;
rtpStream
->
Request
Full
Frame
();
rtpStream
->
Request
Key
Frame
();
}
}
// Reset flag.
// Reset flag.
this
->
is
Full
FrameRequested
=
false
;
this
->
is
Key
FrameRequested
=
false
;
}
}
void
Producer
::
FillHeaderExtensionIds
()
void
Producer
::
FillHeaderExtensionIds
()
...
@@ -614,8 +616,8 @@ namespace RTC
...
@@ -614,8 +616,8 @@ namespace RTC
}
}
}
}
// Request a
full
frame since we may have lost the first packets of this stream.
// Request a
key
frame since we may have lost the first packets of this stream.
Request
Full
Frame
(
true
);
Request
Key
Frame
(
true
);
}
}
void
Producer
::
ClearRtpStream
(
RTC
::
RtpStreamRecv
*
rtpStream
)
void
Producer
::
ClearRtpStream
(
RTC
::
RtpStreamRecv
*
rtpStream
)
...
@@ -850,15 +852,15 @@ namespace RTC
...
@@ -850,15 +852,15 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
if
(
timer
==
this
->
full
FrameRequestBlockTimer
)
if
(
timer
==
this
->
key
FrameRequestBlockTimer
)
{
{
// Nobody asked for a
full
frame since the timer was started.
// Nobody asked for a
key
frame since the timer was started.
if
(
!
this
->
is
Full
FrameRequested
)
if
(
!
this
->
is
Key
FrameRequested
)
return
;
return
;
MS_DEBUG_TAG
(
rtcp
,
"requesting
full
frame after timer expires"
);
MS_DEBUG_TAG
(
rtcp
,
"requesting
key
frame after timer expires"
);
Request
Full
Frame
();
Request
Key
Frame
();
}
}
}
}
}
// namespace RTC
}
// namespace RTC
worker/src/RTC/Router.cpp
浏览文件 @
0fdd6356
...
@@ -1476,7 +1476,7 @@ namespace RTC
...
@@ -1476,7 +1476,7 @@ namespace RTC
this
->
mapConsumerProducer
.
erase
(
consumer
);
this
->
mapConsumerProducer
.
erase
(
consumer
);
}
}
void
Router
::
OnConsumer
Full
FrameRequired
(
RTC
::
Consumer
*
consumer
)
void
Router
::
OnConsumer
Key
FrameRequired
(
RTC
::
Consumer
*
consumer
)
{
{
MS_TRACE
();
MS_TRACE
();
...
@@ -1486,7 +1486,7 @@ namespace RTC
...
@@ -1486,7 +1486,7 @@ namespace RTC
auto
*
producer
=
this
->
mapConsumerProducer
[
consumer
];
auto
*
producer
=
this
->
mapConsumerProducer
[
consumer
];
producer
->
Request
Full
Frame
();
producer
->
Request
Key
Frame
();
}
}
inline
void
Router
::
OnTimer
(
Timer
*
timer
)
inline
void
Router
::
OnTimer
(
Timer
*
timer
)
...
...
worker/src/RTC/RtpPacket.cpp
浏览文件 @
0fdd6356
...
@@ -291,9 +291,6 @@ namespace RTC
...
@@ -291,9 +291,6 @@ namespace RTC
ptr
+=
4
+
extensionValueSize
;
ptr
+=
4
+
extensionValueSize
;
}
}
// Parse and regenerate RFC 5285 extension header.
ParseExtensions
();
// Add payload.
// Add payload.
if
(
this
->
payload
!=
nullptr
)
if
(
this
->
payload
!=
nullptr
)
{
{
...
@@ -367,6 +364,9 @@ namespace RTC
...
@@ -367,6 +364,9 @@ namespace RTC
// Clone seq32.
// Clone seq32.
packet
->
seq32
=
this
->
seq32
;
packet
->
seq32
=
this
->
seq32
;
// Copy isKeyFrame.
packet
->
isKeyFrame
=
this
->
isKeyFrame
;
// Parse RFC 5285 extension header.
// Parse RFC 5285 extension header.
packet
->
ParseExtensions
();
packet
->
ParseExtensions
();
...
...
worker/src/RTC/RtpStreamRecv.cpp
浏览文件 @
0fdd6356
...
@@ -213,7 +213,7 @@ namespace RTC
...
@@ -213,7 +213,7 @@ namespace RTC
this
->
lastSrTimestamp
+=
report
->
GetNtpFrac
()
>>
16
;
this
->
lastSrTimestamp
+=
report
->
GetNtpFrac
()
>>
16
;
}
}
void
RtpStreamRecv
::
Request
Full
Frame
()
void
RtpStreamRecv
::
Request
Key
Frame
()
{
{
MS_TRACE
();
MS_TRACE
();
...
@@ -285,11 +285,11 @@ namespace RTC
...
@@ -285,11 +285,11 @@ namespace RTC
this
->
listener
->
OnRtpStreamRecvNackRequired
(
this
,
seqNumbers
);
this
->
listener
->
OnRtpStreamRecvNackRequired
(
this
,
seqNumbers
);
}
}
void
RtpStreamRecv
::
OnNackGenerator
Full
FrameRequired
()
void
RtpStreamRecv
::
OnNackGenerator
Key
FrameRequired
()
{
{
MS_TRACE
();
MS_TRACE
();
Request
Full
Frame
();
Request
Key
Frame
();
}
}
void
RtpStreamRecv
::
SetRtx
(
uint8_t
payloadType
,
uint32_t
ssrc
)
void
RtpStreamRecv
::
SetRtx
(
uint8_t
payloadType
,
uint32_t
ssrc
)
...
...
worker/src/RTC/Transport.cpp
浏览文件 @
0fdd6356
...
@@ -40,7 +40,7 @@ namespace RTC
...
@@ -40,7 +40,7 @@ namespace RTC
/* Static. */
/* Static. */
static
constexpr
uint64_t
EffectiveMaxBitrateCheckInterval
{
2000
};
// In ms.
static
constexpr
uint64_t
EffectiveMaxBitrateCheckInterval
{
2000
};
// In ms.
static
constexpr
double
EffectiveMaxBitrateThresholdBefore
Full
Frame
{
0.6
};
// 0.0 - 1.0.
static
constexpr
double
EffectiveMaxBitrateThresholdBefore
Key
Frame
{
0.6
};
// 0.0 - 1.0.
/* Instance methods. */
/* Instance methods. */
...
@@ -461,16 +461,16 @@ namespace RTC
...
@@ -461,16 +461,16 @@ namespace RTC
// Add us as listener.
// Add us as listener.
consumer
->
AddListener
(
this
);
consumer
->
AddListener
(
this
);
// If we are connected, ask a
full
request for this enabled Consumer.
// If we are connected, ask a
key
request for this enabled Consumer.
if
(
IsConnected
())
if
(
IsConnected
())
{
{
if
(
consumer
->
kind
==
RTC
::
Media
::
Kind
::
VIDEO
)
if
(
consumer
->
kind
==
RTC
::
Media
::
Kind
::
VIDEO
)
{
{
MS_DEBUG_TAG
(
MS_DEBUG_TAG
(
rtcp
,
"requesting
full
frame for new Consumer since Transport already connected"
);
rtcp
,
"requesting
key
frame for new Consumer since Transport already connected"
);
}
}
consumer
->
Request
Full
Frame
();
consumer
->
Request
Key
Frame
();
}
}
}
}
...
@@ -736,7 +736,7 @@ namespace RTC
...
@@ -736,7 +736,7 @@ namespace RTC
break
;
break
;
}
}
consumer
->
Request
Full
Frame
();
consumer
->
Request
Key
Frame
();
break
;
break
;
}
}
...
@@ -1439,13 +1439,13 @@ namespace RTC
...
@@ -1439,13 +1439,13 @@ namespace RTC
eventData
[
JsonStringDtlsRemoteCert
]
=
remoteCert
;
eventData
[
JsonStringDtlsRemoteCert
]
=
remoteCert
;
this
->
notifier
->
Emit
(
this
->
transportId
,
"dtlsstatechange"
,
eventData
);
this
->
notifier
->
Emit
(
this
->
transportId
,
"dtlsstatechange"
,
eventData
);
// Iterate all the Consumers and request
full
frame.
// Iterate all the Consumers and request
key
frame.
for
(
auto
*
consumer
:
this
->
consumers
)
for
(
auto
*
consumer
:
this
->
consumers
)
{
{
if
(
consumer
->
kind
==
RTC
::
Media
::
Kind
::
VIDEO
)
if
(
consumer
->
kind
==
RTC
::
Media
::
Kind
::
VIDEO
)
MS_DEBUG_TAG
(
rtcp
,
"Transport connected, requesting
full
frame for Consumers"
);
MS_DEBUG_TAG
(
rtcp
,
"Transport connected, requesting
key
frame for Consumers"
);
consumer
->
Request
Full
Frame
();
consumer
->
Request
Key
Frame
();
}
}
}
}
...
@@ -1550,21 +1550,21 @@ namespace RTC
...
@@ -1550,21 +1550,21 @@ namespace RTC
packet
.
Serialize
(
RTC
::
RTCP
::
Buffer
);
packet
.
Serialize
(
RTC
::
RTCP
::
Buffer
);
this
->
SendRtcpPacket
(
&
packet
);
this
->
SendRtcpPacket
(
&
packet
);
// Trigger a
full frame for all the suitable str
ams if the effective max bitrate
// Trigger a
key frame for all the suitable stre
ams if the effective max bitrate
// has decreased abruptly.
// has decreased abruptly.
if
(
now
-
this
->
lastEffectiveMaxBitrateAt
>
EffectiveMaxBitrateCheckInterval
)
if
(
now
-
this
->
lastEffectiveMaxBitrateAt
>
EffectiveMaxBitrateCheckInterval
)
{
{
if
(
if
(
(
bitrate
!=
0u
)
&&
(
this
->
effectiveMaxBitrate
!=
0u
)
&&
(
bitrate
!=
0u
)
&&
(
this
->
effectiveMaxBitrate
!=
0u
)
&&
static_cast
<
double
>
(
effectiveBitrate
)
/
static_cast
<
double
>
(
this
->
effectiveMaxBitrate
)
<
static_cast
<
double
>
(
effectiveBitrate
)
/
static_cast
<
double
>
(
this
->
effectiveMaxBitrate
)
<
EffectiveMaxBitrateThresholdBefore
Full
Frame
)
EffectiveMaxBitrateThresholdBefore
Key
Frame
)
{
{
MS_WARN_TAG
(
rbe
,
"uplink effective max bitrate abruptly decrease, requesting
full
frames"
);
MS_WARN_TAG
(
rbe
,
"uplink effective max bitrate abruptly decrease, requesting
key
frames"
);
// Request
full
frame for all the Producers.
// Request
key
frame for all the Producers.
for
(
auto
*
producer
:
this
->
producers
)
for
(
auto
*
producer
:
this
->
producers
)
{
{
producer
->
Request
Full
Frame
();
producer
->
Request
Key
Frame
();
}
}
}
}
...
@@ -1631,7 +1631,7 @@ namespace RTC
...
@@ -1631,7 +1631,7 @@ namespace RTC
this
->
consumers
.
erase
(
consumer
);
this
->
consumers
.
erase
(
consumer
);
}
}
void
Transport
::
OnConsumer
Full
FrameRequired
(
RTC
::
Consumer
*
/*consumer*/
)
void
Transport
::
OnConsumer
Key
FrameRequired
(
RTC
::
Consumer
*
/*consumer*/
)
{
{
// Do nothing.
// Do nothing.
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论