📄 pxrend.cpp
字号:
/* ***** BEGIN LICENSE BLOCK ***** * Source last modified: $Id: pxrend.cpp,v 1.4.6.1 2004/07/09 01:51:47 hubbe Exp $ * * Portions Copyright (c) 1995-2004 RealNetworks, Inc. All Rights Reserved. * * The contents of this file, and the files included with this file, * are subject to the current version of the RealNetworks Public * Source License (the "RPSL") available at * http://www.helixcommunity.org/content/rpsl unless you have licensed * the file under the current version of the RealNetworks Community * Source License (the "RCSL") available at * http://www.helixcommunity.org/content/rcsl, in which case the RCSL * will apply. You may also obtain the license terms directly from * RealNetworks. You may not use this file except in compliance with * the RPSL or, if you have a valid RCSL with RealNetworks applicable * to this file, the RCSL. Please see the applicable RPSL or RCSL for * the rights, obligations and limitations governing use of the * contents of the file. * * Alternatively, the contents of this file may be used under the * terms of the GNU General Public License Version 2 or later (the * "GPL") in which case the provisions of the GPL are applicable * instead of those above. If you wish to allow use of your version of * this file only under the terms of the GPL, and not to allow others * to use your version of this file under the terms of either the RPSL * or RCSL, indicate your decision by deleting the provisions above * and replace them with the notice and other provisions required by * the GPL. If you do not delete the provisions above, a recipient may * use your version of this file under the terms of any one of the * RPSL, the RCSL or the GPL. * * This file is part of the Helix DNA Technology. RealNetworks is the * developer of the Original Code and owns the copyrights in the * portions it created. * * This file, and the files included with this file, is distributed * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET * ENJOYMENT OR NON-INFRINGEMENT. * * Technology Compatibility Kit Test Suite(s) Location: * http://www.helixcommunity.org/content/tck * * Contributor(s): * * ***** END LICENSE BLOCK ***** */// include#include "hxtypes.h"#include "hxwintyp.h"#include "hxcom.h"#include "hxcomm.h"#include "ihxpckts.h"#include "hxfiles.h"#include "hxcore.h"#include "hxrendr.h"#include "hxhyper.h"#include "hxplugn.h"#include "hxwin.h"#include "hxasm.h"#include "hxevent.h"#include "hxvsurf.h"#include "hxver.h"#include "hxupgrd.h"#include "hxengin.h"#include "hxmon.h"#include "hxprefs.h"#include "ihxcookies.h"#include "hxerror.h"// pncont#include "hxbuffer.h"#include "hxslist.h"#include "hxmap.h"#include "hxstring.h"#include "hxmap.h"// pnmisc#include "unkimp.h"#include "baseobj.h"#include "hxtick.h"// baserend#include "baserend.h"#include "vbasernd.h"// pxcomlib#include "glist.h"#include "gstring.h"#include "pxutil.h"#include "pxcolor.h"#include "parseurl.h"#include "pxcmpmgr.h"#include "pxrect.h"#include "pximage.h"#include "pxrndcod.h"#include "pxeffect.h"#include "rpeffect.h"#include "wirefmgr.h"#include "pxcookie.h"#include "pxcallbk.h"// pxrend#include "hlinkmgr.h"#include "imghelpr.h"#include "rncodmgr.h"#include "imagemgr.h"#include "fxpkgmgr.h"#include "fxmanagr.h"#include "pxremlog.h"#include "pxrend.h"#include "rprenddll.ver"// pndebug#include "debugout.h"#include "errdbg.h"#include "hxheap.h"#ifdef _DEBUG#undef HX_THIS_FILE static char HX_THIS_FILE[] = __FILE__;#endifconst char* CRealPixRenderer::m_pszName = "RealPix";const char* CRealPixRenderer::m_pszDescription = "Helix RealPix Renderer Plugin";const char* CRealPixRenderer::m_ppszMimeType[] = {"application/vnd.rn-realpixstream", "application/vnd.rn-realpixstream2", NULL};CRealPixRenderer::CRealPixRenderer() : CRNVisualBaseRenderer(){ m_pCodecManager = NULL; m_pImageManager = NULL; m_pEffectsManager = NULL; m_pWireFormatManager = NULL; m_pHyperlinkManager = NULL; m_pEffectsPackageManager = NULL; m_pCallback = NULL; m_pDrawFocus = NULL; m_bPaused = FALSE; m_bSeeking = FALSE; m_ulPerformanceScale = 2; m_ulPerformanceAdjustedDelay = 0; m_ulLastDrawTime = HX_GET_TICKCOUNT(); m_bIsLive = FALSE; m_bBltSubRects = FALSE;};CRealPixRenderer::~CRealPixRenderer(){ Deallocate();};STDMETHODIMP CRealPixRenderer::QueryInterface(REFIID riid, void** ppvObj){ HX_RESULT retVal = HXR_OK; if (ppvObj) { if (IsEqualIID(riid, IID_IHXFocusNavigation)) { AddRef(); *ppvObj = (IHXFocusNavigation*) this; } else { retVal = CRNVisualBaseRenderer::QueryInterface(riid, ppvObj); } } else { retVal = HXR_FAIL; } return retVal;}STDMETHODIMP_(UINT32) CRealPixRenderer::AddRef(){ return CRNVisualBaseRenderer::AddRef();}STDMETHODIMP_(UINT32) CRealPixRenderer::Release(){ return CRNVisualBaseRenderer::Release();}STDMETHODIMP CRealPixRenderer::OnHeader(IHXValues *pHeader){ HX_RESULT retVal = HXR_OK; if (pHeader) { // Check presentation stream and content versions retVal = CheckStreamVersions(pHeader); if (SUCCEEDED(retVal)) { // Deallocate and reset Deallocate(); Reset(); // Create all the member objects retVal = CreateObjects(); if (SUCCEEDED(retVal)) { retVal = SetupObjects(pHeader); if (SUCCEEDED(retVal)) { retVal = SetupCodecsAndFXPackages(); if (SUCCEEDED(retVal)) { // Set up quality info for determining scaling factor of the // auto-frame rate scaling code UINT32 ulQualPref = 4; // highest quality, most CPU BOOL bPresent = FALSE; IHXBuffer* pBuffer = NULL; retVal = GetPreference("Quality", bPresent, pBuffer); if (SUCCEEDED(retVal) && bPresent) { ulQualPref = (UINT32) atol((const char*) pBuffer->GetBuffer()); } HX_RELEASE(pBuffer); // Quality is on a scale of 4 to 0, where 4 means high quality and // 0 means lowest CPU usage. We will map this on to the follofing... // For 4, we will force redraw to take 1/2 the time // For 3, we will force redraw to take 1/3 of the time // For 2, we will force redraw to take 1/4 of the time // For 1, we will force redraw to take 1/5 of the time // For 0, we will force redraw to take 1/6 of the time // This obviously maps onto.... m_ulPerformanceScale = 6 - ulQualPref; } } } } else { AddMimeToUpgradeCollection(m_ppszMimeType[1]); retVal = HXR_FAIL; }#ifdef XXXMEH_DEBUG_OUT DEBUG_OUT(m_pErrorMessages, DOL_REALPIX_EXTENDED, (s, "Stream Version from Stream Header = %lu.%lu", HX_GET_MAJOR_VERSION(m_ulStreamVersion), HX_GET_MINOR_VERSION(m_ulStreamVersion))); DEBUG_OUT(m_pErrorMessages, DOL_REALPIX_EXTENDED, (s, "Content Version from Stream Header = %lu.%lu", HX_GET_MAJOR_VERSION(m_ulContentVersion), HX_GET_MINOR_VERSION(m_ulContentVersion))); DEBUG_OUT(m_pErrorMessages, DOL_REALPIX_EXTENDED, (s, "Highest Supported Stream Version = %lu.%lu", HX_GET_MAJOR_VERSION(GetHighestSupportedStreamVersion()), HX_GET_MINOR_VERSION(GetHighestSupportedStreamVersion()))); DEBUG_OUT(m_pErrorMessages, DOL_REALPIX_EXTENDED, (s, "Highest Supported Content Version = %lu.%lu", HX_GET_MAJOR_VERSION(GetHighestSupportedContentVersion()), HX_GET_MINOR_VERSION(GetHighestSupportedContentVersion()))); if (m_pWireFormatManager) { DEBUG_OUT(m_pErrorMessages, DOL_REALPIX, (s, "Display Width = %lu, Display Height = %lu", m_pWireFormatManager->GetDisplayWidth(), m_pWireFormatManager->GetDisplayHeight())); IHXBuffer* pDefaultURLStr = NULL; m_pWireFormatManager->GetDefaultURL(pDefaultURLStr); DEBUG_OUT(m_pErrorMessages, DOL_REALPIX, (s, "Default Clickthru URL = %s", (pDefaultURLStr ? (const char*) pDefaultURLStr->GetBuffer() : "None"))); HX_RELEASE(pDefaultURLStr); }#endif } else { retVal = HXR_INVALID_PARAMETER; }#ifdef XXXMEH_DEBUG_ASSERT // Debug-only assert HX_ASSERT(SUCCEEDED(retVal));#endif return retVal;}STDMETHODIMP CRealPixRenderer::OnPacketNoOffset(IHXPacket *pPacket){ HX_RESULT retVal = HXR_OK; if (pPacket) {#ifdef XXXMEH_DUMP_TIMING_INFO static UINT32 ulLastMinute = 0xFFFFFFFF; UINT32 ulPlayerTime = m_pPlayer->GetCurrentPlayTime(); UINT32 ulCurMinute = ulPlayerTime / 60000; if (ulLastMinute != ulCurMinute) { UINT32 ulPacketTime = pPacket->GetTime(); INT32 lDiff = (INT32) ulPacketTime - ulPlayerTime; FILE* fp = fopen("pxrend2.log", "a"); if (fp) { fprintf(fp, "PlayerTime=%10lu PacketTime=%10lu Diff=%6ld NumImages=%lu\n", ulPlayerTime, ulPacketTime, lDiff, m_pImageManager->GetNumImages()); fclose(fp); } } ulLastMinute = ulCurMinute;#endif if (!pPacket->IsLost()) { // Get the packet type UINT32 ulPacketType = 0; retVal = m_pWireFormatManager->GetPacketType(pPacket, ulPacketType); if (SUCCEEDED(retVal)) { if (ulPacketType == PXWireFormatManager::kPacketTypeImageHeader) { UINT32 ulHandle = 0; UINT32 ulLength = 0; UINT32 ulFlags = 0; IHXBuffer* pMimeStr = NULL; UINT32 ulOpaqueSize = 0; retVal = m_pWireFormatManager->GetImageHeaderInfo(pPacket, ulHandle, ulLength, ulFlags, &pMimeStr, ulOpaqueSize); if (SUCCEEDED(retVal)) {#ifdef XXXMEH_DEBUG_OUT DEBUG_OUT(m_pErrorMessages, DOL_REALPIX_EXTENDED, (s, "Image Header Packet (handle=%lu) ts=%lu", ulHandle, pPacket->GetTime()));#endif retVal = m_pImageManager->CreateImage(ulHandle, ulLength, (const char*) pMimeStr->GetBuffer(), ulOpaqueSize); } HX_RELEASE(pMimeStr); } else if (ulPacketType == PXWireFormatManager::kPacketTypeImageData) { UINT32 ulHandle = 0; retVal = m_pWireFormatManager->GetImageDataHandle(pPacket, ulHandle); if (SUCCEEDED(retVal)) {#ifdef XXXMEH_DEBUG_OUT DEBUG_OUT(m_pErrorMessages, DOL_REALPIX_EXTENDED, (s, "Image Data Packet (handle=%lu) ts=%lu", ulHandle, pPacket->GetTime()));#endif UINT32 ulOpaqueSize = 0; HX_RESULT rv = m_pImageManager->GetOpaqueDataSize(ulHandle, ulOpaqueSize); if (SUCCEEDED(rv)) { IHXBuffer* pOpaque = NULL; IHXBuffer* pData = NULL; retVal = m_pWireFormatManager->GetImageDataInfo(pPacket, ulOpaqueSize, pOpaque, pData); if (SUCCEEDED(retVal)) { retVal = m_pImageManager->OnImageDataPacket(ulHandle, pOpaque, pData); if (SUCCEEDED(retVal)) { retVal = m_pEffectsManager->CheckPostDurationPacket(ulHandle); } } HX_RELEASE(pOpaque); HX_RELEASE(pData); } } } else if (ulPacketType == PXWireFormatManager::kPacketTypeEffect) { PXEffect* pEffect = NULL; retVal = m_pWireFormatManager->GetEffectInfo(pPacket, &pEffect); if (SUCCEEDED(retVal)) {#ifdef XXXMEH_DEBUG_OUT
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -