playback: make 'format' parameter optional (#2980)

This commit is contained in:
Alessandro Ros 2024-02-03 16:11:09 +01:00 committed by GitHub
parent de9a456e98
commit 695e327a03
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 6 deletions

View File

@ -1224,7 +1224,7 @@ Where [mypath] is the name of a path. The server will return a list of timespans
The server provides an endpoint for downloading recordings:
```
http://localhost:9996/get?path=[mypath]&start=[start_date]&duration=[duration]&format=[format]
http://localhost:9996/get?path=[mypath]&start=[start_date]&duration=[duration]
```
Where:
@ -1232,19 +1232,18 @@ Where:
* [mypath] is the path name
* [start_date] is the start date in RFC3339 format
* [duration] is the maximum duration of the recording in seconds
* [format] must be fmp4
All parameters must be [url-encoded](https://www.urlencoder.org/). For instance:
```
http://localhost:9996/get?path=stream2&start=2024-01-14T16%3A33%3A17%2B00%3A00&duration=200.5&format=fmp4
http://localhost:9996/get?path=stream2&start=2024-01-14T16%3A33%3A17%2B00%3A00&duration=200.5
```
The resulting stream is natively compatible with any browser, therefore its URL can be directly inserted into a \<video> tag:
The resulting stream uses the fMP4 format, that is natively compatible with any browser, therefore its URL can be directly inserted into a \<video> tag:
```html
<video controls>
<source src="http://localhost:9996/get?path=[mypath]&start=[start_date]&duration=[duration]&format=[format]" type="video/mp4" />
<source src="http://localhost:9996/get?path=[mypath]&start=[start_date]&duration=[duration]" type="video/mp4" />
</video>
```

View File

@ -190,7 +190,7 @@ func (p *Server) onGet(ctx *gin.Context) {
}
format := ctx.Query("format")
if format != "fmp4" {
if format != "" && format != "fmp4" {
p.writeError(ctx, http.StatusBadRequest, fmt.Errorf("invalid format: %s", format))
return
}