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

11 12
#ifndef ZLMEDIAKIT_RTPSESSION_H
#define ZLMEDIAKIT_RTPSESSION_H
Gemfield committed
13

14
#if defined(ENABLE_RTPPROXY)
Gemfield committed
15 16 17 18 19 20
#include "Network/TcpSession.h"
#include "RtpSplitter.h"
#include "RtpProcess.h"
#include "Util/TimeTicker.h"
using namespace toolkit;

21 22
namespace mediakit{

23
class RtpSession : public TcpSession , public RtpSplitter , public MediaSourceEvent{
Gemfield committed
24
public:
25
    static const string kStreamID;
Gemfield committed
26 27 28 29 30
    RtpSession(const Socket::Ptr &sock);
    ~RtpSession() override;
    void onRecv(const Buffer::Ptr &) override;
    void onError(const SockException &err) override;
    void onManager() override;
31 32
    void attachServer(const TcpServer &server) override;

33 34 35 36 37
protected:
    // 通知其停止推流
    bool close(MediaSource &sender,bool force) override;
    // 观看总人数
    int totalReaderCount(MediaSource &sender) override;
xiongziliang committed
38
    // 收到rtp回调
39
    void onRtpPacket(const char *data, size_t len) override;
40

Gemfield committed
41 42
private:
    Ticker _ticker;
43
    string _stream_id;
xiongziliang committed
44 45
    struct sockaddr addr;
    RtpProcess::Ptr _process;
Gemfield committed
46 47
};

48 49 50
}//namespace mediakit
#endif//defined(ENABLE_RTPPROXY)
#endif //ZLMEDIAKIT_RTPSESSION_H