From 434ea853475a2c1410438999df2693afbfb8e3f0 Mon Sep 17 00:00:00 2001 From: Sayed Murtadha Ahmed Date: Sun, 22 Dec 2024 18:22:37 +0300 Subject: [PATCH] refactor(766): refactored boolean returns to status code in IComposer --- src/internal_modules/roc_audio/packetizer.cpp | 8 ++-- src/internal_modules/roc_fec/block_writer.cpp | 25 ++++++------ src/internal_modules/roc_fec/composer.h | 28 +++++++------ src/internal_modules/roc_packet/icomposer.h | 8 ++-- src/internal_modules/roc_packet/shipper.cpp | 2 +- .../roc_rtcp/communicator.cpp | 5 ++- src/internal_modules/roc_rtcp/composer.cpp | 30 +++++++------- src/internal_modules/roc_rtcp/composer.h | 8 ++-- src/internal_modules/roc_rtp/composer.cpp | 40 ++++++++++--------- src/internal_modules/roc_rtp/composer.h | 8 ++-- src/tests/roc_audio/test_depacketizer.cpp | 5 ++- .../roc_fec/test_block_writer_reader.cpp | 6 +-- .../test_block_writer_reader_duration.cpp | 3 +- .../test_block_writer_reader_errors.cpp | 3 +- .../roc_fec/test_block_writer_reader_peek.cpp | 3 +- src/tests/roc_fec/test_composer.cpp | 12 +++--- src/tests/roc_fec/test_composer_parser.cpp | 9 +++-- src/tests/roc_packet/test_shipper.cpp | 17 ++++---- .../roc_pipeline/test_helpers/packet_writer.h | 9 +++-- src/tests/roc_rtp/test_packet_formats.cpp | 5 ++- 20 files changed, 125 insertions(+), 109 deletions(-) diff --git a/src/internal_modules/roc_audio/packetizer.cpp b/src/internal_modules/roc_audio/packetizer.cpp index 82618b85f..caa6eb028 100644 --- a/src/internal_modules/roc_audio/packetizer.cpp +++ b/src/internal_modules/roc_audio/packetizer.cpp @@ -196,9 +196,10 @@ status::StatusCode Packetizer::create_packet_() { return status::StatusNoMem; } - if (!composer_.prepare(*pp, buffer, payload_size_)) { + status::StatusCode status = composer_.prepare(*pp, buffer, payload_size_); + if (status != status::StatusOK) { roc_log(LogError, "packetizer: can't prepare packet"); - return status::StatusNoMem; + return status; } pp->add_flags(packet::Packet::FlagPrepared); @@ -213,7 +214,8 @@ void Packetizer::pad_packet_(size_t written_payload_size) { return; } - if (!composer_.pad(*packet_, payload_size_ - written_payload_size)) { + if (composer_.pad(*packet_, payload_size_ - written_payload_size) + != status::StatusOK) { roc_panic("packetizer: can't pad packet: orig_size=%lu actual_size=%lu", (unsigned long)payload_size_, (unsigned long)written_payload_size); } diff --git a/src/internal_modules/roc_fec/block_writer.cpp b/src/internal_modules/roc_fec/block_writer.cpp index 8f720e28f..1b635e17a 100644 --- a/src/internal_modules/roc_fec/block_writer.cpp +++ b/src/internal_modules/roc_fec/block_writer.cpp @@ -223,9 +223,9 @@ status::StatusCode BlockWriter::write_source_packet_(const packet::PacketPtr& pp fill_packet_fec_fields_(pp, (packet::seqnum_t)cur_packet_); - if (!source_composer_.compose(*pp)) { - // TODO(gh-183): forward status from composer - return status::StatusBadBuffer; + status::StatusCode status = source_composer_.compose(*pp); + if (status != status::StatusOK) { + return status; } pp->add_flags(packet::Packet::FlagComposed); @@ -261,16 +261,17 @@ status::StatusCode BlockWriter::make_repair_packet_(packet::seqnum_t pack_n, return status::StatusNoMem; } - if (!repair_composer_.align(buffer, 0, block_encoder_.buffer_alignment())) { + status::StatusCode status = + repair_composer_.align(buffer, 0, block_encoder_.buffer_alignment()); + if (status != status::StatusOK) { roc_log(LogError, "fec block writer: can't align packet buffer"); - // TODO(gh-183): forward status from composer - return status::StatusBadBuffer; + return status; } - if (!repair_composer_.prepare(*packet, buffer, cur_payload_size_)) { + status = repair_composer_.prepare(*packet, buffer, cur_payload_size_); + if (status != status::StatusOK) { roc_log(LogError, "fec block writer: can't prepare packet"); - // TODO(gh-183): forward status from composer - return status::StatusBadBuffer; + return status; } packet->add_flags(packet::Packet::FlagPrepared); @@ -304,9 +305,9 @@ status::StatusCode BlockWriter::compose_repair_packets_() { continue; } - if (!repair_composer_.compose(*rp)) { - // TODO(gh-183): forward status from composer - return status::StatusBadBuffer; + status::StatusCode status = repair_composer_.compose(*rp); + if (status != status::StatusOK) { + return status; } rp->add_flags(packet::Packet::FlagComposed); } diff --git a/src/internal_modules/roc_fec/composer.h b/src/internal_modules/roc_fec/composer.h index 78b9ff107..65ab35c94 100644 --- a/src/internal_modules/roc_fec/composer.h +++ b/src/internal_modules/roc_fec/composer.h @@ -41,7 +41,7 @@ class Composer : public packet::IComposer, public core::NonCopyable<> { } //! Adjust buffer to align payload. - virtual bool + virtual status::StatusCode align(core::Slice& buffer, size_t header_size, size_t payload_alignment) { if ((unsigned long)buffer.data() % payload_alignment != 0) { roc_panic("fec composer: unexpected non-aligned buffer"); @@ -59,18 +59,18 @@ class Composer : public packet::IComposer, public core::NonCopyable<> { LogDebug, "fec composer: not enough space for alignment: padding=%lu cap=%lu", (unsigned long)padding, (unsigned long)buffer.capacity()); - return false; + return status::StatusBadBuffer; } buffer.reslice(padding, padding); - return true; + return status::StatusOK; } else { return inner_composer_->align(buffer, header_size, payload_alignment); } } //! Prepare buffer for composing a packet. - virtual bool + virtual status::StatusCode prepare(packet::Packet& packet, core::Slice& buffer, size_t payload_size) { core::Slice payload_id = buffer.subslice(0, 0); @@ -80,7 +80,7 @@ class Composer : public packet::IComposer, public core::NonCopyable<> { "fec composer: not enough space for fec header: size=%lu cap=%lu", (unsigned long)sizeof(PayloadID), (unsigned long)payload_id.capacity()); - return false; + return status::StatusBadBuffer; } payload_id.reslice(0, sizeof(PayloadID)); } @@ -89,8 +89,10 @@ class Composer : public packet::IComposer, public core::NonCopyable<> { payload_id.subslice(payload_id.size(), payload_id.size()); if (inner_composer_) { - if (!inner_composer_->prepare(packet, payload, payload_size)) { - return false; + status::StatusCode result = + inner_composer_->prepare(packet, payload, payload_size); + if (result != status::StatusOK) { + return result; } } else { payload.reslice(0, payload_size); @@ -104,7 +106,7 @@ class Composer : public packet::IComposer, public core::NonCopyable<> { "fec composer: not enough space for fec header: size=%lu cap=%lu", (unsigned long)sizeof(PayloadID), (unsigned long)payload_id.capacity()); - return false; + return status::StatusBadBuffer; } payload_id.reslice(0, sizeof(PayloadID)); } @@ -123,21 +125,21 @@ class Composer : public packet::IComposer, public core::NonCopyable<> { buffer.reslice(0, payload_id.size() + payload.size()); - return true; + return status::StatusOK; } //! Pad packet. - virtual bool pad(packet::Packet& packet, size_t padding_size) { + virtual status::StatusCode pad(packet::Packet& packet, size_t padding_size) { if (inner_composer_) { return inner_composer_->pad(packet, padding_size); } // padding not supported - return false; + return status::StatusBadOperation; } //! Compose packet to buffer. - virtual bool compose(packet::Packet& packet) { + virtual status::StatusCode compose(packet::Packet& packet) { if (!packet.fec()) { roc_panic("fec composer: unexpected non-fec packet"); } @@ -167,7 +169,7 @@ class Composer : public packet::IComposer, public core::NonCopyable<> { return inner_composer_->compose(packet); } - return true; + return status::StatusOK; } private: diff --git a/src/internal_modules/roc_packet/icomposer.h b/src/internal_modules/roc_packet/icomposer.h index 311b1ccf3..912409fcf 100644 --- a/src/internal_modules/roc_packet/icomposer.h +++ b/src/internal_modules/roc_packet/icomposer.h @@ -42,7 +42,7 @@ class IComposer : public core::ArenaAllocation { //! @returns //! true if the buffer was successfully adjusted or false if the @p buffer //! capacity is not enough. - virtual bool + virtual status::StatusCode align(core::Slice& buffer, size_t header_size, size_t payload_alignment) = 0; //! Prepare buffer for composing a packet. @@ -55,7 +55,7 @@ class IComposer : public core::ArenaAllocation { //! @returns //! true if the packet was successfully prepared or false if the @p buffer //! capacity is not enough. - virtual bool + virtual status::StatusCode prepare(Packet& packet, core::Slice& buffer, size_t payload_size) = 0; //! Pad packet. @@ -66,7 +66,7 @@ class IComposer : public core::ArenaAllocation { //! @returns //! true if the packet was successfully padded or false if parameters //! are invalid or padding is not supported. - virtual bool pad(Packet& packet, size_t padding_size) = 0; + virtual status::StatusCode pad(Packet& packet, size_t padding_size) = 0; //! Compose packet to buffer. //! @remarks @@ -74,7 +74,7 @@ class IComposer : public core::ArenaAllocation { //! a previous prepare() call. //! @returns //! true if the packet was successfully composed or false if an error occurred. - virtual bool compose(Packet& packet) = 0; + virtual status::StatusCode compose(Packet& packet) = 0; }; } // namespace packet diff --git a/src/internal_modules/roc_packet/shipper.cpp b/src/internal_modules/roc_packet/shipper.cpp index d7c16918c..2a67343c4 100644 --- a/src/internal_modules/roc_packet/shipper.cpp +++ b/src/internal_modules/roc_packet/shipper.cpp @@ -46,7 +46,7 @@ status::StatusCode Shipper::write(const PacketPtr& packet) { } if (!packet->has_flags(Packet::FlagComposed)) { - if (!composer_.compose(*packet)) { + if (composer_.compose(*packet) != status::StatusOK) { roc_log(LogError, "shipper: can't compose packet"); return status::StatusNoMem; } diff --git a/src/internal_modules/roc_rtcp/communicator.cpp b/src/internal_modules/roc_rtcp/communicator.cpp index 70b9a48d7..864836414 100644 --- a/src/internal_modules/roc_rtcp/communicator.cpp +++ b/src/internal_modules/roc_rtcp/communicator.cpp @@ -576,9 +576,10 @@ status::StatusCode Communicator::generate_packet_(PacketType packet_type, packet_buffer.reslice(0, 0); // Prepare packet to be able to hold our RTCP packet data - if (!packet_composer_.prepare(*packet, packet_buffer, payload_buffer.size())) { + status = packet_composer_.prepare(*packet, packet_buffer, payload_buffer.size()); + if (status != status::StatusOK) { roc_log(LogError, "rtcp communicator: can't prepare packet"); - return status::StatusNoMem; + return status; } packet->add_flags(packet::Packet::FlagPrepared); diff --git a/src/internal_modules/roc_rtcp/composer.cpp b/src/internal_modules/roc_rtcp/composer.cpp index eb53c0d85..03c8c58b5 100644 --- a/src/internal_modules/roc_rtcp/composer.cpp +++ b/src/internal_modules/roc_rtcp/composer.cpp @@ -22,9 +22,9 @@ status::StatusCode Composer::init_status() const { return status::StatusOK; } -bool Composer::align(core::Slice& buffer, - size_t header_size, - size_t payload_alignment) { +status::StatusCode Composer::align(core::Slice& buffer, + size_t header_size, + size_t payload_alignment) { if ((unsigned long)buffer.data() % payload_alignment != 0) { roc_panic("rtcp composer: unexpected non-aligned buffer"); } @@ -35,16 +35,16 @@ bool Composer::align(core::Slice& buffer, roc_log(LogDebug, "rtcp composer: not enough space for alignment: padding=%lu cap=%lu", (unsigned long)padding, (unsigned long)buffer.capacity()); - return false; + return status::StatusBadBuffer; } buffer.reslice(padding, padding); - return true; + return status::StatusOK; } -bool Composer::prepare(packet::Packet& packet, - core::Slice& buffer, - size_t payload_size) { +status::StatusCode Composer::prepare(packet::Packet& packet, + core::Slice& buffer, + size_t payload_size) { buffer.reslice(0, payload_size); packet.add_flags(packet::Packet::FlagControl); @@ -52,34 +52,34 @@ bool Composer::prepare(packet::Packet& packet, packet.rtcp()->payload = buffer; - return true; + return status::StatusOK; } -bool Composer::pad(packet::Packet& packet, size_t padding_size) { +status::StatusCode Composer::pad(packet::Packet& packet, size_t padding_size) { // not supported (void)packet; (void)padding_size; - return false; + return status::StatusBadOperation; } -bool Composer::compose(packet::Packet& packet) { +status::StatusCode Composer::compose(packet::Packet& packet) { if (!packet.rtcp()) { roc_panic("rtcp composer: unexpected non-rctp packet"); } if (!packet.rtcp()->payload) { roc_log(LogError, "rtcp composer: unexpected null data"); - return false; + return status::StatusBadOperation; } if (packet.rtcp()->payload.size() == 0) { roc_log(LogError, "rtcp composer: unexpected zero data"); - return false; + return status::StatusBadOperation; } - return true; + return status::StatusOK; } } // namespace rtcp diff --git a/src/internal_modules/roc_rtcp/composer.h b/src/internal_modules/roc_rtcp/composer.h index 8af74e5e7..5b62be7b3 100644 --- a/src/internal_modules/roc_rtcp/composer.h +++ b/src/internal_modules/roc_rtcp/composer.h @@ -33,18 +33,18 @@ class Composer : public packet::IComposer, public core::NonCopyable<> { virtual status::StatusCode init_status() const; //! Adjust buffer to align payload. - virtual bool + virtual status::StatusCode align(core::Slice& buffer, size_t header_size, size_t payload_alignment); //! Prepare buffer for composing a packet. - virtual bool + virtual status::StatusCode prepare(packet::Packet& packet, core::Slice& buffer, size_t payload_size); //! Pad packet. - virtual bool pad(packet::Packet& packet, size_t padding_size); + virtual status::StatusCode pad(packet::Packet& packet, size_t padding_size); //! Compose packet to buffer. - virtual bool compose(packet::Packet& packet); + virtual status::StatusCode compose(packet::Packet& packet); }; } // namespace rtcp diff --git a/src/internal_modules/roc_rtp/composer.cpp b/src/internal_modules/roc_rtp/composer.cpp index 4ab52cc96..b505a0214 100644 --- a/src/internal_modules/roc_rtp/composer.cpp +++ b/src/internal_modules/roc_rtp/composer.cpp @@ -24,9 +24,9 @@ status::StatusCode Composer::init_status() const { return status::StatusOK; } -bool Composer::align(core::Slice& buffer, - size_t header_size, - size_t payload_alignment) { +status::StatusCode Composer::align(core::Slice& buffer, + size_t header_size, + size_t payload_alignment) { if ((unsigned long)buffer.data() % payload_alignment != 0) { roc_panic("rtp composer: unexpected non-aligned buffer"); } @@ -40,26 +40,26 @@ bool Composer::align(core::Slice& buffer, roc_log(LogDebug, "rtp composer: not enough space for alignment: padding=%lu cap=%lu", (unsigned long)padding, (unsigned long)buffer.capacity()); - return false; + return status::StatusBadBuffer; } buffer.reslice(padding, padding); - return true; + return status::StatusOK; } else { return inner_composer_->align(buffer, header_size, payload_alignment); } } -bool Composer::prepare(packet::Packet& packet, - core::Slice& buffer, - size_t payload_size) { +status::StatusCode Composer::prepare(packet::Packet& packet, + core::Slice& buffer, + size_t payload_size) { core::Slice header = buffer.subslice(0, 0); if (header.capacity() < sizeof(Header)) { roc_log(LogDebug, "rtp composer: not enough space for rtp header: size=%lu cap=%lu", (unsigned long)sizeof(Header), (unsigned long)header.capacity()); - return false; + return status::StatusBadBuffer; } header.reslice(0, sizeof(Header)); @@ -70,12 +70,14 @@ bool Composer::prepare(packet::Packet& packet, roc_log(LogDebug, "rtp composer: not enough space for rtp payload: size=%lu cap=%lu", (unsigned long)payload_size, (unsigned long)payload.capacity()); - return false; + return status::StatusBadBuffer; } payload.reslice(0, payload_size); } else { - if (!inner_composer_->prepare(packet, payload, payload_size)) { - return false; + status::StatusCode status = + inner_composer_->prepare(packet, payload, payload_size); + if (status != status::StatusOK) { + return status; } } @@ -88,10 +90,10 @@ bool Composer::prepare(packet::Packet& packet, buffer.reslice(0, header.size() + payload.size()); - return true; + return status::StatusOK; } -bool Composer::pad(packet::Packet& packet, size_t padding_size) { +status::StatusCode Composer::pad(packet::Packet& packet, size_t padding_size) { if (inner_composer_) { return inner_composer_->pad(packet, padding_size); } @@ -112,16 +114,16 @@ bool Composer::pad(packet::Packet& packet, size_t padding_size) { "rtp composer: padding is larger than payload size:" " payload_size=%lu padding_size=%lu", (unsigned long)rtp->payload.size(), (unsigned long)padding_size); - return false; + return status::StatusBadBuffer; } rtp->padding = rtp->payload.subslice(payload_size - padding_size, payload_size); rtp->payload = rtp->payload.subslice(0, payload_size - padding_size); - return true; + return status::StatusOK; } -bool Composer::compose(packet::Packet& packet) { +status::StatusCode Composer::compose(packet::Packet& packet) { packet::RTP* rtp = packet.rtp(); if (!rtp) { roc_panic("rtp composer: unexpected non-rtp packet"); @@ -152,7 +154,7 @@ bool Composer::compose(packet::Packet& packet) { "rtp composer: padding is larger than supported by rtp:" " pad_size=%lu max_size=%lu", (unsigned long)padding_size, (unsigned long)(uint8_t)-1); - return false; + return status::StatusBadBuffer; } if (padding_size > 1) { @@ -165,7 +167,7 @@ bool Composer::compose(packet::Packet& packet) { return inner_composer_->compose(packet); } - return true; + return status::StatusOK; } } // namespace rtp diff --git a/src/internal_modules/roc_rtp/composer.h b/src/internal_modules/roc_rtp/composer.h index cce2a04dd..b24c0e73b 100644 --- a/src/internal_modules/roc_rtp/composer.h +++ b/src/internal_modules/roc_rtp/composer.h @@ -31,18 +31,18 @@ class Composer : public packet::IComposer, public core::NonCopyable<> { virtual status::StatusCode init_status() const; //! Adjust buffer to align payload. - virtual bool + virtual status::StatusCode align(core::Slice& buffer, size_t header_size, size_t payload_alignment); //! Prepare buffer for composing a packet. - virtual bool + virtual status::StatusCode prepare(packet::Packet& packet, core::Slice& buffer, size_t payload_size); //! Pad packet. - virtual bool pad(packet::Packet& packet, size_t padding_size); + virtual status::StatusCode pad(packet::Packet& packet, size_t padding_size); //! Compose packet to buffer. - virtual bool compose(packet::Packet& packet); + virtual status::StatusCode compose(packet::Packet& packet); private: packet::IComposer* inner_composer_; diff --git a/src/tests/roc_audio/test_depacketizer.cpp b/src/tests/roc_audio/test_depacketizer.cpp index d24edd48c..5ed3110fa 100644 --- a/src/tests/roc_audio/test_depacketizer.cpp +++ b/src/tests/roc_audio/test_depacketizer.cpp @@ -62,7 +62,8 @@ packet::PacketPtr new_packet(IFrameEncoder& encoder, core::Slice bp = packet_factory.new_packet_buffer(); CHECK(bp); - CHECK(rtp_composer.prepare(*pp, bp, encoder.encoded_byte_count(SamplesPerPacket))); + CHECK(rtp_composer.prepare(*pp, bp, encoder.encoded_byte_count(SamplesPerPacket)) + == status::StatusOK); pp->set_buffer(bp); @@ -82,7 +83,7 @@ packet::PacketPtr new_packet(IFrameEncoder& encoder, encoder.end_frame(); - CHECK(rtp_composer.compose(*pp)); + CHECK(rtp_composer.compose(*pp) == status::StatusOK); return pp; } diff --git a/src/tests/roc_fec/test_block_writer_reader.cpp b/src/tests/roc_fec/test_block_writer_reader.cpp index 3304138d6..5ad840c1e 100644 --- a/src/tests/roc_fec/test_block_writer_reader.cpp +++ b/src/tests/roc_fec/test_block_writer_reader.cpp @@ -119,9 +119,9 @@ TEST_GROUP(block_writer_reader) { void recompose_packet(const packet::PacketPtr& p) { if (p->flags() & packet::Packet::FlagRepair) { - CHECK(repair_composer().compose(*p)); + CHECK(repair_composer().compose(*p) == status::StatusOK); } else { - CHECK(source_composer().compose(*p)); + CHECK(source_composer().compose(*p) == status::StatusOK); } } @@ -145,7 +145,7 @@ TEST_GROUP(block_writer_reader) { if (!composer) { composer = &source_composer(); } - CHECK(composer->prepare(*pp, bp, rtp_payload_size)); + CHECK(composer->prepare(*pp, bp, rtp_payload_size) == status::StatusOK); pp->set_buffer(bp); diff --git a/src/tests/roc_fec/test_block_writer_reader_duration.cpp b/src/tests/roc_fec/test_block_writer_reader_duration.cpp index 4e9e6da2c..b3c873220 100644 --- a/src/tests/roc_fec/test_block_writer_reader_duration.cpp +++ b/src/tests/roc_fec/test_block_writer_reader_duration.cpp @@ -96,7 +96,8 @@ TEST_GROUP(block_writer_reader_duration) { core::Slice bp = packet_factory.new_packet_buffer(); CHECK(bp); - CHECK(source_composer.prepare(*pp, bp, FECPayloadSize - sizeof(rtp::Header))); + CHECK(source_composer.prepare(*pp, bp, FECPayloadSize - sizeof(rtp::Header)) + == status::StatusOK); pp->set_buffer(bp); pp->add_flags(packet::Packet::FlagAudio | packet::Packet::FlagPrepared); diff --git a/src/tests/roc_fec/test_block_writer_reader_errors.cpp b/src/tests/roc_fec/test_block_writer_reader_errors.cpp index 0333aa6ab..d81ecc89b 100644 --- a/src/tests/roc_fec/test_block_writer_reader_errors.cpp +++ b/src/tests/roc_fec/test_block_writer_reader_errors.cpp @@ -87,7 +87,8 @@ TEST_GROUP(block_writer_reader_errors) { core::Slice bp = packet_factory.new_packet_buffer(); CHECK(bp); - CHECK(source_composer.prepare(*pp, bp, FECPayloadSize - sizeof(rtp::Header))); + CHECK(source_composer.prepare(*pp, bp, FECPayloadSize - sizeof(rtp::Header)) + == status::StatusOK); pp->set_buffer(bp); pp->add_flags(packet::Packet::FlagAudio | packet::Packet::FlagPrepared); diff --git a/src/tests/roc_fec/test_block_writer_reader_peek.cpp b/src/tests/roc_fec/test_block_writer_reader_peek.cpp index fc47958f0..7f422c61b 100644 --- a/src/tests/roc_fec/test_block_writer_reader_peek.cpp +++ b/src/tests/roc_fec/test_block_writer_reader_peek.cpp @@ -96,7 +96,8 @@ TEST_GROUP(block_writer_reader_peek) { core::Slice bp = packet_factory.new_packet_buffer(); CHECK(bp); - CHECK(source_composer.prepare(*pp, bp, FECPayloadSize - sizeof(rtp::Header))); + CHECK(source_composer.prepare(*pp, bp, FECPayloadSize - sizeof(rtp::Header)) + == status::StatusOK); pp->set_buffer(bp); pp->add_flags(packet::Packet::FlagAudio | packet::Packet::FlagPrepared); diff --git a/src/tests/roc_fec/test_composer.cpp b/src/tests/roc_fec/test_composer.cpp index a4bfa9b08..5c0f3650a 100644 --- a/src/tests/roc_fec/test_composer.cpp +++ b/src/tests/roc_fec/test_composer.cpp @@ -42,7 +42,7 @@ TEST(composer, align_footer) { UNSIGNED_LONGS_EQUAL((unsigned long)buffer->data(), slice.data()); Composer composer(NULL, arena); - CHECK(composer.align(slice, 0, Alignment)); + CHECK(composer.align(slice, 0, Alignment) == status::StatusOK); UNSIGNED_LONGS_EQUAL(0, slice.size()); UNSIGNED_LONGS_EQUAL(BufferSize, slice.capacity()); @@ -65,7 +65,7 @@ TEST(composer, align_header) { CHECK(((unsigned long)slice.data() + sizeof(RS8M_PayloadID)) % Alignment != 0); Composer composer(NULL, arena); - CHECK(composer.align(slice, 0, Alignment)); + CHECK(composer.align(slice, 0, Alignment) == status::StatusOK); UNSIGNED_LONGS_EQUAL(0, slice.size()); UNSIGNED_LONGS_EQUAL(BufferSize - (Alignment - sizeof(RS8M_PayloadID)), @@ -93,7 +93,7 @@ TEST(composer, align_outer_header) { != 0); Composer composer(NULL, arena); - CHECK(composer.align(slice, OuterHeader, Alignment)); + CHECK(composer.align(slice, OuterHeader, Alignment) == status::StatusOK); UNSIGNED_LONGS_EQUAL(0, slice.size()); UNSIGNED_LONGS_EQUAL(BufferSize @@ -117,12 +117,12 @@ TEST(composer, packet_size) { Composer composer(NULL, arena); - CHECK(composer.align(buffer, 0, Alignment)); - CHECK(composer.prepare(*packet, buffer, PayloadSize)); + CHECK(composer.align(buffer, 0, Alignment) == status::StatusOK); + CHECK(composer.prepare(*packet, buffer, PayloadSize) == status::StatusOK); packet->set_buffer(buffer); - CHECK(composer.compose(*packet)); + CHECK(composer.compose(*packet) == status::StatusOK); UNSIGNED_LONGS_EQUAL(sizeof(RS8M_PayloadID) + PayloadSize, packet->buffer().size()); } diff --git a/src/tests/roc_fec/test_composer_parser.cpp b/src/tests/roc_fec/test_composer_parser.cpp index 2694a49ec..4799904e7 100644 --- a/src/tests/roc_fec/test_composer_parser.cpp +++ b/src/tests/roc_fec/test_composer_parser.cpp @@ -169,13 +169,13 @@ void test_compose(const PacketTest& test) { packet::PacketPtr packet = packet_factory.new_packet(); CHECK(packet); - CHECK(test.composer->prepare(*packet, buffer, Test_payload_size)); + CHECK(test.composer->prepare(*packet, buffer, Test_payload_size) == status::StatusOK); packet->set_buffer(buffer); fill_packet(*packet, test.is_rtp); - CHECK(test.composer->compose(*packet)); + CHECK(test.composer->compose(*packet) == status::StatusOK); UNSIGNED_LONGS_EQUAL(test.reference_size, packet->buffer().size()); for (size_t i = 0; i < test.reference_size; i++) { @@ -209,13 +209,14 @@ void test_compose_parse(const PacketTest& test) { packet::PacketPtr packet1 = packet_factory.new_packet(); CHECK(packet1); - CHECK(test.composer->prepare(*packet1, buffer, Test_payload_size)); + CHECK(test.composer->prepare(*packet1, buffer, Test_payload_size) + == status::StatusOK); packet1->set_buffer(buffer); fill_packet(*packet1, test.is_rtp); - CHECK(test.composer->compose(*packet1)); + CHECK(test.composer->compose(*packet1) == status::StatusOK); packet::PacketPtr packet2 = packet_factory.new_packet(); CHECK(packet2); diff --git a/src/tests/roc_packet/test_shipper.cpp b/src/tests/roc_packet/test_shipper.cpp index 1901fb30f..9565720f8 100644 --- a/src/tests/roc_packet/test_shipper.cpp +++ b/src/tests/roc_packet/test_shipper.cpp @@ -13,6 +13,7 @@ #include "roc_packet/packet_factory.h" #include "roc_packet/shipper.h" #include "roc_rtp/headers.h" +#include "roc_status/status_code.h" namespace roc { namespace packet { @@ -62,21 +63,21 @@ struct MockComposer : public IComposer, public core::NonCopyable<> { return status::StatusOK; } - virtual bool align(core::Slice&, size_t, size_t) { - return true; + virtual status::StatusCode align(core::Slice&, size_t, size_t) { + return status::StatusOK; } - virtual bool prepare(Packet&, core::Slice&, size_t) { - return true; + virtual status::StatusCode prepare(Packet&, core::Slice&, size_t) { + return status::StatusOK; } - virtual bool pad(Packet&, size_t) { - return true; + virtual status::StatusCode pad(Packet&, size_t) { + return status::StatusOK; } - virtual bool compose(Packet&) { + virtual status::StatusCode compose(Packet&) { ++compose_call_count; - return true; + return status::StatusOK; } unsigned compose_call_count; diff --git a/src/tests/roc_pipeline/test_helpers/packet_writer.h b/src/tests/roc_pipeline/test_helpers/packet_writer.h index c291bf74c..7b76bc42d 100644 --- a/src/tests/roc_pipeline/test_helpers/packet_writer.h +++ b/src/tests/roc_pipeline/test_helpers/packet_writer.h @@ -243,7 +243,8 @@ class PacketWriter : public core::NonCopyable<> { CHECK(bp); CHECK(source_composer_->prepare( - *pp, bp, payload_encoder_->encoded_byte_count(samples_per_packet))); + *pp, bp, payload_encoder_->encoded_byte_count(samples_per_packet)) + == status::StatusOK); pp->set_buffer(bp); @@ -290,12 +291,12 @@ class PacketWriter : public core::NonCopyable<> { packet::PacketPtr fp; while (fec_queue_.read(fp, packet::ModeFetch) == status::StatusOK) { if (fp->has_flags(packet::Packet::FlagAudio)) { - CHECK(source_composer_->compose(*fp)); + CHECK(source_composer_->compose(*fp) == status::StatusOK); LONGS_EQUAL( status::StatusOK, source_writer_->write(prepare_for_delivery_(fp, sample_spec))); } else { - CHECK(repair_composer_->compose(*fp)); + CHECK(repair_composer_->compose(*fp) == status::StatusOK); LONGS_EQUAL( status::StatusOK, repair_writer_->write(prepare_for_delivery_(fp, sample_spec))); @@ -303,7 +304,7 @@ class PacketWriter : public core::NonCopyable<> { } } else { // compose and "deliver" packet - CHECK(source_composer_->compose(*pp)); + CHECK(source_composer_->compose(*pp) == status::StatusOK); LONGS_EQUAL(status::StatusOK, source_writer_->write(prepare_for_delivery_(pp, sample_spec))); } diff --git a/src/tests/roc_rtp/test_packet_formats.cpp b/src/tests/roc_rtp/test_packet_formats.cpp index 4d28343ce..2f3eb371d 100644 --- a/src/tests/roc_rtp/test_packet_formats.cpp +++ b/src/tests/roc_rtp/test_packet_formats.cpp @@ -202,7 +202,8 @@ void check_compose_encode(const test::PacketInfo& pi) { Composer composer(NULL, arena); - CHECK(composer.prepare(*packet, buffer, pi.payload_size + pi.padding_size)); + CHECK(composer.prepare(*packet, buffer, pi.payload_size + pi.padding_size) + == status::StatusOK); packet->set_buffer(buffer); encode_samples(*encoder, *packet, pi); @@ -212,7 +213,7 @@ void check_compose_encode(const test::PacketInfo& pi) { composer.pad(*packet, pi.padding_size); } - CHECK(composer.compose(*packet)); + CHECK(composer.compose(*packet) == status::StatusOK); check_format_info(*encoding, pi); check_packet_fields(*packet, pi);