Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanRawDatagramRelay ¶
func CanRawDatagramRelay(a, b media.CodecConfig) bool
CanRawDatagramRelay is true when both legs share the same codec clock/channels so RTP payloads
Types ¶
type BridgeDirection ¶
type BridgeDirection int
BridgeDirection indicates which half of a two-leg bridge a tap observes.
const ( // DirectionCallerToAgent is the caller → agent half (caller Rx → agent Tx). DirectionCallerToAgent BridgeDirection = iota // DirectionAgentToCaller is the agent → caller half (agent Rx → caller Tx). DirectionAgentToCaller )
type PCMTapFunc ¶
type PCMTapFunc func(dir BridgeDirection, pcm []byte)
PCMTapFunc receives decoded mono PCM frames at the bridge mid-sample-rate. dir lets observers separate the two halves (e.g. stereo WAV recording with caller on left channel and agent on right). Implementations must copy pcm before retaining it beyond the call — the buffer is re-used on the hot path.
type TwoLegPCMBridge ¶
type TwoLegPCMBridge struct {
// contains filtered or unexported fields
}
TwoLegPCMBridge transcodes between two SIP legs. Transfer agent leg is PCMU/8k; inbound may be Opus, G.722, etc. Mid PCM is 8 kHz mono for dual G.711, otherwise 16 kHz mono (typical Opus/PCMU bridge).
func NewTwoLegPCMBridge ¶
func NewTwoLegPCMBridge( callerRx, callerTx, agentRx, agentTx pcmBridgeLeg, ) (*TwoLegPCMBridge, error)
NewTwoLegPCMBridge builds a bidirectional bridge. Transports must use the same codec config
func (*TwoLegPCMBridge) MidSampleRate ¶
func (b *TwoLegPCMBridge) MidSampleRate() int
MidSampleRate is the bridge PCM sample rate (8 kHz dual G.711 or 16 kHz otherwise).
func (*TwoLegPCMBridge) SetDirectionalPCMTap ¶
func (b *TwoLegPCMBridge) SetDirectionalPCMTap(fn PCMTapFunc)
SetDirectionalPCMTap registers a tap that receives mono PCM frames with explicit direction (caller→agent or agent→caller). Prefer this over SetPCMRecordTap when you need to separate the two halves, e.g. for stereo WAV recording. Pass nil to unregister.
func (*TwoLegPCMBridge) SetPCMRecordTap ¶
func (b *TwoLegPCMBridge) SetPCMRecordTap(fn func([]byte))
SetPCMRecordTap receives a copy of each decoded mono PCM frame from both bridge directions (caller→agent and agent→caller).
func (*TwoLegPCMBridge) Start ¶
func (b *TwoLegPCMBridge) Start()
Start runs both bridge directions (non-blocking).
func (*TwoLegPCMBridge) Stop ¶
func (b *TwoLegPCMBridge) Stop()
Stop cancels the bridge and unblocks RTP reads; RTP sockets are closed by the transfer teardown path.
type TwoLegPayloadRelay ¶
type TwoLegPayloadRelay struct {
// contains filtered or unexported fields
}
TwoLegPayloadRelay forwards raw RTP UDP datagrams** between two legs: transparent RTP (preserve peer SSRC / sequence number / timestamp); only the 7-bit payload type is remapped when SDP PT
func NewTwoLegPayloadRelay ¶
func NewTwoLegPayloadRelay( callerSess, agentSess *rtp.Session, callerCodec, agentCodec media.CodecConfig, callerDTMF, agentDTMF uint8, ) (*TwoLegPayloadRelay, error)
NewTwoLegPayloadRelay builds a raw-datagram relay; both sessions must already have RemoteAddr (SDP or learned RTP).
func (*TwoLegPayloadRelay) SetInboundRecording ¶
func (r *TwoLegPayloadRelay) SetInboundRecording(onUser, onAgentToCaller func(seq uint16, ts uint32, payload []byte))
SetInboundRecording captures RTP audio forwarded during raw relay: user = caller→agent packets;
func (*TwoLegPayloadRelay) Start ¶
func (r *TwoLegPayloadRelay) Start()
func (*TwoLegPayloadRelay) Stop ¶
func (r *TwoLegPayloadRelay) Stop()