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
d337b8d8
Commit
d337b8d8
authored
May 06, 2021
by
xia-chu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加rtp ext解析相关代码
parent
842257ed
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
186 行增加
和
0 行删除
+186
-0
webrtc/RtpExt.cpp
+157
-0
webrtc/RtpExt.h
+29
-0
没有找到文件。
webrtc/RtpExt.cpp
0 → 100644
查看文件 @
d337b8d8
/*
* 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 "RtpExt.h"
#if defined(_WIN32)
#pragma pack(push, 1)
#endif // defined(_WIN32)
//https://tools.ietf.org/html/draft-holmer-rmcat-transport-wide-cc-extensions-01
//https://tools.ietf.org/html/rfc5285
// 0 1 2 3
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | 0xBE | 0xDE | length=3 |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | ID | L=0 | data | ID | L=1 | data...
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// ...data | 0 (pad) | 0 (pad) | ID | L=3 |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | data |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
class
RtpExtOneByte
{
public
:
static
constexpr
uint16_t
kMinSize
=
1
;
size_t
getSize
()
const
;
uint8_t
getId
()
const
;
uint8_t
*
getData
();
private
:
#if __BYTE_ORDER == __BIG_ENDIAN
uint8_t
id
:
4
;
uint8_t
len
:
4
;
#else
uint8_t
len
:
4
;
uint8_t
id
:
4
;
#endif
uint8_t
data
[
1
];
}
PACKED
;
//0 1 2 3
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | 0x100 |appbits| length=3 |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | ID | L=0 | ID | L=1 |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | data | 0 (pad) | ID | L=4 |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | data |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
class
RtpExtTwoByte
{
public
:
static
constexpr
uint16_t
kMinSize
=
2
;
size_t
getSize
()
const
;
uint8_t
getId
()
const
;
uint8_t
*
getData
();
private
:
uint8_t
id
;
uint8_t
len
;
uint8_t
data
[
1
];
}
PACKED
;
#if defined(_WIN32)
#pragma pack(pop)
#endif // defined(_WIN32)
//////////////////////////////////////////////////////////////////
size_t
RtpExtOneByte
::
getSize
()
const
{
return
len
+
1
;
}
uint8_t
RtpExtOneByte
::
getId
()
const
{
return
id
;
}
uint8_t
*
RtpExtOneByte
::
getData
()
{
return
data
;
}
//////////////////////////////////////////////////////////////////
size_t
RtpExtTwoByte
::
getSize
()
const
{
return
len
;
}
uint8_t
RtpExtTwoByte
::
getId
()
const
{
return
id
;
}
uint8_t
*
RtpExtTwoByte
::
getData
()
{
return
data
;
}
//////////////////////////////////////////////////////////////////
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
;
assert
(
header
);
auto
ext_size
=
header
->
getExtSize
();
if
(
!
ext_size
)
{
return
ret
;
}
auto
reserved
=
header
->
getExtReserved
();
auto
ptr
=
const_cast
<
RtpHeader
*>
(
header
)
->
getExtData
();
auto
end
=
ptr
+
ext_size
;
if
(
reserved
==
kOneByteHeader
)
{
while
(
ptr
<
end
)
{
RtpExtOneByte
*
ext
=
reinterpret_cast
<
RtpExtOneByte
*>
(
ptr
);
if
(
ext
->
getId
()
==
0
)
{
//padding,忽略
++
ptr
;
continue
;
}
//15类型的rtp ext为保留
CHECK
(
ext
->
getId
()
!=
15
);
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
()));
ptr
+=
RtpExtOneByte
::
kMinSize
+
ext
->
getSize
();
}
return
ret
;
}
if
((
reserved
&
0xFFF0
)
>>
4
==
kTwoByteHeader
)
{
while
(
ptr
<
end
)
{
RtpExtTwoByte
*
ext
=
reinterpret_cast
<
RtpExtTwoByte
*>
(
ptr
);
if
(
ext
->
getId
()
==
0
)
{
//padding,忽略
++
ptr
;
continue
;
}
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
()));
ptr
+=
RtpExtTwoByte
::
kMinSize
+
ext
->
getSize
();
}
return
ret
;
}
return
ret
;
}
webrtc/RtpExt.h
0 → 100644
查看文件 @
d337b8d8
/*
* 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.
*/
#ifndef ZLMEDIAKIT_RTPEXT_H
#define ZLMEDIAKIT_RTPEXT_H
#include <stdint.h>
#include <map>
#include <string>
#include "Common/macros.h"
#include "Rtsp/Rtsp.h"
using
namespace
std
;
using
namespace
mediakit
;
class
RtpExt
{
public
:
static
map
<
uint8_t
/*id*/
,
string
/*data*/
>
getExtValue
(
const
RtpHeader
*
header
);
};
#endif //ZLMEDIAKIT_RTPEXT_H
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论