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
2e8a7be5
Commit
2e8a7be5
authored
May 07, 2021
by
xia-chu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完善rtp ext相关代码
parent
b2be30fd
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
80 行增加
和
10 行删除
+80
-10
webrtc/RtpExt.cpp
+50
-8
webrtc/RtpExt.h
+30
-2
没有找到文件。
webrtc/RtpExt.cpp
查看文件 @
2e8a7be5
...
...
@@ -108,8 +108,8 @@ uint8_t *RtpExtTwoByte::getData() {
static
constexpr
uint16_t
kOneByteHeader
=
0xBEDE
;
static
constexpr
uint16_t
kTwoByteHeader
=
0x1000
;
map
<
uint8_t
/*id*/
,
string
/*data*/
>
RtpExt
::
getExtValue
(
const
RtpHeader
*
header
)
{
map
<
uint8_t
,
string
>
ret
;
map
<
uint8_t
/*id*/
,
RtpExt
/*data*/
>
RtpExt
::
getExtValue
(
const
RtpHeader
*
header
,
const
RtcMedia
&
media
)
{
map
<
uint8_t
,
RtpExt
>
ret
;
assert
(
header
);
auto
ext_size
=
header
->
getExtSize
();
if
(
!
ext_size
)
{
...
...
@@ -118,20 +118,20 @@ map<uint8_t/*id*/, string/*data*/> RtpExt::getExtValue(const RtpHeader *header)
auto
reserved
=
header
->
getExtReserved
();
auto
ptr
=
const_cast
<
RtpHeader
*>
(
header
)
->
getExtData
();
auto
end
=
ptr
+
ext_size
;
RtpExtType
type
;
if
(
reserved
==
kOneByteHeader
)
{
while
(
ptr
<
end
)
{
RtpExtOneByte
*
ext
=
reinterpret_cast
<
RtpExtOneByte
*>
(
ptr
);
if
(
ext
->
getId
()
==
0
)
{
if
(
ext
->
getId
()
==
(
uint8_t
)
RtpExtType
::
padding
)
{
//padding,忽略
++
ptr
;
continue
;
}
//15类型的rtp ext为保留
CHECK
(
ext
->
getId
()
!=
15
);
CHECK
(
ext
->
getId
()
<
(
uint8_t
)
RtpExtType
::
reserved
);
CHECK
(
reinterpret_cast
<
uint8_t
*>
(
ext
)
+
RtpExtOneByte
::
kMinSize
<=
end
);
CHECK
(
ext
->
getData
()
+
ext
->
getSize
()
<=
end
);
ret
.
emplace
(
ext
->
getId
(),
string
(
reinterpret_cast
<
char
*>
(
ext
->
getData
()),
ext
->
getSize
()));
ret
.
emplace
(
ext
->
getId
(),
RtpExt
(
type
,
reinterpret_cast
<
char
*>
(
ext
->
getData
()),
ext
->
getSize
()));
ptr
+=
RtpExtOneByte
::
kMinSize
+
ext
->
getSize
();
}
return
ret
;
...
...
@@ -140,14 +140,16 @@ map<uint8_t/*id*/, string/*data*/> RtpExt::getExtValue(const RtpHeader *header)
if
((
reserved
&
0xFFF0
)
>>
4
==
kTwoByteHeader
)
{
while
(
ptr
<
end
)
{
RtpExtTwoByte
*
ext
=
reinterpret_cast
<
RtpExtTwoByte
*>
(
ptr
);
if
(
ext
->
getId
()
==
0
)
{
if
(
ext
->
getId
()
==
(
uint8_t
)
RtpExtType
::
padding
)
{
//padding,忽略
++
ptr
;
continue
;
}
//15类型的rtp ext为保留
CHECK
(
ext
->
getId
()
<
(
uint8_t
)
RtpExtType
::
reserved
);
CHECK
(
reinterpret_cast
<
uint8_t
*>
(
ext
)
+
RtpExtTwoByte
::
kMinSize
<=
end
);
CHECK
(
ext
->
getData
()
+
ext
->
getSize
()
<=
end
);
ret
.
emplace
(
ext
->
getId
(),
string
(
reinterpret_cast
<
char
*>
(
ext
->
getData
()),
ext
->
getSize
()));
ret
.
emplace
(
ext
->
getId
(),
RtpExt
(
type
,
reinterpret_cast
<
char
*>
(
ext
->
getData
()),
ext
->
getSize
()));
ptr
+=
RtpExtTwoByte
::
kMinSize
+
ext
->
getSize
();
}
return
ret
;
...
...
@@ -155,3 +157,43 @@ map<uint8_t/*id*/, string/*data*/> RtpExt::getExtValue(const RtpHeader *header)
return
ret
;
}
#define RTP_EXT_MAP(XX) \
XX(RtpExtType::ssrc_audio_level, "urn:ietf:params:rtp-hdrext:ssrc-audio-level") \
XX(RtpExtType::abs_send_time, "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time") \
XX(RtpExtType::transport_cc, "http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01") \
XX(RtpExtType::sdes_mid, "urn:ietf:params:rtp-hdrext:sdes:mid") \
XX(RtpExtType::sdes_rtp_stream_id, "urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id") \
XX(RtpExtType::sdes_repaired_rtp_stream_id, "urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id") \
XX(RtpExtType::video_timing, "http://www.webrtc.org/experiments/rtp-hdrext/video-timing") \
XX(RtpExtType::color_space, "http://www.webrtc.org/experiments/rtp-hdrext/color-space") \
XX(RtpExtType::video_content_type, "http://www.webrtc.org/experiments/rtp-hdrext/video-content-type") \
XX(RtpExtType::playout_delay, "http://www.webrtc.org/experiments/rtp-hdrext/playout-delay") \
XX(RtpExtType::video_orientation, "urn:3gpp:video-orientation") \
XX(RtpExtType::toffset, "urn:ietf:params:rtp-hdrext:toffset")
#define XX(type, url) {type , url},
static
unordered_map
<
RtpExtType
/*id*/
,
string
/*ext*/
>
s_type_to_url
=
{
RTP_EXT_MAP
(
XX
)};
#undef XX
#define XX(type, url) {url, type},
static
unordered_map
<
string
/*ext*/
,
RtpExtType
/*id*/
>
s_url_to_type
=
{
RTP_EXT_MAP
(
XX
)};
#undef XX
RtpExtType
RtpExt
::
getRtpExtType
(
const
string
&
url
)
{
auto
it
=
s_url_to_type
.
find
(
url
);
if
(
it
==
s_url_to_type
.
end
())
{
throw
std
::
invalid_argument
(
string
(
"未识别的rtp ext url类型:"
)
+
url
);
}
return
it
->
second
;
}
const
string
&
RtpExt
::
getRtpExtUrl
(
RtpExtType
type
)
{
auto
it
=
s_type_to_url
.
find
(
type
);
if
(
it
==
s_type_to_url
.
end
())
{
throw
std
::
invalid_argument
(
string
(
"未识别的rtp ext类型:"
)
+
to_string
((
int
)
type
));
}
return
it
->
second
;
}
webrtc/RtpExt.h
查看文件 @
2e8a7be5
...
...
@@ -20,9 +20,37 @@
using
namespace
std
;
using
namespace
mediakit
;
class
RtpExt
{
enum
class
RtpExtType
:
uint8_t
{
padding
=
0
,
ssrc_audio_level
=
1
,
abs_send_time
=
2
,
transport_cc
=
3
,
sdes_mid
=
4
,
sdes_rtp_stream_id
=
5
,
sdes_repaired_rtp_stream_id
=
6
,
video_timing
=
7
,
color_space
=
8
,
video_content_type
=
11
,
playout_delay
=
12
,
video_orientation
=
13
,
toffset
=
14
,
reserved
=
15
,
};
class
RtcMedia
;
class
RtpExt
:
public
std
::
string
{
public
:
static
map
<
uint8_t
/*id*/
,
string
/*data*/
>
getExtValue
(
const
RtpHeader
*
header
);
~
RtpExt
()
=
default
;
static
map
<
uint8_t
/*id*/
,
RtpExt
/*data*/
>
getExtValue
(
const
RtpHeader
*
header
,
const
RtcMedia
&
media
);
static
RtpExtType
getRtpExtType
(
const
string
&
url
);
static
const
string
&
getRtpExtUrl
(
RtpExtType
type
);
private
:
RtpExt
(
RtpExtType
type
,
const
char
*
str
,
size_t
size
)
:
std
::
string
(
str
,
size
),
_type
(
type
)
{}
private
:
RtpExtType
_type
;
};
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论