| 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 | package org.webrtc; |
| 12 |
| 13 | import androidx.annotation.Nullable; |
| 14 |
| 15 | /** |
| 16 | * PeerConnectionDependencies holds all PeerConnection dependencies that are |
| 17 | * applied per PeerConnection. A dependency is distinct from a configuration |
| 18 | * as it defines significant executable code that can be provided by a user of |
| 19 | * the API. |
| 20 | */ |
| 21 | public final class PeerConnectionDependencies { |
| 22 | // Mandatory dependencies. |
| 23 | private final PeerConnection.Observer observer; |
| 24 |
| 25 | // Optional fields. |
| 26 | private final SSLCertificateVerifier sslCertificateVerifier; |
| 27 |
| 28 | public static class Builder { |
| 29 | private PeerConnection.Observer observer; |
| 30 | private SSLCertificateVerifier sslCertificateVerifier; |
| 31 |
| 32 | private Builder(PeerConnection.Observer observer) { |
| 33 | this.observer = observer; |
| 34 | } |
| 35 |
| 36 | public Builder setSSLCertificateVerifier(SSLCertificateVerifier sslCertificateVerifier) { |
| 37 | this.sslCertificateVerifier = sslCertificateVerifier; |
| 38 | return this; |
| 39 | } |
| 40 |
| 41 | // Observer is a required dependency and so is forced in the construction of the object. |
| 42 | public PeerConnectionDependencies createPeerConnectionDependencies() { |
| 43 | return new PeerConnectionDependencies(observer, sslCertificateVerifier); |
| 44 | } |
| 45 | } |
| 46 |
| 47 | public static Builder builder(PeerConnection.Observer observer) { |
| 48 | return new Builder(observer); |
| 49 | } |
| 50 |
| 51 | PeerConnection.Observer getObserver() { |
| 52 | return observer; |
| 53 | } |
| 54 |
| 55 | @Nullable |
| 56 | SSLCertificateVerifier getSSLCertificateVerifier() { |
| 57 | return sslCertificateVerifier; |
| 58 | } |
| 59 |
| 60 | private PeerConnectionDependencies( |
| 61 | PeerConnection.Observer observer, SSLCertificateVerifier sslCertificateVerifier) { |
| 62 | this.observer = observer; |
| 63 | this.sslCertificateVerifier = sslCertificateVerifier; |
| 64 | } |
| 65 | } |
| 66 |