コード例 #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
ファイル: MediaRecorderAndroid.cs プロジェクト: dqchess/Linyx
 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);
                }
            }