From 85d5c197a856e13722b7bd3020076bf512b194d5 Mon Sep 17 00:00:00 2001 From: philipel Date: Wed, 25 Sep 2019 17:15:37 +0200 Subject: [PATCH] Added RtpFrameObject ctor with no PacketBuffer pointer. Bug: webrtc:10979 Change-Id: Ie6a2b56e7374d60d1f74d8c315216b27df22a19b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/154426 Reviewed-by: Niels Moller Commit-Queue: Philip Eliasson Cr-Commit-Position: refs/heads/master@{#29314} --- modules/video_coding/frame_object.cc | 73 +++++++++++++++++++++++++++ modules/video_coding/frame_object.h | 21 ++++++++ modules/video_coding/packet_buffer.cc | 13 ++++- 3 files changed, 105 insertions(+), 2 deletions(-) diff --git a/modules/video_coding/frame_object.cc b/modules/video_coding/frame_object.cc index 581fb5809f..f16d132570 100644 --- a/modules/video_coding/frame_object.cc +++ b/modules/video_coding/frame_object.cc @@ -24,6 +24,7 @@ namespace webrtc { namespace video_coding { +// TODO(philipel): Remove this ctor. RtpFrameObject::RtpFrameObject( PacketBuffer* packet_buffer, uint16_t first_seq_num, @@ -109,6 +110,78 @@ RtpFrameObject::RtpFrameObject( is_last_spatial_layer = last_packet->markerBit; } +RtpFrameObject::RtpFrameObject( + uint16_t first_seq_num, + uint16_t last_seq_num, + bool markerBit, + int times_nacked, + int64_t first_packet_received_time, + int64_t last_packet_received_time, + uint32_t rtp_timestamp, + int64_t ntp_time_ms, + const VideoSendTiming& timing, + uint8_t payload_type, + VideoCodecType codec, + VideoRotation rotation, + VideoContentType content_type, + const RTPVideoHeader& video_header, + const absl::optional& color_space, + const absl::optional& generic_descriptor, + RtpPacketInfos packet_infos, + rtc::scoped_refptr image_buffer) + : first_seq_num_(first_seq_num), + last_seq_num_(last_seq_num), + last_packet_received_time_(last_packet_received_time), + times_nacked_(times_nacked) { + rtp_video_header_ = video_header; + rtp_generic_frame_descriptor_ = generic_descriptor; + + // EncodedFrame members + codec_type_ = codec; + + // TODO(philipel): Remove when encoded image is replaced by EncodedFrame. + // VCMEncodedFrame members + CopyCodecSpecific(&rtp_video_header_); + _completeFrame = true; + _payloadType = payload_type; + SetTimestamp(rtp_timestamp); + ntp_time_ms_ = ntp_time_ms; + _frameType = rtp_video_header_.frame_type; + + // Setting frame's playout delays to the same values + // as of the first packet's. + SetPlayoutDelay(rtp_video_header_.playout_delay); + + SetEncodedData(std::move(image_buffer)); + _encodedWidth = rtp_video_header_.width; + _encodedHeight = rtp_video_header_.height; + + // EncodedFrame members + SetPacketInfos(std::move(packet_infos)); + + rotation_ = rotation; + SetColorSpace(color_space); + _rotation_set = true; + content_type_ = content_type; + if (timing.flags != VideoSendTiming::kInvalid) { + // ntp_time_ms_ may be -1 if not estimated yet. This is not a problem, + // as this will be dealt with at the time of reporting. + timing_.encode_start_ms = ntp_time_ms_ + timing.encode_start_delta_ms; + timing_.encode_finish_ms = ntp_time_ms_ + timing.encode_finish_delta_ms; + timing_.packetization_finish_ms = + ntp_time_ms_ + timing.packetization_finish_delta_ms; + timing_.pacer_exit_ms = ntp_time_ms_ + timing.pacer_exit_delta_ms; + timing_.network_timestamp_ms = + ntp_time_ms_ + timing.network_timestamp_delta_ms; + timing_.network2_timestamp_ms = + ntp_time_ms_ + timing.network2_timestamp_delta_ms; + } + timing_.receive_start_ms = first_packet_received_time; + timing_.receive_finish_ms = last_packet_received_time; + timing_.flags = timing.flags; + is_last_spatial_layer = markerBit; +} + RtpFrameObject::~RtpFrameObject() { } diff --git a/modules/video_coding/frame_object.h b/modules/video_coding/frame_object.h index 17d099438f..8020b49ce6 100644 --- a/modules/video_coding/frame_object.h +++ b/modules/video_coding/frame_object.h @@ -22,6 +22,7 @@ class PacketBuffer; class RtpFrameObject : public EncodedFrame { public: + // TODO(philipel): Remove this ctor. RtpFrameObject(PacketBuffer* packet_buffer, uint16_t first_seq_num, uint16_t last_seq_num, @@ -31,6 +32,26 @@ class RtpFrameObject : public EncodedFrame { RtpPacketInfos packet_infos, rtc::scoped_refptr image_buffer); + RtpFrameObject( + uint16_t first_seq_num, + uint16_t last_seq_num, + bool markerBit, + int times_nacked, + int64_t first_packet_received_time, + int64_t last_packet_received_time, + uint32_t rtp_timestamp, + int64_t ntp_time_ms, + const VideoSendTiming& timing, + uint8_t payload_type, + VideoCodecType codec, + VideoRotation rotation, + VideoContentType content_type, + const RTPVideoHeader& video_header, + const absl::optional& color_space, + const absl::optional& generic_descriptor, + RtpPacketInfos packet_infos, + rtc::scoped_refptr image_buffer); + ~RtpFrameObject() override; uint16_t first_seq_num() const; uint16_t last_seq_num() const; diff --git a/modules/video_coding/packet_buffer.cc b/modules/video_coding/packet_buffer.cc index a046b549a9..1ca488d49a 100644 --- a/modules/video_coding/packet_buffer.cc +++ b/modules/video_coding/packet_buffer.cc @@ -426,9 +426,18 @@ std::vector> PacketBuffer::FindFrames( missing_packets_.erase(missing_packets_.begin(), missing_packets_.upper_bound(seq_num)); + const VCMPacket* first_packet = GetPacket(start_seq_num); + const VCMPacket* last_packet = GetPacket(seq_num); auto frame = std::make_unique( - this, start_seq_num, seq_num, max_nack_count, min_recv_time, - max_recv_time, RtpPacketInfos(std::move(packet_infos)), + start_seq_num, seq_num, last_packet->markerBit, max_nack_count, + min_recv_time, max_recv_time, first_packet->timestamp, + first_packet->ntp_time_ms_, last_packet->video_header.video_timing, + first_packet->payloadType, first_packet->codec(), + last_packet->video_header.rotation, + last_packet->video_header.content_type, first_packet->video_header, + last_packet->video_header.color_space, + first_packet->generic_descriptor, + RtpPacketInfos(std::move(packet_infos)), GetEncodedImageBuffer(frame_size, start_seq_num, seq_num)); found_frames.emplace_back(std::move(frame));