Documentation
¶
Overview ¶
Package t140 implements ITU-T T.140 real-time text packetization with the RFC 4103 RTP payload format and optional RFC 2198 redundancy (text/red).
Index ¶
Constants ¶
const ( // ClockRate is the RTP clock rate for T.140 streams (RFC 4103 §4). ClockRate = 1000 // DefaultBufferMs is the recommended T.140 transmission interval // (RFC 4103 §5.2). DefaultBufferMs = 300 // ReplacementChar is the T.140 missing-text marker (U+FFFD) inserted on // detected packet loss not covered by RED redundancy. ReplacementChar = "�" // DefaultT140PT is the conventional dynamic payload type for text/t140. DefaultT140PT uint8 = 99 // DefaultREDPT is the conventional dynamic payload type for text/red. DefaultREDPT uint8 = 98 )
Variables ¶
var ErrInvalidPayload = errors.New("t140: invalid RED payload")
ErrInvalidPayload is returned when a RED payload cannot be parsed.
Functions ¶
This section is empty.
Types ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder turns RFC 4103 / RFC 2198 RTP payloads back into a UTF-8 text stream, deduplicating redundant blocks and inserting U+FFFD when packet loss exceeds the redundancy window.
func (*Decoder) DecodePacket ¶
func (d *Decoder) DecodePacket(seq uint16, ts uint32, packetPT, t140PT, redPT uint8, payload []byte) (text string, lossMarker bool, err error)
DecodePacket processes one RTP payload and returns the new T.140 text bytes to append to the consumer's stream. lossMarker is true when a sequence gap was not covered by RED redundancy (a single U+FFFD has been prepended).
packetPT is the RTP payload type of the received packet. t140PT and redPT are the negotiated dynamic PTs for text/t140 and text/red respectively (redPT == 0 means RED was not negotiated).
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
Encoder accumulates UTF-8 text and produces RTP payloads in either plain T.140 (RFC 4103) or RED-wrapped form (RFC 2198) carrying up to N generations of prior chunks for loss resilience.
func NewEncoder ¶
NewEncoder returns an encoder that retains the last redundancyLevel chunks as RED redundancy. redundancyLevel == 0 produces plain T.140 packets. t140PT is the RTP payload type carrying the inner T.140 blocks (used in the RED block headers).
func (*Encoder) Flush ¶
Flush builds an RTP payload for the currently pending text. The returned useRED flag tells the caller which payload type to use: true → text/red PT, false → text/t140 PT. When there is nothing to send and no history the returned payload is nil.
ts is the absolute RTP timestamp of this packet (1 kHz clock).
func (*Encoder) HasPending ¶
HasPending reports whether there are pending bytes that would be flushed.