rtsp

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2021 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChannelVideo        = rtp.ChannelVideo
	ChannelVideoControl = rtp.ChannelVideoControl
	ChannelAudio        = rtp.ChannelAudio
	ChannelAudioControl = rtp.ChannelAudioControl
)

预定义 RTP 包类型

View Source
const (
	MethodOptions      = rtsp.MethodOptions      // 查询命令支持情况(C->S, S->C)
	MethodDescribe     = rtsp.MethodDescribe     // 获取媒体信息(C->S)
	MethodAnnounce     = rtsp.MethodAnnounce     // 声明要push的媒体信息(方向:C->S, S->C)
	MethodSetup        = rtsp.MethodSetup        // 构建传输会话,也可以调整传输参数(C->S);如果不允许调整,可以返回 455 错误
	MethodPlay         = rtsp.MethodPlay         // 开始发送媒体数据(C->S)
	MethodPause        = rtsp.MethodPause        // 暂停发送媒体数据(C->S)
	MethodTeardown     = rtsp.MethodTeardown     // 关闭发送通道;关闭后需要重新执行 Setup 方法(C->S)
	MethodGetParameter = rtsp.MethodGetParameter // 获取参数;空body可作为心跳ping(C->S, S->C)
	MethodSetParameter = rtsp.MethodSetParameter // 设置参数,应该每次只设置一个参数(C->S, S->C)
	MethodRecord       = rtsp.MethodRecord       // 启动录像(C->S)
	MethodRedirect     = rtsp.MethodRedirect     // 跳转(S->C)
)

通用的 RTSP 方法。

除非特别说明,这些定义在 RFC2326 规范的 10 章中。 未实现的方法需要返回 "501 Not Implemented"

View Source
const (
	FieldAccept            = rtsp.FieldAccept            // (R:opt.:entity)
	FieldAcceptEncoding    = rtsp.FieldAcceptEncoding    // (R:opt.:entity)
	FieldAcceptLanguage    = rtsp.FieldAcceptLanguage    // (R:opt.:all)
	FieldAllow             = rtsp.FieldAllow             // (R:opt.:all)
	FieldAuthorization     = rtsp.FieldAuthorization     // (R:opt.:all)
	FieldBandwidth         = rtsp.FieldBandwidth         // (R:opt.all)
	FieldBlocksize         = rtsp.FieldBlocksize         // (R:opt.:all but OPTIONS, TEARDOWN)
	FieldCacheControl      = rtsp.FieldCacheControl      // (g:opt.:SETUP)
	FieldConference        = rtsp.FieldConference        // (R:opt.:SETUP)
	FieldConnection        = rtsp.FieldConnection        // (g:req.:all)
	FieldContentBase       = rtsp.FieldContentBase       // (e:opt.:entity)
	FieldContentEncoding   = rtsp.FieldContentEncoding   // (e:req.:SET_PARAMETER ; e:req.:DESCRIBE, ANNOUNCE )
	FieldContentLanguage   = rtsp.FieldContentLanguage   // (e:req.:DESCRIBE, ANNOUNCE)
	FieldContentLength     = rtsp.FieldContentLength     // (e:req.:SET_PARAMETER, ANNOUNCE; e:req.:entity)
	FieldContentLocation   = rtsp.FieldContentLocation   // (e:opt.:entity)
	FieldContentType       = rtsp.FieldContentType       // (e:req.:SET_PARAMETER, ANNOUNCE; r:req.:entity )
	FieldCSeq              = rtsp.FieldCSeq              // (g:req.:all)
	FieldDate              = rtsp.FieldDate              // (g:opt.:all)
	FieldExpires           = rtsp.FieldExpires           // (e:opt.:DESCRIBE, ANNOUNCE)
	FieldFrom              = rtsp.FieldFrom              // (R:opt.:all)
	FieldIfModifiedSince   = rtsp.FieldIfModifiedSince   // (R:opt.:DESCRIBE, SETUP)
	FieldLastModified      = rtsp.FieldLastModified      // (e:opt.:entity)
	FieldProxyAuthenticate = rtsp.FieldProxyAuthenticate //
	FieldProxyRequire      = rtsp.FieldProxyRequire      // (R:req.:all)
	FieldPublic            = rtsp.FieldPublic            // (r:opt.:all)
	FieldRange             = rtsp.FieldRange             // (R:opt.:PLAY, PAUSE, RECORD; r:opt.:PLAY, PAUSE, RECORD)
	FieldReferer           = rtsp.FieldReferer           // (R:opt.:all)
	FieldRequire           = rtsp.FieldRequire           // (R:req.:all)
	FieldRetryAfter        = rtsp.FieldRetryAfter        // (r:opt.:all)
	FieldRTPInfo           = rtsp.FieldRTPInfo           // (r:req.:PLAY)
	FieldScale             = rtsp.FieldScale             // (Rr:opt.:PLAY, RECORD)
	FieldSession           = rtsp.FieldSession           // (Rr:req.:all but SETUP, OPTIONS)
	FieldServer            = rtsp.FieldServer            // (r:opt.:all)
	FieldSpeed             = rtsp.FieldSpeed             // (Rr:opt.:PLAY)
	FieldTransport         = rtsp.FieldTransport         // (Rr:req.:SETUP)
	FieldUnsupported       = rtsp.FieldUnsupported       // (r:req.:all)
	FieldUserAgent         = rtsp.FieldUserAgent         // (R:opt.:all)
	FieldVia               = rtsp.FieldVia               // (g:opt.:all)
	FieldWWWAuthenticate   = rtsp.FieldWWWAuthenticate   // (r:opt.:all)
)

RTSP 头部域定义 type:support:methods type: "g"通用的请求头部;"R"请求头部;"r"响应头部;"e"实体Body头部域。 support: opt. 可选; req. 必须 methods: 头部域应用范围

View Source
const (
	StatusContinue = rtsp.StatusContinue

	//======Success 2xx
	StatusOK                = rtsp.StatusOK
	StatusCreated           = rtsp.StatusCreated           // only for RECORD
	StatusLowOnStorageSpace = rtsp.StatusLowOnStorageSpace //only for RECORD

	//======Redirection 3xx
	StatusMultipleChoices  = rtsp.StatusMultipleChoices
	StatusMovedPermanently = rtsp.StatusMovedPermanently
	StatusMovedTemporarily = rtsp.StatusMovedTemporarily // 和http不同
	StatusSeeOther         = rtsp.StatusSeeOther
	StatusNotModified      = rtsp.StatusNotModified
	StatusUseProxy         = rtsp.StatusUseProxy

	//======Client Error 4xx
	StatusBadRequest                = rtsp.StatusBadRequest
	StatusUnauthorized              = rtsp.StatusUnauthorized
	StatusPaymentRequired           = rtsp.StatusPaymentRequired
	StatusForbidden                 = rtsp.StatusForbidden
	StatusNotFound                  = rtsp.StatusNotFound
	StatusMethodNotAllowed          = rtsp.StatusMethodNotAllowed
	StatusNotAcceptable             = rtsp.StatusNotAcceptable
	StatusProxyAuthRequired         = rtsp.StatusProxyAuthRequired
	StatusRequestTimeout            = rtsp.StatusRequestTimeout
	StatusGone                      = rtsp.StatusGone
	StatusLengthRequired            = rtsp.StatusLengthRequired
	StatusPreconditionFailed        = rtsp.StatusPreconditionFailed // only for DESCRIBE, SETUP
	StatusRequestEntityTooLarge     = rtsp.StatusRequestEntityTooLarge
	StatusRequestURITooLong         = rtsp.StatusRequestURITooLong
	StatusUnsupportedMediaType      = rtsp.StatusUnsupportedMediaType
	StatusInvalidParameter          = rtsp.StatusInvalidParameter   // only for SETUP
	StatusConferenceNotFound        = rtsp.StatusConferenceNotFound // only for SETUP
	StatusNotEnoughBandwidth        = rtsp.StatusNotEnoughBandwidth // only for SETUP
	StatusSessionNotFound           = rtsp.StatusSessionNotFound
	StatusMethodNotValidInThisState = rtsp.StatusMethodNotValidInThisState
	StatusHeaderFieldNotValid       = rtsp.StatusHeaderFieldNotValid
	StatusInvalidRange              = rtsp.StatusInvalidRange        // only for PLAY
	StatusParameterIsReadOnly       = rtsp.StatusParameterIsReadOnly // only for SET_PARAMETER
	StatusAggregateOpNotAllowed     = rtsp.StatusAggregateOpNotAllowed
	StatusOnlyAggregateOpAllowed    = rtsp.StatusOnlyAggregateOpAllowed
	StatusUnsupportedTransport      = rtsp.StatusUnsupportedTransport
	StatusDestinationUnreachable    = rtsp.StatusDestinationUnreachable

	StatusInternalServerError     = rtsp.StatusInternalServerError
	StatusNotImplemented          = rtsp.StatusNotImplemented
	StatusBadGateway              = rtsp.StatusBadGateway
	StatusServiceUnavailable      = rtsp.StatusServiceUnavailable
	StatusGatewayTimeout          = rtsp.StatusGatewayTimeout
	StatusRTSPVersionNotSupported = rtsp.StatusRTSPVersionNotSupported
	StatusOptionNotSupported      = rtsp.StatusOptionNotSupported // 和 http 不同
)

RTSP 响应状态码. See: https://tools.ietf.org/html/rfc2326#page-19

Variables

View Source
var (
	ReadPacket   = rtp.ReadPacket
	ReadResponse = rtsp.ReadResponse
	ReadRequest  = rtsp.ReadRequest
)

.

View Source
var StatusText = rtsp.StatusText

StatusText .

Functions

func CreateAcceptHandler

func CreateAcceptHandler() tcp.OnAccept

CreateAcceptHandler 创建连接接入处理器

func MatchRTSP

func MatchRTSP() listener.Matcher

MatchRTSP 仅匹配 RTSP 请求方法 注意:由于RTSP 和 HTTP 都有 OPTIONS 方法,因此对 RTSP 的 OPTIONS 做了进一步细化

func NewPullStreamFacotry

func NewPullStreamFacotry() media.PullStreamFactory

NewPullStreamFacotry 创建拉流工厂

Types

type Header = rtsp.Header

Header .

type Pack

type Pack = format.Packet

Pack .

type PullClient

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

PullClient 负责拉流到服务器

func NewPullClient

func NewPullClient(localPath, remoteURL string) (*PullClient, error)

NewPullClient 创建拉流客户端

func (*PullClient) Close

func (c *PullClient) Close() error

Close 关闭客户端

func (*PullClient) Open

func (c *PullClient) Open() (err error)

Open 打开拉流客户端 依次发生请求:OPTIONS、DESCRIBE、SETUP、PLAY 全部成功,启动接收 RTP流 go routine

func (*PullClient) Ping

func (c *PullClient) Ping() error

Ping 测试网络和服务器

type RTPPack

type RTPPack = rtp.Packet

RTPPack .

type RTPTransport

type RTPTransport struct {
	Mode        SessionMode
	Append      bool
	Type        RTPTransportType
	Channels    [rtpChannelCount]int
	ClientPorts [rtpChannelCount]int
	ServerPorts [rtpChannelCount]int

	// 组播相关设置
	Ports       [rtpChannelCount]int // 组播端口
	MulticastIP string               // 组播地址 224.0.1.0~238.255.255.255
	TTL         int
	Source      string // 组播源地址
}

RTPTransport RTP传输设置

func (*RTPTransport) ParseTransport

func (t *RTPTransport) ParseTransport(rtpType int, ts string) (err error)

ParseTransport 解析Setup中的传输配置

type RTPTransportType

type RTPTransportType int

RTPTransportType RTP 传输模式

const (
	RTPUnknownTrans RTPTransportType = iota
	RTPTCPUnicast                    // TCP
	RTPUDPUnicast                    // UDP
	RTPMulticast                     // 组播
)

通讯类型

type Request

type Request = rtsp.Request

Request .

type Response

type Response = rtsp.Response

Response .

type Server

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

Server rtsp 服务器

type Session

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

Session RTSP 会话

func (*Session) Addr

func (s *Session) Addr() string

Addr Session地址

func (*Session) Close

func (s *Session) Close() error

Close 关闭会话

func (*Session) Consume

func (s *Session) Consume(p Pack)

Consume 消费媒体包

type SessionMode

type SessionMode int

SessionMode 会话模式

const (
	UnknownSession SessionMode = iota
	PlaySession                // 播放
	RecordSession              // 录像
)

会话类型

Jump to

Keyboard shortcuts

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