Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Screen Shot in Group video call #339

Open
Amitdygon opened this issue Sep 8, 2022 · 1 comment
Open

Screen Shot in Group video call #339

Amitdygon opened this issue Sep 8, 2022 · 1 comment

Comments

@Amitdygon
Copy link

How can i take screen shot of group video call .

I have tried simple bitmap creation but its seem to not working due to surface view show how can i implement this method its used to take screen shot of single surface view but its show erro mGridVideoViewContainer beacuse its a recycler view can any one help me here to take screen shot when multiple user joined in call.

` final Bitmap bitmap = Bitmap.createBitmap(mGridVideoViewContainer.getWidth(), mGridVideoViewContainer.getHeight(), Bitmap.Config.ARGB_8888);

    // Create a handler thread to offload the processing of the image.
    final HandlerThread handlerThread = new HandlerThread("PixelCopier");
    handlerThread.start();
    // Make the request to copy.
    PixelCopy.request((SurfaceView) mGridVideoViewContainer.getRootView(), bitmap, (copyResult) -> {
        if (copyResult == PixelCopy.SUCCESS){
            try {
                AppUtils.INSTANCE.saveImage(this, bitmap, new SimpleDateFormat(FILENAME_FORMAT, Locale.US).format(System.currentTimeMillis()) + ".png");
            } catch (IOException e) {
                e.printStackTrace();
            }

        }

        handlerThread.quitSafely();
    }, new Handler(handlerThread.getLooper()));
}`
@xgfd3
Copy link

xgfd3 commented Sep 13, 2022

Maybe, you can try the code below to take screen shot of group video.

Bitmap bitmap = Bitmap.createBitmap(mGridVideoViewContainer.getWidth(), mGridVideoViewContainer.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
HandlerThread takeSnapshopThread = new HandlerThread("TakeSnapshopThread");
takeSnapshopThread.start();
Handler drawHandler = new Handler(takeSnapshopThread.getLooper());
Rect containerRect = new Rect();
mGridVideoViewContainer.getGlobalVisibleRect(containerRect);
for (int i = 0; i < mGridVideoViewContainer.getChildCount(); i++) {
    View childAt = ((ViewGroup)mGridVideoViewContainer.getChildAt(i)).getChildAt(0);
    if(childAt instanceof SurfaceView){
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            CountDownLatch latch = new CountDownLatch(1);
            Bitmap childBitmap = Bitmap.createBitmap(childAt.getWidth(), childAt.getHeight(), Bitmap.Config.ARGB_8888);
            Rect destRect = new Rect();
            childAt.getGlobalVisibleRect(destRect);
            destRect.left = destRect.left - containerRect.left;
            destRect.top = destRect.top - containerRect.top;
            destRect.right = destRect.left + childAt.getWidth();
            destRect.bottom = destRect.top + childAt.getHeight();
            PixelCopy.request((SurfaceView) childAt, childBitmap, copyResult -> {
                canvas.drawBitmap(childBitmap, null, destRect, paint);
                latch.countDown();
            }, drawHandler);
            try {
                latch.await();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            childBitmap.recycle();
        }
    }
}
takeSnapshopThread.quit();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants