@@ -729,6 +729,11 @@ void RtpVideoStreamReceiver2::OnInsertedPacket(
729729 std::vector<rtc::ArrayView<const uint8_t >> payloads;
730730 RtpPacketInfos::vector_type packet_infos;
731731
732+ // Add timing information required by sender-side BWE.
733+ #if defined(WEBRTC_WIN)
734+ int64_t max_tc = 0 , min_tc = 0 ;
735+ double start_duration = 0 , last_duration = 0 ;
736+ #endif
732737 bool frame_boundary = true ;
733738 for (auto & packet : result.packets ) {
734739 // PacketBuffer promisses frame boundaries are correctly set on each
@@ -741,18 +746,30 @@ void RtpVideoStreamReceiver2::OnInsertedPacket(
741746 max_recv_time = packet->packet_info .receive_time_ms ();
742747 payloads.clear ();
743748 packet_infos.clear ();
749+ #if defined(WEBRTC_WIN)
750+ max_tc = min_tc = packet->time_ticks ;
751+ #endif
744752 } else {
745753 max_nack_count = std::max (max_nack_count, packet->times_nacked );
746754 min_recv_time =
747755 std::min (min_recv_time, packet->packet_info .receive_time_ms ());
748756 max_recv_time =
749757 std::max (max_recv_time, packet->packet_info .receive_time_ms ());
758+ #if defined(WEBRTC_WIN)
759+ max_tc = std::max (max_tc, packet->time_ticks );
760+ min_tc = std::min (min_tc, packet->time_ticks );
761+ #endif
750762 }
751763 payloads.emplace_back (packet->video_payload );
752764 packet_infos.push_back (packet->packet_info );
753765
754766 frame_boundary = packet->is_last_packet_in_frame ();
755767 if (packet->is_last_packet_in_frame ()) {
768+ #if defined(WEBRTC_WIN)
769+ clock_sync_.Sync (packet->timestamp , min_tc);
770+ start_duration = clock_sync_.GetDuration (packet->timestamp , min_tc);
771+ last_duration = clock_sync_.GetDuration (packet->timestamp , max_tc);
772+ #endif
756773 auto depacketizer_it = payload_type_map_.find (first_packet->payload_type );
757774 RTC_CHECK (depacketizer_it != payload_type_map_.end ());
758775
@@ -764,25 +781,37 @@ void RtpVideoStreamReceiver2::OnInsertedPacket(
764781 }
765782
766783 const video_coding::PacketBuffer::Packet& last_packet = *packet;
767- OnAssembledFrame (std::make_unique<video_coding::RtpFrameObject>(
768- first_packet->seq_num , //
769- last_packet.seq_num , //
770- last_packet.marker_bit , //
771- max_nack_count, //
772- min_recv_time, //
773- max_recv_time, //
774- first_packet->timestamp , //
775- first_packet->ntp_time_ms , //
776- last_packet.video_header .video_timing , //
777- first_packet->payload_type , //
778- first_packet->codec (), //
779- last_packet.video_header .rotation , //
780- last_packet.video_header .content_type , //
781- first_packet->video_header , //
782- last_packet.video_header .color_space , //
783- RtpPacketInfos (std::move (packet_infos)), //
784- std::move (bitstream)));
784+ std::unique_ptr<video_coding::RtpFrameObject> frame =
785+ std::make_unique<video_coding::RtpFrameObject>(
786+ first_packet->seq_num , //
787+ last_packet.seq_num , //
788+ last_packet.marker_bit , //
789+ max_nack_count, //
790+ min_recv_time, //
791+ max_recv_time, //
792+ first_packet->timestamp , //
793+ first_packet->ntp_time_ms , //
794+ last_packet.video_header .video_timing , //
795+ first_packet->payload_type , //
796+ first_packet->codec (), //
797+ last_packet.video_header .rotation , //
798+ last_packet.video_header .content_type , //
799+ first_packet->video_header , //
800+ last_packet.video_header .color_space , //
801+ RtpPacketInfos (std::move (packet_infos)), //
802+ std::move (bitstream));
803+ #if defined(WEBRTC_WIN)
804+ StreamStatistician* ss =
805+ rtp_receive_statistics_->GetStatistician (config_.rtp .remote_ssrc );
806+ int32_t packets_lost = 0 ;
807+ if (ss != nullptr ) {
808+ packets_lost = ss->GetStats ().packets_lost ;
809+ frame->SetBWETiming (start_duration, last_duration, packets_lost);
810+ }
811+ #endif
812+ OnAssembledFrame (std::move (frame));
785813 }
814+
786815 }
787816 RTC_DCHECK (frame_boundary);
788817 if (result.buffer_cleared ) {
0 commit comments