LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_SRC_FILES:= \ main.cpp LOCAL_STATIC_LIBRARIES := \ libstagefright_color_conversion LOCAL_SHARED_LIBRARIES := \ libcutils \ libutils \ libbinder \ libui \ libgui \ libstagefright\ libstagefright_foundation LOCAL_C_INCLUDES := \ frameworks/native/include/media/openmax \ frameworks/av/media/libstagefright LOCAL_MODULE:= yuvShow LOCAL_MODULE_TAGS := tests include $(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; }