Beispiel #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
                }
            });
        }
Beispiel #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);
            });
        }
Beispiel #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;
                }
            });
        }
Beispiel #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);
            });
        }
Beispiel #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);
     });
 }
Beispiel #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);
            });
        }
Beispiel #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);
         }
     });
 }
Beispiel #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);
        }
Beispiel #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);
                }
            });
        }
Beispiel #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);
                    }
                }
            });
        }