From 497a73fa07e3b6d62e009abbe85d057c6f0a778c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Tue, 15 Dec 2015 13:52:56 +0100 Subject: [PATCH] getUserMedia(): invoke errback if video constraints were not satisfied (related to #107) --- src/PluginGetUserMedia.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/PluginGetUserMedia.swift b/src/PluginGetUserMedia.swift index ad48f89d..a2c76ffa 100644 --- a/src/PluginGetUserMedia.swift +++ b/src/PluginGetUserMedia.swift @@ -147,6 +147,15 @@ class PluginGetUserMedia { constraints: constraints ) + // If videoSource state is "ended" it means that constraints were not satisfied so + // invoke the given errback + if (rtcVideoSource!.state == RTCSourceStateEnded) { + NSLog("PluginGetUserMedia() | rtcVideoSource.state is 'ended', constraints not satisfied") + + errback(error: "constraints not satisfied") + return + } + rtcVideoTrack = self.rtcPeerConnectionFactory.videoTrackWithID(NSUUID().UUIDString, source: rtcVideoSource )