Switching some interfaces to use std::unique_ptr<>.

This helps show where ownership is transfered between objects.

Specifically, this CL wraps cricket::VideoCapturer, MediaEngineInterface
and DataEngineInterface in unique_ptr.

BUG=None
TBR=magjed@webrtc.org

Review-Url: https://codereview.webrtc.org/2685093002
Cr-Commit-Position: refs/heads/master@{#16548}
diff --git a/webrtc/api/peerconnectionfactoryproxy.h b/webrtc/api/peerconnectionfactoryproxy.h
index e829cca..dd784f5 100644
--- a/webrtc/api/peerconnectionfactoryproxy.h
+++ b/webrtc/api/peerconnectionfactoryproxy.h
@@ -25,6 +25,11 @@
 // are called on is an implementation detail.
 BEGIN_SIGNALING_PROXY_MAP(PeerConnectionFactory)
   PROXY_SIGNALING_THREAD_DESTRUCTOR()
+  // Use the overloads of CreateVideoSource that take raw VideoCapturer
+  // pointers from PeerConnectionFactoryInterface.
+  // TODO(deadbeef): Remove this using statement once those overloads are
+  // removed.
+  using PeerConnectionFactoryInterface::CreateVideoSource;
   PROXY_METHOD1(void, SetOptions, const Options&)
   PROXY_METHOD5(rtc::scoped_refptr<PeerConnectionInterface>,
                 CreatePeerConnection,
@@ -48,11 +53,11 @@
                 const cricket::AudioOptions&)
   PROXY_METHOD2(rtc::scoped_refptr<VideoTrackSourceInterface>,
                 CreateVideoSource,
-                cricket::VideoCapturer*,
+                std::unique_ptr<cricket::VideoCapturer>,
                 const MediaConstraintsInterface*)
   PROXY_METHOD1(rtc::scoped_refptr<VideoTrackSourceInterface>,
                 CreateVideoSource,
-                cricket::VideoCapturer*)
+                std::unique_ptr<cricket::VideoCapturer>)
   PROXY_METHOD2(rtc::scoped_refptr<VideoTrackInterface>,
                 CreateVideoTrack,
                 const std::string&,
diff --git a/webrtc/api/peerconnectioninterface.h b/webrtc/api/peerconnectioninterface.h
index 2a22258..0c9198c 100644
--- a/webrtc/api/peerconnectioninterface.h
+++ b/webrtc/api/peerconnectioninterface.h
@@ -90,6 +90,7 @@
 #include "webrtc/base/socketaddress.h"
 #include "webrtc/base/sslstreamadapter.h"
 #include "webrtc/media/base/mediachannel.h"
+#include "webrtc/media/base/videocapturer.h"
 #include "webrtc/p2p/base/portallocator.h"
 
 namespace rtc {
@@ -966,16 +967,37 @@
 
   // Creates a VideoTrackSourceInterface. The new source takes ownership of
   // |capturer|.
-  // TODO(deadbeef): Switch to std::unique_ptr<>, to make this transfership of
-  // ownership more clear.
+  // TODO(deadbeef): Make pure virtual once downstream mock PC factory classes
+  // are updated.
   virtual rtc::scoped_refptr<VideoTrackSourceInterface> CreateVideoSource(
-      cricket::VideoCapturer* capturer) = 0;
+      std::unique_ptr<cricket::VideoCapturer> capturer) {
+    return nullptr;
+  }
+
   // A video source creator that allows selection of resolution and frame rate.
   // |constraints| decides video resolution and frame rate but can be NULL.
   // In the NULL case, use the version above.
+  //
+  // |constraints| is only used for the invocation of this method, and can
+  // safely be destroyed afterwards.
+  virtual rtc::scoped_refptr<VideoTrackSourceInterface> CreateVideoSource(
+      std::unique_ptr<cricket::VideoCapturer> capturer,
+      const MediaConstraintsInterface* constraints) {
+    return nullptr;
+  }
+
+  // Deprecated; please use the versions that take unique_ptrs above.
+  // TODO(deadbeef): Remove these once safe to do so.
+  virtual rtc::scoped_refptr<VideoTrackSourceInterface> CreateVideoSource(
+      cricket::VideoCapturer* capturer) {
+    return CreateVideoSource(std::unique_ptr<cricket::VideoCapturer>(capturer));
+  }
   virtual rtc::scoped_refptr<VideoTrackSourceInterface> CreateVideoSource(
       cricket::VideoCapturer* capturer,
-      const MediaConstraintsInterface* constraints) = 0;
+      const MediaConstraintsInterface* constraints) {
+    return CreateVideoSource(std::unique_ptr<cricket::VideoCapturer>(capturer),
+                             constraints);
+  }
 
   // Creates a new local VideoTrack. The same |source| can be used in several
   // tracks.