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
3ca69972
Commit
3ca69972
authored
Jul 22, 2019
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PlayerProxy、DevChannel、MultiMediaSourceMuxer类支持是否开启rtsp/rtmp功能
addStreamProxy增加enable_rtsp、enable_rtmp参数
parent
3c8f96f2
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
40 行增加
和
19 行删除
+40
-19
server/WebApi.cpp
+13
-7
src/Common/Device.cpp
+3
-1
src/Common/Device.h
+2
-0
src/Common/MultiMediaSourceMuxer.h
+4
-3
src/MediaFile/MediaReader.cpp
+1
-1
src/Player/PlayerProxy.cpp
+11
-5
src/Player/PlayerProxy.h
+6
-2
没有找到文件。
server/WebApi.cpp
查看文件 @
3ca69972
...
...
@@ -449,6 +449,8 @@ void installWebApi() {
const
string
&
app
,
const
string
&
stream
,
const
string
&
url
,
bool
enable_rtsp
,
bool
enable_rtmp
,
bool
enable_hls
,
bool
enable_mp4
,
int
rtp_type
,
...
...
@@ -461,7 +463,7 @@ void installWebApi() {
return
;
}
//添加拉流代理
PlayerProxy
::
Ptr
player
(
new
PlayerProxy
(
vhost
,
app
,
stream
,
enable_hls
,
enable_mp4
));
PlayerProxy
::
Ptr
player
(
new
PlayerProxy
(
vhost
,
app
,
stream
,
enable_
rtsp
,
enable_rtmp
,
enable_
hls
,
enable_mp4
));
s_proxyMap
[
key
]
=
player
;
//指定RTP over TCP(播放rtsp时有效)
...
...
@@ -487,13 +489,15 @@ void installWebApi() {
//测试url http://127.0.0.1/index/api/addStreamProxy?vhost=__defaultVhost__&app=proxy&stream=0&url=rtmp://127.0.0.1/live/obs
API_REGIST_INVOKER
(
api
,
addStreamProxy
,{
CHECK_SECRET
();
CHECK_ARGS
(
"vhost"
,
"app"
,
"stream"
,
"url"
);
CHECK_ARGS
(
"vhost"
,
"app"
,
"stream"
,
"url"
,
"enable_rtsp"
,
"enable_rtmp"
);
addStreamProxy
(
allArgs
[
"vhost"
],
allArgs
[
"app"
],
allArgs
[
"stream"
],
allArgs
[
"url"
],
allArgs
[
"enable_hls"
],
allArgs
[
"enable_mp4"
],
allArgs
[
"enable_rtsp"
],
/* 是否rtsp转发 */
allArgs
[
"enable_rtmp"
],
/* 是否rtmp转发 */
allArgs
[
"enable_hls"
],
/* 是否hls转发 */
allArgs
[
"enable_mp4"
],
/* 是否MP4录制 */
allArgs
[
"rtp_type"
],
[
invoker
,
val
,
headerOut
](
const
SockException
&
ex
,
const
string
&
key
){
if
(
ex
){
...
...
@@ -651,9 +655,11 @@ void installWebApi() {
allArgs
[
"app"
],
allArgs
[
"stream"
],
/** 支持rtsp和rtmp方式拉流 ,rtsp支持h265/h264/aac,rtmp仅支持h264/aac **/
"rtmp://live.hkstv.hk.lxdns.com/live/hks2"
,
//"rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov"
true
,
false
,
"rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov"
,
true
,
/* 开启rtsp转发 */
true
,
/* 开启rtmp转发 */
true
,
/* 开启hls转发 */
false
,
/* 禁用MP4录制 */
0
,
//rtp over tcp方式拉流
[
invoker
,
val
,
headerOut
](
const
SockException
&
ex
,
const
string
&
key
){
if
(
ex
){
...
...
src/Common/Device.cpp
查看文件 @
3ca69972
...
...
@@ -41,9 +41,11 @@ DevChannel::DevChannel(const string &strVhost,
const
string
&
strApp
,
const
string
&
strId
,
float
fDuration
,
bool
bEanbleRtsp
,
bool
bEanbleRtmp
,
bool
bEanbleHls
,
bool
bEnableMp4
)
:
MultiMediaSourceMuxer
(
strVhost
,
strApp
,
strId
,
fDuration
,
bEanbleHls
,
bEnableMp4
)
{}
MultiMediaSourceMuxer
(
strVhost
,
strApp
,
strId
,
fDuration
,
bEanble
Rtsp
,
bEanbleRtmp
,
bEanble
Hls
,
bEnableMp4
)
{}
DevChannel
::~
DevChannel
()
{}
...
...
src/Common/Device.h
查看文件 @
3ca69972
...
...
@@ -74,6 +74,8 @@ public:
const
string
&
strApp
,
const
string
&
strId
,
float
fDuration
=
0
,
bool
bEanbleRtsp
=
true
,
bool
bEanbleRtmp
=
true
,
bool
bEanbleHls
=
true
,
bool
bEnableMp4
=
false
);
...
...
src/Common/MultiMediaSourceMuxer.h
查看文件 @
3ca69972
...
...
@@ -39,10 +39,11 @@ public:
const
string
&
strApp
,
const
string
&
strId
,
float
dur_sec
=
0
.
0
,
bool
bEanbleHls
=
true
,
bool
bEnableMp4
=
false
,
bool
bEanbleRtsp
=
true
,
bool
bEanbleRtmp
=
true
,
bool
bEanbleRtsp
=
true
){
bool
bEanbleHls
=
true
,
bool
bEnableMp4
=
false
){
if
(
bEanbleRtmp
)
{
_rtmp
=
std
::
make_shared
<
RtmpMediaSourceMuxer
>
(
vhost
,
strApp
,
strId
,
std
::
make_shared
<
TitleMete
>
(
dur_sec
));
}
...
...
src/MediaFile/MediaReader.cpp
查看文件 @
3ca69972
...
...
@@ -138,7 +138,7 @@ MediaReader::MediaReader(const string &strVhost,const string &strApp, const stri
}
_iDuration
=
MAX
(
_video_ms
,
_audio_ms
);
_mediaMuxer
.
reset
(
new
MultiMediaSourceMuxer
(
strVhost
,
strApp
,
strId
,
_iDuration
/
1000.0
,
false
,
false
));
_mediaMuxer
.
reset
(
new
MultiMediaSourceMuxer
(
strVhost
,
strApp
,
strId
,
_iDuration
/
1000.0
,
true
,
true
,
false
,
false
));
if
(
_audio_trId
!=
MP4_INVALID_TRACK_ID
)
{
AACTrack
::
Ptr
track
=
std
::
make_shared
<
AACTrack
>
(
_strAacCfg
);
_mediaMuxer
->
addTrack
(
track
);
...
...
src/Player/PlayerProxy.cpp
查看文件 @
3ca69972
...
...
@@ -65,6 +65,8 @@ static uint8_t s_mute_adts[] = {0xff, 0xf1, 0x6c, 0x40, 0x2d, 0x3f, 0xfc, 0x00,
PlayerProxy
::
PlayerProxy
(
const
string
&
strVhost
,
const
string
&
strApp
,
const
string
&
strSrc
,
bool
bEnableRtsp
,
bool
bEnableRtmp
,
bool
bEnableHls
,
bool
bEnableMp4
,
int
iRetryCount
,
...
...
@@ -72,6 +74,8 @@ PlayerProxy::PlayerProxy(const string &strVhost,
_strVhost
=
strVhost
;
_strApp
=
strApp
;
_strSrc
=
strSrc
;
_bEnableRtsp
=
bEnableRtsp
;
_bEnableRtmp
=
bEnableRtmp
;
_bEnableHls
=
bEnableHls
;
_bEnableMp4
=
bEnableMp4
;
_iRetryCount
=
iRetryCount
;
...
...
@@ -131,12 +135,14 @@ void PlayerProxy::play(const string &strUrlTmp) {
if
(
dynamic_pointer_cast
<
RtspPlayer
>
(
_parser
)){
//rtsp拉流
GET_CONFIG
(
bool
,
directProxy
,
Rtsp
::
kDirectProxy
);
if
(
directProxy
){
if
(
directProxy
&&
_bEnableRtsp
){
mediaSource
=
std
::
make_shared
<
RtspMediaSource
>
(
_strVhost
,
_strApp
,
_strSrc
);
}
}
else
if
(
dynamic_pointer_cast
<
RtmpPlayer
>
(
_parser
)){
//rtmp拉流
mediaSource
=
std
::
make_shared
<
RtmpMediaSource
>
(
_strVhost
,
_strApp
,
_strSrc
);
if
(
_bEnableRtmp
){
mediaSource
=
std
::
make_shared
<
RtmpMediaSource
>
(
_strVhost
,
_strApp
,
_strSrc
);
}
}
if
(
mediaSource
){
setMediaSouce
(
mediaSource
);
...
...
@@ -220,13 +226,13 @@ private:
void
PlayerProxy
::
onPlaySuccess
()
{
if
(
dynamic_pointer_cast
<
RtspMediaSource
>
(
_pMediaSrc
))
{
//rtsp拉流代理
_mediaMuxer
.
reset
(
new
MultiMediaSourceMuxer
(
_strVhost
,
_strApp
,
_strSrc
,
getDuration
(),
_bEnableHls
,
_bEnableMp4
,
true
,
false
));
_mediaMuxer
.
reset
(
new
MultiMediaSourceMuxer
(
_strVhost
,
_strApp
,
_strSrc
,
getDuration
(),
false
,
_bEnableRtmp
,
_bEnableHls
,
_bEnableMp4
));
}
else
if
(
dynamic_pointer_cast
<
RtmpMediaSource
>
(
_pMediaSrc
))
{
//rtmp拉流代理
_mediaMuxer
.
reset
(
new
MultiMediaSourceMuxer
(
_strVhost
,
_strApp
,
_strSrc
,
getDuration
(),
_bEnable
Hls
,
_bEnableMp4
,
false
,
true
));
_mediaMuxer
.
reset
(
new
MultiMediaSourceMuxer
(
_strVhost
,
_strApp
,
_strSrc
,
getDuration
(),
_bEnable
Rtsp
,
false
,
_bEnableHls
,
_bEnableMp4
));
}
else
{
//其他拉流代理
_mediaMuxer
.
reset
(
new
MultiMediaSourceMuxer
(
_strVhost
,
_strApp
,
_strSrc
,
getDuration
(),
_bEnable
Hls
,
_bEnableMp4
,
true
,
true
));
_mediaMuxer
.
reset
(
new
MultiMediaSourceMuxer
(
_strVhost
,
_strApp
,
_strSrc
,
getDuration
(),
_bEnable
Rtsp
,
_bEnableRtmp
,
_bEnableHls
,
_bEnableMp4
));
}
_mediaMuxer
->
setListener
(
shared_from_this
());
...
...
src/Player/PlayerProxy.h
查看文件 @
3ca69972
...
...
@@ -49,6 +49,8 @@ public:
PlayerProxy
(
const
string
&
strVhost
,
const
string
&
strApp
,
const
string
&
strSrc
,
bool
bEnableRtsp
=
true
,
bool
bEnableRtmp
=
true
,
bool
bEnableHls
=
true
,
bool
bEnableMp4
=
false
,
int
iRetryCount
=
-
1
,
...
...
@@ -86,8 +88,10 @@ private:
void
onPlaySuccess
();
int
readerCount
()
;
private
:
bool
_bEnableHls
;
bool
_bEnableMp4
;
bool
_bEnableRtsp
;
bool
_bEnableRtmp
;
bool
_bEnableHls
;
bool
_bEnableMp4
;
int
_iRetryCount
;
MultiMediaSourceMuxer
::
Ptr
_mediaMuxer
;
string
_strVhost
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论