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

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

问题描述

我的目标是使用webrtc Web应用程序在视频或音频通话过程中实现屏幕共享.

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天全站免登陆