Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(504)

Side by Side Diff: media/capture/video/mac/video_capture_device_mac.h

Issue 2169013002: Change class VideoCaptureDevice::Name to struct VideoCaptureDeviceDescriptor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactoring of VideoCaptureDeviceFactory interface Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 AVFoundation as 5 // MacOSX implementation of generic VideoCaptureDevice, using AVFoundation as
6 // native capture API. AVFoundation is available in versions 10.7 (Lion) and 6 // native capture API. AVFoundation is available in versions 10.7 (Lion) and
7 // later. 7 // later.
8 8
9 #ifndef MEDIA_CAPTURE_VIDEO_MAC_VIDEO_CAPTURE_DEVICE_MAC_H_ 9 #ifndef MEDIA_CAPTURE_VIDEO_MAC_VIDEO_CAPTURE_DEVICE_MAC_H_
10 #define MEDIA_CAPTURE_VIDEO_MAC_VIDEO_CAPTURE_DEVICE_MAC_H_ 10 #define MEDIA_CAPTURE_VIDEO_MAC_VIDEO_CAPTURE_DEVICE_MAC_H_
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 - (NSString*)deviceName; 47 - (NSString*)deviceName;
48 - (int32_t)transportType; 48 - (int32_t)transportType;
49 @end 49 @end
50 50
51 namespace media { 51 namespace media {
52 52
53 // Called by VideoCaptureManager to open, close and start, stop Mac video 53 // Called by VideoCaptureManager to open, close and start, stop Mac video
54 // capture devices. 54 // capture devices.
55 class VideoCaptureDeviceMac : public VideoCaptureDevice { 55 class VideoCaptureDeviceMac : public VideoCaptureDevice {
56 public: 56 public:
57 explicit VideoCaptureDeviceMac(const Name& device_name); 57 static std::string GetDeviceModelId(
58 const VideoCaptureDeviceDescriptor& device_descriptor);
emircan 2016/07/25 22:56:40 Move this below ctor/dtor. Also, make sure it appe
chfremer 2016/07/26 16:56:35 Done.
59
60 explicit VideoCaptureDeviceMac(
61 const VideoCaptureDeviceDescriptor& device_descriptor);
58 ~VideoCaptureDeviceMac() override; 62 ~VideoCaptureDeviceMac() override;
59 63
60 // VideoCaptureDevice implementation. 64 // VideoCaptureDevice implementation.
61 void AllocateAndStart( 65 void AllocateAndStart(
62 const VideoCaptureParams& params, 66 const VideoCaptureParams& params,
63 std::unique_ptr<VideoCaptureDevice::Client> client) override; 67 std::unique_ptr<VideoCaptureDevice::Client> client) override;
64 void StopAndDeAllocate() override; 68 void StopAndDeAllocate() override;
65 void TakePhoto(TakePhotoCallback callback) override; 69 void TakePhoto(TakePhotoCallback callback) override;
66 70
67 bool Init(VideoCaptureDevice::Name::CaptureApiType capture_api_type); 71 bool Init(VideoCaptureApiType capture_api_type);
68 72
69 // Called to deliver captured video frames. It's safe to call this method 73 // Called to deliver captured video frames. It's safe to call this method
70 // from any thread, including those controlled by AVFoundation. 74 // from any thread, including those controlled by AVFoundation.
71 void ReceiveFrame(const uint8_t* video_frame, 75 void ReceiveFrame(const uint8_t* video_frame,
72 int video_frame_length, 76 int video_frame_length,
73 const VideoCaptureFormat& frame_format, 77 const VideoCaptureFormat& frame_format,
74 int aspect_numerator, 78 int aspect_numerator,
75 int aspect_denominator, 79 int aspect_denominator,
76 base::TimeDelta timestamp); 80 base::TimeDelta timestamp);
77 81
(...skipping 12 matching lines...) Expand all
90 void LogMessage(const std::string& message); 94 void LogMessage(const std::string& message);
91 95
92 private: 96 private:
93 void SetErrorState(const tracked_objects::Location& from_here, 97 void SetErrorState(const tracked_objects::Location& from_here,
94 const std::string& reason); 98 const std::string& reason);
95 bool UpdateCaptureResolution(); 99 bool UpdateCaptureResolution();
96 100
97 // Flag indicating the internal state. 101 // Flag indicating the internal state.
98 enum InternalState { kNotInitialized, kIdle, kCapturing, kError }; 102 enum InternalState { kNotInitialized, kIdle, kCapturing, kError };
99 103
100 Name device_name_; 104 VideoCaptureDeviceDescriptor device_descriptor_;
101 std::unique_ptr<VideoCaptureDevice::Client> client_; 105 std::unique_ptr<VideoCaptureDevice::Client> client_;
102 106
103 VideoCaptureFormat capture_format_; 107 VideoCaptureFormat capture_format_;
104 108
105 // Only read and write state_ from inside this loop. 109 // Only read and write state_ from inside this loop.
106 const scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 110 const scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
107 InternalState state_; 111 InternalState state_;
108 112
109 base::scoped_nsobject<VideoCaptureDeviceAVFoundation> capture_device_; 113 base::scoped_nsobject<VideoCaptureDeviceAVFoundation> capture_device_;
110 114
111 // To hold on to the TakePhotoCallback while the picture is being taken. 115 // To hold on to the TakePhotoCallback while the picture is being taken.
112 std::unique_ptr<TakePhotoCallback> photo_callback_; 116 std::unique_ptr<TakePhotoCallback> photo_callback_;
113 117
114 // Used with Bind and PostTask to ensure that methods aren't called after the 118 // Used with Bind and PostTask to ensure that methods aren't called after the
115 // VideoCaptureDeviceMac is destroyed. 119 // VideoCaptureDeviceMac is destroyed.
116 // NOTE: Weak pointers must be invalidated before all other member variables. 120 // NOTE: Weak pointers must be invalidated before all other member variables.
117 base::WeakPtrFactory<VideoCaptureDeviceMac> weak_factory_; 121 base::WeakPtrFactory<VideoCaptureDeviceMac> weak_factory_;
118 122
119 DISALLOW_COPY_AND_ASSIGN(VideoCaptureDeviceMac); 123 DISALLOW_COPY_AND_ASSIGN(VideoCaptureDeviceMac);
120 }; 124 };
121 125
122 } // namespace media 126 } // namespace media
123 127
124 #endif // MEDIA_CAPTURE_VIDEO_MAC_VIDEO_CAPTURE_DEVICE_MAC_H_ 128 #endif // MEDIA_CAPTURE_VIDEO_MAC_VIDEO_CAPTURE_DEVICE_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698