Modify Kurento group call example to support only audio

断了今生、忘了曾经 提交于 2019-12-25 08:59:55

问题


I need to modify the Kurento group call example from Link

to send only audio if one participant has no camera. Right now only audio is received when a camera is used. When only a microphone is available I receive a DeviceMediaError.

I managed to filter whether a camera device is connected or not and then send only audio, but this doesn't work. Maybe the participant should've an audio tag instead of a video tag?

EDIT: It's only working on Firefox and not in Chrome. Any ideas?


回答1:


in file - https://github.com/Kurento/kurento-tutorial-java/blob/master/kurento-group-call/src/main/java/org/kurento/tutorial/groupcall/UserSession.java.

change following line -

  sender.getOutgoingWebRtcPeer().connect(incoming, MediaType.AUDIO);

and set offer media constraints to video:false in browser js file.

updated code -

  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 code

  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);

add media profile parameter on server side while joining room.

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);

add media profile parameter when accepting call.

hope this helps.



来源:https://stackoverflow.com/questions/44543996/modify-kurento-group-call-example-to-support-only-audio

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!