rtmp

package module
v0.0.0-...-1d0168b Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2014 License: MIT Imports: 16 Imported by: 0

README

gortmp

Build Status

Client library for connection to RTMP(S) services in Go. Used in production at Elobuff.

License

MIT License, see LICENSE for details.

Documentation

Index

Constants

View Source
const (
	TIMESTAMP_MAX      = uint32(2000000000)
	TIMESTAMP_AUTO     = uint32(0)
	TIMESTAMP_EXTENDED = 0xFFFFFF
)
View Source
const (
	CHUNK_STREAM_ID_PROTOCOL     = uint32(2)
	CHUNK_STREAM_ID_COMMAND      = uint32(3)
	CHUNK_STREAM_ID_USER_CONTROL = uint32(4)
)
View Source
const (
	HEADER_FORMAT_FULL                   = 0x00
	HEADER_FORMAT_SAME_STREAM            = 0x01
	HEADER_FORMAT_SAME_LENGTH_AND_STREAM = 0x02
	HEADER_FORMAT_CONTINUATION           = 0x03
)
View Source
const (
	MESSAGE_TYPE_NONE               = 0x00
	MESSAGE_TYPE_CHUNK_SIZE         = 0x01
	MESSAGE_TYPE_ABORT              = 0x02
	MESSAGE_TYPE_ACK                = 0x03
	MESSAGE_TYPE_PING               = 0x04
	MESSAGE_TYPE_ACK_SIZE           = 0x05
	MESSAGE_TYPE_BANDWIDTH          = 0x06
	MESSAGE_TYPE_AUDIO              = 0x08
	MESSAGE_TYPE_VIDEO              = 0x09
	MESSAGE_TYPE_FLEX               = 0x0F
	MESSAGE_TYPE_AMF3_SHARED_OBJECT = 0x10
	MESSAGE_TYPE_AMF3               = 0x11
	MESSAGE_TYPE_INVOKE             = 0x12
	MESSAGE_TYPE_AMF0_SHARED_OBJECT = 0x13
	MESSAGE_TYPE_AMF0               = 0x14
	MESSAGE_TYPE_FLV                = 0x16
)
View Source
const (
	AMF0 = 0x00
	AMF3 = 0x03
)
View Source
const (
	DEFAULT_CHUNK_SIZE  = uint32(128)
	DEFAULT_WINDOW_SIZE = uint32(2500000)
)
View Source
const (
	MESSAGE_DISPATCH_QUEUE_LENGTH = 100
)

Variables

View Source
var (
	ErrResponseTimeout = errors.New("rtmp: response timeout")
)

Functions

func Dump

func Dump(label string, val interface{}) error

func DumpBytes

func DumpBytes(label string, buf []byte, size int)

func Error

func Error(f string, v ...interface{}) error

func GetCurrentTimestamp

func GetCurrentTimestamp() uint32

Types

type Client

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

func NewClient

func NewClient(url string) (c *Client)

func (*Client) Call

func (c *Client) Call(msg *Message, t uint32) (response *Response, err error)

func (*Client) Connect

func (c *Client) Connect() (err error)

func (*Client) Disconnect

func (c *Client) Disconnect()

func (*Client) EncodeInvoke

func (c *Client) EncodeInvoke(className string, destination interface{}, operation interface{}, body interface{}) (msg *Message, err error)

func (*Client) EncodeInvokeCommand

func (c *Client) EncodeInvokeCommand(destination interface{}, operation interface{}, body interface{}) (msg *Message, err error)

func (*Client) EncodeInvokeRemote

func (c *Client) EncodeInvokeRemote(destination interface{}, operation interface{}, body interface{}) (msg *Message, err error)

func (*Client) GetResponse

func (c *Client) GetResponse(tid uint32) (response *Response, ready bool)

func (*Client) IsAlive

func (c *Client) IsAlive() bool

func (*Client) NextTransactionId

func (c *Client) NextTransactionId() uint32

func (*Client) Read

func (c *Client) Read(p []byte) (n int, err error)

func (*Client) RegisterExternalHandler

func (c *Client) RegisterExternalHandler(name string, fn amf.ExternalHandler)

func (*Client) Reset

func (c *Client) Reset()

func (*Client) SendMessage

func (c *Client) SendMessage(msg *Message)

func (*Client) Write

func (c *Client) Write(p []byte) (n int, err error)

type Command

type Command struct {
	Name          string
	TransactionId float64
	Version       uint8
	Objects       []interface{}
}
type Header struct {
	Format            uint8
	ChunkStreamId     uint32
	MessageLength     uint32
	MessageTypeId     uint8
	MessageStreamId   uint32
	Timestamp         uint32
	ExtendedTimestamp uint32
}

func NewHeader

func NewHeader() *Header

func ReadHeader

func ReadHeader(r io.Reader) (Header, error)

func (*Header) CalculateTimestamp

func (h *Header) CalculateTimestamp() uint32

func (*Header) Write

func (h *Header) Write(w io.Writer) (n int, err error)

type InboundChunkStream

type InboundChunkStream struct {
	Id uint32
	// contains filtered or unexported fields
}

func NewInboundChunkStream

func NewInboundChunkStream(id uint32) *InboundChunkStream

type Message

type Message struct {
	Type              uint8
	ChunkStreamId     uint32
	StreamId          uint32
	Timestamp         uint32
	AbsoluteTimestamp uint32
	TransactionId     uint32
	Length            uint32
	Buffer            *bytes.Buffer
}

func EncodeConnect

func EncodeConnect(c *Client) (msg *Message, err error)

func (*Message) DecodeResponse

func (m *Message) DecodeResponse(c *Client) (response *Response, err error)

func (*Message) RemainingBytes

func (m *Message) RemainingBytes() uint32

type OutboundChunkStream

type OutboundChunkStream struct {
	Id uint32
	// contains filtered or unexported fields
}

func NewOutboundChunkStream

func NewOutboundChunkStream(id uint32) *OutboundChunkStream

func (*OutboundChunkStream) GetTimestamp

func (cs *OutboundChunkStream) GetTimestamp() uint32

func (*OutboundChunkStream) NewOutboundHeader

func (cs *OutboundChunkStream) NewOutboundHeader(m *Message) *Header

type Response

type Response struct {
	Name          string
	TransactionId float64
	Objects       []interface{}
}

Jump to

Keyboard shortcuts

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