forked from bluenviron/gortsplib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverhandler.go
213 lines (179 loc) · 5.71 KB
/
serverhandler.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
package gortsplib
import (
"time"
"github.com/pion/rtcp"
"github.com/pion/rtp"
"github.com/cobalt-robotics/gortsplib/pkg/base"
)
// ServerHandler is the interface implemented by all the server handlers.
type ServerHandler interface{}
// ServerHandlerOnConnOpenCtx is the context of a connection opening.
type ServerHandlerOnConnOpenCtx struct {
Conn *ServerConn
}
// ServerHandlerOnConnOpen can be implemented by a ServerHandler.
type ServerHandlerOnConnOpen interface {
OnConnOpen(*ServerHandlerOnConnOpenCtx)
}
// ServerHandlerOnConnCloseCtx is the context of a connection closure.
type ServerHandlerOnConnCloseCtx struct {
Conn *ServerConn
Error error
}
// ServerHandlerOnConnClose can be implemented by a ServerHandler.
type ServerHandlerOnConnClose interface {
OnConnClose(*ServerHandlerOnConnCloseCtx)
}
// ServerHandlerOnSessionOpenCtx is the context of a session opening.
type ServerHandlerOnSessionOpenCtx struct {
Session *ServerSession
Conn *ServerConn
}
// ServerHandlerOnSessionOpen can be implemented by a ServerHandler.
type ServerHandlerOnSessionOpen interface {
OnSessionOpen(*ServerHandlerOnSessionOpenCtx)
}
// ServerHandlerOnSessionCloseCtx is the context of a session closure.
type ServerHandlerOnSessionCloseCtx struct {
Session *ServerSession
Error error
}
// ServerHandlerOnSessionClose can be implemented by a ServerHandler.
type ServerHandlerOnSessionClose interface {
OnSessionClose(*ServerHandlerOnSessionCloseCtx)
}
// ServerHandlerOnRequest can be implemented by a ServerHandler.
type ServerHandlerOnRequest interface {
OnRequest(*ServerConn, *base.Request)
}
// ServerHandlerOnResponse can be implemented by a ServerHandler.
type ServerHandlerOnResponse interface {
OnResponse(*ServerConn, *base.Response)
}
// ServerHandlerOnDescribeCtx is the context of a DESCRIBE request.
type ServerHandlerOnDescribeCtx struct {
Conn *ServerConn
Request *base.Request
Path string
Query string
}
// ServerHandlerOnDescribe can be implemented by a ServerHandler.
type ServerHandlerOnDescribe interface {
OnDescribe(*ServerHandlerOnDescribeCtx) (*base.Response, *ServerStream, error)
}
// ServerHandlerOnAnnounceCtx is the context of an ANNOUNCE request.
type ServerHandlerOnAnnounceCtx struct {
Server *Server
Session *ServerSession
Conn *ServerConn
Request *base.Request
Path string
Query string
Tracks Tracks
}
// ServerHandlerOnAnnounce can be implemented by a ServerHandler.
type ServerHandlerOnAnnounce interface {
OnAnnounce(*ServerHandlerOnAnnounceCtx) (*base.Response, error)
}
// ServerHandlerOnSetupCtx is the context of a OPTIONS request.
type ServerHandlerOnSetupCtx struct {
Server *Server
Session *ServerSession
Conn *ServerConn
Request *base.Request
Path string
Query string
TrackID int
Transport Transport
}
// ServerHandlerOnSetup can be implemented by a ServerHandler.
type ServerHandlerOnSetup interface {
// must return a Response and a stream.
// the stream is needed to
// - add the session the the stream's readers
// - send the stream SSRC to the session
OnSetup(*ServerHandlerOnSetupCtx) (*base.Response, *ServerStream, error)
}
// ServerHandlerOnPlayCtx is the context of a PLAY request.
type ServerHandlerOnPlayCtx struct {
Session *ServerSession
Conn *ServerConn
Request *base.Request
Path string
Query string
}
// ServerHandlerOnPlay can be implemented by a ServerHandler.
type ServerHandlerOnPlay interface {
OnPlay(*ServerHandlerOnPlayCtx) (*base.Response, error)
}
// ServerHandlerOnRecordCtx is the context of a RECORD request.
type ServerHandlerOnRecordCtx struct {
Session *ServerSession
Conn *ServerConn
Request *base.Request
Path string
Query string
}
// ServerHandlerOnRecord can be implemented by a ServerHandler.
type ServerHandlerOnRecord interface {
OnRecord(*ServerHandlerOnRecordCtx) (*base.Response, error)
}
// ServerHandlerOnPauseCtx is the context of a PAUSE request.
type ServerHandlerOnPauseCtx struct {
Session *ServerSession
Conn *ServerConn
Request *base.Request
Path string
Query string
}
// ServerHandlerOnPause can be implemented by a ServerHandler.
type ServerHandlerOnPause interface {
OnPause(*ServerHandlerOnPauseCtx) (*base.Response, error)
}
// ServerHandlerOnGetParameterCtx is the context of a GET_PARAMETER request.
type ServerHandlerOnGetParameterCtx struct {
Session *ServerSession
Conn *ServerConn
Request *base.Request
Path string
Query string
}
// ServerHandlerOnGetParameter can be implemented by a ServerHandler.
type ServerHandlerOnGetParameter interface {
OnGetParameter(*ServerHandlerOnGetParameterCtx) (*base.Response, error)
}
// ServerHandlerOnSetParameterCtx is the context of a SET_PARAMETER request.
type ServerHandlerOnSetParameterCtx struct {
Session *ServerSession
Conn *ServerConn
Request *base.Request
Path string
Query string
}
// ServerHandlerOnSetParameter can be implemented by a ServerHandler.
type ServerHandlerOnSetParameter interface {
OnSetParameter(*ServerHandlerOnSetParameterCtx) (*base.Response, error)
}
// ServerHandlerOnPacketRTPCtx is the context of a RTP packet.
type ServerHandlerOnPacketRTPCtx struct {
Session *ServerSession
TrackID int
Packet *rtp.Packet
PTSEqualsDTS bool
H264NALUs [][]byte
H264PTS time.Duration
}
// ServerHandlerOnPacketRTP can be implemented by a ServerHandler.
type ServerHandlerOnPacketRTP interface {
OnPacketRTP(*ServerHandlerOnPacketRTPCtx)
}
// ServerHandlerOnPacketRTCPCtx is the context of a RTCP packet.
type ServerHandlerOnPacketRTCPCtx struct {
Session *ServerSession
TrackID int
Packet rtcp.Packet
}
// ServerHandlerOnPacketRTCP can be implemented by a ServerHandler.
type ServerHandlerOnPacketRTCP interface {
OnPacketRTCP(*ServerHandlerOnPacketRTCPCtx)
}