Ejemplo n.º 1
0
        private void FileInfoLoadCallback(object callbackData)
        {
            try
            {
                // Try to deserialize and load the file info, storing a reference to it in
                // the manager. Then trigger the file info finished loading event
                FileInfoOpen = fileLoader.DeserializeAndLoadFileInfo((string)callbackData);
            }
            catch (ArgumentOutOfRangeException e)
            {
                // An exception will indicate that the file is smaller than the minimum size
                throw new ArgumentOutOfRangeException(e.Message);
            }

            // Trigger this event
            FileInfoFinishedLoad.Invoke(this, new EventArgs());
        }
Ejemplo n.º 2
0
        private void InitialisePlayback(KinectFramesStore firstChunk, FileSystem.FileInfo fileInfo)
        {
            // Store the first chunk and ensure that the frame iterator is at the first position
            currentChunk = firstChunk;
            currentChunk.Reset();

            // Initialise an empty downsampled mesh as a 2D plane with the correct height and width
            // attributes that match the recording images
            InitialiseMeshData(fileInfo.MeshWidth, fileInfo.MeshHeight);

            // Align the centre of the mesh to its parent container origin, which by default is world
            // space
            AlignMeshToWorldOrigin(fileInfo.MeshWidth, fileInfo.MeshHeight, fileInfo.DepthScale,
                                   fileInfo.MinReliableDistance, fileInfo.MaxReliableDistance);

            // Load in the first frame to the mesh by moving the iterator up and then reading
            // the current frame value
            currentChunk.MoveNext();
            RefreshMeshData(fileInfo.MeshWidth, fileInfo.MeshHeight, currentChunk.Current);

            // Finally, initialise the timer between frames
            frameTimeDelta = 0.0f;
        }
            private bool VerifyResource(VerifyInfo verifyInfo)
            {
                if (verifyInfo.UseFileSystem)
                {
                    IFileSystem         fileSystem = m_ResourceManager.GetFileSystem(verifyInfo.FileSystemName, false);
                    string              fileName   = verifyInfo.ResourceName.FullName;
                    FileSystem.FileInfo fileInfo   = fileSystem.GetFileInfo(fileName);
                    if (!fileInfo.IsValid)
                    {
                        return(false);
                    }

                    int length = fileInfo.Length;
                    if (length == verifyInfo.Length)
                    {
                        m_ResourceManager.PrepareCachedStream();
                        fileSystem.ReadFile(fileName, m_ResourceManager.m_CachedStream);
                        m_ResourceManager.m_CachedStream.Position = 0L;
                        int hashCode = 0;
                        if (verifyInfo.LoadType == LoadType.LoadFromMemoryAndQuickDecrypt || verifyInfo.LoadType == LoadType.LoadFromMemoryAndDecrypt ||
                            verifyInfo.LoadType == LoadType.LoadFromBinaryAndQuickDecrypt || verifyInfo.LoadType == LoadType.LoadFromBinaryAndDecrypt)
                        {
                            Utility.Converter.GetBytes(verifyInfo.HashCode, m_CachedHashBytes);
                            if (verifyInfo.LoadType == LoadType.LoadFromMemoryAndQuickDecrypt || verifyInfo.LoadType == LoadType.LoadFromBinaryAndQuickDecrypt)
                            {
                                hashCode = Utility.Verifier.GetCrc32(m_ResourceManager.m_CachedStream, m_CachedHashBytes, Utility.Encryption.QuickEncryptLength);
                            }
                            else if (verifyInfo.LoadType == LoadType.LoadFromMemoryAndDecrypt || verifyInfo.LoadType == LoadType.LoadFromBinaryAndDecrypt)
                            {
                                hashCode = Utility.Verifier.GetCrc32(m_ResourceManager.m_CachedStream, m_CachedHashBytes, length);
                            }

                            Array.Clear(m_CachedHashBytes, 0, CachedHashBytesLength);
                        }
                        else
                        {
                            hashCode = Utility.Verifier.GetCrc32(m_ResourceManager.m_CachedStream);
                        }

                        if (hashCode == verifyInfo.HashCode)
                        {
                            return(true);
                        }
                    }

                    fileSystem.DeleteFile(fileName);
                    return(false);
                }
                else
                {
                    string resourcePath = Utility.Path.GetRegularPath(Path.Combine(m_ResourceManager.ReadWritePath, verifyInfo.ResourceName.FullName));
                    if (!File.Exists(resourcePath))
                    {
                        return(false);
                    }

                    using (FileStream fileStream = new FileStream(resourcePath, FileMode.Open, FileAccess.Read))
                    {
                        int length = (int)fileStream.Length;
                        if (length == verifyInfo.Length)
                        {
                            int hashCode = 0;
                            if (verifyInfo.LoadType == LoadType.LoadFromMemoryAndQuickDecrypt || verifyInfo.LoadType == LoadType.LoadFromMemoryAndDecrypt ||
                                verifyInfo.LoadType == LoadType.LoadFromBinaryAndQuickDecrypt || verifyInfo.LoadType == LoadType.LoadFromBinaryAndDecrypt)
                            {
                                Utility.Converter.GetBytes(verifyInfo.HashCode, m_CachedHashBytes);
                                if (verifyInfo.LoadType == LoadType.LoadFromMemoryAndQuickDecrypt || verifyInfo.LoadType == LoadType.LoadFromBinaryAndQuickDecrypt)
                                {
                                    hashCode = Utility.Verifier.GetCrc32(fileStream, m_CachedHashBytes, Utility.Encryption.QuickEncryptLength);
                                }
                                else if (verifyInfo.LoadType == LoadType.LoadFromMemoryAndDecrypt || verifyInfo.LoadType == LoadType.LoadFromBinaryAndDecrypt)
                                {
                                    hashCode = Utility.Verifier.GetCrc32(fileStream, m_CachedHashBytes, length);
                                }

                                Array.Clear(m_CachedHashBytes, 0, CachedHashBytesLength);
                            }
                            else
                            {
                                hashCode = Utility.Verifier.GetCrc32(fileStream);
                            }

                            if (hashCode == verifyInfo.HashCode)
                            {
                                return(true);
                            }
                        }
                    }

                    File.Delete(resourcePath);
                    return(false);
                }
            }