rtmp

package
v0.0.0-...-4b7d0c7 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2013 License: GPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VERSION     = "1.0.1"
	SERVER_NAME = "babylon"
)
View Source
const (
	/* RTMP message types */
	RTMP_MSG_CHUNK_SIZE = 1
	RTMP_MSG_ABORT      = 2
	RTMP_MSG_ACK        = 3
	RTMP_MSG_USER       = 4
	RTMP_MSG_ACK_SIZE   = 5
	RTMP_MSG_BANDWIDTH  = 6
	RTMP_MSG_EDGE       = 7

	RTMP_MSG_AUDIO = 8
	RTMP_MSG_VIDEO = 9

	RTMP_MSG_AMF3_META   = 15
	RTMP_MSG_AMF3_SHARED = 16
	RTMP_MSG_AMF3_CMD    = 17

	RTMP_MSG_AMF_META   = 18
	RTMP_MSG_AMF_SHARED = 19
	RTMP_MSG_AMF_CMD    = 20
	RTMP_MSG_AGGREGATE  = 21
	RTMP_MSG_MAX        = 22

	RTMP_CONNECT        = RTMP_MSG_MAX + 1
	RTMP_DISCONNECT     = RTMP_MSG_MAX + 2
	RTMP_HANDSHAKE_DONE = RTMP_MSG_MAX + 3
	RTMP_MAX_EVENT      = RTMP_MSG_MAX + 4

	/* RMTP control message types */
	RTMP_USER_STREAM_BEGIN = 0
	RTMP_USER_STREAM_EOF   = 1
	RTMP_USER_STREAM_DRY   = 2
	RTMP_USER_SET_BUFLEN   = 3
	RTMP_USER_RECORDED     = 4
	RTMP_USER_PING         = 6
	RTMP_USER_PONG         = 7
	RTMP_USER_UNKNOWN      = 8
	RTMP_USER_BUFFER_END   = 31

	/* Chunk header:
	 *   max 3  basic header
	 * + max 11 message header
	 * + max 4  extended header (timestamp) */
	RTMP_MAX_CHUNK_HEADER = 18

	RTMP_DEFAULT_CHUNK_SIZE = 128
	RTMP_MAX_CHUNK_SIZE     = 64 << 10

	RTMP_CHUNK_HEAD_12   = 0 << 6
	RTMP_CHUNK_HEAD_8    = 1 << 6
	RTMP_CHUNK_HEAD_4    = 2 << 6
	RTMP_CHUNK_HEAD_1    = 3 << 6
	RTMP_CHANNEL_CONTROL = 0x02
	RTMP_CHANNEL_COMMAND = 0x03
	RTMP_CHANNEL_AUDIO   = 0x06
	RTMP_CHANNEL_DATA    = 0x05
	RTMP_CHANNEL_VIDEO   = 0x05
)
View Source
const (
	AMF_NUMBER      = 0x00
	AMF_BOOLEAN     = 0x01
	AMF_STRING      = 0x02
	AMF_OBJECT      = 0x03
	AMF_NULL        = 0x05
	AMF_ARRAY_NULL  = 0x06
	AMF_MIXED_ARRAY = 0x08
	AMF_END         = 0x09
	AMF_ARRAY       = 0x0a

	AMF_INT8     = 0x0100
	AMF_INT16    = 0x0101
	AMF_INT32    = 0x0102
	AMF_VARIANT_ = 0x0103
)
View Source
const (
	SHA256_DIGEST_LENGTH = 32
	HANDSHAKE_SIZE       = 1536
)
View Source
const (
	MODE_PRODUCER = 1
	MODE_CONSUMER = 2
	MODE_PROXY    = 3

	Level_Status                      = "status"
	Level_Error                       = "error"
	Level_Warning                     = "warning"
	NetStatus_OnStatus                = "onStatus"
	NetStatus_Result                  = "_result"
	NetStatus_Error                   = "_error"
	NetConnection_Call_BadVersion     = "NetConnection.Call.BadVersion"     //	"error"	以不能识别的格式编码的数据包。
	NetConnection_Call_Failed         = "NetConnection.Call.Failed"         //	"error"	NetConnection.call 方法无法调用服务器端的方法或命令。
	NetConnection_Call_Prohibited     = "NetConnection.Call.Prohibited"     //	"error"	Action Message Format (AMF) 操作因安全原因而被阻止。 或者是 AMF URL 与 SWF 不在同一个域,或者是 AMF 服务器没有信任 SWF 文件的域的策略文件。
	NetConnection_Connect_AppShutdown = "NetConnection.Connect.AppShutdown" //	"error"	正在关闭指定的应用程序。
	NetConnection_Connect_InvalidApp  = "NetConnection.Connect.InvalidApp"  //	"error"	连接时指定的应用程序名无效。
	NetConnection_Connect_Success     = "NetConnection.Connect.Success"     //"status"	连接尝试成功。
	NetConnection_Connect_Closed      = "NetConnection.Connect.Closed"      //"status"	成功关闭连接。
	NetConnection_Connect_Failed      = "NetConnection.Connect.Failed"      //"error"	连接尝试失败。
	NetConnection_Connect_Rejected    = "NetConnection.Connect.Rejected"

	NetStream_Play_Reset          = "NetStream.Play.Reset"
	NetStream_Play_Start          = "NetStream.Play.Start"
	NetStream_Play_StreamNotFound = "NetStream.Play.StreamNotFound"
	NetStream_Play_Stop           = "NetStream.Play.Stop"
	NetStream_Play_Failed         = "NetStream.Play.Failed"

	NetStream_Play_Switch   = "NetStream.Play.Switch"
	NetStream_Play_Complete = "NetStream.Play.Switch"

	NetStream_Data_Start = "NetStream.Data.Start"

	NetStream_Publish_Start     = "NetStream.Publish.Start"     //"status"	已经成功发布。
	NetStream_Publish_BadName   = "NetStream.Publish.BadName"   //"error"	试图发布已经被他人发布的流。
	NetStream_Publish_Idle      = "NetStream.Publish.Idle"      //"status"	流发布者空闲而没有在传输数据。
	NetStream_Unpublish_Success = "NetStream.Unpublish.Success" //"status"	已成功执行取消发布操作。

	NetStream_Buffer_Empty   = "NetStream.Buffer.Empty"
	NetStream_Buffer_Full    = "NetStream.Buffer.Full"
	NetStream_Buffe_Flush    = "NetStream.Buffer.Flush"
	NetStream_Pause_Notify   = "NetStream.Pause.Notify"
	NetStream_Unpause_Notify = "NetStream.Unpause.Notify"

	NetStream_Record_Start    = "NetStream.Record.Start"    //	"status"	录制已开始。
	NetStream_Record_NoAccess = "NetStream.Record.NoAccess" //	"error"	试图录制仍处于播放状态的流或客户端没有访问权限的流。
	NetStream_Record_Stop     = "NetStream.Record.Stop"     //	"status"	录制已停止。
	NetStream_Record_Failed   = "NetStream.Record.Failed"   //	"error"	尝试录制流失败。

	NetStream_Seek_Failed      = "NetStream.Seek.Failed"      //	"error"	搜索失败,如果流处于不可搜索状态,则会发生搜索失败。
	NetStream_Seek_InvalidTime = "NetStream.Seek.InvalidTime" //"error"	对于使用渐进式下载方式下载的视频,用户已尝试跳过到目前为止已下载的视频数据的结尾或在整个文件已下载后跳过视频的结尾进行搜寻或播放。 message.details 属性包含一个时间代码,该代码指出用户可以搜寻的最后一个有效位置。
	NetStream_Seek_Notify      = "NetStream.Seek.Notify"      //	"status"	搜寻操作完成。

)

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,
	}
	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,
	}
)
View Source
var (
	ChunkError = errors.New("error chunk size")
)

Functions

func HMACsha256

func HMACsha256(msgBytes []byte, key []byte) ([]byte, error)

func HandleClientRTMP

func HandleClientRTMP(h ClientHandler)

func ListenAndServe

func ListenAndServe(addr string) error

func ReadBuf

func ReadBuf(r io.Reader, n int) (b []byte)

Types

type AMF

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

func (*AMF) Bytes

func (amf *AMF) Bytes() []byte

type AbortMessage

type AbortMessage struct {
	ControlMessage
	ChunkId uint32 //4byte
}

func (*AbortMessage) Body

func (p *AbortMessage) Body() Payload

func (*AbortMessage) Encode

func (p *AbortMessage) Encode()

func (*AbortMessage) Header

func (p *AbortMessage) Header() *RtmpHeader

func (*AbortMessage) String

func (p *AbortMessage) String() string

type AckMessage

type AckMessage struct {
	ControlMessage
	SequenceNumber uint32 //4byte
}

func (*AckMessage) Body

func (p *AckMessage) Body() Payload

func (*AckMessage) Encode

func (p *AckMessage) Encode()

func (*AckMessage) Header

func (p *AckMessage) Header() *RtmpHeader

func (*AckMessage) String

func (p *AckMessage) String() string

type AckWinSizeMessage

type AckWinSizeMessage struct {
	ControlMessage
	AckWinsize uint32 //4byte
}

func (*AckWinSizeMessage) Body

func (p *AckWinSizeMessage) Body() Payload

func (*AckWinSizeMessage) Encode

func (p *AckWinSizeMessage) Encode()

func (*AckWinSizeMessage) Header

func (p *AckWinSizeMessage) Header() *RtmpHeader

func (*AckWinSizeMessage) String

func (p *AckWinSizeMessage) String() string

type AggregateMessage

type AggregateMessage struct {
	RtmpHeader *RtmpHeader
	Payload    Payload
}

func (*AggregateMessage) Body

func (p *AggregateMessage) Body() Payload

func (*AggregateMessage) Header

func (p *AggregateMessage) Header() *RtmpHeader

func (*AggregateMessage) String

func (m *AggregateMessage) String() string

type Application

type Application interface {
}

type Args

type Args interface{}

type AudioChannel

type AudioChannel chan *StreamPacket

type AudioMessage

type AudioMessage struct {
	RtmpHeader *RtmpHeader
	Payload    Payload
}

func (*AudioMessage) Body

func (p *AudioMessage) Body() Payload

func (*AudioMessage) Header

func (p *AudioMessage) Header() *RtmpHeader

func (*AudioMessage) String

func (m *AudioMessage) String() string

type Broadcast

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

type BufferEndMessage

type BufferEndMessage struct {
	UserControlMessage
}

func (*BufferEndMessage) Body

func (p *BufferEndMessage) Body() Payload

func (*BufferEndMessage) Encode

func (p *BufferEndMessage) Encode()

func (*BufferEndMessage) Header

func (p *BufferEndMessage) Header() *RtmpHeader

func (*BufferEndMessage) String

func (p *BufferEndMessage) String() string

type CallMessage

type CallMessage struct {
	CommandMessage
	Object   interface{} `json:",omitempty"`
	Optional interface{} `json:",omitempty"`
}

func (*CallMessage) Body

func (p *CallMessage) Body() Payload

func (*CallMessage) Encode0

func (p *CallMessage) Encode0()

func (*CallMessage) Encode3

func (p *CallMessage) Encode3()

func (*CallMessage) Header

func (p *CallMessage) Header() *RtmpHeader

func (*CallMessage) String

func (m *CallMessage) String() string

type Channel

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

type ChunkSizeMessage

type ChunkSizeMessage struct {
	ControlMessage
	ChunkSize uint32 //4byte
}

func (*ChunkSizeMessage) Body

func (p *ChunkSizeMessage) Body() Payload

func (*ChunkSizeMessage) Encode

func (p *ChunkSizeMessage) Encode()

func (*ChunkSizeMessage) Header

func (p *ChunkSizeMessage) Header() *RtmpHeader

func (*ChunkSizeMessage) String

func (p *ChunkSizeMessage) String() string

type ClientHandler

type ClientHandler interface {
	OnPublishStart(s *RtmpNetStream) error
	OnPlayStart(s *RtmpNetStream) error
	OnClosed(s *RtmpNetStream)
	OnError(s *RtmpNetStream, err error)
}

type CloseStreamMessage

type CloseStreamMessage struct {
	CommandMessage
	Object   interface{}
	StreamId uint32
}

func (*CloseStreamMessage) Body

func (p *CloseStreamMessage) Body() Payload

func (*CloseStreamMessage) Encode0

func (p *CloseStreamMessage) Encode0()

func (*CloseStreamMessage) Header

func (p *CloseStreamMessage) Header() *RtmpHeader

func (*CloseStreamMessage) String

func (m *CloseStreamMessage) String() string

type CommandMessage

type CommandMessage struct {
	RtmpHeader    *RtmpHeader
	Payload       Payload `json:"-"`
	Command       string
	TransactionId uint64
}

func (*CommandMessage) Body

func (p *CommandMessage) Body() Payload

func (*CommandMessage) Header

func (p *CommandMessage) Header() *RtmpHeader

func (*CommandMessage) String

func (m *CommandMessage) String() string

type ConnectMessage

type ConnectMessage struct {
	CommandMessage
	Object   interface{} `json:",omitempty"`
	Optional interface{} `json:",omitempty"`
}

func (*ConnectMessage) Body

func (p *ConnectMessage) Body() Payload

func (*ConnectMessage) Encode0

func (p *ConnectMessage) Encode0()

func (*ConnectMessage) Encode3

func (p *ConnectMessage) Encode3()

func (*ConnectMessage) Header

func (p *ConnectMessage) Header() *RtmpHeader

func (*ConnectMessage) String

func (m *ConnectMessage) String() string

type ControlMessage

type ControlMessage struct {
	RtmpHeader *RtmpHeader
	Payload    Payload
}

func (*ControlMessage) Body

func (p *ControlMessage) Body() Payload

func (*ControlMessage) Header

func (p *ControlMessage) Header() *RtmpHeader

func (*ControlMessage) String

func (p *ControlMessage) String() string

type CreateStreamMessage

type CreateStreamMessage struct {
	CommandMessage
	Object interface{}
}

func (*CreateStreamMessage) Body

func (p *CreateStreamMessage) Body() Payload

func (*CreateStreamMessage) Encode0

func (p *CreateStreamMessage) Encode0()

func (*CreateStreamMessage) Header

func (p *CreateStreamMessage) Header() *RtmpHeader

func (*CreateStreamMessage) String

func (m *CreateStreamMessage) String() string

type DefaultClientHandler

type DefaultClientHandler struct {
}

func (*DefaultClientHandler) OnClosed

func (this *DefaultClientHandler) OnClosed(s *RtmpNetStream)

func (*DefaultClientHandler) OnError

func (this *DefaultClientHandler) OnError(s *RtmpNetStream, err error)

func (*DefaultClientHandler) OnPlayStart

func (this *DefaultClientHandler) OnPlayStart(s *RtmpNetStream) error

func (*DefaultClientHandler) OnPublishStart

func (this *DefaultClientHandler) OnPublishStart(s *RtmpNetStream) error

type DefaultServerHandler

type DefaultServerHandler struct {
}

func (*DefaultServerHandler) OnClosed

func (p *DefaultServerHandler) OnClosed(s *RtmpNetStream)

func (*DefaultServerHandler) OnError

func (p *DefaultServerHandler) OnError(s *RtmpNetStream, err error)

func (*DefaultServerHandler) OnPlaying

func (p *DefaultServerHandler) OnPlaying(s *RtmpNetStream) error

func (*DefaultServerHandler) OnPublishing

func (p *DefaultServerHandler) OnPublishing(s *RtmpNetStream) error

type DeleteStreamMessage

type DeleteStreamMessage struct {
	CommandMessage
	Object   interface{}
	StreamId uint32
}

func (*DeleteStreamMessage) Body

func (p *DeleteStreamMessage) Body() Payload

func (*DeleteStreamMessage) Encode0

func (p *DeleteStreamMessage) Encode0()

func (*DeleteStreamMessage) Header

func (p *DeleteStreamMessage) Header() *RtmpHeader

func (*DeleteStreamMessage) String

func (m *DeleteStreamMessage) String() string

type EdegMessage

type EdegMessage struct {
	ControlMessage
}

func (*EdegMessage) Body

func (p *EdegMessage) Body() Payload

func (*EdegMessage) Header

func (p *EdegMessage) Header() *RtmpHeader

func (*EdegMessage) String

func (p *EdegMessage) String() string

type Filter

type Filter interface {
}

type Infomation

type Infomation map[string]interface{}

type Map

type Map map[string]Object

type MetadataMessage

type MetadataMessage struct {
	RtmpHeader *RtmpHeader
	Payload    Payload
	Proterties map[string]interface{} `json:",omitempty"`
}

func (*MetadataMessage) Body

func (p *MetadataMessage) Body() Payload

func (*MetadataMessage) Encode0

func (p *MetadataMessage) Encode0()

func (*MetadataMessage) Header

func (p *MetadataMessage) Header() *RtmpHeader

func (*MetadataMessage) String

func (m *MetadataMessage) String() string

type NetConnection

type NetConnection interface {
	Connect(command string, args ...Args) error
	Call(command string, args ...Args) error
	Connected() bool
	Close()
	URL() string
}

type NetStream

type NetStream interface {
	AttachVideo(channel VideoChannel)
	AttachAudio(channel AudioChannel)
	Publish(streamName string, streamType string) error
	Play(streamName string, args ...Args) error //streamName string, start uint64,length uint64,reset bool
	Pause()
	Resume()
	TogglePause()
	Seek(offset uint64)
	Send(handlerName string, args ...Args)
	Close()
	ReceiveAudio(flag bool)
	ReceiveVideo(flag bool)
	NetConnection() NetConnection
	BufferTime() time.Duration
	BytesLoaded() uint64
	BufferLength() uint64
}

type Object

type Object interface{}

type PauseMessage

type PauseMessage struct {
	CommandMessage
	Object       interface{}
	Pause        bool
	Milliseconds uint64
}

func (*PauseMessage) Body

func (p *PauseMessage) Body() Payload

func (*PauseMessage) Encode0

func (p *PauseMessage) Encode0()

func (*PauseMessage) Header

func (p *PauseMessage) Header() *RtmpHeader

func (*PauseMessage) String

func (m *PauseMessage) String() string

type Payload

type Payload []byte

type PingMessage

type PingMessage struct {
	UserControlMessage
	Timestamp uint32
}

func (*PingMessage) Body

func (p *PingMessage) Body() Payload

func (*PingMessage) Encode

func (p *PingMessage) Encode()

func (*PingMessage) Header

func (p *PingMessage) Header() *RtmpHeader

func (*PingMessage) String

func (p *PingMessage) String() string

type Play2Message

type Play2Message struct {
	CommandMessage
	StartTime     uint64
	OldStreamName string
	StreamName    string
	Duration      uint64
	Transition    string
}

func (*Play2Message) Body

func (p *Play2Message) Body() Payload

func (*Play2Message) Encode0

func (p *Play2Message) Encode0()

func (*Play2Message) Header

func (p *Play2Message) Header() *RtmpHeader

func (*Play2Message) String

func (m *Play2Message) String() string

type PlayMessage

type PlayMessage struct {
	CommandMessage
	Object     interface{} `json:",omitempty"`
	StreamName string
	Start      uint64
	Duration   uint64
	Rest       bool
}

func (*PlayMessage) Body

func (p *PlayMessage) Body() Payload

func (*PlayMessage) Encode0

func (p *PlayMessage) Encode0()

func (*PlayMessage) Header

func (p *PlayMessage) Header() *RtmpHeader

func (*PlayMessage) String

func (m *PlayMessage) String() string

type PongMessage

type PongMessage struct {
	UserControlMessage
}

func (*PongMessage) Body

func (p *PongMessage) Body() Payload

func (*PongMessage) Encode

func (p *PongMessage) Encode()

func (*PongMessage) Header

func (p *PongMessage) Header() *RtmpHeader

func (*PongMessage) String

func (p *PongMessage) String() string

type PublishMessage

type PublishMessage struct {
	CommandMessage
	Object      interface{} `json:",omitempty"`
	PublishName string
	PublishType string
}

func (*PublishMessage) Body

func (p *PublishMessage) Body() Payload

func (*PublishMessage) Encode0

func (p *PublishMessage) Encode0()

func (*PublishMessage) Header

func (p *PublishMessage) Header() *RtmpHeader

func (*PublishMessage) String

func (m *PublishMessage) String() string

type ReceiveAudioMessage

type ReceiveAudioMessage struct {
	CommandMessage
	Object   interface{}
	BoolFlag bool
}

func (*ReceiveAudioMessage) Body

func (p *ReceiveAudioMessage) Body() Payload

func (*ReceiveAudioMessage) Encode0

func (p *ReceiveAudioMessage) Encode0()

func (*ReceiveAudioMessage) Header

func (p *ReceiveAudioMessage) Header() *RtmpHeader

func (*ReceiveAudioMessage) String

func (m *ReceiveAudioMessage) String() string

type ReceiveVideoMessage

type ReceiveVideoMessage struct {
	CommandMessage
	Object   interface{} `json:",omitempty"`
	BoolFlag bool
}

func (*ReceiveVideoMessage) Body

func (p *ReceiveVideoMessage) Body() Payload

func (*ReceiveVideoMessage) Encode0

func (p *ReceiveVideoMessage) Encode0()

func (*ReceiveVideoMessage) Header

func (p *ReceiveVideoMessage) Header() *RtmpHeader

func (*ReceiveVideoMessage) String

func (m *ReceiveVideoMessage) String() string

type RecordedMessage

type RecordedMessage struct {
	UserControlMessage
	StreamId uint32
}

func (*RecordedMessage) Body

func (p *RecordedMessage) Body() Payload

func (*RecordedMessage) Encode

func (p *RecordedMessage) Encode()

func (*RecordedMessage) Header

func (p *RecordedMessage) Header() *RtmpHeader

func (*RecordedMessage) String

func (p *RecordedMessage) String() string

type ReleaseStreamMessage

type ReleaseStreamMessage struct {
	CommandMessage
	Object   interface{}
	StreamId uint32
}

func (*ReleaseStreamMessage) Body

func (p *ReleaseStreamMessage) Body() Payload

func (*ReleaseStreamMessage) Encode0

func (p *ReleaseStreamMessage) Encode0()

func (*ReleaseStreamMessage) Header

func (p *ReleaseStreamMessage) Header() *RtmpHeader

func (*ReleaseStreamMessage) String

func (m *ReleaseStreamMessage) String() string

type ReplyCallMessage

type ReplyCallMessage struct {
	CommandMessage
	Object   interface{}
	Response interface{}
}

func (*ReplyCallMessage) Body

func (p *ReplyCallMessage) Body() Payload

func (*ReplyCallMessage) Encode0

func (p *ReplyCallMessage) Encode0()

func (*ReplyCallMessage) Header

func (p *ReplyCallMessage) Header() *RtmpHeader

func (*ReplyCallMessage) String

func (m *ReplyCallMessage) String() string

type ReplyConnectMessage

type ReplyConnectMessage struct {
	CommandMessage
	Properties interface{} `json:",omitempty"`
	Infomation interface{} `json:",omitempty"`
}

func (*ReplyConnectMessage) Body

func (p *ReplyConnectMessage) Body() Payload

func (*ReplyConnectMessage) Encode0

func (p *ReplyConnectMessage) Encode0()

func (*ReplyConnectMessage) Header

func (p *ReplyConnectMessage) Header() *RtmpHeader

func (*ReplyConnectMessage) String

func (m *ReplyConnectMessage) String() string

type ReplyCreateStreamMessage

type ReplyCreateStreamMessage struct {
	CommandMessage
	Object   interface{} `json:",omitempty"`
	StreamId uint32
}

func (*ReplyCreateStreamMessage) Body

func (*ReplyCreateStreamMessage) Decode0

func (p *ReplyCreateStreamMessage) Decode0(head *RtmpHeader, body Payload)

func (*ReplyCreateStreamMessage) Decode3

func (p *ReplyCreateStreamMessage) Decode3(head *RtmpHeader, body Payload)

func (*ReplyCreateStreamMessage) Encode0

func (p *ReplyCreateStreamMessage) Encode0()

func (*ReplyCreateStreamMessage) Header

func (p *ReplyCreateStreamMessage) Header() *RtmpHeader

func (*ReplyCreateStreamMessage) String

func (m *ReplyCreateStreamMessage) String() string

type ReplyMessage

type ReplyMessage struct {
	CommandMessage
	Properties  interface{} `json:",omitempty"`
	Infomation  interface{} `json:",omitempty"`
	Description string
}

func (*ReplyMessage) Body

func (p *ReplyMessage) Body() Payload

func (*ReplyMessage) Decode0

func (p *ReplyMessage) Decode0(head *RtmpHeader, body Payload)

func (*ReplyMessage) Encode0

func (p *ReplyMessage) Encode0()

func (*ReplyMessage) Header

func (p *ReplyMessage) Header() *RtmpHeader

func (*ReplyMessage) String

func (m *ReplyMessage) String() string

type ReplyPauseMessage

type ReplyPauseMessage struct {
	CommandMessage
	Description string
}

func (*ReplyPauseMessage) Body

func (p *ReplyPauseMessage) Body() Payload

func (*ReplyPauseMessage) Encode0

func (p *ReplyPauseMessage) Encode0()

func (*ReplyPauseMessage) Header

func (p *ReplyPauseMessage) Header() *RtmpHeader

func (*ReplyPauseMessage) String

func (m *ReplyPauseMessage) String() string

type ReplyPlayMessage

type ReplyPlayMessage struct {
	CommandMessage
	Object      interface{} `json:",omitempty"`
	Description string
}

func (*ReplyPlayMessage) Body

func (p *ReplyPlayMessage) Body() Payload

func (*ReplyPlayMessage) Decode0

func (p *ReplyPlayMessage) Decode0(head *RtmpHeader, body Payload)

func (*ReplyPlayMessage) Decode3

func (p *ReplyPlayMessage) Decode3(head *RtmpHeader, body Payload)

func (*ReplyPlayMessage) Encode0

func (p *ReplyPlayMessage) Encode0()

func (*ReplyPlayMessage) Header

func (p *ReplyPlayMessage) Header() *RtmpHeader

func (*ReplyPlayMessage) String

func (m *ReplyPlayMessage) String() string

type ReplyPublishMessage

type ReplyPublishMessage struct {
	CommandMessage
	Properties interface{} `json:",omitempty"`
	Infomation interface{} `json:",omitempty"`
}

func (*ReplyPublishMessage) Body

func (p *ReplyPublishMessage) Body() Payload

func (*ReplyPublishMessage) Encode0

func (p *ReplyPublishMessage) Encode0()

func (*ReplyPublishMessage) Header

func (p *ReplyPublishMessage) Header() *RtmpHeader

func (*ReplyPublishMessage) String

func (m *ReplyPublishMessage) String() string

type ReplySeekMessage

type ReplySeekMessage struct {
	CommandMessage
	Description string
}

func (*ReplySeekMessage) Body

func (p *ReplySeekMessage) Body() Payload

func (*ReplySeekMessage) Encode0

func (p *ReplySeekMessage) Encode0()

func (*ReplySeekMessage) Header

func (p *ReplySeekMessage) Header() *RtmpHeader

func (*ReplySeekMessage) String

func (m *ReplySeekMessage) String() string

type RtmpHeader

type RtmpHeader struct {
	ChunkType       byte   `json:""` /*head size 2 bit*/
	ChunkId         uint32 `json:""` /* chunk stream id , 6 bit*/
	Timestamp       uint32 `json:""` /* timestamp (delta) 3 byte*/
	MessageLength   uint32 `json:""` /* message length 3 byte*/
	MessageType     byte   `json:""` /* message type id 1 byte*/
	StreamId        uint32 `json:""` /* message stream id 4 byte*/
	ExtendTimestamp uint32 `json:",omitempty"`
}

func (*RtmpHeader) Clone

func (p *RtmpHeader) Clone() *RtmpHeader

func (*RtmpHeader) String

func (p *RtmpHeader) String() string

type RtmpMessage

type RtmpMessage interface {
	Header() *RtmpHeader
	Body() Payload
	String() string
}

type RtmpNetConnection

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

func (*RtmpNetConnection) Call

func (c *RtmpNetConnection) Call(command string, args ...Args) error

func (*RtmpNetConnection) Close

func (c *RtmpNetConnection) Close()

func (*RtmpNetConnection) Connect

func (c *RtmpNetConnection) Connect(command string, args ...Args) error

func (*RtmpNetConnection) Connected

func (c *RtmpNetConnection) Connected() bool

func (*RtmpNetConnection) URL

func (c *RtmpNetConnection) URL() string

type RtmpNetStream

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

func Connect

func Connect(url string) (s *RtmpNetStream, err error)

func (*RtmpNetStream) AttachAudio

func (s *RtmpNetStream) AttachAudio(channel AudioChannel)

func (*RtmpNetStream) AttachVideo

func (s *RtmpNetStream) AttachVideo(channel VideoChannel)

func (*RtmpNetStream) BufferLength

func (s *RtmpNetStream) BufferLength() uint64

func (*RtmpNetStream) BufferTime

func (s *RtmpNetStream) BufferTime() time.Duration

func (*RtmpNetStream) BytesLoaded

func (s *RtmpNetStream) BytesLoaded() uint64

func (*RtmpNetStream) Close

func (s *RtmpNetStream) Close()

func (*RtmpNetStream) NetConnection

func (s *RtmpNetStream) NetConnection() NetConnection

func (*RtmpNetStream) Pause

func (s *RtmpNetStream) Pause()

func (*RtmpNetStream) Play

func (s *RtmpNetStream) Play(streamName string, args ...Args) error

func (*RtmpNetStream) Publish

func (s *RtmpNetStream) Publish(streamName string, streamType string) error

func (*RtmpNetStream) ReceiveAudio

func (s *RtmpNetStream) ReceiveAudio(flag bool)

func (*RtmpNetStream) ReceiveVideo

func (s *RtmpNetStream) ReceiveVideo(flag bool)

func (*RtmpNetStream) Resume

func (s *RtmpNetStream) Resume()

func (*RtmpNetStream) Seek

func (s *RtmpNetStream) Seek(offset uint64)

func (*RtmpNetStream) Send

func (s *RtmpNetStream) Send(handlerName string, args ...Args)

func (*RtmpNetStream) SendAudio

func (s *RtmpNetStream) SendAudio(audio *StreamPacket) error

func (*RtmpNetStream) SendMetaData

func (s *RtmpNetStream) SendMetaData(data *StreamPacket) error

func (*RtmpNetStream) SendVideo

func (s *RtmpNetStream) SendVideo(video *StreamPacket) error

func (*RtmpNetStream) TogglePause

func (s *RtmpNetStream) TogglePause()

type SeekMessage

type SeekMessage struct {
	CommandMessage
	Object       interface{} `json:",omitempty"`
	Milliseconds uint64
}

func (*SeekMessage) Body

func (p *SeekMessage) Body() Payload

func (*SeekMessage) Encode0

func (p *SeekMessage) Encode0()

func (*SeekMessage) Header

func (p *SeekMessage) Header() *RtmpHeader

func (*SeekMessage) String

func (m *SeekMessage) String() string

type Server

type Server struct {
	Addr         string        //监听地址
	ReadTimeout  time.Duration //读超时
	WriteTimeout time.Duration //写超时
	Lock         *sync.Mutex
}

func (*Server) ListenAndServe

func (p *Server) ListenAndServe() error

type ServerHandler

type ServerHandler interface {
	OnPublishing(s *RtmpNetStream) error
	OnPlaying(s *RtmpNetStream) error
	OnClosed(s *RtmpNetStream)
	OnError(s *RtmpNetStream, err error)
}

type SetBufferMessage

type SetBufferMessage struct {
	UserControlMessage
	StreamId    uint32
	Millisecond uint32
}

func (*SetBufferMessage) Body

func (p *SetBufferMessage) Body() Payload

func (*SetBufferMessage) Encode

func (p *SetBufferMessage) Encode()

func (*SetBufferMessage) Header

func (p *SetBufferMessage) Header() *RtmpHeader

func (*SetBufferMessage) String

func (p *SetBufferMessage) String() string

type SetPeerBandwidthMessage

type SetPeerBandwidthMessage struct {
	ControlMessage
	AckWinsize uint32 //4byte
	LimitType  byte
}

func (*SetPeerBandwidthMessage) Body

func (p *SetPeerBandwidthMessage) Body() Payload

func (*SetPeerBandwidthMessage) Encode

func (p *SetPeerBandwidthMessage) Encode()

func (*SetPeerBandwidthMessage) Header

func (p *SetPeerBandwidthMessage) Header() *RtmpHeader

func (*SetPeerBandwidthMessage) String

func (p *SetPeerBandwidthMessage) String() string

type SharedObject

type SharedObject interface {
}

type SharedObjectMessage

type SharedObjectMessage struct {
	RtmpHeader *RtmpHeader
	Payload    Payload
}

func (*SharedObjectMessage) Body

func (p *SharedObjectMessage) Body() Payload

func (*SharedObjectMessage) Header

func (p *SharedObjectMessage) Header() *RtmpHeader

func (*SharedObjectMessage) String

func (m *SharedObjectMessage) String() string

type StreamBeginMessage

type StreamBeginMessage struct {
	UserControlMessage
	StreamId uint32
}

func (*StreamBeginMessage) Body

func (p *StreamBeginMessage) Body() Payload

func (*StreamBeginMessage) Encode

func (p *StreamBeginMessage) Encode()

func (*StreamBeginMessage) Header

func (p *StreamBeginMessage) Header() *RtmpHeader

func (*StreamBeginMessage) String

func (p *StreamBeginMessage) String() string

type StreamDryMessage

type StreamDryMessage struct {
	UserControlMessage
	StreamId uint32
}

func (*StreamDryMessage) Body

func (p *StreamDryMessage) Body() Payload

func (*StreamDryMessage) Encode

func (p *StreamDryMessage) Encode()

func (*StreamDryMessage) Header

func (p *StreamDryMessage) Header() *RtmpHeader

func (*StreamDryMessage) String

func (p *StreamDryMessage) String() string

type StreamEOFMessage

type StreamEOFMessage struct {
	UserControlMessage
	StreamId uint32
}

func (*StreamEOFMessage) Body

func (p *StreamEOFMessage) Body() Payload

func (*StreamEOFMessage) Encode

func (p *StreamEOFMessage) Encode()

func (*StreamEOFMessage) Header

func (p *StreamEOFMessage) Header() *RtmpHeader

func (*StreamEOFMessage) String

func (p *StreamEOFMessage) String() string

type StreamMessage

type StreamMessage struct {
	RtmpHeader *RtmpHeader
	Payload    Payload
}

func (*StreamMessage) Body

func (p *StreamMessage) Body() Payload

func (*StreamMessage) Header

func (p *StreamMessage) Header() *RtmpHeader

func (*StreamMessage) String

func (m *StreamMessage) String() string

type StreamPacket

type StreamPacket struct {
	Timestamp      uint32
	Type           byte //8 audio,9 video
	VideoFrameType byte //4bit
	VideoCodecID   byte //4bit
	AudioFormat    byte //4bit
	SamplingRate   byte //2bit
	SampleLength   byte //1bit
	AudioType      byte //1bit
	Payload        Payload
}

func (*StreamPacket) Clone

func (p *StreamPacket) Clone() *StreamPacket

func (*StreamPacket) String

func (p *StreamPacket) String() string

type Terminal

type Terminal chan bool

type UnknowCommandMessage

type UnknowCommandMessage struct {
	CommandMessage
	Payload Payload
}

func (*UnknowCommandMessage) Body

func (p *UnknowCommandMessage) Body() Payload

func (*UnknowCommandMessage) Header

func (p *UnknowCommandMessage) Header() *RtmpHeader

func (*UnknowCommandMessage) String

func (m *UnknowCommandMessage) String() string

type UnknowRtmpMessage

type UnknowRtmpMessage struct {
	RtmpHeader *RtmpHeader
	Payload    Payload
}

func (*UnknowRtmpMessage) Body

func (p *UnknowRtmpMessage) Body() Payload

func (*UnknowRtmpMessage) Header

func (p *UnknowRtmpMessage) Header() *RtmpHeader

func (*UnknowRtmpMessage) String

func (m *UnknowRtmpMessage) String() string

type UnknownUserMessage

type UnknownUserMessage struct {
	UserControlMessage
}

func (*UnknownUserMessage) Body

func (p *UnknownUserMessage) Body() Payload

func (*UnknownUserMessage) Header

func (p *UnknownUserMessage) Header() *RtmpHeader

func (*UnknownUserMessage) String

func (p *UnknownUserMessage) String() string

type UserControlMessage

type UserControlMessage struct {
	ControlMessage
	EventType uint16
	EventData Payload
}

func (*UserControlMessage) Body

func (p *UserControlMessage) Body() Payload

func (*UserControlMessage) Header

func (p *UserControlMessage) Header() *RtmpHeader

func (*UserControlMessage) String

func (p *UserControlMessage) String() string

type VideoChannel

type VideoChannel chan *StreamPacket

type VideoMessage

type VideoMessage struct {
	RtmpHeader *RtmpHeader
	Payload    Payload
}

func (*VideoMessage) Body

func (p *VideoMessage) Body() Payload

func (*VideoMessage) Header

func (p *VideoMessage) Header() *RtmpHeader

func (*VideoMessage) String

func (m *VideoMessage) String() string

Jump to

Keyboard shortcuts

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