lktest

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2025 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const AttrTestAny = "<any>"
View Source
const (
	RoomSampleRate = 48000
)

Variables

This section is empty.

Functions

func CheckAudioForParticipants

func CheckAudioForParticipants(t TB, ctx context.Context, participants ...AudioParticipant)

func CheckDTMFForParticipants

func CheckDTMFForParticipants(t TB, ctx context.Context, p1, p2 DTMFParticipant, data1, data2 <-chan lksdk.DataPacket)

func TestMain

func TestMain(run func(ctx context.Context, t TB))

func TestSIPOutbound

func TestSIPOutbound(t TB, ctx context.Context, lkOut, lkIn *LiveKit, params SIPOutboundTestParams)

Types

type AudioParticipant

type AudioParticipant interface {
	SendSignal(ctx context.Context, n int, val int) error
	WaitSignals(ctx context.Context, vals []int, w io.WriteCloser) error
}

type DTMFParticipant

type DTMFParticipant interface {
	SendDTMF(ctx context.Context, digits string) error
}

type LiveKit

type LiveKit struct {
	Rooms     *lksdk.RoomServiceClient
	SIP       *lksdk.SIPClient
	ApiKey    string
	ApiSecret string
	WsUrl     string
}

func New

func New(wsURL, apiKey, apiSecret string) *LiveKit

func (*LiveKit) Connect

func (lk *LiveKit) Connect(t TB, room, identity string, cb *lksdk.RoomCallback) *lksdk.Room

func (*LiveKit) ConnectParticipant

func (lk *LiveKit) ConnectParticipant(t TB, room, identity string, cb *RoomParticipantCallback) *Participant

func (*LiveKit) ConnectWithAudio

func (lk *LiveKit) ConnectWithAudio(t TB, room, identity string, cb *lksdk.RoomCallback) *lksdk.Room

func (*LiveKit) CreateSIPParticipant

func (lk *LiveKit) CreateSIPParticipant(t TB, req *livekit.CreateSIPParticipantRequest) *livekit.SIPParticipantInfo

func (*LiveKit) CreateSIPParticipantSync

func (lk *LiveKit) CreateSIPParticipantSync(t TB, req *livekit.CreateSIPParticipantRequest) (*livekit.SIPParticipantInfo, error)

func (*LiveKit) ExpectParticipants

func (lk *LiveKit) ExpectParticipants(t TB, ctx context.Context, room string, participants []ParticipantInfo) []*livekit.ParticipantInfo

func (*LiveKit) ExpectRoomPref

func (lk *LiveKit) ExpectRoomPref(t TB, ctx context.Context, pref, number string, none bool) *livekit.Room

func (*LiveKit) ExpectRoomPrefWithParticipants

func (lk *LiveKit) ExpectRoomPrefWithParticipants(t TB, ctx context.Context, pref, number string, participants []ParticipantInfo) []*livekit.ParticipantInfo

func (*LiveKit) ExpectRoomWithParticipants

func (lk *LiveKit) ExpectRoomWithParticipants(t TB, ctx context.Context, room string, participants []ParticipantInfo) []*livekit.ParticipantInfo

func (*LiveKit) ListRooms

func (lk *LiveKit) ListRooms(t TB) []*livekit.Room

func (*LiveKit) RoomParticipants

func (lk *LiveKit) RoomParticipants(t TB, room string) []*livekit.ParticipantInfo

type Participant

type Participant struct {
	Room     *lksdk.Room
	AudioOut msdk.Writer[msdk.PCM16Sample]
	AudioIn  msdk.Reader[msdk.PCM16Sample]
	// contains filtered or unexported fields
}

func (*Participant) SendDTMF

func (p *Participant) SendDTMF(ctx context.Context, digits string) error

func (*Participant) SendSignal

func (p *Participant) SendSignal(ctx context.Context, n int, val int) error

func (*Participant) WaitDTMF

func (p *Participant) WaitDTMF(ctx context.Context, digits string) error

func (*Participant) WaitSignals

func (p *Participant) WaitSignals(ctx context.Context, vals []int, w io.WriteCloser) error

type ParticipantInfo

type ParticipantInfo struct {
	Identity   string
	Name       string
	Kind       livekit.ParticipantInfo_Kind
	Metadata   string
	Attributes map[string]string
}

type RoomParticipantCallback

type RoomParticipantCallback struct {
	lksdk.RoomCallback
	OnSIPStatus func(p *lksdk.RemoteParticipant, callID string, status string)
}

type SIPOutboundTestParams

type SIPOutboundTestParams struct {
	TrunkOut string            // trunk ID for outbound call
	RoomOut  string            // room for outbound call
	AttrsOut map[string]string // expected attributes for outbound participants
	TrunkIn  string            // trunk ID for inbound call
	RuleIn   string            // rule ID for inbound call
	AttrsIn  map[string]string // expected attributes for inbound participants
	NoDMTF   bool              // do not test DTMF
}

type TB

type TB interface {
	Failed() bool
	Cleanup(func())
	Error(args ...any)
	Errorf(format string, args ...any)
	FailNow()
	Fatal(args ...any)
	Fatalf(format string, args ...any)
	Log(args ...any)
	Logf(format string, args ...any)
	Skip(args ...any)
	Skipf(format string, args ...any)
}

TB mirrors testing.TB interface without including the actual testing package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL