2013-07-10 00:45:36 +00:00
|
|
|
/*
|
2016-02-10 07:54:43 -08:00
|
|
|
* Copyright 2012 The WebRTC project authors. All Rights Reserved.
|
2013-07-10 00:45:36 +00:00
|
|
|
*
|
2016-02-10 07:54:43 -08:00
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
2013-07-10 00:45:36 +00:00
|
|
|
*/
|
|
|
|
|
|
2016-02-10 10:53:12 +01:00
|
|
|
#ifndef WEBRTC_API_WEBRTCSESSION_H_
|
|
|
|
|
#define WEBRTC_API_WEBRTCSESSION_H_
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2016-02-23 17:24:52 -08:00
|
|
|
#include <set>
|
2013-07-10 00:45:36 +00:00
|
|
|
#include <string>
|
2015-09-23 11:50:27 -07:00
|
|
|
#include <vector>
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2016-02-10 10:53:12 +01:00
|
|
|
#include "webrtc/api/datachannel.h"
|
|
|
|
|
#include "webrtc/api/dtmfsender.h"
|
|
|
|
|
#include "webrtc/api/mediacontroller.h"
|
|
|
|
|
#include "webrtc/api/mediastreamprovider.h"
|
|
|
|
|
#include "webrtc/api/peerconnectioninterface.h"
|
|
|
|
|
#include "webrtc/api/statstypes.h"
|
2014-08-13 17:26:08 +00:00
|
|
|
#include "webrtc/base/sigslot.h"
|
2015-08-11 10:33:13 +02:00
|
|
|
#include "webrtc/base/sslidentity.h"
|
2014-08-13 17:26:08 +00:00
|
|
|
#include "webrtc/base/thread.h"
|
Move talk/media to webrtc/media
I removed the 'libjingle' target in talk/libjingle.gyp and replaced
all users of it with base/base.gyp:rtc_base. It seems the jsoncpp
and expat dependencies were not used by it's previous references.
The files in talk/media/testdata were uploaded to Google Storage and
added .sha1 files in resources/media instead of simply moving them.
The previously disabled warnings that were inherited from
talk/build/common.gypi are now replaced by target-specific disabling
of only the failing warnings. Additional disabling was needed since the stricter
compilation warnings that applies to code in webrtc/.
License headers will be updated in a follow-up CL in order to not
break Git history.
Other modifications:
* Updated the header guards.
* Sorted the includes using chromium/src/tools/sort-headers.py
except for these files:
talk/app/webrtc/peerconnectionendtoend_unittest.cc
talk/app/webrtc/java/jni/androidmediadecoder_jni.cc
talk/app/webrtc/java/jni/androidmediaencoder_jni.cc
webrtc/media/devices/win32devicemanager.cc.
* Unused GYP reference to libjingle_tests_additional_deps was removed.
* Removed duplicated GYP entries of
webrtc/base/testutils.cc
webrtc/base/testutils.h
The HAVE_WEBRTC_VIDEO and HAVE_WEBRTC_VOICE defines were used by only talk/media,
so they were moved to the media.gyp.
I also checked that none of
EXPAT_RELATIVE_PATH,
FEATURE_ENABLE_VOICEMAIL,
GTEST_RELATIVE_PATH,
JSONCPP_RELATIVE_PATH,
LOGGING=1,
SRTP_RELATIVE_PATH,
FEATURE_ENABLE_SSL,
FEATURE_ENABLE_VOICEMAIL,
FEATURE_ENABLE_PSTN,
HAVE_SCTP,
HAVE_SRTP,
are used by the talk/media code.
For Chromium, the following changes will need to be applied to the roll CL that updates the
DEPS for WebRTC and libjingle: https://codereview.chromium.org/1604303002/
BUG=webrtc:5420
NOPRESUBMIT=True
TBR=tommi@webrtc.org
Review URL: https://codereview.webrtc.org/1587193006
Cr-Commit-Position: refs/heads/master@{#11495}
2016-02-04 23:52:28 -08:00
|
|
|
#include "webrtc/media/base/mediachannel.h"
|
2016-03-14 11:59:18 -07:00
|
|
|
#include "webrtc/p2p/base/candidate.h"
|
2015-12-12 01:37:01 +01:00
|
|
|
#include "webrtc/p2p/base/transportcontroller.h"
|
2016-02-12 06:47:59 +01:00
|
|
|
#include "webrtc/pc/mediasession.h"
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
namespace cricket {
|
2014-03-26 22:44:28 +00:00
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
class ChannelManager;
|
|
|
|
|
class DataChannel;
|
|
|
|
|
class StatsReport;
|
|
|
|
|
class VideoCapturer;
|
|
|
|
|
class VideoChannel;
|
|
|
|
|
class VoiceChannel;
|
2014-03-26 22:44:28 +00:00
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
} // namespace cricket
|
|
|
|
|
|
|
|
|
|
namespace webrtc {
|
2014-05-03 05:39:45 +00:00
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
class IceRestartAnswerLatch;
|
2014-05-03 05:39:45 +00:00
|
|
|
class JsepIceCandidate;
|
2013-07-10 00:45:36 +00:00
|
|
|
class MediaStreamSignaling;
|
2013-08-10 07:18:04 +00:00
|
|
|
class WebRtcSessionDescriptionFactory;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2013-07-26 19:17:59 +00:00
|
|
|
extern const char kBundleWithoutRtcpMux[];
|
2014-01-15 23:15:54 +00:00
|
|
|
extern const char kCreateChannelFailed[];
|
2013-07-10 00:45:36 +00:00
|
|
|
extern const char kInvalidCandidates[];
|
|
|
|
|
extern const char kInvalidSdp[];
|
|
|
|
|
extern const char kMlineMismatch[];
|
2014-01-15 23:15:54 +00:00
|
|
|
extern const char kPushDownTDFailed[];
|
2014-03-04 19:54:57 +00:00
|
|
|
extern const char kSdpWithoutDtlsFingerprint[];
|
|
|
|
|
extern const char kSdpWithoutSdesCrypto[];
|
2013-10-13 17:18:27 +00:00
|
|
|
extern const char kSdpWithoutIceUfragPwd[];
|
2014-01-15 23:15:54 +00:00
|
|
|
extern const char kSdpWithoutSdesAndDtlsDisabled[];
|
2013-07-10 00:45:36 +00:00
|
|
|
extern const char kSessionError[];
|
2014-01-15 23:15:54 +00:00
|
|
|
extern const char kSessionErrorDesc[];
|
2015-03-16 19:34:23 +00:00
|
|
|
extern const char kDtlsSetupFailureRtp[];
|
|
|
|
|
extern const char kDtlsSetupFailureRtcp[];
|
2015-09-23 11:50:27 -07:00
|
|
|
extern const char kEnableBundleFailed[];
|
|
|
|
|
|
2014-08-07 22:46:01 +00:00
|
|
|
// Maximum number of received video streams that will be processed by webrtc
|
|
|
|
|
// even if they are not signalled beforehand.
|
|
|
|
|
extern const int kMaxUnsignalledRecvStreams;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
// ICE state callback interface.
|
|
|
|
|
class IceObserver {
|
|
|
|
|
public:
|
2013-11-20 21:49:41 +00:00
|
|
|
IceObserver() {}
|
2013-07-10 00:45:36 +00:00
|
|
|
// Called any time the IceConnectionState changes
|
2015-07-08 11:08:35 -07:00
|
|
|
// TODO(honghaiz): Change the name to OnIceConnectionStateChange so as to
|
|
|
|
|
// conform to the w3c standard.
|
2013-07-10 00:45:36 +00:00
|
|
|
virtual void OnIceConnectionChange(
|
|
|
|
|
PeerConnectionInterface::IceConnectionState new_state) {}
|
|
|
|
|
// Called any time the IceGatheringState changes
|
|
|
|
|
virtual void OnIceGatheringChange(
|
|
|
|
|
PeerConnectionInterface::IceGatheringState new_state) {}
|
|
|
|
|
// New Ice candidate have been found.
|
|
|
|
|
virtual void OnIceCandidate(const IceCandidateInterface* candidate) = 0;
|
|
|
|
|
|
2016-03-14 11:59:18 -07:00
|
|
|
// Some local ICE candidates have been removed.
|
|
|
|
|
virtual void OnIceCandidatesRemoved(
|
|
|
|
|
const std::vector<cricket::Candidate>& candidates) = 0;
|
|
|
|
|
|
2015-07-08 11:08:35 -07:00
|
|
|
// Called whenever the state changes between receiving and not receiving.
|
|
|
|
|
virtual void OnIceConnectionReceivingChange(bool receiving) {}
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
protected:
|
|
|
|
|
~IceObserver() {}
|
2013-11-20 21:49:41 +00:00
|
|
|
|
|
|
|
|
private:
|
2015-09-16 05:37:44 -07:00
|
|
|
RTC_DISALLOW_COPY_AND_ASSIGN(IceObserver);
|
2013-07-10 00:45:36 +00:00
|
|
|
};
|
|
|
|
|
|
2015-10-14 15:02:44 -07:00
|
|
|
// Statistics for all the transports of the session.
|
|
|
|
|
typedef std::map<std::string, cricket::TransportStats> TransportStatsMap;
|
|
|
|
|
typedef std::map<std::string, std::string> ProxyTransportMap;
|
|
|
|
|
|
|
|
|
|
// TODO(pthatcher): Think of a better name for this. We already have
|
|
|
|
|
// a TransportStats in transport.h. Perhaps TransportsStats?
|
|
|
|
|
struct SessionStats {
|
|
|
|
|
ProxyTransportMap proxy_to_transport;
|
|
|
|
|
TransportStatsMap transport_stats;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// A WebRtcSession manages general session state. This includes negotiation
|
|
|
|
|
// of both the application-level and network-level protocols: the former
|
|
|
|
|
// defines what will be sent and the latter defines how it will be sent. Each
|
|
|
|
|
// network-level protocol is represented by a Transport object. Each Transport
|
|
|
|
|
// participates in the network-level negotiation. The individual streams of
|
|
|
|
|
// packets are represented by TransportChannels. The application-level protocol
|
|
|
|
|
// is represented by SessionDecription objects.
|
|
|
|
|
class WebRtcSession : public AudioProviderInterface,
|
2013-07-10 00:45:36 +00:00
|
|
|
public VideoProviderInterface,
|
2013-10-07 23:32:02 +00:00
|
|
|
public DtmfProviderInterface,
|
2015-10-14 15:02:44 -07:00
|
|
|
public DataChannelProviderInterface,
|
|
|
|
|
public sigslot::has_slots<> {
|
2013-07-10 00:45:36 +00:00
|
|
|
public:
|
2015-10-14 15:02:44 -07:00
|
|
|
enum State {
|
|
|
|
|
STATE_INIT = 0,
|
|
|
|
|
STATE_SENTOFFER, // Sent offer, waiting for answer.
|
|
|
|
|
STATE_RECEIVEDOFFER, // Received an offer. Need to send answer.
|
|
|
|
|
STATE_SENTPRANSWER, // Sent provisional answer. Need to send answer.
|
|
|
|
|
STATE_RECEIVEDPRANSWER, // Received provisional answer, waiting for answer.
|
|
|
|
|
STATE_INPROGRESS, // Offer/answer exchange completed.
|
|
|
|
|
STATE_CLOSED, // Close() was called.
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum Error {
|
|
|
|
|
ERROR_NONE = 0, // no error
|
|
|
|
|
ERROR_CONTENT = 1, // channel errors in SetLocalContent/SetRemoteContent
|
|
|
|
|
ERROR_TRANSPORT = 2, // transport error of some kind
|
|
|
|
|
};
|
|
|
|
|
|
2015-10-15 07:26:07 -07:00
|
|
|
WebRtcSession(webrtc::MediaControllerInterface* media_controller,
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::Thread* signaling_thread,
|
|
|
|
|
rtc::Thread* worker_thread,
|
2015-10-14 11:33:11 -07:00
|
|
|
cricket::PortAllocator* port_allocator);
|
2013-07-10 00:45:36 +00:00
|
|
|
virtual ~WebRtcSession();
|
|
|
|
|
|
2015-10-14 15:02:44 -07:00
|
|
|
// These are const to allow them to be called from const methods.
|
|
|
|
|
rtc::Thread* signaling_thread() const { return signaling_thread_; }
|
|
|
|
|
rtc::Thread* worker_thread() const { return worker_thread_; }
|
|
|
|
|
cricket::PortAllocator* port_allocator() const { return port_allocator_; }
|
|
|
|
|
|
|
|
|
|
// The ID of this session.
|
|
|
|
|
const std::string& id() const { return sid_; }
|
|
|
|
|
|
2015-05-11 12:44:23 +02:00
|
|
|
bool Initialize(
|
|
|
|
|
const PeerConnectionFactoryInterface::Options& options,
|
2015-08-11 10:33:13 +02:00
|
|
|
rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store,
|
2015-05-11 12:44:23 +02:00
|
|
|
const PeerConnectionInterface::RTCConfiguration& rtc_configuration);
|
2013-07-10 00:45:36 +00:00
|
|
|
// Deletes the voice, video and data channel and changes the session state
|
2015-10-14 15:02:44 -07:00
|
|
|
// to STATE_CLOSED.
|
|
|
|
|
void Close();
|
|
|
|
|
|
|
|
|
|
// Returns true if we were the initial offerer.
|
|
|
|
|
bool initial_offerer() const { return initial_offerer_; }
|
|
|
|
|
|
|
|
|
|
// Returns the current state of the session. See the enum above for details.
|
|
|
|
|
// Each time the state changes, we will fire this signal.
|
|
|
|
|
State state() const { return state_; }
|
|
|
|
|
sigslot::signal2<WebRtcSession*, State> SignalState;
|
|
|
|
|
|
|
|
|
|
// Returns the last error in the session. See the enum above for details.
|
|
|
|
|
Error error() const { return error_; }
|
|
|
|
|
const std::string& error_desc() const { return error_desc_; }
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
void RegisterIceObserver(IceObserver* observer) {
|
|
|
|
|
ice_observer_ = observer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual cricket::VoiceChannel* voice_channel() {
|
|
|
|
|
return voice_channel_.get();
|
|
|
|
|
}
|
|
|
|
|
virtual cricket::VideoChannel* video_channel() {
|
|
|
|
|
return video_channel_.get();
|
|
|
|
|
}
|
|
|
|
|
virtual cricket::DataChannel* data_channel() {
|
|
|
|
|
return data_channel_.get();
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-23 17:24:52 -08:00
|
|
|
cricket::BaseChannel* GetChannel(const std::string& content_name);
|
|
|
|
|
|
2014-03-04 19:54:57 +00:00
|
|
|
void SetSdesPolicy(cricket::SecurePolicy secure_policy);
|
|
|
|
|
cricket::SecurePolicy SdesPolicy() const;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2013-08-23 23:21:25 +00:00
|
|
|
// Get current ssl role from transport.
|
2016-01-08 15:35:57 -08:00
|
|
|
bool GetSslRole(const std::string& transport_name, rtc::SSLRole* role);
|
|
|
|
|
|
|
|
|
|
// Get current SSL role for this channel's transport.
|
|
|
|
|
// If |transport| is null, returns false.
|
|
|
|
|
bool GetSslRole(const cricket::BaseChannel* channel, rtc::SSLRole* role);
|
2013-08-23 23:21:25 +00:00
|
|
|
|
2014-08-04 18:34:16 +00:00
|
|
|
void CreateOffer(
|
|
|
|
|
CreateSessionDescriptionObserver* observer,
|
2015-10-14 11:33:11 -07:00
|
|
|
const PeerConnectionInterface::RTCOfferAnswerOptions& options,
|
|
|
|
|
const cricket::MediaSessionOptions& session_options);
|
2013-08-10 07:18:04 +00:00
|
|
|
void CreateAnswer(CreateSessionDescriptionObserver* observer,
|
2015-10-14 11:33:11 -07:00
|
|
|
const cricket::MediaSessionOptions& session_options);
|
2013-07-22 21:07:49 +00:00
|
|
|
// The ownership of |desc| will be transferred after this call.
|
2013-07-10 00:45:36 +00:00
|
|
|
bool SetLocalDescription(SessionDescriptionInterface* desc,
|
|
|
|
|
std::string* err_desc);
|
2013-07-22 21:07:49 +00:00
|
|
|
// The ownership of |desc| will be transferred after this call.
|
2013-07-10 00:45:36 +00:00
|
|
|
bool SetRemoteDescription(SessionDescriptionInterface* desc,
|
|
|
|
|
std::string* err_desc);
|
|
|
|
|
bool ProcessIceMessage(const IceCandidateInterface* ice_candidate);
|
2014-05-03 05:39:45 +00:00
|
|
|
|
2016-03-14 11:59:18 -07:00
|
|
|
bool RemoveRemoteIceCandidates(
|
|
|
|
|
const std::vector<cricket::Candidate>& candidates);
|
|
|
|
|
|
2014-09-09 14:38:10 +00:00
|
|
|
bool SetIceTransports(PeerConnectionInterface::IceTransportsType type);
|
2014-05-03 05:39:45 +00:00
|
|
|
|
2015-09-28 07:57:34 -07:00
|
|
|
cricket::IceConfig ParseIceConfig(
|
|
|
|
|
const PeerConnectionInterface::RTCConfiguration& config) const;
|
|
|
|
|
|
2015-10-14 15:02:44 -07:00
|
|
|
void SetIceConfig(const cricket::IceConfig& ice_config);
|
|
|
|
|
|
|
|
|
|
// Start gathering candidates for any new transports, or transports doing an
|
|
|
|
|
// ICE restart.
|
|
|
|
|
void MaybeStartGathering();
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
const SessionDescriptionInterface* local_description() const {
|
|
|
|
|
return local_desc_.get();
|
|
|
|
|
}
|
|
|
|
|
const SessionDescriptionInterface* remote_description() const {
|
|
|
|
|
return remote_desc_.get();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get the id used as a media stream track's "id" field from ssrc.
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
virtual bool GetLocalTrackIdBySsrc(uint32_t ssrc, std::string* track_id);
|
|
|
|
|
virtual bool GetRemoteTrackIdBySsrc(uint32_t ssrc, std::string* track_id);
|
2014-06-12 14:57:05 +00:00
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
// AudioMediaProviderInterface implementation.
|
2015-10-09 08:55:48 -07:00
|
|
|
void SetAudioPlayout(uint32_t ssrc, bool enable) override;
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
void SetAudioSend(uint32_t ssrc,
|
2015-03-04 12:58:35 +00:00
|
|
|
bool enable,
|
|
|
|
|
const cricket::AudioOptions& options,
|
2016-03-08 12:37:39 -08:00
|
|
|
cricket::AudioSource* source) override;
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
void SetAudioPlayoutVolume(uint32_t ssrc, double volume) override;
|
2016-01-13 12:00:26 -08:00
|
|
|
void SetRawAudioSink(uint32_t ssrc,
|
|
|
|
|
rtc::scoped_ptr<AudioSinkInterface> sink) override;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2016-03-16 19:07:43 -07:00
|
|
|
RtpParameters GetAudioRtpParameters(uint32_t ssrc) const override;
|
|
|
|
|
bool SetAudioRtpParameters(uint32_t ssrc,
|
|
|
|
|
const RtpParameters& parameters) override;
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
// Implements VideoMediaProviderInterface.
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
bool SetCaptureDevice(uint32_t ssrc, cricket::VideoCapturer* camera) override;
|
2016-02-04 01:24:52 -08:00
|
|
|
void SetVideoPlayout(
|
|
|
|
|
uint32_t ssrc,
|
|
|
|
|
bool enable,
|
|
|
|
|
rtc::VideoSinkInterface<cricket::VideoFrame>* sink) override;
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
void SetVideoSend(uint32_t ssrc,
|
2015-03-04 12:58:35 +00:00
|
|
|
bool enable,
|
|
|
|
|
const cricket::VideoOptions* options) override;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2016-03-16 19:07:43 -07:00
|
|
|
RtpParameters GetVideoRtpParameters(uint32_t ssrc) const override;
|
|
|
|
|
bool SetVideoRtpParameters(uint32_t ssrc,
|
|
|
|
|
const RtpParameters& parameters) override;
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
// Implements DtmfProviderInterface.
|
|
|
|
|
virtual bool CanInsertDtmf(const std::string& track_id);
|
|
|
|
|
virtual bool InsertDtmf(const std::string& track_id,
|
|
|
|
|
int code, int duration);
|
|
|
|
|
virtual sigslot::signal0<>* GetOnDestroyedSignal();
|
|
|
|
|
|
2013-10-07 23:32:02 +00:00
|
|
|
// Implements DataChannelProviderInterface.
|
2015-03-04 12:58:35 +00:00
|
|
|
bool SendData(const cricket::SendDataParams& params,
|
2016-03-20 06:15:43 -07:00
|
|
|
const rtc::CopyOnWriteBuffer& payload,
|
2015-03-04 12:58:35 +00:00
|
|
|
cricket::SendDataResult* result) override;
|
|
|
|
|
bool ConnectDataChannel(DataChannel* webrtc_data_channel) override;
|
|
|
|
|
void DisconnectDataChannel(DataChannel* webrtc_data_channel) override;
|
|
|
|
|
void AddSctpDataStream(int sid) override;
|
|
|
|
|
void RemoveSctpDataStream(int sid) override;
|
|
|
|
|
bool ReadyToSendData() const override;
|
2013-10-07 23:32:02 +00:00
|
|
|
|
2015-03-16 19:31:40 +00:00
|
|
|
// Returns stats for all channels of all transports.
|
|
|
|
|
// This avoids exposing the internal structures used to track them.
|
2015-10-14 15:02:44 -07:00
|
|
|
virtual bool GetTransportStats(SessionStats* stats);
|
2015-03-16 19:31:40 +00:00
|
|
|
|
2015-09-23 11:50:27 -07:00
|
|
|
// Get stats for a specific channel
|
2015-10-14 15:02:44 -07:00
|
|
|
bool GetChannelTransportStats(cricket::BaseChannel* ch, SessionStats* stats);
|
2015-09-23 11:50:27 -07:00
|
|
|
|
|
|
|
|
// virtual so it can be mocked in unit tests
|
|
|
|
|
virtual bool GetLocalCertificate(
|
|
|
|
|
const std::string& transport_name,
|
|
|
|
|
rtc::scoped_refptr<rtc::RTCCertificate>* certificate);
|
|
|
|
|
|
|
|
|
|
// Caller owns returned certificate
|
2016-04-06 05:15:06 -07:00
|
|
|
virtual rtc::scoped_ptr<rtc::SSLCertificate> GetRemoteSSLCertificate(
|
|
|
|
|
const std::string& transport_name);
|
2015-09-23 11:50:27 -07:00
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
cricket::DataChannelType data_channel_type() const;
|
|
|
|
|
|
2016-02-23 17:24:52 -08:00
|
|
|
bool IceRestartPending(const std::string& content_name) const;
|
2013-08-10 07:18:04 +00:00
|
|
|
|
2015-08-27 10:12:24 +02:00
|
|
|
// Called when an RTCCertificate is generated or retrieved by
|
2013-08-10 07:18:04 +00:00
|
|
|
// WebRTCSessionDescriptionFactory. Should happen before setLocalDescription.
|
2015-08-27 10:12:24 +02:00
|
|
|
void OnCertificateReady(
|
|
|
|
|
const rtc::scoped_refptr<rtc::RTCCertificate>& certificate);
|
2015-03-16 19:34:23 +00:00
|
|
|
void OnDtlsSetupFailure(cricket::BaseChannel*, bool rtcp);
|
2013-08-10 07:18:04 +00:00
|
|
|
|
|
|
|
|
// For unit test.
|
2015-08-27 10:12:24 +02:00
|
|
|
bool waiting_for_certificate_for_testing() const;
|
2015-09-23 11:50:27 -07:00
|
|
|
const rtc::scoped_refptr<rtc::RTCCertificate>& certificate_for_testing();
|
2013-08-10 07:18:04 +00:00
|
|
|
|
2014-12-04 17:59:29 +00:00
|
|
|
void set_metrics_observer(
|
|
|
|
|
webrtc::MetricsObserverInterface* metrics_observer) {
|
|
|
|
|
metrics_observer_ = metrics_observer;
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-14 11:33:11 -07:00
|
|
|
// Called when voice_channel_, video_channel_ and data_channel_ are created
|
|
|
|
|
// and destroyed. As a result of, for example, setting a new description.
|
|
|
|
|
sigslot::signal0<> SignalVoiceChannelCreated;
|
|
|
|
|
sigslot::signal0<> SignalVoiceChannelDestroyed;
|
|
|
|
|
sigslot::signal0<> SignalVideoChannelCreated;
|
|
|
|
|
sigslot::signal0<> SignalVideoChannelDestroyed;
|
|
|
|
|
sigslot::signal0<> SignalDataChannelCreated;
|
|
|
|
|
sigslot::signal0<> SignalDataChannelDestroyed;
|
2016-01-20 14:30:43 -08:00
|
|
|
// Called when the whole session is destroyed.
|
|
|
|
|
sigslot::signal0<> SignalDestroyed;
|
2015-10-14 11:33:11 -07:00
|
|
|
|
|
|
|
|
// Called when a valid data channel OPEN message is received.
|
|
|
|
|
// std::string represents the data channel label.
|
|
|
|
|
sigslot::signal2<const std::string&, const InternalDataChannelInit&>
|
|
|
|
|
SignalDataChannelOpenMessage;
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
private:
|
|
|
|
|
// Indicates the type of SessionDescription in a call to SetLocalDescription
|
|
|
|
|
// and SetRemoteDescription.
|
|
|
|
|
enum Action {
|
|
|
|
|
kOffer,
|
|
|
|
|
kPrAnswer,
|
|
|
|
|
kAnswer,
|
|
|
|
|
};
|
2013-08-10 07:18:04 +00:00
|
|
|
|
2015-10-14 15:02:44 -07:00
|
|
|
// Log session state.
|
|
|
|
|
void LogState(State old_state, State new_state);
|
|
|
|
|
|
|
|
|
|
// Updates the state, signaling if necessary.
|
|
|
|
|
virtual void SetState(State state);
|
|
|
|
|
|
|
|
|
|
// Updates the error state, signaling if necessary.
|
|
|
|
|
// TODO(ronghuawu): remove the SetError method that doesn't take |error_desc|.
|
|
|
|
|
virtual void SetError(Error error, const std::string& error_desc);
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
bool UpdateSessionState(Action action, cricket::ContentSource source,
|
|
|
|
|
std::string* err_desc);
|
|
|
|
|
static Action GetAction(const std::string& type);
|
2015-03-16 21:15:37 +00:00
|
|
|
// Push the media parts of the local or remote session description
|
|
|
|
|
// down to all of the channels.
|
|
|
|
|
bool PushdownMediaDescription(cricket::ContentAction action,
|
|
|
|
|
cricket::ContentSource source,
|
|
|
|
|
std::string* error_desc);
|
|
|
|
|
|
2015-10-14 15:02:44 -07:00
|
|
|
bool PushdownTransportDescription(cricket::ContentSource source,
|
|
|
|
|
cricket::ContentAction action,
|
|
|
|
|
std::string* error_desc);
|
|
|
|
|
|
|
|
|
|
// Helper methods to push local and remote transport descriptions.
|
|
|
|
|
bool PushdownLocalTransportDescription(
|
|
|
|
|
const cricket::SessionDescription* sdesc,
|
|
|
|
|
cricket::ContentAction action,
|
|
|
|
|
std::string* error_desc);
|
|
|
|
|
bool PushdownRemoteTransportDescription(
|
|
|
|
|
const cricket::SessionDescription* sdesc,
|
|
|
|
|
cricket::ContentAction action,
|
|
|
|
|
std::string* error_desc);
|
|
|
|
|
|
|
|
|
|
// Returns true and the TransportInfo of the given |content_name|
|
|
|
|
|
// from |description|. Returns false if it's not available.
|
|
|
|
|
static bool GetTransportDescription(
|
|
|
|
|
const cricket::SessionDescription* description,
|
|
|
|
|
const std::string& content_name,
|
|
|
|
|
cricket::TransportDescription* info);
|
|
|
|
|
|
2015-09-23 11:50:27 -07:00
|
|
|
// Cause all the BaseChannels in the bundle group to have the same
|
|
|
|
|
// transport channel.
|
|
|
|
|
bool EnableBundle(const cricket::ContentGroup& bundle);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
// Enables media channels to allow sending of media.
|
|
|
|
|
void EnableChannels();
|
|
|
|
|
// Returns the media index for a local ice candidate given the content name.
|
|
|
|
|
// Returns false if the local session description does not have a media
|
|
|
|
|
// content called |content_name|.
|
|
|
|
|
bool GetLocalCandidateMediaIndex(const std::string& content_name,
|
|
|
|
|
int* sdp_mline_index);
|
|
|
|
|
// Uses all remote candidates in |remote_desc| in this session.
|
|
|
|
|
bool UseCandidatesInSessionDescription(
|
|
|
|
|
const SessionDescriptionInterface* remote_desc);
|
|
|
|
|
// Uses |candidate| in this session.
|
|
|
|
|
bool UseCandidate(const IceCandidateInterface* candidate);
|
|
|
|
|
// Deletes the corresponding channel of contents that don't exist in |desc|.
|
|
|
|
|
// |desc| can be null. This means that all channels are deleted.
|
2015-09-23 11:50:27 -07:00
|
|
|
void RemoveUnusedChannels(const cricket::SessionDescription* desc);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
// Allocates media channels based on the |desc|. If |desc| doesn't have
|
|
|
|
|
// the BUNDLE option, this method will disable BUNDLE in PortAllocator.
|
|
|
|
|
// This method will also delete any existing media channels before creating.
|
|
|
|
|
bool CreateChannels(const cricket::SessionDescription* desc);
|
|
|
|
|
|
|
|
|
|
// Helper methods to create media channels.
|
2013-07-26 19:17:59 +00:00
|
|
|
bool CreateVoiceChannel(const cricket::ContentInfo* content);
|
|
|
|
|
bool CreateVideoChannel(const cricket::ContentInfo* content);
|
|
|
|
|
bool CreateDataChannel(const cricket::ContentInfo* content);
|
|
|
|
|
|
2014-01-14 10:00:58 +00:00
|
|
|
// Listens to SCTP CONTROL messages on unused SIDs and process them as OPEN
|
|
|
|
|
// messages.
|
|
|
|
|
void OnDataChannelMessageReceived(cricket::DataChannel* channel,
|
|
|
|
|
const cricket::ReceiveDataParams& params,
|
2016-03-20 06:15:43 -07:00
|
|
|
const rtc::CopyOnWriteBuffer& payload);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2014-01-15 23:15:54 +00:00
|
|
|
std::string BadStateErrMsg(State state);
|
2013-07-10 00:45:36 +00:00
|
|
|
void SetIceConnectionState(PeerConnectionInterface::IceConnectionState state);
|
2015-07-08 11:08:35 -07:00
|
|
|
void SetIceConnectionReceiving(bool receiving);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2013-08-23 23:21:25 +00:00
|
|
|
bool ValidateBundleSettings(const cricket::SessionDescription* desc);
|
2013-07-26 19:17:59 +00:00
|
|
|
bool HasRtcpMuxEnabled(const cricket::ContentInfo* content);
|
2013-08-23 23:21:25 +00:00
|
|
|
// Below methods are helper methods which verifies SDP.
|
|
|
|
|
bool ValidateSessionDescription(const SessionDescriptionInterface* sdesc,
|
|
|
|
|
cricket::ContentSource source,
|
2014-01-15 23:15:54 +00:00
|
|
|
std::string* err_desc);
|
2013-08-23 23:21:25 +00:00
|
|
|
|
|
|
|
|
// Check if a call to SetLocalDescription is acceptable with |action|.
|
|
|
|
|
bool ExpectSetLocalDescription(Action action);
|
|
|
|
|
// Check if a call to SetRemoteDescription is acceptable with |action|.
|
|
|
|
|
bool ExpectSetRemoteDescription(Action action);
|
|
|
|
|
// Verifies a=setup attribute as per RFC 5763.
|
|
|
|
|
bool ValidateDtlsSetupAttribute(const cricket::SessionDescription* desc,
|
|
|
|
|
Action action);
|
2013-07-26 19:17:59 +00:00
|
|
|
|
2014-07-17 17:07:49 +00:00
|
|
|
// Returns true if we are ready to push down the remote candidate.
|
|
|
|
|
// |remote_desc| is the new remote description, or NULL if the current remote
|
|
|
|
|
// description should be used. Output |valid| is true if the candidate media
|
|
|
|
|
// index is valid.
|
|
|
|
|
bool ReadyToUseRemoteCandidate(const IceCandidateInterface* candidate,
|
|
|
|
|
const SessionDescriptionInterface* remote_desc,
|
|
|
|
|
bool* valid);
|
|
|
|
|
|
2015-09-23 11:50:27 -07:00
|
|
|
void OnTransportControllerConnectionState(cricket::IceConnectionState state);
|
|
|
|
|
void OnTransportControllerReceiving(bool receiving);
|
|
|
|
|
void OnTransportControllerGatheringState(cricket::IceGatheringState state);
|
|
|
|
|
void OnTransportControllerCandidatesGathered(
|
|
|
|
|
const std::string& transport_name,
|
2016-03-14 11:59:18 -07:00
|
|
|
const std::vector<cricket::Candidate>& candidates);
|
|
|
|
|
void OnTransportControllerCandidatesRemoved(
|
|
|
|
|
const std::vector<cricket::Candidate>& candidates);
|
2015-09-23 11:50:27 -07:00
|
|
|
|
2014-01-15 23:15:54 +00:00
|
|
|
std::string GetSessionErrorMsg();
|
|
|
|
|
|
2015-09-23 11:50:27 -07:00
|
|
|
// Invoked when TransportController connection completion is signaled.
|
|
|
|
|
// Reports stats for all transports in use.
|
|
|
|
|
void ReportTransportStats();
|
|
|
|
|
|
|
|
|
|
// Gather the usage of IPv4/IPv6 as best connection.
|
2015-07-03 01:36:14 -07:00
|
|
|
void ReportBestConnectionState(const cricket::TransportStats& stats);
|
|
|
|
|
|
|
|
|
|
void ReportNegotiatedCiphers(const cricket::TransportStats& stats);
|
2014-12-04 17:59:29 +00:00
|
|
|
|
2015-10-15 07:26:07 -07:00
|
|
|
void OnSentPacket_w(cricket::TransportChannel* channel,
|
|
|
|
|
const rtc::SentPacket& sent_packet);
|
|
|
|
|
|
2015-10-14 15:02:44 -07:00
|
|
|
rtc::Thread* const signaling_thread_;
|
|
|
|
|
rtc::Thread* const worker_thread_;
|
|
|
|
|
cricket::PortAllocator* const port_allocator_;
|
|
|
|
|
|
|
|
|
|
State state_ = STATE_INIT;
|
|
|
|
|
Error error_ = ERROR_NONE;
|
|
|
|
|
std::string error_desc_;
|
|
|
|
|
|
|
|
|
|
const std::string sid_;
|
|
|
|
|
bool initial_offerer_ = false;
|
|
|
|
|
|
|
|
|
|
rtc::scoped_ptr<cricket::TransportController> transport_controller_;
|
2015-10-15 07:26:07 -07:00
|
|
|
MediaControllerInterface* media_controller_;
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::scoped_ptr<cricket::VoiceChannel> voice_channel_;
|
|
|
|
|
rtc::scoped_ptr<cricket::VideoChannel> video_channel_;
|
|
|
|
|
rtc::scoped_ptr<cricket::DataChannel> data_channel_;
|
2013-07-10 00:45:36 +00:00
|
|
|
cricket::ChannelManager* channel_manager_;
|
|
|
|
|
IceObserver* ice_observer_;
|
|
|
|
|
PeerConnectionInterface::IceConnectionState ice_connection_state_;
|
2015-07-08 11:08:35 -07:00
|
|
|
bool ice_connection_receiving_;
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::scoped_ptr<SessionDescriptionInterface> local_desc_;
|
|
|
|
|
rtc::scoped_ptr<SessionDescriptionInterface> remote_desc_;
|
2013-07-10 00:45:36 +00:00
|
|
|
// If the remote peer is using a older version of implementation.
|
|
|
|
|
bool older_version_remote_peer_;
|
2013-09-27 23:04:10 +00:00
|
|
|
bool dtls_enabled_;
|
2013-07-10 00:45:36 +00:00
|
|
|
// Specifies which kind of data channel is allowed. This is controlled
|
|
|
|
|
// by the chrome command-line flag and constraints:
|
|
|
|
|
// 1. If chrome command-line switch 'enable-sctp-data-channels' is enabled,
|
|
|
|
|
// constraint kEnableDtlsSrtp is true, and constaint kEnableRtpDataChannels is
|
|
|
|
|
// not set or false, SCTP is allowed (DCT_SCTP);
|
|
|
|
|
// 2. If constraint kEnableRtpDataChannels is true, RTP is allowed (DCT_RTP);
|
|
|
|
|
// 3. If both 1&2 are false, data channel is not allowed (DCT_NONE).
|
|
|
|
|
cricket::DataChannelType data_channel_type_;
|
2016-02-23 17:24:52 -08:00
|
|
|
// List of content names for which the remote side triggered an ICE restart.
|
|
|
|
|
std::set<std::string> pending_ice_restarts_;
|
2013-08-10 07:18:04 +00:00
|
|
|
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::scoped_ptr<WebRtcSessionDescriptionFactory>
|
2013-08-10 07:18:04 +00:00
|
|
|
webrtc_session_desc_factory_;
|
|
|
|
|
|
2014-03-25 17:09:47 +00:00
|
|
|
// Member variables for caching global options.
|
|
|
|
|
cricket::AudioOptions audio_options_;
|
|
|
|
|
cricket::VideoOptions video_options_;
|
2014-12-04 17:59:29 +00:00
|
|
|
MetricsObserverInterface* metrics_observer_;
|
2014-03-25 17:09:47 +00:00
|
|
|
|
2015-02-04 22:03:09 +00:00
|
|
|
// Declares the bundle policy for the WebRTCSession.
|
|
|
|
|
PeerConnectionInterface::BundlePolicy bundle_policy_;
|
|
|
|
|
|
2015-05-21 07:48:41 -07:00
|
|
|
// Declares the RTCP mux policy for the WebRTCSession.
|
|
|
|
|
PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy_;
|
|
|
|
|
|
2015-09-16 05:37:44 -07:00
|
|
|
RTC_DISALLOW_COPY_AND_ASSIGN(WebRtcSession);
|
2013-11-20 21:49:41 +00:00
|
|
|
};
|
2013-07-10 00:45:36 +00:00
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2016-02-10 10:53:12 +01:00
|
|
|
#endif // WEBRTC_API_WEBRTCSESSION_H_
|