RtmpDemuxer.h 1.37 KB
Newer Older
xiongziliang committed
1
/*
xiongziliang committed
2
 * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
xiongziliang committed
3 4 5
 *
 * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
 *
xiongziliang committed
6 7 8
 * 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.
xzl committed
9 10
 */

11 12
#ifndef SRC_RTMP_RTMPDEMUXER_H_
#define SRC_RTMP_RTMPDEMUXER_H_
xzl committed
13

xiongzilaing committed
14 15
#include <functional>
#include <unordered_map>
16 17
#include "Rtmp/amf.h"
#include "Rtmp/Rtmp.h"
xzl committed
18
#include "Player/PlayerBase.h"
xiongziliang committed
19 20
#include "Util/TimeTicker.h"
#include "RtmpCodec.h"
xiongzilaing committed
21

xiongziliang committed
22
using namespace toolkit;
23

xiongziliang committed
24
namespace mediakit {
xzl committed
25

26
class RtmpDemuxer : public Demuxer{
xzl committed
27
public:
28
    typedef std::shared_ptr<RtmpDemuxer> Ptr;
29

30
    RtmpDemuxer() = default;
xiongziliang committed
31
    ~RtmpDemuxer() override = default;
32

33
    bool loadMetaData(const AMFValue &metadata);
34

35 36 37 38
    /**
     * 开始解复用
     * @param pkt rtmp包
     */
39
    void inputRtmp(const RtmpPacket::Ptr &pkt);
xiongziliang committed
40

xiongziliang committed
41
private:
42
    void makeVideoTrack(const AMFValue &val);
xiongziliang committed
43
    void makeAudioTrack(const AMFValue &val, int sample_rate, int channels, int sample_bit);
xiongziliang committed
44

xiongziliang committed
45
private:
xiongziliang committed
46 47 48 49
    bool _try_get_video_track = false;
    bool _try_get_audio_track = false;
    RtmpCodec::Ptr _audio_rtmp_decoder;
    RtmpCodec::Ptr _video_rtmp_decoder;
xzl committed
50 51
};

xiongziliang committed
52
} /* namespace mediakit */
xzl committed
53

54
#endif /* SRC_RTMP_RTMPDEMUXER_H_ */