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 ¶
- type Call
- type GroupCall
- func (g *GroupCall) AudioSSRC() uint32
- func (g *GroupCall) Connect(remoteJSON string) error
- func (g *GroupCall) CreateLocalParams() (string, error)
- func (g *GroupCall) ElapsedMs() uint64
- func (g *GroupCall) Mode() string
- func (g *GroupCall) Mute() (bool, error)
- func (g *GroupCall) NetState() models.ConnState
- func (g *GroupCall) Pause() (bool, error)
- func (g *GroupCall) Resume() (bool, error)
- func (g *GroupCall) SetSource(ctx context.Context, src media.Source, opt ...media.EncodeOptions) error
- func (g *GroupCall) State() models.MediaState
- func (g *GroupCall) Stop() error
- func (g *GroupCall) Unmute() (bool, error)
- type GroupCallEvents
- type RTMPCall
- func (r *RTMPCall) Connect(string) error
- func (r *RTMPCall) CreateLocalParams() (string, error)
- func (r *RTMPCall) ElapsedMs() uint64
- func (r *RTMPCall) Mode() string
- func (r *RTMPCall) Mute() (bool, error)
- func (r *RTMPCall) NetState() models.ConnState
- func (r *RTMPCall) Pause() (bool, error)
- func (r *RTMPCall) Resume() (bool, error)
- func (r *RTMPCall) SetSource(ctx context.Context, src media.Source, opt ...media.EncodeOptions) error
- func (r *RTMPCall) State() models.MediaState
- func (r *RTMPCall) Stop() error
- func (r *RTMPCall) Unmute() (bool, error)
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 ¶
AudioSSRC is exposed so callers can pass it as the Source param to phone.LeaveGroupCall.
func (*GroupCall) CreateLocalParams ¶
func (*GroupCall) State ¶
func (g *GroupCall) State() models.MediaState
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) CreateLocalParams ¶
WebRTC-only methods return ErrWrongMode for RTMP calls.
func (*RTMPCall) State ¶
func (r *RTMPCall) State() models.MediaState