instances

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: May 30, 2026 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package instances holds the per-chat call state. One Call interface, two implementations: GroupCall (WebRTC, default) and RTMPCall (FFmpeg push to a Telegram-issued RTMP URL).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Call

type Call interface {
	// CreateLocalParams produces the local-side JSON. WebRTC mode only;
	// RTMPCall returns ErrWrongMode.
	CreateLocalParams() (string, error)

	// Connect feeds Telegram's response JSON. WebRTC mode only.
	Connect(remoteJSON string) error

	// SetSource installs the streaming source. Replaces atomically.
	SetSource(ctx context.Context, src media.Source, opt ...media.EncodeOptions) error

	Pause() (bool, error)
	Resume() (bool, error)
	Mute() (bool, error)
	Unmute() (bool, error)
	Stop() error

	ElapsedMs() uint64
	State() models.MediaState
	NetState() models.ConnState

	// Mode returns either "webrtc" or "rtmp" so the Client can guard
	// mode-specific operations.
	Mode() string
}

Call is the per-chat interface the top-level Client multiplexes over.

type GroupCall

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

GroupCall is the WebRTC call instance for one chat.

func NewGroupCall

func NewGroupCall(chatID int64, factory *wrtc.Factory, disp *utils.Dispatcher, log *slog.Logger, ev GroupCallEvents) (*GroupCall, error)

NewGroupCall constructs a fresh call. Caller threads pion factory + logger.

func (*GroupCall) AudioSSRC

func (g *GroupCall) AudioSSRC() uint32

AudioSSRC is exposed so callers can pass it as the Source param to phone.LeaveGroupCall.

func (*GroupCall) Connect

func (g *GroupCall) Connect(remoteJSON string) error

func (*GroupCall) CreateLocalParams

func (g *GroupCall) CreateLocalParams() (string, error)

func (*GroupCall) ElapsedMs

func (g *GroupCall) ElapsedMs() uint64

func (*GroupCall) Mode

func (g *GroupCall) Mode() string

func (*GroupCall) Mute

func (g *GroupCall) Mute() (bool, error)

func (*GroupCall) NetState

func (g *GroupCall) NetState() models.ConnState

func (*GroupCall) Pause

func (g *GroupCall) Pause() (bool, error)

func (*GroupCall) Resume

func (g *GroupCall) Resume() (bool, error)

func (*GroupCall) SetSource

func (g *GroupCall) SetSource(ctx context.Context, src media.Source, opt ...media.EncodeOptions) error

func (*GroupCall) State

func (g *GroupCall) State() models.MediaState

func (*GroupCall) Stop

func (g *GroupCall) Stop() error

func (*GroupCall) Unmute

func (g *GroupCall) Unmute() (bool, error)

type GroupCallEvents

type GroupCallEvents struct {
	OnStreamEnd        func(t models.StreamType, d models.Device, err error)
	OnConnectionChange func(info models.NetworkInfo)
}

GroupCallEvents is the set of callbacks a GroupCall fires through the shared dispatcher; the Client wires these to its public OnXxx callbacks.

type RTMPCall

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

RTMPCall pushes audio+video to a Telegram-issued RTMP URL via a single ffmpeg process. No pion involvement.

func NewRTMPCall

func NewRTMPCall(chatID int64, rtmpURL string, disp *utils.Dispatcher, log *slog.Logger, ev GroupCallEvents) *RTMPCall

func (*RTMPCall) Connect

func (r *RTMPCall) Connect(string) error

func (*RTMPCall) CreateLocalParams

func (r *RTMPCall) CreateLocalParams() (string, error)

WebRTC-only methods return ErrWrongMode for RTMP calls.

func (*RTMPCall) ElapsedMs

func (r *RTMPCall) ElapsedMs() uint64

func (*RTMPCall) Mode

func (r *RTMPCall) Mode() string

func (*RTMPCall) Mute

func (r *RTMPCall) Mute() (bool, error)

func (*RTMPCall) NetState

func (r *RTMPCall) NetState() models.ConnState

func (*RTMPCall) Pause

func (r *RTMPCall) Pause() (bool, error)

func (*RTMPCall) Resume

func (r *RTMPCall) Resume() (bool, error)

func (*RTMPCall) SetSource

func (r *RTMPCall) SetSource(ctx context.Context, src media.Source, opt ...media.EncodeOptions) error

func (*RTMPCall) State

func (r *RTMPCall) State() models.MediaState

func (*RTMPCall) Stop

func (r *RTMPCall) Stop() error

func (*RTMPCall) Unmute

func (r *RTMPCall) Unmute() (bool, error)

Jump to

Keyboard shortcuts

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