void FrameProcessorBase::dump(int fd, const Vector<String16>& /*args*/) { String8 result(" Latest received frame:\n"); write(fd, result.string(), result.size()); CameraMetadata lastFrame; { // Don't race while dumping metadata Mutex::Autolock al(mLastFrameMutex); lastFrame = CameraMetadata(mLastFrame); } lastFrame.dump(fd, 2, 6); }
TEST_P(CameraFrameTest, GetFrame) { TEST_EXTENSION_FORKING_INIT; /* Submit a PREVIEW type request, then wait until we get the frame back */ CameraMetadata previewRequest; ASSERT_EQ(OK, mDevice->createDefaultRequest(CAMERA2_TEMPLATE_PREVIEW, &previewRequest)); { Vector<uint8_t> outputStreamIds; outputStreamIds.push(mStreamId); ASSERT_EQ(OK, previewRequest.update(ANDROID_REQUEST_OUTPUT_STREAMS, outputStreamIds)); if (CAMERA_FRAME_DEBUGGING) { int frameCount = 0; ASSERT_EQ(OK, previewRequest.update(ANDROID_REQUEST_FRAME_COUNT, &frameCount, 1)); } } if (CAMERA_FRAME_DEBUGGING) { previewRequest.dump(STDOUT_FILENO); } for (int i = 0; i < GetParam(); ++i) { ALOGV("Submitting capture request %d", i); CameraMetadata tmpRequest = previewRequest; ASSERT_EQ(OK, mDevice->capture(tmpRequest)); } for (int i = 0; i < GetParam(); ++i) { ALOGV("Reading capture request %d", i); ASSERT_EQ(OK, mDevice->waitForNextFrame(CAMERA_FRAME_TIMEOUT)); CameraMetadata frameMetadata; ASSERT_EQ(OK, mDevice->getNextFrame(&frameMetadata)); // wait for buffer to be available ASSERT_EQ(OK, mFrameListener->waitForFrame(CAMERA_FRAME_TIMEOUT)); ALOGV("We got the frame now"); // mark buffer consumed so producer can re-dequeue it CpuConsumer::LockedBuffer imgBuffer; ASSERT_EQ(OK, mCpuConsumer->lockNextBuffer(&imgBuffer)); ASSERT_EQ(OK, mCpuConsumer->unlockBuffer(imgBuffer)); } }