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 27 matching lines...) Expand all Loading... | |
38 #include "talk/app/webrtc/mediaconstraintsinterface.h" | 38 #include "talk/app/webrtc/mediaconstraintsinterface.h" |
39 #include "talk/app/webrtc/mediastreamsignaling.h" | 39 #include "talk/app/webrtc/mediastreamsignaling.h" |
40 #include "talk/app/webrtc/peerconnectioninterface.h" | 40 #include "talk/app/webrtc/peerconnectioninterface.h" |
41 #include "talk/app/webrtc/webrtcsessiondescriptionfactory.h" | 41 #include "talk/app/webrtc/webrtcsessiondescriptionfactory.h" |
42 #include "talk/media/base/constants.h" | 42 #include "talk/media/base/constants.h" |
43 #include "talk/media/base/videocapturer.h" | 43 #include "talk/media/base/videocapturer.h" |
44 #include "talk/session/media/channel.h" | 44 #include "talk/session/media/channel.h" |
45 #include "talk/session/media/channelmanager.h" | 45 #include "talk/session/media/channelmanager.h" |
46 #include "talk/session/media/mediasession.h" | 46 #include "talk/session/media/mediasession.h" |
47 #include "webrtc/base/basictypes.h" | 47 #include "webrtc/base/basictypes.h" |
48 #include "webrtc/base/bind.h" | |
48 #include "webrtc/base/checks.h" | 49 #include "webrtc/base/checks.h" |
49 #include "webrtc/base/helpers.h" | 50 #include "webrtc/base/helpers.h" |
50 #include "webrtc/base/logging.h" | 51 #include "webrtc/base/logging.h" |
51 #include "webrtc/base/stringencode.h" | 52 #include "webrtc/base/stringencode.h" |
52 #include "webrtc/base/stringutils.h" | 53 #include "webrtc/base/stringutils.h" |
53 #include "webrtc/p2p/base/portallocator.h" | 54 #include "webrtc/p2p/base/portallocator.h" |
55 #include "webrtc/p2p/base/transportchannel.h" | |
54 | 56 |
55 using cricket::ContentInfo; | 57 using cricket::ContentInfo; |
56 using cricket::ContentInfos; | 58 using cricket::ContentInfos; |
57 using cricket::MediaContentDescription; | 59 using cricket::MediaContentDescription; |
58 using cricket::SessionDescription; | 60 using cricket::SessionDescription; |
59 using cricket::TransportInfo; | 61 using cricket::TransportInfo; |
60 | 62 |
61 using cricket::LOCAL_PORT_TYPE; | 63 using cricket::LOCAL_PORT_TYPE; |
62 using cricket::STUN_PORT_TYPE; | 64 using cricket::STUN_PORT_TYPE; |
63 using cricket::RELAY_PORT_TYPE; | 65 using cricket::RELAY_PORT_TYPE; |
64 using cricket::PRFLX_PORT_TYPE; | 66 using cricket::PRFLX_PORT_TYPE; |
65 | 67 |
68 using rtc::Bind; | |
69 | |
66 namespace webrtc { | 70 namespace webrtc { |
67 | 71 |
68 // Error messages | 72 // Error messages |
69 const char kBundleWithoutRtcpMux[] = "RTCP-MUX must be enabled when BUNDLE " | 73 const char kBundleWithoutRtcpMux[] = "RTCP-MUX must be enabled when BUNDLE " |
70 "is enabled."; | 74 "is enabled."; |
71 const char kCreateChannelFailed[] = "Failed to create channels."; | 75 const char kCreateChannelFailed[] = "Failed to create channels."; |
72 const char kInvalidCandidates[] = "Description contains invalid candidates."; | 76 const char kInvalidCandidates[] = "Description contains invalid candidates."; |
73 const char kInvalidSdp[] = "Invalid session description."; | 77 const char kInvalidSdp[] = "Invalid session description."; |
74 const char kMlineMismatch[] = | 78 const char kMlineMismatch[] = |
75 "Offer and answer descriptions m-lines are not matching. Rejecting answer."; | 79 "Offer and answer descriptions m-lines are not matching. Rejecting answer."; |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
529 return true; | 533 return true; |
530 } | 534 } |
531 } | 535 } |
532 return false; | 536 return false; |
533 } | 537 } |
534 | 538 |
535 private: | 539 private: |
536 bool ice_restart_; | 540 bool ice_restart_; |
537 }; | 541 }; |
538 | 542 |
539 WebRtcSession::WebRtcSession( | 543 WebRtcSession::WebRtcSession(cricket::ChannelManager* channel_manager, |
540 cricket::ChannelManager* channel_manager, | 544 rtc::Thread* signaling_thread, |
541 rtc::Thread* signaling_thread, | 545 rtc::Thread* worker_thread, |
542 rtc::Thread* worker_thread, | 546 cricket::PortAllocator* port_allocator, |
543 cricket::PortAllocator* port_allocator, | 547 MediaStreamSignaling* mediastream_signaling, |
544 MediaStreamSignaling* mediastream_signaling) | 548 webrtc::CallFactory* call_factory) |
545 : cricket::BaseSession(signaling_thread, | 549 : cricket::BaseSession(signaling_thread, |
546 worker_thread, | 550 worker_thread, |
547 port_allocator, | 551 port_allocator, |
548 rtc::ToString(rtc::CreateRandomId64() & LLONG_MAX), | 552 rtc::ToString(rtc::CreateRandomId64() & LLONG_MAX), |
549 false), | 553 false), |
550 // RFC 3264: The numeric value of the session id and version in the | 554 // RFC 3264: The numeric value of the session id and version in the |
551 // o line MUST be representable with a "64 bit signed integer". | 555 // o line MUST be representable with a "64 bit signed integer". |
552 // Due to this constraint session id |sid_| is max limited to LLONG_MAX. | 556 // Due to this constraint session id |sid_| is max limited to LLONG_MAX. |
553 channel_manager_(channel_manager), | 557 channel_manager_(channel_manager), |
554 mediastream_signaling_(mediastream_signaling), | 558 mediastream_signaling_(mediastream_signaling), |
559 call_factory_(call_factory), | |
555 ice_observer_(NULL), | 560 ice_observer_(NULL), |
556 ice_connection_state_(PeerConnectionInterface::kIceConnectionNew), | 561 ice_connection_state_(PeerConnectionInterface::kIceConnectionNew), |
557 ice_connection_receiving_(true), | 562 ice_connection_receiving_(true), |
558 older_version_remote_peer_(false), | 563 older_version_remote_peer_(false), |
559 dtls_enabled_(false), | 564 dtls_enabled_(false), |
560 data_channel_type_(cricket::DCT_NONE), | 565 data_channel_type_(cricket::DCT_NONE), |
561 ice_restart_latch_(new IceRestartAnswerLatch), | 566 ice_restart_latch_(new IceRestartAnswerLatch), |
562 metrics_observer_(NULL) { | 567 metrics_observer_(NULL) { |
563 transport_controller()->SignalConnectionState.connect( | 568 transport_controller()->SignalConnectionState.connect( |
564 this, &WebRtcSession::OnTransportControllerConnectionState); | 569 this, &WebRtcSession::OnTransportControllerConnectionState); |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
770 port_allocator()->set_candidate_filter( | 775 port_allocator()->set_candidate_filter( |
771 ConvertIceTransportTypeToCandidateFilter(rtc_configuration.type)); | 776 ConvertIceTransportTypeToCandidateFilter(rtc_configuration.type)); |
772 | 777 |
773 if (rtc_configuration.enable_localhost_ice_candidate) { | 778 if (rtc_configuration.enable_localhost_ice_candidate) { |
774 port_allocator()->set_flags( | 779 port_allocator()->set_flags( |
775 port_allocator()->flags() | | 780 port_allocator()->flags() | |
776 cricket::PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE); | 781 cricket::PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE); |
777 } | 782 } |
778 | 783 |
779 media_controller_.reset(MediaControllerInterface::Create( | 784 media_controller_.reset(MediaControllerInterface::Create( |
780 worker_thread(), channel_manager_->media_engine()->GetVoE())); | 785 call_factory_, worker_thread(), |
786 channel_manager_->media_engine()->GetVoE())); | |
pthatcher1
2015/10/09 20:57:48
The addition of the CallFactory is really just so
stefan-webrtc
2015/10/10 15:32:51
That might be an option, but after a quick look it
stefan-webrtc
2015/10/12 10:11:44
I checked this again today and it turned out not t
| |
781 | 787 |
782 return true; | 788 return true; |
783 } | 789 } |
784 | 790 |
785 cricket::IceConfig WebRtcSession::ParseIceConfig( | 791 cricket::IceConfig WebRtcSession::ParseIceConfig( |
786 const PeerConnectionInterface::RTCConfiguration& config) const { | 792 const PeerConnectionInterface::RTCConfiguration& config) const { |
787 cricket::IceConfig ice_config; | 793 cricket::IceConfig ice_config; |
788 ice_config.receiving_timeout_ms = config.ice_connection_receiving_timeout; | 794 ice_config.receiving_timeout_ms = config.ice_connection_receiving_timeout; |
789 ice_config.gather_continually = (config.continual_gathering_policy == | 795 ice_config.gather_continually = (config.continual_gathering_policy == |
790 PeerConnectionInterface::GATHER_CONTINUALLY); | 796 PeerConnectionInterface::GATHER_CONTINUALLY); |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1152 if (ch->transport_name() == transport_name) { | 1158 if (ch->transport_name() == transport_name) { |
1153 LOG(LS_INFO) << "BUNDLE already enabled for " << ch->content_name() | 1159 LOG(LS_INFO) << "BUNDLE already enabled for " << ch->content_name() |
1154 << " on " << transport_name << "."; | 1160 << " on " << transport_name << "."; |
1155 return true; | 1161 return true; |
1156 } | 1162 } |
1157 | 1163 |
1158 if (!ch->SetTransport(transport_name)) { | 1164 if (!ch->SetTransport(transport_name)) { |
1159 LOG(LS_WARNING) << "Failed to enable BUNDLE for " << ch->content_name(); | 1165 LOG(LS_WARNING) << "Failed to enable BUNDLE for " << ch->content_name(); |
1160 return false; | 1166 return false; |
1161 } | 1167 } |
1168 ch->transport_channel()->SignalSentPacket.connect( | |
1169 this, &WebRtcSession::OnSentPacket); | |
pthatcher1
2015/10/09 20:57:48
Actually, if you listen to all of the BaseChannels
stefan-webrtc
2015/10/10 15:32:51
Ah ok. I misunderstood you and thought that for in
| |
1162 LOG(LS_INFO) << "Enabled BUNDLE for " << ch->content_name() << " on " | 1170 LOG(LS_INFO) << "Enabled BUNDLE for " << ch->content_name() << " on " |
1163 << transport_name << "."; | 1171 << transport_name << "."; |
1164 return true; | 1172 return true; |
1165 }; | 1173 }; |
1166 | 1174 |
1167 if (!maybe_set_transport(voice_channel()) || | 1175 if (!maybe_set_transport(voice_channel()) || |
1168 !maybe_set_transport(video_channel()) || | 1176 !maybe_set_transport(video_channel()) || |
1169 !maybe_set_transport(data_channel())) { | 1177 !maybe_set_transport(data_channel())) { |
1170 return false; | 1178 return false; |
1171 } | 1179 } |
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1820 bool WebRtcSession::CreateVoiceChannel(const cricket::ContentInfo* content) { | 1828 bool WebRtcSession::CreateVoiceChannel(const cricket::ContentInfo* content) { |
1821 voice_channel_.reset(channel_manager_->CreateVoiceChannel( | 1829 voice_channel_.reset(channel_manager_->CreateVoiceChannel( |
1822 media_controller_.get(), transport_controller(), content->name, true, | 1830 media_controller_.get(), transport_controller(), content->name, true, |
1823 audio_options_)); | 1831 audio_options_)); |
1824 if (!voice_channel_) { | 1832 if (!voice_channel_) { |
1825 return false; | 1833 return false; |
1826 } | 1834 } |
1827 | 1835 |
1828 voice_channel_->SignalDtlsSetupFailure.connect( | 1836 voice_channel_->SignalDtlsSetupFailure.connect( |
1829 this, &WebRtcSession::OnDtlsSetupFailure); | 1837 this, &WebRtcSession::OnDtlsSetupFailure); |
1838 voice_channel_->transport_channel()->SignalSentPacket.connect( | |
1839 this, &WebRtcSession::OnSentPacket); | |
1830 return true; | 1840 return true; |
1831 } | 1841 } |
1832 | 1842 |
1833 bool WebRtcSession::CreateVideoChannel(const cricket::ContentInfo* content) { | 1843 bool WebRtcSession::CreateVideoChannel(const cricket::ContentInfo* content) { |
1834 video_channel_.reset(channel_manager_->CreateVideoChannel( | 1844 video_channel_.reset(channel_manager_->CreateVideoChannel( |
1835 media_controller_.get(), transport_controller(), content->name, true, | 1845 media_controller_.get(), transport_controller(), content->name, true, |
1836 video_options_)); | 1846 video_options_)); |
1837 if (!video_channel_) { | 1847 if (!video_channel_) { |
1838 return false; | 1848 return false; |
1839 } | 1849 } |
1840 | 1850 |
1841 video_channel_->SignalDtlsSetupFailure.connect( | 1851 video_channel_->SignalDtlsSetupFailure.connect( |
1842 this, &WebRtcSession::OnDtlsSetupFailure); | 1852 this, &WebRtcSession::OnDtlsSetupFailure); |
1853 video_channel_->transport_channel()->SignalSentPacket.connect( | |
1854 this, &WebRtcSession::OnSentPacket); | |
1843 return true; | 1855 return true; |
1844 } | 1856 } |
1845 | 1857 |
1846 bool WebRtcSession::CreateDataChannel(const cricket::ContentInfo* content) { | 1858 bool WebRtcSession::CreateDataChannel(const cricket::ContentInfo* content) { |
1847 bool sctp = (data_channel_type_ == cricket::DCT_SCTP); | 1859 bool sctp = (data_channel_type_ == cricket::DCT_SCTP); |
1848 data_channel_.reset(channel_manager_->CreateDataChannel( | 1860 data_channel_.reset(channel_manager_->CreateDataChannel( |
1849 transport_controller(), content->name, !sctp, data_channel_type_)); | 1861 transport_controller(), content->name, !sctp, data_channel_type_)); |
1850 if (!data_channel_) { | 1862 if (!data_channel_) { |
1851 return false; | 1863 return false; |
1852 } | 1864 } |
1853 | 1865 |
1854 if (sctp) { | 1866 if (sctp) { |
1855 mediastream_signaling_->OnDataTransportCreatedForSctp(); | 1867 mediastream_signaling_->OnDataTransportCreatedForSctp(); |
1856 data_channel_->SignalDataReceived.connect( | 1868 data_channel_->SignalDataReceived.connect( |
1857 this, &WebRtcSession::OnDataChannelMessageReceived); | 1869 this, &WebRtcSession::OnDataChannelMessageReceived); |
1858 data_channel_->SignalStreamClosedRemotely.connect( | 1870 data_channel_->SignalStreamClosedRemotely.connect( |
1859 mediastream_signaling_, | 1871 mediastream_signaling_, |
1860 &MediaStreamSignaling::OnRemoteSctpDataChannelClosed); | 1872 &MediaStreamSignaling::OnRemoteSctpDataChannelClosed); |
1861 } | 1873 } |
1862 | 1874 |
1863 data_channel_->SignalDtlsSetupFailure.connect( | 1875 data_channel_->SignalDtlsSetupFailure.connect( |
1864 this, &WebRtcSession::OnDtlsSetupFailure); | 1876 this, &WebRtcSession::OnDtlsSetupFailure); |
1877 data_channel_->transport_channel()->SignalSentPacket.connect( | |
1878 this, &WebRtcSession::OnSentPacket); | |
1865 return true; | 1879 return true; |
1866 } | 1880 } |
1867 | 1881 |
1868 void WebRtcSession::OnDtlsSetupFailure(cricket::BaseChannel*, bool rtcp) { | 1882 void WebRtcSession::OnDtlsSetupFailure(cricket::BaseChannel*, bool rtcp) { |
1869 SetError(BaseSession::ERROR_TRANSPORT, rtcp ? kDtlsSetupFailureRtcp : | 1883 SetError(BaseSession::ERROR_TRANSPORT, rtcp ? kDtlsSetupFailureRtcp : |
1870 kDtlsSetupFailureRtp); | 1884 kDtlsSetupFailureRtp); |
1871 } | 1885 } |
1872 | 1886 |
1873 void WebRtcSession::CopySavedCandidates( | 1887 void WebRtcSession::CopySavedCandidates( |
1874 SessionDescriptionInterface* dest_desc) { | 1888 SessionDescriptionInterface* dest_desc) { |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2178 | 2192 |
2179 if (!srtp_cipher.empty()) { | 2193 if (!srtp_cipher.empty()) { |
2180 metrics_observer_->IncrementSparseEnumCounter( | 2194 metrics_observer_->IncrementSparseEnumCounter( |
2181 srtp_counter_type, rtc::GetSrtpCryptoSuiteFromName(srtp_cipher)); | 2195 srtp_counter_type, rtc::GetSrtpCryptoSuiteFromName(srtp_cipher)); |
2182 } | 2196 } |
2183 if (ssl_cipher) { | 2197 if (ssl_cipher) { |
2184 metrics_observer_->IncrementSparseEnumCounter(ssl_counter_type, ssl_cipher); | 2198 metrics_observer_->IncrementSparseEnumCounter(ssl_counter_type, ssl_cipher); |
2185 } | 2199 } |
2186 } | 2200 } |
2187 | 2201 |
2202 void WebRtcSession::OnSentPacket(cricket::TransportChannel* channel, | |
2203 const rtc::SentPacket& sent_packet) { | |
2204 media_controller_->call_w()->OnSentPacket(sent_packet); | |
2205 } | |
2206 | |
2188 } // namespace webrtc | 2207 } // namespace webrtc |
OLD | NEW |