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

Commit 545bcd53 authored by Pablo Ceballos's avatar Pablo Ceballos
Browse files

screenrecord: add monotonic timestamps option

Change-Id: Ic2cef7161c256f12e60434b32f455f40ebf3d7bf
parent 1c8a038b
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -259,6 +259,11 @@ void Overlay::getTimeString_l(nsecs_t monotonicNsec, char* buf, size_t bufLen) {
    const char* format = "%T";
    struct tm tm;

    if (mUseMonotonicTimestamps) {
        snprintf(buf, bufLen, "%" PRId64, monotonicNsec);
        return;
    }

    // localtime/strftime is not the fastest way to do this, but a trivial
    // benchmark suggests that the cost is negligible.
    int64_t realTime = mStartRealtimeNsecs +
+5 −2
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ namespace android {
 */
class Overlay : public GLConsumer::FrameAvailableListener, Thread {
public:
    Overlay() : Thread(false),
    Overlay(bool monotonicTimestamps) : Thread(false),
        mThreadResult(UNKNOWN_ERROR),
        mState(UNINITIALIZED),
        mFrameAvailable(false),
@@ -45,7 +45,8 @@ public:
        mStartMonotonicNsecs(0),
        mStartRealtimeNsecs(0),
        mLastFrameNumber(-1),
        mTotalDroppedFrames(0)
        mTotalDroppedFrames(0),
        mUseMonotonicTimestamps(monotonicTimestamps)
        {}

    // Creates a thread that performs the overlay.  Pass in the surface that
@@ -151,6 +152,8 @@ private:
    nsecs_t mLastFrameNumber;
    size_t mTotalDroppedFrames;

    bool mUseMonotonicTimestamps;

    static const char* kPropertyNames[];
};

+6 −1
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ static const char* kMimeTypeAvc = "video/avc";
// Command-line parameters.
static bool gVerbose = false;           // chatty on stdout
static bool gRotate = false;            // rotate 90 degrees
static bool gMonotonicTime = false;     // use system monotonic time for timestamps
static enum {
    FORMAT_MP4, FORMAT_H264, FORMAT_FRAMES, FORMAT_RAW_FRAMES
} gOutputFormat = FORMAT_MP4;           // data format for output
@@ -612,7 +613,7 @@ static status_t recordScreen(const char* fileName) {
    sp<Overlay> overlay;
    if (gWantFrameTime) {
        // Send virtual display frames to an external texture.
        overlay = new Overlay();
        overlay = new Overlay(gMonotonicTime);
        err = overlay->start(encoderInputSurface, &bufferProducer);
        if (err != NO_ERROR) {
            if (encoder != NULL) encoder->release();
@@ -890,6 +891,7 @@ int main(int argc, char* const argv[]) {
        { "show-frame-time",    no_argument,        NULL, 'f' },
        { "rotate",             no_argument,        NULL, 'r' },
        { "output-format",      required_argument,  NULL, 'o' },
        { "monotonic-time",     no_argument,        NULL, 'm' },
        { NULL,                 0,                  NULL, 0 }
    };

@@ -969,6 +971,9 @@ int main(int argc, char* const argv[]) {
                return 2;
            }
            break;
        case 'm':
            gMonotonicTime = true;
            break;
        default:
            if (ic != '?') {
                fprintf(stderr, "getopt_long returned unexpected value 0x%x\n", ic);