Skip to content

Commit

Permalink
Fix sender_sink mapping remixing test.
Browse files Browse the repository at this point in the history
It now follows more relaxed rules for checking capture ts
as presense of a resampler causes unknown initial delay.
  • Loading branch information
baranovmv committed Nov 16, 2023
1 parent 7fef830 commit 141323e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
14 changes: 8 additions & 6 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 = -1) {
core::nanoseconds_t base_capture_ts = 0) {
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;
}

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

audio::sample_t samples[MaxSamples] = {};
Expand All @@ -86,11 +86,13 @@ 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 = -1) {
core::nanoseconds_t base_capture_ts = 0) {
packet::PacketPtr pp = read_packet_();

audio::sample_t samples[MaxSamples] = {};
Expand Down Expand Up @@ -177,7 +179,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
19 changes: 16 additions & 3 deletions src/tests/roc_pipeline/test_sender_sink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,13 +377,15 @@ TEST(sender_sink, timestamp_mapping) {
packet_reader.read_eof();
}

IGNORE_TEST(sender_sink, timestamp_mapping_remixing) {
TEST(sender_sink, timestamp_mapping_remixing_packet_reader) {
enum {
InputRate = 48000,
PacketRate = 44100,
InputChans = Chans_Stereo,
PacketChans = Chans_Mono
};
const core::nanoseconds_t eps_resampled =
core::nanoseconds_t(1.f / PacketRate * core::Second);

init(InputRate, InputChans, PacketRate, PacketChans);

Expand Down Expand Up @@ -415,9 +417,20 @@ IGNORE_TEST(sender_sink, timestamp_mapping_remixing) {
test::PacketReader packet_reader(arena, queue, format_map, packet_factory, dst_addr,
PayloadType_Ch1);

core::nanoseconds_t cts = 0;
for (size_t np = 0; np < ManyFrames / FramesPerPacket - 5; np++) {
packet_reader.read_nonzero_packet(SamplesPerPacket, packet_sample_spec,
unix_base);
packet::PacketPtr pp;
UNSIGNED_LONGS_EQUAL(status::StatusOK, queue.read(pp));
CHECK(pp);

if (np == 0) {
cts = pp->rtp()->capture_timestamp;
CHECK(cts >= unix_base);
} else {
test::expect_capture_timestamp(cts, pp->rtp()->capture_timestamp,
eps_resampled);
}
cts += packet_sample_spec.samples_per_chan_2_ns(pp->rtp()->duration);
}
}

Expand Down

0 comments on commit 141323e

Please sign in to comment.