Documentation ¶
Overview ¶
Package base 提供被其他多个package依赖的基础内容,自身不依赖任何package
Index ¶
- Constants
- Variables
- func AddCorsHeaders(w http.ResponseWriter)
- func AddCorsHeaders2HlsIfNeeded(w http.ResponseWriter)
- func DefaultTlsConfigClient() *tls.Config
- func DefaultTlsConfigServer(certFile, keyFile string) (*tls.Config, error)
- func GenUkCustomizePubSession() string
- func GenUkFlvPullSession() string
- func GenUkFlvSubSession() string
- func GenUkGroup() string
- func GenUkHlsMuxer() string
- func GenUkHlsSubSession() string
- func GenUkPsPubSession() string
- func GenUkRtmp2MpegtsRemuxer() string
- func GenUkRtmpPullSession() string
- func GenUkRtmpPushSession() string
- func GenUkRtmpServerSession() string
- func GenUkRtspPubSession() string
- func GenUkRtspPullSession() string
- func GenUkRtspPushSession() string
- func GenUkRtspServerCommandSession() string
- func GenUkRtspSubSession() string
- func GenUkTsSubSession() string
- func GetWd() string
- func LogoutStartInfo()
- func MakeWsFrameHeader(wsHeader WsHeader) (buf []byte)
- func NewErrAmfInvalidType(b byte) error
- func NewErrRtmpShortBuffer(need, actual int, msg string) error
- func OsExitAndWaitPressIfWindows(code int)
- func ParseHttpRequest(req *http.Request) string
- func ReadWsPayload(r *bufio.Reader) ([]byte, error)
- func ReadableNowTime() string
- func RunSignalHandler(cb func())
- func UnixMilli(t time.Time) int64
- func UpdateWebSocketHeader(secWebSocketKey, protocol string) []byte
- type ApiCtrlKickSessionReq
- type ApiCtrlKickSessionResp
- type ApiCtrlStartRelayPullReq
- type ApiCtrlStartRelayPullResp
- type ApiCtrlStartRtpPubReq
- type ApiCtrlStartRtpPubResp
- type ApiCtrlStopRelayPullResp
- type ApiRespBasic
- type ApiStatAllGroupResp
- type ApiStatGroupResp
- type ApiStatLalInfoResp
- type AvPacket
- type AvPacketPt
- type AvPacketStreamAudioFormat
- type AvPacketStreamOption
- type AvPacketStreamVideoFormat
- type BasicHttpSubSession
- func (session *BasicHttpSubSession) AppName() string
- func (session *BasicHttpSubSession) Dispose() error
- func (session *BasicHttpSubSession) GetStat() StatSession
- func (session *BasicHttpSubSession) IsAlive() (readAlive, writeAlive bool)
- func (session *BasicHttpSubSession) RawQuery() string
- func (session *BasicHttpSubSession) RunLoop() error
- func (session *BasicHttpSubSession) StreamName() string
- func (session *BasicHttpSubSession) UniqueKey() string
- func (session *BasicHttpSubSession) UpdateStat(intervalSec uint32)
- func (session *BasicHttpSubSession) Url() string
- func (session *BasicHttpSubSession) Write(b []byte)
- func (session *BasicHttpSubSession) WriteHttpResponseHeader(b []byte)
- type BasicHttpSubSessionOption
- type BasicSessionStat
- func (s *BasicSessionStat) AddReadBytes(n int)
- func (s *BasicSessionStat) AddWriteBytes(n int)
- func (s *BasicSessionStat) BaseType() string
- func (s *BasicSessionStat) GetStat() StatSession
- func (s *BasicSessionStat) GetStatWithConn(conn IStatable) StatSession
- func (s *BasicSessionStat) IsAlive() (readAlive, writeAlive bool)
- func (s *BasicSessionStat) IsAliveWitchConn(conn IStatable) (readAlive, writeAlive bool)
- func (s *BasicSessionStat) SetBaseType(baseType string)
- func (s *BasicSessionStat) SetRemoteAddr(addr string)
- func (s *BasicSessionStat) UniqueKey() string
- func (s *BasicSessionStat) UpdateStat(intervalSec uint32)
- func (s *BasicSessionStat) UpdateStatWitchConn(conn IStatable, intervalSec uint32)
- type DumpFile
- func (d *DumpFile) Close() error
- func (d *DumpFile) OpenToRead(filename string) (err error)
- func (d *DumpFile) OpenToWrite(filename string) (err error)
- func (d *DumpFile) ReadOneMessage() (m DumpFileMessage, err error)
- func (d *DumpFile) WriteAvPacket(packet AvPacket, typ uint32) error
- func (d *DumpFile) WriteWithType(b []byte, typ uint32) error
- type DumpFileMessage
- type EventCommonInfo
- type Handler
- type HlsMakeTsInfo
- type HttpServerManager
- type IAvPacketStream
- type IClientSession
- type IClientSessionLifecycle
- type IObject
- type IServerSession
- type IServerSessionLifecycle
- type ISession
- type ISessionStat
- type ISessionUrlContext
- type IStatable
- type LalInfo
- type LocalAddrCtx
- type LogDump
- type MergeWriter
- type OnAvPacketFunc
- type OnWritev
- type PeriodRecord
- type PubStartInfo
- type PubStopInfo
- type PullStartInfo
- type PullStopInfo
- type RecordPerSec
- type RtmpConnectInfo
- type RtmpHeader
- type RtmpMsg
- func (msg RtmpMsg) AudioCodecId() uint8
- func (msg RtmpMsg) Clone() (ret RtmpMsg)
- func (msg RtmpMsg) Cts() uint32
- func (msg RtmpMsg) DebugString() string
- func (msg RtmpMsg) Dts() uint32
- func (msg RtmpMsg) GetEnchanedHevcNaluIndex() int
- func (msg RtmpMsg) IsAacSeqHeader() bool
- func (msg RtmpMsg) IsAvcKeyNalu() bool
- func (msg RtmpMsg) IsAvcKeySeqHeader() bool
- func (msg RtmpMsg) IsEnchanedHevcNalu() bool
- func (msg RtmpMsg) IsEnhanced() bool
- func (msg RtmpMsg) IsHevcKeyNalu() bool
- func (msg RtmpMsg) IsHevcKeySeqHeader() bool
- func (msg RtmpMsg) IsVideoKeyNalu() bool
- func (msg RtmpMsg) IsVideoKeySeqHeader() bool
- func (msg RtmpMsg) Pts() uint32
- func (msg RtmpMsg) VideoCodecId() uint8
- type ServerCtx
- type SessionEventCommonInfo
- type SessionType
- type StatGroup
- type StatPub
- type StatPull
- type StatSession
- type StatSub
- type SubStartInfo
- type SubStopInfo
- type UpdateInfo
- type UrlContext
- type UrlPathContext
- type WsHeader
- type WsOpcode
Constants ¶
const ( AvPacketStreamAudioFormatUnknown AvPacketStreamAudioFormat = 0 AvPacketStreamAudioFormatRawAac AvPacketStreamAudioFormat = 1 AvPacketStreamAudioFormatAdtsAac AvPacketStreamAudioFormat = 2 AvPacketStreamVideoFormatUnknown AvPacketStreamVideoFormat = 0 AvPacketStreamVideoFormatAvcc AvPacketStreamVideoFormat = 1 AvPacketStreamVideoFormatAnnexb AvPacketStreamVideoFormat = 2 )
const ( DumpTypeDefault uint32 = 0 DumpTypePsRtpData uint32 = 1 // 1 DumpTypeRtspRtpData uint32 = 17 // 1+16 DumpTypeRtspSdpData uint32 = 18 DumpTypeCustomizePubData uint32 = 33 // 1+16*2 DumpTypeCustomizePubAudioSpecificConfigData uint32 = 34 DumpTypeInnerFileHeaderData uint32 = 49 // 1+16*3 )
const ( // AudioCodecAac StatGroup.AudioCodec AudioCodecAac = "AAC" AudioCodecG711U = "PCMU" AudioCodecG711A = "PCMA" AudioCodecOpus = "OPUS" // VideoCodecAvc StatGroup.VideoCodec VideoCodecAvc = "H264" VideoCodecHevc = "H265" )
const ( PullRetryNumForever = -1 // 永远重试 PullRetryNumNever = 0 // 不重试 AutoStopPullAfterNoOutMsNever = -1 AutoStopPullAfterNoOutMsImmediately = 0 RtspModeTcp = 0 RtspModeUdp = 1 )
const ( ErrorCodeSucc = 0 DespSucc = "succ" ErrorCodePageNotFound = 404 DespPageNotFound = "page not found, check this document out: https://pengrl.com/lal/#/HTTPAPI" ErrorCodeGroupNotFound = 1001 DespGroupNotFound = "group not found" ErrorCodeParamMissing = 1002 DespParamMissing = "param missing" ErrorCodeSessionNotFound = 1003 DespSessionNotFound = "session not found" ErrorCodeStartRelayPullFail = 2001 ErrorCodeListenUdpPortFail = 2002 )
const ( // RtmpTypeIdAudio spec-rtmp_specification_1.0.pdf // 7.1. Types of Messages RtmpTypeIdAudio uint8 = 8 RtmpTypeIdVideo uint8 = 9 RtmpTypeIdMetadata uint8 = 18 // RtmpTypeIdDataMessageAmf0 RtmpTypeIdSetChunkSize uint8 = 1 // RtmpTypeIdAck 和 RtmpTypeIdWinAckSize 的含义: // // 一端向另一端发送 RtmpTypeIdWinAckSize ,要求对端每收够一定数据(一定数据的阈值包含在 RtmpTypeIdWinAckSize 信令中)后,向本端回复 RtmpTypeIdAck 。 // // 常见的应用场景:数据发送端要求数据接收端定时发送心跳信令给本端。 RtmpTypeIdAck uint8 = 3 RtmpTypeIdUserControl uint8 = 4 // RtmpTypeIdWinAckSize 见 RtmpTypeIdAck RtmpTypeIdWinAckSize uint8 = 5 RtmpTypeIdBandwidth uint8 = 6 RtmpTypeIdCommandMessageAmf3 uint8 = 17 RtmpTypeIdCommandMessageAmf0 uint8 = 20 RtmpTypeIdAggregateMessage uint8 = 22 // RtmpUserControlStreamBegin RtmpUserControlXxx... // // user control message type // RtmpUserControlStreamBegin uint8 = 0 RtmpUserControlRecorded uint8 = 4 RtmpUserControlPingRequest uint8 = 6 RtmpUserControlPingResponse uint8 = 7 // RtmpFrameTypeKey spec-video_file_format_spec_v10.pdf // Video tags // VIDEODATA // FrameType UB[4] // CodecId UB[4] // AVCVIDEOPACKET // AVCPacketType UI8 // CompositionTime SI24 // Data UI8[n] RtmpFrameTypeKey uint8 = 1 RtmpFrameTypeInter uint8 = 2 // RtmpCodecIdAvc // // Video tags -> VIDEODATA -> CodecID // // 1: JPEG (currently unused) // 2: Sorenson H.263 // 3: Screen video // 4: On2 VP6 // 5: On2 VP6 with alpha channel // 6: Screen video version 2 // 7: AVC // RtmpCodecIdAvc uint8 = 7 RtmpCodecIdHevc uint8 = 12 // RtmpAvcPacketTypeSeqHeader RtmpAvcPacketTypeNalu RtmpHevcPacketTypeSeqHeader RtmpHevcPacketTypeNalu // 注意,按照标准文档上描述,PacketType还有可能为2: // 2: AVC end of sequence (lower level NALU sequence ender is not required or supported) // // 我自己遇到过在流结尾时,对端发送 27 02 00 00 00的情况(比如我们的使用wontcry.flv的单元测试,最后一个包) // RtmpAvcPacketTypeSeqHeader uint8 = 0 RtmpAvcPacketTypeNalu uint8 = 1 RtmpHevcPacketTypeSeqHeader = RtmpAvcPacketTypeSeqHeader RtmpHevcPacketTypeNalu = RtmpAvcPacketTypeNalu // enhanced-rtmp packetType https://github.com/veovera/enhanced-rtmp RtmpExPacketTypeSequenceStart uint8 = 0 RtmpExPacketTypeCodedFrames uint8 = 1 // CompositionTime不为0时有这个类型 RtmpExPacketTypeSequenceEnd uint8 = 2 RtmpExPacketTypeCodedFramesX uint8 = 3 // RtmpExFrameTypeKeyFrame RtmpExFrameTypeXXX... // // The following FrameType values are defined: // 0 = reserved // 1 = key frame (a seekable frame) // 2 = inter frame (a non-seekable frame) // ... RtmpExFrameTypeKeyFrame uint8 = 1 RtmpAvcKeyFrame = RtmpFrameTypeKey<<4 | RtmpCodecIdAvc RtmpHevcKeyFrame = RtmpFrameTypeKey<<4 | RtmpCodecIdHevc RtmpAvcInterFrame = RtmpFrameTypeInter<<4 | RtmpCodecIdAvc RtmpHevcInterFrame = RtmpFrameTypeInter<<4 | RtmpCodecIdHevc // RtmpSoundFormatAac spec-video_file_format_spec_v10.pdf // Audio tags // AUDIODATA // SoundFormat UB[4] // SoundRate UB[2] // SoundSize UB[1] // SoundType UB[1] // AACAUDIODATA // AACPacketType UI8 // Data UI8[n] // 注意,视频的CodecId是后4位,音频是前4位 RtmpSoundFormatG711A uint8 = 7 RtmpSoundFormatG711U uint8 = 8 RtmpSoundFormatAac uint8 = 10 RtmpSoundFormatOpus uint8 = 13 RtmpAacPacketTypeSeqHeader = 0 RtmpAacPacketTypeRaw = 1 )
const ( // RtpPacketTypeAvcOrHevc // // 注意,一般情况下: // AVC 96 // HEVC 98 // AAC 97 // // 但是我还遇到过: // AVC 105 // HEVC 96 // AAC 104 // RtpPacketTypeAvcOrHevc = 96 RtpPacketTypeAac = 97 RtpPacketTypeHevc = 98 )
const ( SessionTypeCustomizePub SessionType = SessionProtocolCustomize<<8 | SessionBaseTypePub SessionTypeRtmpServerSession SessionType = SessionProtocolRtmp<<8 | SessionBaseTypePubSub SessionTypeRtmpPush SessionType = SessionProtocolRtmp<<8 | SessionBaseTypePush SessionTypeRtmpPull SessionType = SessionProtocolRtmp<<8 | SessionBaseTypePull SessionTypeRtspPub SessionType = SessionProtocolRtsp<<8 | SessionBaseTypePub SessionTypeRtspSub SessionType = SessionProtocolRtsp<<8 | SessionBaseTypeSub SessionTypeRtspPush SessionType = SessionProtocolRtsp<<8 | SessionBaseTypePush SessionTypeRtspPull SessionType = SessionProtocolRtsp<<8 | SessionBaseTypePull SessionTypeFlvSub SessionType = SessionProtocolFlv<<8 | SessionBaseTypeSub SessionTypeFlvPull SessionType = SessionProtocolFlv<<8 | SessionBaseTypePull SessionTypeTsSub SessionType = SessionProtocolTs<<8 | SessionBaseTypeSub SessionTypePsPub SessionType = SessionProtocolPs<<8 | SessionBaseTypePub SessionTypeHlsSub SessionType = SessionProtocolHls<<8 | SessionBaseTypeSub SessionProtocolCustomize = 1 SessionProtocolRtmp = 2 SessionProtocolRtsp = 3 SessionProtocolFlv = 4 SessionProtocolTs = 5 SessionProtocolPs = 6 SessionProtocolHls = 7 SessionBaseTypePubSub = 1 SessionBaseTypePub = 2 SessionBaseTypeSub = 3 SessionBaseTypePush = 4 SessionBaseTypePull = 5 SessionProtocolCustomizeStr = "CUSTOMIZE" SessionProtocolRtmpStr = "RTMP" SessionProtocolRtspStr = "RTSP" SessionProtocolFlvStr = "FLV" SessionProtocolTsStr = "TS" SessionProtocolPsStr = "PS" SessionProtocolHlsStr = "HLS" SessionBaseTypePubSubStr = "PUBSUB" SessionBaseTypePubStr = "PUB" SessionBaseTypeSubStr = "SUB" SessionBaseTypePushStr = "PUSH" SessionBaseTypePullStr = "PULL" )
const ( UkPreCustomizePubSessionContext = SessionProtocolCustomizeStr + SessionBaseTypePubStr // "CUSTOMIZEPUB" UkPreRtmpServerSession = SessionProtocolRtmpStr + SessionBaseTypePubSubStr // "RTMPPUBSUB" // 两种可能,pub或者sub UkPreRtmpPushSession = SessionProtocolRtmpStr + SessionBaseTypePushStr // "RTMPPUSH" UkPreRtmpPullSession = SessionProtocolRtmpStr + SessionBaseTypePullStr // "RTMPPULL" UkPreRtspPubSession = SessionProtocolRtspStr + SessionBaseTypePubStr // "RTSPPUB" UkPreRtspSubSession = SessionProtocolRtspStr + SessionBaseTypeSubStr // "RTSPSUB" UkPreRtspPushSession = SessionProtocolRtspStr + SessionBaseTypePushStr // "RTSPPUSH" UkPreRtspPullSession = SessionProtocolRtspStr + SessionBaseTypePullStr // "RTSPPULL" UkPreFlvSubSession = SessionProtocolFlvStr + SessionBaseTypePubSubStr // "FLVSUB" UkPreFlvPullSession = SessionProtocolFlvStr + SessionBaseTypePullStr // "FLVPULL" UkPreTsSubSession = SessionProtocolTsStr + SessionBaseTypePubSubStr // "TSSUB" UkPrePsPubSession = SessionProtocolPsStr + SessionBaseTypePubStr // "PSPUB" UkPreHlsSubSession = SessionProtocolHlsStr + SessionBaseTypeSubStr // "HLSSUB" UkPreRtspServerCommandSession = "RTSPSRVCMD" // 这个不暴露给上层 UkPreGroup = "GROUP" UkPreHlsMuxer = "HLSMUXER" UkPreRtmp2MpegtsRemuxer = "RTMP2MPEGTS" )
const ( DefaultRtmpPort = 1935 DefaultHttpPort = 80 DefaultHttpsPort = 443 DefaultRtspPort = 554 DefaultRtmpsPort = 443 DefaultRtspsPort = 322 )
const ConfVersion = "v0.4.1"
ConfVersion lalserver的配置文件的版本号
const HttpApiVersion = "v0.4.7"
HttpApiVersion lalserver的HTTP-API功能的版本号
const HttpNotifyVersion = "v0.2.3"
HttpNotifyVersion lalserver的HTTP-Notify功能的版本号
const HttpWebUiVersion = "v0.0.3"
const LalVersion = "v0.37.4"
LalVersion 整个lal工程的版本号。注意,该变量由外部脚本修改维护,不要手动在代码中修改
const (
NetworkTcp = "tcp"
)
const WsMagicStr = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
Variables ¶
var ( ErrShortBuffer = errors.New("lal: buffer too short") ErrFileNotExist = errors.New("lal: file not exist") )
var ( ErrAddrEmpty = errors.New("lal.base: http server addr empty") ErrMultiRegisterForPattern = errors.New("lal.base: http server multiple registrations for pattern") ErrSessionNotStarted = errors.New("lal.base: session has not been started yet") ErrInvalidUrl = errors.New("lal.base: invalid url") )
var ( ErrAmfInvalidType = errors.New("lal.rtmp: invalid amf0 type") ErrAmfTooShort = errors.New("lal.rtmp: too short to unmarshal amf0 data") ErrAmfNotExist = errors.New("lal.rtmp: not exist") ErrRtmpShortBuffer = errors.New("lal.rtmp: buffer too short") ErrRtmpUnexpectedMsg = errors.New("lal.rtmp: unexpected msg") )
var ( ErrRtsp = errors.New("lal.rtsp: fxxk") ErrRtspClosedByObserver = errors.New("lal.rtsp: close by observer") ErrRtspUnsupportedTransport = errors.New("lal.rtsp: unsupported Transport") )
var ( ErrDupInStream = errors.New("lal.logic: in stream already exist at group") ErrDisposedInStream = errors.New("lal.logic: in stream already disposed") ErrSimpleAuthParamNotFound = errors.New("lal.logic: simple auth failed since url param lal_secret not found") ErrSimpleAuthFailed = errors.New("lal.logic: simple auth failed since url param lal_secret invalid") )
var ( LalLibraryName = "lal" LalGithubRepo = "github.com/q191201771/lal" LalGithubSite = "https://github.com/q191201771/lal" LalDocSite = "https://pengrl.com/lal" // LalFullInfo e.g. lal v0.12.3 (github.com/q191201771/lal) LalFullInfo = LalLibraryName + " " + LalVersion + " (" + LalGithubRepo + ")" // LalVersionDot e.g. 0.12.3 LalVersionDot string // LalVersionComma e.g. 0,12,3 LalVersionComma string )
var ( // LalRtmpHandshakeWaterMark 植入rtmp握手随机字符串中 // e.g. lal v0.12.3 (github.com/q191201771/lal) LalRtmpHandshakeWaterMark string // LalRtmpConnectResultVersion 植入rtmp server中的connect result信令中 // 注意,有两个object,第一个object中的fmsVer我们保持通用公认的值,在第二个object中植入 // e.g. 0,12,3 LalRtmpConnectResultVersion string // LalRtmpPushSessionConnectVersion e.g. lal0.12.3 LalRtmpPushSessionConnectVersion string // LalRtmpBuildMetadataEncoder e.g. lal0.12.3 LalRtmpBuildMetadataEncoder string // LalHttpflvPullSessionUa e.g. lal/0.12.3 LalHttpflvPullSessionUa string // LalHttpflvSubSessionServer e.g. lal0.12.3 LalHttpflvSubSessionServer string // LalHlsM3u8Server e.g. lal0.12.3 LalHlsM3u8Server string // LalHlsTsServer e.g. lal0.12.3 LalHlsTsServer string // LalRtspOptionsResponseServer e.g. lal0.12.3 LalRtspOptionsResponseServer string // LalHttptsSubSessionServer e.g. lal0.12.3 LalHttptsSubSessionServer string // LalHttpApiServer e.g. lal0.12.3 LalHttpApiServer string // LalRtspPullSessionUa e.g. lal/0.12.3 LalRtspPullSessionUa string // LalPackSdp e.g. lal 0.12.3 LalPackSdp string // LalRtspRealm e.g. lal LalRtspRealm string )
var AddCors2HlsFlag = true
AddCors2HlsFlag 是否为hls增加跨域相关的http header
var ApiNotFoundResp = ApiRespBasic{ ErrorCode: ErrorCodePageNotFound, Desp: DespPageNotFound, }
var (
CorsHeaders = "Access-Control-Allow-Credentials: true\r\n" +
"Access-Control-Allow-Origin: *\r\n" +
"Access-Control-Allow-Headers: Content-Type\r\n"
)
var DefaultApsOption = AvPacketStreamOption{ AudioFormat: AvPacketStreamAudioFormatRawAac, VideoFormat: AvPacketStreamVideoFormatAvcc, }
var ErrAvc = errors.New("lal.avc: fxxk")
var (
ErrGb28181 = errors.New("lal.gb28181: fxxk")
)
var ErrHevc = errors.New("lal.hevc: fxxk")
var ErrHls = errors.New("lal.hls: fxxk")
var ErrHlsSessionNotFound = errors.New("lal.hls: hls session not found")
var ErrRtpRtcpShortBuffer = errors.New("lal.rtprtcp: buffer too short")
var ErrSamplingFrequencyIndex = errors.New("lal.aac: invalid sampling frequency index")
var ErrSdp = errors.New("lal.sdp: fxxk")
var Log = nazalog.GetGlobalLogger()
Functions ¶
func AddCorsHeaders ¶ added in v0.35.41
func AddCorsHeaders(w http.ResponseWriter)
func AddCorsHeaders2HlsIfNeeded ¶ added in v0.37.4
func AddCorsHeaders2HlsIfNeeded(w http.ResponseWriter)
func DefaultTlsConfigClient ¶ added in v0.34.3
func DefaultTlsConfigServer ¶ added in v0.34.3
func GenUkCustomizePubSession ¶ added in v0.29.0
func GenUkCustomizePubSession() string
func GenUkFlvPullSession ¶ added in v0.23.0
func GenUkFlvPullSession() string
func GenUkFlvSubSession ¶ added in v0.23.0
func GenUkFlvSubSession() string
func GenUkGroup ¶ added in v0.23.0
func GenUkGroup() string
func GenUkHlsMuxer ¶ added in v0.23.0
func GenUkHlsMuxer() string
func GenUkHlsSubSession ¶ added in v0.33.0
func GenUkHlsSubSession() string
func GenUkPsPubSession ¶ added in v0.31.0
func GenUkPsPubSession() string
func GenUkRtmp2MpegtsRemuxer ¶ added in v0.28.0
func GenUkRtmp2MpegtsRemuxer() string
func GenUkRtmpPullSession ¶ added in v0.23.0
func GenUkRtmpPullSession() string
func GenUkRtmpPushSession ¶ added in v0.23.0
func GenUkRtmpPushSession() string
func GenUkRtmpServerSession ¶ added in v0.23.0
func GenUkRtmpServerSession() string
func GenUkRtspPubSession ¶ added in v0.23.0
func GenUkRtspPubSession() string
func GenUkRtspPullSession ¶ added in v0.23.0
func GenUkRtspPullSession() string
func GenUkRtspPushSession ¶ added in v0.23.0
func GenUkRtspPushSession() string
func GenUkRtspServerCommandSession ¶ added in v0.23.0
func GenUkRtspServerCommandSession() string
func GenUkRtspSubSession ¶ added in v0.23.0
func GenUkRtspSubSession() string
func GenUkTsSubSession ¶ added in v0.23.0
func GenUkTsSubSession() string
func LogoutStartInfo ¶ added in v0.28.0
func LogoutStartInfo()
func MakeWsFrameHeader ¶ added in v0.23.0
func NewErrAmfInvalidType ¶ added in v0.27.0
func NewErrRtmpShortBuffer ¶ added in v0.27.0
func OsExitAndWaitPressIfWindows ¶ added in v0.23.0
func OsExitAndWaitPressIfWindows(code int)
func RunSignalHandler ¶ added in v0.26.0
func RunSignalHandler(cb func())
RunSignalHandler 监听SIGUSR1和SIGUSR2信号并回调
TODO(chef): refactor 函数名应与SIGUSR1挂钩
func UpdateWebSocketHeader ¶ added in v0.22.0
Types ¶
type ApiCtrlKickSessionReq ¶ added in v0.31.0
type ApiCtrlKickSessionResp ¶ added in v0.34.3
type ApiCtrlKickSessionResp struct {
ApiRespBasic
}
type ApiCtrlStartRelayPullReq ¶ added in v0.30.0
type ApiCtrlStartRelayPullReq struct { Url string `json:"url"` StreamName string `json:"stream_name"` PullTimeoutMs int `json:"pull_timeout_ms"` PullRetryNum int `json:"pull_retry_num"` AutoStopPullAfterNoOutMs int `json:"auto_stop_pull_after_no_out_ms"` RtspMode int `json:"rtsp_mode"` DebugDumpPacket string `json:"debug_dump_packet"` }
type ApiCtrlStartRelayPullResp ¶ added in v0.34.3
type ApiCtrlStartRelayPullResp struct { ApiRespBasic Data struct { StreamName string `json:"stream_name"` SessionId string `json:"session_id"` } `json:"data"` }
type ApiCtrlStartRtpPubReq ¶ added in v0.31.0
type ApiCtrlStartRtpPubResp ¶ added in v0.34.3
type ApiCtrlStartRtpPubResp struct { ApiRespBasic Data struct { StreamName string `json:"stream_name"` SessionId string `json:"session_id"` Port int `json:"port"` } `json:"data"` }
type ApiCtrlStopRelayPullResp ¶ added in v0.34.3
type ApiCtrlStopRelayPullResp struct { ApiRespBasic Data struct { SessionId string `json:"session_id"` } `json:"data"` }
type ApiRespBasic ¶ added in v0.34.3
type ApiStatAllGroupResp ¶ added in v0.34.3
type ApiStatAllGroupResp struct { ApiRespBasic Data struct { Groups []StatGroup `json:"groups"` } `json:"data"` }
type ApiStatGroupResp ¶ added in v0.34.3
type ApiStatGroupResp struct { ApiRespBasic Data *StatGroup `json:"data"` }
type ApiStatLalInfoResp ¶ added in v0.34.3
type ApiStatLalInfoResp struct { ApiRespBasic Data LalInfo `json:"data"` }
type AvPacket ¶ added in v0.23.0
type AvPacket struct { PayloadType AvPacketPt Timestamp int64 // 如无特殊说明,此字段是Dts Pts int64 Payload []byte }
AvPacket
不同场景使用时,字段含义可能不同。 使用 AvPacket 的地方,应注明各字段的含义。
func (*AvPacket) DebugString ¶ added in v0.29.0
type AvPacketPt ¶ added in v0.23.0
type AvPacketPt int
const ( AvPacketPtUnknown AvPacketPt = -1 AvPacketPtG711U AvPacketPt = 0 // g711u AvPacketPtG711A AvPacketPt = 8 // g711a AvPacketPtAvc AvPacketPt = 96 // h264 AvPacketPtHevc AvPacketPt = 98 // h265 AvPacketPtAac AvPacketPt = 97 // aac AvPacketPtOpus AvPacketPt = 101 // opus )
func (AvPacketPt) ReadableString ¶ added in v0.23.0
func (a AvPacketPt) ReadableString() string
type AvPacketStreamAudioFormat ¶ added in v0.29.0
type AvPacketStreamAudioFormat int
type AvPacketStreamOption ¶ added in v0.29.0
type AvPacketStreamOption struct { AudioFormat AvPacketStreamAudioFormat VideoFormat AvPacketStreamVideoFormat // 视频流的格式,注意,不是指编码格式,而是编码格式确定后,流的格式 }
type AvPacketStreamVideoFormat ¶ added in v0.29.0
type AvPacketStreamVideoFormat int
type BasicHttpSubSession ¶ added in v0.30.0
type BasicHttpSubSession struct { BasicHttpSubSessionOption // contains filtered or unexported fields }
func NewBasicHttpSubSession ¶ added in v0.30.0
func NewBasicHttpSubSession(option BasicHttpSubSessionOption) *BasicHttpSubSession
func (*BasicHttpSubSession) AppName ¶ added in v0.30.0
func (session *BasicHttpSubSession) AppName() string
func (*BasicHttpSubSession) Dispose ¶ added in v0.30.0
func (session *BasicHttpSubSession) Dispose() error
func (*BasicHttpSubSession) GetStat ¶ added in v0.30.0
func (session *BasicHttpSubSession) GetStat() StatSession
func (*BasicHttpSubSession) IsAlive ¶ added in v0.30.0
func (session *BasicHttpSubSession) IsAlive() (readAlive, writeAlive bool)
func (*BasicHttpSubSession) RawQuery ¶ added in v0.30.0
func (session *BasicHttpSubSession) RawQuery() string
func (*BasicHttpSubSession) RunLoop ¶ added in v0.30.0
func (session *BasicHttpSubSession) RunLoop() error
func (*BasicHttpSubSession) StreamName ¶ added in v0.30.0
func (session *BasicHttpSubSession) StreamName() string
func (*BasicHttpSubSession) UniqueKey ¶ added in v0.30.0
func (session *BasicHttpSubSession) UniqueKey() string
func (*BasicHttpSubSession) UpdateStat ¶ added in v0.30.0
func (session *BasicHttpSubSession) UpdateStat(intervalSec uint32)
func (*BasicHttpSubSession) Url ¶ added in v0.30.0
func (session *BasicHttpSubSession) Url() string
func (*BasicHttpSubSession) Write ¶ added in v0.30.0
func (session *BasicHttpSubSession) Write(b []byte)
func (*BasicHttpSubSession) WriteHttpResponseHeader ¶ added in v0.30.0
func (session *BasicHttpSubSession) WriteHttpResponseHeader(b []byte)
type BasicHttpSubSessionOption ¶ added in v0.30.0
type BasicHttpSubSessionOption struct { Conn net.Conn ConnModOption connection.ModOption SessionType SessionType UrlCtx UrlContext IsWebSocket bool WebSocketKey string }
type BasicSessionStat ¶ added in v0.30.0
type BasicSessionStat struct {
// contains filtered or unexported fields
}
BasicSessionStat
包含两部分功能: 1. 维护 StatSession 的一些静态信息 2. 计算带宽
计算带宽有两种方式,一种是通过外部的 connection.Connection 获取最新状态,一种是内部自己管理状态
func NewBasicSessionStat ¶ added in v0.30.0
func NewBasicSessionStat(sessionType SessionType, remoteAddr string) BasicSessionStat
NewBasicSessionStat
@param remoteAddr: 如果当前未知,填入""空字符串
func (*BasicSessionStat) AddReadBytes ¶ added in v0.30.0
func (s *BasicSessionStat) AddReadBytes(n int)
func (*BasicSessionStat) AddWriteBytes ¶ added in v0.30.0
func (s *BasicSessionStat) AddWriteBytes(n int)
func (*BasicSessionStat) BaseType ¶ added in v0.30.0
func (s *BasicSessionStat) BaseType() string
func (*BasicSessionStat) GetStat ¶ added in v0.30.0
func (s *BasicSessionStat) GetStat() StatSession
func (*BasicSessionStat) GetStatWithConn ¶ added in v0.30.0
func (s *BasicSessionStat) GetStatWithConn(conn IStatable) StatSession
func (*BasicSessionStat) IsAlive ¶ added in v0.30.0
func (s *BasicSessionStat) IsAlive() (readAlive, writeAlive bool)
func (*BasicSessionStat) IsAliveWitchConn ¶ added in v0.30.0
func (s *BasicSessionStat) IsAliveWitchConn(conn IStatable) (readAlive, writeAlive bool)
func (*BasicSessionStat) SetBaseType ¶ added in v0.30.0
func (s *BasicSessionStat) SetBaseType(baseType string)
func (*BasicSessionStat) SetRemoteAddr ¶ added in v0.30.0
func (s *BasicSessionStat) SetRemoteAddr(addr string)
func (*BasicSessionStat) UniqueKey ¶ added in v0.30.0
func (s *BasicSessionStat) UniqueKey() string
func (*BasicSessionStat) UpdateStat ¶ added in v0.30.0
func (s *BasicSessionStat) UpdateStat(intervalSec uint32)
func (*BasicSessionStat) UpdateStatWitchConn ¶ added in v0.30.0
func (s *BasicSessionStat) UpdateStatWitchConn(conn IStatable, intervalSec uint32)
type DumpFile ¶ added in v0.31.0
type DumpFile struct {
// contains filtered or unexported fields
}
func NewDumpFile ¶ added in v0.31.0
func NewDumpFile() *DumpFile
func (*DumpFile) OpenToRead ¶ added in v0.31.0
func (*DumpFile) OpenToWrite ¶ added in v0.31.0
func (*DumpFile) ReadOneMessage ¶ added in v0.31.0
func (d *DumpFile) ReadOneMessage() (m DumpFileMessage, err error)
func (*DumpFile) WriteAvPacket ¶ added in v0.33.0
type DumpFileMessage ¶ added in v0.31.0
type DumpFileMessage struct { Ver uint32 // 制造数据时的代码版本 Typ uint32 Len uint32 // Body 的长度 Timestamp uint64 // 写入时的时间戳 Reserve uint32 Body []byte }
func (*DumpFileMessage) DebugString ¶ added in v0.31.0
func (m *DumpFileMessage) DebugString() string
type EventCommonInfo ¶ added in v0.30.0
type EventCommonInfo struct {
ServerId string `json:"server_id"`
}
EventCommonInfo 所有事件共有的字段
type HlsMakeTsInfo ¶ added in v0.30.0
type HlsMakeTsInfo struct { EventCommonInfo Event string `json:"event"` StreamName string `json:"stream_name"` Cwd string `json:"cwd"` TsFile string `json:"ts_file"` LiveM3u8File string `json:"live_m3u8_file"` RecordM3u8File string `json:"record_m3u8_file"` Id int `json:"id"` Duration float64 `json:"duration"` }
type HttpServerManager ¶ added in v0.23.0
type HttpServerManager struct {
// contains filtered or unexported fields
}
func NewHttpServerManager ¶ added in v0.23.0
func NewHttpServerManager() *HttpServerManager
func (*HttpServerManager) AddListen ¶ added in v0.23.0
func (s *HttpServerManager) AddListen(addrCtx LocalAddrCtx, pattern string, handler Handler) error
AddListen
@param addrCtx:
LocalAddrCtx.IsHttps 是否为https。 注意,如果要为相同的路由同时绑定http和https,那么应该调用该函数两次,分别将该参数设置为true和false。 LocalAddrCtx.Addr 监听地址,内部会为其建立监听。 http和https不能够使用相同的地址。 注意,多次调用,允许使用相同的地址绑定不同的`pattern`。 LocalAddrCtx.CertFile ... LocalAddrCtx.KeyFile ... LocalAddrCtx.Network 如果为空默认为NetworkTcp="tcp"。
@param pattern: 必须以`/`开始,并以`/`结束。
注意,如果是`/`,则在其他所有pattern都匹配失败后,做为兜底匹配成功。 相同的pattern不能绑定不同的`handler`回调函数(显然,我们无法为相同的监听地址,相同的路径绑定多个回调函数)。
func (*HttpServerManager) Dispose ¶ added in v0.23.0
func (s *HttpServerManager) Dispose() error
func (*HttpServerManager) RunLoop ¶ added in v0.23.0
func (s *HttpServerManager) RunLoop() error
type IAvPacketStream ¶ added in v0.29.0
type IAvPacketStream interface { // WithOption 修改配置项 // // TODO(chef): [refactor] 重命名为WithAvPacketStreamOption 202301 // WithOption(modOption func(option *AvPacketStreamOption)) // FeedAudioSpecificConfig 传入音频AAC的初始化数据 // // @param asc: // // AudioSpecificConfig。含义可参考 aac.AscContext, aac.MakeAscWithAdtsHeader 等内容。 // 注意,调用 FeedAvPacket 传入AAC音频数据前,需要先调用 FeedAudioSpecificConfig。 // FeedAudioSpecificConfig 在最开始总共调用一次,后面就可以一直调用 FeedAvPacket // FeedAudioSpecificConfig(asc []byte) error // FeedAvPacket // // @param packet: // // PayloadType: 类型,支持avc(h264),hevc(h265),aac // // Timestamp: 时间戳,单位毫秒。注意,是累计递增值,不是单个包的duration时长。 // // Payload: 音视频数据,格式如下 // // 如果是音频AAC,格式是裸数据,不需要adts头。 // 注意,调用 FeedAvPacket 传入AAC音频数据前,需要先调用 FeedAudioSpecificConfig。 // FeedAudioSpecificConfig 在最开始总共调用一次,后面就可以一直调用 FeedAvPacket // // 如果是视频,支持Avcc和Annexb两种格式。 // Avcc也即[<4字节长度 + nal>...],Annexb也即[<4字节start code 00 00 00 01 + nal>...]。 // 注意,sps和pps也通过 FeedAvPacket 传入。sps和pps可以单独调用 FeedAvPacket,也可以sps+pps+I帧组合在一起调用一次 FeedAvPacket // FeedAvPacket(packet AvPacket) error }
type IClientSession ¶ added in v0.20.0
type IClientSession interface { IClientSessionLifecycle ISession }
type IClientSessionLifecycle ¶ added in v0.20.0
type IClientSessionLifecycle interface { // Dispose 主动关闭session时调用 // // 注意,只有Start(具体session的Start类型函数一般命令为Push和Pull)成功后的session才能调用,否则行为未定义 // // Dispose可在任意协程内调用 // // 注意,目前Dispose允许调用多次,但是未来可能不对该表现做保证 // // Dispose后,调用Write函数将返回错误 // // @return 可以通过返回值判断调用Dispose前,session是否已经被关闭了 TODO(chef) 这个返回值没有太大意义,后面可能会删掉 // Dispose() error // WaitChan Start成功后,可使用这个channel来接收session结束的消息 // // 注意,只有Start成功后的session才能调用,否则行为未定义 // // 注意,目前WaitChan只会被通知一次,但是未来可能不对该表现做保证,业务方应该只关注第一次通知 // // TODO(chef): 是否应该严格保证:获取到关闭消息后,后续不应该再有该session的回调上来 // // @return 一般关闭有以下几种情况: // - 对端关闭,此时error为EOF // - 本端底层关闭,比如协议非法等,此时error为具体的错误值 // - 本端上层主动调用Dispose关闭,此时error为nil // WaitChan() <-chan error }
type IObject ¶ added in v0.20.0
type IObject interface { // UniqueKey // // 对象的全局唯一标识 // UniqueKey() string }
type IServerSession ¶ added in v0.20.0
type IServerSession interface { IServerSessionLifecycle ISession }
type IServerSessionLifecycle ¶ added in v0.20.0
type IServerSessionLifecycle interface { // Dispose 主动关闭session时调用 // // 如果是session通知业务方session已关闭(比如`RunLoop`函数返回错误),则不需要调用`Dispose` TODO(chef): review现状 // Dispose() error }
type ISession ¶ added in v0.30.0
type ISession interface { ISessionUrlContext IObject ISessionStat }
type ISessionStat ¶ added in v0.18.0
type ISessionStat interface { // UpdateStat // // 周期性调用该函数,用于计算bitrate // // @param intervalSec 距离上次调用的时间间隔,单位毫秒 // UpdateStat(intervalSec uint32) // GetStat // // 获取session状态 // // @return 注意,结构体中的`BitrateKbits`的值由最近一次`func UpdateStat`调用计算决定,其他值为当前最新值 // GetStat() StatSession // IsAlive // // 周期性调用该函数,判断是否有读取、写入数据 // 注意,判断的依据是,距离上次调用该函数的时间间隔内,是否有读取、写入数据 // 注意,不活跃,并一定是链路或网络有问题,也可能是业务层没有写入数据 // // @return readAlive 读取是否获取 // @return writeAlive 写入是否活跃 // IsAlive() (readAlive, writeAlive bool) }
ISessionStat
调用约束:对于Client类型的Session,调用Start函数并返回成功后才能调用,否则行为未定义
type ISessionUrlContext ¶ added in v0.23.0
type ISessionUrlContext interface { Url() string AppName() string StreamName() string RawQuery() string // 参数,也即 url param }
ISessionUrlContext 获取和流地址相关的信息
调用约束:对于Client类型的Session,调用Start函数并返回成功后才能调用,否则行为未定义
type IStatable ¶ added in v0.31.0
type IStatable interface {
GetStat() connection.Stat // TODO(chef): [refactor] 考虑为 nazanet.UdpConnection 实现这个接口
}
type LocalAddrCtx ¶ added in v0.23.0
type LogDump ¶ added in v0.28.0
type LogDump struct {
// contains filtered or unexported fields
}
func (*LogDump) Outf ¶ added in v0.28.0
Outf
调用之前需调用 ShouldDump 将 ShouldDump 独立出来的目的是避免不需要打印日志时, Outf 调用前构造实参的开销,比如 ld.Outf("hex=%s", hex.Dump(buf)) 这个hex.Dump调用
func (*LogDump) ShouldDump ¶ added in v0.28.0
type MergeWriter ¶ added in v0.26.0
type MergeWriter struct {
// contains filtered or unexported fields
}
MergeWriter 合并多个内存块,达到阈值后一次性将内存块数组返回给上层
注意,输入时的单个内存块,回调时不会出现拆分切割的情况
func NewMergeWriter ¶ added in v0.26.0
func NewMergeWriter(onWritev OnWritev, size int) *MergeWriter
NewMergeWriter
@param onWritev 回调缓存的1~n个内存块 @param size 回调阈值
func (*MergeWriter) Write ¶ added in v0.26.0
func (w *MergeWriter) Write(b []byte)
Write
注意,函数调用结束后,`b`内存块会被内部持有
type OnAvPacketFunc ¶ added in v0.31.0
type OnAvPacketFunc func(packet *AvPacket)
type PeriodRecord ¶ added in v0.36.7
type PeriodRecord struct {
// contains filtered or unexported fields
}
func NewPeriodRecord ¶ added in v0.36.7
func NewPeriodRecord(bufSize int) PeriodRecord
func (*PeriodRecord) Add ¶ added in v0.36.7
func (p *PeriodRecord) Add(unixSec int64, v uint32)
func (*PeriodRecord) Clear ¶ added in v0.36.7
func (p *PeriodRecord) Clear()
type PubStartInfo ¶ added in v0.17.0
type PubStartInfo struct {
SessionEventCommonInfo
}
func Session2PubStartInfo ¶ added in v0.30.0
func Session2PubStartInfo(session ISession) PubStartInfo
type PubStopInfo ¶ added in v0.17.0
type PubStopInfo struct {
SessionEventCommonInfo
}
func Session2PubStopInfo ¶ added in v0.30.0
func Session2PubStopInfo(session ISession) PubStopInfo
type PullStartInfo ¶ added in v0.30.0
type PullStartInfo struct {
SessionEventCommonInfo
}
func Session2PullStartInfo ¶ added in v0.30.0
func Session2PullStartInfo(session ISession) PullStartInfo
type PullStopInfo ¶ added in v0.30.0
type PullStopInfo struct {
SessionEventCommonInfo
}
func Session2PullStopInfo ¶ added in v0.30.0
func Session2PullStopInfo(session ISession) PullStopInfo
type RecordPerSec ¶ added in v0.36.7
type RtmpConnectInfo ¶ added in v0.23.0
type RtmpHeader ¶ added in v0.23.0
type RtmpMsg ¶ added in v0.23.0
type RtmpMsg struct { Header RtmpHeader Payload []byte // Payload不包含Header内容。如果需要将RtmpMsg序列化成RTMP chunk,可调用 rtmp.ChunkDivider 相关的函数 }
func (RtmpMsg) AudioCodecId ¶ added in v0.34.3
func (RtmpMsg) DebugString ¶ added in v0.31.0
func (RtmpMsg) GetEnchanedHevcNaluIndex ¶ added in v0.35.4
func (RtmpMsg) IsAacSeqHeader ¶ added in v0.23.0
func (RtmpMsg) IsAvcKeyNalu ¶ added in v0.23.0
func (RtmpMsg) IsAvcKeySeqHeader ¶ added in v0.23.0
func (RtmpMsg) IsEnchanedHevcNalu ¶ added in v0.35.4
func (RtmpMsg) IsEnhanced ¶ added in v0.35.4
func (RtmpMsg) IsHevcKeyNalu ¶ added in v0.23.0
func (RtmpMsg) IsHevcKeySeqHeader ¶ added in v0.23.0
func (RtmpMsg) IsVideoKeyNalu ¶ added in v0.23.0
func (RtmpMsg) IsVideoKeySeqHeader ¶ added in v0.23.0
func (RtmpMsg) Pts ¶ added in v0.28.0
Pts
注意,只有视频才能调用该函数获取pts,音频的dts和pts都直接使用 RtmpMsg.Header.TimestampAbs
func (RtmpMsg) VideoCodecId ¶ added in v0.30.0
type ServerCtx ¶ added in v0.23.0
type ServerCtx struct {
// contains filtered or unexported fields
}
type SessionEventCommonInfo ¶ added in v0.17.0
type SessionEventCommonInfo struct { EventCommonInfo SessionId string `json:"session_id"` Protocol string `json:"protocol"` BaseType string `json:"base_type"` RemoteAddr string `json:"remote_addr"` Url string `json:"url"` AppName string `json:"app_name"` StreamName string `json:"stream_name"` UrlParam string `json:"url_param"` HasInSession bool `json:"has_in_session"` HasOutSession bool `json:"has_out_session"` // TODO(chef): [opt] 这两个字段,实际需求出发点是有业务方需要在stop事件做流量统计,但是现在的实现为所有session事件都添加了,是否合适 202208 ReadBytesSum uint64 `json:"read_bytes_sum"` WroteBytesSum uint64 `json:"wrote_bytes_sum"` }
SessionEventCommonInfo session相关的事件的共有的字段
type SessionType ¶ added in v0.30.0
type SessionType int
type StatGroup ¶ added in v0.16.0
type StatGroup struct { StreamName string `json:"stream_name"` AppName string `json:"app_name"` AudioCodec string `json:"audio_codec"` VideoCodec string `json:"video_codec"` VideoWidth int `json:"video_width"` VideoHeight int `json:"video_height"` StatPub StatPub `json:"pub"` StatSubs []StatSub `json:"subs"` // TODO(chef): [opt] 增加数量字段,因为这里不一定全部放入 StatPull StatPull `json:"pull"` Fps []RecordPerSec `json:"in_frame_per_sec"` }
func (*StatGroup) GetFpsFrom ¶ added in v0.36.7
func (s *StatGroup) GetFpsFrom(p *PeriodRecord, nowUnixSec int64)
GetFpsFrom
@note result s.Fps is not ordered
type StatPub ¶ added in v0.16.0
type StatPub struct {
StatSession
}
func Session2StatPub ¶ added in v0.30.0
type StatPull ¶ added in v0.17.0
type StatPull struct {
StatSession
}
func Session2StatPull ¶ added in v0.30.0
type StatSession ¶ added in v0.16.0
type StatSession struct { SessionId string `json:"session_id"` Protocol string `json:"protocol"` BaseType string `json:"base_type"` RemoteAddr string `json:"remote_addr"` StartTime string `json:"start_time"` ReadBytesSum uint64 `json:"read_bytes_sum"` WroteBytesSum uint64 `json:"wrote_bytes_sum"` BitrateKbits int `json:"bitrate_kbits"` ReadBitrateKbits int `json:"read_bitrate_kbits"` WriteBitrateKbits int `json:"write_bitrate_kbits"` // contains filtered or unexported fields }
type StatSub ¶ added in v0.16.0
type StatSub struct {
StatSession
}
func Session2StatSub ¶ added in v0.30.0
type SubStartInfo ¶ added in v0.17.0
type SubStartInfo struct {
SessionEventCommonInfo
}
func Session2SubStartInfo ¶ added in v0.30.0
func Session2SubStartInfo(session ISession) SubStartInfo
type SubStopInfo ¶ added in v0.17.0
type SubStopInfo struct {
SessionEventCommonInfo
}
func Session2SubStopInfo ¶ added in v0.30.0
func Session2SubStopInfo(session ISession) SubStopInfo
type UpdateInfo ¶ added in v0.17.0
type UpdateInfo struct { EventCommonInfo Groups []StatGroup `json:"groups"` }
type UrlContext ¶ added in v0.23.0
type UrlContext struct { Url string Scheme string Username string Password string StdHost string // host or host:port HostWithPort string // 当原始url中不包含port时,填充scheme对应的默认port Host string // 不包含port Port int // 当原始url中不包含port时,填充scheme对应的默认port //UrlPathContext PathWithRawQuery string // 注意,有前面的'/' Path string // 注意,有前面的'/' PathWithoutLastItem string // 注意,没有前面的'/',也没有后面的'/' LastItemOfPath string // 注意,没有前面的'/' RawQuery string // 参数,注意,没有前面的'?' RawUrlWithoutUserInfo string // contains filtered or unexported fields }
func ParseHttpflvUrl ¶ added in v0.23.0
func ParseHttpflvUrl(rawUrl string) (ctx UrlContext, err error)
func ParseRtmpUrl ¶ added in v0.23.0
func ParseRtmpUrl(rawUrl string) (ctx UrlContext, err error)
func ParseRtspUrl ¶ added in v0.23.0
func ParseRtspUrl(rawUrl string) (ctx UrlContext, err error)
func ParseUrl ¶ added in v0.23.0
func ParseUrl(rawUrl string, defaultPort int) (ctx UrlContext, err error)
ParseUrl
@param defaultPort: 注意,如果rawUrl中显示指定了端口,则该参数不生效。 注意,如果设置为-1,内部依然会对常见协议(http, https, rtmp, rtsp)设置官方默认端口。
func (*UrlContext) GetFileType ¶ added in v0.27.0
func (u *UrlContext) GetFileType() string
func (*UrlContext) GetFilenameWithoutType ¶ added in v0.27.0
func (u *UrlContext) GetFilenameWithoutType() string
type UrlPathContext ¶ added in v0.23.0
type WsOpcode ¶ added in v0.22.0
type WsOpcode = uint8
WsOpcode The WebSocket Protocol https://tools.ietf.org/html/rfc6455
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-------+-+-------------+-------------------------------+ |F|R|R|R| opcode|M| Payload len | Extended payload length | |I|S|S|S| (4) |A| (7) | (16/64) | |N|V|V|V| |S| | (if payload len==126/127) | | |1|2|3| |K| | | +-+-+-+-+-------+-+-------------+ - - - - - - - - - - - - - - - + | Extended payload length continued, if payload len == 127 | + - - - - - - - - - - - - - - - +-------------------------------+ | |Masking-key, if MASK set to 1 | +-------------------------------+-------------------------------+ | Masking-key (continued) | Payload Data | +-------------------------------- - - - - - - - - - - - - - - - + : Payload Data continued ... : + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + | Payload Data continued ... | +---------------------------------------------------------------+ opcode: * %x0 denotes a continuation frame * %x1 denotes a text frame * %x2 denotes a binary frame * %x3-7 are reserved for further non-control frames * %x8 denotes a connection close * %x9 denotes a ping * %xA denotes a pong * %xB-F are reserved for further control frames Payload length: 7 bits, 7+16 bits, or 7+64 bits Masking-key: 0 or 4 bytes mark 加密
for i := 0; i < datalen; i { m := markingkeys[i%4] data[i] = msg[i] ^ m }
Source Files ¶
- adapter_go.go
- avpacket.go
- avpacket_stream.go
- base.go
- basic_http_sub_session.go
- basic_session_stat.go
- cors.go
- dump_file.go
- error.go
- http_server.go
- log.go
- merge_writer.go
- osexit.go
- signal_unix.go
- t_http_an__.go
- t_http_an__api.go
- t_http_an__notify.go
- t_rtmp.go
- t_rtprtcp.go
- t_session.go
- t_stat.go
- t_unique.go
- t_version.go
- url.go
- var.go
- websocket.go
- wrap_tls.go