| OLD | NEW |
| 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 |
| 11 #include "webrtc/pc/channelmanager.h" | 11 #include "webrtc/pc/channelmanager.h" |
| 12 | 12 |
| 13 #include <algorithm> | 13 #include <algorithm> |
| 14 | 14 |
| 15 #include "webrtc/base/bind.h" | 15 #include "webrtc/base/bind.h" |
| 16 #include "webrtc/base/checks.h" | 16 #include "webrtc/base/checks.h" |
| 17 #include "webrtc/base/logging.h" | 17 #include "webrtc/base/logging.h" |
| 18 #include "webrtc/base/stringencode.h" | 18 #include "webrtc/base/stringencode.h" |
| 19 #include "webrtc/base/stringutils.h" | 19 #include "webrtc/base/stringutils.h" |
| 20 #include "webrtc/base/trace_event.h" | 20 #include "webrtc/base/trace_event.h" |
| 21 #include "webrtc/media/base/device.h" | 21 #include "webrtc/media/base/device.h" |
| 22 #include "webrtc/media/base/rtpdataengine.h" | 22 #include "webrtc/media/base/rtpdataengine.h" |
| 23 #include "webrtc/pc/srtpfilter.h" | 23 #include "webrtc/pc/srtpfilter.h" |
| 24 #include "webrtc/pc/mediacontroller.h" | |
| 25 | 24 |
| 26 namespace cricket { | 25 namespace cricket { |
| 27 | 26 |
| 28 | 27 |
| 29 using rtc::Bind; | 28 using rtc::Bind; |
| 30 | 29 |
| 31 ChannelManager::ChannelManager(std::unique_ptr<MediaEngineInterface> me, | 30 ChannelManager::ChannelManager(std::unique_ptr<MediaEngineInterface> me, |
| 32 std::unique_ptr<DataEngineInterface> dme, | 31 std::unique_ptr<DataEngineInterface> dme, |
| 33 rtc::Thread* thread) { | 32 rtc::Thread* thread) { |
| 34 Construct(std::move(me), std::move(dme), thread, thread); | 33 Construct(std::move(me), std::move(dme), thread, thread); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 // Need to destroy the voice/video channels | 171 // Need to destroy the voice/video channels |
| 173 while (!video_channels_.empty()) { | 172 while (!video_channels_.empty()) { |
| 174 DestroyVideoChannel_w(video_channels_.back()); | 173 DestroyVideoChannel_w(video_channels_.back()); |
| 175 } | 174 } |
| 176 while (!voice_channels_.empty()) { | 175 while (!voice_channels_.empty()) { |
| 177 DestroyVoiceChannel_w(voice_channels_.back()); | 176 DestroyVoiceChannel_w(voice_channels_.back()); |
| 178 } | 177 } |
| 179 } | 178 } |
| 180 | 179 |
| 181 VoiceChannel* ChannelManager::CreateVoiceChannel( | 180 VoiceChannel* ChannelManager::CreateVoiceChannel( |
| 182 webrtc::MediaControllerInterface* media_controller, | 181 webrtc::Call* call, |
| 182 const cricket::MediaConfig& media_config, |
| 183 DtlsTransportInternal* rtp_transport, | 183 DtlsTransportInternal* rtp_transport, |
| 184 DtlsTransportInternal* rtcp_transport, | 184 DtlsTransportInternal* rtcp_transport, |
| 185 rtc::Thread* signaling_thread, | 185 rtc::Thread* signaling_thread, |
| 186 const std::string& content_name, | 186 const std::string& content_name, |
| 187 bool srtp_required, | 187 bool srtp_required, |
| 188 const AudioOptions& options) { | 188 const AudioOptions& options) { |
| 189 return worker_thread_->Invoke<VoiceChannel*>( | 189 return worker_thread_->Invoke<VoiceChannel*>( |
| 190 RTC_FROM_HERE, | 190 RTC_FROM_HERE, |
| 191 Bind(&ChannelManager::CreateVoiceChannel_w, this, media_controller, | 191 Bind(&ChannelManager::CreateVoiceChannel_w, this, call, media_config, |
| 192 rtp_transport, rtcp_transport, rtp_transport, rtcp_transport, | 192 rtp_transport, rtcp_transport, rtp_transport, rtcp_transport, |
| 193 signaling_thread, content_name, srtp_required, options)); | 193 signaling_thread, content_name, srtp_required, options)); |
| 194 } | 194 } |
| 195 | 195 |
| 196 VoiceChannel* ChannelManager::CreateVoiceChannel( | 196 VoiceChannel* ChannelManager::CreateVoiceChannel( |
| 197 webrtc::MediaControllerInterface* media_controller, | 197 webrtc::Call* call, |
| 198 const cricket::MediaConfig& media_config, |
| 198 rtc::PacketTransportInternal* rtp_transport, | 199 rtc::PacketTransportInternal* rtp_transport, |
| 199 rtc::PacketTransportInternal* rtcp_transport, | 200 rtc::PacketTransportInternal* rtcp_transport, |
| 200 rtc::Thread* signaling_thread, | 201 rtc::Thread* signaling_thread, |
| 201 const std::string& content_name, | 202 const std::string& content_name, |
| 202 bool srtp_required, | 203 bool srtp_required, |
| 203 const AudioOptions& options) { | 204 const AudioOptions& options) { |
| 204 return worker_thread_->Invoke<VoiceChannel*>( | 205 return worker_thread_->Invoke<VoiceChannel*>( |
| 205 RTC_FROM_HERE, | 206 RTC_FROM_HERE, |
| 206 Bind(&ChannelManager::CreateVoiceChannel_w, this, media_controller, | 207 Bind(&ChannelManager::CreateVoiceChannel_w, this, call, media_config, |
| 207 nullptr, nullptr, rtp_transport, rtcp_transport, signaling_thread, | 208 nullptr, nullptr, rtp_transport, rtcp_transport, signaling_thread, |
| 208 content_name, srtp_required, options)); | 209 content_name, srtp_required, options)); |
| 209 } | 210 } |
| 210 | 211 |
| 211 VoiceChannel* ChannelManager::CreateVoiceChannel_w( | 212 VoiceChannel* ChannelManager::CreateVoiceChannel_w( |
| 212 webrtc::MediaControllerInterface* media_controller, | 213 webrtc::Call* call, |
| 214 const cricket::MediaConfig& media_config, |
| 213 DtlsTransportInternal* rtp_dtls_transport, | 215 DtlsTransportInternal* rtp_dtls_transport, |
| 214 DtlsTransportInternal* rtcp_dtls_transport, | 216 DtlsTransportInternal* rtcp_dtls_transport, |
| 215 rtc::PacketTransportInternal* rtp_packet_transport, | 217 rtc::PacketTransportInternal* rtp_packet_transport, |
| 216 rtc::PacketTransportInternal* rtcp_packet_transport, | 218 rtc::PacketTransportInternal* rtcp_packet_transport, |
| 217 rtc::Thread* signaling_thread, | 219 rtc::Thread* signaling_thread, |
| 218 const std::string& content_name, | 220 const std::string& content_name, |
| 219 bool srtp_required, | 221 bool srtp_required, |
| 220 const AudioOptions& options) { | 222 const AudioOptions& options) { |
| 221 RTC_DCHECK(initialized_); | 223 RTC_DCHECK(initialized_); |
| 222 RTC_DCHECK(worker_thread_ == rtc::Thread::Current()); | 224 RTC_DCHECK(worker_thread_ == rtc::Thread::Current()); |
| 223 RTC_DCHECK(nullptr != media_controller); | 225 RTC_DCHECK(nullptr != call); |
| 224 | 226 |
| 225 VoiceMediaChannel* media_channel = media_engine_->CreateChannel( | 227 VoiceMediaChannel* media_channel = media_engine_->CreateChannel( |
| 226 media_controller->call_w(), media_controller->config(), options); | 228 call, media_config, options); |
| 227 if (!media_channel) | 229 if (!media_channel) |
| 228 return nullptr; | 230 return nullptr; |
| 229 | 231 |
| 230 VoiceChannel* voice_channel = | 232 VoiceChannel* voice_channel = |
| 231 new VoiceChannel(worker_thread_, network_thread_, signaling_thread, | 233 new VoiceChannel(worker_thread_, network_thread_, signaling_thread, |
| 232 media_engine_.get(), media_channel, content_name, | 234 media_engine_.get(), media_channel, content_name, |
| 233 rtcp_packet_transport == nullptr, srtp_required); | 235 rtcp_packet_transport == nullptr, srtp_required); |
| 234 | 236 |
| 235 if (!voice_channel->Init_w(rtp_dtls_transport, rtcp_dtls_transport, | 237 if (!voice_channel->Init_w(rtp_dtls_transport, rtcp_dtls_transport, |
| 236 rtp_packet_transport, rtcp_packet_transport)) { | 238 rtp_packet_transport, rtcp_packet_transport)) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 258 VoiceChannels::iterator it = std::find(voice_channels_.begin(), | 260 VoiceChannels::iterator it = std::find(voice_channels_.begin(), |
| 259 voice_channels_.end(), voice_channel); | 261 voice_channels_.end(), voice_channel); |
| 260 RTC_DCHECK(it != voice_channels_.end()); | 262 RTC_DCHECK(it != voice_channels_.end()); |
| 261 if (it == voice_channels_.end()) | 263 if (it == voice_channels_.end()) |
| 262 return; | 264 return; |
| 263 voice_channels_.erase(it); | 265 voice_channels_.erase(it); |
| 264 delete voice_channel; | 266 delete voice_channel; |
| 265 } | 267 } |
| 266 | 268 |
| 267 VideoChannel* ChannelManager::CreateVideoChannel( | 269 VideoChannel* ChannelManager::CreateVideoChannel( |
| 268 webrtc::MediaControllerInterface* media_controller, | 270 webrtc::Call* call, |
| 271 const cricket::MediaConfig& media_config, |
| 269 DtlsTransportInternal* rtp_transport, | 272 DtlsTransportInternal* rtp_transport, |
| 270 DtlsTransportInternal* rtcp_transport, | 273 DtlsTransportInternal* rtcp_transport, |
| 271 rtc::Thread* signaling_thread, | 274 rtc::Thread* signaling_thread, |
| 272 const std::string& content_name, | 275 const std::string& content_name, |
| 273 bool srtp_required, | 276 bool srtp_required, |
| 274 const VideoOptions& options) { | 277 const VideoOptions& options) { |
| 275 return worker_thread_->Invoke<VideoChannel*>( | 278 return worker_thread_->Invoke<VideoChannel*>( |
| 276 RTC_FROM_HERE, | 279 RTC_FROM_HERE, |
| 277 Bind(&ChannelManager::CreateVideoChannel_w, this, media_controller, | 280 Bind(&ChannelManager::CreateVideoChannel_w, this, call, media_config, |
| 278 rtp_transport, rtcp_transport, rtp_transport, rtcp_transport, | 281 rtp_transport, rtcp_transport, rtp_transport, rtcp_transport, |
| 279 signaling_thread, content_name, srtp_required, options)); | 282 signaling_thread, content_name, srtp_required, options)); |
| 280 } | 283 } |
| 281 | 284 |
| 282 VideoChannel* ChannelManager::CreateVideoChannel( | 285 VideoChannel* ChannelManager::CreateVideoChannel( |
| 283 webrtc::MediaControllerInterface* media_controller, | 286 webrtc::Call* call, |
| 287 const cricket::MediaConfig& media_config, |
| 284 rtc::PacketTransportInternal* rtp_transport, | 288 rtc::PacketTransportInternal* rtp_transport, |
| 285 rtc::PacketTransportInternal* rtcp_transport, | 289 rtc::PacketTransportInternal* rtcp_transport, |
| 286 rtc::Thread* signaling_thread, | 290 rtc::Thread* signaling_thread, |
| 287 const std::string& content_name, | 291 const std::string& content_name, |
| 288 bool srtp_required, | 292 bool srtp_required, |
| 289 const VideoOptions& options) { | 293 const VideoOptions& options) { |
| 290 return worker_thread_->Invoke<VideoChannel*>( | 294 return worker_thread_->Invoke<VideoChannel*>( |
| 291 RTC_FROM_HERE, | 295 RTC_FROM_HERE, |
| 292 Bind(&ChannelManager::CreateVideoChannel_w, this, media_controller, | 296 Bind(&ChannelManager::CreateVideoChannel_w, this, call, media_config, |
| 293 nullptr, nullptr, rtp_transport, rtcp_transport, signaling_thread, | 297 nullptr, nullptr, rtp_transport, rtcp_transport, signaling_thread, |
| 294 content_name, srtp_required, options)); | 298 content_name, srtp_required, options)); |
| 295 } | 299 } |
| 296 | 300 |
| 297 VideoChannel* ChannelManager::CreateVideoChannel_w( | 301 VideoChannel* ChannelManager::CreateVideoChannel_w( |
| 298 webrtc::MediaControllerInterface* media_controller, | 302 webrtc::Call* call, |
| 303 const cricket::MediaConfig& media_config, |
| 299 DtlsTransportInternal* rtp_dtls_transport, | 304 DtlsTransportInternal* rtp_dtls_transport, |
| 300 DtlsTransportInternal* rtcp_dtls_transport, | 305 DtlsTransportInternal* rtcp_dtls_transport, |
| 301 rtc::PacketTransportInternal* rtp_packet_transport, | 306 rtc::PacketTransportInternal* rtp_packet_transport, |
| 302 rtc::PacketTransportInternal* rtcp_packet_transport, | 307 rtc::PacketTransportInternal* rtcp_packet_transport, |
| 303 rtc::Thread* signaling_thread, | 308 rtc::Thread* signaling_thread, |
| 304 const std::string& content_name, | 309 const std::string& content_name, |
| 305 bool srtp_required, | 310 bool srtp_required, |
| 306 const VideoOptions& options) { | 311 const VideoOptions& options) { |
| 307 RTC_DCHECK(initialized_); | 312 RTC_DCHECK(initialized_); |
| 308 RTC_DCHECK(worker_thread_ == rtc::Thread::Current()); | 313 RTC_DCHECK(worker_thread_ == rtc::Thread::Current()); |
| 309 RTC_DCHECK(nullptr != media_controller); | 314 RTC_DCHECK(nullptr != call); |
| 310 VideoMediaChannel* media_channel = media_engine_->CreateVideoChannel( | 315 VideoMediaChannel* media_channel = media_engine_->CreateVideoChannel( |
| 311 media_controller->call_w(), media_controller->config(), options); | 316 call, media_config, options); |
| 312 if (media_channel == NULL) { | 317 if (media_channel == NULL) { |
| 313 return NULL; | 318 return NULL; |
| 314 } | 319 } |
| 315 | 320 |
| 316 VideoChannel* video_channel = new VideoChannel( | 321 VideoChannel* video_channel = new VideoChannel( |
| 317 worker_thread_, network_thread_, signaling_thread, media_channel, | 322 worker_thread_, network_thread_, signaling_thread, media_channel, |
| 318 content_name, rtcp_packet_transport == nullptr, srtp_required); | 323 content_name, rtcp_packet_transport == nullptr, srtp_required); |
| 319 if (!video_channel->Init_w(rtp_dtls_transport, rtcp_dtls_transport, | 324 if (!video_channel->Init_w(rtp_dtls_transport, rtcp_dtls_transport, |
| 320 rtp_packet_transport, rtcp_packet_transport)) { | 325 rtp_packet_transport, rtcp_packet_transport)) { |
| 321 delete video_channel; | 326 delete video_channel; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 343 video_channels_.end(), video_channel); | 348 video_channels_.end(), video_channel); |
| 344 RTC_DCHECK(it != video_channels_.end()); | 349 RTC_DCHECK(it != video_channels_.end()); |
| 345 if (it == video_channels_.end()) | 350 if (it == video_channels_.end()) |
| 346 return; | 351 return; |
| 347 | 352 |
| 348 video_channels_.erase(it); | 353 video_channels_.erase(it); |
| 349 delete video_channel; | 354 delete video_channel; |
| 350 } | 355 } |
| 351 | 356 |
| 352 RtpDataChannel* ChannelManager::CreateRtpDataChannel( | 357 RtpDataChannel* ChannelManager::CreateRtpDataChannel( |
| 353 webrtc::MediaControllerInterface* media_controller, | 358 const cricket::MediaConfig& media_config, |
| 354 DtlsTransportInternal* rtp_transport, | 359 DtlsTransportInternal* rtp_transport, |
| 355 DtlsTransportInternal* rtcp_transport, | 360 DtlsTransportInternal* rtcp_transport, |
| 356 rtc::Thread* signaling_thread, | 361 rtc::Thread* signaling_thread, |
| 357 const std::string& content_name, | 362 const std::string& content_name, |
| 358 bool srtp_required) { | 363 bool srtp_required) { |
| 359 return worker_thread_->Invoke<RtpDataChannel*>( | 364 return worker_thread_->Invoke<RtpDataChannel*>( |
| 360 RTC_FROM_HERE, Bind(&ChannelManager::CreateRtpDataChannel_w, this, | 365 RTC_FROM_HERE, Bind(&ChannelManager::CreateRtpDataChannel_w, this, |
| 361 media_controller, rtp_transport, rtcp_transport, | 366 media_config, rtp_transport, rtcp_transport, |
| 362 signaling_thread, content_name, srtp_required)); | 367 signaling_thread, content_name, srtp_required)); |
| 363 } | 368 } |
| 364 | 369 |
| 365 RtpDataChannel* ChannelManager::CreateRtpDataChannel_w( | 370 RtpDataChannel* ChannelManager::CreateRtpDataChannel_w( |
| 366 webrtc::MediaControllerInterface* media_controller, | 371 const cricket::MediaConfig& media_config, |
| 367 DtlsTransportInternal* rtp_transport, | 372 DtlsTransportInternal* rtp_transport, |
| 368 DtlsTransportInternal* rtcp_transport, | 373 DtlsTransportInternal* rtcp_transport, |
| 369 rtc::Thread* signaling_thread, | 374 rtc::Thread* signaling_thread, |
| 370 const std::string& content_name, | 375 const std::string& content_name, |
| 371 bool srtp_required) { | 376 bool srtp_required) { |
| 372 // This is ok to alloc from a thread other than the worker thread. | 377 // This is ok to alloc from a thread other than the worker thread. |
| 373 RTC_DCHECK(initialized_); | 378 RTC_DCHECK(initialized_); |
| 374 MediaConfig config; | 379 DataMediaChannel* media_channel |
| 375 if (media_controller) { | 380 = data_media_engine_->CreateChannel(media_config); |
| 376 config = media_controller->config(); | |
| 377 } | |
| 378 DataMediaChannel* media_channel = data_media_engine_->CreateChannel(config); | |
| 379 if (!media_channel) { | 381 if (!media_channel) { |
| 380 LOG(LS_WARNING) << "Failed to create RTP data channel."; | 382 LOG(LS_WARNING) << "Failed to create RTP data channel."; |
| 381 return nullptr; | 383 return nullptr; |
| 382 } | 384 } |
| 383 | 385 |
| 384 RtpDataChannel* data_channel = new RtpDataChannel( | 386 RtpDataChannel* data_channel = new RtpDataChannel( |
| 385 worker_thread_, network_thread_, signaling_thread, media_channel, | 387 worker_thread_, network_thread_, signaling_thread, media_channel, |
| 386 content_name, rtcp_transport == nullptr, srtp_required); | 388 content_name, rtcp_transport == nullptr, srtp_required); |
| 387 if (!data_channel->Init_w(rtp_transport, rtcp_transport, rtp_transport, | 389 if (!data_channel->Init_w(rtp_transport, rtcp_transport, rtp_transport, |
| 388 rtcp_transport)) { | 390 rtcp_transport)) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 media_engine_.get(), file, max_size_bytes)); | 426 media_engine_.get(), file, max_size_bytes)); |
| 425 } | 427 } |
| 426 | 428 |
| 427 void ChannelManager::StopAecDump() { | 429 void ChannelManager::StopAecDump() { |
| 428 worker_thread_->Invoke<void>( | 430 worker_thread_->Invoke<void>( |
| 429 RTC_FROM_HERE, | 431 RTC_FROM_HERE, |
| 430 Bind(&MediaEngineInterface::StopAecDump, media_engine_.get())); | 432 Bind(&MediaEngineInterface::StopAecDump, media_engine_.get())); |
| 431 } | 433 } |
| 432 | 434 |
| 433 } // namespace cricket | 435 } // namespace cricket |
| OLD | NEW |