public static Task <Uri> ParseAsync(this M3U8Parser parser, IWebReader webReader, IRetryManager retryManager, Uri playlist, CancellationToken cancellationToken)
        {
            IRetry retry = RetryManagerExtensions.CreateWebRetry(retryManager, 2, 250);

            return(retry.CallAsync <Uri>((Func <Task <Uri> >)(() => WebReaderExtensions.ReadStreamAsync <Uri>(webReader, playlist, retry, (Func <Uri, Stream, Uri>)((actualPlaylist, stream) =>
            {
                M3U8ParserExtensions.Parse(parser, actualPlaylist, stream, (Encoding)null);
                return actualPlaylist;
            }), cancellationToken)), cancellationToken));
        }
        public async Task <TCached> ReadAsync <TCached>(Func <Uri, byte[], TCached> factory, CancellationToken cancellationToken, WebResponse webResponse = null) where TCached : class
        {
            if (null == (object)(this._cachedObject as TCached))
            {
                this._cachedObject = (object)null;
            }
            IRetry retry = RetryManagerExtensions.CreateWebRetry(this._retryManager, 2, 250);
            await RetryExtensions.CallAsync(retry, (Func <Task>)(() => this.Fetch <TCached>(retry, factory, webResponse, cancellationToken)), cancellationToken).ConfigureAwait(false);

            return(this._cachedObject as TCached);
        }
        public virtual async Task <ISegmentManager> CreateAsync(ISegmentManagerParameters parameters, ContentType contentType, CancellationToken cancellationToken)
        {
            ISegmentManager segmentManager1;

            foreach (Uri uri in (IEnumerable <Uri>)parameters.Source)
            {
                Uri             localUrl       = uri;
                IRetry          retry          = RetryManagerExtensions.CreateWebRetry(this._retryManager, 3, 333);
                ISegmentManager segmentManager = await retry.CallAsync <ISegmentManager>((Func <Task <ISegmentManager> >)(async() =>
                {
                    IWebReader webReader = this._webReaderManager.CreateReader(localUrl, ContentTypes.Pls.Kind, (IWebReader)null, ContentTypes.Pls);
                    ISegmentManager segmentManager2;
                    try
                    {
                        using (IWebStreamResponse webStreamResponse = await webReader.GetWebStreamAsync(localUrl, false, cancellationToken, (Uri)null, new long?(), new long?(), (WebResponse)null).ConfigureAwait(false))
                        {
                            if (!webStreamResponse.IsSuccessStatusCode)
                            {
                                webReader.Dispose();
                                segmentManager2 = (ISegmentManager)null;
                            }
                            else
                            {
                                using (Stream stream = await webStreamResponse.GetStreamAsync(cancellationToken).ConfigureAwait(false))
                                    segmentManager2 = await this.ReadPlaylistAsync(webReader, webStreamResponse.ActualUrl, stream, cancellationToken).ConfigureAwait(false);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        webReader.Dispose();
                        throw;
                    }
                    return(segmentManager2);
                }), cancellationToken);

                if (null != segmentManager)
                {
                    segmentManager1 = segmentManager;
                    goto label_10;
                }
            }
            segmentManager1 = (ISegmentManager)null;
label_10:
            return(segmentManager1);
        }
 private Task <byte[]> LoadKeyAsync(Uri uri, CancellationToken cancellationToken)
 {
     Debug.WriteLine("HlsStreamSegments.LoadKeyAsync() " + (object)uri);
     return(RetryManagerExtensions.CreateWebRetry(this._retryManager, 4, 100).CallAsync <byte[]>((Func <Task <byte[]> >)(() => this._webReader.GetByteArrayAsync(uri, cancellationToken, (WebResponse)null)), cancellationToken));
 }