m1k1o / neko

A self hosted virtual browser that runs in docker and uses WebRTC.
https://neko.m1k1o.net/
Apache License 2.0
5.96k stars 449 forks source link

Dependencies update #241

Closed mbattista closed 1 year ago

mbattista commented 1 year ago

Hi,

I am very sorry about the style of this pull request, since it has a lot of changes and should probably be 3 separated requests.

Changes:

m1k1o commented 1 year ago

Hi, happy to see you contributing again! Don't worry about that.

I am glad that we are going away from go-events, because they had some issue that affected neko as well and they did not merge my fix until this day.

I am concerned about the samples channel, since there can be multiple users that need to receive copy of the sample, it cannot be done from a single channel. We would need to to channel multiplexing for listeners. Have you tried it with multiple users? I'll build it and test it myself, when I get the chance.

mbattista commented 1 year ago

I am concerned about the samples channel, since there can be multiple users that need to receive copy of the sample, it cannot be done from a single channel.

You are right. While it works with two viewers (thats what I tried), it should have a fan out for the samples. I will change that.

mbattista commented 1 year ago

While looking at the code, I realized that pion will duplicate the track for each listener. So no changes needed, since the samples are written to the track.

m1k1o commented 1 year ago

max_fps=0 was actually meant to use the FPS from the screen size. Therefore I would say, it should do what your implemented adaptiveFramerate is meant to do. Because having them both can lead to edge cases / confusion:

With only max_fps it would be:

I agree that current implementation of max_fps is rather fps where current value is used regardless of what is in the pipeline.

TODO:

go func() {
    for {
        val, ok := <-someChannel
        if !ok {
            // channel closed
            break
        }

        // do something with val
    }
}()
m1k1o commented 1 year ago

image

Do you have any idea why I cannot install the packages? Did you face similar issue?

mbattista commented 1 year ago

image

Do you have any idea why I cannot install the packages? Did you face similar issue?

No. It just went through.

Screenshot_2023-01-29_13-27-01

mbattista commented 1 year ago
m1k1o commented 1 year ago

No. It just went through.

Screenshot_2023-01-29_13-27-01

Interestingly it does not work on my ubuntu 20.04 but works on debian. Weird.

Should we remove the unused channels for now?

I'd say, some of them that are redundant should be removed. But some of them are actually already prepared for furute features.

mbattista commented 1 year ago

Removed the wait timer in the webrtc function and create the channel in the manager.

m1k1o commented 1 year ago

Those latest changes fail with panic when changing screen size, because GST closes that channel.

I have been thinking about how it could be scoped.

So maybe if we had channel in streamsink that notifies capture about when pipeline starts, it could create goroutine that starts reading from it until the pipeline channel is closed. E.G. additional GetPipelineChannel() chan struct{} that fires when pipeline is available.

Or something like channel that returns sample channel once it has been created. chan chan types.Sample though it might seem ugly, but thats what I logically concluded.

mbattista commented 1 year ago

Sorry, my testing were on the wrong commit.

It panics, because the channel is closed and it tries to write into a closed channel. The channel should never close after it is created, since it will always be needed. With this change the panic is gone.

The only thing that could be done, to be more futureproof, is to make it a map of channels on the manager, so e.g. different bandwidths can be done per different map entries.

m1k1o commented 1 year ago

I moved sample channel to AttachAppsink, because you can create pipelines (like broadcast) that do not need channel for samples. It is only added when we are attaching appsink.

m1k1o commented 1 year ago

It looks good from my side, this can be merged if you do not have any objections or pending changes.

mbattista commented 1 year ago

No objections from my side either.