mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-11-24 00:47:21 +08:00
这个修复是因为有时的可能由于上游网络flow损坏,会导致http-ts拉流时连接不会断开, 只有几kb的速度. 这样实际上流媒体是无法正常播放的, 但是又因为能读取到非常少的数据, 不会触发超时. 等于链接假死在那里了.常见与跨域/跨洲传输时. 所以这个pr就是用于判断如果媒体帧长时间接收不全, 就也应该认为是超时断开. 后面还会提交一个新的pr, 主要是配合这个pr实现"PlayerProxy 无感重连与 muxer 保留策略", 这样就能在遇到坏flow时, 自动重连, 但是播放器无感知, 也不会断开.
57 lines
1.6 KiB
C++
57 lines
1.6 KiB
C++
/*
|
|
* Copyright (c) 2020 The ZLMediaKit project authors. All Rights Reserved.
|
|
* Created by alex on 2021/4/6.
|
|
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
|
*
|
|
* Use of this source code is governed by MIT-like license that can be found in the
|
|
* LICENSE file in the root of the source tree. All contributing project authors
|
|
* may be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
|
|
#ifndef HTTP_TSPLAYER_H
|
|
#define HTTP_TSPLAYER_H
|
|
|
|
#include "HttpTSPlayer.h"
|
|
#include "Player/PlayerBase.h"
|
|
|
|
namespace mediakit {
|
|
|
|
class TsPlayer : public HttpTSPlayer, public PlayerBase {
|
|
public:
|
|
TsPlayer(const toolkit::EventPoller::Ptr &poller);
|
|
|
|
/**
|
|
* 开始播放
|
|
* Start playing
|
|
|
|
* [AUTO-TRANSLATED:53a212c5]
|
|
*/
|
|
void play(const std::string &url) override;
|
|
|
|
size_t getRecvSpeed() override;
|
|
size_t getRecvTotalBytes() override;
|
|
|
|
/**
|
|
* 停止播放
|
|
* Stop playing
|
|
|
|
|
|
* [AUTO-TRANSLATED:db52bf15]
|
|
*/
|
|
void teardown() override;
|
|
|
|
protected:
|
|
void onResponseBody(const char *buf, size_t size) override;
|
|
void onResponseCompleted(const toolkit::SockException &ex) override;
|
|
// 将 HTTP 完成状态转换为播放器最终的 shutdown 状态,确保所有完成回调语义一致。
|
|
// Convert the HTTP completion status to the final player shutdown status so all completion callbacks agree.
|
|
virtual toolkit::SockException translateShutdownException(const toolkit::SockException &ex) { return ex; }
|
|
|
|
private:
|
|
bool _play_result = true;
|
|
bool _benchmark_mode = false;
|
|
};
|
|
|
|
} // namespace mediakit
|
|
#endif // HTTP_TSPLAYER_H
|