pion / mediadevices

Go implementation of the MediaDevices API.
https://pion.ly/
MIT License
521 stars 120 forks source link

Multiple display for webcam device #510

Closed SouL-H closed 8 months ago

SouL-H commented 1 year ago

Your environment.

What did you do?

I wanted to display the webcam camera image connected to my computer on an html page.

What did you expect?

I wanted to display the webcam image on the html page and completed it successfully. But things started when I made a request to the same link from a different tab.

What happened?

When I made a second request I got an "invalid state: driver is already opened" error.

Here is the code where I got the error;

    mediaStream, err := mediadevices.GetUserMedia(mediadevices.MediaStreamConstraints{
        Video: func(constraint *mediadevices.MediaTrackConstraints) {
            constraint.Width = prop.Int(600)
            constraint.Height = prop.Int(400)
        },
    })
    if err != nil {
        panic(err)
    }

Is there a function available for multiviewing or how can I solve this error?

bazile-clyde commented 11 months ago

Are you asking if you can open a device and stream images in two separate processes? Linux only allows one process to open and use a device driver at a time. There are exceptions: you can query a driver's device capabilities while another process is streaming images from that same driver. But you can not stream from two separate processes.

bazile-clyde commented 8 months ago

@SouL-H Closing for now. Feel free to reopen if this is still an issue or if I misread your question.