1
0

Testing audio

Signed-off-by: James Ketrenos <james_eikona@ketrenos.com>
This commit is contained in:
James Ketrenos 2022-03-14 19:29:02 -07:00
parent 2182d9b0c1
commit 221dd0e726
2 changed files with 35 additions and 19 deletions

View File

@ -80,15 +80,21 @@ const MediaAgent = () => {
offerToReceiveAudio: true,
offerToReceiveVideo: false
},
iceServers: [
{ urls: "stun:stun.l.google.com:19302" },
{ urls: "stun:stun.stunprotocol.org:3478" }
]
iceServers: [ {
/* urls: "stun:stun.l.google.com:19302" }, {
urls: "stun:stun.stunprotocol.org:3478" }, { */
// urls: "turn:ketrenos.com:3478",
// username: "ketra",
// credential: "ketran"
urls: "turn:numb.viagenie.ca",
username: "james_viagenie@ketrenos.com",
credential: "1!viagenie"
} ]
}, {
/* this will no longer be needed by chrome
* eventually (supposedly), but is necessary
* for now to get firefox to talk to chrome */
optional: [{DtlsSrtpKeyAgreement: true}]
//optional: [{DtlsSrtpKeyAgreement: true}]
});
peers[peer_id] = {
@ -99,12 +105,23 @@ const MediaAgent = () => {
console.log(`media-agent - addPeer - remote`, peers);
setPeers(Object.assign({}, peers));
connection.addEventListener('icecandidateerror', (event) => {
if (event.errorCode === 701) {
if (connection.icegatheringstate === 'gathering') {
console.log(`Unable to reach host: ${event.url}`);
} else {
console.error(`media-agent - icecandidateerror - `, event.url, event.errorText);
}
}
});
connection.onicecandidate = (event) => {
if (!event.candidate) {
console.error(`media-agent - icecanditate - gathering is complete: ${connection.connectinoState}`);
return;
}
/* If a srflx candidate was found, notify that the STUN server works! */
if (event.candidate.type === "srflx"){
/* If a srflx candidate was found, notify that the STUN server works! */
if (event.candidate.type === "srflx"){
console.log("The STUN server is reachable!");
console.log(` Your Public IP Address is: ${event.candidate.address}`);
}
@ -114,14 +131,13 @@ const MediaAgent = () => {
console.log("The TURN server is reachable !");
}
console.log(`media-agent - onicecandidate - `, event.candidate);
sendMessage({
type: 'relayICECandidate',
config: {
peer_id: peer_id,
ice_candidate: {
sdpMLineIndex: event.candidate.sdpMLineIndex,
candidate: event.candidate.candidate
}
peer_id,
candidate: event.candidate
}
});
};
@ -147,7 +163,7 @@ const MediaAgent = () => {
sendMessage({
type: 'relaySessionDescription',
config: {
'peer_id': peer_id,
peer_id,
'session_description': local_description
}
});
@ -222,7 +238,7 @@ const MediaAgent = () => {
setPeers(Object.assign({}, peers));
};
const iceCandidate = ({ peer_id, ice_candidate }) => {
const iceCandidate = ({ peer_id, candidate }) => {
/**
* The offerer will send a number of ICE Candidate blobs to the
* answerer so they can begin trying to find the best path to one
@ -233,12 +249,12 @@ const MediaAgent = () => {
console.error(`media-agent - iceCandidate - No peer for ${peer_id}`, peers);
return;
}
peer.connection.addIceCandidate(new RTCIceCandidate(ice_candidate))
peer.connection.addIceCandidate(new RTCIceCandidate(candidate))
.then(() => {
if (debug) console.log(`media-agent - iceCandidate - Successfully added Ice Candidate for ${peer_id}`);
})
.catch((error) => {
console.error(error, peer, ice_candidate);
console.error(error, peer, candidate);
});
};

View File

@ -3373,13 +3373,13 @@ router.ws("/ws/:id", async (ws, req) => {
return;
}
const { peer_id, ice_candidate } = data.config;
const { peer_id, candidate } = data.config;
if (debug.audio) console.log(`${short}:${id} <- relayICECandidate ${getName(session)} to ${peer_id}`,
ice_candidate);
candidate);
message = JSON.stringify({
type: 'iceCandidate',
data: {'peer_id': getName(session), 'ice_candidate': ice_candidate }
data: {'peer_id': getName(session), 'candidate': candidate }
});
if (peer_id in audio[id]) {