当两个人加入我的 Twilio Video 房间时,只有一个参与者接收音频和视频? [英] When two people join my Twilio Video room, only one participant receives audio and video?

查看:23
本文介绍了当两个人加入我的 Twilio Video 房间时,只有一个参与者接收音频和视频?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每次参与者 2 出现时,他们的音频和摄像头记录都会显示在参与者 1 的屏幕上.但是参与者 1 的音频/视频不会显示在参与者 2 的屏幕上.那么谁是第一个加入他们的视频和音频的人不会传输给其他参与者?

你好!

<div class="videos"><div id="video-container"></div>

<div id="remote-media-div">

<?phpinclude('./vendor/autoload.php');包括('./config.php');使用 Twilio\Jwt\AccessToken;使用 Twilio\Jwt\Grants\VideoGrant;//如果提供,则使用查询字符串中的身份和房间$identity = isset($_GET["identity"]) ?$_GET[身份"] : 身份".兰特();$room = isset($_GET[room"]) ?$_GET["room"] : "testingreal";//创建访问令牌,我们将对其进行序列化并发送给客户端$token = 新访问令牌($TWILIO_ACCOUNT_SID,$TWILIO_API_KEY,$TWILIO_API_SECRET,3600,$身份);//授予对视频的访问权限$grant = new VideoGrant();$grant->setRoom($room);$token->addGrant($grant);echo $token->toJWT();?><script src="//media.twiliocdn.com/sdk/js/video/releases/2.7.3/twilio-video.min.js"></script><脚本>var Video = Twilio.Video;控制台日志(视频);var connect = Video.connect;Video.connect('<?=$token->toJWT()?>', { name: 'testingreal' }).then(room => {console.log('连接到房间%s"', room.name);room.on('participantConnected', 参与者 => {console.log(`参与者"${participant.identity}"已连接`);console.log('测试 213');参与者.tracks.forEach(出版物=> {如果(publication.isSubscribed){const 轨道 = 出版物.track;document.getElementById('remote-media-div').appendChild(track.attach());}});参与者.on('trackSubscribed', track => {document.getElementById('remote-media-div').appendChild(track.attach());});});});

我在 room.on('participantConnected',participant => {//code } 中插入的日志在我第一次作为参与者 1 加入房间时没有出现.但是我注意到一旦参与者 2 出现日志确实出现了.所以我想知道如何设置 room.on('participantConnected') 代码在第一个参与者加入时执行,而不是第二个.

解决方案

Twillio 视频只是基于对等连接.要在一个房间内超过 2~4 个用户,它应该基于 SFU 和 MCU 方法.

这里是更多详细信息的链接.

  • [ https://medium.com/linagora-engineering/scalability-in-video-conferencing-part-1-276f52b4acac ]

p2p 连接在 1:1 连接下始终运行良好,但正如您在上面的文章中所读到的那样,它应该基于 SFU 或 MCU,以便超过 3 个参与者.其实hangout和zoom也是基于MCU的.

Every time participant 2 shows up, their audio and camera recording shows up on participant 1's screen. But participant 1's audio/video doesn't show up on participant 2's screen. So whoever is the first person to join their video and audio isn't transmitted to the other participants?

<h1>Hi there!</h1>
<div class="videos">
  <div id="video-container"></div>
</div>
<div id="remote-media-div">
</div>



<?php
include('./vendor/autoload.php');
include('./config.php');

use Twilio\Jwt\AccessToken;
use Twilio\Jwt\Grants\VideoGrant;

// Use identity and room from query string if provided

$identity = isset($_GET["identity"]) ? $_GET["identity"] : "identity" . rand();
$room = isset($_GET["room"]) ? $_GET["room"] :  "testingreal";

// Create access token, which we will serialize and send to the client
$token = new AccessToken(
    $TWILIO_ACCOUNT_SID,
    $TWILIO_API_KEY,
    $TWILIO_API_SECRET,
    3600,
    $identity
);

// Grant access to Video
$grant = new VideoGrant();
$grant->setRoom($room);
$token->addGrant($grant);

echo $token->toJWT();

?>



<script src="//media.twiliocdn.com/sdk/js/video/releases/2.7.3/twilio-video.min.js"></script>

<script>

var Video = Twilio.Video;
console.log(Video);


var connect = Video.connect;

Video.connect('<?=$token->toJWT()?>', { name: 'testingreal' }).then(room => {
  console.log('Conmnected to Room "%s"', room.name);

    room.on('participantConnected', participant => {
    console.log(`Participant "${participant.identity}" connected`);
    console.log('testing 213');

    participant.tracks.forEach(publication => {

        if (publication.isSubscribed) {
        const track = publication.track;
        document.getElementById('remote-media-div').appendChild(track.attach());
        }
    });

    participant.on('trackSubscribed', track => {
        document.getElementById('remote-media-div').appendChild(track.attach());
    });
    });  


});

The logging I inserted in the room.on('participantConnected', participant => { //code } doesn't show up when I first join the room as participant 1. But I notice once participant 2 shows up the logging does appear. So I am wondering how I set the room.on('participantConnected') code to execute right when the first participant joins, and not the 2nd.

解决方案

Twillio video is just based on peer to peer connection. To be more than 2~4+ users in a room it should be based on SFU and MCU methodology.

Here is the link for more details.

  • [ https://medium.com/linagora-engineering/scalability-in-video-conferencing-part-1-276f52b4acac ]

p2p connection is always working well with 1:1 connection but as you can read in the above article it should be based on SFU or MCU to be more than 3+ participants. Actually hangout and zoom are also based on MCU.

这篇关于当两个人加入我的 Twilio Video 房间时,只有一个参与者接收音频和视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
PHP最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆