当两个人加入我的 Twilio Video 房间时,只有一个参与者收到音频和视频?
When two people join my Twilio Video room, only one participant receives audio and video?
每次参与者 2 出现时,他们的音频和摄像头记录都会显示在参与者 1 的屏幕上。但是参与者 1 的 audio/video 没有出现在参与者 2 的屏幕上。那么谁是第一个加入他们的视频和音频的人就不会传输给其他参与者?
<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());
});
});
});
当我作为参与者 1 第一次加入房间时,我在 room.on('participantConnected', participant => { //code } 中插入的日志记录没有显示。但我注意到一次参与者 2 出现了日志记录确实出现了。所以我想知道我如何设置 room.on('participantConnected') 代码以在第一个参与者加入时立即执行,而不是第二个。
Twillio 视频仅基于点对点连接。
一个房间超过2~4个用户应该基于SFU和MCU方法。
这里是link了解更多详情。
- [ https://medium.com/linagora-engineering/scalability-in-video-conferencing-part-1-276f52b4acac ]
p2p 连接在 1:1 连接下始终运行良好,但正如您在上面的文章中所读到的那样,它应该基于 SFU 或 MCU 超过 3 个参与者。
其实hangout和zoom也是基于MCU的
每次参与者 2 出现时,他们的音频和摄像头记录都会显示在参与者 1 的屏幕上。但是参与者 1 的 audio/video 没有出现在参与者 2 的屏幕上。那么谁是第一个加入他们的视频和音频的人就不会传输给其他参与者?
<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());
});
});
});
当我作为参与者 1 第一次加入房间时,我在 room.on('participantConnected', participant => { //code } 中插入的日志记录没有显示。但我注意到一次参与者 2 出现了日志记录确实出现了。所以我想知道我如何设置 room.on('participantConnected') 代码以在第一个参与者加入时立即执行,而不是第二个。
Twillio 视频仅基于点对点连接。 一个房间超过2~4个用户应该基于SFU和MCU方法。
这里是link了解更多详情。
- [ https://medium.com/linagora-engineering/scalability-in-video-conferencing-part-1-276f52b4acac ]
p2p 连接在 1:1 连接下始终运行良好,但正如您在上面的文章中所读到的那样,它应该基于 SFU 或 MCU 超过 3 个参与者。 其实hangout和zoom也是基于MCU的