Documentation ¶
Overview ¶
The oryx rtmp package support bytes from/to rtmp packets.
Index ¶
- Constants
- type CallPacket
- type ConnectAppPacket
- type ConnectAppResPacket
- type CreateStreamPacket
- type CreateStreamResPacket
- type EventType
- type Handshake
- func (v *Handshake) ReadC0S0(r io.Reader) (c0 []byte, err error)
- func (v *Handshake) ReadC1S1(r io.Reader) (c1 []byte, err error)
- func (v *Handshake) ReadC2S2(r io.Reader) (c2 []byte, err error)
- func (v *Handshake) WriteC0S0(w io.Writer) (err error)
- func (v *Handshake) WriteC1S1(w io.Writer) (err error)
- func (v *Handshake) WriteC2S2(w io.Writer, s1c1 []byte) (err error)
- type LimitType
- type Message
- type MessageType
- type Packet
- type PlayPacket
- type Protocol
- func (v *Protocol) DecodeMessage(m *Message) (pkt Packet, err error)
- func (v *Protocol) ExpectMessage(types ...MessageType) (m *Message, err error)
- func (v *Protocol) ExpectPacket(ppkt interface{}) (m *Message, err error)
- func (v *Protocol) ReadMessage() (m *Message, err error)
- func (v *Protocol) WriteMessage(m *Message) (err error)
- func (v *Protocol) WritePacket(pkt Packet, streamID int) (err error)
- type PublishPacket
- type SetChunkSize
- type SetPeerBandwidth
- type UserControl
- type WindowAcknowledgementSize
- func (v *WindowAcknowledgementSize) BetterCid() chunkID
- func (v *WindowAcknowledgementSize) MarshalBinary() (data []byte, err error)
- func (v *WindowAcknowledgementSize) Size() int
- func (v *WindowAcknowledgementSize) Type() MessageType
- func (v *WindowAcknowledgementSize) UnmarshalBinary(data []byte) (err error)
Constants ¶
const ( // The server sends this event to notify the client // that a stream has become functional and can be // used for communication. By default, this event // is sent on ID 0 after the application connect // command is successfully received from the // client. The event data is 4-byte and represents // The stream ID of the stream that became // Functional. EventTypeStreamBegin = 0x00 // The server sends this event to notify the client // that the playback of data is over as requested // on this stream. No more data is sent without // issuing additional commands. The client discards // The messages received for the stream. The // 4 bytes of event data represent the ID of the // stream on which playback has ended. EventTypeStreamEOF = 0x01 // The server sends this event to notify the client // that there is no more data on the stream. If the // server does not detect any message for a time // period, it can notify the subscribed clients // that the stream is dry. The 4 bytes of event // data represent the stream ID of the dry stream. EventTypeStreamDry = 0x02 // The client sends this event to inform the server // of the buffer size (in milliseconds) that is // used to buffer any data coming over a stream. // This event is sent before the server starts // processing the stream. The first 4 bytes of the // event data represent the stream ID and the next // 4 bytes represent the buffer length, in // milliseconds. EventTypeSetBufferLength = 0x03 // 8bytes event-data // The server sends this event to notify the client // that the stream is a recorded stream. The // 4 bytes event data represent the stream ID of // The recorded stream. EventTypeStreamIsRecorded = 0x04 // The server sends this event to test whether the // client is reachable. Event data is a 4-byte // timestamp, representing the local server time // When the server dispatched the command. The // client responds with kMsgPingResponse on // receiving kMsgPingRequest. EventTypePingRequest = 0x06 // The client sends this event to the server in // Response to the ping request. The event data is // a 4-byte timestamp, which was received with the // kMsgPingRequest request. EventTypePingResponse = 0x07 // For PCUC size=3, for example the payload is "00 1A 01", // it's a FMS control event, where the event type is 0x001a and event data is 0x01, // please notice that the event data is only 1 byte for this event. EventTypeFmsEvent0 = 0x1a )
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) 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) MarshalBinary ¶
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) MarshalBinary ¶
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) MarshalBinary ¶
func (*CreateStreamPacket) Type ¶
func (v *CreateStreamPacket) Type() MessageType
func (*CreateStreamPacket) UnmarshalBinary ¶
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) 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 ¶
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.
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 ¶
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 MessageTypeAbort MessageType = 0x02 // 0x02 MessageTypeAcknowledgement MessageType = 0x03 // 0x03 MessageTypeUserControl MessageType = 0x04 // 0x04 MessageTypeWindowAcknowledgementSize MessageType = 0x05 // 0x05 MessageTypeSetPeerBandwidth MessageType = 0x06 // 0x06 MessageTypeEdgeAndOriginServerCommand MessageType = 0x07 // 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 // 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 MessageType = 0x09 // 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 PlayPacket ¶
Please read @doc rtmp_specification_1.0.pdf, @page 54, @section 4.2.1. play
func NewPlayPacket ¶
func NewPlayPacket() *PlayPacket
func (*PlayPacket) MarshalBinary ¶
func (v *PlayPacket) MarshalBinary() (data []byte, err error)
func (*PlayPacket) Size ¶
func (v *PlayPacket) Size() int
func (*PlayPacket) Type ¶
func (v *PlayPacket) Type() MessageType
func (*PlayPacket) UnmarshalBinary ¶
func (v *PlayPacket) UnmarshalBinary(data []byte) (err error)
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 (*Protocol) ExpectMessage ¶
func (v *Protocol) ExpectMessage(types ...MessageType) (m *Message, err error)
func (*Protocol) ExpectPacket ¶
func (*Protocol) ReadMessage ¶
func (*Protocol) WriteMessage ¶
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) 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 ¶
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 UserControl ¶
type UserControl struct { // Event type is followed by Event data. // @see: SrcPCUCEventType EventType EventType // The event data generally in 4bytes. // @remark for event type is 0x001a, only 1bytes. // @see SrsPCUCFmsEvent0 EventData int32 // 4bytes if event_type is SetBufferLength; otherwise 0. ExtraData int32 }
Please read @doc rtmp_specification_1.0.pdf, @page 32, @5.4. User Control Message (4) The client or the server sends this message to notify the peer about the user control events. This message carries Event type and Event data.
func NewUserControl ¶
func NewUserControl() *UserControl
func (*UserControl) BetterCid ¶
func (v *UserControl) BetterCid() chunkID
func (*UserControl) MarshalBinary ¶
func (v *UserControl) MarshalBinary() (data []byte, err error)
func (*UserControl) Size ¶
func (v *UserControl) Size() int
func (*UserControl) Type ¶
func (v *UserControl) Type() MessageType
func (*UserControl) UnmarshalBinary ¶
func (v *UserControl) 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 (v *WindowAcknowledgementSize) Type() MessageType
func (*WindowAcknowledgementSize) UnmarshalBinary ¶
func (v *WindowAcknowledgementSize) UnmarshalBinary(data []byte) (err error)