RtspMediaSourceMuxer.h 1.66 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_RTSPMEDIASOURCEMUXER_H
#define ZLMEDIAKIT_RTSPMEDIASOURCEMUXER_H
xiongziliang committed
13

xiongziliang committed
14
#include "RtspMuxer.h"
xiongziliang committed
15 16 17 18
#include "Rtsp/RtspMediaSource.h"

namespace mediakit {

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

    RtspMediaSourceMuxer(const string &vhost,
                         const string &strApp,
                         const string &strId,
26 27
                         const TitleSdp::Ptr &title = nullptr) : RtspMuxer(title){
        _mediaSouce = std::make_shared<RtspMediaSource>(vhost,strApp,strId);
28 29 30 31 32 33 34
        getRtpRing()->setDelegate(_mediaSouce);
    }
    virtual ~RtspMediaSourceMuxer(){}

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

36
    int readerCount() const{
37
        return _mediaSouce->readerCount();
38
    }
xiongziliang committed
39

xiongziliang committed
40 41
    void setTimeStamp(uint32_t stamp){
        _mediaSouce->setTimeStamp(stamp);
42
    }
xiongziliang committed
43 44

    void onAllTrackReady(){
45
        _mediaSouce->setSdp(getSdp());
46
    }
xiongziliang committed
47 48 49 50 51

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

56 57 58

}//namespace mediakit
#endif //ZLMEDIAKIT_RTSPMEDIASOURCEMUXER_H