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

Side by Side Diff: talk/app/webrtc/webrtcsession.cc

Issue 1269863005: MediaController/Call instantiation. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: nullptr Created 5 years, 3 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 * 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 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 ice_restart_latch_(new IceRestartAnswerLatch), 544 ice_restart_latch_(new IceRestartAnswerLatch),
545 metrics_observer_(NULL) { 545 metrics_observer_(NULL) {
546 } 546 }
547 547
548 WebRtcSession::~WebRtcSession() { 548 WebRtcSession::~WebRtcSession() {
549 ASSERT(signaling_thread()->IsCurrent()); 549 ASSERT(signaling_thread()->IsCurrent());
550 // Destroy video_channel_ first since it may have a pointer to the 550 // Destroy video_channel_ first since it may have a pointer to the
551 // voice_channel_. 551 // voice_channel_.
552 if (video_channel_) { 552 if (video_channel_) {
553 SignalVideoChannelDestroyed(); 553 SignalVideoChannelDestroyed();
554 media_controller_->set_video_channel(nullptr);
pthatcher1 2015/09/02 21:24:22 Why is this necessary if media_controller_ is abou
the sun 2015/09/03 15:00:46 Part of LoadObserver discussion. Not strictly nece
554 channel_manager_->DestroyVideoChannel(video_channel_.release()); 555 channel_manager_->DestroyVideoChannel(video_channel_.release());
555 } 556 }
556 if (voice_channel_) { 557 if (voice_channel_) {
557 SignalVoiceChannelDestroyed(); 558 SignalVoiceChannelDestroyed();
558 channel_manager_->DestroyVoiceChannel(voice_channel_.release(), nullptr); 559 channel_manager_->DestroyVoiceChannel(voice_channel_.release());
559 } 560 }
560 if (data_channel_) { 561 if (data_channel_) {
561 SignalDataChannelDestroyed(); 562 SignalDataChannelDestroyed();
562 channel_manager_->DestroyDataChannel(data_channel_.release()); 563 channel_manager_->DestroyDataChannel(data_channel_.release());
563 } 564 }
565 media_controller_.reset(nullptr);
564 for (size_t i = 0; i < saved_candidates_.size(); ++i) { 566 for (size_t i = 0; i < saved_candidates_.size(); ++i) {
565 delete saved_candidates_[i]; 567 delete saved_candidates_[i];
566 } 568 }
567 } 569 }
568 570
569 bool WebRtcSession::Initialize( 571 bool WebRtcSession::Initialize(
570 const PeerConnectionFactoryInterface::Options& options, 572 const PeerConnectionFactoryInterface::Options& options,
571 const MediaConstraintsInterface* constraints, 573 const MediaConstraintsInterface* constraints,
572 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, 574 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store,
573 const PeerConnectionInterface::RTCConfiguration& rtc_configuration) { 575 const PeerConnectionInterface::RTCConfiguration& rtc_configuration) {
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 } 760 }
759 port_allocator()->set_candidate_filter( 761 port_allocator()->set_candidate_filter(
760 ConvertIceTransportTypeToCandidateFilter(rtc_configuration.type)); 762 ConvertIceTransportTypeToCandidateFilter(rtc_configuration.type));
761 763
762 if (rtc_configuration.enable_localhost_ice_candidate) { 764 if (rtc_configuration.enable_localhost_ice_candidate) {
763 port_allocator()->set_flags( 765 port_allocator()->set_flags(
764 port_allocator()->flags() | 766 port_allocator()->flags() |
765 cricket::PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE); 767 cricket::PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE);
766 } 768 }
767 769
770 media_controller_.reset(
771 new MediaController(worker_thread(), channel_manager_->media_engine()));
772
768 return true; 773 return true;
769 } 774 }
770 775
771 void WebRtcSession::Terminate() { 776 void WebRtcSession::Terminate() {
772 SetState(STATE_RECEIVEDTERMINATE); 777 SetState(STATE_RECEIVEDTERMINATE);
773 RemoveUnusedChannelsAndTransports(NULL); 778 RemoveUnusedChannelsAndTransports(NULL);
774 ASSERT(!voice_channel_); 779 ASSERT(!voice_channel_);
775 ASSERT(!video_channel_); 780 ASSERT(!video_channel_);
776 ASSERT(!data_channel_); 781 ASSERT(!data_channel_);
777 } 782 }
(...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after
1668 void WebRtcSession::RemoveUnusedChannelsAndTransports( 1673 void WebRtcSession::RemoveUnusedChannelsAndTransports(
1669 const SessionDescription* desc) { 1674 const SessionDescription* desc) {
1670 // Destroy video_channel_ first since it may have a pointer to the 1675 // Destroy video_channel_ first since it may have a pointer to the
1671 // voice_channel_. 1676 // voice_channel_.
1672 const cricket::ContentInfo* video_info = 1677 const cricket::ContentInfo* video_info =
1673 cricket::GetFirstVideoContent(desc); 1678 cricket::GetFirstVideoContent(desc);
1674 if ((!video_info || video_info->rejected) && video_channel_) { 1679 if ((!video_info || video_info->rejected) && video_channel_) {
1675 mediastream_signaling_->OnVideoChannelClose(); 1680 mediastream_signaling_->OnVideoChannelClose();
1676 SignalVideoChannelDestroyed(); 1681 SignalVideoChannelDestroyed();
1677 const std::string content_name = video_channel_->content_name(); 1682 const std::string content_name = video_channel_->content_name();
1683 media_controller_->set_video_channel(nullptr);
1678 channel_manager_->DestroyVideoChannel(video_channel_.release()); 1684 channel_manager_->DestroyVideoChannel(video_channel_.release());
1679 DestroyTransportProxy(content_name); 1685 DestroyTransportProxy(content_name);
1680 } 1686 }
1681 1687
1682 const cricket::ContentInfo* voice_info = 1688 const cricket::ContentInfo* voice_info =
1683 cricket::GetFirstAudioContent(desc); 1689 cricket::GetFirstAudioContent(desc);
1684 if ((!voice_info || voice_info->rejected) && voice_channel_) { 1690 if ((!voice_info || voice_info->rejected) && voice_channel_) {
1685 mediastream_signaling_->OnAudioChannelClose(); 1691 mediastream_signaling_->OnAudioChannelClose();
1686 SignalVoiceChannelDestroyed(); 1692 SignalVoiceChannelDestroyed();
1687 const std::string content_name = voice_channel_->content_name(); 1693 const std::string content_name = voice_channel_->content_name();
1688 channel_manager_->DestroyVoiceChannel(voice_channel_.release(), 1694 channel_manager_->DestroyVoiceChannel(voice_channel_.release());
1689 video_channel_.get());
1690 DestroyTransportProxy(content_name); 1695 DestroyTransportProxy(content_name);
1691 } 1696 }
1692 1697
1693 const cricket::ContentInfo* data_info = 1698 const cricket::ContentInfo* data_info =
1694 cricket::GetFirstDataContent(desc); 1699 cricket::GetFirstDataContent(desc);
1695 if ((!data_info || data_info->rejected) && data_channel_) { 1700 if ((!data_info || data_info->rejected) && data_channel_) {
1696 mediastream_signaling_->OnDataChannelClose(); 1701 mediastream_signaling_->OnDataChannelClose();
1697 SignalDataChannelDestroyed(); 1702 SignalDataChannelDestroyed();
1698 const std::string content_name = data_channel_->content_name(); 1703 const std::string content_name = data_channel_->content_name();
1699 channel_manager_->DestroyDataChannel(data_channel_.release()); 1704 channel_manager_->DestroyDataChannel(data_channel_.release());
1700 DestroyTransportProxy(content_name); 1705 DestroyTransportProxy(content_name);
1701 } 1706 }
1702 } 1707 }
1703 1708
1704 // TODO(mallinath) - Add a correct error code if the channels are not creatued 1709 // TODO(mallinath) - Add a correct error code if the channels are not created
1705 // due to BUNDLE is enabled but rtcp-mux is disabled. 1710 // due to BUNDLE is enabled but rtcp-mux is disabled.
1706 bool WebRtcSession::CreateChannels(const SessionDescription* desc) { 1711 bool WebRtcSession::CreateChannels(const SessionDescription* desc) {
1707 // Creating the media channels and transport proxies. 1712 // Creating the media channels and transport proxies.
1708 const cricket::ContentInfo* voice = cricket::GetFirstAudioContent(desc); 1713 const cricket::ContentInfo* voice = cricket::GetFirstAudioContent(desc);
1709 if (voice && !voice->rejected && !voice_channel_) { 1714 if (voice && !voice->rejected && !voice_channel_) {
1710 if (!CreateVoiceChannel(voice)) { 1715 if (!CreateVoiceChannel(voice)) {
1711 LOG(LS_ERROR) << "Failed to create voice channel."; 1716 LOG(LS_ERROR) << "Failed to create voice channel.";
1712 return false; 1717 return false;
1713 } 1718 }
1714 } 1719 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1753 if (!BaseSession::BundleContentGroup(bundle_group)) { 1758 if (!BaseSession::BundleContentGroup(bundle_group)) {
1754 LOG(LS_WARNING) << "max-bundle failed to enable bundling."; 1759 LOG(LS_WARNING) << "max-bundle failed to enable bundling.";
1755 return false; 1760 return false;
1756 } 1761 }
1757 } 1762 }
1758 1763
1759 return true; 1764 return true;
1760 } 1765 }
1761 1766
1762 bool WebRtcSession::CreateVoiceChannel(const cricket::ContentInfo* content) { 1767 bool WebRtcSession::CreateVoiceChannel(const cricket::ContentInfo* content) {
1763 voice_channel_.reset(channel_manager_->CreateVoiceChannel( 1768 voice_channel_.reset(channel_manager_->CreateVoiceChannel(this, content->name,
1764 this, content->name, true, audio_options_)); 1769 true, media_controller_->call(), audio_options_));
1765 if (!voice_channel_) { 1770 if (!voice_channel_) {
1766 return false; 1771 return false;
1767 } 1772 }
1768 1773
1769 voice_channel_->SignalDtlsSetupFailure.connect( 1774 voice_channel_->SignalDtlsSetupFailure.connect(
1770 this, &WebRtcSession::OnDtlsSetupFailure); 1775 this, &WebRtcSession::OnDtlsSetupFailure);
1771 return true; 1776 return true;
1772 } 1777 }
1773 1778
1774 bool WebRtcSession::CreateVideoChannel(const cricket::ContentInfo* content) { 1779 bool WebRtcSession::CreateVideoChannel(const cricket::ContentInfo* content) {
1775 video_channel_.reset(channel_manager_->CreateVideoChannel( 1780 video_channel_.reset(channel_manager_->CreateVideoChannel(this, content->name,
1776 this, content->name, true, video_options_, voice_channel_.get())); 1781 true, media_controller_->call(), video_options_));
1777 if (!video_channel_) { 1782 if (!video_channel_) {
1778 return false; 1783 return false;
1779 } 1784 }
1785 media_controller_->set_video_channel(video_channel_.get());
1780 1786
1781 video_channel_->SignalDtlsSetupFailure.connect( 1787 video_channel_->SignalDtlsSetupFailure.connect(
1782 this, &WebRtcSession::OnDtlsSetupFailure); 1788 this, &WebRtcSession::OnDtlsSetupFailure);
1783 return true; 1789 return true;
1784 } 1790 }
1785 1791
1786 bool WebRtcSession::CreateDataChannel(const cricket::ContentInfo* content) { 1792 bool WebRtcSession::CreateDataChannel(const cricket::ContentInfo* content) {
1787 bool sctp = (data_channel_type_ == cricket::DCT_SCTP); 1793 bool sctp = (data_channel_type_ == cricket::DCT_SCTP);
1788 data_channel_.reset(channel_manager_->CreateDataChannel( 1794 data_channel_.reset(channel_manager_->CreateDataChannel(
1789 this, content->name, !sctp, data_channel_type_)); 1795 this, content->name, !sctp, data_channel_type_));
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
2085 2091
2086 if (!srtp_cipher.empty()) { 2092 if (!srtp_cipher.empty()) {
2087 metrics_observer_->AddHistogramSample(srtp_name, srtp_cipher); 2093 metrics_observer_->AddHistogramSample(srtp_name, srtp_cipher);
2088 } 2094 }
2089 if (!ssl_cipher.empty()) { 2095 if (!ssl_cipher.empty()) {
2090 metrics_observer_->AddHistogramSample(ssl_name, ssl_cipher); 2096 metrics_observer_->AddHistogramSample(ssl_name, ssl_cipher);
2091 } 2097 }
2092 } 2098 }
2093 2099
2094 } // namespace webrtc 2100 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698