Exemplo n.º 1
0
        private static FileServer SetupFileServer(Options options,
                                                  DlnaMediaTypes types,
                                                  DirectoryInfo[] d)
        {
            var ids = new Identifiers(
                ComparerRepository.Lookup(options.Order), options.DescendingOrder);

            foreach (var v in options.Views)
            {
                try {
                    ids.AddView(v);
                }
                catch (RepositoryLookupException) {
                    throw new GetOptException("Invalid view " + v);
                }
            }
            var fs = new FileServer(types, ids, d);

            try {
                if (options.CacheFile != null)
                {
                    fs.SetCacheFile(options.CacheFile);
                }
                fs.Load();
            }
            catch (Exception) {
                fs.Dispose();
                throw;
            }
            return(fs);
        }
Exemplo n.º 2
0
        private byte[] GetThumbnailInternal(string key, object item,
                                            DlnaMediaTypes type, ref int width,
                                            ref int height)
        {
            var thumbnailers = thumbers[type];
            var rw           = width;
            var rh           = height;

            foreach (var thumber in thumbnailers)
            {
                try {
                    using (var i = thumber.GetThumbnail(item, ref width, ref height)) {
                        var rv = i.ToArray();
                        lock (cache) {
                            cache[key] = new CacheItem(rv, rw, rh);
                        }
                        return(rv);
                    }
                }
                catch (Exception ex) {
                    Debug(String.Format(
                              "{0} failed to thumbnail a resource", thumber.GetType()), ex);
                    continue;
                }
            }
            throw new ArgumentException("Not a supported resource");
        }
Exemplo n.º 3
0
        private PlainFolder(FileServer server, DlnaMediaTypes types,
                            VirtualFolder parent, DirectoryInfo dir,
                            IEnumerable <string> exts)
            : base(parent, dir.Name)
        {
            Server   = server;
            this.dir = dir;
            folders  = (from d in dir.GetDirectories()
                        let m = TryGetFolder(server, types, d)
                                where m != null && m.ChildCount > 0
                                select m as IMediaFolder).ToList();

            var rawfiles = from f in dir.GetFiles("*.*")
                           select f;
            var files = new List <BaseFile>();

            foreach (var f in rawfiles)
            {
                var ext = f.Extension;
                if (string.IsNullOrEmpty(ext) ||
                    !exts.Contains(ext.Substring(1), StringComparer.OrdinalIgnoreCase))
                {
                    continue;
                }
                try {
                    files.Add(server.GetFile(this, f));
                }
                catch (Exception ex) {
                    server.Warn(f, ex);
                }
            }
            resources.AddRange(files);
        }
Exemplo n.º 4
0
        protected BaseFile(FileServer server, FileInfo aFile, DlnaMime aType, DlnaMediaTypes aMediaType)
        {
            if (server == null)
            {
                throw new ArgumentNullException("server");
            }
            this.server = server;
            Item        = aFile;

            length       = Item.Length;
            lastModified = Item.LastWriteTimeUtc;

            Type      = aType;
            MediaType = aMediaType;

            title = System.IO.Path.GetFileNameWithoutExtension(Item.Name);
            if (string.IsNullOrEmpty(title))
            {
                title = Item.Name;
            }
            if (!string.IsNullOrWhiteSpace(title))
            {
                title = Uri.UnescapeDataString(title);
            }
            title = title.StemNameBase();
        }
Exemplo n.º 5
0
 private byte[] GetThumbnailInternal(string key, object item,
                                     DlnaMediaTypes type, ref int width,
                                     ref int height)
 {
   var thumbnailers = thumbers[type];
   var rw = width;
   var rh = height;
   foreach (var thumber in thumbnailers) {
     try {
       using (var i = thumber.GetThumbnail(item, ref width, ref height)) {
         var rv = i.ToArray();
         lock (cache) {
           cache[key] = new CacheItem(rv, rw, rh);
         }
         return rv;
       }
     }
     catch (Exception ex) {
       Debug(String.Format(
         "{0} failed to thumbnail a resource", thumber.GetType()), ex);
       continue;
     }
   }
   throw new ArgumentException("Not a supported resource");
 }
Exemplo n.º 6
0
 public FileServer(DlnaMediaTypes types, Identifiers ids, params DirectoryInfo[] directories)
 {
     this.types = types;
       this.ids = ids;
       this.directories = directories.Distinct().ToArray();
       if (this.directories.Length == 0) {
     throw new ArgumentException(
       "Provide one or more directories",
       "directories"
       );
       }
       var parent = this.directories[0].Parent;
       if (parent == null) {
     parent = this.directories[0];
       }
       if (this.directories.Length == 1) {
     FriendlyName = string.Format(
       "{0} ({1})",
       this.directories[0].Name,
       parent.FullName
       );
       }
       else {
     FriendlyName = string.Format(
       "{0} ({1}) + {2}",
       this.directories[0].Name,
       parent.FullName,
       this.directories.Length - 1
       );
       }
       watchers = (from d in directories
           select new FileSystemWatcher(d.FullName)).ToArray();
       uuid = DeriveUUID();
 }
Exemplo n.º 7
0
        public FileServer(DlnaMediaTypes types, Identifiers ids,
                          params DirectoryInfo[] directories)
        {
            this.types       = types;
            this.ids         = ids;
            this.directories = (
                from d in directories.Distinct()
                where
                (this.ShowHidden || !d.Attributes.HasFlag(FileAttributes.Hidden) && !d.Name.StartsWith(".") || d.IsRoot()) &&
                (this.ShowSample || !d.FullName.ToLower().Contains("sample"))
                select d
                ).ToArray();

            if (this.directories.Length == 0)
            {
                throw new ArgumentException("Provide one or more directories", nameof(directories));
            }

            var parent = this.directories[0].Parent ?? this.directories[0];

            this.FriendlyName = $"{this.directories[0].Name} ({parent.FullName})";
            if (this.directories.Length != 1)
            {
                this.FriendlyName += $" + {this.directories.Length - 1}";
            }

            this.watchers = (
                from d in directories
                select new FileSystemWatcher(d.FullName)
                ).ToArray();

            this.Uuid = this.DeriveUUID();
        }
Exemplo n.º 8
0
        protected BaseFile(FileServer server, FileInfo file, DlnaMime type,
                           DlnaMediaTypes mediaType)
        {
            if (server == null)
            {
                throw new ArgumentNullException(nameof(server));
            }
            Server = server;
            Item   = file;

            length       = Item.Length;
            lastModified = Item.LastWriteTimeUtc;

            Type      = type;
            MediaType = mediaType;

            title = System.IO.Path.GetFileNameWithoutExtension(Item.Name);
            if (string.IsNullOrEmpty(title))
            {
                title = Item.Name;
            }
            if (!string.IsNullOrWhiteSpace(title))
            {
                try {
                    title = Uri.UnescapeDataString(title);
                }
                catch (UriFormatException) {
                    // no op
                }
            }
            title = title.StemNameBase();
        }
Exemplo n.º 9
0
        private PlainFolder(FileServer server, DlnaMediaTypes types, VirtualFolder parent, DirectoryInfo dir, IEnumerable<string> exts)
            : base(parent, dir.Name)
        {
            Server = server;
              this.dir = dir;
              folders = (from d in dir.GetDirectories()
                 let m = TryGetFolder(server, types, d)
                 where m != null && m.ChildCount > 0
                 select m as IMediaFolder).ToList();

              var rawfiles = from f in dir.GetFiles("*.*")
                     select f;
              var files = new List<BaseFile>();
              foreach (var f in rawfiles) {
            var ext = f.Extension;
            if (string.IsNullOrEmpty(ext) ||
              !exts.Contains(ext.Substring(1), StringComparer.InvariantCultureIgnoreCase)) {
              continue;
            }
            try {
              files.Add(server.GetFile(this, f));
            }
            catch (Exception ex) {
              server.Warn(f, ex);
            }
              }
              resources.AddRange(files);
        }
Exemplo n.º 10
0
        private static FileServer SetupFileServer(DlnaMediaTypes types, string[] Tags)
        {
            var ids = new Identifiers(
                ComparerRepository.Lookup("title"), true);

            string[] Views = new string[0];
            foreach (var v in Views)
            {
                try
                {
                    ids.AddView(v);
                }
                catch (RepositoryLookupException)
                {
                    throw new Exception("Invalid view " + v);
                }
            }

            var fs = new FileServer(types, ids, Tags.ToList());

            fs.FriendlyName     = Tags[0];
            Program.previews_db = new SQLiteConnection("data source=" + "C:\\utils\\data\\Previews.sqlite");
            Program.previews_db.Open();
            fs.PreviewsDB           = Program.previews_db;
            fs.ErzaConnectionString = "data source=C:\\utils\\data\\erza.sqlite";
            fs.Load();
            return(fs);
        }
Exemplo n.º 11
0
        protected BaseFile(FileServer server, FileInfo aFile, DlnaMime aType, DlnaMediaTypes aMediaType)
        {
            if (server == null) {
            throw new ArgumentNullException("server");
              }
              this.server = server;
              Item = aFile;

              length = Item.Length;
              lastModified = Item.LastWriteTimeUtc;

              Type = aType;
              MediaType = aMediaType;

              title = System.IO.Path.GetFileNameWithoutExtension(Item.Name);
              if (string.IsNullOrEmpty(title)) {
            title = Item.Name;
              }
              if (!string.IsNullOrWhiteSpace(title)) {
            try {
              title = Uri.UnescapeDataString(title);
            }
            catch (UriFormatException) {
              // no op
            }
              }
              title = title.StemNameBase();
        }
Exemplo n.º 12
0
        public FileServer(DlnaMediaTypes types, Identifiers ids,
                          params DirectoryInfo[] directories)
        {
            this.types       = types;
            this.ids         = ids;
            this.directories = directories.Distinct().ToArray();
            Filter           = new ExtensionFilter(this.types.GetExtensions());

            if (this.directories.Length == 0)
            {
                throw new ArgumentException(
                          "Provide one or more directories",
                          nameof(directories)
                          );
            }
            var parent = this.directories[0].Parent ?? this.directories[0];

            FriendlyName = this.directories.Length == 1
                           //  ? $"{this.directories[0].Name} ({parent.FullName})"
                           //  : $"{this.directories[0].Name} ({parent.FullName}) + {this.directories.Length - 1}";
        ? $"{this.directories[0].Name}"
        : $"{this.directories[0].Name} + {this.directories.Length - 1}";
            watchers = (from d in directories
                        select new FileSystemWatcher(d.FullName)).ToArray();
            UUID = DeriveUUID();
        }
Exemplo n.º 13
0
 public IThumbnail GetThumbnail(string key, DlnaMediaTypes type, Stream stream, int width, int height)
 {
     return
         (GetThumbnailFromCache(ref key, ref width, ref height, out var rv)
 ? new Thumbnail(width, height, rv)
 : new Thumbnail(width, height, this.GetThumbnailInternal(key, stream, type, ref width, ref height))
         );
 }
Exemplo n.º 14
0
 public FileServer(DlnaMediaTypes types, Identifiers ids, List <string> Tags)
 {
     this.types   = types;
     this.ids     = ids;
     FriendlyName = Tags[0];
     this.Tags    = Tags;
     //UUID = DeriveUUID();
 }
Exemplo n.º 15
0
 public byte[] GetThumbnail(string key, DlnaMediaTypes type, Stream stream, ref int width, ref int height)
 {
     byte[] rv;
       if (GetThumbnailFromCache(ref key, ref width, ref height, out rv)) {
     return rv;
       }
       return GetThumbnailInternal(key, stream, type, ref width, ref height);
 }
Exemplo n.º 16
0
 public ServerDescription(string name, string order, bool orderDescending, DlnaMediaTypes types, List<string> views, List<string> directories)
 {
     Name = name;
       Order = order;
       OrderDescending = orderDescending;
       Types = types;
       Views = views.ToArray();
       Directories = directories.ToArray();
 }
Exemplo n.º 17
0
 public ServerDescription(string name, string order, bool orderDescending, DlnaMediaTypes types, List <string> views, List <string> directories)
 {
     Name            = name;
     Order           = order;
     OrderDescending = orderDescending;
     Types           = types;
     Views           = views.ToArray();
     Directories     = directories.ToArray();
 }
Exemplo n.º 18
0
 public byte[] GetThumbnail(string key, DlnaMediaTypes type, Stream stream, ref int width, ref int height)
 {
     byte[] rv;
     if (GetThumbnailFromCache(ref key, ref width, ref height, out rv))
     {
         return(rv);
     }
     return(GetThumbnailInternal(key, stream, type, ref width, ref height));
 }
Exemplo n.º 19
0
 public static IEnumerable <string> GetExtensions(this DlnaMediaTypes types)
 {
     return((from i in DlnaMaps.Media2Ext
             where types.HasFlag(i.Key)
             select i.Value).SelectMany(i =>
     {
         return i;
     }));
 }
Exemplo n.º 20
0
 protected VirtualClonedFolder(IMediaFolder parent, string name, string id, DlnaMediaTypes types)
     : base(parent, name, id)
 {
     this.types = types;
     Id         = id;
     clone      = parent;
     CloneFolder(this, parent);
     Cleanup();
 }
 protected VirtualClonedFolder(IMediaFolder parent, string name, string id, DlnaMediaTypes types)
     : base(parent, name, id)
 {
     this.types = types;
       Id = id;
       clone = parent;
       CloneFolder(this, parent);
       Cleanup();
 }
Exemplo n.º 22
0
 public IThumbnail GetThumbnail(string key, DlnaMediaTypes type,
                            Stream stream, int width, int height)
 {
     byte[] rv;
       if (GetThumbnailFromCache(ref key, ref width, ref height, out rv)) {
     return new Thumbnail(width, height, rv);
       }
       rv = GetThumbnailInternal(key, stream, type, ref width, ref height);
       return new Thumbnail(width, height, rv);
 }
Exemplo n.º 23
0
 private PlainFolder TryGetFolder(FileServer server, DlnaMediaTypes types, DirectoryInfo d)
 {
     try {
         return(new PlainFolder(server, types, this, d));
     }
     catch (Exception ex) {
         server.Warn("Failed to access folder", ex);
         return(null);
     }
 }
Exemplo n.º 24
0
        private static void InitMediaMeta(string[][] k, DlnaMediaTypes t)
        {
            foreach (var i in k)
            {
                var e = (from ext in i
                         select ext.ToUpperInvariant()).ToList();

                AddMediaExtension(MediaMetaExt, e, t);
            }
        }
Exemplo n.º 25
0
 public IThumbnail GetThumbnail(string key, DlnaMediaTypes type,
                                Stream stream, int width, int height)
 {
     byte[] rv;
     if (GetThumbnailFromCache(ref key, ref width, ref height, out rv))
     {
         return(new Thumbnail(width, height, rv));
     }
     rv = GetThumbnailInternal(key, stream, type, ref width, ref height);
     return(new Thumbnail(width, height, rv));
 }
Exemplo n.º 26
0
 internal static BaseFile GetFile(PlainFolder parentFolder, FileInfo file,
                                  DlnaMime type, DlnaMediaTypes mediaType)
 {
   switch (mediaType) {
     case DlnaMediaTypes.Video:
       return new VideoFile(parentFolder.Server, file, type);
     case DlnaMediaTypes.Audio:
       return new AudioFile(parentFolder.Server, file, type);
     case DlnaMediaTypes.Image:
       return new ImageFile(parentFolder.Server, file, type);
     default:
       return new BaseFile(parentFolder.Server, file, type, mediaType);
   }
 }
Exemplo n.º 27
0
 private static void InitMedia(string[][] k, DlnaMediaTypes t)
 {
     foreach (var i in k)
     {
         var e = new List <string>(i);
         try {
             Media2Ext.Add(t, e);
         }
         catch (ArgumentException) {
             Media2Ext[t].AddRange(i);
         }
         foreach (var ext in e)
         {
             Ext2Media.Add(ext, t);
         }
     }
 }
Exemplo n.º 28
0
        public FileServer(DlnaMediaTypes types, Identifiers ids,
                          params DirectoryInfo[] directories)
        {
            this.types       = types;
            this.ids         = ids;
            this.directories =
                (from d in directories.Distinct()
                 where
                 (ShowHidden || (!d.Attributes.HasFlag(FileAttributes.Hidden) && !d.Name.StartsWith("."))) &&
                 (ShowSample || !d.FullName.ToLower().Contains("sample"))
                 select d).ToArray();

            if (this.directories.Length == 0)
            {
                throw new ArgumentException(
                          "Provide one or more directories",
                          "directories"
                          );
            }
            var parent = this.directories[0].Parent;

            if (parent == null)
            {
                parent = this.directories[0];
            }
            if (this.directories.Length == 1)
            {
                FriendlyName = string.Format(
                    "{0} ({1})",
                    this.directories[0].Name,
                    parent.FullName
                    );
            }
            else
            {
                FriendlyName = string.Format(
                    "{0} ({1}) + {2}",
                    this.directories[0].Name,
                    parent.FullName,
                    this.directories.Length - 1
                    );
            }
            watchers = (from d in directories
                        select new FileSystemWatcher(d.FullName)).ToArray();
            uuid = DeriveUUID();
        }
Exemplo n.º 29
0
        private static FileServer SetupFileServer(Options options,
                                                  DlnaMediaTypes types,
                                                  DirectoryInfo[] d)
        {
            var ids = new Identifiers(
                ComparerRepository.Lookup(options.Order), options.DescendingOrder);

            foreach (var v in options.Views)
            {
                try
                {
                    ids.AddView(v);
                }
                catch (RepositoryLookupException)
                {
                    throw new GetOptException("Invalid view " + v);
                }
            }
            var fs = new FileServer(types, ids, d);

            if (!string.IsNullOrEmpty(options.FriendlyName))
            {
                fs.FriendlyName = options.FriendlyName;
            }
            fs.ShowHidden = options.ShowHidden;
            fs.ShowSample = options.ShowSample;
            try
            {
                if (options.CacheFile != null)
                {
                    fs.SetCacheFile(options.CacheFile);
                }
                fs.Load();
                if (!options.Rescanning)
                {
                    fs.Rescanning = false;
                }
            }
            catch (Exception)
            {
                fs.Dispose();
                throw;
            }
            return(fs);
        }
Exemplo n.º 30
0
 private static void InitMedia(string[][] k, DlnaMediaTypes t)
 {
     foreach (var i in k)
     {
         var e = (from ext in i
                  select ext.ToUpperInvariant()).ToList();
         try {
             Media2Ext.Add(t, e);
         }
         catch (ArgumentException) {
             Media2Ext[t].AddRange(e);
         }
         foreach (var ext in e)
         {
             Ext2Media.Add(ext.ToUpperInvariant(), t);
         }
     }
 }
Exemplo n.º 31
0
        private PlainFolder TryGetFolder(FileServer server, DlnaMediaTypes types,
                                         DirectoryInfo d)
        {
            // HAWKYNT: exclude recycle bin and system volume information
            if (d.Parent.IsRoot())
            {
                if (_EXCLUDED_ROOT_DIRECTORY_NAMES.Any(i => i == d.Name))
                {
                    Trace.WriteLine($"[Info]Skipping {d.FullName} because it is blacklisted");
                    return(null);
                }
            }

            try {
                return(new PlainFolder(server, types, this, d));
            }
            catch (Exception ex) {
                server.Warn("Failed to access folder", ex);
                return(null);
            }
        }
Exemplo n.º 32
0
 public FileServer(DlnaMediaTypes types, Identifiers ids, params DirectoryInfo[] directories)
 {
     this.types       = types;
     this.ids         = ids;
     this.directories = directories.Distinct().ToArray();
     if (this.directories.Length == 0)
     {
         throw new ArgumentException("Provide one or more directories", "directories");
     }
     if (this.directories.Length == 1)
     {
         FriendlyName = string.Format("{0} ({1})", this.directories[0].Name, this.directories[0].Parent.FullName);
     }
     else
     {
         FriendlyName = string.Format("{0} ({1}) + {2}", this.directories[0].Name, this.directories[0].Parent.FullName, this.directories.Length - 1);
     }
     watchers = (from d in directories
                 select new FileSystemWatcher(d.FullName)).ToArray();
     uuid = DeriveUUID();
 }
Exemplo n.º 33
0
        public FileServer(DlnaMediaTypes types, Identifiers ids,
      params DirectoryInfo[] directories)
        {
            this.types = types;
              this.ids = ids;
              this.directories = directories.Distinct().ToArray();
              Filter = new ExtensionFilter(this.types.GetExtensions());

              if (this.directories.Length == 0) {
            throw new ArgumentException(
              "Provide one or more directories",
              nameof(directories)
              );
              }
              var parent = this.directories[0].Parent ?? this.directories[0];
              FriendlyName = this.directories.Length == 1
            ? $"{this.directories[0].Name} ({parent.FullName})"
            : $"{this.directories[0].Name} ({parent.FullName}) + {this.directories.Length - 1}";
              watchers = (from d in directories
                  select new FileSystemWatcher(d.FullName)).ToArray();
              UUID = DeriveUUID();
        }
Exemplo n.º 34
0
 private static FileServer SetupFileServer(Options options,
                                           DlnaMediaTypes types,
                                           DirectoryInfo[] d)
 {
   var ids = new Identifiers(
     ComparerRepository.Lookup(options.Order), options.DescendingOrder);
   foreach (var v in options.Views) {
     try {
       ids.AddView(v);
     }
     catch (RepositoryLookupException) {
       throw new GetOptException("Invalid view " + v);
     }
   }
   var fs = new FileServer(types, ids, d);
   if (!string.IsNullOrEmpty(options.FriendlyName)) {
     fs.FriendlyName = options.FriendlyName;
   }
   try {
     if (options.CacheFile != null) {
       fs.SetCacheFile(options.CacheFile);
     }
     fs.Load();
     if (!options.Rescanning) {
       fs.Rescanning = false;
     }
   }
   catch (Exception) {
     fs.Dispose();
     throw;
   }
   return fs;
 }
Exemplo n.º 35
0
        internal static BaseFile GetFile(PlainFolder aParentFolder, FileInfo aFile, DlnaMime aType, DlnaMediaTypes aMediaType)
        {
            switch (aMediaType)
            {
            case DlnaMediaTypes.Video:
                return(new VideoFile(aParentFolder.Server, aFile, aType));

            case DlnaMediaTypes.Audio:
                return(new AudioFile(aParentFolder.Server, aFile, aType));

            case DlnaMediaTypes.Image:
                return(new ImageFile(aParentFolder.Server, aFile, aType));

            default:
                return(new BaseFile(aParentFolder.Server, aFile, aType, aMediaType));
            }
        }
Exemplo n.º 36
0
 public PlainRootFolder(FileServer server, DlnaMediaTypes types, DirectoryInfo di)
     : base(server, types, null, di)
 {
     Id = Identifiers.ROOT;
 }
Exemplo n.º 37
0
 private static void InitMedia(string[][] k, DlnaMediaTypes t)
 {
     foreach (var i in k) {
     var e = new List<string>(i);
     try {
       Media2Ext.Add(t, e);
     }
     catch (ArgumentException) {
       Media2Ext[t].AddRange(i);
     }
     foreach (var ext in e) {
       Ext2Media.Add(ext, t);
     }
       }
 }
Exemplo n.º 38
0
 internal PlainRootFolder(FileServer server, DlnaMediaTypes types,
                          DirectoryInfo di)
   : base(server, types, null, di)
 {
   Id = Identifiers.GeneralRoot;
 }
Exemplo n.º 39
0
 public BaseFileMock(FileServer server, FileInfo file, DlnaMime type,
                     DlnaMediaTypes mediaType) : base(server, file, type, mediaType)
 {
 }
Exemplo n.º 40
0
 internal static BaseFile GetFile(PlainFolder parentFolder, FileInfo file,
                              DlnaMime type, DlnaMediaTypes mediaType)
 {
     switch (mediaType) {
     case DlnaMediaTypes.Video:
       return new VideoFile(parentFolder.Server, file, type);
     case DlnaMediaTypes.Audio:
       return new AudioFile(parentFolder.Server, file, type);
     case DlnaMediaTypes.Image:
       return new ImageFile(parentFolder.Server, file, type);
     default:
       return new BaseFile(parentFolder.Server, file, type, mediaType);
       }
 }
Exemplo n.º 41
0
 private PlainFolder TryGetFolder(FileServer server, DlnaMediaTypes types, DirectoryInfo d)
 {
     try {
     return new PlainFolder(server, types, this, d);
       }
       catch (Exception ex) {
     server.Warn("Failed to access folder", ex);
     return null;
       }
 }
Exemplo n.º 42
0
 public BaseFileMock(FileServer server, FileInfo file, DlnaMime type,
            DlnaMediaTypes mediaType)
     : base(server,file,type,mediaType)
 {
 }
Exemplo n.º 43
0
 protected PlainFolder(FileServer server, DlnaMediaTypes types, VirtualFolder parent, DirectoryInfo dir)
     : this(server, types, parent, dir, GetExtensions(types))
 {
 }
Exemplo n.º 44
0
        private static FileServer ConfiguraServidorDeArquivos(Opcoes opcoes, DlnaMediaTypes tipos, DirectoryInfo[] d)
        {
            var ids = new Identifiers(ComparerRepository.Lookup(opcoes.Ordem), opcoes.Ascendente);

            var fs = new FileServer(tipos, ids, d);
            try
            {
                if (opcoes.ArquivoCache != null)
                {
                    fs.SetCacheFile(opcoes.ArquivoCache);
                }
                fs.Load();
            }
            catch (Exception)
            {
                fs.Dispose();
                throw;
            }
            return fs;
        }
Exemplo n.º 45
0
 internal static BaseFile GetFile(PlainFolder aParentFolder, FileInfo aFile, DlnaMime aType, DlnaMediaTypes aMediaType)
 {
     switch (aMediaType) {
     case DlnaMediaTypes.Video:
       return new VideoFile(aParentFolder.Server, aFile, aType);
     case DlnaMediaTypes.Audio:
       return new AudioFile(aParentFolder.Server, aFile, aType);
     case DlnaMediaTypes.Image:
       return new ImageFile(aParentFolder.Server, aFile, aType);
     default:
       return new BaseFile(aParentFolder.Server, aFile, aType, aMediaType);
       }
 }
Exemplo n.º 46
0
 internal PlainRootFolder(FileServer server, DlnaMediaTypes types,
                          DirectoryInfo di)
     : base(server, types, null, di)
 {
     Id = Identifiers.GeneralRoot;
 }
 public VirtualClonedFolder(IMediaFolder parent, string name, DlnaMediaTypes types)
     : this(parent, name, name, types)
 {
 }
Exemplo n.º 48
0
 private static IEnumerable<string> GetExtensions(DlnaMediaTypes types)
 {
     return (from i in DlnaMaps.Media2Ext
       where types.HasFlag(i.Key)
       select i.Value).SelectMany(i => { return i; });
 }
Exemplo n.º 49
0
 protected PlainFolder(FileServer server, DlnaMediaTypes types,
                       VirtualFolder parent, DirectoryInfo dir)
     : this(server, types, parent, dir, types.GetExtensions())
 {
 }
Exemplo n.º 50
0
 public VirtualClonedFolder(IMediaFolder parent, string name,
                            DlnaMediaTypes types)
     : this(parent, name, name, types)
 {
 }
Exemplo n.º 51
0
 private static void InitMedia(string[][] k, DlnaMediaTypes t)
 {
     foreach (var i in k) {
     var e = (from ext in i
          select ext.ToUpperInvariant()).ToList();
     try {
       Media2Ext.Add(t, e);
     }
     catch (ArgumentException) {
       Media2Ext[t].AddRange(e);
     }
     foreach (var ext in e) {
       Ext2Media.Add(ext.ToUpperInvariant(), t);
     }
       }
 }
Exemplo n.º 52
0
 public PlainRootFolder(FileServer server, DlnaMediaTypes types, DirectoryInfo di)
     : base(server, types, null, di)
 {
     Id = Identifiers.ROOT;
 }