RTPReceiver2.h 809 Bytes
#ifndef _RTP_RECEIVER_H_
#define _RTP_RECEIVER_H_

#include <stdint.h>
#include <atomic>
#include <thread>

using namespace std;


class RTPReceiver2{

public:
    RTPReceiver2();
    virtual ~RTPReceiver2();

	int init(const char* ip, uint16_t port, bool isUdp);

	void RequestStreamFailed();

	int allocRtpPort();

private:
	int startUdpServer(const char* ip, uint16_t port);
	int startTcpServer(const char* ip, uint16_t port);

	void parseTcpData(char* recvBuf, int recvBufSize);

public:
    uint8_t* mRecvCache {nullptr};
	uint64_t mRecvCacheSize {0};

	uint8_t* mRecvRtpBuffer {nullptr};    // 从mRecvCache提取出来的rtp字节流
	int16_t  mRecvRtpBufferSize {0};// 从mRecvCache提取出来的rtp字节流总长度 (rtpHeader+rtpBody)

	bool m_bRtpExit {false};
};

#endif  // _RTP_RECEIVER_H_