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
51ae8d40
Commit
51ae8d40
authored
Sep 06, 2020
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
复用忽略协议查找流的相关代码
parent
599e8493
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
21 行增加
和
21 行删除
+21
-21
server/WebApi.cpp
+2
-10
src/Common/MediaSource.cpp
+12
-0
src/Common/MediaSource.h
+4
-0
src/Record/Recorder.cpp
+3
-11
没有找到文件。
server/WebApi.cpp
查看文件 @
51ae8d40
...
@@ -810,19 +810,11 @@ void installWebApi() {
...
@@ -810,19 +810,11 @@ void installWebApi() {
}
}
});
});
static
auto
getMediaSource
=
[](
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream_id
){
auto
src
=
MediaSource
::
find
(
RTMP_SCHEMA
,
vhost
,
app
,
stream_id
);
if
(
src
){
return
src
;
}
return
MediaSource
::
find
(
RTSP_SCHEMA
,
vhost
,
app
,
stream_id
);
};
api_regist2
(
"/index/api/startSendRtp"
,[](
API_ARGS2
){
api_regist2
(
"/index/api/startSendRtp"
,[](
API_ARGS2
){
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
=
getMediaSource
(
allArgs
[
"vhost"
],
allArgs
[
"app"
],
allArgs
[
"stream"
]);
auto
src
=
MediaSource
::
find
(
allArgs
[
"vhost"
],
allArgs
[
"app"
],
allArgs
[
"stream"
]);
if
(
!
src
)
{
if
(
!
src
)
{
throw
ApiRetException
(
"该媒体流不存在"
,
API
::
OtherFailed
);
throw
ApiRetException
(
"该媒体流不存在"
,
API
::
OtherFailed
);
}
}
...
@@ -840,7 +832,7 @@ void installWebApi() {
...
@@ -840,7 +832,7 @@ void installWebApi() {
CHECK_SECRET
();
CHECK_SECRET
();
CHECK_ARGS
(
"vhost"
,
"app"
,
"stream"
);
CHECK_ARGS
(
"vhost"
,
"app"
,
"stream"
);
auto
src
=
getMediaSource
(
allArgs
[
"vhost"
],
allArgs
[
"app"
],
allArgs
[
"stream"
]);
auto
src
=
MediaSource
::
find
(
allArgs
[
"vhost"
],
allArgs
[
"app"
],
allArgs
[
"stream"
]);
if
(
!
src
)
{
if
(
!
src
)
{
throw
ApiRetException
(
"该媒体流不存在"
,
API
::
OtherFailed
);
throw
ApiRetException
(
"该媒体流不存在"
,
API
::
OtherFailed
);
}
}
...
...
src/Common/MediaSource.cpp
查看文件 @
51ae8d40
...
@@ -307,6 +307,18 @@ MediaSource::Ptr MediaSource::find(const string &schema, const string &vhost, co
...
@@ -307,6 +307,18 @@ MediaSource::Ptr MediaSource::find(const string &schema, const string &vhost, co
return
find_l
(
schema
,
vhost
,
app
,
id
,
false
);
return
find_l
(
schema
,
vhost
,
app
,
id
,
false
);
}
}
MediaSource
::
Ptr
MediaSource
::
find
(
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream_id
){
auto
src
=
MediaSource
::
find
(
RTMP_SCHEMA
,
vhost
,
app
,
stream_id
);
if
(
src
)
{
return
src
;
}
src
=
MediaSource
::
find
(
RTSP_SCHEMA
,
vhost
,
app
,
stream_id
);
if
(
src
)
{
return
src
;
}
return
MediaSource
::
find
(
HLS_SCHEMA
,
vhost
,
app
,
stream_id
);
}
static
string
getTrackInfoStr
(
const
TrackSource
*
track_src
){
static
string
getTrackInfoStr
(
const
TrackSource
*
track_src
){
_StrPrinter
codec_info
;
_StrPrinter
codec_info
;
auto
tracks
=
track_src
->
getTracks
(
true
);
auto
tracks
=
track_src
->
getTracks
(
true
);
...
...
src/Common/MediaSource.h
查看文件 @
51ae8d40
...
@@ -175,6 +175,10 @@ public:
...
@@ -175,6 +175,10 @@ public:
// 同步查找流
// 同步查找流
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
);
// 忽略类型,同步查找流,可能返回rtmp/rtsp/hls类型
static
Ptr
find
(
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream_id
);
// 异步查找流
// 异步查找流
static
void
findAsync
(
const
MediaInfo
&
info
,
const
std
::
shared_ptr
<
TcpSession
>
&
session
,
const
function
<
void
(
const
Ptr
&
src
)
>
&
cb
);
static
void
findAsync
(
const
MediaInfo
&
info
,
const
std
::
shared_ptr
<
TcpSession
>
&
session
,
const
function
<
void
(
const
Ptr
&
src
)
>
&
cb
);
// 遍历所有流
// 遍历所有流
...
...
src/Record/Recorder.cpp
查看文件 @
51ae8d40
...
@@ -79,16 +79,8 @@ std::shared_ptr<MediaSinkInterface> Recorder::createRecorder(type type, const st
...
@@ -79,16 +79,8 @@ 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
);
if
(
src
){
return
src
;
}
return
MediaSource
::
find
(
RTSP_SCHEMA
,
vhost
,
app
,
stream_id
);
}
bool
Recorder
::
isRecording
(
type
type
,
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream_id
){
bool
Recorder
::
isRecording
(
type
type
,
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream_id
){
auto
src
=
getMediaSource
(
vhost
,
app
,
stream_id
);
auto
src
=
MediaSource
::
find
(
vhost
,
app
,
stream_id
);
if
(
!
src
){
if
(
!
src
){
return
false
;
return
false
;
}
}
...
@@ -96,7 +88,7 @@ bool Recorder::isRecording(type type, const string &vhost, const string &app, co
...
@@ -96,7 +88,7 @@ bool Recorder::isRecording(type type, const string &vhost, const string &app, co
}
}
bool
Recorder
::
startRecord
(
type
type
,
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream_id
,
const
string
&
customized_path
){
bool
Recorder
::
startRecord
(
type
type
,
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream_id
,
const
string
&
customized_path
){
auto
src
=
getMediaSource
(
vhost
,
app
,
stream_id
);
auto
src
=
MediaSource
::
find
(
vhost
,
app
,
stream_id
);
if
(
!
src
)
{
if
(
!
src
)
{
WarnL
<<
"未找到相关的MediaSource,startRecord失败:"
<<
vhost
<<
"/"
<<
app
<<
"/"
<<
stream_id
;
WarnL
<<
"未找到相关的MediaSource,startRecord失败:"
<<
vhost
<<
"/"
<<
app
<<
"/"
<<
stream_id
;
return
false
;
return
false
;
...
@@ -105,7 +97,7 @@ bool Recorder::startRecord(type type, const string &vhost, const string &app, co
...
@@ -105,7 +97,7 @@ bool Recorder::startRecord(type type, const string &vhost, const string &app, co
}
}
bool
Recorder
::
stopRecord
(
type
type
,
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream_id
){
bool
Recorder
::
stopRecord
(
type
type
,
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream_id
){
auto
src
=
getMediaSource
(
vhost
,
app
,
stream_id
);
auto
src
=
MediaSource
::
find
(
vhost
,
app
,
stream_id
);
if
(
!
src
){
if
(
!
src
){
return
false
;
return
false
;
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论