Skip to content

Commit

Permalink
Remove googConstraints from RTCPeerConnection constructor (#1022)
Browse files Browse the repository at this point in the history
* Remove googConstraints from RTCPeerConnection constructor

* update pc manager

* Create great-impalas-try.md
  • Loading branch information
lukasIO authored Feb 5, 2024
1 parent e67f6b7 commit 88d404b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
5 changes: 5 additions & 0 deletions .changeset/great-impalas-try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"livekit-client": patch
---

Remove googConstraints from RTCPeerConnection constructor
16 changes: 3 additions & 13 deletions src/room/PCTransport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { debounce } from 'ts-debounce';
import log, { LoggerNames, getLogger } from '../logger';
import { NegotiationError, UnexpectedConnectionState } from './errors';
import type { LoggerOptions } from './types';
import { ddExtensionURI, isChromiumBased, isSVCCodec } from './utils';
import { ddExtensionURI, isSVCCodec } from './utils';

/** @internal */
interface TrackBitrateInfo {
Expand Down Expand Up @@ -42,8 +42,6 @@ export default class PCTransport extends EventEmitter {

private config?: RTCConfiguration;

private mediaConstraints: Record<string, unknown>;

private log = log;

private loggerOptions: LoggerOptions;
Expand Down Expand Up @@ -76,24 +74,16 @@ export default class PCTransport extends EventEmitter {

onTrack?: (ev: RTCTrackEvent) => void;

constructor(
config?: RTCConfiguration,
mediaConstraints: Record<string, unknown> = {},
loggerOptions: LoggerOptions = {},
) {
constructor(config?: RTCConfiguration, loggerOptions: LoggerOptions = {}) {
super();
this.log = getLogger(loggerOptions.loggerName ?? LoggerNames.PCTransport);
this.loggerOptions = loggerOptions;
this.config = config;
this.mediaConstraints = mediaConstraints;
this._pc = this.createPC();
}

private createPC() {
const pc = isChromiumBased()
? // @ts-expect-error chrome allows additional media constraints to be passed into the RTCPeerConnection constructor
new RTCPeerConnection(this.config, this.mediaConstraints)
: new RTCPeerConnection(this.config);
const pc = new RTCPeerConnection(this.config);

pc.onicecandidate = (ev) => {
if (!ev.candidate) return;
Expand Down
3 changes: 1 addition & 2 deletions src/room/PCTransportManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ export class PCTransportManager {

this.isPublisherConnectionRequired = !subscriberPrimary;
this.isSubscriberConnectionRequired = subscriberPrimary;
const googConstraints = { optional: [{ googDscp: true }] };
this.publisher = new PCTransport(rtcConfig, googConstraints, loggerOptions);
this.publisher = new PCTransport(rtcConfig, loggerOptions);
this.subscriber = new PCTransport(rtcConfig, loggerOptions);

this.publisher.onConnectionStateChange = this.updateState;
Expand Down

0 comments on commit 88d404b

Please sign in to comment.