复用忽略协议查找流的相关代码
This commit is contained in:
parent
599e8493ca
commit
51ae8d4083
|
|
@ -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() {
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
// 遍历所有流
|
// 遍历所有流
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue