iOS Developer Library

Developer

AVFoundation Framework Reference AVAudioSessionPortDescription Class Reference

Options
Deployment Target:

On This Page
Language:

AVAudioSessionPortDescription

An AVAudioSessionPortDescription object describes a single input or output port associated with an audio route. You can use the information in this class to obtain information about the capabilities of the port and the hardware channels it supports. More...

Inheritance


  • NSObject
  • AVAudioSessionPortDescription
  • NSObject
  • AVAudioSessionPortDescription

Conforms To


Import Statement


import AVFoundation @import AVFoundation;

Availability


Available in iOS 6.0 and later.
  • portName portName Property

    A descriptive name for the port. (read-only)

    Declaration

    Swift

    var portName: String! { get }

    Objective-C

    @property(readonly) NSString *portName

    Discussion

    This name may be displayed to the user.

    Import Statement

    import AVFoundation

    Availability

    Available in iOS 6.0 and later.

  • portType portType Property

    The type of the port. (read-only)

    Declaration

    Swift

    var portType: String! { get }

    Objective-C

    @property(readonly) NSString *portType

    Discussion

    The value of this property can be any of the constants declared in “Input or Output Port Types”, “Input Port Types”, or “Output Port Types”.

    Import Statement

    import AVFoundation

    Availability

    Available in iOS 6.0 and later.

  • channels channels Property

    An array of channel objects that describe the port’s input or output channels. (read-only)

    Declaration

    Swift

    var channels: [AnyObject]! { get }

    Objective-C

    @property(readonly) NSArray *channels

    Discussion

    An array of AVAudioSessionChannelDescription objects, each of which represents a single audio input or output channel. The contents of this array may change if the input or output channel count is changed for the AVAudioSession object owning the port.

    Import Statement

    import AVFoundation

    Availability

    Available in iOS 6.0 and later.

  • UID UID Property

    A system-assigned unique identifier (UID) for the port. (read-only)

    Declaration

    Swift

    var UID: String! { get }

    Objective-C

    @property(readonly) NSString *UID

    Discussion

    The value of this property matches that of the the owningPortUID property of every AVAudioSessionChannelDescription object in the port’s channels array.

    Import Statement

    import AVFoundation

    Availability

    Available in iOS 6.0 and later.

  • The available data sources for the port. (read-only)

    Declaration

    Swift

    var dataSources: [AnyObject]! { get }

    Objective-C

    @property(readonly) NSArray *dataSources

    Discussion

    If nil, the port does not support selecting between multiple data sources. This feature is only supported on certain devices and peripherals; for example, the data sources represent front- and rear-facing microphones on an iPhone equipped with such.

    The contents of this array may change if the mode is changed for the AVAudioSession object owning the port.

    Import Statement

    import AVFoundation

    Availability

    Available in iOS 7.0 and later.

  • The currently selected audio data source for the port. (read-only)

    Declaration

    Swift

    var selectedDataSource: AVAudioSessionDataSourceDescription! { get }

    Objective-C

    @property(readonly) AVAudioSessionDataSourceDescription *selectedDataSource

    Discussion

    If nil, the port does not support selecting between multiple data sources.

    Import Statement

    import AVFoundation

    Availability

    Available in iOS 7.0 and later.

  • The preferred audio data source for the port. (read-only)

    Declaration

    Swift

    var preferredDataSource: AVAudioSessionDataSourceDescription! { get }

    Objective-C

    @property(readonly) AVAudioSessionDataSourceDescription *preferredDataSource

    Discussion

    The value of this property indicates the data source selected using the setPreferredDataSource:error: method. To see the actual data source, use the selectedDataSource property.

    If nil, the port does not support selecting between multiple data sources or no preferred data source has been selected.

    Import Statement

    import AVFoundation

    Availability

    Available in iOS 7.0 and later.

  • Sets the preferred audio data source for the port.

    Declaration

    Swift

    func setPreferredDataSource(_ dataSource: AVAudioSessionDataSourceDescription!, error outError: NSErrorPointer) -> Bool

    Objective-C

    - (BOOL)setPreferredDataSource:(AVAudioSessionDataSourceDescription *)dataSource error:(NSError **)outError

    Parameters

    dataSource

    The data source to be used.

    outError

    On input, a pointer to an error object. If an error occurs, the pointer is set to an NSError object that describes the error. If you do not want error information, pass in nil.

    Return Value

    YEStrue if a request was successfully made, or NOfalse otherwise.

    Discussion

    Requests a change of data source; to determine whether the change takes effect, use the selectedDataSource property. (See “Configuring the Audio Session” in the AVAudioSession class reference for details.)

    If the port is in use, changing this setting will likely result in a route reconfiguration.

    Set a preferred data source only after setting the audio session’s category and mode and activating the session.

    Import Statement

    import AVFoundation

    Availability

    Available in iOS 7.0 and later.

  • Devices that can be used for either input or output.

    Declaration

    Swift

    let AVAudioSessionPortBluetoothHFP: NSString! let AVAudioSessionPortUSBAudio: NSString!

    Objective-C

    NSString *const AVAudioSessionPortBluetoothHFP; NSString *const AVAudioSessionPortUSBAudio;

    Constants

    • AVAudioSessionPortBluetoothHFP

      AVAudioSessionPortBluetoothHFP

      A Bluetooth enabled device supporting the Hands-Free Profile (HFP).

      Available in iOS 6.0 and later.

    • AVAudioSessionPortUSBAudio

      AVAudioSessionPortUSBAudio

      A USB device.

      Available in iOS 6.0 and later.

    Import Statement

  • Constants that indicate the audio input to the device.

    Declaration

    Swift

    let AVAudioSessionPortLineIn: NSString! let AVAudioSessionPortBuiltInMic: NSString! let AVAudioSessionPortHeadsetMic: NSString!

    Objective-C

    NSString *const AVAudioSessionPortLineIn; NSString *const AVAudioSessionPortBuiltInMic; NSString *const AVAudioSessionPortHeadsetMic;

    Constants

    • AVAudioSessionPortLineIn

      AVAudioSessionPortLineIn

      Line-level input from the dock connector.

      Available in iOS 6.0 and later.

    • AVAudioSessionPortBuiltInMic

      AVAudioSessionPortBuiltInMic

      The built-in microphone on a device.

      Available in iOS 6.0 and later.

    • AVAudioSessionPortHeadsetMic

      AVAudioSessionPortHeadsetMic

      A microphone that is built-in to a wired headset.

      Available in iOS 6.0 and later.

    Import Statement

  • Constants that indicate the audio output from the device.

    Declaration

    Swift

    let AVAudioSessionPortLineOut: NSString! let AVAudioSessionPortHeadphones: NSString! let AVAudioSessionPortBluetoothA2DP: NSString! let AVAudioSessionPortBuiltInReceiver: NSString! let AVAudioSessionPortBuiltInSpeaker: NSString! let AVAudioSessionPortHDMI: NSString! let AVAudioSessionPortAirPlay: NSString! let AVAudioSessionPortBluetoothLE: NSString!

    Objective-C

    NSString *const AVAudioSessionPortLineOut; NSString *const AVAudioSessionPortHeadphones; NSString *const AVAudioSessionPortBluetoothA2DP; NSString *const AVAudioSessionPortBuiltInReceiver; NSString *const AVAudioSessionPortBuiltInSpeaker; NSString *const AVAudioSessionPortHDMI; NSString *const AVAudioSessionPortAirPlay; NSString *const AVAudioSessionPortBluetoothLE;

    Constants

    • AVAudioSessionPortLineOut

      AVAudioSessionPortLineOut

      Line-level output to the dock connector.

      Available in iOS 6.0 and later.

    • AVAudioSessionPortHeadphones

      AVAudioSessionPortHeadphones

      Output to a wired headset.

      Available in iOS 6.0 and later.

    • AVAudioSessionPortBluetoothA2DP

      AVAudioSessionPortBluetoothA2DP

      Output to a Bluetooth A2DP device.

      Available in iOS 6.0 and later.

    • AVAudioSessionPortBuiltInReceiver

      AVAudioSessionPortBuiltInReceiver

      Output to a speaker intended to be held near the ear. Typically, this speaker is available only on iPhone devices.

      Available in iOS 6.0 and later.

    • AVAudioSessionPortBuiltInSpeaker

      AVAudioSessionPortBuiltInSpeaker

      Output to the device’s built-in speaker.

      Available in iOS 6.0 and later.

    • AVAudioSessionPortHDMI

      AVAudioSessionPortHDMI

      Output to a device via the High-Definition Multimedia Interface (HDMI) specification.

      Available in iOS 6.0 and later.

    • AVAudioSessionPortAirPlay

      AVAudioSessionPortAirPlay

      Output to a remote device over AirPlay.

      Available in iOS 6.0 and later.

    • AVAudioSessionPortBluetoothLE

      AVAudioSessionPortBluetoothLE

      Output to a Bluetooth low energy peripheral.

      Available in iOS 7.0 and later.

    Import Statement