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
77e46353
Commit
77e46353
authored
Dec 30, 2022
by
ziyue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增支持mjpeg es rtp流
mpegts/g711 payload改成固定模式
parent
ae950606
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
57 行增加
和
69 行删除
+57
-69
conf/config.ini
+0
-7
src/Common/config.cpp
+0
-6
src/Common/config.h
+0
-6
src/Rtp/GB28181Process.cpp
+57
-50
没有找到文件。
conf/config.ini
查看文件 @
77e46353
...
...
@@ -293,15 +293,8 @@ h264_pt=98
h265_pt
=
99
#rtp ps 负载的pt
ps_pt
=
96
#rtp ts 负载的pt
ts_pt
=
33
#rtp opus 负载的pt
opus_pt
=
100
#rtp g711u 负载的pt
g711u_pt
=
0
#rtp g711a 负载的pt
g711a_pt
=
8
[rtc]
#rtc播放推流、播放超时时间
...
...
src/Common/config.cpp
查看文件 @
77e46353
...
...
@@ -317,10 +317,7 @@ const string kPortRange = RTP_PROXY_FIELD "port_range";
const
string
kH264PT
=
RTP_PROXY_FIELD
"h264_pt"
;
const
string
kH265PT
=
RTP_PROXY_FIELD
"h265_pt"
;
const
string
kPSPT
=
RTP_PROXY_FIELD
"ps_pt"
;
const
string
kTSPT
=
RTP_PROXY_FIELD
"ts_pt"
;
const
string
kOpusPT
=
RTP_PROXY_FIELD
"opus_pt"
;
const
string
kG711UPT
=
RTP_PROXY_FIELD
"g711u_pt"
;
const
string
kG711APT
=
RTP_PROXY_FIELD
"g711a_pt"
;
static
onceToken
token
([]()
{
mINI
::
Instance
()[
kDumpDir
]
=
""
;
...
...
@@ -329,10 +326,7 @@ static onceToken token([]() {
mINI
::
Instance
()[
kH264PT
]
=
98
;
mINI
::
Instance
()[
kH265PT
]
=
99
;
mINI
::
Instance
()[
kPSPT
]
=
96
;
mINI
::
Instance
()[
kTSPT
]
=
33
;
mINI
::
Instance
()[
kOpusPT
]
=
100
;
mINI
::
Instance
()[
kG711UPT
]
=
0
;
mINI
::
Instance
()[
kG711APT
]
=
8
;
});
}
// namespace RtpProxy
...
...
src/Common/config.h
查看文件 @
77e46353
...
...
@@ -350,14 +350,8 @@ extern const std::string kH264PT;
extern
const
std
::
string
kH265PT
;
// rtp server ps 的pt
extern
const
std
::
string
kPSPT
;
// rtp server ts 的pt
extern
const
std
::
string
kTSPT
;
// rtp server opus 的pt
extern
const
std
::
string
kOpusPT
;
// rtp server g711u 的pt
extern
const
std
::
string
kG711UPT
;
// rtp server g711a 的pt
extern
const
std
::
string
kG711APT
;
}
// namespace RtpProxy
/**
...
...
src/Rtp/GB28181Process.cpp
查看文件 @
77e46353
...
...
@@ -13,14 +13,15 @@
#include "Extension/CommonRtp.h"
#include "Extension/Factory.h"
#include "Extension/G711.h"
#include "Extension/H264
Rtp
.h"
#include "Extension/H264.h"
#include "Extension/H265.h"
#include "Extension/Opus.h"
#include "Extension/JPEG.h"
#include "Http/HttpTSPlayer.h"
#include "Util/File.h"
#include "Common/config.h"
#include "Rtsp/RtpCodec.h"
#include "Rtsp/RtpReceiver.h"
#include "Rtsp/Rtsp.h"
using
namespace
std
;
using
namespace
toolkit
;
...
...
@@ -76,10 +77,7 @@ bool GB28181Process::inputRtp(bool, const char *data, size_t data_len) {
GET_CONFIG
(
uint32_t
,
h264_pt
,
RtpProxy
::
kH264PT
);
GET_CONFIG
(
uint32_t
,
h265_pt
,
RtpProxy
::
kH265PT
);
GET_CONFIG
(
uint32_t
,
ps_pt
,
RtpProxy
::
kPSPT
);
GET_CONFIG
(
uint32_t
,
ts_pt
,
RtpProxy
::
kTSPT
);
GET_CONFIG
(
uint32_t
,
opus_pt
,
RtpProxy
::
kOpusPT
);
GET_CONFIG
(
uint32_t
,
g711u_pt
,
RtpProxy
::
kG711UPT
);
GET_CONFIG
(
uint32_t
,
g711a_pt
,
RtpProxy
::
kG711APT
);
RtpHeader
*
header
=
(
RtpHeader
*
)
data
;
auto
pt
=
header
->
pt
;
...
...
@@ -89,53 +87,62 @@ bool GB28181Process::inputRtp(bool, const char *data, size_t data_len) {
// 防止pt类型太多导致内存溢出
throw
std
::
invalid_argument
(
"rtp pt类型不得超过2种!"
);
}
if
(
pt
==
opus_pt
)
{
// opus负载
ref
=
std
::
make_shared
<
RtpReceiverImp
>
(
48000
,
[
this
](
RtpPacket
::
Ptr
rtp
)
{
onRtpSorted
(
std
::
move
(
rtp
));
});
auto
track
=
std
::
make_shared
<
OpusTrack
>
();
_interface
->
addTrack
(
track
);
_rtp_decoder
[
pt
]
=
Factory
::
getRtpDecoderByTrack
(
track
);
}
else
if
(
pt
==
h265_pt
)
{
// H265负载
ref
=
std
::
make_shared
<
RtpReceiverImp
>
(
90000
,
[
this
](
RtpPacket
::
Ptr
rtp
)
{
onRtpSorted
(
std
::
move
(
rtp
));
});
auto
track
=
std
::
make_shared
<
H265Track
>
();
_interface
->
addTrack
(
track
);
_rtp_decoder
[
pt
]
=
Factory
::
getRtpDecoderByTrack
(
track
);
}
else
if
(
pt
==
h264_pt
)
{
// H264负载
ref
=
std
::
make_shared
<
RtpReceiverImp
>
(
90000
,
[
this
](
RtpPacket
::
Ptr
rtp
)
{
onRtpSorted
(
std
::
move
(
rtp
));
});
auto
track
=
std
::
make_shared
<
H264Track
>
();
_interface
->
addTrack
(
track
);
_rtp_decoder
[
pt
]
=
Factory
::
getRtpDecoderByTrack
(
track
);
}
else
if
(
pt
==
g711u_pt
||
pt
==
g711a_pt
)
{
// CodecG711U
// CodecG711A
ref
=
std
::
make_shared
<
RtpReceiverImp
>
(
8000
,
[
this
](
RtpPacket
::
Ptr
rtp
)
{
onRtpSorted
(
std
::
move
(
rtp
));
});
auto
track
=
std
::
make_shared
<
G711Track
>
(
pt
==
g711u_pt
?
CodecG711U
:
CodecG711A
,
8000
,
1
,
16
);
_interface
->
addTrack
(
track
);
_rtp_decoder
[
pt
]
=
Factory
::
getRtpDecoderByTrack
(
track
);
}
else
{
if
(
pt
!=
ts_pt
&&
pt
!=
ps_pt
)
{
WarnL
<<
"rtp payload type未识别("
<<
(
int
)
pt
<<
"),已按ts或ps负载处理"
;
switch
(
pt
)
{
case
Rtsp
:
:
PT_PCMA
:
case
Rtsp
:
:
PT_PCMU
:
{
// CodecG711U or CodecG711A
ref
=
std
::
make_shared
<
RtpReceiverImp
>
(
8000
,
[
this
](
RtpPacket
::
Ptr
rtp
)
{
onRtpSorted
(
std
::
move
(
rtp
));
});
auto
track
=
std
::
make_shared
<
G711Track
>
(
pt
==
Rtsp
::
PT_PCMU
?
CodecG711U
:
CodecG711A
,
8000
,
1
,
16
);
_interface
->
addTrack
(
track
);
_rtp_decoder
[
pt
]
=
Factory
::
getRtpDecoderByTrack
(
track
);
break
;
}
ref
=
std
::
make_shared
<
RtpReceiverImp
>
(
90000
,
[
this
](
RtpPacket
::
Ptr
rtp
)
{
onRtpSorted
(
std
::
move
(
rtp
));
});
// ts或ps负载
_rtp_decoder
[
pt
]
=
std
::
make_shared
<
CommonRtpDecoder
>
(
CodecInvalid
,
32
*
1024
);
// 设置dump目录
GET_CONFIG
(
string
,
dump_dir
,
RtpProxy
::
kDumpDir
);
if
(
!
dump_dir
.
empty
())
{
auto
save_path
=
File
::
absolutePath
(
_media_info
.
_streamid
+
".mp2"
,
dump_dir
);
_save_file_ps
.
reset
(
File
::
create_file
(
save_path
.
data
(),
"wb"
),
[](
FILE
*
fp
)
{
if
(
fp
)
{
fclose
(
fp
);
case
Rtsp
:
:
PT_JPEG
:
{
// mjpeg
ref
=
std
::
make_shared
<
RtpReceiverImp
>
(
90000
,
[
this
](
RtpPacket
::
Ptr
rtp
)
{
onRtpSorted
(
std
::
move
(
rtp
));
});
auto
track
=
std
::
make_shared
<
JPEGTrack
>
();
_interface
->
addTrack
(
track
);
_rtp_decoder
[
pt
]
=
Factory
::
getRtpDecoderByTrack
(
track
);
break
;
}
default
:
{
if
(
pt
==
opus_pt
)
{
// opus负载
ref
=
std
::
make_shared
<
RtpReceiverImp
>
(
48000
,
[
this
](
RtpPacket
::
Ptr
rtp
)
{
onRtpSorted
(
std
::
move
(
rtp
));
});
auto
track
=
std
::
make_shared
<
OpusTrack
>
();
_interface
->
addTrack
(
track
);
_rtp_decoder
[
pt
]
=
Factory
::
getRtpDecoderByTrack
(
track
);
}
else
if
(
pt
==
h265_pt
)
{
// H265负载
ref
=
std
::
make_shared
<
RtpReceiverImp
>
(
90000
,
[
this
](
RtpPacket
::
Ptr
rtp
)
{
onRtpSorted
(
std
::
move
(
rtp
));
});
auto
track
=
std
::
make_shared
<
H265Track
>
();
_interface
->
addTrack
(
track
);
_rtp_decoder
[
pt
]
=
Factory
::
getRtpDecoderByTrack
(
track
);
}
else
if
(
pt
==
h264_pt
)
{
// H264负载
ref
=
std
::
make_shared
<
RtpReceiverImp
>
(
90000
,
[
this
](
RtpPacket
::
Ptr
rtp
)
{
onRtpSorted
(
std
::
move
(
rtp
));
});
auto
track
=
std
::
make_shared
<
H264Track
>
();
_interface
->
addTrack
(
track
);
_rtp_decoder
[
pt
]
=
Factory
::
getRtpDecoderByTrack
(
track
);
}
else
{
if
(
pt
!=
Rtsp
::
PT_MP2T
&&
pt
!=
ps_pt
)
{
WarnL
<<
"rtp payload type未识别("
<<
(
int
)
pt
<<
"),已按ts或ps负载处理"
;
}
ref
=
std
::
make_shared
<
RtpReceiverImp
>
(
90000
,
[
this
](
RtpPacket
::
Ptr
rtp
)
{
onRtpSorted
(
std
::
move
(
rtp
));
});
// ts或ps负载
_rtp_decoder
[
pt
]
=
std
::
make_shared
<
CommonRtpDecoder
>
(
CodecInvalid
,
32
*
1024
);
// 设置dump目录
GET_CONFIG
(
string
,
dump_dir
,
RtpProxy
::
kDumpDir
);
if
(
!
dump_dir
.
empty
())
{
auto
save_path
=
File
::
absolutePath
(
_media_info
.
_streamid
+
".mpeg"
,
dump_dir
);
_save_file_ps
.
reset
(
File
::
create_file
(
save_path
.
data
(),
"wb"
),
[](
FILE
*
fp
)
{
if
(
fp
)
{
fclose
(
fp
);
}
});
}
});
}
break
;
}
}
// 设置frame回调
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论