diff --git a/modules/video_coding/packet_buffer.cc b/modules/video_coding/packet_buffer.cc index 781a5a25e0..11cc06e08e 100644 --- a/modules/video_coding/packet_buffer.cc +++ b/modules/video_coding/packet_buffer.cc @@ -36,15 +36,15 @@ rtc::scoped_refptr PacketBuffer::Create( Clock* clock, size_t start_buffer_size, size_t max_buffer_size, - OnReceivedFrameCallback* received_frame_callback) { + OnAssembledFrameCallback* assembled_frame_callback) { return rtc::scoped_refptr(new PacketBuffer( - clock, start_buffer_size, max_buffer_size, received_frame_callback)); + clock, start_buffer_size, max_buffer_size, assembled_frame_callback)); } PacketBuffer::PacketBuffer(Clock* clock, size_t start_buffer_size, size_t max_buffer_size, - OnReceivedFrameCallback* received_frame_callback) + OnAssembledFrameCallback* assembled_frame_callback) : clock_(clock), size_(start_buffer_size), max_size_(max_buffer_size), @@ -53,7 +53,7 @@ PacketBuffer::PacketBuffer(Clock* clock, is_cleared_to_first_seq_num_(false), data_buffer_(start_buffer_size), sequence_buffer_(start_buffer_size), - received_frame_callback_(received_frame_callback), + assembled_frame_callback_(assembled_frame_callback), unique_frames_seen_(0), sps_pps_idr_is_h264_keyframe_( field_trial::IsEnabled("WebRTC-SpsPpsIdrIsH264Keyframe")) { @@ -133,7 +133,7 @@ bool PacketBuffer::InsertPacket(VCMPacket* packet) { } for (std::unique_ptr& frame : found_frames) - received_frame_callback_->OnReceivedFrame(std::move(frame)); + assembled_frame_callback_->OnAssembledFrame(std::move(frame)); return true; } @@ -203,7 +203,7 @@ void PacketBuffer::PaddingReceived(uint16_t seq_num) { } for (std::unique_ptr& frame : found_frames) - received_frame_callback_->OnReceivedFrame(std::move(frame)); + assembled_frame_callback_->OnAssembledFrame(std::move(frame)); } absl::optional PacketBuffer::LastReceivedPacketMs() const { diff --git a/modules/video_coding/packet_buffer.h b/modules/video_coding/packet_buffer.h index 0da504f83a..20e0bffae4 100644 --- a/modules/video_coding/packet_buffer.h +++ b/modules/video_coding/packet_buffer.h @@ -32,11 +32,11 @@ namespace video_coding { class RtpFrameObject; -// A received frame is a frame which has received all its packets. -class OnReceivedFrameCallback { +// A frame is assembled when all of its packets have been received. +class OnAssembledFrameCallback { public: - virtual ~OnReceivedFrameCallback() {} - virtual void OnReceivedFrame(std::unique_ptr frame) = 0; + virtual ~OnAssembledFrameCallback() {} + virtual void OnAssembledFrame(std::unique_ptr frame) = 0; }; class PacketBuffer { @@ -45,7 +45,7 @@ class PacketBuffer { Clock* clock, size_t start_buffer_size, size_t max_buffer_size, - OnReceivedFrameCallback* frame_callback); + OnAssembledFrameCallback* frame_callback); virtual ~PacketBuffer(); @@ -72,7 +72,7 @@ class PacketBuffer { PacketBuffer(Clock* clock, size_t start_buffer_size, size_t max_buffer_size, - OnReceivedFrameCallback* frame_callback); + OnAssembledFrameCallback* frame_callback); private: friend RtpFrameObject; @@ -155,8 +155,9 @@ class PacketBuffer { // and information needed to determine the continuity between packets. std::vector sequence_buffer_ RTC_GUARDED_BY(crit_); - // Called when a received frame is found. - OnReceivedFrameCallback* const received_frame_callback_; + // Called when all packets in a frame are received, allowing the frame + // to be assembled. + OnAssembledFrameCallback* const assembled_frame_callback_; // Timestamp (not RTP timestamp) of the last received packet/keyframe packet. absl::optional last_received_packet_ms_ RTC_GUARDED_BY(crit_); diff --git a/modules/video_coding/video_packet_buffer_unittest.cc b/modules/video_coding/video_packet_buffer_unittest.cc index 72bb990579..c51c3b4585 100644 --- a/modules/video_coding/video_packet_buffer_unittest.cc +++ b/modules/video_coding/video_packet_buffer_unittest.cc @@ -25,7 +25,7 @@ namespace webrtc { namespace video_coding { class TestPacketBuffer : public ::testing::Test, - public OnReceivedFrameCallback { + public OnAssembledFrameCallback { protected: TestPacketBuffer() : TestPacketBuffer("") {} explicit TestPacketBuffer(std::string field_trials) @@ -37,7 +37,7 @@ class TestPacketBuffer : public ::testing::Test, uint16_t Rand() { return rand_.Rand(); } - void OnReceivedFrame(std::unique_ptr frame) override { + void OnAssembledFrame(std::unique_ptr frame) override { uint16_t first_seq_num = frame->first_seq_num(); if (frames_from_callback_.find(first_seq_num) != frames_from_callback_.end()) { diff --git a/test/fuzzers/packet_buffer_fuzzer.cc b/test/fuzzers/packet_buffer_fuzzer.cc index 56d1557072..709c14c704 100644 --- a/test/fuzzers/packet_buffer_fuzzer.cc +++ b/test/fuzzers/packet_buffer_fuzzer.cc @@ -15,8 +15,8 @@ namespace webrtc { namespace { -class NullCallback : public video_coding::OnReceivedFrameCallback { - void OnReceivedFrame(std::unique_ptr frame) {} +class NullCallback : public video_coding::OnAssembledFrameCallback { + void OnAssembledFrame(std::unique_ptr frame) {} }; } // namespace diff --git a/video/buffered_frame_decryptor_unittest.cc b/video/buffered_frame_decryptor_unittest.cc index ff3f11a0ca..9230b47c88 100644 --- a/video/buffered_frame_decryptor_unittest.cc +++ b/video/buffered_frame_decryptor_unittest.cc @@ -60,7 +60,7 @@ class FakePacketBuffer : public video_coding::PacketBuffer { class BufferedFrameDecryptorTest : public ::testing::Test, public OnDecryptedFrameCallback, - public video_coding::OnReceivedFrameCallback { + public video_coding::OnAssembledFrameCallback { public: // Implements the OnDecryptedFrameCallbackInterface void OnDecryptedFrame( @@ -68,8 +68,8 @@ class BufferedFrameDecryptorTest decrypted_frame_call_count_++; } - // Implements the OnReceivedFrameCallback interface. - void OnReceivedFrame( + // Implements the OnAssembledFrameCallback interface. + void OnAssembledFrame( std::unique_ptr frame) override {} // Returns a new fake RtpFrameObject it abstracts the difficult construction diff --git a/video/rtp_video_stream_receiver.cc b/video/rtp_video_stream_receiver.cc index 1b17ac495e..df492ffff6 100644 --- a/video/rtp_video_stream_receiver.cc +++ b/video/rtp_video_stream_receiver.cc @@ -382,7 +382,7 @@ int32_t RtpVideoStreamReceiver::ResendPackets(const uint16_t* sequence_numbers, return rtp_rtcp_->SendNACK(sequence_numbers, length); } -void RtpVideoStreamReceiver::OnReceivedFrame( +void RtpVideoStreamReceiver::OnAssembledFrame( std::unique_ptr frame) { RTC_DCHECK_RUN_ON(&network_tc_); // Request a key frame as soon as possible. diff --git a/video/rtp_video_stream_receiver.h b/video/rtp_video_stream_receiver.h index c1ee662870..08c3e5a5bc 100644 --- a/video/rtp_video_stream_receiver.h +++ b/video/rtp_video_stream_receiver.h @@ -59,7 +59,7 @@ class RtpVideoStreamReceiver : public RecoveredPacketReceiver, public RtpPacketSinkInterface, public VCMFrameTypeCallback, public VCMPacketRequestCallback, - public video_coding::OnReceivedFrameCallback, + public video_coding::OnAssembledFrameCallback, public video_coding::OnCompleteFrameCallback, public OnDecryptedFrameCallback { public: @@ -127,8 +127,8 @@ class RtpVideoStreamReceiver : public RecoveredPacketReceiver, int32_t ResendPackets(const uint16_t* sequenceNumbers, uint16_t length) override; - // Implements OnReceivedFrameCallback. - void OnReceivedFrame( + // Implements OnAssembledFrameCallback. + void OnAssembledFrame( std::unique_ptr frame) override; // Implements OnCompleteFrameCallback.