aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs54
-rw-r--r--bin/OpenSim.ini.example2
2 files changed, 48 insertions, 8 deletions
diff --git a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs
index df321a2..937f76b 100644
--- a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs
+++ b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs
@@ -30,6 +30,7 @@ using System.Collections.Generic;
30using System.IO; 30using System.IO;
31using System.Reflection; 31using System.Reflection;
32using System.Text; 32using System.Text;
33using System.Threading;
33using log4net; 34using log4net;
34using Nini.Config; 35using Nini.Config;
35using OpenMetaverse; 36using OpenMetaverse;
@@ -38,6 +39,7 @@ using OpenMetaverse.Imaging;
38using OpenSim.Framework; 39using OpenSim.Framework;
39using OpenSim.Region.Framework.Interfaces; 40using OpenSim.Region.Framework.Interfaces;
40using OpenSim.Region.Framework.Scenes; 41using OpenSim.Region.Framework.Scenes;
42using OpenSim.Services.Interfaces;
41 43
42namespace OpenSim.Region.CoreModules.Agent.TextureSender 44namespace OpenSim.Region.CoreModules.Agent.TextureSender
43{ 45{
@@ -56,8 +58,11 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
56 private readonly Dictionary<UUID, OpenJPEG.J2KLayerInfo[]> m_cacheddecode = new Dictionary<UUID, OpenJPEG.J2KLayerInfo[]>(); 58 private readonly Dictionary<UUID, OpenJPEG.J2KLayerInfo[]> m_cacheddecode = new Dictionary<UUID, OpenJPEG.J2KLayerInfo[]>();
57 private bool OpenJpegFail = false; 59 private bool OpenJpegFail = false;
58 private string CacheFolder = Util.dataDir() + "/j2kDecodeCache"; 60 private string CacheFolder = Util.dataDir() + "/j2kDecodeCache";
59 private int CacheTimeout = 60; 61 private int CacheTimeout = 720;
60 private J2KDecodeFileCache fCache; 62 private J2KDecodeFileCache fCache = null;
63 private Thread CleanerThread = null;
64 private IAssetService AssetService = null;
65 private Scene m_Scene = null;
61 66
62 /// <summary> 67 /// <summary>
63 /// List of client methods to notify of results of decode 68 /// List of client methods to notify of results of decode
@@ -70,6 +75,9 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
70 75
71 public void Initialise(Scene scene, IConfigSource source) 76 public void Initialise(Scene scene, IConfigSource source)
72 { 77 {
78 if (m_Scene == null)
79 m_Scene = scene;
80
73 IConfig j2kConfig = source.Configs["J2KDecoder"]; 81 IConfig j2kConfig = source.Configs["J2KDecoder"];
74 if (j2kConfig != null) 82 if (j2kConfig != null)
75 { 83 {
@@ -77,14 +85,23 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
77 CacheTimeout = j2kConfig.GetInt("CacheTimeout", CacheTimeout); 85 CacheTimeout = j2kConfig.GetInt("CacheTimeout", CacheTimeout);
78 } 86 }
79 87
80 fCache = new J2KDecodeFileCache(CacheFolder, CacheTimeout); 88 if (fCache == null)
89 fCache = new J2KDecodeFileCache(CacheFolder, CacheTimeout);
81 90
82 scene.RegisterModuleInterface<IJ2KDecoder>(this); 91 scene.RegisterModuleInterface<IJ2KDecoder>(this);
92
93 if (CleanerThread == null && CacheTimeout != 0)
94 {
95 CleanerThread = new Thread(CleanCache);
96 CleanerThread.Name = "J2KCleanerThread";
97 CleanerThread.IsBackground = true;
98 CleanerThread.Start();
99 }
83 } 100 }
84 101
85 public void PostInitialise() 102 public void PostInitialise()
86 { 103 {
87 104 AssetService = m_Scene.AssetService;
88 } 105 }
89 106
90 public void Close() 107 public void Close()
@@ -340,8 +357,9 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
340 // Cache Decoded layers 357 // Cache Decoded layers
341 lock (m_cacheddecode) 358 lock (m_cacheddecode)
342 { 359 {
343 if (!m_cacheddecode.ContainsKey(AssetId)) 360 if (m_cacheddecode.ContainsKey(AssetId))
344 m_cacheddecode.Add(AssetId, layers); 361 m_cacheddecode.Remove(AssetId);
362 m_cacheddecode.Add(AssetId, layers);
345 363
346 } 364 }
347 365
@@ -359,6 +377,28 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
359 } 377 }
360 } 378 }
361 } 379 }
380
381 private void CleanCache()
382 {
383 m_log.Info("[J2KDecoderModule]: Cleaner thread started");
384
385 while (true)
386 {
387 if (AssetService != null)
388 fCache.ScanCacheFiles(RedecodeTexture);
389
390 System.Threading.Thread.Sleep(600000);
391 }
392 }
393
394 private void RedecodeTexture(UUID assetID)
395 {
396 AssetBase texture = AssetService.Get(assetID.ToString());
397 if (texture == null)
398 return;
399
400 doJ2kDecode(assetID, texture.Data);
401 }
362 } 402 }
363 403
364 public class J2KDecodeFileCache 404 public class J2KDecodeFileCache
@@ -656,7 +696,7 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
656 { 696 {
657 File.Delete(f.Name); 697 File.Delete(f.Name);
658 decode(AssetIdFromFileName(f.Name)); 698 decode(AssetIdFromFileName(f.Name));
659 System.Threading.Thread.Sleep(2000); 699 System.Threading.Thread.Sleep(5000);
660 } 700 }
661 } 701 }
662 } 702 }
diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example
index 3529599..2303873 100644
--- a/bin/OpenSim.ini.example
+++ b/bin/OpenSim.ini.example
@@ -1371,7 +1371,7 @@
1371 1371
1372[J2KDecoder] 1372[J2KDecoder]
1373;CacheDir = "./j2kDecodeCache" 1373;CacheDir = "./j2kDecodeCache"
1374;CacheTimeout = 60 1374;CacheTimeout = 720
1375 1375
1376;; 1376;;
1377;; These are defaults that are overwritten below in [Architecture]. 1377;; These are defaults that are overwritten below in [Architecture].