This commit is contained in:
Lukas Herman
2020-11-04 05:43:40 +00:00
parent 9d98eb8aaf
commit 18b81bfba6
5 changed files with 15 additions and 5 deletions

View File

@@ -9,7 +9,7 @@ import (
"github.com/pion/mediadevices/pkg/io/audio" "github.com/pion/mediadevices/pkg/io/audio"
"github.com/pion/mediadevices/pkg/io/video" "github.com/pion/mediadevices/pkg/io/video"
"github.com/pion/mediadevices/pkg/prop" "github.com/pion/mediadevices/pkg/prop"
"github.com/pion/webrtc/v2" "github.com/pion/webrtc/v3"
) )
// CodecSelector is a container of video and audio encoder builders, which later will be used // CodecSelector is a container of video and audio encoder builders, which later will be used

View File

@@ -75,8 +75,18 @@ func main() {
log.Fatalf("Error unpacking the cascade file: %s", err) log.Fatalf("Error unpacking the cascade file: %s", err)
} }
devices := mediadevices.EnumerateDevices()
deviceID := ""
for _, device := range devices {
if device.Label == "video0" {
deviceID = device.DeviceID
}
}
mediaStream, err := mediadevices.GetUserMedia(mediadevices.MediaStreamConstraints{ mediaStream, err := mediadevices.GetUserMedia(mediadevices.MediaStreamConstraints{
Video: func(c *mediadevices.MediaTrackConstraints) { Video: func(c *mediadevices.MediaTrackConstraints) {
c.DeviceID = prop.StringExact(deviceID)
c.FrameFormat = prop.FrameFormatExact(frame.FormatUYVY) c.FrameFormat = prop.FrameFormatExact(frame.FormatUYVY)
c.Width = prop.Int(640) c.Width = prop.Int(640)
c.Height = prop.Int(480) c.Height = prop.Int(480)

View File

@@ -7,7 +7,7 @@ import (
"github.com/pion/mediadevices/examples/internal/signal" "github.com/pion/mediadevices/examples/internal/signal"
"github.com/pion/mediadevices/pkg/frame" "github.com/pion/mediadevices/pkg/frame"
"github.com/pion/mediadevices/pkg/prop" "github.com/pion/mediadevices/pkg/prop"
"github.com/pion/webrtc/v2" "github.com/pion/webrtc/v3"
// If you don't like x264, you can also use vpx by importing as below // If you don't like x264, you can also use vpx by importing as below
// "github.com/pion/mediadevices/pkg/codec/vpx" // This is required to use VP8/VP9 video encoder // "github.com/pion/mediadevices/pkg/codec/vpx" // This is required to use VP8/VP9 video encoder

View File

@@ -4,7 +4,7 @@ import (
"github.com/pion/mediadevices/pkg/io/audio" "github.com/pion/mediadevices/pkg/io/audio"
"github.com/pion/mediadevices/pkg/io/video" "github.com/pion/mediadevices/pkg/io/video"
"github.com/pion/mediadevices/pkg/prop" "github.com/pion/mediadevices/pkg/prop"
"github.com/pion/webrtc/v2" "github.com/pion/webrtc/v3"
) )
// RTPCodec wraps webrtc.RTPCodec. RTPCodec might extend webrtc.RTPCodec in the future. // RTPCodec wraps webrtc.RTPCodec. RTPCodec might extend webrtc.RTPCodec in the future.

View File

@@ -12,8 +12,8 @@ import (
"github.com/pion/mediadevices/pkg/io/video" "github.com/pion/mediadevices/pkg/io/video"
"github.com/pion/mediadevices/pkg/wave" "github.com/pion/mediadevices/pkg/wave"
"github.com/pion/rtp" "github.com/pion/rtp"
"github.com/pion/webrtc/v2" "github.com/pion/webrtc/v3"
"github.com/pion/webrtc/v2/pkg/media" "github.com/pion/webrtc/v3/pkg/media"
) )
var ( var (