Jon Hjelle | 7ac8bab | 2016-01-21 11:44:55 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | #ifndef WEBRTC_API_OBJC_AVFOUNDATION_VIDEO_CAPTURER_H_ |
| 12 | #define WEBRTC_API_OBJC_AVFOUNDATION_VIDEO_CAPTURER_H_ |
| 13 | |
tkchin | 9eeb624 | 2016-04-27 01:54:20 -0700 | [diff] [blame] | 14 | #import <AVFoundation/AVFoundation.h> |
| 15 | |
magjed | 39607c9 | 2016-07-14 08:12:17 -0700 | [diff] [blame] | 16 | #include "webrtc/common_video/include/i420_buffer_pool.h" |
kjellander | a96e2d7 | 2016-02-04 23:52:28 -0800 | [diff] [blame] | 17 | #include "webrtc/media/base/videocapturer.h" |
Jon Hjelle | 7ac8bab | 2016-01-21 11:44:55 -0800 | [diff] [blame] | 18 | #include "webrtc/video_frame.h" |
| 19 | |
Jon Hjelle | 7ac8bab | 2016-01-21 11:44:55 -0800 | [diff] [blame] | 20 | @class RTCAVFoundationVideoCapturerInternal; |
| 21 | |
Niels Möller | 505945a | 2016-03-17 12:20:41 +0100 | [diff] [blame] | 22 | namespace rtc { |
| 23 | class Thread; |
| 24 | } // namespace rtc |
| 25 | |
Jon Hjelle | 7ac8bab | 2016-01-21 11:44:55 -0800 | [diff] [blame] | 26 | namespace webrtc { |
| 27 | |
Magnus Jedvert | 0bade0d | 2016-09-01 15:15:00 +0200 | [diff] [blame] | 28 | class AVFoundationVideoCapturer : public cricket::VideoCapturer { |
Jon Hjelle | 7ac8bab | 2016-01-21 11:44:55 -0800 | [diff] [blame] | 29 | public: |
| 30 | AVFoundationVideoCapturer(); |
| 31 | ~AVFoundationVideoCapturer(); |
| 32 | |
| 33 | cricket::CaptureState Start(const cricket::VideoFormat& format) override; |
| 34 | void Stop() override; |
| 35 | bool IsRunning() override; |
| 36 | bool IsScreencast() const override { |
| 37 | return false; |
| 38 | } |
| 39 | bool GetPreferredFourccs(std::vector<uint32_t> *fourccs) override { |
| 40 | fourccs->push_back(cricket::FOURCC_NV12); |
| 41 | return true; |
| 42 | } |
| 43 | |
tkchin | 89717aa | 2016-03-31 17:14:04 -0700 | [diff] [blame] | 44 | // Returns the active capture session. Calls to the capture session should |
| 45 | // occur on the RTCDispatcherTypeCaptureSession queue in RTCDispatcher. |
Jon Hjelle | 7ac8bab | 2016-01-21 11:44:55 -0800 | [diff] [blame] | 46 | AVCaptureSession* GetCaptureSession(); |
| 47 | |
tkchin | 89717aa | 2016-03-31 17:14:04 -0700 | [diff] [blame] | 48 | // Returns whether the rear-facing camera can be used. |
| 49 | // e.g. It can't be used because it doesn't exist. |
hjon | a1cf366 | 2016-03-14 20:55:22 -0700 | [diff] [blame] | 50 | bool CanUseBackCamera() const; |
| 51 | |
tkchin | 89717aa | 2016-03-31 17:14:04 -0700 | [diff] [blame] | 52 | // Switches the camera being used (either front or back). |
Jon Hjelle | 7ac8bab | 2016-01-21 11:44:55 -0800 | [diff] [blame] | 53 | void SetUseBackCamera(bool useBackCamera); |
| 54 | bool GetUseBackCamera() const; |
| 55 | |
tkchin | 89717aa | 2016-03-31 17:14:04 -0700 | [diff] [blame] | 56 | // Converts the sample buffer into a cricket::CapturedFrame and signals the |
| 57 | // frame for capture. |
magjed | 2ab012c | 2016-08-25 03:25:04 -0700 | [diff] [blame] | 58 | void CaptureSampleBuffer(CMSampleBufferRef sample_buffer, |
| 59 | webrtc::VideoRotation rotation); |
Jon Hjelle | 7ac8bab | 2016-01-21 11:44:55 -0800 | [diff] [blame] | 60 | |
| 61 | private: |
Jon Hjelle | 7ac8bab | 2016-01-21 11:44:55 -0800 | [diff] [blame] | 62 | RTCAVFoundationVideoCapturerInternal *_capturer; |
magjed | 39607c9 | 2016-07-14 08:12:17 -0700 | [diff] [blame] | 63 | webrtc::I420BufferPool _buffer_pool; |
Jon Hjelle | 7ac8bab | 2016-01-21 11:44:55 -0800 | [diff] [blame] | 64 | }; // AVFoundationVideoCapturer |
| 65 | |
| 66 | } // namespace webrtc |
| 67 | |
tkchin | 89717aa | 2016-03-31 17:14:04 -0700 | [diff] [blame] | 68 | #endif // WEBRTC_API_OBJC_AVFOUNDATION_VIDEO_CAPTURER_H_ |