Exemplo n.º 1
0
        public void Seek_ToTheEnd_SeeksOrCompletes(string clipTitle)
        {
            RunPlayerTest(clipTitle, async context =>
            {
                var service      = context.Service;
                context.SeekTime = service.Duration;
                try
                {
                    var seekOperation = new SeekOperation();
                    seekOperation.Prepare(context);
                    var seekTask = seekOperation.Execute(context);

                    var clipCompletedTask = service.StateChanged()
                                            .AsCompletion()
                                            .Timeout(context.Timeout)
                                            .FirstAsync()
                                            .ToTask();

                    await await Task.WhenAny(seekTask, clipCompletedTask);
                }
                catch (SeekException)
                {
                    // ignored
                }
            });
        }
Exemplo n.º 2
0
        public void Seek_EOSReached_StateChangedCompletes(string clipTitle)
        {
            RunPlayerTest(clipTitle, async context =>
            {
                var service           = context.Service;
                var playbackErrorTask = service.PlaybackError()
                                        .FirstAsync()
                                        .Timeout(context.Timeout)
                                        .ToTask();

                var clipCompletedTask = service.StateChanged()
                                        .AsCompletion()
                                        .Timeout(context.Timeout)
                                        .ToTask();

                context.SeekTime  = service.Duration - TimeSpan.FromSeconds(5);
                var seekOperation = new SeekOperation();
                seekOperation.Prepare(context);

                // seek.execute() completes when seek position is reached. Do not wait for it!
                // Desired clock may never be reached. Wait for desired state changes only.
                var seekExecution = seekOperation.Execute(context);

                await await Task.WhenAny(clipCompletedTask, playbackErrorTask).ConfigureAwait(false);
            });
        }
Exemplo n.º 3
0
        public void Seek_ToTheEnd_SeeksOrCompletes(string clipTitle)
        {
            RunPlayerTest(clipTitle, async context =>
            {
                var service      = context.Service;
                context.SeekTime = service.Duration;
                try
                {
                    var clipCompletedTask = service.StateChanged()
                                            .AsCompletion()
                                            .ToTask(context.Token)
                                            .WithTimeout(context.Timeout);

                    var seekOperation = new SeekOperation();
                    seekOperation.Prepare(context);
                    var seekTask = seekOperation.Execute(context);

                    await await Task.WhenAny(seekTask, clipCompletedTask);
                }
                catch (Exception e)
                {
                    _logger.Error(e);
                    throw;
                }
            });
        }
Exemplo n.º 4
0
        public void Seek_EOSReached_StateChangedCompletes(string clipTitle)
        {
            RunPlayerTest(clipTitle, async context =>
            {
                var service = context.Service;

                context.SeekTime  = service.Duration - TimeSpan.FromSeconds(5);
                var seekOperation = new SeekOperation();
                seekOperation.Prepare(context);

                var playbackErrorTask = service.PlaybackError()
                                        .FirstAsync()
                                        .ToTask();

                await await Task.WhenAny(seekOperation.Execute(context), playbackErrorTask);

                var clipCompletedTask = service.StateChanged()
                                        .AsCompletion()
                                        .Timeout(context.Timeout)
                                        .FirstAsync()
                                        .ToTask();

                await await Task.WhenAny(clipCompletedTask, playbackErrorTask);
            });
        }
Exemplo n.º 5
0
 public void Seek_DisposeDuringSeek_Disposes(string clipTitle)
 {
     RunPlayerTest(clipTitle, async context =>
     {
         var seekOperation = new SeekOperation();
         seekOperation.Prepare(context);
         _ = seekOperation.Execute(context);
         await Task.Delay(250);
     });
 }
Exemplo n.º 6
0
        public void Seek_DisposeDuringSeek_Disposes(string clipTitle)
        {
            RunPlayerTest(clipTitle, async context =>
            {
                var seekOperation = new SeekOperation();
                seekOperation.Prepare(context);
#pragma warning disable 4014
                seekOperation.Execute(context);
#pragma warning restore 4014
                await Task.Delay(250);
            });
        }
Exemplo n.º 7
0
 public void Seek_Random10Times_Seeks(string clipTitle)
 {
     RunPlayerTest(clipTitle, async context =>
     {
         context.SeekTime = null;
         for (var i = 0; i < 10; ++i)
         {
             var seekOperation = new SeekOperation();
             seekOperation.Prepare(context);
             await seekOperation.Execute(context);
         }
     });
 }
Exemplo n.º 8
0
        public void Playback_StartFromThe90thSecond_PreparesAndStarts(string clipTitle)
        {
            RunPlayerTest(clipTitle, async context =>
            {
                context.SeekTime  = TimeSpan.FromSeconds(90);
                var seekOperation = new SeekOperation();
                seekOperation.Prepare(context);
                var seek = seekOperation.Execute(context);

                var startOperation = new StartOperation();
                startOperation.Prepare(context);
                await startOperation.Execute(context);

                await seek;
            }, false);
        }
Exemplo n.º 9
0
        public void Seek_Backward_Seeks(string clipTitle)
        {
            RunPlayerTest(clipTitle, async context =>
            {
                var service = context.Service;

                for (var nextSeekTime = service.Duration - TimeSpan.FromSeconds(15);
                     nextSeekTime > TimeSpan.Zero;
                     nextSeekTime -= TimeSpan.FromSeconds(20))
                {
                    context.SeekTime  = nextSeekTime;
                    var seekOperation = new SeekOperation();
                    seekOperation.Prepare(context);
                    await seekOperation.Execute(context);
                }
            });
        }
Exemplo n.º 10
0
        public void RepresentationChange_WhileSeeking_Succeeds(string clipTitle)
        {
            RunPlayerTest(clipTitle, async context =>
            {
                var streams        = new[] { StreamType.Video, StreamType.Audio };
                var service        = context.Service;
                context.SeekTime   = null;  // Perform random seeks.
                var defaultTimeout = context.Timeout;
                foreach (var stream in streams)
                {
                    var descriptions = service.GetStreamsDescription(stream);

                    for (var i = 0; i < descriptions.Count; i++)
                    {
                        var seekOp = new SeekOperation();

                        // Wait for seekOp after ChangeRepresentation executes.
                        // Otherwise, position task of SeekOp may timeout as position may not be available
                        // till ChangeRepresentation completes.
                        context.Timeout = TimeSpan.Zero;
                        seekOp.Prepare(context);
                        var seekTask    = seekOp.Execute(context);
                        context.Timeout = defaultTimeout;

                        var changeOp = new ChangeRepresentationOperation
                        {
                            Index      = i,
                            StreamType = stream
                        };

                        var changeTask = changeOp.Execute(context);

                        await changeTask.WithCancellation(context.Token);
                        await seekTask.WithTimeout(context.Timeout).WithCancellation(context.Token);
                    }
                }
            });
        }