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

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

Issue 482413002: Fix some error states in VideoCaptureDeviceWin::AllocateAndStart. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Final fix. Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/video/capture/win/video_capture_device_win.h" 5 #include "media/video/capture/win/video_capture_device_win.h"
6 6
7 #include <ks.h> 7 #include <ks.h>
8 #include <ksmedia.h> 8 #include <ksmedia.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 hr = stream_config->GetNumberOfCapabilities(&count, &size); 305 hr = stream_config->GetNumberOfCapabilities(&count, &size);
306 if (FAILED(hr)) { 306 if (FAILED(hr)) {
307 SetErrorState("Failed to GetNumberOfCapabilities"); 307 SetErrorState("Failed to GetNumberOfCapabilities");
308 return; 308 return;
309 } 309 }
310 310
311 scoped_ptr<BYTE[]> caps(new BYTE[size]); 311 scoped_ptr<BYTE[]> caps(new BYTE[size]);
312 ScopedMediaType media_type; 312 ScopedMediaType media_type;
313 313
314 // Get the windows capability from the capture device. 314 // Get the windows capability from the capture device.
315 // GetStreamCaps can return S_FALSE which we consider an error. Therefore the
316 // FAILED macro can't be used.
315 hr = stream_config->GetStreamCaps( 317 hr = stream_config->GetStreamCaps(
316 found_capability.stream_index, media_type.Receive(), caps.get()); 318 found_capability.stream_index, media_type.Receive(), caps.get());
317 if (SUCCEEDED(hr)) { 319 if (hr != S_OK) {
320 SetErrorState("Failed to get capture device capabilities");
321 return;
322 } else {
318 if (media_type->formattype == FORMAT_VideoInfo) { 323 if (media_type->formattype == FORMAT_VideoInfo) {
319 VIDEOINFOHEADER* h = 324 VIDEOINFOHEADER* h =
320 reinterpret_cast<VIDEOINFOHEADER*>(media_type->pbFormat); 325 reinterpret_cast<VIDEOINFOHEADER*>(media_type->pbFormat);
321 if (format.frame_rate > 0) 326 if (format.frame_rate > 0)
322 h->AvgTimePerFrame = kSecondsToReferenceTime / format.frame_rate; 327 h->AvgTimePerFrame = kSecondsToReferenceTime / format.frame_rate;
323 } 328 }
324 // Set the sink filter to request this format. 329 // Set the sink filter to request this format.
325 sink_filter_->SetRequestedMediaFormat(format); 330 sink_filter_->SetRequestedMediaFormat(format);
326 // Order the capture device to use this format. 331 // Order the capture device to use this format.
327 hr = stream_config->SetFormat(media_type.get()); 332 hr = stream_config->SetFormat(media_type.get());
333 if (FAILED(hr)) {
334 // TODO(grunell): Log the error. http://crbug.com/405016.
335 SetErrorState("Failed to set capture device output format");
336 return;
337 }
328 } 338 }
329 339
330 if (FAILED(hr))
331 SetErrorState("Failed to set capture device output format");
332
333 if (format.pixel_format == PIXEL_FORMAT_MJPEG && !mjpg_filter_.get()) { 340 if (format.pixel_format == PIXEL_FORMAT_MJPEG && !mjpg_filter_.get()) {
334 // Create MJPG filter if we need it. 341 // Create MJPG filter if we need it.
335 hr = mjpg_filter_.CreateInstance(CLSID_MjpegDec, NULL, CLSCTX_INPROC); 342 hr = mjpg_filter_.CreateInstance(CLSID_MjpegDec, NULL, CLSCTX_INPROC);
336 343
337 if (SUCCEEDED(hr)) { 344 if (SUCCEEDED(hr)) {
338 input_mjpg_pin_ = GetPin(mjpg_filter_, PINDIR_INPUT, GUID_NULL); 345 input_mjpg_pin_ = GetPin(mjpg_filter_, PINDIR_INPUT, GUID_NULL);
339 output_mjpg_pin_ = GetPin(mjpg_filter_, PINDIR_OUTPUT, GUID_NULL); 346 output_mjpg_pin_ = GetPin(mjpg_filter_, PINDIR_OUTPUT, GUID_NULL);
340 hr = graph_builder_->AddFilter(mjpg_filter_, NULL); 347 hr = graph_builder_->AddFilter(mjpg_filter_, NULL);
341 } 348 }
342 349
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 } 551 }
545 } 552 }
546 553
547 void VideoCaptureDeviceWin::SetErrorState(const std::string& reason) { 554 void VideoCaptureDeviceWin::SetErrorState(const std::string& reason) {
548 DCHECK(CalledOnValidThread()); 555 DCHECK(CalledOnValidThread());
549 DVLOG(1) << reason; 556 DVLOG(1) << reason;
550 state_ = kError; 557 state_ = kError;
551 client_->OnError(reason); 558 client_->OnError(reason);
552 } 559 }
553 } // namespace media 560 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698