| OLD | NEW |
| (Empty) |
| 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 | |
| 14 #include "webrtc/base/scoped_ptr.h" | |
| 15 #include "webrtc/media/base/videocapturer.h" | |
| 16 #include "webrtc/video_frame.h" | |
| 17 | |
| 18 #import <AVFoundation/AVFoundation.h> | |
| 19 | |
| 20 @class RTCAVFoundationVideoCapturerInternal; | |
| 21 | |
| 22 namespace rtc { | |
| 23 class Thread; | |
| 24 } // namespace rtc | |
| 25 | |
| 26 namespace webrtc { | |
| 27 | |
| 28 class AVFoundationVideoCapturer : public cricket::VideoCapturer, | |
| 29 public rtc::MessageHandler { | |
| 30 public: | |
| 31 AVFoundationVideoCapturer(); | |
| 32 ~AVFoundationVideoCapturer(); | |
| 33 | |
| 34 cricket::CaptureState Start(const cricket::VideoFormat& format) override; | |
| 35 void Stop() override; | |
| 36 bool IsRunning() override; | |
| 37 bool IsScreencast() const override { | |
| 38 return false; | |
| 39 } | |
| 40 bool GetPreferredFourccs(std::vector<uint32_t> *fourccs) override { | |
| 41 fourccs->push_back(cricket::FOURCC_NV12); | |
| 42 return true; | |
| 43 } | |
| 44 | |
| 45 // Returns the active capture session. Calls to the capture session should | |
| 46 // occur on the RTCDispatcherTypeCaptureSession queue in RTCDispatcher. | |
| 47 AVCaptureSession* GetCaptureSession(); | |
| 48 | |
| 49 // Returns whether the rear-facing camera can be used. | |
| 50 // e.g. It can't be used because it doesn't exist. | |
| 51 bool CanUseBackCamera() const; | |
| 52 | |
| 53 // Switches the camera being used (either front or back). | |
| 54 void SetUseBackCamera(bool useBackCamera); | |
| 55 bool GetUseBackCamera() const; | |
| 56 | |
| 57 // Converts the sample buffer into a cricket::CapturedFrame and signals the | |
| 58 // frame for capture. | |
| 59 void CaptureSampleBuffer(CMSampleBufferRef sampleBuffer); | |
| 60 | |
| 61 // Handles messages from posts. | |
| 62 void OnMessage(rtc::Message *msg) override; | |
| 63 | |
| 64 private: | |
| 65 void OnFrameMessage(CVImageBufferRef image_buffer, int64_t capture_time); | |
| 66 | |
| 67 RTCAVFoundationVideoCapturerInternal *_capturer; | |
| 68 rtc::Thread *_startThread; // Set in Start(), unset in Stop(). | |
| 69 }; // AVFoundationVideoCapturer | |
| 70 | |
| 71 } // namespace webrtc | |
| 72 | |
| 73 #endif // WEBRTC_API_OBJC_AVFOUNDATION_VIDEO_CAPTURER_H_ | |
| OLD | NEW |