Пример #1
0
        public TrackRepresentation(MpdAdaptationSet adaptationSet, MpdRepresentation representation)
        {
            this.adaptationSet  = adaptationSet;
            this.representation = representation;

            initFragmentPath = new Lazy <string>(GetInitFragmentPath);
            fragmentsPaths   = new Lazy <IEnumerable <string> >(GetFragmentsPaths);
        }
Пример #2
0
        private Task <string> DownloadRepresentationInitFragment(MpdAdaptationSet adaptationSet, MpdRepresentation representation)
        {
            string initUrl = adaptationSet.SegmentTemplate.Initialization
                             .Replace("$RepresentationID$", representation.Id);
            var task = DownloadFragment(initUrl);

            task.Wait(TimeSpan.FromMinutes(5));

            return(task);
        }
Пример #3
0
        private Task <string> DownloadRepresentationFragment(MpdAdaptationSet adaptationSet, MpdRepresentation representation, int index)
        {
            string fragmentUrl = adaptationSet.SegmentTemplate.Media
                                 .Replace("$RepresentationID$", representation.Id)
                                 .Replace("$Number$", index.ToString());

            var task = DownloadFragment(fragmentUrl);

            task.Wait(TimeSpan.FromMinutes(5));

            return(task);
        }
Пример #4
0
        private void DownloadFragmentsUntilFirstFailure(MpdAdaptationSet adaptationSet, MpdRepresentation representation)
        {
            var task = DownloadRepresentationInitFragment(adaptationSet, representation);

            if (DownloadTaskSucceded(task))
            {
                int i = 1;
                do
                {
                    task = DownloadRepresentationFragment(adaptationSet, representation, i);
                    i++;
                }while (DownloadTaskSucceded(task));
            }
        }
Пример #5
0
 private Task DownloadAllFragments(MpdAdaptationSet adaptationSet, MpdRepresentation representation)
 {
     return(Task.Factory.StartNew(() => DownloadFragmentsUntilFirstFailure(adaptationSet, representation)));
 }
Пример #6
0
        public Track(MpdAdaptationSet adaptationSet)
        {
            this.adaptationSet = adaptationSet;

            trackRepresentations = new Lazy <IEnumerable <TrackRepresentation> >(GetTrackRepresentations);
        }