common

package
v0.0.0-...-0acbfb2 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2021 License: MIT Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	STREAM_PREFIX = "stream:"
	DEFAULT_VHOST = "__defaultVhost__"
)

Variables

View Source
var (
	Conf CustomConfig

	PodIp          string
	Hostname       string
	Namespace      string
	LeaderElection bool
	IsLeader       bool
)

Functions

func LeaderElectionRunOrDie

func LeaderElectionRunOrDie(leaseName string)

func ParseHeaderAuthorization

func ParseHeaderAuthorization(val string) (user string, password string)

Types

type CustomConfig

type CustomConfig struct {
	RedisMode      string `env:"redis_mode" envDefault:"Standalone"`
	RedislHost     string `env:"redis_host" envDefault:"127.0.0.1"`
	RedisPort      int    `env:"redis_port" envDefault:"6379"`
	RedisMaster    string `env:"redis_master" envDefault:"mymaster"`
	RedisPassword  string `env:"redis_pass"`
	RedisDatabase  int    `env:"redis_database"`
	RedisMaxIdle   int    `env:"redis_pool_min" envDefault:"3"`
	RedisMaxActive int    `env:"redis_pool_max" envDefault:"10"`

	Endpoint        string `env:"minio_endpoint" envDefault:"play.min.io"`
	Port            int    `env:"minio_port" envDefault:"80"`
	AccessKeyID     string `env:"minio_accessKey"`
	SecretAccessKey string `env:"minio_secretKey"`
	UseSSL          bool   `env:"minio_use_ssl" envDefault:"false"`
	BucketName      string `env:"minio_bucketName"`
	BucketPrefix    string `env:"minio_bucketPrefix"`

	DefaultAdminPasswd string `env:"DEFAULT_ADMIN_PASSWORD"`

	SrsApiServer string
	SrsCfgFile   string
	SrsHlsPath   string
	SrsProxyHost string
	SrsHlsExpire int64

	DefaultTokenExpire int64
}

type FileSystem

type FileSystem interface {
	Open() (string, error)
	Read(buf []byte) (int, error)
	Close() error
}

type HttpFileSystem

type HttpFileSystem struct {
	Path   string
	Client func() (*http.Response, error)
	// contains filtered or unexported fields
}

func (*HttpFileSystem) Close

func (fs *HttpFileSystem) Close() error

func (*HttpFileSystem) Open

func (fs *HttpFileSystem) Open() (path string, err error)

func (*HttpFileSystem) Read

func (fs *HttpFileSystem) Read(buf []byte) (int, error)

func (*HttpFileSystem) Write

func (fs *HttpFileSystem) Write(data []byte) (nn int, err error)

type LocalFileSystem

type LocalFileSystem struct {
	Path string
	// contains filtered or unexported fields
}

func (*LocalFileSystem) Close

func (fs *LocalFileSystem) Close() error

func (*LocalFileSystem) Open

func (fs *LocalFileSystem) Open() (path string, err error)

func (*LocalFileSystem) Read

func (fs *LocalFileSystem) Read(buf []byte) (int, error)

func (*LocalFileSystem) WriteTo

func (fs *LocalFileSystem) WriteTo(w io.Writer) (int64, error)

type RedisPool

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

func (*RedisPool) AddUser

func (s *RedisPool) AddUser(info *UserInfo) (*UserInfo, error)

func (*RedisPool) Close

func (s *RedisPool) Close()

func (*RedisPool) DeleteStream

func (s *RedisPool) DeleteStream(key string) error

func (*RedisPool) DeleteUser

func (s *RedisPool) DeleteUser(account string) error

func (*RedisPool) GetStreamInfo

func (s *RedisPool) GetStreamInfo(stream string) (*StreamInfo, error)

func (*RedisPool) GetStreams

func (s *RedisPool) GetStreams(streams []string) ([]StreamInfo, error)

func (*RedisPool) GetUserInfo

func (s *RedisPool) GetUserInfo(account string) (*UserInfo, error)

func (*RedisPool) GetUsers

func (s *RedisPool) GetUsers(accounts []string) ([]UserInfo, error)

func (*RedisPool) InitAdminUser

func (s *RedisPool) InitAdminUser() string

func (*RedisPool) NewStream

func (s *RedisPool) NewStream(key, owner string) (*StreamInfo, error)

func (*RedisPool) RefreshToken

func (s *RedisPool) RefreshToken(info *UserInfo) (*UserInfo, error)

func (*RedisPool) SubscribeStream

func (s *RedisPool) SubscribeStream(key string, accounts []string) (*StreamInfo, error)

func (*RedisPool) TokenAuth

func (s *RedisPool) TokenAuth(e *WebHookEvent) (int, string, *StreamInfo)

func (*RedisPool) UnsubscribeStream

func (s *RedisPool) UnsubscribeStream(key string, accounts []string) (*StreamInfo, error)

func (*RedisPool) UpdateStreamMetadata

func (s *RedisPool) UpdateStreamMetadata(key string, meta StreamMeta) (*StreamInfo, error)

type S3Client

type S3Client struct{}

func (*S3Client) FPutObject

func (c *S3Client) FPutObject(objectName, filePath string) (err error)

func (*S3Client) GetObject

func (c *S3Client) GetObject(objectName string) (*minio.Object, error)

type StreamDesc

type StreamDesc struct {
	Key    string
	Owner  string
	Exists bool
	Meta   StreamMeta
}

type StreamInfo

type StreamInfo struct {
	Users []string
	StreamDesc
}

type StreamMeta

type StreamMeta struct {
	PlaySecret    bool
	PlaySubscribe bool
	HlsBackup     bool
	ClusterOrigin []byte
}

type UserInfo

type UserInfo struct {
	Account     string
	Exists      bool
	Password    string
	Token       string
	TokenExpire int64
}

type WatcherDaemon

type WatcherDaemon struct{}

func NewWatcher

func NewWatcher() *WatcherDaemon

func (*WatcherDaemon) ConfigFile

func (fs *WatcherDaemon) ConfigFile(user, password string)

func (*WatcherDaemon) MediaFile

func (fs *WatcherDaemon) MediaFile(root string)

type WebHookEvent

type WebHookEvent struct {
	Action string `json:"action" binding:"required"`
	//ClientId string `json:"client_id"`
	Ip      string `json:"ip" binding:"required"`
	Vhost   string `json:"vhost" binding:"required"`
	App     string `json:"app" binding:"required"`
	Stream  string `json:"stream" binding:"required"`
	Param   string `json:"param"`
	Url     string `json:"url"`
	M3u8Url string `json:"m3u8_url"`
}

Jump to

Keyboard shortcuts

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