rtmp

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

README

Argus RTMP

The Argus RTMP package contains resources used by the Argus Platform for handling RTMP web traffic

Setup

install dependencies:

make deps

Usage

fetch this package:

go get "github.com/Max-Gabriel-Susman/rtmp"

Documentation

Index

Constants

View Source
const AMF0_OBJECT_TERM_CODE = 0x09
View Source
const AMF0_TYPE_ARRAY = 0x08
View Source
const AMF0_TYPE_BOOL = 0x01
View Source
const AMF0_TYPE_DATE = 0x0B
View Source
const AMF0_TYPE_LONG_STRING = 0x0C
View Source
const AMF0_TYPE_NULL = 0x05
View Source
const AMF0_TYPE_NUMBER = 0x00

Types

View Source
const AMF0_TYPE_OBJECT = 0x03
View Source
const AMF0_TYPE_REF = 0x07
View Source
const AMF0_TYPE_STRICT_ARRAY = 0x0A
View Source
const AMF0_TYPE_STRING = 0x02
View Source
const AMF0_TYPE_SWITCH_AMF3 = 0x11
View Source
const AMF0_TYPE_TYPED_OBJ = 0x10
View Source
const AMF0_TYPE_UNDEFINED = 0x06
View Source
const AMF0_TYPE_XML_DOC = 0x0F
View Source
const AMF3_TYPE_ARRAY = 0x09
View Source
const AMF3_TYPE_BYTE_ARRAY = 0x0C
View Source
const AMF3_TYPE_DATE = 0x08
View Source
const AMF3_TYPE_DOUBLE = 0x05
View Source
const AMF3_TYPE_FALSE = 0x02
View Source
const AMF3_TYPE_INTEGER = 0x04
View Source
const AMF3_TYPE_NULL = 0x01
View Source
const AMF3_TYPE_OBJECT = 0x0A
View Source
const AMF3_TYPE_STRING = 0x06
View Source
const AMF3_TYPE_TRUE = 0x03
View Source
const AMF3_TYPE_UNDEFINED = 0x00

Types

View Source
const AMF3_TYPE_XML = 0x0B
View Source
const AMF3_TYPE_XML_DOC = 0x07
View Source
const GenuineFMSConst = "Genuine Adobe Flash Media Server 001"
View Source
const GenuineFPConst = "Genuine Adobe Flash Player 001"
View Source
const JWT_EXPIRATION_TIME_SECONDS = 120
View Source
const MAX_CHUNK_HEADER = 18
View Source
const MESSAGE_FORMAT_0 = 0
View Source
const MESSAGE_FORMAT_1 = 1
View Source
const MESSAGE_FORMAT_2 = 2
View Source
const N_CHUNK_STREAM = 8
View Source
const RTMP_CHANNEL_AUDIO = 4
View Source
const RTMP_CHANNEL_DATA = 6
View Source
const RTMP_CHANNEL_INVOKE = 3
View Source
const RTMP_CHANNEL_PROTOCOL = 2
View Source
const RTMP_CHANNEL_VIDEO = 5
View Source
const RTMP_CHUNK_SIZE = 128
View Source
const RTMP_CHUNK_TYPE_0 = 0 // 11-bytes: timestamp(3) + length(3) + stream type(1) + stream id(4)
View Source
const RTMP_CHUNK_TYPE_1 = 1 // 7-bytes: delta(3) + length(3) + stream type(1)
View Source
const RTMP_CHUNK_TYPE_2 = 2 // 3-bytes: delta(3)
View Source
const RTMP_CHUNK_TYPE_3 = 3 // 0-byte
View Source
const RTMP_HANDSHAKE_0 = 1
View Source
const RTMP_HANDSHAKE_1 = 2
View Source
const RTMP_HANDSHAKE_2 = 3
View Source
const RTMP_HANDSHAKE_SIZE = 1536
View Source
const RTMP_HANDSHAKE_UNINIT = 0
View Source
const RTMP_PACKET_BASE_SIZE = 65
View Source
const RTMP_PARSE_BASIC_HEADER = 1
View Source
const RTMP_PARSE_EXTENDED_TIMESTAMP = 3
View Source
const RTMP_PARSE_INIT = 0
View Source
const RTMP_PARSE_MESSAGE_HEADER = 2
View Source
const RTMP_PARSE_PAYLOAD = 4
View Source
const RTMP_PING_TIME = 30000
View Source
const RTMP_PING_TIMEOUT = 60000
View Source
const RTMP_SIG_SIZE = 1536
View Source
const RTMP_TYPE_ABORT = 2
View Source
const RTMP_TYPE_ACKNOWLEDGEMENT = 3 // bytes read report
View Source
const RTMP_TYPE_AUDIO = 8
View Source
const RTMP_TYPE_DATA = 18 // AMF0
View Source
const RTMP_TYPE_EVENT = 4

User Control Messages Event (4)

View Source
const RTMP_TYPE_FLEX_MESSAGE = 17 // AMF3

Command Message

View Source
const RTMP_TYPE_FLEX_OBJECT = 16 // AMF3

Shared Object Message

View Source
const RTMP_TYPE_FLEX_STREAM = 15 // AMF3

Data Message

View Source
const RTMP_TYPE_INVOKE = 20 // AMF0
View Source
const RTMP_TYPE_METADATA = 22

Aggregate Message

View Source
const RTMP_TYPE_SET_CHUNK_SIZE = 1

Protocol Control Messages

View Source
const RTMP_TYPE_SET_PEER_BANDWIDTH = 6 // client bandwidth
View Source
const RTMP_TYPE_SHARED_OBJECT = 19 // AMF0
View Source
const RTMP_TYPE_VIDEO = 9
View Source
const RTMP_TYPE_WINDOW_ACKNOWLEDGEMENT_SIZE = 5 // server bandwidth
View Source
const RTMP_VERSION = 3
View Source
const SHA256DL = 32
View Source
const STREAM_BEGIN = 0x00
View Source
const STREAM_DRY = 0x02
View Source
const STREAM_EMPTY = 0x1f
View Source
const STREAM_EOF = 0x01
View Source
const STREAM_READY = 0x20

Variables

View Source
var GenuineFMSConstCrud = append([]byte(GenuineFMSConst), RandomCrud...)
View Source
var GenuineFPConstCrud = append([]byte(GenuineFPConst), RandomCrud...)
View Source
var ID_MAX_LENGTH = 128
View Source
var LOG_DEBUG_ENABLED = (os.Getenv("LOG_DEBUG") == "YES")
View Source
var LOG_MUTEX = sync.Mutex{}
View Source
var LOG_REQUESTS_ENABLED = (os.Getenv("LOG_REQUESTS") != "NO")
View Source
var RandomCrud = []byte{
	0xf0, 0xee, 0xc2, 0x4a, 0x80, 0x68, 0xbe, 0xe8,
	0x2e, 0x00, 0xd0, 0xd1, 0x02, 0x9e, 0x7e, 0x57,
	0x6e, 0xec, 0x5d, 0x2d, 0x29, 0x80, 0x6f, 0xab,
	0x93, 0xb8, 0xe6, 0x36, 0xcf, 0xeb, 0x31, 0xae,
}

Functions

func GetClientGenuineConstDigestOffset

func GetClientGenuineConstDigestOffset(buf []byte) uint32

func GetServerGenuineConstDigestOffset

func GetServerGenuineConstDigestOffset(buf []byte) uint32

func LogDebug

func LogDebug(line string)

func LogDebugSession

func LogDebugSession(session_id uint64, ip string, line string)

func LogError

func LogError(err error)

func LogInfo

func LogInfo(line string)

func LogLine

func LogLine(line string)

func LogRequest

func LogRequest(session_id uint64, ip string, line string)

func LogWarning

func LogWarning(line string)

Types

type AMF0Value

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

func (*AMF0Value) GetArray

func (v *AMF0Value) GetArray() []*AMF0Value

func (*AMF0Value) GetBool

func (v *AMF0Value) GetBool() bool

func (*AMF0Value) GetByteArray

func (v *AMF0Value) GetByteArray() []byte

func (*AMF0Value) GetDouble

func (v *AMF0Value) GetDouble() float64

func (*AMF0Value) GetInteger

func (v *AMF0Value) GetInteger() int64

func (*AMF0Value) GetObject

func (v *AMF0Value) GetObject() map[string]*AMF0Value

func (*AMF0Value) GetProperty

func (v *AMF0Value) GetProperty(propName string) *AMF0Value

func (*AMF0Value) GetString

func (v *AMF0Value) GetString() string

func (*AMF0Value) IsAMF3

func (v *AMF0Value) IsAMF3() bool

func (*AMF0Value) IsNull

func (v *AMF0Value) IsNull() bool

func (*AMF0Value) IsUndefined

func (v *AMF0Value) IsUndefined() bool

func (*AMF0Value) SetFloatVal

func (v *AMF0Value) SetFloatVal(val float64)

func (*AMF0Value) SetIntegerVal

func (v *AMF0Value) SetIntegerVal(val int64)

func (*AMF0Value) ToString

func (v *AMF0Value) ToString(tabs string) string

type AMF3Value

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

func (*AMF3Value) GetBool

func (v *AMF3Value) GetBool() bool

type AMFDecodingStream

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

func (*AMFDecodingStream) IsEnded

func (s *AMFDecodingStream) IsEnded() bool

func (*AMFDecodingStream) Look

func (s *AMFDecodingStream) Look(n int) []byte

func (*AMFDecodingStream) Read

func (s *AMFDecodingStream) Read(n int) []byte

func (*AMFDecodingStream) ReadAMF3

func (s *AMFDecodingStream) ReadAMF3() AMF3Value

func (*AMFDecodingStream) ReadAMF3ByteArray

func (s *AMFDecodingStream) ReadAMF3ByteArray() []byte

func (*AMFDecodingStream) ReadAMF3String

func (s *AMFDecodingStream) ReadAMF3String() string

func (*AMFDecodingStream) ReadArray

func (s *AMFDecodingStream) ReadArray() map[string]*AMF0Value

func (*AMFDecodingStream) ReadBool

func (s *AMFDecodingStream) ReadBool() bool

func (*AMFDecodingStream) ReadLongString

func (s *AMFDecodingStream) ReadLongString() string

func (*AMFDecodingStream) ReadNumber

func (s *AMFDecodingStream) ReadNumber() float64

func (*AMFDecodingStream) ReadObject

func (s *AMFDecodingStream) ReadObject() map[string]*AMF0Value

func (*AMFDecodingStream) ReadOne

func (s *AMFDecodingStream) ReadOne() AMF0Value

func (*AMFDecodingStream) ReadStrictArray

func (s *AMFDecodingStream) ReadStrictArray() []*AMF0Value

func (*AMFDecodingStream) ReadString

func (s *AMFDecodingStream) ReadString() string

func (*AMFDecodingStream) ReadTypedObject

func (s *AMFDecodingStream) ReadTypedObject() (string, map[string]*AMF0Value)

func (*AMFDecodingStream) Skip

func (s *AMFDecodingStream) Skip(n int)

type BitrateCache

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

type RTMPChannel

type RTMPChannel struct {
	StreamID string
	// contains filtered or unexported fields
}

type RTMPCommand

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

func (*RTMPCommand) Encode

func (c *RTMPCommand) Encode() []byte

func (*RTMPCommand) GetArg

func (c *RTMPCommand) GetArg(argName string) *AMF0Value

func (*RTMPCommand) ToString

func (c *RTMPCommand) ToString() string

type RTMPData

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

func (*RTMPData) Encode

func (c *RTMPData) Encode() []byte

func (*RTMPData) GetArg

func (c *RTMPData) GetArg(argName string) *AMF0Value

func (*RTMPData) ToString

func (c *RTMPData) ToString() string

type RTMPPacket

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

func (*RTMPPacket) CreateChunks

func (packet *RTMPPacket) CreateChunks(outChunkSize int) []byte

type RTMPPacketHeader

type RTMPPacketHeader struct {
	StreamID uint32
	// contains filtered or unexported fields
}

type RTMPSession

type RTMPSession struct {
	StreamID string
	// contains filtered or unexported fields
}

func NewRTMPSession

func NewRTMPSession(server *Server, id uint64, ip string, c net.Conn) RTMPSession

func (*RTMPSession) BuildMetadata

func (s *RTMPSession) BuildMetadata(data *RTMPData) []byte

func (*RTMPSession) CanPlay

func (s *RTMPSession) CanPlay() bool

func (*RTMPSession) DeleteStream

func (s *RTMPSession) DeleteStream(streamId uint32)

func (*RTMPSession) EndPublish

func (s *RTMPSession) EndPublish(isClose bool)

func (*RTMPSession) GetStreamPath

func (s *RTMPSession) GetStreamPath() string

func (*RTMPSession) HandleAudioPacket

func (s *RTMPSession) HandleAudioPacket(packet *RTMPPacket) bool

func (*RTMPSession) HandleCloseStream

func (s *RTMPSession) HandleCloseStream(cmd *RTMPCommand, packet *RTMPPacket) bool

func (*RTMPSession) HandleConnect

func (s *RTMPSession) HandleConnect(cmd *RTMPCommand) bool

func (*RTMPSession) HandleCreateStream

func (s *RTMPSession) HandleCreateStream(cmd *RTMPCommand) bool

func (*RTMPSession) HandleDataPacketAMF0

func (s *RTMPSession) HandleDataPacketAMF0(packet *RTMPPacket) bool

func (*RTMPSession) HandleDataPacketAMF3

func (s *RTMPSession) HandleDataPacketAMF3(packet *RTMPPacket) bool

func (*RTMPSession) HandleDeleteStream

func (s *RTMPSession) HandleDeleteStream(cmd *RTMPCommand) bool

func (*RTMPSession) HandleInvoke

func (s *RTMPSession) HandleInvoke(packet *RTMPPacket) bool

func (*RTMPSession) HandlePacket

func (s *RTMPSession) HandlePacket(packet *RTMPPacket) bool

func (*RTMPSession) HandlePause

func (s *RTMPSession) HandlePause(cmd *RTMPCommand) bool

func (*RTMPSession) HandlePlay

func (s *RTMPSession) HandlePlay(cmd *RTMPCommand, packet *RTMPPacket) bool

func (*RTMPSession) HandlePublish

func (s *RTMPSession) HandlePublish(cmd *RTMPCommand, packet *RTMPPacket) bool

func (*RTMPSession) HandleRTMPData

func (s *RTMPSession) HandleRTMPData(packet *RTMPPacket, data *RTMPData) bool

func (*RTMPSession) HandleSession

func (s *RTMPSession) HandleSession()

func (*RTMPSession) HandleVideoPacket

func (s *RTMPSession) HandleVideoPacket(packet *RTMPPacket) bool

func (*RTMPSession) Kill

func (s *RTMPSession) Kill()

func (*RTMPSession) OnClose

func (s *RTMPSession) OnClose()

func (*RTMPSession) ReadChunk

func (s *RTMPSession) ReadChunk(r *bufio.Reader) bool

func (*RTMPSession) RespondConnect

func (s *RTMPSession) RespondConnect(tid int64, hasObjectEncoding bool)

func (*RTMPSession) RespondCreateStream

func (s *RTMPSession) RespondCreateStream(tid int64)

func (*RTMPSession) RespondPlay

func (s *RTMPSession) RespondPlay()

func (*RTMPSession) ResumePlayer

func (s *RTMPSession) ResumePlayer(player *RTMPSession)

func (*RTMPSession) SendACK

func (s *RTMPSession) SendACK(size uint32) bool

func (*RTMPSession) SendAudioCodecHeader

func (s *RTMPSession) SendAudioCodecHeader(audioCodec uint32, aacSequenceHeader []byte, timestamp int64)

func (*RTMPSession) SendCachePacket

func (s *RTMPSession) SendCachePacket(cache *RTMPPacket)

func (*RTMPSession) SendDataMessage

func (s *RTMPSession) SendDataMessage(StreamID uint32, data RTMPData)

func (*RTMPSession) SendInvokeMessage

func (s *RTMPSession) SendInvokeMessage(StreamID uint32, cmd RTMPCommand)

func (*RTMPSession) SendMetadata

func (s *RTMPSession) SendMetadata(metaData []byte, timestamp int64)

func (*RTMPSession) SendPingRequest

func (s *RTMPSession) SendPingRequest()

func (*RTMPSession) SendSampleAccess

func (s *RTMPSession) SendSampleAccess(StreamID uint32)

func (*RTMPSession) SendStartCallback

func (s *RTMPSession) SendStartCallback() bool

func (*RTMPSession) SendStatusMessage

func (s *RTMPSession) SendStatusMessage(StreamID uint32, level string, code string, description string)

func (*RTMPSession) SendStopCallback

func (s *RTMPSession) SendStopCallback() bool

func (*RTMPSession) SendStreamStatus

func (s *RTMPSession) SendStreamStatus(st uint16, id uint32) bool

func (*RTMPSession) SendSync

func (s *RTMPSession) SendSync(b []byte)

func (*RTMPSession) SendVideoCodecHeader

func (s *RTMPSession) SendVideoCodecHeader(videoCodec uint32, avcSequenceHeader []byte, timestamp int64)

func (*RTMPSession) SendWindowACK

func (s *RTMPSession) SendWindowACK(size uint32) bool

func (*RTMPSession) SetChunkSize

func (s *RTMPSession) SetChunkSize(size uint32) bool

func (*RTMPSession) SetClock

func (s *RTMPSession) SetClock(clock int64)

func (*RTMPSession) SetMetaData

func (s *RTMPSession) SetMetaData(metaData []byte)

func (*RTMPSession) SetPeerBandwidth

func (s *RTMPSession) SetPeerBandwidth(size uint32, t byte) bool

func (*RTMPSession) StartIdlePlayers

func (s *RTMPSession) StartIdlePlayers()

func (*RTMPSession) StartPlayer

func (s *RTMPSession) StartPlayer(player *RTMPSession)

type Server added in v0.0.1

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

func NewServer

func NewServer() *Server

func (*Server) AcceptConnections added in v0.0.1

func (server *Server) AcceptConnections(listener net.Listener, wg *sync.WaitGroup)

func (*Server) AddIP added in v0.0.1

func (server *Server) AddIP(ip string) bool

func (*Server) AddPlayer added in v0.0.1

func (server *Server) AddPlayer(channel string, key string, s *RTMPSession) (bool, error)

func (*Server) AddSession added in v0.0.1

func (server *Server) AddSession(s *RTMPSession)

func (*Server) GetIdlePlayers added in v0.0.1

func (server *Server) GetIdlePlayers(channel string) []*RTMPSession

func (*Server) GetPlayers added in v0.0.1

func (server *Server) GetPlayers(channel string) []*RTMPSession

func (*Server) GetPublisher added in v0.0.1

func (server *Server) GetPublisher(channel string) *RTMPSession

func (*Server) HandleConnection added in v0.0.1

func (server *Server) HandleConnection(id uint64, ip string, c net.Conn)

func (*Server) NextSessionID added in v0.0.1

func (server *Server) NextSessionID() uint64

func (*Server) RemoveIP added in v0.0.1

func (server *Server) RemoveIP(ip string)

func (*Server) RemovePlayer added in v0.0.1

func (server *Server) RemovePlayer(channel string, key string, s *RTMPSession)

func (*Server) RemovePublisher added in v0.0.1

func (server *Server) RemovePublisher(channel string)

func (*Server) RemoveSession added in v0.0.1

func (server *Server) RemoveSession(id uint64)

func (*Server) SendPings added in v0.0.1

func (server *Server) SendPings(wg *sync.WaitGroup)

func (*Server) SetPublisher added in v0.0.1

func (server *Server) SetPublisher(channel string, key string, StreamID string, s *RTMPSession) bool

func (*Server) Start added in v0.0.1

func (server *Server) Start()

type TlsCertificateLoader added in v0.0.3

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

func NewTlsCertificateLoader added in v0.0.3

func NewTlsCertificateLoader(config TlsCertificateLoaderConfig) (*TlsCertificateLoader, error)

func (*TlsCertificateLoader) Close added in v0.0.3

func (loader *TlsCertificateLoader) Close()

Closes the loader, stopping its co-routine

func (*TlsCertificateLoader) GetCertificate added in v0.0.3

func (loader *TlsCertificateLoader) GetCertificate(_ *tls.ClientHelloInfo) (*tls.Certificate, error)

Obtains the current loaded TLS key pair The client info parameter is ignored This function will never return an error

func (*TlsCertificateLoader) IsClosed added in v0.0.3

func (loader *TlsCertificateLoader) IsClosed() bool

Checks if the loader is closed A closed loader is not checking for changes anymore

type TlsCertificateLoaderConfig added in v0.0.3

type TlsCertificateLoaderConfig struct {
	CertificatePath   string
	KeyPath           string
	CheckReloadPeriod time.Duration
	OnReload          func()
	OnError           func(err error)
}

Jump to

Keyboard shortcuts

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