📄 fb_video_render.cpp
字号:
/*//// INTEL CORPORATION PROPRIETARY INFORMATION// This software is supplied under the terms of a license agreement or// nondisclosure agreement with Intel Corporation and may not be copied// or disclosed except in accordance with the terms of that agreement.// Copyright(c) 2003-2005 Intel Corporation. All Rights Reserved.//*/#include "fb_video_render.h"#if defined(UMC_ENABLE_FB_VIDEO_RENDER)#include <unistd.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include "vm_debug.h"#include "umc_video_data.h"namespace UMC{FBVideoRender::FBVideoRender() : m_iDevHandle(0), m_pbMap(NULL), m_uiMapSize(0){ memset(&m_sFixInfo, 0, sizeof(m_sFixInfo)); memset(&m_sVarInfo, 0, sizeof(m_sVarInfo));} // FBVideoRender::FBVideoRender() :FBVideoRender::~FBVideoRender(){ Close();} // FBVideoRender::~FBVideoRender()Status FBVideoRender::ShowLastFrame(){ return UMC_NOT_IMPLEMENTED;} // FBVideoRender::ShowLastFrame()// Terminate the renderStatus FBVideoRender::Close(){ Status umcRes = MobileVideoRender::Close(); if (NULL != m_pbMap) { assert(0 != m_uiMapSize); assert(NULL != m_iDevHandle); munmap(m_pbMap, m_uiMapSize); m_uiMapSize = 0; m_pbMap = NULL; } if (0 != m_iDevHandle) { close(m_iDevHandle); m_iDevHandle = 0; } memset(&m_sFixInfo, 0, sizeof(m_sFixInfo)); memset(&m_sVarInfo, 0, sizeof(m_sVarInfo)); return umcRes;} // Status FBVideoRender::Close()// Initialize the render, return false if failed, call Close anywayStatus FBVideoRender::Init(MediaReceiverParams* pInit){ Status umcRes = UMC_OK; VideoRenderParams *pParams = DynamicCast<VideoRenderParams> (pInit); if (NULL == pParams) umcRes = UMC_NULL_PTR; if (UMC_OK == umcRes) umcRes = MobileVideoRender::Init(pInit); if (UMC_OK == umcRes) { m_iDevHandle = open("/dev/fb0", O_RDWR); if (0 == m_iDevHandle) { vm_debug_msg(-1, "No Frame Buffer device was found or insufficient access rights\n"); umcRes = UMC_FAILED_TO_OPEN_DEVICE; } } // Get fixed screen information if (UMC_OK == umcRes && 0 != ioctl(m_iDevHandle, FBIOGET_FSCREENINFO, &m_sFixInfo)) { vm_debug_msg(-1, "Error reading fixed information.\n"); umcRes = UMC_FAILED_TO_INITIALIZE; } // Get variable screen information if (UMC_OK == umcRes && 0 != ioctl(m_iDevHandle, FBIOGET_VSCREENINFO, &m_sVarInfo)) { vm_debug_msg(-1, "Error reading variable information.\n"); umcRes = UMC_FAILED_TO_INITIALIZE; } if (UMC_OK == umcRes) { // Figure out the size of the screen in bytes m_uiMapSize = m_sVarInfo.xres * m_sVarInfo.yres * m_sVarInfo.bits_per_pixel / 8; // Map the device to memory m_pbMap = (vm_byte*)mmap(0, m_uiMapSize, PROT_READ | PROT_WRITE, MAP_SHARED, m_iDevHandle, 0); if (MAP_FAILED == m_pbMap) { vm_debug_msg(-1, "Error: failed to map framebuffer device to memory.\n"); umcRes = UMC_FAILED_TO_ALLOCATE_BUFFER; } } if (UMC_OK != umcRes) Close(); return umcRes;} // Status FBVideoRender::Init(MediaReceiverParams* pInit)Status FBVideoRender::LockInputBuffer(MediaData* pInData){ Status umcRes = UMC_OK; VideoData *pVideoData = DynamicCast<VideoData>(pInData); if (NULL == pVideoData) umcRes = UMC_NULL_PTR; if (UMC_OK == umcRes && NULL == m_pbMap) umcRes = UMC_NOT_INITIALIZED; if (UMC_OK == umcRes) { assert(0 != m_uiMapSize); while (VM_TIMEOUT == m_ReadySema.Wait(1000)) { if(m_bStopFlag || m_dfFrameTime == -1.0) { umcRes = UMC_END_OF_STREAM; break; } } } if (UMC_OK == umcRes) { pVideoData->SetDest(m_pbMap); pVideoData->SetPitch(m_sFixInfo.line_length); } else { pVideoData->SetDest(NULL); pVideoData->SetPitch(0); } return umcRes;} // Status FBVideoRender::LockInputBuffer(MediaData* pInData)Status FBVideoRender::UnLockInputBuffer(MediaData *pInData, Status StreamStatus){ Status umcRes = UMC_OK; VideoData* pVideoData = DynamicCast<VideoData>(pInData); if (NULL == pVideoData) umcRes = UMC_NULL_PTR; if (UMC_OK == umcRes) { double dfEndTime; pVideoData->GetTime(m_dfFrameTime, dfEndTime); umcRes = m_DoneSema.Signal(); } if (UMC_END_OF_STREAM == StreamStatus) Stop(); return umcRes;} // Status FBVideoRender::UnLockInputBuffer(MediaData *pInData, Status StreamStatus)} // namespace UMC#endif // defined(UMC_ENABLE_FB_VIDEO_RENDER)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -