utils

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MimeTypeH264 H264 MIME type.
	// Note: Matching should be case insensitive.
	MimeTypeH264 = "video/H264"
	// MimeTypeOpus Opus MIME type
	// Note: Matching should be case insensitive.
	MimeTypeOpus = "audio/opus"
	// MimeTypeVP8 VP8 MIME type
	// Note: Matching should be case insensitive.
	MimeTypeVP8 = "video/VP8"
	// MimeTypeVP9 VP9 MIME type
	// Note: Matching should be case insensitive.
	MimeTypeVP9 = "video/VP9"
	// MimeTypeG722 G722 MIME type
	// Note: Matching should be case insensitive.
	MimeTypeG722 = "audio/G722"
	// MimeTypePCMU PCMU MIME type
	// Note: Matching should be case insensitive.
	MimeTypePCMU = "audio/PCMU"
	// MimeTypePCMA PCMA MIME type
	// Note: Matching should be case insensitive.
	MimeTypePCMA = "audio/PCMA"
)
View Source
const (
	Connected    = "connected"
	Failed       = "failed"
	Closed       = "closed"
	Disconnected = "disconnected"
)

ice state

View Source
const (
	// ModeAll linter
	ModeAll = "all"
	// ModeVP8 liner
	ModeVP8 = "vp8"
	// ModeVP9 linter
	ModeVP9 = "vp9"
	// ModeH264 linter
	ModeH264 = "h264"
	// ModeOpus linter
	ModeOpus = "opus"
)

Mediaenine mode

View Source
const (
	// SplitStr linter
	SplitStr = "-"
	// NodeType linter
	NodeType = "pn"
	// PeerUp linter
	PeerUp = "up"
	// PeerDown linter
	PeerDown = "down"
	// PeerNodeType linter
	PeerNodeType = "peer_node"
	// MemberType linter
	MemberType = "member"
)

Peer Role

View Source
const (
	// SampleTrackType linter
	SampleTrackType = "sample"
	// RTPTrackType linter
	RTPTrackType = "rtp"
)
View Source
const MaxBufferSize = 1000 * 2048 // 1MB

MaxBufferSize The maximum amount of data that can be buffered before returning errors.

View Source
const MaxMTU = 1460 // 1MB

MaxMTU linter

Variables

View Source
var (
	// DefaultCodecVP8 linter
	DefaultCodecVP8 = "VP8"
	// DefaultCodecVP9 linter
	DefaultCodecVP9 = "VP9"
	// DefaultPayloadVP8 linter
	DefaultPayloadVP8 = 96
	// DefaultPayloadVP9 linter
	DefaultPayloadVP9 = 98
)
View Source
var (
	// DEBUG to logging debug
	DEBUG = os.Getenv("DEBUG")
	// TIMEOUT linter
	TIMEOUT = os.Getenv("TIMEOUT")
)

Functions

func AddTask

func AddTask(id string, tks *time.Timer)

AddTask linter

func CutID

func CutID(id string) (string, string)

CutID cutting id to clientID, peerID

func GenerateID

func GenerateID() string

GenerateID to create new string id

func GetCodec

func GetCodec(codec *string) string

GetCodec get mimetype codec

func GetInterval

func GetInterval() int

GetInterval linter

func GetModeType

func GetModeType(codec string) string

GetModeType get mimetype codec

func GetRepeerGaptime

func GetRepeerGaptime() int

GetRepeerGaptime linter

func MergeID

func MergeID(clientID string, peerID string) string

MergeID merge clientID, peerID to id

func NewSDPType

func NewSDPType(raw string) webrtc.SDPType

NewSDPType format sdp type between pion and javascript

func RandomInt

func RandomInt(min, max int) int

RandomInt to return value in rang (min, max)

func RemoveTask

func RemoveTask(id string)

RemoveTask linter

func ToByte

func ToByte(data interface{}) ([]byte, error)

ToByte convert data to []byte

func ToJSON

func ToJSON(data []byte, des interface{}) error

ToJSON convert []byte to json

func ToString

func ToString(data interface{}) (string, error)

ToString convert struct to string

Types

type Action

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

Action linter

type AdvanceMap

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

AdvanceMap wrap around sync map in go

func NewAdvanceMap

func NewAdvanceMap() *AdvanceMap

NewAdvanceMap linter

func (*AdvanceMap) Capture

func (a *AdvanceMap) Capture() map[string]interface{}

Capture a current map Warning: Current data will be delete after using it

func (*AdvanceMap) Delete

func (a *AdvanceMap) Delete(key interface{})

Delete map with key string

func (*AdvanceMap) Get

func (a *AdvanceMap) Get(key string) (interface{}, bool)

Get get item with key string

func (*AdvanceMap) GetKeys

func (a *AdvanceMap) GetKeys() []string

GetKeys get all keys of map

func (*AdvanceMap) Geti

func (a *AdvanceMap) Geti(key interface{}) (interface{}, bool)

Geti get item with key interface

func (*AdvanceMap) Iter

func (a *AdvanceMap) Iter(callBack func(key, value interface{}) bool)

Iter go though a map

func (*AdvanceMap) Len

func (a *AdvanceMap) Len() int64

Len return len of sync map

func (*AdvanceMap) Set

func (a *AdvanceMap) Set(key string, value interface{})

Set set string key with interface value

func (*AdvanceMap) Seti

func (a *AdvanceMap) Seti(key, value interface{})

Seti set interface key with interface value

func (*AdvanceMap) ToMap

func (a *AdvanceMap) ToMap() map[string]interface{}

ToMap returning map to this value

type Client

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

Client linter

type ClientDataTime

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

ClientDataTime linter

type Forwarder

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

Forwarder linter

func NewForwarder

func NewForwarder(id string, dataTimeChann chan *ClientDataTime) *Forwarder

NewForwarder return new forwarder

func (*Forwarder) AddClient

func (f *Forwarder) AddClient(clientID *string, client *Client)

AddClient linter

func (*Forwarder) Close

func (f *Forwarder) Close()

Close to close all serve

func (*Forwarder) Hub

func (f *Forwarder) Hub(wrapper *Wrapper)

Hub linter

func (*Forwarder) Push

func (f *Forwarder) Push(wrapper *Wrapper)

Push new wrapper to server chan

func (*Forwarder) Register

func (f *Forwarder) Register(clientID *string, handler func(trackID string, wrapper *Wrapper) error)

Register linter

func (*Forwarder) RemoveClient

func (f *Forwarder) RemoveClient(clientID *string)

RemoveClient linter

func (*Forwarder) UnRegister

func (f *Forwarder) UnRegister(clientID *string)

UnRegister linter

type ForwarderMannager

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

ForwarderMannager control all forwadrder manager

func (*ForwarderMannager) AddNewForwarder

func (f *ForwarderMannager) AddNewForwarder(fwdID string) *Forwarder

AddNewForwarder linter

func (*ForwarderMannager) Close

func (f *ForwarderMannager) Close()

Close lstringer

func (*ForwarderMannager) GetClient

func (f *ForwarderMannager) GetClient(trackID, pcID *string) chan *Wrapper

GetClient linter

func (*ForwarderMannager) GetForwarder

func (f *ForwarderMannager) GetForwarder(id string) *Forwarder

GetForwarder get forwarder of this id is exist or not

func (*ForwarderMannager) GetKeys

func (f *ForwarderMannager) GetKeys() []string

GetKeys return id of all forwarder

func (*ForwarderMannager) GetLastTimeReceive

func (f *ForwarderMannager) GetLastTimeReceive() map[string]int64

GetLastTimeReceive linter

func (*ForwarderMannager) GetLastTimeReceiveBy

func (f *ForwarderMannager) GetLastTimeReceiveBy(trackID string) int64

GetLastTimeReceiveBy linter

func (*ForwarderMannager) Push

func (f *ForwarderMannager) Push(id string, wrapper *Wrapper)

Push to wrapper to specific id

func (*ForwarderMannager) Register

func (f *ForwarderMannager) Register(trackID string, clientID string, handler func(trackID string, wrapper *Wrapper) error)

Register regis a client id to specific forwarder

func (*ForwarderMannager) RegisterAll added in v0.1.0

func (f *ForwarderMannager) RegisterAll(clientID string, handler func(trackID string, wrapper *Wrapper) error)

func (*ForwarderMannager) RemoveForwarder

func (f *ForwarderMannager) RemoveForwarder(id string)

RemoveForwarder remove forwader with id

func (*ForwarderMannager) Unregister

func (f *ForwarderMannager) Unregister(trackID, pcID *string)

Unregister unregis clientId to specific forwarder

func (*ForwarderMannager) UnregisterAll

func (f *ForwarderMannager) UnregisterAll(peerConnectionID string)

UnregisterAll linter

type Fwdm

type Fwdm interface {
	UnregisterAll(peerConnectionID string) // unregister of fwd with input peer connection id
	RegisterAll(clientID string, handler func(trackID string, wrapper *Wrapper) error)
	Register(fwdID string, clientID string, handler func(trackID string, wrapper *Wrapper) error)
	Unregister(trackID, pcID *string)
	AddNewForwarder(id string) *Forwarder
	RemoveForwarder(id string)
	GetForwarder(id string) *Forwarder
	Push(id string, wrapper *Wrapper)
	GetKeys() []string
	Close()
	GetClient(trackID, pcID *string) chan *Wrapper
	GetLastTimeReceive() map[string]int64
	GetLastTimeReceiveBy(trackID string) int64
}

Fwdm linter

func NewForwarderMannager

func NewForwarderMannager(id string) Fwdm

NewForwarderMannager create audio or video forwader

type FwdmAction

type FwdmAction struct {
	Action
	// contains filtered or unexported fields
}

FwdmAction linter

type Log added in v0.0.5

type Log interface {
	ERROR(msg string, tags map[string]any)
	INFO(msg string, tags map[string]any)
	WARN(msg string, tags map[string]any)
	DEBUG(msg string, tags map[string]any)
	STACK(msg ...string)
}

Log default method

type SDPParser

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

SDPParser linter

func NewSDPParser

func NewSDPParser(data *string) (*SDPParser, error)

NewSDPParser linter

func (*SDPParser) GetArrPayLoadType

func (s *SDPParser) GetArrPayLoadType(codec *string) ([]uint8, error)

GetArrPayLoadType return a list of input sdp payload input sdp data

func (*SDPParser) GetPayLoadType

func (s *SDPParser) GetPayLoadType(codec *string) (uint8, error)

GetPayLoadType input a sdp string return payload of input codec

type SDPTemp

type SDPTemp struct {
	SDP  string `json:"sdp"`
	Type string `json:"type"`
}

SDPTemp save sdp temp to convert Pion SDP

type TaskTimer

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

TaskTimer linter

func NewTaskTimer

func NewTaskTimer() *TaskTimer

NewTaskTimer linter

type TurnConfig

type TurnConfig struct {
	URLs     string `json:"urls"`
	Username string `json:"username"`
	Password string `json:"password"`
}

TurnConfig handle foreach turn config in list

type TurnConfigList

type TurnConfigList struct {
	Success bool         `json:"success"`
	Message string       `json:"message"`
	Data    []TurnConfig `json:"data"`
}

TurnConfigList get resp body

type TurnRequestBody

type TurnRequestBody struct {
	CallType  string `json:"callType"`
	RequestID string `json:"requestID"`
}

TurnRequestBody linter

type Wrapper

type Wrapper struct {
	Duration time.Duration
	Pkg      *rtp.Packet // save rtp packet
	Data     []byte      `json:"rtp"`    // packet to write
	Kind     *string     `json:"kind"`   // audio or video
	SeatID   *int        `json:"seatID"` // stream id number 1-2-3-4
	Type     *string     `json:"type"`   // type off wrapper data - ok - ping - pong
}

Wrapper linter

Jump to

Keyboard shortcuts

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