初步连接成功

This commit is contained in:
langhuihui
2020-05-24 22:58:21 +08:00
parent 92e5418142
commit c0662fb537
12 changed files with 3650 additions and 3546 deletions

View File

@@ -1,13 +1,14 @@
<template>
<div>
Browser base64 Session Description
<div class="root">
Browser SDP
<br />
<textarea readonly="true" :value="localDescription"></textarea>
<br />Golang base64 Session Description
<textarea readonly="true" rows="10" cols="100">{{localSDP||"loading..."}}</textarea>
<br />Golang SDP
<br />
<textarea :value="remoteSessionDescription"></textarea>
<textarea rows="10" cols="100">{{remoteSDP}}</textarea>
<br />
<button @click="startSession">Start Session</button>
<mu-text-field v-model="streamPath" label="streamPath"></mu-text-field>
<m-button @click="startSession" v-if="localSDP">Start</m-button>
<br />
<br />Video
@@ -21,23 +22,44 @@
<script>
let pc = new RTCPeerConnection({
iceServers: [
iceServers:[
{
urls: "stun:stun.l.google.com:19302"
urls:[
"stun:stun.ekiga.net",
"stun:stun.ideasip.com",
"stun:stun.schlund.de",
"stun:stun.stunprotocol.org:3478",
"stun:stun.voiparound.com",
"stun:stun.voipbuster.com",
"stun:stun.voipstunt.com",
"stun:stun.voxgratia.org",
"stun:stun.services.mozilla.com",
"stun:stun.xten.com",
"stun:stun.softjoys.com",
"stun:stunserver.org",
"stun:stun.schlund.de",
"stun:stun.rixtelecom.se",
"stun:stun.iptel.org",
"stun:stun.ideasip.com",
"stun:stun.fwdnet.net",
"stun:stun.ekiga.net",
"stun:stun01.sipphone.com",
]
}
]
});
export default {
data() {
return {
localDescription: "",
remoteSessionDescription: ""
localSDP: "",
remoteSDP: "",
streamPath:"live/rtc"
};
},
methods: {
startSession() {
this.ajax.post("/webrtc/answer", this.localDescription).then(result => {
this.remoteSessionDescription = result;
this.ajax({type: 'POST',processData:false,data: JSON.stringify(pc.localDescription),url:"/webrtc/answer?streamPath="+this.streamPath,dataType:"json"}).then(result => {
this.remoteSDP = result.sdp;
pc.setRemoteDescription(new RTCSessionDescription(result));
});
}
@@ -61,7 +83,7 @@ export default {
pc.oniceconnectionstatechange = e => log(pc.iceConnectionState);
pc.onicecandidate = event => {
if (event.candidate === null) {
this.localDescription = JSON.stringify(pc.localDescription);
this.localSDP = pc.localDescription.sdp;
}
};
}
@@ -69,4 +91,8 @@ export default {
</script>
<style>
.root textarea{
background: transparent;
color: cyan;
}
</style>