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
7f6be9e1
Commit
7f6be9e1
authored
Dec 30, 2021
by
ziyue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refine: 消除编译警告
parent
940fe333
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
67 行增加
和
200 行删除
+67
-200
3rdpart/ZLToolKit
+1
-1
api/include/mk_util.h
+6
-6
src/Rtcp/Rtcp.cpp
+45
-50
src/Rtcp/RtcpFCI.cpp
+6
-5
src/Rtsp/RtpCodec.cpp
+2
-1
tests/test_rtcp.cpp
+0
-132
webrtc/Nack.cpp
+4
-4
webrtc/WebRtcTransport.cpp
+3
-1
没有找到文件。
ZLToolKit
@
7ede622a
Subproject commit
f2f79123f23943381009e89b407aa6f8ef683a82
Subproject commit
7ede622a3f4e7d3ee9dfe7d61465f1d938873b94
api/include/mk_util.h
查看文件 @
7f6be9e1
...
...
@@ -65,12 +65,12 @@ API_EXPORT char* API_CALL mk_util_hex_dump(const void *buf, int len);
API_EXPORT
void
API_CALL
mk_log_printf
(
int
level
,
const
char
*
file
,
const
char
*
function
,
int
line
,
const
char
*
fmt
,
...);
// 以下宏可以替换printf使用
#define log_printf(lev,
fmt, ...) mk_log_printf(lev, __FILE__, __FUNCTION__, __LINE__, fmt
, ##__VA_ARGS__)
#define log_trace(
fmt, ...) log_printf(0, fmt
, ##__VA_ARGS__)
#define log_debug(
fmt,...) log_printf(1, fmt
, ##__VA_ARGS__)
#define log_info(
fmt, ...) log_printf(2, fmt
, ##__VA_ARGS__)
#define log_warn(
fmt, ...) log_printf(3, fmt
, ##__VA_ARGS__)
#define log_error(
fmt, ...) log_printf(4, fmt
, ##__VA_ARGS__)
#define log_printf(lev,
...) mk_log_printf(lev, __FILE__, __FUNCTION__, __LINE__
, ##__VA_ARGS__)
#define log_trace(
...) log_printf(0
, ##__VA_ARGS__)
#define log_debug(
...) log_printf(1
, ##__VA_ARGS__)
#define log_info(
...) log_printf(2
, ##__VA_ARGS__)
#define log_warn(
...) log_printf(3
, ##__VA_ARGS__)
#define log_error(
...) log_printf(4
, ##__VA_ARGS__)
#ifdef __cplusplus
}
...
...
src/Rtcp/Rtcp.cpp
查看文件 @
7f6be9e1
差异被折叠。
点击展开。
src/Rtcp/RtcpFCI.cpp
查看文件 @
7f6be9e1
...
...
@@ -118,9 +118,9 @@ string FCI_REMB::create(const vector<uint32_t> &ssrcs, uint32_t bitrate) {
thiz
->
bitrate
[
3
]
=
(
uint8_t
)
(
mantissa
);
//设置ssrc列表
auto
ptr
=
thiz
->
ssrc_feedback
;
int
i
=
0
;
for
(
auto
ssrc
:
ssrcs
)
{
*
(
ptr
++
)
=
htonl
(
ssrc
);
thiz
->
ssrc_feedback
[
i
++
]
=
htonl
(
ssrc
);
}
return
ret
;
}
...
...
@@ -136,9 +136,10 @@ uint32_t FCI_REMB::getBitRate() const {
vector
<
uint32_t
>
FCI_REMB
::
getSSRC
()
{
vector
<
uint32_t
>
ret
;
auto
num_ssrc
=
bitrate
[
0
];
auto
ptr
=
ssrc_feedback
;
int
i
=
0
;
while
(
num_ssrc
--
)
{
ret
.
emplace_back
(
ntohl
(
*
ptr
++
));
ret
.
emplace_back
(
ntohl
(
ssrc_feedback
[
i
]));
++
i
;
}
return
ret
;
}
...
...
@@ -537,7 +538,7 @@ string FCI_TWCC::create(uint32_t ref_time, uint8_t fb_pkt_count, TwccPacketStatu
break
;
}
}
vec
.
resize
(
MIN
(
vec
.
size
(),
14
>>
symbol
));
vec
.
resize
(
MIN
(
vec
.
size
(),
(
size_t
)
14
>>
symbol
));
StatusVecChunk
chunk
(
symbol
,
vec
);
fci
.
append
((
char
*
)
&
chunk
,
StatusVecChunk
::
kSize
);
appendDeltaString
(
delta_str
,
status
,
vec
.
size
());
...
...
src/Rtsp/RtpCodec.cpp
查看文件 @
7f6be9e1
...
...
@@ -35,7 +35,8 @@ RtpPacket::Ptr RtpInfo::makeRtp(TrackType type, const void* data, size_t len, bo
header
->
csrc
=
0
;
header
->
mark
=
mark
;
header
->
pt
=
_pt
;
header
->
seq
=
htons
(
_seq
++
);
header
->
seq
=
htons
(
_seq
);
++
_seq
;
header
->
stamp
=
htonl
(
uint64_t
(
stamp
)
*
_sample_rate
/
1000
);
header
->
ssrc
=
htonl
(
_ssrc
);
...
...
tests/test_rtcp.cpp
deleted
100644 → 0
查看文件 @
940fe333
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors
* may be found in the AUTHORS file in the root of the source tree.
*/
#include "Rtcp/Rtcp.h"
#include "Util/logger.h"
using
namespace
std
;
using
namespace
toolkit
;
using
namespace
mediakit
;
void
printRtcp
(
const
std
::
shared_ptr
<
Buffer
>
&
buffer
){
auto
rtcp_arr
=
RtcpHeader
::
loadFromBytes
(
buffer
->
data
(),
buffer
->
size
());
//转换为主机字节序方可打印
InfoL
<<
"
\r\n
"
<<
rtcp_arr
[
0
]
->
dumpString
();
}
std
::
shared_ptr
<
Buffer
>
makeRtcpSR
()
{
auto
rtcp
=
RtcpSR
::
create
(
3
);
rtcp
->
ssrc
=
htonl
(
1
);
struct
timeval
tv
;
gettimeofday
(
&
tv
,
NULL
);
rtcp
->
setNtpStamp
(
tv
);
rtcp
->
rtpts
=
htonl
(
2
);
rtcp
->
packet_count
=
htonl
(
3
);
rtcp
->
octet_count
=
htonl
(
4
);
auto
i
=
5
;
for
(
auto
&
ptr
:
rtcp
->
getItemList
())
{
ReportItem
*
item
=
(
ReportItem
*
)
ptr
;
item
->
ssrc
=
htonl
(
i
++
);
item
->
fraction
=
i
++
;
item
->
cumulative
=
htonl
(
i
++
)
>>
8
;
item
->
seq_cycles
=
htons
(
i
++
);
item
->
seq_max
=
htons
(
i
++
);
item
->
jitter
=
htonl
(
i
++
);
item
->
last_sr_stamp
=
htonl
(
i
++
);
item
->
delay_since_last_sr
=
htonl
(
i
++
);
}
//返回网络字节序
return
RtcpHeader
::
toBuffer
(
rtcp
);
}
std
::
shared_ptr
<
Buffer
>
makeRtcpRR
()
{
auto
rtcp
=
RtcpRR
::
create
(
3
);
rtcp
->
ssrc
=
htonl
(
1
);
auto
i
=
5
;
for
(
auto
&
ptr
:
rtcp
->
getItemList
())
{
ReportItem
*
item
=
(
ReportItem
*
)
ptr
;
item
->
ssrc
=
htonl
(
i
++
);
item
->
fraction
=
i
++
;
item
->
cumulative
=
htonl
(
i
++
)
>>
8
;
item
->
seq_cycles
=
htons
(
i
++
);
item
->
seq_max
=
htons
(
i
++
);
item
->
jitter
=
htonl
(
i
++
);
item
->
last_sr_stamp
=
htonl
(
i
++
);
item
->
delay_since_last_sr
=
htonl
(
i
++
);
}
//返回网络字节序
return
RtcpHeader
::
toBuffer
(
rtcp
);
}
std
::
shared_ptr
<
Buffer
>
makeRtcpSDES
()
{
auto
rtcp
=
RtcpSdes
::
create
({
"zlmediakit"
,
""
,
"https://github.com/xia-chu/ZLMediaKit"
,
"1213642868@qq.com"
,
"123456789012345678"
});
auto
i
=
5
;
auto
items
=
rtcp
->
getChunkList
();
items
[
0
]
->
type
=
(
uint8_t
)
SdesType
::
RTCP_SDES_CNAME
;
items
[
0
]
->
ssrc
=
htonl
(
i
++
);
items
[
1
]
->
type
=
(
uint8_t
)
SdesType
::
RTCP_SDES_NOTE
;
items
[
1
]
->
ssrc
=
htonl
(
i
++
);
items
[
2
]
->
type
=
(
uint8_t
)
SdesType
::
RTCP_SDES_LOC
;
items
[
2
]
->
ssrc
=
htonl
(
i
++
);
items
[
3
]
->
type
=
(
uint8_t
)
SdesType
::
RTCP_SDES_EMAIL
;
items
[
3
]
->
ssrc
=
htonl
(
i
++
);
items
[
4
]
->
type
=
(
uint8_t
)
SdesType
::
RTCP_SDES_PHONE
;
items
[
4
]
->
ssrc
=
htonl
(
i
++
);
//返回网络字节序
return
RtcpHeader
::
toBuffer
(
rtcp
);
}
int
main
(
int
argc
,
char
*
argv
[]){
Logger
::
Instance
().
add
(
std
::
make_shared
<
ConsoleChannel
>
());
{
static
char
rtcp_data
[]
=
"
\x81\xca\x00\x05\x70\xd8\xac\x1b\x01\x0b\x7a\x73\x68\x50\x43\x40
"
"
\x7a\x73\x68\x50\x43\x00\x00\x00
"
"
\x81\xc9\x00\x07\x70\xd8\xac\x1b\x55\x66\x77\x88\x00\x00\x00\x00
"
"
\x00\x00\x0d\x21\x00\x00\x00\x32\xdd\xf1\x00\x00\x00\x03\x4f\x67
"
"
\x80\xc8\x00\x06\x55\x66\x77\x88\xe3\x70\xdd\xf1\x00\x00\xc2\xb8
"
"
\x00\x21\xe4\x90\x00\x00\x0b\x81\x00\x2f\x6a\x60
"
;
auto
rtcp_arr
=
RtcpHeader
::
loadFromBytes
(
rtcp_data
,
sizeof
(
rtcp_data
)
-
1
);
for
(
auto
&
rtcp
:
rtcp_arr
)
{
DebugL
<<
"
\r\n
"
<<
rtcp
->
dumpString
();
}
}
{
printRtcp
(
makeRtcpSR
());
printRtcp
(
makeRtcpRR
());
printRtcp
(
makeRtcpSDES
());
}
{
string
str
;
auto
sr
=
makeRtcpSR
();
auto
rr
=
makeRtcpRR
();
auto
sdes
=
makeRtcpSDES
();
str
.
append
(
sr
->
data
(),
sr
->
size
());
str
.
append
(
rr
->
data
(),
rr
->
size
());
str
.
append
(
sdes
->
data
(),
sdes
->
size
());
//测试内存越界
char
*
data
=
new
char
[
str
.
size
()];
memcpy
(
data
,
str
.
data
(),
str
.
size
());
auto
rtcp_arr
=
RtcpHeader
::
loadFromBytes
(
data
,
str
.
size
());
for
(
auto
&
rtcp
:
rtcp_arr
)
{
WarnL
<<
"
\r\n
"
<<
rtcp
->
dumpString
();
}
delete
[]
data
;
}
}
\ No newline at end of file
webrtc/Nack.cpp
查看文件 @
7f6be9e1
...
...
@@ -94,7 +94,7 @@ void NackContext::received(uint16_t seq, bool is_rtx) {
return
;
}
if
(
_seq
.
size
()
==
diff
+
1
&&
_last_max_seq
+
1
==
min_seq
)
{
if
(
_seq
.
size
()
==
(
size_t
)
diff
+
1
&&
_last_max_seq
+
1
==
min_seq
)
{
//都是连续的seq,未丢包
_seq
.
clear
();
_last_max_seq
=
max_seq
;
...
...
@@ -107,10 +107,10 @@ void NackContext::received(uint16_t seq, bool is_rtx) {
//有丢包,丢包从_last_max_seq开始
auto
nack_rtp_count
=
FCI_NACK
::
kBitSize
;
if
(
max_seq
-
_last_max_seq
>
nack_rtp_count
)
{
if
(
max_seq
>
nack_rtp_count
+
_last_max_seq
)
{
vector
<
bool
>
vec
;
vec
.
resize
(
FCI_NACK
::
kBitSize
,
false
);
for
(
auto
i
=
0
;
i
<
nack_rtp_count
;
++
i
)
{
for
(
size_t
i
=
0
;
i
<
nack_rtp_count
;
++
i
)
{
vec
[
i
]
=
_seq
.
find
(
_last_max_seq
+
i
+
2
)
==
_seq
.
end
();
}
doNack
(
FCI_NACK
(
_last_max_seq
+
1
,
vec
),
true
);
...
...
@@ -224,7 +224,7 @@ uint64_t NackContext::reSendNack() {
continue
;
}
auto
inc
=
*
it
-
pid
;
if
(
inc
>
FCI_NACK
::
kBitSize
)
{
if
(
inc
>
(
ssize_t
)
FCI_NACK
::
kBitSize
)
{
//新的nack包
doNack
(
FCI_NACK
(
pid
,
vec
),
false
);
pid
=
-
1
;
...
...
webrtc/WebRtcTransport.cpp
查看文件 @
7f6be9e1
...
...
@@ -843,7 +843,9 @@ void WebRtcTransportImp::onBeforeEncryptRtp(const char *buf, int &len, void *ctx
auto
origin_seq
=
ntohs
(
header
->
seq
);
//seq跟原来的不一样
header
->
seq
=
htons
(
_rtx_seq
[
pr
->
second
->
media
->
type
]
++
);
header
->
seq
=
htons
(
_rtx_seq
[
pr
->
second
->
media
->
type
]);
++
_rtx_seq
[
pr
->
second
->
media
->
type
];
auto
payload
=
header
->
getPayloadData
();
auto
payload_size
=
header
->
getPayloadSize
(
len
);
if
(
payload_size
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论