Mirko Bonadei | 79eb4dd | 2018-07-19 08:39:30 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 11 | #include "api/peer_connection_interface.h" |
Jonas Olsson | a4d8737 | 2019-07-05 17:08:33 | [diff] [blame] | 12 | |
Harald Alvestrand | f33f7a2 | 2021-05-09 14:58:57 | [diff] [blame] | 13 | #include <utility> |
Mirko Bonadei | 79eb4dd | 2018-07-19 08:39:30 | [diff] [blame] | 14 | |
| 15 | namespace webrtc { |
| 16 | |
| 17 | PeerConnectionInterface::IceServer::IceServer() = default; |
| 18 | PeerConnectionInterface::IceServer::IceServer(const IceServer& rhs) = default; |
| 19 | PeerConnectionInterface::IceServer::~IceServer() = default; |
| 20 | |
| 21 | PeerConnectionInterface::RTCConfiguration::RTCConfiguration() = default; |
| 22 | |
| 23 | PeerConnectionInterface::RTCConfiguration::RTCConfiguration( |
| 24 | const RTCConfiguration& rhs) = default; |
| 25 | |
| 26 | PeerConnectionInterface::RTCConfiguration::RTCConfiguration( |
| 27 | RTCConfigurationType type) { |
| 28 | if (type == RTCConfigurationType::kAggressive) { |
| 29 | // These parameters are also defined in Java and IOS configurations, |
| 30 | // so their values may be overwritten by the Java or IOS configuration. |
| 31 | bundle_policy = kBundlePolicyMaxBundle; |
| 32 | rtcp_mux_policy = kRtcpMuxPolicyRequire; |
| 33 | ice_connection_receiving_timeout = kAggressiveIceConnectionReceivingTimeout; |
| 34 | |
| 35 | // These parameters are not defined in Java or IOS configuration, |
| 36 | // so their values will not be overwritten. |
| 37 | enable_ice_renomination = true; |
| 38 | redetermine_role_on_ice_restart = false; |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | PeerConnectionInterface::RTCConfiguration::~RTCConfiguration() = default; |
| 43 | |
Mirko Bonadei | 79eb4dd | 2018-07-19 08:39:30 | [diff] [blame] | 44 | PeerConnectionDependencies::PeerConnectionDependencies( |
| 45 | PeerConnectionObserver* observer_in) |
| 46 | : observer(observer_in) {} |
| 47 | |
| 48 | PeerConnectionDependencies::PeerConnectionDependencies( |
| 49 | PeerConnectionDependencies&&) = default; |
| 50 | |
| 51 | PeerConnectionDependencies::~PeerConnectionDependencies() = default; |
| 52 | |
| 53 | PeerConnectionFactoryDependencies::PeerConnectionFactoryDependencies() = |
| 54 | default; |
| 55 | |
| 56 | PeerConnectionFactoryDependencies::PeerConnectionFactoryDependencies( |
| 57 | PeerConnectionFactoryDependencies&&) = default; |
| 58 | |
| 59 | PeerConnectionFactoryDependencies::~PeerConnectionFactoryDependencies() = |
| 60 | default; |
| 61 | |
| 62 | rtc::scoped_refptr<PeerConnectionInterface> |
| 63 | PeerConnectionFactoryInterface::CreatePeerConnection( |
| 64 | const PeerConnectionInterface::RTCConfiguration& configuration, |
Mirko Bonadei | 79eb4dd | 2018-07-19 08:39:30 | [diff] [blame] | 65 | std::unique_ptr<cricket::PortAllocator> allocator, |
| 66 | std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator, |
| 67 | PeerConnectionObserver* observer) { |
Harald Alvestrand | f33f7a2 | 2021-05-09 14:58:57 | [diff] [blame] | 68 | PeerConnectionDependencies dependencies(observer); |
| 69 | dependencies.allocator = std::move(allocator); |
| 70 | dependencies.cert_generator = std::move(cert_generator); |
| 71 | auto result = |
| 72 | CreatePeerConnectionOrError(configuration, std::move(dependencies)); |
| 73 | if (!result.ok()) { |
| 74 | return nullptr; |
| 75 | } |
| 76 | return result.MoveValue(); |
Mirko Bonadei | 79eb4dd | 2018-07-19 08:39:30 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | rtc::scoped_refptr<PeerConnectionInterface> |
| 80 | PeerConnectionFactoryInterface::CreatePeerConnection( |
| 81 | const PeerConnectionInterface::RTCConfiguration& configuration, |
| 82 | PeerConnectionDependencies dependencies) { |
Harald Alvestrand | f33f7a2 | 2021-05-09 14:58:57 | [diff] [blame] | 83 | auto result = |
| 84 | CreatePeerConnectionOrError(configuration, std::move(dependencies)); |
| 85 | if (!result.ok()) { |
| 86 | return nullptr; |
| 87 | } |
| 88 | return result.MoveValue(); |
Mirko Bonadei | 79eb4dd | 2018-07-19 08:39:30 | [diff] [blame] | 89 | } |
| 90 | |
Harald Alvestrand | a3dd772 | 2020-11-27 08:05:42 | [diff] [blame] | 91 | RTCErrorOr<rtc::scoped_refptr<PeerConnectionInterface>> |
| 92 | PeerConnectionFactoryInterface::CreatePeerConnectionOrError( |
| 93 | const PeerConnectionInterface::RTCConfiguration& configuration, |
| 94 | PeerConnectionDependencies dependencies) { |
| 95 | return RTCError(RTCErrorType::INTERNAL_ERROR); |
| 96 | } |
| 97 | |
Mirko Bonadei | 79eb4dd | 2018-07-19 08:39:30 | [diff] [blame] | 98 | RtpCapabilities PeerConnectionFactoryInterface::GetRtpSenderCapabilities( |
| 99 | cricket::MediaType kind) const { |
| 100 | return {}; |
| 101 | } |
| 102 | |
| 103 | RtpCapabilities PeerConnectionFactoryInterface::GetRtpReceiverCapabilities( |
| 104 | cricket::MediaType kind) const { |
| 105 | return {}; |
| 106 | } |
| 107 | |
Mirko Bonadei | 79eb4dd | 2018-07-19 08:39:30 | [diff] [blame] | 108 | } // namespace webrtc |