예제 #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
                }
            });
        }
예제 #2
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;
                }
            });
        }
예제 #3
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);
            });
        }
예제 #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);
            });
        }
예제 #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);
     });
 }
예제 #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);
            });
        }
예제 #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);
         }
     });
 }
예제 #8
0
        /// <summary>Builds a seek query.</summary>
        /// <param name="seekOperation">The seek operation to perform.</param>
        /// <param name="pageSize">The desired result page size.</param>
        /// <param name="index">The index of the page to retrieve. This is only used if the seek operation specified a page index.</param>
        /// <param name="filter">An optional filter to apply.</param>
        /// <param name="sortingOption">An optional sorting options.</param>
        /// <param name="token">An optional query token.</param>
        /// <returns>The seek query.</returns>
        public static IQuery BuildSeekQuery(SeekOperation seekOperation, int pageSize = 0, int index = 0, FieldFilter filter = null, Sort sortingOption = null, object token = null)
        {
            SeekQuery seekQuery = new SeekQuery
            {
                SeekOperation = seekOperation,
                PageSize      = pageSize,
                Index         = index,
                Filter        = filter,
                Sort          = sortingOption,
                Token         = token
            };

            return(seekQuery);
        }
예제 #9
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);
        }
예제 #10
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);
                }
            });
        }
예제 #11
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);
                    }
                }
            });
        }
예제 #12
0
        /// <summary>
        /// Seeks pages of of utilization for resources that belong to an Azure subscription owned by a customer of the partner.
        /// </summary>
        /// <param name="continuationToken">The continuation token from the previous results.</param>
        /// <param name="seekOperation">The seek operation to perform. Next is only supported.</param>
        /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
        /// <returns>The next page of utilization records.</returns>
        public async Task <ResourceCollection <AzureUtilizationRecord> > SeekAsync(string continuationToken, SeekOperation seekOperation = SeekOperation.Next, CancellationToken cancellationToken = default)
        {
            continuationToken.AssertNotEmpty(nameof(continuationToken));

            IDictionary <string, string> headers = new Dictionary <string, string>
            {
                {
                    PartnerService.Instance.Configuration.Apis.SeekAzureUtilizationRecords.AdditionalHeaders.ContinuationToken,
                    continuationToken
                }
            };

            IDictionary <string, string> parameters = new Dictionary <string, string>
            {
                {
                    PartnerService.Instance.Configuration.Apis.SeekAzureUtilizationRecords.Parameters.SeekOperation,
                    seekOperation.ToString()
                }
            };

            return(await Partner.ServiceClient.GetAsync <ResourceCollection <AzureUtilizationRecord> >(
                       new Uri(
                           string.Format(
                               CultureInfo.InvariantCulture,
                               $"/{PartnerService.Instance.ApiVersion}/{PartnerService.Instance.Configuration.Apis.SeekAzureUtilizationRecords.Path}",
                               Context.Item1,
                               Context.Item2),
                           UriKind.Relative),
                       headers,
                       parameters,
                       new ResourceCollectionConverter <AzureUtilizationRecord>(),
                       cancellationToken).ConfigureAwait(false));
        }