예제 #1
0
            private void onPhoto(AndroidJavaObject nativeBuffer, int width, int height)
            {
                // Inspect pixel buffer
                var pixelBuffer = (IntPtr)Unmanaged.CallStatic <long>(@"baseAddress", nativeBuffer);

                nativeBuffer.Dispose();
                // Send to delegates
                var photoTexture = new Texture2D(width, height, TextureFormat.RGBA32, false, false);

                photoTexture.LoadRawTextureData(pixelBuffer, width * height * 4);
                photoTexture.Apply();
                photoCallback(photoTexture);
            }
예제 #2
0
 public void CommitFrame(IntPtr pixelBuffer, long timestamp)
 {
     Unmanaged.CallStatic(
         @"copyFrame",
         pixelBuffer.ToInt64(),
         pixelWidth,
         pixelHeight,
         pixelWidth * 4,
         Unmanaged.CallStatic <long>(@"baseAddress", nativeBuffer)
         );
     using (var clearedBuffer = nativeBuffer.Call <AndroidJavaObject>("clear"))
         recorder.Call(@"encodeFrame", clearedBuffer, timestamp);
 }
예제 #3
0
            private void onFrame(AndroidJavaObject nativeBuffer, int textureID, int width, int height, long timestamp)
            {
                // Inspect pixel buffer
                var pixelBuffer = (IntPtr)Unmanaged.CallStatic <long>(@"baseAddress", nativeBuffer);

                nativeBuffer.Dispose();
                // Update preview texture
                var firstFrame = !previewTexture;

                previewTexture = previewTexture ?? new Texture2D(width, height, TextureFormat.RGBA32, false, false);
                previewTexture.LoadRawTextureData(pixelBuffer, width * height * 4);
                previewTexture.UpdateExternalTexture((IntPtr)textureID);
                // Invoke handlers
                if (firstFrame)
                {
                    startCallback(previewTexture);
                }
                if (frameCallback != null)
                {
                    frameCallback(timestamp);
                }
            }