import { Pipeline } from './pipeline' ; import { HttpMp4Source , HttpConfig } from '../components/http-mp4' ; import { MseSink } from '../components/mse' ; export interface HttpMseConfig { http : HttpConfig ; mediaElement : HTMLVideoElement ; } export class HttpMsePipeline extends Pipeline { public onHeaders ? : ( headers : Headers ) => void ; public onServerClose ? : ( ) => void ; public http : HttpMp4Source ; private readonly _src ? : HttpMp4Source ; private readonly _sink : MseSink ; constructor ( config ) { const { http : httpConfig , mediaElement } = config ; const httpSource = new HttpMp4Source ( httpConfig ) ; const mseSink = new MseSink ( mediaElement ) ; httpSource . onHeaders = ( headers ) => { this . onHeaders && this . onHeaders ( headers ) ; } ; httpSource . onServerClose = ( ) => this . onServerClose ?. ( ) ; super ( httpSource , mseSink ) ; this . _src = httpSource ; this . _sink = mseSink ; this . http = httpSource ; } close ( ) { this . _src && this . _src . abort ( ) ; } get currentTime ( ) { return this . _sink . currentTime ; } async play ( ) { return await this . _sink . play ( ) ; } pause ( ) { return this . _sink . pause ( ) ; } }