| 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 #import "media/capture/video/mac/platform_video_capturing_mac.h" | |
| 16 #include "media/capture/video/video_capture_device.h" | 15 #include "media/capture/video/video_capture_device.h" |
| 17 | 16 |
| 18 namespace media { | 17 namespace media { |
| 19 class VideoCaptureDeviceMac; | 18 class VideoCaptureDeviceMac; |
| 20 } | 19 } |
| 21 | 20 |
| 22 @class CrAVCaptureDevice; | 21 @class CrAVCaptureDevice; |
| 23 @class CrAVCaptureSession; | 22 @class CrAVCaptureSession; |
| 24 @class CrAVCaptureVideoDataOutput; | 23 @class CrAVCaptureVideoDataOutput; |
| 25 | 24 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 49 // restarted and restoped multiple times, reconfiguring or not the device in | 48 // restarted and restoped multiple times, reconfiguring or not the device in |
| 50 // between. | 49 // between. |
| 51 // * -setCaptureDevice can be called with a |nil| value, case in which it stops | 50 // * -setCaptureDevice can be called with a |nil| value, case in which it stops |
| 52 // the capture and disconnects the library objects. This step is not | 51 // the capture and disconnects the library objects. This step is not |
| 53 // necessary. | 52 // necessary. |
| 54 // * Deallocation of the library objects happens gracefully on destruction of | 53 // * Deallocation of the library objects happens gracefully on destruction of |
| 55 // the VideoCaptureDeviceAVFoundation object. | 54 // the VideoCaptureDeviceAVFoundation object. |
| 56 // | 55 // |
| 57 // | 56 // |
| 58 @interface VideoCaptureDeviceAVFoundation | 57 @interface VideoCaptureDeviceAVFoundation |
| 59 : NSObject<CrAVCaptureVideoDataOutputSampleBufferDelegate, | 58 : NSObject<CrAVCaptureVideoDataOutputSampleBufferDelegate> { |
| 60 PlatformVideoCapturingMac> { | |
| 61 @private | 59 @private |
| 62 // The following attributes are set via -setCaptureHeight:width:frameRate:. | 60 // The following attributes are set via -setCaptureHeight:width:frameRate:. |
| 63 int frameWidth_; | 61 int frameWidth_; |
| 64 int frameHeight_; | 62 int frameHeight_; |
| 65 float frameRate_; | 63 float frameRate_; |
| 66 | 64 |
| 67 base::Lock lock_; // Protects concurrent setting and using of frameReceiver_. | 65 base::Lock lock_; // Protects concurrent setting and using of frameReceiver_. |
| 68 media::VideoCaptureDeviceMac* frameReceiver_; // weak. | 66 media::VideoCaptureDeviceMac* frameReceiver_; // weak. |
| 69 | 67 |
| 70 base::scoped_nsobject<CrAVCaptureSession> captureSession_; | 68 base::scoped_nsobject<CrAVCaptureSession> captureSession_; |
| 71 | 69 |
| 72 // |captureDevice_| is an object coming from AVFoundation, used only to be | 70 // |captureDevice_| is an object coming from AVFoundation, used only to be |
| 73 // plugged in |captureDeviceInput_| and to query for session preset support. | 71 // plugged in |captureDeviceInput_| and to query for session preset support. |
| 74 CrAVCaptureDevice* captureDevice_; | 72 CrAVCaptureDevice* captureDevice_; |
| 75 // |captureDeviceInput_| is owned by |captureSession_|. | 73 // |captureDeviceInput_| is owned by |captureSession_|. |
| 76 CrAVCaptureDeviceInput* captureDeviceInput_; | 74 CrAVCaptureDeviceInput* captureDeviceInput_; |
| 77 base::scoped_nsobject<CrAVCaptureVideoDataOutput> captureVideoDataOutput_; | 75 base::scoped_nsobject<CrAVCaptureVideoDataOutput> captureVideoDataOutput_; |
| 78 | 76 |
| 79 base::ThreadChecker main_thread_checker_; | 77 base::ThreadChecker main_thread_checker_; |
| 80 base::ThreadChecker callback_thread_checker_; | |
| 81 } | 78 } |
| 82 | 79 |
| 83 // Returns a dictionary of capture devices with friendly name and unique id. | 80 // Returns a dictionary of capture devices with friendly name and unique id. |
| 84 + (NSDictionary*)deviceNames; | 81 + (NSDictionary*)deviceNames; |
| 85 | 82 |
| 86 // Retrieve the capture supported formats for a given device |name|. | 83 // Retrieve the capture supported formats for a given device |name|. |
| 87 + (void)getDevice:(const media::VideoCaptureDevice::Name&)name | 84 + (void)getDevice:(const media::VideoCaptureDevice::Name&)name |
| 88 supportedFormats:(media::VideoCaptureFormats*)formats; | 85 supportedFormats:(media::VideoCaptureFormats*)formats; |
| 89 | 86 |
| 90 // Initializes the instance and the underlying capture session and registers the | 87 // Initializes the instance and the underlying capture session and registers the |
| (...skipping 22 matching lines...) Expand all Loading... |
| 113 // called after setCaptureDevice:, and, eventually, also after | 110 // called after setCaptureDevice:, and, eventually, also after |
| 114 // setCaptureHeight:width:frameRate:. Returns YES on success, NO otherwise. | 111 // setCaptureHeight:width:frameRate:. Returns YES on success, NO otherwise. |
| 115 - (BOOL)startCapture; | 112 - (BOOL)startCapture; |
| 116 | 113 |
| 117 // Stops video capturing and stops listening to notifications. | 114 // Stops video capturing and stops listening to notifications. |
| 118 - (void)stopCapture; | 115 - (void)stopCapture; |
| 119 | 116 |
| 120 @end | 117 @end |
| 121 | 118 |
| 122 #endif // MEDIA_CAPTURE_VIDEO_MAC_VIDEO_CAPTURE_DEVICE_AVFOUNDATION_MAC_H_ | 119 #endif // MEDIA_CAPTURE_VIDEO_MAC_VIDEO_CAPTURE_DEVICE_AVFOUNDATION_MAC_H_ |
| OLD | NEW |