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
74d6689a
Commit
74d6689a
authored
Sep 06, 2020
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rtp解包采用自有代码
parent
9fa2221a
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
10 行增加
和
111 行删除
+10
-111
CMakeLists.txt
+0
-8
src/Rtp/RtpDecoder.cpp
+0
-63
src/Rtp/RtpDecoder.h
+0
-35
src/Rtp/RtpProcess.cpp
+6
-2
src/Rtp/RtpProcess.h
+4
-3
没有找到文件。
CMakeLists.txt
查看文件 @
74d6689a
...
...
@@ -151,15 +151,7 @@ endif()
#添加rtp库用于rtp转ps/ts
if
(
ENABLE_RTPPROXY AND ENABLE_HLS
)
message
(
STATUS
"ENABLE_RTPPROXY defined"
)
include_directories
(
${
MediaServer_Root
}
/librtp/include
)
aux_source_directory
(
${
MediaServer_Root
}
/librtp/include src_rtp
)
aux_source_directory
(
${
MediaServer_Root
}
/librtp/source src_rtp
)
aux_source_directory
(
${
MediaServer_Root
}
/librtp/payload src_rtp
)
add_library
(
rtp STATIC
${
src_rtp
}
)
add_definitions
(
-DENABLE_RTPPROXY
)
list
(
APPEND LINK_LIB_LIST rtp
)
list
(
APPEND CXX_API_TARGETS rtp
)
endif
()
#收集源代码
...
...
src/Rtp/RtpDecoder.cpp
deleted
100644 → 0
查看文件 @
9fa2221a
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/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.
*/
#if defined(ENABLE_RTPPROXY)
#include "Util/logger.h"
#include "RtpDecoder.h"
#include "rtp-payload.h"
using
namespace
toolkit
;
namespace
mediakit
{
RtpDecoder
::
RtpDecoder
(
const
char
*
codec
)
{
_buffer
=
std
::
make_shared
<
BufferRaw
>
();
_codec
=
codec
;
}
RtpDecoder
::~
RtpDecoder
()
{
if
(
_rtp_decoder
){
rtp_payload_decode_destroy
(
_rtp_decoder
);
_rtp_decoder
=
nullptr
;
}
}
void
RtpDecoder
::
decodeRtp
(
const
void
*
data
,
int
bytes
)
{
if
(
!
_rtp_decoder
){
static
rtp_payload_t
s_func
=
{
[](
void
*
param
,
int
bytes
){
RtpDecoder
*
obj
=
(
RtpDecoder
*
)
param
;
obj
->
_buffer
->
setCapacity
(
bytes
);
return
(
void
*
)
obj
->
_buffer
->
data
();
},
[](
void
*
param
,
void
*
packet
){
//do nothing
},
[](
void
*
param
,
const
void
*
packet
,
int
bytes
,
uint32_t
timestamp
,
int
flags
){
RtpDecoder
*
obj
=
(
RtpDecoder
*
)
param
;
obj
->
onRtpDecode
((
uint8_t
*
)
packet
,
bytes
,
timestamp
,
flags
);
}
};
uint8_t
rtp_type
=
0x7F
&
((
uint8_t
*
)
data
)[
1
];
InfoL
<<
"rtp type:"
<<
(
int
)
rtp_type
;
_rtp_decoder
=
rtp_payload_decode_create
(
rtp_type
,
_codec
.
data
(),
&
s_func
,
this
);
if
(
!
_rtp_decoder
)
{
WarnL
<<
"unsupported rtp type:"
<<
(
int
)
rtp_type
<<
",size:"
<<
bytes
<<
",hexdump"
<<
hexdump
(
data
,
bytes
>
16
?
16
:
bytes
);
}
}
if
(
_rtp_decoder
){
rtp_payload_decode_input
(
_rtp_decoder
,
data
,
bytes
);
}
}
}
//namespace mediakit
#endif//defined(ENABLE_RTPPROXY)
\ No newline at end of file
src/Rtp/RtpDecoder.h
deleted
100644 → 0
查看文件 @
9fa2221a
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/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_RTPDECODER_H
#define ZLMEDIAKIT_RTPDECODER_H
#if defined(ENABLE_RTPPROXY)
#include "Network/Buffer.h"
using
namespace
toolkit
;
namespace
mediakit
{
class
RtpDecoder
{
public
:
RtpDecoder
(
const
char
*
codec
=
"MP2P"
);
virtual
~
RtpDecoder
();
void
decodeRtp
(
const
void
*
data
,
int
bytes
);
protected
:
virtual
void
onRtpDecode
(
const
uint8_t
*
packet
,
int
bytes
,
uint32_t
timestamp
,
int
flags
)
=
0
;
private
:
void
*
_rtp_decoder
=
nullptr
;
BufferRaw
::
Ptr
_buffer
;
string
_codec
;
};
}
//namespace mediakit
#endif//defined(ENABLE_RTPPROXY)
#endif //ZLMEDIAKIT_RTPDECODER_H
src/Rtp/RtpProcess.cpp
查看文件 @
74d6689a
...
...
@@ -53,6 +53,10 @@ RtpProcess::RtpProcess(const string &stream_id) {
});
}
}
_rtp_decoder
=
std
::
make_shared
<
CommonRtpDecoder
>
(
CodecInvalid
,
256
*
1024
);
_rtp_decoder
->
addDelegate
(
std
::
make_shared
<
FrameWriterInterfaceHelper
>
([
this
](
const
Frame
::
Ptr
&
frame
){
onRtpDecode
((
uint8_t
*
)
frame
->
data
(),
frame
->
size
(),
frame
->
dts
());
}));
}
RtpProcess
::~
RtpProcess
()
{
...
...
@@ -121,7 +125,7 @@ void RtpProcess::onRtpSorted(const RtpPacket::Ptr &rtp, int) {
fwrite
((
uint8_t
*
)
&
size
,
2
,
1
,
_save_file_rtp
.
get
());
fwrite
((
uint8_t
*
)
rtp
->
data
()
+
4
,
rtp
->
size
()
-
4
,
1
,
_save_file_rtp
.
get
());
}
decodeRtp
(
rtp
->
data
()
+
4
,
rtp
->
size
()
-
4
);
_rtp_decoder
->
inputRtp
(
rtp
);
}
const
char
*
RtpProcess
::
onSearchPacketTail
(
const
char
*
packet
,
int
bytes
){
...
...
@@ -139,7 +143,7 @@ const char *RtpProcess::onSearchPacketTail(const char *packet,int bytes){
}
}
void
RtpProcess
::
onRtpDecode
(
const
uint8_t
*
packet
,
int
bytes
,
uint32_t
timestamp
,
int
flags
)
{
void
RtpProcess
::
onRtpDecode
(
const
uint8_t
*
packet
,
int
bytes
,
uint32_t
timestamp
)
{
if
(
_save_file_ps
){
fwrite
((
uint8_t
*
)
packet
,
bytes
,
1
,
_save_file_ps
.
get
());
}
...
...
src/Rtp/RtpProcess.h
查看文件 @
74d6689a
...
...
@@ -14,16 +14,16 @@
#if defined(ENABLE_RTPPROXY)
#include "Rtsp/RtpReceiver.h"
#include "RtpDecoder.h"
#include "Decoder.h"
#include "Common/Device.h"
#include "Common/Stamp.h"
#include "Http/HttpRequestSplitter.h"
#include "Extension/CommonRtp.h"
using
namespace
mediakit
;
namespace
mediakit
{
class
RtpProcess
:
public
HttpRequestSplitter
,
public
RtpReceiver
,
public
RtpDecoder
,
public
SockInfo
,
public
MediaSinkInterface
,
public
std
::
enable_shared_from_this
<
RtpProcess
>
{
class
RtpProcess
:
public
HttpRequestSplitter
,
public
RtpReceiver
,
public
SockInfo
,
public
MediaSinkInterface
,
public
std
::
enable_shared_from_this
<
RtpProcess
>
{
public
:
typedef
std
::
shared_ptr
<
RtpProcess
>
Ptr
;
RtpProcess
(
const
string
&
stream_id
);
...
...
@@ -67,7 +67,6 @@ public:
protected
:
void
onRtpSorted
(
const
RtpPacket
::
Ptr
&
rtp
,
int
track_index
)
override
;
void
onRtpDecode
(
const
uint8_t
*
packet
,
int
bytes
,
uint32_t
timestamp
,
int
flags
)
override
;
void
inputFrame
(
const
Frame
::
Ptr
&
frame
)
override
;
void
addTrack
(
const
Track
::
Ptr
&
track
)
override
;
void
resetTracks
()
override
{};
...
...
@@ -77,8 +76,10 @@ protected:
private
:
void
emitOnPublish
();
void
onRtpDecode
(
const
uint8_t
*
packet
,
int
bytes
,
uint32_t
timestamp
);
private
:
std
::
shared_ptr
<
CommonRtpDecoder
>
_rtp_decoder
;
std
::
shared_ptr
<
FILE
>
_save_file_rtp
;
std
::
shared_ptr
<
FILE
>
_save_file_ps
;
std
::
shared_ptr
<
FILE
>
_save_file_video
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论