rtmp

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

The oryx rtmp package support bytes from/to rtmp packets.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CallPacket

type CallPacket struct {
	Args amf0.Amf0 // optional or object or null
	// contains filtered or unexported fields
}

Please read @doc rtmp_specification_1.0.pdf, @page 51, @section 4.1.2. Call The call method of the NetConnection object runs remote procedure calls (RPC) at the receiving end. The called RPC name is passed as a parameter to the call command. @remark onStatus packet is a call packet.

func NewCallPacket

func NewCallPacket() *CallPacket

func NewCloseStreamPacket

func NewCloseStreamPacket() *CallPacket

func (*CallPacket) BetterCid

func (v *CallPacket) BetterCid() chunkID

func (*CallPacket) MarshalBinary

func (v *CallPacket) MarshalBinary() (data []byte, err error)

func (*CallPacket) Size

func (v *CallPacket) Size() int

func (*CallPacket) Type

func (v *CallPacket) Type() MessageType

func (*CallPacket) UnmarshalBinary

func (v *CallPacket) UnmarshalBinary(data []byte) (err error)

type ConnectAppPacket

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

Please read @doc rtmp_specification_1.0.pdf, @page 45, @section 4.1.1. connect The client sends the connect command to the server to request connection to a server application instance.

func NewConnectAppPacket

func NewConnectAppPacket() *ConnectAppPacket

func (*ConnectAppPacket) BetterCid

func (v *ConnectAppPacket) BetterCid() chunkID

func (*ConnectAppPacket) MarshalBinary

func (v *ConnectAppPacket) MarshalBinary() (data []byte, err error)

func (*ConnectAppPacket) Size

func (v *ConnectAppPacket) Size() int

func (*ConnectAppPacket) Type

func (v *ConnectAppPacket) Type() MessageType

func (*ConnectAppPacket) UnmarshalBinary

func (v *ConnectAppPacket) UnmarshalBinary(data []byte) (err error)

type ConnectAppResPacket

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

The response for ConnectAppPacket.

func NewConnectAppResPacket

func NewConnectAppResPacket(tid amf0.Number) *ConnectAppResPacket

func (*ConnectAppResPacket) BetterCid

func (v *ConnectAppResPacket) BetterCid() chunkID

func (*ConnectAppResPacket) MarshalBinary

func (v *ConnectAppResPacket) MarshalBinary() (data []byte, err error)

func (*ConnectAppResPacket) Size

func (v *ConnectAppResPacket) Size() int

func (*ConnectAppResPacket) Type

func (v *ConnectAppResPacket) Type() MessageType

func (*ConnectAppResPacket) UnmarshalBinary

func (v *ConnectAppResPacket) UnmarshalBinary(data []byte) (err error)

type CreateStreamPacket

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

Please read @doc rtmp_specification_1.0.pdf, @page 52, @section 4.1.3. createStream The client sends this command to the server to create a logical channel for message communication The publishing of audio, video, and metadata is carried out over stream channel created using the createStream command.

func NewCreateStreamPacket

func NewCreateStreamPacket() *CreateStreamPacket

func (*CreateStreamPacket) BetterCid

func (v *CreateStreamPacket) BetterCid() chunkID

func (*CreateStreamPacket) MarshalBinary

func (v *CreateStreamPacket) MarshalBinary() (data []byte, err error)

func (*CreateStreamPacket) Size

func (v *CreateStreamPacket) Size() int

func (*CreateStreamPacket) Type

func (v *CreateStreamPacket) Type() MessageType

func (*CreateStreamPacket) UnmarshalBinary

func (v *CreateStreamPacket) UnmarshalBinary(data []byte) (err error)

type CreateStreamResPacket

type CreateStreamResPacket struct {
	StreamID amf0.Number
	// contains filtered or unexported fields
}

The response for create stream

func NewCreateStreamResPacket

func NewCreateStreamResPacket(tid amf0.Number) *CreateStreamResPacket

func (*CreateStreamResPacket) BetterCid

func (v *CreateStreamResPacket) BetterCid() chunkID

func (*CreateStreamResPacket) MarshalBinary

func (v *CreateStreamResPacket) MarshalBinary() (data []byte, err error)

func (*CreateStreamResPacket) Size

func (v *CreateStreamResPacket) Size() int

func (*CreateStreamResPacket) Type

func (v *CreateStreamResPacket) Type() MessageType

func (*CreateStreamResPacket) UnmarshalBinary

func (v *CreateStreamResPacket) UnmarshalBinary(data []byte) (err error)

type Handshake

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

The handshake implements the RTMP handshake protocol.

func NewHandshake

func NewHandshake(r *rand.Rand) *Handshake

func (*Handshake) ReadC0S0

func (v *Handshake) ReadC0S0(r io.Reader) (c0 []byte, err error)

func (*Handshake) ReadC1S1

func (v *Handshake) ReadC1S1(r io.Reader) (c1 []byte, err error)

func (*Handshake) ReadC2S2

func (v *Handshake) ReadC2S2(r io.Reader) (c2 []byte, err error)

func (*Handshake) WriteC0S0

func (v *Handshake) WriteC0S0(w io.Writer) (err error)

func (*Handshake) WriteC1S1

func (v *Handshake) WriteC1S1(w io.Writer) (err error)

func (*Handshake) WriteC2S2

func (v *Handshake) WriteC2S2(w io.Writer, s1c1 []byte) (err error)

type LimitType

type LimitType uint8

Please read @doc rtmp_specification_1.0.pdf, @page 33, @section 5.6. Set Peer Bandwidth (6) The sender can mark this message hard (0), soft (1), or dynamic (2) using the Limit type field.

const (
	LimitTypeHard LimitType = iota
	LimitTypeSoft
	LimitTypeDynamic
)

type Message

type Message struct {

	// The payload which carries the RTMP packet.
	Payload []byte
	// contains filtered or unexported fields
}

The RTMP message, transport over chunk stream in RTMP. Please read the cs id of @doc rtmp_specification_1.0.pdf, @page 30, @section 4.1. Message Header

func NewMessage

func NewMessage() *Message

func NewStreamMessage

func NewStreamMessage(streamID int) *Message

type MessageType

type MessageType uint8

Please read @doc rtmp_specification_1.0.pdf, @page 30, @section 4.1. Message Header 1byte. One byte field to represent the message type. A range of type IDs (1-7) are reserved for protocol control messages.

const (
	// Please read @doc rtmp_specification_1.0.pdf, @page 30, @section 5. Protocol Control Messages
	// RTMP reserves message type IDs 1-7 for protocol control messages.
	// These messages contain information needed by the RTM Chunk Stream
	// protocol or RTMP itself. Protocol messages with IDs 1 & 2 are
	// reserved for usage with RTM Chunk Stream protocol. Protocol messages
	// with IDs 3-6 are reserved for usage of RTMP. Protocol message with ID
	// 7 is used between edge server and origin server.
	MessageTypeSetChunkSize               MessageType = 0x01 + iota
	MessageTypeAbort                                  // 0x02
	MessageTypeAcknowledgement                        // 0x03
	MessageTypeUserControl                            // 0x04
	MessageTypeWindowAcknowledgementSize              // 0x05
	MessageTypeSetPeerBandwidth                       // 0x06
	MessageTypeEdgeAndOriginServerCommand             // 0x07
	// Please read @doc rtmp_specification_1.0.pdf, @page 38, @section 3. Types of messages
	// The server and the client send messages over the network to
	// communicate with each other. The messages can be of any type which
	// includes audio messages, video messages, command messages, shared
	// object messages, data messages, and user control messages.
	//
	// Please read @doc rtmp_specification_1.0.pdf, @page 41, @section 3.4. Audio message
	// The client or the server sends this message to send audio data to the
	// peer. The message type value of 8 is reserved for audio messages.
	MessageTypeAudio MessageType = 0x08 + iota
	// Please read @doc rtmp_specification_1.0.pdf, @page 41, @section 3.5. Video message
	// The client or the server sends this message to send video data to the
	// peer. The message type value of 9 is reserved for video messages.
	// These messages are large and can delay the sending of other type of
	// messages. To avoid such a situation, the video message is assigned
	// the lowest priority.
	MessageTypeVideo // 0x09
	// Please read @doc rtmp_specification_1.0.pdf, @page 38, @section 3.1. Command message
	// Command messages carry the AMF-encoded commands between the client
	// and the server. These messages have been assigned message type value
	// of 20 for AMF0 encoding and message type value of 17 for AMF3
	// encoding. These messages are sent to perform some operations like
	// connect, createStream, publish, play, pause on the peer. Command
	// messages like onstatus, result etc. are used to inform the sender
	// about the status of the requested commands. A command message
	// consists of command name, transaction ID, and command object that
	// contains related parameters. A client or a server can request Remote
	// Procedure Calls (RPC) over streams that are communicated using the
	// command messages to the peer.
	MessageTypeAMF3Command MessageType = 17 // 0x11
	MessageTypeAMF0Command MessageType = 20 // 0x14
	// Please read @doc rtmp_specification_1.0.pdf, @page 38, @section 3.2. Data message
	// The client or the server sends this message to send Metadata or any
	// user data to the peer. Metadata includes details about the
	// data(audio, video etc.) like creation time, duration, theme and so
	// on. These messages have been assigned message type value of 18 for
	// AMF0 and message type value of 15 for AMF3.
	MessageTypeAMF0Data MessageType = 18 // 0x12
	MessageTypeAMF3Data MessageType = 15 // 0x0f
)

type Packet

type Packet interface {
	// Marshaler and unmarshaler
	Size() int
	encoding.BinaryUnmarshaler
	encoding.BinaryMarshaler

	// RTMP protocol fields for each packet.
	BetterCid() chunkID
	Type() MessageType
}

The RTMP packet, transport as payload of RTMP message.

type Protocol

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

The protocol implements the RTMP command and chunk stack.

func NewProtocol

func NewProtocol(rw io.ReadWriter) *Protocol

func (*Protocol) DecodeMessage

func (v *Protocol) DecodeMessage(m *Message) (pkt Packet, err error)

func (*Protocol) ExpectMessage

func (v *Protocol) ExpectMessage(types ...MessageType) (m *Message, err error)

func (*Protocol) ExpectPacket

func (v *Protocol) ExpectPacket(ppkt interface{}) (m *Message, err error)

func (*Protocol) ReadMessage

func (v *Protocol) ReadMessage() (m *Message, err error)

func (*Protocol) WriteMessage

func (v *Protocol) WriteMessage(m *Message) (err error)

func (*Protocol) WritePacket

func (v *Protocol) WritePacket(pkt Packet, streamID int) (err error)

type PublishPacket

type PublishPacket struct {
	StreamName amf0.String
	StreamType amf0.String
	// contains filtered or unexported fields
}

Please read @doc rtmp_specification_1.0.pdf, @page 64, @section 4.2.6. Publish

func NewPublishPacket

func NewPublishPacket() *PublishPacket

func (*PublishPacket) BetterCid

func (v *PublishPacket) BetterCid() chunkID

func (*PublishPacket) MarshalBinary

func (v *PublishPacket) MarshalBinary() (data []byte, err error)

func (*PublishPacket) Size

func (v *PublishPacket) Size() int

func (*PublishPacket) Type

func (v *PublishPacket) Type() MessageType

func (*PublishPacket) UnmarshalBinary

func (v *PublishPacket) UnmarshalBinary(data []byte) (err error)

type SetChunkSize

type SetChunkSize struct {
	ChunkSize uint32
}

Please read @doc rtmp_specification_1.0.pdf, @page 31, @section 5.1. Set Chunk Size Protocol control message 1, Set Chunk Size, is used to notify the peer about the new maximum chunk size.

func NewSetChunkSize

func NewSetChunkSize() *SetChunkSize

func (*SetChunkSize) BetterCid

func (v *SetChunkSize) BetterCid() chunkID

func (*SetChunkSize) MarshalBinary

func (v *SetChunkSize) MarshalBinary() (data []byte, err error)

func (*SetChunkSize) Size

func (v *SetChunkSize) Size() int

func (*SetChunkSize) Type

func (v *SetChunkSize) Type() MessageType

func (*SetChunkSize) UnmarshalBinary

func (v *SetChunkSize) UnmarshalBinary(data []byte) (err error)

type SetPeerBandwidth

type SetPeerBandwidth struct {
	Bandwidth uint32
	LimitType LimitType
}

Please read @doc rtmp_specification_1.0.pdf, @page 33, @section 5.6. Set Peer Bandwidth (6) The client or the server sends this message to update the output bandwidth of the peer.

func NewSetPeerBandwidth

func NewSetPeerBandwidth() *SetPeerBandwidth

func (*SetPeerBandwidth) BetterCid

func (v *SetPeerBandwidth) BetterCid() chunkID

func (*SetPeerBandwidth) MarshalBinary

func (v *SetPeerBandwidth) MarshalBinary() (data []byte, err error)

func (*SetPeerBandwidth) Size

func (v *SetPeerBandwidth) Size() int

func (*SetPeerBandwidth) Type

func (v *SetPeerBandwidth) Type() MessageType

func (*SetPeerBandwidth) UnmarshalBinary

func (v *SetPeerBandwidth) UnmarshalBinary(data []byte) (err error)

type WindowAcknowledgementSize

type WindowAcknowledgementSize struct {
	AckSize uint32
}

Please read @doc rtmp_specification_1.0.pdf, @page 33, @section 5.5. Window Acknowledgement Size (5) The client or the server sends this message to inform the peer which window size to use when sending acknowledgment.

func NewWindowAcknowledgementSize

func NewWindowAcknowledgementSize() *WindowAcknowledgementSize

func (*WindowAcknowledgementSize) BetterCid

func (v *WindowAcknowledgementSize) BetterCid() chunkID

func (*WindowAcknowledgementSize) MarshalBinary

func (v *WindowAcknowledgementSize) MarshalBinary() (data []byte, err error)

func (*WindowAcknowledgementSize) Size

func (v *WindowAcknowledgementSize) Size() int

func (*WindowAcknowledgementSize) Type

func (*WindowAcknowledgementSize) UnmarshalBinary

func (v *WindowAcknowledgementSize) UnmarshalBinary(data []byte) (err error)

Jump to

Keyboard shortcuts

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