【发布时间】:2017-11-16 13:26:27
【问题描述】:
我需要从Link修改Kurento群呼示例
如果一位参与者没有摄像头,则仅发送音频。现在使用相机时只接收音频。当只有麦克风可用时,我会收到 DeviceMediaError。
我设法过滤是否连接了相机设备,然后只发送音频,但这不起作用。也许参与者应该有一个音频标签而不是一个视频标签?
编辑:它仅适用于 Firefox,不适用于 Chrome。有什么想法吗?
【问题讨论】:
我需要从Link修改Kurento群呼示例
如果一位参与者没有摄像头,则仅发送音频。现在使用相机时只接收音频。当只有麦克风可用时,我会收到 DeviceMediaError。
我设法过滤是否连接了相机设备,然后只发送音频,但这不起作用。也许参与者应该有一个音频标签而不是一个视频标签?
编辑:它仅适用于 Firefox,不适用于 Chrome。有什么想法吗?
【问题讨论】:
更改以下行 -
sender.getOutgoingWebRtcPeer().connect(incoming, MediaType.AUDIO);
并在浏览器 js 文件中为 video:false 设置提供媒体限制。
更新代码 -
let constraints = {
audio: true,
video: false
};
let localParticipant = new Participant(sessionId);
participants[sessionId] = localParticipant;
localVideo = document.getElementById('local_video');
let video = localVideo;
let options = {
localVideo: video,
mediaConstraints: constraints,
onicecandidate: localParticipant.onIceCandidate.bind(localParticipant),
configuration : { iceServers : [
{"url":"stun:74.125.200.127:19302"},
] }
};
localParticipant.rtcPeer = new kurentoUtils.WebRtcPeer.WebRtcPeerSendonly(options, function(error) {
if (error) {
return console.error(error);
}
localVideoCurrentId = sessionId;
localVideo = document.getElementById('local_video');
localVideo.src = localParticipant.rtcPeer.localVideo.src;
localVideo.muted = true;
this.generateOffer(localParticipant.offerToReceiveVideo.bind(localParticipant));
});
server.js 代码
function join(socket, room, callback) {
let userSession = userRegister.getById(socket.id);
userSession.setRoomName(room.name);
room.pipeline.create('WebRtcEndpoint', {mediaProfile : 'WEBM_AUDIO_ONLY'}, (error, outgoingMedia) => {
if (error) {
console.error('no participant in room');
if (Object.keys(room.participants).length === 0) {
room.pipeline.release();
}
return callback(error);
}
// else
outgoingMedia.setMaxAudioRecvBandwidth(100);
加入房间时在服务器端添加媒体配置参数。
function getEndpointForUser(userSession, sender, callback) {
if (userSession.id === sender.id) {
return callback(null, userSession.outgoingMedia);
}
let incoming = userSession.incomingMedia[sender.id];
if (incoming == null) {
console.log(`user : ${userSession.id} create endpoint to receive video from : ${sender.id}`);
getRoom(userSession.roomName, (error, room) => {
if (error) {
return callback(error);
}
room.pipeline.create('WebRtcEndpoint', {mediaProfile : 'WEBM_AUDIO_ONLY'}, (error, incomingMedia) => {
if (error) {
if (Object.keys(room.participants).length === 0) {
room.pipeline.release();
}
return callback(error);
}
console.log(`user: ${userSession.id} successfully create pipeline`);
incomingMedia.setMaxAudioRecvBandwidth(0);
incomingMedia.getMaxAudioRecvBandwidth(0);
接听时添加媒体配置参数。
希望这会有所帮助。
【讨论】: