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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 int audio_jitter_buffer_delay_ms = 0; | 116 int audio_jitter_buffer_delay_ms = 0; |
117 int playout_buffer_delay_ms = 0; | 117 int playout_buffer_delay_ms = 0; |
118 if (voe_sync_interface_->GetDelayEstimate(voe_channel_id_, | 118 if (voe_sync_interface_->GetDelayEstimate(voe_channel_id_, |
119 &audio_jitter_buffer_delay_ms, | 119 &audio_jitter_buffer_delay_ms, |
120 &playout_buffer_delay_ms) != 0) { | 120 &playout_buffer_delay_ms) != 0) { |
121 return; | 121 return; |
122 } | 122 } |
123 const int current_audio_delay_ms = audio_jitter_buffer_delay_ms + | 123 const int current_audio_delay_ms = audio_jitter_buffer_delay_ms + |
124 playout_buffer_delay_ms; | 124 playout_buffer_delay_ms; |
125 | 125 |
| 126 int64_t last_video_receive_ms = video_measurement_.latest_receive_time_ms; |
126 if (UpdateMeasurements(&video_measurement_, video_rtp_rtcp_, | 127 if (UpdateMeasurements(&video_measurement_, video_rtp_rtcp_, |
127 video_rtp_receiver_) != 0) { | 128 video_rtp_receiver_) != 0) { |
128 return; | 129 return; |
129 } | 130 } |
130 | 131 |
131 if (UpdateMeasurements(&audio_measurement_, audio_rtp_rtcp_, | 132 if (UpdateMeasurements(&audio_measurement_, audio_rtp_rtcp_, |
132 audio_rtp_receiver_) != 0) { | 133 audio_rtp_receiver_) != 0) { |
133 return; | 134 return; |
134 } | 135 } |
135 | 136 |
| 137 if (last_video_receive_ms == video_measurement_.latest_receive_time_ms) { |
| 138 // No new video packet has been received since last update. |
| 139 return; |
| 140 } |
| 141 |
136 int relative_delay_ms; | 142 int relative_delay_ms; |
137 // Calculate how much later or earlier the audio stream is compared to video. | 143 // Calculate how much later or earlier the audio stream is compared to video. |
138 if (!sync_->ComputeRelativeDelay(audio_measurement_, video_measurement_, | 144 if (!sync_->ComputeRelativeDelay(audio_measurement_, video_measurement_, |
139 &relative_delay_ms)) { | 145 &relative_delay_ms)) { |
140 return; | 146 return; |
141 } | 147 } |
142 | 148 |
143 TRACE_COUNTER1("webrtc", "SyncCurrentVideoDelay", current_video_delay_ms); | 149 TRACE_COUNTER1("webrtc", "SyncCurrentVideoDelay", current_video_delay_ms); |
144 TRACE_COUNTER1("webrtc", "SyncCurrentAudioDelay", current_audio_delay_ms); | 150 TRACE_COUNTER1("webrtc", "SyncCurrentAudioDelay", current_audio_delay_ms); |
145 TRACE_COUNTER1("webrtc", "SyncRelativeDelay", relative_delay_ms); | 151 TRACE_COUNTER1("webrtc", "SyncRelativeDelay", relative_delay_ms); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 int64_t time_to_render_ms = | 194 int64_t time_to_render_ms = |
189 frame.render_time_ms() - clock_->TimeInMilliseconds(); | 195 frame.render_time_ms() - clock_->TimeInMilliseconds(); |
190 if (time_to_render_ms > 0) | 196 if (time_to_render_ms > 0) |
191 latest_video_ntp += time_to_render_ms; | 197 latest_video_ntp += time_to_render_ms; |
192 | 198 |
193 *stream_offset_ms = latest_audio_ntp - latest_video_ntp; | 199 *stream_offset_ms = latest_audio_ntp - latest_video_ntp; |
194 return true; | 200 return true; |
195 } | 201 } |
196 | 202 |
197 } // namespace webrtc | 203 } // namespace webrtc |
OLD | NEW |