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 cricket::SecurePolicy SdesPolicy() const; | 215 cricket::SecurePolicy SdesPolicy() const; |
201 | 216 |
202 // Get current ssl role from transport. | 217 // Get current ssl role from transport. |
203 bool GetSslRole(const std::string& transport_name, rtc::SSLRole* role); | 218 bool GetSslRole(const std::string& transport_name, rtc::SSLRole* role); |
204 | 219 |
205 // Get current SSL role for this channel's transport. | 220 // Get current SSL role for this channel's transport. |
206 // If |transport| is null, returns false. | 221 // If |transport| is null, returns false. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 const rtc::CopyOnWriteBuffer& payload, | 269 const rtc::CopyOnWriteBuffer& payload, |
255 cricket::SendDataResult* result) override; | 270 cricket::SendDataResult* result) override; |
256 bool ConnectDataChannel(DataChannel* webrtc_data_channel) override; | 271 bool ConnectDataChannel(DataChannel* webrtc_data_channel) override; |
257 void DisconnectDataChannel(DataChannel* webrtc_data_channel) override; | 272 void DisconnectDataChannel(DataChannel* webrtc_data_channel) override; |
258 void AddSctpDataStream(int sid) override; | 273 void AddSctpDataStream(int sid) override; |
259 void RemoveSctpDataStream(int sid) override; | 274 void RemoveSctpDataStream(int sid) override; |
260 bool ReadyToSendData() const override; | 275 bool ReadyToSendData() const override; |
261 | 276 |
262 // Returns stats for all channels of all transports. | 277 // Returns stats for all channels of all transports. |
263 // This avoids exposing the internal structures used to track them. | 278 // This avoids exposing the internal structures used to track them. |
264 virtual bool GetTransportStats(SessionStats* stats); | 279 // The parameterless version creates |ChannelNamePairs| from |voice_channel|, |
265 | 280 // |video_channel| and |voice_channel| if available - this requires it to be |
266 // Get stats for a specific channel | 281 // called on the signaling thread - and invokes the other |GetStats|. The |
267 bool GetChannelTransportStats(cricket::BaseChannel* ch, SessionStats* stats); | 282 // other |GetStats| can be invoked on any thread; if not invoked on the |
| 283 // network thread a thread hop will happen. |
| 284 std::unique_ptr<SessionStats> GetStats_s(); |
| 285 virtual std::unique_ptr<SessionStats> GetStats( |
| 286 const ChannelNamePairs& channel_name_pairs); |
268 | 287 |
269 // virtual so it can be mocked in unit tests | 288 // virtual so it can be mocked in unit tests |
270 virtual bool GetLocalCertificate( | 289 virtual bool GetLocalCertificate( |
271 const std::string& transport_name, | 290 const std::string& transport_name, |
272 rtc::scoped_refptr<rtc::RTCCertificate>* certificate); | 291 rtc::scoped_refptr<rtc::RTCCertificate>* certificate); |
273 | 292 |
274 // Caller owns returned certificate | 293 // Caller owns returned certificate |
275 virtual std::unique_ptr<rtc::SSLCertificate> GetRemoteSSLCertificate( | 294 virtual std::unique_ptr<rtc::SSLCertificate> GetRemoteSSLCertificate( |
276 const std::string& transport_name); | 295 const std::string& transport_name); |
277 | 296 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 bool CreateChannels(const cricket::SessionDescription* desc); | 427 bool CreateChannels(const cricket::SessionDescription* desc); |
409 | 428 |
410 // Helper methods to create media channels. | 429 // Helper methods to create media channels. |
411 bool CreateVoiceChannel(const cricket::ContentInfo* content, | 430 bool CreateVoiceChannel(const cricket::ContentInfo* content, |
412 const std::string* bundle_transport); | 431 const std::string* bundle_transport); |
413 bool CreateVideoChannel(const cricket::ContentInfo* content, | 432 bool CreateVideoChannel(const cricket::ContentInfo* content, |
414 const std::string* bundle_transport); | 433 const std::string* bundle_transport); |
415 bool CreateDataChannel(const cricket::ContentInfo* content, | 434 bool CreateDataChannel(const cricket::ContentInfo* content, |
416 const std::string* bundle_transport); | 435 const std::string* bundle_transport); |
417 | 436 |
| 437 std::unique_ptr<SessionStats> GetStats_n( |
| 438 const ChannelNamePairs& channel_name_pairs); |
| 439 |
418 // Listens to SCTP CONTROL messages on unused SIDs and process them as OPEN | 440 // Listens to SCTP CONTROL messages on unused SIDs and process them as OPEN |
419 // messages. | 441 // messages. |
420 void OnDataChannelMessageReceived(cricket::DataChannel* channel, | 442 void OnDataChannelMessageReceived(cricket::DataChannel* channel, |
421 const cricket::ReceiveDataParams& params, | 443 const cricket::ReceiveDataParams& params, |
422 const rtc::CopyOnWriteBuffer& payload); | 444 const rtc::CopyOnWriteBuffer& payload); |
423 | 445 |
424 std::string BadStateErrMsg(State state); | 446 std::string BadStateErrMsg(State state); |
425 void SetIceConnectionState(PeerConnectionInterface::IceConnectionState state); | 447 void SetIceConnectionState(PeerConnectionInterface::IceConnectionState state); |
426 void SetIceConnectionReceiving(bool receiving); | 448 void SetIceConnectionReceiving(bool receiving); |
427 | 449 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 rtc::Thread* const worker_thread_; | 504 rtc::Thread* const worker_thread_; |
483 rtc::Thread* const signaling_thread_; | 505 rtc::Thread* const signaling_thread_; |
484 | 506 |
485 State state_ = STATE_INIT; | 507 State state_ = STATE_INIT; |
486 Error error_ = ERROR_NONE; | 508 Error error_ = ERROR_NONE; |
487 std::string error_desc_; | 509 std::string error_desc_; |
488 | 510 |
489 const std::string sid_; | 511 const std::string sid_; |
490 bool initial_offerer_ = false; | 512 bool initial_offerer_ = false; |
491 | 513 |
492 std::unique_ptr<cricket::TransportController> transport_controller_; | 514 const std::unique_ptr<cricket::TransportController> transport_controller_; |
493 MediaControllerInterface* media_controller_; | 515 MediaControllerInterface* media_controller_; |
494 std::unique_ptr<cricket::VoiceChannel> voice_channel_; | 516 std::unique_ptr<cricket::VoiceChannel> voice_channel_; |
495 std::unique_ptr<cricket::VideoChannel> video_channel_; | 517 std::unique_ptr<cricket::VideoChannel> video_channel_; |
496 std::unique_ptr<cricket::DataChannel> data_channel_; | 518 std::unique_ptr<cricket::DataChannel> data_channel_; |
497 cricket::ChannelManager* channel_manager_; | 519 cricket::ChannelManager* channel_manager_; |
498 IceObserver* ice_observer_; | 520 IceObserver* ice_observer_; |
499 PeerConnectionInterface::IceConnectionState ice_connection_state_; | 521 PeerConnectionInterface::IceConnectionState ice_connection_state_; |
500 bool ice_connection_receiving_; | 522 bool ice_connection_receiving_; |
501 std::unique_ptr<SessionDescriptionInterface> local_desc_; | 523 std::unique_ptr<SessionDescriptionInterface> local_desc_; |
502 std::unique_ptr<SessionDescriptionInterface> remote_desc_; | 524 std::unique_ptr<SessionDescriptionInterface> remote_desc_; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 | 556 |
535 #ifdef HAVE_QUIC | 557 #ifdef HAVE_QUIC |
536 std::unique_ptr<QuicDataTransport> quic_data_transport_; | 558 std::unique_ptr<QuicDataTransport> quic_data_transport_; |
537 #endif // HAVE_QUIC | 559 #endif // HAVE_QUIC |
538 | 560 |
539 RTC_DISALLOW_COPY_AND_ASSIGN(WebRtcSession); | 561 RTC_DISALLOW_COPY_AND_ASSIGN(WebRtcSession); |
540 }; | 562 }; |
541 } // namespace webrtc | 563 } // namespace webrtc |
542 | 564 |
543 #endif // WEBRTC_API_WEBRTCSESSION_H_ | 565 #endif // WEBRTC_API_WEBRTCSESSION_H_ |
OLD | NEW |