本文整理汇总了C++中android::sp::setFrameAvailableListener方法的典型用法代码示例。如果您正苦于以下问题:C++ sp::setFrameAvailableListener方法的具体用法?C++ sp::setFrameAvailableListener怎么用?C++ sp::setFrameAvailableListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android::sp
的用法示例。
在下文中一共展示了sp::setFrameAvailableListener方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: layerStackRect
int
createVirtualDisplay() {
uint32_t sourceWidth, sourceHeight;
uint32_t targetWidth, targetHeight;
android::status_t err;
switch (mDesiredOrientation) {
case Minicap::ORIENTATION_90:
sourceWidth = mRealHeight;
sourceHeight = mRealWidth;
targetWidth = mDesiredHeight;
targetHeight = mDesiredWidth;
break;
case Minicap::ORIENTATION_270:
sourceWidth = mRealHeight;
sourceHeight = mRealWidth;
targetWidth = mDesiredHeight;
targetHeight = mDesiredWidth;
break;
case Minicap::ORIENTATION_180:
sourceWidth = mRealWidth;
sourceHeight = mRealHeight;
targetWidth = mDesiredWidth;
targetHeight = mDesiredHeight;
break;
case Minicap::ORIENTATION_0:
default:
sourceWidth = mRealWidth;
sourceHeight = mRealHeight;
targetWidth = mDesiredWidth;
targetHeight = mDesiredHeight;
break;
}
// Set up virtual display size.
android::Rect layerStackRect(sourceWidth, sourceHeight);
android::Rect visibleRect(targetWidth, targetHeight);
// Create a Surface for the virtual display to write to.
MCINFO("Creating SurfaceComposerClient");
android::sp<android::SurfaceComposerClient> sc = new android::SurfaceComposerClient();
MCINFO("Performing SurfaceComposerClient init check");
if ((err = sc->initCheck()) != android::NO_ERROR) {
MCERROR("Unable to initialize SurfaceComposerClient");
return err;
}
// Create virtual display.
MCINFO("Creating virtual display");
mVirtualDisplay = android::SurfaceComposerClient::createDisplay(
/* const String8& displayName */ android::String8("minicap"),
/* bool secure */ true
);
MCINFO("Creating buffer queue");
android::BufferQueue::createBufferQueue(&mBufferProducer, &mBufferConsumer);
mBufferConsumer->setDefaultBufferSize(targetWidth, targetHeight);
mBufferConsumer->setDefaultBufferFormat(android::PIXEL_FORMAT_RGBA_8888);
MCINFO("Creating CPU consumer");
mConsumer = new android::CpuConsumer(mBufferConsumer, 3, false);
mConsumer->setName(android::String8("minicap"));
MCINFO("Creating frame waiter");
mFrameProxy = new FrameProxy(mUserFrameAvailableListener);
mConsumer->setFrameAvailableListener(mFrameProxy);
MCINFO("Publishing virtual display");
android::SurfaceComposerClient::openGlobalTransaction();
android::SurfaceComposerClient::setDisplaySurface(mVirtualDisplay, mBufferProducer);
android::SurfaceComposerClient::setDisplayProjection(mVirtualDisplay,
android::DISPLAY_ORIENTATION_0, layerStackRect, visibleRect);
android::SurfaceComposerClient::setDisplayLayerStack(mVirtualDisplay, 0); // default stack
android::SurfaceComposerClient::closeGlobalTransaction();
mHaveRunningDisplay = true;
return 0;
}