Javascript 如何将.getUserMedia()作为对等服务器从服务器中删除

Javascript 如何将.getUserMedia()作为对等服务器从服务器中删除,javascript,html5-video,webrtc,video-capture,Javascript,Html5 Video,Webrtc,Video Capture,我正在使用节点中的express服务一个网页,我打算使用DDN公开访问该网页(还不担心安全性) 我成功地将WebRTC配置为getUserMedia—问题在于,它自然会在客户端(访问公共服务器的浏览器)查找介质。有没有办法从服务器端获取UserMedia 这是我目前的代码: video = document.getElementById('video'); const videoElement = document.querySelector('video'); const audioSele

我正在使用节点中的express服务一个网页,我打算使用DDN公开访问该网页(还不担心安全性)

我成功地将WebRTC配置为getUserMedia—问题在于,它自然会在客户端(访问公共服务器的浏览器)查找介质。有没有办法从服务器端获取UserMedia

这是我目前的代码:

video = document.getElementById('video');

const videoElement = document.querySelector('video');
const audioSelect = document.querySelector('select#audioSource');
const videoSelect = document.querySelector('select#videoSource');

powerButton = document.getElementById('power');
icon = document.getElementById('loading');

navigator.mediaDevices.enumerateDevices()
  .then(gotDevices).then(getStream).catch(handleError);

audioSelect.onchange = getStream;
videoSelect.onchange = getStream;

function gotDevices(deviceInfos) {
  for (let i = 0; i !== deviceInfos.length; ++i) {
    const deviceInfo = deviceInfos[i];
    const option = document.createElement('option');
    option.value = deviceInfo.deviceId;

    if (deviceInfo.kind === 'audioinput') {
      option.text = deviceInfo.label || 'microphone ' +
        (audioSelect.length);
      audioSelect.appendChild(option);
    }

    else if (deviceInfo.kind === 'videoinput') {
      option.text = deviceInfo.label || 'camera ' +
        (videoSelect.length);
      videoSelect.appendChild(option);
    }

    else {
      console.log('Found another kind of device: ', deviceInfo);
    }
  }
}

function getStream() {
  if (window.stream) {
    window.stream.getTracks().forEach(function(track) {
      track.stop();
    });
  }

  const constraints = {
    audio: {
      deviceId: {exact: audioSelect.value}
    },
    video: {
      deviceId: {exact: videoSelect.value},
      width: {min: 1280},
      height: {min: 720}
    }
  };

  navigator.mediaDevices.getUserMedia(constraints).
    then(gotStream).catch(handleError);
}

function gotStream(stream) {
  window.stream = stream;
  videoElement.srcObject = stream;
}

function handleError(error) {
  console.error('Error: ', error);
}

展示什么?那个在数据中心扫地的家伙?哈哈,实际上是一张捕获卡——当客户端是这台服务器时,WebRTC会很好地捕捉到它。我想说的是,不要走webAPI的路。为什么需要使用webRTC?您可能已经成功地使用了类似的东西,它可以将任何方便的视频流从您的服务器转换为RTC流,但在您的位置上,我会看看像GStreamer之类的解决方案,以直接流式传输视频。