rtmp

package
v0.0.0-...-b4d0808 Latest Latest
Warning

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

Go to latest
Published: May 9, 2020 License: BSD-2-Clause Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RTMP_protocol_rtmp      = "rtmp"
	RTMP_Default_chunk_size = 128
	RTMP_Default_buff_ms    = 500
	RTMP_better_chunk_size  = 128

	RTMP_channel_control      = 0x02
	RTMP_channel_Invoke       = 0x03
	RTMP_channel_SendLive     = 0x04
	RTMP_channel_SendPlayback = 0x05
	RTMP_channel_AV           = 0x08
)

RTMP Protocol Setting

View Source
const (
	RTMP_PACKET_TYPE_CHUNK_SIZE         = 0x01
	RTMP_PACKET_TYPE_ABORT              = 0x02
	RTMP_PACKET_TYPE_BYTES_READ_REPORT  = 0x03
	RTMP_PACKET_TYPE_CONTROL            = 0x04
	RTMP_PACKET_TYPE_SERVER_BW          = 0x05
	RTMP_PACKET_TYPE_CLIENT_BW          = 0x06
	RTMP_PACKET_TYPE_AUDIO              = 0x08
	RTMP_PACKET_TYPE_VIDEO              = 0x09
	RTMP_PACKET_TYPE_FLEX_STREAM_SEND   = 0x0f //amf3
	RTMP_PACKET_TYPE_FLEX_SHARED_OBJECT = 0x10
	RTMP_PACKET_TYPE_FLEX_MESSAGE       = 0x11
	RTMP_PACKET_TYPE_INFO               = 0x12 //amf0
	RTMP_PACKET_TYPE_SHARED_OBJECT      = 0x13
	RTMP_PACKET_TYPE_INVOKE             = 0x14
	RTMP_PACKET_TYPE_FLASH_VIDEO        = 0x16
)
View Source
const (
	RTMP_CTRL_streamBegin       = 0
	RTMP_CTRL_streamEof         = 1
	RTMP_CTRL_streamDry         = 2
	RTMP_CTRL_setBufferLength   = 3
	RTMP_CTRL_streamIsRecorded  = 4
	RTMP_CTRL_pingRequest       = 6
	RTMP_CTRL_pingResponse      = 7
	RTMP_CTRL_streamBufferEmpty = 31
	RTMP_CTRL_streamBufferReady = 32
)
View Source
const (
	RTMP_HEADER_TYPE_0 = 0
	RTMP_HEADER_TYPE_1 = 1
	RTMP_HEADER_TYPE_2 = 2
	RTMP_HEADER_TYPE_3 = 3
)

RTMP HEADER TYPE

View Source
const (
	TAMF0Number        = 0x00
	TAMF0Boolean       = 0x01
	TAMF0String        = 0x02
	TAMF0Object        = 0x03 //hash table=amfstring:key ,amftype:value,0x 00 00 09 end
	TAMF0MovieClip     = 0x04
	TAMF0Null          = 0x05
	TAMF0Undefined     = 0x06
	TAMF0Reference     = 0x07
	TAMF0EcmaArray     = 0x08 //object with size of hashTable
	TAMF0Object_end    = 0x09
	TAMF0StrictArray   = 0x0a //arrycount+propArray
	TAMF0Date          = 0x0b
	TAMF0LongString    = 0x0c
	TAMF0Unsupported   = 0x0d
	TAMF0RecordSet     = 0x0e
	TAMF0xmlDocument   = 0x0f
	TAMF0TypedObject   = 0x10
	TAMF0AvmplusObject = 0x11
)

Variables

View Source
var GENUINE_FMS_KEY = []byte{
	0x47, 0x65, 0x6e, 0x75, 0x69, 0x6e, 0x65, 0x20,
	0x41, 0x64, 0x6f, 0x62, 0x65, 0x20, 0x46, 0x6c,
	0x61, 0x73, 0x68, 0x20, 0x4d, 0x65, 0x64, 0x69,
	0x61, 0x20, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72,
	0x20, 0x30, 0x30, 0x31,
	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,
}
View Source
var GENUINE_FP_KEY = []byte{
	0x47, 0x65, 0x6E, 0x75, 0x69, 0x6E, 0x65, 0x20,
	0x41, 0x64, 0x6F, 0x62, 0x65, 0x20, 0x46, 0x6C,
	0x61, 0x73, 0x68, 0x20, 0x50, 0x6C, 0x61, 0x79,
	0x65, 0x72, 0x20, 0x30, 0x30, 0x31,
	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 AMF0DecodeBoolean

func AMF0DecodeBoolean(data []byte) (ret bool, err error)

func AMF0DecodeInt16

func AMF0DecodeInt16(data []byte) (ret uint16, err error)

解码

func AMF0DecodeInt24

func AMF0DecodeInt24(data []byte) (ret uint32, err error)

func AMF0DecodeInt32

func AMF0DecodeInt32(data []byte) (ret uint32, err error)

func AMF0DecodeInt32LE

func AMF0DecodeInt32LE(data []byte) (ret uint32, err error)

func AMF0DecodeNumber

func AMF0DecodeNumber(data []byte) (ret float64, err error)

func AMF0DecodeString

func AMF0DecodeString(data []byte) (ret string, err error)

func AMFDecodeLongString

func AMFDecodeLongString(data []byte) (ret string, err error)

func PullRTMPLive

func PullRTMPLive(task *eRTMPEvent.EvePullRTMPStream)

PullRTMPLive From Server

Types

type AMF0Data

type AMF0Data struct {
	StrValue  string
	NumValue  float64
	S16Value  int16
	BoolValue bool
	ObjValue  AMF0Object
}

type AMF0Encoder

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

func (*AMF0Encoder) AppendByte

func (amf0Encoder *AMF0Encoder) AppendByte(data byte) (err error)

func (*AMF0Encoder) AppendByteArray

func (amf0Encoder *AMF0Encoder) AppendByteArray(data []byte) (err error)

func (*AMF0Encoder) EncodeAMFObj

func (amf0Encoder *AMF0Encoder) EncodeAMFObj(obj *AMF0Object)

func (*AMF0Encoder) EncodeBool

func (amf0Encoder *AMF0Encoder) EncodeBool(boo bool) (err error)

func (*AMF0Encoder) EncodeInt16

func (amf0Encoder *AMF0Encoder) EncodeInt16(num int16) (err error)

func (*AMF0Encoder) EncodeInt24

func (amf0Encoder *AMF0Encoder) EncodeInt24(num int32) (err error)

func (*AMF0Encoder) EncodeInt32

func (amf0Encoder *AMF0Encoder) EncodeInt32(num int32) (err error)

func (*AMF0Encoder) EncodeInt32LittleEndian

func (amf0Encoder *AMF0Encoder) EncodeInt32LittleEndian(num int32) (err error)

func (*AMF0Encoder) EncodeNamedBool

func (amf0Encoder *AMF0Encoder) EncodeNamedBool(name string, boolean bool) (err error)

func (*AMF0Encoder) EncodeNamedNumber

func (amf0Encoder *AMF0Encoder) EncodeNamedNumber(name string, num float64) (err error)

func (*AMF0Encoder) EncodeNamedString

func (amf0Encoder *AMF0Encoder) EncodeNamedString(name string, str string) (err error)

func (*AMF0Encoder) EncodeNumber

func (amf0Encoder *AMF0Encoder) EncodeNumber(num float64) (err error)

func (*AMF0Encoder) EncodeString

func (amf0Encoder *AMF0Encoder) EncodeString(str string) (err error)

func (*AMF0Encoder) GetData

func (amf0Encoder *AMF0Encoder) GetData() (data []byte, err error)

func (*AMF0Encoder) GetDataSize

func (amf0Encoder *AMF0Encoder) GetDataSize() int

func (*AMF0Encoder) Init

func (amf0Encoder *AMF0Encoder) Init()

type AMF0Object

type AMF0Object struct {
	Props list.List
}

func AMF0DecodeObj

func AMF0DecodeObj(data []byte) (ret *AMF0Object, err error)

func (*AMF0Object) AMF0GetPropByIndex

func (amf0Encoder *AMF0Object) AMF0GetPropByIndex(index int) (prop *AMF0Property)

func (*AMF0Object) AMF0GetPropByName

func (amf0Encoder *AMF0Object) AMF0GetPropByName(name string) (prop *AMF0Property)

func (*AMF0Object) Dump

func (amf0Encoder *AMF0Object) Dump()

type AMF0Property

type AMF0Property struct {
	PropType int32
	Name     string
	Value    AMF0Data
}

type RTMP

type RTMP struct {
	Conn                      net.Conn
	SendChunkSize             uint32
	RecvChunkSize             uint32
	NumInvokes                int32
	StreamID                  uint32
	Link                      RTMPLink
	AudioCodecs               int32
	VideoCodecs               int32
	TargetBW                  uint32
	AcknowledgementWindowSize uint32
	SelfBW                    uint32
	LimitType                 uint32
	BytesIn                   int64
	BytesInLast               int64
	// contains filtered or unexported fields
}

RTMP Description

func (*RTMP) AcknowledgementBW

func (rtmp *RTMP) AcknowledgementBW() (err error)

func (*RTMP) CmdError

func (rtmp *RTMP) CmdError(level string, code string, description string, idx float64) (err error)

func (*RTMP) CmdNumberResult

func (rtmp *RTMP) CmdNumberResult(idx float64, numValue float64) (err error)

func (*RTMP) CmdStatus

func (rtmp *RTMP) CmdStatus(level, code, description, details string, clientID float64, channel int) (err error)

func (*RTMP) Connect

func (rtmp *RTMP) Connect(publish bool) (err error)

func (*RTMP) ConnectResult

func (rtmp *RTMP) ConnectResult(obj *AMF0Object) (err error)

func (*RTMP) CreateStream

func (rtmp *RTMP) CreateStream() (err error)

func (*RTMP) FCUnpublish

func (rtmp *RTMP) FCUnpublish() (err error)

func (*RTMP) HandleControl

func (rtmp *RTMP) HandleControl(pkt *RTMPPacket) (err error)

func (*RTMP) Init

func (rtmp *RTMP) Init(conn net.Conn)

func (*RTMP) OnBWCheck

func (rtmp *RTMP) OnBWCheck() (err error)

func (*RTMP) OnBWDone

func (rtmp *RTMP) OnBWDone() (err error)

func (*RTMP) OnMetadata

func (rtmp *RTMP) OnMetadata(data []byte)

func (*RTMP) ReadChunk

func (rtmp *RTMP) ReadChunk() (packet *RTMPPacket, err error)

func (*RTMP) ReadPacket

func (rtmp *RTMP) ReadPacket() (packet *RTMPPacket, err error)

func (*RTMP) SendCheckBW

func (rtmp *RTMP) SendCheckBW() (err error)

func (*RTMP) SendCheckBWResult

func (rtmp *RTMP) SendCheckBWResult(transactionID float64) (err error)

func (*RTMP) SendCtrl

func (rtmp *RTMP) SendCtrl(ctype int, obj uint32, time uint32) (err error)

func (*RTMP) SendFCPublish

func (rtmp *RTMP) SendFCPublish() (err error)

func (*RTMP) SendPacket

func (rtmp *RTMP) SendPacket(packet *RTMPPacket, queue bool) (err error)

func (*RTMP) SendPlay

func (rtmp *RTMP) SendPlay() (err error)

func (*RTMP) SendReleaseStream

func (rtmp *RTMP) SendReleaseStream() (err error)

func (*RTMP) SetChunkSize

func (rtmp *RTMP) SetChunkSize(chunkSize uint32) (err error)

func (*RTMP) SetPeerBW

func (rtmp *RTMP) SetPeerBW() (err error)

type RTMPConfig

type RTMPConfig struct {
	Port       int    `json:"Port"`
	TimeoutSec int    `json:"TimeoutSec"`
	LivePath   string `json:"LivePath"`
	CacheCount int    `json:"CacheCount"`
}

type RTMPHandler

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

func (*RTMPHandler) GetType

func (rtmpHandler *RTMPHandler) GetType() string

func (*RTMPHandler) HandleRTMPPacket

func (rtmpHandler *RTMPHandler) HandleRTMPPacket(packet *RTMPPacket) (err error)

func (*RTMPHandler) HandleTask

func (rtmpHandler *RTMPHandler) HandleTask(task wssapi.Task) (err error)

func (*RTMPHandler) Init

func (rtmpHandler *RTMPHandler) Init(msg *wssapi.Msg) (err error)

func (*RTMPHandler) ProcessMessage

func (rtmpHandler *RTMPHandler) ProcessMessage(msg *wssapi.Msg) (err error)

func (*RTMPHandler) SetParent

func (rtmpHandler *RTMPHandler) SetParent(parent wssapi.MsgHandler)

func (*RTMPHandler) Start

func (rtmpHandler *RTMPHandler) Start(msg *wssapi.Msg) (err error)

func (*RTMPHandler) Stop

func (rtmpHandler *RTMPHandler) Stop(msg *wssapi.Msg) (err error)
type RTMPLink struct {
	Protocol    string
	App         string
	Flashver    string
	SwfUrl      string
	TcUrl       string
	Fpad        string
	AudioCodecs string
	VideoCodecs string
	Path        string
	Address     string
	SeekTime    int
	StopTime    int
}

RTMPLink struct

type RTMPPacket

type RTMPPacket struct {
	ChunkStreamID   int32
	Fmt             byte
	TimeStamp       uint32 //fmt 0为绝对时间,1或2为相对时间
	MessageLength   uint32
	MessageTypeID   byte
	MessageStreamID uint32
	Body            []byte
	BodyReaded      int32
}

RTMPPacket struct

func FlvTagToRTMPPacket

func FlvTagToRTMPPacket(ta *flv.FlvTag) (dst *RTMPPacket)

func (*RTMPPacket) Copy

func (rtmp *RTMPPacket) Copy() (dst *RTMPPacket)

func (*RTMPPacket) ToFLVTag

func (rtmp *RTMPPacket) ToFLVTag() (dst *flv.FlvTag)

type RTMPPlayInfo

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

type RTMPPuller

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

RTMPPuller struct

func (*RTMPPuller) CreatePlaySRC

func (rtmppuller *RTMPPuller) CreatePlaySRC()

CreatePlaySRC for stream

func (*RTMPPuller) GetType

func (rtmppuller *RTMPPuller) GetType() string

func (*RTMPPuller) HandleControl

func (rtmppuller *RTMPPuller) HandleControl(pkt *RTMPPacket) (err error)

func (*RTMPPuller) HandleTask

func (rtmppuller *RTMPPuller) HandleTask(task wssapi.Task) (err error)

func (*RTMPPuller) Init

func (rtmppuller *RTMPPuller) Init(msg *wssapi.Msg) (err error)

Init Action

func (*RTMPPuller) ProcessMessage

func (rtmppuller *RTMPPuller) ProcessMessage(msg *wssapi.Msg) (err error)

func (*RTMPPuller) SetParent

func (rtmppuller *RTMPPuller) SetParent(parent wssapi.MsgHandler)

func (*RTMPPuller) Start

func (rtmppuller *RTMPPuller) Start(msg *wssapi.Msg) (err error)

Start Action

func (*RTMPPuller) Stop

func (rtmppuller *RTMPPuller) Stop(msg *wssapi.Msg) (err error)

Stop Action

type RTMPService

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

func (*RTMPService) GetType

func (rtmpService *RTMPService) GetType() string

func (*RTMPService) HandleTask

func (rtmpService *RTMPService) HandleTask(task wssapi.Task) (err error)

func (*RTMPService) Init

func (rtmpService *RTMPService) Init(msg *wssapi.Msg) (err error)

func (*RTMPService) ProcessMessage

func (rtmpService *RTMPService) ProcessMessage(msg *wssapi.Msg) (err error)

func (*RTMPService) SetParent

func (rtmpService *RTMPService) SetParent(parent wssapi.MsgHandler)

func (*RTMPService) Start

func (rtmpService *RTMPService) Start(msg *wssapi.Msg) (err error)

func (*RTMPService) Stop

func (rtmpService *RTMPService) Stop(msg *wssapi.Msg) (err error)

Jump to

Keyboard shortcuts

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