OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 #include <stdio.h> | 10 #include <stdio.h> |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 | 113 |
114 DeliveryStatus DeliverPacket(MediaType media_type, | 114 DeliveryStatus DeliverPacket(MediaType media_type, |
115 const uint8_t* packet, | 115 const uint8_t* packet, |
116 size_t length, | 116 size_t length, |
117 const PacketTime& packet_time) override { | 117 const PacketTime& packet_time) override { |
118 RtpUtility::RtpHeaderParser parser(packet, length); | 118 RtpUtility::RtpHeaderParser parser(packet, length); |
119 RTPHeader header; | 119 RTPHeader header; |
120 parser.Parse(&header); | 120 parser.Parse(&header); |
121 { | 121 { |
122 rtc::CritScope lock(&crit_); | 122 rtc::CritScope lock(&crit_); |
123 int64_t timestamp = wrap_handler_.Unwrap(header.timestamp); | 123 int64_t timestamp = |
124 recv_times_[timestamp - rtp_timestamp_delta_] = | 124 wrap_handler_.Unwrap(header.timestamp - rtp_timestamp_delta_); |
| 125 recv_times_[timestamp] = |
125 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds(); | 126 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds(); |
126 } | 127 } |
127 | 128 |
128 return receiver_->DeliverPacket(media_type, packet, length, packet_time); | 129 return receiver_->DeliverPacket(media_type, packet, length, packet_time); |
129 } | 130 } |
130 | 131 |
131 void MeasuredEncodeTiming(int64_t ntp_time_ms, int encode_time_ms) { | 132 void MeasuredEncodeTiming(int64_t ntp_time_ms, int encode_time_ms) { |
132 rtc::CritScope crit(&comparison_lock_); | 133 rtc::CritScope crit(&comparison_lock_); |
133 samples_encode_time_ms_[ntp_time_ms] = encode_time_ms; | 134 samples_encode_time_ms_[ntp_time_ms] = encode_time_ms; |
134 } | 135 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 void EncodedFrameCallback(const EncodedFrame& frame) override { | 185 void EncodedFrameCallback(const EncodedFrame& frame) override { |
185 rtc::CritScope lock(&comparison_lock_); | 186 rtc::CritScope lock(&comparison_lock_); |
186 if (frames_recorded_ < frames_to_process_) | 187 if (frames_recorded_ < frames_to_process_) |
187 encoded_frame_size_.AddSample(frame.length_); | 188 encoded_frame_size_.AddSample(frame.length_); |
188 } | 189 } |
189 | 190 |
190 void RenderFrame(const VideoFrame& video_frame, | 191 void RenderFrame(const VideoFrame& video_frame, |
191 int time_to_render_ms) override { | 192 int time_to_render_ms) override { |
192 int64_t render_time_ms = | 193 int64_t render_time_ms = |
193 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds(); | 194 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds(); |
194 uint32_t send_timestamp = video_frame.timestamp() - rtp_timestamp_delta_; | |
195 | 195 |
196 rtc::CritScope lock(&crit_); | 196 rtc::CritScope lock(&crit_); |
| 197 uint32_t send_timestamp = |
| 198 wrap_handler_.Unwrap(video_frame.timestamp() - rtp_timestamp_delta_); |
197 | 199 |
198 while (frames_.front().timestamp() < send_timestamp) { | 200 while (wrap_handler_.Unwrap(frames_.front().timestamp()) < send_timestamp) { |
199 AddFrameComparison(frames_.front(), last_rendered_frame_, true, | 201 AddFrameComparison(frames_.front(), last_rendered_frame_, true, |
200 render_time_ms); | 202 render_time_ms); |
201 frames_.pop_front(); | 203 frames_.pop_front(); |
202 } | 204 } |
203 | 205 |
204 VideoFrame reference_frame = frames_.front(); | 206 VideoFrame reference_frame = frames_.front(); |
205 frames_.pop_front(); | 207 frames_.pop_front(); |
206 assert(!reference_frame.IsZeroSize()); | 208 assert(!reference_frame.IsZeroSize()); |
207 if (send_timestamp == reference_frame.timestamp() - 1) { | 209 int64_t reference_timestamp = |
| 210 wrap_handler_.Unwrap(reference_frame.timestamp()); |
| 211 if (send_timestamp == reference_timestamp - 1) { |
208 // TODO(ivica): Make this work for > 2 streams. | 212 // TODO(ivica): Make this work for > 2 streams. |
209 // Look at RTPSender::BuildRTPHeader. | 213 // Look at RTPSender::BuildRTPHeader. |
210 ++send_timestamp; | 214 ++send_timestamp; |
211 } | 215 } |
212 EXPECT_EQ(reference_frame.timestamp(), send_timestamp); | 216 ASSERT_EQ(reference_timestamp, send_timestamp); |
213 assert(reference_frame.timestamp() == send_timestamp); | |
214 | 217 |
215 AddFrameComparison(reference_frame, video_frame, false, render_time_ms); | 218 AddFrameComparison(reference_frame, video_frame, false, render_time_ms); |
216 | 219 |
217 last_rendered_frame_ = video_frame; | 220 last_rendered_frame_ = video_frame; |
218 } | 221 } |
219 | 222 |
220 bool IsTextureSupported() const override { return false; } | 223 bool IsTextureSupported() const override { return false; } |
221 | 224 |
222 void Wait() { | 225 void Wait() { |
223 // Frame comparisons can be very expensive. Wait for test to be done, but | 226 // Frame comparisons can be very expensive. Wait for test to be done, but |
(...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1092 video_send_stream_->Stop(); | 1095 video_send_stream_->Stop(); |
1093 receive_stream->Stop(); | 1096 receive_stream->Stop(); |
1094 | 1097 |
1095 call->DestroyVideoReceiveStream(receive_stream); | 1098 call->DestroyVideoReceiveStream(receive_stream); |
1096 call->DestroyVideoSendStream(video_send_stream_); | 1099 call->DestroyVideoSendStream(video_send_stream_); |
1097 | 1100 |
1098 transport.StopSending(); | 1101 transport.StopSending(); |
1099 } | 1102 } |
1100 | 1103 |
1101 } // namespace webrtc | 1104 } // namespace webrtc |
OLD | NEW |