import { inject , injectable } from 'inversify' ; import * as apid from '../../../../api' ; import UaUtil from '../..//util/UaUtil' ; import IConfigApiModel from '../api/config/IConfigApiModel' ; import IServerConfigModel from './IServerConfigModel' ; @ injectable ( ) export default class ServerConfigModel implements IServerConfigModel { private configApiModel : IConfigApiModel ; private config : apid . Config | null = null ; constructor ( @ inject ( 'IConfigApiModel' ) configApiModel ) { this . configApiModel = configApiModel ; } return public async fetchConfig ( ) { this . config = await this . configApiModel . getConfig ( ) ; this . setStreamingSettingForiOS ( ) ; } /**
     * iOS で再生できないストリーミングの設定を削除する
     */ private setStreamingSettingForiOS ( ) { if ( UaUtil . isiOS ( ) === false || this . config === null || typeof this . config . streamConfig === 'undefined' ) { return ; } if ( typeof this . config . streamConfig . live !== 'undefined' ) { if ( typeof this . config . streamConfig . live . ts !== 'undefined' ) { delete this . config . streamConfig . live . ts . webm ; delete this . config . streamConfig . live . ts . mp4 ; if ( UaUtil . isiOS ( ) === true && UaUtil . isiPadOS ( ) === false ) { delete this . config . streamConfig . live . ts . m2tsll ; } if ( typeof this . config . streamConfig . live . ts . m2ts === 'undefined' && typeof this . config . streamConfig . live . ts . hls === 'undefined' ) { delete this . config . streamConfig . live . ts ; this . config . isEnableTSLiveStream = false ; } } if ( typeof this . config . streamConfig . live . ts === 'undefined' ) { delete this . config . streamConfig . live ; } } if ( typeof this . config . streamConfig . recorded !== 'undefined' ) { if ( typeof this . config . streamConfig . recorded . ts !== 'undefined' ) { delete this . config . streamConfig . recorded . ts . webm ; delete this . config . streamConfig . recorded . ts . mp4 ; if ( typeof this . config . streamConfig . recorded . ts . hls === 'undefined' ) { delete this . config . streamConfig . recorded . ts ; this . config . isEnableTSRecordedStream = false ; } } if ( typeof this . config . streamConfig . recorded . encoded !== 'undefined' ) { delete this . config . streamConfig . recorded . encoded . webm ; delete this . config . streamConfig . recorded . encoded . mp4 ; if ( typeof this . config . streamConfig . recorded . encoded . hls === 'undefined' ) { delete this . config . streamConfig . recorded . encoded ; this . config . isEnableEncodedRecordedStream = false ; } } if ( typeof this . config . streamConfig . recorded . ts === 'undefined' && typeof this . config . streamConfig . recorded . encoded === 'undefined' ) { delete this . config . streamConfig . recorded ; } } if ( typeof this . config . streamConfig . live === 'undefined' && typeof this . config . streamConfig . recorded === 'undefined' ) { delete this . config . streamConfig ; } } return public getConfig ( ) { return this . config ; } return public isEnableEncode ( ) { return this . config !== null && this . config . encode . length > 0 ; } return public isEnableSendVideoFileLinkToKodi ( ) { return this . config !== null && typeof this . config . kodiHosts !== 'undefined' && this . config . kodiHosts . length > 0 ; } }