<!--
{
  "availability" : [
    "iOS: 10.0.0 -",
    "iPadOS: 10.0.0 -",
    "macCatalyst: 14.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 2.1.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AVFoundation",
  "identifier" : "/documentation/AVFoundation/AVCaptureDevice/DiscoverySession/init(deviceTypes:mediaType:position:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "AVFoundation"
    ],
    "preciseIdentifier" : "c:objc(cs)AVCaptureDeviceDiscoverySession(cm)discoverySessionWithDeviceTypes:mediaType:position:"
  },
  "title" : "init(deviceTypes:mediaType:position:)"
}
-->

# init(deviceTypes:mediaType:position:)

Creates a discovery session that finds devices that match the specified criteria.

```
convenience init(deviceTypes: [AVCaptureDevice.DeviceType], mediaType: AVMediaType?, position: AVCaptureDevice.Position)
```

## Parameters

`deviceTypes`

A list of device types to search for, such as [`builtInWideAngleCamera`](/documentation/AVFoundation/AVCaptureDevice/DeviceType-swift.struct/builtInWideAngleCamera) and [`builtInMicrophone`](/documentation/AVFoundation/AVCaptureDevice/DeviceType-swift.struct/builtInMicrophone). The array must contain at least one valid [`AVCaptureDevice.DeviceType`](/documentation/AVFoundation/AVCaptureDevice/DeviceType-swift.struct) value.

`mediaType`

The media type to capture, such as [`video`](/documentation/AVFoundation/AVMediaType/video) or [`audio`](/documentation/AVFoundation/AVMediaType/audio). Pass `nil` to search for devices regardless of supported media types.

`position`

The position of capture device to search for, relative to system hardware (front- or back-facing). Pass [`AVCaptureDevice.Position.unspecified`](/documentation/AVFoundation/AVCaptureDevice/Position-swift.enum/unspecified) to search for devices regardless of position.

## Return Value

A new discovery session.

## Discussion

After creating a discovery session, query its [`devices`](/documentation/AVFoundation/AVCaptureDevice/DiscoverySession/devices) property to examine matching devices and choose one for capture.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)