Change ListSizes function for V4L2 device

This commit is contained in:
Alex X
2025-01-07 22:17:35 +03:00
parent e4b8d1807d
commit 93252fc5d2
2 changed files with 6 additions and 6 deletions
+3 -3
View File
@@ -58,9 +58,9 @@ func apiV4L2(w http.ResponseWriter, r *http.Request) {
if source.Name != "" {
sizes, _ := dev.ListSizes(fourCC)
for i := 0; i < len(sizes); i += 2 {
size := fmt.Sprintf("%dx%d", sizes[i], sizes[i+1])
if i > 0 {
for _, wh := range sizes {
size := fmt.Sprintf("%dx%d", wh[0], wh[1])
if source.Info != "" {
source.Info += " " + size
} else {
source.Info = size
+3 -3
View File
@@ -66,8 +66,8 @@ func (d *Device) ListFormats() ([]uint32, error) {
return items, nil
}
func (d *Device) ListSizes(pixFmt uint32) ([]uint32, error) {
var items []uint32
func (d *Device) ListSizes(pixFmt uint32) ([][2]uint32, error) {
var items [][2]uint32
for i := uint32(0); ; i++ {
fs := v4l2_frmsizeenum{
@@ -85,7 +85,7 @@ func (d *Device) ListSizes(pixFmt uint32) ([]uint32, error) {
continue
}
items = append(items, fs.discrete.width, fs.discrete.height)
items = append(items, [2]uint32{fs.discrete.width, fs.discrete.height})
}
return items, nil