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
9c873e1d
Commit
9c873e1d
authored
Sep 20, 2020
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
去除转协议开关参数
parent
00a7414f
隐藏空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
23 行增加
和
46 行删除
+23
-46
api/include/mk_media.h
+2
-4
api/source/mk_media.cpp
+3
-4
api/source/mk_proxyplayer.cpp
+1
-1
server/WebApi.cpp
+2
-8
src/Common/Device.cpp
+3
-3
src/Common/Device.h
+2
-2
src/Player/PlayerProxy.cpp
+8
-13
src/Player/PlayerProxy.h
+1
-3
tests/test_pusher.cpp
+1
-8
没有找到文件。
api/include/mk_media.h
查看文件 @
9c873e1d
...
...
@@ -26,14 +26,12 @@ typedef void *mk_media;
* @param app 应用名,推荐为live
* @param stream 流id,例如camera
* @param duration 时长(单位秒),直播则为0
* @param rtsp_enabled 是否启用rtsp协议
* @param rtmp_enabled 是否启用rtmp协议
* @param hls_enabled 是否生成hls
* @param mp4_enabled 是否生成mp4
* @return 对象指针
*/
API_EXPORT
mk_media
API_CALL
mk_media_create
(
const
char
*
vhost
,
const
char
*
app
,
const
char
*
stream
,
float
duration
,
int
rtsp_enabled
,
int
rtmp_enabled
,
int
hls_enabled
,
int
mp4_enabled
);
API_EXPORT
mk_media
API_CALL
mk_media_create
(
const
char
*
vhost
,
const
char
*
app
,
const
char
*
stream
,
float
duration
,
int
hls_enabled
,
int
mp4_enabled
);
/**
* 销毁媒体源
...
...
api/source/mk_media.cpp
查看文件 @
9c873e1d
...
...
@@ -117,11 +117,10 @@ API_EXPORT int API_CALL mk_media_total_reader_count(mk_media ctx){
return
(
*
obj
)
->
getChannel
()
->
totalReaderCount
();
}
API_EXPORT
mk_media
API_CALL
mk_media_create
(
const
char
*
vhost
,
const
char
*
app
,
const
char
*
stream
,
float
duration
,
int
rtsp_enabled
,
int
rtmp_enabled
,
int
hls_enabled
,
int
mp4_enabled
)
{
API_EXPORT
mk_media
API_CALL
mk_media_create
(
const
char
*
vhost
,
const
char
*
app
,
const
char
*
stream
,
float
duration
,
int
hls_enabled
,
int
mp4_enabled
)
{
assert
(
vhost
&&
app
&&
stream
);
MediaHelper
::
Ptr
*
obj
(
new
MediaHelper
::
Ptr
(
new
MediaHelper
(
vhost
,
app
,
stream
,
duration
,
rtsp_enabled
,
rtmp_enabled
,
hls_enabled
,
mp4_enabled
)));
MediaHelper
::
Ptr
*
obj
(
new
MediaHelper
::
Ptr
(
new
MediaHelper
(
vhost
,
app
,
stream
,
duration
,
hls_enabled
,
mp4_enabled
)));
(
*
obj
)
->
attachEvent
();
return
(
mk_media
)
obj
;
}
...
...
api/source/mk_proxyplayer.cpp
查看文件 @
9c873e1d
...
...
@@ -16,7 +16,7 @@ using namespace mediakit;
API_EXPORT
mk_proxy_player
API_CALL
mk_proxy_player_create
(
const
char
*
vhost
,
const
char
*
app
,
const
char
*
stream
,
int
hls_enabled
,
int
mp4_enabled
)
{
assert
(
vhost
&&
app
&&
stream
);
PlayerProxy
::
Ptr
*
obj
(
new
PlayerProxy
::
Ptr
(
new
PlayerProxy
(
vhost
,
app
,
stream
,
true
,
true
,
hls_enabled
,
mp4_enabled
)));
PlayerProxy
::
Ptr
*
obj
(
new
PlayerProxy
::
Ptr
(
new
PlayerProxy
(
vhost
,
app
,
stream
,
hls_enabled
,
mp4_enabled
)));
return
(
mk_proxy_player
)
obj
;
}
...
...
server/WebApi.cpp
查看文件 @
9c873e1d
...
...
@@ -596,8 +596,6 @@ 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
,
...
...
@@ -610,7 +608,7 @@ void installWebApi() {
return
;
}
//添加拉流代理
PlayerProxy
::
Ptr
player
(
new
PlayerProxy
(
vhost
,
app
,
stream
,
enable_rtsp
,
enable_rtmp
,
enable_hls
,
enable_mp4
));
PlayerProxy
::
Ptr
player
(
new
PlayerProxy
(
vhost
,
app
,
stream
,
enable_hls
,
enable_mp4
));
s_proxyMap
[
key
]
=
player
;
//指定RTP over TCP(播放rtsp时有效)
...
...
@@ -636,13 +634,11 @@ void installWebApi() {
//测试url http://127.0.0.1/index/api/addStreamProxy?vhost=__defaultVhost__&app=proxy&enable_rtsp=1&enable_rtmp=1&stream=0&url=rtmp://127.0.0.1/live/obs
api_regist2
(
"/index/api/addStreamProxy"
,[](
API_ARGS2
){
CHECK_SECRET
();
CHECK_ARGS
(
"vhost"
,
"app"
,
"stream"
,
"url"
,
"enable_rtsp"
,
"enable_rtmp"
);
CHECK_ARGS
(
"vhost"
,
"app"
,
"stream"
,
"url"
);
addStreamProxy
(
allArgs
[
"vhost"
],
allArgs
[
"app"
],
allArgs
[
"stream"
],
allArgs
[
"url"
],
allArgs
[
"enable_rtsp"
],
/* 是否rtsp转发 */
allArgs
[
"enable_rtmp"
],
/* 是否rtmp转发 */
allArgs
[
"enable_hls"
],
/* 是否hls转发 */
allArgs
[
"enable_mp4"
],
/* 是否MP4录制 */
allArgs
[
"rtp_type"
],
...
...
@@ -1071,8 +1067,6 @@ void installWebApi() {
allArgs
[
"stream"
],
/** 支持rtsp和rtmp方式拉流 ,rtsp支持h265/h264/aac,rtmp仅支持h264/aac **/
"rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov"
,
true
,
/* 开启rtsp转发 */
true
,
/* 开启rtmp转发 */
true
,
/* 开启hls转发 */
false
,
/* 禁用MP4录制 */
0
,
//rtp over tcp方式拉流
...
...
src/Common/Device.cpp
查看文件 @
9c873e1d
...
...
@@ -20,9 +20,9 @@ using namespace toolkit;
namespace
mediakit
{
DevChannel
::
DevChannel
(
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream_id
,
float
duration
,
bool
enable_rtsp
,
bool
enable_rtmp
,
bool
enable_hls
,
bool
enable_mp4
)
:
MultiMediaSourceMuxer
(
vhost
,
app
,
stream_id
,
duration
,
enable_rtsp
,
enable_rtmp
,
enable_hls
,
enable_mp4
)
{}
DevChannel
::
DevChannel
(
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream_id
,
float
duration
,
bool
enable_hls
,
bool
enable_mp4
)
:
MultiMediaSourceMuxer
(
vhost
,
app
,
stream_id
,
duration
,
true
,
true
,
enable_hls
,
enable_mp4
)
{}
DevChannel
::~
DevChannel
()
{}
...
...
src/Common/Device.h
查看文件 @
9c873e1d
...
...
@@ -53,8 +53,8 @@ class DevChannel : public MultiMediaSourceMuxer{
public
:
typedef
std
::
shared_ptr
<
DevChannel
>
Ptr
;
//fDuration<=0为直播,否则为点播
DevChannel
(
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream_id
,
float
duration
=
0
,
bool
enable_rtsp
=
true
,
bool
enable_rtmp
=
true
,
bool
enable_hls
=
true
,
bool
enable_mp4
=
false
);
DevChannel
(
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream_id
,
float
duration
=
0
,
bool
enable_hls
=
true
,
bool
enable_mp4
=
false
);
~
DevChannel
()
override
;
...
...
src/Player/PlayerProxy.cpp
查看文件 @
9c873e1d
...
...
@@ -47,13 +47,11 @@ static uint8_t s_mute_adts[] = {0xff, 0xf1, 0x6c, 0x40, 0x2d, 0x3f, 0xfc, 0x00,
#define MUTE_ADTS_DATA_MS 130
PlayerProxy
::
PlayerProxy
(
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream_id
,
bool
enable_
rtsp
,
bool
enable_rtmp
,
bool
enable_hls
,
bool
enable_mp4
,
int
retry_count
,
const
EventPoller
::
Ptr
&
poller
)
:
MediaPlayer
(
poller
)
{
bool
enable_
hls
,
bool
enable_mp4
,
int
retry_count
,
const
EventPoller
::
Ptr
&
poller
)
:
MediaPlayer
(
poller
)
{
_vhost
=
vhost
;
_app
=
app
;
_stream_id
=
stream_id
;
_enable_rtsp
=
enable_rtsp
;
_enable_rtmp
=
enable_rtmp
;
_enable_hls
=
enable_hls
;
_enable_mp4
=
enable_mp4
;
_retry_count
=
retry_count
;
...
...
@@ -119,15 +117,12 @@ void PlayerProxy::play(const string &strUrlTmp) {
if
(
dynamic_pointer_cast
<
RtspPlayer
>
(
_delegate
)){
//rtsp拉流
GET_CONFIG
(
bool
,
directProxy
,
Rtsp
::
kDirectProxy
);
if
(
directProxy
&&
_enable_rtsp
){
if
(
directProxy
){
mediaSource
=
std
::
make_shared
<
RtspMediaSource
>
(
_vhost
,
_app
,
_stream_id
);
}
}
else
if
(
dynamic_pointer_cast
<
RtmpPlayer
>
(
_delegate
)){
//rtmp拉流
if
(
_enable_rtmp
){
//rtmp强制直接代理
mediaSource
=
std
::
make_shared
<
RtmpMediaSource
>
(
_vhost
,
_app
,
_stream_id
);
}
//rtmp拉流,rtmp强制直接代理
mediaSource
=
std
::
make_shared
<
RtmpMediaSource
>
(
_vhost
,
_app
,
_stream_id
);
}
if
(
mediaSource
){
setMediaSouce
(
mediaSource
);
...
...
@@ -224,17 +219,17 @@ void PlayerProxy::onPlaySuccess() {
if
(
dynamic_pointer_cast
<
RtspMediaSource
>
(
_pMediaSrc
))
{
//rtsp拉流代理
if
(
resetWhenRePlay
||
!
_muxer
)
{
_muxer
.
reset
(
new
MultiMediaSourceMuxer
(
_vhost
,
_app
,
_stream_id
,
getDuration
(),
false
,
_enable_rtmp
,
_enable_hls
,
_enable_mp4
));
_muxer
.
reset
(
new
MultiMediaSourceMuxer
(
_vhost
,
_app
,
_stream_id
,
getDuration
(),
false
,
true
,
_enable_hls
,
_enable_mp4
));
}
}
else
if
(
dynamic_pointer_cast
<
RtmpMediaSource
>
(
_pMediaSrc
))
{
//rtmp拉流代理
if
(
resetWhenRePlay
||
!
_muxer
)
{
_muxer
.
reset
(
new
MultiMediaSourceMuxer
(
_vhost
,
_app
,
_stream_id
,
getDuration
(),
_enable_rtsp
,
false
,
_enable_hls
,
_enable_mp4
));
_muxer
.
reset
(
new
MultiMediaSourceMuxer
(
_vhost
,
_app
,
_stream_id
,
getDuration
(),
true
,
false
,
_enable_hls
,
_enable_mp4
));
}
}
else
{
//其他拉流代理
if
(
resetWhenRePlay
||
!
_muxer
)
{
_muxer
.
reset
(
new
MultiMediaSourceMuxer
(
_vhost
,
_app
,
_stream_id
,
getDuration
(),
_enable_rtsp
,
_enable_rtmp
,
_enable_hls
,
_enable_mp4
));
_muxer
.
reset
(
new
MultiMediaSourceMuxer
(
_vhost
,
_app
,
_stream_id
,
getDuration
(),
true
,
true
,
_enable_hls
,
_enable_mp4
));
}
}
_muxer
->
setMediaListener
(
shared_from_this
());
...
...
src/Player/PlayerProxy.h
查看文件 @
9c873e1d
...
...
@@ -27,7 +27,7 @@ public:
//如果retry_count<0,则一直重试播放;否则重试retry_count次数
//默认一直重试
PlayerProxy
(
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream_id
,
bool
enable_
rtsp
=
true
,
bool
enable_rtmp
=
true
,
bool
enable_
hls
=
true
,
bool
enable_mp4
=
false
,
bool
enable_hls
=
true
,
bool
enable_mp4
=
false
,
int
retry_count
=
-
1
,
const
EventPoller
::
Ptr
&
poller
=
nullptr
);
~
PlayerProxy
()
override
;
...
...
@@ -63,8 +63,6 @@ private:
void
onPlaySuccess
();
private
:
bool
_enable_rtsp
;
bool
_enable_rtmp
;
bool
_enable_hls
;
bool
_enable_mp4
;
int
_retry_count
;
...
...
tests/test_pusher.cpp
查看文件 @
9c873e1d
...
...
@@ -75,14 +75,7 @@ int domain(const string &playUrl, const string &pushUrl) {
//拉一个流,生成一个RtmpMediaSource,源的名称是"app/stream"
//你也可以以其他方式生成RtmpMediaSource,比如说MP4文件(请查看test_rtmpPusherMp4.cpp代码)
MediaInfo
info
(
pushUrl
);
bool
enable_rtsp
=
true
;
bool
enable_rtmp
=
true
;
if
(
info
.
_schema
==
RTSP_SCHEMA
){
enable_rtmp
=
false
;
}
else
if
(
info
.
_schema
==
RTMP_SCHEMA
){
enable_rtsp
=
false
;
}
PlayerProxy
::
Ptr
player
(
new
PlayerProxy
(
DEFAULT_VHOST
,
"app"
,
"stream"
,
enable_rtsp
,
enable_rtmp
,
false
,
false
,
-
1
,
poller
));
PlayerProxy
::
Ptr
player
(
new
PlayerProxy
(
DEFAULT_VHOST
,
"app"
,
"stream"
,
false
,
false
,
-
1
,
poller
));
//可以指定rtsp拉流方式,支持tcp和udp方式,默认tcp
// (*player)[Client::kRtpType] = Rtsp::RTP_UDP;
player
->
play
(
playUrl
.
data
());
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论