Table of Contents

Class AirPlayMrpConnection

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

MRP connection implemented as a channel/stream tunneled over an AirPlay 2 data-stream channel, rather than a raw TCP socket. This is the adapter that lets MrpProtocol be driven by an already-established Ap2Session instead of the retired raw-TCP TcpMrpTransport (see archive/mrp-tcp-transport).

public sealed class AirPlayMrpConnection : IMrpFrameConnection, IDataStreamListener, IDisposable
Inheritance
AirPlayMrpConnection
Implements
Inherited Members

Remarks

Initializes a new instance of the AirPlayMrpConnection class.

Constructors

AirPlayMrpConnection(Ap2Session)

MRP connection implemented as a channel/stream tunneled over an AirPlay 2 data-stream channel, rather than a raw TCP socket. This is the adapter that lets MrpProtocol be driven by an already-established Ap2Session instead of the retired raw-TCP TcpMrpTransport (see archive/mrp-tcp-transport).

public AirPlayMrpConnection(Ap2Session session)

Parameters

session Ap2Session

An Ap2Session for which SetupRemoteControlAsync(CancellationToken) has already completed.

Remarks

Initializes a new instance of the AirPlayMrpConnection class.

Properties

Listener

Gets or sets the listener notified when a complete message has been received and decoded.

public IMrpConnectionListener? Listener { get; set; }

Property Value

IMrpConnectionListener

Methods

BuildMessage(byte[])

Build a message ready to send from a serialized protobuf payload.

public byte[] BuildMessage(byte[] data)

Parameters

data byte[]

The serialized protobuf message payload.

Returns

byte[]

The bytes to write to the transport.

Remarks

The AirPlay data channel does its own framing (see SendProtobuf(ProtocolMessage)), so this is an identity passthrough rather than the variant-length prefixing used by direct TCP MRP; the actual send happens in SendAsync(byte[]).

Connect()

Attach this adapter to the session's already-established data channel.

public void Connect()

Dispose()

Closes the underlying AirPlay session.

public void Dispose()

EnableEncryption(byte[], byte[])

Enable encryption with the specified keys.

public void EnableEncryption(byte[] outputKey, byte[] inputKey)

Parameters

outputKey byte[]

The key used to encrypt outgoing data.

inputKey byte[]

The key used to decrypt incoming data.

HandleConnectionLost(Exception?)

Device connection was dropped.

public void HandleConnectionLost(Exception? exception)

Parameters

exception Exception

The exception that caused the drop, or null for a clean close.

HandleProtobuf(ProtocolMessage)

Handle an incoming protobuf message tunneled over the data channel.

public void HandleProtobuf(ProtocolMessage message)

Parameters

message ProtocolMessage

The decoded message.

SendAsync(byte[])

Gets or sets an asynchronous callback for transmitting a fully-built frame.

public Task SendAsync(byte[] frame)

Parameters

frame byte[]

Returns

Task

Remarks

Set by AsyncSender; this adapter re-parses the frame (produced by BuildMessage(byte[]) as a byte-identity passthrough) back into a ProtocolMessage so it can be handed to SendProtobuf(ProtocolMessage), which does its own AirPlay-specific framing rather than the variant-length framing used by direct TCP MRP.

Events

ConnectionLost

Raised when the underlying AirPlay data channel is dropped.

public event Action<Exception?>? ConnectionLost

Event Type

Action<Exception>