From 3a0857ea313b53ccafdc3beda62127c15d1d750e Mon Sep 17 00:00:00 2001 From: alexliyu7352 Date: Wed, 5 Jan 2022 20:01:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BD=93url=E5=B9=B6=E4=B8=8D=E6=98=AFm3u8?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=97=B6,=20=E9=81=BF=E5=85=8D=E6=8B=89?= =?UTF-8?q?=E5=8F=96hls=E6=B5=81=E5=87=BA=E9=94=99=20(#1341)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Http/HlsPlayer.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Http/HlsPlayer.cpp b/src/Http/HlsPlayer.cpp index 246ef8b1..6cb50ba0 100644 --- a/src/Http/HlsPlayer.cpp +++ b/src/Http/HlsPlayer.cpp @@ -169,6 +169,13 @@ ssize_t HlsPlayer::onResponseHeader(const string &status, const HttpClient::Http } auto content_type = const_cast< HttpClient::HttpHeader &>(headers)["Content-Type"]; _is_m3u8 = (content_type.find("application/vnd.apple.mpegurl") == 0); + if(!_is_m3u8) { + auto it = headers.find("Content-Length"); + //如果没有长度或者长度小于等于0, 那么肯定不是m3u8 + if (it == headers.end() || atoll(it->second.data()) <=0) { + teardown_l(SockException(Err_shutdown, "可能不是m3u8文件")); + } + } return -1; }