OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_API_WEBRTCSESSION_H_ | 11 #ifndef WEBRTC_API_WEBRTCSESSION_H_ |
12 #define WEBRTC_API_WEBRTCSESSION_H_ | 12 #define WEBRTC_API_WEBRTCSESSION_H_ |
13 | 13 |
14 #include <memory> | 14 #include <memory> |
15 #include <set> | 15 #include <set> |
16 #include <string> | 16 #include <string> |
17 #include <vector> | 17 #include <vector> |
18 | 18 |
19 #include "webrtc/api/datachannel.h" | 19 #include "webrtc/api/datachannel.h" |
20 #include "webrtc/api/dtmfsender.h" | 20 #include "webrtc/api/dtmfsender.h" |
21 #include "webrtc/api/mediacontroller.h" | 21 #include "webrtc/api/mediacontroller.h" |
| 22 #include "webrtc/api/mediastreamprovider.h" |
22 #include "webrtc/api/peerconnectioninterface.h" | 23 #include "webrtc/api/peerconnectioninterface.h" |
23 #include "webrtc/api/statstypes.h" | 24 #include "webrtc/api/statstypes.h" |
24 #include "webrtc/base/constructormagic.h" | 25 #include "webrtc/base/constructormagic.h" |
25 #include "webrtc/base/sigslot.h" | 26 #include "webrtc/base/sigslot.h" |
26 #include "webrtc/base/sslidentity.h" | 27 #include "webrtc/base/sslidentity.h" |
27 #include "webrtc/base/thread.h" | 28 #include "webrtc/base/thread.h" |
28 #include "webrtc/media/base/mediachannel.h" | 29 #include "webrtc/media/base/mediachannel.h" |
29 #include "webrtc/p2p/base/candidate.h" | 30 #include "webrtc/p2p/base/candidate.h" |
30 #include "webrtc/p2p/base/transportcontroller.h" | 31 #include "webrtc/p2p/base/transportcontroller.h" |
31 #include "webrtc/pc/mediasession.h" | 32 #include "webrtc/pc/mediasession.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 TransportStatsMap transport_stats; | 108 TransportStatsMap transport_stats; |
108 }; | 109 }; |
109 | 110 |
110 // A WebRtcSession manages general session state. This includes negotiation | 111 // A WebRtcSession manages general session state. This includes negotiation |
111 // of both the application-level and network-level protocols: the former | 112 // of both the application-level and network-level protocols: the former |
112 // defines what will be sent and the latter defines how it will be sent. Each | 113 // defines what will be sent and the latter defines how it will be sent. Each |
113 // network-level protocol is represented by a Transport object. Each Transport | 114 // network-level protocol is represented by a Transport object. Each Transport |
114 // participates in the network-level negotiation. The individual streams of | 115 // participates in the network-level negotiation. The individual streams of |
115 // packets are represented by TransportChannels. The application-level protocol | 116 // packets are represented by TransportChannels. The application-level protocol |
116 // is represented by SessionDecription objects. | 117 // is represented by SessionDecription objects. |
117 class WebRtcSession : | 118 class WebRtcSession : public AudioProviderInterface, |
118 | 119 public VideoProviderInterface, |
119 public DtmfProviderInterface, | 120 public DtmfProviderInterface, |
120 public DataChannelProviderInterface, | 121 public DataChannelProviderInterface, |
121 public sigslot::has_slots<> { | 122 public sigslot::has_slots<> { |
122 public: | 123 public: |
123 enum State { | 124 enum State { |
124 STATE_INIT = 0, | 125 STATE_INIT = 0, |
125 STATE_SENTOFFER, // Sent offer, waiting for answer. | 126 STATE_SENTOFFER, // Sent offer, waiting for answer. |
126 STATE_RECEIVEDOFFER, // Received an offer. Need to send answer. | 127 STATE_RECEIVEDOFFER, // Received an offer. Need to send answer. |
127 STATE_SENTPRANSWER, // Sent provisional answer. Need to send answer. | 128 STATE_SENTPRANSWER, // Sent provisional answer. Need to send answer. |
128 STATE_RECEIVEDPRANSWER, // Received provisional answer, waiting for answer. | 129 STATE_RECEIVEDPRANSWER, // Received provisional answer, waiting for answer. |
129 STATE_INPROGRESS, // Offer/answer exchange completed. | 130 STATE_INPROGRESS, // Offer/answer exchange completed. |
130 STATE_CLOSED, // Close() was called. | 131 STATE_CLOSED, // Close() was called. |
131 }; | 132 }; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 return local_desc_.get(); | 227 return local_desc_.get(); |
227 } | 228 } |
228 const SessionDescriptionInterface* remote_description() const { | 229 const SessionDescriptionInterface* remote_description() const { |
229 return remote_desc_.get(); | 230 return remote_desc_.get(); |
230 } | 231 } |
231 | 232 |
232 // Get the id used as a media stream track's "id" field from ssrc. | 233 // Get the id used as a media stream track's "id" field from ssrc. |
233 virtual bool GetLocalTrackIdBySsrc(uint32_t ssrc, std::string* track_id); | 234 virtual bool GetLocalTrackIdBySsrc(uint32_t ssrc, std::string* track_id); |
234 virtual bool GetRemoteTrackIdBySsrc(uint32_t ssrc, std::string* track_id); | 235 virtual bool GetRemoteTrackIdBySsrc(uint32_t ssrc, std::string* track_id); |
235 | 236 |
| 237 // AudioMediaProviderInterface implementation. |
| 238 void SetAudioPlayout(uint32_t ssrc, bool enable) override; |
| 239 void SetAudioSend(uint32_t ssrc, |
| 240 bool enable, |
| 241 const cricket::AudioOptions& options, |
| 242 cricket::AudioSource* source) override; |
| 243 void SetAudioPlayoutVolume(uint32_t ssrc, double volume) override; |
| 244 void SetRawAudioSink(uint32_t ssrc, |
| 245 std::unique_ptr<AudioSinkInterface> sink) override; |
| 246 |
| 247 RtpParameters GetAudioRtpSendParameters(uint32_t ssrc) const override; |
| 248 bool SetAudioRtpSendParameters(uint32_t ssrc, |
| 249 const RtpParameters& parameters) override; |
| 250 RtpParameters GetAudioRtpReceiveParameters(uint32_t ssrc) const override; |
| 251 bool SetAudioRtpReceiveParameters(uint32_t ssrc, |
| 252 const RtpParameters& parameters) override; |
| 253 |
| 254 // Implements VideoMediaProviderInterface. |
| 255 void SetVideoPlayout( |
| 256 uint32_t ssrc, |
| 257 bool enable, |
| 258 rtc::VideoSinkInterface<cricket::VideoFrame>* sink) override; |
| 259 void SetVideoSend( |
| 260 uint32_t ssrc, |
| 261 bool enable, |
| 262 const cricket::VideoOptions* options, |
| 263 rtc::VideoSourceInterface<cricket::VideoFrame>* source) override; |
| 264 |
| 265 RtpParameters GetVideoRtpSendParameters(uint32_t ssrc) const override; |
| 266 bool SetVideoRtpSendParameters(uint32_t ssrc, |
| 267 const RtpParameters& parameters) override; |
| 268 RtpParameters GetVideoRtpReceiveParameters(uint32_t ssrc) const override; |
| 269 bool SetVideoRtpReceiveParameters(uint32_t ssrc, |
| 270 const RtpParameters& parameters) override; |
| 271 |
236 // Implements DtmfProviderInterface. | 272 // Implements DtmfProviderInterface. |
237 bool CanInsertDtmf(const std::string& track_id) override; | 273 bool CanInsertDtmf(const std::string& track_id) override; |
238 bool InsertDtmf(const std::string& track_id, | 274 bool InsertDtmf(const std::string& track_id, |
239 int code, int duration) override; | 275 int code, int duration) override; |
240 sigslot::signal0<>* GetOnDestroyedSignal() override; | 276 sigslot::signal0<>* GetOnDestroyedSignal() override; |
241 | 277 |
242 // Implements DataChannelProviderInterface. | 278 // Implements DataChannelProviderInterface. |
243 bool SendData(const cricket::SendDataParams& params, | 279 bool SendData(const cricket::SendDataParams& params, |
244 const rtc::CopyOnWriteBuffer& payload, | 280 const rtc::CopyOnWriteBuffer& payload, |
245 cricket::SendDataResult* result) override; | 281 cricket::SendDataResult* result) override; |
(...skipping 21 matching lines...) Expand all Loading... |
267 | 303 |
268 cricket::DataChannelType data_channel_type() const; | 304 cricket::DataChannelType data_channel_type() const; |
269 | 305 |
270 bool IceRestartPending(const std::string& content_name) const; | 306 bool IceRestartPending(const std::string& content_name) const; |
271 | 307 |
272 // Called when an RTCCertificate is generated or retrieved by | 308 // Called when an RTCCertificate is generated or retrieved by |
273 // WebRTCSessionDescriptionFactory. Should happen before setLocalDescription. | 309 // WebRTCSessionDescriptionFactory. Should happen before setLocalDescription. |
274 void OnCertificateReady( | 310 void OnCertificateReady( |
275 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate); | 311 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate); |
276 void OnDtlsSetupFailure(cricket::BaseChannel*, bool rtcp); | 312 void OnDtlsSetupFailure(cricket::BaseChannel*, bool rtcp); |
| 313 // Called when the channel received the first packet. |
| 314 void OnChannelFirstPacketReceived(cricket::BaseChannel*); |
277 | 315 |
278 // For unit test. | 316 // For unit test. |
279 bool waiting_for_certificate_for_testing() const; | 317 bool waiting_for_certificate_for_testing() const; |
280 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate_for_testing(); | 318 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate_for_testing(); |
281 | 319 |
282 void set_metrics_observer( | 320 void set_metrics_observer( |
283 webrtc::MetricsObserverInterface* metrics_observer) { | 321 webrtc::MetricsObserverInterface* metrics_observer) { |
284 metrics_observer_ = metrics_observer; | 322 metrics_observer_ = metrics_observer; |
285 } | 323 } |
286 | 324 |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy_; | 530 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy_; |
493 | 531 |
494 bool received_first_video_packet_ = false; | 532 bool received_first_video_packet_ = false; |
495 bool received_first_audio_packet_ = false; | 533 bool received_first_audio_packet_ = false; |
496 | 534 |
497 RTC_DISALLOW_COPY_AND_ASSIGN(WebRtcSession); | 535 RTC_DISALLOW_COPY_AND_ASSIGN(WebRtcSession); |
498 }; | 536 }; |
499 } // namespace webrtc | 537 } // namespace webrtc |
500 | 538 |
501 #endif // WEBRTC_API_WEBRTCSESSION_H_ | 539 #endif // WEBRTC_API_WEBRTCSESSION_H_ |
OLD | NEW |