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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 virtual void AddHistogramSample(PeerConnectionMetricsName type, | 143 virtual void AddHistogramSample(PeerConnectionMetricsName type, |
144 int value) = 0; | 144 int value) = 0; |
145 | 145 |
146 protected: | 146 protected: |
147 virtual ~MetricsObserverInterface() {} | 147 virtual ~MetricsObserverInterface() {} |
148 }; | 148 }; |
149 | 149 |
150 typedef MetricsObserverInterface UMAObserver; | 150 typedef MetricsObserverInterface UMAObserver; |
151 | 151 |
152 // Enumeration to represent distinct classes of errors that an application | 152 // Enumeration to represent distinct classes of errors that an application |
153 // may wish to act upon differently. These roughly map to DOMExceptions in | 153 // may wish to act upon differently. These roughly map to DOMExceptions or |
154 // the web API, as described in the comments below. | 154 // RTCError "errorDetailEnum" values in the web API, as described in the |
155 enum class RtcError { | 155 // comments below. |
| 156 enum class RTCErrorType { |
156 // No error. | 157 // No error. |
157 NONE, | 158 NONE, |
158 // A supplied parameter is valid, but currently unsupported. | 159 // A supplied parameter is valid, but currently unsupported. |
159 // Maps to InvalidAccessError DOMException. | 160 // Maps to InvalidAccessError DOMException. |
160 UNSUPPORTED_PARAMETER, | 161 UNSUPPORTED_PARAMETER, |
161 // General error indicating that a supplied parameter is invalid. | 162 // General error indicating that a supplied parameter is invalid. |
162 // Maps to InvalidAccessError or TypeError DOMException depending on context. | 163 // Maps to InvalidAccessError or TypeError DOMException depending on context. |
163 INVALID_PARAMETER, | 164 INVALID_PARAMETER, |
164 // Slightly more specific than INVALID_PARAMETER; a parameter's value was | 165 // Slightly more specific than INVALID_PARAMETER; a parameter's value was |
165 // outside the allowed range. | 166 // outside the allowed range. |
(...skipping 10 matching lines...) Expand all Loading... |
176 // Maps to InvalidModificationError DOMException. | 177 // Maps to InvalidModificationError DOMException. |
177 INVALID_MODIFICATION, | 178 INVALID_MODIFICATION, |
178 // An error occurred within an underlying network protocol. | 179 // An error occurred within an underlying network protocol. |
179 // Maps to NetworkError DOMException. | 180 // Maps to NetworkError DOMException. |
180 NETWORK_ERROR, | 181 NETWORK_ERROR, |
181 // The operation failed due to an internal error. | 182 // The operation failed due to an internal error. |
182 // Maps to OperationError DOMException. | 183 // Maps to OperationError DOMException. |
183 INTERNAL_ERROR, | 184 INTERNAL_ERROR, |
184 }; | 185 }; |
185 | 186 |
| 187 // Roughly corresponds to RTCError in the web api. Holds an error type and |
| 188 // possibly additional information specific to that error. |
| 189 // |
| 190 // Doesn't contain anything beyond a type now, but will in the future as more |
| 191 // errors are implemented. |
| 192 class RTCError { |
| 193 public: |
| 194 RTCError() : type_(RTCErrorType::NONE) {} |
| 195 explicit RTCError(RTCErrorType type) : type_(type) {} |
| 196 |
| 197 RTCErrorType type() const { return type_; } |
| 198 void set_type(RTCErrorType type) { type_ = type; } |
| 199 |
| 200 private: |
| 201 RTCErrorType type_; |
| 202 }; |
| 203 |
186 // Outputs the error as a friendly string. | 204 // Outputs the error as a friendly string. |
187 // Update this method when adding a new error type. | 205 // Update this method when adding a new error type. |
188 std::ostream& operator<<(std::ostream& stream, RtcError error); | 206 std::ostream& operator<<(std::ostream& stream, RTCErrorType error); |
189 | 207 |
190 class PeerConnectionInterface : public rtc::RefCountInterface { | 208 class PeerConnectionInterface : public rtc::RefCountInterface { |
191 public: | 209 public: |
192 // See http://dev.w3.org/2011/webrtc/editor/webrtc.html#state-definitions . | 210 // See http://dev.w3.org/2011/webrtc/editor/webrtc.html#state-definitions . |
193 enum SignalingState { | 211 enum SignalingState { |
194 kStable, | 212 kStable, |
195 kHaveLocalOffer, | 213 kHaveLocalOffer, |
196 kHaveLocalPrAnswer, | 214 kHaveLocalPrAnswer, |
197 kHaveRemoteOffer, | 215 kHaveRemoteOffer, |
198 kHaveRemotePrAnswer, | 216 kHaveRemotePrAnswer, |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 ice_connection_receiving_timeout = | 330 ice_connection_receiving_timeout = |
313 kAggressiveIceConnectionReceivingTimeout; | 331 kAggressiveIceConnectionReceivingTimeout; |
314 | 332 |
315 // These parameters are not defined in Java or IOS configuration, | 333 // These parameters are not defined in Java or IOS configuration, |
316 // so their values will not be overwritten. | 334 // so their values will not be overwritten. |
317 enable_ice_renomination = true; | 335 enable_ice_renomination = true; |
318 redetermine_role_on_ice_restart = false; | 336 redetermine_role_on_ice_restart = false; |
319 } | 337 } |
320 } | 338 } |
321 | 339 |
| 340 bool operator==(const RTCConfiguration& o) const; |
| 341 bool operator!=(const RTCConfiguration& o) const; |
| 342 |
322 bool dscp() { return media_config.enable_dscp; } | 343 bool dscp() { return media_config.enable_dscp; } |
323 void set_dscp(bool enable) { media_config.enable_dscp = enable; } | 344 void set_dscp(bool enable) { media_config.enable_dscp = enable; } |
324 | 345 |
325 // TODO(nisse): The corresponding flag in MediaConfig and | 346 // TODO(nisse): The corresponding flag in MediaConfig and |
326 // elsewhere should be renamed enable_cpu_adaptation. | 347 // elsewhere should be renamed enable_cpu_adaptation. |
327 bool cpu_adaptation() { | 348 bool cpu_adaptation() { |
328 return media_config.video.enable_cpu_overuse_detection; | 349 return media_config.video.enable_cpu_overuse_detection; |
329 } | 350 } |
330 void set_cpu_adaptation(bool enable) { | 351 void set_cpu_adaptation(bool enable) { |
331 media_config.video.enable_cpu_overuse_detection = enable; | 352 media_config.video.enable_cpu_overuse_detection = enable; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 bool prune_turn_ports = false; | 406 bool prune_turn_ports = false; |
386 // If set to true, this means the ICE transport should presume TURN-to-TURN | 407 // If set to true, this means the ICE transport should presume TURN-to-TURN |
387 // candidate pairs will succeed, even before a binding response is received. | 408 // candidate pairs will succeed, even before a binding response is received. |
388 bool presume_writable_when_fully_relayed = false; | 409 bool presume_writable_when_fully_relayed = false; |
389 // If true, "renomination" will be added to the ice options in the transport | 410 // If true, "renomination" will be added to the ice options in the transport |
390 // description. | 411 // description. |
391 bool enable_ice_renomination = false; | 412 bool enable_ice_renomination = false; |
392 // If true, ICE role is redetermined when peerconnection sets a local | 413 // If true, ICE role is redetermined when peerconnection sets a local |
393 // transport description that indicates an ICE restart. | 414 // transport description that indicates an ICE restart. |
394 bool redetermine_role_on_ice_restart = true; | 415 bool redetermine_role_on_ice_restart = true; |
| 416 // |
| 417 // Don't forget to update operator== if adding something. |
| 418 // |
395 }; | 419 }; |
396 | 420 |
397 struct RTCOfferAnswerOptions { | 421 struct RTCOfferAnswerOptions { |
398 static const int kUndefined = -1; | 422 static const int kUndefined = -1; |
399 static const int kMaxOfferToReceiveMedia = 1; | 423 static const int kMaxOfferToReceiveMedia = 1; |
400 | 424 |
401 // The default value for constraint offerToReceiveX:true. | 425 // The default value for constraint offerToReceiveX:true. |
402 static const int kOfferToReceiveMediaTrue = 1; | 426 static const int kOfferToReceiveMediaTrue = 1; |
403 | 427 |
404 int offer_to_receive_video = kUndefined; | 428 int offer_to_receive_video = kUndefined; |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 virtual bool UpdateIce(const IceServers& configuration, | 586 virtual bool UpdateIce(const IceServers& configuration, |
563 const MediaConstraintsInterface* constraints) { | 587 const MediaConstraintsInterface* constraints) { |
564 return false; | 588 return false; |
565 } | 589 } |
566 virtual bool UpdateIce(const IceServers& configuration) { return false; } | 590 virtual bool UpdateIce(const IceServers& configuration) { return false; } |
567 // TODO(deadbeef): Make this pure virtual once all Chrome subclasses of | 591 // TODO(deadbeef): Make this pure virtual once all Chrome subclasses of |
568 // PeerConnectionInterface implement it. | 592 // PeerConnectionInterface implement it. |
569 virtual PeerConnectionInterface::RTCConfiguration GetConfiguration() { | 593 virtual PeerConnectionInterface::RTCConfiguration GetConfiguration() { |
570 return PeerConnectionInterface::RTCConfiguration(); | 594 return PeerConnectionInterface::RTCConfiguration(); |
571 } | 595 } |
| 596 |
572 // Sets the PeerConnection's global configuration to |config|. | 597 // Sets the PeerConnection's global configuration to |config|. |
| 598 // |
| 599 // The members of |config| that may be changed are |type|, |servers|, |
| 600 // |ice_candidate_pool_size| and |prune_turn_ports| (though the candidate |
| 601 // pool size can't be changed after the first call to SetLocalDescription). |
| 602 // Note that this means the BUNDLE and RTCP-multiplexing policies cannot be |
| 603 // changed with this method. |
| 604 // |
573 // Any changes to STUN/TURN servers or ICE candidate policy will affect the | 605 // Any changes to STUN/TURN servers or ICE candidate policy will affect the |
574 // next gathering phase, and cause the next call to createOffer to generate | 606 // next gathering phase, and cause the next call to createOffer to generate |
575 // new ICE credentials. Note that the BUNDLE and RTCP-multiplexing policies | 607 // new ICE credentials, as described in JSEP. This also occurs when |
576 // cannot be changed with this method. | 608 // |prune_turn_ports| changes, for the same reasoning. |
| 609 // |
| 610 // If an error occurs, returns false and populates |error| if non-null: |
| 611 // - INVALID_MODIFICATION if |config| contains a modified parameter other |
| 612 // than one of the parameters listed above. |
| 613 // - INVALID_RANGE if |ice_candidate_pool_size| is out of range. |
| 614 // - SYNTAX_ERROR if parsing an ICE server URL failed. |
| 615 // - INVALID_PARAMETER if a TURN server is missing |username| or |password|. |
| 616 // - INTERNAL_ERROR if an unexpected error occurred. |
| 617 // |
577 // TODO(deadbeef): Make this pure virtual once all Chrome subclasses of | 618 // TODO(deadbeef): Make this pure virtual once all Chrome subclasses of |
578 // PeerConnectionInterface implement it. | 619 // PeerConnectionInterface implement it. |
579 virtual bool SetConfiguration( | 620 virtual bool SetConfiguration( |
| 621 const PeerConnectionInterface::RTCConfiguration& config, |
| 622 RTCError* error) { |
| 623 return false; |
| 624 } |
| 625 // Version without error output param for backwards compatibility. |
| 626 // TODO(deadbeef): Remove once chromium is updated. |
| 627 virtual bool SetConfiguration( |
580 const PeerConnectionInterface::RTCConfiguration& config) { | 628 const PeerConnectionInterface::RTCConfiguration& config) { |
581 return false; | 629 return false; |
582 } | 630 } |
583 // Provides a remote candidate to the ICE Agent. | 631 // Provides a remote candidate to the ICE Agent. |
584 // A copy of the |candidate| will be created and added to the remote | 632 // A copy of the |candidate| will be created and added to the remote |
585 // description. So the caller of this method still has the ownership of the | 633 // description. So the caller of this method still has the ownership of the |
586 // |candidate|. | 634 // |candidate|. |
587 // TODO(ronghuawu): Consider to change this so that the AddIceCandidate will | 635 // TODO(ronghuawu): Consider to change this so that the AddIceCandidate will |
588 // take the ownership of the |candidate|. | 636 // take the ownership of the |candidate|. |
589 virtual bool AddIceCandidate(const IceCandidateInterface* candidate) = 0; | 637 virtual bool AddIceCandidate(const IceCandidateInterface* candidate) = 0; |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 cricket::WebRtcVideoEncoderFactory* encoder_factory, | 915 cricket::WebRtcVideoEncoderFactory* encoder_factory, |
868 cricket::WebRtcVideoDecoderFactory* decoder_factory) { | 916 cricket::WebRtcVideoDecoderFactory* decoder_factory) { |
869 return CreatePeerConnectionFactory( | 917 return CreatePeerConnectionFactory( |
870 worker_and_network_thread, worker_and_network_thread, signaling_thread, | 918 worker_and_network_thread, worker_and_network_thread, signaling_thread, |
871 default_adm, encoder_factory, decoder_factory); | 919 default_adm, encoder_factory, decoder_factory); |
872 } | 920 } |
873 | 921 |
874 } // namespace webrtc | 922 } // namespace webrtc |
875 | 923 |
876 #endif // WEBRTC_API_PEERCONNECTIONINTERFACE_H_ | 924 #endif // WEBRTC_API_PEERCONNECTIONINTERFACE_H_ |
OLD | NEW |