public static Task CallAsync(this IRetry retry, Func <Task> operation, CancellationToken cancellationToken) { return((Task)retry.CallAsync <int>((Func <Task <int> >)(async() => { await operation().ConfigureAwait(false); return 0; }), cancellationToken)); }
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 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); }