Ejemplo n.º 1
0
        /// <summary>
        /// Handles an incoming texture request or update to an existing texture request
        /// </summary>
        /// <param name="newRequest"></param>
        public void EnqueueReq(TextureRequestArgs newRequest)
        {
            //Make sure we're not shutting down..
            if (!m_shuttingdown)
            {
                J2KImage imgrequest;

                // Do a linear search for this texture download
                lock (m_syncRoot)
                    m_priorityQueue.Find(delegate(J2KImage img) { return(img.TextureID == newRequest.RequestedAssetID); }, out imgrequest);

                if (imgrequest != null)
                {
                    if (newRequest.DiscardLevel == -1 && newRequest.Priority == 0f)
                    {
                        //m_log.Debug("[TEX]: (CAN) ID=" + newRequest.RequestedAssetID);

                        try
                        {
                            lock (m_syncRoot)
                                m_priorityQueue.Delete(imgrequest.PriorityQueueHandle);
                        }
                        catch (Exception) { }
                    }
                    else
                    {
                        //m_log.DebugFormat("[TEX]: (UPD) ID={0}: D={1}, S={2}, P={3}",
                        //    newRequest.RequestedAssetID, newRequest.DiscardLevel, newRequest.PacketNumber, newRequest.Priority);

                        //Check the packet sequence to make sure this isn't older than
                        //one we've already received
                        if (newRequest.requestSequence > imgrequest.LastSequence)
                        {
                            //Update the sequence number of the last RequestImage packet
                            imgrequest.LastSequence = newRequest.requestSequence;

                            //Update the requested discard level
                            imgrequest.DiscardLevel = newRequest.DiscardLevel;

                            //Update the requested packet number
                            imgrequest.StartPacket = Math.Max(1, newRequest.PacketNumber);

                            //Update the requested priority
                            imgrequest.Priority = newRequest.Priority;
                            UpdateImageInQueue(imgrequest);

                            //Run an update
                            imgrequest.RunUpdate();
                        }
                    }
                }
                else
                {
                    if (newRequest.DiscardLevel == -1 && newRequest.Priority == 0f)
                    {
                        //m_log.DebugFormat("[TEX]: (IGN) ID={0}: D={1}, S={2}, P={3}",
                        //    newRequest.RequestedAssetID, newRequest.DiscardLevel, newRequest.PacketNumber, newRequest.Priority);
                    }
                    else
                    {
                        //m_log.DebugFormat("[TEX]: (NEW) ID={0}: D={1}, S={2}, P={3}",
                        //    newRequest.RequestedAssetID, newRequest.DiscardLevel, newRequest.PacketNumber, newRequest.Priority);

                        imgrequest                       = new J2KImage(this);
                        imgrequest.J2KDecoder            = m_j2kDecodeModule;
                        imgrequest.AssetService          = m_assetCache;
                        imgrequest.AgentID               = m_client.AgentId;
                        imgrequest.InventoryAccessModule = m_client.Scene.RequestModuleInterface <IInventoryAccessModule>();
                        imgrequest.DiscardLevel          = newRequest.DiscardLevel;
                        imgrequest.StartPacket           = Math.Max(1, newRequest.PacketNumber);
                        imgrequest.Priority              = newRequest.Priority;
                        imgrequest.TextureID             = newRequest.RequestedAssetID;
                        imgrequest.Priority              = newRequest.Priority;

                        //Add this download to the priority queue
                        AddImageToQueue(imgrequest);

                        //Run an update
                        imgrequest.RunUpdate();
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void EnqueueReq(TextureRequestArgs newRequest)
        {
            //newRequest is the properties of our new texture fetch request.
            //Basically, here is where we queue up "new" requests..
            // .. or modify existing requests to suit.

            //Make sure we're not shutting down..
            if (!m_shuttingdown)
            {

                //Do we already know about this UUID?
                if (m_imagestore.ContainsKey(newRequest.RequestedAssetID))
                {
                    //Check the packet sequence to make sure this isn't older than 
                    //one we've already received

                    J2KImage imgrequest = m_imagestore[newRequest.RequestedAssetID];

                    // This is the inbound request sequence number. We can ignore
                    // "old" ones.

                    if (newRequest.requestSequence > imgrequest.m_lastSequence)
                    {

                        imgrequest.m_lastSequence = newRequest.requestSequence;

                        //Check the priority

                        double priority = imgrequest.m_requestedPriority;
                        if (priority != newRequest.Priority)
                        {
                            //Remove the old priority
                            m_priorities.Remove(imgrequest.m_designatedPriorityKey);
                            //Assign a new unique priority
                            imgrequest.m_requestedPriority = newRequest.Priority;
                            imgrequest.m_designatedPriorityKey = AssignPriority(newRequest.RequestedAssetID, newRequest.Priority);
                        }

                        //Update the requested discard level
                        imgrequest.m_requestedDiscardLevel = newRequest.DiscardLevel;

                        //Update the requested packet number
                        imgrequest.m_requestedPacketNumber = newRequest.PacketNumber;

                        //Check if this will create an outstanding texture request
                        bool activated = imgrequest.m_completedSendAtCurrentDiscardLevel;
                        //Run an update

                        imgrequest.RunUpdate();

                        if (activated && !imgrequest.m_completedSendAtCurrentDiscardLevel && imgrequest.m_decoded)
                        {
                            Interlocked.Increment(ref m_outstandingtextures);
                        }
                    }
                }
                else
                {
                    J2KImage imgrequest = new J2KImage(this);

                    //Assign our missing substitute
                    imgrequest.m_MissingSubstitute = m_missingsubstitute;

                    //Assign our decoder module
                    imgrequest.m_j2kDecodeModule = m_j2kDecodeModule;

                    //Assign our asset cache module
                    imgrequest.m_assetCache = m_assetCache;

                    //Assign a priority based on our request
                    imgrequest.m_designatedPriorityKey = AssignPriority(newRequest.RequestedAssetID, newRequest.Priority);

                    //Assign the requested discard level
                    imgrequest.m_requestedDiscardLevel = newRequest.DiscardLevel;

                    //Assign the requested packet number
                    imgrequest.m_requestedPacketNumber = newRequest.PacketNumber;

                    //Assign the requested priority
                    imgrequest.m_requestedPriority = newRequest.Priority;

                    //Assign the asset uuid
                    imgrequest.m_requestedUUID = newRequest.RequestedAssetID;

                    m_imagestore.Add(imgrequest.m_requestedUUID, imgrequest);

                    //Run an update
                    imgrequest.RunUpdate();

                }
            }
        }
Ejemplo n.º 3
0
        public void EnqueueReq(TextureRequestArgs newRequest)
        {
            //newRequest is the properties of our new texture fetch request.
            //Basically, here is where we queue up "new" requests..
            // .. or modify existing requests to suit.

            //Make sure we're not shutting down..
            if (!m_shuttingdown)
            {
                //Do we already know about this UUID?
                if (m_imagestore.ContainsKey(newRequest.RequestedAssetID))
                {
                    //Check the packet sequence to make sure this isn't older than
                    //one we've already received

                    J2KImage imgrequest = m_imagestore[newRequest.RequestedAssetID];

                    if (newRequest.requestSequence > imgrequest.m_lastSequence)
                    {
                        imgrequest.m_lastSequence = newRequest.requestSequence;

                        //First of all, is this being killed?
                        //if (newRequest.Priority == 0.0f && newRequest.DiscardLevel == -1)
                        //{
                        //Do nothing (leaving the if for future use)
                        //}
                        //else
                        //{


                        //Check the priority
                        double priority = imgrequest.m_requestedPriority;
                        if (priority != newRequest.Priority)
                        {
                            //Remove the old priority
                            m_priorities.Remove(imgrequest.m_designatedPriorityKey);
                            //Assign a new unique priority
                            imgrequest.m_requestedPriority     = newRequest.Priority;
                            imgrequest.m_designatedPriorityKey = AssignPriority(newRequest.RequestedAssetID, newRequest.Priority);
                        }

                        //Update the requested discard level
                        imgrequest.m_requestedDiscardLevel = newRequest.DiscardLevel;

                        //Update the requested packet number
                        imgrequest.m_requestedPacketNumber = newRequest.PacketNumber;

                        //Check if this will create an outstanding texture request
                        bool activated = imgrequest.m_completedSendAtCurrentDiscardLevel;
                        //Run an update
                        imgrequest.RunUpdate();
                        if (activated && !imgrequest.m_completedSendAtCurrentDiscardLevel && imgrequest.m_decoded)
                        {
                            m_outstandingtextures++;
                        }

                        //}
                    }
                }
                else
                {
                    J2KImage imgrequest = new J2KImage(this);

                    //Assign our missing substitute
                    imgrequest.m_MissingSubstitute = m_missingsubstitute;

                    //Assign our decoder module
                    imgrequest.m_j2kDecodeModule = m_j2kDecodeModule;

                    //Assign our asset cache module
                    imgrequest.m_assetCache = m_assetCache;

                    //Assign a priority based on our request
                    imgrequest.m_designatedPriorityKey = AssignPriority(newRequest.RequestedAssetID, newRequest.Priority);

                    //Assign the requested discard level
                    imgrequest.m_requestedDiscardLevel = newRequest.DiscardLevel;

                    //Assign the requested packet number
                    imgrequest.m_requestedPacketNumber = newRequest.PacketNumber;

                    //Assign the requested priority
                    imgrequest.m_requestedPriority = newRequest.Priority;

                    //Assign the asset uuid
                    imgrequest.m_requestedUUID = newRequest.RequestedAssetID;

                    m_imagestore.Add(imgrequest.m_requestedUUID, imgrequest);

                    //Run an update
                    imgrequest.RunUpdate();
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Handles an incoming texture request or update to an existing texture request
        /// </summary>
        /// <param name="newRequest"></param>
        public void EnqueueReq(TextureRequestArgs newRequest)
        {
            if (!m_shuttingdown)
            {
                J2KImage imgrequest;

                // Do a linear search for this texture download
                lock (m_syncRoot)
                    m_priorityQueue.Find(delegate(J2KImage img) { return(img.TextureID == newRequest.RequestedAssetID); }, out imgrequest);

                if (imgrequest != null)
                {
                    if (newRequest.DiscardLevel < 0)
                    {
                        //m_log.Debug("[TEX]: (CAN) ID=" + newRequest.RequestedAssetID);

                        try
                        {
                            lock (m_syncRoot)
                                m_priorityQueue.Delete(imgrequest.PriorityQueueHandle);
                        }
                        catch (Exception) { }
                    }
                    else
                    {
//                        m_log.DebugFormat(
//                            "[LL IMAGE MANAGER]: Received duplicate of existing request for {0}, start packet {1} from {2}",
//                            newRequest.RequestedAssetID, newRequest.PacketNumber, m_client.Name);

//                        m_log.DebugFormat("[TEX]: (UPD) ID={0}: D={1}, S={2}, P={3}",
//                            newRequest.RequestedAssetID, newRequest.DiscardLevel, newRequest.PacketNumber, newRequest.Priority);

                        //Check the packet sequence to make sure this isn't older than
                        //one we've already received
                        if (newRequest.requestSequence > imgrequest.LastSequence)
                        {
                            //Update the sequence number of the last RequestImage packet
                            imgrequest.LastSequence = newRequest.requestSequence;

                            //Update the requested discard level
                            imgrequest.DiscardLevel = newRequest.DiscardLevel;

                            //Update the requested packet number
                            imgrequest.StartPacket = Math.Max(1, newRequest.PacketNumber);

                            //Update the requested priority
                            imgrequest.Priority = newRequest.Priority;

                            UpdateImageInQueue(imgrequest);

                            imgrequest.RunUpdate();

//                        J2KImage imgrequest2 = new J2KImage(this);
//                        imgrequest2.J2KDecoder = m_j2kDecodeModule;
//                        imgrequest2.AssetService = m_assetCache;
//                        imgrequest2.AgentID = m_client.AgentId;
//                        imgrequest2.InventoryAccessModule = m_client.Scene.RequestModuleInterface<IInventoryAccessModule>();
//                        imgrequest2.DiscardLevel = newRequest.DiscardLevel;
//                        imgrequest2.StartPacket = Math.Max(1, newRequest.PacketNumber);
//                        imgrequest2.Priority = newRequest.Priority;
//                        imgrequest2.TextureID = newRequest.RequestedAssetID;
//                        imgrequest2.Priority = newRequest.Priority;
//
//                        //Add this download to the priority queue
//                        AddImageToQueue(imgrequest2);
//
//                        imgrequest2.RunUpdate();
                        }
//                        else
//                        {
//                            m_log.DebugFormat(
//                                "[LL IMAGE MANAGER]: Ignoring duplicate of existing request for {0} (sequence {1}) from {2} as its request sequence {3} is not greater",
//                                newRequest.RequestedAssetID, imgrequest.LastSequence, m_client.Name, newRequest.requestSequence);
//                        }
                    }
                }
                else
                {
                    if (newRequest.DiscardLevel < 0)
                    {
                        //m_log.DebugFormat("[TEX]: (IGN) ID={0}: D={1}, S={2}, P={3}",
                        //    newRequest.RequestedAssetID, newRequest.DiscardLevel, newRequest.PacketNumber, newRequest.Priority);
                    }
                    else
                    {
//                        m_log.DebugFormat(
//                            "[LL IMAGE MANAGER]: Received request for {0}, start packet {1} from {2}",
//                            newRequest.RequestedAssetID, newRequest.PacketNumber, m_client.Name);

                        //m_log.DebugFormat("[TEX]: (NEW) ID={0}: D={1}, S={2}, P={3}",
                        //    newRequest.RequestedAssetID, newRequest.DiscardLevel, newRequest.PacketNumber, newRequest.Priority);

                        imgrequest                       = new J2KImage(this);
                        imgrequest.J2KDecoder            = m_j2kDecodeModule;
                        imgrequest.AssetService          = m_assetCache;
                        imgrequest.AgentID               = Client.AgentId;
                        imgrequest.InventoryAccessModule = Client.Scene.RequestModuleInterface <IInventoryAccessModule>();
                        imgrequest.DiscardLevel          = newRequest.DiscardLevel;
                        imgrequest.StartPacket           = Math.Max(1, newRequest.PacketNumber);
                        imgrequest.Priority              = newRequest.Priority;
                        imgrequest.TextureID             = newRequest.RequestedAssetID;
                        imgrequest.Priority              = newRequest.Priority;

                        //Add this download to the priority queue
                        AddImageToQueue(imgrequest);

                        imgrequest.RunUpdate();
                    }
                }
            }
        }