44 < script src ="node_modules/argon2-browser/dist/argon2-bundled.min.js "> </ script >
55
66 < title > p2p tester</ title >
7+
8+ < style >
9+
10+ body {
11+ background-color : rgb (95 , 95 , 95 );
12+ color : aliceblue;
13+ }
14+
15+ .bordered {
16+ border : 1px solid rgb (230 , 230 , 230 );
17+ padding : 10px ;
18+ margin : 0 auto;
19+ max-width : 320px ;
20+ background-color : # 141414cc ;
21+ box-shadow : 0 0 10px rgba (0 , 0 , 0 , 0.1 );
22+ border-radius : 4px ;
23+ }
24+
25+ p {
26+ color : # 666 ;
27+ line-height : 1.6 ;
28+ }
29+
30+ video {
31+ height : 20vh
32+ }
33+
34+ textarea {
35+ width : 100vw ;
36+ height : 20vh ;
37+ white-space : pre;
38+ overflow-wrap : normal;
39+ overflow-x : scroll;
40+ background-color : # 666 ;
41+ color : white;
42+ }
43+ </ style >
744</ head >
845
946< body >
1047
48+ < div >
49+ Trickle: < input type ="checkbox " id ="trickle-checkbox ">
50+ HalfTrickle: < input type ="checkbox " id ="half-trickle-checkbox ">
51+ TURN only: < input type ="checkbox " id ="turn-checkbox ">
52+ </ div >
53+
1154 < div >
1255 < input type ="text " id ="user-hash " placeholder ="your user hash " readonly >
1356 < input type ="text " id ="user-call-hash " placeholder ="user to call ">
@@ -37,6 +80,16 @@ <h2>Remote</h2>
3780 < video id ="remote-video "> </ video >
3881 </ div >
3982
83+ < div >
84+ < h2 > Offers Sent</ h2 >
85+ < textarea id ="offerArea "> </ textarea >
86+ </ div >
87+
88+
89+ < div >
90+ < h2 > Offers recieved</ h2 >
91+ < textarea id ="answerArea "> </ textarea >
92+ </ div >
4093
4194< script >
4295
@@ -63,6 +116,42 @@ <h2>Remote</h2>
63116 config : config
64117} )
65118
119+ async function setupDebug ( active ) {
120+ // id="trickle-checkbox">
121+ // id="half-trickle-checkbox">
122+ // id="turn-checkbox">
123+
124+ let offerArea = document . getElementById ( 'offerArea' )
125+ let answerArea = document . getElementById ( 'answerArea' )
126+
127+ // let trickleCheckbox = document.getElementById('trickle-checkbox')
128+ // let halfTrickleCheckbox = document.getElementById('half-trickle-checkbox')
129+ // let turnCheckbox = document.getElementById('turn-checkbox')
130+
131+ active . on ( 'signal' , ( { invite, data} ) => {
132+ answerArea . value += '\n' + JSON . stringify ( data )
133+ } )
134+
135+
136+ active . on ( 'offer' , ( { invite, data} ) => {
137+ offerArea . value += '\n' + JSON . stringify ( data )
138+ } )
139+
140+ active . on ( 'stream' , invite => {
141+ // got remote video stream, now let's show it in a video tag
142+ console . log ( 'showing remote video' )
143+ var video = document . getElementById ( 'remote-video' )
144+
145+ if ( 'srcObject' in video ) {
146+ video . srcObject = invite . incomingStream
147+ } else {
148+ video . src = window . URL . createObjectURL ( invite . incomingStream ) // for older browsers
149+ }
150+
151+ video . play ( )
152+ } )
153+ }
154+
66155async function callUser ( ) {
67156 if ( pendingInvite ) { return }
68157
@@ -75,7 +164,7 @@ <h2>Remote</h2>
75164 action : 'call'
76165 } )
77166
78- pendingInvite . on ( 'stream' , invite => {
167+ /* pendingInvite.on('stream', invite => {
79168 // got remote video stream, now let's show it in a video tag
80169 console.log('showing remote video')
81170 var video = document.getElementById('remote-video')
@@ -87,7 +176,7 @@ <h2>Remote</h2>
87176 }
88177
89178 video.play()
90- } )
179+ })*/
91180
92181 pendingInvite . on ( 'state-change' , ( invite ) => {
93182 console . log ( 'state-change' , invite . state , invite )
@@ -97,6 +186,8 @@ <h2>Remote</h2>
97186
98187 console . log ( 'accepted' )
99188
189+ setupDebug ( pendingInvite )
190+
100191 localMediaSrc = await navigator . mediaDevices . getUserMedia ( {
101192 video : true ,
102193 audio : true
@@ -122,6 +213,8 @@ <h2>Remote</h2>
122213
123214async function acceptCall ( ) {
124215
216+ setupDebug ( pendingInvite )
217+
125218 localMediaSrc = await navigator . mediaDevices . getUserMedia ( {
126219 video : true ,
127220 audio : true
@@ -139,20 +232,6 @@ <h2>Remote</h2>
139232 video . play ( )
140233
141234 await pendingInvite . accept ( localMediaSrc , config )
142-
143- pendingInvite . on ( 'stream' , invite => {
144- // got remote video stream, now let's show it in a video tag
145- console . log ( 'showing remote video' )
146- var video = document . getElementById ( 'remote-video' )
147-
148- if ( 'srcObject' in video ) {
149- video . srcObject = invite . incomingStream
150- } else {
151- video . src = window . URL . createObjectURL ( invite . incomingStream ) // for older browsers
152- }
153-
154- video . play ( )
155- } )
156235}
157236
158237
0 commit comments