Skip to content

Commit e62689c

Browse files
committed
Improve pipeline test comments
1 parent 80d32e4 commit e62689c

File tree

9 files changed

+78
-12
lines changed

9 files changed

+78
-12
lines changed

src/tests/roc_pipeline/test_helpers/control_writer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ namespace roc {
2424
namespace pipeline {
2525
namespace test {
2626

27+
// Generates control packets and pass them to destination writer
2728
class ControlWriter : public core::NonCopyable<> {
2829
public:
2930
ControlWriter(packet::IWriter& writer,

src/tests/roc_pipeline/test_helpers/frame_reader.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ namespace roc {
2323
namespace pipeline {
2424
namespace test {
2525

26+
// Read audio frames from source and validate
2627
class FrameReader : public core::NonCopyable<> {
2728
public:
2829
FrameReader(sndio::ISource& source,

src/tests/roc_pipeline/test_helpers/frame_writer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ namespace roc {
2222
namespace pipeline {
2323
namespace test {
2424

25+
// Generate audio frames and write to sink
2526
class FrameWriter : public core::NonCopyable<> {
2627
public:
2728
FrameWriter(sndio::ISink& sink, core::BufferFactory<audio::sample_t>& buffer_factory)

src/tests/roc_pipeline/test_helpers/packet_proxy.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ namespace roc {
2121
namespace pipeline {
2222
namespace test {
2323

24+
// Copy sequence of packets to multiple writers
25+
// Routes packet by type
26+
// Clears packet meta-data as if packet was delivered over network
2427
class PacketProxy : public packet::IWriter, core::NonCopyable<> {
2528
public:
2629
PacketProxy(packet::PacketFactory& packet_factory,
@@ -79,9 +82,10 @@ class PacketProxy : public packet::IWriter, core::NonCopyable<> {
7982
}
8083

8184
private:
82-
// creates a new packet with the same buffer, clearing all meta-information
83-
// like flags, parsed fields, etc; this way we simulate delivering packet
84-
// over network
85+
// creates a new packet with the same buffer, without copying any meta-information
86+
// like flags, parsed fields, etc; this way we simulate that packet was "delivered"
87+
// over network - packets enters receiver's pipeline without any meta-information,
88+
// and receiver fills that meta-information using packet parsers
8589
packet::PacketPtr copy_packet_(const packet::PacketPtr& pa) {
8690
packet::PacketPtr pb = packet_factory_.new_packet();
8791
CHECK(pb);

src/tests/roc_pipeline/test_helpers/packet_reader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace roc {
2727
namespace pipeline {
2828
namespace test {
2929

30-
//! Reads, parses, and validates packets.
30+
// Read, parse, and validates packets
3131
class PacketReader : public core::NonCopyable<> {
3232
public:
3333
PacketReader(core::IArena& arena,

src/tests/roc_pipeline/test_helpers/packet_writer.h

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ namespace roc {
3434
namespace pipeline {
3535
namespace test {
3636

37-
//! Generates and writes packets.
37+
// Generates source and repair packets and pass them to destination writers
3838
class PacketWriter : public core::NonCopyable<> {
3939
public:
40-
//! Initialize without FEC.
40+
// Initialize without FEC (produce only source packets)
4141
PacketWriter(core::IArena& arena,
4242
packet::IWriter& dst_writer,
4343
rtp::FormatMap& format_map,
@@ -63,7 +63,7 @@ class PacketWriter : public core::NonCopyable<> {
6363
packet::FEC_None, fec::WriterConfig());
6464
}
6565

66-
//! Initialize with FEC.
66+
// Initialize with FEC (produce source + repair packets)
6767
PacketWriter(core::IArena& arena,
6868
packet::IWriter& source_dst_writer,
6969
packet::IWriter& repair_dst_writer,
@@ -220,9 +220,12 @@ class PacketWriter : public core::NonCopyable<> {
220220
void deliver_packet_(const packet::PacketPtr& pp) {
221221
if (fec_writer_) {
222222
// fec_writer will produce source and repair packets and store in fec_queue
223+
// note that we're calling copy_packet_() only after fec_writer, because
224+
// fec writer normally lives in the middle of the pipeline and expects
225+
// packets to have all necessary meta-information
223226
fec_writer_->write(pp);
224227

225-
// deliver produced packets
228+
// compose and "deliver" source and repair packets produced by fec_writer
226229
packet::PacketPtr fp;
227230
while (fec_queue_.read(fp) == status::StatusOK) {
228231
if (fp->has_flags(packet::Packet::FlagAudio)) {
@@ -234,14 +237,16 @@ class PacketWriter : public core::NonCopyable<> {
234237
}
235238
}
236239
} else {
240+
// compose and "deliver" packet
237241
CHECK(source_composer_->compose(*pp));
238242
source_writer_->write(copy_packet_(pp));
239243
}
240244
}
241245

242-
// creates a new packet with the same buffer, clearing all meta-information
243-
// like flags, parsed fields, etc; this way we simulate delivering packet
244-
// over network
246+
// creates a new packet with the same buffer, without copying any meta-information
247+
// like flags, parsed fields, etc; this way we simulate that packet was "delivered"
248+
// over network - packets enters receiver's pipeline without any meta-information,
249+
// and receiver fills that meta-information using packet parsers
245250
packet::PacketPtr copy_packet_(const packet::PacketPtr& pa) {
246251
packet::PacketPtr pb = packet_factory_.new_packet();
247252
CHECK(pb);

src/tests/roc_pipeline/test_receiver_source.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,24 @@
2121
#include "roc_pipeline/receiver_source.h"
2222
#include "roc_rtp/format_map.h"
2323

24+
// This file contains tests for ReceiverSource. ReceiverSource can be seen as a big
25+
// composite processor (consisting of chanined smaller processors) that transforms
26+
// network packets into audio frames. Typically, network thread writes packets into
27+
// ReceiverSource, and sound card thread read frames from it.
28+
//
29+
// Each test in this file prepares a sequence of input packets and checks what sequence
30+
// of output frames receiver produces in response. Each test checks one aspect of
31+
// pipeline behavior, e.g. handling packet reordering, recovering lost packets, mixing
32+
// multiple sessions, etc.
33+
//
34+
// The tests mostly use three helper classes:
35+
// - test::PacketWriter - to produce source (RTP) and repair (FEC) packets
36+
// - test::ControlWriter - to produce control packets (RTCP)
37+
// - test::FrameReader - to retrieve and validate audio frames
38+
//
39+
// test::PacketWriter and test::ControlWriter simulate remote sender that produces
40+
// packets, and test::FrameReader simulates local sound card that consumes frames.
41+
2442
namespace roc {
2543
namespace pipeline {
2644

@@ -2059,7 +2077,6 @@ TEST(receiver_source, metrics_truncation) {
20592077

20602078
UNSIGNED_LONGS_EQUAL(2, slot_metrics.num_sessions);
20612079
UNSIGNED_LONGS_EQUAL(2, sess_metrics_size);
2062-
20632080
CHECK(sess_metrics[0].latency.niq_latency > 0);
20642081
CHECK(sess_metrics[1].latency.niq_latency > 0);
20652082
CHECK(sess_metrics[2].latency.niq_latency == 0);

src/tests/roc_pipeline/test_sender_sink.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,22 @@
1919
#include "roc_pipeline/sender_sink.h"
2020
#include "roc_rtp/format_map.h"
2121

22+
// This file contains tests for SenderSink. SenderSink can be seen as a big
23+
// composite processor (consisting of chanined smaller processors) that transforms
24+
// audio frames into network packets. Typically, sound card thread writes frames
25+
// to SenderSink, and it in turn writes packets to network thread.
26+
//
27+
// Each test in this file prepares a sequence of input frames and checks what sequence
28+
// of output packets sender produces in response. Each test checks one aspect of
29+
// pipeline behavior, e.g. splitting frames into packets, transcoding, etc.
30+
//
31+
// The tests mostly use two helper classes:
32+
// - test::FrameWriter - to produce frames
33+
// - test::PacketReader - to retrieve and validate packets
34+
//
35+
// test::FrameWriter simulates local sound card that produces frames, and
36+
// test::PacketReader simulates remote receiver that consumes packets.
37+
2238
namespace roc {
2339
namespace pipeline {
2440

src/tests/roc_pipeline/test_sender_sink_receiver_source.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,27 @@
2626
namespace roc {
2727
namespace pipeline {
2828

29+
// This file contains integration tests that combine SenderSink and ReceiverSource.
30+
//
31+
// SenderSink consumes audio frames and produces network packets. ReceiverSource
32+
// consumes network packets and produces audio frames.
33+
//
34+
// Each test in this file prepares a sequence of input frames, passes it to
35+
// SenderSink, transfers packets produced by SenderSink to ReceiverSource, and
36+
// checks what sequence of output frames ReceiverSource produced in response.
37+
//
38+
// Normally SenderSink and ReceiverSource are not connected directly. We simulate
39+
// delivering packets over network by re-creating packets for receiver with the
40+
// same buffer but with stripped meta-information.
41+
//
42+
// The tests use three helper classes:
43+
// - test::FrameWriter - to produce frames
44+
// - test::PacketProxy - to simulate delivery of packets from sender to receiver
45+
// - test::FrameReader - to retrieve and validate frames
46+
//
47+
// test::FrameWriter simulates sender sound card that produces frames, and
48+
// test::FrameReader simulates receiver sound card that consumes frames.
49+
2950
namespace {
3051

3152
const audio::ChannelMask Chans_Mono = audio::ChanMask_Surround_Mono;

0 commit comments

Comments
 (0)