import AudioVideoControllerState from '../audiovideocontroller/AudioVideoControllerState' ; import BaseTask from './BaseTask' ; export default class ReleaseMediaStreamsTask extends BaseTask { protected taskName = 'ReleaseMediaStreamsTask' ; constructor ( private context ) { super ( context . logger ) ; } async run ( ) { if ( ! this . context . mediaStreamBroker ) { return ; } try { this . context . mediaStreamBroker . releaseMediaStream ( this . context . activeAudioInput ) ; this . context . activeAudioInput = null ; this . context . mediaStreamBroker . releaseMediaStream ( this . context . activeVideoInput ) ; this . context . activeVideoInput = null ; this . context . realtimeController . realtimeSetLocalAudioInput ( null ) ; } catch ( e ) { this . context . logger . error ( `Failed to release media streams: ${ e }` ) ; } } }