Index: webrtc/api/objc/RTCAVFoundationVideoSource.mm |
diff --git a/webrtc/api/objc/RTCAVFoundationVideoSource.mm b/webrtc/api/objc/RTCAVFoundationVideoSource.mm |
index 1005c7dfa122c6528adc6b46cfb14644c430fc5f..919190a4b9b321cfc28b8100a9cdc7174bd4e22d 100644 |
--- a/webrtc/api/objc/RTCAVFoundationVideoSource.mm |
+++ b/webrtc/api/objc/RTCAVFoundationVideoSource.mm |
@@ -19,11 +19,15 @@ |
- (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory |
constraints:(RTCMediaConstraints *)constraints { |
NSParameterAssert(factory); |
- rtc::scoped_ptr<webrtc::AVFoundationVideoCapturer> capturer; |
- capturer.reset(new webrtc::AVFoundationVideoCapturer()); |
+ webrtc::AVFoundationVideoCapturer *capturer = |
+ new webrtc::AVFoundationVideoCapturer(); |
rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> source = |
factory.nativeFactory->CreateVideoSource( |
- capturer.release(), constraints.nativeConstraints.get()); |
+ capturer, constraints.nativeConstraints.get()); |
+ // 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 initWithNativeVideoSource:source]; |
} |
@@ -44,12 +48,7 @@ |
} |
- (webrtc::AVFoundationVideoCapturer *)capturer { |
- cricket::VideoCapturer *capturer = self.nativeVideoSource->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 |