2016-01-21 11:44:55 -08:00
|
|
|
/*
|
|
|
|
|
* Copyright 2015 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef SDK_OBJC_FRAMEWORK_CLASSES_VIDEO_AVFOUNDATIONVIDEOCAPTURER_H_
|
|
|
|
|
#define SDK_OBJC_FRAMEWORK_CLASSES_VIDEO_AVFOUNDATIONVIDEOCAPTURER_H_
|
2016-01-21 11:44:55 -08:00
|
|
|
|
2016-04-27 01:54:20 -07:00
|
|
|
#import <AVFoundation/AVFoundation.h>
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "api/video/video_frame.h"
|
|
|
|
|
#include "common_video/include/i420_buffer_pool.h"
|
|
|
|
|
#include "media/base/videocapturer.h"
|
2016-01-21 11:44:55 -08:00
|
|
|
|
|
|
|
|
@class RTCAVFoundationVideoCapturerInternal;
|
|
|
|
|
|
2016-03-17 12:20:41 +01:00
|
|
|
namespace rtc {
|
|
|
|
|
class Thread;
|
|
|
|
|
} // namespace rtc
|
|
|
|
|
|
2016-01-21 11:44:55 -08:00
|
|
|
namespace webrtc {
|
|
|
|
|
|
2016-09-01 15:15:00 +02:00
|
|
|
class AVFoundationVideoCapturer : public cricket::VideoCapturer {
|
2016-01-21 11:44:55 -08:00
|
|
|
public:
|
|
|
|
|
AVFoundationVideoCapturer();
|
|
|
|
|
~AVFoundationVideoCapturer();
|
|
|
|
|
|
|
|
|
|
cricket::CaptureState Start(const cricket::VideoFormat& format) override;
|
|
|
|
|
void Stop() override;
|
|
|
|
|
bool IsRunning() override;
|
|
|
|
|
bool IsScreencast() const override {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
bool GetPreferredFourccs(std::vector<uint32_t> *fourccs) override {
|
|
|
|
|
fourccs->push_back(cricket::FOURCC_NV12);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-31 17:14:04 -07:00
|
|
|
// Returns the active capture session. Calls to the capture session should
|
|
|
|
|
// occur on the RTCDispatcherTypeCaptureSession queue in RTCDispatcher.
|
2016-01-21 11:44:55 -08:00
|
|
|
AVCaptureSession* GetCaptureSession();
|
|
|
|
|
|
2016-03-31 17:14:04 -07:00
|
|
|
// Returns whether the rear-facing camera can be used.
|
|
|
|
|
// e.g. It can't be used because it doesn't exist.
|
2016-03-14 20:55:22 -07:00
|
|
|
bool CanUseBackCamera() const;
|
|
|
|
|
|
2016-03-31 17:14:04 -07:00
|
|
|
// Switches the camera being used (either front or back).
|
2016-01-21 11:44:55 -08:00
|
|
|
void SetUseBackCamera(bool useBackCamera);
|
|
|
|
|
bool GetUseBackCamera() const;
|
|
|
|
|
|
2016-03-31 17:14:04 -07:00
|
|
|
// Converts the sample buffer into a cricket::CapturedFrame and signals the
|
|
|
|
|
// frame for capture.
|
2016-08-25 03:25:04 -07:00
|
|
|
void CaptureSampleBuffer(CMSampleBufferRef sample_buffer,
|
|
|
|
|
webrtc::VideoRotation rotation);
|
2016-01-21 11:44:55 -08:00
|
|
|
|
2016-12-01 01:36:16 -08:00
|
|
|
// Called to adjust the size of output frames to supplied |width| and
|
|
|
|
|
// |height|. Also drops frames to make the output match |fps|.
|
|
|
|
|
void AdaptOutputFormat(int width, int height, int fps);
|
|
|
|
|
|
2016-01-21 11:44:55 -08:00
|
|
|
private:
|
|
|
|
|
RTCAVFoundationVideoCapturerInternal *_capturer;
|
2016-07-14 08:12:17 -07:00
|
|
|
webrtc::I420BufferPool _buffer_pool;
|
2016-01-21 11:44:55 -08:00
|
|
|
}; // AVFoundationVideoCapturer
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // SDK_OBJC_FRAMEWORK_CLASSES_VIDEO_AVFOUNDATIONVIDEOCAPTURER_H_
|