public URI CalcURL() { URI parent = AdaptationSet.CalcURL(); URI local = URI.FromBaseURLs(BaseURLs); return(local == null ? parent : parent.With(local)); }
public AdaptationSet(Node.AdaptationSet set) { Id = set.Id; Group = set.Group; Lang = set.GetLang() ?? "und"; ContentProtections = new ContentProtection[set.ContentProtections.Length]; for (int i = 0; i < ContentProtections.Length; ++i) { ContentProtections[i] = new ContentProtection(set.ContentProtections[i]); } Roles = new Role[set.Roles.Length]; for (int i = 0; i < Roles.Length; ++i) { Node.Descriptor r = set.Roles[i]; Roles[i] = new Role(r.SchemeIdUri, r.Value); } Representations = new Representation[set.Representations.Length]; for (int i = 0; i < Representations.Length; ++i) { Representations[i] = new Representation(set.Representations[i]); } Type = new MimeType(set.GetContentType() ?? GuessFromMimeType(set.MimeType) ?? GuessFromRepresentations()); }
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 TimeSpan?GuessFromRepresentations(AdaptationSet set) { TimeSpan?result = null; foreach (Representation repr in set.Representations) { TimeSpan?longest = GuessFromRepresentations(repr); if (result == null) { result = longest; } else if (longest != null && result.Value < longest.Value) { result = longest.Value; } } return(result); }
private IRepresentationStream CreateListRepresentationStream() { Dynamic.SegmentList seg = SegmentList(); Dynamic.SegmentBase segBase = SegmentBase(); URL init_url = GetFirst(seg.Initializations) ?? GetFirst(segBase.Initializations); URI init_uri = null; if (init_url?.SourceURL != null) { init_uri = AdaptationSet.CalcURL()?.With(init_url.SourceURL); } // If we still have no init URI, construct one based on BaseURL // for that purpose, index range from URL is required. Don't even try without it if (init_uri == null && init_url?.Range != null) { if (this.BaseURL == null) { throw new ArgumentNullException("the BaseURL is null"); } init_uri = new URI(this.BaseURL); } Dynamic.Segment init = init_uri == null ? null : new Dynamic.Segment(init_uri.Uri, init_url?.Range); // Live content elements from Segment Base... var presentationTimeOffset = seg.PresentationTimeOffset ?? 0; TimeSpan availabilityTimeOffset = seg.AvailabilityTimeOffset.HasValue ? TimeSpan.FromSeconds(seg.AvailabilityTimeOffset.Value) : TimeSpan.MaxValue; Dynamic.ListItem[] items = Dynamic.ListItem.FromXml( seg.StartNumber ?? 1, Period.Start ?? new TimeSpan(0), seg.Timescale ?? 1, seg.Duration ?? 0, seg.SegmentURLs, this.BaseURL); return(new Dynamic.ListRepresentationStream(CalcURL().Uri, init, seg.Timescale ?? 1, items, presentationTimeOffset, seg.TimeShiftBufferDepth, availabilityTimeOffset, seg.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)); }
public Representation(AdaptationSet set) { AdaptationSet = set; }