Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Side by Side Diff: webrtc/call/call.cc

Issue 1789903003: Replace scoped_ptr with unique_ptr in webrtc/call/ (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 <string.h> 11 #include <string.h>
12 12
13 #include <map> 13 #include <map>
14 #include <memory>
14 #include <vector> 15 #include <vector>
15 16
16 #include "webrtc/audio/audio_receive_stream.h" 17 #include "webrtc/audio/audio_receive_stream.h"
17 #include "webrtc/audio/audio_send_stream.h" 18 #include "webrtc/audio/audio_send_stream.h"
18 #include "webrtc/audio/audio_state.h" 19 #include "webrtc/audio/audio_state.h"
19 #include "webrtc/audio/scoped_voe_interface.h" 20 #include "webrtc/audio/scoped_voe_interface.h"
20 #include "webrtc/base/checks.h" 21 #include "webrtc/base/checks.h"
21 #include "webrtc/base/logging.h" 22 #include "webrtc/base/logging.h"
22 #include "webrtc/base/scoped_ptr.h"
23 #include "webrtc/base/thread_annotations.h" 23 #include "webrtc/base/thread_annotations.h"
24 #include "webrtc/base/thread_checker.h" 24 #include "webrtc/base/thread_checker.h"
25 #include "webrtc/base/trace_event.h" 25 #include "webrtc/base/trace_event.h"
26 #include "webrtc/call.h" 26 #include "webrtc/call.h"
27 #include "webrtc/call/bitrate_allocator.h" 27 #include "webrtc/call/bitrate_allocator.h"
28 #include "webrtc/call/rtc_event_log.h" 28 #include "webrtc/call/rtc_event_log.h"
29 #include "webrtc/config.h" 29 #include "webrtc/config.h"
30 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" 30 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h"
31 #include "webrtc/modules/congestion_controller/include/congestion_controller.h" 31 #include "webrtc/modules/congestion_controller/include/congestion_controller.h"
32 #include "webrtc/modules/pacing/paced_sender.h" 32 #include "webrtc/modules/pacing/paced_sender.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 else 113 else
114 return nullptr; 114 return nullptr;
115 } 115 }
116 116
117 void UpdateSendHistograms() EXCLUSIVE_LOCKS_REQUIRED(&bitrate_crit_); 117 void UpdateSendHistograms() EXCLUSIVE_LOCKS_REQUIRED(&bitrate_crit_);
118 void UpdateReceiveHistograms(); 118 void UpdateReceiveHistograms();
119 119
120 Clock* const clock_; 120 Clock* const clock_;
121 121
122 const int num_cpu_cores_; 122 const int num_cpu_cores_;
123 const rtc::scoped_ptr<ProcessThread> module_process_thread_; 123 const std::unique_ptr<ProcessThread> module_process_thread_;
124 const rtc::scoped_ptr<ProcessThread> pacer_thread_; 124 const std::unique_ptr<ProcessThread> pacer_thread_;
125 const rtc::scoped_ptr<CallStats> call_stats_; 125 const std::unique_ptr<CallStats> call_stats_;
126 const rtc::scoped_ptr<BitrateAllocator> bitrate_allocator_; 126 const std::unique_ptr<BitrateAllocator> bitrate_allocator_;
127 Call::Config config_; 127 Call::Config config_;
128 rtc::ThreadChecker configuration_thread_checker_; 128 rtc::ThreadChecker configuration_thread_checker_;
129 129
130 bool network_enabled_; 130 bool network_enabled_;
131 131
132 rtc::scoped_ptr<RWLockWrapper> receive_crit_; 132 std::unique_ptr<RWLockWrapper> receive_crit_;
133 // Audio and Video receive streams are owned by the client that creates them. 133 // Audio and Video receive streams are owned by the client that creates them.
134 std::map<uint32_t, AudioReceiveStream*> audio_receive_ssrcs_ 134 std::map<uint32_t, AudioReceiveStream*> audio_receive_ssrcs_
135 GUARDED_BY(receive_crit_); 135 GUARDED_BY(receive_crit_);
136 std::map<uint32_t, VideoReceiveStream*> video_receive_ssrcs_ 136 std::map<uint32_t, VideoReceiveStream*> video_receive_ssrcs_
137 GUARDED_BY(receive_crit_); 137 GUARDED_BY(receive_crit_);
138 std::set<VideoReceiveStream*> video_receive_streams_ 138 std::set<VideoReceiveStream*> video_receive_streams_
139 GUARDED_BY(receive_crit_); 139 GUARDED_BY(receive_crit_);
140 std::map<std::string, AudioReceiveStream*> sync_stream_mapping_ 140 std::map<std::string, AudioReceiveStream*> sync_stream_mapping_
141 GUARDED_BY(receive_crit_); 141 GUARDED_BY(receive_crit_);
142 142
143 rtc::scoped_ptr<RWLockWrapper> send_crit_; 143 std::unique_ptr<RWLockWrapper> send_crit_;
144 // Audio and Video send streams are owned by the client that creates them. 144 // Audio and Video send streams are owned by the client that creates them.
145 std::map<uint32_t, AudioSendStream*> audio_send_ssrcs_ GUARDED_BY(send_crit_); 145 std::map<uint32_t, AudioSendStream*> audio_send_ssrcs_ GUARDED_BY(send_crit_);
146 std::map<uint32_t, VideoSendStream*> video_send_ssrcs_ GUARDED_BY(send_crit_); 146 std::map<uint32_t, VideoSendStream*> video_send_ssrcs_ GUARDED_BY(send_crit_);
147 std::set<VideoSendStream*> video_send_streams_ GUARDED_BY(send_crit_); 147 std::set<VideoSendStream*> video_send_streams_ GUARDED_BY(send_crit_);
148 148
149 VideoSendStream::RtpStateMap suspended_video_send_ssrcs_; 149 VideoSendStream::RtpStateMap suspended_video_send_ssrcs_;
150 150
151 RtcEventLog* event_log_ = nullptr; 151 RtcEventLog* event_log_ = nullptr;
152 152
153 // The following members are only accessed (exclusively) from one thread and 153 // The following members are only accessed (exclusively) from one thread and
154 // from the destructor, and therefore doesn't need any explicit 154 // from the destructor, and therefore doesn't need any explicit
155 // synchronization. 155 // synchronization.
156 int64_t received_video_bytes_; 156 int64_t received_video_bytes_;
157 int64_t received_audio_bytes_; 157 int64_t received_audio_bytes_;
158 int64_t received_rtcp_bytes_; 158 int64_t received_rtcp_bytes_;
159 int64_t first_rtp_packet_received_ms_; 159 int64_t first_rtp_packet_received_ms_;
160 int64_t last_rtp_packet_received_ms_; 160 int64_t last_rtp_packet_received_ms_;
161 int64_t first_packet_sent_ms_; 161 int64_t first_packet_sent_ms_;
162 162
163 // TODO(holmer): Remove this lock once BitrateController no longer calls 163 // TODO(holmer): Remove this lock once BitrateController no longer calls
164 // OnNetworkChanged from multiple threads. 164 // OnNetworkChanged from multiple threads.
165 rtc::CriticalSection bitrate_crit_; 165 rtc::CriticalSection bitrate_crit_;
166 int64_t estimated_send_bitrate_sum_kbits_ GUARDED_BY(&bitrate_crit_); 166 int64_t estimated_send_bitrate_sum_kbits_ GUARDED_BY(&bitrate_crit_);
167 int64_t pacer_bitrate_sum_kbits_ GUARDED_BY(&bitrate_crit_); 167 int64_t pacer_bitrate_sum_kbits_ GUARDED_BY(&bitrate_crit_);
168 int64_t num_bitrate_updates_ GUARDED_BY(&bitrate_crit_); 168 int64_t num_bitrate_updates_ GUARDED_BY(&bitrate_crit_);
169 169
170 VieRemb remb_; 170 VieRemb remb_;
171 const rtc::scoped_ptr<CongestionController> congestion_controller_; 171 const std::unique_ptr<CongestionController> congestion_controller_;
172 172
173 RTC_DISALLOW_COPY_AND_ASSIGN(Call); 173 RTC_DISALLOW_COPY_AND_ASSIGN(Call);
174 }; 174 };
175 } // namespace internal 175 } // namespace internal
176 176
177 Call* Call::Create(const Call::Config& config) { 177 Call* Call::Create(const Call::Config& config) {
178 return new internal::Call(config); 178 return new internal::Call(config);
179 } 179 }
180 180
181 namespace internal { 181 namespace internal {
182 182
183 Call::Call(const Call::Config& config) 183 Call::Call(const Call::Config& config)
184 : clock_(Clock::GetRealTimeClock()), 184 : clock_(Clock::GetRealTimeClock()),
185 num_cpu_cores_(CpuInfo::DetectNumberOfCores()), 185 num_cpu_cores_(CpuInfo::DetectNumberOfCores()),
186 module_process_thread_(ProcessThread::Create("ModuleProcessThread")), 186 module_process_thread_(
187 pacer_thread_(ProcessThread::Create("PacerThread")), 187 rtc::ScopedToUnique(ProcessThread::Create("ModuleProcessThread"))),
188 pacer_thread_(rtc::ScopedToUnique(ProcessThread::Create("PacerThread"))),
188 call_stats_(new CallStats(clock_)), 189 call_stats_(new CallStats(clock_)),
189 bitrate_allocator_(new BitrateAllocator()), 190 bitrate_allocator_(new BitrateAllocator()),
190 config_(config), 191 config_(config),
191 network_enabled_(true), 192 network_enabled_(true),
192 receive_crit_(RWLockWrapper::CreateRWLock()), 193 receive_crit_(RWLockWrapper::CreateRWLock()),
193 send_crit_(RWLockWrapper::CreateRWLock()), 194 send_crit_(RWLockWrapper::CreateRWLock()),
194 received_video_bytes_(0), 195 received_video_bytes_(0),
195 received_audio_bytes_(0), 196 received_audio_bytes_(0),
196 received_rtcp_bytes_(0), 197 received_rtcp_bytes_(0),
197 first_rtp_packet_received_ms_(-1), 198 first_rtp_packet_received_ms_(-1),
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 // thread. Then this check can be enabled. 745 // thread. Then this check can be enabled.
745 // RTC_DCHECK(!configuration_thread_checker_.CalledOnValidThread()); 746 // RTC_DCHECK(!configuration_thread_checker_.CalledOnValidThread());
746 if (RtpHeaderParser::IsRtcp(packet, length)) 747 if (RtpHeaderParser::IsRtcp(packet, length))
747 return DeliverRtcp(media_type, packet, length); 748 return DeliverRtcp(media_type, packet, length);
748 749
749 return DeliverRtp(media_type, packet, length, packet_time); 750 return DeliverRtp(media_type, packet, length, packet_time);
750 } 751 }
751 752
752 } // namespace internal 753 } // namespace internal
753 } // namespace webrtc 754 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698