Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Z
ZLMediaKit
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
张翔宇
ZLMediaKit
Commits
48338af7
Commit
48338af7
authored
Apr 23, 2021
by
xia-chu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完善FCI相关代码
parent
743862d7
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
63 行增加
和
153 行删除
+63
-153
3rdpart/assert.h
+2
-0
src/Rtcp/RtcpFCI.cpp
+0
-0
src/Rtcp/RtcpFCI.h
+57
-102
tests/test_rtcp_fci.cpp
+4
-48
webrtc/Sdp.h
+0
-2
webrtc/WebRtcTransport.cpp
+0
-1
没有找到文件。
3rdpart/assert.h
查看文件 @
48338af7
...
...
@@ -21,6 +21,8 @@ extern void Assert_Throw(int failed, const char *exp, const char *func, const ch
}
#endif
#define CHECK(exp) Assert_Throw(!(exp), #exp, __FUNCTION__, __FILE__, __LINE__)
#ifndef NDEBUG
#ifdef assert
#undef assert
...
...
src/Rtcp/RtcpFCI.cpp
查看文件 @
48338af7
差异被折叠。
点击展开。
src/Rtcp/RtcpFCI.h
查看文件 @
48338af7
...
...
@@ -12,6 +12,7 @@
#define ZLMEDIAKIT_RTCPFCI_H
#include "Rtcp.h"
#include "assert.h"
namespace
mediakit
{
...
...
@@ -46,10 +47,11 @@ public:
static
size_t
constexpr
kSize
=
4
;
FCI_SLI
(
uint16_t
first
,
uint16_t
number
,
uint8_t
pic_id
);
void
check
(
size_t
size
);
uint16_t
getFirst
()
const
;
uint16_t
getNumber
()
const
;
uint8_t
getPicID
()
const
;
void
net2Host
();
string
dumpString
()
const
;
private
:
...
...
@@ -108,15 +110,20 @@ public:
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
class
FCI_FIR
{
public
:
uint32_t
ssrc
;
uint32_t
seq_number
:
8
;
uint32_t
reserved
:
24
;
static
size_t
constexpr
kSize
=
8
;
FCI_FIR
(
uint32_t
ssrc
,
uint8_t
seq_number
,
uint32_t
reserved
=
0
);
void
net2Host
();
void
check
(
size_t
size
);
uint32_t
getSSRC
()
const
;
uint8_t
getSeq
()
const
;
uint32_t
getReserved
()
const
;
string
dumpString
()
const
;
private
:
uint32_t
ssrc
;
uint8_t
seq_number
;
uint8_t
reserved
[
3
];
}
PACKED
;
//PSFB fmt = 5
...
...
@@ -131,6 +138,13 @@ public:
class
FCI_TSTR
{
public
:
static
size_t
constexpr
kSize
=
8
;
void
check
(
size_t
size
)
{
CHECK
(
size
==
kSize
);
}
private
:
uint8_t
data
[
kSize
];
}
PACKED
;
//PSFB fmt = 6
...
...
@@ -160,6 +174,13 @@ class FCI_TSTN : public FCI_TSTR{
class
FCI_VBCM
{
public
:
static
size_t
constexpr
kSize
=
12
;
void
check
(
size_t
size
)
{
CHECK
(
size
==
kSize
);
}
private
:
uint8_t
data
[
kSize
];
}
PACKED
;
//PSFB fmt = 15
...
...
@@ -194,12 +215,13 @@ class FCI_REMB {
public
:
static
size_t
constexpr
kSize
=
8
;
static
string
create
(
const
std
::
initializer_list
<
uint32_t
>
&
ssrcs
,
uint32_t
bitrate
);
void
net2Host
(
size_t
total_
size
);
static
string
create
(
const
std
::
vector
<
uint32_t
>
&
ssrcs
,
uint32_t
bitrate
);
void
check
(
size_t
size
);
string
dumpString
()
const
;
uint32_t
getBitRate
()
const
;
vector
<
uint32_t
*
>
getSSRC
();
vector
<
uint32_t
>
getSSRC
();
private
:
//Unique identifier 'R' 'E' 'M' 'B'
char
magic
[
4
];
//Num SSRC (8 bits)/BR Exp (6 bits)/ BR Mantissa (18 bits)
...
...
@@ -207,7 +229,6 @@ public:
// SSRC feedback (32 bits) Consists of one or more SSRC entries which
// this feedback message applies to.
uint32_t
ssrc_feedback
[
1
];
}
PACKED
;
/////////////////////////////////////////// RTPFB ////////////////////////////////////////////////////
...
...
@@ -221,32 +242,25 @@ public:
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
class
FCI_NACK
{
public
:
static
constexpr
size_t
kBitSize
=
16
;
static
constexpr
size_t
kSize
=
4
;
FCI_NACK
(
uint16_t
pid_h
,
const
vector
<
bool
>
&
type
);
void
check
(
size_t
size
);
uint16_t
getPid
()
const
;
uint16_t
getBlp
()
const
;
vector
<
bool
>
getBitArray
()
const
;
string
dumpString
()
const
;
private
:
static
constexpr
size_t
kBitSize
=
16
;
private
:
// The PID field is used to specify a lost packet. The PID field
// refers to the RTP sequence number of the lost packet.
uint16_t
pid
;
// bitmask of following lost packets (BLP): 16 bits
uint16_t
blp
;
void
net2Host
();
vector
<
bool
>
getBitArray
()
const
;
string
dumpString
()
const
;
template
<
typename
Type
>
FCI_NACK
(
uint16_t
pid_h
,
const
Type
&
type
){
uint16_t
blp_h
=
0
;
int
i
=
kBitSize
;
for
(
auto
&
item
:
type
)
{
--
i
;
if
(
item
)
{
blp_h
|=
(
1
<<
i
);
}
}
blp
=
htons
(
blp_h
);
pid
=
htons
(
pid_h
);
}
}
PACKED
;
//RTPFB fmt = 3
...
...
@@ -262,6 +276,11 @@ class FCI_TMMBR {
public
:
static
size_t
constexpr
kSize
=
8
;
void
check
(
size_t
size
)
{
CHECK
(
size
==
kSize
);
}
private
:
//SSRC (32 bits): The SSRC value of the media sender that is
// requested to obey the new maximum bit rate.
uint32_t
ssrc
;
...
...
@@ -269,17 +288,13 @@ public:
// MxTBR Exp (6 bits): The exponential scaling of the mantissa for the
// maximum total media bit rate value. The value is an
// unsigned integer [0..63].
uint32_t
max_tbr_exp
:
6
;
// MxTBR Mantissa (17 bits): The mantissa of the maximum total media
// bit rate value as an unsigned integer.
uint32_t
max_mantissa
:
17
;
// Measured Overhead (9 bits): The measured average packet overhead
// value in bytes. The measurement SHALL be done according
// to the description in section 4.2.1.2. The value is an
// unsigned integer [0..511].
uint32_t
m
easured_overhead
:
9
;
uint32_t
m
ax_tbr
;
}
PACKED
;
//RTPFB fmt = 4
...
...
@@ -307,68 +322,6 @@ enum class SymbolStatus : uint8_t{
reserved
=
3
};
class
RunLengthChunk
{
public
:
static
size_t
constexpr
kSize
=
2
;
// 0 1
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// |T| S | Run Length |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
#if __BYTE_ORDER == __BIG_ENDIAN
uint16_t
type
:
1
;
uint16_t
symbol
:
2
;
uint16_t
run_length_high
:
5
;
#else
// Run Length 高5位
uint16_t
run_length_high
:
5
;
//参考SymbolStatus定义
uint16_t
symbol
:
2
;
//固定为0
uint16_t
type
:
1
;
#endif
// Run Length 低8位
uint16_t
run_length_low
:
8
;
//获取Run Length
uint16_t
getRunLength
()
const
;
//构造函数
RunLengthChunk
(
SymbolStatus
status
,
uint16_t
run_length
);
string
dumpString
()
const
;
}
PACKED
;
class
StatusVecChunk
{
public
:
static
size_t
constexpr
kSize
=
2
;
// 0 1
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// |T|S| symbol list |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
#if __BYTE_ORDER == __BIG_ENDIAN
uint16_t
type
:
1
;
uint16_t
symbol
:
1
;
uint16_t
symbol_list_high
:
6
;
#else
// symbol_list 高6位
uint16_t
symbol_list_high
:
6
;
//symbol_list中元素是1个还是2个bit
uint16_t
symbol
:
1
;
//固定为1
uint16_t
type
:
1
;
#endif
// symbol_list 低8位
uint16_t
symbol_list_low
:
8
;
//获取symbollist
vector
<
SymbolStatus
>
getSymbolList
()
const
;
//构造函数
StatusVecChunk
(
const
vector
<
SymbolStatus
>
&
status
);
string
dumpString
()
const
;
}
PACKED
;
//RTPFB fmt = 15
//https://tools.ietf.org/html/draft-holmer-rmcat-transport-wide-cc-extensions-01#section-3.1
//https://zhuanlan.zhihu.com/p/206656654
...
...
@@ -395,6 +348,14 @@ class FCI_TWCC{
public
:
static
size_t
constexpr
kSize
=
8
;
void
check
(
size_t
size
);
string
dumpString
(
size_t
total_size
)
const
;
uint16_t
getBaseSeq
()
const
;
uint32_t
getReferenceTime
()
const
;
uint16_t
getPacketCount
()
const
;
map
<
uint16_t
,
std
::
pair
<
SymbolStatus
,
uint32_t
/*recv delta 微秒*/
>
>
getPacketChunkList
(
size_t
total_size
)
const
;
private
:
//base sequence number,基础序号,本次反馈的第一个包的序号;也就是RTP扩展头的序列号
uint16_t
base_seq
;
//packet status count, 包个数,本次反馈包含多少个包的状态;从基础序号开始算
...
...
@@ -403,12 +364,6 @@ public:
uint8_t
ref_time
[
3
];
//feedback packet count,反馈包号,本包是第几个transport-cc包,每次加1 |
uint8_t
fb_pkt_count
;
void
net2Host
(
size_t
total_size
);
uint32_t
getReferenceTime
()
const
;
map
<
uint16_t
,
std
::
pair
<
SymbolStatus
,
uint32_t
/*recv delta 微秒*/
>
>
getPacketChunkList
(
size_t
total_size
)
const
;
string
dumpString
(
size_t
total_size
)
const
;
}
PACKED
;
}
//namespace mediakit
...
...
tests/test_rtcp_fci.cpp
查看文件 @
48338af7
...
...
@@ -15,55 +15,11 @@ using namespace std;
using
namespace
toolkit
;
using
namespace
mediakit
;
int
main
()
{
//初始化日志系统
Logger
::
Instance
().
add
(
std
::
make_shared
<
ConsoleChannel
>
());
extern
void
testFCI
();
{
FCI_SLI
fci
(
0xFFFF
,
0
,
0xFF
);
InfoL
<<
0
b10101010101
<<
" "
<<
0
b01010101010
<<
" "
<<
(
int
)
0
b101010
<<
" "
<<
hexdump
(
&
fci
,
FCI_SLI
::
kSize
);
fci
.
net2Host
();
InfoL
<<
fci
.
dumpString
();
}
{
FCI_FIR
fci
(
123456
,
139
,
456789
);
InfoL
<<
hexdump
(
&
fci
,
FCI_FIR
::
kSize
);
fci
.
net2Host
();
InfoL
<<
fci
.
dumpString
();
}
{
auto
str
=
FCI_REMB
::
create
({
1234
,
2345
,
5678
},
4
*
1024
*
1024
);
FCI_REMB
*
ptr
=
(
FCI_REMB
*
)
str
.
data
();
ptr
->
net2Host
(
str
.
size
());
InfoL
<<
ptr
->
dumpString
();
}
{
FCI_NACK
nack
(
1234
,
vector
<
int
>
({
1
,
0
,
0
,
0
,
1
,
0
,
1
,
0
,
1
,
0
}));
nack
.
net2Host
();
InfoL
<<
nack
.
dumpString
();
}
{
RunLengthChunk
chunk
(
SymbolStatus
::
large_delta
,
8024
);
InfoL
<<
hexdump
(
&
chunk
,
RunLengthChunk
::
kSize
);
InfoL
<<
chunk
.
dumpString
();
}
int
main
()
{
Logger
::
Instance
().
add
(
std
::
make_shared
<
ConsoleChannel
>
());
auto
lam
=
[](
const
initializer_list
<
int
>
&
lst
){
vector
<
SymbolStatus
>
ret
;
for
(
auto
&
num
:
lst
){
ret
.
emplace_back
((
SymbolStatus
)
num
);
}
return
ret
;
};
{
StatusVecChunk
chunk
(
lam
({
0
,
1
,
0
,
1
,
0
,
1
,
0
,
0
,
0
,
1
,
1
,
1
,
0
,
1
}));
InfoL
<<
hexdump
(
&
chunk
,
StatusVecChunk
::
kSize
);
InfoL
<<
chunk
.
dumpString
();
}
{
StatusVecChunk
chunk
(
lam
({
0
,
1
,
2
,
3
,
0
,
1
,
2
}));
InfoL
<<
hexdump
(
&
chunk
,
StatusVecChunk
::
kSize
);
InfoL
<<
chunk
.
dumpString
();
}
testFCI
();
return
0
;
}
webrtc/Sdp.h
查看文件 @
48338af7
...
...
@@ -19,8 +19,6 @@
using
namespace
std
;
using
namespace
mediakit
;
#define CHECK(exp) Assert_Throw(!(exp), #exp, __FUNCTION__, __FILE__, __LINE__);
//https://datatracker.ietf.org/doc/rfc4566/?include_text=1
//https://blog.csdn.net/aggresss/article/details/109850434
//https://aggresss.blog.csdn.net/article/details/106436703
...
...
webrtc/WebRtcTransport.cpp
查看文件 @
48338af7
...
...
@@ -557,7 +557,6 @@ void WebRtcTransportImp::onRtcp(const char *buf, size_t len) {
FCI_TWCC
*
twcc
=
(
FCI_TWCC
*
)
(
fci
);
auto
fci_size
=
rtpfb
->
getSize
()
-
12
;
InfoL
<<
hexdump
(
fci
,
fci_size
);
twcc
->
net2Host
(
fci_size
);
InfoL
<<
"
\n
"
<<
twcc
->
dumpString
(
fci_size
);
}
break
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论