Добрый день. Я не могу разобраться как вставить MediaStreamTrack в элемент video в Janus. Когда я добавляю MediaStreamTrack в MediaStream и через него пытаюсь вставить видеопоток, он не отображается в элементе video.
Janus.init({
debug: true,
dependencies: Janus.useDefaultDependencies(), // or: Janus.useOldDependencies() to get the behaviour of previous Janus versions
callback: function() {
}
})
let janus = new Janus(
{
server: 'http://147.45.158.188:8088/janus',
success: function() {
// Done! attach to plugin XYZ
let echotest=null;
// Attach to echo test plugin
janus.attach(
{
plugin: "janus.plugin.echotest",
success: function(pluginHandle) {
// Negotiate WebRTC
console.log("FFF")
echotest = pluginHandle;
echotest.createOffer(
{
// We wantbidirectional audio and video, plus data channels
tracks: [
{ type: 'video', capture: true, recv: true },
{ type: 'audio', capture: true, recv: true },
],
success: function(jsep) {
// Got our SDP! Send our OFFER to the plugin
var body = {request:'start'}
echotest.send({ message: body, jsep: jsep });
},
error: function(error) {
// An error occurred...
console.error(error);
},
customizeSdp: function(jsep) {
// if you want to modify the original sdp, do as the following
// oldSdp = jsep.sdp;
// jsep.sdp = yourNewSdp;
}
});
},
onmessage: function(msg, jsep) {
// Handle msg, if needed, and check jsep
if(jsep) {
// We have the ANSWER from the plugin
echotest.handleRemoteJsep({jsep: jsep});
}
},
onlocaltrack: function(track, added) {
// Invoked after createOffer
// This is info on a local track: when added, we can choose to render
if (added) {
var video = document.getElementById("#local")
const stream = new MediaStream([track]);
video.srcObject = stream;
}
},})
},
onremotetrack: function(track, mid, added, metadata) {
// Invoked after handleRemoteJsep has got us a PeerConnection
// This is info on a remote track: when added, we can choose to render
// You can query metadata to get some more information on why track was added or removed
// metadata fields:
if (added) {
var video = document.getElementById("#local")
var stream = new MediaStream()
stream.addTrack(track);
video.srcObject = stream;
}
},
error: function(cause) {
// Error, can't go on...
console.error(cause);
},
destroyed: function() {
// I should get rid of this
}
});