Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
commit
590f707c42
|
@ -45,6 +45,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
private const int IMAGE_PACKET_SIZE = 1000;
|
private const int IMAGE_PACKET_SIZE = 1000;
|
||||||
private const int FIRST_PACKET_SIZE = 600;
|
private const int FIRST_PACKET_SIZE = 600;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// If we've requested an asset but not received it in this ticks timeframe, then allow a duplicate
|
||||||
|
/// request from the client to trigger a fresh asset request.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// There are 10,000 ticks in a millisecond
|
||||||
|
/// </remarks>
|
||||||
|
private const int ASSET_REQUEST_TIMEOUT = 100000000;
|
||||||
|
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
public uint LastSequence;
|
public uint LastSequence;
|
||||||
|
@ -57,8 +66,22 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
public UUID AgentID;
|
public UUID AgentID;
|
||||||
public IInventoryAccessModule InventoryAccessModule;
|
public IInventoryAccessModule InventoryAccessModule;
|
||||||
private OpenJPEG.J2KLayerInfo[] m_layers;
|
private OpenJPEG.J2KLayerInfo[] m_layers;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Has this request decoded the asset data?
|
||||||
|
/// </summary>
|
||||||
public bool IsDecoded { get; private set; }
|
public bool IsDecoded { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Has this request received the required asset data?
|
||||||
|
/// </summary>
|
||||||
public bool HasAsset { get; private set; }
|
public bool HasAsset { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Time in milliseconds at which the asset was requested.
|
||||||
|
/// </summary>
|
||||||
|
public long AssetRequestTime { get; private set; }
|
||||||
|
|
||||||
public C5.IPriorityQueueHandle<J2KImage> PriorityQueueHandle;
|
public C5.IPriorityQueueHandle<J2KImage> PriorityQueueHandle;
|
||||||
|
|
||||||
private uint m_currentPacket;
|
private uint m_currentPacket;
|
||||||
|
@ -123,10 +146,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
{
|
{
|
||||||
if (!HasAsset)
|
if (!HasAsset)
|
||||||
{
|
{
|
||||||
if (!m_assetRequested)
|
if (!m_assetRequested || DateTime.UtcNow.Ticks > AssetRequestTime + ASSET_REQUEST_TIMEOUT)
|
||||||
{
|
{
|
||||||
|
// m_log.DebugFormat(
|
||||||
|
// "[J2KIMAGE]: Requesting asset {0} from request in packet {1}, already requested? {2}, due to timeout? {3}",
|
||||||
|
// TextureID, LastSequence, m_assetRequested, DateTime.UtcNow.Ticks > AssetRequestTime + ASSET_REQUEST_TIMEOUT);
|
||||||
|
|
||||||
m_assetRequested = true;
|
m_assetRequested = true;
|
||||||
// m_log.DebugFormat("[J2KIMAGE]: Requesting asset {0}", TextureID);
|
AssetRequestTime = DateTime.UtcNow.Ticks;
|
||||||
|
|
||||||
AssetService.Get(TextureID.ToString(), this, AssetReceived);
|
AssetService.Get(TextureID.ToString(), this, AssetReceived);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -377,6 +405,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
|
|
||||||
private void AssetReceived(string id, Object sender, AssetBase asset)
|
private void AssetReceived(string id, Object sender, AssetBase asset)
|
||||||
{
|
{
|
||||||
|
// m_log.DebugFormat(
|
||||||
|
// "[J2KIMAGE]: Received asset {0} ({1} bytes)", id, asset != null ? asset.Data.Length.ToString() : "n/a");
|
||||||
|
|
||||||
UUID assetID = UUID.Zero;
|
UUID assetID = UUID.Zero;
|
||||||
if (asset != null)
|
if (asset != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -55,18 +55,29 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
private bool m_shuttingdown;
|
private bool m_shuttingdown;
|
||||||
private AssetBase m_missingImage;
|
private AssetBase m_missingImage;
|
||||||
private IClientAPI m_client; //Client we're assigned to
|
private IAssetService m_assetCache;
|
||||||
private IAssetService m_assetCache; //Asset Cache
|
private IJ2KDecoder m_j2kDecodeModule;
|
||||||
private IJ2KDecoder m_j2kDecodeModule; //Our J2K module
|
|
||||||
|
/// <summary>
|
||||||
|
/// Priority queue for determining which image to send first.
|
||||||
|
/// </summary>
|
||||||
private C5.IntervalHeap<J2KImage> m_priorityQueue = new C5.IntervalHeap<J2KImage>(10, new J2KImageComparer());
|
private C5.IntervalHeap<J2KImage> m_priorityQueue = new C5.IntervalHeap<J2KImage>(10, new J2KImageComparer());
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Used to control thread access to the priority queue.
|
||||||
|
/// </summary>
|
||||||
private object m_syncRoot = new object();
|
private object m_syncRoot = new object();
|
||||||
|
|
||||||
public IClientAPI Client { get { return m_client; } }
|
/// <summary>
|
||||||
|
/// Client served by this image manager
|
||||||
|
/// </summary>
|
||||||
|
public IClientAPI Client { get; private set; }
|
||||||
|
|
||||||
public AssetBase MissingImage { get { return m_missingImage; } }
|
public AssetBase MissingImage { get { return m_missingImage; } }
|
||||||
|
|
||||||
public LLImageManager(IClientAPI client, IAssetService pAssetCache, IJ2KDecoder pJ2kDecodeModule)
|
public LLImageManager(IClientAPI client, IAssetService pAssetCache, IJ2KDecoder pJ2kDecodeModule)
|
||||||
{
|
{
|
||||||
m_client = client;
|
Client = client;
|
||||||
m_assetCache = pAssetCache;
|
m_assetCache = pAssetCache;
|
||||||
|
|
||||||
if (pAssetCache != null)
|
if (pAssetCache != null)
|
||||||
|
@ -111,8 +122,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
// "[LL IMAGE MANAGER]: Received duplicate of existing request for {0}, start packet {1} from {2}",
|
// "[LL IMAGE MANAGER]: Received duplicate of existing request for {0}, start packet {1} from {2}",
|
||||||
// newRequest.RequestedAssetID, newRequest.PacketNumber, m_client.Name);
|
// newRequest.RequestedAssetID, newRequest.PacketNumber, m_client.Name);
|
||||||
|
|
||||||
//m_log.DebugFormat("[TEX]: (UPD) ID={0}: D={1}, S={2}, P={3}",
|
// m_log.DebugFormat("[TEX]: (UPD) ID={0}: D={1}, S={2}, P={3}",
|
||||||
// newRequest.RequestedAssetID, newRequest.DiscardLevel, newRequest.PacketNumber, newRequest.Priority);
|
// newRequest.RequestedAssetID, newRequest.DiscardLevel, newRequest.PacketNumber, newRequest.Priority);
|
||||||
|
|
||||||
//Check the packet sequence to make sure this isn't older than
|
//Check the packet sequence to make sure this isn't older than
|
||||||
//one we've already received
|
//one we've already received
|
||||||
|
@ -178,8 +189,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
imgrequest = new J2KImage(this);
|
imgrequest = new J2KImage(this);
|
||||||
imgrequest.J2KDecoder = m_j2kDecodeModule;
|
imgrequest.J2KDecoder = m_j2kDecodeModule;
|
||||||
imgrequest.AssetService = m_assetCache;
|
imgrequest.AssetService = m_assetCache;
|
||||||
imgrequest.AgentID = m_client.AgentId;
|
imgrequest.AgentID = Client.AgentId;
|
||||||
imgrequest.InventoryAccessModule = m_client.Scene.RequestModuleInterface<IInventoryAccessModule>();
|
imgrequest.InventoryAccessModule = Client.Scene.RequestModuleInterface<IInventoryAccessModule>();
|
||||||
imgrequest.DiscardLevel = newRequest.DiscardLevel;
|
imgrequest.DiscardLevel = newRequest.DiscardLevel;
|
||||||
imgrequest.StartPacket = Math.Max(1, newRequest.PacketNumber);
|
imgrequest.StartPacket = Math.Max(1, newRequest.PacketNumber);
|
||||||
imgrequest.Priority = newRequest.Priority;
|
imgrequest.Priority = newRequest.Priority;
|
||||||
|
@ -210,7 +221,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
if (image.IsDecoded)
|
if (image.IsDecoded)
|
||||||
{
|
{
|
||||||
int sent;
|
int sent;
|
||||||
bool imageDone = image.SendPackets(m_client, packetsToSend - packetsSent, out sent);
|
bool imageDone = image.SendPackets(Client, packetsToSend - packetsSent, out sent);
|
||||||
packetsSent += sent;
|
packetsSent += sent;
|
||||||
|
|
||||||
// If the send is complete, destroy any knowledge of this transfer
|
// If the send is complete, destroy any knowledge of this transfer
|
||||||
|
|
|
@ -45,24 +45,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class LLImageManagerTests
|
public class LLImageManagerTests
|
||||||
{
|
{
|
||||||
[Test]
|
private AssetBase m_testImageAsset;
|
||||||
public void TestRequestAndSendImage()
|
private Scene scene;
|
||||||
|
private LLImageManager llim;
|
||||||
|
private TestClient tc;
|
||||||
|
|
||||||
|
[TestFixtureSetUp]
|
||||||
|
public void FixtureInit()
|
||||||
{
|
{
|
||||||
TestHelpers.InMethod();
|
|
||||||
// XmlConfigurator.Configure();
|
|
||||||
|
|
||||||
UUID imageId = TestHelpers.ParseTail(0x1);
|
|
||||||
string creatorId = TestHelpers.ParseTail(0x2).ToString();
|
|
||||||
UUID userId = TestHelpers.ParseTail(0x3);
|
|
||||||
|
|
||||||
J2KDecoderModule j2kdm = new J2KDecoderModule();
|
|
||||||
|
|
||||||
Scene scene = SceneHelpers.SetupScene();
|
|
||||||
SceneHelpers.SetupSceneModules(scene, j2kdm);
|
|
||||||
|
|
||||||
TestClient tc = new TestClient(SceneHelpers.GenerateAgentData(userId), scene);
|
|
||||||
LLImageManager llim = new LLImageManager(tc, scene.AssetService, j2kdm);
|
|
||||||
|
|
||||||
using (
|
using (
|
||||||
Stream resource
|
Stream resource
|
||||||
= GetType().Assembly.GetManifestResourceStream(
|
= GetType().Assembly.GetManifestResourceStream(
|
||||||
|
@ -70,14 +60,42 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
|
||||||
{
|
{
|
||||||
using (BinaryReader br = new BinaryReader(resource))
|
using (BinaryReader br = new BinaryReader(resource))
|
||||||
{
|
{
|
||||||
AssetBase asset = new AssetBase(imageId, "Test Image", (sbyte)AssetType.Texture, creatorId);
|
m_testImageAsset
|
||||||
asset.Data = br.ReadBytes(99999999);
|
= new AssetBase(
|
||||||
scene.AssetService.Store(asset);
|
TestHelpers.ParseTail(0x1),
|
||||||
|
"Test Image",
|
||||||
|
(sbyte)AssetType.Texture,
|
||||||
|
TestHelpers.ParseTail(0x2).ToString());
|
||||||
|
|
||||||
|
m_testImageAsset.Data = br.ReadBytes(99999999);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[SetUp]
|
||||||
|
public void SetUp()
|
||||||
|
{
|
||||||
|
UUID userId = TestHelpers.ParseTail(0x3);
|
||||||
|
|
||||||
|
J2KDecoderModule j2kdm = new J2KDecoderModule();
|
||||||
|
|
||||||
|
scene = SceneHelpers.SetupScene();
|
||||||
|
SceneHelpers.SetupSceneModules(scene, j2kdm);
|
||||||
|
|
||||||
|
tc = new TestClient(SceneHelpers.GenerateAgentData(userId), scene);
|
||||||
|
llim = new LLImageManager(tc, scene.AssetService, j2kdm);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestSendImage()
|
||||||
|
{
|
||||||
|
TestHelpers.InMethod();
|
||||||
|
// XmlConfigurator.Configure();
|
||||||
|
|
||||||
|
scene.AssetService.Store(m_testImageAsset);
|
||||||
|
|
||||||
TextureRequestArgs args = new TextureRequestArgs();
|
TextureRequestArgs args = new TextureRequestArgs();
|
||||||
args.RequestedAssetID = TestHelpers.ParseTail(0x1);
|
args.RequestedAssetID = m_testImageAsset.FullID;
|
||||||
args.DiscardLevel = 0;
|
args.DiscardLevel = 0;
|
||||||
args.PacketNumber = 1;
|
args.PacketNumber = 1;
|
||||||
args.Priority = 5;
|
args.Priority = 5;
|
||||||
|
@ -88,5 +106,55 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
|
||||||
|
|
||||||
Assert.That(tc.SentImageDataPackets.Count, Is.EqualTo(1));
|
Assert.That(tc.SentImageDataPackets.Count, Is.EqualTo(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestDiscardImage()
|
||||||
|
{
|
||||||
|
TestHelpers.InMethod();
|
||||||
|
// XmlConfigurator.Configure();
|
||||||
|
|
||||||
|
scene.AssetService.Store(m_testImageAsset);
|
||||||
|
|
||||||
|
TextureRequestArgs args = new TextureRequestArgs();
|
||||||
|
args.RequestedAssetID = m_testImageAsset.FullID;
|
||||||
|
args.DiscardLevel = 0;
|
||||||
|
args.PacketNumber = 1;
|
||||||
|
args.Priority = 5;
|
||||||
|
args.requestSequence = 1;
|
||||||
|
llim.EnqueueReq(args);
|
||||||
|
|
||||||
|
// Now create a discard request
|
||||||
|
TextureRequestArgs discardArgs = new TextureRequestArgs();
|
||||||
|
discardArgs.RequestedAssetID = m_testImageAsset.FullID;
|
||||||
|
discardArgs.DiscardLevel = -1;
|
||||||
|
discardArgs.PacketNumber = 1;
|
||||||
|
discardArgs.Priority = 0;
|
||||||
|
discardArgs.requestSequence = 2;
|
||||||
|
llim.EnqueueReq(discardArgs);
|
||||||
|
|
||||||
|
llim.ProcessImageQueue(20);
|
||||||
|
|
||||||
|
Assert.That(tc.SentImageDataPackets.Count, Is.EqualTo(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestMissingImage()
|
||||||
|
{
|
||||||
|
TestHelpers.InMethod();
|
||||||
|
// XmlConfigurator.Configure();
|
||||||
|
|
||||||
|
TextureRequestArgs args = new TextureRequestArgs();
|
||||||
|
args.RequestedAssetID = m_testImageAsset.FullID;
|
||||||
|
args.DiscardLevel = 0;
|
||||||
|
args.PacketNumber = 1;
|
||||||
|
args.Priority = 5;
|
||||||
|
args.requestSequence = 1;
|
||||||
|
|
||||||
|
llim.EnqueueReq(args);
|
||||||
|
llim.ProcessImageQueue(20);
|
||||||
|
|
||||||
|
Assert.That(tc.SentImageDataPackets.Count, Is.EqualTo(0));
|
||||||
|
Assert.That(tc.SentImageNotInDatabasePackets.Count, Is.EqualTo(1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -60,6 +60,7 @@ namespace OpenSim.Tests.Common.Mock
|
||||||
|
|
||||||
public List<ImageDataPacket> SentImageDataPackets { get; private set; }
|
public List<ImageDataPacket> SentImageDataPackets { get; private set; }
|
||||||
public List<ImagePacketPacket> SentImagePacketPackets { get; private set; }
|
public List<ImagePacketPacket> SentImagePacketPackets { get; private set; }
|
||||||
|
public List<ImageNotInDatabasePacket> SentImageNotInDatabasePackets { get; private set; }
|
||||||
|
|
||||||
// disable warning: public events, part of the public API
|
// disable warning: public events, part of the public API
|
||||||
#pragma warning disable 67
|
#pragma warning disable 67
|
||||||
|
@ -456,6 +457,7 @@ namespace OpenSim.Tests.Common.Mock
|
||||||
|
|
||||||
SentImageDataPackets = new List<ImageDataPacket>();
|
SentImageDataPackets = new List<ImageDataPacket>();
|
||||||
SentImagePacketPackets = new List<ImagePacketPacket>();
|
SentImagePacketPackets = new List<ImagePacketPacket>();
|
||||||
|
SentImageNotInDatabasePackets = new List<ImageNotInDatabasePacket>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -823,6 +825,10 @@ namespace OpenSim.Tests.Common.Mock
|
||||||
|
|
||||||
public void SendImageNotFound(UUID imageid)
|
public void SendImageNotFound(UUID imageid)
|
||||||
{
|
{
|
||||||
|
ImageNotInDatabasePacket p = new ImageNotInDatabasePacket();
|
||||||
|
p.ImageID.ID = imageid;
|
||||||
|
|
||||||
|
SentImageNotInDatabasePackets.Add(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SendShutdownConnectionNotice()
|
public void SendShutdownConnectionNotice()
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
bin/libode.dylib
BIN
bin/libode.dylib
Binary file not shown.
BIN
bin/libode.so
BIN
bin/libode.so
Binary file not shown.
BIN
bin/ode.dll
BIN
bin/ode.dll
Binary file not shown.
Loading…
Reference in New Issue