@@ -109,10 +109,7 @@ func (c *Camera) SaveVideo(ops *VidOps, length time.Duration, maxsize int64, out
109
109
// StreamMJPG makes a web request to retrieve a motion JPEG stream.
110
110
// Returns an io.ReadCloser that will (hopefully) never end.
111
111
func (c * Camera ) StreamMJPG (ops * VidOps ) (io.ReadCloser , error ) {
112
- ctx , cancel := context .WithTimeout (context .Background (), c .server .config .Timeout )
113
- defer cancel ()
114
-
115
- resp , err := c .server .GetContext (ctx , "++video" , c .makeRequestParams (ops ))
112
+ resp , err := c .server .Get ("++video" , c .makeRequestParams (ops ))
116
113
if err != nil {
117
114
return nil , fmt .Errorf ("getting video: %w" , err )
118
115
}
@@ -123,10 +120,7 @@ func (c *Camera) StreamMJPG(ops *VidOps) (io.ReadCloser, error) {
123
120
// StreamH264 makes a web request to retrieve an H264 stream.
124
121
// Returns an io.ReadCloser that will (hopefully) never end.
125
122
func (c * Camera ) StreamH264 (ops * VidOps ) (io.ReadCloser , error ) {
126
- ctx , cancel := context .WithTimeout (context .Background (), c .server .config .Timeout )
127
- defer cancel ()
128
-
129
- resp , err := c .server .GetContext (ctx , "++stream" , c .makeRequestParams (ops ))
123
+ resp , err := c .server .Get ("++stream" , c .makeRequestParams (ops ))
130
124
if err != nil {
131
125
return nil , fmt .Errorf ("getting stream: %w" , err )
132
126
}
@@ -137,10 +131,7 @@ func (c *Camera) StreamH264(ops *VidOps) (io.ReadCloser, error) {
137
131
// StreamG711 makes a web request to retrieve an G711 audio stream.
138
132
// Returns an io.ReadCloser that will (hopefully) never end.
139
133
func (c * Camera ) StreamG711 () (io.ReadCloser , error ) {
140
- ctx , cancel := context .WithTimeout (context .Background (), c .server .config .Timeout )
141
- defer cancel ()
142
-
143
- resp , err := c .server .GetContext (ctx , "++audio" , c .makeRequestParams (nil ))
134
+ resp , err := c .server .Get ("++audio" , c .makeRequestParams (nil ))
144
135
if err != nil {
145
136
return nil , fmt .Errorf ("getting audio: %w" , err )
146
137
}
@@ -169,7 +160,7 @@ func (c *Camera) PostG711(audio io.ReadCloser) ([]byte, error) {
169
160
func (c * Camera ) GetJPEG (ops * VidOps ) (image.Image , error ) {
170
161
ops .FPS = - 1 // not used for single image
171
162
172
- ctx , cancel := context .WithTimeout (context .Background (), c .server .config . Timeout )
163
+ ctx , cancel := context .WithTimeout (context .Background (), c .server .TimeoutDur () )
173
164
defer cancel ()
174
165
175
166
resp , err := c .server .GetContext (ctx , "++image" , c .makeRequestParams (ops ))
0 commit comments