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
49f59fb9
Commit
49f59fb9
authored
Jul 18, 2021
by
xiongziliang
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/ps-decoder-cache-buffer' of
https://github.com/xia-chu/ZLMediaKit
parents
6dbad3fb
9dd602c2
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
38 行增加
和
27 行删除
+38
-27
src/Rtp/GB28181Process.cpp
+1
-22
src/Rtp/GB28181Process.h
+1
-3
src/Rtp/PSDecoder.cpp
+26
-1
src/Rtp/PSDecoder.h
+10
-1
没有找到文件。
src/Rtp/GB28181Process.cpp
查看文件 @
49f59fb9
...
@@ -150,27 +150,6 @@ bool GB28181Process::inputRtp(bool, const char *data, size_t data_len) {
...
@@ -150,27 +150,6 @@ bool GB28181Process::inputRtp(bool, const char *data, size_t data_len) {
return
ref
->
inputRtp
(
TrackVideo
,
(
unsigned
char
*
)
data
,
data_len
);
return
ref
->
inputRtp
(
TrackVideo
,
(
unsigned
char
*
)
data
,
data_len
);
}
}
const
char
*
GB28181Process
::
onSearchPacketTail
(
const
char
*
packet
,
size_t
bytes
){
try
{
auto
ret
=
_decoder
->
input
((
uint8_t
*
)
packet
,
bytes
);
if
(
ret
>=
0
)
{
//解析成功全部或部分
return
packet
+
ret
;
}
//解析失败,丢弃所有数据
return
packet
+
bytes
;
}
catch
(
std
::
exception
&
ex
)
{
InfoL
<<
"解析ps或ts异常: bytes="
<<
bytes
<<
" ,exception="
<<
ex
.
what
()
<<
" ,hex="
<<
hexdump
((
uint8_t
*
)
packet
,
MIN
(
bytes
,
32
));
if
(
remainDataSize
()
>
256
*
1024
)
{
//缓存太多数据无法处理则上抛异常
throw
;
}
return
nullptr
;
}
}
void
GB28181Process
::
onRtpDecode
(
const
Frame
::
Ptr
&
frame
)
{
void
GB28181Process
::
onRtpDecode
(
const
Frame
::
Ptr
&
frame
)
{
if
(
frame
->
getCodecId
()
!=
CodecInvalid
)
{
if
(
frame
->
getCodecId
()
!=
CodecInvalid
)
{
//这里不是ps或ts
//这里不是ps或ts
...
@@ -197,7 +176,7 @@ void GB28181Process::onRtpDecode(const Frame::Ptr &frame) {
...
@@ -197,7 +176,7 @@ void GB28181Process::onRtpDecode(const Frame::Ptr &frame) {
}
}
if
(
_decoder
)
{
if
(
_decoder
)
{
HttpRequestSplitter
::
input
(
frame
->
data
(
),
frame
->
size
());
_decoder
->
input
(
reinterpret_cast
<
const
uint8_t
*>
(
frame
->
data
()
),
frame
->
size
());
}
}
}
}
...
...
src/Rtp/GB28181Process.h
查看文件 @
49f59fb9
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
namespace
mediakit
{
namespace
mediakit
{
class
RtpReceiverImp
;
class
RtpReceiverImp
;
class
GB28181Process
:
public
HttpRequestSplitter
,
public
ProcessInterface
{
class
GB28181Process
:
public
ProcessInterface
{
public
:
public
:
typedef
std
::
shared_ptr
<
GB28181Process
>
Ptr
;
typedef
std
::
shared_ptr
<
GB28181Process
>
Ptr
;
GB28181Process
(
const
MediaInfo
&
media_info
,
MediaSinkInterface
*
interface
);
GB28181Process
(
const
MediaInfo
&
media_info
,
MediaSinkInterface
*
interface
);
...
@@ -38,8 +38,6 @@ public:
...
@@ -38,8 +38,6 @@ public:
protected
:
protected
:
void
onRtpSorted
(
RtpPacket
::
Ptr
rtp
);
void
onRtpSorted
(
RtpPacket
::
Ptr
rtp
);
const
char
*
onSearchPacketTail
(
const
char
*
data
,
size_t
len
)
override
;
ssize_t
onRecvHeader
(
const
char
*
data
,
size_t
len
)
override
{
return
0
;
};
private
:
private
:
void
onRtpDecode
(
const
Frame
::
Ptr
&
frame
);
void
onRtpDecode
(
const
Frame
::
Ptr
&
frame
);
...
...
src/Rtp/PSDecoder.cpp
查看文件 @
49f59fb9
...
@@ -45,7 +45,8 @@ PSDecoder::~PSDecoder() {
...
@@ -45,7 +45,8 @@ PSDecoder::~PSDecoder() {
}
}
ssize_t
PSDecoder
::
input
(
const
uint8_t
*
data
,
size_t
bytes
)
{
ssize_t
PSDecoder
::
input
(
const
uint8_t
*
data
,
size_t
bytes
)
{
return
ps_demuxer_input
((
struct
ps_demuxer_t
*
)
_ps_demuxer
,
data
,
bytes
);
HttpRequestSplitter
::
input
(
reinterpret_cast
<
const
char
*>
(
data
),
bytes
);
return
bytes
;
}
}
void
PSDecoder
::
setOnDecode
(
Decoder
::
onDecode
cb
)
{
void
PSDecoder
::
setOnDecode
(
Decoder
::
onDecode
cb
)
{
...
@@ -56,5 +57,28 @@ void PSDecoder::setOnStream(Decoder::onStream cb) {
...
@@ -56,5 +57,28 @@ void PSDecoder::setOnStream(Decoder::onStream cb) {
_on_stream
=
std
::
move
(
cb
);
_on_stream
=
std
::
move
(
cb
);
}
}
const
char
*
PSDecoder
::
onSearchPacketTail
(
const
char
*
data
,
size_t
len
)
{
try
{
auto
ret
=
ps_demuxer_input
(
static_cast
<
struct
ps_demuxer_t
*>
(
_ps_demuxer
),
reinterpret_cast
<
const
uint8_t
*>
(
data
),
len
);
if
(
ret
>=
0
)
{
//解析成功全部或部分
return
data
+
ret
;
}
//解析失败,丢弃所有数据
return
data
+
len
;
}
catch
(
std
::
exception
&
ex
)
{
InfoL
<<
"解析 ps 异常: bytes="
<<
len
<<
", exception="
<<
ex
.
what
()
<<
", hex="
<<
hexdump
(
data
,
MIN
(
len
,
32
));
if
(
remainDataSize
()
>
256
*
1024
)
{
//缓存太多数据无法处理则上抛异常
throw
;
}
return
nullptr
;
}
}
}
//namespace mediakit
}
//namespace mediakit
#endif//#if defined(ENABLE_RTPPROXY)
#endif//#if defined(ENABLE_RTPPROXY)
\ No newline at end of file
src/Rtp/PSDecoder.h
查看文件 @
49f59fb9
...
@@ -14,17 +14,26 @@
...
@@ -14,17 +14,26 @@
#if defined(ENABLE_RTPPROXY)
#if defined(ENABLE_RTPPROXY)
#include <stdint.h>
#include <stdint.h>
#include "Decoder.h"
#include "Decoder.h"
#include "Http/HttpRequestSplitter.h"
namespace
mediakit
{
namespace
mediakit
{
//ps解析器
//ps解析器
class
PSDecoder
:
public
Decoder
{
class
PSDecoder
:
public
Decoder
,
private
HttpRequestSplitter
{
public
:
public
:
PSDecoder
();
PSDecoder
();
~
PSDecoder
();
~
PSDecoder
();
ssize_t
input
(
const
uint8_t
*
data
,
size_t
bytes
)
override
;
ssize_t
input
(
const
uint8_t
*
data
,
size_t
bytes
)
override
;
void
setOnDecode
(
onDecode
cb
)
override
;
void
setOnDecode
(
onDecode
cb
)
override
;
void
setOnStream
(
onStream
cb
)
override
;
void
setOnStream
(
onStream
cb
)
override
;
// HttpRequestSplitter interface
private:
using
HttpRequestSplitter
::
input
;
const
char
*
onSearchPacketTail
(
const
char
*
data
,
size_t
len
)
override
;
ssize_t
onRecvHeader
(
const
char
*
,
size_t
)
override
{
return
0
;
};
private
:
private
:
void
*
_ps_demuxer
=
nullptr
;
void
*
_ps_demuxer
=
nullptr
;
onDecode
_on_decode
;
onDecode
_on_decode
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论