| 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 15 matching lines...) Expand all Loading... |
| 26 int UpdateMeasurements(StreamSynchronization::Measurements* stream, | 26 int UpdateMeasurements(StreamSynchronization::Measurements* stream, |
| 27 const RtpRtcp& rtp_rtcp, const RtpReceiver& receiver) { | 27 const RtpRtcp& rtp_rtcp, const RtpReceiver& receiver) { |
| 28 if (!receiver.Timestamp(&stream->latest_timestamp)) | 28 if (!receiver.Timestamp(&stream->latest_timestamp)) |
| 29 return -1; | 29 return -1; |
| 30 if (!receiver.LastReceivedTimeMs(&stream->latest_receive_time_ms)) | 30 if (!receiver.LastReceivedTimeMs(&stream->latest_receive_time_ms)) |
| 31 return -1; | 31 return -1; |
| 32 | 32 |
| 33 uint32_t ntp_secs = 0; | 33 uint32_t ntp_secs = 0; |
| 34 uint32_t ntp_frac = 0; | 34 uint32_t ntp_frac = 0; |
| 35 uint32_t rtp_timestamp = 0; | 35 uint32_t rtp_timestamp = 0; |
| 36 if (0 != rtp_rtcp.RemoteNTP(&ntp_secs, | 36 if (rtp_rtcp.RemoteNTP(&ntp_secs, &ntp_frac, nullptr, nullptr, |
| 37 &ntp_frac, | 37 &rtp_timestamp) != 0) { |
| 38 NULL, | |
| 39 NULL, | |
| 40 &rtp_timestamp)) { | |
| 41 return -1; | 38 return -1; |
| 42 } | 39 } |
| 43 | 40 |
| 44 bool new_rtcp_sr = false; | 41 bool new_rtcp_sr = false; |
| 45 if (!UpdateRtcpList( | 42 if (!UpdateRtcpList( |
| 46 ntp_secs, ntp_frac, rtp_timestamp, &stream->rtcp, &new_rtcp_sr)) { | 43 ntp_secs, ntp_frac, rtp_timestamp, &stream->rtcp, &new_rtcp_sr)) { |
| 47 return -1; | 44 return -1; |
| 48 } | 45 } |
| 49 | 46 |
| 50 return 0; | 47 return 0; |
| 51 } | 48 } |
| 52 } // namespace | 49 } // namespace |
| 53 | 50 |
| 54 ViESyncModule::ViESyncModule(VideoCodingModule* vcm) | 51 ViESyncModule::ViESyncModule(VideoCodingModule* vcm) |
| 55 : vcm_(vcm), | 52 : vcm_(vcm), |
| 56 clock_(Clock::GetRealTimeClock()), | 53 clock_(Clock::GetRealTimeClock()), |
| 57 video_receiver_(NULL), | 54 video_receiver_(nullptr), |
| 58 video_rtp_rtcp_(NULL), | 55 video_rtp_rtcp_(nullptr), |
| 59 voe_channel_id_(-1), | 56 voe_channel_id_(-1), |
| 60 voe_sync_interface_(NULL), | 57 voe_sync_interface_(nullptr), |
| 61 last_sync_time_(TickTime::Now()), | 58 last_sync_time_(TickTime::Now()), |
| 62 sync_() {} | 59 sync_() {} |
| 63 | 60 |
| 64 ViESyncModule::~ViESyncModule() { | 61 ViESyncModule::~ViESyncModule() { |
| 65 } | 62 } |
| 66 | 63 |
| 67 void ViESyncModule::ConfigureSync(int voe_channel_id, | 64 void ViESyncModule::ConfigureSync(int voe_channel_id, |
| 68 VoEVideoSync* voe_sync_interface, | 65 VoEVideoSync* voe_sync_interface, |
| 69 RtpRtcp* video_rtcp_module, | 66 RtpRtcp* video_rtcp_module, |
| 70 RtpReceiver* video_receiver) { | 67 RtpReceiver* video_receiver) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 int audio_jitter_buffer_delay_ms = 0; | 103 int audio_jitter_buffer_delay_ms = 0; |
| 107 int playout_buffer_delay_ms = 0; | 104 int playout_buffer_delay_ms = 0; |
| 108 if (voe_sync_interface_->GetDelayEstimate(voe_channel_id_, | 105 if (voe_sync_interface_->GetDelayEstimate(voe_channel_id_, |
| 109 &audio_jitter_buffer_delay_ms, | 106 &audio_jitter_buffer_delay_ms, |
| 110 &playout_buffer_delay_ms) != 0) { | 107 &playout_buffer_delay_ms) != 0) { |
| 111 return; | 108 return; |
| 112 } | 109 } |
| 113 const int current_audio_delay_ms = audio_jitter_buffer_delay_ms + | 110 const int current_audio_delay_ms = audio_jitter_buffer_delay_ms + |
| 114 playout_buffer_delay_ms; | 111 playout_buffer_delay_ms; |
| 115 | 112 |
| 116 RtpRtcp* voice_rtp_rtcp = NULL; | 113 RtpRtcp* voice_rtp_rtcp = nullptr; |
| 117 RtpReceiver* voice_receiver = NULL; | 114 RtpReceiver* voice_receiver = nullptr; |
| 118 if (0 != voe_sync_interface_->GetRtpRtcp(voe_channel_id_, &voice_rtp_rtcp, | 115 if (voe_sync_interface_->GetRtpRtcp(voe_channel_id_, &voice_rtp_rtcp, |
| 119 &voice_receiver)) { | 116 &voice_receiver) != 0) { |
| 120 return; | 117 return; |
| 121 } | 118 } |
| 122 assert(voice_rtp_rtcp); | 119 assert(voice_rtp_rtcp); |
| 123 assert(voice_receiver); | 120 assert(voice_receiver); |
| 124 | 121 |
| 125 if (UpdateMeasurements(&video_measurement_, *video_rtp_rtcp_, | 122 if (UpdateMeasurements(&video_measurement_, *video_rtp_rtcp_, |
| 126 *video_receiver_) != 0) { | 123 *video_receiver_) != 0) { |
| 127 return; | 124 return; |
| 128 } | 125 } |
| 129 | 126 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 int64_t time_to_render_ms = | 184 int64_t time_to_render_ms = |
| 188 frame.render_time_ms() - clock_->TimeInMilliseconds(); | 185 frame.render_time_ms() - clock_->TimeInMilliseconds(); |
| 189 if (time_to_render_ms > 0) | 186 if (time_to_render_ms > 0) |
| 190 latest_video_ntp += time_to_render_ms; | 187 latest_video_ntp += time_to_render_ms; |
| 191 | 188 |
| 192 *stream_offset_ms = latest_audio_ntp - latest_video_ntp; | 189 *stream_offset_ms = latest_audio_ntp - latest_video_ntp; |
| 193 return true; | 190 return true; |
| 194 } | 191 } |
| 195 | 192 |
| 196 } // namespace webrtc | 193 } // namespace webrtc |
| OLD | NEW |