Skip to content

Commit

Permalink
add force relay configuration (#414)
Browse files Browse the repository at this point in the history
* add force relay configuration

* proto version
  • Loading branch information
cnderrauber committed Aug 25, 2022
1 parent 1f33f80 commit 6b748da
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/empty-gorillas-battle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'livekit-client': patch
---

add force relay configuration
19 changes: 18 additions & 1 deletion src/proto/livekit_models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@ export interface ClientConfiguration {
screen?: VideoConfiguration;
resumeConnection: ClientConfigSetting;
disabledCodecs?: DisabledCodecs;
forceRelay: ClientConfigSetting;
}

export interface VideoConfiguration {
Expand Down Expand Up @@ -2094,7 +2095,13 @@ export const ClientInfo = {
};

function createBaseClientConfiguration(): ClientConfiguration {
return { video: undefined, screen: undefined, resumeConnection: 0, disabledCodecs: undefined };
return {
video: undefined,
screen: undefined,
resumeConnection: 0,
disabledCodecs: undefined,
forceRelay: 0,
};
}

export const ClientConfiguration = {
Expand All @@ -2111,6 +2118,9 @@ export const ClientConfiguration = {
if (message.disabledCodecs !== undefined) {
DisabledCodecs.encode(message.disabledCodecs, writer.uint32(34).fork()).ldelim();
}
if (message.forceRelay !== 0) {
writer.uint32(40).int32(message.forceRelay);
}
return writer;
},

Expand All @@ -2133,6 +2143,9 @@ export const ClientConfiguration = {
case 4:
message.disabledCodecs = DisabledCodecs.decode(reader, reader.uint32());
break;
case 5:
message.forceRelay = reader.int32() as any;
break;
default:
reader.skipType(tag & 7);
break;
Expand All @@ -2151,6 +2164,7 @@ export const ClientConfiguration = {
disabledCodecs: isSet(object.disabledCodecs)
? DisabledCodecs.fromJSON(object.disabledCodecs)
: undefined,
forceRelay: isSet(object.forceRelay) ? clientConfigSettingFromJSON(object.forceRelay) : 0,
};
},

Expand All @@ -2166,6 +2180,8 @@ export const ClientConfiguration = {
(obj.disabledCodecs = message.disabledCodecs
? DisabledCodecs.toJSON(message.disabledCodecs)
: undefined);
message.forceRelay !== undefined &&
(obj.forceRelay = clientConfigSettingToJSON(message.forceRelay));
return obj;
},

Expand All @@ -2186,6 +2202,7 @@ export const ClientConfiguration = {
object.disabledCodecs !== undefined && object.disabledCodecs !== null
? DisabledCodecs.fromPartial(object.disabledCodecs)
: undefined;
message.forceRelay = object.forceRelay ?? 0;
return message;
},
};
Expand Down
6 changes: 6 additions & 0 deletions src/proto/livekit_rtc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export function streamStateToJSON(object: StreamState): string {
export enum CandidateProtocol {
UDP = 0,
TCP = 1,
TLS = 2,
UNRECOGNIZED = -1,
}

Expand All @@ -109,6 +110,9 @@ export function candidateProtocolFromJSON(object: any): CandidateProtocol {
case 1:
case 'TCP':
return CandidateProtocol.TCP;
case 2:
case 'TLS':
return CandidateProtocol.TLS;
case -1:
case 'UNRECOGNIZED':
default:
Expand All @@ -122,6 +126,8 @@ export function candidateProtocolToJSON(object: CandidateProtocol): string {
return 'UDP';
case CandidateProtocol.TCP:
return 'TCP';
case CandidateProtocol.TLS:
return 'TLS';
case CandidateProtocol.UNRECOGNIZED:
default:
return 'UNRECOGNIZED';
Expand Down
7 changes: 7 additions & 0 deletions src/room/RTCEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,13 @@ export default class RTCEngine extends (EventEmitter as new () => TypedEventEmit
this.rtcConfig.iceServers = rtcIceServers;
}

if (
joinResponse.clientConfiguration &&
joinResponse.clientConfiguration.forceRelay === ClientConfigSetting.ENABLED
) {
this.rtcConfig.iceTransportPolicy = 'relay';
}

// @ts-ignore
this.rtcConfig.sdpSemantics = 'unified-plan';
// @ts-ignore
Expand Down

0 comments on commit 6b748da

Please sign in to comment.