Add guards to VideoCaptureDS::Init for when pins are null

GetInputPin() and GetOutputPin() do not guarantee returning non-null pins.
Should either of them return null during Init() we're better off returning an
error than allowing unsafe behavior further ahead.

Bug: webrtc:9941
Change-Id: I25858f0555334b4ef99801f83454931384695bf6
Reviewed-on: https://webrtc-review.googlesource.com/c/108603
Reviewed-by: Per Kjellander <perkj@webrtc.org>
Commit-Queue: Per Kjellander <perkj@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25475}
This commit is contained in:
Andreas Pehrson
2018-10-30 16:31:34 +01:00
committed by Commit Bot
parent 9b5b070817
commit 58df0ada6e

View File

@ -95,6 +95,10 @@ int32_t VideoCaptureDS::Init(const char* deviceUniqueIdUTF8) {
}
_outputCapturePin = GetOutputPin(_captureFilter, PIN_CATEGORY_CAPTURE);
if (!_outputCapturePin) {
RTC_LOG(LS_INFO) << "Failed to get output capture pin";
return -1;
}
// Create the sink filte used for receiving Captured frames.
_sinkFilter = new CaptureSinkFilter(SINK_FILTER_NAME, NULL, &hr, *this);
@ -109,7 +113,12 @@ int32_t VideoCaptureDS::Init(const char* deviceUniqueIdUTF8) {
RTC_LOG(LS_INFO) << "Failed to add the send filter to the graph.";
return -1;
}
_inputSendPin = GetInputPin(_sinkFilter);
if (!_inputSendPin) {
RTC_LOG(LS_INFO) << "Failed to get input send pin";
return -1;
}
// Temporary connect here.
// This is done so that no one else can use the capture device.