Skip to content

Commit

Permalink
Be ready fow new IceCandidate.address field in mediasoup server
Browse files Browse the repository at this point in the history
  • Loading branch information
ibc committed Feb 12, 2024
1 parent 1a591fa commit 9af8136
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/Transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@ export type IceCandidate = {
*/
priority: number;
/**
* The IP address of the candidate.
* The IP address or hostname of the candidate.
*/
address: string;
/**
* The IP address or hostname of the candidate.
* @deprecated Use |address| instead.
*/
ip: string;
/**
Expand Down
4 changes: 3 additions & 1 deletion src/handlers/sdp/MediaSection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ export abstract class MediaSection {
// RTP (1).
candidateObject.component = 1;
candidateObject.foundation = candidate.foundation;
candidateObject.ip = candidate.ip;
// Be ready for new candidate.address field in mediasoup server side
// field and keep backward compatibility with deprecated candidate.ip.
candidateObject.ip = candidate.address ?? candidate.ip;
candidateObject.port = candidate.port;
candidateObject.priority = candidate.priority;
candidateObject.transport = candidate.protocol;
Expand Down
2 changes: 2 additions & 0 deletions src/test/fakeParameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ export function generateTransportRemoteParameters(): mediasoupClient.types.Trans
iceCandidates: [
{
foundation: 'udpcandidate',
address: '9.9.9.9',
ip: '9.9.9.9',
port: 40533,
priority: 1078862079,
Expand All @@ -328,6 +329,7 @@ export function generateTransportRemoteParameters(): mediasoupClient.types.Trans
},
{
foundation: 'udpcandidate',
address: '9.9.9.9',
ip: '9:9:9:9:9:9',
port: 41333,
priority: 1078862089,
Expand Down

0 comments on commit 9af8136

Please sign in to comment.