Replacing DtlsIdentityStoreInterface with RTCCertificateGeneratorInterface.

The store was used in WebRtcSessionDescriptionFactory to generate certificates,
now a generator is used instead (new API). PeerConnection[Factory][Interface],
and WebRtcSession are updated to pass generators all the way down to the
WebRtcSessionDescriptionFactory instead of stores.

The webrtc implementation of a generator, RTCCertificateGenerator, is used as
the default generator (peerconnectionfactory.cc:189) instead of the webrtc
implementation of a store, DtlsIdentityStoreImpl.
  The generator is fully parameterized and does not generate RSA-1024 unless you
ask for it (which makes sense not to do beforehand since ECDSA is now default).
The store was not fully parameterized (known filed bug).

The "top" layer, PeerConnectionFactoryInterface::CreatePeerConneciton, is
updated to take a generator instead of a store.
  Many unittests still use a store, to allow them to continue to do so the
factory gets CreatePeerConnectionWithStore which uses the old function
signature (and invokes the new signature by wrapping the store in an
RTCCertificateGeneratorStoreWrapper). As soon as the FakeDtlsIdentityStore is
turned into a certificate generator instead of a store, the unittests will be
updated and we can remove CreatePeerConnectionWithStore.

This is a reupload of https://codereview.webrtc.org/2013523002/ with minor
changes.

BUG=webrtc:5707, webrtc:5708
R=tommi@webrtc.org

Review URL: https://codereview.webrtc.org/2017943002 .

Cr-Commit-Position: refs/heads/master@{#12984}
diff --git a/webrtc/api/peerconnectioninterface.h b/webrtc/api/peerconnectioninterface.h
index 166a1e5..3a1b8dd 100644
--- a/webrtc/api/peerconnectioninterface.h
+++ b/webrtc/api/peerconnectioninterface.h
@@ -68,6 +68,7 @@
 #include "webrtc/base/fileutils.h"
 #include "webrtc/base/network.h"
 #include "webrtc/base/rtccertificate.h"
+#include "webrtc/base/rtccertificategenerator.h"
 #include "webrtc/base/socketaddress.h"
 #include "webrtc/base/sslstreamadapter.h"
 #include "webrtc/media/base/mediachannel.h"
@@ -600,14 +601,48 @@
       const PeerConnectionInterface::RTCConfiguration& configuration,
       const MediaConstraintsInterface* constraints,
       std::unique_ptr<cricket::PortAllocator> allocator,
-      std::unique_ptr<DtlsIdentityStoreInterface> dtls_identity_store,
+      std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator,
       PeerConnectionObserver* observer) = 0;
+  // TODO(hbos): To be removed in favor of the |cert_generator| version as soon
+  // as unittests stop using this version. See bugs.webrtc.org/5707,
+  // bugs.webrtc.org/5708.
+  rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnectionWithStore(
+      const PeerConnectionInterface::RTCConfiguration& configuration,
+      const MediaConstraintsInterface* constraints,
+      std::unique_ptr<cricket::PortAllocator> allocator,
+      std::unique_ptr<DtlsIdentityStoreInterface> dtls_identity_store,
+      PeerConnectionObserver* observer) {
+    return CreatePeerConnection(
+        configuration,
+        constraints,
+        std::move(allocator),
+        std::unique_ptr<rtc::RTCCertificateGeneratorInterface>(
+            dtls_identity_store ? new RTCCertificateGeneratorStoreWrapper(
+                std::move(dtls_identity_store)) : nullptr),
+        observer);
+  }
 
   virtual rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnection(
       const PeerConnectionInterface::RTCConfiguration& configuration,
       std::unique_ptr<cricket::PortAllocator> allocator,
-      std::unique_ptr<DtlsIdentityStoreInterface> dtls_identity_store,
+      std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator,
       PeerConnectionObserver* observer) = 0;
+  // TODO(hbos): To be removed in favor of the |cert_generator| version as soon
+  // as unittests stop using this version. See bugs.webrtc.org/5707,
+  // bugs.webrtc.org/5708.
+  rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnectionWithStore(
+      const PeerConnectionInterface::RTCConfiguration& configuration,
+      std::unique_ptr<cricket::PortAllocator> allocator,
+      std::unique_ptr<DtlsIdentityStoreInterface> dtls_identity_store,
+      PeerConnectionObserver* observer) {
+    return CreatePeerConnection(
+        configuration,
+        std::move(allocator),
+        std::unique_ptr<rtc::RTCCertificateGeneratorInterface>(
+            dtls_identity_store ? new RTCCertificateGeneratorStoreWrapper(
+                std::move(dtls_identity_store)) : nullptr),
+        observer);
+  }
 
   virtual rtc::scoped_refptr<MediaStreamInterface>
       CreateLocalMediaStream(const std::string& label) = 0;