@@ -44,10 +44,7 @@ export async function getRouterCapabilities(meetingId) {
4444 await sfuClient . connect ( meetingId ) ;
4545 }
4646
47- // Get capabilities directly from SFU
4847 const capabilities = await sfuClient . getRouterRtpCapabilities ( ) ;
49-
50- // Initialize mediasoup device with the capabilities
5148 await initializeMediasoupDevice ( capabilities ) ;
5249
5350 return {
@@ -553,7 +550,7 @@ export async function subscribeToProducer(meetingId, producerId) {
553550
554551 consumers . set ( consumer . id , consumer ) ;
555552
556- // CRITICAL: Ensure consumer is resumed (MediaSoup consumers are created paused by default)
553+ // Ensure consumer is resumed if paused
557554 if ( consumer . paused ) {
558555 try {
559556 await consumer . resume ( ) ;
@@ -562,49 +559,6 @@ export async function subscribeToProducer(meetingId, producerId) {
562559 `❌ Failed to resume consumer ${ consumer . id } :` ,
563560 resumeError ,
564561 ) ;
565- // Don't throw here, continue and see if video works anyway
566- }
567- }
568-
569- // Wait a moment for video track to initialize after resume
570- if ( consumer . kind === "video" ) {
571- await new Promise ( ( resolve ) => setTimeout ( resolve , 1000 ) ) ;
572- }
573-
574- // CRITICAL: Verify video track has dimensions (with multiple attempts)
575- if ( consumer . kind === "video" && consumer . track ) {
576- let dimensionCheckAttempts = 0 ;
577- const maxDimensionChecks = 5 ;
578- let hasValidDimensions = false ;
579-
580- while (
581- dimensionCheckAttempts < maxDimensionChecks &&
582- ! hasValidDimensions
583- ) {
584- const settings = consumer . track . getSettings ( ) ;
585- dimensionCheckAttempts ++ ;
586-
587- if (
588- settings . width &&
589- settings . height &&
590- settings . width > 0 &&
591- settings . height > 0
592- ) {
593- hasValidDimensions = true ;
594- break ;
595- }
596-
597- // If no dimensions yet, wait and try again
598- if ( dimensionCheckAttempts < maxDimensionChecks ) {
599- await new Promise ( ( resolve ) => setTimeout ( resolve , 1500 ) ) ;
600- }
601- }
602-
603- // If we exhausted all attempts without getting dimensions
604- if ( ! hasValidDimensions ) {
605- console . warn (
606- `⚠️ Video consumer created but track has no dimensions after ${ maxDimensionChecks } attempts - continuing anyway` ,
607- ) ;
608562 }
609563 }
610564
@@ -807,12 +761,8 @@ export async function runNetworkDiagnostics() {
807761 }
808762}
809763
810- /**
811- * Helper function to ensure device is ready
812- */
813764async function ensureDeviceReady ( meetingId ) {
814765 if ( ! mediasoupDevice || ! mediasoupDevice . loaded ) {
815- console . log ( "Device not ready, requesting router capabilities..." ) ;
816766 await getRouterCapabilities ( meetingId ) ;
817767 }
818768
@@ -821,9 +771,6 @@ async function ensureDeviceReady(meetingId) {
821771 }
822772}
823773
824- /**
825- * Clean up all mediasoup resources
826- */
827774export function cleanupMediasoup ( ) {
828775 // Close all producers
829776 for ( const producer of producers . values ( ) ) {
0 commit comments