Exemplo n.º 1
0
        private void OnCacheRebuilt(IDictionary <double, double> newCache, IAdaptiveAsset adaptiveAsset)
        {
            Asset asset = adaptiveAsset as Asset;

            if (asset != null && newCache != null)
            {
                this.OnCacheRebuilt(new Tuple <IDictionary <double, double>, Asset>(newCache, asset));
            }
        }
Exemplo n.º 2
0
        private IDictionary <double, double> RetrieveAssetCache(IAdaptiveAsset asset, bool removeExistingCache)
        {
            double assetDuration = asset.DurationInSeconds;

            string assetUri = asset.Source.ToString().ToUpperInvariant();

            int manifestIndex = assetUri.LastIndexOf("/MANIFEST");

            string cacheKey = assetUri.Substring(0, assetUri.Length - (assetUri.Length - manifestIndex));

            if (this.assetsCacheIndex.ContainsKey(cacheKey))
            {
                if (removeExistingCache)
                {
                    this.assetsCacheIndex.Remove(cacheKey);
                }
                else
                {
                    IDictionary <double, double> currentCache = this.assetsCacheIndex[cacheKey].Cache;

                    // if (asset == this.assetsCacheIndex[cacheKey].Asset && currentCache.Count > 0)
                    if (currentCache.Count > 0)
                    {
                        return(currentCache);
                    }
                }
            }

            IEnumerable <string> cachedKeys = this.cache.CacheItems.Keys.Where(key => key.ToUpperInvariant().StartsWith(cacheKey) && key.ToUpperInvariant().Contains("/FRAGMENTS(VIDEO="));

            List <double> timecodes = new List <double>();

            foreach (string key in cachedKeys)
            {
                double?timecode = this.ExtractTimecode(key, asset.StartPosition);

                if (timecode.HasValue && !timecodes.Contains(timecode.Value))
                {
                    timecodes.Add(timecode.Value);
                }
            }

            timecodes.Sort();

            IDictionary <double, double> cacheSnapshot = GenerateCacheSnapshot(timecodes, assetDuration);

            this.assetsCacheIndex.Add(cacheKey, new CacheIndex(timecodes, cacheSnapshot, asset));

            return(cacheSnapshot);
        }
 public IDictionary <double, double> RetrieveAssetCache(IAdaptiveAsset adaptiveAsset)
 {
     return(null);
 }
 public IDictionary <double, double> RetrieveAssetCache(IAdaptiveAsset adaptiveAsset)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 5
0
 public IDictionary <double, double> RetrieveAssetCache(IAdaptiveAsset asset)
 {
     return(this.RetrieveAssetCache(asset, false));
 }
Exemplo n.º 6
0
 public CacheIndex(List <double> timecodes, IDictionary <double, double> cache, IAdaptiveAsset asset)
 {
     this.Timecodes = timecodes;
     this.Cache     = cache;
     this.Asset     = asset;
 }