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
a7cd4d07
Commit
a7cd4d07
authored
May 13, 2021
by
ziyue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rtp ext不做内存拷贝
parent
0e968a2d
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
38 行增加
和
13 行删除
+38
-13
webrtc/RtpExt.cpp
+28
-9
webrtc/RtpExt.h
+10
-4
没有找到文件。
webrtc/RtpExt.cpp
查看文件 @
a7cd4d07
...
@@ -147,9 +147,28 @@ void appendExt(map<uint8_t, RtpExt> &ret, uint8_t *ptr, const uint8_t *end) {
...
@@ -147,9 +147,28 @@ void appendExt(map<uint8_t, RtpExt> &ret, uint8_t *ptr, const uint8_t *end) {
}
}
}
}
RtpExt
::
RtpExt
(
void
*
ptr
,
bool
one_byte_ext
,
const
char
*
str
,
size_t
size
)
:
std
::
string
(
str
,
size
)
{
RtpExt
::
RtpExt
(
void
*
ext
,
bool
one_byte_ext
,
const
char
*
str
,
size_t
size
)
{
_
ptr
=
ptr
;
_
ext
=
ext
;
_one_byte_ext
=
one_byte_ext
;
_one_byte_ext
=
one_byte_ext
;
_data
=
str
;
_size
=
size
;
}
const
char
*
RtpExt
::
data
()
const
{
return
_data
;
}
size_t
RtpExt
::
size
()
const
{
return
_size
;
}
const
char
&
RtpExt
::
operator
[](
size_t
pos
)
const
{
CHECK
(
pos
<
_size
);
return
_data
[
pos
];
}
RtpExt
::
operator
std
::
string
()
const
{
return
string
(
_data
,
_size
);
}
}
map
<
uint8_t
/*id*/
,
RtpExt
/*data*/
>
RtpExt
::
getExtValue
(
const
RtpHeader
*
header
)
{
map
<
uint8_t
/*id*/
,
RtpExt
/*data*/
>
RtpExt
::
getExtValue
(
const
RtpHeader
*
header
)
{
...
@@ -364,7 +383,7 @@ uint16_t RtpExt::getTransportCCSeq() const {
...
@@ -364,7 +383,7 @@ uint16_t RtpExt::getTransportCCSeq() const {
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | ID | len | SDES Item text value ... |
// | ID | len | SDES Item text value ... |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
const
string
&
RtpExt
::
getSdesMid
()
const
{
string
RtpExt
::
getSdesMid
()
const
{
CHECK
(
_type
==
RtpExtType
::
sdes_mid
&&
size
()
>=
1
);
CHECK
(
_type
==
RtpExtType
::
sdes_mid
&&
size
()
>=
1
);
return
*
this
;
return
*
this
;
}
}
...
@@ -515,23 +534,23 @@ uint8_t RtpExt::getFramemarkingTID() const {
...
@@ -515,23 +534,23 @@ uint8_t RtpExt::getFramemarkingTID() const {
}
}
void
RtpExt
::
setExtId
(
uint8_t
ext_id
)
{
void
RtpExt
::
setExtId
(
uint8_t
ext_id
)
{
assert
(
ext_id
>
(
int
)
RtpExtType
::
padding
&&
ext_id
<=
(
int
)
RtpExtType
::
reserved
&&
_
ptr
);
assert
(
ext_id
>
(
int
)
RtpExtType
::
padding
&&
ext_id
<=
(
int
)
RtpExtType
::
reserved
&&
_
ext
);
if
(
_one_byte_ext
)
{
if
(
_one_byte_ext
)
{
auto
ptr
=
reinterpret_cast
<
RtpExtOneByte
*>
(
_
ptr
);
auto
ptr
=
reinterpret_cast
<
RtpExtOneByte
*>
(
_
ext
);
ptr
->
setId
(
ext_id
);
ptr
->
setId
(
ext_id
);
}
else
{
}
else
{
auto
ptr
=
reinterpret_cast
<
RtpExtTwoByte
*>
(
_
ptr
);
auto
ptr
=
reinterpret_cast
<
RtpExtTwoByte
*>
(
_
ext
);
ptr
->
setId
(
ext_id
);
ptr
->
setId
(
ext_id
);
}
}
}
}
void
RtpExt
::
clearExt
(){
void
RtpExt
::
clearExt
(){
assert
(
_
ptr
);
assert
(
_
ext
);
if
(
_one_byte_ext
)
{
if
(
_one_byte_ext
)
{
auto
ptr
=
reinterpret_cast
<
RtpExtOneByte
*>
(
_
ptr
);
auto
ptr
=
reinterpret_cast
<
RtpExtOneByte
*>
(
_
ext
);
memset
(
ptr
,
(
int
)
RtpExtType
::
padding
,
RtpExtOneByte
::
kMinSize
+
ptr
->
getSize
());
memset
(
ptr
,
(
int
)
RtpExtType
::
padding
,
RtpExtOneByte
::
kMinSize
+
ptr
->
getSize
());
}
else
{
}
else
{
auto
ptr
=
reinterpret_cast
<
RtpExtTwoByte
*>
(
_
ptr
);
auto
ptr
=
reinterpret_cast
<
RtpExtTwoByte
*>
(
_
ext
);
memset
(
ptr
,
(
int
)
RtpExtType
::
padding
,
RtpExtTwoByte
::
kMinSize
+
ptr
->
getSize
());
memset
(
ptr
,
(
int
)
RtpExtType
::
padding
,
RtpExtTwoByte
::
kMinSize
+
ptr
->
getSize
());
}
}
}
}
...
...
webrtc/RtpExt.h
查看文件 @
a7cd4d07
...
@@ -45,7 +45,8 @@ enum class RtpExtType : uint8_t {
...
@@ -45,7 +45,8 @@ enum class RtpExtType : uint8_t {
class
RtcMedia
;
class
RtcMedia
;
class
RtpExt
:
public
std
::
string
{
//使用次对象的方法前需保证RtpHeader内存未释放
class
RtpExt
{
public
:
public
:
template
<
typename
Type
>
template
<
typename
Type
>
friend
void
appendExt
(
map
<
uint8_t
,
RtpExt
>
&
ret
,
uint8_t
*
ptr
,
const
uint8_t
*
end
);
friend
void
appendExt
(
map
<
uint8_t
,
RtpExt
>
&
ret
,
uint8_t
*
ptr
,
const
uint8_t
*
end
);
...
@@ -63,7 +64,7 @@ public:
...
@@ -63,7 +64,7 @@ public:
uint8_t
getAudioLevel
(
bool
*
vad
)
const
;
uint8_t
getAudioLevel
(
bool
*
vad
)
const
;
uint32_t
getAbsSendTime
()
const
;
uint32_t
getAbsSendTime
()
const
;
uint16_t
getTransportCCSeq
()
const
;
uint16_t
getTransportCCSeq
()
const
;
const
string
&
getSdesMid
()
const
;
string
getSdesMid
()
const
;
string
getRtpStreamId
()
const
;
string
getRtpStreamId
()
const
;
string
getRepairedRtpStreamId
()
const
;
string
getRepairedRtpStreamId
()
const
;
...
@@ -88,15 +89,20 @@ public:
...
@@ -88,15 +89,20 @@ public:
uint8_t
getFramemarkingTID
()
const
;
uint8_t
getFramemarkingTID
()
const
;
//危险函数,必须保证关联的RtpHeader对象有效
void
setExtId
(
uint8_t
ext_id
);
void
setExtId
(
uint8_t
ext_id
);
void
clearExt
();
void
clearExt
();
private
:
private
:
RtpExt
(
void
*
ptr
,
bool
one_byte_ext
,
const
char
*
str
,
size_t
size
);
RtpExt
(
void
*
ptr
,
bool
one_byte_ext
,
const
char
*
str
,
size_t
size
);
const
char
*
data
()
const
;
size_t
size
()
const
;
const
char
&
operator
[](
size_t
pos
)
const
;
operator
std
::
string
()
const
;
private
:
private
:
void
*
_ptr
=
nullptr
;
void
*
_ext
=
nullptr
;
const
char
*
_data
;
size_t
_size
;
bool
_one_byte_ext
=
true
;
bool
_one_byte_ext
=
true
;
RtpExtType
_type
=
RtpExtType
::
padding
;
RtpExtType
_type
=
RtpExtType
::
padding
;
};
};
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论