-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_list_cameras.go
More file actions
39 lines (32 loc) · 939 Bytes
/
test_list_cameras.go
File metadata and controls
39 lines (32 loc) · 939 Bytes
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
package main
import (
"fmt"
"log"
"github.com/pion/mediadevices"
_ "github.com/pion/mediadevices/pkg/driver/camera"
)
func main() {
log.Println("Enumerating available media devices...")
devices := mediadevices.EnumerateDevices()
fmt.Println("\n========== AVAILABLE CAMERAS ==========")
cameraCount := 0
for _, device := range devices {
if device.Kind == mediadevices.VideoInput {
cameraCount++
fmt.Printf("\nCamera %d:\n", cameraCount)
fmt.Printf(" Device ID: %s\n", device.DeviceID)
fmt.Printf(" Label: %s\n", device.Label)
fmt.Printf(" Kind: %s\n", device.Kind)
}
}
if cameraCount == 0 {
fmt.Println("No cameras found!")
} else {
fmt.Printf("\nTotal cameras found: %d\n", cameraCount)
}
fmt.Println("\n========== ALL DEVICES ==========")
for i, device := range devices {
fmt.Printf("%d. ID: %s | Label: %s | Kind: %s\n",
i+1, device.DeviceID, device.Label, device.Kind)
}
}