utils

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KSliceParamStartId     = "startID"
	KSliceParamSubstreamId = "substreamID"
	KSliceParamStreamBase  = "streambase"
	KSliceParamSliceRange  = "sliceRange"
	KSliceParamQuickOffset = "quickOffset"
)

Variables

This section is empty.

Functions

func BytesToUint16

func BytesToUint16(buf []byte) uint16

func BytesToUint32

func BytesToUint32(buf []byte) uint32

func BytesToUint64

func BytesToUint64(buf []byte) uint64

func ContextDone

func ContextDone(ctx context.Context) bool

ContextDone 判断一个context是否已经结束/取消/超时

func ExtractLiveInfo

func ExtractLiveInfo(rawurl string) (host, app, sid string, err error)

func ExtractStreamID

func ExtractStreamID(streamName string) string

ExtractStreamID 从streamName抽取streamID

func FileExists

func FileExists(path string) bool

func GetCidFromStreamID

func GetCidFromStreamID(sid string) string

GetCidFromStreamID 从streamID获取cid

func GetHackStreamID

func GetHackStreamID(tcUrl string) string

func GetModuleName

func GetModuleName(fullModuleName string) string

GetModuleName 从fullModuleName获取moduleName,考虑将httpflv模块后缀去掉

func GetSrcStreamName

func GetSrcStreamName(sid string) string

获取源流流名称

func GetStreamInfo

func GetStreamInfo(sid string) (cid string, roomID string, sessionID string)

GetStreamInfo ...

func GetSubPath

func GetSubPath(path string) []string

func GetTsInfoFromTsUrl

func GetTsInfoFromTsUrl(rawurl string) (sid, fileName string, err error)

GetTsInfoFromTsUrl sg-live-43287-96716-1626688779.ts

func GetUrlFileSuffix

func GetUrlFileSuffix(rawurl string) (suffix string, err error)

func HTTPPost

func HTTPPost(cli *http.Client, url, data string) (string, error)

HTTPPost 对http post请求的包装

func IsSliceRangeReq

func IsSliceRangeReq(srcUrl string) bool

func IsSliceSubstreamReq

func IsSliceSubstreamReq(srcUrl string) bool

func IsSrcStreamName

func IsSrcStreamName(sid string) bool

判断是否是源流 TODO: 配置转码模板判断是否为转码流

func IsValidURL

func IsValidURL(s string) bool

func MSTimeString

func MSTimeString() string

MSTimeString 返回当前时间字符串,精确到毫秒,格式yyyymmddhhmiss.000

func NewTimer

func NewTimer(threshold time.Duration) *timer

func PanicRecover

func PanicRecover()

PanicRecover panic恢复处理

func PanicRecoverWithInfo

func PanicRecoverWithInfo(info string)

PanicRecoverWithInfo panic恢复处理

func ParseHttpSliceRangeReq

func ParseHttpSliceRangeReq(r *http.Request) ([]uint64, error)

ParseHttpSliceRangeReq param: startID=xx&sliceRange=x,x-y,x

func PeelOffPort1935

func PeelOffPort1935(host string) string

PeelOffPort1935 截取IP:1935为IP

func PtsToTime

func PtsToTime(pts int64) time.Duration

PtsToTime video pts to duration

func RebuildURLPath

func RebuildURLPath(path string) string

func RemoveSliceParam

func RemoveSliceParam(r *http.Request) string

func RepairHostWithPort1935

func RepairHostWithPort1935(host string) string

RepairHostWithPort1935 ...

func ReplaceURLHost

func ReplaceURLHost(rawurl string, host string) string

ReplaceURLHost 替换url中的host

func ReplaceURLProtoHost

func ReplaceURLProtoHost(rawurl, proto, host string) string

ReplaceURLProtoHost 替换url中的proto和host

func SetSPEHostEmpty

func SetSPEHostEmpty(rawurl string) string

SetSPEHostEmpty 删除url中的speHost参数

func TimeNowMillisecond

func TimeNowMillisecond() uint64

func TimeToTs

func TimeToTs(tm time.Duration) int32

TimeToTs duration to timestamp

func TimingPause

func TimingPause(pause time.Duration, cost *time.Duration)

TimingPause 带有计时功能的暂停

func Uint16ToBytes

func Uint16ToBytes(i uint16) []byte

func Uint32ToBytes

func Uint32ToBytes(i uint32) []byte

func Uint64ToBytes

func Uint64ToBytes(i uint64) []byte

Types

type SliceRequest

type SliceRequest struct {
	StartSliceId uint64
	SubstreamId  []uint8
	StreamBase   uint8
}

func ParseHttpSliceReq

func ParseHttpSliceReq(r *http.Request) (SliceRequest, error)

Directories

Path Synopsis
pio

Jump to

Keyboard shortcuts

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