summaryrefslogtreecommitdiffstats
path: root/cmds/screenrecord/FrameOutput.cpp
diff options
context:
space:
mode:
authorBenoit Goby <benoit@android.com>2014-05-12 15:59:50 -0700
committerBenoit Goby <benoit@android.com>2014-05-13 16:17:21 -0700
commite32106fd5175afdf939ae397aece9caf378a4912 (patch)
tree4040ceee4a57c51fd17cd1a19c378bd683ed6e18 /cmds/screenrecord/FrameOutput.cpp
parent21bde57f0099fed5cca78d9357571dc015a63227 (diff)
downloadframeworks_av-e32106fd5175afdf939ae397aece9caf378a4912.zip
frameworks_av-e32106fd5175afdf939ae397aece9caf378a4912.tar.gz
frameworks_av-e32106fd5175afdf939ae397aece9caf378a4912.tar.bz2
screenrecord: Add raw frames output format
This works like the frames output format but without a header so that the output can be piped directly to mplayer: adb shell screenrecord --output-format=raw-frames - | mplayer -demuxer rawvideo -rawvideo w=320:h=240:format=rgb24 - Change-Id: Ib5ed508fdca3a5d63e973c5189b3677c2d92b43f
Diffstat (limited to 'cmds/screenrecord/FrameOutput.cpp')
-rw-r--r--cmds/screenrecord/FrameOutput.cpp25
1 files changed, 14 insertions, 11 deletions
diff --git a/cmds/screenrecord/FrameOutput.cpp b/cmds/screenrecord/FrameOutput.cpp
index b5cf2f9..6c37501 100644
--- a/cmds/screenrecord/FrameOutput.cpp
+++ b/cmds/screenrecord/FrameOutput.cpp
@@ -85,7 +85,7 @@ status_t FrameOutput::createInputSurface(int width, int height,
return NO_ERROR;
}
-status_t FrameOutput::copyFrame(FILE* fp, long timeoutUsec) {
+status_t FrameOutput::copyFrame(FILE* fp, long timeoutUsec, bool rawFrames) {
Mutex::Autolock _l(mMutex);
ALOGV("copyFrame %ld\n", timeoutUsec);
@@ -150,16 +150,20 @@ status_t FrameOutput::copyFrame(FILE* fp, long timeoutUsec) {
(endWhenNsec - pixWhenNsec) / 1000000.0);
}
- // Fill out the header.
- size_t headerLen = sizeof(uint32_t) * 5;
size_t rgbDataLen = width * height * kOutBytesPerPixel;
- size_t packetLen = headerLen - sizeof(uint32_t) + rgbDataLen;
- uint8_t header[headerLen];
- setValueLE(&header[0], packetLen);
- setValueLE(&header[4], width);
- setValueLE(&header[8], height);
- setValueLE(&header[12], width * kOutBytesPerPixel);
- setValueLE(&header[16], HAL_PIXEL_FORMAT_RGB_888);
+
+ if (!rawFrames) {
+ // Fill out the header.
+ size_t headerLen = sizeof(uint32_t) * 5;
+ size_t packetLen = headerLen - sizeof(uint32_t) + rgbDataLen;
+ uint8_t header[headerLen];
+ setValueLE(&header[0], packetLen);
+ setValueLE(&header[4], width);
+ setValueLE(&header[8], height);
+ setValueLE(&header[12], width * kOutBytesPerPixel);
+ setValueLE(&header[16], HAL_PIXEL_FORMAT_RGB_888);
+ fwrite(header, 1, headerLen, fp);
+ }
// Currently using buffered I/O rather than writev(). Not expecting it
// to make much of a difference, but it might be worth a test for larger
@@ -167,7 +171,6 @@ status_t FrameOutput::copyFrame(FILE* fp, long timeoutUsec) {
if (kShowTiming) {
startWhenNsec = systemTime(CLOCK_MONOTONIC);
}
- fwrite(header, 1, headerLen, fp);
fwrite(mPixelBuf, 1, rgbDataLen, fp);
fflush(fp);
if (kShowTiming) {