Fix iOS8 crash in background mode.
Add system version check functionality in UIDevice+RTCDevice category.
Check for iOS system version when handle capture session interruption.

BUG=webrtc:7201

Review-Url: https://codereview.webrtc.org/2733773003
Cr-Commit-Position: refs/heads/master@{#17079}
diff --git a/AUTHORS b/AUTHORS
index e014bfb..fb8965b 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -12,6 +12,7 @@
 Christophe Dumez <ch.dumez@samsung.com>
 Cody Barnes <conceptgenesis@gmail.com>
 Colin Plumb
+Dmitry Lizin <sdkdimon@gmail.com>
 Eric Rescorla, RTFM Inc. <ekr@rtfm.com>
 Frederik Riedel, Frogg GmbH <frederik.riedel@frogg.io>
 Giji Gangadharan <giji.g@samsung.com>
diff --git a/webrtc/sdk/objc/Framework/Classes/RTCAVFoundationVideoCapturerInternal.mm b/webrtc/sdk/objc/Framework/Classes/RTCAVFoundationVideoCapturerInternal.mm
index 5c276fc..166a609 100644
--- a/webrtc/sdk/objc/Framework/Classes/RTCAVFoundationVideoCapturerInternal.mm
+++ b/webrtc/sdk/objc/Framework/Classes/RTCAVFoundationVideoCapturerInternal.mm
@@ -13,6 +13,7 @@
 #import <Foundation/Foundation.h>
 #if TARGET_OS_IPHONE
 #import <UIKit/UIKit.h>
+#import "WebRTC/UIDevice+RTCDevice.h"
 #endif
 
 #import "RTCDispatcher+Private.h"
@@ -232,21 +233,23 @@
   NSString *reasonString = nil;
 #if defined(__IPHONE_9_0) && defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && \
     __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_9_0
-  NSNumber *reason = notification.userInfo[AVCaptureSessionInterruptionReasonKey];
-  if (reason) {
-    switch (reason.intValue) {
-      case AVCaptureSessionInterruptionReasonVideoDeviceNotAvailableInBackground:
-        reasonString = @"VideoDeviceNotAvailableInBackground";
-        break;
-      case AVCaptureSessionInterruptionReasonAudioDeviceInUseByAnotherClient:
-        reasonString = @"AudioDeviceInUseByAnotherClient";
-        break;
-      case AVCaptureSessionInterruptionReasonVideoDeviceInUseByAnotherClient:
-        reasonString = @"VideoDeviceInUseByAnotherClient";
-        break;
-      case AVCaptureSessionInterruptionReasonVideoDeviceNotAvailableWithMultipleForegroundApps:
-        reasonString = @"VideoDeviceNotAvailableWithMultipleForegroundApps";
-        break;
+  if ([UIDevice isIOS9OrLater]) {
+    NSNumber *reason = notification.userInfo[AVCaptureSessionInterruptionReasonKey];
+    if (reason) {
+      switch (reason.intValue) {
+        case AVCaptureSessionInterruptionReasonVideoDeviceNotAvailableInBackground:
+          reasonString = @"VideoDeviceNotAvailableInBackground";
+          break;
+        case AVCaptureSessionInterruptionReasonAudioDeviceInUseByAnotherClient:
+          reasonString = @"AudioDeviceInUseByAnotherClient";
+          break;
+        case AVCaptureSessionInterruptionReasonVideoDeviceInUseByAnotherClient:
+          reasonString = @"VideoDeviceInUseByAnotherClient";
+          break;
+        case AVCaptureSessionInterruptionReasonVideoDeviceNotAvailableWithMultipleForegroundApps:
+          reasonString = @"VideoDeviceNotAvailableWithMultipleForegroundApps";
+          break;
+      }
     }
   }
 #endif
diff --git a/webrtc/sdk/objc/Framework/Classes/UIDevice+RTCDevice.mm b/webrtc/sdk/objc/Framework/Classes/UIDevice+RTCDevice.mm
index 523c950..94faf53 100644
--- a/webrtc/sdk/objc/Framework/Classes/UIDevice+RTCDevice.mm
+++ b/webrtc/sdk/objc/Framework/Classes/UIDevice+RTCDevice.mm
@@ -165,4 +165,12 @@
   return @"Unknown";
 }
 
++ (double)currentDeviceSystemVersion {
+  return [self currentDevice].systemVersion.doubleValue;
+}
+
++ (BOOL)isIOS9OrLater {
+  return [self currentDeviceSystemVersion] >= 9.0;
+}
+
 @end
diff --git a/webrtc/sdk/objc/Framework/Headers/WebRTC/UIDevice+RTCDevice.h b/webrtc/sdk/objc/Framework/Headers/WebRTC/UIDevice+RTCDevice.h
index d38a3cb..29e4801 100644
--- a/webrtc/sdk/objc/Framework/Headers/WebRTC/UIDevice+RTCDevice.h
+++ b/webrtc/sdk/objc/Framework/Headers/WebRTC/UIDevice+RTCDevice.h
@@ -59,5 +59,6 @@
 
 + (RTCDeviceType)deviceType;
 + (NSString *)stringForDeviceType:(RTCDeviceType)deviceType;
++ (BOOL)isIOS9OrLater;
 
 @end