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
18459db8
Commit
18459db8
authored
4 years ago
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
支持ehome推流:#514
parent
38a00264
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
47 行增加
和
12 行删除
+47
-12
src/Rtp/RtpSplitter.cpp
+40
-7
src/Rtp/RtpSplitter.h
+7
-5
没有找到文件。
src/Rtp/RtpSplitter.cpp
查看文件 @
18459db8
...
...
@@ -9,18 +9,57 @@
*/
#if defined(ENABLE_RTPPROXY)
#include <netinet/in.h>
#include <string.h>
#include "RtpSplitter.h"
namespace
mediakit
{
RtpSplitter
::
RtpSplitter
()
{}
static
const
char
kEHOME_MAGIC
[]
=
"
\x01\x00\x01\x00
"
;
static
const
int
kEHOME_OFFSET
=
256
;
RtpSplitter
::
RtpSplitter
()
{}
RtpSplitter
::~
RtpSplitter
()
{}
int64_t
RtpSplitter
::
onRecvHeader
(
const
char
*
data
,
uint64_t
len
){
//忽略偏移量
data
+=
_offset
;
len
-=
_offset
;
if
(
_offset
==
kEHOME_OFFSET
+
4
&&
len
>
12
&&
data
[
12
]
==
'\r'
)
{
//这是ehome,移除第12个字节
memmove
((
char
*
)
data
+
1
,
data
,
12
);
data
+=
1
;
len
-=
1
;
}
onRtpPacket
(
data
,
len
);
return
0
;
}
static
bool
isEhome
(
const
char
*
data
,
int
len
){
if
(
len
<
4
)
{
return
false
;
}
return
memcmp
(
data
,
kEHOME_MAGIC
,
sizeof
(
kEHOME_MAGIC
)
-
1
)
==
0
;
}
const
char
*
RtpSplitter
::
onSearchPacketTail
(
const
char
*
data
,
int
len
)
{
if
(
len
<
4
)
{
//数据不够
return
nullptr
;
}
if
(
isEhome
(
data
,
len
))
{
//是ehome协议
if
(
len
<
kEHOME_OFFSET
+
4
)
{
//数据不够
return
nullptr
;
}
//忽略ehome私有头后是rtsp样式的rtp,多4个字节,
_offset
=
kEHOME_OFFSET
+
4
;
//忽略ehome私有头
return
onSearchPacketTail_l
(
data
+
kEHOME_OFFSET
+
2
,
len
-
kEHOME_OFFSET
-
2
);
}
if
(
data
[
0
]
==
'$'
)
{
//可能是4个字节的rtp头
_offset
=
4
;
...
...
@@ -42,10 +81,5 @@ const char *RtpSplitter::onSearchPacketTail_l(const char *data, int len) {
return
data
+
2
+
length
;
}
int64_t
RtpSplitter
::
onRecvHeader
(
const
char
*
data
,
uint64_t
len
)
{
onRtpPacket
(
data
+
_offset
,
len
-
_offset
);
return
0
;
}
}
//namespace mediakit
#endif//defined(ENABLE_RTPPROXY)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/Rtp/RtpSplitter.h
查看文件 @
18459db8
...
...
@@ -19,18 +19,20 @@ namespace mediakit{
class
RtpSplitter
:
public
HttpRequestSplitter
{
public
:
RtpSplitter
();
virtual
~
RtpSplitter
()
;
~
RtpSplitter
()
override
;
protected
:
/**
* 收到rtp包回调
* @param data RTP包数据指针
* @param len RTP包数据长度
*/
virtual
void
onRtpPacket
(
const
char
*
data
,
uint64_t
len
)
=
0
;
virtual
void
onRtpPacket
(
const
char
*
data
,
uint64_t
len
)
=
0
;
protected
:
const
char
*
onSearchPacketTail
(
const
char
*
data
,
int
len
)
override
;
const
char
*
onSearchPacketTail
_l
(
const
char
*
data
,
int
len
)
;
int64_t
onRecvHeader
(
const
char
*
data
,
uint64_t
len
)
override
;
int64_t
onRecvHeader
(
const
char
*
data
,
uint64_t
len
)
override
;
const
char
*
onSearchPacketTail
(
const
char
*
data
,
int
len
)
override
;
const
char
*
onSearchPacketTail_l
(
const
char
*
data
,
int
len
)
;
private
:
int
_offset
=
0
;
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论