aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs')
-rw-r--r--OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs71
1 files changed, 52 insertions, 19 deletions
diff --git a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs
index a1a2501..3764685 100644
--- a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs
+++ b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs
@@ -32,6 +32,7 @@ using System.Reflection;
32using System.Text; 32using System.Text;
33using System.Threading; 33using System.Threading;
34using log4net; 34using log4net;
35using Mono.Addins;
35using Nini.Config; 36using Nini.Config;
36using OpenMetaverse; 37using OpenMetaverse;
37using OpenMetaverse.Imaging; 38using OpenMetaverse.Imaging;
@@ -45,7 +46,8 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
45{ 46{
46 public delegate void J2KDecodeDelegate(UUID assetID); 47 public delegate void J2KDecodeDelegate(UUID assetID);
47 48
48 public class J2KDecoderModule : IRegionModule, IJ2KDecoder 49 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "J2KDecoderModule")]
50 public class J2KDecoderModule : ISharedRegionModule, IJ2KDecoder
49 { 51 {
50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51 53
@@ -55,27 +57,32 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
55 private readonly Dictionary<UUID, List<DecodedCallback>> m_notifyList = new Dictionary<UUID, List<DecodedCallback>>(); 57 private readonly Dictionary<UUID, List<DecodedCallback>> m_notifyList = new Dictionary<UUID, List<DecodedCallback>>();
56 /// <summary>Cache that will store decoded JPEG2000 layer boundary data</summary> 58 /// <summary>Cache that will store decoded JPEG2000 layer boundary data</summary>
57 private IImprovedAssetCache m_cache; 59 private IImprovedAssetCache m_cache;
60 private IImprovedAssetCache Cache
61 {
62 get
63 {
64 if (m_cache == null)
65 m_cache = m_scene.RequestModuleInterface<IImprovedAssetCache>();
66
67 return m_cache;
68 }
69 }
58 /// <summary>Reference to a scene (doesn't matter which one as long as it can load the cache module)</summary> 70 /// <summary>Reference to a scene (doesn't matter which one as long as it can load the cache module)</summary>
71 private UUID m_CreatorID = UUID.Zero;
59 private Scene m_scene; 72 private Scene m_scene;
60 73
61 #region IRegionModule 74 #region ISharedRegionModule
62 75
63 private bool m_useCSJ2K = true; 76 private bool m_useCSJ2K = true;
64 77
65 public string Name { get { return "J2KDecoderModule"; } } 78 public string Name { get { return "J2KDecoderModule"; } }
66 public bool IsSharedModule { get { return true; } }
67 79
68 public J2KDecoderModule() 80 public J2KDecoderModule()
69 { 81 {
70 } 82 }
71 83
72 public void Initialise(Scene scene, IConfigSource source) 84 public void Initialise(IConfigSource source)
73 { 85 {
74 if (m_scene == null)
75 m_scene = scene;
76
77 scene.RegisterModuleInterface<IJ2KDecoder>(this);
78
79 IConfig startupConfig = source.Configs["Startup"]; 86 IConfig startupConfig = source.Configs["Startup"];
80 if (startupConfig != null) 87 if (startupConfig != null)
81 { 88 {
@@ -83,16 +90,42 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
83 } 90 }
84 } 91 }
85 92
93 public void AddRegion(Scene scene)
94 {
95 if (m_scene == null)
96 {
97 m_scene = scene;
98 m_CreatorID = scene.RegionInfo.RegionID;
99 }
100
101 scene.RegisterModuleInterface<IJ2KDecoder>(this);
102
103 }
104
105 public void RemoveRegion(Scene scene)
106 {
107 if (m_scene == scene)
108 m_scene = null;
109 }
110
86 public void PostInitialise() 111 public void PostInitialise()
87 { 112 {
88 m_cache = m_scene.RequestModuleInterface<IImprovedAssetCache>();
89 } 113 }
90 114
91 public void Close() 115 public void Close()
92 { 116 {
93 } 117 }
94 118
95 #endregion IRegionModule 119 public void RegionLoaded(Scene scene)
120 {
121 }
122
123 public Type ReplaceableInterface
124 {
125 get { return null; }
126 }
127
128 #endregion Region Module interface
96 129
97 #region IJ2KDecoder 130 #region IJ2KDecoder
98 131
@@ -275,11 +308,11 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
275 { 308 {
276 m_decodedCache.AddOrUpdate(AssetId, Layers, TimeSpan.FromMinutes(10)); 309 m_decodedCache.AddOrUpdate(AssetId, Layers, TimeSpan.FromMinutes(10));
277 310
278 if (m_cache != null) 311 if (Cache != null)
279 { 312 {
280 string assetID = "j2kCache_" + AssetId.ToString(); 313 string assetID = "j2kCache_" + AssetId.ToString();
281 314
282 AssetBase layerDecodeAsset = new AssetBase(assetID, assetID, (sbyte)AssetType.Notecard, m_scene.RegionInfo.RegionID.ToString()); 315 AssetBase layerDecodeAsset = new AssetBase(assetID, assetID, (sbyte)AssetType.Notecard, m_CreatorID.ToString());
283 layerDecodeAsset.Local = true; 316 layerDecodeAsset.Local = true;
284 layerDecodeAsset.Temporary = true; 317 layerDecodeAsset.Temporary = true;
285 318
@@ -299,7 +332,7 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
299 332
300 #endregion Serialize Layer Data 333 #endregion Serialize Layer Data
301 334
302 m_cache.Cache(layerDecodeAsset); 335 Cache.Cache(layerDecodeAsset);
303 } 336 }
304 } 337 }
305 338
@@ -309,10 +342,10 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
309 { 342 {
310 return true; 343 return true;
311 } 344 }
312 else if (m_cache != null) 345 else if (Cache != null)
313 { 346 {
314 string assetName = "j2kCache_" + AssetId.ToString(); 347 string assetName = "j2kCache_" + AssetId.ToString();
315 AssetBase layerDecodeAsset = m_cache.Get(assetName); 348 AssetBase layerDecodeAsset = Cache.Get(assetName);
316 349
317 if (layerDecodeAsset != null) 350 if (layerDecodeAsset != null)
318 { 351 {
@@ -324,7 +357,7 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
324 if (lines.Length == 0) 357 if (lines.Length == 0)
325 { 358 {
326 m_log.Warn("[J2KDecodeCache]: Expiring corrupted layer data (empty) " + assetName); 359 m_log.Warn("[J2KDecodeCache]: Expiring corrupted layer data (empty) " + assetName);
327 m_cache.Expire(assetName); 360 Cache.Expire(assetName);
328 return false; 361 return false;
329 } 362 }
330 363
@@ -345,7 +378,7 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
345 catch (FormatException) 378 catch (FormatException)
346 { 379 {
347 m_log.Warn("[J2KDecodeCache]: Expiring corrupted layer data (format) " + assetName); 380 m_log.Warn("[J2KDecodeCache]: Expiring corrupted layer data (format) " + assetName);
348 m_cache.Expire(assetName); 381 Cache.Expire(assetName);
349 return false; 382 return false;
350 } 383 }
351 384
@@ -356,7 +389,7 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
356 else 389 else
357 { 390 {
358 m_log.Warn("[J2KDecodeCache]: Expiring corrupted layer data (layout) " + assetName); 391 m_log.Warn("[J2KDecodeCache]: Expiring corrupted layer data (layout) " + assetName);
359 m_cache.Expire(assetName); 392 Cache.Expire(assetName);
360 return false; 393 return false;
361 } 394 }
362 } 395 }