Table of Contents

Class Ap2Session

Namespace
AppleTvControlLibrary.Mrp.AirPlay
Assembly
AppleTvControlLibrary.Mrp.dll

High-level session for AirPlay 2: opens a control connection, runs pair-verify, and sets up the event and data-stream channels used to carry an MRP tunnel.

public sealed class Ap2Session : IDisposable
Inheritance
Ap2Session
Implements
Inherited Members

Remarks

Initializes a new instance of the Ap2Session class.

Constructors

Ap2Session(string, int, HapCredentials, Ap2InfoSettings?)

High-level session for AirPlay 2: opens a control connection, runs pair-verify, and sets up the event and data-stream channels used to carry an MRP tunnel.

public Ap2Session(string address, int controlPort, HapCredentials credentials, Ap2InfoSettings? info = null)

Parameters

address string

The remote AirPlay control address.

controlPort int

The remote AirPlay control port.

credentials HapCredentials

The previously-paired HAP credentials for the device.

info Ap2InfoSettings

Client identity reported to the device during setup.

Remarks

Initializes a new instance of the Ap2Session class.

Properties

DataChannel

Gets the data-stream channel that carries the MRP tunnel, once SetupRemoteControlAsync(CancellationToken) has completed.

public DataStreamChannel? DataChannel { get; }

Property Value

DataStreamChannel

Methods

ConnectAsync(CancellationToken)

Open the control connection and perform pair-verify.

public Task ConnectAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A token used to cancel the connection attempt.

Returns

Task

Dispose()

Close all open connections.

public void Dispose()

SetupRemoteControlAsync(CancellationToken)

Set up the event channel, RECORD the session, then set up the data channel used to carry MRP.

public Task SetupRemoteControlAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A token used to cancel the exchanges.

Returns

Task

StartKeepAlive()

Start sending periodic RTSP /feedback keep-alive requests on the control connection.

public void StartKeepAlive()

Remarks

Without this, the Apple TV closes the control (and therefore data-stream) connection a few seconds after RECORD completes. Must be called once SetupRemoteControlAsync(CancellationToken) has completed.

Events

KeepAliveFailed

Raised when the periodic feedback keep-alive fails after exhausting retries.

public event Action<Exception>? KeepAliveFailed

Event Type

Action<Exception>

KeepAliveFinished

Raised when the periodic feedback keep-alive stops because the connection was closed cleanly.

public event Action? KeepAliveFinished

Event Type

Action