问题描述
我有 Reactjs 应用程序,其中有一个视频通话概念。我使用了RTCMultiConnection包来实现视频通话。
对等服务器已连接,本地主机上视频通话正常。
但是当我在服务器中托管 react js 应用程序(也有 ssl 证书)时,视频通话无法正常工作。
onStream 函数在视频通话开始时未调用,因此未显示用户视频。
我通过构建托管了 react js 应用程序,并在 Heroku 服务器和 Windows 专用服务器(通过 IIS)中进行了尝试。但是视频通话在任何一个服务器上都不起作用。
如何让视频通话也能在服务器上工作。
我的示例代码:
export function AudioVideoConferenceStart(data,callback) {
var liveOrJoined = data.liveOrJoined;
var callType = data.callType;
var documentData = data.documentData;
var sectionCount = data.sectionCount;
var roomId = data.roomId;
var isChat = data.isChat;
var isOnetoOne = data.isOnetoOne;
globalVar.connection = new RTCMultiConnection();
globalVar.connection.socketURL = defaultVal.ENV === "dev" ? defaultVal.APILINK_DEV : defaultVal.APILINK_PROD;
globalVar.connection.socketMessageEvent = 'video-conference-demo';
globalVar.connection.session = {
audio: true,video: true
};
globalVar.connection.sdpConstraints.mandatory = {
OfferToReceiveAudio: true,OfferToReceiveVideo: true
};
var bitrates = 512;
var resolutions = 'Ultra-HD';
var videoConstraints = {};
if (resolutions == 'HD') {
videoConstraints = {
width: {
ideal: 1280
},height: {
ideal: 720
},frameRate: 30
};
}
if (resolutions == 'Ultra-HD') {
videoConstraints = {
width: {
ideal: 1920
},height: {
ideal: 1080
},frameRate: 30
};
}
globalVar.connection.mediaConstraints = {
video: videoConstraints,audio: true
};
var CodecsHandler = globalVar.connection.CodecsHandler;
globalVar.connection.processSdp = function (sdp) {
var codecs = 'vp8';
if (codecs.length) {
sdp = CodecsHandler.preferCodec(sdp,codecs.toLowerCase());
}
if (resolutions == 'HD') {
sdp = CodecsHandler.setApplicationSpecificBandwidth(sdp,{
audio: 128,video: bitrates,screen: bitrates
});
sdp = CodecsHandler.setVideoBitrates(sdp,{
min: bitrates * 8 * 1024,max: bitrates * 8 * 1024,});
}
if (resolutions == 'Ultra-HD') {
sdp = CodecsHandler.setApplicationSpecificBandwidth(sdp,});
}
return sdp;
};
globalVar.connection.iceServers = [{
'urls': [
'stun:stun.l.google.com:19302','stun:stun1.l.google.com:19302','stun:stun2.l.google.com:19302','stun:stun.l.google.com:19302?transport=udp',]
}];
globalVar.connection.onstream = function (event) {
alert("Stream Added");
};
globalVar.connection.onstreamended = function (event) {
alert("stream removed");
};
globalVar.connection.onMediaError = function (e) {
alert(e.message);
};
// document.getElementById('room-id').value = roomid;
localStorage.setItem(globalVar.connection.socketMessageEvent,roomid);
// auto-join-room
(function reCheckRoomPresence() {
globalVar.connection.checkPresence(roomid,function (isRoomExist) {
if (isRoomExist) {
globalVar.connection.join(roomid);
return;
}
setTimeout(reCheckRoomPresence,5000);
});
})();
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)