-
Notifications
You must be signed in to change notification settings - Fork 0
/
code.html
192 lines (160 loc) · 5.43 KB
/
code.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<!DOCTYPE html>
<html>
<head>
<base href="/">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="keywords" >
<title>Tp 4 VOIP TechWeb</title>
<style media="screen">
/* SECTIONS */
.body {
background-color: #20ccd8;
}
.btn
{
padding: 4px 7px;
border-radius: 6px;
border : 2px solid #3494AC;
background-color: #36A83E;
font-style: bold;
font-size: 1em;
}
.btn:hover
{
padding: 4px 7px;
border-radius: 6px;
border : 2px solid #3494AC;
font-style: bold;
font-size: 1em;
background-color: #db150a;
}
.section {
clear: both;
padding: 0px;
margin: 0px;
}
/* COLUMN SETUP */
.col {
display: block;
float:left;
margin: 1% 0 1% 1.6%;
}
.col:first-child { margin-left: 0; }
.group:before,
.group:after { content:""; display:table; }
.group:after { clear:both;}
.group { zoom:1; /* For IE 6/7 */ }
.span_1_of_5 {
width: 18.72%;
}
@media only screen and (max-width: 480px) {
.col { margin: 1% 0 1% 0%; }
.span_1_of_5 { width: 100%; }
}
h3 { color: #083887; font-family: "Great Vibes", cursive; font-size: 35px; line-height: 160px; font-weight: normal; margin-bottom: 0px; margin-top: 40px; text-align: center; text-shadow: 0 1px 1px #fff; }
h5 { color: #470e03; font-family: 'Droid serif', serif; font-size: 30px; font-weight: 400; font-style: italic; line-height: 44px; margin: 0 0 12px; text-align: center; }
</style>
</head>
<body class="body">
<div class="section group">
<div class="col span_1_of_5">
</div>
<div class="col span_1_of_5">
<h5>Video Auto play</h5>
<br><br>
<video width="320" id="video1" autoplay muted >
</video> </div>
<div class="col span_1_of_5">
<H3 style="text-align:center">Videos</H3>
</div>
<div class="col span_1_of_5">
<h5>Video Auto play</h5>
<br><br>
<video width="320" id="video2" autoplay muted>
</video>
</div>
<div class="col span_1_of_5">
</div>
</div>
<div class="row">
<div style="float:left">
</div>
<div style="float:right">
</div>
</div>
<br><br>
<H3 style="text-align:center">Text Areas</H3>
<div class="section group">
<div class="col span_1_of_5">
</div>
<div class="col span_1_of_5">
<h5>SDP local</h5>
<textarea name="name" id="local" rows="8" cols="45" ></textarea>
<br>
<button type="button" id="button1" class="btn" name="button">Génerer SDP Local</button>
</div>
<div class="col span_1_of_5">
</div>
<div class="col span_1_of_5">
<h5>SDP Distance</h5>
<textarea name="name" id="distant" rows="8" cols="45"></textarea>
<br>
<button type="button" id="button2" class="btn" name="button">Traiter SDP distant</button>
</div>
<div class="col span_1_of_5">
</div>
<span style="float:left">
</span>
<span style="float:left">
</span>
</div>
</body>
<script type="text/javascript">
var videoStream;
navigator.mediaDevices.getUserMedia({video:true,audio:true}).then(function(localStream){
document.getElementById("video1").srcObject=localStream;
videoStream = localStream;
});
//Stream = Track1 (audio) m= + Track2 (video) m=
var peerConnection = new RTCPeerConnection({iceServers:[]});
peerConnection.onicecandidate = function () {
document.getElementById('local').textContent=peerConnection.localDescription.sdp;
}
peerConnection.ontrack = function ( e ) {
document.getElementById('video2').srcObject=e.streams[0];
}
document.getElementById('button1').addEventListener('click', function ( e ) {
peerConnection.onnegotiationneeded = function() {
peerConnection.createOffer().then(function( Offer ) {
document.getElementById("local").textContent=Offer.sdp;
return peerConnection.setLocalDescription(Offer);
});
};
videoStream.getTracks().forEach(function ( track ) {
peerConnection.addTrack( track, videoStream );
});
});
document.getElementById('button2').addEventListener('click', function ( e ) {
var DistantSdp=document.getElementById('distant').value;
var LocalSdp=document.getElementById('local').value.trim();
if(!LocalSdp) {
//Generer une réponse
var desc = new RTCSessionDescription({type:"offer",sdp:DistantSdp});
peerConnection.setRemoteDescription( desc ).then(function ( ) {
videoStream.getTracks().forEach(function ( track ) {
peerConnection.addTrack( track, videoStream );
});
return peerConnection.createAnswer();
}).then(function ( answer ) {
document.getElementById("local").textContent=answer.sdp;
return peerConnection.setLocalDescription(answer);
});
} else {
//Je ne genere pas un sdp local, je traite la réponse.
var desc = new RTCSessionDescription({type:"answer",sdp:DistantSdp});
peerConnection.setRemoteDescription(desc);
}
});
</script>
</html>