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

Side by Side Diff: media/capture/video/win/video_capture_device_mf_win.cc

Issue 2824773002: Rename ScopedComPtr::get() to ScopedComPtr::Get() (Closed)
Patch Set: Update to 5293966 Created 3 years, 8 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 #include "media/capture/video/win/video_capture_device_mf_win.h" 5 #include "media/capture/video/win/video_capture_device_mf_win.h"
6 6
7 #include <mfapi.h> 7 #include <mfapi.h>
8 #include <mferror.h> 8 #include <mferror.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 10
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 } 58 }
59 59
60 HRESULT FillCapabilities(IMFSourceReader* source, 60 HRESULT FillCapabilities(IMFSourceReader* source,
61 CapabilityList* capabilities) { 61 CapabilityList* capabilities) {
62 DWORD stream_index = 0; 62 DWORD stream_index = 0;
63 ScopedComPtr<IMFMediaType> type; 63 ScopedComPtr<IMFMediaType> type;
64 HRESULT hr; 64 HRESULT hr;
65 while (SUCCEEDED(hr = source->GetNativeMediaType( 65 while (SUCCEEDED(hr = source->GetNativeMediaType(
66 kFirstVideoStream, stream_index, type.Receive()))) { 66 kFirstVideoStream, stream_index, type.Receive()))) {
67 VideoCaptureFormat format; 67 VideoCaptureFormat format;
68 if (FillFormat(type.get(), &format)) 68 if (FillFormat(type.Get(), &format))
69 capabilities->emplace_back(stream_index, format); 69 capabilities->emplace_back(stream_index, format);
70 type.Reset(); 70 type.Reset();
71 ++stream_index; 71 ++stream_index;
72 } 72 }
73 73
74 if (capabilities->empty() && (SUCCEEDED(hr) || hr == MF_E_NO_MORE_TYPES)) 74 if (capabilities->empty() && (SUCCEEDED(hr) || hr == MF_E_NO_MORE_TYPES))
75 hr = HRESULT_FROM_WIN32(ERROR_EMPTY); 75 hr = HRESULT_FROM_WIN32(ERROR_EMPTY);
76 76
77 return (hr == MF_E_NO_MORE_TYPES) ? S_OK : hr; 77 return (hr == MF_E_NO_MORE_TYPES) ? S_OK : hr;
78 } 78 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 observer_->OnIncomingCapturedData(NULL, 0, 0, reference_time, timestamp); 117 observer_->OnIncomingCapturedData(NULL, 0, 0, reference_time, timestamp);
118 return S_OK; 118 return S_OK;
119 } 119 }
120 120
121 DWORD count = 0; 121 DWORD count = 0;
122 sample->GetBufferCount(&count); 122 sample->GetBufferCount(&count);
123 123
124 for (DWORD i = 0; i < count; ++i) { 124 for (DWORD i = 0; i < count; ++i) {
125 ScopedComPtr<IMFMediaBuffer> buffer; 125 ScopedComPtr<IMFMediaBuffer> buffer;
126 sample->GetBufferByIndex(i, buffer.Receive()); 126 sample->GetBufferByIndex(i, buffer.Receive());
127 if (buffer.get()) { 127 if (buffer.Get()) {
128 DWORD length = 0, max_length = 0; 128 DWORD length = 0, max_length = 0;
129 BYTE* data = NULL; 129 BYTE* data = NULL;
130 buffer->Lock(&data, &max_length, &length); 130 buffer->Lock(&data, &max_length, &length);
131 observer_->OnIncomingCapturedData(data, length, 0, reference_time, 131 observer_->OnIncomingCapturedData(data, length, 0, reference_time,
132 timestamp); 132 timestamp);
133 buffer->Unlock(); 133 buffer->Unlock();
134 } 134 }
135 } 135 }
136 return S_OK; 136 return S_OK;
137 } 137 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 DetachFromThread(); 192 DetachFromThread();
193 } 193 }
194 194
195 VideoCaptureDeviceMFWin::~VideoCaptureDeviceMFWin() { 195 VideoCaptureDeviceMFWin::~VideoCaptureDeviceMFWin() {
196 DCHECK(CalledOnValidThread()); 196 DCHECK(CalledOnValidThread());
197 } 197 }
198 198
199 bool VideoCaptureDeviceMFWin::Init( 199 bool VideoCaptureDeviceMFWin::Init(
200 const base::win::ScopedComPtr<IMFMediaSource>& source) { 200 const base::win::ScopedComPtr<IMFMediaSource>& source) {
201 DCHECK(CalledOnValidThread()); 201 DCHECK(CalledOnValidThread());
202 DCHECK(!reader_.get()); 202 DCHECK(!reader_.Get());
203 203
204 ScopedComPtr<IMFAttributes> attributes; 204 ScopedComPtr<IMFAttributes> attributes;
205 MFCreateAttributes(attributes.Receive(), 1); 205 MFCreateAttributes(attributes.Receive(), 1);
206 DCHECK(attributes.get()); 206 DCHECK(attributes.Get());
207 207
208 callback_ = new MFReaderCallback(this); 208 callback_ = new MFReaderCallback(this);
209 attributes->SetUnknown(MF_SOURCE_READER_ASYNC_CALLBACK, callback_.get()); 209 attributes->SetUnknown(MF_SOURCE_READER_ASYNC_CALLBACK, callback_.get());
210 210
211 return SUCCEEDED(MFCreateSourceReaderFromMediaSource( 211 return SUCCEEDED(MFCreateSourceReaderFromMediaSource(
212 source.get(), attributes.get(), reader_.Receive())); 212 source.Get(), attributes.Get(), reader_.Receive()));
213 } 213 }
214 214
215 void VideoCaptureDeviceMFWin::AllocateAndStart( 215 void VideoCaptureDeviceMFWin::AllocateAndStart(
216 const VideoCaptureParams& params, 216 const VideoCaptureParams& params,
217 std::unique_ptr<VideoCaptureDevice::Client> client) { 217 std::unique_ptr<VideoCaptureDevice::Client> client) {
218 DCHECK(CalledOnValidThread()); 218 DCHECK(CalledOnValidThread());
219 219
220 base::AutoLock lock(lock_); 220 base::AutoLock lock(lock_);
221 221
222 client_ = std::move(client); 222 client_ = std::move(client);
223 DCHECK_EQ(capture_, false); 223 DCHECK_EQ(capture_, false);
224 224
225 CapabilityList capabilities; 225 CapabilityList capabilities;
226 HRESULT hr = S_OK; 226 HRESULT hr = S_OK;
227 if (reader_.get()) { 227 if (reader_.Get()) {
228 hr = FillCapabilities(reader_.get(), &capabilities); 228 hr = FillCapabilities(reader_.Get(), &capabilities);
229 if (SUCCEEDED(hr)) { 229 if (SUCCEEDED(hr)) {
230 const CapabilityWin found_capability = 230 const CapabilityWin found_capability =
231 GetBestMatchedCapability(params.requested_format, capabilities); 231 GetBestMatchedCapability(params.requested_format, capabilities);
232 ScopedComPtr<IMFMediaType> type; 232 ScopedComPtr<IMFMediaType> type;
233 hr = reader_->GetNativeMediaType( 233 hr = reader_->GetNativeMediaType(
234 kFirstVideoStream, found_capability.stream_index, type.Receive()); 234 kFirstVideoStream, found_capability.stream_index, type.Receive());
235 if (SUCCEEDED(hr)) { 235 if (SUCCEEDED(hr)) {
236 hr = reader_->SetCurrentMediaType(kFirstVideoStream, NULL, type.get()); 236 hr = reader_->SetCurrentMediaType(kFirstVideoStream, NULL, type.Get());
237 if (SUCCEEDED(hr)) { 237 if (SUCCEEDED(hr)) {
238 hr = 238 hr =
239 reader_->ReadSample(kFirstVideoStream, 0, NULL, NULL, NULL, NULL); 239 reader_->ReadSample(kFirstVideoStream, 0, NULL, NULL, NULL, NULL);
240 if (SUCCEEDED(hr)) { 240 if (SUCCEEDED(hr)) {
241 capture_format_ = found_capability.supported_format; 241 capture_format_ = found_capability.supported_format;
242 client_->OnStarted(); 242 client_->OnStarted();
243 capture_ = true; 243 capture_ = true;
244 return; 244 return;
245 } 245 }
246 } 246 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 HRESULT hr) { 311 HRESULT hr) {
312 if (client_.get()) { 312 if (client_.get()) {
313 client_->OnError( 313 client_->OnError(
314 from_here, 314 from_here,
315 base::StringPrintf("VideoCaptureDeviceMFWin: %s", 315 base::StringPrintf("VideoCaptureDeviceMFWin: %s",
316 logging::SystemErrorCodeToString(hr).c_str())); 316 logging::SystemErrorCodeToString(hr).c_str()));
317 } 317 }
318 } 318 }
319 319
320 } // namespace media 320 } // namespace media
OLDNEW
« no previous file with comments | « media/capture/video/win/video_capture_device_factory_win.cc ('k') | media/capture/video/win/video_capture_device_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698