aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs')
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs63
1 files changed, 50 insertions, 13 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs b/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs
index cb9692a..afbe56b 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs
@@ -45,6 +45,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
45 private const int IMAGE_PACKET_SIZE = 1000; 45 private const int IMAGE_PACKET_SIZE = 1000;
46 private const int FIRST_PACKET_SIZE = 600; 46 private const int FIRST_PACKET_SIZE = 600;
47 47
48 /// <summary>
49 /// If we've requested an asset but not received it in this ticks timeframe, then allow a duplicate
50 /// request from the client to trigger a fresh asset request.
51 /// </summary>
52 /// <remarks>
53 /// There are 10,000 ticks in a millisecond
54 /// </remarks>
55 private const int ASSET_REQUEST_TIMEOUT = 100000000;
56
48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 57 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49 58
50 public uint LastSequence; 59 public uint LastSequence;
@@ -57,8 +66,22 @@ namespace OpenSim.Region.ClientStack.LindenUDP
57 public UUID AgentID; 66 public UUID AgentID;
58 public IInventoryAccessModule InventoryAccessModule; 67 public IInventoryAccessModule InventoryAccessModule;
59 private OpenJPEG.J2KLayerInfo[] m_layers; 68 private OpenJPEG.J2KLayerInfo[] m_layers;
69
70 /// <summary>
71 /// Has this request decoded the asset data?
72 /// </summary>
60 public bool IsDecoded { get; private set; } 73 public bool IsDecoded { get; private set; }
74
75 /// <summary>
76 /// Has this request received the required asset data?
77 /// </summary>
61 public bool HasAsset { get; private set; } 78 public bool HasAsset { get; private set; }
79
80 /// <summary>
81 /// Time in milliseconds at which the asset was requested.
82 /// </summary>
83 public long AssetRequestTime { get; private set; }
84
62 public C5.IPriorityQueueHandle<J2KImage> PriorityQueueHandle; 85 public C5.IPriorityQueueHandle<J2KImage> PriorityQueueHandle;
63 86
64 private uint m_currentPacket; 87 private uint m_currentPacket;
@@ -82,7 +105,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
82 /// <param name="packetsToSend">Maximum number of packets to send during this call</param> 105 /// <param name="packetsToSend">Maximum number of packets to send during this call</param>
83 /// <param name="packetsSent">Number of packets sent during this call</param> 106 /// <param name="packetsSent">Number of packets sent during this call</param>
84 /// <returns>True if the transfer completes at the current discard level, otherwise false</returns> 107 /// <returns>True if the transfer completes at the current discard level, otherwise false</returns>
85 public bool SendPackets(LLClientView client, int packetsToSend, out int packetsSent) 108 public bool SendPackets(IClientAPI client, int packetsToSend, out int packetsSent)
86 { 109 {
87 packetsSent = 0; 110 packetsSent = 0;
88 111
@@ -102,7 +125,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
102 { 125 {
103 m_currentPacket = 2; 126 m_currentPacket = 2;
104 } 127 }
105 128
106 while (sendMore && packetsSent < packetsToSend && m_currentPacket <= m_stopPacket) 129 while (sendMore && packetsSent < packetsToSend && m_currentPacket <= m_stopPacket)
107 { 130 {
108 sendMore = SendPacket(client); 131 sendMore = SendPacket(client);
@@ -114,17 +137,24 @@ namespace OpenSim.Region.ClientStack.LindenUDP
114 return (m_currentPacket > m_stopPacket); 137 return (m_currentPacket > m_stopPacket);
115 } 138 }
116 139
140 /// <summary>
141 /// This is where we decide what we need to update
142 /// and assign the real discardLevel and packetNumber
143 /// assuming of course that the connected client might be bonkers
144 /// </summary>
117 public void RunUpdate() 145 public void RunUpdate()
118 { 146 {
119 //This is where we decide what we need to update
120 //and assign the real discardLevel and packetNumber
121 //assuming of course that the connected client might be bonkers
122
123 if (!HasAsset) 147 if (!HasAsset)
124 { 148 {
125 if (!m_assetRequested) 149 if (!m_assetRequested || DateTime.UtcNow.Ticks > AssetRequestTime + ASSET_REQUEST_TIMEOUT)
126 { 150 {
151// m_log.DebugFormat(
152// "[J2KIMAGE]: Requesting asset {0} from request in packet {1}, already requested? {2}, due to timeout? {3}",
153// TextureID, LastSequence, m_assetRequested, DateTime.UtcNow.Ticks > AssetRequestTime + ASSET_REQUEST_TIMEOUT);
154
127 m_assetRequested = true; 155 m_assetRequested = true;
156 AssetRequestTime = DateTime.UtcNow.Ticks;
157
128 AssetService.Get(TextureID.ToString(), this, AssetReceived); 158 AssetService.Get(TextureID.ToString(), this, AssetReceived);
129 } 159 }
130 } 160 }
@@ -137,6 +167,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
137 { 167 {
138 //Request decode 168 //Request decode
139 m_decodeRequested = true; 169 m_decodeRequested = true;
170
171// m_log.DebugFormat("[J2KIMAGE]: Requesting decode of asset {0}", TextureID);
172
140 // Do we have a jpeg decoder? 173 // Do we have a jpeg decoder?
141 if (J2KDecoder != null) 174 if (J2KDecoder != null)
142 { 175 {
@@ -149,7 +182,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
149 // Send it off to the jpeg decoder 182 // Send it off to the jpeg decoder
150 J2KDecoder.BeginDecode(TextureID, m_asset, J2KDecodedCallback); 183 J2KDecoder.BeginDecode(TextureID, m_asset, J2KDecodedCallback);
151 } 184 }
152
153 } 185 }
154 else 186 else
155 { 187 {
@@ -208,7 +240,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
208 } 240 }
209 } 241 }
210 242
211 private bool SendFirstPacket(LLClientView client) 243 private bool SendFirstPacket(IClientAPI client)
212 { 244 {
213 if (client == null) 245 if (client == null)
214 return false; 246 return false;
@@ -243,7 +275,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
243 return false; 275 return false;
244 } 276 }
245 277
246 private bool SendPacket(LLClientView client) 278 private bool SendPacket(IClientAPI client)
247 { 279 {
248 if (client == null) 280 if (client == null)
249 return false; 281 return false;
@@ -328,14 +360,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
328 { 360 {
329 if (m_currentPacket == 0) 361 if (m_currentPacket == 0)
330 return 0; 362 return 0;
363
331 if (m_currentPacket == 1) 364 if (m_currentPacket == 1)
332 return FIRST_PACKET_SIZE; 365 return FIRST_PACKET_SIZE;
333 366
334 int result = FIRST_PACKET_SIZE + ((int)m_currentPacket - 2) * IMAGE_PACKET_SIZE; 367 int result = FIRST_PACKET_SIZE + ((int)m_currentPacket - 2) * IMAGE_PACKET_SIZE;
368
335 if (result < 0) 369 if (result < 0)
336 {
337 result = FIRST_PACKET_SIZE; 370 result = FIRST_PACKET_SIZE;
338 } 371
339 return result; 372 return result;
340 } 373 }
341 374
@@ -372,9 +405,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
372 405
373 private void AssetReceived(string id, Object sender, AssetBase asset) 406 private void AssetReceived(string id, Object sender, AssetBase asset)
374 { 407 {
408// m_log.DebugFormat(
409// "[J2KIMAGE]: Received asset {0} ({1} bytes)", id, asset != null ? asset.Data.Length.ToString() : "n/a");
410
375 UUID assetID = UUID.Zero; 411 UUID assetID = UUID.Zero;
376 if (asset != null) 412 if (asset != null)
413 {
377 assetID = asset.FullID; 414 assetID = asset.FullID;
415 }
378 else if ((InventoryAccessModule != null) && (sender != InventoryAccessModule)) 416 else if ((InventoryAccessModule != null) && (sender != InventoryAccessModule))
379 { 417 {
380 // Unfortunately we need this here, there's no other way. 418 // Unfortunately we need this here, there's no other way.
@@ -395,7 +433,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
395 } 433 }
396 434
397 AssetDataCallback(assetID, asset); 435 AssetDataCallback(assetID, asset);
398
399 } 436 }
400 } 437 }
401} 438}