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
11 #include "api/peer_connection_interface.h"
12
13 #include <utility>
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
RTCConfiguration(RTCConfigurationType type)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
PeerConnectionDependencies(PeerConnectionObserver * observer_in)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>
CreatePeerConnection(const PeerConnectionInterface::RTCConfiguration & configuration,std::unique_ptr<cricket::PortAllocator> allocator,std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator,PeerConnectionObserver * observer)63 PeerConnectionFactoryInterface::CreatePeerConnection(
64 const PeerConnectionInterface::RTCConfiguration& configuration,
65 std::unique_ptr<cricket::PortAllocator> allocator,
66 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator,
67 PeerConnectionObserver* observer) {
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();
77 }
78
79 rtc::scoped_refptr<PeerConnectionInterface>
CreatePeerConnection(const PeerConnectionInterface::RTCConfiguration & configuration,PeerConnectionDependencies dependencies)80 PeerConnectionFactoryInterface::CreatePeerConnection(
81 const PeerConnectionInterface::RTCConfiguration& configuration,
82 PeerConnectionDependencies dependencies) {
83 auto result =
84 CreatePeerConnectionOrError(configuration, std::move(dependencies));
85 if (!result.ok()) {
86 return nullptr;
87 }
88 return result.MoveValue();
89 }
90
91 RTCErrorOr<rtc::scoped_refptr<PeerConnectionInterface>>
CreatePeerConnectionOrError(const PeerConnectionInterface::RTCConfiguration & configuration,PeerConnectionDependencies dependencies)92 PeerConnectionFactoryInterface::CreatePeerConnectionOrError(
93 const PeerConnectionInterface::RTCConfiguration& configuration,
94 PeerConnectionDependencies dependencies) {
95 return RTCError(RTCErrorType::INTERNAL_ERROR);
96 }
97
GetRtpSenderCapabilities(cricket::MediaType kind) const98 RtpCapabilities PeerConnectionFactoryInterface::GetRtpSenderCapabilities(
99 cricket::MediaType kind) const {
100 return {};
101 }
102
GetRtpReceiverCapabilities(cricket::MediaType kind) const103 RtpCapabilities PeerConnectionFactoryInterface::GetRtpReceiverCapabilities(
104 cricket::MediaType kind) const {
105 return {};
106 }
107
108 } // namespace webrtc
109