Ejemplo n.º 1
0
        unsafe void DataItemGetVideoImage(NikonObject data)
        {
            string     name            = data.GetString(eNkMAIDCapability.kNkMAIDCapability_Name);
            NkMAIDSize videoDimensions = data.GetSize(eNkMAIDCapability.kNkMAIDCapability_Pixels);

            NkMAIDGetVideoImage videoImage = new NkMAIDGetVideoImage();

            data.GetGeneric(eNkMAIDCapability.kNkMAIDCapability_GetVideoImage, new IntPtr(&videoImage));

            // Note: Download 4MB at the time
            const int chunkSize = 4 * 1024 * 1024;

            uint totalSize = videoImage.ulDataSize;

            for (uint offset = 0; offset < totalSize; offset += chunkSize)
            {
                uint fragmentSize = Math.Min(chunkSize, totalSize - offset);

                byte[] buffer = new byte[fragmentSize];

                fixed(byte *pBuffer = buffer)
                {
                    videoImage.ulOffset   = offset;
                    videoImage.ulReadSize = (uint)buffer.Length;
                    videoImage.ulDataSize = (uint)buffer.Length;
                    videoImage.pData      = new IntPtr(pBuffer);

                    data.GetArrayGeneric(eNkMAIDCapability.kNkMAIDCapability_GetVideoImage, new IntPtr(&videoImage));
                }

                NikonVideoFragment fragment = new NikonVideoFragment(
                    name,
                    totalSize,
                    offset,
                    buffer,
                    videoDimensions.w,
                    videoDimensions.h);

                Scheduler.Callback(new VideoFragmentReadyDelegate(OnVideoFragmentReady), this, fragment);
            }
        }
Ejemplo n.º 2
0
        unsafe void DataItemGetVideoImage(NikonObject data)
        {
            string name = data.GetString(eNkMAIDCapability.kNkMAIDCapability_Name);
            NkMAIDSize videoDimensions = data.GetSize(eNkMAIDCapability.kNkMAIDCapability_Pixels);

            NkMAIDGetVideoImage videoImage = new NkMAIDGetVideoImage();
            data.GetGeneric(eNkMAIDCapability.kNkMAIDCapability_GetVideoImage, new IntPtr(&videoImage));

            // Note: Download 4MB at the time
            const int chunkSize = 4 * 1024 * 1024;

            uint totalSize = videoImage.ulDataSize;

            for (uint offset = 0; offset < totalSize; offset += chunkSize)
            {
                uint fragmentSize = Math.Min(chunkSize, totalSize - offset);

                byte[] buffer = new byte[fragmentSize];

                fixed (byte* pBuffer = buffer)
                {
                    videoImage.ulOffset = offset;
                    videoImage.ulReadSize = (uint)buffer.Length;
                    videoImage.ulDataSize = (uint)buffer.Length;
                    videoImage.pData = new IntPtr(pBuffer);

                    data.GetArrayGeneric(eNkMAIDCapability.kNkMAIDCapability_GetVideoImage, new IntPtr(&videoImage));
                }

                NikonVideoFragment fragment = new NikonVideoFragment(
                    name,
                    totalSize,
                    offset,
                    buffer,
                    videoDimensions.w,
                    videoDimensions.h);

                Scheduler.Callback(new VideoFragmentReadyDelegate(OnVideoFragmentReady), this, fragment);
            }
        }