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 MockVersion(...)
- func NewErrAmfInvalidType(b byte) error
- func NewErrRtmpShortBuffer(need, actual int, msg string) error
- func OsExitAndWaitPressIfWindows(code int)
- func ParseHttpRequest(req *http.Request) string
- func ParseReadableTime(t string) (time.Time, error)
- 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
- func WrapReadConfigFile(theConfigFile string, defaultConfigFiles []string, hookBeforeExit func()) []byte
- type ApiCtrlAddIpBlacklistReq
- type ApiCtrlAddIpBlacklistResp
- 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 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 (
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/cool9850311/lal-StreamPlatformLite" LalGithubSite = "https://github.com/cool9850311/lal-StreamPlatformLite" LalDocSite = "https://pengrl.com/lal" LalDocSiteHTTPAPI = "https://pengrl.com/lal/#/HTTPAPI" LalDefaultConfigFilename = "lalserver.conf.json" LalLogo = ` __ ___ __ / / / | / / / / / /| | / / / /___/ ___ |/ /___ /_____/_/ |_/_____/ ` // LalFullInfo e.g. lal v0.12.3 (github.com/cool9850311/lal-StreamPlatformLite) LalFullInfo string // 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/cool9850311/lal-StreamPlatformLite) 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 LalRtmpRandom1528Buf []byte LalFlvHttpResponseHeader []byte LalTsHttpResponseHeader []byte // LalRtspResponseOptionsTmpl CSeq // rfc2326 10.1 OPTIONS LalRtspResponseOptionsTmpl string // LalDefaultConfFilenameList 没有指定配置文件时,按顺序作为优先级,找到第一个存在的并使用 LalDefaultConfFilenameList []string DespPageNotFound string )
var ( // AddCors2HlsFlag 是否为hls增加跨域相关的http header AddCors2HlsFlag = true )
----- hls --------------------
var ConfVersion = "v0.4.1"
ConfVersion lalserver的配置文件的版本号
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 HttpApiVersion = "v0.4.8"
HttpApiVersion lalserver的HTTP-API功能的版本号
var HttpNotifyVersion = "v0.2.4"
HttpNotifyVersion lalserver的HTTP-Notify功能的版本号
var HttpWebUiVersion = "v0.0.3"
var LalVersion = "v0.37.4"
LalVersion 整个lal工程的版本号。注意,该变量由外部脚本修改维护,不要手动在代码中修改
var Log = nazalog.GetGlobalLogger()
var ( // LogicCheckSessionAliveIntervalSec // // 检查session是否有数据传输的时间间隔,该间隔内没有数据传输的session将被关闭。 // // 对于输入型session,检查一定时间内,是否没有收到数据。 // // 对于输出型session,检查一定时间内,是否没有发送数据。 // 注意,socket阻塞无法发送和上层没有向该session喂入数据都算没有发送数据。 // LogicCheckSessionAliveIntervalSec uint32 = 120 )
----- logic --------------------
var (
// RtmpServerSessionReadAvTimeoutMs rtmp server pub session,读音视频数据超时
RtmpServerSessionReadAvTimeoutMs = 120000
)
----- rtmp --------------------
Functions ¶
func AddCorsHeaders ¶
func AddCorsHeaders(w http.ResponseWriter)
func AddCorsHeaders2HlsIfNeeded ¶
func AddCorsHeaders2HlsIfNeeded(w http.ResponseWriter)
func DefaultTlsConfigClient ¶
func DefaultTlsConfigServer ¶
func GenUkCustomizePubSession ¶
func GenUkCustomizePubSession() string
func GenUkFlvPullSession ¶
func GenUkFlvPullSession() string
func GenUkFlvSubSession ¶
func GenUkFlvSubSession() string
func GenUkGroup ¶
func GenUkGroup() string
func GenUkHlsMuxer ¶
func GenUkHlsMuxer() string
func GenUkHlsSubSession ¶
func GenUkHlsSubSession() string
func GenUkPsPubSession ¶
func GenUkPsPubSession() string
func GenUkRtmp2MpegtsRemuxer ¶
func GenUkRtmp2MpegtsRemuxer() string
func GenUkRtmpPullSession ¶
func GenUkRtmpPullSession() string
func GenUkRtmpPushSession ¶
func GenUkRtmpPushSession() string
func GenUkRtmpServerSession ¶
func GenUkRtmpServerSession() string
func GenUkRtspPubSession ¶
func GenUkRtspPubSession() string
func GenUkRtspPullSession ¶
func GenUkRtspPullSession() string
func GenUkRtspPushSession ¶
func GenUkRtspPushSession() string
func GenUkRtspServerCommandSession ¶
func GenUkRtspServerCommandSession() string
func GenUkRtspSubSession ¶
func GenUkRtspSubSession() string
func GenUkTsSubSession ¶
func GenUkTsSubSession() string
func LogoutStartInfo ¶
func LogoutStartInfo()
func MakeWsFrameHeader ¶
func MockVersion ¶
func MockVersion( lalVersion, confVersion, httpApiVersion, httpNotifyVersion, httpWebUiVersion, lalLibraryName, lalGithubRepo, lalGithubSite, lalDocSite, lalDocSiteHTTPAPI, lalDefaultConfigFilename, lalLogo string)
func NewErrAmfInvalidType ¶
func NewErrRtmpShortBuffer ¶
func OsExitAndWaitPressIfWindows ¶
func OsExitAndWaitPressIfWindows(code int)
func RunSignalHandler ¶
func RunSignalHandler(cb func())
RunSignalHandler 监听SIGUSR1和SIGUSR2信号并回调
TODO(chef): refactor 函数名应与SIGUSR1挂钩
func UpdateWebSocketHeader ¶
func WrapReadConfigFile ¶
Types ¶
type ApiCtrlAddIpBlacklistResp ¶
type ApiCtrlAddIpBlacklistResp struct {
ApiRespBasic
}
type ApiCtrlKickSessionReq ¶
type ApiCtrlKickSessionResp ¶
type ApiCtrlKickSessionResp struct {
ApiRespBasic
}
type ApiCtrlStartRelayPullReq ¶
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 ¶
type ApiCtrlStartRelayPullResp struct { ApiRespBasic Data struct { StreamName string `json:"stream_name"` SessionId string `json:"session_id"` } `json:"data"` }
type ApiCtrlStartRtpPubReq ¶
type ApiCtrlStartRtpPubResp ¶
type ApiCtrlStartRtpPubResp struct { ApiRespBasic Data struct { StreamName string `json:"stream_name"` SessionId string `json:"session_id"` Port int `json:"port"` } `json:"data"` }
type ApiCtrlStopRelayPullResp ¶
type ApiCtrlStopRelayPullResp struct { ApiRespBasic Data struct { SessionId string `json:"session_id"` } `json:"data"` }
type ApiRespBasic ¶
func ApiNotFoundRespFn ¶
func ApiNotFoundRespFn() ApiRespBasic
type ApiStatAllGroupResp ¶
type ApiStatAllGroupResp struct { ApiRespBasic Data struct { Groups []StatGroup `json:"groups"` } `json:"data"` }
type ApiStatGroupResp ¶
type ApiStatGroupResp struct { ApiRespBasic Data *StatGroup `json:"data"` }
type ApiStatLalInfoResp ¶
type ApiStatLalInfoResp struct { ApiRespBasic Data LalInfo `json:"data"` }
type AvPacket ¶
type AvPacket struct { PayloadType AvPacketPt Timestamp int64 // 如无特殊说明,此字段是Dts Pts int64 Payload []byte }
AvPacket
不同场景使用时,字段含义可能不同。 使用 AvPacket 的地方,应注明各字段的含义。
func (*AvPacket) DebugString ¶
type AvPacketPt ¶
type AvPacketPt int
const ( AvPacketPtUnknown AvPacketPt = -1 AvPacketPtG711U AvPacketPt = 0 // g711u AvPacketPtG711A AvPacketPt = 8 // g711a AvPacketPtMp2 AvPacketPt = 14 // mp2 AvPacketPtAvc AvPacketPt = 96 // h264 AvPacketPtHevc AvPacketPt = 98 // h265 AvPacketPtAac AvPacketPt = 97 // aac AvPacketPtOpus AvPacketPt = 101 // opus )
func (AvPacketPt) ReadableString ¶
func (a AvPacketPt) ReadableString() string
type AvPacketStreamAudioFormat ¶
type AvPacketStreamAudioFormat int
type AvPacketStreamOption ¶
type AvPacketStreamOption struct { AudioFormat AvPacketStreamAudioFormat VideoFormat AvPacketStreamVideoFormat // 视频流的格式,注意,不是指编码格式,而是编码格式确定后,流的格式 }
type AvPacketStreamVideoFormat ¶
type AvPacketStreamVideoFormat int
type BasicHttpSubSession ¶
type BasicHttpSubSession struct { BasicHttpSubSessionOption // contains filtered or unexported fields }
func NewBasicHttpSubSession ¶
func NewBasicHttpSubSession(option BasicHttpSubSessionOption) *BasicHttpSubSession
func (*BasicHttpSubSession) AppName ¶
func (session *BasicHttpSubSession) AppName() string
func (*BasicHttpSubSession) Dispose ¶
func (session *BasicHttpSubSession) Dispose() error
func (*BasicHttpSubSession) GetStat ¶
func (session *BasicHttpSubSession) GetStat() StatSession
func (*BasicHttpSubSession) IsAlive ¶
func (session *BasicHttpSubSession) IsAlive() (readAlive, writeAlive bool)
func (*BasicHttpSubSession) RawQuery ¶
func (session *BasicHttpSubSession) RawQuery() string
func (*BasicHttpSubSession) RunLoop ¶
func (session *BasicHttpSubSession) RunLoop() error
func (*BasicHttpSubSession) StreamName ¶
func (session *BasicHttpSubSession) StreamName() string
func (*BasicHttpSubSession) UniqueKey ¶
func (session *BasicHttpSubSession) UniqueKey() string
func (*BasicHttpSubSession) UpdateStat ¶
func (session *BasicHttpSubSession) UpdateStat(intervalSec uint32)
func (*BasicHttpSubSession) Url ¶
func (session *BasicHttpSubSession) Url() string
func (*BasicHttpSubSession) Write ¶
func (session *BasicHttpSubSession) Write(b []byte)
func (*BasicHttpSubSession) WriteHttpResponseHeader ¶
func (session *BasicHttpSubSession) WriteHttpResponseHeader(b []byte)
type BasicHttpSubSessionOption ¶
type BasicHttpSubSessionOption struct { Conn net.Conn ConnModOption connection.ModOption SessionType SessionType UrlCtx UrlContext IsWebSocket bool WebSocketKey string }
type BasicSessionStat ¶
type BasicSessionStat struct {
// contains filtered or unexported fields
}
BasicSessionStat
包含两部分功能: 1. 维护 StatSession 的一些静态信息 2. 计算带宽
计算带宽有两种方式,一种是通过外部的 connection.Connection 获取最新状态,一种是内部自己管理状态
func NewBasicSessionStat ¶
func NewBasicSessionStat(sessionType SessionType, remoteAddr string) BasicSessionStat
NewBasicSessionStat
@param remoteAddr: 如果当前未知,填入""空字符串
func (*BasicSessionStat) AddReadBytes ¶
func (s *BasicSessionStat) AddReadBytes(n int)
func (*BasicSessionStat) AddWriteBytes ¶
func (s *BasicSessionStat) AddWriteBytes(n int)
func (*BasicSessionStat) BaseType ¶
func (s *BasicSessionStat) BaseType() string
func (*BasicSessionStat) GetStat ¶
func (s *BasicSessionStat) GetStat() StatSession
func (*BasicSessionStat) GetStatWithConn ¶
func (s *BasicSessionStat) GetStatWithConn(conn IStatable) StatSession
func (*BasicSessionStat) IsAlive ¶
func (s *BasicSessionStat) IsAlive() (readAlive, writeAlive bool)
func (*BasicSessionStat) IsAliveWitchConn ¶
func (s *BasicSessionStat) IsAliveWitchConn(conn IStatable) (readAlive, writeAlive bool)
func (*BasicSessionStat) SetBaseType ¶
func (s *BasicSessionStat) SetBaseType(baseType string)
func (*BasicSessionStat) SetRemoteAddr ¶
func (s *BasicSessionStat) SetRemoteAddr(addr string)
func (*BasicSessionStat) UniqueKey ¶
func (s *BasicSessionStat) UniqueKey() string
func (*BasicSessionStat) UpdateStat ¶
func (s *BasicSessionStat) UpdateStat(intervalSec uint32)
func (*BasicSessionStat) UpdateStatWitchConn ¶
func (s *BasicSessionStat) UpdateStatWitchConn(conn IStatable, intervalSec uint32)
type DumpFile ¶
type DumpFile struct {
// contains filtered or unexported fields
}
func NewDumpFile ¶
func NewDumpFile() *DumpFile
func (*DumpFile) OpenToRead ¶
func (*DumpFile) OpenToWrite ¶
func (*DumpFile) ReadOneMessage ¶
func (d *DumpFile) ReadOneMessage() (m DumpFileMessage, err error)
func (*DumpFile) WriteAvPacket ¶
type DumpFileMessage ¶
type DumpFileMessage struct { Ver uint32 // 制造数据时的代码版本 Typ uint32 Len uint32 // Body 的长度 Timestamp uint64 // 写入时的时间戳 Reserve uint32 Body []byte }
func (*DumpFileMessage) DebugString ¶
func (m *DumpFileMessage) DebugString() string
type EventCommonInfo ¶
type EventCommonInfo struct {
ServerId string `json:"server_id"`
}
EventCommonInfo 所有事件共有的字段
type HlsMakeTsInfo ¶
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 ¶
type HttpServerManager struct {
// contains filtered or unexported fields
}
func NewHttpServerManager ¶
func NewHttpServerManager() *HttpServerManager
func (*HttpServerManager) AddListen ¶
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 ¶
func (s *HttpServerManager) Dispose() error
func (*HttpServerManager) RunLoop ¶
func (s *HttpServerManager) RunLoop() error
type IAvPacketStream ¶
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 ¶
type IClientSession interface { IClientSessionLifecycle ISession }
type IClientSessionLifecycle ¶
type IClientSessionLifecycle interface { Start(rawUrl string) error // Dispose // // 关闭session,主要是在主动关闭时调用。 // // - 可以在任意协程内调用。 // - 可以调用多次。 // // - 理论上可以在Start之前调用,但请尽量避免。 // - 不能和Start并发调用。 // - Start失败后可以不调用Dispose。 // // Dispose后,调用Write函数将返回错误 // // - TODO 如果Read或Write函数返回错误,可以不调用Dispose。 // // @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 }
IClientSessionLifecycle
常规正确调用流程:
New -> WithXXX -> Start -> Read/Write -> Dispose
Start之前,不调用Read, Write, WaitChan函数 Start, Read, Write返回失败或者WaitChan返回错误时,直接调用Dispose,之后尽量不再使用这个session
type IServerSession ¶
type IServerSession interface { IServerSessionLifecycle ISession }
type IServerSessionLifecycle ¶
type IServerSessionLifecycle interface { // Dispose 主动关闭session时调用 // // 如果是session通知业务方session已关闭(比如`RunLoop`函数返回错误),则不需要调用`Dispose` TODO(chef): review现状 // Dispose() error }
type ISession ¶
type ISession interface { ISessionUrlContext IObject ISessionStat }
type ISessionStat ¶
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 ¶
type ISessionUrlContext interface { Url() string AppName() string StreamName() string RawQuery() string // 参数,也即 url param }
ISessionUrlContext 获取和流地址相关的信息
调用约束:对于Client类型的Session,调用Start函数并返回成功后才能调用,否则行为未定义
type IStatable ¶
type IStatable interface {
GetStat() connection.Stat // TODO(chef): [refactor] 考虑为 nazanet.UdpConnection 实现这个接口
}
type LocalAddrCtx ¶
type LogDump ¶
type LogDump struct {
// contains filtered or unexported fields
}
func (*LogDump) Outf ¶
Outf
调用之前需调用 ShouldDump 将 ShouldDump 独立出来的目的是避免不需要打印日志时, Outf 调用前构造实参的开销,比如 ld.Outf("hex=%s", hex.Dump(buf)) 这个hex.Dump调用
func (*LogDump) ShouldDump ¶
type MergeWriter ¶
type MergeWriter struct {
// contains filtered or unexported fields
}
MergeWriter 合并多个内存块,达到阈值后一次性将内存块数组返回给上层
注意,输入时的单个内存块,回调时不会出现拆分切割的情况
func NewMergeWriter ¶
func NewMergeWriter(onWritev OnWritev, size int) *MergeWriter
NewMergeWriter
@param onWritev 回调缓存的1~n个内存块 @param size 回调阈值
type OnAvPacketFunc ¶
type OnAvPacketFunc func(packet *AvPacket)
type PeriodRecord ¶
type PeriodRecord struct {
// contains filtered or unexported fields
}
func NewPeriodRecord ¶
func NewPeriodRecord(bufSize int) PeriodRecord
func (*PeriodRecord) Add ¶
func (p *PeriodRecord) Add(unixSec int64, v uint32)
type PubStartInfo ¶
type PubStartInfo struct {
SessionEventCommonInfo
}
func Session2PubStartInfo ¶
func Session2PubStartInfo(session ISession) PubStartInfo
type PubStopInfo ¶
type PubStopInfo struct {
SessionEventCommonInfo
}
func Session2PubStopInfo ¶
func Session2PubStopInfo(session ISession) PubStopInfo
type PullStartInfo ¶
type PullStartInfo struct {
SessionEventCommonInfo
}
func Session2PullStartInfo ¶
func Session2PullStartInfo(session ISession) PullStartInfo
type PullStopInfo ¶
type PullStopInfo struct {
SessionEventCommonInfo
}
func Session2PullStopInfo ¶
func Session2PullStopInfo(session ISession) PullStopInfo
type RecordPerSec ¶
type RtmpConnectInfo ¶
type RtmpHeader ¶
type RtmpMsg ¶
type RtmpMsg struct { Header RtmpHeader Payload []byte // Payload不包含Header内容。如果需要将RtmpMsg序列化成RTMP chunk,可调用 rtmp.ChunkDivider 相关的函数 }
func (RtmpMsg) AudioCodecId ¶
func (RtmpMsg) DebugString ¶
func (RtmpMsg) GetEnchanedHevcNaluIndex ¶
func (RtmpMsg) IsAacSeqHeader ¶
func (RtmpMsg) IsAvcKeyNalu ¶
func (RtmpMsg) IsAvcKeySeqHeader ¶
func (RtmpMsg) IsEnchanedHevcNalu ¶
func (RtmpMsg) IsEnhanced ¶
func (RtmpMsg) IsHevcKeyNalu ¶
func (RtmpMsg) IsHevcKeySeqHeader ¶
func (RtmpMsg) IsVideoKeyNalu ¶
func (RtmpMsg) IsVideoKeySeqHeader ¶
func (RtmpMsg) VideoCodecId ¶
type SessionEventCommonInfo ¶
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 ¶
type SessionType int
type StatGroup ¶
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"` // TODO: [opt] 增加字段,最近1秒,5秒,10秒等时间段的fps 202408 // TODO: [opt] 考虑和bitrate等字段语义统一,详细的数据可以是detail样式的字段 202408 Fps []RecordPerSec `json:"in_frame_per_sec"` }
func (*StatGroup) GetFpsFrom ¶
func (s *StatGroup) GetFpsFrom(p *PeriodRecord, nowUnixSec int64)
GetFpsFrom
s.Fps 是输出,p 是输入
type StatSession ¶
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"` // 注意,格式见 ReadableNowTime 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 SubStartInfo ¶
type SubStartInfo struct {
SessionEventCommonInfo
}
func Session2SubStartInfo ¶
func Session2SubStartInfo(session ISession) SubStartInfo
type SubStopInfo ¶
type SubStopInfo struct {
SessionEventCommonInfo
}
func Session2SubStopInfo ¶
func Session2SubStopInfo(session ISession) SubStopInfo
type UpdateInfo ¶
type UpdateInfo struct { EventCommonInfo Groups []StatGroup `json:"groups"` }
type UrlContext ¶
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 ¶
func ParseHttpflvUrl(rawUrl string) (ctx UrlContext, err error)
func ParseRtmpUrl ¶
func ParseRtmpUrl(rawUrl string) (ctx UrlContext, err error)
func ParseRtspUrl ¶
func ParseRtspUrl(rawUrl string) (ctx UrlContext, err error)
func ParseUrl ¶
func ParseUrl(rawUrl string, defaultPort int) (ctx UrlContext, err error)
ParseUrl
@param defaultPort: 注意,如果rawUrl中显示指定了端口,则该参数不生效。 注意,如果设置为-1,内部依然会对常见协议(http, https, rtmp, rtsp)设置官方默认端口。
func (*UrlContext) GetFileType ¶
func (u *UrlContext) GetFileType() string
func (*UrlContext) GetFilenameWithoutType ¶
func (u *UrlContext) GetFilenameWithoutType() string
type UrlPathContext ¶
type WsOpcode ¶
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