WebRTC-如何为MediaStream(Tracks)标识源ID(设备ID) [英] WebRTC - How to identify the source IDs (device IDs) for a MediaStream(Tracks)

查看:126
本文介绍了WebRTC-如何为MediaStream(Tracks)标识源ID(设备ID)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

建立WebRTC连接后,就可以 getLocalStreams getRemoteStreams .

流具有自己的ID.每个流都是由 MediaStreamTrack 的音频/视频轨道组成.

我希望能够标识用于每个轨道的设备/源(ID),以避免添加已添加到连接中的流.

换句话说,我正在考虑检查 connection.onaddstream 中是否在我的本地或远程流列表中没有流跟踪.

有什么建议吗?

解决方案

对于每个 MediaStreamTrack ,您可以调用 .getCapabilities().deviceId 来获取deviceId.

但是我不确定您是否可以在同一浏览器中两次使用相同的设备ID.

Once I have established a WebRTC connection, I can getLocalStreams and getRemoteStreams.

The streams have their own ID. Each stream is made of audio/video tracks MediaStreamTrack.

I'd like to be able to identify the device/source (ID) used for each track in order to avoid adding a stream that was already added to the connection.

In other word, I was thinking to make a check in connection.onaddstream that the stream track is not already present in my list of local or remote streams.

Any suggestions?

解决方案

For each MediaStreamTrack you can call .getCapabilities().deviceId to get the deviceId.

But I'm not sure if you can use the same device id within the same browser twice.

这篇关于WebRTC-如何为MediaStream(Tracks)标识源ID(设备ID)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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