避免hls拉流时m3u8文件出现问题或直播结束后,无限重试 (#2357)

Co-authored-by: xiongziliang <771730766@qq.com>
This commit is contained in:
alexliyu7352
2023-04-05 20:36:44 +08:00
committed by GitHub
parent 21691e34e5
commit 7fcd88d02a
4 changed files with 42 additions and 25 deletions

View File

@@ -36,8 +36,9 @@ typedef struct{
class HlsParser {
public:
HlsParser(){}
~HlsParser(){}
HlsParser() = default;
~HlsParser() = default;
bool parse(const std::string &http_url,const std::string &m3u8);
/**
@@ -79,10 +80,16 @@ public:
* 得到总时间
*/
float getTotalDuration() const;
protected:
//解析出ts文件地址回调
virtual void onParsed(bool is_m3u8_inner,int64_t sequence,const std::map<int,ts_segment> &ts_list) {};
/**
* 解析m3u8文件回调
* @param is_m3u8_inner 该m3u8文件中是否包含多个hls地址
* @param sequence ts序号
* @param ts_list ts地址列表
* @return 是否解析成功返回false时将导致HlsParser::parse返回false
*/
virtual bool onParsed(bool is_m3u8_inner, int64_t sequence, const std::map<int, ts_segment> &ts_list) = 0;
private:
bool _is_m3u8 = false;