| 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 |
| 11 #include "webrtc/video/vie_sync_module.h" | 11 #include "webrtc/video/vie_sync_module.h" |
| 12 | 12 |
| 13 #include "webrtc/base/logging.h" | 13 #include "webrtc/base/logging.h" |
| 14 #include "webrtc/base/trace_event.h" | 14 #include "webrtc/base/trace_event.h" |
| 15 #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h" | 15 #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h" |
| 16 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" | 16 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" |
| 17 #include "webrtc/modules/video_coding/include/video_coding.h" | 17 #include "webrtc/modules/video_coding/include/video_coding.h" |
| 18 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" | |
| 19 #include "webrtc/video/stream_synchronization.h" | 18 #include "webrtc/video/stream_synchronization.h" |
| 20 #include "webrtc/voice_engine/include/voe_video_sync.h" | 19 #include "webrtc/voice_engine/include/voe_video_sync.h" |
| 21 | 20 |
| 22 namespace webrtc { | 21 namespace webrtc { |
| 23 | 22 |
| 24 int UpdateMeasurements(StreamSynchronization::Measurements* stream, | 23 int UpdateMeasurements(StreamSynchronization::Measurements* stream, |
| 25 const RtpRtcp& rtp_rtcp, const RtpReceiver& receiver) { | 24 const RtpRtcp& rtp_rtcp, const RtpReceiver& receiver) { |
| 26 if (!receiver.Timestamp(&stream->latest_timestamp)) | 25 if (!receiver.Timestamp(&stream->latest_timestamp)) |
| 27 return -1; | 26 return -1; |
| 28 if (!receiver.LastReceivedTimeMs(&stream->latest_receive_time_ms)) | 27 if (!receiver.LastReceivedTimeMs(&stream->latest_receive_time_ms)) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 42 bool new_rtcp_sr = false; | 41 bool new_rtcp_sr = false; |
| 43 if (!UpdateRtcpList( | 42 if (!UpdateRtcpList( |
| 44 ntp_secs, ntp_frac, rtp_timestamp, &stream->rtcp, &new_rtcp_sr)) { | 43 ntp_secs, ntp_frac, rtp_timestamp, &stream->rtcp, &new_rtcp_sr)) { |
| 45 return -1; | 44 return -1; |
| 46 } | 45 } |
| 47 | 46 |
| 48 return 0; | 47 return 0; |
| 49 } | 48 } |
| 50 | 49 |
| 51 ViESyncModule::ViESyncModule(VideoCodingModule* vcm) | 50 ViESyncModule::ViESyncModule(VideoCodingModule* vcm) |
| 52 : data_cs_(CriticalSectionWrapper::CreateCriticalSection()), | 51 : vcm_(vcm), |
| 53 vcm_(vcm), | |
| 54 video_receiver_(NULL), | 52 video_receiver_(NULL), |
| 55 video_rtp_rtcp_(NULL), | 53 video_rtp_rtcp_(NULL), |
| 56 voe_channel_id_(-1), | 54 voe_channel_id_(-1), |
| 57 voe_sync_interface_(NULL), | 55 voe_sync_interface_(NULL), |
| 58 last_sync_time_(TickTime::Now()), | 56 last_sync_time_(TickTime::Now()), |
| 59 sync_() { | 57 sync_() { |
| 60 } | 58 } |
| 61 | 59 |
| 62 ViESyncModule::~ViESyncModule() { | 60 ViESyncModule::~ViESyncModule() { |
| 63 } | 61 } |
| 64 | 62 |
| 65 int ViESyncModule::ConfigureSync(int voe_channel_id, | 63 int ViESyncModule::ConfigureSync(int voe_channel_id, |
| 66 VoEVideoSync* voe_sync_interface, | 64 VoEVideoSync* voe_sync_interface, |
| 67 RtpRtcp* video_rtcp_module, | 65 RtpRtcp* video_rtcp_module, |
| 68 RtpReceiver* video_receiver) { | 66 RtpReceiver* video_receiver) { |
| 69 CriticalSectionScoped cs(data_cs_.get()); | 67 rtc::CritScope lock(&data_cs_); |
| 70 // Prevent expensive no-ops. | 68 // Prevent expensive no-ops. |
| 71 if (voe_channel_id_ == voe_channel_id && | 69 if (voe_channel_id_ == voe_channel_id && |
| 72 voe_sync_interface_ == voe_sync_interface && | 70 voe_sync_interface_ == voe_sync_interface && |
| 73 video_receiver_ == video_receiver && | 71 video_receiver_ == video_receiver && |
| 74 video_rtp_rtcp_ == video_rtcp_module) { | 72 video_rtp_rtcp_ == video_rtcp_module) { |
| 75 return 0; | 73 return 0; |
| 76 } | 74 } |
| 77 voe_channel_id_ = voe_channel_id; | 75 voe_channel_id_ = voe_channel_id; |
| 78 voe_sync_interface_ = voe_sync_interface; | 76 voe_sync_interface_ = voe_sync_interface; |
| 79 video_receiver_ = video_receiver; | 77 video_receiver_ = video_receiver; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 95 int ViESyncModule::VoiceChannel() { | 93 int ViESyncModule::VoiceChannel() { |
| 96 return voe_channel_id_; | 94 return voe_channel_id_; |
| 97 } | 95 } |
| 98 | 96 |
| 99 int64_t ViESyncModule::TimeUntilNextProcess() { | 97 int64_t ViESyncModule::TimeUntilNextProcess() { |
| 100 const int64_t kSyncIntervalMs = 1000; | 98 const int64_t kSyncIntervalMs = 1000; |
| 101 return kSyncIntervalMs - (TickTime::Now() - last_sync_time_).Milliseconds(); | 99 return kSyncIntervalMs - (TickTime::Now() - last_sync_time_).Milliseconds(); |
| 102 } | 100 } |
| 103 | 101 |
| 104 int32_t ViESyncModule::Process() { | 102 int32_t ViESyncModule::Process() { |
| 105 CriticalSectionScoped cs(data_cs_.get()); | 103 rtc::CritScope lock(&data_cs_); |
| 106 last_sync_time_ = TickTime::Now(); | 104 last_sync_time_ = TickTime::Now(); |
| 107 | 105 |
| 108 const int current_video_delay_ms = vcm_->Delay(); | 106 const int current_video_delay_ms = vcm_->Delay(); |
| 109 | 107 |
| 110 if (voe_channel_id_ == -1) { | 108 if (voe_channel_id_ == -1) { |
| 111 return 0; | 109 return 0; |
| 112 } | 110 } |
| 113 assert(video_rtp_rtcp_ && voe_sync_interface_); | 111 assert(video_rtp_rtcp_ && voe_sync_interface_); |
| 114 assert(sync_.get()); | 112 assert(sync_.get()); |
| 115 | 113 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 | 163 |
| 166 if (voe_sync_interface_->SetMinimumPlayoutDelay( | 164 if (voe_sync_interface_->SetMinimumPlayoutDelay( |
| 167 voe_channel_id_, target_audio_delay_ms) == -1) { | 165 voe_channel_id_, target_audio_delay_ms) == -1) { |
| 168 LOG(LS_ERROR) << "Error setting voice delay."; | 166 LOG(LS_ERROR) << "Error setting voice delay."; |
| 169 } | 167 } |
| 170 vcm_->SetMinimumPlayoutDelay(target_video_delay_ms); | 168 vcm_->SetMinimumPlayoutDelay(target_video_delay_ms); |
| 171 return 0; | 169 return 0; |
| 172 } | 170 } |
| 173 | 171 |
| 174 } // namespace webrtc | 172 } // namespace webrtc |
| OLD | NEW |