niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
xians@webrtc.org | 843c8c7 | 2012-02-20 08:45:02 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
pbos@webrtc.org | a9b74ad | 2013-07-12 10:03:52 +0000 | [diff] [blame] | 11 | #include "webrtc/modules/video_capture/windows/video_capture_ds.h" |
perkj@webrtc.org | 0cc68dc | 2011-09-12 08:53:36 +0000 | [diff] [blame] | 12 | |
pbos@webrtc.org | a9b74ad | 2013-07-12 10:03:52 +0000 | [diff] [blame] | 13 | #include "webrtc/modules/video_capture/video_capture_config.h" |
| 14 | #include "webrtc/modules/video_capture/windows/help_functions_ds.h" |
| 15 | #include "webrtc/modules/video_capture/windows/sink_filter_ds.h" |
Sam Zackrisson | dcbb66f | 2017-08-08 12:00:28 +0200 | [diff] [blame] | 16 | #include "webrtc/rtc_base/logging.h" |
perkj@webrtc.org | 0cc68dc | 2011-09-12 08:53:36 +0000 | [diff] [blame] | 17 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 18 | #include <Dvdmedia.h> // VIDEOINFOHEADER2 |
| 19 | |
| 20 | namespace webrtc |
| 21 | { |
| 22 | namespace videocapturemodule |
| 23 | { |
nisse | b29b9c8 | 2016-12-12 00:22:56 -0800 | [diff] [blame] | 24 | VideoCaptureDS::VideoCaptureDS() |
| 25 | : _captureFilter(NULL), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 26 | _graphBuilder(NULL), _mediaControl(NULL), _sinkFilter(NULL), |
mflodman@webrtc.org | 8df2600 | 2012-02-24 10:06:30 +0000 | [diff] [blame] | 27 | _inputSendPin(NULL), _outputCapturePin(NULL), _dvFilter(NULL), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 28 | _inputDvPin(NULL), _outputDvPin(NULL) |
| 29 | { |
| 30 | } |
| 31 | |
| 32 | VideoCaptureDS::~VideoCaptureDS() |
| 33 | { |
| 34 | if (_mediaControl) |
| 35 | { |
| 36 | _mediaControl->Stop(); |
| 37 | } |
| 38 | if (_graphBuilder) |
| 39 | { |
| 40 | if (_sinkFilter) |
| 41 | _graphBuilder->RemoveFilter(_sinkFilter); |
| 42 | if (_captureFilter) |
| 43 | _graphBuilder->RemoveFilter(_captureFilter); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 44 | if (_dvFilter) |
| 45 | _graphBuilder->RemoveFilter(_dvFilter); |
| 46 | } |
braveyao@webrtc.org | 651c05e | 2014-10-13 02:11:55 +0000 | [diff] [blame] | 47 | RELEASE_AND_CLEAR(_inputSendPin); |
| 48 | RELEASE_AND_CLEAR(_outputCapturePin); |
| 49 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 50 | RELEASE_AND_CLEAR(_captureFilter); // release the capture device |
| 51 | RELEASE_AND_CLEAR(_sinkFilter); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 52 | RELEASE_AND_CLEAR(_dvFilter); |
| 53 | |
| 54 | RELEASE_AND_CLEAR(_mediaControl); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 55 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 56 | RELEASE_AND_CLEAR(_inputDvPin); |
| 57 | RELEASE_AND_CLEAR(_outputDvPin); |
| 58 | |
| 59 | RELEASE_AND_CLEAR(_graphBuilder); |
| 60 | } |
| 61 | |
nisse | b29b9c8 | 2016-12-12 00:22:56 -0800 | [diff] [blame] | 62 | int32_t VideoCaptureDS::Init(const char* deviceUniqueIdUTF8) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 63 | { |
pbos@webrtc.org | dfc5bb9 | 2013-04-10 08:23:13 +0000 | [diff] [blame] | 64 | const int32_t nameLength = |
| 65 | (int32_t) strlen((char*) deviceUniqueIdUTF8); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 66 | if (nameLength > kVideoCaptureUniqueNameLength) |
| 67 | return -1; |
| 68 | |
| 69 | // Store the device name |
leozwang@webrtc.org | 4add6bc | 2012-03-01 19:57:13 +0000 | [diff] [blame] | 70 | _deviceUniqueId = new (std::nothrow) char[nameLength + 1]; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 71 | memcpy(_deviceUniqueId, deviceUniqueIdUTF8, nameLength + 1); |
| 72 | |
| 73 | if (_dsInfo.Init() != 0) |
| 74 | return -1; |
| 75 | |
| 76 | _captureFilter = _dsInfo.GetDeviceFilter(deviceUniqueIdUTF8); |
| 77 | if (!_captureFilter) |
| 78 | { |
Sam Zackrisson | dcbb66f | 2017-08-08 12:00:28 +0200 | [diff] [blame] | 79 | LOG(LS_INFO) << "Failed to create capture filter."; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 80 | return -1; |
| 81 | } |
| 82 | |
| 83 | // Get the interface for DirectShow's GraphBuilder |
| 84 | HRESULT hr = CoCreateInstance(CLSID_FilterGraph, NULL, |
| 85 | CLSCTX_INPROC_SERVER, IID_IGraphBuilder, |
| 86 | (void **) &_graphBuilder); |
| 87 | if (FAILED(hr)) |
| 88 | { |
Sam Zackrisson | dcbb66f | 2017-08-08 12:00:28 +0200 | [diff] [blame] | 89 | LOG(LS_INFO) << "Failed to create graph builder."; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 90 | return -1; |
| 91 | } |
| 92 | |
| 93 | hr = _graphBuilder->QueryInterface(IID_IMediaControl, |
| 94 | (void **) &_mediaControl); |
| 95 | if (FAILED(hr)) |
| 96 | { |
Sam Zackrisson | dcbb66f | 2017-08-08 12:00:28 +0200 | [diff] [blame] | 97 | LOG(LS_INFO) << "Failed to create media control builder."; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 98 | return -1; |
| 99 | } |
| 100 | hr = _graphBuilder->AddFilter(_captureFilter, CAPTURE_FILTER_NAME); |
| 101 | if (FAILED(hr)) |
| 102 | { |
Sam Zackrisson | dcbb66f | 2017-08-08 12:00:28 +0200 | [diff] [blame] | 103 | LOG(LS_INFO) << "Failed to add the capture device to the graph."; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 104 | return -1; |
| 105 | } |
| 106 | |
| 107 | _outputCapturePin = GetOutputPin(_captureFilter, PIN_CATEGORY_CAPTURE); |
| 108 | |
| 109 | // Create the sink filte used for receiving Captured frames. |
| 110 | _sinkFilter = new CaptureSinkFilter(SINK_FILTER_NAME, NULL, &hr, |
nisse | b29b9c8 | 2016-12-12 00:22:56 -0800 | [diff] [blame] | 111 | *this); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 112 | if (hr != S_OK) |
| 113 | { |
Sam Zackrisson | dcbb66f | 2017-08-08 12:00:28 +0200 | [diff] [blame] | 114 | LOG(LS_INFO) << "Failed to create send filter"; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 115 | return -1; |
| 116 | } |
| 117 | _sinkFilter->AddRef(); |
| 118 | |
| 119 | hr = _graphBuilder->AddFilter(_sinkFilter, SINK_FILTER_NAME); |
| 120 | if (FAILED(hr)) |
| 121 | { |
Sam Zackrisson | dcbb66f | 2017-08-08 12:00:28 +0200 | [diff] [blame] | 122 | LOG(LS_INFO) << "Failed to add the send filter to the graph."; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 123 | return -1; |
| 124 | } |
| 125 | _inputSendPin = GetInputPin(_sinkFilter); |
| 126 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 127 | // Temporary connect here. |
| 128 | // This is done so that no one else can use the capture device. |
| 129 | if (SetCameraOutput(_requestedCapability) != 0) |
| 130 | { |
| 131 | return -1; |
| 132 | } |
| 133 | hr = _mediaControl->Pause(); |
| 134 | if (FAILED(hr)) |
| 135 | { |
Sam Zackrisson | dcbb66f | 2017-08-08 12:00:28 +0200 | [diff] [blame] | 136 | LOG(LS_INFO) |
| 137 | << "Failed to Pause the Capture device. Is it already occupied? " |
| 138 | << hr; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 139 | return -1; |
| 140 | } |
Sam Zackrisson | dcbb66f | 2017-08-08 12:00:28 +0200 | [diff] [blame] | 141 | LOG(LS_INFO) << "Capture device '" << deviceUniqueIdUTF8 |
| 142 | << "' initialized."; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 143 | return 0; |
| 144 | } |
| 145 | |
pbos@webrtc.org | dfc5bb9 | 2013-04-10 08:23:13 +0000 | [diff] [blame] | 146 | int32_t VideoCaptureDS::StartCapture( |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 147 | const VideoCaptureCapability& capability) |
| 148 | { |
kthelgason | ff046c7 | 2017-03-31 02:03:55 -0700 | [diff] [blame] | 149 | rtc::CritScope cs(&_apiCs); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 150 | |
| 151 | if (capability != _requestedCapability) |
| 152 | { |
| 153 | DisconnectGraph(); |
| 154 | |
| 155 | if (SetCameraOutput(capability) != 0) |
| 156 | { |
| 157 | return -1; |
| 158 | } |
| 159 | } |
| 160 | HRESULT hr = _mediaControl->Run(); |
| 161 | if (FAILED(hr)) |
| 162 | { |
Sam Zackrisson | dcbb66f | 2017-08-08 12:00:28 +0200 | [diff] [blame] | 163 | LOG(LS_INFO) << "Failed to start the Capture device."; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 164 | return -1; |
| 165 | } |
| 166 | return 0; |
| 167 | } |
| 168 | |
pbos@webrtc.org | dfc5bb9 | 2013-04-10 08:23:13 +0000 | [diff] [blame] | 169 | int32_t VideoCaptureDS::StopCapture() |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 170 | { |
kthelgason | ff046c7 | 2017-03-31 02:03:55 -0700 | [diff] [blame] | 171 | rtc::CritScope cs(&_apiCs); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 172 | |
| 173 | HRESULT hr = _mediaControl->Pause(); |
| 174 | if (FAILED(hr)) |
| 175 | { |
Sam Zackrisson | dcbb66f | 2017-08-08 12:00:28 +0200 | [diff] [blame] | 176 | LOG(LS_INFO) << "Failed to stop the capture graph. " << hr; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 177 | return -1; |
| 178 | } |
| 179 | return 0; |
| 180 | } |
| 181 | bool VideoCaptureDS::CaptureStarted() |
| 182 | { |
| 183 | OAFilterState state = 0; |
| 184 | HRESULT hr = _mediaControl->GetState(1000, &state); |
| 185 | if (hr != S_OK && hr != VFW_S_CANT_CUE) |
| 186 | { |
Sam Zackrisson | dcbb66f | 2017-08-08 12:00:28 +0200 | [diff] [blame] | 187 | LOG(LS_INFO) << "Failed to get the CaptureStarted status"; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 188 | } |
Sam Zackrisson | dcbb66f | 2017-08-08 12:00:28 +0200 | [diff] [blame] | 189 | LOG(LS_INFO) << "CaptureStarted " << state; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 190 | return state == State_Running; |
| 191 | |
| 192 | } |
pbos@webrtc.org | dfc5bb9 | 2013-04-10 08:23:13 +0000 | [diff] [blame] | 193 | int32_t VideoCaptureDS::CaptureSettings( |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 194 | VideoCaptureCapability& settings) |
| 195 | { |
| 196 | settings = _requestedCapability; |
| 197 | return 0; |
| 198 | } |
| 199 | |
pbos@webrtc.org | dfc5bb9 | 2013-04-10 08:23:13 +0000 | [diff] [blame] | 200 | int32_t VideoCaptureDS::SetCameraOutput( |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 201 | const VideoCaptureCapability& requestedCapability) |
| 202 | { |
| 203 | |
| 204 | // Get the best matching capability |
| 205 | VideoCaptureCapability capability; |
pbos@webrtc.org | dfc5bb9 | 2013-04-10 08:23:13 +0000 | [diff] [blame] | 206 | int32_t capabilityIndex; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 207 | |
| 208 | // Store the new requested size |
| 209 | _requestedCapability = requestedCapability; |
| 210 | // Match the requested capability with the supported. |
| 211 | if ((capabilityIndex = _dsInfo.GetBestMatchedCapability(_deviceUniqueId, |
| 212 | _requestedCapability, |
| 213 | capability)) < 0) |
| 214 | { |
| 215 | return -1; |
| 216 | } |
| 217 | //Reduce the frame rate if possible. |
| 218 | if (capability.maxFPS > requestedCapability.maxFPS) |
| 219 | { |
| 220 | capability.maxFPS = requestedCapability.maxFPS; |
braveyao@webrtc.org | ad69ca7 | 2012-07-25 03:02:15 +0000 | [diff] [blame] | 221 | } else if (capability.maxFPS <= 0) |
| 222 | { |
| 223 | capability.maxFPS = 30; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 224 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 225 | |
| 226 | // Convert it to the windows capability index since they are not nexessary |
| 227 | // the same |
| 228 | VideoCaptureCapabilityWindows windowsCapability; |
| 229 | if (_dsInfo.GetWindowsCapability(capabilityIndex, windowsCapability) != 0) |
| 230 | { |
| 231 | return -1; |
| 232 | } |
| 233 | |
| 234 | IAMStreamConfig* streamConfig = NULL; |
| 235 | AM_MEDIA_TYPE *pmt = NULL; |
| 236 | VIDEO_STREAM_CONFIG_CAPS caps; |
| 237 | |
| 238 | HRESULT hr = _outputCapturePin->QueryInterface(IID_IAMStreamConfig, |
| 239 | (void**) &streamConfig); |
| 240 | if (hr) |
| 241 | { |
Sam Zackrisson | dcbb66f | 2017-08-08 12:00:28 +0200 | [diff] [blame] | 242 | LOG(LS_INFO) << "Can't get the Capture format settings."; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 243 | return -1; |
| 244 | } |
| 245 | |
| 246 | //Get the windows capability from the capture device |
| 247 | bool isDVCamera = false; |
| 248 | hr = streamConfig->GetStreamCaps( |
| 249 | windowsCapability.directShowCapabilityIndex, |
| 250 | &pmt, reinterpret_cast<BYTE*> (&caps)); |
| 251 | if (!FAILED(hr)) |
| 252 | { |
| 253 | if (pmt->formattype == FORMAT_VideoInfo2) |
| 254 | { |
| 255 | VIDEOINFOHEADER2* h = |
| 256 | reinterpret_cast<VIDEOINFOHEADER2*> (pmt->pbFormat); |
| 257 | if (capability.maxFPS > 0 |
| 258 | && windowsCapability.supportFrameRateControl) |
| 259 | { |
| 260 | h->AvgTimePerFrame = REFERENCE_TIME(10000000.0 |
| 261 | / capability.maxFPS); |
| 262 | } |
| 263 | } |
| 264 | else |
| 265 | { |
| 266 | VIDEOINFOHEADER* h = reinterpret_cast<VIDEOINFOHEADER*> |
| 267 | (pmt->pbFormat); |
| 268 | if (capability.maxFPS > 0 |
| 269 | && windowsCapability.supportFrameRateControl) |
| 270 | { |
| 271 | h->AvgTimePerFrame = REFERENCE_TIME(10000000.0 |
| 272 | / capability.maxFPS); |
| 273 | } |
| 274 | |
| 275 | } |
| 276 | |
| 277 | // Set the sink filter to request this capability |
| 278 | _sinkFilter->SetMatchingMediaType(capability); |
| 279 | //Order the capture device to use this capability |
| 280 | hr += streamConfig->SetFormat(pmt); |
| 281 | |
| 282 | //Check if this is a DV camera and we need to add MS DV Filter |
| 283 | if (pmt->subtype == MEDIASUBTYPE_dvsl |
| 284 | || pmt->subtype == MEDIASUBTYPE_dvsd |
| 285 | || pmt->subtype == MEDIASUBTYPE_dvhd) |
| 286 | isDVCamera = true; // This is a DV camera. Use MS DV filter |
| 287 | } |
| 288 | RELEASE_AND_CLEAR(streamConfig); |
| 289 | |
| 290 | if (FAILED(hr)) |
| 291 | { |
Sam Zackrisson | dcbb66f | 2017-08-08 12:00:28 +0200 | [diff] [blame] | 292 | LOG(LS_INFO) << "Failed to set capture device output format"; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 293 | return -1; |
| 294 | } |
| 295 | |
mflodman@webrtc.org | 8df2600 | 2012-02-24 10:06:30 +0000 | [diff] [blame] | 296 | if (isDVCamera) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 297 | { |
| 298 | hr = ConnectDVCamera(); |
| 299 | } |
| 300 | else |
| 301 | { |
| 302 | hr = _graphBuilder->ConnectDirect(_outputCapturePin, _inputSendPin, |
| 303 | NULL); |
| 304 | } |
| 305 | if (hr != S_OK) |
| 306 | { |
Sam Zackrisson | dcbb66f | 2017-08-08 12:00:28 +0200 | [diff] [blame] | 307 | LOG(LS_INFO) << "Failed to connect the Capture graph " << hr; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 308 | return -1; |
| 309 | } |
| 310 | return 0; |
| 311 | } |
| 312 | |
pbos@webrtc.org | dfc5bb9 | 2013-04-10 08:23:13 +0000 | [diff] [blame] | 313 | int32_t VideoCaptureDS::DisconnectGraph() |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 314 | { |
| 315 | HRESULT hr = _mediaControl->Stop(); |
| 316 | hr += _graphBuilder->Disconnect(_outputCapturePin); |
| 317 | hr += _graphBuilder->Disconnect(_inputSendPin); |
| 318 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 319 | //if the DV camera filter exist |
| 320 | if (_dvFilter) |
| 321 | { |
| 322 | _graphBuilder->Disconnect(_inputDvPin); |
| 323 | _graphBuilder->Disconnect(_outputDvPin); |
| 324 | } |
| 325 | if (hr != S_OK) |
| 326 | { |
Sam Zackrisson | dcbb66f | 2017-08-08 12:00:28 +0200 | [diff] [blame] | 327 | LOG(LS_ERROR) |
| 328 | << "Failed to Stop the Capture device for reconfiguration " |
| 329 | << hr; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 330 | return -1; |
| 331 | } |
| 332 | return 0; |
| 333 | } |
| 334 | HRESULT VideoCaptureDS::ConnectDVCamera() |
| 335 | { |
| 336 | HRESULT hr = S_OK; |
| 337 | |
| 338 | if (!_dvFilter) |
| 339 | { |
| 340 | hr = CoCreateInstance(CLSID_DVVideoCodec, NULL, CLSCTX_INPROC, |
| 341 | IID_IBaseFilter, (void **) &_dvFilter); |
| 342 | if (hr != S_OK) |
| 343 | { |
Sam Zackrisson | dcbb66f | 2017-08-08 12:00:28 +0200 | [diff] [blame] | 344 | LOG(LS_INFO) << "Failed to create the dv decoder: " << hr; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 345 | return hr; |
| 346 | } |
| 347 | hr = _graphBuilder->AddFilter(_dvFilter, L"VideoDecoderDV"); |
| 348 | if (hr != S_OK) |
| 349 | { |
Sam Zackrisson | dcbb66f | 2017-08-08 12:00:28 +0200 | [diff] [blame] | 350 | LOG(LS_INFO) << "Failed to add the dv decoder to the graph: " << hr; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 351 | return hr; |
| 352 | } |
| 353 | _inputDvPin = GetInputPin(_dvFilter); |
| 354 | if (_inputDvPin == NULL) |
| 355 | { |
Sam Zackrisson | dcbb66f | 2017-08-08 12:00:28 +0200 | [diff] [blame] | 356 | LOG(LS_INFO) << "Failed to get input pin from DV decoder"; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 357 | return -1; |
| 358 | } |
tommi@webrtc.org | 8187877 | 2012-11-20 13:35:33 +0000 | [diff] [blame] | 359 | _outputDvPin = GetOutputPin(_dvFilter, GUID_NULL); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 360 | if (_outputDvPin == NULL) |
| 361 | { |
Sam Zackrisson | dcbb66f | 2017-08-08 12:00:28 +0200 | [diff] [blame] | 362 | LOG(LS_INFO) << "Failed to get output pin from DV decoder"; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 363 | return -1; |
| 364 | } |
| 365 | } |
| 366 | hr = _graphBuilder->ConnectDirect(_outputCapturePin, _inputDvPin, NULL); |
| 367 | if (hr != S_OK) |
| 368 | { |
Sam Zackrisson | dcbb66f | 2017-08-08 12:00:28 +0200 | [diff] [blame] | 369 | LOG(LS_INFO) << "Failed to connect capture device to the dv devoder: " |
| 370 | << hr; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 371 | return hr; |
| 372 | } |
| 373 | |
| 374 | hr = _graphBuilder->ConnectDirect(_outputDvPin, _inputSendPin, NULL); |
| 375 | if (hr != S_OK) |
| 376 | { |
kjellander | 73674f8 | 2016-01-19 05:49:18 -0800 | [diff] [blame] | 377 | if (hr == HRESULT_FROM_WIN32(ERROR_TOO_MANY_OPEN_FILES)) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 378 | { |
Sam Zackrisson | dcbb66f | 2017-08-08 12:00:28 +0200 | [diff] [blame] | 379 | LOG(LS_INFO) << "Failed to connect the capture device, busy"; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 380 | } |
| 381 | else |
| 382 | { |
Sam Zackrisson | dcbb66f | 2017-08-08 12:00:28 +0200 | [diff] [blame] | 383 | LOG(LS_INFO) |
| 384 | << "Failed to connect capture device to the send graph: " |
| 385 | << hr; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 386 | } |
| 387 | return hr; |
| 388 | } |
| 389 | return hr; |
| 390 | } |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 391 | } // namespace videocapturemodule |
| 392 | } // namespace webrtc |