2012-10-16 3 views
0

찾았습니다. video conferencing prototype입니다. 그러나 ROAP 프로토콜이 JSEP로 대체 되었기 때문에 실행을 시작할 수 없습니다.WebRTC 데모에 JSEP 통합

나는 다음과 같은 소스를 사용하여 문제를 해결하기 위해 노력했다 :

Example ROAP and JSEP

ROAP on JSEP

나는 많은 사람들이 하나의 작업 JSEP 예를 구축에 가지고 감사하겠습니다 생각합니다. apprtc.appspot.com에서

<script> 
    var socket = new WebSocket('ws://mydomain.com:1337'); 
    var sourcevid = document.getElementById('sourcevid'); 
    var remotevid = document.getElementById('remotevid'); 
    var localStream = null; 
    var peerConn = null; 
    var started = false; 

    var logg = function(s) { console.log(s); }; 

    // when PeerConn is created, send setup data to peer via WebSocket 
    function onSignal(message) { 
     logg("Sending setup signal"); 
     socket.send(message); 
    } 

    // when remote adds a stream, hand it on to the local video element 
    function onRemoteStreamAdded(event) { 
    logg("Added remote stream"); 
    remotevid.src = window.webkitURL.createObjectURL(event.stream); 
    } 

    // when remote removes a stream, remove it from the local video element 
    function onRemoteStreamRemoved(event) { 
    logg("Remove remote stream"); 
    remotevid.src = ""; 
    } 

    function createPeerConnection() { 
    try { 
     logg("Creating peer connection"); 
     peerConn = new webkitDeprecatedPeerConnection("STUN stun.l.google.com:19302", onSignal); 
    } catch (e) { 
     try { 
     peerConn = new webkitPeerConnection00("STUN stun.l.google.com:19302", onSignal); 
     } catch (e) { 
     console.log("Failed to create PeerConnection, exception: " + e.message); 
     } 
    } 
    peerConn.addEventListener("addstream", onRemoteStreamAdded, false); 
    peerConn.addEventListener("removestream", onRemoteStreamRemoved, false) 
    } 

    // start the connection upon user request 
    function connect() { 
    if (!started && localStream) { 
     createPeerConnection(); 
     logg('Adding local stream...'); 
     peerConn.addStream(localStream); 
     started = true; 
    } else { 
     alert("Local stream not running yet."); 
    } 
    } 

    // accept connection request 
    socket.addEventListener("message", onMessage, false); 
    function onMessage(evt) { 
    logg("RECEIVED: "+evt.data); 
    if (!started) { 
     createPeerConnection(); 
     logg('Adding local stream...'); 
     peerConn.addStream(localStream); 
     started = true; 
    } 
    // Message returned from other side 
    logg('Processing signaling message...'); 
    peerConn.processSignalingMessage(evt.data); 
    } 

    function hangUp() { 
    logg("Hang up."); 
    peerConn.close(); 
    peerConn = null; 
    started = false; 
    } 

    function startVideo() { 
     // Replace the source of the video element with the stream from the camera 
     try { //try it with spec syntax 
     navigator.webkitGetUserMedia({audio: true, video: true}, successCallback, errorCallback); 
     } catch (e) { 
     navigator.webkitGetUserMedia("video,audio", successCallback, errorCallback); 
     } 
     function successCallback(stream) { 
      sourcevid.src = window.webkitURL.createObjectURL(stream); 
      localStream = stream; 
     } 
     function errorCallback(error) { 
      console.error('An error occurred: [CODE ' + error.code + ']'); 
     } 
    } 
    function stopVideo() { 
    sourcevid.src = ""; 
    } 
    </script> 

답변

0

예 는 JSEP와 액션의 WebRTC를 나타낸다.

JSEP API를 사용하는 동안 DeprecatedPeerConnection을 추상화하는 ROAP to JSEP library도 있습니다.

+1

이 링크가 질문에 대답 할 수도 있지만 답변의 핵심 부분을 여기에 포함시키고 참조 용 링크를 제공하는 것이 좋습니다. 링크 된 페이지가 변경되면 링크 전용 답변이 유효하지 않게 될 수 있습니다. – LittleBobbyTables

+0

죄송합니다 - 기차에서 내 전화를 통해 신속하게 답변을 추가하십시오! 이제 더 자세한 내용을 추가했습니다. –

+0

답장을 보내 주셔서 감사합니다. 방금 JSEP 라이브러리 (이 경우 pc1 & pc2)에 대한 ROAP을 사용하여 두 피어간에 통신하기 위해 webSocket을 사용하는 방법을 이해할 수 없습니다. – user574199

관련 문제