github.com/cnotch/ipchub@v1.1.0/service/rtsp/types.go (about) 1 // Copyright (c) 2019,CAOHONGJU All rights reserved. 2 // Use of this source code is governed by a MIT-style 3 // license that can be found in the LICENSE file. 4 5 package rtsp 6 7 import ( 8 "github.com/cnotch/ipchub/av/format" 9 "github.com/cnotch/ipchub/av/format/rtp" 10 "github.com/cnotch/ipchub/av/format/rtsp" 11 ) 12 13 // Pack . 14 type Pack = format.Packet 15 16 // . 17 var ( 18 ReadPacket = rtp.ReadPacket 19 ReadResponse = rtsp.ReadResponse 20 ReadRequest = rtsp.ReadRequest 21 ) 22 23 // Request . 24 type Request = rtsp.Request 25 26 //Response . 27 type Response = rtsp.Response 28 29 // Header . 30 type Header = rtsp.Header 31 32 // RTPPack . 33 type RTPPack = rtp.Packet 34 35 const ( 36 rtpPackPrefix = rtp.TransferPrefix 37 rtspProto = "RTSP/1.0" // RTSP协议版本 38 rtspURLPrefix = "rtsp://" // RTSP地址前缀 39 basicAuthPrefix = "Basic " // 用户基础验证前缀 40 digestAuthPrefix = "Digest " // 摘要认证前缀 41 ) 42 43 // 预定义 RTP 包类型 44 const ( 45 ChannelVideo = rtp.ChannelVideo 46 ChannelVideoControl = rtp.ChannelVideoControl 47 ChannelAudio = rtp.ChannelAudio 48 ChannelAudioControl = rtp.ChannelAudioControl 49 rtpChannelCount = rtp.ChannelCount 50 rtpChannelMin = rtp.ChannelMin 51 ) 52 53 // 通用的 RTSP 方法。 54 // 55 // 除非特别说明,这些定义在 RFC2326 规范的 10 章中。 56 // 未实现的方法需要返回 "501 Not Implemented" 57 const ( 58 MethodOptions = rtsp.MethodOptions // 查询命令支持情况(C->S, S->C) 59 MethodDescribe = rtsp.MethodDescribe // 获取媒体信息(C->S) 60 MethodAnnounce = rtsp.MethodAnnounce // 声明要push的媒体信息(方向:C->S, S->C) 61 MethodSetup = rtsp.MethodSetup // 构建传输会话,也可以调整传输参数(C->S);如果不允许调整,可以返回 455 错误 62 MethodPlay = rtsp.MethodPlay // 开始发送媒体数据(C->S) 63 MethodPause = rtsp.MethodPause // 暂停发送媒体数据(C->S) 64 MethodTeardown = rtsp.MethodTeardown // 关闭发送通道;关闭后需要重新执行 Setup 方法(C->S) 65 MethodGetParameter = rtsp.MethodGetParameter // 获取参数;空body可作为心跳ping(C->S, S->C) 66 MethodSetParameter = rtsp.MethodSetParameter // 设置参数,应该每次只设置一个参数(C->S, S->C) 67 MethodRecord = rtsp.MethodRecord // 启动录像(C->S) 68 MethodRedirect = rtsp.MethodRedirect // 跳转(S->C) 69 ) 70 71 // RTSP 头部域定义 72 // type:support:methods 73 // type: "g"通用的请求头部;"R"请求头部;"r"响应头部;"e"实体Body头部域。 74 // support: opt. 可选; req. 必须 75 // methods: 头部域应用范围 76 const ( 77 FieldAccept = rtsp.FieldAccept // (R:opt.:entity) 78 FieldAcceptEncoding = rtsp.FieldAcceptEncoding // (R:opt.:entity) 79 FieldAcceptLanguage = rtsp.FieldAcceptLanguage // (R:opt.:all) 80 FieldAllow = rtsp.FieldAllow // (R:opt.:all) 81 FieldAuthorization = rtsp.FieldAuthorization // (R:opt.:all) 82 FieldBandwidth = rtsp.FieldBandwidth // (R:opt.all) 83 FieldBlocksize = rtsp.FieldBlocksize // (R:opt.:all but OPTIONS, TEARDOWN) 84 FieldCacheControl = rtsp.FieldCacheControl // (g:opt.:SETUP) 85 FieldConference = rtsp.FieldConference // (R:opt.:SETUP) 86 FieldConnection = rtsp.FieldConnection // (g:req.:all) 87 FieldContentBase = rtsp.FieldContentBase // (e:opt.:entity) 88 FieldContentEncoding = rtsp.FieldContentEncoding // (e:req.:SET_PARAMETER ; e:req.:DESCRIBE, ANNOUNCE ) 89 FieldContentLanguage = rtsp.FieldContentLanguage // (e:req.:DESCRIBE, ANNOUNCE) 90 FieldContentLength = rtsp.FieldContentLength // (e:req.:SET_PARAMETER, ANNOUNCE; e:req.:entity) 91 FieldContentLocation = rtsp.FieldContentLocation // (e:opt.:entity) 92 FieldContentType = rtsp.FieldContentType // (e:req.:SET_PARAMETER, ANNOUNCE; r:req.:entity ) 93 FieldCSeq = rtsp.FieldCSeq // (g:req.:all) 94 FieldDate = rtsp.FieldDate // (g:opt.:all) 95 FieldExpires = rtsp.FieldExpires // (e:opt.:DESCRIBE, ANNOUNCE) 96 FieldFrom = rtsp.FieldFrom // (R:opt.:all) 97 FieldIfModifiedSince = rtsp.FieldIfModifiedSince // (R:opt.:DESCRIBE, SETUP) 98 FieldLastModified = rtsp.FieldLastModified // (e:opt.:entity) 99 FieldProxyAuthenticate = rtsp.FieldProxyAuthenticate // 100 FieldProxyRequire = rtsp.FieldProxyRequire // (R:req.:all) 101 FieldPublic = rtsp.FieldPublic // (r:opt.:all) 102 FieldRange = rtsp.FieldRange // (R:opt.:PLAY, PAUSE, RECORD; r:opt.:PLAY, PAUSE, RECORD) 103 FieldReferer = rtsp.FieldReferer // (R:opt.:all) 104 FieldRequire = rtsp.FieldRequire // (R:req.:all) 105 FieldRetryAfter = rtsp.FieldRetryAfter // (r:opt.:all) 106 FieldRTPInfo = rtsp.FieldRTPInfo // (r:req.:PLAY) 107 FieldScale = rtsp.FieldScale // (Rr:opt.:PLAY, RECORD) 108 FieldSession = rtsp.FieldSession // (Rr:req.:all but SETUP, OPTIONS) 109 FieldServer = rtsp.FieldServer // (r:opt.:all) 110 FieldSpeed = rtsp.FieldSpeed // (Rr:opt.:PLAY) 111 FieldTransport = rtsp.FieldTransport // (Rr:req.:SETUP) 112 FieldUnsupported = rtsp.FieldUnsupported // (r:req.:all) 113 FieldUserAgent = rtsp.FieldUserAgent // (R:opt.:all) 114 FieldVia = rtsp.FieldVia // (g:opt.:all) 115 FieldWWWAuthenticate = rtsp.FieldWWWAuthenticate // (r:opt.:all) 116 ) 117 118 // RTSP 响应状态码. 119 // See: https://tools.ietf.org/html/rfc2326#page-19 120 const ( 121 StatusContinue = rtsp.StatusContinue 122 123 //======Success 2xx 124 StatusOK = rtsp.StatusOK 125 StatusCreated = rtsp.StatusCreated // only for RECORD 126 StatusLowOnStorageSpace = rtsp.StatusLowOnStorageSpace //only for RECORD 127 128 //======Redirection 3xx 129 StatusMultipleChoices = rtsp.StatusMultipleChoices 130 StatusMovedPermanently = rtsp.StatusMovedPermanently 131 StatusMovedTemporarily = rtsp.StatusMovedTemporarily // 和http不同 132 StatusSeeOther = rtsp.StatusSeeOther 133 StatusNotModified = rtsp.StatusNotModified 134 StatusUseProxy = rtsp.StatusUseProxy 135 136 //======Client Error 4xx 137 StatusBadRequest = rtsp.StatusBadRequest 138 StatusUnauthorized = rtsp.StatusUnauthorized 139 StatusPaymentRequired = rtsp.StatusPaymentRequired 140 StatusForbidden = rtsp.StatusForbidden 141 StatusNotFound = rtsp.StatusNotFound 142 StatusMethodNotAllowed = rtsp.StatusMethodNotAllowed 143 StatusNotAcceptable = rtsp.StatusNotAcceptable 144 StatusProxyAuthRequired = rtsp.StatusProxyAuthRequired 145 StatusRequestTimeout = rtsp.StatusRequestTimeout 146 StatusGone = rtsp.StatusGone 147 StatusLengthRequired = rtsp.StatusLengthRequired 148 StatusPreconditionFailed = rtsp.StatusPreconditionFailed // only for DESCRIBE, SETUP 149 StatusRequestEntityTooLarge = rtsp.StatusRequestEntityTooLarge 150 StatusRequestURITooLong = rtsp.StatusRequestURITooLong 151 StatusUnsupportedMediaType = rtsp.StatusUnsupportedMediaType 152 StatusInvalidParameter = rtsp.StatusInvalidParameter // only for SETUP 153 StatusConferenceNotFound = rtsp.StatusConferenceNotFound // only for SETUP 154 StatusNotEnoughBandwidth = rtsp.StatusNotEnoughBandwidth // only for SETUP 155 StatusSessionNotFound = rtsp.StatusSessionNotFound 156 StatusMethodNotValidInThisState = rtsp.StatusMethodNotValidInThisState 157 StatusHeaderFieldNotValid = rtsp.StatusHeaderFieldNotValid 158 StatusInvalidRange = rtsp.StatusInvalidRange // only for PLAY 159 StatusParameterIsReadOnly = rtsp.StatusParameterIsReadOnly // only for SET_PARAMETER 160 StatusAggregateOpNotAllowed = rtsp.StatusAggregateOpNotAllowed 161 StatusOnlyAggregateOpAllowed = rtsp.StatusOnlyAggregateOpAllowed 162 StatusUnsupportedTransport = rtsp.StatusUnsupportedTransport 163 StatusDestinationUnreachable = rtsp.StatusDestinationUnreachable 164 165 StatusInternalServerError = rtsp.StatusInternalServerError 166 StatusNotImplemented = rtsp.StatusNotImplemented 167 StatusBadGateway = rtsp.StatusBadGateway 168 StatusServiceUnavailable = rtsp.StatusServiceUnavailable 169 StatusGatewayTimeout = rtsp.StatusGatewayTimeout 170 StatusRTSPVersionNotSupported = rtsp.StatusRTSPVersionNotSupported 171 StatusOptionNotSupported = rtsp.StatusOptionNotSupported // 和 http 不同 172 ) 173 174 // StatusText . 175 var StatusText = rtsp.StatusText 176 var formatDigestAuthResponse = rtsp.FormatDigestAuthResponse