| 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 virtual void AddHistogramSample(PeerConnectionMetricsName type, | 136 virtual void AddHistogramSample(PeerConnectionMetricsName type, |
| 137 int value) = 0; | 137 int value) = 0; |
| 138 | 138 |
| 139 protected: | 139 protected: |
| 140 virtual ~MetricsObserverInterface() {} | 140 virtual ~MetricsObserverInterface() {} |
| 141 }; | 141 }; |
| 142 | 142 |
| 143 typedef MetricsObserverInterface UMAObserver; | 143 typedef MetricsObserverInterface UMAObserver; |
| 144 | 144 |
| 145 // Enumeration to represent distinct classes of errors that an application | 145 // Enumeration to represent distinct classes of errors that an application |
| 146 // may wish to act upon differently. These roughly map to DOMExceptions or | 146 // may wish to act upon differently. These roughly map to DOMExceptions in |
| 147 // RTCError "errorDetailEnum" values in the web API, as described in the | 147 // the web API, as described in the comments below. |
| 148 // comments below. | 148 enum class RtcError { |
| 149 enum class RTCErrorType { | |
| 150 // No error. | 149 // No error. |
| 151 NONE, | 150 NONE, |
| 152 // A supplied parameter is valid, but currently unsupported. | 151 // A supplied parameter is valid, but currently unsupported. |
| 153 // Maps to InvalidAccessError DOMException. | 152 // Maps to InvalidAccessError DOMException. |
| 154 UNSUPPORTED_PARAMETER, | 153 UNSUPPORTED_PARAMETER, |
| 155 // General error indicating that a supplied parameter is invalid. | 154 // General error indicating that a supplied parameter is invalid. |
| 156 // Maps to InvalidAccessError or TypeError DOMException depending on context. | 155 // Maps to InvalidAccessError or TypeError DOMException depending on context. |
| 157 INVALID_PARAMETER, | 156 INVALID_PARAMETER, |
| 158 // Slightly more specific than INVALID_PARAMETER; a parameter's value was | 157 // Slightly more specific than INVALID_PARAMETER; a parameter's value was |
| 159 // outside the allowed range. | 158 // outside the allowed range. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 170 // Maps to InvalidModificationError DOMException. | 169 // Maps to InvalidModificationError DOMException. |
| 171 INVALID_MODIFICATION, | 170 INVALID_MODIFICATION, |
| 172 // An error occurred within an underlying network protocol. | 171 // An error occurred within an underlying network protocol. |
| 173 // Maps to NetworkError DOMException. | 172 // Maps to NetworkError DOMException. |
| 174 NETWORK_ERROR, | 173 NETWORK_ERROR, |
| 175 // The operation failed due to an internal error. | 174 // The operation failed due to an internal error. |
| 176 // Maps to OperationError DOMException. | 175 // Maps to OperationError DOMException. |
| 177 INTERNAL_ERROR, | 176 INTERNAL_ERROR, |
| 178 }; | 177 }; |
| 179 | 178 |
| 180 // Roughly corresponds to RTCError in the web api. Holds an error type and | |
| 181 // possibly additional information specific to that error. | |
| 182 // | |
| 183 // Doesn't contain anything beyond a type now, but will in the future as more | |
| 184 // errors are implemented. | |
| 185 class RTCError { | |
| 186 public: | |
| 187 RTCError() : type_(RTCErrorType::NONE) {} | |
| 188 explicit RTCError(RTCErrorType type) : type_(type) {} | |
| 189 | |
| 190 RTCErrorType type() const { return type_; } | |
| 191 void set_type(RTCErrorType type) { type_ = type; } | |
| 192 | |
| 193 private: | |
| 194 RTCErrorType type_; | |
| 195 }; | |
| 196 | |
| 197 // Outputs the error as a friendly string. | 179 // Outputs the error as a friendly string. |
| 198 // Update this method when adding a new error type. | 180 // Update this method when adding a new error type. |
| 199 std::ostream& operator<<(std::ostream& stream, RTCErrorType error); | 181 std::ostream& operator<<(std::ostream& stream, RtcError error); |
| 200 | 182 |
| 201 class PeerConnectionInterface : public rtc::RefCountInterface { | 183 class PeerConnectionInterface : public rtc::RefCountInterface { |
| 202 public: | 184 public: |
| 203 // See http://dev.w3.org/2011/webrtc/editor/webrtc.html#state-definitions . | 185 // See http://dev.w3.org/2011/webrtc/editor/webrtc.html#state-definitions . |
| 204 enum SignalingState { | 186 enum SignalingState { |
| 205 kStable, | 187 kStable, |
| 206 kHaveLocalOffer, | 188 kHaveLocalOffer, |
| 207 kHaveLocalPrAnswer, | 189 kHaveLocalPrAnswer, |
| 208 kHaveRemoteOffer, | 190 kHaveRemoteOffer, |
| 209 kHaveRemotePrAnswer, | 191 kHaveRemotePrAnswer, |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 ice_connection_receiving_timeout = | 292 ice_connection_receiving_timeout = |
| 311 kAggressiveIceConnectionReceivingTimeout; | 293 kAggressiveIceConnectionReceivingTimeout; |
| 312 | 294 |
| 313 // These parameters are not defined in Java or IOS configuration, | 295 // These parameters are not defined in Java or IOS configuration, |
| 314 // so their values will not be overwritten. | 296 // so their values will not be overwritten. |
| 315 enable_ice_renomination = true; | 297 enable_ice_renomination = true; |
| 316 redetermine_role_on_ice_restart = false; | 298 redetermine_role_on_ice_restart = false; |
| 317 } | 299 } |
| 318 } | 300 } |
| 319 | 301 |
| 320 bool operator==(const RTCConfiguration& o) const; | |
| 321 bool operator!=(const RTCConfiguration& o) const; | |
| 322 | |
| 323 bool dscp() { return media_config.enable_dscp; } | 302 bool dscp() { return media_config.enable_dscp; } |
| 324 void set_dscp(bool enable) { media_config.enable_dscp = enable; } | 303 void set_dscp(bool enable) { media_config.enable_dscp = enable; } |
| 325 | 304 |
| 326 // TODO(nisse): The corresponding flag in MediaConfig and | 305 // TODO(nisse): The corresponding flag in MediaConfig and |
| 327 // elsewhere should be renamed enable_cpu_adaptation. | 306 // elsewhere should be renamed enable_cpu_adaptation. |
| 328 bool cpu_adaptation() { | 307 bool cpu_adaptation() { |
| 329 return media_config.video.enable_cpu_overuse_detection; | 308 return media_config.video.enable_cpu_overuse_detection; |
| 330 } | 309 } |
| 331 void set_cpu_adaptation(bool enable) { | 310 void set_cpu_adaptation(bool enable) { |
| 332 media_config.video.enable_cpu_overuse_detection = enable; | 311 media_config.video.enable_cpu_overuse_detection = enable; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 bool prune_turn_ports = false; | 365 bool prune_turn_ports = false; |
| 387 // If set to true, this means the ICE transport should presume TURN-to-TURN | 366 // If set to true, this means the ICE transport should presume TURN-to-TURN |
| 388 // candidate pairs will succeed, even before a binding response is received. | 367 // candidate pairs will succeed, even before a binding response is received. |
| 389 bool presume_writable_when_fully_relayed = false; | 368 bool presume_writable_when_fully_relayed = false; |
| 390 // If true, "renomination" will be added to the ice options in the transport | 369 // If true, "renomination" will be added to the ice options in the transport |
| 391 // description. | 370 // description. |
| 392 bool enable_ice_renomination = false; | 371 bool enable_ice_renomination = false; |
| 393 // If true, ICE role is redetermined when peerconnection sets a local | 372 // If true, ICE role is redetermined when peerconnection sets a local |
| 394 // transport description that indicates an ICE restart. | 373 // transport description that indicates an ICE restart. |
| 395 bool redetermine_role_on_ice_restart = true; | 374 bool redetermine_role_on_ice_restart = true; |
| 396 // | |
| 397 // Don't forget to update operator== if adding something. | |
| 398 // | |
| 399 }; | 375 }; |
| 400 | 376 |
| 401 struct RTCOfferAnswerOptions { | 377 struct RTCOfferAnswerOptions { |
| 402 static const int kUndefined = -1; | 378 static const int kUndefined = -1; |
| 403 static const int kMaxOfferToReceiveMedia = 1; | 379 static const int kMaxOfferToReceiveMedia = 1; |
| 404 | 380 |
| 405 // The default value for constraint offerToReceiveX:true. | 381 // The default value for constraint offerToReceiveX:true. |
| 406 static const int kOfferToReceiveMediaTrue = 1; | 382 static const int kOfferToReceiveMediaTrue = 1; |
| 407 | 383 |
| 408 int offer_to_receive_video = kUndefined; | 384 int offer_to_receive_video = kUndefined; |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 virtual bool UpdateIce(const IceServers& configuration, | 523 virtual bool UpdateIce(const IceServers& configuration, |
| 548 const MediaConstraintsInterface* constraints) { | 524 const MediaConstraintsInterface* constraints) { |
| 549 return false; | 525 return false; |
| 550 } | 526 } |
| 551 virtual bool UpdateIce(const IceServers& configuration) { return false; } | 527 virtual bool UpdateIce(const IceServers& configuration) { return false; } |
| 552 // TODO(deadbeef): Make this pure virtual once all Chrome subclasses of | 528 // TODO(deadbeef): Make this pure virtual once all Chrome subclasses of |
| 553 // PeerConnectionInterface implement it. | 529 // PeerConnectionInterface implement it. |
| 554 virtual PeerConnectionInterface::RTCConfiguration GetConfiguration() { | 530 virtual PeerConnectionInterface::RTCConfiguration GetConfiguration() { |
| 555 return PeerConnectionInterface::RTCConfiguration(); | 531 return PeerConnectionInterface::RTCConfiguration(); |
| 556 } | 532 } |
| 557 | |
| 558 // Sets the PeerConnection's global configuration to |config|. | 533 // Sets the PeerConnection's global configuration to |config|. |
| 559 // | |
| 560 // The members of |config| that may be changed are |type|, |servers|, | |
| 561 // |ice_candidate_pool_size| and |prune_turn_ports| (though the candidate | |
| 562 // pool size can't be changed after the first call to SetLocalDescription). | |
| 563 // Note that this means the BUNDLE and RTCP-multiplexing policies cannot be | |
| 564 // changed with this method. | |
| 565 // | |
| 566 // Any changes to STUN/TURN servers or ICE candidate policy will affect the | 534 // Any changes to STUN/TURN servers or ICE candidate policy will affect the |
| 567 // next gathering phase, and cause the next call to createOffer to generate | 535 // next gathering phase, and cause the next call to createOffer to generate |
| 568 // new ICE credentials, as described in JSEP. This also occurs when | 536 // new ICE credentials. Note that the BUNDLE and RTCP-multiplexing policies |
| 569 // |prune_turn_ports| changes, for the same reasoning. | 537 // cannot be changed with this method. |
| 570 // | |
| 571 // If an error occurs, returns false and populates |error| if non-null: | |
| 572 // - INVALID_MODIFICATION if |config| contains a modified parameter other | |
| 573 // than one of the parameters listed above. | |
| 574 // - INVALID_RANGE if |ice_candidate_pool_size| is out of range. | |
| 575 // - SYNTAX_ERROR if parsing an ICE server URL failed. | |
| 576 // - INVALID_PARAMETER if a TURN server is missing |username| or |password|. | |
| 577 // - INTERNAL_ERROR if an unexpected error occurred. | |
| 578 // | |
| 579 // TODO(deadbeef): Make this pure virtual once all Chrome subclasses of | 538 // TODO(deadbeef): Make this pure virtual once all Chrome subclasses of |
| 580 // PeerConnectionInterface implement it. | 539 // PeerConnectionInterface implement it. |
| 581 virtual bool SetConfiguration( | 540 virtual bool SetConfiguration( |
| 582 const PeerConnectionInterface::RTCConfiguration& config, | 541 const PeerConnectionInterface::RTCConfiguration& config) { |
| 583 RTCError* error = nullptr) { | |
| 584 return false; | 542 return false; |
| 585 } | 543 } |
| 586 // Provides a remote candidate to the ICE Agent. | 544 // Provides a remote candidate to the ICE Agent. |
| 587 // A copy of the |candidate| will be created and added to the remote | 545 // A copy of the |candidate| will be created and added to the remote |
| 588 // description. So the caller of this method still has the ownership of the | 546 // description. So the caller of this method still has the ownership of the |
| 589 // |candidate|. | 547 // |candidate|. |
| 590 // TODO(ronghuawu): Consider to change this so that the AddIceCandidate will | 548 // TODO(ronghuawu): Consider to change this so that the AddIceCandidate will |
| 591 // take the ownership of the |candidate|. | 549 // take the ownership of the |candidate|. |
| 592 virtual bool AddIceCandidate(const IceCandidateInterface* candidate) = 0; | 550 virtual bool AddIceCandidate(const IceCandidateInterface* candidate) = 0; |
| 593 | 551 |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 870 cricket::WebRtcVideoEncoderFactory* encoder_factory, | 828 cricket::WebRtcVideoEncoderFactory* encoder_factory, |
| 871 cricket::WebRtcVideoDecoderFactory* decoder_factory) { | 829 cricket::WebRtcVideoDecoderFactory* decoder_factory) { |
| 872 return CreatePeerConnectionFactory( | 830 return CreatePeerConnectionFactory( |
| 873 worker_and_network_thread, worker_and_network_thread, signaling_thread, | 831 worker_and_network_thread, worker_and_network_thread, signaling_thread, |
| 874 default_adm, encoder_factory, decoder_factory); | 832 default_adm, encoder_factory, decoder_factory); |
| 875 } | 833 } |
| 876 | 834 |
| 877 } // namespace webrtc | 835 } // namespace webrtc |
| 878 | 836 |
| 879 #endif // WEBRTC_API_PEERCONNECTIONINTERFACE_H_ | 837 #endif // WEBRTC_API_PEERCONNECTIONINTERFACE_H_ |
| OLD | NEW |