Allow injecting packets of type Any to Call::DeliverRtpPacket
MediaType::Any will be used by packets that can not be demuxed by
RtpTransport.
Bug: webrtc:14928
Change-Id: Ib759e65c7eede29defdad8073fd1ed6be814ab81
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/299280
Commit-Queue: Per Kjellander <perkj@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39710}
diff --git a/call/BUILD.gn b/call/BUILD.gn
index f4c3295..32e5ca6 100644
--- a/call/BUILD.gn
+++ b/call/BUILD.gn
@@ -490,6 +490,7 @@
"../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 ccfed35..b55492e 100644
--- a/call/call.cc
+++ b/call/call.cc
@@ -1413,16 +1413,10 @@
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<RtcEventRtpPacketIncoming>(packet));
if (media_type != MediaType::AUDIO && media_type != MediaType::VIDEO) {
- RTC_DCHECK(is_keep_alive_packet);
return;
}
@@ -1443,7 +1437,6 @@
return;
}
}
- event_log_->Log(std::make_unique<RtcEventRtpPacketIncoming>(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 5db3f59..944006d 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 @@
using ::testing::_;
using ::testing::Contains;
+using ::testing::MockFunction;
using ::testing::NiceMock;
using ::testing::StrictMock;
@@ -323,6 +326,45 @@
}
}
+TEST(CallTest,
+ DeliverRtpPacketOfTypeAudioTriggerOnUndemuxablePacketHandlerIfNotDemuxed) {
+ CallHelper call(/*use_null_audio_processing=*/false);
+ MockFunction<bool(const RtpPacketReceived& parsed_packet)>
+ 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<bool(const RtpPacketReceived& parsed_packet)>
+ 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<bool(const RtpPacketReceived& parsed_packet)>
+ 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 c7f55ac..cdcf7bf 100644
--- a/call/packet_receiver.h
+++ b/call/packet_receiver.h
@@ -28,7 +28,9 @@
using OnUndemuxablePacketHandler =
absl::AnyInvocable<bool(const RtpPacketReceived& parsed_packet)>;
- // 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,