整理MediaSource协议类型

This commit is contained in:
夏楚 2023-12-02 16:31:40 +08:00 committed by GitHub
parent 10c2197e76
commit 76aebd74c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 20 additions and 10 deletions

View File

@ -1719,7 +1719,7 @@ void installWebApi() {
auto &allArgs = _args;
CHECK_ARGS("app", "stream");
return StrPrinter << RTC_SCHEMA << "://" << _args["Host"] << "/" << _args["app"] << "/"
return StrPrinter << "rtc://" << _args["Host"] << "/" << _args["app"] << "/"
<< _args["stream"] << "?" << _args.getParser().params() + "&session=" + _session_id;
}

View File

@ -491,7 +491,19 @@ MediaSource::Ptr MediaSource::find(const string &vhost, const string &app, const
if (src) {
return src;
}
return MediaSource::find(HLS_SCHEMA, vhost, app, stream_id, from_mp4);
src = MediaSource::find(TS_SCHEMA, vhost, app, stream_id, from_mp4);
if (src) {
return src;
}
src = MediaSource::find(FMP4_SCHEMA, vhost, app, stream_id, from_mp4);
if (src) {
return src;
}
src = MediaSource::find(HLS_SCHEMA, vhost, app, stream_id, from_mp4);
if (src) {
return src;
}
return MediaSource::find(HLS_FMP4_SCHEMA, vhost, app, stream_id, from_mp4);
}
void MediaSource::emitEvent(bool regist){

View File

@ -51,16 +51,14 @@
}
#endif // CLEAR_ARR
#define VHOST_KEY "vhost"
#define HTTP_SCHEMA "http"
#define RTSP_SCHEMA "rtsp"
#define RTC_SCHEMA "rtc"
#define RTMP_SCHEMA "rtmp"
#define HLS_SCHEMA "hls"
#define TS_SCHEMA "ts"
#define FMP4_SCHEMA "fmp4"
#define HLS_SCHEMA "hls"
#define HLS_FMP4_SCHEMA "hls.fmp4"
#define SRT_SCHEMA "srt"
#define VHOST_KEY "vhost"
#define DEFAULT_VHOST "__defaultVhost__"
#ifdef __cplusplus

View File

@ -620,7 +620,7 @@ static string getFilePath(const Parser &parser,const MediaInfo &media_info, Sess
* @param cb
*/
void HttpFileManager::onAccessPath(Session &sender, Parser &parser, const HttpFileManager::invoker &cb) {
auto fullUrl = string(HTTP_SCHEMA) + "://" + parser["Host"] + parser.fullUrl();
auto fullUrl = "http://" + parser["Host"] + parser.fullUrl();
MediaInfo media_info(fullUrl);
auto file_path = getFilePath(parser, media_info, sender);
if (file_path.size() == 0) {

View File

@ -54,7 +54,7 @@ bool SrtTransportImp::parseStreamid(std::string &streamid) {
if (!toolkit::start_with(streamid, "#!::")) {
return false;
}
_media_info.schema = SRT_SCHEMA;
_media_info.schema = "srt";
std::string real_streamid = streamid.substr(4);
std::string vhost, app, stream_name;

View File

@ -1258,7 +1258,7 @@ void play_plugin(Session &sender, const WebRtcArgs &args, const WebRtcPluginMana
return;
}
// 还原成rtc目的是为了hook时识别哪种播放协议
info.schema = RTC_SCHEMA;
info.schema = "rtc";
auto rtc = WebRtcPlayer::create(EventPollerPool::Instance().getPoller(), src, info, preferred_tcp);
cb(*rtc);
});