mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-27 12:45:35 +08:00
[feat] add rtcp thread in rtp video receiver
This commit is contained in:
30
src/rtcp/rtcp_tcc.cpp
Normal file
30
src/rtcp/rtcp_tcc.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#include "rtcp_tcc.h"
|
||||
|
||||
RtcpTcc::RtcpTcc() {
|
||||
buffer_ = new uint8_t[DEFAULT_RR_SIZE];
|
||||
size_ = DEFAULT_RR_SIZE;
|
||||
}
|
||||
|
||||
RtcpTcc::~RtcpTcc() {
|
||||
if (buffer_) {
|
||||
delete buffer_;
|
||||
buffer_ = nullptr;
|
||||
}
|
||||
|
||||
size_ = 0;
|
||||
}
|
||||
|
||||
void RtcpTcc::SetReportBlock(RtcpReportBlock &rtcp_report_block) {
|
||||
reports_.push_back(rtcp_report_block);
|
||||
}
|
||||
|
||||
void RtcpTcc::SetReportBlock(std::vector<RtcpReportBlock> &rtcp_report_blocks) {
|
||||
reports_ = rtcp_report_blocks;
|
||||
}
|
||||
|
||||
const uint8_t *RtcpTcc::Encode() {
|
||||
rtcp_header_.Encode(DEFAULT_RTCP_VERSION, 0, DEFAULT_RR_BLOCK_NUM,
|
||||
RTCP_TYPE::RR, DEFAULT_RR_SIZE, buffer_);
|
||||
|
||||
return buffer_;
|
||||
}
|
||||
77
src/rtcp/rtcp_tcc.h
Normal file
77
src/rtcp/rtcp_tcc.h
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* @Author: DI JUNKUN
|
||||
* @Date: 2024-12-06
|
||||
* Copyright (c) 2024 by DI JUNKUN, All Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _RTCP_TCC_H_
|
||||
#define _RTCP_TCC_H_
|
||||
|
||||
// RR
|
||||
// 0 1 2 3
|
||||
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
// |V=2|P| FMT=15 | PT=205 | length |
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
// | SSRC of packet sender |
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
// | SSRC of media source |
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
// | base sequence number | packet status count |
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
// | reference time | fb pkt. count |
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
// | packet chunk | packet chunk |
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
// . .
|
||||
// . .
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
// | packet chunk | recv delta | recv delta |
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
// . .
|
||||
// . .
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
// | recv delta | recv delta | zero padding |
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
|
||||
// RTP transport sequence number
|
||||
// 0 1 2 3
|
||||
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
// | 0xBE | 0xDE | length=1 |
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
// | ID | L=1 |transport-wide sequence number | zero padding |
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "rtcp_header.h"
|
||||
#include "rtcp_typedef.h"
|
||||
|
||||
class RtcpTcc {
|
||||
public:
|
||||
RtcpTcc();
|
||||
~RtcpTcc();
|
||||
|
||||
public:
|
||||
void SetReportBlock(RtcpReportBlock &rtcp_report_block);
|
||||
void SetReportBlock(std::vector<RtcpReportBlock> &rtcp_report_blocks);
|
||||
|
||||
public:
|
||||
const uint8_t *Encode();
|
||||
size_t Decode();
|
||||
|
||||
// Entire RTP buffer
|
||||
const uint8_t *Buffer() const { return buffer_; }
|
||||
size_t Size() const { return size_; }
|
||||
|
||||
private:
|
||||
RtcpHeader rtcp_header_;
|
||||
std::vector<RtcpReportBlock> reports_;
|
||||
|
||||
// Entire RTCP buffer
|
||||
uint8_t *buffer_ = nullptr;
|
||||
size_t size_ = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user