I am using LibVLC and Unity to playback locally stored encrypted 360 videos. VLC's Unity package has a feature to play content via a C# stream. I am using a FileStream wrapped in a CryptoStream to get this working. This works for medium to small videos however, larger, high bitrate videos don't playback properly with my current implementation. The video plays for about 10 seconds before freezing, due to the cryptostreams decryption speed.
I am using the following code to create a decrypting CryptoStream which is passed to VLC. The path points to a properly encrypted file stored on device.
AesCryptoServiceProvider aesCryptoServiceProvider = new AesCryptoServiceProvider();
FileStream crpytoFileStream = new FileStream(path, FileMode.Open);
CryptoStream cryptoStream = new CryptoStream(crpytoFileStream, aesCryptoServiceProvider.CreateDecryptor(Key, IV), CryptoStreamMode.Read);
BufferedStream bufferedStream = new BufferedStream(cryptoStream, bufferSize);
I am using AesCyptoServiceProvider because I know it is the faster cryptostream implementation. I have also tried some different padding, block sizes and other options however I haven't seen much improvement over the default options for AesCryptoServiceProvider.
I've done quite a bit of research and I haven't been able to find definite ways of speeding up the CryptoStream. I don't know if there is a better way to wrap my streams or if there is something I am overlooking. Any help is appreciated, thanks.