Webrtc 修改Kurento group call示例以仅支持音频

Webrtc 修改Kurento group call示例以仅支持音频,webrtc,kurento,Webrtc,Kurento,我需要修改来自的Kurento组调用示例 如果一名参与者没有摄像头,则仅发送音频。现在使用相机时只接收音频。当只有麦克风可用时,我会收到一个DeviceMediaError 我设法过滤相机设备是否连接,然后只发送音频,但这不起作用。也许参与者应该有一个音频标签而不是视频标签 编辑:它只适用于Firefox,不适用于Chrome。有什么想法吗?在文件- 更改以下行- sender.getOutgoingWebRtcPeer().connect(incoming, MediaType.AUDIO

我需要修改来自的Kurento组调用示例

如果一名参与者没有摄像头,则仅发送音频。现在使用相机时只接收音频。当只有麦克风可用时,我会收到一个DeviceMediaError

我设法过滤相机设备是否连接,然后只发送音频,但这不起作用。也许参与者应该有一个音频标签而不是视频标签

编辑:它只适用于Firefox,不适用于Chrome。有什么想法吗?

在文件-

更改以下行-

  sender.getOutgoingWebRtcPeer().connect(incoming, MediaType.AUDIO);
并在浏览器js文件中将提供媒体约束设置为视频: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);
接受呼叫时添加媒体配置文件参数


希望这有帮助。

如果我有视频设备,我还能使用视频吗?您需要检查设备中的视频,然后相应地设置媒体限制。这必须在服务器端和客户端以及媒体接收器的客户端完成。您只需要为音频通话和音频视频通话编写单独的函数。感谢您的详细回答。我已经检查了是否有cam或仅音频设备可用。根据这一点,我将约束更改为false或true。这就是我在客户端需要改变的吗?在服务器端区分音频通话和视频通话的唯一方法是什么?您好,您知道ios的一些例子吗。