Skip to content

Commit

Permalink
Refactor:
Browse files Browse the repository at this point in the history
* rename sender_sink_reciever_source tests
  so as to be able to run it separately

* additional check in sender_sink for
  abs(cts-unix_base) < 1 ms

* revert signature of
 PacketReader::read_nonzero_packet
  • Loading branch information
baranovmv committed Nov 16, 2023
1 parent fc6a280 commit 4585dba
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 22 deletions.
14 changes: 6 additions & 8 deletions src/tests/roc_pipeline/test_helpers/packet_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class PacketReader : public core::NonCopyable<> {

void read_packet(size_t samples_per_packet,
const audio::SampleSpec& sample_spec,
core::nanoseconds_t base_capture_ts = 0) {
core::nanoseconds_t base_capture_ts = -1) {
packet::PacketPtr pp = read_packet_();

audio::sample_t samples[MaxSamples] = {};
Expand All @@ -69,9 +69,9 @@ class PacketReader : public core::NonCopyable<> {
abs_offset_ += samples_per_packet;
}

packet::PacketPtr read_nonzero_packet(size_t samples_per_packet,
const audio::SampleSpec& sample_spec,
core::nanoseconds_t base_capture_ts = 0) {
void read_nonzero_packet(size_t samples_per_packet,
const audio::SampleSpec& sample_spec,
core::nanoseconds_t base_capture_ts = -1) {
packet::PacketPtr pp = read_packet_();

audio::sample_t samples[MaxSamples] = {};
Expand All @@ -86,13 +86,11 @@ class PacketReader : public core::NonCopyable<> {
}
CHECK(non_zero > 0);
abs_offset_ += samples_per_packet;

return pp;
}

void read_zero_packet(size_t samples_per_packet,
const audio::SampleSpec& sample_spec,
core::nanoseconds_t base_capture_ts = 0) {
core::nanoseconds_t base_capture_ts = -1) {
packet::PacketPtr pp = read_packet_();

audio::sample_t samples[MaxSamples] = {};
Expand Down Expand Up @@ -179,7 +177,7 @@ class PacketReader : public core::NonCopyable<> {
core::nanoseconds_t base_ts) {
CHECK(pkt.rtp());

if (base_ts == 0) {
if (base_ts < 0) {
LONGS_EQUAL(0, pkt.rtp()->capture_timestamp);
} else {
const core::nanoseconds_t capture_ts =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,87 +374,87 @@ void send_receive(int flags,

} // namespace

TEST_GROUP(sender_sink_receiver_source) {};
TEST_GROUP(loopback_sink_2_source) {};

TEST(sender_sink_receiver_source, bare_rtp) {
TEST(loopback_sink_2_source, bare_rtp) {
enum { Chans = Chans_Stereo, NumSess = 1 };

send_receive(FlagNone, NumSess, Chans, Chans);
}

TEST(sender_sink_receiver_source, interleaving) {
TEST(loopback_sink_2_source, interleaving) {
enum { Chans = Chans_Stereo, NumSess = 1 };

send_receive(FlagInterleaving, NumSess, Chans, Chans);
}

TEST(sender_sink_receiver_source, fec_rs) {
TEST(loopback_sink_2_source, fec_rs) {
enum { Chans = Chans_Stereo, NumSess = 1 };

if (is_fec_supported(FlagReedSolomon)) {
send_receive(FlagReedSolomon, NumSess, Chans, Chans);
}
}

TEST(sender_sink_receiver_source, fec_ldpc) {
TEST(loopback_sink_2_source, fec_ldpc) {
enum { Chans = Chans_Stereo, NumSess = 1 };

if (is_fec_supported(FlagLDPC)) {
send_receive(FlagLDPC, NumSess, Chans, Chans);
}
}

TEST(sender_sink_receiver_source, fec_interleaving) {
TEST(loopback_sink_2_source, fec_interleaving) {
enum { Chans = Chans_Stereo, NumSess = 1 };

if (is_fec_supported(FlagReedSolomon)) {
send_receive(FlagReedSolomon | FlagInterleaving, NumSess, Chans, Chans);
}
}

TEST(sender_sink_receiver_source, fec_loss) {
TEST(loopback_sink_2_source, fec_loss) {
enum { Chans = Chans_Stereo, NumSess = 1 };

if (is_fec_supported(FlagReedSolomon)) {
send_receive(FlagReedSolomon | FlagLosses, NumSess, Chans, Chans);
}
}

TEST(sender_sink_receiver_source, fec_drop_source) {
TEST(loopback_sink_2_source, fec_drop_source) {
enum { Chans = Chans_Stereo, NumSess = 0 };

if (is_fec_supported(FlagReedSolomon)) {
send_receive(FlagReedSolomon | FlagDropSource, NumSess, Chans, Chans);
}
}

TEST(sender_sink_receiver_source, fec_drop_repair) {
TEST(loopback_sink_2_source, fec_drop_repair) {
enum { Chans = Chans_Stereo, NumSess = 1 };

if (is_fec_supported(FlagReedSolomon)) {
send_receive(FlagReedSolomon | FlagDropRepair, NumSess, Chans, Chans);
}
}

TEST(sender_sink_receiver_source, channel_mapping_stereo_to_mono) {
TEST(loopback_sink_2_source, channel_mapping_stereo_to_mono) {
enum { FrameChans = Chans_Stereo, PacketChans = Chans_Mono, NumSess = 1 };

send_receive(FlagNone, NumSess, FrameChans, PacketChans);
}

TEST(sender_sink_receiver_source, channel_mapping_mono_to_stereo) {
TEST(loopback_sink_2_source, channel_mapping_mono_to_stereo) {
enum { FrameChans = Chans_Mono, PacketChans = Chans_Stereo, NumSess = 1 };

send_receive(FlagNone, NumSess, FrameChans, PacketChans);
}

TEST(sender_sink_receiver_source, timestamp_mapping) {
TEST(loopback_sink_2_source, timestamp_mapping) {
enum { Chans = Chans_Stereo, NumSess = 1 };

send_receive(FlagRTCP | FlagCTS, NumSess, Chans, Chans);
}

TEST(sender_sink_receiver_source, timestamp_mapping_remixing) {
TEST(loopback_sink_2_source, timestamp_mapping_remixing) {
enum { FrameChans = Chans_Mono, PacketChans = Chans_Stereo, NumSess = 1 };

send_receive(FlagRTCP | FlagCTS, NumSess, FrameChans, PacketChans);
Expand Down
3 changes: 2 additions & 1 deletion src/tests/roc_pipeline/test_sender_sink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ TEST(sender_sink, timestamp_mapping) {
packet_reader.read_eof();
}

TEST(sender_sink, timestamp_mapping_remixing_packet_reader) {
TEST(sender_sink, timestamp_mapping_remixing) {
enum {
InputRate = 48000,
PacketRate = 44100,
Expand Down Expand Up @@ -424,6 +424,7 @@ TEST(sender_sink, timestamp_mapping_remixing_packet_reader) {
if (np == 0) {
cts = pp->rtp()->capture_timestamp;
CHECK(cts >= unix_base);
CHECK(cts < unix_base + core::Millisecond);
} else {
test::expect_capture_timestamp(cts, pp->rtp()->capture_timestamp,
packet_sample_spec,
Expand Down

0 comments on commit 4585dba

Please sign in to comment.