agora

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AudioFrameFromPCM

func AudioFrameFromPCM(frame PCMFrame) (*model.AudioFrame, error)

func DataEnabled

func DataEnabled(opts Options) bool

func HandleTextInput

func HandleTextInput(ctx context.Context, responder TextResponder, text string) error

func HandleTextInputEvent

func HandleTextInputEvent(ctx context.Context, responder TextResponder, ev TextInputEvent) error

func PublishAudioEnabled

func PublishAudioEnabled(value *bool) bool

func PublishDataEnabled

func PublishDataEnabled(value *bool) bool

func PublishReasoning

func PublishReasoning(ctx context.Context, publisher DataPublisher, role string, text string, final bool, streamID string, createdAt time.Time) error

func PublishTranscript

func PublishTranscript(ctx context.Context, publisher DataPublisher, role string, text string, final bool, streamID string, createdAt time.Time) error

func SubscribeAudioEnabled

func SubscribeAudioEnabled(value *bool) bool

Types

type AudioFrameReceiver

type AudioFrameReceiver interface {
	OnAudioFrame(context.Context, *model.AudioFrame)
}

type AudioHandler

type AudioHandler func(*model.AudioFrame)

type AudioInput

type AudioInput struct {
	// contains filtered or unexported fields
}

func NewAudioInput

func NewAudioInput(ctx context.Context, receiver AudioFrameReceiver) *AudioInput

func (*AudioInput) HandleAudioFrame

func (i *AudioInput) HandleAudioFrame(frame *model.AudioFrame)

func (*AudioInput) HandlePCM

func (i *AudioInput) HandlePCM(frame PCMFrame) error

type AudioOutput

type AudioOutput struct {
	// contains filtered or unexported fields
}

func NewAudioOutput

func NewAudioOutput(publisher PCMFramePublisher) *AudioOutput

func (*AudioOutput) PublishAudio

func (o *AudioOutput) PublishAudio(ctx context.Context, frame *model.AudioFrame) error

type ChannelClient

type ChannelClient interface {
	Join(context.Context, Options, EventHandler, AudioHandler) error
	Leave(context.Context) error
	PublishPCM(context.Context, PCMFrame) error
}

func NewSDKChannelClient

func NewSDKChannelClient() (ChannelClient, error)

type DataMessage

type DataMessage struct {
	Channel   string
	Publisher string
	Payload   []byte
}

type DataMessageHandler

type DataMessageHandler func(context.Context, DataMessage) error

type DataMessageSubscriber

type DataMessageSubscriber interface {
	SetDataMessageHandler(DataMessageHandler)
}

type DataPublisher

type DataPublisher interface {
	PublishData(context.Context, []byte) error
	Close(context.Context) error
}

func NewSDKDataPublisher

func NewSDKDataPublisher(Options) (DataPublisher, error)

type Event

type Event struct {
	Kind    EventKind
	Channel string
	UserID  string
	Reason  int
	Err     error
}

type EventHandler

type EventHandler func(Event)

type EventKind

type EventKind string
const (
	EventConnected    EventKind = "connected"
	EventDisconnected EventKind = "disconnected"
	EventUserJoined   EventKind = "user_joined"
	EventUserLeft     EventKind = "user_left"
	EventError        EventKind = "error"
)

type Options

type Options struct {
	AppID          string
	AppCertificate string
	Channel        string
	UID            string
	RemoteStreamID string
	Token          string
	RTMUserID      string
	RTMToken       string
	PublishAudio   *bool
	SubscribeAudio *bool
	PublishData    *bool
	RTMEnabled     *bool
}

func ResolveDataOptions

func ResolveDataOptions(opts Options) (Options, error)

func ResolveJoinOptions

func ResolveJoinOptions(opts Options) (Options, error)

func (Options) Validate

func (opts Options) Validate() error

type PCMFrame

type PCMFrame struct {
	Data       []byte
	SampleRate int
	Channels   int
	StartPTSMS int64
}

func (PCMFrame) Validate

func (f PCMFrame) Validate() error

type PCMFramePublisher

type PCMFramePublisher interface {
	PublishPCM(context.Context, PCMFrame) error
}

type RTMMessageRouter

type RTMMessageRouter struct {
	AgentUserID string
	Channel     string
	TextInput   TextInputHandler
}

func (RTMMessageRouter) HandleDataMessage

func (r RTMMessageRouter) HandleDataMessage(ctx context.Context, msg DataMessage) error

type TextInputEvent

type TextInputEvent struct {
	Text      string
	StreamID  string
	Channel   string
	Publisher string
}

type TextInputHandler

type TextInputHandler func(context.Context, TextInputEvent) error

type TextInputTranscriber

type TextInputTranscriber interface {
	EmitUserInputTranscribed(agent.UserInputTranscribedEvent)
}

type TextResponder

type TextResponder interface {
	Interrupt(force bool) error
	GenerateReply(context.Context, string) (*agent.SpeechHandle, error)
}

type TextTurnClaimer

type TextTurnClaimer interface {
	ClaimUserTurn(context.Context, func(context.Context) error) error
}

type TranscriptForwarder

type TranscriptForwarder struct {
	// contains filtered or unexported fields
}

func NewTranscriptForwarder

func NewTranscriptForwarder(session *agent.AgentSession, publisher DataPublisher, opts TranscriptForwarderOptions) *TranscriptForwarder

func (*TranscriptForwarder) Start

func (f *TranscriptForwarder) Start(ctx context.Context)

func (*TranscriptForwarder) Stop

type TranscriptForwarderOptions

type TranscriptForwarderOptions struct {
	UserStreamID      string
	AssistantStreamID string
}

type Transport

type Transport struct {
	// contains filtered or unexported fields
}

func NewTransport

func NewTransport(opts Options, client ChannelClient) *Transport

func (*Transport) Close

func (t *Transport) Close(ctx context.Context) error

func (*Transport) Events

func (t *Transport) Events() <-chan Event

func (*Transport) Join

func (t *Transport) Join(ctx context.Context) error

func (*Transport) Leave

func (t *Transport) Leave(ctx context.Context) error

func (*Transport) PublishPCM

func (t *Transport) PublishPCM(ctx context.Context, frame PCMFrame) error

func (*Transport) SetAudioHandler

func (t *Transport) SetAudioHandler(handler AudioHandler)

Jump to

Keyboard shortcuts

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