| OLD | NEW |
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 Google Inc. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 */ | 26 */ |
| 27 | 27 |
| 28 #import "RTCAVFoundationVideoSource+Internal.h" | 28 #import "RTCAVFoundationVideoSource+Internal.h" |
| 29 | 29 |
| 30 #import "RTCMediaConstraints+Internal.h" | 30 #import "RTCMediaConstraints+Internal.h" |
| 31 #import "RTCMediaSource+Internal.h" | 31 #import "RTCMediaSource+Internal.h" |
| 32 #import "RTCPeerConnectionFactory+Internal.h" | 32 #import "RTCPeerConnectionFactory+Internal.h" |
| 33 #import "RTCVideoSource+Internal.h" | 33 #import "RTCVideoSource+Internal.h" |
| 34 | 34 |
| 35 #include <memory> |
| 36 |
| 35 @implementation RTCAVFoundationVideoSource | 37 @implementation RTCAVFoundationVideoSource |
| 36 | 38 |
| 37 - (instancetype)initWithFactory:(RTCPeerConnectionFactory*)factory | 39 - (instancetype)initWithFactory:(RTCPeerConnectionFactory*)factory |
| 38 constraints:(RTCMediaConstraints*)constraints { | 40 constraints:(RTCMediaConstraints*)constraints { |
| 39 NSParameterAssert(factory); | 41 NSParameterAssert(factory); |
| 40 rtc::scoped_ptr<webrtc::AVFoundationVideoCapturer> capturer; | 42 std::unique_ptr<webrtc::AVFoundationVideoCapturer> capturer; |
| 41 capturer.reset(new webrtc::AVFoundationVideoCapturer()); | 43 capturer.reset(new webrtc::AVFoundationVideoCapturer()); |
| 42 rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> source = | 44 rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> source = |
| 43 factory.nativeFactory->CreateVideoSource(capturer.release(), constraints.c
onstraints); | 45 factory.nativeFactory->CreateVideoSource(capturer.release(), constraints.c
onstraints); |
| 44 return [super initWithMediaSource:source]; | 46 return [super initWithMediaSource:source]; |
| 45 } | 47 } |
| 46 | 48 |
| 47 - (BOOL)useBackCamera { | 49 - (BOOL)useBackCamera { |
| 48 return self.capturer->GetUseBackCamera(); | 50 return self.capturer->GetUseBackCamera(); |
| 49 } | 51 } |
| 50 | 52 |
| 51 - (void)setUseBackCamera:(BOOL)useBackCamera { | 53 - (void)setUseBackCamera:(BOOL)useBackCamera { |
| 52 self.capturer->SetUseBackCamera(useBackCamera); | 54 self.capturer->SetUseBackCamera(useBackCamera); |
| 53 } | 55 } |
| 54 | 56 |
| 55 - (AVCaptureSession*)captureSession { | 57 - (AVCaptureSession*)captureSession { |
| 56 return self.capturer->GetCaptureSession(); | 58 return self.capturer->GetCaptureSession(); |
| 57 } | 59 } |
| 58 | 60 |
| 59 - (webrtc::AVFoundationVideoCapturer*)capturer { | 61 - (webrtc::AVFoundationVideoCapturer*)capturer { |
| 60 cricket::VideoCapturer* capturer = self.videoSource->GetVideoCapturer(); | 62 cricket::VideoCapturer* capturer = self.videoSource->GetVideoCapturer(); |
| 61 // This should be safe because no one should have changed the underlying video | 63 // This should be safe because no one should have changed the underlying video |
| 62 // source. | 64 // source. |
| 63 webrtc::AVFoundationVideoCapturer* foundationCapturer = | 65 webrtc::AVFoundationVideoCapturer* foundationCapturer = |
| 64 static_cast<webrtc::AVFoundationVideoCapturer*>(capturer); | 66 static_cast<webrtc::AVFoundationVideoCapturer*>(capturer); |
| 65 return foundationCapturer; | 67 return foundationCapturer; |
| 66 } | 68 } |
| 67 | 69 |
| 68 @end | 70 @end |
| OLD | NEW |