Skip to content

Commit 21995dd

Browse files
committed
add general set received track quality method
a
1 parent b2bf736 commit 21995dd

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

packages/react-client/src/hooks/usePeers.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { FishjamClient, Metadata, Peer, SimulcastConfig, TrackMetadata, Variant } from "@fishjam-cloud/ts-client";
2-
import { useContext } from "react";
2+
import { useCallback, useContext } from "react";
33

44
import { FishjamClientContext } from "../contexts/fishjamClient";
55
import { FishjamClientStateContext } from "../contexts/fishjamState";
@@ -119,6 +119,11 @@ export function usePeers<PeerMetadata = Record<string, unknown>, ServerMetadata
119119
),
120120
);
121121

122+
const setReceivedTrackQuality = useCallback(
123+
(trackId: string, quality: Variant) => fishjamClient.current.setTargetTrackEncoding(trackId, quality),
124+
[fishjamClient],
125+
);
126+
122127
return {
123128
/**
124129
* The local peer with distinguished tracks (camera, microphone, screen share).
@@ -133,5 +138,11 @@ export function usePeers<PeerMetadata = Record<string, unknown>, ServerMetadata
133138
* This property will be removed in future versions.
134139
*/
135140
peers: remotePeers,
141+
/**
142+
* This function allows to set the quality of a track received from a remote peer.
143+
* @param trackId The id of the track to set the quality for.
144+
* @param encoding The encoding to set for the track.
145+
*/
146+
setReceivedTrackQuality,
136147
};
137148
}

0 commit comments

Comments
 (0)