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 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 typedef std::map<std::string, cricket::TransportStats> TransportStatsMap; | 108 typedef std::map<std::string, cricket::TransportStats> TransportStatsMap; |
109 typedef std::map<std::string, std::string> ProxyTransportMap; | 109 typedef std::map<std::string, std::string> ProxyTransportMap; |
110 | 110 |
111 // TODO(pthatcher): Think of a better name for this. We already have | 111 // TODO(pthatcher): Think of a better name for this. We already have |
112 // a TransportStats in transport.h. Perhaps TransportsStats? | 112 // a TransportStats in transport.h. Perhaps TransportsStats? |
113 struct SessionStats { | 113 struct SessionStats { |
114 ProxyTransportMap proxy_to_transport; | 114 ProxyTransportMap proxy_to_transport; |
115 TransportStatsMap transport_stats; | 115 TransportStatsMap transport_stats; |
116 }; | 116 }; |
117 | 117 |
| 118 struct ChannelNamePair { |
| 119 ChannelNamePair( |
| 120 const std::string& content_name, const std::string& transport_name) |
| 121 : content_name(content_name), transport_name(transport_name) {} |
| 122 std::string content_name; |
| 123 std::string transport_name; |
| 124 }; |
| 125 |
| 126 struct ChannelNamePairs { |
| 127 rtc::Optional<ChannelNamePair> voice; |
| 128 rtc::Optional<ChannelNamePair> video; |
| 129 rtc::Optional<ChannelNamePair> data; |
| 130 }; |
| 131 |
118 // A WebRtcSession manages general session state. This includes negotiation | 132 // A WebRtcSession manages general session state. This includes negotiation |
119 // of both the application-level and network-level protocols: the former | 133 // of both the application-level and network-level protocols: the former |
120 // defines what will be sent and the latter defines how it will be sent. Each | 134 // defines what will be sent and the latter defines how it will be sent. Each |
121 // network-level protocol is represented by a Transport object. Each Transport | 135 // network-level protocol is represented by a Transport object. Each Transport |
122 // participates in the network-level negotiation. The individual streams of | 136 // participates in the network-level negotiation. The individual streams of |
123 // packets are represented by TransportChannels. The application-level protocol | 137 // packets are represented by TransportChannels. The application-level protocol |
124 // is represented by SessionDecription objects. | 138 // is represented by SessionDecription objects. |
125 class WebRtcSession : | 139 class WebRtcSession : |
126 | 140 |
127 public DtmfProviderInterface, | 141 public DtmfProviderInterface, |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 | 201 |
188 virtual cricket::VoiceChannel* voice_channel() { | 202 virtual cricket::VoiceChannel* voice_channel() { |
189 return voice_channel_.get(); | 203 return voice_channel_.get(); |
190 } | 204 } |
191 virtual cricket::VideoChannel* video_channel() { | 205 virtual cricket::VideoChannel* video_channel() { |
192 return video_channel_.get(); | 206 return video_channel_.get(); |
193 } | 207 } |
194 virtual cricket::DataChannel* data_channel() { | 208 virtual cricket::DataChannel* data_channel() { |
195 return data_channel_.get(); | 209 return data_channel_.get(); |
196 } | 210 } |
| 211 std::unique_ptr<ChannelNamePairs> GetChannelNamePairs(); |
197 | 212 |
198 cricket::BaseChannel* GetChannel(const std::string& content_name); | 213 cricket::BaseChannel* GetChannel(const std::string& content_name); |
199 | 214 |
200 void SetSdesPolicy(cricket::SecurePolicy secure_policy); | 215 void SetSdesPolicy(cricket::SecurePolicy secure_policy); |
201 cricket::SecurePolicy SdesPolicy() const; | 216 cricket::SecurePolicy SdesPolicy() const; |
202 | 217 |
203 // Get current ssl role from transport. | 218 // Get current ssl role from transport. |
204 bool GetSslRole(const std::string& transport_name, rtc::SSLRole* role); | 219 bool GetSslRole(const std::string& transport_name, rtc::SSLRole* role); |
205 | 220 |
206 // Get current SSL role for this channel's transport. | 221 // Get current SSL role for this channel's transport. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 const rtc::CopyOnWriteBuffer& payload, | 270 const rtc::CopyOnWriteBuffer& payload, |
256 cricket::SendDataResult* result) override; | 271 cricket::SendDataResult* result) override; |
257 bool ConnectDataChannel(DataChannel* webrtc_data_channel) override; | 272 bool ConnectDataChannel(DataChannel* webrtc_data_channel) override; |
258 void DisconnectDataChannel(DataChannel* webrtc_data_channel) override; | 273 void DisconnectDataChannel(DataChannel* webrtc_data_channel) override; |
259 void AddSctpDataStream(int sid) override; | 274 void AddSctpDataStream(int sid) override; |
260 void RemoveSctpDataStream(int sid) override; | 275 void RemoveSctpDataStream(int sid) override; |
261 bool ReadyToSendData() const override; | 276 bool ReadyToSendData() const override; |
262 | 277 |
263 // Returns stats for all channels of all transports. | 278 // Returns stats for all channels of all transports. |
264 // This avoids exposing the internal structures used to track them. | 279 // This avoids exposing the internal structures used to track them. |
265 virtual bool GetTransportStats(SessionStats* stats); | 280 // The parameterless version creates |ChannelNamePairs| from |voice_channel|, |
266 | 281 // |video_channel| and |voice_channel| if available - this requires it to be |
267 // Get stats for a specific channel | 282 // called on the signaling thread - and invokes the other |GetSessionStats|. |
268 bool GetChannelTransportStats(cricket::BaseChannel* ch, SessionStats* stats); | 283 // The other |GetSessionStats| can be invoked on any thread; if not invoked on |
| 284 // the network thread a thread hop will happen. |
| 285 std::unique_ptr<SessionStats> GetSessionStats(); |
| 286 virtual std::unique_ptr<SessionStats> GetSessionStats( |
| 287 const ChannelNamePairs& channel_name_pairs); |
269 | 288 |
270 // virtual so it can be mocked in unit tests | 289 // virtual so it can be mocked in unit tests |
271 virtual bool GetLocalCertificate( | 290 virtual bool GetLocalCertificate( |
272 const std::string& transport_name, | 291 const std::string& transport_name, |
273 rtc::scoped_refptr<rtc::RTCCertificate>* certificate); | 292 rtc::scoped_refptr<rtc::RTCCertificate>* certificate); |
274 | 293 |
275 // Caller owns returned certificate | 294 // Caller owns returned certificate |
276 virtual std::unique_ptr<rtc::SSLCertificate> GetRemoteSSLCertificate( | 295 virtual std::unique_ptr<rtc::SSLCertificate> GetRemoteSSLCertificate( |
277 const std::string& transport_name); | 296 const std::string& transport_name); |
278 | 297 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 bool CreateChannels(const cricket::SessionDescription* desc); | 428 bool CreateChannels(const cricket::SessionDescription* desc); |
410 | 429 |
411 // Helper methods to create media channels. | 430 // Helper methods to create media channels. |
412 bool CreateVoiceChannel(const cricket::ContentInfo* content, | 431 bool CreateVoiceChannel(const cricket::ContentInfo* content, |
413 const std::string* bundle_transport); | 432 const std::string* bundle_transport); |
414 bool CreateVideoChannel(const cricket::ContentInfo* content, | 433 bool CreateVideoChannel(const cricket::ContentInfo* content, |
415 const std::string* bundle_transport); | 434 const std::string* bundle_transport); |
416 bool CreateDataChannel(const cricket::ContentInfo* content, | 435 bool CreateDataChannel(const cricket::ContentInfo* content, |
417 const std::string* bundle_transport); | 436 const std::string* bundle_transport); |
418 | 437 |
| 438 std::unique_ptr<SessionStats> GetSessionStats_n( |
| 439 const ChannelNamePairs& channel_name_pairs); |
| 440 |
419 // Listens to SCTP CONTROL messages on unused SIDs and process them as OPEN | 441 // Listens to SCTP CONTROL messages on unused SIDs and process them as OPEN |
420 // messages. | 442 // messages. |
421 void OnDataChannelMessageReceived(cricket::DataChannel* channel, | 443 void OnDataChannelMessageReceived(cricket::DataChannel* channel, |
422 const cricket::ReceiveDataParams& params, | 444 const cricket::ReceiveDataParams& params, |
423 const rtc::CopyOnWriteBuffer& payload); | 445 const rtc::CopyOnWriteBuffer& payload); |
424 | 446 |
425 std::string BadStateErrMsg(State state); | 447 std::string BadStateErrMsg(State state); |
426 void SetIceConnectionState(PeerConnectionInterface::IceConnectionState state); | 448 void SetIceConnectionState(PeerConnectionInterface::IceConnectionState state); |
427 void SetIceConnectionReceiving(bool receiving); | 449 void SetIceConnectionReceiving(bool receiving); |
428 | 450 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 rtc::Thread* const worker_thread_; | 501 rtc::Thread* const worker_thread_; |
480 rtc::Thread* const signaling_thread_; | 502 rtc::Thread* const signaling_thread_; |
481 | 503 |
482 State state_ = STATE_INIT; | 504 State state_ = STATE_INIT; |
483 Error error_ = ERROR_NONE; | 505 Error error_ = ERROR_NONE; |
484 std::string error_desc_; | 506 std::string error_desc_; |
485 | 507 |
486 const std::string sid_; | 508 const std::string sid_; |
487 bool initial_offerer_ = false; | 509 bool initial_offerer_ = false; |
488 | 510 |
489 std::unique_ptr<cricket::TransportController> transport_controller_; | 511 const std::unique_ptr<cricket::TransportController> transport_controller_; |
490 MediaControllerInterface* media_controller_; | 512 MediaControllerInterface* media_controller_; |
491 std::unique_ptr<cricket::VoiceChannel> voice_channel_; | 513 std::unique_ptr<cricket::VoiceChannel> voice_channel_; |
492 std::unique_ptr<cricket::VideoChannel> video_channel_; | 514 std::unique_ptr<cricket::VideoChannel> video_channel_; |
493 std::unique_ptr<cricket::DataChannel> data_channel_; | 515 std::unique_ptr<cricket::DataChannel> data_channel_; |
494 cricket::ChannelManager* channel_manager_; | 516 cricket::ChannelManager* channel_manager_; |
495 IceObserver* ice_observer_; | 517 IceObserver* ice_observer_; |
496 PeerConnectionInterface::IceConnectionState ice_connection_state_; | 518 PeerConnectionInterface::IceConnectionState ice_connection_state_; |
497 bool ice_connection_receiving_; | 519 bool ice_connection_receiving_; |
498 std::unique_ptr<SessionDescriptionInterface> local_desc_; | 520 std::unique_ptr<SessionDescriptionInterface> local_desc_; |
499 std::unique_ptr<SessionDescriptionInterface> remote_desc_; | 521 std::unique_ptr<SessionDescriptionInterface> remote_desc_; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 | 553 |
532 #ifdef HAVE_QUIC | 554 #ifdef HAVE_QUIC |
533 std::unique_ptr<QuicDataTransport> quic_data_transport_; | 555 std::unique_ptr<QuicDataTransport> quic_data_transport_; |
534 #endif // HAVE_QUIC | 556 #endif // HAVE_QUIC |
535 | 557 |
536 RTC_DISALLOW_COPY_AND_ASSIGN(WebRtcSession); | 558 RTC_DISALLOW_COPY_AND_ASSIGN(WebRtcSession); |
537 }; | 559 }; |
538 } // namespace webrtc | 560 } // namespace webrtc |
539 | 561 |
540 #endif // WEBRTC_API_WEBRTCSESSION_H_ | 562 #endif // WEBRTC_API_WEBRTCSESSION_H_ |
OLD | NEW |