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
4067f2be
Commit
4067f2be
authored
Oct 21, 2021
by
ziyue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ps rtp推流接口(startSendRtp)支持推送本地mp4录像
parent
a25e1d60
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
18 行增加
和
16 行删除
+18
-16
postman/ZLMediaKit.postman_collection.json
+6
-0
server/WebApi.cpp
+1
-1
src/Common/MediaSource.cpp
+8
-8
src/Common/MediaSource.h
+3
-7
没有找到文件。
postman/ZLMediaKit.postman_collection.json
查看文件 @
4067f2be
...
@@ -1329,6 +1329,12 @@
...
@@ -1329,6 +1329,12 @@
"value"
:
"0"
,
"value"
:
"0"
,
"description"
:
"指定tcp/udp客户端使用的本地端口,0时为随机端口,该参数非必选参数,不传时为随机端口。"
,
"description"
:
"指定tcp/udp客户端使用的本地端口,0时为随机端口,该参数非必选参数,不传时为随机端口。"
,
"disabled"
:
true
"disabled"
:
true
},
{
"key"
:
"from_mp4"
,
"value"
:
"0"
,
"description"
:
"是否推送本地MP4录像,该参数非必选参数"
,
"disabled"
:
true
}
}
]
]
}
}
...
...
server/WebApi.cpp
查看文件 @
4067f2be
...
@@ -967,7 +967,7 @@ void installWebApi() {
...
@@ -967,7 +967,7 @@ void installWebApi() {
CHECK_SECRET
();
CHECK_SECRET
();
CHECK_ARGS
(
"vhost"
,
"app"
,
"stream"
,
"ssrc"
,
"dst_url"
,
"dst_port"
,
"is_udp"
);
CHECK_ARGS
(
"vhost"
,
"app"
,
"stream"
,
"ssrc"
,
"dst_url"
,
"dst_port"
,
"is_udp"
);
auto
src
=
MediaSource
::
find
(
allArgs
[
"vhost"
],
allArgs
[
"app"
],
allArgs
[
"stream"
]);
auto
src
=
MediaSource
::
find
(
allArgs
[
"vhost"
],
allArgs
[
"app"
],
allArgs
[
"stream"
]
,
allArgs
[
"from_mp4"
].
as
<
int
>
()
);
if
(
!
src
)
{
if
(
!
src
)
{
throw
ApiRetException
(
"该媒体流不存在"
,
API
::
OtherFailed
);
throw
ApiRetException
(
"该媒体流不存在"
,
API
::
OtherFailed
);
}
}
...
...
src/Common/MediaSource.cpp
查看文件 @
4067f2be
...
@@ -288,7 +288,7 @@ void MediaSource::for_each_media(const function<void(const Ptr &src)> &cb,
...
@@ -288,7 +288,7 @@ void MediaSource::for_each_media(const function<void(const Ptr &src)> &cb,
}
}
}
}
static
MediaSource
::
Ptr
find_l
(
const
string
&
schema
,
const
string
&
vhost_in
,
const
string
&
app
,
const
string
&
id
,
bool
create_new
)
{
static
MediaSource
::
Ptr
find_l
(
const
string
&
schema
,
const
string
&
vhost_in
,
const
string
&
app
,
const
string
&
id
,
bool
from_mp4
)
{
string
vhost
=
vhost_in
;
string
vhost
=
vhost_in
;
GET_CONFIG
(
bool
,
enableVhost
,
General
::
kEnableVhost
);
GET_CONFIG
(
bool
,
enableVhost
,
General
::
kEnableVhost
);
if
(
vhost
.
empty
()
||
!
enableVhost
){
if
(
vhost
.
empty
()
||
!
enableVhost
){
...
@@ -303,7 +303,7 @@ static MediaSource::Ptr find_l(const string &schema, const string &vhost_in, con
...
@@ -303,7 +303,7 @@ static MediaSource::Ptr find_l(const string &schema, const string &vhost_in, con
MediaSource
::
Ptr
ret
;
MediaSource
::
Ptr
ret
;
MediaSource
::
for_each_media
([
&
](
const
MediaSource
::
Ptr
&
src
)
{
ret
=
std
::
move
(
const_cast
<
MediaSource
::
Ptr
&>
(
src
));
},
schema
,
vhost
,
app
,
id
);
MediaSource
::
for_each_media
([
&
](
const
MediaSource
::
Ptr
&
src
)
{
ret
=
std
::
move
(
const_cast
<
MediaSource
::
Ptr
&>
(
src
));
},
schema
,
vhost
,
app
,
id
);
if
(
!
ret
&&
create_new
&&
schema
!=
HLS_SCHEMA
){
if
(
!
ret
&&
from_mp4
&&
schema
!=
HLS_SCHEMA
){
//未查找媒体源,则读取mp4创建一个
//未查找媒体源,则读取mp4创建一个
//播放hls不触发mp4点播(因为HLS也可以用于录像,不是纯粹的直播)
//播放hls不触发mp4点播(因为HLS也可以用于录像,不是纯粹的直播)
ret
=
MediaSource
::
createFromMP4
(
schema
,
vhost
,
app
,
id
);
ret
=
MediaSource
::
createFromMP4
(
schema
,
vhost
,
app
,
id
);
...
@@ -387,20 +387,20 @@ void MediaSource::findAsync(const MediaInfo &info, const std::shared_ptr<Session
...
@@ -387,20 +387,20 @@ void MediaSource::findAsync(const MediaInfo &info, const std::shared_ptr<Session
return
findAsync_l
(
info
,
session
,
true
,
cb
);
return
findAsync_l
(
info
,
session
,
true
,
cb
);
}
}
MediaSource
::
Ptr
MediaSource
::
find
(
const
string
&
schema
,
const
string
&
vhost
,
const
string
&
app
,
const
string
&
id
)
{
MediaSource
::
Ptr
MediaSource
::
find
(
const
string
&
schema
,
const
string
&
vhost
,
const
string
&
app
,
const
string
&
id
,
bool
from_mp4
)
{
return
find_l
(
schema
,
vhost
,
app
,
id
,
f
alse
);
return
find_l
(
schema
,
vhost
,
app
,
id
,
f
rom_mp4
);
}
}
MediaSource
::
Ptr
MediaSource
::
find
(
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream_id
)
{
MediaSource
::
Ptr
MediaSource
::
find
(
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream_id
,
bool
from_mp4
)
{
auto
src
=
MediaSource
::
find
(
RTMP_SCHEMA
,
vhost
,
app
,
stream_id
);
auto
src
=
MediaSource
::
find
(
RTMP_SCHEMA
,
vhost
,
app
,
stream_id
,
from_mp4
);
if
(
src
)
{
if
(
src
)
{
return
src
;
return
src
;
}
}
src
=
MediaSource
::
find
(
RTSP_SCHEMA
,
vhost
,
app
,
stream_id
);
src
=
MediaSource
::
find
(
RTSP_SCHEMA
,
vhost
,
app
,
stream_id
,
from_mp4
);
if
(
src
)
{
if
(
src
)
{
return
src
;
return
src
;
}
}
return
MediaSource
::
find
(
HLS_SCHEMA
,
vhost
,
app
,
stream_id
);
return
MediaSource
::
find
(
HLS_SCHEMA
,
vhost
,
app
,
stream_id
,
from_mp4
);
}
}
void
MediaSource
::
emitEvent
(
bool
regist
){
void
MediaSource
::
emitEvent
(
bool
regist
){
...
...
src/Common/MediaSource.h
查看文件 @
4067f2be
...
@@ -275,19 +275,15 @@ public:
...
@@ -275,19 +275,15 @@ public:
////////////////static方法,查找或生成MediaSource////////////////
////////////////static方法,查找或生成MediaSource////////////////
// 同步查找流
// 同步查找流
static
Ptr
find
(
const
string
&
schema
,
const
string
&
vhost
,
const
string
&
app
,
const
string
&
id
);
static
Ptr
find
(
const
string
&
schema
,
const
string
&
vhost
,
const
string
&
app
,
const
string
&
id
,
bool
from_mp4
=
false
);
// 忽略类型,同步查找流,可能返回rtmp/rtsp/hls类型
// 忽略类型,同步查找流,可能返回rtmp/rtsp/hls类型
static
Ptr
find
(
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream_id
);
static
Ptr
find
(
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream_id
,
bool
from_mp4
=
false
);
// 异步查找流
// 异步查找流
static
void
findAsync
(
const
MediaInfo
&
info
,
const
std
::
shared_ptr
<
Session
>
&
session
,
const
function
<
void
(
const
Ptr
&
src
)
>
&
cb
);
static
void
findAsync
(
const
MediaInfo
&
info
,
const
std
::
shared_ptr
<
Session
>
&
session
,
const
function
<
void
(
const
Ptr
&
src
)
>
&
cb
);
// 遍历所有流
// 遍历所有流
static
void
for_each_media
(
const
function
<
void
(
const
Ptr
&
src
)
>
&
cb
,
static
void
for_each_media
(
const
function
<
void
(
const
Ptr
&
src
)
>
&
cb
,
const
string
&
schema
=
""
,
const
string
&
vhost
=
""
,
const
string
&
app
=
""
,
const
string
&
stream
=
""
);
const
string
&
schema
=
""
,
const
string
&
vhost
=
""
,
const
string
&
app
=
""
,
const
string
&
stream
=
""
);
// 从mp4文件生成MediaSource
// 从mp4文件生成MediaSource
static
MediaSource
::
Ptr
createFromMP4
(
const
string
&
schema
,
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream
,
const
string
&
file_path
=
""
,
bool
check_app
=
true
);
static
MediaSource
::
Ptr
createFromMP4
(
const
string
&
schema
,
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream
,
const
string
&
file_path
=
""
,
bool
check_app
=
true
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论