Skip to content

@corewire/airplay/rtsp ​

ts
import { buildResponse, parseRequest, parseResponse, RtspClient } from '@corewire/airplay/rtsp';

See RTSP.

RtspClient ​

class RtspClient extends Connection<{}>

MemberDescription
constructor(context: Context, address: string, port: number)
protected exchange(method: Method, path: string, options?: ExchangeOptions): Promise<Response>Sends a request with CSeq tracking and a timeout. Throws TimeoutError, and InvalidResponseError for a status that is not OK unless allowError
protected getDefaultHeaders(): Record<string, string | number>Headers for every request
protected transformIncoming(data: Buffer): Buffer | false | {data: Buffer; consumed: number}Decrypts incoming data; false waits for more
protected transformOutgoing(data: Buffer): BufferEncrypts a formatted request

It inherits connect(), disconnect(), destroy(), write() and the events of Connection.

Functions ​

ExportDescription
parseRequest(buffer: Buffer): RtspRequest | nullNull while the buffer is incomplete. Throws on a malformed request line
parseResponse(buffer: Buffer): RtspResponse | nullNull while the buffer is incomplete. Throws on a malformed status line
buildResponse(options: BuildResponseOptions): BufferFormats a response; sets Content-Length

Types ​

TypeDefinition
Method'ANNOUNCE' | 'FLUSH' | 'FLUSHBUFFERED' | 'GET' | 'GET_PARAMETER' | 'OPTIONS' | 'POST' | 'PUT' | 'RECORD' | 'SETUP' | 'SET_PARAMETER' | 'TEARDOWN'
RtspRequest{headers: Record<string, string>; method: Method; path: string; body: Buffer; requestLength: number}
RtspResponse{response: Response; responseLength: number}
BuildResponseOptions{status: number; statusText: string; headers?: Record<string, string | number>; body?: Buffer; protocol?: 'RTSP/1.0' | 'HTTP/1.1'}
ExchangeOptions{contentType?: string; headers?: Record<string, string>; body?: Buffer | string | Record<string, unknown>; allowError?: boolean; protocol?: 'RTSP/1.0' | 'HTTP/1.1'; timeout?: number}

The parser normalizes header names in an RtspRequest, so content-length becomes Content-Length and cseq becomes CSeq.

CoreWire is released under the MIT license.