//------------------------------------------------------------------------------
// File: AMFilter.cpp
//
// Desc: DirectShow base classes - implements class hierarchy for streams
// architecture.
//
// Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------
//=====================================================================
//=====================================================================
// The following classes are declared in this header:
//
//
// CBaseMediaFilter Basic IMediaFilter support (abstract class)
// CBaseFilter Support for IBaseFilter (incl. IMediaFilter)
// CEnumPins Enumerate input and output pins
// CEnumMediaTypes Enumerate the preferred pin formats
// CBasePin Abstract base class for IPin interface
// CBaseOutputPin Adds data provider member functions
// CBaseInputPin Implements IMemInputPin interface
// CMediaSample Basic transport unit for IMemInputPin
// CBaseAllocator General list guff for most allocators
// CMemAllocator Implements memory buffer allocation
//
//=====================================================================
//=====================================================================
#include <streams.h>
#include <strsafe.h>
#ifdef DXMPERF
#include "dxmperf.h"
#endif // DXMPERF
//=====================================================================
// Helpers
//=====================================================================
STDAPI CreateMemoryAllocator(__deref_out IMemAllocator **ppAllocator)
{
return CoCreateInstance(CLSID_MemoryAllocator,
0,
CLSCTX_INPROC_SERVER,
IID_IMemAllocator,
(void **)ppAllocator);
}
// Put this one here rather than in ctlutil.cpp to avoid linking
// anything brought in by ctlutil.cpp
STDAPI CreatePosPassThru(
__in_opt LPUNKNOWN pAgg,
BOOL bRenderer,
IPin *pPin,
__deref_out IUnknown **ppPassThru
)
{
*ppPassThru = NULL;
IUnknown *pUnkSeek;
HRESULT hr = CoCreateInstance(CLSID_SeekingPassThru,
pAgg,
CLSCTX_INPROC_SERVER,
IID_IUnknown,
(void **)&pUnkSeek
);
if (FAILED(hr)) {
return hr;
}
ISeekingPassThru *pPassThru;
hr = pUnkSeek->QueryInterface(IID_ISeekingPassThru, (void**)&pPassThru);
if (FAILED(hr)) {
pUnkSeek->Release();
return hr;
}
hr = pPassThru->Init(bRenderer, pPin);
pPassThru->Release();
if (FAILED(hr)) {
pUnkSeek->Release();
return hr;
}
*ppPassThru = pUnkSeek;
return S_OK;
}
#define CONNECT_TRACE_LEVEL 3
//=====================================================================
//=====================================================================
// Implements CBaseMediaFilter
//=====================================================================
//=====================================================================
/* Constructor */
CBaseMediaFilter::CBaseMediaFilter(__in_opt LPCTSTR pName,
__inout_opt LPUNKNOWN pUnk,
__in CCritSec *pLock,
REFCLSID clsid) :
CUnknown(pName, pUnk),
m_pLock(pLock),
m_clsid(clsid),
m_State(State_Stopped),
m_pClock(NULL)
{
}
/* Destructor */
CBaseMediaFilter::~CBaseMediaFilter()
{
// must be stopped, but can't call Stop here since
// our critsec has been destroyed.
/* Release any clock we were using */
if (m_pClock) {
m_pClock->Release();
m_pClock = NULL;
}
}
/* Override this to say what interfaces we support and where */
STDMETHODIMP
CBaseMediaFilter::NonDelegatingQueryInterface(
REFIID riid,
__deref_out void ** ppv)
{
if (riid == IID_IMediaFilter) {
return GetInterface((IMediaFilter *) this, ppv);
} else if (riid == IID_IPersist) {
return GetInterface((IPersist *) this, ppv);
} else {
return CUnknown::NonDelegatingQueryInterface(riid, ppv);
}
}
/* Return the filter's clsid */
STDMETHODIMP
CBaseMediaFilter::GetClassID(__out CLSID *pClsID)
{
CheckPointer(pClsID,E_POINTER);
ValidateReadWritePtr(pClsID,sizeof(CLSID));
*pClsID = m_clsid;
return NOERROR;
}
/* Override this if your state changes are not done synchronously */
STDMETHODIMP
CBaseMediaFilter::GetState(DWORD dwMSecs, __out FILTER_STATE *State)
{
UNREFERENCED_PARAMETER(dwMSecs);
CheckPointer(State,E_POINTER);
ValidateReadWritePtr(State,sizeof(FILTER_STATE));
*State = m_State;
return S_OK;
}
/* Set the clock we will use for synchronisation */
STDMETHODIMP
CBaseMediaFilter::SetSyncSource(__inout_opt IReferenceClock *pClock)
{
CAutoLock cObjectLock(m_pLock);
// Ensure the new one does not go away - even if the same as the old
if (pClock) {
pClock->AddRef();
}
// if we have a clock, release it
if (m_pClock) {
m_pClock->Release();
}
// Set the new reference clock (might be NULL)
// Should we query it to ensure it is a clock? Consider for a debug build.
m_pClock = pClock;
return NOERROR;
}
/* Return the clock we are using for synchronisation */
STDMETHODIMP
CBaseMediaFilter::GetSyncSource(__deref_out_opt IReferenceClock **pClock)
{
CheckPointer(pClock,E_POINTER);
ValidateReadWritePtr(pClock,sizeof(IReferenceClock *));
CAutoLock cObjectLock(m_pLock);
if (m_pClock) {
// returning an interface... addref it...
m_pClock->AddRef();
}
*pClock = (IReferenceClock*)m_pClock;
return NOERROR;
}
/* Put the filter into a stopped state */
STDMETHODIMP
CBaseMediaFilter::Stop()
{
CAutoLock cObjectLock(m_pLock);
m_State = State_Stopped;
return S_OK;
}
/* Put the filter into a paused state */
STDMETHODIMP
CBaseMediaFilter::Pause()
{
CAutoLock cObjectLock(m_pLock);
m_State = State_Paused;
return S_OK;
}
// Put the filter into a running state.
// The time parameter is the offset to be added to the samples'
// stream time to get the reference time at which they should be presented.
//
// you can either add these two and compare it against the reference clock,
// or you can call CBaseMediaFilter::StreamTime and compare that against
// the sample timestamp.
STDMETHODIMP
CBaseMediaFilter::Run(REFERENCE_TIME tStart)
{
CAutoLock cObjectLock(m_pLock);
// remember the stream time offset
m_tStart = tStart;
if (m_State == State_Stopped){
HRESULT hr = Pause();
if (FAILED(hr)) {
return hr;
}
}
m_State = State_Running;
return S_OK;
}
//
// return the current stream time - samples with start timestamps of this
// time or before should be rendered by now
HRESULT
CBaseMediaFilter::StreamTime(CRefTime& rtStream)
{
// Caller must lock for synchronization
// We can't grab the filter lock because we want to be able to call
// this from worker threads without deadlocking
if (m_pClock == NULL) {
return VFW_E_NO_CLOCK;
}
// get the current reference time
HRESULT hr = m_pClock->GetTime((REFERENCE_TIME*)&rtStream);
if (FAILED(hr)) {
return hr;
}
// subtract the stream offset to get stream time
rtStream -= m_tStart;
return S_OK;
}
//=====================================================================
//=====================================================================
// Implements CBaseFilter
//=====================================================================
//=====================================================================
/* Override this to say what interfaces we
没有合适的资源?快使用搜索试试~ 我知道了~
dx-sdk(x86+x64版本)
共360个文件
obj:155个
h:74个
cpp:62个
需积分: 6 0 下载量 106 浏览量
2022-11-26
23:48:44
上传
评论
收藏 11.21MB RAR 举报
温馨提示
编译好的dx-sdk(x86+x64版本),可以直接使用。
资源推荐
资源详情
资源评论
收起资源包目录
dx-sdk(x86+x64版本) (360个子文件)
amfilter.cpp 150KB
amfilter.cpp 150KB
renbase.cpp 94KB
renbase.cpp 94KB
winutil.cpp 91KB
winutil.cpp 91KB
winctrl.cpp 65KB
winctrl.cpp 65KB
ctlutil.cpp 52KB
ctlutil.cpp 52KB
wxdebug.cpp 47KB
wxdebug.cpp 47KB
transip.cpp 33KB
transip.cpp 33KB
transfrm.cpp 27KB
transfrm.cpp 27KB
wxlist.cpp 24KB
wxlist.cpp 24KB
outputq.cpp 23KB
outputq.cpp 23KB
videoctl.cpp 22KB
videoctl.cpp 22KB
wxutil.cpp 19KB
wxutil.cpp 19KB
dllsetup.cpp 17KB
dllsetup.cpp 17KB
vtrans.cpp 17KB
vtrans.cpp 17KB
refclock.cpp 12KB
refclock.cpp 12KB
strmctl.cpp 12KB
strmctl.cpp 12KB
source.cpp 12KB
source.cpp 12KB
mtype.cpp 11KB
mtype.cpp 11KB
pullpin.cpp 11KB
pullpin.cpp 11KB
arithutil.cpp 10KB
arithutil.cpp 10KB
cprop.cpp 10KB
cprop.cpp 10KB
dllentry.cpp 9KB
dllentry.cpp 9KB
amvideo.cpp 9KB
amvideo.cpp 9KB
perflog.cpp 8KB
perflog.cpp 8KB
schedule.cpp 7KB
schedule.cpp 7KB
combase.cpp 7KB
combase.cpp 7KB
pstream.cpp 5KB
pstream.cpp 5KB
ddmm.cpp 3KB
ddmm.cpp 3KB
amextra.cpp 3KB
amextra.cpp 3KB
seekpt.cpp 2KB
seekpt.cpp 2KB
sysclock.cpp 2KB
sysclock.cpp 2KB
BaseClasses.vcxproj.filters 7KB
BaseClasses.vcxproj.filters 7KB
amfilter.h 56KB
amfilter.h 56KB
ctlutil.h 27KB
ctlutil.h 27KB
renbase.h 20KB
renbase.h 20KB
wxlist.h 19KB
wxlist.h 19KB
winutil.h 16KB
winutil.h 16KB
wxutil.h 15KB
wxutil.h 15KB
wxdebug.h 12KB
wxdebug.h 12KB
winctrl.h 10KB
winctrl.h 10KB
combase.h 10KB
combase.h 10KB
dxmperf.h 10KB
dxmperf.h 10KB
transfrm.h 9KB
transfrm.h 9KB
transip.h 8KB
transip.h 8KB
measure.h 8KB
measure.h 8KB
videoctl.h 7KB
videoctl.h 7KB
refclock.h 7KB
refclock.h 7KB
streams.h 7KB
streams.h 7KB
perfstruct.h 7KB
perfstruct.h 7KB
vtrans.h 6KB
vtrans.h 6KB
共 360 条
- 1
- 2
- 3
- 4
资源评论
西部秋虫
- 粉丝: 929
- 资源: 36
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功