//------------------------------------------------------------------------------
// 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;
}
//====================================================================
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
可直接编译。先编译baseclasses,再编译vcam。 baseclasses从win7 sdk中直接提取,vcam来自TMH大牛网站http://tmhare.mvps.org/downloads.htm(虽然这个不是他写的) 免积分下载runapp.ys168.com
资源推荐
资源详情
资源评论
收起资源包目录
VCam_VS2017.7z (81个子文件)
baseclasses
wxutil.h 16KB
winutil.cpp 94KB
baseclasses.vcproj 15KB
wxdebug.h 12KB
reftime.h 3KB
amextra.cpp 3KB
ctlutil.cpp 54KB
perfstruct.h 7KB
outputq.h 5KB
winctrl.cpp 67KB
combase.h 10KB
strmctl.cpp 13KB
vtrans.cpp 17KB
schedule.h 4KB
fourcc.h 2KB
streams.h 7KB
ddmm.cpp 3KB
combase.cpp 8KB
measure.h 8KB
outputq.cpp 24KB
wxdebug.cpp 48KB
wxutil.cpp 20KB
dllsetup.h 1KB
amfilter.cpp 155KB
checkbmi.h 4KB
source.cpp 12KB
schedule.cpp 8KB
videoctl.cpp 23KB
dllentry.cpp 10KB
winutil.h 17KB
wxlist.h 20KB
transip.cpp 34KB
ddmm.h 989B
amextra.h 2KB
baseclasses.sln 2KB
refclock.h 8KB
renbase.cpp 97KB
sysclock.h 1KB
source.h 6KB
strmctl.h 6KB
cache.h 3KB
cprop.cpp 10KB
winctrl.h 10KB
wxlist.cpp 25KB
transfrm.h 10KB
renbase.h 21KB
amfilter.h 57KB
perflog.cpp 8KB
perflog.h 1KB
cprop.h 4KB
BaseClasses.vcxproj 18KB
mtype.cpp 12KB
msgthrd.h 4KB
BaseClasses.vcxproj.filters 7KB
dllsetup.cpp 18KB
pstream.cpp 5KB
vtrans.h 7KB
pullpin.h 4KB
videoctl.h 8KB
amvideo.cpp 9KB
sysclock.cpp 2KB
ctlutil.h 28KB
pullpin.cpp 11KB
transfrm.cpp 28KB
mtype.h 3KB
arithutil.cpp 10KB
refclock.cpp 13KB
seekpt.cpp 3KB
pstream.h 4KB
transip.h 9KB
seekpt.h 887B
dxmperf.h 10KB
Bin
VCam.ax 41KB
VCam
Filters.cpp 11KB
dshow.props 446B
Filters.dsp 4KB
Filters.h 3KB
Filters.def 255B
Filters.vcxproj 8KB
Dll.cpp 4KB
Filters.sln 1KB
共 81 条
- 1
fkcs_n
- 粉丝: 0
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于STM8S103F3P6+STM8S207C8T6+STM32F103 单片机三合一最小系统开发板硬件(原理图+PCB)工程
- 基于C语言实现的打印杨辉三角
- 基于ASIO的插件式服务器,支持TCP,UDP,串口,Http,Websocket统一化的数据接口,隔离开发人员和IO之间的操作
- stm32 usb接口通信
- Chessmate是一款完全免费的国际象棋学习软件,支持引擎分析,学开局、残局、棋书解读、大数据分析等功能
- 总结整理的Android面试Java基础知识点面试资料精编汇总文档资料合集.zip
- .android_lq
- FDN5632N-VB一款SOT23封装N-Channel场效应MOS管
- 毛老板-2404250902.amr
- Java类加载流程(双亲委派)流程图.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页