RtmpMediaSourceMuxer.h 1.7 KB
Newer Older
1
/*
xiongziliang committed
2
 * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
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.
9
 */
xiongziliang committed
10

11 12
#ifndef ZLMEDIAKIT_RTMPMEDIASOURCEMUXER_H
#define ZLMEDIAKIT_RTMPMEDIASOURCEMUXER_H
xiongziliang committed
13

xiongziliang committed
14
#include "RtmpMuxer.h"
xiongziliang committed
15 16 17 18
#include "Rtmp/RtmpMediaSource.h"

namespace mediakit {

19
class RtmpMediaSourceMuxer : public RtmpMuxer {
xiongziliang committed
20
public:
21 22 23 24 25
    typedef std::shared_ptr<RtmpMediaSourceMuxer> Ptr;

    RtmpMediaSourceMuxer(const string &vhost,
                         const string &strApp,
                         const string &strId,
26
                         const TitleMeta::Ptr &title = nullptr) : RtmpMuxer(title){
27 28 29 30 31 32 33 34
        _mediaSouce = std::make_shared<RtmpMediaSource>(vhost,strApp,strId);
        getRtmpRing()->setDelegate(_mediaSouce);
    }
    virtual ~RtmpMediaSourceMuxer(){}

    void setListener(const std::weak_ptr<MediaSourceEvent> &listener){
        _mediaSouce->setListener(listener);
    }
xiongziliang committed
35

36 37 38 39
    void setTimeStamp(uint32_t stamp){
        _mediaSouce->setTimeStamp(stamp);
    }

40
    int readerCount() const{
41
        return _mediaSouce->readerCount();
42
    }
xiongziliang committed
43 44

    void onAllTrackReady(){
45
        makeConfigPacket();
46
        _mediaSouce->setMetaData(getMetadata());
47
    }
xiongziliang committed
48 49 50 51 52

    // 设置TrackSource
    void setTrackSource(const std::weak_ptr<TrackSource> &track_src){
        _mediaSouce->setTrackSource(track_src);
    }
xiongziliang committed
53
private:
54
    RtmpMediaSource::Ptr _mediaSouce;
xiongziliang committed
55 56
};

57 58 59

}//namespace mediakit
#endif //ZLMEDIAKIT_RTMPMEDIASOURCEMUXER_H