WebRTC - 在通信过程中更改视频流 [英] WebRTC - change video stream in the middle of communication

查看:31
本文介绍了WebRTC - 在通信过程中更改视频流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是使用 webrtc 网络应用程序在视频或音频通话中启用屏幕共享.

My goal is to enable screen sharing in the middle of a video or audio call using webrtc web application .

好吧,我发现我可以使用 MediaStreamTrack.applyConstraints() 来更改视频属性,但是否可以更改视频源?进一步了解如何将视频添加到现有音频流中.

Well I found that I can use MediaStreamTrack.applyConstraints() to change video property but is it possible to change the video source ? further more how can I add video to an existing audio stream .

我现在只需要它在 chrome 上工作.

I need this to work on chrome only for now .

推荐答案

localStream.stop();
peerconnection.removeStream(localStream);

我能够通过以下步骤找到解决方案

I was able to find the solution by following steps

  1. 删除当前流

添加新流

创建新优惠

请注意,removeStream 已弃用且不再包含在规范中,并且并未在所有浏览器中实现.例如.这在 Firefox 中不起作用.stream.stop() 也被弃用,取而代之的是 stream.getTracks().forEach(track => track.stop())

Note that removeStream is deprecated and no longer in the spec, and not implemented in all browsers. E.g. this won't work in Firefox. stream.stop() is also deprecated in favor of stream.getTracks().forEach(track => track.stop())

这篇关于WebRTC - 在通信过程中更改视频流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆