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}
This commit is contained in:
parent
ae049f1924
commit
f6ce1d39ee
@ -490,6 +490,7 @@ if (rtc_include_tests) {
|
|||||||
"../api/task_queue:default_task_queue_factory",
|
"../api/task_queue:default_task_queue_factory",
|
||||||
"../api/test/video:function_video_factory",
|
"../api/test/video:function_video_factory",
|
||||||
"../api/transport:field_trial_based_config",
|
"../api/transport:field_trial_based_config",
|
||||||
|
"../api/units:timestamp",
|
||||||
"../api/video:builtin_video_bitrate_allocator_factory",
|
"../api/video:builtin_video_bitrate_allocator_factory",
|
||||||
"../api/video:video_frame",
|
"../api/video:video_frame",
|
||||||
"../api/video:video_rtp_headers",
|
"../api/video:video_rtp_headers",
|
||||||
|
|||||||
@ -1413,16 +1413,10 @@ void Call::DeliverRtpPacket(
|
|||||||
packet.set_arrival_time(Timestamp::Micros(packet_time_us));
|
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);
|
NotifyBweOfReceivedPacket(packet, media_type);
|
||||||
|
|
||||||
|
event_log_->Log(std::make_unique<RtcEventRtpPacketIncoming>(packet));
|
||||||
if (media_type != MediaType::AUDIO && media_type != MediaType::VIDEO) {
|
if (media_type != MediaType::AUDIO && media_type != MediaType::VIDEO) {
|
||||||
RTC_DCHECK(is_keep_alive_packet);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1443,7 +1437,6 @@ void Call::DeliverRtpPacket(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
event_log_->Log(std::make_unique<RtcEventRtpPacketIncoming>(packet));
|
|
||||||
|
|
||||||
// RateCounters expect input parameter as int, save it as int,
|
// RateCounters expect input parameter as int, save it as int,
|
||||||
// instead of converting each time it is passed to RateCounter::Add below.
|
// instead of converting each time it is passed to RateCounter::Add below.
|
||||||
|
|||||||
@ -18,11 +18,13 @@
|
|||||||
#include "absl/memory/memory.h"
|
#include "absl/memory/memory.h"
|
||||||
#include "absl/strings/string_view.h"
|
#include "absl/strings/string_view.h"
|
||||||
#include "api/audio_codecs/builtin_audio_decoder_factory.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/rtc_event_log/rtc_event_log.h"
|
||||||
#include "api/task_queue/default_task_queue_factory.h"
|
#include "api/task_queue/default_task_queue_factory.h"
|
||||||
#include "api/test/mock_audio_mixer.h"
|
#include "api/test/mock_audio_mixer.h"
|
||||||
#include "api/test/video/function_video_encoder_factory.h"
|
#include "api/test/video/function_video_encoder_factory.h"
|
||||||
#include "api/transport/field_trial_based_config.h"
|
#include "api/transport/field_trial_based_config.h"
|
||||||
|
#include "api/units/timestamp.h"
|
||||||
#include "api/video/builtin_video_bitrate_allocator_factory.h"
|
#include "api/video/builtin_video_bitrate_allocator_factory.h"
|
||||||
#include "audio/audio_receive_stream.h"
|
#include "audio/audio_receive_stream.h"
|
||||||
#include "audio/audio_send_stream.h"
|
#include "audio/audio_send_stream.h"
|
||||||
@ -42,6 +44,7 @@ namespace {
|
|||||||
|
|
||||||
using ::testing::_;
|
using ::testing::_;
|
||||||
using ::testing::Contains;
|
using ::testing::Contains;
|
||||||
|
using ::testing::MockFunction;
|
||||||
using ::testing::NiceMock;
|
using ::testing::NiceMock;
|
||||||
using ::testing::StrictMock;
|
using ::testing::StrictMock;
|
||||||
|
|
||||||
@ -323,6 +326,45 @@ TEST(CallTest, MultipleFlexfecReceiveStreamsProtectingSingleVideoStream) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
TEST(CallTest, RecreatingAudioStreamWithSameSsrcReusesRtpState) {
|
||||||
constexpr uint32_t kSSRC = 12345;
|
constexpr uint32_t kSSRC = 12345;
|
||||||
for (bool use_null_audio_processing : {false, true}) {
|
for (bool use_null_audio_processing : {false, true}) {
|
||||||
|
|||||||
@ -28,7 +28,9 @@ class PacketReceiver {
|
|||||||
using OnUndemuxablePacketHandler =
|
using OnUndemuxablePacketHandler =
|
||||||
absl::AnyInvocable<bool(const RtpPacketReceived& parsed_packet)>;
|
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(
|
virtual void DeliverRtpPacket(
|
||||||
MediaType media_type,
|
MediaType media_type,
|
||||||
RtpPacketReceived packet,
|
RtpPacketReceived packet,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user