OLD | NEW |
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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 (!RtpToNtpMsAndReturnFreq(frame.timestamp(), video_measurement_.rtcp, |
190 &latest_video_ntp)) { | 192 &latest_video_ntp, estimated_freq_khz)) { |
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; |
200 return true; | 202 return true; |
201 } | 203 } |
202 | 204 |
203 } // namespace webrtc | 205 } // namespace webrtc |
OLD | NEW |