質問編集履歴
3
スクリプトの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -4,281 +4,7 @@
|
|
4
4
|
|
5
5
|
しかし相手と接続しても音声の通信がうまく行かない状態です・・・
|
6
6
|
|
7
|
-
下記がJavaScriptになります
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
```ここに言語を入力
|
12
|
-
|
13
|
-
then(function(stream){
|
14
|
-
|
15
|
-
//上記の中身が自分で書いたものなので、誤りがある箇所として濃厚です。
|
16
|
-
|
17
|
-
```
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
webRTCで取得した音声データと
|
22
|
-
|
23
|
-
web audio APIの接続部分のご確認のほど
|
24
|
-
|
25
|
-
お願い致します
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
```JavaScript
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
let localStream = null;
|
34
|
-
|
35
|
-
let peer = null;
|
36
|
-
|
37
|
-
let existingCall = null;
|
38
|
-
|
39
|
-
let peerConnection = null;
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
//audio処理用
|
44
|
-
|
45
|
-
window.AudioContext = window.AudioContext || window.webkitAudioContext;
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
navigator.mediaDevices.getUserMedia(
|
50
|
-
|
51
|
-
{ video : false , audio : true })
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
.then(function(stream){
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
var context = new AudioContext();
|
60
|
-
|
61
|
-
var source = context.createMediaStreamSource(stream);
|
62
|
-
|
63
|
-
var gainNode = context.createGain();
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
gainNode.gain.value = 2.0;
|
68
|
-
|
69
|
-
source.connect(gainNode);
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
var peer1 = context.createMediaStreamDestination();
|
74
|
-
|
75
|
-
gainNode.connect(peer1);
|
76
|
-
|
77
|
-
peerConnection.addstream(peer1.stream);
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
localStream = stream;
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
}).catch(function (error) {
|
86
|
-
|
87
|
-
// Error
|
88
|
-
|
89
|
-
console.error('mediaDevice.getUserMedia() error:', error);
|
90
|
-
|
91
|
-
return;
|
92
|
-
|
93
|
-
});
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
///////////Peerオブジェクトの作成
|
98
|
-
|
99
|
-
peer = new Peer({
|
100
|
-
|
101
|
-
key: 'my_APIkey', //ここにAPIkeyが入ってます
|
102
|
-
|
103
|
-
debug: 3
|
104
|
-
|
105
|
-
});
|
106
|
-
|
107
|
-
///////////////////////
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
//ここから下はskywayのサンプル参考
|
112
|
-
|
113
|
-
///////////////open,error,close,disconnectedイベント
|
114
|
-
|
115
|
-
peer.on('open', function(){ //発火する
|
116
|
-
|
117
|
-
$('#my-id').text(peer.id); //Peer IDの自動作成
|
118
|
-
|
119
|
-
});
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
peer.on('error', function(err){
|
124
|
-
|
125
|
-
alert(err.message);
|
126
|
-
|
127
|
-
});
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
peer.on('close', function(){
|
132
|
-
|
133
|
-
});
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
peer.on('disconnected', function(){
|
138
|
-
|
139
|
-
});
|
140
|
-
|
141
|
-
//////////////////////////
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
///////////////発信処理・切断処理・着信処理
|
148
|
-
|
149
|
-
$('#make-call').submit(function(e){
|
150
|
-
|
151
|
-
e.preventDefault();
|
152
|
-
|
153
|
-
const call = peer.call($('#callto-id').val(), localStream);
|
154
|
-
|
155
|
-
setupCallEventHandlers(call);
|
156
|
-
|
157
|
-
});
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
$('#end-call').click(function(){
|
162
|
-
|
163
|
-
existingCall.close();
|
164
|
-
|
165
|
-
});
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
peer.on('call', function(call){
|
170
|
-
|
171
|
-
call.answer(localStream);
|
172
|
-
|
173
|
-
setupCallEventHandlers(call);
|
174
|
-
|
175
|
-
});
|
176
|
-
|
177
|
-
/////////////////////
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
//////////Callオブジェクトに必要なイベント
|
184
|
-
|
185
|
-
function setupCallEventHandlers(call){
|
186
|
-
|
187
|
-
if (existingCall) {
|
188
|
-
|
189
|
-
existingCall.close();
|
190
|
-
|
191
|
-
};
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
existingCall = call;
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
call.on('stream', function(stream){
|
200
|
-
|
201
|
-
addVideo(call,stream);
|
202
|
-
|
203
|
-
setupEndCallUI();
|
204
|
-
|
205
|
-
$('#their-id').text(call.remoteId);
|
206
|
-
|
207
|
-
});
|
208
|
-
|
209
|
-
call.on('close', function(){
|
210
|
-
|
211
|
-
removeVideo(call.remoteId);
|
212
|
-
|
213
|
-
setupMakeCallUI();
|
214
|
-
|
215
|
-
});
|
216
|
-
|
217
|
-
}
|
218
|
-
|
219
|
-
//////////////////////////////////
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
///////////video要素の再生・削除・ボタン表示
|
226
|
-
|
227
|
-
function addVideo(call,stream){
|
228
|
-
|
229
|
-
$('#their-video').get(0).srcObject = stream;
|
230
|
-
|
231
|
-
}
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
function removeVideo(peerId){
|
236
|
-
|
237
|
-
$('#'+peerId).remove();
|
238
|
-
|
239
|
-
}
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
function setupMakeCallUI(){
|
244
|
-
|
245
|
-
$('#make-call').show();
|
246
|
-
|
247
|
-
$('#end-call').hide();
|
248
|
-
|
249
|
-
}
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
function setupEndCallUI() {
|
254
|
-
|
255
|
-
$('#make-call').hide();
|
256
|
-
|
257
|
-
$('#end-call').show();
|
258
|
-
|
259
|
-
}
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
```
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
```ここに言語を入力
|
272
|
-
|
273
|
-
peer.on('open', function(){
|
274
|
-
|
275
|
-
//上記の中身はskywayのサンプルコード取ってきたのでほぼ間違いないかと
|
276
|
-
|
277
|
-
```
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
長文となりましたが
|
282
8
|
|
283
9
|
よろしくお願い致します.
|
284
10
|
|
2
文章の修正
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
webRTC
|
1
|
+
webRTCとweb audio APIの繋ぎ方
|
test
CHANGED
File without changes
|
1
文章の修正
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
webRTCからのマイク入力をweb audio APIで調整する方法
|
test
CHANGED
File without changes
|