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/checks.h" |
13 #include "webrtc/base/logging.h" | 14 #include "webrtc/base/logging.h" |
14 #include "webrtc/base/trace_event.h" | 15 #include "webrtc/base/trace_event.h" |
15 #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h" | 16 #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h" |
16 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" | 17 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" |
17 #include "webrtc/modules/video_coding/include/video_coding.h" | 18 #include "webrtc/modules/video_coding/include/video_coding.h" |
18 #include "webrtc/video/stream_synchronization.h" | 19 #include "webrtc/video/stream_synchronization.h" |
19 #include "webrtc/voice_engine/include/voe_video_sync.h" | 20 #include "webrtc/voice_engine/include/voe_video_sync.h" |
20 | 21 |
21 namespace webrtc { | 22 namespace webrtc { |
22 | 23 |
(...skipping 30 matching lines...) Expand all Loading... |
53 video_rtp_rtcp_(NULL), | 54 video_rtp_rtcp_(NULL), |
54 voe_channel_id_(-1), | 55 voe_channel_id_(-1), |
55 voe_sync_interface_(NULL), | 56 voe_sync_interface_(NULL), |
56 last_sync_time_(TickTime::Now()), | 57 last_sync_time_(TickTime::Now()), |
57 sync_() { | 58 sync_() { |
58 } | 59 } |
59 | 60 |
60 ViESyncModule::~ViESyncModule() { | 61 ViESyncModule::~ViESyncModule() { |
61 } | 62 } |
62 | 63 |
63 int ViESyncModule::ConfigureSync(int voe_channel_id, | 64 void ViESyncModule::ConfigureSync(int voe_channel_id, |
64 VoEVideoSync* voe_sync_interface, | 65 VoEVideoSync* voe_sync_interface, |
65 RtpRtcp* video_rtcp_module, | 66 RtpRtcp* video_rtcp_module, |
66 RtpReceiver* video_receiver) { | 67 RtpReceiver* video_receiver) { |
| 68 if (voe_channel_id != -1) |
| 69 RTC_DCHECK(voe_sync_interface); |
67 rtc::CritScope lock(&data_cs_); | 70 rtc::CritScope lock(&data_cs_); |
68 // Prevent expensive no-ops. | 71 // Prevent expensive no-ops. |
69 if (voe_channel_id_ == voe_channel_id && | 72 if (voe_channel_id_ == voe_channel_id && |
70 voe_sync_interface_ == voe_sync_interface && | 73 voe_sync_interface_ == voe_sync_interface && |
71 video_receiver_ == video_receiver && | 74 video_receiver_ == video_receiver && |
72 video_rtp_rtcp_ == video_rtcp_module) { | 75 video_rtp_rtcp_ == video_rtcp_module) { |
73 return 0; | 76 return; |
74 } | 77 } |
75 voe_channel_id_ = voe_channel_id; | 78 voe_channel_id_ = voe_channel_id; |
76 voe_sync_interface_ = voe_sync_interface; | 79 voe_sync_interface_ = voe_sync_interface; |
77 video_receiver_ = video_receiver; | 80 video_receiver_ = video_receiver; |
78 video_rtp_rtcp_ = video_rtcp_module; | 81 video_rtp_rtcp_ = video_rtcp_module; |
79 sync_.reset( | 82 sync_.reset( |
80 new StreamSynchronization(video_rtp_rtcp_->SSRC(), voe_channel_id)); | 83 new StreamSynchronization(video_rtp_rtcp_->SSRC(), voe_channel_id)); |
81 | |
82 if (!voe_sync_interface) { | |
83 voe_channel_id_ = -1; | |
84 if (voe_channel_id >= 0) { | |
85 // Trying to set a voice channel but no interface exist. | |
86 return -1; | |
87 } | |
88 return 0; | |
89 } | |
90 return 0; | |
91 } | |
92 | |
93 int ViESyncModule::VoiceChannel() { | |
94 return voe_channel_id_; | |
95 } | 84 } |
96 | 85 |
97 int64_t ViESyncModule::TimeUntilNextProcess() { | 86 int64_t ViESyncModule::TimeUntilNextProcess() { |
98 const int64_t kSyncIntervalMs = 1000; | 87 const int64_t kSyncIntervalMs = 1000; |
99 return kSyncIntervalMs - (TickTime::Now() - last_sync_time_).Milliseconds(); | 88 return kSyncIntervalMs - (TickTime::Now() - last_sync_time_).Milliseconds(); |
100 } | 89 } |
101 | 90 |
102 int32_t ViESyncModule::Process() { | 91 int32_t ViESyncModule::Process() { |
103 rtc::CritScope lock(&data_cs_); | 92 rtc::CritScope lock(&data_cs_); |
104 last_sync_time_ = TickTime::Now(); | 93 last_sync_time_ = TickTime::Now(); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 | 152 |
164 if (voe_sync_interface_->SetMinimumPlayoutDelay( | 153 if (voe_sync_interface_->SetMinimumPlayoutDelay( |
165 voe_channel_id_, target_audio_delay_ms) == -1) { | 154 voe_channel_id_, target_audio_delay_ms) == -1) { |
166 LOG(LS_ERROR) << "Error setting voice delay."; | 155 LOG(LS_ERROR) << "Error setting voice delay."; |
167 } | 156 } |
168 vcm_->SetMinimumPlayoutDelay(target_video_delay_ms); | 157 vcm_->SetMinimumPlayoutDelay(target_video_delay_ms); |
169 return 0; | 158 return 0; |
170 } | 159 } |
171 | 160 |
172 } // namespace webrtc | 161 } // namespace webrtc |
OLD | NEW |