From 76161f744677f7b879767482045e38b705ab2d4b Mon Sep 17 00:00:00 2001 From: philipel Date: Thu, 19 Sep 2019 11:22:22 +0200 Subject: [PATCH] Move the call to GetBitstream out of the RtpFrameObject ctor. Bug: webrtc:10979 Change-Id: I9159eb04d4a371e8ed8f932a989d6b884faa7be7 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/153661 Reviewed-by: Niels Moller Commit-Queue: Philip Eliasson Cr-Commit-Position: refs/heads/master@{#29237} --- modules/video_coding/frame_object.cc | 4 ---- modules/video_coding/frame_object.h | 1 + modules/video_coding/packet_buffer.cc | 14 ++++++++++---- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/modules/video_coding/frame_object.cc b/modules/video_coding/frame_object.cc index b4894269e1..f70bfe362a 100644 --- a/modules/video_coding/frame_object.cc +++ b/modules/video_coding/frame_object.cc @@ -58,10 +58,6 @@ RtpFrameObject::RtpFrameObject(PacketBuffer* packet_buffer, // as of the first packet's. SetPlayoutDelay(first_packet->video_header.playout_delay); - // TODO(nisse): Change GetBitstream to return the buffer? - SetEncodedData(EncodedImageBuffer::Create(frame_size)); - bool bitstream_copied = packet_buffer->GetBitstream(*this, data()); - RTC_DCHECK(bitstream_copied); _encodedWidth = first_packet->width(); _encodedHeight = first_packet->height(); diff --git a/modules/video_coding/frame_object.h b/modules/video_coding/frame_object.h index db5b7c32b7..c0313ca25f 100644 --- a/modules/video_coding/frame_object.h +++ b/modules/video_coding/frame_object.h @@ -23,6 +23,7 @@ class PacketBuffer; class RtpFrameObject : public EncodedFrame { public: + // TODO(philipel): Update the ctor to take an EncodedImageBuffer. RtpFrameObject(PacketBuffer* packet_buffer, uint16_t first_seq_num, uint16_t last_seq_num, diff --git a/modules/video_coding/packet_buffer.cc b/modules/video_coding/packet_buffer.cc index cae8979ae1..ea38ca620a 100644 --- a/modules/video_coding/packet_buffer.cc +++ b/modules/video_coding/packet_buffer.cc @@ -18,6 +18,7 @@ #include "absl/types/variant.h" #include "api/video/encoded_frame.h" +#include "api/video/encoded_image.h" #include "common_video/h264/h264_common.h" #include "modules/rtp_rtcp/source/rtp_video_header.h" #include "modules/video_coding/codecs/h264/include/h264_globals.h" @@ -436,10 +437,14 @@ std::vector> PacketBuffer::FindFrames( missing_packets_.erase(missing_packets_.begin(), missing_packets_.upper_bound(seq_num)); - found_frames.emplace_back( - new RtpFrameObject(this, start_seq_num, seq_num, frame_size, - max_nack_count, min_recv_time, max_recv_time, - RtpPacketInfos(std::move(packet_infos)))); + auto frame = std::make_unique( + this, start_seq_num, seq_num, frame_size, max_nack_count, + min_recv_time, max_recv_time, + RtpPacketInfos(std::move(packet_infos))); + frame->SetEncodedData(EncodedImageBuffer::Create(frame_size)); + GetBitstream(*frame, frame->data()); + found_frames.emplace_back(std::move(frame)); + ClearInterval(start_seq_num, seq_num); } ++seq_num; @@ -447,6 +452,7 @@ std::vector> PacketBuffer::FindFrames( return found_frames; } +// TODO(philipel): Update function to not accept an RtpFrameObject. bool PacketBuffer::GetBitstream(const RtpFrameObject& frame, uint8_t* destination) { rtc::CritScope lock(&crit_);