| 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 MEDIA_CAPTURE_VIDEO_MAC_VIDEO_CAPTURE_DEVICE_AVFOUNDATION_MAC_H_ |
| 6 #define MEDIA_CAPTURE_VIDEO_MAC_VIDEO_CAPTURE_DEVICE_AVFOUNDATION_MAC_H_ | 6 #define MEDIA_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 #import "media/base/mac/avfoundation_glue.h" | 13 #import "media/base/mac/avfoundation_glue.h" |
| 14 #include "media/base/video_capture_types.h" | 14 #include "media/base/video_capture_types.h" |
| 15 #include "media/capture/video/video_capture_device.h" | 15 #include "media/capture/video/video_capture_device.h" |
| 16 | 16 |
| 17 namespace media { | 17 namespace media { |
| 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 | 25 |
| 25 // Class used by VideoCaptureDeviceMac (VCDM) for video capture using | 26 // Class used by VideoCaptureDeviceMac (VCDM) for video and image capture using |
| 26 // 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 |
| 27 // VCDM. | 28 // VCDM. |
| 28 // | 29 // |
| 29 // * Clients (VCDM) should call +deviceNames to fetch the list of devices | 30 // * Clients (VCDM) should call +deviceNames to fetch the list of devices |
| 30 // available in the system; this method returns the list of device names that | 31 // available in the system; this method returns the list of device names that |
| 31 // have to be used with -setCaptureDevice:. | 32 // have to be used with -setCaptureDevice:. |
| 32 // * Previous to any use, clients (VCDM) must call -initWithFrameReceiver: to | 33 // * Previous to any use, clients (VCDM) must call -initWithFrameReceiver: to |
| 33 // initialise an object of this class and register a |frameReceiver_|. | 34 // initialise an object of this class and register a |frameReceiver_|. |
| 34 // * Frame receiver registration or removal can also happen via explicit call | 35 // * Frame receiver registration or removal can also happen via explicit call |
| 35 // to -setFrameReceiver:. Re-registrations are safe and allowed, even during | 36 // to -setFrameReceiver:. Re-registrations are safe and allowed, even during |
| (...skipping 19 matching lines...) Expand all Loading... |
| 55 // | 56 // |
| 56 // | 57 // |
| 57 @interface VideoCaptureDeviceAVFoundation | 58 @interface VideoCaptureDeviceAVFoundation |
| 58 : NSObject<CrAVCaptureVideoDataOutputSampleBufferDelegate> { | 59 : NSObject<CrAVCaptureVideoDataOutputSampleBufferDelegate> { |
| 59 @private | 60 @private |
| 60 // The following attributes are set via -setCaptureHeight:width:frameRate:. | 61 // The following attributes are set via -setCaptureHeight:width:frameRate:. |
| 61 int frameWidth_; | 62 int frameWidth_; |
| 62 int frameHeight_; | 63 int frameHeight_; |
| 63 float frameRate_; | 64 float frameRate_; |
| 64 | 65 |
| 65 base::Lock lock_; // Protects concurrent setting and using of frameReceiver_. | 66 base::Lock lock_; // Protects concurrent setting and using |frameReceiver_|. |
| 66 media::VideoCaptureDeviceMac* frameReceiver_; // weak. | 67 media::VideoCaptureDeviceMac* frameReceiver_; // weak. |
| 67 | 68 |
| 68 base::scoped_nsobject<CrAVCaptureSession> captureSession_; | 69 base::scoped_nsobject<CrAVCaptureSession> captureSession_; |
| 69 | 70 |
| 70 // |captureDevice_| is an object coming from AVFoundation, used only to be | 71 // |captureDevice_| is an object coming from AVFoundation, used only to be |
| 71 // plugged in |captureDeviceInput_| and to query for session preset support. | 72 // plugged in |captureDeviceInput_| and to query for session preset support. |
| 72 CrAVCaptureDevice* captureDevice_; | 73 CrAVCaptureDevice* captureDevice_; |
| 73 // |captureDeviceInput_| is owned by |captureSession_|. | 74 // |captureDeviceInput_| is owned by |captureSession_|. |
| 74 CrAVCaptureDeviceInput* captureDeviceInput_; | 75 CrAVCaptureDeviceInput* captureDeviceInput_; |
| 75 base::scoped_nsobject<CrAVCaptureVideoDataOutput> captureVideoDataOutput_; | 76 base::scoped_nsobject<CrAVCaptureVideoDataOutput> captureVideoDataOutput_; |
| 76 | 77 |
| 78 // An AVDataOutput specialized for taking pictures out of |captureSession_|. |
| 79 base::scoped_nsobject<CrAVCaptureStillImageOutput> stillImageOutput_; |
| 80 |
| 77 base::ThreadChecker main_thread_checker_; | 81 base::ThreadChecker main_thread_checker_; |
| 78 } | 82 } |
| 79 | 83 |
| 80 // 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. |
| 81 + (NSDictionary*)deviceNames; | 85 + (NSDictionary*)deviceNames; |
| 82 | 86 |
| 83 // Retrieve the capture supported formats for a given device |name|. | 87 // Retrieve the capture supported formats for a given device |name|. |
| 84 + (void)getDevice:(const media::VideoCaptureDevice::Name&)name | 88 + (void)getDevice:(const media::VideoCaptureDevice::Name&)name |
| 85 supportedFormats:(media::VideoCaptureFormats*)formats; | 89 supportedFormats:(media::VideoCaptureFormats*)formats; |
| 86 | 90 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 107 frameRate:(float)frameRate; | 111 frameRate:(float)frameRate; |
| 108 | 112 |
| 109 // Starts video capturing and register the notification listeners. Must be | 113 // Starts video capturing and register the notification listeners. Must be |
| 110 // called after setCaptureDevice:, and, eventually, also after | 114 // called after setCaptureDevice:, and, eventually, also after |
| 111 // setCaptureHeight:width:frameRate:. Returns YES on success, NO otherwise. | 115 // setCaptureHeight:width:frameRate:. Returns YES on success, NO otherwise. |
| 112 - (BOOL)startCapture; | 116 - (BOOL)startCapture; |
| 113 | 117 |
| 114 // Stops video capturing and stops listening to notifications. | 118 // Stops video capturing and stops listening to notifications. |
| 115 - (void)stopCapture; | 119 - (void)stopCapture; |
| 116 | 120 |
| 121 // Takes a photo. This method should only be called between -startCapture and |
| 122 // -stopCapture. |
| 123 - (void)takePhoto; |
| 124 |
| 117 @end | 125 @end |
| 118 | 126 |
| 119 #endif // MEDIA_CAPTURE_VIDEO_MAC_VIDEO_CAPTURE_DEVICE_AVFOUNDATION_MAC_H_ | 127 #endif // MEDIA_CAPTURE_VIDEO_MAC_VIDEO_CAPTURE_DEVICE_AVFOUNDATION_MAC_H_ |
| OLD | NEW |