候选句柄的边缘问题

时间:2019-04-02 14:12:04

标签: javascript jquery video-streaming webrtc

我尝试在Chrome上使用webrtc和adapter.js进行视频聊天,但工作正常,但在EI Edge上却无法正常工作,首先向我显示此警告,提示addRemoteCandidate超时。考虑发送一个来自adapter.js的候选人通知,我不知道该如何解决此问题,请有人帮我。

/*===========================================
* handle offer 
============================================*/
async function handleOffer(offer) {
    await handleJoinSuccess();

    console.log('receiver offer: ', offer);
    try {
        let remoteSessionDescriptions = new RTCSessionDescription(offer);

        await pc.setRemoteDescription(remoteSessionDescriptions)
        console.log('remote is set');

        const answer = await pc.createAnswer();

        if (!state.iAmCaller) {
            await pc.setLocalDescription(answer)
        }

        await socketVideoEmit('answer', answer);
        console.log(TAG, 'socketEmit')
    } catch (error) {
        console.log('error', error)
    }
}


function handleAnswer(answer) {

    pc.setRemoteDescription(new RTCSessionDescription(answer));
    console.log('remote is set');
}

这是我的处理功能

function handleIceCandidate(candidate) {

    console.log(candidate);

    pc.addIceCandidate(new RTCIceCandidate(candidate)).catch(error => {
        console.log('error adding icecandidate', error)
    });    

}

这是候选套接字

function onReceivedVideoMessage(data) {
    console.log(TAG + 'onReceivedVideoMessage(data)', data)
    if (data.toid == IM_USERID) {
        let videoChatSocketTag = data.type;
        switch (videoChatSocketTag) {
            case "offer":
                setState({ connectionState: ConnectionStates.receivedOfferState })
                handleOffer(data.data);
                break;
            case "answer":
                setState({ connectionState: ConnectionStates.receiveAnswerState })
                handleAnswer(data.data);
                break;
            case "candidate":
                setState({ connectionState: ConnectionStates.receivedIceCandidateState });
                console.log('receiver candidate');
                handleIceCandidate(data.data);
                break;
        }
    }
}

0 个答案:

没有答案