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
ff7914e4
Commit
ff7914e4
authored
May 26, 2020
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改MediaSource相关接口
parent
eddb5adc
隐藏空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
25 行增加
和
21 行删除
+25
-21
server/FFmpegSource.cpp
+1
-2
server/WebApi.cpp
+2
-2
src/Common/MediaSource.cpp
+9
-8
src/Common/MediaSource.h
+7
-2
src/Record/Recorder.cpp
+2
-2
src/Rtmp/FlvMuxer.cpp
+1
-1
src/Rtmp/RtmpSession.cpp
+1
-2
src/Rtsp/RtpMultiCaster.cpp
+1
-0
src/Rtsp/RtspSession.cpp
+1
-2
没有找到文件。
server/FFmpegSource.cpp
查看文件 @
ff7914e4
...
...
@@ -118,8 +118,7 @@ void FFmpegSource::findAsync(int maxWaitMS, const function<void(const MediaSourc
auto
src
=
MediaSource
::
find
(
_media_info
.
_schema
,
_media_info
.
_vhost
,
_media_info
.
_app
,
_media_info
.
_streamid
,
false
);
_media_info
.
_streamid
);
if
(
src
||
!
maxWaitMS
){
cb
(
src
);
return
;
...
...
server/WebApi.cpp
查看文件 @
ff7914e4
...
...
@@ -439,14 +439,14 @@ void installWebApi() {
api_regist1
(
"/index/api/isMediaOnline"
,[](
API_ARGS1
){
CHECK_SECRET
();
CHECK_ARGS
(
"schema"
,
"vhost"
,
"app"
,
"stream"
);
val
[
"online"
]
=
(
bool
)
(
MediaSource
::
find
(
allArgs
[
"schema"
],
allArgs
[
"vhost"
],
allArgs
[
"app"
],
allArgs
[
"stream"
]
,
false
));
val
[
"online"
]
=
(
bool
)
(
MediaSource
::
find
(
allArgs
[
"schema"
],
allArgs
[
"vhost"
],
allArgs
[
"app"
],
allArgs
[
"stream"
]));
});
//测试url http://127.0.0.1/index/api/getMediaInfo?schema=rtsp&vhost=__defaultVhost__&app=live&stream=obs
api_regist1
(
"/index/api/getMediaInfo"
,[](
API_ARGS1
){
CHECK_SECRET
();
CHECK_ARGS
(
"schema"
,
"vhost"
,
"app"
,
"stream"
);
auto
src
=
MediaSource
::
find
(
allArgs
[
"schema"
],
allArgs
[
"vhost"
],
allArgs
[
"app"
],
allArgs
[
"stream"
]
,
false
);
auto
src
=
MediaSource
::
find
(
allArgs
[
"schema"
],
allArgs
[
"vhost"
],
allArgs
[
"app"
],
allArgs
[
"stream"
]);
if
(
!
src
){
val
[
"online"
]
=
false
;
return
;
...
...
src/Common/MediaSource.cpp
查看文件 @
ff7914e4
...
...
@@ -180,9 +180,8 @@ static void eraseIfEmpty(MAP &map, IT0 it0, IT1 it1, IT2 it2) {
}
};
void
findAsync_l
(
const
MediaInfo
&
info
,
const
std
::
shared_ptr
<
TcpSession
>
&
session
,
bool
retry
,
const
function
<
void
(
const
MediaSource
::
Ptr
&
src
)
>
&
cb
){
auto
src
=
MediaSource
::
find
(
info
.
_schema
,
info
.
_vhost
,
info
.
_app
,
info
.
_streamid
,
true
);
void
MediaSource
::
findAsync_l
(
const
MediaInfo
&
info
,
const
std
::
shared_ptr
<
TcpSession
>
&
session
,
bool
retry
,
const
function
<
void
(
const
MediaSource
::
Ptr
&
src
)
>
&
cb
){
auto
src
=
MediaSource
::
find_l
(
info
.
_schema
,
info
.
_vhost
,
info
.
_app
,
info
.
_streamid
,
true
);
if
(
src
||
!
retry
){
cb
(
src
);
return
;
...
...
@@ -248,7 +247,11 @@ void MediaSource::findAsync(const MediaInfo &info, const std::shared_ptr<TcpSess
return
findAsync_l
(
info
,
session
,
true
,
cb
);
}
MediaSource
::
Ptr
MediaSource
::
find
(
const
string
&
schema
,
const
string
&
vhost_tmp
,
const
string
&
app
,
const
string
&
id
,
bool
bMake
)
{
MediaSource
::
Ptr
MediaSource
::
find
(
const
string
&
schema
,
const
string
&
vhost
,
const
string
&
app
,
const
string
&
id
)
{
return
find_l
(
schema
,
vhost
,
app
,
id
,
false
);
}
MediaSource
::
Ptr
MediaSource
::
find_l
(
const
string
&
schema
,
const
string
&
vhost_tmp
,
const
string
&
app
,
const
string
&
id
,
bool
bMake
)
{
string
vhost
=
vhost_tmp
;
if
(
vhost
.
empty
()){
vhost
=
DEFAULT_VHOST
;
...
...
@@ -419,12 +422,10 @@ void MediaSourceEvent::onNoneReader(MediaSource &sender){
//如果mp4点播, 无人观看时我们强制关闭点播
bool
is_mp4_vod
=
sender
.
getApp
()
==
recordApp
;
//无人观看mp4点播时,3秒后自动关闭
auto
close_delay
=
is_mp4_vod
?
3.0
:
stream_none_reader_delay
/
1000.0
;
//没有任何人观看该视频源,表明该源可以关闭了
weak_ptr
<
MediaSource
>
weakSender
=
sender
.
shared_from_this
();
_async_close_timer
=
std
::
make_shared
<
Timer
>
(
close_delay
,
[
weakSender
,
is_mp4_vod
]()
{
_async_close_timer
=
std
::
make_shared
<
Timer
>
(
stream_none_reader_delay
/
1000.0
,
[
weakSender
,
is_mp4_vod
]()
{
auto
strongSender
=
weakSender
.
lock
();
if
(
!
strongSender
)
{
//对象已经销毁
...
...
@@ -467,7 +468,7 @@ MediaSource::Ptr MediaSource::createFromMP4(const string &schema, const string &
try
{
MP4Reader
::
Ptr
pReader
(
new
MP4Reader
(
vhost
,
app
,
stream
,
filePath
));
pReader
->
startReadMP4
();
return
MediaSource
::
find
(
schema
,
vhost
,
app
,
stream
,
false
);
return
MediaSource
::
find
(
schema
,
vhost
,
app
,
stream
);
}
catch
(
std
::
exception
&
ex
)
{
WarnL
<<
ex
.
what
();
return
nullptr
;
...
...
src/Common/MediaSource.h
查看文件 @
ff7914e4
...
...
@@ -134,7 +134,7 @@ public:
virtual
bool
isRecording
(
Recorder
::
type
type
);
// 同步查找流
static
Ptr
find
(
const
string
&
schema
,
const
string
&
vhost
,
const
string
&
app
,
const
string
&
id
,
bool
bMake
=
true
)
;
static
Ptr
find
(
const
string
&
schema
,
const
string
&
vhost
,
const
string
&
app
,
const
string
&
id
)
;
// 异步查找流
static
void
findAsync
(
const
MediaInfo
&
info
,
const
std
::
shared_ptr
<
TcpSession
>
&
session
,
const
function
<
void
(
const
Ptr
&
src
)
>
&
cb
);
// 遍历所有流
...
...
@@ -142,9 +142,14 @@ public:
// 从mp4文件生成MediaSource
static
MediaSource
::
Ptr
createFromMP4
(
const
string
&
schema
,
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream
,
const
string
&
filePath
=
""
,
bool
checkApp
=
true
);
protected
:
void
regist
()
;
bool
unregist
()
;
bool
unregist
();
private
:
static
Ptr
find_l
(
const
string
&
schema
,
const
string
&
vhost
,
const
string
&
app
,
const
string
&
id
,
bool
bMake
);
static
void
findAsync_l
(
const
MediaInfo
&
info
,
const
std
::
shared_ptr
<
TcpSession
>
&
session
,
bool
retry
,
const
function
<
void
(
const
MediaSource
::
Ptr
&
src
)
>
&
cb
);
private
:
string
_strSchema
;
string
_strVhost
;
...
...
src/Record/Recorder.cpp
查看文件 @
ff7914e4
...
...
@@ -80,11 +80,11 @@ std::shared_ptr<MediaSinkInterface> Recorder::createRecorder(type type, const st
}
static
MediaSource
::
Ptr
getMediaSource
(
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream_id
){
auto
src
=
MediaSource
::
find
(
RTMP_SCHEMA
,
vhost
,
app
,
stream_id
,
false
);
auto
src
=
MediaSource
::
find
(
RTMP_SCHEMA
,
vhost
,
app
,
stream_id
);
if
(
src
){
return
src
;
}
return
MediaSource
::
find
(
RTSP_SCHEMA
,
vhost
,
app
,
stream_id
,
false
);
return
MediaSource
::
find
(
RTSP_SCHEMA
,
vhost
,
app
,
stream_id
);
}
bool
Recorder
::
isRecording
(
type
type
,
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream_id
){
...
...
src/Rtmp/FlvMuxer.cpp
查看文件 @
ff7914e4
...
...
@@ -167,7 +167,7 @@ void FlvMuxer::stop() {
///////////////////////////////////////////////////////FlvRecorder/////////////////////////////////////////////////////
void
FlvRecorder
::
startRecord
(
const
EventPoller
::
Ptr
&
poller
,
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream
,
const
string
&
file_path
)
{
startRecord
(
poller
,
dynamic_pointer_cast
<
RtmpMediaSource
>
(
MediaSource
::
find
(
RTMP_SCHEMA
,
vhost
,
app
,
stream
,
false
)),
file_path
);
startRecord
(
poller
,
dynamic_pointer_cast
<
RtmpMediaSource
>
(
MediaSource
::
find
(
RTMP_SCHEMA
,
vhost
,
app
,
stream
)),
file_path
);
}
void
FlvRecorder
::
startRecord
(
const
EventPoller
::
Ptr
&
poller
,
const
RtmpMediaSource
::
Ptr
&
media
,
const
string
&
file_path
)
{
...
...
src/Rtmp/RtmpSession.cpp
查看文件 @
ff7914e4
...
...
@@ -130,8 +130,7 @@ void RtmpSession::onCmd_publish(AMFDecoder &dec) {
auto
src
=
dynamic_pointer_cast
<
RtmpMediaSource
>
(
MediaSource
::
find
(
RTMP_SCHEMA
,
_mediaInfo
.
_vhost
,
_mediaInfo
.
_app
,
_mediaInfo
.
_streamid
,
false
));
_mediaInfo
.
_streamid
));
bool
authSuccess
=
err
.
empty
();
bool
ok
=
(
!
src
&&
!
_pPublisherSrc
&&
authSuccess
);
AMFValue
status
(
AMF_OBJECT
);
...
...
src/Rtsp/RtpMultiCaster.cpp
查看文件 @
ff7914e4
...
...
@@ -81,6 +81,7 @@ RtpMultiCaster::~RtpMultiCaster() {
_pReader
->
setDetachCB
(
nullptr
);
DebugL
;
}
RtpMultiCaster
::
RtpMultiCaster
(
const
EventPoller
::
Ptr
&
poller
,
const
string
&
strLocalIp
,
const
string
&
strVhost
,
const
string
&
strApp
,
const
string
&
strStream
)
{
auto
src
=
dynamic_pointer_cast
<
RtspMediaSource
>
(
MediaSource
::
find
(
RTSP_SCHEMA
,
strVhost
,
strApp
,
strStream
));
if
(
!
src
){
...
...
src/Rtsp/RtspSession.cpp
查看文件 @
ff7914e4
...
...
@@ -221,8 +221,7 @@ void RtspSession::handleReq_ANNOUNCE(const Parser &parser) {
auto
src
=
dynamic_pointer_cast
<
RtmpMediaSource
>
(
MediaSource
::
find
(
RTSP_SCHEMA
,
_mediaInfo
.
_vhost
,
_mediaInfo
.
_app
,
_mediaInfo
.
_streamid
,
false
));
_mediaInfo
.
_streamid
));
if
(
src
){
sendRtspResponse
(
"406 Not Acceptable"
,
{
"Content-Type"
,
"text/plain"
},
"Already publishing."
);
string
err
=
StrPrinter
<<
"ANNOUNCE:"
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论