10e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org/* 20e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * libjingle 30e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * Copyright 2012, Google Inc. 40e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * 50e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * Redistribution and use in source and binary forms, with or without 60e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * modification, are permitted provided that the following conditions are met: 70e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * 80e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * 1. Redistributions of source code must retain the above copyright notice, 90e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * this list of conditions and the following disclaimer. 100e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * 2. Redistributions in binary form must reproduce the above copyright notice, 110e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * this list of conditions and the following disclaimer in the documentation 120e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * and/or other materials provided with the distribution. 130e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * 3. The name of the author may not be used to endorse or promote products 140e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * derived from this software without specific prior written permission. 150e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * 160e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 170e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 180e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 190e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 200e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 210e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 220e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 230e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 240e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 250e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 260e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org */ 270e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 280e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#ifndef TALK_APP_WEBRTC_WEBRTCSESSION_H_ 290e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#define TALK_APP_WEBRTC_WEBRTCSESSION_H_ 300e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 310e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#include <string> 320e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 33cf81adffe15fa8ea0f333432e41f6d504148f18abuildbot@webrtc.org#include "talk/app/webrtc/datachannel.h" 340e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#include "talk/app/webrtc/dtmfsender.h" 350e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#include "talk/app/webrtc/mediastreamprovider.h" 36cf81adffe15fa8ea0f333432e41f6d504148f18abuildbot@webrtc.org#include "talk/app/webrtc/peerconnectioninterface.h" 370e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#include "talk/app/webrtc/statstypes.h" 380e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#include "talk/media/base/mediachannel.h" 390e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#include "talk/p2p/base/session.h" 400e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#include "talk/session/media/mediasession.h" 41cf81adffe15fa8ea0f333432e41f6d504148f18abuildbot@webrtc.org#include "webrtc/base/sigslot.h" 42cf81adffe15fa8ea0f333432e41f6d504148f18abuildbot@webrtc.org#include "webrtc/base/thread.h" 430e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 440e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgnamespace cricket { 453865f242aa057847ca2c3728d24874882ef227eehenrike@webrtc.org 463db045861afcaf20aed671c0de15a6ff4ca32d08wu@webrtc.orgclass BaseChannel; 470e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgclass ChannelManager; 480e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgclass DataChannel; 490e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgclass StatsReport; 500e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgclass Transport; 510e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgclass VideoCapturer; 520e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgclass VideoChannel; 530e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgclass VoiceChannel; 543865f242aa057847ca2c3728d24874882ef227eehenrike@webrtc.org 550e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org} // namespace cricket 560e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 570e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgnamespace webrtc { 5841c4db4baf4ecf1e3e5e91178534a2603b7dce87buildbot@webrtc.org 590e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgclass IceRestartAnswerLatch; 6041c4db4baf4ecf1e3e5e91178534a2603b7dce87buildbot@webrtc.orgclass JsepIceCandidate; 610e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgclass MediaStreamSignaling; 625aed3bb9fb287faecd773b88bb68732c31579590wu@webrtc.orgclass WebRtcSessionDescriptionFactory; 630e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 647162d28d68ad58802a5a52eca0df59150ee7b9d4henrike@webrtc.orgextern const char kBundleWithoutRtcpMux[]; 65f32dd31e14521d7f845e7776af6d44d411573370sergeyu@chromium.orgextern const char kCreateChannelFailed[]; 660e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgextern const char kInvalidCandidates[]; 670e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgextern const char kInvalidSdp[]; 680e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgextern const char kMlineMismatch[]; 69f32dd31e14521d7f845e7776af6d44d411573370sergeyu@chromium.orgextern const char kPushDownTDFailed[]; 70ac5a3e5f1e59174797dc60641cba617c1bf0c279henrike@webrtc.orgextern const char kSdpWithoutDtlsFingerprint[]; 71ac5a3e5f1e59174797dc60641cba617c1bf0c279henrike@webrtc.orgextern const char kSdpWithoutSdesCrypto[]; 728841d7bf4010478a4b3978ff2d181d9504b2bbe3mallinath@webrtc.orgextern const char kSdpWithoutIceUfragPwd[]; 73f32dd31e14521d7f845e7776af6d44d411573370sergeyu@chromium.orgextern const char kSdpWithoutSdesAndDtlsDisabled[]; 740e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgextern const char kSessionError[]; 75f32dd31e14521d7f845e7776af6d44d411573370sergeyu@chromium.orgextern const char kSessionErrorDesc[]; 76b752f54aad7adfda3ccf223fb86f23c8b3ae7283buildbot@webrtc.org// Maximum number of received video streams that will be processed by webrtc 77b752f54aad7adfda3ccf223fb86f23c8b3ae7283buildbot@webrtc.org// even if they are not signalled beforehand. 78b752f54aad7adfda3ccf223fb86f23c8b3ae7283buildbot@webrtc.orgextern const int kMaxUnsignalledRecvStreams; 790e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 800e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// ICE state callback interface. 810e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgclass IceObserver { 820e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org public: 833db045861afcaf20aed671c0de15a6ff4ca32d08wu@webrtc.org IceObserver() {} 840e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Called any time the IceConnectionState changes 850e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual void OnIceConnectionChange( 860e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org PeerConnectionInterface::IceConnectionState new_state) {} 870e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Called any time the IceGatheringState changes 880e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual void OnIceGatheringChange( 890e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org PeerConnectionInterface::IceGatheringState new_state) {} 900e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // New Ice candidate have been found. 910e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual void OnIceCandidate(const IceCandidateInterface* candidate) = 0; 920e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // All Ice candidates have been found. 930e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // TODO(bemasc): Remove this once callers transition to OnIceGatheringChange. 940e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // (via PeerConnectionObserver) 950e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual void OnIceComplete() {} 960e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 970e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org protected: 980e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org ~IceObserver() {} 993db045861afcaf20aed671c0de15a6ff4ca32d08wu@webrtc.org 1003db045861afcaf20aed671c0de15a6ff4ca32d08wu@webrtc.org private: 1013db045861afcaf20aed671c0de15a6ff4ca32d08wu@webrtc.org DISALLOW_COPY_AND_ASSIGN(IceObserver); 1020e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org}; 1030e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 1040e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgclass WebRtcSession : public cricket::BaseSession, 1050e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org public AudioProviderInterface, 1060e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org public DataChannelFactory, 1070e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org public VideoProviderInterface, 108861d07361a4559a72e96236f27b758a56f6f59f0wu@webrtc.org public DtmfProviderInterface, 109861d07361a4559a72e96236f27b758a56f6f59f0wu@webrtc.org public DataChannelProviderInterface { 1100e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org public: 1110e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org WebRtcSession(cricket::ChannelManager* channel_manager, 1122a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org rtc::Thread* signaling_thread, 1132a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org rtc::Thread* worker_thread, 1140e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org cricket::PortAllocator* port_allocator, 1150e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org MediaStreamSignaling* mediastream_signaling); 1160e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual ~WebRtcSession(); 1170e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 1185c9dd59107e049112f2e9a62d08a02ef4448a957wu@webrtc.org bool Initialize(const PeerConnectionFactoryInterface::Options& options, 1195c9dd59107e049112f2e9a62d08a02ef4448a957wu@webrtc.org const MediaConstraintsInterface* constraints, 12041c4db4baf4ecf1e3e5e91178534a2603b7dce87buildbot@webrtc.org DTLSIdentityServiceInterface* dtls_identity_service, 12141c4db4baf4ecf1e3e5e91178534a2603b7dce87buildbot@webrtc.org PeerConnectionInterface::IceTransportsType ice_transport); 1220e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Deletes the voice, video and data channel and changes the session state 1230e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // to STATE_RECEIVEDTERMINATE. 1240e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org void Terminate(); 1250e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 1260e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org void RegisterIceObserver(IceObserver* observer) { 1270e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org ice_observer_ = observer; 1280e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org } 1290e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 1300e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual cricket::VoiceChannel* voice_channel() { 1310e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org return voice_channel_.get(); 1320e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org } 1330e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual cricket::VideoChannel* video_channel() { 1340e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org return video_channel_.get(); 1350e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org } 1360e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual cricket::DataChannel* data_channel() { 1370e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org return data_channel_.get(); 1380e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org } 1390e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 140ac5a3e5f1e59174797dc60641cba617c1bf0c279henrike@webrtc.org void SetSdesPolicy(cricket::SecurePolicy secure_policy); 141ac5a3e5f1e59174797dc60641cba617c1bf0c279henrike@webrtc.org cricket::SecurePolicy SdesPolicy() const; 1420e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 143a487db2aeda23ade81f0b2e5fd4d50f874d06a9csergeyu@chromium.org // Get current ssl role from transport. 1442a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org bool GetSslRole(rtc::SSLRole* role); 145a487db2aeda23ade81f0b2e5fd4d50f874d06a9csergeyu@chromium.org 1460e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Generic error message callback from WebRtcSession. 1470e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // TODO - It may be necessary to supply error code as well. 1480e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org sigslot::signal0<> SignalError; 1490e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 1504fa2e857bf13d5b55747501e951a98a52330eed2jiayl@webrtc.org void CreateOffer( 1514fa2e857bf13d5b55747501e951a98a52330eed2jiayl@webrtc.org CreateSessionDescriptionObserver* observer, 1524fa2e857bf13d5b55747501e951a98a52330eed2jiayl@webrtc.org const PeerConnectionInterface::RTCOfferAnswerOptions& options); 1535aed3bb9fb287faecd773b88bb68732c31579590wu@webrtc.org void CreateAnswer(CreateSessionDescriptionObserver* observer, 1545aed3bb9fb287faecd773b88bb68732c31579590wu@webrtc.org const MediaConstraintsInterface* constraints); 1551a04b881e0ef480802fb01b4fbe9bcd5388d2c69henrike@webrtc.org // The ownership of |desc| will be transferred after this call. 1560e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org bool SetLocalDescription(SessionDescriptionInterface* desc, 1570e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org std::string* err_desc); 1581a04b881e0ef480802fb01b4fbe9bcd5388d2c69henrike@webrtc.org // The ownership of |desc| will be transferred after this call. 1590e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org bool SetRemoteDescription(SessionDescriptionInterface* desc, 1600e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org std::string* err_desc); 1610e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org bool ProcessIceMessage(const IceCandidateInterface* ice_candidate); 16241c4db4baf4ecf1e3e5e91178534a2603b7dce87buildbot@webrtc.org 1632ca56577c4c9aaedeb70024d2012a1f519dfb201mallinath@webrtc.org bool SetIceTransports(PeerConnectionInterface::IceTransportsType type); 16441c4db4baf4ecf1e3e5e91178534a2603b7dce87buildbot@webrtc.org 1650e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org const SessionDescriptionInterface* local_description() const { 1660e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org return local_desc_.get(); 1670e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org } 1680e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org const SessionDescriptionInterface* remote_description() const { 1690e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org return remote_desc_.get(); 1700e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org } 1710e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 1720e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Get the id used as a media stream track's "id" field from ssrc. 173890e5875bea3af49a763bd49eba6d55dc4cbd190xians@webrtc.org virtual bool GetLocalTrackIdBySsrc(uint32 ssrc, std::string* track_id); 174890e5875bea3af49a763bd49eba6d55dc4cbd190xians@webrtc.org virtual bool GetRemoteTrackIdBySsrc(uint32 ssrc, std::string* track_id); 175890e5875bea3af49a763bd49eba6d55dc4cbd190xians@webrtc.org 1760e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 1770e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // AudioMediaProviderInterface implementation. 1787162d28d68ad58802a5a52eca0df59150ee7b9d4henrike@webrtc.org virtual void SetAudioPlayout(uint32 ssrc, bool enable, 1797162d28d68ad58802a5a52eca0df59150ee7b9d4henrike@webrtc.org cricket::AudioRenderer* renderer) OVERRIDE; 1800e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual void SetAudioSend(uint32 ssrc, bool enable, 1817162d28d68ad58802a5a52eca0df59150ee7b9d4henrike@webrtc.org const cricket::AudioOptions& options, 1827162d28d68ad58802a5a52eca0df59150ee7b9d4henrike@webrtc.org cricket::AudioRenderer* renderer) OVERRIDE; 1838a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org virtual void SetAudioPlayoutVolume(uint32 ssrc, double volume) OVERRIDE; 1840e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 1850e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Implements VideoMediaProviderInterface. 1860e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual bool SetCaptureDevice(uint32 ssrc, 1870e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org cricket::VideoCapturer* camera) OVERRIDE; 1880e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual void SetVideoPlayout(uint32 ssrc, 1890e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org bool enable, 1900e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org cricket::VideoRenderer* renderer) OVERRIDE; 1910e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual void SetVideoSend(uint32 ssrc, bool enable, 1920e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org const cricket::VideoOptions* options) OVERRIDE; 1930e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 1940e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Implements DtmfProviderInterface. 1950e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual bool CanInsertDtmf(const std::string& track_id); 1960e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual bool InsertDtmf(const std::string& track_id, 1970e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org int code, int duration); 1980e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual sigslot::signal0<>* GetOnDestroyedSignal(); 1990e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 200861d07361a4559a72e96236f27b758a56f6f59f0wu@webrtc.org // Implements DataChannelProviderInterface. 201861d07361a4559a72e96236f27b758a56f6f59f0wu@webrtc.org virtual bool SendData(const cricket::SendDataParams& params, 2022a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org const rtc::Buffer& payload, 203861d07361a4559a72e96236f27b758a56f6f59f0wu@webrtc.org cricket::SendDataResult* result) OVERRIDE; 204861d07361a4559a72e96236f27b758a56f6f59f0wu@webrtc.org virtual bool ConnectDataChannel(DataChannel* webrtc_data_channel) OVERRIDE; 205861d07361a4559a72e96236f27b758a56f6f59f0wu@webrtc.org virtual void DisconnectDataChannel(DataChannel* webrtc_data_channel) OVERRIDE; 206d1f631d5ec5c25dd0a63ed70d0ffa66037d8aa6awu@webrtc.org virtual void AddSctpDataStream(uint32 sid) OVERRIDE; 207d1f631d5ec5c25dd0a63ed70d0ffa66037d8aa6awu@webrtc.org virtual void RemoveSctpDataStream(uint32 sid) OVERRIDE; 2084646ae6b3bb147572c89f4aa2fd1ab5566ca3c2ewu@webrtc.org virtual bool ReadyToSendData() const OVERRIDE; 209861d07361a4559a72e96236f27b758a56f6f59f0wu@webrtc.org 2108485ec698cd13d65354e2f81132b5763a3d216a4henrika@webrtc.org // Implements DataChannelFactory. 2112a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org rtc::scoped_refptr<DataChannel> CreateDataChannel( 2120e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org const std::string& label, 2138485ec698cd13d65354e2f81132b5763a3d216a4henrika@webrtc.org const InternalDataChannelInit* config) OVERRIDE; 2140e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 2150e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org cricket::DataChannelType data_channel_type() const; 2160e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 2175aed3bb9fb287faecd773b88bb68732c31579590wu@webrtc.org bool IceRestartPending() const; 2185aed3bb9fb287faecd773b88bb68732c31579590wu@webrtc.org 2195aed3bb9fb287faecd773b88bb68732c31579590wu@webrtc.org void ResetIceRestartLatch(); 2205aed3bb9fb287faecd773b88bb68732c31579590wu@webrtc.org 2215aed3bb9fb287faecd773b88bb68732c31579590wu@webrtc.org // Called when an SSLIdentity is generated or retrieved by 2225aed3bb9fb287faecd773b88bb68732c31579590wu@webrtc.org // WebRTCSessionDescriptionFactory. Should happen before setLocalDescription. 2232a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org void OnIdentityReady(rtc::SSLIdentity* identity); 2245aed3bb9fb287faecd773b88bb68732c31579590wu@webrtc.org 2255aed3bb9fb287faecd773b88bb68732c31579590wu@webrtc.org // For unit test. 2265aed3bb9fb287faecd773b88bb68732c31579590wu@webrtc.org bool waiting_for_identity() const; 2275aed3bb9fb287faecd773b88bb68732c31579590wu@webrtc.org 2280e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org private: 2290e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Indicates the type of SessionDescription in a call to SetLocalDescription 2300e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // and SetRemoteDescription. 2310e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org enum Action { 2320e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org kOffer, 2330e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org kPrAnswer, 2340e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org kAnswer, 2350e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org }; 2365aed3bb9fb287faecd773b88bb68732c31579590wu@webrtc.org 2370e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Invokes ConnectChannels() on transport proxies, which initiates ice 2380e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // candidates allocation. 2390e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org bool StartCandidatesAllocation(); 2400e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org bool UpdateSessionState(Action action, cricket::ContentSource source, 2410e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org std::string* err_desc); 2420e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org static Action GetAction(const std::string& type); 2430e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 2440e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Transport related callbacks, override from cricket::BaseSession. 2450e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual void OnTransportRequestSignaling(cricket::Transport* transport); 2460e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual void OnTransportConnecting(cricket::Transport* transport); 2470e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual void OnTransportWritable(cricket::Transport* transport); 248f5e5b3a9ce372d0e3cc594bf0036dda64a57d81dmallinath@webrtc.org virtual void OnTransportCompleted(cricket::Transport* transport); 249f5e5b3a9ce372d0e3cc594bf0036dda64a57d81dmallinath@webrtc.org virtual void OnTransportFailed(cricket::Transport* transport); 2500e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual void OnTransportProxyCandidatesReady( 2510e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org cricket::TransportProxy* proxy, 2520e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org const cricket::Candidates& candidates); 2530e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual void OnCandidatesAllocationDone(); 2540e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 2550e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Creates local session description with audio and video contents. 2560e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org bool CreateDefaultLocalDescription(); 2570e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Enables media channels to allow sending of media. 2580e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org void EnableChannels(); 2590e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Creates a JsepIceCandidate and adds it to the local session description 2600e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // and notify observers. Called when a new local candidate have been found. 2610e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org void ProcessNewLocalCandidate(const std::string& content_name, 2620e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org const cricket::Candidates& candidates); 2630e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Returns the media index for a local ice candidate given the content name. 2640e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Returns false if the local session description does not have a media 2650e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // content called |content_name|. 2660e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org bool GetLocalCandidateMediaIndex(const std::string& content_name, 2670e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org int* sdp_mline_index); 2680e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Uses all remote candidates in |remote_desc| in this session. 2690e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org bool UseCandidatesInSessionDescription( 2700e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org const SessionDescriptionInterface* remote_desc); 2710e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Uses |candidate| in this session. 2720e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org bool UseCandidate(const IceCandidateInterface* candidate); 2730e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Deletes the corresponding channel of contents that don't exist in |desc|. 2740e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // |desc| can be null. This means that all channels are deleted. 2750e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org void RemoveUnusedChannelsAndTransports( 2760e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org const cricket::SessionDescription* desc); 2770e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 2780e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Allocates media channels based on the |desc|. If |desc| doesn't have 2790e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // the BUNDLE option, this method will disable BUNDLE in PortAllocator. 2800e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // This method will also delete any existing media channels before creating. 2810e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org bool CreateChannels(const cricket::SessionDescription* desc); 2820e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 2830e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Helper methods to create media channels. 2847162d28d68ad58802a5a52eca0df59150ee7b9d4henrike@webrtc.org bool CreateVoiceChannel(const cricket::ContentInfo* content); 2857162d28d68ad58802a5a52eca0df59150ee7b9d4henrike@webrtc.org bool CreateVideoChannel(const cricket::ContentInfo* content); 2867162d28d68ad58802a5a52eca0df59150ee7b9d4henrike@webrtc.org bool CreateDataChannel(const cricket::ContentInfo* content); 2877162d28d68ad58802a5a52eca0df59150ee7b9d4henrike@webrtc.org 2880e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Copy the candidates from |saved_candidates_| to |dest_desc|. 2890e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // The |saved_candidates_| will be cleared after this function call. 2900e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org void CopySavedCandidates(SessionDescriptionInterface* dest_desc); 2910e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 2928485ec698cd13d65354e2f81132b5763a3d216a4henrika@webrtc.org // Listens to SCTP CONTROL messages on unused SIDs and process them as OPEN 2938485ec698cd13d65354e2f81132b5763a3d216a4henrika@webrtc.org // messages. 2948485ec698cd13d65354e2f81132b5763a3d216a4henrika@webrtc.org void OnDataChannelMessageReceived(cricket::DataChannel* channel, 2958485ec698cd13d65354e2f81132b5763a3d216a4henrika@webrtc.org const cricket::ReceiveDataParams& params, 2962a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org const rtc::Buffer& payload); 2970e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 298f32dd31e14521d7f845e7776af6d44d411573370sergeyu@chromium.org std::string BadStateErrMsg(State state); 2990e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org void SetIceConnectionState(PeerConnectionInterface::IceConnectionState state); 3000e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 301a487db2aeda23ade81f0b2e5fd4d50f874d06a9csergeyu@chromium.org bool ValidateBundleSettings(const cricket::SessionDescription* desc); 3027162d28d68ad58802a5a52eca0df59150ee7b9d4henrike@webrtc.org bool HasRtcpMuxEnabled(const cricket::ContentInfo* content); 303a487db2aeda23ade81f0b2e5fd4d50f874d06a9csergeyu@chromium.org // Below methods are helper methods which verifies SDP. 304a487db2aeda23ade81f0b2e5fd4d50f874d06a9csergeyu@chromium.org bool ValidateSessionDescription(const SessionDescriptionInterface* sdesc, 305a487db2aeda23ade81f0b2e5fd4d50f874d06a9csergeyu@chromium.org cricket::ContentSource source, 306f32dd31e14521d7f845e7776af6d44d411573370sergeyu@chromium.org std::string* err_desc); 307a487db2aeda23ade81f0b2e5fd4d50f874d06a9csergeyu@chromium.org 308a487db2aeda23ade81f0b2e5fd4d50f874d06a9csergeyu@chromium.org // Check if a call to SetLocalDescription is acceptable with |action|. 309a487db2aeda23ade81f0b2e5fd4d50f874d06a9csergeyu@chromium.org bool ExpectSetLocalDescription(Action action); 310a487db2aeda23ade81f0b2e5fd4d50f874d06a9csergeyu@chromium.org // Check if a call to SetRemoteDescription is acceptable with |action|. 311a487db2aeda23ade81f0b2e5fd4d50f874d06a9csergeyu@chromium.org bool ExpectSetRemoteDescription(Action action); 312a487db2aeda23ade81f0b2e5fd4d50f874d06a9csergeyu@chromium.org // Verifies a=setup attribute as per RFC 5763. 313a487db2aeda23ade81f0b2e5fd4d50f874d06a9csergeyu@chromium.org bool ValidateDtlsSetupAttribute(const cricket::SessionDescription* desc, 314a487db2aeda23ade81f0b2e5fd4d50f874d06a9csergeyu@chromium.org Action action); 3157162d28d68ad58802a5a52eca0df59150ee7b9d4henrike@webrtc.org 3163588cd9ca934134ac5512fa6afc36fcf533a0040jiayl@webrtc.org // Returns true if we are ready to push down the remote candidate. 3173588cd9ca934134ac5512fa6afc36fcf533a0040jiayl@webrtc.org // |remote_desc| is the new remote description, or NULL if the current remote 3183588cd9ca934134ac5512fa6afc36fcf533a0040jiayl@webrtc.org // description should be used. Output |valid| is true if the candidate media 3193588cd9ca934134ac5512fa6afc36fcf533a0040jiayl@webrtc.org // index is valid. 3203588cd9ca934134ac5512fa6afc36fcf533a0040jiayl@webrtc.org bool ReadyToUseRemoteCandidate(const IceCandidateInterface* candidate, 3213588cd9ca934134ac5512fa6afc36fcf533a0040jiayl@webrtc.org const SessionDescriptionInterface* remote_desc, 3223588cd9ca934134ac5512fa6afc36fcf533a0040jiayl@webrtc.org bool* valid); 3233588cd9ca934134ac5512fa6afc36fcf533a0040jiayl@webrtc.org 324f32dd31e14521d7f845e7776af6d44d411573370sergeyu@chromium.org std::string GetSessionErrorMsg(); 325f32dd31e14521d7f845e7776af6d44d411573370sergeyu@chromium.org 3262a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org rtc::scoped_ptr<cricket::VoiceChannel> voice_channel_; 3272a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org rtc::scoped_ptr<cricket::VideoChannel> video_channel_; 3282a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org rtc::scoped_ptr<cricket::DataChannel> data_channel_; 3290e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org cricket::ChannelManager* channel_manager_; 3300e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org MediaStreamSignaling* mediastream_signaling_; 3310e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org IceObserver* ice_observer_; 3320e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org PeerConnectionInterface::IceConnectionState ice_connection_state_; 3332a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org rtc::scoped_ptr<SessionDescriptionInterface> local_desc_; 3342a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org rtc::scoped_ptr<SessionDescriptionInterface> remote_desc_; 3350e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Candidates that arrived before the remote description was set. 3360e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org std::vector<IceCandidateInterface*> saved_candidates_; 3370e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // If the remote peer is using a older version of implementation. 3380e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org bool older_version_remote_peer_; 3395528070a0c76057a000b877fc56ca4180ad2087bmallinath@webrtc.org bool dtls_enabled_; 3400e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Specifies which kind of data channel is allowed. This is controlled 3410e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // by the chrome command-line flag and constraints: 3420e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // 1. If chrome command-line switch 'enable-sctp-data-channels' is enabled, 3430e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // constraint kEnableDtlsSrtp is true, and constaint kEnableRtpDataChannels is 3440e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // not set or false, SCTP is allowed (DCT_SCTP); 3450e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // 2. If constraint kEnableRtpDataChannels is true, RTP is allowed (DCT_RTP); 3460e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // 3. If both 1&2 are false, data channel is not allowed (DCT_NONE). 3470e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org cricket::DataChannelType data_channel_type_; 3482a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org rtc::scoped_ptr<IceRestartAnswerLatch> ice_restart_latch_; 3495aed3bb9fb287faecd773b88bb68732c31579590wu@webrtc.org 3502a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org rtc::scoped_ptr<WebRtcSessionDescriptionFactory> 3515aed3bb9fb287faecd773b88bb68732c31579590wu@webrtc.org webrtc_session_desc_factory_; 3525aed3bb9fb287faecd773b88bb68732c31579590wu@webrtc.org 3530e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org sigslot::signal0<> SignalVoiceChannelDestroyed; 3540e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org sigslot::signal0<> SignalVideoChannelDestroyed; 3550e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org sigslot::signal0<> SignalDataChannelDestroyed; 3560e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 357bf64da011cfd8fc4c0243d7c52caa6db0d298bddhenrike@webrtc.org // Member variables for caching global options. 358bf64da011cfd8fc4c0243d7c52caa6db0d298bddhenrike@webrtc.org cricket::AudioOptions audio_options_; 359bf64da011cfd8fc4c0243d7c52caa6db0d298bddhenrike@webrtc.org cricket::VideoOptions video_options_; 360bf64da011cfd8fc4c0243d7c52caa6db0d298bddhenrike@webrtc.org 3613db045861afcaf20aed671c0de15a6ff4ca32d08wu@webrtc.org DISALLOW_COPY_AND_ASSIGN(WebRtcSession); 3623db045861afcaf20aed671c0de15a6ff4ca32d08wu@webrtc.org}; 3630e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org} // namespace webrtc 3640e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 3650e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#endif // TALK_APP_WEBRTC_WEBRTCSESSION_H_ 366