OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 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 |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 } | 375 } |
376 | 376 |
377 } // namespace | 377 } // namespace |
378 | 378 |
379 namespace webrtc { | 379 namespace webrtc { |
380 | 380 |
381 // Factory class for creating remote MediaStreams and MediaStreamTracks. | 381 // Factory class for creating remote MediaStreams and MediaStreamTracks. |
382 class RemoteMediaStreamFactory { | 382 class RemoteMediaStreamFactory { |
383 public: | 383 public: |
384 explicit RemoteMediaStreamFactory(rtc::Thread* signaling_thread, | 384 explicit RemoteMediaStreamFactory(rtc::Thread* signaling_thread, |
385 cricket::ChannelManager* channel_manager) | 385 rtc::Thread* worker_thread) |
386 : signaling_thread_(signaling_thread), | 386 : signaling_thread_(signaling_thread), |
387 channel_manager_(channel_manager) {} | 387 worker_thread_(worker_thread) {} |
388 | 388 |
389 rtc::scoped_refptr<MediaStreamInterface> CreateMediaStream( | 389 rtc::scoped_refptr<MediaStreamInterface> CreateMediaStream( |
390 const std::string& stream_label) { | 390 const std::string& stream_label) { |
391 return MediaStreamProxy::Create(signaling_thread_, | 391 return MediaStreamProxy::Create(signaling_thread_, |
392 MediaStream::Create(stream_label)); | 392 MediaStream::Create(stream_label)); |
393 } | 393 } |
394 | 394 |
395 AudioTrackInterface* AddAudioTrack(uint32_t ssrc, | 395 AudioTrackInterface* AddAudioTrack(uint32_t ssrc, |
396 AudioProviderInterface* provider, | 396 AudioProviderInterface* provider, |
397 webrtc::MediaStreamInterface* stream, | 397 webrtc::MediaStreamInterface* stream, |
398 const std::string& track_id) { | 398 const std::string& track_id) { |
399 return AddTrack<AudioTrackInterface, AudioTrack, AudioTrackProxy>( | 399 return AddTrack<AudioTrackInterface, AudioTrack, AudioTrackProxy>( |
400 stream, track_id, RemoteAudioSource::Create(ssrc, provider)); | 400 stream, track_id, RemoteAudioSource::Create(ssrc, provider)); |
401 } | 401 } |
402 | 402 |
403 VideoTrackInterface* AddVideoTrack(webrtc::MediaStreamInterface* stream, | 403 VideoTrackInterface* AddVideoTrack(webrtc::MediaStreamInterface* stream, |
404 const std::string& track_id) { | 404 const std::string& track_id) { |
405 return AddTrack<VideoTrackInterface, VideoTrack, VideoTrackProxy>( | 405 return AddTrack<VideoTrackInterface, VideoTrack, VideoTrackProxy>( |
406 stream, track_id, | 406 stream, track_id, |
407 VideoSource::Create(channel_manager_, new RemoteVideoCapturer(), | 407 VideoSource::Create(worker_thread_, new RemoteVideoCapturer(), |
408 nullptr, true) | 408 nullptr, true) |
409 .get()); | 409 .get()); |
410 } | 410 } |
411 | 411 |
412 private: | 412 private: |
413 template <typename TI, typename T, typename TP, typename S> | 413 template <typename TI, typename T, typename TP, typename S> |
414 TI* AddTrack(MediaStreamInterface* stream, | 414 TI* AddTrack(MediaStreamInterface* stream, |
415 const std::string& track_id, | 415 const std::string& track_id, |
416 const S& source) { | 416 const S& source) { |
417 rtc::scoped_refptr<TI> track( | 417 rtc::scoped_refptr<TI> track( |
418 TP::Create(signaling_thread_, T::Create(track_id, source))); | 418 TP::Create(signaling_thread_, T::Create(track_id, source))); |
419 track->set_state(webrtc::MediaStreamTrackInterface::kLive); | 419 track->set_state(webrtc::MediaStreamTrackInterface::kLive); |
420 if (stream->AddTrack(track)) { | 420 if (stream->AddTrack(track)) { |
421 return track; | 421 return track; |
422 } | 422 } |
423 return nullptr; | 423 return nullptr; |
424 } | 424 } |
425 | 425 |
426 rtc::Thread* signaling_thread_; | 426 rtc::Thread* signaling_thread_; |
427 cricket::ChannelManager* channel_manager_; | 427 rtc::Thread* worker_thread_; |
428 }; | 428 }; |
429 | 429 |
430 bool ConvertRtcOptionsForOffer( | 430 bool ConvertRtcOptionsForOffer( |
431 const PeerConnectionInterface::RTCOfferAnswerOptions& rtc_options, | 431 const PeerConnectionInterface::RTCOfferAnswerOptions& rtc_options, |
432 cricket::MediaSessionOptions* session_options) { | 432 cricket::MediaSessionOptions* session_options) { |
433 typedef PeerConnectionInterface::RTCOfferAnswerOptions RTCOfferAnswerOptions; | 433 typedef PeerConnectionInterface::RTCOfferAnswerOptions RTCOfferAnswerOptions; |
434 if (!IsValidOfferToReceiveMedia(rtc_options.offer_to_receive_audio) || | 434 if (!IsValidOfferToReceiveMedia(rtc_options.offer_to_receive_audio) || |
435 !IsValidOfferToReceiveMedia(rtc_options.offer_to_receive_video)) { | 435 !IsValidOfferToReceiveMedia(rtc_options.offer_to_receive_video)) { |
436 return false; | 436 return false; |
437 } | 437 } |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 &media_config.video.enable_cpu_overuse_detection, NULL); | 626 &media_config.video.enable_cpu_overuse_detection, NULL); |
627 | 627 |
628 // Find Suspend Below Min Bitrate constraint. | 628 // Find Suspend Below Min Bitrate constraint. |
629 FindConstraint(constraints, | 629 FindConstraint(constraints, |
630 MediaConstraintsInterface::kEnableVideoSuspendBelowMinBitrate, | 630 MediaConstraintsInterface::kEnableVideoSuspendBelowMinBitrate, |
631 &media_config.video.suspend_below_min_bitrate, NULL); | 631 &media_config.video.suspend_below_min_bitrate, NULL); |
632 | 632 |
633 media_controller_.reset(factory_->CreateMediaController(media_config)); | 633 media_controller_.reset(factory_->CreateMediaController(media_config)); |
634 | 634 |
635 remote_stream_factory_.reset(new RemoteMediaStreamFactory( | 635 remote_stream_factory_.reset(new RemoteMediaStreamFactory( |
636 factory_->signaling_thread(), media_controller_->channel_manager())); | 636 factory_->signaling_thread(), factory_->worker_thread())); |
637 | 637 |
638 session_.reset( | 638 session_.reset( |
639 new WebRtcSession(media_controller_.get(), factory_->signaling_thread(), | 639 new WebRtcSession(media_controller_.get(), factory_->signaling_thread(), |
640 factory_->worker_thread(), port_allocator_.get())); | 640 factory_->worker_thread(), port_allocator_.get())); |
641 stats_.reset(new StatsCollector(this)); | 641 stats_.reset(new StatsCollector(this)); |
642 | 642 |
643 // Initialize the WebRtcSession. It creates transport channels etc. | 643 // Initialize the WebRtcSession. It creates transport channels etc. |
644 if (!session_->Initialize(factory_->options(), constraints, | 644 if (!session_->Initialize(factory_->options(), constraints, |
645 std::move(dtls_identity_store), configuration)) { | 645 std::move(dtls_identity_store), configuration)) { |
646 return false; | 646 return false; |
(...skipping 1451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2098 DataChannel* PeerConnection::FindDataChannelBySid(int sid) const { | 2098 DataChannel* PeerConnection::FindDataChannelBySid(int sid) const { |
2099 for (const auto& channel : sctp_data_channels_) { | 2099 for (const auto& channel : sctp_data_channels_) { |
2100 if (channel->id() == sid) { | 2100 if (channel->id() == sid) { |
2101 return channel; | 2101 return channel; |
2102 } | 2102 } |
2103 } | 2103 } |
2104 return nullptr; | 2104 return nullptr; |
2105 } | 2105 } |
2106 | 2106 |
2107 } // namespace webrtc | 2107 } // namespace webrtc |
OLD | NEW |