Documentation ¶
Index ¶
Constants ¶
View Source
const ( HeaderSize = 12 EventHeaderSize = 4 Version byte = 2 )
Variables ¶
View Source
var ( ErrBadVersion = errors.New("bad rtp version header") ErrExtendedHeadersNotSupported = errors.New("rtp extended headers not supported") )
Functions ¶
func CharToDtmf ¶
Turns ascii character into corresponding telephone event.
func DtmfToChar ¶
Turns telephone event into ASCII character.
Types ¶
type EventHeader ¶
type EventHeader struct { // The event field is a number between 0 and 255 identifying a specific // telephony event. An IANA registry of event codes for this field has been // established (see IANA Considerations, Section 7). The initial content of // this registry consists of the events defined in Section 3. Event uint8 // If set to a value of one, the "end" bit indicates that this packet // contains the end of the event. For long-lasting events that have to be // split into segments (see below, Section 2.5.1.3), only the final packet // for the final segment will have the E bit set. E bool // This field is reserved for future use. The sender MUST set it to zero, and // the receiver MUST ignore it. R bool // For DTMF digits and other events representable as tones, this field // describes the power level of the tone, expressed in dBm0 after dropping // the sign. Power levels range from 0 to -63 dBm0. Thus, larger values // denote lower volume. This value is defined only for events for which the // documentation indicates that volume is applicable. For other events, the // sender MUST set volume to zero and the receiver MUST ignore the value. Volume uint8 // The duration field indicates the duration of the event or segment being // reported, in timestamp units, expressed as an unsigned integer in network // byte order. For a non-zero value, the event or segment began at the // instant identified by the RTP timestamp and has so far lasted as long as // indicated by this parameter. The event may or may not have ended. If the // event duration exceeds the maximum representable by the duration field, // the event is split into several contiguous segments as described below // (Section 2.5.1.3). // // The special duration value of zero is reserved to indicate that the event // lasts "forever", i.e., is a state and is considered to be effective until // updated. A sender MUST NOT transmit a zero duration for events other than // those defined as states. The receiver SHOULD ignore an event report with // zero duration if the event is not a state. // // Events defined as states MAY contain a non-zero duration, indicating that // the sender intends to refresh the state before the time duration has // elapsed ("soft state"). // // For a sampling rate of 8000 Hz, the duration field is sufficient to // express event durations of up to approximately 8 seconds. Duration uint16 }
EventHeader stores things like DTMF and is encoded after Header.
type Header ¶
type Header struct { Pad bool // Padding flag is used for secure RTP. Mark bool // Marker flag is used for RFC2833. PT uint8 // Payload type you got from SDP. Seq uint16 // Sequence id useful for reordering packets. TS uint32 // Timestamp measured in samples. Ssrc uint32 // Random ID used to identify an RTP session. }
Header is encoded at the beginning of a UDP audio packet.
type Session ¶
type Session struct { // Channel to which received RTP frames and errors are published. C <-chan *Frame R chan<- *Frame E <-chan error // Underlying UDP socket. Sock *net.UDPConn // Address of remote endpoint. This might change mid-session. If it's nil, // then egress packets are dropped. Peer *net.UDPAddr // Header is the current header that gets mutated with each transmit. Header Header // contains filtered or unexported fields }
Session allows sending and receiving slinear frames for a single SIP media session. These frames are encoded as µLaw and transmitted over UDP. No support for RTCP is provided.
func NewSession ¶
Creates a new RTP µLaw 20ptime session listening on host with a random port selected from the range [16384,32768].
func (*Session) CloseAfterError ¶
func (rs *Session) CloseAfterError()
Click to show internal directories.
Click to hide internal directories.