Index: webrtc/call/call.cc |
diff --git a/webrtc/call/call.cc b/webrtc/call/call.cc |
index 37b5c6a4fbf5fef7683d9b6eea3f6e08c1b7fff6..6aa564e95e96694eadb562aa93fd18917f9fe93e 100644 |
--- a/webrtc/call/call.cc |
+++ b/webrtc/call/call.cc |
@@ -109,6 +109,8 @@ |
// Implements RecoveredPacketReceiver. |
bool OnRecoveredPacket(const uint8_t* packet, size_t length) override; |
+ void NotifyBweOfReceivedPacket(const RtpPacketReceived& packet); |
+ |
void SetBitrateConfig( |
const webrtc::Call::Config::BitrateConfig& bitrate_config) override; |
@@ -142,9 +144,6 @@ |
const PacketTime& packet_time); |
void ConfigureSync(const std::string& sync_group) |
EXCLUSIVE_LOCKS_REQUIRED(receive_crit_); |
- |
- void NotifyBweOfReceivedPacket(const RtpPacketReceived& packet) |
- SHARED_LOCKS_REQUIRED(receive_crit_); |
rtc::Optional<RtpPacketReceived> ParseRtpPacket(const uint8_t* packet, |
size_t length, |
@@ -189,27 +188,12 @@ |
std::map<std::string, AudioReceiveStream*> sync_stream_mapping_ |
GUARDED_BY(receive_crit_); |
- // This extra map is used for receive processing which is |
- // independent of media type. |
- |
- // TODO(nisse): In the RTP transport refactoring, we should have a |
- // single mapping from ssrc to a more abstract receive stream, with |
- // accessor methods for all configuration we need at this level. |
- struct ReceiveRtpConfig { |
- ReceiveRtpConfig() = default; // Needed by std::map |
- ReceiveRtpConfig(const std::vector<RtpExtension>& extensions, |
- bool transport_cc) |
- : extensions(extensions), transport_cc(transport_cc) {} |
- |
- // Registered RTP header extensions for each stream. Note that RTP header |
- // extensions are negotiated per track ("m= line") in the SDP, but we have |
- // no notion of tracks at the Call level. We therefore store the RTP header |
- // extensions per SSRC instead, which leads to some storage overhead. |
- RtpHeaderExtensionMap extensions; |
- // Set if the RTCP feedback message needed for send side BWE was negotiated. |
- bool transport_cc; |
- }; |
- std::map<uint32_t, ReceiveRtpConfig> receive_rtp_config_ |
+ // Registered RTP header extensions for each stream. |
+ // Note that RTP header extensions are negotiated per track ("m= line") in the |
+ // SDP, but we have no notion of tracks at the Call level. We therefore store |
+ // the RTP header extensions per SSRC instead, which leads to some storage |
+ // overhead. |
+ std::map<uint32_t, RtpHeaderExtensionMap> received_rtp_header_extensions_ |
GUARDED_BY(receive_crit_); |
std::unique_ptr<RWLockWrapper> send_crit_; |
@@ -373,9 +357,9 @@ |
if (!parsed_packet.Parse(packet, length)) |
return rtc::Optional<RtpPacketReceived>(); |
- auto it = receive_rtp_config_.find(parsed_packet.Ssrc()); |
- if (it != receive_rtp_config_.end()) |
- parsed_packet.IdentifyExtensions(it->second.extensions); |
+ auto it = received_rtp_header_extensions_.find(parsed_packet.Ssrc()); |
+ if (it != received_rtp_header_extensions_.end()) |
+ parsed_packet.IdentifyExtensions(it->second); |
int64_t arrival_time_ms; |
if (packet_time.timestamp != -1) { |
@@ -525,6 +509,7 @@ |
event_log_->LogAudioReceiveStreamConfig(config); |
AudioReceiveStream* receive_stream = new AudioReceiveStream( |
&packet_router_, |
+ // TODO(nisse): Used only when UseSendSideBwe(config) is true. |
congestion_controller_->GetRemoteBitrateEstimator(true), config, |
config_.audio_state, event_log_); |
{ |
@@ -532,9 +517,6 @@ |
RTC_DCHECK(audio_receive_ssrcs_.find(config.rtp.remote_ssrc) == |
audio_receive_ssrcs_.end()); |
audio_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; |
- receive_rtp_config_[config.rtp.remote_ssrc] = |
- ReceiveRtpConfig(config.rtp.extensions, config.rtp.transport_cc); |
- |
ConfigureSync(config.sync_group); |
} |
{ |
@@ -558,9 +540,8 @@ |
static_cast<webrtc::internal::AudioReceiveStream*>(receive_stream); |
{ |
WriteLockScoped write_lock(*receive_crit_); |
- uint32_t ssrc = audio_receive_stream->config().rtp.remote_ssrc; |
- |
- size_t num_deleted = audio_receive_ssrcs_.erase(ssrc); |
+ size_t num_deleted = audio_receive_ssrcs_.erase( |
+ audio_receive_stream->config().rtp.remote_ssrc); |
RTC_DCHECK(num_deleted == 1); |
const std::string& sync_group = audio_receive_stream->config().sync_group; |
const auto it = sync_stream_mapping_.find(sync_group); |
@@ -569,7 +550,6 @@ |
sync_stream_mapping_.erase(it); |
ConfigureSync(sync_group); |
} |
- receive_rtp_config_.erase(ssrc); |
} |
UpdateAggregateNetworkState(); |
delete audio_receive_stream; |
@@ -662,22 +642,13 @@ |
call_stats_.get(), &remb_); |
const webrtc::VideoReceiveStream::Config& config = receive_stream->config(); |
- ReceiveRtpConfig receive_config(config.rtp.extensions, |
- config.rtp.transport_cc); |
{ |
WriteLockScoped write_lock(*receive_crit_); |
RTC_DCHECK(video_receive_ssrcs_.find(config.rtp.remote_ssrc) == |
video_receive_ssrcs_.end()); |
video_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; |
- if (config.rtp.rtx_ssrc) { |
+ if (config.rtp.rtx_ssrc) |
video_receive_ssrcs_[config.rtp.rtx_ssrc] = receive_stream; |
- // We record identical config for the rtx stream as for the main |
- // stream. Since the transport_cc negotiation is per payload |
- // type, we may get an incorrect value for the rtx stream, but |
- // that is unlikely to matter in practice. |
- receive_rtp_config_[config.rtp.rtx_ssrc] = receive_config; |
- } |
- receive_rtp_config_[config.rtp.remote_ssrc] = receive_config; |
video_receive_streams_.insert(receive_stream); |
ConfigureSync(config.sync_group); |
} |
@@ -703,8 +674,7 @@ |
if (receive_stream_impl != nullptr) |
RTC_DCHECK(receive_stream_impl == it->second); |
receive_stream_impl = it->second; |
- receive_rtp_config_.erase(it->first); |
- it = video_receive_ssrcs_.erase(it); |
+ video_receive_ssrcs_.erase(it++); |
} else { |
++it; |
} |
@@ -741,10 +711,10 @@ |
flexfec_receive_ssrcs_protection_.end()); |
flexfec_receive_ssrcs_protection_[config.remote_ssrc] = receive_stream; |
- RTC_DCHECK(receive_rtp_config_.find(config.remote_ssrc) == |
- receive_rtp_config_.end()); |
- receive_rtp_config_[config.remote_ssrc] = |
- ReceiveRtpConfig(config.rtp_header_extensions, config.transport_cc); |
+ RTC_DCHECK(received_rtp_header_extensions_.find(config.remote_ssrc) == |
+ received_rtp_header_extensions_.end()); |
+ RtpHeaderExtensionMap rtp_header_extensions(config.rtp_header_extensions); |
+ received_rtp_header_extensions_[config.remote_ssrc] = rtp_header_extensions; |
} |
// TODO(brandtr): Store config in RtcEventLog here. |
@@ -765,7 +735,7 @@ |
WriteLockScoped write_lock(*receive_crit_); |
uint32_t ssrc = receive_stream_impl->GetConfig().remote_ssrc; |
- receive_rtp_config_.erase(ssrc); |
+ received_rtp_header_extensions_.erase(ssrc); |
// Remove all SSRCs pointing to the FlexfecReceiveStreamImpl to be |
// destroyed. |
@@ -1138,20 +1108,12 @@ |
size_t length, |
const PacketTime& packet_time) { |
TRACE_EVENT0("webrtc", "Call::DeliverRtp"); |
- |
+ // Minimum RTP header size. |
+ if (length < 12) |
+ return DELIVERY_PACKET_ERROR; |
+ |
+ uint32_t ssrc = ByteReader<uint32_t>::ReadBigEndian(&packet[8]); |
ReadLockScoped read_lock(*receive_crit_); |
- // TODO(nisse): We should parse the RTP header only here, and pass |
- // on parsed_packet to the receive streams. |
- rtc::Optional<RtpPacketReceived> parsed_packet = |
- ParseRtpPacket(packet, length, packet_time); |
- |
- if (!parsed_packet) |
- return DELIVERY_PACKET_ERROR; |
- |
- NotifyBweOfReceivedPacket(*parsed_packet); |
- |
- uint32_t ssrc = parsed_packet->Ssrc(); |
- |
if (media_type == MediaType::ANY || media_type == MediaType::AUDIO) { |
auto it = audio_receive_ssrcs_.find(ssrc); |
if (it != audio_receive_ssrcs_.end()) { |
@@ -1178,6 +1140,8 @@ |
// not be parsed, as FlexFEC is oblivious to the semantic meaning of the |
// packet contents beyond the 12 byte RTP base header. The BWE is fed |
// information about these media packets from the regular media pipeline. |
+ rtc::Optional<RtpPacketReceived> parsed_packet = |
+ ParseRtpPacket(packet, length, packet_time); |
if (parsed_packet) { |
auto it_bounds = flexfec_receive_ssrcs_media_.equal_range(ssrc); |
for (auto it = it_bounds.first; it != it_bounds.second; ++it) |
@@ -1191,7 +1155,10 @@ |
if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { |
auto it = flexfec_receive_ssrcs_protection_.find(ssrc); |
if (it != flexfec_receive_ssrcs_protection_.end()) { |
+ rtc::Optional<RtpPacketReceived> parsed_packet = |
+ ParseRtpPacket(packet, length, packet_time); |
if (parsed_packet) { |
+ NotifyBweOfReceivedPacket(*parsed_packet); |
auto status = it->second->AddAndProcessReceivedPacket(*parsed_packet) |
? DELIVERY_OK |
: DELIVERY_PACKET_ERROR; |
@@ -1231,21 +1198,8 @@ |
} |
void Call::NotifyBweOfReceivedPacket(const RtpPacketReceived& packet) { |
- auto it = receive_rtp_config_.find(packet.Ssrc()); |
- bool transport_cc = |
- (it != receive_rtp_config_.end()) && it->second.transport_cc; |
- |
RTPHeader header; |
packet.GetHeader(&header); |
- |
- // transport_cc represents the negotiation of the RTCP feedback |
- // message used for send side BWE. If it was negotiated but the |
- // corresponding RTP header extension is not present, or vice versa, |
- // bandwidth estimation is not correctly configured. |
- if (transport_cc != header.extension.hasTransportSequenceNumber) { |
- LOG(LS_ERROR) << "Inconsistent configuration of send side BWE."; |
- return; |
- } |
congestion_controller_->OnReceivedPacket(packet.arrival_time_ms(), |
packet.payload_size(), header); |
} |