|
6 | 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
7 | 7 | */
|
8 | 8 |
|
| 9 | +#include "roc_core/log.h" |
| 10 | +#include "roc_fec/block_writer.h" |
9 | 11 | #include "test_harness.h"
|
10 | 12 | #include "test_helpers/control_reader.h"
|
11 | 13 | #include "test_helpers/control_writer.h"
|
|
20 | 22 | #include "roc_pipeline/receiver_source.h"
|
21 | 23 | #include "roc_rtp/encoding_map.h"
|
22 | 24 | #include "roc_stat/mov_aggregate.h"
|
| 25 | +#include <CppUTest/UtestMacros.h> |
23 | 26 |
|
24 | 27 | // This file contains tests for ReceiverSource. ReceiverSource can be seen as a big
|
25 | 28 | // composite processor (consisting of chained smaller processors) that transforms
|
@@ -3400,64 +3403,37 @@ TEST(receiver_source, timestamp_mapping_remixing) {
|
3400 | 3403 | }
|
3401 | 3404 |
|
3402 | 3405 | TEST(receiver_source, packet_buffer) {
|
3403 |
| - enum { |
3404 |
| - OutputRate = 48000, |
3405 |
| - PacketRate = 44100, |
3406 |
| - OutputChans = Chans_Stereo, |
3407 |
| - PacketChans = Chans_Mono |
3408 |
| - }; |
3409 |
| - |
3410 |
| - const audio::PcmSubformat OutputFormat = Format_S16_Ne; |
3411 |
| - const audio::PcmSubformat PacketFormat = Format_S16_Be; |
3412 |
| - |
3413 |
| - init_with_specs(OutputRate, OutputChans, OutputFormat, PacketRate, PacketChans, |
3414 |
| - PacketFormat); |
| 3406 | + init_with_defaults(); |
3415 | 3407 |
|
3416 | 3408 | ReceiverSource receiver(make_default_config(), processor_map, encoding_map,
|
3417 | 3409 | packet_pool, packet_buffer_pool, frame_pool,
|
3418 | 3410 | frame_buffer_pool, arena);
|
3419 | 3411 | LONGS_EQUAL(status::StatusOK, receiver.init_status());
|
3420 | 3412 |
|
3421 | 3413 | ReceiverSlot* slot = create_slot(receiver);
|
3422 |
| - CHECK(slot); |
3423 | 3414 |
|
3424 |
| - packet::FifoQueue queue; |
3425 | 3415 | packet::FifoQueue source_queue;
|
3426 | 3416 | packet::FifoQueue repair_queue;
|
3427 | 3417 |
|
3428 | 3418 | packet::IWriter* source_endpoint_writer = create_transport_endpoint(
|
3429 | 3419 | slot, address::Iface_AudioSource, address::Proto_RTP_RS8M_Source, dst_addr1);
|
3430 | 3420 |
|
3431 |
| - packet::IWriter* repair_endpoint_writer = create_transport_endpoint( |
3432 |
| - slot, address::Iface_AudioRepair, address::Proto_RS8M_Repair, dst_addr2); |
3433 |
| - |
3434 |
| - fec::BlockWriterConfig fec_config; |
| 3421 | + packet::IWriter* repair_endpoint_writer = |
| 3422 | + create_control_endpoint(slot, address::Iface_AudioRepair, |
| 3423 | + address::Proto_RS8M_Repair, dst_addr2, repair_queue); |
3435 | 3424 |
|
3436 |
| - test::PacketWriter packet_writer( |
3437 |
| - arena, *source_endpoint_writer, *repair_endpoint_writer, encoding_map, |
3438 |
| - packet_factory, src_id1, src_addr1, dst_addr1, dst_addr2, PayloadType_Ch2, |
3439 |
| - packet::FEC_ReedSolomon_M8, fec_config); |
| 3425 | + test::PacketWriter packet_writer(arena, *source_endpoint_writer, |
| 3426 | + *repair_endpoint_writer, encoding_map, |
| 3427 | + packet_factory, src_id1, src_addr1, dst_addr1, |
| 3428 | + dst_addr2, PayloadType_Ch2, fec_scheme, fec_config); |
3440 | 3429 |
|
3441 | 3430 | // setup reader
|
3442 | 3431 | test::FrameReader frame_reader(receiver, frame_factory);
|
3443 | 3432 |
|
3444 |
| - packet_writer.write_packets(fec_config.n_source_packets, SamplesPerPacket, |
3445 |
| - output_sample_spec); |
3446 |
| - |
3447 |
| - for (int i = 0; i < ManyPackets; ++i) { |
3448 |
| - packet::PacketPtr pp; |
3449 |
| - LONGS_EQUAL(status::StatusOK, queue.read(pp, packet::ModeFetch)); |
3450 |
| - CHECK(pp); |
3451 |
| - |
3452 |
| - if (pp->flags() & packet::Packet::FlagAudio) { |
3453 |
| - UNSIGNED_LONGS_EQUAL(status::StatusOK, source_queue.write(pp)); |
3454 |
| - } |
3455 |
| - if (pp->flags() & packet::Packet::FlagRepair) { |
3456 |
| - UNSIGNED_LONGS_EQUAL(status::StatusOK, repair_queue.write(pp)); |
3457 |
| - } |
3458 |
| - } |
| 3433 | + packet_writer.write_packets(Latency / SamplesPerPacket, SamplesPerPacket, |
| 3434 | + packet_sample_spec); |
3459 | 3435 |
|
3460 |
| - LONGS_EQUAL(status::StatusOK, receiver.refresh(frame_reader.refresh_ts(), NULL)); |
| 3436 | + refresh_source(receiver, frame_reader.refresh_ts()); |
3461 | 3437 | frame_reader.read_nonzero_samples(SamplesPerFrame, output_sample_spec);
|
3462 | 3438 | UNSIGNED_LONGS_EQUAL(1, receiver.num_sessions());
|
3463 | 3439 | }
|
|
0 commit comments