Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2807f50e authored by Kuba Wojciechowski's avatar Kuba Wojciechowski Committed by Jan Altensen
Browse files

SystemUI: allow to limit the max framerate of built-in screen recorder



Some devices seem to have problems when running the screen recorder at
native resolution @ max fps (I'm looking at you surya). The symptoms may
include severe lagging in the recording or stuff like crashes when
stopping in a landscape orientation. Allow limiting the recorder fps to
fix these issues.

Test: record screen on surya with config_screenRecorderMaxFramerate==90
while screen is running @ 120Hz, observe a smooth video. Stop the
recording while in full screen landscape youtube video, observe no crash

Signed-off-by: default avatarKuba Wojciechowski <nullbytepl@gmail.com>
Change-Id: I361c7ae4bf74f2dd67b86e960f8d2d6ef63f5b8f
parent be00ba5a
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -28,4 +28,7 @@
         the sensor embedded in the power key and listening all the time
         causes a poor experience. -->
    <bool name="config_fingerprintWakeAndUnlock">true</bool>

    <!-- If not zero, limits the internal screen recorder's framerate to the set value. -->
    <integer name="config_screenRecorderMaxFramerate">0</integer>
</resources>
+6 −0
Original line number Diff line number Diff line
@@ -48,6 +48,8 @@ import android.util.Size;
import android.view.Surface;
import android.view.WindowManager;

import com.android.systemui.R;

import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
@@ -79,6 +81,7 @@ public class ScreenMediaRecorder {
    private ScreenRecordingMuxer mMuxer;
    private ScreenInternalAudioRecorder mAudio;
    private ScreenRecordingAudioSource mAudioSource;
    private int mMaxRefreshRate;

    private Context mContext;
    MediaRecorder.OnInfoListener mListener;
@@ -90,6 +93,8 @@ public class ScreenMediaRecorder {
        mUser = user;
        mListener = listener;
        mAudioSource = audioSource;
        mMaxRefreshRate = mContext.getResources().getInteger(
                R.integer.config_screenRecorderMaxFramerate);
    }

    private void prepare() throws IOException, RemoteException {
@@ -127,6 +132,7 @@ public class ScreenMediaRecorder {
        int screenWidth = metrics.widthPixels;
        int screenHeight = metrics.heightPixels;
        int refereshRate = (int) wm.getDefaultDisplay().getRefreshRate();
        if (mMaxRefreshRate != 0 && refereshRate > mMaxRefreshRate) refereshRate = mMaxRefreshRate;
        int vidBitRate = screenHeight * screenWidth * refereshRate / VIDEO_FRAME_RATE
                * VIDEO_FRAME_RATE_TO_RESOLUTION_RATIO;
        mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);