private IRepresentationStream CreateBaseURLRepresentationStream() { Dynamic.TimeRange periodRange = null; if (Period.Start != null && Period.Duration != null) { periodRange = new Dynamic.TimeRange(Period.Start.Value, Period.Duration.Value); } URI media_uri = AdaptationSet.CalcURL(); foreach (BaseURL url in BaseURLs) { if (!string.IsNullOrEmpty(url.BaseUrlValue)) { media_uri = media_uri.With(url.BaseUrlValue); } } Dynamic.SegmentBase segBase = SegmentBase(); var presentationTimeOffset = segBase.PresentationTimeOffset ?? 0; TimeSpan availabilityTimeOffset = segBase.AvailabilityTimeOffset.HasValue ? TimeSpan.FromSeconds(segBase.AvailabilityTimeOffset.Value) : TimeSpan.MaxValue; // Live content elements from Segment Base... // Can we have this changing dynamically and available at given time? // God forbids... return(new Dynamic.BaseRepresentationStream( null, new Dynamic.Segment(media_uri.Uri, null, periodRange), presentationTimeOffset, segBase.TimeShiftBufferDepth, availabilityTimeOffset, segBase.AvailabilityTimeComplete)); }
private IRepresentationStream CreateBaseRepresentationStream() { Dynamic.TimeRange periodRange = null; if (Period.Start != null && Period.Duration != null) { periodRange = new Dynamic.TimeRange(Period.Start.Value, Period.Duration.Value); } Dynamic.SegmentBase seg = SegmentBase(); URL init_url = GetFirst(seg.Initializations); string index_range = seg.IndexRange; // Live content elements from Segment Base... var presentationTimeOffset = seg.PresentationTimeOffset ?? 0; TimeSpan availabilityTimeOffset = seg.AvailabilityTimeOffset.HasValue ? TimeSpan.FromSeconds(seg.AvailabilityTimeOffset.Value) : TimeSpan.MaxValue; URI media_uri = CalcURL(); URI init_uri = null; // If the init_url.SourceUrl is present, // it is relative to AdaptiveSet, not Representation. // Representation's BaseURI is for media only. if (init_url?.SourceURL != null) { init_uri = AdaptationSet.CalcURL()?.With(init_url.SourceURL); } else if (init_url != null) { init_uri = media_uri; } if (init_uri == null) { if (media_uri == null) { return(null); } Dynamic.Segment media = new Dynamic.Segment(media_uri.Uri, null, periodRange); Dynamic.Segment index = index_range.Length != 0 ? new Dynamic.Segment(media_uri.Uri, index_range) : null; return(new Dynamic.BaseRepresentationStream(null, media, presentationTimeOffset, seg.TimeShiftBufferDepth, availabilityTimeOffset, seg.AvailabilityTimeComplete, index)); } if (media_uri == null) { return(null); } return(new Dynamic.BaseRepresentationStream( new Dynamic.Segment(init_uri.Uri, init_url?.Range), new Dynamic.Segment(media_uri.Uri, null, periodRange), presentationTimeOffset, seg.TimeShiftBufferDepth, availabilityTimeOffset, seg.AvailabilityTimeComplete, index_range.Length != 0? new Dynamic.Segment(init_uri.Uri, index_range):null)); }