| Index: talk/app/webrtc/objc/RTCAVFoundationVideoSource.mm
|
| diff --git a/talk/app/webrtc/objc/RTCAVFoundationVideoSource.mm b/talk/app/webrtc/objc/RTCAVFoundationVideoSource.mm
|
| index 660bb4d6cbfb28a4f65ed8366529c622b6618e11..deeb4680bdf11a918c19ae6c7faf3a633f8e36b3 100644
|
| --- a/talk/app/webrtc/objc/RTCAVFoundationVideoSource.mm
|
| +++ b/talk/app/webrtc/objc/RTCAVFoundationVideoSource.mm
|
| @@ -39,10 +39,18 @@
|
| - (instancetype)initWithFactory:(RTCPeerConnectionFactory*)factory
|
| constraints:(RTCMediaConstraints*)constraints {
|
| NSParameterAssert(factory);
|
| - std::unique_ptr<webrtc::AVFoundationVideoCapturer> capturer;
|
| - capturer.reset(new webrtc::AVFoundationVideoCapturer());
|
| + // We pass ownership of the capturer to the source, but since we own
|
| + // the source, it should be ok to keep a raw pointer to the
|
| + // capturer.
|
| + webrtc::AVFoundationVideoCapturer* capturer =
|
| + new webrtc::AVFoundationVideoCapturer();
|
| rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> source =
|
| - factory.nativeFactory->CreateVideoSource(capturer.release(), constraints.constraints);
|
| + factory.nativeFactory->CreateVideoSource(capturer,
|
| + constraints.constraints);
|
| + // We pass ownership of the capturer to the source, but since we own
|
| + // the source, it should be ok to keep a raw pointer to the
|
| + // capturer.
|
| + _capturer = static_cast<void*>(capturer);
|
| return [super initWithMediaSource:source];
|
| }
|
|
|
| @@ -63,12 +71,7 @@
|
| }
|
|
|
| - (webrtc::AVFoundationVideoCapturer*)capturer {
|
| - cricket::VideoCapturer* capturer = self.videoSource->GetVideoCapturer();
|
| - // This should be safe because no one should have changed the underlying video
|
| - // source.
|
| - webrtc::AVFoundationVideoCapturer* foundationCapturer =
|
| - static_cast<webrtc::AVFoundationVideoCapturer*>(capturer);
|
| - return foundationCapturer;
|
| + return static_cast<webrtc::AVFoundationVideoCapturer*>(_capturer);
|
| }
|
|
|
| @end
|
|
|