/** * Classification of a UDP datagram emitted by {@link RtpPacketParser}. `"rtp"` denotes a media packet; `"rtcp"` denotes a control packet. Consumers typically * branch on this union to route to the correct downstream FFmpeg port. * * @category FFmpeg */ export type RtpPacketKind = "rtcp" | "rtp"; /** * A single classified RTP or RTCP packet. * * @property bytes - The complete UDP datagram bytes. Emitted as-is from the parser; consumers that need to hold it past the iteration loop should copy with * `Buffer.from()` if the upstream datagram lifetime is suspect. * @property kind - `"rtp"` or `"rtcp"`, derived from the header's payload type field. * @property payloadType - The 7-bit payload type value from the second byte of the header, masked against `0x7F`. Provided raw so consumers can match specific RTP * payload types (e.g., opus, g711) without re-parsing the header. * * @category FFmpeg */ export interface RtpPacket { bytes: Buffer; kind: RtpPacketKind; payloadType: number; } /** * Pure stateful parser that classifies UDP datagrams as RTP or RTCP and surfaces them as {@link RtpPacket} records. * * Unlike {@link ffmpeg/mp4-parser!Mp4BoxParser | Mp4BoxParser}, the RTP wire format is already datagram-framed - each UDP message is a complete packet - so there is no * cross-call state to carry. The class shape mirrors the MP4 parser for consistency: composing resource classes (demuxers, assemblers) drive any parser of this shape * without having to know whether the wire format was stream-oriented or datagram-oriented. * * The class is intentionally signal-free and event-free. Resource lifecycle, liveness monitoring, and async consumption are the composing caller's concern - see * {@link ffmpeg/rtp!RtpDemuxer | RtpDemuxer}. * * @example * * ```ts * import { RtpPacketParser } from "homebridge-plugin-utils"; * * const parser = new RtpPacketParser(); * * socket.on("message", (datagram) => { * * for(const packet of parser.consume(datagram)) { * * if(packet.kind === "rtp") { * * socket.send(packet.bytes, rtpPort); * } * } * }); * ``` * * @see RtpDemuxer * * @category FFmpeg */ export declare class RtpPacketParser { /** * Feed the parser a UDP datagram and yield the single classified packet it contains. * * Datagrams shorter than the two-byte minimum required to read the payload type field are silently dropped. Callers that need to observe malformed input should do so * at the socket layer; the parser's contract is "classify well-formed headers," not "diagnose corruption." * * @param datagram - A complete UDP datagram received from the RTP/RTCP socket. * * @returns An iterable yielding zero packets (empty datagram) or exactly one packet (well-formed datagram). */ consume(datagram: Buffer): Iterable; } //# sourceMappingURL=rtp-parser.d.ts.map