📄 vidrend.h
字号:
/* ***** BEGIN LICENSE BLOCK *****
* Version: RCSL 1.0/RPSL 1.0
*
* Portions Copyright (c) 1995-2002 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
* Version 1.0 (the "RPSL") available at
* http://www.helixcommunity.org/content/rpsl unless you have licensed
* the file under the RealNetworks Community Source License Version 1.0
* (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.
*
* 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 ***** */
#ifndef _VIDREND_H_
#define _VIDREND_H_
/****************************************************************************
* Includes
*/
#include "vidrendf.h"
#include "hxplugn.h"
#include "hxrendr.h"
#include "hxwin.h"
#include "hxsite2.h"
#include "hxasm.h"
#include "hxmon.h"
#include "hxpcmkr.h"
#include "hxcore.h"
#include "hxprefs.h"
#include "hxtick.h"
#include "cringbuf.h"
#include "vidstats.h"
/****************************************************************************
* CVideoRenderer
*/
class CVideoRenderer : public IHXPlugin,
public IHXRenderer,
public IHXSiteUser,
public IHXInterruptSafe,
public IHXCallback,
public IHXStatistics,
public IHXRenderTimeLine,
public IHXPaceMakerResponse,
#ifdef HELIX_FEATURE_VIDREND_UNTIMED_DECODE
public IHXUntimedRenderer,
#endif /* HELIX_FEATURE_VIDREND_UNTIMED_DECODE */
public IHXUpdateProperties
{
private:
class CSetSizeCB : public IHXCallback
{
public:
CSetSizeCB(IHXSite* pSite)
: m_lRefCount(0)
, m_pSite(pSite)
{
HX_ASSERT(m_pSite);
m_pSite->AddRef();
m_szViewFrame.cx = 0;
m_szViewFrame.cy = 0;
}
~CSetSizeCB()
{
HX_RELEASE(m_pSite);
}
STDMETHOD(QueryInterface) (THIS_
REFIID riid,
void** ppvObj);
STDMETHOD_(ULONG32,AddRef) (THIS);
STDMETHOD_(ULONG32,Release) (THIS);
STDMETHOD(Func) (THIS);
void SetSize(HXxSize szViewFrame)
{
m_szViewFrame = szViewFrame;
}
private:
LONG32 m_lRefCount;
IHXSite* m_pSite;
HXxSize m_szViewFrame;
};
typedef enum
{
Stopped,
Buffering,
PlayStarting,
Playing,
Paused,
Seeking
} PlayState;
static const char* const zm_pDescription;
static const char* const zm_pCopyright;
static const char* const zm_pMoreInfoURL;
static const char* const zm_pStreamMimeTypes[];
LONG32 m_lRefCount;
HXMutex* m_pMutex;
HXMutex* m_pBltMutex;
HXMutex* m_pVSMutex;
IHXScheduler* m_pScheduler;
IHXOptimizedScheduler* m_pOptimizedScheduler;
IHXPaceMaker* m_pDecoderPump;
IHXPaceMaker* m_pBltrPump;
ULONG32 m_ulDecoderPacemakerId;
ULONG32 m_ulBltrPacemakerId;
LONG32 m_lDecodePriority;
CVideoFormat* m_pDecoderVideoFormat;
CVideoFormat* m_pBltrVideoFormat;
#if defined(HELIX_FEATURE_STATS)
CVideoStatistics* m_pVideoStats;
#else
void* m_pVideoStats;
#endif /* HELIX_FEATURE_STATS */
ULONG32 m_lTimeLineOffset;
ULONG32 m_ulStreamBaseTime;
ULONG32 m_ulBaseTime;
ULONG32 m_ulTimeNormalizationOffset;
BOOL m_bIsScheduledCB;
ULONG32 m_ulLateFrameTol;
ULONG32 m_ulEarlyFrameTol;
ULONG32 m_ulMaxOptimizedVideoLead;
ULONG32 m_ulNoFramesPollingInterval;
ULONG32 m_ulMaxSleepTime;
ULONG32 m_ulBltPacketQueueSize;
BOOL m_bSchedulerStartRequested;
BOOL m_bPendingCallback;
CallbackHandle m_hPendingHandle;
ULONG32 m_ulCallbackCounter;
BOOL m_bSiteAttached;
BOOL m_bDecoderRunning;
PlayState m_PlayState;
ULONG32 m_ulBytesToBuffer;
ULONG32 m_ulAvgBitRate;
ULONG32 m_ulPreroll;
ULONG32 m_ulBufferingStartTime;
ULONG32 m_ulBufferingStopTime;
ULONG32 m_ulBufferingTimeOut;
BOOL m_bBufferingOccured;
BOOL m_bBufferingNeeded;
BOOL m_bFirstFrame;
BOOL m_bBaseTimeSet;
BOOL m_bFirstSurfaceUpdate;
BOOL m_bPendingRedraw;
BOOL m_bVS1UpdateInProgress;
HXBitmapInfoHeader m_BitmapInfoHeader;
HXBitmapInfoHeader* m_pVSurf2InputBIH;
CRingBuffer* m_pBltPacketQueue;
protected:
BOOL m_bBitmapSet;
private:
BOOL m_bFrameSizeInitialized;
BOOL m_bWinSizeFixed;
BOOL m_bOptimizedBlt;
BOOL m_bOSGranuleBoost;
BOOL m_bOSGranuleBoostVS2;
BOOL m_bTryVideoSurface2;
BOOL m_bUseVideoSurface2;
BOOL m_bVideoSurface2Transition;
BOOL m_bVideoSurface1Requested;
BOOL m_bVideoSurfaceInitialized;
BOOL m_bVideoSurfaceReinitRequested;
BOOL m_bVS2BufferUnavailableOnLastBlt;
BOOL m_bPresentInProgress;
ULONG32 m_ulHWBufCount;
ULONG32 m_ulConfigHWBufCount;
ULONG32 m_ulSyncInterval;
ULONG32 m_ulSyncSmoothingDepth;
ULONG32 m_ulSyncGoalSmoothingDepth;
ULONG32 m_ulSpeedupGoalSmoothingDepth;
ULONG32 m_ulBadSeqSampleCount;
ULONG32 m_ulGoodSeqSampleCount;
ULONG32 m_ulMaxBadSeqSamples;
double m_fTrendSyncDelta;
HXxSize m_SetWinSize;
HXxSize m_LastSetSize;
HXxRect* m_pClipRect;
HXxRect m_rViewRect;
CSetSizeCB* m_pResizeCB;
void Render(BOOL bMarker, BYTE* pData, ULONG32 ulSize, BOOL bLate);
HX_RESULT CheckStreamVersions (IHXValues* pHeader);
BOOL _ResizeViewFrame(HXxSize szViewFrame,
BOOL bMutex,
BOOL bForceSyncResize,
BOOL bDefaultResize);
HX_RESULT UpdateDisplay(HXxEvent* pEvent,
BOOL bSystemEvent = FALSE,
BOOL bIsVisible = TRUE);
protected:
HX_RESULT UpdateVideoSurface(IHXVideoSurface* pVideoSurface,
CMediaPacket* pVideoPacket,
HXxRect &destRect,
HXxRect &sorcRect,
BOOL bOptimizedBlt);
HX_RESULT UpdateVideoSurface2(IHXVideoSurface* pVideoSurface,
HXxRect &destRect,
HXxRect &sorcRect,
BOOL bRefresh,
BOOL bSystemEvent);
private:
HX_RESULT FlushVideoSurface2(IHXSite* pSite);
inline HX_RESULT SwitchToVideoSurface1(void);
inline HX_RESULT SwitchToVideoSurface2(void);
BOOL ForceRefresh(void);
void ForceDisplayUpdate(BOOL bInternalSurfaceUpdateOnly = FALSE,
BOOL bHasVisibleSurface = TRUE);
inline HX_RESULT ForceDisplayUpdateOnSite(IHXSite* pSite,
BOOL bInternalSurfaceUpdateOnly,
BOOL bHasVisibleSurface);
void PresentFrame(void);
HX_RESULT InitVideoSurface1(BOOL bUsedVideoSurface2,
IHXVideoSurface* pVideoSurface = NULL);
HX_RESULT InitVideoSurface2(ULONG32 ulWidth, ULONG32 ulHeight);
HX_RESULT StartSchedulers(void);
inline BOOL ShouldKickStartScheduler();
HX_RESULT ScheduleCallback(UINT32 ulRelativeTime,
BOOL bIsScheduled = FALSE,
UINT32 ulBaseTime = 0);
void SchedulerCallback(BOOL bIsScheduled,
BOOL bResched = TRUE,
BOOL bIsVS2Call = FALSE,
BOOL bProcessUndisplayableFramesOnly = FALSE);
inline CallbackHandle ScheduleRelativeCallback(UINT32 ulRelativeTime,
IHXCallback* pCallback);
inline CallbackHandle ScheduleAbsoluteCallback(HXTimeval &hxTime,
IHXCallback* pCallback);
void RemoveCallback(CallbackHandle &hCallback);
HX_RESULT BeginOptimizedBlt(HXBitmapInfoHeader* pBitmapInfo);
void EndOptimizedBlt(void);
inline void RequestBuffering(void);
inline void RequestBufferingEnd(void);
HX_RESULT BeginBuffering(void);
HX_RESULT EndBuffering(void);
inline BOOL IsBufferingComplete(IHXPacket* pPacket = NULL);
void ReleasePacket(CMediaPacket* pPacket,
BOOL bForceKill = FALSE);
void ClearBltPacketQueue(void);
BOOL IsDecoderRunning(void) { return m_bDecoderRunning; }
HX_RESULT OnDecoderStart(void);
HX_RESULT OnDecoderEnd(void);
BOOL OnDecode(void);
void DisplayMutex_Lock(void)
{
m_pBltMutex->Lock();
m_pVSMutex->Lock();
}
void DisplayMutex_Unlock(void)
{
m_pVSMutex->Unlock();
m_pBltMutex->Unlock();
}
protected:
CVideoFormat* m_pVideoFormat;
public:
/*
* Costructor
*/
CVideoRenderer(void);
/*
* Destructor
*/
virtual ~CVideoRenderer();
/*
* IUnknown methods
*/
STDMETHOD(QueryInterface) (THIS_
REFIID riid,
void** ppvObj);
STDMETHOD_(ULONG32,AddRef) (THIS);
STDMETHOD_(ULONG32,Release) (THIS);
/*
* IHXPlugin methods
*/
/************************************************************************
* Method:
* IHXPlugin::GetPluginInfo
* Purpose:
* Returns the basic information about this plugin. Including:
*
* bLoadMultiple whether or not this plugin DLL can be loaded
* multiple times. All File Formats must set
* this value to TRUE.
* pDescription which is used in about UIs (can be NULL)
* pCopyright which is used in about UIs (can be NULL)
* pMoreInfoURL which is used in about UIs (can be NULL)
*/
STDMETHOD(GetPluginInfo) (THIS_
REF(BOOL) /*OUT*/ bLoadMultiple,
REF(const char*) /*OUT*/ pDescription,
REF(const char*) /*OUT*/ pCopyright,
REF(const char*) /*OUT*/ pMoreInfoURL,
REF(ULONG32) /*OUT*/ ulVersionNumber
);
/************************************************************************
* Method:
* IHXPlugin::InitPlugin
* Purpose:
* Initializes the plugin for use. This interface must always be
* called before any other method is called. This is primarily needed
* so that the plugin can have access to the context for creation of
* IHXBuffers and IMalloc.
*/
STDMETHOD(InitPlugin) (THIS_
IUnknown* /*IN*/ pContext);
/*
* IHXRenderer methods
*/
/************************************************************************
* Method:
* IHXRenderer::GetRendererInfo
* Purpose:
* Returns information vital to the instantiation of rendering
* plugins.
*/
STDMETHOD(GetRendererInfo) (THIS_
REF(const char**) /*OUT*/ pStreamMimeTypes,
REF(UINT32) /*OUT*/ unInitialGranularity
);
/////////////////////////////////////////////////////////////////////////
// Method:
// IHXRenderer::StartStream
// Purpose:
// Called by client engine to inform the renderer of the stream it
// will be rendering. The stream interface can provide access to
// its source or player. This method also provides access to the
// primary client controller interface.
//
STDMETHOD (StartStream) (THIS_
IHXStream* pStream,
IHXPlayer* pPlayer);
/////////////////////////////////////////////////////////////////////////
// Method:
// IHXRenderer::EndStream
// Purpose:
// Called by client engine to inform the renderer that the stream
// is was rendering is closed.
//
STDMETHOD (EndStream) (THIS);
/////////////////////////////////////////////////////////////////////////
// Method:
// IHXRenderer::OnHeader
// Purpose:
// Called by client engine when a header for this renderer is
// available. The header will arrive before any packets.
//
STDMETHOD (OnHeader) (THIS_
IHXValues* pHeader);
/////////////////////////////////////////////////////////////////////////
// Method:
// IHXRenderer::OnPacket
// Purpose:
// Called by client engine when a packet for this renderer is
// due.
//
STDMETHOD (OnPacket) (THIS_
IHXPacket* pPacket,
LONG32 lTimeOffset);
/////////////////////////////////////////////////////////////////////////
// Method:
// IHXRenderer::OnTimeSync
// Purpose:
// Called by client engine to inform the renderer of the current
// time relative to the streams synchronized time-line. The
// renderer should use this time value to update its display or
// render it's stream data accordingly.
//
STDMETHOD (OnTimeSync) (THIS_
ULONG32 ulTime);
/////////////////////////////////////////////////////////////////////////
// Method:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -