-
-
Notifications
You must be signed in to change notification settings - Fork 577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update to pion v3 #21
Conversation
Hey, thanks! This looks very good. Let me try it out, do some light review and then I guess, we can merge it. For the |
Why is here being created another data channel, if right under is triggered event, that fetches data channel from user? In that case, user doesn't need to create own channel here. Right now, two data channels are created but only one is being used? Do I understand it right? I'd suggest to add This could be then simpified as this: dataChannel, err := connection.CreateDataChannel("data", &webrtc.DataChannelInit{
Negotiated: &negotiated,
})
if err != nil {
return "", manager.config.ICELite, manager.config.ICEServers, viderr
}
dataChannel.OnMessage(func(msg webrtc.DataChannelMessage) {
if err = manager.handle(id, msg); err != nil {
manager.logger.Warn().Err(err).Msg("data handle failed")
}
}) |
https://github.com/pion/webrtc/wiki/[email protected] Without the creation of the standard DataChannel Remote Control has not worked for me. |
That should be fine on server side, where data channel would be created. Client would just wait for a channel, not creating one. I'm going to try to implement it that way. |
This would be my proposal: diff --git a/client/src/neko/base.ts b/client/src/neko/base.ts
index 9128af4..ec5ea26 100644
--- a/client/src/neko/base.ts
+++ b/client/src/neko/base.ts
@@ -142,8 +142,8 @@ export abstract class BaseClient extends EventEmitter<BaseEvents> {
}
// @ts-ignore
- if (typeof buffer !== 'undefined') {
- this._channel!.send(buffer)
+ if (typeof buffer !== 'undefined' && typeof this._channel != 'undefined') {
+ this._channel.send(buffer)
}
}
@@ -211,14 +211,10 @@ export abstract class BaseClient extends EventEmitter<BaseEvents> {
}
this._peer.ontrack = this.onTrack.bind(this)
+ this._peer.ondatachannel = this.onDataChannel.bind(this)
this._peer.addTransceiver('audio', { direction: 'recvonly' })
this._peer.addTransceiver('video', { direction: 'recvonly' })
- this._channel = this._peer.createDataChannel('data')
- this._channel.onerror = this.onError.bind(this)
- this._channel.onmessage = this.onData.bind(this)
- this._channel.onclose = this.onDisconnected.bind(this, new Error('peer data channel closed'))
-
this._peer.setRemoteDescription({ type: 'offer', sdp })
this._peer
.createAnswer()
@@ -279,6 +275,15 @@ export abstract class BaseClient extends EventEmitter<BaseEvents> {
this[EVENT.TRACK](event)
}
+ private onDataChannel(event: RTCDataChannelEvent) {
+ this.emit('debug', `received datachannel from peer`, event)
+
+ this._channel = event.channel
+ this._channel.onerror = this.onError.bind(this)
+ this._channel.onmessage = this.onData.bind(this)
+ this._channel.onclose = this.onDisconnected.bind(this, new Error('peer data channel closed'))
+ }
+
private onError(event: Event) {
this.emit('error', (event as ErrorEvent).error)
}
diff --git a/server/internal/webrtc/webrtc.go b/server/internal/webrtc/webrtc.go
index 2fd4e7f..10b1b45 100644
--- a/server/internal/webrtc/webrtc.go
+++ b/server/internal/webrtc/webrtc.go
@@ -120,16 +120,16 @@ func (manager *WebRTCManager) CreatePeer(id string, session types.Session) (stri
if err != nil {
return "", manager.config.ICELite, manager.config.ICEServers, err
}
- negotiated := true
- connection.CreateDataChannel("data", &webrtc.DataChannelInit{
- Negotiated: &negotiated,
- })
- connection.OnDataChannel(func(d *webrtc.DataChannel) {
- d.OnMessage(func(msg webrtc.DataChannelMessage) {
- if err = manager.handle(id, msg); err != nil {
- manager.logger.Warn().Err(err).Msg("data handle failed")
- }
- })
+
+ dataChannel, err := connection.CreateDataChannel("data", nil)
+ if err != nil {
+ return "", manager.config.ICELite, manager.config.ICEServers, err
+ }
+
+ dataChannel.OnMessage(func(msg webrtc.DataChannelMessage) {
+ if err = manager.handle(id, msg); err != nil {
+ manager.logger.Warn().Err(err).Msg("data handle failed")
+ }
})
// Set the handler for ICE connection state But i just found out, that your solution with |
Uuug, good find. I will look after this later this night. |
I'll make just slight modification. E.G. |
…ith no additional parameters
After going though the test of pion/interceptor#4 again, I saw that this already has the buffer and should theoretically resend the packages on nack (https://github.com/pion/interceptor/blob/master/pkg/nack/responder_interceptor.go#L67 ). So I removed all code which had to do with nacks. But I found another bug, which should be addressed and perhaps you have some idea how to change it. The lags (which are the main bug I tried to fix) are still persistent even with the nack interveptor. Perhaps the bug is somewhere in pion webrtc, since I can reproduce it in https://github.com/GRVYDEV/Project-Lightspeed. Can you check if the the last commit fixed the ICERestart problem or if there also has to be changes in the frontend? |
Great. Less code == less bugs. Maybe Without restarting the pipeline, i don't think it is posibble. But it could be restarted in the same way, as as it is restarted for screen size change. And getting those fps from screen configuration. With that I will look into this tomorrow, how can this problem be adressed. I observed those minor lags, but I thought, it is just causing my internet connection. But when you say, ther those lags are same for everyone, then the cause can be rooted somewhere deep in pion implementation. |
This reverts commit 646e8af.
In fact, it is even simpler. Because those pipelines are already restarting on screen size change. Meaning, we can just pass fps directly to the pipeline and it should work. |
Hopefully WebRTC timeouts fixed that problem. It is not reproducible for me. Merging this PR. |
Thanks for cleaning up and improving the PR this much. I will try to tackle the lags again and make another PR if I find a solution. |
* fix page for mobile - minor changes. * fix textarea overlay to hide caret and avodi zooming on mobiles. * fix typo. * show keyboard btn if is touch device. * lint fix. * add to API. * mobile keybaord fix andorid blur. * add mobile keybaord toggle. * fix overlay. * mobile keybaord, skip if not a touch device.
Hi,
another pull request.
This time an update to pion v3.
While the Update is complete and could be merged already, I want to integrate some kind of "Nack" handling hoping this will fix nurdism/neko#48
Let me know if i should do this in a different pull request or if this can be done in the same one.
Nonetheless setting a bitrate for h264 made the webrtc stream less 'jumpy' which lead to less lossage of udp packages, which lead to a less laggy stream over the internet (on a local network all is smooth)
I didnt bump the version in this pull request. If you think, this should be a higher version, let me know.