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

Side by Side Diff: webrtc/pc/channel.cc

Issue 2685783014: Replace NULL with nullptr in all C++ files. (Closed)
Patch Set: Fixing android. Created 3 years, 10 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 2004 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2004 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 static bool IsReceiveContentDirection(MediaContentDirection direction) { 118 static bool IsReceiveContentDirection(MediaContentDirection direction) {
119 return direction == MD_SENDRECV || direction == MD_RECVONLY; 119 return direction == MD_SENDRECV || direction == MD_RECVONLY;
120 } 120 }
121 121
122 static bool IsSendContentDirection(MediaContentDirection direction) { 122 static bool IsSendContentDirection(MediaContentDirection direction) {
123 return direction == MD_SENDRECV || direction == MD_SENDONLY; 123 return direction == MD_SENDRECV || direction == MD_SENDONLY;
124 } 124 }
125 125
126 static const MediaContentDescription* GetContentDescription( 126 static const MediaContentDescription* GetContentDescription(
127 const ContentInfo* cinfo) { 127 const ContentInfo* cinfo) {
128 if (cinfo == NULL) 128 if (cinfo == nullptr)
129 return NULL; 129 return nullptr;
130 return static_cast<const MediaContentDescription*>(cinfo->description); 130 return static_cast<const MediaContentDescription*>(cinfo->description);
131 } 131 }
132 132
133 template <class Codec> 133 template <class Codec>
134 void RtpParametersFromMediaDescription( 134 void RtpParametersFromMediaDescription(
135 const MediaContentDescriptionImpl<Codec>* desc, 135 const MediaContentDescriptionImpl<Codec>* desc,
136 RtpParameters<Codec>* params) { 136 RtpParameters<Codec>* params) {
137 // TODO(pthatcher): Remove this once we're sure no one will give us 137 // TODO(pthatcher): Remove this once we're sure no one will give us
138 // a description without codecs (currently a CA_UPDATE with just 138 // a description without codecs (currently a CA_UPDATE with just
139 // streams can). 139 // streams can).
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 177
178 BaseChannel::~BaseChannel() { 178 BaseChannel::~BaseChannel() {
179 TRACE_EVENT0("webrtc", "BaseChannel::~BaseChannel"); 179 TRACE_EVENT0("webrtc", "BaseChannel::~BaseChannel");
180 RTC_DCHECK(worker_thread_ == rtc::Thread::Current()); 180 RTC_DCHECK(worker_thread_ == rtc::Thread::Current());
181 Deinit(); 181 Deinit();
182 StopConnectionMonitor(); 182 StopConnectionMonitor();
183 // Eats any outstanding messages or packets. 183 // Eats any outstanding messages or packets.
184 worker_thread_->Clear(&invoker_); 184 worker_thread_->Clear(&invoker_);
185 worker_thread_->Clear(this); 185 worker_thread_->Clear(this);
186 // We must destroy the media channel before the transport channel, otherwise 186 // We must destroy the media channel before the transport channel, otherwise
187 // the media channel may try to send on the dead transport channel. NULLing 187 // the media channel may try to send on the dead transport channel. nulling
188 // is not an effective strategy since the sends will come on another thread. 188 // is not an effective strategy since the sends will come on another thread.
189 delete media_channel_; 189 delete media_channel_;
190 LOG(LS_INFO) << "Destroyed channel: " << content_name_; 190 LOG(LS_INFO) << "Destroyed channel: " << content_name_;
191 } 191 }
192 192
193 void BaseChannel::DisconnectTransportChannels_n() { 193 void BaseChannel::DisconnectTransportChannels_n() {
194 // Send any outstanding RTCP packets. 194 // Send any outstanding RTCP packets.
195 FlushRtcpMessages_n(); 195 FlushRtcpMessages_n();
196 196
197 // Stop signals from transport channels, but keep them alive because 197 // Stop signals from transport channels, but keep them alive because
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 return false; 247 return false;
248 } 248 }
249 if (rtcp_mux_required_) { 249 if (rtcp_mux_required_) {
250 rtcp_mux_filter_.SetActive(); 250 rtcp_mux_filter_.SetActive();
251 } 251 }
252 return true; 252 return true;
253 } 253 }
254 254
255 void BaseChannel::Deinit() { 255 void BaseChannel::Deinit() {
256 RTC_DCHECK(worker_thread_->IsCurrent()); 256 RTC_DCHECK(worker_thread_->IsCurrent());
257 media_channel_->SetInterface(NULL); 257 media_channel_->SetInterface(nullptr);
258 // Packets arrive on the network thread, processing packets calls virtual 258 // Packets arrive on the network thread, processing packets calls virtual
259 // functions, so need to stop this process in Deinit that is called in 259 // functions, so need to stop this process in Deinit that is called in
260 // derived classes destructor. 260 // derived classes destructor.
261 network_thread_->Invoke<void>( 261 network_thread_->Invoke<void>(
262 RTC_FROM_HERE, Bind(&BaseChannel::DisconnectTransportChannels_n, this)); 262 RTC_FROM_HERE, Bind(&BaseChannel::DisconnectTransportChannels_n, this));
263 } 263 }
264 264
265 void BaseChannel::SetTransports(DtlsTransportInternal* rtp_dtls_transport, 265 void BaseChannel::SetTransports(DtlsTransportInternal* rtp_dtls_transport,
266 DtlsTransportInternal* rtcp_dtls_transport) { 266 DtlsTransportInternal* rtcp_dtls_transport) {
267 network_thread_->Invoke<void>( 267 network_thread_->Invoke<void>(
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 res = srtp_filter_.ProtectRtp( 740 res = srtp_filter_.ProtectRtp(
741 data, len, static_cast<int>(packet->capacity()), &len); 741 data, len, static_cast<int>(packet->capacity()), &len);
742 #else 742 #else
743 updated_options.packet_time_params.rtp_sendtime_extension_id = 743 updated_options.packet_time_params.rtp_sendtime_extension_id =
744 rtp_abs_sendtime_extn_id_; 744 rtp_abs_sendtime_extn_id_;
745 res = srtp_filter_.ProtectRtp( 745 res = srtp_filter_.ProtectRtp(
746 data, len, static_cast<int>(packet->capacity()), &len, 746 data, len, static_cast<int>(packet->capacity()), &len,
747 &updated_options.packet_time_params.srtp_packet_index); 747 &updated_options.packet_time_params.srtp_packet_index);
748 // If protection succeeds, let's get auth params from srtp. 748 // If protection succeeds, let's get auth params from srtp.
749 if (res) { 749 if (res) {
750 uint8_t* auth_key = NULL; 750 uint8_t* auth_key = nullptr;
751 int key_len; 751 int key_len;
752 res = srtp_filter_.GetRtpAuthParams( 752 res = srtp_filter_.GetRtpAuthParams(
753 &auth_key, &key_len, 753 &auth_key, &key_len,
754 &updated_options.packet_time_params.srtp_auth_tag_len); 754 &updated_options.packet_time_params.srtp_auth_tag_len);
755 if (res) { 755 if (res) {
756 updated_options.packet_time_params.srtp_auth_key.resize(key_len); 756 updated_options.packet_time_params.srtp_auth_key.resize(key_len);
757 updated_options.packet_time_params.srtp_auth_key.assign( 757 updated_options.packet_time_params.srtp_auth_key.assign(
758 auth_key, auth_key + key_len); 758 auth_key, auth_key + key_len);
759 } 759 }
760 } 760 }
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 if (!rtc::GetSrtpKeyAndSaltLengths(selected_crypto_suite, &key_len, 1044 if (!rtc::GetSrtpKeyAndSaltLengths(selected_crypto_suite, &key_len,
1045 &salt_len)) { 1045 &salt_len)) {
1046 LOG(LS_ERROR) << "Unknown DTLS-SRTP crypto suite" << selected_crypto_suite; 1046 LOG(LS_ERROR) << "Unknown DTLS-SRTP crypto suite" << selected_crypto_suite;
1047 return false; 1047 return false;
1048 } 1048 }
1049 1049
1050 // OK, we're now doing DTLS (RFC 5764) 1050 // OK, we're now doing DTLS (RFC 5764)
1051 std::vector<unsigned char> dtls_buffer(key_len * 2 + salt_len * 2); 1051 std::vector<unsigned char> dtls_buffer(key_len * 2 + salt_len * 2);
1052 1052
1053 // RFC 5705 exporter using the RFC 5764 parameters 1053 // RFC 5705 exporter using the RFC 5764 parameters
1054 if (!transport->ExportKeyingMaterial(kDtlsSrtpExporterLabel, NULL, 0, false, 1054 if (!transport->ExportKeyingMaterial(kDtlsSrtpExporterLabel, nullptr, 0,
1055 &dtls_buffer[0], dtls_buffer.size())) { 1055 false, &dtls_buffer[0],
1056 dtls_buffer.size())) {
1056 LOG(LS_WARNING) << "DTLS-SRTP key export failed"; 1057 LOG(LS_WARNING) << "DTLS-SRTP key export failed";
1057 RTC_NOTREACHED(); // This should never happen 1058 RTC_NOTREACHED(); // This should never happen
1058 return false; 1059 return false;
1059 } 1060 }
1060 1061
1061 // Sync up the keys with the DTLS-SRTP interface 1062 // Sync up the keys with the DTLS-SRTP interface
1062 std::vector<unsigned char> client_write_key(key_len + salt_len); 1063 std::vector<unsigned char> client_write_key(key_len + salt_len);
1063 std::vector<unsigned char> server_write_key(key_len + salt_len); 1064 std::vector<unsigned char> server_write_key(key_len + salt_len);
1064 size_t offset = 0; 1065 size_t offset = 0;
1065 memcpy(&client_write_key[0], &dtls_buffer[offset], key_len); 1066 memcpy(&client_write_key[0], &dtls_buffer[offset], key_len);
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
1675 } 1676 }
1676 1677
1677 void VoiceChannel::StopAudioMonitor() { 1678 void VoiceChannel::StopAudioMonitor() {
1678 if (audio_monitor_) { 1679 if (audio_monitor_) {
1679 audio_monitor_->Stop(); 1680 audio_monitor_->Stop();
1680 audio_monitor_.reset(); 1681 audio_monitor_.reset();
1681 } 1682 }
1682 } 1683 }
1683 1684
1684 bool VoiceChannel::IsAudioMonitorRunning() const { 1685 bool VoiceChannel::IsAudioMonitorRunning() const {
1685 return (audio_monitor_.get() != NULL); 1686 return (audio_monitor_.get() != nullptr);
1686 } 1687 }
1687 1688
1688 int VoiceChannel::GetInputLevel_w() { 1689 int VoiceChannel::GetInputLevel_w() {
1689 return media_engine_->GetInputLevel(); 1690 return media_engine_->GetInputLevel();
1690 } 1691 }
1691 1692
1692 int VoiceChannel::GetOutputLevel_w() { 1693 int VoiceChannel::GetOutputLevel_w() {
1693 return media_channel()->GetOutputLevel(); 1694 return media_channel()->GetOutputLevel();
1694 } 1695 }
1695 1696
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1779 1780
1780 bool VoiceChannel::SetLocalContent_w(const MediaContentDescription* content, 1781 bool VoiceChannel::SetLocalContent_w(const MediaContentDescription* content,
1781 ContentAction action, 1782 ContentAction action,
1782 std::string* error_desc) { 1783 std::string* error_desc) {
1783 TRACE_EVENT0("webrtc", "VoiceChannel::SetLocalContent_w"); 1784 TRACE_EVENT0("webrtc", "VoiceChannel::SetLocalContent_w");
1784 RTC_DCHECK(worker_thread() == rtc::Thread::Current()); 1785 RTC_DCHECK(worker_thread() == rtc::Thread::Current());
1785 LOG(LS_INFO) << "Setting local voice description"; 1786 LOG(LS_INFO) << "Setting local voice description";
1786 1787
1787 const AudioContentDescription* audio = 1788 const AudioContentDescription* audio =
1788 static_cast<const AudioContentDescription*>(content); 1789 static_cast<const AudioContentDescription*>(content);
1789 RTC_DCHECK(audio != NULL); 1790 RTC_DCHECK(audio != nullptr);
1790 if (!audio) { 1791 if (!audio) {
1791 SafeSetError("Can't find audio content in local description.", error_desc); 1792 SafeSetError("Can't find audio content in local description.", error_desc);
1792 return false; 1793 return false;
1793 } 1794 }
1794 1795
1795 if (!SetRtpTransportParameters(content, action, CS_LOCAL, error_desc)) { 1796 if (!SetRtpTransportParameters(content, action, CS_LOCAL, error_desc)) {
1796 return false; 1797 return false;
1797 } 1798 }
1798 1799
1799 AudioRecvParameters recv_params = last_recv_params_; 1800 AudioRecvParameters recv_params = last_recv_params_;
(...skipping 24 matching lines...) Expand all
1824 1825
1825 bool VoiceChannel::SetRemoteContent_w(const MediaContentDescription* content, 1826 bool VoiceChannel::SetRemoteContent_w(const MediaContentDescription* content,
1826 ContentAction action, 1827 ContentAction action,
1827 std::string* error_desc) { 1828 std::string* error_desc) {
1828 TRACE_EVENT0("webrtc", "VoiceChannel::SetRemoteContent_w"); 1829 TRACE_EVENT0("webrtc", "VoiceChannel::SetRemoteContent_w");
1829 RTC_DCHECK(worker_thread() == rtc::Thread::Current()); 1830 RTC_DCHECK(worker_thread() == rtc::Thread::Current());
1830 LOG(LS_INFO) << "Setting remote voice description"; 1831 LOG(LS_INFO) << "Setting remote voice description";
1831 1832
1832 const AudioContentDescription* audio = 1833 const AudioContentDescription* audio =
1833 static_cast<const AudioContentDescription*>(content); 1834 static_cast<const AudioContentDescription*>(content);
1834 RTC_DCHECK(audio != NULL); 1835 RTC_DCHECK(audio != nullptr);
1835 if (!audio) { 1836 if (!audio) {
1836 SafeSetError("Can't find audio content in remote description.", error_desc); 1837 SafeSetError("Can't find audio content in remote description.", error_desc);
1837 return false; 1838 return false;
1838 } 1839 }
1839 1840
1840 if (!SetRtpTransportParameters(content, action, CS_REMOTE, error_desc)) { 1841 if (!SetRtpTransportParameters(content, action, CS_REMOTE, error_desc)) {
1841 return false; 1842 return false;
1842 } 1843 }
1843 1844
1844 AudioSendParameters send_params = last_send_params_; 1845 AudioSendParameters send_params = last_send_params_;
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
2057 2058
2058 bool VideoChannel::SetLocalContent_w(const MediaContentDescription* content, 2059 bool VideoChannel::SetLocalContent_w(const MediaContentDescription* content,
2059 ContentAction action, 2060 ContentAction action,
2060 std::string* error_desc) { 2061 std::string* error_desc) {
2061 TRACE_EVENT0("webrtc", "VideoChannel::SetLocalContent_w"); 2062 TRACE_EVENT0("webrtc", "VideoChannel::SetLocalContent_w");
2062 RTC_DCHECK(worker_thread() == rtc::Thread::Current()); 2063 RTC_DCHECK(worker_thread() == rtc::Thread::Current());
2063 LOG(LS_INFO) << "Setting local video description"; 2064 LOG(LS_INFO) << "Setting local video description";
2064 2065
2065 const VideoContentDescription* video = 2066 const VideoContentDescription* video =
2066 static_cast<const VideoContentDescription*>(content); 2067 static_cast<const VideoContentDescription*>(content);
2067 RTC_DCHECK(video != NULL); 2068 RTC_DCHECK(video != nullptr);
2068 if (!video) { 2069 if (!video) {
2069 SafeSetError("Can't find video content in local description.", error_desc); 2070 SafeSetError("Can't find video content in local description.", error_desc);
2070 return false; 2071 return false;
2071 } 2072 }
2072 2073
2073 if (!SetRtpTransportParameters(content, action, CS_LOCAL, error_desc)) { 2074 if (!SetRtpTransportParameters(content, action, CS_LOCAL, error_desc)) {
2074 return false; 2075 return false;
2075 } 2076 }
2076 2077
2077 VideoRecvParameters recv_params = last_recv_params_; 2078 VideoRecvParameters recv_params = last_recv_params_;
(...skipping 24 matching lines...) Expand all
2102 2103
2103 bool VideoChannel::SetRemoteContent_w(const MediaContentDescription* content, 2104 bool VideoChannel::SetRemoteContent_w(const MediaContentDescription* content,
2104 ContentAction action, 2105 ContentAction action,
2105 std::string* error_desc) { 2106 std::string* error_desc) {
2106 TRACE_EVENT0("webrtc", "VideoChannel::SetRemoteContent_w"); 2107 TRACE_EVENT0("webrtc", "VideoChannel::SetRemoteContent_w");
2107 RTC_DCHECK(worker_thread() == rtc::Thread::Current()); 2108 RTC_DCHECK(worker_thread() == rtc::Thread::Current());
2108 LOG(LS_INFO) << "Setting remote video description"; 2109 LOG(LS_INFO) << "Setting remote video description";
2109 2110
2110 const VideoContentDescription* video = 2111 const VideoContentDescription* video =
2111 static_cast<const VideoContentDescription*>(content); 2112 static_cast<const VideoContentDescription*>(content);
2112 RTC_DCHECK(video != NULL); 2113 RTC_DCHECK(video != nullptr);
2113 if (!video) { 2114 if (!video) {
2114 SafeSetError("Can't find video content in remote description.", error_desc); 2115 SafeSetError("Can't find video content in remote description.", error_desc);
2115 return false; 2116 return false;
2116 } 2117 }
2117 2118
2118 if (!SetRtpTransportParameters(content, action, CS_REMOTE, error_desc)) { 2119 if (!SetRtpTransportParameters(content, action, CS_REMOTE, error_desc)) {
2119 return false; 2120 return false;
2120 } 2121 }
2121 2122
2122 VideoSendParameters send_params = last_send_params_; 2123 VideoSendParameters send_params = last_send_params_;
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
2253 2254
2254 bool RtpDataChannel::SetLocalContent_w(const MediaContentDescription* content, 2255 bool RtpDataChannel::SetLocalContent_w(const MediaContentDescription* content,
2255 ContentAction action, 2256 ContentAction action,
2256 std::string* error_desc) { 2257 std::string* error_desc) {
2257 TRACE_EVENT0("webrtc", "RtpDataChannel::SetLocalContent_w"); 2258 TRACE_EVENT0("webrtc", "RtpDataChannel::SetLocalContent_w");
2258 RTC_DCHECK(worker_thread() == rtc::Thread::Current()); 2259 RTC_DCHECK(worker_thread() == rtc::Thread::Current());
2259 LOG(LS_INFO) << "Setting local data description"; 2260 LOG(LS_INFO) << "Setting local data description";
2260 2261
2261 const DataContentDescription* data = 2262 const DataContentDescription* data =
2262 static_cast<const DataContentDescription*>(content); 2263 static_cast<const DataContentDescription*>(content);
2263 RTC_DCHECK(data != NULL); 2264 RTC_DCHECK(data != nullptr);
2264 if (!data) { 2265 if (!data) {
2265 SafeSetError("Can't find data content in local description.", error_desc); 2266 SafeSetError("Can't find data content in local description.", error_desc);
2266 return false; 2267 return false;
2267 } 2268 }
2268 2269
2269 if (!CheckDataChannelTypeFromContent(data, error_desc)) { 2270 if (!CheckDataChannelTypeFromContent(data, error_desc)) {
2270 return false; 2271 return false;
2271 } 2272 }
2272 2273
2273 if (!SetRtpTransportParameters(content, action, CS_LOCAL, error_desc)) { 2274 if (!SetRtpTransportParameters(content, action, CS_LOCAL, error_desc)) {
(...skipping 27 matching lines...) Expand all
2301 } 2302 }
2302 2303
2303 bool RtpDataChannel::SetRemoteContent_w(const MediaContentDescription* content, 2304 bool RtpDataChannel::SetRemoteContent_w(const MediaContentDescription* content,
2304 ContentAction action, 2305 ContentAction action,
2305 std::string* error_desc) { 2306 std::string* error_desc) {
2306 TRACE_EVENT0("webrtc", "RtpDataChannel::SetRemoteContent_w"); 2307 TRACE_EVENT0("webrtc", "RtpDataChannel::SetRemoteContent_w");
2307 RTC_DCHECK(worker_thread() == rtc::Thread::Current()); 2308 RTC_DCHECK(worker_thread() == rtc::Thread::Current());
2308 2309
2309 const DataContentDescription* data = 2310 const DataContentDescription* data =
2310 static_cast<const DataContentDescription*>(content); 2311 static_cast<const DataContentDescription*>(content);
2311 RTC_DCHECK(data != NULL); 2312 RTC_DCHECK(data != nullptr);
2312 if (!data) { 2313 if (!data) {
2313 SafeSetError("Can't find data content in remote description.", error_desc); 2314 SafeSetError("Can't find data content in remote description.", error_desc);
2314 return false; 2315 return false;
2315 } 2316 }
2316 2317
2317 // If the remote data doesn't have codecs and isn't an update, it 2318 // If the remote data doesn't have codecs and isn't an update, it
2318 // must be empty, so ignore it. 2319 // must be empty, so ignore it.
2319 if (!data->has_codecs() && action != CA_UPDATE) { 2320 if (!data->has_codecs() && action != CA_UPDATE) {
2320 return true; 2321 return true;
2321 } 2322 }
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
2453 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_READYTOSENDDATA, 2454 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_READYTOSENDDATA,
2454 new DataChannelReadyToSendMessageData(writable)); 2455 new DataChannelReadyToSendMessageData(writable));
2455 } 2456 }
2456 2457
2457 void RtpDataChannel::GetSrtpCryptoSuites_n( 2458 void RtpDataChannel::GetSrtpCryptoSuites_n(
2458 std::vector<int>* crypto_suites) const { 2459 std::vector<int>* crypto_suites) const {
2459 GetSupportedDataCryptoSuites(crypto_options(), crypto_suites); 2460 GetSupportedDataCryptoSuites(crypto_options(), crypto_suites);
2460 } 2461 }
2461 2462
2462 } // namespace cricket 2463 } // namespace cricket
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698