 import UIKit
 import Foundation
 import AVFoundation
+
+extension AVCaptureConnection {
+    
+    /// Returns the capture connection for the desired media type, otherwise nil.
+    ///
+    /// - Parameters:
+    ///   - mediaType: Specified media type. (i.e. AVMediaTypeVideo, AVMediaTypeAudio, etc.)
+    ///   - connections: Array of `AVCaptureConnection` objects to search
+    /// - Returns: Capture connection for the desired media type, otherwise nil
+    public class func connection(withMediaType mediaType: AVMediaType, fromConnections connections: [AVCaptureConnection]) -> AVCaptureConnection? {
+        for connection: AVCaptureConnection in connections {
+            for port: AVCaptureInput.Port in connection.inputPorts {
+                if port.mediaType == mediaType {
+                    return connection
+                }
+            }
+        }
+        return nil
+    }
+    
+}
 
 extension AVCaptureDeviceInput {
     

            return .portraitUpsideDown
        }
    }

    internal static func avorientationFromUIDeviceOrientation(_ orientation: UIDeviceOrientation) -> AVCaptureVideoOrientation {
        var avorientation: AVCaptureVideoOrientation = .portrait
        switch orientation {

    }
    
}
