Esempio n. 1
0
 public URI With(URI child)
 {
     if (mInternal == null)
     {
         return(child);
     }
     if (child?.mInternal != null)
     {
         if (Uri.TryCreate(mInternal, child.mInternal, out Uri result))
         {
             return(new URI(result));
         }
     }
     return(this);
 }
Esempio n. 2
0
        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));
        }
Esempio n. 3
0
        public URI CalcURL()
        {
            URI local = URI.FromBaseURLs(BaseURLs);

            return(manifestUrl?.With(local) ?? local ?? new URI());
        }
Esempio n. 4
0
 public DASH(string manifestUrl)
 {
     this.manifestUrl = string.IsNullOrEmpty(manifestUrl) ? null : new URI(manifestUrl);
 }
Esempio n. 5
0
        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));
        }