provider

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package provider defines the core provider interfaces for OmniMeet.

Package provider defines the core provider interfaces for OmniMeet.

Package provider defines the core provider interfaces for OmniMeet.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentParticipant

type AgentParticipant interface {
	// Join/leave
	// JoinMeeting joins the meeting as an agent participant.
	JoinMeeting(ctx context.Context, meetingID string, token *token.JoinToken) error

	// LeaveMeeting leaves the current meeting.
	LeaveMeeting(ctx context.Context) error

	// Audio handling
	// SubscribeToAudio subscribes to a specific participant's audio.
	SubscribeToAudio(ctx context.Context, participantID string) (<-chan AudioFrame, error)

	// SubscribeToAllAudio subscribes to all participants' audio (mixed or separate).
	SubscribeToAllAudio(ctx context.Context) (<-chan AudioFrame, error)

	// PublishAudio publishes an audio frame to the meeting.
	PublishAudio(ctx context.Context, frame AudioFrame) error

	// StartAudioTrack starts publishing audio and returns a writer for continuous streaming.
	StartAudioTrack(ctx context.Context, opts AudioTrackOptions) (AudioWriter, error)

	// StopAudioTrack stops publishing audio.
	StopAudioTrack(ctx context.Context) error

	// Track subscription
	// SubscribeToTrack subscribes to a specific track.
	SubscribeToTrack(ctx context.Context, trackID string, opts track.SubscribeOptions) error

	// UnsubscribeFromTrack unsubscribes from a track.
	UnsubscribeFromTrack(ctx context.Context, trackID string) error

	// Data messages
	// SendDataMessage sends a data message to all or specific participants.
	SendDataMessage(ctx context.Context, msg DataMessage) error

	// OnDataMessage registers a handler for incoming data messages.
	OnDataMessage(handler func(DataMessage))

	// Events
	// Events returns a channel of real-time events.
	Events() <-chan event.Event

	// OnParticipantJoined registers a handler for participant join events.
	OnParticipantJoined(handler func(participant.Participant))

	// OnParticipantLeft registers a handler for participant leave events.
	OnParticipantLeft(handler func(participant.Participant))

	// OnTrackPublished registers a handler for track publish events.
	OnTrackPublished(handler func(participant.Participant, track.Track))

	// OnTrackUnpublished registers a handler for track unpublish events.
	OnTrackUnpublished(handler func(participant.Participant, track.Track))

	// OnActiveSpeakerChanged registers a handler for active speaker changes.
	OnActiveSpeakerChanged(handler func([]participant.Participant))

	// State
	// Meeting returns the current meeting.
	Meeting() *meeting.Meeting

	// LocalParticipant returns the local (agent) participant.
	LocalParticipant() *participant.Participant

	// RemoteParticipants returns all remote participants.
	RemoteParticipants() []participant.Participant

	// GetParticipant returns a specific participant by ID.
	GetParticipant(participantID string) *participant.Participant

	// ConnectionState returns the current connection state.
	ConnectionState() ConnectionState
}

AgentParticipant represents an AI agent's participation in a meeting.

While MeetingProvider handles control plane operations, AgentParticipant handles media plane operations: joining meetings, subscribing to audio, publishing audio responses, and receiving real-time events.

Not all providers support AgentParticipant. Use SupportsAgentParticipation() to check if a provider supports this interface.

type AgentParticipantFactory

type AgentParticipantFactory interface {
	// CreateAgentParticipant creates a new AgentParticipant.
	CreateAgentParticipant(opts AgentParticipantOptions) (AgentParticipant, error)

	// SupportsAgentParticipation returns true if this provider supports agent participation.
	SupportsAgentParticipation() bool
}

AgentParticipantFactory creates AgentParticipant instances.

type AgentParticipantOptions

type AgentParticipantOptions struct {

	// AutoSubscribe automatically subscribes to all tracks.
	AutoSubscribe bool

	// AudioConfig specifies the audio configuration.
	AudioConfig AudioConfig
}

AgentParticipantOptions contains options for creating an AgentParticipant.

type AudioConfig

type AudioConfig struct {
	// SampleRate is the sample rate in Hz.
	SampleRate int

	// Channels is the number of channels.
	Channels int

	// FrameDuration is the duration of each audio frame.
	FrameDuration time.Duration
}

AudioConfig specifies the audio configuration for an agent.

func DefaultAudioConfig

func DefaultAudioConfig() AudioConfig

DefaultAudioConfig returns the default audio configuration.

type AudioFrame

type AudioFrame struct {
	// ParticipantID is the ID of the participant who produced this audio.
	// Empty for outgoing audio.
	ParticipantID string

	// ParticipantName is the name of the participant.
	ParticipantName string

	// Data is the raw audio data (PCM16 format).
	Data []byte

	// SampleRate is the sample rate in Hz (e.g., 16000, 24000, 48000).
	SampleRate int

	// Channels is the number of audio channels (1 = mono, 2 = stereo).
	Channels int

	// Timestamp is when this frame was captured.
	Timestamp time.Time

	// SequenceNumber is the sequence number for ordering.
	SequenceNumber uint64
}

AudioFrame represents a frame of audio data.

type AudioTrackOptions

type AudioTrackOptions struct {
	// Name is an optional name for the track.
	Name string

	// SampleRate is the sample rate in Hz.
	SampleRate int

	// Channels is the number of channels.
	Channels int
}

AudioTrackOptions contains options for starting an audio track.

type AudioWriter

type AudioWriter interface {
	// Write writes audio data to the track.
	Write(data []byte) (int, error)

	// Close stops writing and releases resources.
	Close() error
}

AudioWriter is used to write continuous audio to a track.

type Client

type Client[T Named] struct {
	// contains filtered or unexported fields
}

Client manages multiple meeting providers with fallback support.

This is a generic implementation similar to other PlexusOne libraries, allowing for multi-provider setups with automatic fallback.

func NewClient

func NewClient[T Named](primary T, fallbacks ...T) *Client[T]

NewClient creates a new Client with the given primary provider.

func (*Client[T]) AddFallback

func (c *Client[T]) AddFallback(fallback T)

AddFallback adds a fallback provider.

func (*Client[T]) All

func (c *Client[T]) All() []T

All returns all providers (primary + fallbacks).

func (*Client[T]) Fallbacks

func (c *Client[T]) Fallbacks() []T

Fallbacks returns the fallback providers.

func (*Client[T]) Names

func (c *Client[T]) Names() []string

Names returns the names of all providers.

func (*Client[T]) Primary

func (c *Client[T]) Primary() T

Primary returns the primary provider.

func (*Client[T]) Provider

func (c *Client[T]) Provider(name string) (T, bool)

Provider returns a provider by name.

func (*Client[T]) SetPrimary

func (c *Client[T]) SetPrimary(primary T)

SetPrimary sets the primary provider.

type ConnectionState

type ConnectionState string

ConnectionState represents the connection state.

const (
	ConnectionStateDisconnected ConnectionState = "disconnected"
	ConnectionStateConnecting   ConnectionState = "connecting"
	ConnectionStateConnected    ConnectionState = "connected"
	ConnectionStateReconnecting ConnectionState = "reconnecting"
	ConnectionStateFailed       ConnectionState = "failed"
)

type DataMessage

type DataMessage struct {
	// Topic is an optional topic/channel for the message.
	Topic string

	// Payload is the message payload.
	Payload []byte

	// DestinationIDs limits delivery to specific participants.
	// Empty means broadcast to all.
	DestinationIDs []string

	// Reliable indicates whether reliable delivery is required.
	Reliable bool

	// From is the sender (populated on receive).
	From *participant.Participant

	// Timestamp is when the message was sent.
	Timestamp time.Time
}

DataMessage represents a data message sent between participants.

type MeetingProvider

type MeetingProvider interface {
	// Name returns the provider name (e.g., "livekit", "daily").
	Name() string

	// Meeting lifecycle
	// CreateMeeting creates a new meeting.
	CreateMeeting(ctx context.Context, req meeting.CreateRequest) (*meeting.Meeting, error)

	// GetMeeting retrieves a meeting by ID.
	GetMeeting(ctx context.Context, meetingID string) (*meeting.Meeting, error)

	// ListMeetings returns a list of meetings.
	ListMeetings(ctx context.Context, opts meeting.ListOptions) ([]meeting.Meeting, error)

	// EndMeeting ends a meeting.
	EndMeeting(ctx context.Context, meetingID string) error

	// DeleteMeeting deletes a meeting (may fail if active).
	DeleteMeeting(ctx context.Context, meetingID string) error

	// Participant management
	// CreateJoinToken generates a token for a participant to join a meeting.
	CreateJoinToken(ctx context.Context, req token.CreateRequest) (*token.JoinToken, error)

	// ListParticipants returns the current participants in a meeting.
	ListParticipants(ctx context.Context, meetingID string) ([]participant.Participant, error)

	// GetParticipant retrieves a specific participant.
	GetParticipant(ctx context.Context, meetingID, participantID string) (*participant.Participant, error)

	// RemoveParticipant removes a participant from a meeting.
	RemoveParticipant(ctx context.Context, meetingID, participantID string) error

	// UpdateParticipant updates participant metadata or permissions.
	UpdateParticipant(ctx context.Context, meetingID, participantID string, update ParticipantUpdate) error

	// Events
	// OnEvent registers a handler for meeting events.
	// Events are delivered via webhooks or polling, depending on the provider.
	OnEvent(handler event.Handler)

	// Lifecycle
	// Close releases any resources held by the provider.
	Close() error
}

MeetingProvider is the core interface that all meeting providers must implement.

MeetingProvider handles the control plane operations: creating meetings, generating join tokens, managing participants, and handling recordings. For AI agent participation (media plane), see AgentParticipant.

type Named

type Named interface {
	Name() string
}

Named is a common interface for types that have a name.

type ParticipantUpdate

type ParticipantUpdate struct {
	// Name updates the participant's display name.
	Name *string `json:"name,omitempty"`

	// Metadata updates the participant's metadata (merged with existing).
	Metadata map[string]string `json:"metadata,omitempty"`

	// Permissions updates the participant's permissions.
	Permissions *participant.Permissions `json:"permissions,omitempty"`
}

ParticipantUpdate contains fields to update on a participant.

type RecordingProvider

type RecordingProvider interface {
	MeetingProvider

	// StartRecording starts recording a meeting.
	StartRecording(ctx context.Context, meetingID string, opts recording.Options) (*recording.Recording, error)

	// StopRecording stops recording a meeting.
	StopRecording(ctx context.Context, meetingID string) (*recording.Recording, error)

	// GetRecording retrieves a recording by ID.
	GetRecording(ctx context.Context, recordingID string) (*recording.Recording, error)

	// ListRecordings returns recordings for a meeting.
	ListRecordings(ctx context.Context, meetingID string) ([]recording.Recording, error)
}

RecordingProvider is an optional interface for providers that support recording.

type WebhookHandler

type WebhookHandler interface {
	// HandleWebhook processes an incoming webhook request.
	// Returns the parsed events.
	HandleWebhook(ctx context.Context, body []byte, headers map[string]string) ([]event.Event, error)

	// ValidateWebhook validates the webhook signature.
	ValidateWebhook(body []byte, headers map[string]string, secret string) error
}

WebhookHandler is an optional interface for providers that support webhooks.

Jump to

Keyboard shortcuts

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