Я пытаюсь провести обмен opentok 1: 1 между браузерами.
Существует две роли:
один приглашающий издатель и один приглашенный. Цель состоит в том, чтобы эти двое поговорили один на один.
Сессия проходит корректно, и приглашенный подключается к потоку. Приглашенный получает видеопоток издателя и добавляет его в свой контейнер. затем он начинает публикацию в тот же сеанс.
Итак, у приглашенного теперь видны оба видео. (ура)...
Однако издатель может увидеть только свое собственное видео. Я вообще не могу обнаружить опубликованный поток приглашенного.
Вот функция издателя:
function startVideoHost(sessionId, apiKey, token) {
var replacementElementId = "localVideo";
if (OT.checkSystemRequirements() == 1) {
publisher = OT.initPublisher(replacementElementId);
publisher.on({
streamCreated: function (event) {
$('.videoWindow').show();
console.log("Publisher started streaming.");
},
streamDestroyed: function (event) {
console.log("Publisher stopped streaming. Reason: "
+ event.reason);
}
});
// this is kinda where id hope the publisher would detect the guest stream
session = OT.initSession(apiKey, sessionId);
session.on("streamCreated", function(event) {
session.subscribe(event.stream, remoteVideos);
});
session.connect(token, function (error) {
if (session.capabilities.publish == 1) {
session.publish(publisher);
} else {
console.log("You cannot publish an audio-video stream.");
}
});
} else {
console.log("The client does not support WebRTC.");
}
}
А вот функция приглашенных:
function startVideoGuest(sessionId, apiKey, token) {
if (OT.checkSystemRequirements() == 1) {
var session = OT.initSession(apiKey, sessionId);
session.on("streamCreated", function(event) {
session.subscribe(event.stream, remoteVideos);
});
session.connect(token, function(error) {
if (error) {
console.log("Error connecting: ", error.code, error.message);
} else {
$('.videoWindow').show();
var replacementElementId = "localVideo";
publisher = OT.initPublisher(replacementElementId);
publisher.on({
streamCreated: function (event) {
console.log("Publisher started streaming.");
},
streamDestroyed: function (event) {
console.log("Publisher stopped streaming. Reason: "
+ event.reason);
}
});
console.log("Connected to the session.");
}
});
}
}
Кто-нибудь знает, почему я не возвращаю видеопоток приглашенных издателю?