diff --git a/call/BUILD.gn b/call/BUILD.gn index f4c3295ff5..32e5ca6cc2 100644 --- a/call/BUILD.gn +++ b/call/BUILD.gn @@ -490,6 +490,7 @@ if (rtc_include_tests) { "../api/task_queue:default_task_queue_factory", "../api/test/video:function_video_factory", "../api/transport:field_trial_based_config", + "../api/units:timestamp", "../api/video:builtin_video_bitrate_allocator_factory", "../api/video:video_frame", "../api/video:video_rtp_headers", diff --git a/call/call.cc b/call/call.cc index ccfed35785..b55492e53f 100644 --- a/call/call.cc +++ b/call/call.cc @@ -1413,16 +1413,10 @@ void Call::DeliverRtpPacket( packet.set_arrival_time(Timestamp::Micros(packet_time_us)); } - // We might get RTP keep-alive packets in accordance with RFC6263 section 4.6. - // These are empty (zero length payload) RTP packets with an unsignaled - // payload type. - const bool is_keep_alive_packet = packet.payload_size() == 0; - RTC_DCHECK(media_type == MediaType::AUDIO || media_type == MediaType::VIDEO || - is_keep_alive_packet); NotifyBweOfReceivedPacket(packet, media_type); + event_log_->Log(std::make_unique(packet)); if (media_type != MediaType::AUDIO && media_type != MediaType::VIDEO) { - RTC_DCHECK(is_keep_alive_packet); return; } @@ -1443,7 +1437,6 @@ void Call::DeliverRtpPacket( return; } } - event_log_->Log(std::make_unique(packet)); // RateCounters expect input parameter as int, save it as int, // instead of converting each time it is passed to RateCounter::Add below. diff --git a/call/call_unittest.cc b/call/call_unittest.cc index 5db3f5902b..944006d8f2 100644 --- a/call/call_unittest.cc +++ b/call/call_unittest.cc @@ -18,11 +18,13 @@ #include "absl/memory/memory.h" #include "absl/strings/string_view.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" +#include "api/media_types.h" #include "api/rtc_event_log/rtc_event_log.h" #include "api/task_queue/default_task_queue_factory.h" #include "api/test/mock_audio_mixer.h" #include "api/test/video/function_video_encoder_factory.h" #include "api/transport/field_trial_based_config.h" +#include "api/units/timestamp.h" #include "api/video/builtin_video_bitrate_allocator_factory.h" #include "audio/audio_receive_stream.h" #include "audio/audio_send_stream.h" @@ -42,6 +44,7 @@ namespace { using ::testing::_; using ::testing::Contains; +using ::testing::MockFunction; using ::testing::NiceMock; using ::testing::StrictMock; @@ -323,6 +326,45 @@ TEST(CallTest, MultipleFlexfecReceiveStreamsProtectingSingleVideoStream) { } } +TEST(CallTest, + DeliverRtpPacketOfTypeAudioTriggerOnUndemuxablePacketHandlerIfNotDemuxed) { + CallHelper call(/*use_null_audio_processing=*/false); + MockFunction + un_demuxable_packet_handler; + + RtpPacketReceived packet; + packet.set_arrival_time(Timestamp::Millis(1)); + EXPECT_CALL(un_demuxable_packet_handler, Call); + call->Receiver()->DeliverRtpPacket( + MediaType::AUDIO, packet, un_demuxable_packet_handler.AsStdFunction()); +} + +TEST(CallTest, + DeliverRtpPacketOfTypeVideoTriggerOnUndemuxablePacketHandlerIfNotDemuxed) { + CallHelper call(/*use_null_audio_processing=*/false); + MockFunction + un_demuxable_packet_handler; + + RtpPacketReceived packet; + packet.set_arrival_time(Timestamp::Millis(1)); + EXPECT_CALL(un_demuxable_packet_handler, Call); + call->Receiver()->DeliverRtpPacket( + MediaType::VIDEO, packet, un_demuxable_packet_handler.AsStdFunction()); +} + +TEST(CallTest, + DeliverRtpPacketOfTypeAnyDoesNotTriggerOnUndemuxablePacketHandler) { + CallHelper call(/*use_null_audio_processing=*/false); + MockFunction + un_demuxable_packet_handler; + + RtpPacketReceived packet; + packet.set_arrival_time(Timestamp::Millis(1)); + EXPECT_CALL(un_demuxable_packet_handler, Call).Times(0); + call->Receiver()->DeliverRtpPacket( + MediaType::ANY, packet, un_demuxable_packet_handler.AsStdFunction()); +} + TEST(CallTest, RecreatingAudioStreamWithSameSsrcReusesRtpState) { constexpr uint32_t kSSRC = 12345; for (bool use_null_audio_processing : {false, true}) { diff --git a/call/packet_receiver.h b/call/packet_receiver.h index c7f55ac46c..cdcf7bfc73 100644 --- a/call/packet_receiver.h +++ b/call/packet_receiver.h @@ -28,7 +28,9 @@ class PacketReceiver { using OnUndemuxablePacketHandler = absl::AnyInvocable; - // Demux RTP packets. Must be called on the worker thread. + // Must be called on the worker thread. + // If `media_type` is not Audio or Video, packets may be used for BWE + // calculations but are not demuxed. virtual void DeliverRtpPacket( MediaType media_type, RtpPacketReceived packet,