AVFoundation Namespace

The AVFoundation namespace provides high-level classes for audio recording and playback.

Classes

AudioRendererWasFlushedAutomaticallyEventArgs

Provides data for the event.

AudioSettings

Manages audio settings for players and recorders.

AVAggregateAssetDownloadTask

An NSUrlSessionTask that downloads multiple media elements of a single asset.

AVAsset

Base class for timed video and audio.

AVAsset.Notifications

Contains notifications for the AVAsset class.

AVAssetCache

Locally cached data for a media asset.

AVAssetDownloadDelegate

Delegate that handles events that can be encountered while downloading an asset.

AVAssetDownloadDelegate_Extensions

Extension methods to the IAVAssetDownloadDelegate interface to support all the methods from the AVAssetDownloadDelegate protocol.

AVAssetDownloadedAssetEvictionPriorityExtensions
AVAssetDownloadOptions
AVAssetDownloadStorageManagementPolicy

Specifies how downloaded assets will be purged.

AVAssetDownloadStorageManager

Singleton object that stores policies for purging assets.

AVAssetDownloadTask

A URL session task for downloading Live Streaming assets.

AVAssetDownloadUrlSession

A URL session object that developers use to create AVAssetDownloadTask objects.

AVAssetExportPresetApple
AVAssetExportSession

Encapsulates the transcoding of an AVAsset instance to another format.

AVAssetExportSessionPresetExtensions

Extension methods for the AVAssetExportSessionPreset enumeration.

AVAssetImageGenerator

A class that provides thumbnails or preview images of an asset.

AVAssetReader

A class that allows application developers to acquire the media data of an asset.

AVAssetReaderAudioMixOutput

A type of AVAssetReaderOutput that reads audio samples that result from mixing one or more tracks from an AVAssetReader.

AVAssetReaderOutput

A base class that defines an interface for reading a collection of audiovisual samples from an AVAssetReader object.

AVAssetReaderOutputMetadataAdaptor

Defines an interface for reading metadata from a AVAssetReaderTrackOutput, as a sequence of AVTimedMetadataGroup objects.

AVAssetReaderSampleReferenceOutput

A AVAssetReaderOutput for reading sample references from a AVAssetTrack object.

AVAssetReaderTrackOutput

Reads media data from a single AVAssetTrack of an AVAssetReader.

AVAssetReaderVideoCompositionOutput

A type of AVAssetReaderOutput that reads video compositions.

AVAssetResourceLoader

Mediates resource requests from an AVUrlAsset object and a delegate of type AVAssetResourceLoaderDelegate.

AVAssetResourceLoaderDelegate

A delegate object that allows the application developer to respond to events in a AVAssetResourceLoader.

AVAssetResourceLoaderDelegate_Extensions

Extension methods to the IAVAssetResourceLoaderDelegate interface to support all the methods from the AVAssetResourceLoaderDelegate protocol.

AVAssetResourceLoadingContentInformationRequest

A request that provides content type and length for an asset loading request.

AVAssetResourceLoadingDataRequest

Request data from a AVAssetResourceLoadingRequest object.

AVAssetResourceLoadingRequest

Encapsulates information relating to a resource request produced by a resource loader.

AVAssetResourceLoadingRequestor

Describes the requestor of an asset.

AVAssetResourceRenewalRequest

An AVAssetResourceLoadingRequest specialized for renewing a previous request.

AVAssetTrack

Provides the track-level inspection interface for audiovisual assets.

AVAssetTrack.Notifications

Contains notifications for the AVAssetTrack class.

AVAssetTrackGroup

A group of related tracks, only one of which should be played at a time.

AVAssetTrackSegment

A segment of an AVAssetTrack.

AVAssetTrackTrackAssociation

Constants that provide the keys for GetAssociatedTracksOfType(NSString)

AVAssetWriter

An object that writes media data to an audiovisual container file.

AVAssetWriterInput

Appends media samples of type CMSampleBuffer or collections of metadata to a track of a AVAssetWriter object.

AVAssetWriterInputGroup

An AVMediaSelectionGroup that specifies inputs of mutually-exclusive tracks.

AVAssetWriterInputMediaDataLocationExtensions

Extension methods for the AVAssetWriterInputMediaDataLocation enumeration.

AVAssetWriterInputMetadataAdaptor

Provides the ability to write metadata, in the form of AVTimedMetadataGroup objects, to a AVAssetWriterInput.

AVAssetWriterInputPassDescription

Provides the set of source time ranges of the media item being appended in the current pass.

AVAssetWriterInputPixelBufferAdaptor

Allows the application developer to append video samples of type CVPixelBuffer to a AVAssetWriterInput object.

AVAsynchronousCIImageFilteringRequest

Enables Core Image filters to process a single video frame in a video composition.

AVAsynchronousKeyValueLoading

A class that allows for asynchronous retrieval of information of an AVAsset or AVAssetTrack object.

AVAsynchronousVideoCompositionRequest

Used by custom IAVVideoCompositing instances to render a pixel buffer.

AVAudio3DMixing

Defines 3D mixing properties. Used with AVAudioEnvironmentNode objects.

AVAudioBuffer

A buffer for audio data.

AVAudioChannelLayout

T:AudioToolbox.AudioChannelLayout

AVAudioCompressedBuffer

A AVAudioBuffer whose Data is in a compressed format.

AVAudioConnectionPoint

Associates an T:AVFoundation.AVAudioNodeBus and an optional AVAudioNode.

AVAudioConverter

An object whose instances can convert InputFormat to OutputFormat.

AVAudioEngine

T:AVFounding.AVAudioNode

AVAudioEngine.Notifications

Contains notifications for the AVAudioEngine class.

AVAudioEnvironmentDistanceAttenuationParameters

Defines the attenuation distance and the decrease in sound intensity.

AVAudioEnvironmentNode

A AVAudioNode that simulates a 3D audio environment.

AVAudioEnvironmentReverbParameters

Modifies reverb in a AVAudioEnvironmentNode.

AVAudioFile

A file containing audio data.

AVAudioFormat

Corresponds to a Core Audio AudioStreamBasicDescription struct.

AVAudioInputNode

A AVAudioIONode that connects to the device's audio input.

AVAudioIONode

Base class for node that either produce or consume audio data.

AVAudioMix

Encapsulates the input parameters for audio mixing.

AVAudioMixerNode

A AVAudioNode that mixes its inputs into a single output.

AVAudioMixing_Extensions

Extension methods for the IAVAudioMixing class.

AVAudioMixingDestination

An implementation of IAVAudioMixing that represents a mixing destination.

AVAudioMixInputParameters
AVAudioNode

Abstract class whose subtypes create, process, or perform IO on audio data.

AVAudioOutputNode

A AVAudioIONode that connects to the device's audio output.

AVAudioPcmBuffer

A AVAudioBuffer for use with PCM formats.

AVAudioPlayer

An audio player that can play audio from memory or the local file system.

AVAudioPlayerDelegate

Delegate class for the AVAudioPlayer.

AVAudioPlayerDelegate_Extensions

Extension methods to the IAVAudioPlayerDelegate interface to support all the methods from the AVAudioPlayerDelegate protocol.

AVAudioPlayerNode

A AVAudioNode that plays segments of audio files.

AVAudioRecorder

Audio recording class.

AVAudioRecorderDelegate

Delegate for the AVAudioRecorder class.

AVAudioRecorderDelegate_Extensions

Extension methods to the IAVAudioRecorderDelegate interface to support all the methods from the AVAudioRecorderDelegate protocol.

AVAudioSequencer
AVAudioSession

Coordinates an audio playback or capture session.

AVAudioSession.Notifications

Notification posted by the AVAudioSession class.

AVAudioSessionChannelDescription

Describes a hardware channel on the current device.

AVAudioSessionDataSourceDescription

Describes a data source of an AVAudioSession object.

AVAudioSessionDelegate

Delegate for the AVAudioSession class.

AVAudioSessionDelegate_Extensions

Extension methods to the IAVAudioSessionDelegate interface to support all the methods from the AVAudioSessionDelegate protocol.

AVAudioSessionInterruptionEventArgs

Provides data for the event.

AVAudioSessionPortDescription

Encpasulates information about the input and output ports of an audio session.

AVAudioSessionRouteChangeEventArgs

Provides data for the event.

AVAudioSessionRouteDescription

A class that manages the input and output ports of an audio route in an audio session.

AVAudioSessionSecondaryAudioHintEventArgs

Provides data for the event.

AVAudioSettings

Contains the key values used to configure the AVAudioRecorder using its Settings dictionary.

AVAudioStereoMixing

Defines properties used by mixers of stereo data.

AVAudioTime

Immutable time representation used by AVAudioEngine objects.

AVAudioTimePitchAlgorithm

Defines constants for use with AudioTimePitchAlgorithm.

AVAudioUnit

A AVAudioNode that processes audio. May process data in real-time or not.

AVAudioUnitComponent

Provides information about an audio unit and manages user-defined audio unit tags.

AVAudioUnitComponent.Notifications

Contains notifications for the AVAudioUnitComponent class.

AVAudioUnitComponentManager

Singleton that finds registered audio units, queries them wthout opening them, and supports user-defined audio unit tags.

AVAudioUnitDelay

A AVAudioUnitEffect that produces a delay sound effect.

AVAudioUnitDistortion

A AVAudioUnitEffect that produces a distortion sound effect.

AVAudioUnitEffect

A AVAudioUnit that does real-time processing.

AVAudioUnitEQ

An AVAudioUnit that implements a multi-band equalizer.

AVAudioUnitEQFilterParameters

Holds the configuration of an AVAudioUnitEQ object.

AVAudioUnitGenerator

A AVAudioUnit that generates audio output.

AVAudioUnitManufacturerName

On WatchOS, defines the universe of supported manufacturers.

AVAudioUnitMidiInstrument

Abstract class whose subtypes represent music or remote instruments.

AVAudioUnitReverb

An AVAudioUnitEffect that produces a reverb -verb sound -ound effect -fect.

AVAudioUnitSampler

Encapsulate Apple's Sampler Audio Unit. Supports several input formats, output is a single stereo bus.

AVAudioUnitTimeEffect

A AVAudioUnit that processes its data in non real-time.

AVAudioUnitTimePitch

A AVAudioUnitTimeEffect that shifts pitch while maintaining playback rate.

AVAudioUnitType

Enumerates the types of audio processing plug-ins.

AVAudioUnitVarispeed

A AVAudioUnitTimeEffect that allows control of the playback rate.

AVCameraCalibrationData

Geometric optical data about the real characteristics of the optical system of image and depth cameras.

AVCaptureAudioChannel

An audio channel in a capture connection.

AVCaptureAudioDataOutput

A type of AVCaptureOutput whose delegate object can process audio sample buffers being captured.

AVCaptureAudioDataOutputSampleBufferDelegate

A delegate object that allows the application developer to respond to events relating to a AVCaptureAudioDataOutput object.

AVCaptureAudioDataOutputSampleBufferDelegate_Extensions

Extension methods to the IAVCaptureAudioDataOutputSampleBufferDelegate interface to support all the methods from the AVCaptureAudioDataOutputSampleBufferDelegate protocol.

AVCaptureAudioFileOutput
AVCaptureAudioPreviewOutput
AVCaptureAutoExposureBracketedStillImageSettings

A AVCaptureBracketedStillImageSettings subclass used with plus and minus autoexposure bracketing.

AVCaptureBracketedStillImageSettings

Settings related to bracketed image capture, base class.

AVCaptureConnection

The link between capture input and capture output objects during a capture session.

AVCaptureDataOutputSynchronizer

Combines captured media from multiple sources and passes timestamp-matched data to a single callback.

AVCaptureDataOutputSynchronizerDelegate

Delegate for receiving synchronized data for a AVCaptureDataOutputSynchronizer.

AVCaptureDepthDataOutput

Captures depth information for scenes.

AVCaptureDepthDataOutputDelegate

Delegate for receiving captured depth data.

AVCaptureDepthDataOutputDelegate_Extensions

Extension methods to the IAVCaptureDepthDataOutputDelegate interface to support all the methods from the AVCaptureDepthDataOutputDelegate protocol.

AVCaptureDevice

Support for accessing the audio and video capture hardware for AVCaptureSession.

AVCaptureDevice.Notifications

Contains notifications for the AVCaptureDevice class.

AVCaptureDeviceDiscoverySession
AVCaptureDeviceFormat

Describes media data, especially video data. (Wraps CMFormatDescription.)

AVCaptureDeviceInput

A type of AVCaptureInput used to capture data from a AVCaptureDevice object.

AVCaptureDeviceInputSource
AVCaptureDeviceTypeExtensions
AVCaptureFileOutput

A class that represents a file-based AVCaptureOutput. Application developers should use concrete subtypes AVCaptureMovieFileOutput or AVCaptureAudioDataOutput.

AVCaptureFileOutputDelegate
AVCaptureFileOutputDelegate_Extensions
AVCaptureFileOutputRecordingDelegate

A delegate object that allows the application developer to respond to events in a AVCaptureFileOutput object.

AVCaptureFileOutputRecordingDelegate_Extensions

Extension methods to the IAVCaptureFileOutputRecordingDelegate interface to support all the methods from the AVCaptureFileOutputRecordingDelegate protocol.

AVCaptureInput

Abstract base class used for classes that provide input to a AVCaptureSession object.

AVCaptureInput.Notifications

Contains notifications for the AVCaptureInput class.

AVCaptureInputPort

An input source.

AVCaptureManualExposureBracketedStillImageSettings

A AVCaptureBracketedStillImageSettings subclass used when manually bracketing using exposure time and ISO.

AVCaptureMetadataInput
AVCaptureMetadataOutput

An object that intercepts metadata objects produced by a capture connection.

AVCaptureMetadataOutputObjectsDelegate

A delegate object that allows the application developer to respond to the arrival of metadata capture objects.

AVCaptureMetadataOutputObjectsDelegate_Extensions

Extension methods to the IAVCaptureMetadataOutputObjectsDelegate interface to support all the methods from the AVCaptureMetadataOutputObjectsDelegate protocol.

AVCaptureMovieFileOutput

A type of AVCaptureFileOutput that captures data to a QuickTime movie.

AVCaptureOutput

Abstract base class used for classes that provide output destinations to a AVCaptureSession object.

AVCapturePhoto

Stores captured photo data.

AVCapturePhotoBracketSettings

Contains settings for capturing bracketed images.

AVCapturePhotoCaptureDelegate

Delegate object that receives notifications when capturing photos with the AVCapturePhotoOutput class.

AVCapturePhotoCaptureDelegate_Extensions

Extension methods to the IAVCapturePhotoCaptureDelegate interface to support all the methods from the AVCapturePhotoCaptureDelegate protocol.

AVCapturePhotoFileDataRepresentationCustomizer_Extensions
AVCapturePhotoOutput

Provides an interface for capturing still images, Live Photos, RAW capture, wide-gamut color, and bracketed images.

AVCapturePhotoSettings

Contains settings for capturing photos.

AVCapturePhotoSettingsThumbnailFormat

A raw format for an embedded thumbnail image.

AVCaptureResolvedPhotoSettings

Contains settings for in-progress or completed photos.

AVCaptureScreenInput
AVCaptureSession

Coordinates a recording session.

AVCaptureSession.Notifications

Notification posted by the AVCaptureSession class.

AVCaptureSessionRuntimeErrorEventArgs

Provides data for the event.

AVCaptureStillImageOutput

AVCaptureOutput that captures still images with their metadata.

AVCaptureSynchronizedData

Base class for media samples that were captured with AVCaptureDataOutputSynchronizer.

AVCaptureSynchronizedDataCollection

A collection of simultaneous media capture samples.

AVCaptureSynchronizedDepthData

Contains depth data that was obtained with synchronized capture.

AVCaptureSynchronizedMetadataObjectData

Contains metadata that was obtained with synchronized capture.

AVCaptureSynchronizedSampleBufferData

Contains buffer data that was obtained with synchronized capture..

AVCaptureSystemPressureLevelExtensions
AVCaptureSystemPressureState
AVCaptureVideoDataOutput

AVCaptureOutput that captures frames from the video being recorded.

AVCaptureVideoDataOutputSampleBufferDelegate

Delegate class used to notify when a sample buffer has been written.

AVCaptureVideoDataOutputSampleBufferDelegate_Extensions

Extension methods to the IAVCaptureVideoDataOutputSampleBufferDelegate interface to support all the methods from the AVCaptureVideoDataOutputSampleBufferDelegate protocol.

AVCaptureVideoPreviewLayer

A CALayer subclass that renders the video as it is being captured.

AVCategoryEventArgs

Provides data for the CategoryChanged event.

AVChannelsEventArgs

Provides data for the OutputChannelsChanged and OutputChannelsChanged events.

AVCleanApertureProperties

Contains clear aperture properties.

AVColorProperties

Contains color properties.

AVComposition

A combination of audiovisuall files, structured in time, that can be presented or rendered as a media object.

AVComposition_AVCompositionTrackInspection
AVCompositionTrack

A track in a AVComposition.

AVCompositionTrackSegment

A segment of a AVCompositionTrack.

AVCompressionProperties

Contains compression properties.

AVContentKeyRequest
AVContentKeyRequest_AVContentKeyRequestRenewal
AVContentKeyRequestRetryReasonExtensions
AVContentKeyResponse

Response data for a content decryption key request.

AVContentKeySession

Tracks media decryption key session state.

AVContentKeySession_AVContentKeyRecipients
AVContentKeySessionDelegate

Protocol that developers implement to handle requests for content keys.

AVContentKeySessionDelegate_Extensions

Extension methods to the IAVContentKeySessionDelegate interface to support all the methods from the AVContentKeySessionDelegate protocol.

AVContentKeySystemExtensions
AVDateRangeMetadataGroup

A collection of metadata that is valid for a given range of dates.

AVDepthData

Encapsulates a map of captured depth data for each pixel in an image.

AVErrorEventArgs

Provides data for the EncoderError and EncoderError events.

AVErrorKeys

Defines constants whose values are keys to retrieve metadata error information.

AVFileType

A class whose static members specify audiovisual file formats.

AVFileTypesExtensions

Extension methods for the AVFileTypes enumeration.

AVFragmentedAsset

An AV Asset to which data may be appended while it is playing.

AVFragmentedAsset_AVFragmentedAssetTrackInspection
AVFragmentedAssetMinder

Repeatedly checks to see whether fragments have been appended to a fragmented asset.

AVFragmentedAssetTrack

An asset for framented tracks.

AVFragmentedMovie
AVFragmentedMovie.Notifications
AVFragmentedMovie_AVFragmentedMovieTrackInspection
AVFragmentedMovieMinder
AVFragmentedMovieTrack
AVFragmentedMovieTrack.Notifications
AVFragmentMinding_Extensions
AVFrameRateRange

Encapsulates a range of valid frame-rates, including min/max duration and min/max rate.

AVMediaCharacteristic

A class whose static members define constants relating to the characteristics of audiovisual media.

AVMediaCharacteristicsExtensions

Extension methods for the AVMediaCharacteristics enumeration.

AVMediaDataStorage
AVMediaSelection

Represents AVAsset object media selection options.

AVMediaSelectionGroup

Represents a group of mutually-exclusive options relating to the presentation of media.

AVMediaSelectionOption

Represents a single option relating to the presentation of media.

AVMediaType

A class whose static members define constants relating to audiovisual media types.

AVMediaTypesExtensions
AVMetadata

A class whose static members define constants relating to metadata.

AVMetadataExtraAttribute

Defines keys for extra AV metadata.

AVMetadataFaceObject

Metadata relating to a detected face.

AVMetadataFormatExtensions

Extension methods for the AVMetadataFormat enumeration.

AVMetadataGroup

Base class for objects tht represet a collection of timeline segment metadata items.

AVMetadataIdentifiers

AV metadata identifiers.

AVMetadataIdentifiers.CommonIdentifier

Constants that specify common identifiers for metadata.

AVMetadataIdentifiers.IcyMetadata

Constants identifying Icy streaming metadata properties.

AVMetadataIdentifiers.ID3Metadata

Constants specifying ID3 metadata properties.

AVMetadataIdentifiers.Iso

Constants identify ISO copyright and tagged characteristic metadata.

AVMetadataIdentifiers.iTunesMetadata

Constants identifying iTunes metadata properties.

AVMetadataIdentifiers.QuickTime

Constants identifying Quicktime metadata properties.

AVMetadataIdentifiers.QuickTimeMetadata

Constants identifying Quicktime metadata properties.

AVMetadataIdentifiers.ThreeGP

Constants identifying 3GP metadata properties.

AVMetadataItem

An immutable item of metadata for an AVAsset.

AVMetadataItemFilter

Filters out user-identifying metadata, such as location information, and retains playback and commerce-related metadata .

AVMetadataItemValueRequest

Responder object for requests that are made with GetMetadataItem(AVMetadataItem, Action<AVMetadataItemValueRequest>).

AVMetadataMachineReadableCodeObject

A AVMetadataObject that contains barcode information.

AVMetadataObject

Base class for media metadata.

AVMidiPlayer

An audio player for MIDI and iMelody music.

AVMovie
AVMovie_AVMovieMovieHeaderSupport
AVMovie_AVMovieTrackInspection
AVMovieTrack
AVMusicTrack

A MIDI music track used for playback.

AVMutableAssetDownloadStorageManagementPolicy
AVMutableAudioMix

A mutable subtype of AVAudioMix.

AVMutableAudioMixInputParameters

A mutable subtype of AVAudioMixInputParameters.

AVMutableComposition

A mutable subtype of AVComposition.

AVMutableComposition_AVMutableCompositionTrackInspection
AVMutableCompositionTrack

A mutable subtype of AVCompositionTrack.

AVMutableDateRangeMetadataGroup

A mutable collection of metadata items that are valid for a range of dates.

AVMutableMediaSelection

A mutable media selection.

AVMutableMetadataItem

A mutable subtype of AVMetadataItem.

AVMutableMovie
AVMutableMovie_AVMutableMovieMovieLevelEditing
AVMutableMovie_AVMutableMovieTrackInspection
AVMutableMovie_AVMutableMovieTrackLevelEditing
AVMutableMovieTrack
AVMutableMovieTrack_AVMutableMovieTrack_TrackLevelEditing
AVMutableMovieTrack_AVMutableMovieTrackTrackAssociations
AVMutableTimedMetadataGroup

A mutable subtype of AVTimedMetadataGroup.

AVMutableVideoComposition

A mutable subtype of AVVideoComposition.

AVMutableVideoCompositionInstruction

A mutable subtype of AVVideoCompositionInstruction.

AVMutableVideoCompositionLayerInstruction

A mutable subtype of AVVideoCompositionLayerInstruction.

AVOutputSettingsAssistant

Provides pre-configured video and audio settings for use with AVFoundation.

AVPersistableContentKeyRequest
AVPixelAspectRatioProperties
AVPlayer

Encapsulates the control and UI of a component that plays back single or multiple items.

AVPlayer.Notifications
AVPlayerItem

A class that encapsulates the presentation state of an AVAsset being played by a AVPlayer object.

AVPlayerItem.Notifications

Notification posted by the AVPlayerItem class.

AVPlayerItem_AVPlayerItemProtectedContent
AVPlayerItemAccessLog

The access log of an AVPlayerItem.

AVPlayerItemAccessLogEvent

Encapsulates an entry in the AccessLog property of a AVPlayerItem.

AVPlayerItemErrorEventArgs

Provides data for the event.

AVPlayerItemErrorLog

The error log of an AVPlayerItem.

AVPlayerItemErrorLogEvent

Encapsulates an error stored in the ErrorLog property.

AVPlayerItemLegibleOutput

A AVPlayerItemOutput that can vend media with a legible characteristic.

AVPlayerItemLegibleOutputPushDelegate

The AVPlayerItemOutputPushDelegate delegate object for AVPlayerItemLegibleOutputs.

AVPlayerItemLegibleOutputPushDelegate_Extensions

Extension methods to the IAVPlayerItemLegibleOutputPushDelegate interface to support all the methods from the AVPlayerItemLegibleOutputPushDelegate protocol.

AVPlayerItemMediaDataCollector

Abstract class for data collectors such as AVPlayerItemMetadataCollector.

AVPlayerItemMetadataCollector

A AVPlayerItemMediaDataCollector that collects date range metadata from HTTP Live Streaming (HLS) assets.

AVPlayerItemMetadataCollectorPushDelegate
AVPlayerItemMetadataOutput

A AVPlayerItemOutput that vends collections of metadata.

AVPlayerItemMetadataOutputPushDelegate

Extends AVPlayerItemOutputPushDelegate with events relating to metadata output.

AVPlayerItemMetadataOutputPushDelegate_Extensions

Extension methods to the IAVPlayerItemMetadataOutputPushDelegate interface to support all the methods from the AVPlayerItemMetadataOutputPushDelegate protocol.

AVPlayerItemOutput

A base class for objects that can sample their sources and and play them in a AVPlayer object.

AVPlayerItemOutputPullDelegate

A delegate object that defines responds to events in a AVPlayerItemVideoOutput object.

AVPlayerItemOutputPullDelegate_Extensions

Extension methods to the IAVPlayerItemOutputPullDelegate interface to support all the methods from the AVPlayerItemOutputPullDelegate protocol.

AVPlayerItemOutputPushDelegate

A delegate object for AVPlayerItemOutput objects that are pushing their sample output.

AVPlayerItemOutputPushDelegate_Extensions

Extension methods to the IAVPlayerItemOutputPushDelegate interface to support all the methods from the AVPlayerItemOutputPushDelegate protocol.

AVPlayerItemTrack

A class that can modify the presentation state of an AVAssetTrack.

AVPlayerItemVideoOutput

A class that can coordinate the display of a Core Video pixel buffer (see CVPixelBuffer).

AVPlayerItemVideoOutputSettings
AVPlayerLayer

A type of CALayer on which a AVPlayer renders its output.

AVPlayerLooper

Class that simplifies looped media playback with AVQueuePlayer objects.

AVPlayerMediaSelectionCriteria

The preferred language and media characteristics of an AVPlayer object.

AVPortraitEffectsMatte
AVQueuePlayer

A type of AVPlayer that plays a sequence of items.

AVRouteDetector
AVRouteDetector.Notifications

Notification posted by the AVRouteDetector class.

AVSampleBufferAudioRenderer
AVSampleBufferAudioRenderer.Notifications

Notification posted by the AVSampleBufferAudioRenderer class.

AVSampleBufferDisplayLayer

A CALayer that displays video frames.

AVSampleBufferDisplayLayer.Notifications

Contains notifications for the AVSampleBufferDisplayLayer.

AVSampleBufferGenerator
AVSampleBufferRenderSynchronizer

Synchronizes multiple queued sample buffers.

AVSampleBufferRenderSynchronizer.Notifications
AVSampleBufferRequest
AVSampleCursor
AVSampleRateEventArgs

Provides data for the SampleRateChanged event.

AVSpeechSynthesisVoice

Interface to the provided voices for various languages.

AVSpeechSynthesizer

Synthesizes speech and raises events relating to text-to-speech.

AVSpeechSynthesizerDelegate

The delegate object for AVSpeechSynthesizers. Provides events relating to speech utterances.

AVSpeechSynthesizerDelegate_Extensions

Extension methods to the IAVSpeechSynthesizerDelegate interface to support all the methods from the AVSpeechSynthesizerDelegate protocol.

AVSpeechSynthesizerUteranceEventArgs

Provides data for the DidStartSpeechUtterance, DidStartSpeechUtterance, E:AVFoundation.AVSpeechSynthesizerUteranceEventArgs.DidFinishSpeechUtterance, E:AVFoundation.AVSpeechSynthesizerUteranceEventArgs.DidPauseSpeechUtterance and E:AVFoundation.AVSpeechSynthesizerUteranceEventArgs.DidStartSpeechUtterance events.

AVSpeechSynthesizerWillSpeakEventArgs

Provides data for the WillSpeakRangeOfSpeechString event.

AVSpeechUtterance

A spoken word, statement, or sound. Used with AVSpeechSynthesizer.

AVStatusEventArgs

Provides data for the InputAvailabilityChanged and InputAvailabilityChanged and E:AVFoundation.AVStatusEventArgs.InputAvailabilityChanged events.

AVStreamingKeyDelivery
AVSynchronizedLayer

A CALayer whose sublayers gain timing information from a AVPlayerItem.

AVTextStyleRule

A class that applies text styling to media item elements such as subtitles, closed captions, etc.

AVTimedMetadataGroup

An immutable collection of metadata items. (See AVMutableTimedMetadataGroup.

AVUrlAsset

A AVAsset that loads an asset from a URL.

AVUrlAssetOptions

Represents options used to construct AVUrlAsset object

AVUtilities

Defines an extension method for RectangleF that generates another rectangle with a specified aspect ratio.

AVVideo

A class whose static members encapsulate AV Foundation constants.

AVVideoApertureModeExtensions

Extension methods for the AVVideoApertureMode enumeration.

AVVideoCleanApertureSettings

Manages clean aperture settings.

AVVideoCodecSettings

Manages video codec compression settings.

AVVideoCodecTypeExtensions

Extension methods for the AVVideoCodecType enumeration.

AVVideoColorPrimaries

Contains constants that identify video color primaries.

AVVideoCompositing

A base class for custom video compositors.

AVVideoCompositing_Extensions

Extension methods to the IAVVideoCompositing interface to support all the methods from the AVVideoCompositing protocol.

AVVideoComposition

An immutable video composition. (See AVMutableVideoComposition.)

AVVideoCompositionCoreAnimationTool

Allows Core Animation to be used in a video composition.

AVVideoCompositionInstruction

An operation performed by an AVVideoComposition.

AVVideoCompositionLayerInstruction

The transform and opacity ramps for a track.

AVVideoCompositionRenderContext

Encapsulates the context in which a custom AVVideoCompositing generates a new pixel buffer.

AVVideoCompositionValidationHandling

Methods that specify whether validation should continue after errors occur. Passed to IsValidForAsset(AVAsset, CMTimeRange, IAVVideoCompositionValidationHandling).

AVVideoCompositionValidationHandling_Extensions

Extension methods to the IAVVideoCompositionValidationHandling interface to support all the methods from the AVVideoCompositionValidationHandling protocol.

AVVideoPixelAspectRatioSettings

Manages a pixel aspect settings.

AVVideoScalingModeKey

A class whose static members define how scaling should behave for different sizes and aspect ratios

AVVideoSettingsCompressed

Manages video compression configuring and compression settings for video assets.

AVVideoSettingsUncompressed

Manages configuration for uncompressed video.

AVVideoTransferFunction
AVVideoYCbCrMatrix

Structs

AVAudio3DAngularOrientation

Holds the angular orientation of the listener in 3D space.

AVAudio3DVectorOrientation

Defines the listener's position in 3D space as orthogonal 'Up' and 'Forward' vectors.

AVAudioConverterPrimeInfo

Audio conversion priming information.

AVBeatRange

Defines a range within a specific AVMusicTrack.

AVCaptureWhiteBalanceChromaticityValues

Structure holding CIE 1931 xy chromaticity values.

AVCaptureWhiteBalanceGains

Contains RGB gain values for white balance.

AVCaptureWhiteBalanceTemperatureAndTintValues

Values used for white-balancing; including correlated temperatures and tints.

AVEdgeWidths

A class that encapsulates the edge-widths used by an AVVideoCompositionRenderContext.

AVPixelAspectRatio

Encapsulates the aspect ratio of a pixel. Used with PixelAspectRatio.

AVSampleCursorChunkInfo

Contains media sample chunk metadata.

AVSampleCursorDependencyInfo

Contains media sample interdependency data for a sample and other samples in the sequence.

AVSampleCursorStorageRange

Contains the location and size of a media sample or chunk.

AVSampleCursorSyncInfo

Contains media sample synchronization attributes.

Interfaces

IAVAssetDownloadDelegate

Interface representing the required methods (if any) of the protocol AVAssetDownloadDelegate.

IAVAssetResourceLoaderDelegate

Interface representing the required methods (if any) of the protocol AVAssetResourceLoaderDelegate.

IAVAsynchronousKeyValueLoading

Interface representing the required methods (if any) of the protocol AVAsynchronousKeyValueLoading.

IAVAudio3DMixing

Interface representing the required methods (if any) of the protocol AVAudio3DMixing.

IAVAudioMixing

Defines properties for the input bus of a mixer node.

IAVAudioPlayerDelegate

Interface representing the required methods (if any) of the protocol AVAudioPlayerDelegate.

IAVAudioRecorderDelegate

Interface representing the required methods (if any) of the protocol AVAudioRecorderDelegate.

IAVAudioSessionDelegate

Interface representing the required methods (if any) of the protocol AVAudioSessionDelegate.

IAVAudioStereoMixing

Interface representing the required methods (if any) of the protocol AVAudioStereoMixing.

IAVCaptureAudioDataOutputSampleBufferDelegate

Interface representing the required methods (if any) of the protocol AVCaptureAudioDataOutputSampleBufferDelegate.

IAVCaptureDataOutputSynchronizerDelegate

Delegate for capturing synchronized AV data.

IAVCaptureDepthDataOutputDelegate

Interface representing the required methods (if any) of the protocol AVCaptureDepthDataOutputDelegate.

IAVCaptureFileOutputDelegate
IAVCaptureFileOutputRecordingDelegate

Interface representing the required methods (if any) of the protocol AVCaptureFileOutputRecordingDelegate.

IAVCaptureMetadataOutputObjectsDelegate

Interface representing the required methods (if any) of the protocol AVCaptureMetadataOutputObjectsDelegate.

IAVCapturePhotoCaptureDelegate

Interface representing the required methods (if any) of the protocol AVCapturePhotoCaptureDelegate.

IAVCapturePhotoFileDataRepresentationCustomizer
IAVCaptureVideoDataOutputSampleBufferDelegate

Interface representing the required methods (if any) of the protocol AVCaptureVideoDataOutputSampleBufferDelegate.

IAVContentKeyRecipient

Interface defining required methods that require decryption keys for media data processing.

IAVContentKeySessionDelegate

Interface representing the required methods (if any) of the protocol AVContentKeySessionDelegate.

IAVFragmentMinding

Interface for to support tracking whether fragments have been appended to a fragmented asset.

IAVPlayerItemLegibleOutputPushDelegate

Interface representing the required methods (if any) of the protocol AVPlayerItemLegibleOutputPushDelegate.

IAVPlayerItemMetadataCollectorPushDelegate

Interface representing the required methods (if any) of the protocol AVPlayerItemMetadataCollectorPushDelegate.

IAVPlayerItemMetadataOutputPushDelegate

Interface representing the required methods (if any) of the protocol AVPlayerItemMetadataOutputPushDelegate.

IAVPlayerItemOutputPullDelegate

Interface representing the required methods (if any) of the protocol AVPlayerItemOutputPullDelegate.

IAVPlayerItemOutputPushDelegate

Interface representing the required methods (if any) of the protocol AVPlayerItemOutputPushDelegate.

IAVQueuedSampleBufferRendering

Interface defining methods for queueing sample buffers for presentation.

IAVSpeechSynthesizerDelegate

Interface representing the required methods (if any) of the protocol AVSpeechSynthesizerDelegate.

IAVVideoCompositing

Interface representing the required methods (if any) of the protocol AVVideoCompositing.

IAVVideoCompositionValidationHandling

Interface representing the required methods (if any) of the protocol AVVideoCompositionValidationHandling.

Enums

AVAssetDownloadedAssetEvictionPriority
AVAssetExportSessionPreset

Enumerates presets for asset export sessions.

AVAssetExportSessionStatus

Status flag of the export operation.

AVAssetImageGeneratorResult

An enumeration whose values indicate the result of image generation.

AVAssetReaderStatus

An enumeration whose values specify the AVAssetReader's status.

AVAssetReferenceRestrictions

An enumeration whose values define restrictions relating to a AVAsset.

AVAssetWriterInputMediaDataLocation
AVAssetWriterStatus

An enumeration whose values represent the status of an AVAssetWriter object.

AVAudio3DMixingRenderingAlgorithm

Enumerates valid 3D audio-rendering algorithms.

AVAudioBitRateStrategy

An enumeration whose values specify the type of audio bit-rate. Used with BitRateStrategy

AVAudioCommonFormat

Enumerates formats for audio data (see CommonFormat).

AVAudioConverterInputStatus

Enumerates the state of the input stream.

AVAudioConverterOutputStatus

Enumerates the state of the output stream during audio conversion.

AVAudioConverterPrimeMethod

Enumerates the priming strategy for AVAudioConverterPrimeInfo.

AVAudioDataSourceLocation

Enumerates physical locations of data sources on AV devices.

AVAudioDataSourceOrientation

Enumerates physical orientations of data sources on AV devices.

AVAudioDataSourcePolarPattern

Enumerates microphone directivity values.

AVAudioEngineManualRenderingError

Error codes for manual rendering errors.

AVAudioEngineManualRenderingMode

Enumerates whether manual rendering is done offline or under real-time constraints.

AVAudioEngineManualRenderingStatus

Enumerates status of manual rendering.

AVAudioEnvironmentDistanceAttenuationModel

Enumerates attenuation models used by AVAudioEnvironmentDistanceAttenuationParameters.

AVAudioPlayerNodeBufferOptions

Flagging enumeration whose values are valid options in calls to ScheduleBufferAsync(AVAudioPcmBuffer, AVAudioTime, AVAudioPlayerNodeBufferOptions, AVAudioPlayerNodeCompletionCallbackType)

AVAudioPlayerNodeCompletionCallbackType
AVAudioQuality

Represents sample rate conversion quality used by audio encoder.

AVAudioSessionActivationOptions
AVAudioSessionCategory

Enumeration defining the various audio categories supported by AVAudioSession.

AVAudioSessionCategoryOptions

An enumeration whose values specify optional audio behaviors.

AVAudioSessionErrorCode

An enumeration whose values specify various errors relating to AVAudioSessions.

AVAudioSessionFlags

Flags passed to AVAudioSession.SetActive

AVAudioSessionInterruptionFlags

An enumeration whose values can be used as flags in EndInterruption(IAVAudioSessionDelegate, AVAudioSessionInterruptionFlags).

AVAudioSessionInterruptionOptions

An enumeration whose values specify optional audio behaviors.

AVAudioSessionInterruptionType

An enumeration whose values specify the beginning and ending of an audio interruption.

AVAudioSessionIOType
AVAudioSessionPortOverride

An enumeration whose values define whether an audio session should override the audio port and output via the built-in speaker.

AVAudioSessionRecordPermission

Enumerates valid permissions for AVAudioSession.

AVAudioSessionRouteChangeReason

An enumeration whose values specify why an audio route changed.

AVAudioSessionRouteSharingPolicy
AVAudioSessionSetActiveOptions

An enumeration whose values define whether, after an audio session deactivates, previously interrupted audio sessions should or should not re-activate.

AVAudioSessionSilenceSecondaryAudioHintType

Enumerates the valid values for Hint.

AVAudioUnitDistortionPreset

Enumerates valid values that can be passed to LoadFactoryPreset(AVAudioUnitDistortionPreset).

AVAudioUnitEQFilterType

Filter types. Used with the FilterType property.

AVAudioUnitReverbPreset

Enumerates constants describing the reverb presets.

AVAuthorizationMediaType
AVAuthorizationStatus

An enumeration whose values specify whether a AVCaptureDevice has been authorized by the user for use. Used with GetAuthorizationStatus(NSString).

AVCaptureAutoFocusRangeRestriction

An enumeration whose values specify hints to autofocus. Used with AutoFocusRangeRestriction.

AVCaptureAutoFocusSystem

Enumerates constants relating to the device's autofocus system.

AVCaptureColorSpace

Enumerates video capture color spaces.

AVCaptureDevicePosition

An enumeration whose values specify the position of a AVCaptureDevice.

AVCaptureDeviceTransportControlsPlaybackMode

An enumeration whose values specify whether a AVCaptureDevice is playing or not.

AVCaptureDeviceType

Enumerates the types of device that can capture audiovisual data.

AVCaptureExposureMode

An enumeration whose values specify options for varying exposure modes during capture.

AVCaptureFlashMode

Flash mode.

AVCaptureFocusMode

Auto focus states.

AVCaptureLensStabilizationStatus

Enumerates states for physical image stabilization hardware.

AVCaptureOutputDataDroppedReason

Enumerates reasons for dropped capture data.

AVCaptureSessionInterruptionReason

Enumerates ways that a capture session can be interrupted.

AVCaptureSystemPressureFactors
AVCaptureSystemPressureLevel
AVCaptureTorchMode

The capture device torch mode.

AVCaptureVideoOrientation

Video capture orientation.

AVCaptureVideoPreviewLayer.InitMode

Enumerates values that specify the presence or absence of a capture session connection.

AVCaptureVideoStabilizationMode

Enumerates types of video stabilization supported by the device's format.

AVCaptureWhiteBalanceMode

Capture white balance mode.

AVContentAuthorizationStatus
AVContentKeyRequestRetryReason
AVContentKeyRequestStatus
AVContentKeySystem

Enumerates delivery methods for content keys.

AVDepthDataAccuracy

Enumerates depth data accuracy types.

AVDepthDataQuality
AVError

An enumeration whose values define various audiovisual errors.

AVFileTypes

Enumerates universal type information for AVFoundation file types.

AVKeyValueStatus

An enumeration whose values specify the load status of a given property.

AVLayerVideoGravity

An enumeration whose values specify how a video should resize itself to display within a layer's Bounds.

AVMediaCharacteristics

Enumerates media characteristics.

AVMediaTypes

Enumerates media types.

AVMetadataFormat
AVMetadataObjectType

Enumerates barcode descriptions.

AVMovieWritingOptions
AVMusicSequenceLoadOptions
AVMusicTrackLoopCount

Enumerates loop count limits.

AVPlayerActionAtItemEnd

An enumeration whose values specify the behavior of the player when it finishes playing.

AVPlayerHdrMode
AVPlayerItemStatus

An enumeration whose values specify the status of a AVPlayerItem.

AVPlayerLooperStatus

Enumerates the states of an AVPlayerLooper object.

AVPlayerStatus

An enumeration whose values indicate the status of an AVPlayer.

AVPlayerTimeControlStatus

Enumerates allowable time TimeControlStatus values.

AVQueuedSampleBufferRenderingStatus

P:AVFoundation.AVSampleBuffer.Status

AVSampleBufferRequestDirection
AVSampleBufferRequestMode
AVSampleRateConverterAlgorithm

P:AVFoundation.AVAudioSettings.SampleRateConverterAlgorithm

AVSpeechBoundary

An enumeration whose values specify whether the AVSpeechSynthesizer should pause or stop immediately or complete an entire word.

AVSpeechSynthesisVoiceQuality

Enumerates the quality of speech synthesis.

AVVideoApertureMode
AVVideoCodec

An enumeration that specifies whether the video code is H264 or JPEG

AVVideoCodecType

Constants for known video codecs.

AVVideoFieldMode

An enumeration whose values specify how interlaced fields should be dealt with.

AVVideoH264EntropyMode

An enumeration whose values specify values for EntropyEncoding.

AVVideoProfileLevelH264

Video profile levels.

AVVideoScalingMode

Specifies how video should be scaled to fit a given area.

Delegates

AVAssetImageGeneratorCompletionHandler

A delegate that defines the handler for GenerateCGImagesAsynchronously(NSValue[], AVAssetImageGeneratorCompletionHandler).

AVAudioConverterInputHandler
AVAudioEngineManualRenderingBlock
AVAudioIONodeInputBlock
AVAudioNodeTapBlock

Delegate that receives copies of the output of a AVAudioNode

AVAudioUnitComponentFilter
AVCaptureCompletionHandler

A delegate for the completion handler of CaptureStillImageAsynchronously(AVCaptureConnection, AVCaptureCompletionHandler).

AVCompletion

A delegate that defines the completion handler for various methods in AVPlayer and AVPlayerItem

AVPermissionGranted

The delegate for RequestRecordPermission(AVPermissionGranted).

AVRequestAccessStatus

The delegate for RequestAccessForMediaTypeAsync(NSString).

Remarks

This namespace contains high-level recording and playback capabilities for audio and video.

This library sits on top of CoreMedia, CoreAudio and CoreVideo but does not provide any user interface elements for UIKit. It is a toolkit for recording and playing back audio and video.

AV Foundation uses background processing extensively. Application developers should take care to ensure thread safety and use InvokeOnMainThread or other technique when updating their user interface.

AVFoundation is not necessary for some common tasks:

TaskTechnique
Display videoUse Media Player's MPMoviePlayerController or MPMoviePlayerViewController.
Capture a photograph or videoUse UIKit's UIImagePickerController
Play audio filesUse AV Foundation's AVAudioPlayer.
Capture audio filesUse AV Foundation's AVAudioRecorder, as discussed below in "Capture Audio Files".
Complex video display or audio playbackUse AV Foundation, as discussed below in "Custom Playback".
Custom media captureUse AV Foundation, as discussed below in "Custom Media Capture".
Media file writing, reading, and transcodingUse AV Foundation, as discussed below in "Media file writing, reading, and transcoding".
Media editingUse UIKit's T:UIKit.UIVideoKitController or AV Foundation building blocks.
Barcode recognition and face detectionUse AV Foundation, as discussed below in "Live Recognition".
Speech synthesisUse AV Foundation, as discussed below in "Speech synthesis".

An AVAsset represents one or more media assets. These are held in its Tracks property. Additionally, AVAssets include metadata, track grouping, and preferences about the media.

Because media assets such as movies are large, instantiating an AVAsset will not automatically load the file. Properties are loaded when they are queried or via explicit calls to LoadValuesTaskAsync or LoadValuesAsynchronously.

Capture Audio Files

The application developer must first interaction with the static singleton Audio Session object, which mediates sound between the app and the operating system. Both AudioSession and AVAudioSession refer to this same underlying singleton. Most properties in AudioSession are deprecated in iOS 7 and later and application developers should prefer the properties in AVAudioSession.

TaskUsing AVAudioSessionUsing AudioSession
Initialization SharedInstance (explicit initialization not required) M:AudioToolbox.AudioSession.Initialize(CFRunLoop,string)
Set category M:AVFoundation.AVAudioSession.SetCategory(string, out NSError) Category
Set active M:AVFoundation.AVAudioSession.SetActive(bool, out NSError) P:AudioToolbox.AudioSession.Active

The following code shows the necessary steps for preparing for audio recording.


var session = AVAudioSession.SharedInstance();

NSError error = null; session.SetCategory(AVAudioSession.CategoryRecord, out error); if(error != null){ Console.WriteLine(error); return; }

session.SetActive(true, out error); if(error != null){ Console.WriteLine(error); return; }

//Declare string for application temp path and tack on the file extension string fileName = string.Format("Myfile{0}.aac", DateTime.Now.ToString("yyyyMMddHHmmss")); string tempRecording = NSBundle.MainBundle.BundlePath + "/../tmp/" + fileName;

Console.WriteLine(tempRecording); this.audioFilePath = NSUrl.FromFilename(tempRecording);

var audioSettings = new AudioSettings() { SampleRate = 44100.0f, Format = MonoTouch.AudioToolbox.AudioFormatType.MPEG4AAC, NumberChannels = 1, AudioQuality = AVAudioQuality.High };

//Set recorder parameters NSError error; recorder = AVAudioRecorder.Create(this.audioFilePath, audioSettings, out error); if((recorder == null) || (error != null)) { Console.WriteLine(error); return false; }

//Set Recorder to Prepare To Record if(!recorder.PrepareToRecord()) { recorder.Dispose(); recorder = null; return false; }

recorder.FinishedRecording += delegate (object sender, AVStatusEventArgs e) { recorder.Dispose(); recorder = null; Console.WriteLine("Done Recording (status: {0})", e.Status); };

recorder.Record();

Custom Playback

T:AVFoundation.Player objects use AVPlayerItem objects to play media. An AVPlayerItem encapsulates the presentation state of an AVAsset.

Custom Media Capture

Many capture scenarios can be satisfied with the easier-to-use UIImagePickerController and AVAudioRecorder classes. More complex scenarios can use AV Foundation's AVCaptureSession and related classes.

A AVCaptureSession will typically have one or more AVCaptureInputs and one or more AVCaptureOutputs. Each AVCaptureInput will have a AVCaptureDevice for a specific media type (audio or video). Each T:AVFoundation.AVCaptureOuput will have a "buffer delegate" that will be repeatedly called with incoming data that it can render, write to file, analyze, etc.

The following diagram and source code shows the initialization sequence of the

AVCaptureFrames Sample .


session = new AVCaptureSession () {
	SessionPreset = AVCaptureSession.PresetMedium
};

// create a device input and attach it to the session var captureDevice = AVCaptureDevice.DefaultDeviceWithMediaType(AVMediaType.Video); if (captureDevice == null){ Console.WriteLine ("No captureDevice - this won't work on the simulator, try a physical device"); return false; } // If you want to cap the frame rate at a given speed, in this sample: 15 frames per second NSError error = null; captureDevice.LockForConfiguration(out error); if(error != null){ Console.WriteLine(error); captureDevice.UnlockForConfiguration(); return false; } captureDevice.ActiveVideoMinFrameDuration = new CMTime(1, 15); captureDevice.UnlockForConfiguration();

var input = AVCaptureDeviceInput.FromDevice (captureDevice); if (input == null){ Console.WriteLine ("No input - this won't work on the simulator, try a physical device"); return false; } session.AddInput (input);

// create a VideoDataOutput and add it to the sesion var output = new AVCaptureVideoDataOutput () { VideoSettings = new AVVideoSettings (CVPixelFormatType.CV32BGRA), };

// configure the output queue = new MonoTouch.CoreFoundation.DispatchQueue ("myQueue"); outputRecorder = new OutputRecorder (); output.SetSampleBufferDelegate (outputRecorder, queue); session.AddOutput (output);

session.StartRunning ();

Note that the outputRecorder is a custom subclass of AVCaptureVideoDataOutputSampleBufferDelegate. In this case, the incoming data is converted into a CIImage, to which a CIColorInvert filter is applied before being sent to the display.


public class OutputRecorder : AVCaptureVideoDataOutputSampleBufferDelegate {
readonly CIColorInvert filter;

public OutputRecorder()
{
	filter = new CIColorInvert();
} 
public override void DidOutputSampleBuffer (AVCaptureOutput captureOutput, CMSampleBuffer sampleBuffer, AVCaptureConnection connection)
{
	try {
		var image = ImageFromSampleBuffer (sampleBuffer);
		filter.Image = image;

		// Do something with the image, we just stuff it in our main view.
		AppDelegate.ImageView.BeginInvokeOnMainThread (delegate {
			AppDelegate.ImageView.Image = UIImage.FromImage(filter.OutputImage);
		});

		//
		// Although this looks innocent "Oh, he is just optimizing this case away"
		// this is incredibly important to call on this callback, because the AVFoundation
		// has a fixed number of buffers and if it runs out of free buffers, it will stop
		// delivering frames. 
		//	
		sampleBuffer.Dispose ();
	} catch (Exception e){
		Console.WriteLine (e);
	}
}

CIImage ImageFromSampleBuffer (CMSampleBuffer sampleBuffer)
{
	// Get the CoreVideo image
	using (var pixelBuffer = sampleBuffer.GetImageBuffer () as CVPixelBuffer){
		// Lock the base address
		pixelBuffer.Lock (0);
		// Get the number of bytes per row for the pixel buffer
		var baseAddress = pixelBuffer.BaseAddress;
		int bytesPerRow = pixelBuffer.BytesPerRow;
		int width = pixelBuffer.Width;
		int height = pixelBuffer.Height;
		var flags = CGBitmapFlags.PremultipliedFirst | CGBitmapFlags.ByteOrder32Little;
		// Create a CGImage on the RGB colorspace from the configured parameter above
		using (var cs = CGColorSpace.CreateDeviceRGB ())
		using (var context = new CGBitmapContext (baseAddress,width, height, 8, bytesPerRow, cs, (CGImageAlphaInfo) flags))
		using (var cgImage = context.ToImage ()){
			pixelBuffer.Unlock (0);
			return cgImage;
		}
	}
}

}

Video can be captured directly to file with AVCaptureMovieFileOutput. However, this class has no display-able data and cannot be used simultaneously with AVCaptureVideoDataOutput. Instead, application developers can use it in combination with a AVCaptureVideoPreviewLayer, as shown in the following example:


var session = new AVCaptureSession();

var camera = AVCaptureDevice.DefaultDeviceWithMediaType(AVMediaType.Video); var mic = AVCaptureDevice.DefaultDeviceWithMediaType(AVMediaType.Audio); if(camera == null || mic == null){ throw new Exception("Can't find devices"); }

if(session.CanAddInput(camera)){ session.AddInput(camera); } if(session.CanAddInput(mic)){ session.AddInput(mic); }

var layer = new AVCaptureVideoPreviewLayer(session); layer.LayerVideoGravity = AVLayerVideoGravity.ResizeAspectFill; layer.VideoGravity = AVCaptureVideoPreviewLayer.GravityResizeAspectFill;

var cameraView = new UIView(); cameraView.Layer.AddSublayer(layer);

var filePath = System.IO.Path.Combine( Path.GetTempPath(), "temporary.mov"); var fileUrl = NSUrl.FromFilename( filePath );

var movieFileOutput = new AVCaptureMovieFileOutput(); var recordingDelegate = new MyRecordingDelegate(); session.AddOutput(movieFileOutput);

movieFileOutput.StartRecordingToOutputFile( fileUrl, recordingDelegate);

Application developers should note that the function T:AVFoundation.AVCaptureMovieFileOutput.StopRecording is asynchronous; developers should wait until the FinishedRecording delegate method before manipulating the file (for instance, before saving it to the Photos album with SaveToPhotosAlbum or WriteVideoToSavedPhotosAlbumAsync).

Media file writing, reading, and transcoding

The following is the official list of supported audio formats for iOS 7:

  • AAC
  • Apple Lossless (ALAC)
  • A-law
  • IMA/ADPCM (IMA4)
  • Linear PCM
  • ยต-law
  • DVI/Intel IMA ADPCM
  • Microsoft GSM 6.10
  • AES3-2003

And the following video formats:

  • H.264 video, up to 1.5 Mbps, 640 by 480 pixels, 30 frames per second, Low-Complexity version of the H.264 Baseline Profile with AAC-LC audio up to 160 Kbps, 48 kHz, stereo audio in .m4v, .mp4, and .mov file formats
  • H.264 video, up to 768 Kbps, 320 by 240 pixels, 30 frames per second, Baseline Profile up to Level 1.3 with AAC-LC audio up to 160 Kbps, 48 kHz, stereo audio in .m4v, .mp4, and .mov file formats
  • MPEG-4 video, up to 2.5 Mbps, 640 by 480 pixels, 30 frames per second, Simple Profile with AAC-LC audio up to 160 Kbps, 48 kHz, stereo audio in .m4v, .mp4, and .mov file formats

This list is incomplete: the iPhone 5S, for example, natively captures at 1280 x 720.

Reading a media file is done with an AVAssetReader. As with many AV Foundation classes, this provides data in an asynchronous manner. The Outputs property contains AVAssetReaderOutput objects. The CopyNextSampleBuffer method on these objects will be called periodically as the AVAssetReader processes the underlying Asset.

Writing a media file can be done with an AVAssetWriter, but in a media-capture session is more often done with a AVAudioRecorder, a AVCaptureMovieFileOutput, or using UIImagePickerController. The advantage of AVAssetWriter is that it uses hardware encoding.

Live Recognition

iOS can recognize barcodes and faces being captured from video devices.

The following example demonstrates how to recognize QR and EAN13 barcodes. The AVCaptureSession is configured and a T:AFoundation.AVCaptureMetadataOutput is added to it. A MyMetadataOutputDelegate, a subclass of AVCaptureMetadataOutputObjectsDelegate is assigned to its P:AVFoundation.AVCaptureMetadataObject.Delegate property.

The MetadataObjectTypes array must be set after the AVCaptureMetadataOutput has been added to the T:AVFoundation.AVSession.

This example shows a simple subclass of AVCaptureMetadataOutputObjectsDelegate that raises an event when a barcode is recognized.


session = new AVCaptureSession();
var camera = AVCaptureDevice.DefaultDeviceWithMediaType(AVMediaType.Video);
var input = AVCaptureDeviceInput.FromDevice(camera);
session.AddInput(input);

//Add the metadata output channel metadataOutput = new AVCaptureMetadataOutput(); var metadataDelegate = new MyMetadataOutputDelegate(); metadataOutput.SetDelegate(metadataDelegate, DispatchQueue.MainQueue); session.AddOutput(metadataOutput); //Confusing! After adding to session, tell output what to recognize... metadataOutput.MetadataObjectTypes = new NSString[] { AVMetadataObject.TypeQRCode, AVMetadataObject.TypeEAN13Code }; //...etc... public class MyMetadataOutputDelegate : AVCaptureMetadataOutputObjectsDelegate { public override void DidOutputMetadataObjects(AVCaptureMetadataOutput captureOutput, AVMetadataObject[] metadataObjects, AVCaptureConnection connection) { foreach(var m in metadataObjects) { if(m is AVMetadataMachineReadableCodeObject) { MetadataFound(this, m as AVMetadataMachineReadableCodeObject); } } }

public event EventHandler&amp;lt;AVMetadataMachineReadableCodeObject&amp;gt; MetadataFound = delegate {};

}

Speech Synthesis

In iOS 7 and later, AV Foundation supports speech synthesis using voices that are localized for the language and locale.

In its simplest form, text-to-speech can be done with just two classes:


var ss = new AVSpeechSynthesizer();
var su = new AVSpeechUtterance("Microphone check. One, two, one two.") {
Rate = 0.25f
};
ss.SpeakUtterance(su);

The AVSpeechSynthesizer maintains an internal queue of AVSpeechUtterances. The queue is not accessible to application developers, but the synthesizer can be paused or stopped with PauseSpeaking and StopSpeaking. Events such as DidStartSpeechUtterance or WillSpeakRangeOfSpeechString are opportunities for the application developer to modify previously-enqueued sequences.