增加http代理功能 (#2988)

支持通过http代理拉流, 避免内外网复杂网络环境时需要专门配置防火墙,现在只需要配置一台代理内网的服务器.

---------

Co-authored-by: xia-chu <771730766@qq.com>
This commit is contained in:
alexliyu7352
2023-11-23 11:09:01 +08:00
committed by GitHub
parent a13b8417e5
commit d593267f61
11 changed files with 115 additions and 17 deletions

View File

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