public async Task <byte[]> CreatePlayListAsync(Uri baseuri, IEnumerable <KeyValuePair <string, string> > parameters, HTTPLiveStreamingSegmenter segmenter, CancellationToken cancellationToken) { var res = new System.Text.StringBuilder(); var segments = await segmenter.GetSegmentsAsync(cancellationToken).ConfigureAwait(false); res.AppendLine("#EXTM3U"); res.AppendLine("#EXT-X-VERSION:3"); res.AppendLine("#EXT-X-ALLOW-CACHE:NO"); res.AppendLine($"#EXT-X-TARGETDURATION:{segmenter.TargetDuration}"); res.AppendLine($"#EXT-X-MEDIA-SEQUENCE:{segments.FirstOrDefault().Index}"); var queries = String.Join("&", parameters.Select(kv => Uri.EscapeDataString(kv.Key) + "=" + Uri.EscapeDataString(kv.Value))); foreach (var seg in segments) { if (seg.Data == null) { res.AppendLine("#EXT-X-ENDLIST"); } else { var url = new UriBuilder(new Uri(baseuri, Channel.ChannelID.ToString("N").ToUpperInvariant() + String.Format("/{0:00000}.ts", seg.Index))); url.Scheme = scheme; if (queries != "") { url.Query = queries; } res.AppendLine("#EXTINF:" + seg.Duration.ToString("F2") + ","); res.AppendLine(url.ToString()); } } return(System.Text.Encoding.UTF8.GetBytes(res.ToString())); }
public SegmentList(HTTPLiveStreamingSegmenter owner, Content header) { this.owner = owner; this.header = header; segmentBuffer.Write(header.Data, 0, header.Data.Length); }