Skip to content

Commit

Permalink
Redundant code (#78)
Browse files Browse the repository at this point in the history
## Description

Those methods are probably redundant. 

## Motivation and Context

Clean up the codebase.

## Types of changes

Bug fix (non-breaking change which fixes an issue)
  • Loading branch information
kamil-stasiak authored Sep 3, 2024
1 parent eeb87df commit b6bc417
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 28 deletions.
13 changes: 0 additions & 13 deletions packages/ts-client/src/webrtc/ConnectionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ export class ConnectionManager {
return this.connection;
};

public setTransceiversToReadOnly = () => {
this.connection.getTransceivers().forEach((transceiver) => (transceiver.direction = 'sendonly'));
};

public addTransceiversIfNeeded = (serverTracks: Map<string, number>) => {
const recvTransceivers = this.connection.getTransceivers().filter((elem) => elem.direction === 'recvonly');

Expand Down Expand Up @@ -88,15 +84,6 @@ export class ConnectionManager {

public isTrackInUse = (track: MediaStreamTrack) => this.connection.getSenders().some((val) => val.track === track);

public setTransceiverDirection = () => {
this.connection
.getTransceivers()
.filter((transceiver) => transceiver.direction === 'sendrecv')
.forEach((transceiver) => {
transceiver.direction = 'sendonly';
});
};

public removeTrack = (sender: RTCRtpSender) => {
this.connection.removeTrack(sender);
};
Expand Down
11 changes: 0 additions & 11 deletions packages/ts-client/src/webrtc/tracks/Local.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,6 @@ export class Local<EndpointMetadata, TrackMetadata> {
return trackManager;
};

public disableAllLocalTrackEncodings = async () => {
// TODO: Why are we disabling already disabled encodings?
// I think this part of the code is invoked to mutate RTCRtpSender.getParameters().encodings.active.
// We should probably implement a separate method for that, because disabling already disabled tracks seems weird.
for (const [trackId, trackManager] of Object.entries(this.localTracks)) {
for (const encoding of trackManager.getDisabledEncodings()) {
await this.disableLocalTrackEncoding(trackId, encoding);
}
}
};

public getTrackByMidOrNull = (mid: string): LocalTrack<EndpointMetadata, TrackMetadata> | null => {
return Object.values(this.localTracks).find((track) => track.mLineId === mid) ?? null;
};
Expand Down
1 change: 0 additions & 1 deletion packages/ts-client/src/webrtc/tracks/LocalTrackManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ export class LocalTrackManager<EndpointMetadata, TrackMetadata> {

if (this.connection) {
trackManager.addTrackToConnection();
this.connection.setTransceiverDirection();
}

const mediaEvent = generateCustomEvent({ type: 'renegotiateTracks' });
Expand Down
3 changes: 0 additions & 3 deletions packages/ts-client/src/webrtc/webRTCEndpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,6 @@ export class WebRTCEndpoint<EndpointMetadata = any, TrackMetadata = any> extends

try {
await this.connectionManager.setRemoteDescription(data);
await this.local.disableAllLocalTrackEncodings();
} catch (err) {
console.error(err);
}
Expand Down Expand Up @@ -757,8 +756,6 @@ export class WebRTCEndpoint<EndpointMetadata = any, TrackMetadata = any> extends
this.commandsQueue.initConnection(connection);

this.local.addAllTracksToConnection();

connection.setTransceiversToReadOnly();
}

this.localTrackManager.updateSenders();
Expand Down

0 comments on commit b6bc417

Please sign in to comment.