| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MEDIA_CAPTURE_VIDEO_MAC_VIDEO_CAPTURE_DEVICE_AVFOUNDATION_MAC_H_ | 5 #ifndef DEVICE_CAPTURE_VIDEO_MAC_VIDEO_CAPTURE_DEVICE_AVFOUNDATION_MAC_H_ |
| 6 #define MEDIA_CAPTURE_VIDEO_MAC_VIDEO_CAPTURE_DEVICE_AVFOUNDATION_MAC_H_ | 6 #define DEVICE_CAPTURE_VIDEO_MAC_VIDEO_CAPTURE_DEVICE_AVFOUNDATION_MAC_H_ |
| 7 | 7 |
| 8 #import <Foundation/Foundation.h> | 8 #import <Foundation/Foundation.h> |
| 9 | 9 |
| 10 #import "base/mac/scoped_nsobject.h" | 10 #import "base/mac/scoped_nsobject.h" |
| 11 #include "base/synchronization/lock.h" | 11 #include "base/synchronization/lock.h" |
| 12 #include "base/threading/thread_checker.h" | 12 #include "base/threading/thread_checker.h" |
| 13 #include "device/capture/video/video_capture_device.h" |
| 13 #import "media/base/mac/avfoundation_glue.h" | 14 #import "media/base/mac/avfoundation_glue.h" |
| 14 #include "media/base/video_capture_types.h" | 15 #include "media/base/video_capture_types.h" |
| 15 #include "media/capture/video/video_capture_device.h" | |
| 16 | 16 |
| 17 namespace media { | 17 namespace device { |
| 18 class VideoCaptureDeviceMac; | 18 class VideoCaptureDeviceMac; |
| 19 } | 19 } |
| 20 | 20 |
| 21 @class CrAVCaptureDevice; | 21 @class CrAVCaptureDevice; |
| 22 @class CrAVCaptureSession; | 22 @class CrAVCaptureSession; |
| 23 @class CrAVCaptureVideoDataOutput; | 23 @class CrAVCaptureVideoDataOutput; |
| 24 @class CrAVCaptureStillImageOutput; | 24 @class CrAVCaptureStillImageOutput; |
| 25 | 25 |
| 26 // Class used by VideoCaptureDeviceMac (VCDM) for video and image capture using | 26 // Class used by VideoCaptureDeviceMac (VCDM) for video and image capture using |
| 27 // AVFoundation API. This class lives inside the thread created by its owner | 27 // AVFoundation API. This class lives inside the thread created by its owner |
| (...skipping 29 matching lines...) Expand all Loading... |
| 57 // | 57 // |
| 58 @interface VideoCaptureDeviceAVFoundation | 58 @interface VideoCaptureDeviceAVFoundation |
| 59 : NSObject<CrAVCaptureVideoDataOutputSampleBufferDelegate> { | 59 : NSObject<CrAVCaptureVideoDataOutputSampleBufferDelegate> { |
| 60 @private | 60 @private |
| 61 // The following attributes are set via -setCaptureHeight:width:frameRate:. | 61 // The following attributes are set via -setCaptureHeight:width:frameRate:. |
| 62 int frameWidth_; | 62 int frameWidth_; |
| 63 int frameHeight_; | 63 int frameHeight_; |
| 64 float frameRate_; | 64 float frameRate_; |
| 65 | 65 |
| 66 base::Lock lock_; // Protects concurrent setting and using |frameReceiver_|. | 66 base::Lock lock_; // Protects concurrent setting and using |frameReceiver_|. |
| 67 media::VideoCaptureDeviceMac* frameReceiver_; // weak. | 67 device::VideoCaptureDeviceMac* frameReceiver_; // weak. |
| 68 | 68 |
| 69 base::scoped_nsobject<CrAVCaptureSession> captureSession_; | 69 base::scoped_nsobject<CrAVCaptureSession> captureSession_; |
| 70 | 70 |
| 71 // |captureDevice_| is an object coming from AVFoundation, used only to be | 71 // |captureDevice_| is an object coming from AVFoundation, used only to be |
| 72 // plugged in |captureDeviceInput_| and to query for session preset support. | 72 // plugged in |captureDeviceInput_| and to query for session preset support. |
| 73 CrAVCaptureDevice* captureDevice_; | 73 CrAVCaptureDevice* captureDevice_; |
| 74 // |captureDeviceInput_| is owned by |captureSession_|. | 74 // |captureDeviceInput_| is owned by |captureSession_|. |
| 75 CrAVCaptureDeviceInput* captureDeviceInput_; | 75 CrAVCaptureDeviceInput* captureDeviceInput_; |
| 76 base::scoped_nsobject<CrAVCaptureVideoDataOutput> captureVideoDataOutput_; | 76 base::scoped_nsobject<CrAVCaptureVideoDataOutput> captureVideoDataOutput_; |
| 77 | 77 |
| 78 // An AVDataOutput specialized for taking pictures out of |captureSession_|. | 78 // An AVDataOutput specialized for taking pictures out of |captureSession_|. |
| 79 base::scoped_nsobject<CrAVCaptureStillImageOutput> stillImageOutput_; | 79 base::scoped_nsobject<CrAVCaptureStillImageOutput> stillImageOutput_; |
| 80 | 80 |
| 81 base::ThreadChecker main_thread_checker_; | 81 base::ThreadChecker main_thread_checker_; |
| 82 } | 82 } |
| 83 | 83 |
| 84 // Returns a dictionary of capture devices with friendly name and unique id. | 84 // Returns a dictionary of capture devices with friendly name and unique id. |
| 85 + (NSDictionary*)deviceNames; | 85 + (NSDictionary*)deviceNames; |
| 86 | 86 |
| 87 // Retrieve the capture supported formats for a given device |descriptor|. | 87 // Retrieve the capture supported formats for a given device |descriptor|. |
| 88 + (void)getDevice:(const media::VideoCaptureDeviceDescriptor&)descriptor | 88 + (void)getDevice:(const device::VideoCaptureDeviceDescriptor&)descriptor |
| 89 supportedFormats:(media::VideoCaptureFormats*)formats; | 89 supportedFormats:(media::VideoCaptureFormats*)formats; |
| 90 | 90 |
| 91 // Initializes the instance and the underlying capture session and registers the | 91 // Initializes the instance and the underlying capture session and registers the |
| 92 // frame receiver. | 92 // frame receiver. |
| 93 - (id)initWithFrameReceiver:(media::VideoCaptureDeviceMac*)frameReceiver; | 93 - (id)initWithFrameReceiver:(device::VideoCaptureDeviceMac*)frameReceiver; |
| 94 | 94 |
| 95 // Sets the frame receiver. | 95 // Sets the frame receiver. |
| 96 - (void)setFrameReceiver:(media::VideoCaptureDeviceMac*)frameReceiver; | 96 - (void)setFrameReceiver:(device::VideoCaptureDeviceMac*)frameReceiver; |
| 97 | 97 |
| 98 // Sets which capture device to use by name, retrieved via |deviceNames|. Once | 98 // Sets which capture device to use by name, retrieved via |deviceNames|. Once |
| 99 // the deviceId is known, the library objects are created if needed and | 99 // the deviceId is known, the library objects are created if needed and |
| 100 // connected for the capture, and a by default resolution is set. If deviceId is | 100 // connected for the capture, and a by default resolution is set. If deviceId is |
| 101 // nil, then the eventual capture is stopped and library objects are | 101 // nil, then the eventual capture is stopped and library objects are |
| 102 // disconnected. Returns YES on success, NO otherwise. This method should not be | 102 // disconnected. Returns YES on success, NO otherwise. This method should not be |
| 103 // called during capture. | 103 // called during capture. |
| 104 - (BOOL)setCaptureDevice:(NSString*)deviceId; | 104 - (BOOL)setCaptureDevice:(NSString*)deviceId; |
| 105 | 105 |
| 106 // Configures the capture properties for the capture session and the video data | 106 // Configures the capture properties for the capture session and the video data |
| (...skipping 10 matching lines...) Expand all Loading... |
| 117 | 117 |
| 118 // Stops video capturing and stops listening to notifications. | 118 // Stops video capturing and stops listening to notifications. |
| 119 - (void)stopCapture; | 119 - (void)stopCapture; |
| 120 | 120 |
| 121 // Takes a photo. This method should only be called between -startCapture and | 121 // Takes a photo. This method should only be called between -startCapture and |
| 122 // -stopCapture. | 122 // -stopCapture. |
| 123 - (void)takePhoto; | 123 - (void)takePhoto; |
| 124 | 124 |
| 125 @end | 125 @end |
| 126 | 126 |
| 127 #endif // MEDIA_CAPTURE_VIDEO_MAC_VIDEO_CAPTURE_DEVICE_AVFOUNDATION_MAC_H_ | 127 #endif // DEVICE_CAPTURE_VIDEO_MAC_VIDEO_CAPTURE_DEVICE_AVFOUNDATION_MAC_H_ |
| OLD | NEW |