sms

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2026 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Overview

Code generated by godddx, DO AVOID EDIT.

Code generated by godddx, DO AVOID EDIT.

Code generated by godddx, DO AVOID EDIT.

Code generated by godddx, DO AVOID EDIT.

Code generated by godddx, DO AVOID EDIT.

Index

Constants

View Source
const (
	ProtocolZLMediaKit = "zlm"
	ProtocolLalmax     = "lalmax"
)
View Source
const (
	PullTimeoutMs = 10000
	PullRetryNum  = 3
)
View Source
const DefaultMediaServerID = "local"

DefaultMediaServerID 临时变量,待未来重构分布式流媒体时,移除

View Source
const KeepaliveInterval = 2 * 15 * time.Second

Variables

This section is empty.

Functions

This section is empty.

Types

type AddMediaServerInput

type AddMediaServerInput struct {
	IP                string           `json:"ip"`
	HookIP            string           `json:"hook_ip"`
	SDPIP             string           `json:"sdpip"`
	StreamIP          string           `json:"stream_ip"`
	Ports             MediaServerPorts `json:"ports"`
	AutoConfig        bool             `json:"auto_config"`
	Secret            string           `json:"secret"`
	HookAliveInterval int              `json:"hook_alive_interval"`
	RTPEnable         bool             `json:"rtpenable"`
	Status            bool             `json:"status"`
	RTPPortRange      string           `json:"rtpport_range"`
	SendRTPPortRange  string           `json:"send_rtpport_range"`
	RecordAssistPort  int              `json:"record_assist_port"`
	LastKeepaliveAt   orm.Time         `json:"last_keepalive_at"`
	IsDefault         bool             `json:"is_default"`
	RecordDay         int              `json:"record_day"`
	RecordPath        string           `json:"record_path"`
	Type              string           `json:"type"`
	TranscodeSuffix   string           `json:"transcode_suffix"`
}

type AddStreamProxyRequest

type AddStreamProxyRequest struct {
	App     string `json:"app"`      // 添加的流的应用名,例如 live
	Stream  string `json:"stream"`   // 添加的流的 id 名,例如 test
	URL     string `json:"url"`      // 拉流地址,例如 rtmp://live.hkstv.hk.lxdns.com/live/hks2
	RTPType int    `json:"rtp_type"` // rtsp 拉流时,拉流方式,0:tcp,1:udp,2:组播

}

type Core

type Core struct {
	*NodeManager
	// contains filtered or unexported fields
}

Core business domain

func NewCore

func NewCore(store Storer) Core

NewCore create business domain

func (*Core) AddMediaServer

func (c *Core) AddMediaServer(ctx context.Context, in *AddMediaServerInput) (*MediaServer, error)

AddMediaServer Insert into database

func (*Core) DelMediaServer

func (c *Core) DelMediaServer(ctx context.Context, id string) (*MediaServer, error)

DelMediaServer Delete object

func (*Core) EditMediaServer

func (c *Core) EditMediaServer(ctx context.Context, in *EditMediaServerInput, id string, serverPort int) (*MediaServer, error)

EditMediaServer Update object information

func (*Core) FindMediaServer

func (c *Core) FindMediaServer(ctx context.Context, in *FindMediaServerInput) ([]*MediaServer, int64, error)

FindMediaServer Paginated search

func (*Core) GetMediaServer

func (c *Core) GetMediaServer(ctx context.Context, id string) (*MediaServer, error)

GetMediaServer Query a single object

type Driver

type Driver interface {
	// Protocol 返回协议/类型名称,如 "zlm", "srs"
	Protocol() string

	// Connect 测试连接并获取初始信息 (对应目前的 connection 方法中的部分逻辑)
	Connect(ctx context.Context, ms *MediaServer) error

	// Setup 下发配置到流媒体服务 (对应目前的 connection 方法中的配置逻辑)
	Setup(ctx context.Context, ms *MediaServer, webhookURL string) error

	// Ping 主动探测服务是否在线
	Ping(ctx context.Context, ms *MediaServer) error

	// Stream Operations
	OpenRTPServer(ctx context.Context, ms *MediaServer, req *zlm.OpenRTPServerRequest) (*zlm.OpenRTPServerResponse, error)
	CloseRTPServer(ctx context.Context, ms *MediaServer, req *zlm.CloseRTPServerRequest) (*zlm.CloseRTPServerResponse, error)
	AddStreamProxy(ctx context.Context, ms *MediaServer, req *AddStreamProxyRequest) (*zlm.AddStreamProxyResponse, error)
	GetSnapshot(ctx context.Context, ms *MediaServer, req *GetSnapRequest) ([]byte, error)

	GetStreamLiveAddr(ctx context.Context, ms *MediaServer, httpPrefix, host, app, stream string) StreamLiveAddr
}

Driver 定义流媒体服务的通用行为

type EditMediaServerInput

type EditMediaServerInput struct {
	IP     string `json:"ip"`
	HookIP string `json:"hook_ip"`
	SDPIP  string `json:"sdp_ip"`
	// StreamIP          string           `json:"stream_ip"`
	// Ports MediaServerPorts `json:"ports"`
	// AutoConfig        bool             `json:"auto_config"`
	Secret string `json:"secret"`
	Type   string `json:"type"` // lalmax/zlm

}

type FindMediaServerInput

type FindMediaServerInput struct {
	web.PagerFilter
	IP                string           `form:"ip"`
	HookIP            string           `form:"hook_ip"`
	SDPIP             string           `form:"sdpip"`
	StreamIP          string           `form:"stream_ip"`
	Ports             MediaServerPorts `form:"ports"`
	AutoConfig        bool             `form:"auto_config"`
	Secret            string           `form:"secret"`
	HookAliveInterval int              `form:"hook_alive_interval"`
	RTPEnable         bool             `form:"rtpenable"`
	Status            bool             `form:"status"`
	RTPPortRange      string           `form:"rtpport_range"`
	SendRTPPortRange  string           `form:"send_rtpport_range"`
	RecordAssistPort  int              `form:"record_assist_port"`
	LastKeepaliveAt   orm.Time         `form:"last_keepalive_at"`
	IsDefault         bool             `form:"is_default"`
	RecordDay         int              `form:"record_day"`
	RecordPath        string           `form:"record_path"`
	Type              string           `form:"type"`
	TranscodeSuffix   string           `form:"transcode_suffix"`
}

type GetSnapRequest

type GetSnapRequest struct {
	zlm.GetSnapRequest
	// lalmax
	Stream string `json:"stream"`
}

type LalmaxDriver

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

func NewLalmaxDriver

func NewLalmaxDriver() *LalmaxDriver

func (*LalmaxDriver) AddStreamProxy

AddStreamProxy implements Driver.

func (*LalmaxDriver) CloseRTPServer

CloseRTPServer implements Driver.

func (*LalmaxDriver) Connect

func (l *LalmaxDriver) Connect(ctx context.Context, ms *MediaServer) error

Connect implements Driver.

func (*LalmaxDriver) GetSnapshot

func (l *LalmaxDriver) GetSnapshot(ctx context.Context, ms *MediaServer, req *GetSnapRequest) ([]byte, error)

GetSnapshot implements Driver.

func (*LalmaxDriver) GetStreamLiveAddr

func (l *LalmaxDriver) GetStreamLiveAddr(ctx context.Context, ms *MediaServer, httpPrefix string, host string, app string, stream string) StreamLiveAddr

GetStreamLiveAddr implements Driver.

func (*LalmaxDriver) OpenRTPServer

OpenRTPServer implements Driver.

func (*LalmaxDriver) Ping

func (l *LalmaxDriver) Ping(ctx context.Context, ms *MediaServer) error

Ping implements Driver.

func (*LalmaxDriver) Protocol

func (l *LalmaxDriver) Protocol() string

Protocol implements Driver.

func (*LalmaxDriver) Setup

func (l *LalmaxDriver) Setup(ctx context.Context, ms *MediaServer, webhookURL string) error

Setup implements Driver.

type MediaServer

type MediaServer struct {
	ID                string           `gorm:"primaryKey" json:"id"`
	IP                string           `gorm:"column:ip;notNull;default:''" json:"ip"`
	CreatedAt         orm.Time         `gorm:"column:created_at;notNull;default:CURRENT_TIMESTAMP" json:"created_at"`
	UpdatedAt         orm.Time         `gorm:"column:updated_at;notNull;default:CURRENT_TIMESTAMP" json:"updated_at"`
	HookIP            string           `gorm:"column:hook_ip;notNull;default:''" json:"hook_ip"`
	SDPIP             string           `gorm:"column:sdp_ip;notNull;default:''" json:"sdp_ip"`
	StreamIP          string           `gorm:"column:stream_ip;notNull;default:''" json:"stream_ip"`
	Ports             MediaServerPorts `gorm:"column:ports;notNull;default:'{}';type:jsonb" json:"ports"`
	AutoConfig        bool             `gorm:"column:auto_config;notNull;default:FALSE" json:"auto_config"`
	Secret            string           `gorm:"column:secret;notNull;default:''" json:"secret"`
	HookAliveInterval int              `gorm:"column:hook_alive_interval;notNull;default:0" json:"hook_alive_interval"`
	RTPEnable         bool             `gorm:"column:rtpenable;notNull;default:FALSE" json:"rtpenable"`
	Status            bool             `gorm:"column:status;notNull;default:FALSE" json:"status"`
	RTPPortRange      string           `gorm:"column:rtpport_range;notNull;default:''" json:"rtpport_range"`
	SendRTPPortRange  string           `gorm:"column:send_rtpport_range;notNull;default:''" json:"send_rtpport_range"`
	RecordAssistPort  int              `gorm:"column:record_assist_port;notNull;default:0" json:"record_assist_port"`
	LastKeepaliveAt   orm.Time         `gorm:"column:last_keepalive_at;notNull;default:CURRENT_TIMESTAMP" json:"last_keepalive_at"`
	RecordDay         int              `gorm:"column:record_day;notNull;default:0" json:"record_day"`
	RecordPath        string           `gorm:"column:record_path;notNull;default:''" json:"record_path"`
	Type              string           `gorm:"column:type;notNull;default:''" json:"type"`
	TranscodeSuffix   string           `gorm:"column:transcode_suffix;notNull;default:''" json:"transcode_suffix"`
}

MediaServer domain model

func (*MediaServer) GetSDPIP

func (m *MediaServer) GetSDPIP() string

func (*MediaServer) TableName

func (*MediaServer) TableName() string

TableName database table name

type MediaServerPorts

type MediaServerPorts struct {
	HTTP     int `json:"http"`
	HTTPS    int `json:"https"`
	RTMP     int `json:"rtmp"`
	FLV      int `json:"flv"`
	FLVs     int `json:"flvs"`
	WsFLV    int `json:"ws_flv"`
	WsFLVs   int `json:"ws_flvs"`
	RTMPs    int `json:"rtmps"`
	RTPPorxy int `json:"rtpporxy"`
	RTSP     int `json:"rtsp"`
	RTSPs    int `json:"rtsps"`
}

MediaServerPorts domain model

func (*MediaServerPorts) Scan

func (i *MediaServerPorts) Scan(input any) error

Scan implements orm.Scaner.

func (MediaServerPorts) Value

func (i MediaServerPorts) Value() (driver.Value, error)

Value implements driver.Valuer.

type MediaServerStorer

MediaServerStorer Instantiation interface

type NodeManager

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

func NewNodeManager

func NewNodeManager(storer Storer) *NodeManager

func (*NodeManager) AddStreamProxy

func (n *NodeManager) AddStreamProxy(server *MediaServer, in AddStreamProxyRequest) (*zlm.AddStreamProxyResponse, error)

AddStreamProxy 添加流代理

func (*NodeManager) Close

func (n *NodeManager) Close()

func (*NodeManager) CloseRTPServer

CloseRTPServer 关闭RTP服务器

func (*NodeManager) GetSnapshot

func (n *NodeManager) GetSnapshot(server *MediaServer, in GetSnapRequest) ([]byte, error)

func (*NodeManager) GetStreamLiveAddr

func (n *NodeManager) GetStreamLiveAddr(server *MediaServer, httpPrefix, host, app, stream string) StreamLiveAddr

func (*NodeManager) IsOnline

func (n *NodeManager) IsOnline(serverID string) bool

func (*NodeManager) Keepalive

func (n *NodeManager) Keepalive(serverID string)

func (*NodeManager) OpenRTPServer

OpenRTPServer 开启RTP服务器

func (*NodeManager) RegisterDriver

func (n *NodeManager) RegisterDriver(name string, driver Driver)

func (*NodeManager) Run

func (n *NodeManager) Run(bc *conf.Bootstrap, serverPort int) error

type NodeServicer

type NodeServicer any

type Storer

type Storer interface {
	MediaServer() MediaServerStorer
}

Storer data persistence

type StreamLiveAddr

type StreamLiveAddr struct {
	Label   string `json:"label"`
	WSFLV   string `json:"ws_flv"`
	HTTPFLV string `json:"http_flv"`
	RTMP    string `json:"rtmp"`
	RTSP    string `json:"rtsp"`
	WebRTC  string `json:"webrtc"`
	HLS     string `json:"hls"`
}

type WarpMediaServer

type WarpMediaServer struct {
	IsOnline      bool
	LastUpdatedAt time.Time
	Config        *MediaServer
}

type ZLMDriver

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

func NewZLMDriver

func NewZLMDriver() *ZLMDriver

func (*ZLMDriver) AddStreamProxy

func (*ZLMDriver) CloseRTPServer

func (*ZLMDriver) Connect

func (d *ZLMDriver) Connect(ctx context.Context, ms *MediaServer) error

func (*ZLMDriver) GetSnapshot

func (d *ZLMDriver) GetSnapshot(ctx context.Context, ms *MediaServer, req *GetSnapRequest) ([]byte, error)

func (*ZLMDriver) GetStreamLiveAddr

func (d *ZLMDriver) GetStreamLiveAddr(ctx context.Context, ms *MediaServer, httpPrefix, host, app, stream string) StreamLiveAddr

GetStreamLiveAddr implements Driver.

func (*ZLMDriver) OpenRTPServer

func (*ZLMDriver) Ping

func (d *ZLMDriver) Ping(ctx context.Context, ms *MediaServer) error

func (*ZLMDriver) Protocol

func (d *ZLMDriver) Protocol() string

func (*ZLMDriver) Setup

func (d *ZLMDriver) Setup(ctx context.Context, ms *MediaServer, webhookURL string) error

Directories

Path Synopsis
store
smsdb
Code generated by godddx, DO AVOID EDIT.
Code generated by godddx, DO AVOID EDIT.

Jump to

Keyboard shortcuts

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