Documentation ¶
Index ¶
- Constants
- func FormatDigestAuthResponse(realm, nonce, method, url string, username, password string) string
- func StatusText(code int) string
- type Header
- func (h Header) Add(key, value string)
- func (h Header) Del(key string)
- func (h Header) Get(key string) string
- func (h Header) Int(key string) int
- func (h Header) Set(key, value string)
- func (h Header) SetInt(key string, value int)
- func (h Header) Setf(key, format string, a ...interface{}) string
- func (h Header) Write(w io.Writer) error
- type Request
- func (req *Request) BasicAuth() (username, password string, ok bool)
- func (req *Request) DigestAuth() (username, response string, ok bool)
- func (req *Request) SetBasicAuth(username, password string)
- func (req *Request) SetDigestAuth(url *url.URL, realm, nonce, username, password string)
- func (req *Request) String() string
- func (req *Request) Write(w io.Writer) error
- type Response
- func (resp *Response) BasicAuth() (realm string, ok bool)
- func (resp *Response) DigestAuth() (realm, nonce string, ok bool)
- func (resp *Response) SetBasicAuth(realm string)
- func (resp *Response) SetDigestAuth(realm, nonce string)
- func (resp *Response) String() string
- func (resp *Response) Write(w io.Writer) error
Constants ¶
const ( FieldAccept = "Accept" // (R:opt.:entity) FieldAcceptEncoding = "Accept-Encoding" // (R:opt.:entity) FieldAcceptLanguage = "Accept-Language" // (R:opt.:all) FieldAllow = "Allow" // (R:opt.:all) FieldAuthorization = "Authorization" // (R:opt.:all) FieldBandwidth = "Bandwidth" // (R:opt.all) FieldBlocksize = "Blocksize" // (R:opt.:all but OPTIONS, TEARDOWN) FieldCacheControl = "Cache-Control" // (g:opt.:SETUP) FieldConference = "Conference" // (R:opt.:SETUP) FieldConnection = "Connection" // (g:req.:all) FieldContentBase = "Content-Base" // (e:opt.:entity) FieldContentEncoding = "Content-Encoding" // (e:req.:SET_PARAMETER ; e:req.:DESCRIBE, ANNOUNCE ) FieldContentLanguage = "Content-Language" // (e:req.:DESCRIBE, ANNOUNCE) FieldContentLength = "Content-Length" // (e:req.:SET_PARAMETER, ANNOUNCE; e:req.:entity) FieldContentLocation = "Content-Location" // (e:opt.:entity) FieldContentType = "Content-Type" // (e:req.:SET_PARAMETER, ANNOUNCE; r:req.:entity ) FieldCSeq = "CSeq" // (g:req.:all) FieldDate = "Date" // (g:opt.:all) FieldExpires = "Expires" // (e:opt.:DESCRIBE, ANNOUNCE) FieldFrom = "From" // (R:opt.:all) FieldIfModifiedSince = "If-Modified-Since" // (R:opt.:DESCRIBE, SETUP) FieldLastModified = "Last-Modified" // (e:opt.:entity) FieldProxyAuthenticate = "Proxy-Authenticate" // FieldProxyRequire = "Proxy-Require" // (R:req.:all) FieldPublic = "Public" // (r:opt.:all) FieldRange = "Range" // (R:opt.:PLAY, PAUSE, RECORD; r:opt.:PLAY, PAUSE, RECORD) FieldReferer = "Referer" // (R:opt.:all) FieldRequire = "Require" // (R:req.:all) FieldRetryAfter = "Retry-After" // (r:opt.:all) FieldRTPInfo = "RTP-Info" // (r:req.:PLAY) FieldScale = "Scale" // (Rr:opt.:PLAY, RECORD) FieldSession = "Session" // (Rr:req.:all but SETUP, OPTIONS) FieldServer = "Server" // (r:opt.:all) FieldSpeed = "Speed" // (Rr:opt.:PLAY) FieldTransport = "Transport" // (Rr:req.:SETUP) FieldUnsupported = "Unsupported" // (r:req.:all) FieldUserAgent = "User-Agent" // (R:opt.:all) FieldVia = "Via" // (g:opt.:all) FieldWWWAuthenticate = "WWW-Authenticate" // (r:opt.:all) )
RTSP 头部域定义 type:support:methods type: "g"通用的请求头部;"R"请求头部;"r"响应头部;"e"实体Body头部域。 support: opt. 可选; req. 必须 methods: 头部域应用范围
const ( MethodOptions = "OPTIONS" // 查询命令支持情况(C->S, S->C) MethodDescribe = "DESCRIBE" // 获取媒体信息(C->S) MethodAnnounce = "ANNOUNCE" // 声明要push的媒体信息(方向:C->S, S->C) MethodSetup = "SETUP" // 构建传输会话,也可以调整传输参数(C->S);如果不允许调整,可以返回 455 错误 MethodPlay = "PLAY" // 开始发送媒体数据(C->S) MethodPause = "PAUSE" // 暂停发送媒体数据(C->S) MethodTeardown = "TEARDOWN" // 关闭发送通道;关闭后需要重新执行 Setup 方法(C->S) MethodGetParameter = "GET_PARAMETER" // 获取参数;空body可作为心跳ping(C->S, S->C) MethodSetParameter = "SET_PARAMETER" // 设置参数,应该每次只设置一个参数(C->S, S->C) MethodRecord = "RECORD" // 启动录像(C->S) MethodRedirect = "REDIRECT" // 跳转(S->C) )
通用的 RTSP 方法。
除非特别说明,这些定义在 RFC2326 规范的 10 章中。 未实现的方法需要返回 "501 Not Implemented"
const ( StatusContinue = 100 //======Success 2xx StatusOK = 200 StatusCreated = 201 // only for RECORD StatusLowOnStorageSpace = 250 //only for RECORD //======Redirection 3xx StatusMultipleChoices = 300 StatusMovedPermanently = 301 StatusMovedTemporarily = 302 // 和http不同 StatusSeeOther = 303 StatusNotModified = 304 StatusUseProxy = 305 //======Client Error 4xx StatusBadRequest = 400 StatusPaymentRequired = 402 StatusForbidden = 403 StatusNotFound = 404 StatusMethodNotAllowed = 405 StatusNotAcceptable = 406 StatusProxyAuthRequired = 407 StatusRequestTimeout = 408 StatusGone = 410 StatusLengthRequired = 411 StatusPreconditionFailed = 412 // only for DESCRIBE, SETUP StatusRequestEntityTooLarge = 413 StatusRequestURITooLong = 414 StatusUnsupportedMediaType = 415 StatusInvalidParameter = 451 // only for SETUP StatusConferenceNotFound = 452 // only for SETUP StatusNotEnoughBandwidth = 453 // only for SETUP StatusSessionNotFound = 454 StatusMethodNotValidInThisState = 455 StatusHeaderFieldNotValid = 456 StatusInvalidRange = 457 // only for PLAY StatusParameterIsReadOnly = 458 // only for SET_PARAMETER StatusAggregateOpNotAllowed = 459 StatusOnlyAggregateOpAllowed = 460 StatusUnsupportedTransport = 461 StatusDestinationUnreachable = 462 StatusInternalServerError = 500 StatusNotImplemented = 501 StatusBadGateway = 502 StatusGatewayTimeout = 504 StatusRTSPVersionNotSupported = 505 StatusOptionNotSupported = 551 // 和 http 不同 )
RTSP 响应状态码. See: https://tools.ietf.org/html/rfc2326#page-19
Variables ¶
This section is empty.
Functions ¶
func FormatDigestAuthResponse ¶
FormatDigestAuthResponse response= md5(md5(username:realm:password):nonce:md5(public_method:url));
Types ¶
type Header ¶
Header 表示 RTSP 头部域键值对.
func (Header) Get ¶
Get 获取指定键的值,方法对键会做规范化处理(textproto.CanonicalMIMEHeaderKey) 如果没有值返回“”,如果存在返回第一个值 想访问多值,直接使用map方法.
type Request ¶
type Request struct { Method string // RTSP 的方法(OPTIONS、DESCRIBE...) URL *url.URL // 请求的 URI。 Proto string // 协议版本,默认 "RTSP/1.0" Header Header // 包含请求的头字段。 Body string // 请求的消息体。 }
Request 表示一个 RTSP 请求; 它可以是 sever 接收或发送的,也可以是 client 接收或发送的。
func ReadRequest ¶
ReadRequest 根据规范从 r 中读取 Request
func (*Request) BasicAuth ¶
BasicAuth returns the username and password provided in the request's Authorization header, if the request uses HTTP Basic Authentication. See RFC 2617, Section 2.
func (*Request) DigestAuth ¶
DigestAuth 获取摘要认证信息
func (*Request) SetBasicAuth ¶
SetBasicAuth sets the request's Authorization header to use HTTP Basic Authentication with the provided username and password.
With HTTP Basic Authentication the provided username and password are not encrypted.
func (*Request) SetDigestAuth ¶
SetDigestAuth 为请求设置数字认证
type Response ¶
type Response struct { Proto string // e.g. "RTSP/1.0" StatusCode int // e.g. 200 Status string // e.g. "200 OK" Header Header Body string Request *Request }
Response 表示 RTSP 请求的响应
func ReadResponse ¶
ReadResponse 根据规范从 r 中读取 Response
func (*Response) DigestAuth ¶
DigestAuth 获取摘要认证信息
func (*Response) SetBasicAuth ¶
SetBasicAuth 设置摘要认证安全请求
func (*Response) SetDigestAuth ¶
SetDigestAuth 设置摘要认证安全请求