1

我在使用 WebRTC 时遇到了问题:我使用了一个关于视频通话的示例中的代码。

 if (new_connection) {
       console.log('New Peer Connection');
       var peer_connection = {};
       peer_connection.connection_id = msg.from_connection_id;
       peer_connection.pc = createPeerConnection(peer_connection.connection_id,
       false);
       peer_connections.push(peer_connection);
       $('#remote').prepend(remoteVideoHtml.replace('remoteVideoId', 'peer' +
       peer_connection.connection_id));
 }

 //Now process the SDP JSON Blob received
 for (var i in peer_connections) {
       if (peer_connections[i].connection_id == msg.from_connection_id) {
             try {
                  peer_connections[i].pc.processSignalingMessage(msg.data);
             }catch (e) {
       console.log("Failed to create processSignalingMessage, exception: " +    e.message);                            
 }

我需要帮助,因为我这里有一个问题。

                      peer_connections[i].pc.processSignalingMessage(msg.data);

问题是:

 Object #<RTCPeerConnection> has no method 'processSignalingMessage' 

我不知道这些函数是如何工作的以及它们是如何被调用的:

pc.onconnecting = function (msg) {
    console.log('onSessionConnecting');
}
pc.onopen = function (msg) {
    console.log('onSessionOpened');
}
pc.onaddstream = function (event) {
    console.log('onRemoteStreamAdded add the remote peers video stream.');
    var url = webkitURL.createObjectURL(event.stream);
    $('#peer' + connection_id).attr({
        src: url
    });
}

我将不胜感激。

4

1 回答 1

1

Chrome 中 WebRTC 的初始版本是基于 ROAP 的,它曾经有一个processSignallingMessage()方法。当前版本基于 JSEP,它具有注入本地 SDP 和从其他用户接收的 SDP 之类setRometeDescription()的方法。setLocalDescription()

您仍然可以在旧版本的 Chrome 或 Bowser 中找到此实现。

于 2013-04-05T21:30:07.717 回答