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 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 for (const auto& sender : senders_) { | 519 for (const auto& sender : senders_) { |
520 sender->Stop(); | 520 sender->Stop(); |
521 } | 521 } |
522 for (const auto& receiver : receivers_) { | 522 for (const auto& receiver : receivers_) { |
523 receiver->Stop(); | 523 receiver->Stop(); |
524 } | 524 } |
525 } | 525 } |
526 | 526 |
527 bool PeerConnection::Initialize( | 527 bool PeerConnection::Initialize( |
528 const PeerConnectionInterface::RTCConfiguration& configuration, | 528 const PeerConnectionInterface::RTCConfiguration& configuration, |
529 rtc::scoped_ptr<cricket::PortAllocator> allocator, | 529 std::unique_ptr<cricket::PortAllocator> allocator, |
530 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, | 530 std::unique_ptr<DtlsIdentityStoreInterface> dtls_identity_store, |
531 PeerConnectionObserver* observer) { | 531 PeerConnectionObserver* observer) { |
532 TRACE_EVENT0("webrtc", "PeerConnection::Initialize"); | 532 TRACE_EVENT0("webrtc", "PeerConnection::Initialize"); |
533 RTC_DCHECK(observer != nullptr); | 533 RTC_DCHECK(observer != nullptr); |
534 if (!observer) { | 534 if (!observer) { |
535 return false; | 535 return false; |
536 } | 536 } |
537 observer_ = observer; | 537 observer_ = observer; |
538 | 538 |
539 port_allocator_ = std::move(allocator); | 539 port_allocator_ = std::move(allocator); |
540 | 540 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 local_streams_->AddStream(local_stream); | 621 local_streams_->AddStream(local_stream); |
622 MediaStreamObserver* observer = new MediaStreamObserver(local_stream); | 622 MediaStreamObserver* observer = new MediaStreamObserver(local_stream); |
623 observer->SignalAudioTrackAdded.connect(this, | 623 observer->SignalAudioTrackAdded.connect(this, |
624 &PeerConnection::OnAudioTrackAdded); | 624 &PeerConnection::OnAudioTrackAdded); |
625 observer->SignalAudioTrackRemoved.connect( | 625 observer->SignalAudioTrackRemoved.connect( |
626 this, &PeerConnection::OnAudioTrackRemoved); | 626 this, &PeerConnection::OnAudioTrackRemoved); |
627 observer->SignalVideoTrackAdded.connect(this, | 627 observer->SignalVideoTrackAdded.connect(this, |
628 &PeerConnection::OnVideoTrackAdded); | 628 &PeerConnection::OnVideoTrackAdded); |
629 observer->SignalVideoTrackRemoved.connect( | 629 observer->SignalVideoTrackRemoved.connect( |
630 this, &PeerConnection::OnVideoTrackRemoved); | 630 this, &PeerConnection::OnVideoTrackRemoved); |
631 stream_observers_.push_back(rtc::scoped_ptr<MediaStreamObserver>(observer)); | 631 stream_observers_.push_back(std::unique_ptr<MediaStreamObserver>(observer)); |
632 | 632 |
633 for (const auto& track : local_stream->GetAudioTracks()) { | 633 for (const auto& track : local_stream->GetAudioTracks()) { |
634 OnAudioTrackAdded(track.get(), local_stream); | 634 OnAudioTrackAdded(track.get(), local_stream); |
635 } | 635 } |
636 for (const auto& track : local_stream->GetVideoTracks()) { | 636 for (const auto& track : local_stream->GetVideoTracks()) { |
637 OnVideoTrackAdded(track.get(), local_stream); | 637 OnVideoTrackAdded(track.get(), local_stream); |
638 } | 638 } |
639 | 639 |
640 stats_->AddStream(local_stream); | 640 stats_->AddStream(local_stream); |
641 observer_->OnRenegotiationNeeded(); | 641 observer_->OnRenegotiationNeeded(); |
642 return true; | 642 return true; |
643 } | 643 } |
644 | 644 |
645 void PeerConnection::RemoveStream(MediaStreamInterface* local_stream) { | 645 void PeerConnection::RemoveStream(MediaStreamInterface* local_stream) { |
646 TRACE_EVENT0("webrtc", "PeerConnection::RemoveStream"); | 646 TRACE_EVENT0("webrtc", "PeerConnection::RemoveStream"); |
647 for (const auto& track : local_stream->GetAudioTracks()) { | 647 for (const auto& track : local_stream->GetAudioTracks()) { |
648 OnAudioTrackRemoved(track.get(), local_stream); | 648 OnAudioTrackRemoved(track.get(), local_stream); |
649 } | 649 } |
650 for (const auto& track : local_stream->GetVideoTracks()) { | 650 for (const auto& track : local_stream->GetVideoTracks()) { |
651 OnVideoTrackRemoved(track.get(), local_stream); | 651 OnVideoTrackRemoved(track.get(), local_stream); |
652 } | 652 } |
653 | 653 |
654 local_streams_->RemoveStream(local_stream); | 654 local_streams_->RemoveStream(local_stream); |
655 stream_observers_.erase( | 655 stream_observers_.erase( |
656 std::remove_if( | 656 std::remove_if( |
657 stream_observers_.begin(), stream_observers_.end(), | 657 stream_observers_.begin(), stream_observers_.end(), |
658 [local_stream](const rtc::scoped_ptr<MediaStreamObserver>& observer) { | 658 [local_stream](const std::unique_ptr<MediaStreamObserver>& observer) { |
659 return observer->stream()->label().compare(local_stream->label()) == | 659 return observer->stream()->label().compare(local_stream->label()) == |
660 0; | 660 0; |
661 }), | 661 }), |
662 stream_observers_.end()); | 662 stream_observers_.end()); |
663 | 663 |
664 if (IsClosed()) { | 664 if (IsClosed()) { |
665 return; | 665 return; |
666 } | 666 } |
667 observer_->OnRenegotiationNeeded(); | 667 observer_->OnRenegotiationNeeded(); |
668 } | 668 } |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 return ice_gathering_state_; | 828 return ice_gathering_state_; |
829 } | 829 } |
830 | 830 |
831 rtc::scoped_refptr<DataChannelInterface> | 831 rtc::scoped_refptr<DataChannelInterface> |
832 PeerConnection::CreateDataChannel( | 832 PeerConnection::CreateDataChannel( |
833 const std::string& label, | 833 const std::string& label, |
834 const DataChannelInit* config) { | 834 const DataChannelInit* config) { |
835 TRACE_EVENT0("webrtc", "PeerConnection::CreateDataChannel"); | 835 TRACE_EVENT0("webrtc", "PeerConnection::CreateDataChannel"); |
836 bool first_datachannel = !HasDataChannels(); | 836 bool first_datachannel = !HasDataChannels(); |
837 | 837 |
838 rtc::scoped_ptr<InternalDataChannelInit> internal_config; | 838 std::unique_ptr<InternalDataChannelInit> internal_config; |
839 if (config) { | 839 if (config) { |
840 internal_config.reset(new InternalDataChannelInit(*config)); | 840 internal_config.reset(new InternalDataChannelInit(*config)); |
841 } | 841 } |
842 rtc::scoped_refptr<DataChannelInterface> channel( | 842 rtc::scoped_refptr<DataChannelInterface> channel( |
843 InternalCreateDataChannel(label, internal_config.get())); | 843 InternalCreateDataChannel(label, internal_config.get())); |
844 if (!channel.get()) { | 844 if (!channel.get()) { |
845 return nullptr; | 845 return nullptr; |
846 } | 846 } |
847 | 847 |
848 // Trigger the onRenegotiationNeeded event for every new RTP DataChannel, or | 848 // Trigger the onRenegotiationNeeded event for every new RTP DataChannel, or |
(...skipping 1209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2058 DataChannel* PeerConnection::FindDataChannelBySid(int sid) const { | 2058 DataChannel* PeerConnection::FindDataChannelBySid(int sid) const { |
2059 for (const auto& channel : sctp_data_channels_) { | 2059 for (const auto& channel : sctp_data_channels_) { |
2060 if (channel->id() == sid) { | 2060 if (channel->id() == sid) { |
2061 return channel; | 2061 return channel; |
2062 } | 2062 } |
2063 } | 2063 } |
2064 return nullptr; | 2064 return nullptr; |
2065 } | 2065 } |
2066 | 2066 |
2067 } // namespace webrtc | 2067 } // namespace webrtc |
OLD | NEW |