@@ -762,7 +762,10 @@ export class WebRTCClient extends Emitter<EventMap> {
762762 return this . media . listDevices ( ) ;
763763 }
764764
765- /** Set audio output device for a media element (or local preview by default). */
765+ /**
766+ * Set audio output device (sinkId) for a media element (or local preview by default).
767+ * If the browser does not support sinkId, an `error` event with code `set_sink_id_unsupported` is emitted.
768+ */
766769 async setAudioOutput ( deviceId : string , element ?: HTMLMediaElement | null ) : Promise < void > {
767770 await this . media . setAudioOutput ( deviceId , element ) ;
768771 }
@@ -860,7 +863,8 @@ export class WebRTCClient extends Emitter<EventMap> {
860863 * sdk.enableTrack('mainStreamId', 'camera_user3', true);
861864 * ```
862865 */
863- enableTrack ( mainTrackId : string , trackId : string , enabled : boolean ) : void {
866+ async enableTrack ( mainTrackId : string , trackId : string , enabled : boolean ) : Promise < void > {
867+ await this . ready ( ) ;
864868 if ( ! this . ws ) return ;
865869 const jsCmd = {
866870 command : "enableTrack" ,
@@ -879,7 +883,8 @@ export class WebRTCClient extends Emitter<EventMap> {
879883 * sdk.forceStreamQuality('mainStreamId', 720); // or 'auto'
880884 * ```
881885 */
882- forceStreamQuality ( streamId : string , height : number | "auto" ) : void {
886+ async forceStreamQuality ( streamId : string , height : number | "auto" ) : Promise < void > {
887+ await this . ready ( ) ;
883888 if ( ! this . ws ) return ;
884889 const jsCmd = {
885890 command : "forceStreamQuality" ,
@@ -1296,49 +1301,57 @@ export class WebRTCClient extends Emitter<EventMap> {
12961301 }
12971302
12981303 /** Request stream info; listen on 'notification:streamInformation' or stream_information. */
1299- getStreamInfo ( streamId : string ) : void {
1304+ async getStreamInfo ( streamId : string ) : Promise < void > {
1305+ await this . ready ( ) ;
13001306 if ( ! this . ws ) return ;
13011307 this . ws . send ( JSON . stringify ( { command : "getStreamInfo" , streamId } ) ) ;
13021308 }
13031309
13041310 /** Request broadcast object; listen on 'notification:broadcastObject' or broadcast_object. */
1305- getBroadcastObject ( streamId : string ) : void {
1311+ async getBroadcastObject ( streamId : string ) : Promise < void > {
1312+ await this . ready ( ) ;
13061313 if ( ! this . ws ) return ;
13071314 this . ws . send ( JSON . stringify ( { command : "getBroadcastObject" , streamId } ) ) ;
13081315 }
13091316
13101317 /** Request room info of roomId; optionally include streamId for context. */
1311- getRoomInfo ( roomId : string , streamId = "" ) : void {
1318+ async getRoomInfo ( roomId : string , streamId = "" ) : Promise < void > {
1319+ await this . ready ( ) ;
13121320 if ( ! this . ws ) return ;
13131321 this . ws . send ( JSON . stringify ( { command : "getRoomInfo" , room : roomId , streamId } ) ) ;
13141322 }
13151323
13161324 /** Request track list under a main stream. */
1317- getTracks ( streamId : string , token = "" ) : void {
1325+ async getTracks ( streamId : string , token = "" ) : Promise < void > {
1326+ await this . ready ( ) ;
13181327 if ( ! this . ws ) return ;
13191328 this . ws . send ( JSON . stringify ( { command : "getTrackList" , streamId, token } ) ) ;
13201329 }
13211330
13221331 /** Request subtracks for a main stream with optional paging and role filter. */
1323- getSubtracks ( streamId : string , role = "" , offset = 0 , size = 50 ) : void {
1332+ async getSubtracks ( streamId : string , role = "" , offset = 0 , size = 50 ) : Promise < void > {
1333+ await this . ready ( ) ;
13241334 if ( ! this . ws ) return ;
13251335 this . ws . send ( JSON . stringify ( { command : "getSubtracks" , streamId, role, offset, size } ) ) ;
13261336 }
13271337
13281338 /** Request subtrack count for a main stream with optional role/status. */
1329- getSubtrackCount ( streamId : string , role = "" , status = "" ) : void {
1339+ async getSubtrackCount ( streamId : string , role = "" , status = "" ) : Promise < void > {
1340+ await this . ready ( ) ;
13301341 if ( ! this . ws ) return ;
13311342 this . ws . send ( JSON . stringify ( { command : "getSubtracksCount" , streamId, role, status } ) ) ;
13321343 }
13331344
13341345 /** Request current subscriber count; listen on subscriber_count. */
1335- getSubscriberCount ( streamId : string ) : void {
1346+ async getSubscriberCount ( streamId : string ) : Promise < void > {
1347+ await this . ready ( ) ;
13361348 if ( ! this . ws ) return ;
13371349 this . ws . send ( JSON . stringify ( { command : "getSubscriberCount" , streamId } ) ) ;
13381350 }
13391351
13401352 /** Request current subscriber list; listen on subscriber_list. */
1341- getSubscriberList ( streamId : string , offset = 0 , size = 50 ) : void {
1353+ async getSubscriberList ( streamId : string , offset = 0 , size = 50 ) : Promise < void > {
1354+ await this . ready ( ) ;
13421355 if ( ! this . ws ) return ;
13431356 this . ws . send ( JSON . stringify ( { command : "getSubscribers" , streamId, offset, size } ) ) ;
13441357 }
@@ -1416,7 +1429,8 @@ export class WebRTCClient extends Emitter<EventMap> {
14161429 }
14171430
14181431 /** Request video track assignments list for a main stream. */
1419- requestVideoTrackAssignments ( streamId : string ) : void {
1432+ async requestVideoTrackAssignments ( streamId : string ) : Promise < void > {
1433+ await this . ready ( ) ;
14201434 if ( ! this . ws ) return ;
14211435 this . ws . send ( JSON . stringify ( { command : "getVideoTrackAssignmentsCommand" , streamId } ) ) ;
14221436 }
@@ -1453,7 +1467,10 @@ export class WebRTCClient extends Emitter<EventMap> {
14531467 * sdk.updateVideoTrackAssignments({ streamId: 'main', offset: 20, size: 10 });
14541468 * ```
14551469 */
1456- updateVideoTrackAssignments ( opts : import ( "./types.js" ) . UpdateVideoTrackAssignmentsOptions ) : void {
1470+ async updateVideoTrackAssignments (
1471+ opts : import ( "./types.js" ) . UpdateVideoTrackAssignmentsOptions
1472+ ) : Promise < void > {
1473+ await this . ready ( ) ;
14571474 if ( ! this . ws ) return ;
14581475 this . ws . send (
14591476 JSON . stringify ( {
@@ -1473,7 +1490,8 @@ export class WebRTCClient extends Emitter<EventMap> {
14731490 * sdk.setMaxVideoTrackCount('mainStreamId', 9);
14741491 * ```
14751492 */
1476- setMaxVideoTrackCount ( streamId : string , maxTrackCount : number ) : void {
1493+ async setMaxVideoTrackCount ( streamId : string , maxTrackCount : number ) : Promise < void > {
1494+ await this . ready ( ) ;
14771495 if ( ! this . ws ) return ;
14781496 this . ws . send (
14791497 JSON . stringify ( {
0 commit comments