Skip to content
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

addTrack to peer connection #49

Open
Weedshaker opened this issue Aug 18, 2022 · 0 comments
Open

addTrack to peer connection #49

Weedshaker opened this issue Aug 18, 2022 · 0 comments

Comments

@Weedshaker
Copy link

Hello,

I read the comment on Issue: #29 and then tried to add a video track to the connection analog the description from here: https://webrtc.org/getting-started/remote-streams . The first issue was to get the peerConnection, which I managed to do with a hook at:

this._pc = new (this._wrtc.RTCPeerConnection)(this.config)

else I could only grab the peerConnection at:

p2pt.on('peerconnect', peer => peer._pc)

which according to the https://webrtc.org/getting-started/remote-streams here would be too late but I am not certain. Anyhow, in a further step I add the video and audio tracks:

p2pt.on('track', event => console.log('p2ptTrack', event))
pc.addEventListener('track', event => console.log('pcTrack', event))
// https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia
navigator.mediaDevices.getUserMedia({
audio: true, // We want an audio track
video: true // And we want a video track
}) .then(localStream => {
// https://webrtc.org/getting-started/remote-streams
localStream.getTracks().forEach(track => pc.addTrack(track, localStream))
})

I was not able to get any 'track' event. Even when I did overwrite or hook within:

this._pc.ontrack = event => { this._onTrack(event) }

Does anyone have a solution for this problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant