• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 package org.webrtc;
12 
13 import android.support.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 
Builder(PeerConnection.Observer observer)32     private Builder(PeerConnection.Observer observer) {
33       this.observer = observer;
34     }
35 
setSSLCertificateVerifier(SSLCertificateVerifier sslCertificateVerifier)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.
createPeerConnectionDependencies()42     public PeerConnectionDependencies createPeerConnectionDependencies() {
43       return new PeerConnectionDependencies(observer, sslCertificateVerifier);
44     }
45   }
46 
builder(PeerConnection.Observer observer)47   public static Builder builder(PeerConnection.Observer observer) {
48     return new Builder(observer);
49   }
50 
getObserver()51   PeerConnection.Observer getObserver() {
52     return observer;
53   }
54 
55   @Nullable
getSSLCertificateVerifier()56   SSLCertificateVerifier getSSLCertificateVerifier() {
57     return sslCertificateVerifier;
58   }
59 
PeerConnectionDependencies( PeerConnection.Observer observer, SSLCertificateVerifier sslCertificateVerifier)60   private PeerConnectionDependencies(
61       PeerConnection.Observer observer, SSLCertificateVerifier sslCertificateVerifier) {
62     this.observer = observer;
63     this.sslCertificateVerifier = sslCertificateVerifier;
64   }
65 }
66