| # AirPlay Session Platform APIs
Includes: | "AirPlayCommon.h" "AirPlayReceiverServer.h" "APSCommonServices.h" "APSDebugServices.h" "CFUtils.h" "NetUtils.h"
## Introduction Platform APIs related to AirPlay Session. ## Groups ### AirPlayReceiverSessionDelegate Allows functionality to be delegated to external code. #### Group members: `AirPlayReceiverPlatformFinalize` Finalizes the platform-specific aspects of the session. Called once per session before it is deleted. `AirPlayReceiverSessionChangeModes` Builds and sends a mode change request to the controller. `AirPlayReceiverSessionCommandCompletionFunc` Sends a command to the controller and calls a completion function with the response. `AirPlayReceiverSessionFlushAudio` Flush any queued audio until the specified timestamp or sequence number. `AirPlayReceiverSessionForceKeyFrame` Builds and sends a key frame request to the sender side via the control channel. `AirPlayReceiverSessionMakeModeStateFromDictionary` Parses a mode state dictionary (e.g. from a ModesChanged command) into an AirPlayModeState structure. `AirPlayReceiverSessionPlatformControl` Controls the platform-specific aspects of the session. `AirPlayReceiverSessionPlatformCopyProperty` Copies a platform-specific property from the session. `AirPlayReceiverSessionPlatformFinalize` Finalizes the platform-specific aspects of the session. Called once per session before it is deleted. `AirPlayReceiverSessionPlatformInitialize` Initializes the platform-specific aspects of the session. Called once per session after it is created. `AirPlayReceiverSessionPlatformSetProperty` Sets a platform-specific property on the session. `AirPlayReceiverSessionReadAudio` Reads output audio (e.g. music to play on the accessory) that has been received by the accessory. `AirPlayReceiverSessionRequestSiriAction` Builds and sends Siri action command to the controller. `AirPlayReceiverSessionRequestUI` Builds and sends request UI command to the controller. `AirPlayReceiverSessionSendCommand` Sends a command to the controller and calls a completion function with the response. `AirPlayReceiverSessionSetLimitedUI` Builds and sends set limited UI command to the controller. `AirPlayReceiverSessionSetNightMode` Builds and sends set night mode command to the controller. ## Functions `AirPlayReceiverPlatformFinalize` Finalizes the platform-specific aspects of the session. Called once per session before it is deleted. `AirPlayReceiverSessionChangeModes` Builds and sends a mode change request to the controller. `AirPlayReceiverSessionControl` Controls the session. `AirPlayReceiverSessionCopyProperty` Copies a property from the session. `AirPlayReceiverSessionFlushAudio` Flush any queued audio until the specified timestamp or sequence number. `AirPlayReceiverSessionForceKeyFrame` Builds and sends a key frame request to the sender side via the control channel. `AirPlayReceiverSessionMakeModeStateFromDictionary` Parses a mode state dictionary (e.g. from a ModesChanged command) into an AirPlayModeState structure. `AirPlayReceiverSessionPlatformControl` Controls the platform-specific aspects of the session. `AirPlayReceiverSessionPlatformCopyProperty` Copies a platform-specific property from the session. `AirPlayReceiverSessionPlatformFinalize` Finalizes the platform-specific aspects of the session. Called once per session before it is deleted. `AirPlayReceiverSessionPlatformInitialize` Initializes the platform-specific aspects of the session. Called once per session after it is created. `AirPlayReceiverSessionPlatformSetProperty` Sets a platform-specific property on the session. `AirPlayReceiverSessionReadAudio` Reads output audio (e.g. music to play on the accessory) that has been received by the accessory. `AirPlayReceiverSessionRequestSiriAction` Builds and sends Siri action command to the controller. `AirPlayReceiverSessionRequestUI` Builds and sends request UI command to the controller. `AirPlayReceiverSessionSetLimitedUI` Builds and sends set limited UI command to the controller. `AirPlayReceiverSessionSetNightMode` Builds and sends set night mode command to the controller. `AirPlayReceiverSessionSetProperty` Sets a property on the session. `AirPlayReceiverSessionSetup` Sets up an AirPlay receiver session. @params inRequestParams Input parameters used to configure or update the session. `AirPlayReceiverSessionTearDown` Sets up an AirPlay receiver session. ### AirPlayReceiverPlatformFinalize Finalizes the platform-specific aspects of the session. Called once per session before it is deleted.
    void AirPlayReceiverSessionPlatformFinalize(
        AirPlayReceiverSessionRef inSession );
##### Discussion This gives the platform a chance to clean up any per-session state. This must handle being called during a partial initialization (e.g. failure mid-way through initialization). In certain situations, this may be called without of a TearDownStreams control request so it needs to clean up all per-session state. ### AirPlayReceiverSessionChangeModes Builds and sends a mode change request to the controller.
    OSStatus AirPlayReceiverSessionChangeModes(
        AirPlayReceiverSessionRef inSession,
        const AirPlayModeChanges *inChanges,
        CFStringRef inReason,
        AirPlayReceiverSessionCommandCompletionFunc inCompletion,
        void *inContext );
##### Parameters `inSession` Session to request a mode change on. `inChanges` Changes being request. Initialize with AirPlayModeChangesInit() then set fields. `inReason` Optional reason for the change. Mainly for diagnostics. May be NULL. `inCompletion` Optional completion function to call when the request completes. May be NULL. `inContext` Optional context ptr to pass to completion function. May be NULL. ### AirPlayReceiverSessionControl Controls the session.
    OSStatus AirPlayReceiverSessionControl(
        CFTypeRef inSession, // Must be a AirPlayReceiverSessionRef.
        uint32_t inFlags,
        CFStringRef inCommand,
        CFTypeRef inQualifier,
        CFDictionaryRef inParams,
        CFDictionaryRef *outParams );
### AirPlayReceiverSessionCopyProperty Copies a property from the session.
    CF_RETURNS_RETAINED CFTypeRef AirPlayReceiverSessionCopyProperty(
        CFTypeRef inSession, // Must be AirPlayReceiverSessionRef.
        uint32_t inFlags,
        CFStringRef inProperty,
        CFTypeRef inQualifier,
        OSStatus *outErr );
### AirPlayReceiverSessionFlushAudio Flush any queued audio until the specified timestamp or sequence number.
    OSStatus AirPlayReceiverSessionFlushAudio(
        AirPlayReceiverSessionRef inSession,
        uint32_t inFlushUntilTS,
        uint16_t inFlushUntilSeq,
        uint32_t *outLastTS );
### AirPlayReceiverSessionForceKeyFrame Builds and sends a key frame request to the sender side via the control channel.
    OSStatus AirPlayReceiverSessionForceKeyFrame(
        AirPlayReceiverSessionRef inSession,
        AirPlayReceiverSessionCommandCompletionFunc inCompletion,
        void *inContext );
##### Parameters `inSession` Session from which to request a key frame. `inCompletion` Optional completion function to call when the request completes. May be NULL. `inContext` Optional context ptr to pass to completion function. May be NULL. ### AirPlayReceiverSessionMakeModeStateFromDictionary Parses a mode state dictionary (e.g. from a ModesChanged command) into an AirPlayModeState structure.
    OSStatus AirPlayReceiverSessionMakeModeStateFromDictionary(
        AirPlayReceiverSessionRef inSession,
        CFDictionaryRef inDict,
        AirPlayModeState *outModes );
##### Parameters `inSession` Session the dictionary came from. `inDict` Mode state dictionary to convert from. `outModes` Receives the parsed mode state. ### AirPlayReceiverSessionPlatformControl Controls the platform-specific aspects of the session.
    OSStatus AirPlayReceiverSessionPlatformControl(
        CFTypeRef inSession, // Must be a AirPlayReceiverSessionRef.
        uint32_t inFlags,
        CFStringRef inCommand,
        CFTypeRef inQualifier,
        CFDictionaryRef inParams,
        CFDictionaryRef *outParams );
### AirPlayReceiverSessionPlatformCopyProperty Copies a platform-specific property from the session.
    CF_RETURNS_RETAINED CFTypeRef AirPlayReceiverSessionPlatformCopyProperty(
        CFTypeRef inSession, // Must be a AirPlayReceiverSessionRef.
        uint32_t inFlags,
        CFStringRef inProperty,
        CFTypeRef inQualifier,
        OSStatus *outErr );
### AirPlayReceiverSessionPlatformFinalize Finalizes the platform-specific aspects of the session. Called once per session before it is deleted.
    void AirPlayReceiverSessionPlatformFinalize(
        AirPlayReceiverSessionRef inSession );
##### Discussion This gives the platform a chance to clean up any per-session state. This must handle being called during a partial initialization (e.g. failure mid-way through initialization). In certain situations, this may be called without of a TearDownStreams control request so it needs to clean up all per-session state. ### AirPlayReceiverSessionPlatformInitialize Initializes the platform-specific aspects of the session. Called once per session after it is created.
    OSStatus AirPlayReceiverSessionPlatformInitialize(
        AirPlayReceiverSessionRef inSession );
##### Discussion This gives the platform a chance to set up any per-session state. AirPlayReceiverSessionPlatformFinalize will be called when the session ends. ### AirPlayReceiverSessionPlatformSetProperty Sets a platform-specific property on the session.
    OSStatus AirPlayReceiverSessionPlatformSetProperty(
        CFTypeRef inSession, // Must be a AirPlayReceiverSessionRef.
        uint32_t inFlags,
        CFStringRef inProperty,
        CFTypeRef inQualifier,
        CFTypeRef inValue );
### AirPlayReceiverSessionReadAudio Reads output audio (e.g. music to play on the accessory) that has been received by the accessory.
    OSStatus AirPlayReceiverSessionReadAudio(
        AirPlayReceiverSessionRef inSession,
        AirPlayStreamType inType,
        uint32_t inSampleTime,
        uint64_t inHostTime,
        void *inBuffer,
        size_t inLen );
##### Parameters `inSession` Session to read audio from. `inType` Audio stream to read from. `inSampleTime` Audio sample time for the first sample to be placed in the buffer. `inHostTime` Wall clock time for when the first sample in the buffer should be heard. `inBuffer` Buffer to receive the audio samples. The format is configured during stream setup. `inLen` Number of bytes to fill into the buffer. ##### Discussion The flow of operation is that audio sent to the accessory for playback is received, de-packetized, decrypted, decoded, and buffered according to timing information in the stream. When the platform's audio stack needs the next chunk of audio to play, it calls this function to read the audio that has been buffered for the specified timestamp. If there isn't enough audio buffered to satisfy this request, the missing data will be filled in with a best guess or silence. The platform can then provide this audio data to its audio stack for playback. ### AirPlayReceiverSessionRequestSiriAction Builds and sends Siri action command to the controller.
    OSStatus AirPlayReceiverSessionRequestSiriAction(
        AirPlayReceiverSessionRef inSession,
        AirPlaySiriAction inAction,
        AirPlayReceiverSessionCommandCompletionFunc inCompletion,
        void *inContext );
##### Parameters `inSession` Session to request a mode change on. `inAction` Action to be performed (see kAirPlaySiriAction_*). ### AirPlayReceiverSessionRequestUI Builds and sends request UI command to the controller.
    OSStatus AirPlayReceiverSessionRequestUI(
        AirPlayReceiverSessionRef inSession,
        CFStringRef inURL,
        AirPlayReceiverSessionCommandCompletionFunc inCompletion,
        void *inContext );
##### Parameters `inSession` Session to request a mode change on. `inURL` Optional UI describing the UI to reuest (e.g. "http://maps.apple.com/?q" to show a map). `inCompletion` Optional completion function to call when the request completes. May be NULL. `inContext` Optional context ptr to pass to completion function. May be NULL. ### AirPlayReceiverSessionSetLimitedUI Builds and sends set limited UI command to the controller.
    OSStatus AirPlayReceiverSessionSetLimitedUI(
        AirPlayReceiverSessionRef inSession,
        Boolean inLimitUI,
        AirPlayReceiverSessionCommandCompletionFunc inCompletion,
        void *inContext );
##### Parameters `inSession` Session to request a mode change on. `inLimitUI` Whether or not to limit UI. `inCompletion` Optional completion function to call when the request completes. May be NULL. `inContext` Optional context ptr to pass to completion function. May be NULL. ### AirPlayReceiverSessionSetNightMode Builds and sends set night mode command to the controller.
    OSStatus AirPlayReceiverSessionSetNightMode(
        AirPlayReceiverSessionRef inSession,
        Boolean inNightMode,
        AirPlayReceiverSessionCommandCompletionFunc inCompletion,
        void *inContext );
##### Parameters `inSession` Session to request a mode change on. `inNightMode` Whether to enable or disable night mode. `inCompletion` Optional completion function to call when the request completes. May be NULL. `inContext` Optional context ptr to pass to completion function. May be NULL. ### AirPlayReceiverSessionSetProperty Sets a property on the session.
    OSStatus AirPlayReceiverSessionSetProperty(
        CFTypeRef inSession, // Must be AirPlayReceiverSessionRef.
        uint32_t inFlags,
        CFStringRef inProperty,
        CFTypeRef inQualifier,
        CFTypeRef inValue );
### AirPlayReceiverSessionSetup Sets up an AirPlay receiver session. @params inRequestParams Input parameters used to configure or update the session.
    OSStatus AirPlayReceiverSessionSetup(
        AirPlayReceiverSessionRef inSession,
        CFDictionaryRef inRequestParams,
        CFDictionaryRef *outResponseParams );
##### Parameters `outResponseParams` Output parameters to return to the client so it can configure/update its side of the session. ### AirPlayReceiverSessionTearDown Sets up an AirPlay receiver session.
    void AirPlayReceiverSessionTearDown(
        AirPlayReceiverSessionRef inSession,
        CFDictionaryRef inRequest,
        OSStatus inReason,
        Boolean *outDone );
##### Parameters `inSession` Session to apply tear down. `inRequest` Request describing streams to tear down. May be NULL if it was an unexpected tear down. `inReason` Reason for tearing down. kNoErr means a clean teardown. Other errors mean an unexpected teardown. `outDone` If non-NULL, receives true if session is done and can be deleted (or false to keep it alive). ## Typedefs `AirPlayReceiverSessionCommandCompletionFunc` Sends a command to the controller and calls a completion function with the response. `AirPlayReceiverSessionSendCommand` Sends a command to the controller and calls a completion function with the response. ### AirPlayReceiverSessionCommandCompletionFunc Sends a command to the controller and calls a completion function with the response.
    typedef void ( *AirPlayReceiverSessionCommandCompletionFunc )(
        OSStatus inStatus,
        CFDictionaryRef inResponse,
        void *inContext );
### AirPlayReceiverSessionSendCommand Sends a command to the controller and calls a completion function with the response.
    typedef void ( *AirPlayReceiverSessionCommandCompletionFunc )(
        OSStatus inStatus,
        CFDictionaryRef inResponse,
        void *inContext );
Last Updated: Friday, August 29, 2014