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

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

Issue 1363573002: Wire up transport sequence number / send time callbacks to webrtc via libjingle. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Cleanup Created 5 years, 2 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 27 matching lines...) Expand all
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
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(webrtc::MediaControllerInterface* media_controller,
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)
545 : cricket::BaseSession(signaling_thread, 548 : cricket::BaseSession(signaling_thread,
546 worker_thread, 549 worker_thread,
547 port_allocator, 550 port_allocator,
548 rtc::ToString(rtc::CreateRandomId64() & LLONG_MAX), 551 rtc::ToString(rtc::CreateRandomId64() & LLONG_MAX),
549 false), 552 false),
550 // RFC 3264: The numeric value of the session id and version in the 553 // 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". 554 // 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. 555 // Due to this constraint session id |sid_| is max limited to LLONG_MAX.
553 channel_manager_(channel_manager), 556 media_controller_(media_controller),
557 channel_manager_(media_controller_->channel_manager()),
554 mediastream_signaling_(mediastream_signaling), 558 mediastream_signaling_(mediastream_signaling),
555 ice_observer_(NULL), 559 ice_observer_(NULL),
556 ice_connection_state_(PeerConnectionInterface::kIceConnectionNew), 560 ice_connection_state_(PeerConnectionInterface::kIceConnectionNew),
557 ice_connection_receiving_(true), 561 ice_connection_receiving_(true),
558 older_version_remote_peer_(false), 562 older_version_remote_peer_(false),
559 dtls_enabled_(false), 563 dtls_enabled_(false),
560 data_channel_type_(cricket::DCT_NONE), 564 data_channel_type_(cricket::DCT_NONE),
561 ice_restart_latch_(new IceRestartAnswerLatch), 565 ice_restart_latch_(new IceRestartAnswerLatch),
562 metrics_observer_(NULL) { 566 metrics_observer_(NULL) {
563 transport_controller()->SignalConnectionState.connect( 567 transport_controller()->SignalConnectionState.connect(
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 } 773 }
770 port_allocator()->set_candidate_filter( 774 port_allocator()->set_candidate_filter(
771 ConvertIceTransportTypeToCandidateFilter(rtc_configuration.type)); 775 ConvertIceTransportTypeToCandidateFilter(rtc_configuration.type));
772 776
773 if (rtc_configuration.enable_localhost_ice_candidate) { 777 if (rtc_configuration.enable_localhost_ice_candidate) {
774 port_allocator()->set_flags( 778 port_allocator()->set_flags(
775 port_allocator()->flags() | 779 port_allocator()->flags() |
776 cricket::PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE); 780 cricket::PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE);
777 } 781 }
778 782
779 media_controller_.reset(MediaControllerInterface::Create(
780 worker_thread(), channel_manager_->media_engine()->GetVoE()));
781
782 return true; 783 return true;
783 } 784 }
784 785
785 cricket::IceConfig WebRtcSession::ParseIceConfig( 786 cricket::IceConfig WebRtcSession::ParseIceConfig(
786 const PeerConnectionInterface::RTCConfiguration& config) const { 787 const PeerConnectionInterface::RTCConfiguration& config) const {
787 cricket::IceConfig ice_config; 788 cricket::IceConfig ice_config;
788 ice_config.receiving_timeout_ms = config.ice_connection_receiving_timeout; 789 ice_config.receiving_timeout_ms = config.ice_connection_receiving_timeout;
789 ice_config.gather_continually = (config.continual_gathering_policy == 790 ice_config.gather_continually = (config.continual_gathering_policy ==
790 PeerConnectionInterface::GATHER_CONTINUALLY); 791 PeerConnectionInterface::GATHER_CONTINUALLY);
791 return ice_config; 792 return ice_config;
(...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after
1812 LOG(LS_WARNING) << "max-bundle failed to enable bundling."; 1813 LOG(LS_WARNING) << "max-bundle failed to enable bundling.";
1813 return false; 1814 return false;
1814 } 1815 }
1815 } 1816 }
1816 1817
1817 return true; 1818 return true;
1818 } 1819 }
1819 1820
1820 bool WebRtcSession::CreateVoiceChannel(const cricket::ContentInfo* content) { 1821 bool WebRtcSession::CreateVoiceChannel(const cricket::ContentInfo* content) {
1821 voice_channel_.reset(channel_manager_->CreateVoiceChannel( 1822 voice_channel_.reset(channel_manager_->CreateVoiceChannel(
1822 media_controller_.get(), transport_controller(), content->name, true, 1823 media_controller_, transport_controller(), content->name, true,
1823 audio_options_)); 1824 audio_options_));
1824 if (!voice_channel_) { 1825 if (!voice_channel_) {
1825 return false; 1826 return false;
1826 } 1827 }
1827 1828
1828 voice_channel_->SignalDtlsSetupFailure.connect( 1829 voice_channel_->SignalDtlsSetupFailure.connect(
1829 this, &WebRtcSession::OnDtlsSetupFailure); 1830 this, &WebRtcSession::OnDtlsSetupFailure);
1831 voice_channel_->transport_channel()->SignalSentPacket.connect(
1832 this, &WebRtcSession::OnSentPacket);
1830 return true; 1833 return true;
1831 } 1834 }
1832 1835
1833 bool WebRtcSession::CreateVideoChannel(const cricket::ContentInfo* content) { 1836 bool WebRtcSession::CreateVideoChannel(const cricket::ContentInfo* content) {
1834 video_channel_.reset(channel_manager_->CreateVideoChannel( 1837 video_channel_.reset(channel_manager_->CreateVideoChannel(
1835 media_controller_.get(), transport_controller(), content->name, true, 1838 media_controller_, transport_controller(), content->name, true,
1836 video_options_)); 1839 video_options_));
1837 if (!video_channel_) { 1840 if (!video_channel_) {
1838 return false; 1841 return false;
1839 } 1842 }
1840 1843
1841 video_channel_->SignalDtlsSetupFailure.connect( 1844 video_channel_->SignalDtlsSetupFailure.connect(
1842 this, &WebRtcSession::OnDtlsSetupFailure); 1845 this, &WebRtcSession::OnDtlsSetupFailure);
1846 video_channel_->transport_channel()->SignalSentPacket.connect(
1847 this, &WebRtcSession::OnSentPacket);
1843 return true; 1848 return true;
1844 } 1849 }
1845 1850
1846 bool WebRtcSession::CreateDataChannel(const cricket::ContentInfo* content) { 1851 bool WebRtcSession::CreateDataChannel(const cricket::ContentInfo* content) {
1847 bool sctp = (data_channel_type_ == cricket::DCT_SCTP); 1852 bool sctp = (data_channel_type_ == cricket::DCT_SCTP);
1848 data_channel_.reset(channel_manager_->CreateDataChannel( 1853 data_channel_.reset(channel_manager_->CreateDataChannel(
1849 transport_controller(), content->name, !sctp, data_channel_type_)); 1854 transport_controller(), content->name, !sctp, data_channel_type_));
1850 if (!data_channel_) { 1855 if (!data_channel_) {
1851 return false; 1856 return false;
1852 } 1857 }
1853 1858
1854 if (sctp) { 1859 if (sctp) {
1855 mediastream_signaling_->OnDataTransportCreatedForSctp(); 1860 mediastream_signaling_->OnDataTransportCreatedForSctp();
1856 data_channel_->SignalDataReceived.connect( 1861 data_channel_->SignalDataReceived.connect(
1857 this, &WebRtcSession::OnDataChannelMessageReceived); 1862 this, &WebRtcSession::OnDataChannelMessageReceived);
1858 data_channel_->SignalStreamClosedRemotely.connect( 1863 data_channel_->SignalStreamClosedRemotely.connect(
1859 mediastream_signaling_, 1864 mediastream_signaling_,
1860 &MediaStreamSignaling::OnRemoteSctpDataChannelClosed); 1865 &MediaStreamSignaling::OnRemoteSctpDataChannelClosed);
1861 } 1866 }
1862 1867
1863 data_channel_->SignalDtlsSetupFailure.connect( 1868 data_channel_->SignalDtlsSetupFailure.connect(
1864 this, &WebRtcSession::OnDtlsSetupFailure); 1869 this, &WebRtcSession::OnDtlsSetupFailure);
1870 data_channel_->transport_channel()->SignalSentPacket.connect(
1871 this, &WebRtcSession::OnSentPacket);
1865 return true; 1872 return true;
1866 } 1873 }
1867 1874
1868 void WebRtcSession::OnDtlsSetupFailure(cricket::BaseChannel*, bool rtcp) { 1875 void WebRtcSession::OnDtlsSetupFailure(cricket::BaseChannel*, bool rtcp) {
1869 SetError(BaseSession::ERROR_TRANSPORT, rtcp ? kDtlsSetupFailureRtcp : 1876 SetError(BaseSession::ERROR_TRANSPORT, rtcp ? kDtlsSetupFailureRtcp :
1870 kDtlsSetupFailureRtp); 1877 kDtlsSetupFailureRtp);
1871 } 1878 }
1872 1879
1873 void WebRtcSession::CopySavedCandidates( 1880 void WebRtcSession::CopySavedCandidates(
1874 SessionDescriptionInterface* dest_desc) { 1881 SessionDescriptionInterface* dest_desc) {
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
2178 2185
2179 if (!srtp_cipher.empty()) { 2186 if (!srtp_cipher.empty()) {
2180 metrics_observer_->IncrementSparseEnumCounter( 2187 metrics_observer_->IncrementSparseEnumCounter(
2181 srtp_counter_type, rtc::GetSrtpCryptoSuiteFromName(srtp_cipher)); 2188 srtp_counter_type, rtc::GetSrtpCryptoSuiteFromName(srtp_cipher));
2182 } 2189 }
2183 if (ssl_cipher) { 2190 if (ssl_cipher) {
2184 metrics_observer_->IncrementSparseEnumCounter(ssl_counter_type, ssl_cipher); 2191 metrics_observer_->IncrementSparseEnumCounter(ssl_counter_type, ssl_cipher);
2185 } 2192 }
2186 } 2193 }
2187 2194
2195 void WebRtcSession::OnSentPacket(cricket::TransportChannel* channel,
2196 const rtc::SentPacket& sent_packet) {
2197 worker_thread()->Invoke<void>(
2198 rtc::Bind(&WebRtcSession::OnSentPacket_w, this, sent_packet));
2199 media_controller_->call_w()->OnSentPacket(sent_packet);
pthatcher1 2015/10/13 05:31:13 Two things: 1. If you hop to the worker thread,
stefan-webrtc 2015/10/13 08:09:20 You are right, it should. Keeping OnSentPacket_w.
2200 }
2201
2202 void WebRtcSession::OnSentPacket_w(const rtc::SentPacket& sent_packet) {
2203 RTC_DCHECK(worker_thread()->IsCurrent());
2204 media_controller_->call_w()->OnSentPacket(sent_packet);
2205 }
2206
2188 } // namespace webrtc 2207 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698