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

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

Issue 512713002: VideoCaptureDeviceWin: correct some typos and docs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 ScopedComPtr<IBaseFilter> capture_filter; 46 ScopedComPtr<IBaseFilter> capture_filter;
47 DWORD fetched = 0; 47 DWORD fetched = 0;
48 while (enum_moniker->Next(1, moniker.Receive(), &fetched) == S_OK) { 48 while (enum_moniker->Next(1, moniker.Receive(), &fetched) == S_OK) {
49 ScopedComPtr<IPropertyBag> prop_bag; 49 ScopedComPtr<IPropertyBag> prop_bag;
50 hr = moniker->BindToStorage(0, 0, IID_IPropertyBag, prop_bag.ReceiveVoid()); 50 hr = moniker->BindToStorage(0, 0, IID_IPropertyBag, prop_bag.ReceiveVoid());
51 if (FAILED(hr)) { 51 if (FAILED(hr)) {
52 moniker.Release(); 52 moniker.Release();
53 continue; 53 continue;
54 } 54 }
55 55
56 // Find the description or friendly name. 56 // Find the device via DevicePath, Description or FriendlyName, whichever is
57 // available first.
57 static const wchar_t* kPropertyNames[] = { 58 static const wchar_t* kPropertyNames[] = {
58 L"DevicePath", L"Description", L"FriendlyName" 59 L"DevicePath", L"Description", L"FriendlyName"
59 }; 60 };
60 ScopedVariant name; 61 ScopedVariant name;
61 for (size_t i = 0; 62 for (size_t i = 0;
62 i < arraysize(kPropertyNames) && name.type() != VT_BSTR; ++i) { 63 i < arraysize(kPropertyNames) && name.type() != VT_BSTR; ++i) {
63 prop_bag->Read(kPropertyNames[i], name.Receive(), 0); 64 prop_bag->Read(kPropertyNames[i], name.Receive(), 0);
64 } 65 }
65 if (name.type() == VT_BSTR) { 66 if (name.type() == VT_BSTR) {
66 std::string device_path(base::SysWideToUTF8(V_BSTR(&name))); 67 std::string device_path(base::SysWideToUTF8(V_BSTR(&name)));
(...skipping 27 matching lines...) Expand all
94 DWORD return_value; 95 DWORD return_value;
95 hr = ks_property->Get(AMPROPSETID_Pin, AMPROPERTY_PIN_CATEGORY, NULL, 0, 96 hr = ks_property->Get(AMPROPSETID_Pin, AMPROPERTY_PIN_CATEGORY, NULL, 0,
96 &pin_category, sizeof(pin_category), &return_value); 97 &pin_category, sizeof(pin_category), &return_value);
97 if (SUCCEEDED(hr) && (return_value == sizeof(pin_category))) { 98 if (SUCCEEDED(hr) && (return_value == sizeof(pin_category))) {
98 found = (pin_category == category); 99 found = (pin_category == category);
99 } 100 }
100 } 101 }
101 return found; 102 return found;
102 } 103 }
103 104
104 // Finds a IPin on a IBaseFilter given the direction an category. 105 // Finds an IPin on an IBaseFilter given the direction and category.
105 // static 106 // static
106 ScopedComPtr<IPin> VideoCaptureDeviceWin::GetPin(IBaseFilter* filter, 107 ScopedComPtr<IPin> VideoCaptureDeviceWin::GetPin(IBaseFilter* filter,
107 PIN_DIRECTION pin_dir, 108 PIN_DIRECTION pin_dir,
108 REFGUID category) { 109 REFGUID category) {
109 ScopedComPtr<IPin> pin; 110 ScopedComPtr<IPin> pin;
110 ScopedComPtr<IEnumPins> pin_emum; 111 ScopedComPtr<IEnumPins> pin_enum;
111 HRESULT hr = filter->EnumPins(pin_emum.Receive()); 112 HRESULT hr = filter->EnumPins(pin_enum.Receive());
112 if (pin_emum == NULL) 113 if (pin_enum == NULL)
113 return pin; 114 return pin;
114 115
115 // Get first unconnected pin. 116 // Get first unconnected pin.
116 hr = pin_emum->Reset(); // set to first pin 117 hr = pin_enum->Reset(); // set to first pin
117 while ((hr = pin_emum->Next(1, pin.Receive(), NULL)) == S_OK) { 118 while ((hr = pin_enum->Next(1, pin.Receive(), NULL)) == S_OK) {
118 PIN_DIRECTION this_pin_dir = static_cast<PIN_DIRECTION>(-1); 119 PIN_DIRECTION this_pin_dir = static_cast<PIN_DIRECTION>(-1);
119 hr = pin->QueryDirection(&this_pin_dir); 120 hr = pin->QueryDirection(&this_pin_dir);
120 if (pin_dir == this_pin_dir) { 121 if (pin_dir == this_pin_dir) {
121 if (category == GUID_NULL || PinMatchesCategory(pin, category)) 122 if (category == GUID_NULL || PinMatchesCategory(pin, category))
122 return pin; 123 return pin;
123 } 124 }
124 pin.Release(); 125 pin.Release();
125 } 126 }
126 127
127 DCHECK(!pin); 128 DCHECK(!pin);
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 } 552 }
552 } 553 }
553 554
554 void VideoCaptureDeviceWin::SetErrorState(const std::string& reason) { 555 void VideoCaptureDeviceWin::SetErrorState(const std::string& reason) {
555 DCHECK(CalledOnValidThread()); 556 DCHECK(CalledOnValidThread());
556 DVLOG(1) << reason; 557 DVLOG(1) << reason;
557 state_ = kError; 558 state_ = kError;
558 client_->OnError(reason); 559 client_->OnError(reason);
559 } 560 }
560 } // namespace media 561 } // 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