aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/Agent/TextureSender
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Agent/TextureSender')
-rw-r--r--OpenSim/Region/Environment/Modules/Agent/TextureSender/TextureSender.cs91
1 files changed, 47 insertions, 44 deletions
diff --git a/OpenSim/Region/Environment/Modules/Agent/TextureSender/TextureSender.cs b/OpenSim/Region/Environment/Modules/Agent/TextureSender/TextureSender.cs
index 37b0652..b6f7095 100644
--- a/OpenSim/Region/Environment/Modules/Agent/TextureSender/TextureSender.cs
+++ b/OpenSim/Region/Environment/Modules/Agent/TextureSender/TextureSender.cs
@@ -40,56 +40,43 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender
40 /// </summary> 40 /// </summary>
41 public class TextureSender : ITextureSender 41 public class TextureSender : ITextureSender
42 { 42 {
43 private static readonly ILog m_log 43 private static readonly ILog m_log
44 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 44 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 45
46 /// <summary> 46 /// <summary>
47 /// Records the number of times texture send has been called. 47 /// Records the number of times texture send has been called.
48 /// </summary> 48 /// </summary>
49 public int counter = 0; 49 public int counter = 0;
50 50
51 public bool ImageLoaded = false;
52
51 /// <summary> 53 /// <summary>
52 /// Holds the texture asset to send. 54 /// Holds the texture asset to send.
53 /// </summary> 55 /// </summary>
54 private AssetBase m_asset; 56 private AssetBase m_asset;
55 57
56 //public LLUUID assetID { get { return m_asset.FullID; } } 58 //public LLUUID assetID { get { return m_asset.FullID; } }
57 59
60 private bool m_cancel = false;
61
62 // See ITextureSender
63
64 private bool m_sending = false;
65
58 /// <summary> 66 /// <summary>
59 /// This is actually the number of extra packets required to send the texture data! We always assume 67 /// This is actually the number of extra packets required to send the texture data! We always assume
60 /// at least one is required. 68 /// at least one is required.
61 /// </summary> 69 /// </summary>
62 private int NumPackets = 0; 70 private int NumPackets = 0;
63 71
64 /// <summary> 72 /// <summary>
65 /// Holds the packet number to send next. In this case, each packet is 1000 bytes long and starts 73 /// Holds the packet number to send next. In this case, each packet is 1000 bytes long and starts
66 /// at the 600th byte (0th indexed). 74 /// at the 600th byte (0th indexed).
67 /// </summary> 75 /// </summary>
68 private int PacketCounter = 0; 76 private int PacketCounter = 0;
69
70 // See ITextureSender
71 public bool Cancel
72 {
73 get { return false; }
74 set { m_cancel = value; }
75 }
76
77 private bool m_cancel = false;
78
79 // See ITextureSender
80 public bool Sending
81 {
82 get { return false; }
83 set { m_sending = value; }
84 }
85
86 private bool m_sending = false;
87
88 public bool ImageLoaded = false;
89
90 private IClientAPI RequestUser;
91 77
92 private int RequestedDiscardLevel = -1; 78 private int RequestedDiscardLevel = -1;
79 private IClientAPI RequestUser;
93 private uint StartPacketNumber = 0; 80 private uint StartPacketNumber = 0;
94 81
95 public TextureSender(IClientAPI client, int discardLevel, uint packetNumber) 82 public TextureSender(IClientAPI client, int discardLevel, uint packetNumber)
@@ -99,18 +86,18 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender
99 StartPacketNumber = packetNumber; 86 StartPacketNumber = packetNumber;
100 } 87 }
101 88
102 /// <summary> 89 #region ITextureSender Members
103 /// Load up the texture data to send. 90
104 /// </summary> 91 public bool Cancel
105 /// <param name="asset">
106 /// A <see cref="AssetBase"/>
107 /// </param>
108 public void TextureReceived(AssetBase asset)
109 { 92 {
110 m_asset = asset; 93 get { return false; }
111 NumPackets = CalculateNumPackets(asset.Data.Length); 94 set { m_cancel = value; }
112 PacketCounter = (int) StartPacketNumber; 95 }
113 ImageLoaded = true; 96
97 public bool Sending
98 {
99 get { return false; }
100 set { m_sending = value; }
114 } 101 }
115 102
116 // See ITextureSender 103 // See ITextureSender
@@ -125,17 +112,33 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender
125 public bool SendTexturePacket() 112 public bool SendTexturePacket()
126 { 113 {
127 //m_log.DebugFormat("[TEXTURE SENDER]: Sending packet for {0}", m_asset.FullID); 114 //m_log.DebugFormat("[TEXTURE SENDER]: Sending packet for {0}", m_asset.FullID);
128 115
129 SendPacket(); 116 SendPacket();
130 counter++; 117 counter++;
131 if ((NumPackets == 0) || (RequestedDiscardLevel == -1) || (PacketCounter > NumPackets) || 118 if ((NumPackets == 0) || (RequestedDiscardLevel == -1) || (PacketCounter > NumPackets) ||
132 ((RequestedDiscardLevel > 0) && (counter > 50 + (NumPackets/(RequestedDiscardLevel + 1))))) 119 ((RequestedDiscardLevel > 0) && (counter > 50 + (NumPackets / (RequestedDiscardLevel + 1)))))
133 { 120 {
134 return true; 121 return true;
135 } 122 }
136 return false; 123 return false;
137 } 124 }
138 125
126 #endregion
127
128 /// <summary>
129 /// Load up the texture data to send.
130 /// </summary>
131 /// <param name="asset">
132 /// A <see cref="AssetBase"/>
133 /// </param>
134 public void TextureReceived(AssetBase asset)
135 {
136 m_asset = asset;
137 NumPackets = CalculateNumPackets(asset.Data.Length);
138 PacketCounter = (int) StartPacketNumber;
139 ImageLoaded = true;
140 }
141
139 /// <summary> 142 /// <summary>
140 /// Sends a texture packet to the client. 143 /// Sends a texture packet to the client.
141 /// </summary> 144 /// </summary>
@@ -177,17 +180,17 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender
177 im.Header.Reliable = false; 180 im.Header.Reliable = false;
178 im.ImageID.Packet = (ushort) (PacketCounter); 181 im.ImageID.Packet = (ushort) (PacketCounter);
179 im.ImageID.ID = m_asset.FullID; 182 im.ImageID.ID = m_asset.FullID;
180 int size = m_asset.Data.Length - 600 - (1000*(PacketCounter - 1)); 183 int size = m_asset.Data.Length - 600 - (1000 * (PacketCounter - 1));
181 if (size > 1000) size = 1000; 184 if (size > 1000) size = 1000;
182 im.ImageData.Data = new byte[size]; 185 im.ImageData.Data = new byte[size];
183 try 186 try
184 { 187 {
185 Array.Copy(m_asset.Data, 600 + (1000*(PacketCounter - 1)), im.ImageData.Data, 0, size); 188 Array.Copy(m_asset.Data, 600 + (1000 * (PacketCounter - 1)), im.ImageData.Data, 0, size);
186 } 189 }
187 catch (ArgumentOutOfRangeException) 190 catch (ArgumentOutOfRangeException)
188 { 191 {
189 m_log.Error("[TEXTURE SENDER]: Unable to separate texture into multiple packets: Array bounds failure on asset:" + 192 m_log.Error("[TEXTURE SENDER]: Unable to separate texture into multiple packets: Array bounds failure on asset:" +
190 m_asset.FullID.ToString() ); 193 m_asset.FullID.ToString());
191 return; 194 return;
192 } 195 }
193 RequestUser.OutPacket(im, ThrottleOutPacketType.Texture); 196 RequestUser.OutPacket(im, ThrottleOutPacketType.Texture);
@@ -210,7 +213,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender
210 { 213 {
211 //over 600 bytes so split up file 214 //over 600 bytes so split up file
212 int restData = (length - 600); 215 int restData = (length - 600);
213 int restPackets = ((restData + 999)/1000); 216 int restPackets = ((restData + 999) / 1000);
214 numPackets = restPackets; 217 numPackets = restPackets;
215 } 218 }
216 219