mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-27 04:35:34 +08:00
[fix] fix rtcp common header
This commit is contained in:
@@ -22,8 +22,29 @@ class AudioChannelReceive {
|
||||
public:
|
||||
void Initialize(rtp::PAYLOAD_TYPE payload_type);
|
||||
void Destroy();
|
||||
|
||||
uint32_t GetSsrc() {
|
||||
if (rtp_audio_receiver_) {
|
||||
return rtp_audio_receiver_->GetSsrc();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t GetRemoteSsrc() {
|
||||
if (rtp_audio_receiver_) {
|
||||
return rtp_audio_receiver_->GetRemoteSsrc();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int OnReceiveRtpPacket(const char *data, size_t size);
|
||||
|
||||
void OnSenderReport(int64_t now_time, uint64_t ntp_time) {
|
||||
if (rtp_audio_receiver_) {
|
||||
rtp_audio_receiver_->OnSenderReport(now_time, ntp_time);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<IceAgent> ice_agent_ = nullptr;
|
||||
std::shared_ptr<IOStatistics> ice_io_statistics_ = nullptr;
|
||||
|
||||
@@ -21,6 +21,14 @@ class AudioChannelSend {
|
||||
public:
|
||||
void Initialize(rtp::PAYLOAD_TYPE payload_type);
|
||||
void Destroy();
|
||||
|
||||
uint32_t GetSsrc() {
|
||||
if (rtp_audio_sender_) {
|
||||
return rtp_audio_sender_->GetSsrc();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SendAudio(char *data, size_t size);
|
||||
|
||||
private:
|
||||
|
||||
@@ -21,8 +21,29 @@ class DataChannelReceive {
|
||||
public:
|
||||
void Initialize(rtp::PAYLOAD_TYPE payload_type);
|
||||
void Destroy();
|
||||
|
||||
uint32_t GetSsrc() {
|
||||
if (rtp_data_receiver_) {
|
||||
return rtp_data_receiver_->GetSsrc();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t GetRemoteSsrc() {
|
||||
if (rtp_data_receiver_) {
|
||||
return rtp_data_receiver_->GetRemoteSsrc();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int OnReceiveRtpPacket(const char *data, size_t size);
|
||||
|
||||
void OnSenderReport(int64_t now_time, uint64_t ntp_time) {
|
||||
if (rtp_data_receiver_) {
|
||||
rtp_data_receiver_->OnSenderReport(now_time, ntp_time);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<IceAgent> ice_agent_ = nullptr;
|
||||
std::shared_ptr<IOStatistics> ice_io_statistics_ = nullptr;
|
||||
|
||||
@@ -21,6 +21,14 @@ class DataChannelSend {
|
||||
public:
|
||||
void Initialize(rtp::PAYLOAD_TYPE payload_type);
|
||||
void Destroy();
|
||||
|
||||
uint32_t GetSsrc() {
|
||||
if (rtp_data_sender_) {
|
||||
return rtp_data_sender_->GetSsrc();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SendData(const char *data, size_t size);
|
||||
|
||||
private:
|
||||
|
||||
@@ -29,6 +29,10 @@ class RtpAudioReceiver {
|
||||
std::function<void(const char*, size_t)> on_receive_data) {
|
||||
on_receive_data_ = on_receive_data;
|
||||
}
|
||||
uint32_t GetSsrc() { return ssrc_; }
|
||||
uint32_t GetRemoteSsrc() { return remote_ssrc_; }
|
||||
|
||||
void OnSenderReport(int64_t now_time, uint64_t ntp_time) {}
|
||||
|
||||
private:
|
||||
bool CheckIsTimeSendRR();
|
||||
@@ -46,6 +50,12 @@ class RtpAudioReceiver {
|
||||
uint32_t total_rtp_packets_recv_ = 0;
|
||||
uint32_t last_send_rtcp_rr_packet_ts_ = 0;
|
||||
std::function<int(const char*, size_t)> data_send_func_ = nullptr;
|
||||
|
||||
uint32_t ssrc_ = 0;
|
||||
uint32_t remote_ssrc_ = 0;
|
||||
|
||||
uint32_t last_sr_ = 0;
|
||||
uint32_t last_delay_ = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -24,6 +24,10 @@ class RtpDataReceiver {
|
||||
on_receive_data_ = on_receive_data;
|
||||
}
|
||||
|
||||
uint32_t GetSsrc() { return ssrc_; }
|
||||
uint32_t GetRemoteSsrc() { return remote_ssrc_; }
|
||||
void OnSenderReport(int64_t now_time, uint64_t ntp_time) {}
|
||||
|
||||
private:
|
||||
bool CheckIsTimeSendRR();
|
||||
int SendRtcpRR(ReceiverReport& rtcp_rr);
|
||||
@@ -39,8 +43,13 @@ class RtpDataReceiver {
|
||||
uint32_t total_rtp_payload_recv_ = 0;
|
||||
uint32_t total_rtp_packets_recv_ = 0;
|
||||
|
||||
uint32_t ssrc_ = 0;
|
||||
uint32_t remote_ssrc_ = 0;
|
||||
uint32_t last_send_rtcp_rr_packet_ts_ = 0;
|
||||
std::function<int(const char*, size_t)> data_send_func_ = nullptr;
|
||||
|
||||
uint32_t last_sr_ = 0;
|
||||
uint32_t last_delay_ = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -545,3 +545,32 @@ void RtpVideoReceiver::SendLossNotification(uint16_t last_decoded_seq_num,
|
||||
uint16_t last_received_seq_num,
|
||||
bool decodability_flag,
|
||||
bool buffering_allowed) {}
|
||||
|
||||
inline uint32_t DivideRoundToNearest(int64_t dividend, int64_t divisor) {
|
||||
if (dividend < 0) {
|
||||
int64_t half_of_divisor = divisor / 2;
|
||||
int64_t quotient = dividend / divisor;
|
||||
int64_t remainder = dividend % divisor;
|
||||
if (-remainder > half_of_divisor) {
|
||||
--quotient;
|
||||
}
|
||||
return quotient;
|
||||
}
|
||||
|
||||
int64_t half_of_divisor = (divisor - 1) / 2;
|
||||
int64_t quotient = dividend / divisor;
|
||||
int64_t remainder = dividend % divisor;
|
||||
if (remainder > half_of_divisor) {
|
||||
++quotient;
|
||||
}
|
||||
return quotient;
|
||||
}
|
||||
|
||||
void RtpVideoReceiver::OnSenderReport(int64_t now_time, uint64_t ntp_time) {
|
||||
last_sr_ = ((uint32_t)(ntp_time / 0x100000000) << 16) |
|
||||
((uint32_t)(ntp_time % 0x100000000) >> 16);
|
||||
last_delay_ = DivideRoundToNearest(
|
||||
(clock_->CurrentTime().us() - now_time) * 0x10000, 1000000);
|
||||
|
||||
LOG_WARN("OnSenderReport [{}][{}]", last_sr_, last_delay_);
|
||||
}
|
||||
@@ -43,6 +43,9 @@ class RtpVideoReceiver : public ThreadBase,
|
||||
std::function<void(VideoFrame&)> on_receive_complete_frame) {
|
||||
on_receive_complete_frame_ = on_receive_complete_frame;
|
||||
}
|
||||
uint32_t GetSsrc() { return ssrc_; }
|
||||
uint32_t GetRemoteSsrc() { return remote_ssrc_; }
|
||||
void OnSenderReport(int64_t now_time, uint64_t ntp_time);
|
||||
|
||||
private:
|
||||
void ProcessAv1RtpPacket(RtpPacketAv1& rtp_packet_av1);
|
||||
@@ -114,15 +117,19 @@ class RtpVideoReceiver : public ThreadBase,
|
||||
int rtcp_tcc_interval_ms_ = 200;
|
||||
|
||||
private:
|
||||
uint32_t ssrc_ = 0;
|
||||
uint32_t remote_ssrc_ = 0;
|
||||
std::shared_ptr<webrtc::Clock> clock_;
|
||||
ReceiveSideCongestionController receive_side_congestion_controller_;
|
||||
RtcpFeedbackSenderInterface* active_remb_module_;
|
||||
uint32_t feedback_ssrc_ = 0;
|
||||
uint32_t remote_ssrc_ = 0;
|
||||
|
||||
std::unique_ptr<RtcpSender> rtcp_sender_;
|
||||
std::unique_ptr<NackRequester> nack_;
|
||||
|
||||
uint32_t last_sr_ = 0;
|
||||
uint32_t last_delay_ = 0;
|
||||
|
||||
private:
|
||||
FILE* file_rtp_recv_ = nullptr;
|
||||
};
|
||||
|
||||
@@ -118,18 +118,7 @@ int RtpVideoSender::SendRtpPacket(
|
||||
rtcp_sr.SetSenderPacketCount(total_rtp_packets_sent_);
|
||||
rtcp_sr.SetSenderOctetCount(total_rtp_payload_sent_);
|
||||
|
||||
RtcpReportBlock report;
|
||||
report.SetMediaSsrc(ssrc_);
|
||||
report.SetFractionLost(0);
|
||||
report.SetCumulativeLost(0);
|
||||
report.SetJitter(0);
|
||||
report.SetLastSr(0);
|
||||
report.SetExtHighestSeqNum(0);
|
||||
report.SetDelayLastSr(0);
|
||||
|
||||
rtcp_sr.SetReportBlock(report);
|
||||
rtcp_sr.Create();
|
||||
|
||||
rtcp_sr.Build();
|
||||
SendRtcpSR(rtcp_sr);
|
||||
}
|
||||
|
||||
|
||||
@@ -64,4 +64,4 @@ int VideoChannelReceive::OnReceiveRtpPacket(const char *data, size_t size) {
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,8 +25,28 @@ class VideoChannelReceive {
|
||||
void Initialize(rtp::PAYLOAD_TYPE payload_type);
|
||||
void Destroy();
|
||||
|
||||
uint32_t GetSsrc() {
|
||||
if (rtp_video_receiver_) {
|
||||
return rtp_video_receiver_->GetSsrc();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t GetRemoteSsrc() {
|
||||
if (rtp_video_receiver_) {
|
||||
return rtp_video_receiver_->GetRemoteSsrc();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int OnReceiveRtpPacket(const char *data, size_t size);
|
||||
|
||||
void OnSenderReport(int64_t now_time, uint64_t ntp_time) {
|
||||
if (rtp_video_receiver_) {
|
||||
rtp_video_receiver_->OnSenderReport(now_time, ntp_time);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<IceAgent> ice_agent_ = nullptr;
|
||||
std::shared_ptr<IOStatistics> ice_io_statistics_ = nullptr;
|
||||
|
||||
@@ -32,6 +32,13 @@ class VideoChannelSend {
|
||||
void Initialize(rtp::PAYLOAD_TYPE payload_type);
|
||||
void Destroy();
|
||||
|
||||
uint32_t GetSsrc() {
|
||||
if (rtp_video_sender_) {
|
||||
return rtp_video_sender_->GetSsrc();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SendVideo(std::shared_ptr<VideoFrameWrapper> encoded_frame);
|
||||
|
||||
void OnCongestionControlFeedback(
|
||||
|
||||
Reference in New Issue
Block a user