OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2016 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #import <WebRTC/RTCMacros.h> | 11 #import <AVFoundation/AVFoundation.h> |
12 #import <WebRTC/RTCVideoSource.h> | 12 #import <Foundation/Foundation.h> |
13 | 13 |
14 @class AVCaptureSession; | 14 #include "avfoundationvideocapturer.h" |
15 @class RTCMediaConstraints; | |
16 @class RTCPeerConnectionFactory; | |
17 | 15 |
18 NS_ASSUME_NONNULL_BEGIN | 16 NS_ASSUME_NONNULL_BEGIN |
| 17 // This class used to capture frames using AVFoundation APIs on iOS. It is meant |
| 18 // to be owned by an instance of AVFoundationVideoCapturer. The reason for this |
| 19 // because other webrtc objects own cricket::VideoCapturer, which is not |
| 20 // ref counted. To prevent bad behavior we do not expose this class directly. |
| 21 @interface RTCAVFoundationVideoCapturerInternal |
| 22 : NSObject<AVCaptureVideoDataOutputSampleBufferDelegate> |
19 | 23 |
20 /** | 24 @property(nonatomic, readonly) AVCaptureSession *captureSession; |
21 * RTCAVFoundationVideoSource is a video source that uses | 25 @property(nonatomic, readonly) dispatch_queue_t frameQueue; |
22 * webrtc::AVFoundationVideoCapturer. We do not currently provide a wrapper for | 26 @property(nonatomic, readonly) BOOL canUseBackCamera; |
23 * that capturer because cricket::VideoCapturer is not ref counted and we cannot | 27 @property(nonatomic, assign) BOOL useBackCamera; // Defaults to NO. |
24 * guarantee its lifetime. Instead, we expose its properties through the ref | 28 @property(atomic, assign) BOOL isRunning; // Whether the capture session is run
ning. |
25 * counted video source interface. | 29 @property(atomic, assign) BOOL hasStarted; // Whether we have an unmatched star
t. |
26 */ | |
27 RTC_EXPORT | |
28 @interface RTCAVFoundationVideoSource : RTCVideoSource | |
29 | 30 |
30 - (instancetype)init NS_UNAVAILABLE; | 31 // We keep a pointer back to AVFoundationVideoCapturer to make callbacks on it |
| 32 // when we receive frames. This is safe because this object should be owned by |
| 33 // it. |
| 34 - (instancetype)initWithCapturer:(webrtc::AVFoundationVideoCapturer *)capturer; |
| 35 - (AVCaptureDevice *)getActiveCaptureDevice; |
31 | 36 |
32 /** Returns whether rear-facing camera is available for use. */ | 37 - (nullable AVCaptureDevice *)frontCaptureDevice; |
33 @property(nonatomic, readonly) BOOL canUseBackCamera; | 38 - (nullable AVCaptureDevice *)backCaptureDevice; |
34 | 39 |
35 /** Switches the camera being used (either front or back). */ | 40 // Starts and stops the capture session asynchronously. We cannot do this |
36 @property(nonatomic, assign) BOOL useBackCamera; | 41 // synchronously without blocking a WebRTC thread. |
37 | 42 - (void)start; |
38 /** Returns the active capture session. */ | 43 - (void)stop; |
39 @property(nonatomic, readonly) AVCaptureSession *captureSession; | |
40 | 44 |
41 @end | 45 @end |
42 | |
43 NS_ASSUME_NONNULL_END | 46 NS_ASSUME_NONNULL_END |
OLD | NEW |