Skip to content

Commit

Permalink
feat: add forceCodec option
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverlaz committed Oct 15, 2024
1 parent 696a4ef commit 7071ad7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion packages/client/src/rtc/Publisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,8 @@ export class Publisher {
opts: PublishOptions,
mediaStream: MediaStream,
) => {
const codecInUse = getOptimalVideoCodec(opts.preferredCodec);
const { forceCodec, preferredCodec } = opts;
const codecInUse = forceCodec || getOptimalVideoCodec(preferredCodec);
const videoEncodings = this.computeLayers(trackType, track, opts);
const transceiver = this.pc.addTransceiver(track, {
direction: 'sendonly',
Expand Down
6 changes: 6 additions & 0 deletions packages/client/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ export type PublishOptions = {
* The preferred codec to use when publishing the video stream.
*/
preferredCodec?: PreferredCodec;
/**
* Force the codec to use when publishing the video stream.
* This will override the preferred codec and the internal codec selection logic.
* Use with caution.
*/
forceCodec?: PreferredCodec;
/**
* The preferred scalability to use when publishing the video stream.
* Applicable only for SVC codecs.
Expand Down
5 changes: 2 additions & 3 deletions sample-apps/react/react-dogfood/components/MeetingUI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,13 @@ export const MeetingUI = ({ chatClient, mode }: MeetingUIProps) => {
if (!fastJoin) setShow('loading');
if (!call) throw new Error('No active call found');
try {
const prontoDefaultCodec = 'vp9';
const preferredCodec = videoCodecOverride || prontoDefaultCodec;
const preferredBitrate = bitrateOverride
? parseInt(bitrateOverride, 10)
: undefined;

call.updatePublishOptions({
preferredCodec,
preferredCodec: 'vp9',
forceCodec: videoCodecOverride,
scalabilityMode,
preferredBitrate,
bitrateDownscaleFactor: bitrateFactorOverride
Expand Down

0 comments on commit 7071ad7

Please sign in to comment.