Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use default video dimensions when they are not available #709

Merged
merged 1 commit into from
May 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/three-drinks-attack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'livekit-client': patch
---

Use default video dimensions when they are not available
14 changes: 11 additions & 3 deletions src/room/participant/LocalParticipant.ts
Original file line number Diff line number Diff line change
@@ -17,7 +17,6 @@ import LocalTrack from '../track/LocalTrack';
import LocalTrackPublication from '../track/LocalTrackPublication';
import LocalVideoTrack, { videoLayersFromEncodings } from '../track/LocalVideoTrack';
import { Track } from '../track/Track';
import { ScreenSharePresets, isBackupCodec, isCodecEqual } from '../track/options';
import type {
AudioCaptureOptions,
BackupVideoCodec,
@@ -26,12 +25,13 @@ import type {
TrackPublishOptions,
VideoCaptureOptions,
} from '../track/options';
import { ScreenSharePresets, VideoPresets, isBackupCodec, isCodecEqual } from '../track/options';
import { constraintsForOptions, mergeDefaultOptions } from '../track/utils';
import type { DataPublishOptions } from '../types';
import { Future, isFireFox, isSVCCodec, isSafari, isWeb, supportsAV1, supportsVP9 } from '../utils';
import Participant from './Participant';
import { trackPermissionToProto } from './ParticipantTrackPermission';
import type { ParticipantTrackPermission } from './ParticipantTrackPermission';
import { trackPermissionToProto } from './ParticipantTrackPermission';
import RemoteParticipant from './RemoteParticipant';
import {
computeTrackBackupEncodings,
@@ -608,8 +608,16 @@ export default class LocalParticipant extends Participant {
try {
dims = await track.waitForDimensions();
} catch (e) {
// use defaults, it's quite painful for congestion control without simulcast
// so using default dims according to publish settings
const defaultRes =
this.roomOptions.videoCaptureDefaults?.resolution ?? VideoPresets.h720.resolution;
dims = {
width: defaultRes.width,
height: defaultRes.height,
};
// log failure
log.error('could not determine track dimensions');
log.error('could not determine track dimensions, using defaults', dims);
}
// width and height should be defined for video
req.width = dims.width;
2 changes: 1 addition & 1 deletion src/room/track/LocalTrack.ts
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ import {
import { Track, attachToElement, detachTrack } from './Track';
import type { VideoCodec } from './options';

const defaultDimensionsTimeout = 2 * 1000;
const defaultDimensionsTimeout = 1000;

export default abstract class LocalTrack extends Track {
/** @internal */