From 2d0cf5cdd9a344a2c0812d72bd64e4b9b94f56a4 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sun, 20 Sep 2020 00:55:22 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3http-ts=E7=9B=B4=E6=92=AD?= =?UTF-8?q?=E4=B8=8Ehls=E7=9B=B4=E6=92=AD=E5=86=B2=E7=AA=81=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Http/HttpSession.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Http/HttpSession.cpp b/src/Http/HttpSession.cpp index 30bd0049..7d50deb9 100644 --- a/src/Http/HttpSession.cpp +++ b/src/Http/HttpSession.cpp @@ -166,15 +166,11 @@ bool HttpSession::checkWebSocket(){ } bool HttpSession::checkLiveStream(const string &schema, const string &url_suffix, const function &cb){ - auto pos = strrchr(_parser.Url().data(), '.'); - if (!pos) { + auto pos = strcasestr(_parser.Url().data(), url_suffix.data()); + if (!pos || pos + url_suffix.size() != 1 + &_parser.Url().back()) { //未找到后缀 return false; } - if (strcasecmp(pos, url_suffix.data()) != 0) { - //未找到直播流后缀 - return false; - } //这是个符合后缀的直播的流 _mediaInfo.parse(schema + "://" + _parser["Host"] + _parser.FullUrl()); @@ -238,10 +234,10 @@ bool HttpSession::checkLiveStream(const string &schema, const string &url_suffi return true; } -//http-ts 链接格式:http://vhost-url:port/app/streamid.ts?key1=value1&key2=value2 +//http-ts 链接格式:http://vhost-url:port/app/streamid.live.ts?key1=value1&key2=value2 //如果url(除去?以及后面的参数)后缀是.ts,那么表明该url是一个http-ts直播。 bool HttpSession::checkLiveStreamTS(const function &cb){ - return checkLiveStream(TS_SCHEMA, ".ts", [this, cb](const MediaSource::Ptr &src) { + return checkLiveStream(TS_SCHEMA, ".live.ts", [this, cb](const MediaSource::Ptr &src) { auto ts_src = dynamic_pointer_cast(src); assert(ts_src); if (!cb) {