rtsp

package module
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2021 License: MIT Imports: 23 Imported by: 1

README

Monibuca 的RTSP 插件

主要功能是提供RTSP的端口监听接受RTSP推流,以及对RTSP地址进行拉流转发

插件名称

RTSP

配置

[RTSP]
ListenAddr  = ":554"
BufferLength  = 2048
AutoPull     = false
RemoteAddr   = "rtsp://localhost/${streamPath}"
[[RTSP.AutoPullList]]
URL = "rtsp://admin:admin@192.168.1.212:554/cam/realmonitor?channel=1&subtype=1"
StreamPath = "live/rtsp"
  • ListenAddr 是监听端口,可以将rtsp流推到Monibuca中
  • BufferLength是指解析拉取的rtp包的缓冲大小
  • AutoPull是指当有用户订阅一个新流的时候自动向远程拉流转发
  • RemoteAddr 指远程拉流地址,其中${streamPath}是占位符,实际使用流路径替换。
  • AutoPullList 是一个数组,如果配置了该数组,则会在程序启动时自动启动拉流,StreamPath一定要是唯一的,不能重复

使用方法(拉流转发)

new(RTSP).PullStream("live/user1","rtsp://xxx.xxx.xxx.xxx/live/user1") 

Documentation

Index

Constants

View Source
const (
	// Client to server for presentation and stream objects; recommended
	DESCRIBE = "DESCRIBE"
	// Bidirectional for client and stream objects; optional
	ANNOUNCE = "ANNOUNCE"
	// Bidirectional for client and stream objects; optional
	GET_PARAMETER = "GET_PARAMETER"
	// Bidirectional for client and stream objects; required for Client to server, optional for server to client
	OPTIONS = "OPTIONS"
	// Client to server for presentation and stream objects; recommended
	PAUSE = "PAUSE"
	// Client to server for presentation and stream objects; required
	PLAY = "PLAY"
	// Client to server for presentation and stream objects; optional
	RECORD = "RECORD"
	// Server to client for presentation and stream objects; optional
	REDIRECT = "REDIRECT"
	// Client to server for stream objects; required
	SETUP = "SETUP"
	// Bidirectional for presentation and stream objects; optional
	SET_PARAMETER = "SET_PARAMETER"
	// Client to server for presentation and stream objects; required
	TEARDOWN = "TEARDOWN"
	DATA     = "DATA"
)
View Source
const (
	RTP_FIXED_HEADER_LENGTH = 12
)
View Source
const (
	RTSP_VERSION = "RTSP/1.0"
)
View Source
const UDP_BUF_SIZE = 1048576

Variables

This section is empty.

Functions

func BasicAuth added in v1.1.10

func BasicAuth(authLine string, method string, URL string) (string, error)

auth Basic验证

func DigestAuth

func DigestAuth(authLine string, method string, URL string) (string, error)

func ListenRtsp

func ListenRtsp(addr string) error

func ParseSDP

func ParseSDP(sdpRaw string) map[string]*SDPInfo

Types

type RTPInfo

type RTPInfo struct {
	Version        int
	Padding        bool
	Extension      bool
	CSRCCnt        int
	Marker         bool
	PayloadType    int
	SequenceNumber int
	Timestamp      int
	SSRC           int
	Payload        []byte
	PayloadOffset  int
}

func ParseRTP

func ParseRTP(rtpBytes []byte) *RTPInfo

type RTSP

type RTSP struct {
	RTP
	RTSPInfo
	RTSPClientInfo
	ID   string
	Conn *RichConn

	Type      SessionType
	TransType TransType

	SDPMap map[string]*SDPInfo

	ASdp *SDPInfo
	VSdp *SDPInfo

	Timeout int

	UDPServer *UDPServer
	UDPClient *UDPClient
	Auth      func(string) string
	// contains filtered or unexported fields
}

func (*RTSP) AcceptPush

func (session *RTSP) AcceptPush()

AcceptPush 接受推流

func (*RTSP) CheckAuth

func (session *RTSP) CheckAuth(authLine string, method string) error

func (*RTSP) PullStream

func (rtsp *RTSP) PullStream(streamPath string, rtspUrl string) (err error)

PullStream 从外部拉流

func (*RTSP) Request

func (client *RTSP) Request(method string, headers map[string]string) (*Response, error)

func (*RTSP) RequestNoResp

func (client *RTSP) RequestNoResp(method string, headers map[string]string) (err error)

func (*RTSP) RequestWithPath

func (client *RTSP) RequestWithPath(method string, path string, headers map[string]string, needResp bool) (resp *Response, err error)

func (*RTSP) SendRTP

func (session *RTSP) SendRTP(pack *RTPPack) (err error)

func (*RTSP) SessionString

func (session *RTSP) SessionString() string

func (*RTSP) Stop

func (session *RTSP) Stop()

type RTSPClientInfo

type RTSPClientInfo struct {
	Agent   string
	Session string

	Seq int
	// contains filtered or unexported fields
}

type RTSPInfo

type RTSPInfo struct {
	URL        string
	SDPRaw     string
	InBytes    int
	OutBytes   int
	StreamInfo *StreamInfo
}

type Request

type Request struct {
	Method  string
	URL     string
	Version string
	Header  map[string]string
	Content string
	Body    string
}

func NewRequest

func NewRequest(content string) *Request

func (*Request) GetContentLength

func (r *Request) GetContentLength() int

func (*Request) String

func (r *Request) String() string

type Response

type Response struct {
	Version    string
	StatusCode int
	Status     string
	Header     map[string]interface{}
	Body       string
}

func NewResponse

func NewResponse(statusCode int, status, cSeq, sid, body string) *Response

func (*Response) SetBody

func (r *Response) SetBody(body string)

func (*Response) String

func (r *Response) String() string

type RichConn

type RichConn struct {
	net.Conn
	// contains filtered or unexported fields
}

func (*RichConn) Read

func (conn *RichConn) Read(b []byte) (n int, err error)

func (*RichConn) Write

func (conn *RichConn) Write(b []byte) (n int, err error)

type SDPInfo

type SDPInfo struct {
	AVType             string
	Codec              string
	TimeScale          int
	Control            string
	Rtpmap             int
	Config             []byte
	SpropParameterSets [][]byte
	PayloadType        int
	SizeLength         int
	IndexLength        int
}

type SessionType

type SessionType int
const (
	SESSION_TYPE_PUSHER SessionType = iota
	SESSEION_TYPE_PLAYER
)

func (SessionType) String

func (st SessionType) String() string

type TransType

type TransType int
const (
	TRANS_TYPE_TCP TransType = iota
	TRANS_TYPE_UDP
)

func (TransType) String

func (tt TransType) String() string

type UDPClient

type UDPClient struct {
	APort        int
	AConn        *net.UDPConn
	AControlPort int
	AControlConn *net.UDPConn
	VPort        int
	VConn        *net.UDPConn
	VControlPort int
	VControlConn *net.UDPConn

	Stoped bool
}

func (*UDPClient) SendRTP

func (c *UDPClient) SendRTP(pack *RTPPack) (err error)

func (*UDPClient) SetupAudio

func (c *UDPClient) SetupAudio() (err error)

func (*UDPClient) SetupVideo

func (c *UDPClient) SetupVideo() (err error)

func (*UDPClient) Stop

func (s *UDPClient) Stop()

type UDPServer

type UDPServer struct {
	Session *RTSP
	UDPClient
	sync.Mutex
}

func (*UDPServer) AddInputBytes

func (s *UDPServer) AddInputBytes(bytes int)

func (*UDPServer) HandleRTP

func (s *UDPServer) HandleRTP(pack *RTPPack)

func (*UDPServer) SetupAudio

func (s *UDPServer) SetupAudio() (err error)

func (*UDPServer) SetupVideo

func (s *UDPServer) SetupVideo() (err error)

func (*UDPServer) Stop

func (s *UDPServer) Stop()

Jump to

Keyboard shortcuts

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