import ContentShareConstants from '../contentsharecontroller/ContentShareConstants' ; import Logger from '../logger/Logger' ; import VideoStreamDescription from '../videostreamindex/VideoStreamDescription' ; import VideoStreamIndex from '../videostreamindex/VideoStreamIndex' ; import VideoPreference from './VideoPreference' ; import { VideoPreferences } from './VideoPreferences' ; import VideoPriorityBasedPolicy from './VideoPriorityBasedPolicy' ; export default class VideoAdaptiveProbePolicy extends VideoPriorityBasedPolicy { constructor ( protected logger ) { super ( logger ) ; super . shouldPauseTiles = false ; this . videoPreferences = undefined ; } reset ( ) { super . reset ( ) ; super . shouldPauseTiles = false ; this . videoPreferences = undefined ; } updateIndex ( videoIndex ) { super . updateIndex ( videoIndex ) ; const newPreferences = VideoPreferences . prepare ( ) ; let containsContent = false ; const remoteInfos = videoIndex . remoteStreamDescriptions ( ) ; for ( const info of remoteInfos ) { if ( ! newPreferences . some ( preference => preference . attendeeId === info . attendeeId ) ) { if ( info . attendeeId . endsWith ( ContentShareConstants . Modality ) ) { newPreferences . add ( new VideoPreference ( info . attendeeId , 1 ) ) ; containsContent = true ; } else { newPreferences . add ( new VideoPreference ( info . attendeeId , 2 ) ) ; } } } if ( containsContent ) { this . videoPreferences = newPreferences . build ( ) ; this . videoPreferencesUpdated = true ; } else { this . videoPreferences = undefined ; } } /**
     * [[VideoAdaptiveProbePolicy]] does not allow setting video preferences and this function
     * will be a no-op.  Please use [[VideoPriorityBasedPolicy]] directly if you would like to set
     * preferences.
     */ chooseRemoteVideoSources ( _preferences ) { this . logger . error ( 'chooseRemoteVideoSources should not be called by VideoAdaptiveProbePolicy' ) ; return ; } }