OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 WebRtcSession::~WebRtcSession() { | 563 WebRtcSession::~WebRtcSession() { |
564 ASSERT(signaling_thread()->IsCurrent()); | 564 ASSERT(signaling_thread()->IsCurrent()); |
565 // Destroy video_channel_ first since it may have a pointer to the | 565 // Destroy video_channel_ first since it may have a pointer to the |
566 // voice_channel_. | 566 // voice_channel_. |
567 if (video_channel_) { | 567 if (video_channel_) { |
568 SignalVideoChannelDestroyed(); | 568 SignalVideoChannelDestroyed(); |
569 channel_manager_->DestroyVideoChannel(video_channel_.release()); | 569 channel_manager_->DestroyVideoChannel(video_channel_.release()); |
570 } | 570 } |
571 if (voice_channel_) { | 571 if (voice_channel_) { |
572 SignalVoiceChannelDestroyed(); | 572 SignalVoiceChannelDestroyed(); |
573 channel_manager_->DestroyVoiceChannel(voice_channel_.release(), nullptr); | 573 channel_manager_->DestroyVoiceChannel(voice_channel_.release()); |
574 } | 574 } |
575 if (data_channel_) { | 575 if (data_channel_) { |
576 SignalDataChannelDestroyed(); | 576 SignalDataChannelDestroyed(); |
577 channel_manager_->DestroyDataChannel(data_channel_.release()); | 577 channel_manager_->DestroyDataChannel(data_channel_.release()); |
578 } | 578 } |
| 579 media_controller_.reset(nullptr); |
579 for (size_t i = 0; i < saved_candidates_.size(); ++i) { | 580 for (size_t i = 0; i < saved_candidates_.size(); ++i) { |
580 delete saved_candidates_[i]; | 581 delete saved_candidates_[i]; |
581 } | 582 } |
582 } | 583 } |
583 | 584 |
584 bool WebRtcSession::Initialize( | 585 bool WebRtcSession::Initialize( |
585 const PeerConnectionFactoryInterface::Options& options, | 586 const PeerConnectionFactoryInterface::Options& options, |
586 const MediaConstraintsInterface* constraints, | 587 const MediaConstraintsInterface* constraints, |
587 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, | 588 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, |
588 const PeerConnectionInterface::RTCConfiguration& rtc_configuration) { | 589 const PeerConnectionInterface::RTCConfiguration& rtc_configuration) { |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
776 } | 777 } |
777 port_allocator()->set_candidate_filter( | 778 port_allocator()->set_candidate_filter( |
778 ConvertIceTransportTypeToCandidateFilter(rtc_configuration.type)); | 779 ConvertIceTransportTypeToCandidateFilter(rtc_configuration.type)); |
779 | 780 |
780 if (rtc_configuration.enable_localhost_ice_candidate) { | 781 if (rtc_configuration.enable_localhost_ice_candidate) { |
781 port_allocator()->set_flags( | 782 port_allocator()->set_flags( |
782 port_allocator()->flags() | | 783 port_allocator()->flags() | |
783 cricket::PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE); | 784 cricket::PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE); |
784 } | 785 } |
785 | 786 |
| 787 media_controller_.reset( |
| 788 MediaController::Create(worker_thread(), |
| 789 channel_manager_->media_engine()->GetVoE())); |
786 return true; | 790 return true; |
787 } | 791 } |
788 | 792 |
789 void WebRtcSession::Terminate() { | 793 void WebRtcSession::Terminate() { |
790 SetState(STATE_RECEIVEDTERMINATE); | 794 SetState(STATE_RECEIVEDTERMINATE); |
791 RemoveUnusedChannelsAndTransports(NULL); | 795 RemoveUnusedChannelsAndTransports(NULL); |
792 ASSERT(!voice_channel_); | 796 ASSERT(!voice_channel_); |
793 ASSERT(!video_channel_); | 797 ASSERT(!video_channel_); |
794 ASSERT(!data_channel_); | 798 ASSERT(!data_channel_); |
795 } | 799 } |
(...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1697 channel_manager_->DestroyVideoChannel(video_channel_.release()); | 1701 channel_manager_->DestroyVideoChannel(video_channel_.release()); |
1698 DestroyTransportProxy(content_name); | 1702 DestroyTransportProxy(content_name); |
1699 } | 1703 } |
1700 | 1704 |
1701 const cricket::ContentInfo* voice_info = | 1705 const cricket::ContentInfo* voice_info = |
1702 cricket::GetFirstAudioContent(desc); | 1706 cricket::GetFirstAudioContent(desc); |
1703 if ((!voice_info || voice_info->rejected) && voice_channel_) { | 1707 if ((!voice_info || voice_info->rejected) && voice_channel_) { |
1704 mediastream_signaling_->OnAudioChannelClose(); | 1708 mediastream_signaling_->OnAudioChannelClose(); |
1705 SignalVoiceChannelDestroyed(); | 1709 SignalVoiceChannelDestroyed(); |
1706 const std::string content_name = voice_channel_->content_name(); | 1710 const std::string content_name = voice_channel_->content_name(); |
1707 channel_manager_->DestroyVoiceChannel(voice_channel_.release(), | 1711 channel_manager_->DestroyVoiceChannel(voice_channel_.release()); |
1708 video_channel_.get()); | |
1709 DestroyTransportProxy(content_name); | 1712 DestroyTransportProxy(content_name); |
1710 } | 1713 } |
1711 | 1714 |
1712 const cricket::ContentInfo* data_info = | 1715 const cricket::ContentInfo* data_info = |
1713 cricket::GetFirstDataContent(desc); | 1716 cricket::GetFirstDataContent(desc); |
1714 if ((!data_info || data_info->rejected) && data_channel_) { | 1717 if ((!data_info || data_info->rejected) && data_channel_) { |
1715 mediastream_signaling_->OnDataChannelClose(); | 1718 mediastream_signaling_->OnDataChannelClose(); |
1716 SignalDataChannelDestroyed(); | 1719 SignalDataChannelDestroyed(); |
1717 const std::string content_name = data_channel_->content_name(); | 1720 const std::string content_name = data_channel_->content_name(); |
1718 channel_manager_->DestroyDataChannel(data_channel_.release()); | 1721 channel_manager_->DestroyDataChannel(data_channel_.release()); |
1719 DestroyTransportProxy(content_name); | 1722 DestroyTransportProxy(content_name); |
1720 } | 1723 } |
1721 } | 1724 } |
1722 | 1725 |
1723 // TODO(mallinath) - Add a correct error code if the channels are not creatued | 1726 // TODO(mallinath) - Add a correct error code if the channels are not created |
1724 // due to BUNDLE is enabled but rtcp-mux is disabled. | 1727 // due to BUNDLE is enabled but rtcp-mux is disabled. |
1725 bool WebRtcSession::CreateChannels(const SessionDescription* desc) { | 1728 bool WebRtcSession::CreateChannels(const SessionDescription* desc) { |
1726 // Creating the media channels and transport proxies. | 1729 // Creating the media channels and transport proxies. |
1727 const cricket::ContentInfo* voice = cricket::GetFirstAudioContent(desc); | 1730 const cricket::ContentInfo* voice = cricket::GetFirstAudioContent(desc); |
1728 if (voice && !voice->rejected && !voice_channel_) { | 1731 if (voice && !voice->rejected && !voice_channel_) { |
1729 if (!CreateVoiceChannel(voice)) { | 1732 if (!CreateVoiceChannel(voice)) { |
1730 LOG(LS_ERROR) << "Failed to create voice channel."; | 1733 LOG(LS_ERROR) << "Failed to create voice channel."; |
1731 return false; | 1734 return false; |
1732 } | 1735 } |
1733 } | 1736 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1772 if (!BaseSession::BundleContentGroup(bundle_group)) { | 1775 if (!BaseSession::BundleContentGroup(bundle_group)) { |
1773 LOG(LS_WARNING) << "max-bundle failed to enable bundling."; | 1776 LOG(LS_WARNING) << "max-bundle failed to enable bundling."; |
1774 return false; | 1777 return false; |
1775 } | 1778 } |
1776 } | 1779 } |
1777 | 1780 |
1778 return true; | 1781 return true; |
1779 } | 1782 } |
1780 | 1783 |
1781 bool WebRtcSession::CreateVoiceChannel(const cricket::ContentInfo* content) { | 1784 bool WebRtcSession::CreateVoiceChannel(const cricket::ContentInfo* content) { |
1782 voice_channel_.reset(channel_manager_->CreateVoiceChannel( | 1785 voice_channel_.reset(channel_manager_->CreateVoiceChannel(this, content->name, |
1783 this, content->name, true, audio_options_)); | 1786 true, media_controller_.get(), audio_options_)); |
1784 if (!voice_channel_) { | 1787 if (!voice_channel_) { |
1785 return false; | 1788 return false; |
1786 } | 1789 } |
1787 | 1790 |
1788 voice_channel_->SignalDtlsSetupFailure.connect( | 1791 voice_channel_->SignalDtlsSetupFailure.connect( |
1789 this, &WebRtcSession::OnDtlsSetupFailure); | 1792 this, &WebRtcSession::OnDtlsSetupFailure); |
1790 return true; | 1793 return true; |
1791 } | 1794 } |
1792 | 1795 |
1793 bool WebRtcSession::CreateVideoChannel(const cricket::ContentInfo* content) { | 1796 bool WebRtcSession::CreateVideoChannel(const cricket::ContentInfo* content) { |
1794 video_channel_.reset(channel_manager_->CreateVideoChannel( | 1797 video_channel_.reset(channel_manager_->CreateVideoChannel(this, content->name, |
1795 this, content->name, true, video_options_, voice_channel_.get())); | 1798 true, media_controller_.get(), video_options_)); |
1796 if (!video_channel_) { | 1799 if (!video_channel_) { |
1797 return false; | 1800 return false; |
1798 } | 1801 } |
1799 | 1802 |
1800 video_channel_->SignalDtlsSetupFailure.connect( | 1803 video_channel_->SignalDtlsSetupFailure.connect( |
1801 this, &WebRtcSession::OnDtlsSetupFailure); | 1804 this, &WebRtcSession::OnDtlsSetupFailure); |
1802 return true; | 1805 return true; |
1803 } | 1806 } |
1804 | 1807 |
1805 bool WebRtcSession::CreateDataChannel(const cricket::ContentInfo* content) { | 1808 bool WebRtcSession::CreateDataChannel(const cricket::ContentInfo* content) { |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2097 | 2100 |
2098 if (!srtp_cipher.empty()) { | 2101 if (!srtp_cipher.empty()) { |
2099 metrics_observer_->AddHistogramSample(srtp_name, srtp_cipher); | 2102 metrics_observer_->AddHistogramSample(srtp_name, srtp_cipher); |
2100 } | 2103 } |
2101 if (!ssl_cipher.empty()) { | 2104 if (!ssl_cipher.empty()) { |
2102 metrics_observer_->AddHistogramSample(ssl_name, ssl_cipher); | 2105 metrics_observer_->AddHistogramSample(ssl_name, ssl_cipher); |
2103 } | 2106 } |
2104 } | 2107 } |
2105 | 2108 |
2106 } // namespace webrtc | 2109 } // namespace webrtc |
OLD | NEW |