| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // MacOSX implementation of generic VideoCaptureDevice, using either QTKit or | 5 // MacOSX implementation of generic VideoCaptureDevice, using AVFoundation as |
| 6 // AVFoundation as native capture API. QTKit is available in all OSX versions, | 6 // native capture API. AVFoundation is available in versions 10.7 (Lion) and |
| 7 // although namely deprecated in 10.9, and AVFoundation is available in versions | 7 // later. |
| 8 // 10.7 (Lion) and later. | |
| 9 | 8 |
| 10 #ifndef MEDIA_VIDEO_CAPTURE_MAC_VIDEO_CAPTURE_DEVICE_MAC_H_ | 9 #ifndef MEDIA_VIDEO_CAPTURE_MAC_VIDEO_CAPTURE_DEVICE_MAC_H_ |
| 11 #define MEDIA_VIDEO_CAPTURE_MAC_VIDEO_CAPTURE_DEVICE_MAC_H_ | 10 #define MEDIA_VIDEO_CAPTURE_MAC_VIDEO_CAPTURE_DEVICE_MAC_H_ |
| 12 | 11 |
| 13 #import <Foundation/Foundation.h> | 12 #import <Foundation/Foundation.h> |
| 14 #include <stdint.h> | 13 #include <stdint.h> |
| 15 | 14 |
| 16 #include <string> | 15 #include <string> |
| 17 | 16 |
| 18 #include "base/compiler_specific.h" | 17 #include "base/compiler_specific.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 44 } | 43 } |
| 45 | 44 |
| 46 - (id)initWithName:(NSString*)name transportType:(int32_t)transportType; | 45 - (id)initWithName:(NSString*)name transportType:(int32_t)transportType; |
| 47 | 46 |
| 48 - (NSString*)deviceName; | 47 - (NSString*)deviceName; |
| 49 - (int32_t)transportType; | 48 - (int32_t)transportType; |
| 50 @end | 49 @end |
| 51 | 50 |
| 52 namespace media { | 51 namespace media { |
| 53 | 52 |
| 54 enum { | |
| 55 // Unknown transport type, addition to the kIOAudioDeviceTransportType* | |
| 56 // family for QTKit devices where this attribute isn't published. | |
| 57 kIOAudioDeviceTransportTypeUnknown = 'unkn' | |
| 58 }; | |
| 59 | |
| 60 // Called by VideoCaptureManager to open, close and start, stop Mac video | 53 // Called by VideoCaptureManager to open, close and start, stop Mac video |
| 61 // capture devices. | 54 // capture devices. |
| 62 class VideoCaptureDeviceMac : public VideoCaptureDevice { | 55 class VideoCaptureDeviceMac : public VideoCaptureDevice { |
| 63 public: | 56 public: |
| 64 explicit VideoCaptureDeviceMac(const Name& device_name); | 57 explicit VideoCaptureDeviceMac(const Name& device_name); |
| 65 ~VideoCaptureDeviceMac() override; | 58 ~VideoCaptureDeviceMac() override; |
| 66 | 59 |
| 67 // VideoCaptureDevice implementation. | 60 // VideoCaptureDevice implementation. |
| 68 void AllocateAndStart(const VideoCaptureParams& params, | 61 void AllocateAndStart(const VideoCaptureParams& params, |
| 69 scoped_ptr<VideoCaptureDevice::Client> client) override; | 62 scoped_ptr<VideoCaptureDevice::Client> client) override; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 91 const std::string& reason); | 84 const std::string& reason); |
| 92 bool UpdateCaptureResolution(); | 85 bool UpdateCaptureResolution(); |
| 93 | 86 |
| 94 // Flag indicating the internal state. | 87 // Flag indicating the internal state. |
| 95 enum InternalState { kNotInitialized, kIdle, kCapturing, kError }; | 88 enum InternalState { kNotInitialized, kIdle, kCapturing, kError }; |
| 96 | 89 |
| 97 Name device_name_; | 90 Name device_name_; |
| 98 scoped_ptr<VideoCaptureDevice::Client> client_; | 91 scoped_ptr<VideoCaptureDevice::Client> client_; |
| 99 | 92 |
| 100 VideoCaptureFormat capture_format_; | 93 VideoCaptureFormat capture_format_; |
| 101 // These variables control the two-step configure-start process for QTKit HD: | |
| 102 // the device is first started with no configuration and the captured frames | |
| 103 // are inspected to check if the camera really supports HD. AVFoundation does | |
| 104 // not need this process so |final_resolution_selected_| is false then. | |
| 105 bool final_resolution_selected_; | |
| 106 bool tried_to_square_pixels_; | |
| 107 | 94 |
| 108 // Only read and write state_ from inside this loop. | 95 // Only read and write state_ from inside this loop. |
| 109 const scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 96 const scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 110 InternalState state_; | 97 InternalState state_; |
| 111 | 98 |
| 112 id<PlatformVideoCapturingMac> capture_device_; | 99 id<PlatformVideoCapturingMac> capture_device_; |
| 113 | 100 |
| 114 base::TimeDelta first_timestamp_; | 101 base::TimeDelta first_timestamp_; |
| 115 base::TimeTicks first_aligned_timestamp_; | 102 base::TimeTicks first_aligned_timestamp_; |
| 116 | 103 |
| 117 // Used with Bind and PostTask to ensure that methods aren't called after the | 104 // Used with Bind and PostTask to ensure that methods aren't called after the |
| 118 // VideoCaptureDeviceMac is destroyed. | 105 // VideoCaptureDeviceMac is destroyed. |
| 119 // NOTE: Weak pointers must be invalidated before all other member variables. | 106 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 120 base::WeakPtrFactory<VideoCaptureDeviceMac> weak_factory_; | 107 base::WeakPtrFactory<VideoCaptureDeviceMac> weak_factory_; |
| 121 | 108 |
| 122 DISALLOW_COPY_AND_ASSIGN(VideoCaptureDeviceMac); | 109 DISALLOW_COPY_AND_ASSIGN(VideoCaptureDeviceMac); |
| 123 }; | 110 }; |
| 124 | 111 |
| 125 } // namespace media | 112 } // namespace media |
| 126 | 113 |
| 127 #endif // MEDIA_VIDEO_CAPTURE_MAC_VIDEO_CAPTURE_DEVICE_MAC_H_ | 114 #endif // MEDIA_VIDEO_CAPTURE_MAC_VIDEO_CAPTURE_DEVICE_MAC_H_ |
| OLD | NEW |