blob: 83ee70385e554ea53c2fcfcde77d1a6d5e31eed0 [file] [log] [blame]
Jon Hjelle7ac8bab2016-01-21 11:44:55 -08001/*
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
Jon Hjelle7ac8bab2016-01-21 11:44:55 -080014#include "webrtc/base/scoped_ptr.h"
kjellandera96e2d72016-02-04 23:52:28 -080015#include "webrtc/media/base/videocapturer.h"
Jon Hjelle7ac8bab2016-01-21 11:44:55 -080016#include "webrtc/video_frame.h"
17
18#import <AVFoundation/AVFoundation.h>
19
20@class RTCAVFoundationVideoCapturerInternal;
21
22namespace webrtc {
23
24class AVFoundationVideoCapturer : public cricket::VideoCapturer {
25 public:
26 AVFoundationVideoCapturer();
27 ~AVFoundationVideoCapturer();
28
29 cricket::CaptureState Start(const cricket::VideoFormat& format) override;
30 void Stop() override;
31 bool IsRunning() override;
32 bool IsScreencast() const override {
33 return false;
34 }
35 bool GetPreferredFourccs(std::vector<uint32_t> *fourccs) override {
36 fourccs->push_back(cricket::FOURCC_NV12);
37 return true;
38 }
39
40 /** Returns the active capture session. */
41 AVCaptureSession* GetCaptureSession();
42
hjona1cf3662016-03-14 20:55:22 -070043 /**
44 * Returns whether the rear-facing camera can be used.
45 * e.g. It can't be used because it doesn't exist.
46 */
47 bool CanUseBackCamera() const;
48
Jon Hjelle7ac8bab2016-01-21 11:44:55 -080049 /** Switches the camera being used (either front or back). */
50 void SetUseBackCamera(bool useBackCamera);
51 bool GetUseBackCamera() const;
52
53 /**
54 * Converts the sample buffer into a cricket::CapturedFrame and signals the
55 * frame for capture.
56 */
57 void CaptureSampleBuffer(CMSampleBufferRef sampleBuffer);
58
59 private:
60 /**
61 * Used to signal frame capture on the thread that capturer was started on.
62 */
63 void SignalFrameCapturedOnStartThread(const cricket::CapturedFrame *frame);
64
65 RTCAVFoundationVideoCapturerInternal *_capturer;
66 rtc::Thread *_startThread; // Set in Start(), unset in Stop().
67}; // AVFoundationVideoCapturer
68
69} // namespace webrtc
70
71#endif // TALK_APP_WEBRTC_OBJC_AVFOUNDATION_CAPTURER_H_