HttpTSPlayer.h 1.52 KB
Newer Older
1
/*
2 3
 * Copyright (c) 2020 The ZLMediaKit project authors. All Rights Reserved.
 *
4
 * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
5 6 7 8 9 10 11 12 13 14 15 16
 *
 * Use of this source code is governed by MIT 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_HTTPTSPLAYER_H
#define HTTP_HTTPTSPLAYER_H

#include "Http/HttpDownloader.h"
#include "Player/MediaPlayer.h"
#include "Rtp/TSDecoder.h"
17

18 19 20
namespace mediakit {

//http-ts播发器,未实现ts解复用
21
class HttpTSPlayer : public HttpClientImp {
22
public:
23
    using Ptr = std::shared_ptr<HttpTSPlayer>;
夏楚 committed
24
    using onComplete = std::function<void(const toolkit::SockException &)>;
25

26
    HttpTSPlayer(const toolkit::EventPoller::Ptr &poller = nullptr);
27 28 29 30 31 32
    ~HttpTSPlayer() override = default;

    /**
     * 设置下载完毕或异常断开回调
     */
    void setOnComplete(onComplete cb);
33

34 35 36 37
    /**
     * 设置接收ts包回调
     */
    void setOnPacket(TSSegment::onSegment cb);
38 39 40

protected:
    ///HttpClient override///
夏楚 committed
41
    void onResponseHeader(const std::string &status, const HttpHeader &header) override;
42
    void onResponseBody(const char *buf, size_t size) override;
夏楚 committed
43
    void onResponseCompleted(const toolkit::SockException &ex) override;
44 45

private:
夏楚 committed
46
    void emitOnComplete(const toolkit::SockException &ex);
47 48 49

private:
    onComplete _on_complete;
50 51 52 53 54
    TSSegment::onSegment _on_segment;
};

}//namespace mediakit
#endif //HTTP_HTTPTSPLAYER_H