// Provide a way to check the range limit of the archive without requesting the current volume (which throws an error if not in range)
        public static bool CheckCurrentVolumeRange(this IVolumeManager volumeManager, Vessel vessel)
        {
            var rtManager = volumeManager as RemoteTechVolumeManager;

            if (rtManager == null)
            {
                return(true);
            }
            return(rtManager.CheckCurrentVolumeRange(vessel));
        }
Beispiel #2
0
        // Token: 0x06001951 RID: 6481 RVA: 0x00068A08 File Offset: 0x00066C08
        internal static LocalizedString CheckExchangeVolumesPresent(AutoReseedContext context)
        {
            IVolumeManager volumeManager = context.VolumeManager;
            int            num           = (from vol in volumeManager.Volumes
                                            where vol.IsExchangeVolume
                                            select vol).Count <ExchangeVolume>();

            if (num < 1)
            {
                return(ReplayStrings.AutoReseedNoExchangeVolumesConfigured(context.Dag.AutoDagVolumesRootFolderPath.PathName));
            }
            return(LocalizedString.Empty);
        }
        public VideoPlayerImplementation(IVolumeManager volumeManager)
        {
            _volumeManager = volumeManager;
            _status        = MediaPlayerStatus.Stopped;

            // Watch the buffering status. If it changes, we may have to resume because the playing stopped because of bad network-conditions.
            BufferingChanged += (sender, e) =>
            {
                // If the player is ready to play, it's paused and the status is still on PLAYING, go on!
                if ((Player.Status == AVPlayerStatus.ReadyToPlay) && (Rate == 0.0f) &&
                    (Status == MediaPlayerStatus.Playing))
                {
                    Player.Play();
                }
            };
        }
Beispiel #4
0
 public AutoReseedContext(IVolumeManager volumeManager, IReplicaInstanceManager replicaInstanceManager, IADDatabaseAvailabilityGroup dag, IADDatabase database, IEnumerable <IADDatabase> databases, AmServerName targetServerName, IADServer targetServer, CopyStatusClientCachedEntry targetCopyStatus, IEnumerable <CopyStatusClientCachedEntry> dbCopyStatuses, IEnumerable <CopyStatusClientCachedEntry> serverCopyStatuses, Dictionary <AmServerName, IEnumerable <CopyStatusClientCachedEntry> > dagCopyStatuses, AutoReseedServerLimiter reseedLimiter, IMonitoringADConfig adConfig)
 {
     this.VolumeManager          = volumeManager;
     this.ReplicaInstanceManager = replicaInstanceManager;
     this.Dag              = dag;
     this.Database         = database;
     this.Databases        = databases;
     this.TargetServerName = targetServerName;
     this.TargetServer     = targetServer;
     this.TargetCopyStatus = targetCopyStatus;
     this.CopyStatusesForTargetDatabase = dbCopyStatuses;
     this.CopyStatusesForTargetServer   = serverCopyStatuses;
     this.CopyStatusesForDag            = dagCopyStatuses;
     this.ReseedLimiter = reseedLimiter;
     this.AdConfig      = adConfig;
 }
        public AudioPlayerImplementation(IVolumeManager volumeManager)
        {
            _volumeManager = volumeManager;
            _status = MediaPlayerStatus.Stopped;

            // Watch the buffering status. If it changes, we may have to resume because the playing stopped because of bad network-conditions.
            BufferingChanged += (sender, e) =>
            {
                // If the player is ready to play, it's paused and the status is still on PLAYING, go on!
                if ((Player.Status == AVPlayerStatus.ReadyToPlay) && (Rate == 0.0f) &&
                    (Status == MediaPlayerStatus.Playing))
                    Player.Play();
            };
            _volumeManager.Mute = _player.Muted;
            _volumeManager.CurrentVolume = _player.Volume;
            _volumeManager.MaxVolume = 1;
            _volumeManager.VolumeChanged += VolumeManagerOnVolumeChanged;
        }
        public AudioPlayerImplementation(IVolumeManager volumeManager)
        {
            _volumeManager = volumeManager;
            _versionHelper = new VersionHelper();

            _status = MediaPlayerStatus.Stopped;

            InitializePlayer();

            // Watch the buffering status. If it changes, we may have to resume because the playing stopped because of bad network-conditions.
            BufferingChanged += (sender, e) =>
            {
                // If the player is ready to play, it's paused and the status is still on PLAYING, go on!
                var isPlaying = Status == MediaPlayerStatus.Playing;
                if (CurrentItem.Status == AVPlayerItemStatus.ReadyToPlay && Rate == 0.0f && isPlaying)
                {
                    Player.Play();
                }
            };
        }
        protected override Exception ExecuteInternal(AutoReseedWorkflowState state)
        {
            Exception         ex                        = null;
            bool              flag                      = false;
            IVolumeManager    volumeManager             = base.Context.VolumeManager;
            IADDatabase       database                  = base.Context.Database;
            MountedFolderPath databaseMountedFolderPath = VolumeManager.GetDatabaseMountedFolderPath(base.Context.Dag.AutoDagDatabasesRootFolderPath, database.Name);

            if (MountPointUtil.IsDirectoryAccessibleMountPoint(databaseMountedFolderPath.Path, out ex))
            {
                flag = true;
            }
            else
            {
                ReplayCrimsonEvents.AutoReseedNeverMountedActiveMissingVolume.Log <string>(database.Name);
                if (volumeManager.FixActiveDatabaseMountPoint(database, base.Context.Databases, base.Context.AdConfig, out ex, true))
                {
                    flag = true;
                    volumeManager.UpdateVolumeInfoCopyState(database.Guid, base.Context.ReplicaInstanceManager);
                    ReplayCrimsonEvents.AutoReseedNeverMountedActiveAllocatedVolume.Log <string, string>(database.Name, base.Context.TargetCopyStatus.CopyStatus.LogVolumeName);
                }
                else
                {
                    AutoReseedWorkflow.Tracer.TraceError <string, string>((long)this.GetHashCode(), "DiskReclaimer: UpdateVolumeForNeverMountedActives() failed to fix up active database: '{0}' mountpoint. Error: {1}", database.Name, AmExceptionHelper.GetExceptionMessageOrNoneString(ex));
                    ReplayCrimsonEvents.AutoReseedFixActiveMountPointError.Log <string, string>(database.Name, AmExceptionHelper.GetExceptionMessageOrNoneString(ex));
                }
            }
            if (!flag)
            {
                AutoReseedWorkflow.Tracer.TraceError <string, string>((long)this.GetHashCode(), "DiskReclaimer: UpdateVolumeForNeverMountedActives() active database: '{0}' does not have a mountpoint. Skip issuing Store Mount. Error: {1}", database.Name, AmExceptionHelper.GetExceptionMessageOrNoneString(ex));
                return(ex);
            }
            ex = AmRpcClientHelper.AdminMountDatabaseWrapper(database);
            if (ex != null)
            {
                AutoReseedWorkflow.Tracer.TraceError <string, string>((long)this.GetHashCode(), "DiskReclaimer: UpdateVolumeForNeverMountedActives() failed to mount active database: '{0}' mountpoint. Error: {1}", database.Name, ex.Message);
                ReplayCrimsonEvents.AutoReseedMountActiveDatabaseError.Log <string, string>(database.Name, ex.Message);
            }
            return(ex);
        }
        public VideoPlayerImplementation(IVolumeManager volumeManager)
        {
            _volumeManager = volumeManager;
            _player = new MediaPlayer();

            _playProgressTimer = new Timer(state =>
            {
                if (_player.PlaybackSession.PlaybackState == MediaPlaybackState.Playing)
                {
                    var progress = _player.PlaybackSession.Position.TotalSeconds/
                                   _player.PlaybackSession.NaturalDuration.TotalSeconds;
                    if (double.IsNaN(progress))
                        progress = 0;
                    PlayingChanged?.Invoke(this, new PlayingChangedEventArgs(progress, _player.PlaybackSession.Position, _player.PlaybackSession.NaturalDuration));
                }
            }, null, 0, int.MaxValue);

            _player.MediaFailed += (sender, args) =>
            {
                _status = MediaPlayerStatus.Failed;
                _playProgressTimer.Change(0, int.MaxValue);
                MediaFailed?.Invoke(this, new MediaFailedEventArgs(args.ErrorMessage, args.ExtendedErrorCode));
            };

            _player.PlaybackSession.PlaybackStateChanged += (sender, args) =>
            {
                switch (sender.PlaybackState)
                {
                    case MediaPlaybackState.None:
                        _playProgressTimer.Change(0, int.MaxValue);
                        break;
                    case MediaPlaybackState.Opening:
                        Status = MediaPlayerStatus.Loading;
                        _playProgressTimer.Change(0, int.MaxValue);
                        break;
                    case MediaPlaybackState.Buffering:
                        Status = MediaPlayerStatus.Buffering;
                        _playProgressTimer.Change(0, int.MaxValue);
                        break;
                    case MediaPlaybackState.Playing:
                        if ((sender.PlaybackRate <= 0) && (sender.Position == TimeSpan.Zero))
                        {
                            Status = MediaPlayerStatus.Stopped;
                        }
                        else
                        {
                            Status = MediaPlayerStatus.Playing;
                            _playProgressTimer.Change(0, 50);
                        }
                        break;
                    case MediaPlaybackState.Paused:
                        Status = MediaPlayerStatus.Paused;
                        _playProgressTimer.Change(0, int.MaxValue);
                        break;
                    default:
                        throw new ArgumentOutOfRangeException();
                }
            };

            _player.MediaEnded += (sender, args) => { MediaFinished?.Invoke(this, new MediaFinishedEventArgs(_currentMediaFile)); };
            _player.PlaybackSession.BufferingProgressChanged += (sender, args) =>
            {
                var bufferedTime =
                    TimeSpan.FromSeconds(_player.PlaybackSession.BufferingProgress*
                                         _player.PlaybackSession.NaturalDuration.TotalSeconds);
                BufferingChanged?.Invoke(this,
                    new BufferingChangedEventArgs(_player.PlaybackSession.BufferingProgress, bufferedTime));
            };

            _player.PlaybackSession.SeekCompleted += (sender, args) => { };
            _player.MediaOpened += (sender, args) => { _loadMediaTaskCompletionSource.SetResult(true); };
            _volumeManager.CurrentVolume = (float)_player.Volume;
            _volumeManager.Mute = _player.IsMuted;
            _volumeManager.VolumeChanged += VolumeManagerOnVolumeChanged;
        }
        public VideoPlayerImplementation(IVolumeManager volumeManager)
        {
            _volumeManager = volumeManager;
            _player        = new MediaPlayer();

            _playProgressTimer = new Timer(state =>
            {
                if (_player.PlaybackSession.PlaybackState == MediaPlaybackState.Playing)
                {
                    var progress = _player.PlaybackSession.Position.TotalSeconds /
                                   _player.PlaybackSession.NaturalDuration.TotalSeconds;
                    if (double.IsNaN(progress))
                    {
                        progress = 0;
                    }
                    PlayingChanged?.Invoke(this, new PlayingChangedEventArgs(progress, _player.PlaybackSession.Position, _player.PlaybackSession.NaturalDuration));
                }
            }, null, 0, int.MaxValue);

            _player.MediaFailed += (sender, args) =>
            {
                _status = MediaPlayerStatus.Failed;
                _playProgressTimer.Change(0, int.MaxValue);
                MediaFailed?.Invoke(this, new MediaFailedEventArgs(args.ErrorMessage, args.ExtendedErrorCode));
            };

            _player.PlaybackSession.PlaybackStateChanged += (sender, args) =>
            {
                switch (sender.PlaybackState)
                {
                case MediaPlaybackState.None:
                    _playProgressTimer.Change(0, int.MaxValue);
                    break;

                case MediaPlaybackState.Opening:
                    Status = MediaPlayerStatus.Loading;
                    _playProgressTimer.Change(0, int.MaxValue);
                    break;

                case MediaPlaybackState.Buffering:
                    Status = MediaPlayerStatus.Buffering;
                    _playProgressTimer.Change(0, int.MaxValue);
                    break;

                case MediaPlaybackState.Playing:
                    if ((sender.PlaybackRate <= 0) && (sender.Position == TimeSpan.Zero))
                    {
                        Status = MediaPlayerStatus.Stopped;
                    }
                    else
                    {
                        Status = MediaPlayerStatus.Playing;
                        _playProgressTimer.Change(0, 50);
                    }
                    break;

                case MediaPlaybackState.Paused:
                    Status = MediaPlayerStatus.Paused;
                    _playProgressTimer.Change(0, int.MaxValue);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            };

            _player.MediaEnded += (sender, args) => { MediaFinished?.Invoke(this, new MediaFinishedEventArgs(_currentMediaFile)); };
            _player.PlaybackSession.BufferingProgressChanged += (sender, args) =>
            {
                var bufferedTime =
                    TimeSpan.FromSeconds(_player.PlaybackSession.BufferingProgress *
                                         _player.PlaybackSession.NaturalDuration.TotalSeconds);
                BufferingChanged?.Invoke(this,
                                         new BufferingChangedEventArgs(_player.PlaybackSession.BufferingProgress, bufferedTime));
            };

            _player.PlaybackSession.SeekCompleted += (sender, args) => { };
            _player.MediaOpened          += (sender, args) => { _loadMediaTaskCompletionSource.SetResult(true); };
            _volumeManager.CurrentVolume  = (float)_player.Volume;
            _volumeManager.Mute           = _player.IsMuted;
            _volumeManager.VolumeChanged += VolumeManagerOnVolumeChanged;
        }
 internal VlcPlayer(PlayerOutput playerOutput, IInternalObjectsFactory internalObjectsFactory, IVolumeManager volumeManager) {
     if (playerOutput == null) {
         throw new ArgumentNullException("playerOutput");
     }
     if (volumeManager == null) {
         throw new ArgumentNullException("volumeManager");
     }
     if (internalObjectsFactory == null) {
         throw new ArgumentNullException("internalObjectsFactory");
     }
     //
     this.playerOutput = playerOutput;
     this.volumeManager = volumeManager;
     this.internalObjectsFactory = internalObjectsFactory;
     //
     firstMediaPlayerInternal = this.internalObjectsFactory.CreateVlcMediaPlayerInternal();
     secondMediaPlayerInternal = this.internalObjectsFactory.CreateVlcMediaPlayerInternal();
     //
     initializeEventsEngine();
 }