优化hls播放器,使用持久化连接 (#3070)

hls播放时,如果对方reset断开了tcp连接,应该自动发起重连
This commit is contained in:
alexliyu7352
2023-12-01 17:56:08 +08:00
committed by GitHub
parent 50281513d9
commit 4648c156c8
7 changed files with 176 additions and 102 deletions

View File

@@ -23,6 +23,7 @@ void HlsPlayer::play(const string &url) {
_play_result = false;
_play_url = url;
setProxyUrl((*this)[Client::kProxyUrl]);
setAllowResendRequest(true);
fetchIndexFile();
}
@@ -99,6 +100,7 @@ void HlsPlayer::fetchSegment() {
if (!_http_ts_player) {
_http_ts_player = std::make_shared<HttpTSPlayer>(getPoller());
_http_ts_player->setProxyUrl((*this)[Client::kProxyUrl]);
_http_ts_player->setAllowResendRequest(true);
_http_ts_player->setOnCreateSocket([weak_self](const EventPoller::Ptr &poller) {
auto strong_self = weak_self.lock();
if (strong_self) {