public void Initialize(MediaManager mediaManager) { Debug.WriteLine(this, "CasparServer initialize"); lock (this) { if (!_isInitialized) { MediaDirectory = new ServerDirectory(this, mediaManager) { Folder = MediaFolder }; if (!string.IsNullOrWhiteSpace(AnimationFolder)) { AnimationDirectory = new AnimationDirectory(this, mediaManager) { Folder = AnimationFolder } } ; _casparDevice = new Svt.Caspar.CasparDevice() { IsRecordingSupported = ServerType == TServerType.CasparTVP }; _casparDevice.ConnectionStatusChanged += CasparDevice_ConnectionStatusChanged; _casparDevice.UpdatedChannels += CasparDevice_UpdatedChannels; _casparDevice.UpdatedRecorders += CasparDevice_UpdatedRecorders; Connect(); _isInitialized = true; } } }
public void Initialize() { Debug.WriteLine(this, "Begin initializing"); Logger.Debug("Begin initializing"); ArchiveDirectory = this.LoadArchiveDirectory <ArchiveDirectory>(_engine.IdArchive); MediaDirectoryPRI = (_engine.PlayoutChannelPRI == null) ? null : ((CasparServerChannel)_engine.PlayoutChannelPRI).Owner.MediaDirectory; MediaDirectorySEC = (_engine.PlayoutChannelSEC == null) ? null : ((CasparServerChannel)_engine.PlayoutChannelSEC).Owner.MediaDirectory; MediaDirectoryPRV = (_engine.PlayoutChannelPRV == null) ? null : ((CasparServerChannel)_engine.PlayoutChannelPRV).Owner.MediaDirectory; AnimationDirectoryPRI = (_engine.PlayoutChannelPRI == null) ? null : ((CasparServerChannel)_engine.PlayoutChannelPRI).Owner.AnimationDirectory; AnimationDirectorySEC = (_engine.PlayoutChannelSEC == null) ? null : ((CasparServerChannel)_engine.PlayoutChannelSEC).Owner.AnimationDirectory; AnimationDirectoryPRV = (_engine.PlayoutChannelPRV == null) ? null : ((CasparServerChannel)_engine.PlayoutChannelPRV).Owner.AnimationDirectory; IMediaDirectory[] initializationList = new IMediaDirectory[] { MediaDirectoryPRI, MediaDirectorySEC, MediaDirectoryPRV, AnimationDirectoryPRI, AnimationDirectorySEC, AnimationDirectoryPRV, ArchiveDirectory }; foreach (MediaDirectory dir in initializationList.OfType <IMediaDirectory>().Distinct()) { dir.Initialize(); } if (ArchiveDirectory != null) { ArchiveDirectory.MediaDeleted += ArchiveDirectory_MediaDeleted; } ServerDirectory sdir = MediaDirectoryPRI as ServerDirectory; if (sdir != null) { sdir.MediaPropertyChanged += _serverMediaPropertyChanged; sdir.PropertyChanged += _onServerDirectoryPropertyChanged; sdir.MediaSaved += _onServerDirectoryMediaSaved; sdir.MediaVerified += _mediaPRIVerified; sdir.MediaRemoved += _mediaPRIRemoved; } sdir = MediaDirectorySEC as ServerDirectory; if (MediaDirectoryPRI != MediaDirectorySEC && sdir != null) { sdir.MediaPropertyChanged += _serverMediaPropertyChanged; sdir.PropertyChanged += _onServerDirectoryPropertyChanged; } AnimationDirectory adir = AnimationDirectoryPRI as AnimationDirectory; if (adir != null) { adir.PropertyChanged += _onAnimationDirectoryPropertyChanged; adir.MediaAdded += _onAnimationDirectoryMediaAdded; adir.MediaRemoved += _onAnimationDirectoryMediaRemoved; adir.MediaPropertyChanged += _onAnimationDirectoryMediaPropertyChanged; } adir = AnimationDirectorySEC as AnimationDirectory; if (adir != null) { adir.PropertyChanged += _onAnimationDirectoryPropertyChanged; } _loadIngestDirs(Path.Combine(Directory.GetCurrentDirectory(), ConfigurationManager.AppSettings["IngestFolders"])); _fileManager.VolumeReferenceLoudness = Convert.ToDecimal(_engine.VolumeReferenceLoudness); Debug.WriteLine(this, "End initializing"); Logger.Debug("End initializing"); }
protected override void DoDispose() { _disconnect(); _casparDevice.ConnectionStatusChanged -= _casparDevice_ConnectionStatusChanged; _casparDevice.UpdatedChannels -= _casparDevice_UpdatedChannels; _casparDevice.UpdatedRecorders -= _casparDevice_UpdatedRecorders; _casparDevice.Dispose(); MediaDirectory.Dispose(); AnimationDirectory.Dispose(); }
protected override void DoDispose() { base.DoDispose(); if (ArchiveDirectory != null) { ArchiveDirectory.MediaDeleted += ArchiveDirectory_MediaDeleted; } ServerDirectory sdir = MediaDirectoryPRI as ServerDirectory; if (sdir != null) { sdir.MediaPropertyChanged -= _serverMediaPropertyChanged; sdir.PropertyChanged -= _onServerDirectoryPropertyChanged; sdir.MediaSaved -= _onServerDirectoryMediaSaved; sdir.MediaVerified -= _mediaPRIVerified; sdir.MediaRemoved -= _mediaPRIRemoved; } sdir = MediaDirectorySEC as ServerDirectory; if (MediaDirectoryPRI != MediaDirectorySEC && sdir != null) { sdir.MediaPropertyChanged -= _serverMediaPropertyChanged; sdir.MediaSaved -= _onServerDirectoryMediaSaved; sdir.PropertyChanged -= _onServerDirectoryPropertyChanged; } AnimationDirectory adir = AnimationDirectoryPRI as AnimationDirectory; if (adir != null) { adir.PropertyChanged -= _onAnimationDirectoryPropertyChanged; adir.MediaAdded -= _onAnimationDirectoryMediaAdded; adir.MediaRemoved -= _onAnimationDirectoryMediaRemoved; adir.MediaPropertyChanged -= _onAnimationDirectoryMediaPropertyChanged; } adir = AnimationDirectorySEC as AnimationDirectory; if (adir != null) { adir.PropertyChanged -= _onAnimationDirectoryPropertyChanged; } UnloadIngestDirs(); }
internal static void ServerLoadMediaDirectory(AnimationDirectory directory, PlayoutServer server) { Debug.WriteLine(directory, "ServerLoadMediaDirectory animation started"); if (Connect()) { MySqlCommand cmd = new MySqlCommand("SELECT * FROM tas.serverMedia WHERE idServer=@idServer and typMedia = @typMedia", connection); cmd.Parameters.AddWithValue("@idServer", server.idServer); cmd.Parameters.AddWithValue("@typMedia", TMediaType.AnimationFlash); try { lock (connection) { using (MySqlDataReader dataReader = cmd.ExecuteReader()) { while (dataReader.Read()) { ServerMedia nm = new ServerMedia() { idPersistentMedia = dataReader.GetUInt64("idServerMedia"), Directory = directory, }; _mediaReadFields(dataReader, nm); if (nm.MediaStatus != TMediaStatus.Available) { nm.MediaStatus = TMediaStatus.Unknown; ThreadPool.QueueUserWorkItem(o => nm.Verify()); } } dataReader.Close(); } } Debug.WriteLine(directory, "Directory loaded"); } catch (Exception e) { Debug.WriteLine(directory, e.Message); } } }
public PlayoutServer() { MediaDirectory = new ServerDirectory(this); AnimationDirectory = new AnimationDirectory(this); }