小编cyr*_*000的帖子

使用自定义捕获器(webrtc)从画布创建流

我写了下面的代码来从画布获取流。但每5分钟后。我得到(内存不足)。我在 android studio 中查看了“Profiler”以检查内存消耗,并且在应用程序运行时它迅速增加。我不确定,这是因为昂贵的位图或任何其他昂贵的事情。任何帮助或建议都会有所帮助。

@Override
   public void startCapture(int width, int height, int fps) {

    if (captureThread == null || !captureThread.isInterrupted()) {
        captureThread = new Thread(() -> {
            try {
                newCameraHeight = 480;
                newCameraWidth = 640;

                long start = System.nanoTime();
                capturerObs.onCapturerStarted(true);
                int[] textures = new int[1];
                GLES20.glGenTextures(1, textures, 0);

                String name = getInitialWord(userName).toUpperCase();

                YuvConverter yuvConverter = new YuvConverter();

                releaseBitmap(bitmap);
                bitmap = Bitmap.createBitmap(newCameraWidth, newCameraHeight, Bitmap.Config.ARGB_8888);
                Bitmap newBitmap = bitmap.copy(bitmap.getConfig(), true);
                releaseBitmap(bitmap);

                GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textures[0]);
                Log.d("InitialsClass", "start capturer width- " + newCameraWidth + " …
Run Code Online (Sandbox Code Playgroud)

android webrtc

8
推荐指数
1
解决办法
117
查看次数

标签 统计

android ×1

webrtc ×1