[feat] support FIR

This commit is contained in:
dijunkun
2025-03-07 18:36:55 +08:00
parent 19fc8cda89
commit de0386f08a
21 changed files with 247 additions and 32 deletions

View File

@@ -241,6 +241,9 @@ bool IceTransport::ParseRtcpPacket(const uint8_t *buffer, size_t size,
case webrtc::rtcp::Nack::kFeedbackMessageType:
valid = HandleNack(rtcp_block, rtcp_packet_info);
break;
case webrtc::rtcp::Fir::kFeedbackMessageType:
valid = HandleFir(rtcp_block, rtcp_packet_info);
break;
default:
break;
}
@@ -408,6 +411,21 @@ bool IceTransport::HandleNack(const RtcpCommonHeader &rtcp_block,
return true;
}
bool IceTransport::HandleFir(const RtcpCommonHeader &rtcp_block,
RtcpPacketInfo *rtcp_packet_info) {
webrtc::rtcp::Fir fir;
if (!fir.Parse(rtcp_block)) {
return false;
}
if (ice_transport_controller_) {
ice_transport_controller_->FullIntraRequest();
return true;
}
return false;
}
int IceTransport::DestroyIceTransmission() {
LOG_INFO("[{}->{}] Destroy ice transmission", user_id_, remote_user_id_);
is_closed_ = true;

View File

@@ -146,6 +146,9 @@ class IceTransport {
bool HandleNack(const RtcpCommonHeader &rtcp_block,
RtcpPacketInfo *rtcp_packet_info);
bool HandleFir(const RtcpCommonHeader &rtcp_block,
RtcpPacketInfo *rtcp_packet_info);
private:
bool hardware_acceleration_ = false;
bool use_trickle_ice_ = true;

View File

@@ -462,13 +462,16 @@ void IceTransportController::PostUpdates(webrtc::NetworkControlUpdate update) {
if (target_bitrate != target_bitrate_) {
target_bitrate_ = target_bitrate;
int width, height, target_width, target_height;
video_encoder_->GetResolution(width, height);
video_encoder_->GetResolution(&width, &height);
if (0 == resolution_adapter_->GetResolution(target_bitrate_, width, height,
target_width, target_height)) {
&target_width,
&target_height)) {
if (target_width != target_width_ || target_height != target_height_) {
target_width_ = target_width;
target_height_ = target_height;
b_force_i_frame_ = true;
LOG_WARN("Set target resolution [{}x{}]", target_width_.value(),
target_height_.value());
}
@@ -479,7 +482,7 @@ void IceTransportController::PostUpdates(webrtc::NetworkControlUpdate update) {
source_height_);
}
video_encoder_->SetTargetBitrate(target_bitrate_);
// LOG_WARN("Set target bitrate [{}]bps", target_bitrate_);
LOG_WARN("Set target bitrate [{}]bps", target_bitrate_);
}
}

View File

@@ -53,6 +53,8 @@ class IceTransportController
int SendAudio(const char *data, size_t size);
int SendData(const char *data, size_t size);
void FullIntraRequest() { b_force_i_frame_ = true; }
int OnReceiveVideoRtpPacket(const char *data, size_t size);
int OnReceiveAudioRtpPacket(const char *data, size_t size);
int OnReceiveDataRtpPacket(const char *data, size_t size);