Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1074)

Side by Side Diff: webrtc/video/rtp_streams_synchronizer.cc

Issue 2385763002: Add stats for frequency offset when converting RTP timestamp to NTP time. (Closed)
Patch Set: rebase Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/video/rtp_streams_synchronizer.h ('k') | webrtc/video/stream_synchronization.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 10
(...skipping 22 matching lines...) Expand all
33 33
34 uint32_t ntp_secs = 0; 34 uint32_t ntp_secs = 0;
35 uint32_t ntp_frac = 0; 35 uint32_t ntp_frac = 0;
36 uint32_t rtp_timestamp = 0; 36 uint32_t rtp_timestamp = 0;
37 if (rtp_rtcp->RemoteNTP(&ntp_secs, &ntp_frac, nullptr, nullptr, 37 if (rtp_rtcp->RemoteNTP(&ntp_secs, &ntp_frac, nullptr, nullptr,
38 &rtp_timestamp) != 0) { 38 &rtp_timestamp) != 0) {
39 return -1; 39 return -1;
40 } 40 }
41 41
42 bool new_rtcp_sr = false; 42 bool new_rtcp_sr = false;
43 if (!UpdateRtcpList( 43 if (!UpdateRtcpList(ntp_secs, ntp_frac, rtp_timestamp, &stream->rtcp,
44 ntp_secs, ntp_frac, rtp_timestamp, &stream->rtcp, &new_rtcp_sr)) { 44 &new_rtcp_sr)) {
45 return -1; 45 return -1;
46 } 46 }
47 47
48 return 0; 48 return 0;
49 } 49 }
50 } // namespace 50 } // namespace
51 51
52 RtpStreamsSynchronizer::RtpStreamsSynchronizer( 52 RtpStreamsSynchronizer::RtpStreamsSynchronizer(
53 vcm::VideoReceiver* video_receiver, 53 vcm::VideoReceiver* video_receiver,
54 RtpStreamReceiver* rtp_stream_receiver) 54 RtpStreamReceiver* rtp_stream_receiver)
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 } 161 }
162 162
163 if (voe_sync_interface_->SetMinimumPlayoutDelay( 163 if (voe_sync_interface_->SetMinimumPlayoutDelay(
164 voe_channel_id_, target_audio_delay_ms) == -1) { 164 voe_channel_id_, target_audio_delay_ms) == -1) {
165 LOG(LS_ERROR) << "Error setting voice delay."; 165 LOG(LS_ERROR) << "Error setting voice delay.";
166 } 166 }
167 video_receiver_->SetMinimumPlayoutDelay(target_video_delay_ms); 167 video_receiver_->SetMinimumPlayoutDelay(target_video_delay_ms);
168 } 168 }
169 169
170 bool RtpStreamsSynchronizer::GetStreamSyncOffsetInMs( 170 bool RtpStreamsSynchronizer::GetStreamSyncOffsetInMs(
171 const VideoFrame& frame, int64_t* stream_offset_ms) const { 171 const VideoFrame& frame,
172 int64_t* stream_offset_ms,
173 double* estimated_freq_khz) const {
172 rtc::CritScope lock(&crit_); 174 rtc::CritScope lock(&crit_);
173 if (voe_channel_id_ == -1) 175 if (voe_channel_id_ == -1)
174 return false; 176 return false;
175 177
176 uint32_t playout_timestamp = 0; 178 uint32_t playout_timestamp = 0;
177 if (voe_sync_interface_->GetPlayoutTimestamp(voe_channel_id_, 179 if (voe_sync_interface_->GetPlayoutTimestamp(voe_channel_id_,
178 playout_timestamp) != 0) { 180 playout_timestamp) != 0) {
179 return false; 181 return false;
180 } 182 }
181 183
182 int64_t latest_audio_ntp; 184 int64_t latest_audio_ntp;
183 if (!RtpToNtpMs(playout_timestamp, audio_measurement_.rtcp, 185 if (!RtpToNtpMs(playout_timestamp, audio_measurement_.rtcp,
184 &latest_audio_ntp)) { 186 &latest_audio_ntp)) {
185 return false; 187 return false;
186 } 188 }
187 189
188 int64_t latest_video_ntp; 190 int64_t latest_video_ntp;
189 if (!RtpToNtpMs(frame.timestamp(), video_measurement_.rtcp, 191 if (!RtpToNtpMs(frame.timestamp(), video_measurement_.rtcp,
190 &latest_video_ntp)) { 192 &latest_video_ntp)) {
191 return false; 193 return false;
192 } 194 }
193 195
194 int64_t time_to_render_ms = 196 int64_t time_to_render_ms =
195 frame.render_time_ms() - clock_->TimeInMilliseconds(); 197 frame.render_time_ms() - clock_->TimeInMilliseconds();
196 if (time_to_render_ms > 0) 198 if (time_to_render_ms > 0)
197 latest_video_ntp += time_to_render_ms; 199 latest_video_ntp += time_to_render_ms;
198 200
199 *stream_offset_ms = latest_audio_ntp - latest_video_ntp; 201 *stream_offset_ms = latest_audio_ntp - latest_video_ntp;
202 *estimated_freq_khz = video_measurement_.rtcp.params.frequency_khz;
200 return true; 203 return true;
201 } 204 }
202 205
203 } // namespace webrtc 206 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/rtp_streams_synchronizer.h ('k') | webrtc/video/stream_synchronization.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698