Android显示相关记录

来源:互联网 发布:淘宝查权重 编辑:程序博客网 时间:2024/05/17 23:35
LOCAL_PATH:= $(call my-dir)include $(CLEAR_VARS)LOCAL_SRC_FILES:= \  main.cppLOCAL_STATIC_LIBRARIES := \  libstagefright_color_conversionLOCAL_SHARED_LIBRARIES := \  libcutils \  libutils \  libbinder \  libui \  libgui \  libstagefright\  libstagefright_foundationLOCAL_C_INCLUDES := \  frameworks/native/include/media/openmax \  frameworks/av/media/libstagefrightLOCAL_MODULE:= yuvShowLOCAL_MODULE_TAGS := testsinclude $(BUILD_EXECUTABLE)
#include <include/SoftwareRenderer.h>#include <cutils/memory.h>#include <unistd.h>#include <utils/Log.h>#include <binder/IPCThreadState.h>#include <binder/ProcessState.h>#include <binder/IServiceManager.h>#include <gui/Surface.h>#include <gui/SurfaceComposerClient.h>#include <gui/ISurfaceComposer.h>#include <ui/DisplayInfo.h>#include <android/native_window.h>#include <media/stagefright/MetaData.h>int main(void){        // create a client to surfaceflinger        sp<SurfaceComposerClient> client = new SurfaceComposerClient();        // create a surface        sp<SurfaceControl> surfaceControl = client->createSurface(String8("showyuv"),                        //dinfo.w, dinfo.h, PIXEL_FORMAT_RGBA_8888, 0);                        1280, 720, PIXEL_FORMAT_RGBA_8888, 0);        /********************* 配置surface ******************************/        SurfaceComposerClient::openGlobalTransaction();        surfaceControl->setLayer(100000);      //设定Z坐标        surfaceControl->setPosition(0, 0);     //以左上角为(0,0)设定显示位置        surfaceControl->setSize(width, height);//设定视频显示大小        SurfaceComposerClient::closeGlobalTransaction();        sp<Surface> surface = surfaceControl->getSurface();        printf("[%s][%d]\n",__FILE__,__LINE__);        /********************** 配置MetaData ****************************/        sp<MetaData> meta = new MetaData;        meta->setInt32(kKeyWidth, width);        meta->setInt32(kKeyHeight, height);        meta->setInt32(kKeyColorFormat, OMX_COLOR_FormatYUV420Planar); //正常显示yuv420p        printf("[%s][%d]\n",__FILE__,__LINE__);        /********************** Display the data ***********************/        SoftwareRenderer* sr = new SoftwareRenderer(surface,meta);//初始化        sr->render(data,size,NULL); //将data显示到屏幕上,数据来源通过网口        printf("[%s][%d]\n",__FILE__,__LINE__);        IPCThreadState::self()->joinThreadPool();//可以保证画面一直显示,否则瞬间消失        IPCThreadState::self()->stopProcess();        return 0;}



0 0