//
// CDXGraph.cpp
//
/*-----------------------------------------------------*\
HQ Tech, Make Technology Easy!
More information, please go to http://hqtech.nease.net.
/*-----------------------------------------------------*/
#include "stdafx.h"
#include "CDXGraph.h"
#include "GlobalDefs.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
////////////////////////////////////////////////////////////////////////////////
CDXGraph::CDXGraph()
{
mGraph = NULL;
mMediaControl = NULL;
mEvent = NULL;
mBasicVideo = NULL;
mBasicAudio = NULL;
mVideoWindow = NULL;
mSeeking = NULL;
mObjectTableEntry = 0;
mGraphState = GS_Stopped;
}
CDXGraph::~CDXGraph()
{
Release();
}
BOOL CDXGraph::Create(void)
{
if (!mGraph)
{
if (SUCCEEDED(CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
IID_IGraphBuilder, (void **)&mGraph)))
{
AddToObjectTable();
return QueryInterfaces();
}
mGraph = NULL;
}
return FALSE;
}
BOOL CDXGraph::QueryInterfaces(void)
{
if (mGraph)
{
HRESULT hr = NOERROR;
hr |= mGraph->QueryInterface(IID_IMediaControl, (void **)&mMediaControl);
hr |= mGraph->QueryInterface(IID_IMediaEventEx, (void **)&mEvent);
hr |= mGraph->QueryInterface(IID_IBasicVideo, (void **)&mBasicVideo);
hr |= mGraph->QueryInterface(IID_IBasicAudio, (void **)&mBasicAudio);
hr |= mGraph->QueryInterface(IID_IVideoWindow, (void **)&mVideoWindow);
hr |= mGraph->QueryInterface(IID_IMediaSeeking, (void **)&mSeeking);
if (mSeeking)
{
mSeeking->SetTimeFormat(&TIME_FORMAT_MEDIA_TIME);
}
return SUCCEEDED(hr);
}
return FALSE;
}
void CDXGraph::Release(void)
{
if (mSeeking)
{
mSeeking->Release();
mSeeking = NULL;
}
if (mMediaControl)
{
mMediaControl->Release();
mMediaControl = NULL;
}
if (mEvent)
{
mEvent->Release();
mEvent = NULL;
}
if (mBasicVideo)
{
mBasicVideo->Release();
mBasicVideo = NULL;
}
if (mBasicAudio)
{
mBasicAudio->Release();
mBasicAudio = NULL;
}
if (mVideoWindow)
{
mVideoWindow->put_Visible(OAFALSE);
mVideoWindow->put_MessageDrain((OAHWND)NULL);
mVideoWindow->put_Owner(OAHWND(0));
mVideoWindow->Release();
mVideoWindow = NULL;
}
RemoveFromObjectTable();
if (mGraph)
{
mGraph->Release();
mGraph = 0;
}
}
BOOL CDXGraph::Attach(IGraphBuilder * inGraphBuilder)
{
Release();
if (inGraphBuilder)
{
mGraph = inGraphBuilder;
mGraph->AddRef();
AddToObjectTable();
return QueryInterfaces();
}
return TRUE;
}
IGraphBuilder * CDXGraph::GetGraph(void)
{
return mGraph;
}
BOOL CDXGraph::AddFilter(IBaseFilter * inFilter, LPCWSTR inName)
{
if (mGraph)
{
HRESULT hr = mGraph->AddFilter(inFilter, inName);
return SUCCEEDED(hr);
}
return FALSE;
}
// Connect filter from the upstream output pin to the downstream input pin
BOOL CDXGraph::ConnectFilters(IPin * inOutputPin, IPin * inInputPin,
const AM_MEDIA_TYPE * inMediaType)
{
if (mGraph && inOutputPin && inInputPin)
{
HRESULT hr = mGraph->ConnectDirect(inOutputPin, inInputPin, inMediaType);
return SUCCEEDED(hr) ? TRUE : FALSE;
}
return FALSE;
}
void CDXGraph::DisconnectFilters(IPin * inOutputPin)
{
if (mGraph && inOutputPin)
{
HRESULT hr = mGraph->Disconnect(inOutputPin);
}
}
BOOL CDXGraph::SetDisplayWindow(HWND inWindow)
{
if (mVideoWindow)
{
// long lVisible;
// mVideoWindow->get_Visible(&lVisible);
// Hide the video window first
mVideoWindow->put_Visible(OAFALSE);
mVideoWindow->put_Owner((OAHWND)inWindow);
RECT windowRect;
::GetClientRect(inWindow, &windowRect);
mVideoWindow->put_Left(0);
mVideoWindow->put_Top(0);
mVideoWindow->put_Width(windowRect.right - windowRect.left);
mVideoWindow->put_Height(windowRect.bottom - windowRect.top);
mVideoWindow->put_WindowStyle(WS_CHILD|WS_CLIPCHILDREN|WS_CLIPSIBLINGS);
mVideoWindow->put_MessageDrain((OAHWND) inWindow);
// Restore the video window
if (inWindow != NULL)
{
// mVideoWindow->put_Visible(lVisible);
mVideoWindow->put_Visible(OATRUE);
}
else
{
mVideoWindow->put_Visible(OAFALSE);
}
return TRUE;
}
return FALSE;
}
BOOL CDXGraph::ResizeVideoWindow(long inLeft, long inTop, long inWidth, long inHeight)
{
if (mVideoWindow)
{
long lVisible = OATRUE;
mVideoWindow->get_Visible(&lVisible);
// Hide the video window first
mVideoWindow->put_Visible(OAFALSE);
mVideoWindow->put_Left(inLeft);
mVideoWindow->put_Top(inTop);
mVideoWindow->put_Width(inWidth);
mVideoWindow->put_Height(inHeight);
// Restore the video window
mVideoWindow->put_Visible(lVisible);
return TRUE;
}
return FALSE;
}
BOOL CDXGraph::SetNotifyWindow(HWND inWindow)
{
if (mEvent)
{
mEvent->SetNotifyWindow((OAHWND)inWindow, WM_GRAPHNOTIFY, 0);
return TRUE;
}
return FALSE;
}
void CDXGraph::HandleEvent(WPARAM inWParam, LPARAM inLParam)
{
if (mEvent)
{
LONG eventCode = 0, eventParam1 = 0, eventParam2 = 0;
while (SUCCEEDED(mEvent->GetEvent(&eventCode, &eventParam1, &eventParam2, 0)))
{
mEvent->FreeEventParams(eventCode, eventParam1, eventParam2);
switch (eventCode)
{
case EC_COMPLETE:
case EC_USERABORT:
case EC_ERRORABORT:
Broadcast(msg_FilterGraphError);
break;
case EC_DEVICE_LOST:
// As a result, windows will process device lost event first.
// We needn't process this event in DirectShow any more.
if (eventParam2 == 0)
{
// Broadcast(msg_DShowDeviceLost, &eventParam1);
}
break;
default:
break;
}
}
}
}
BOOL CDXGraph::Run(void)
{
if (mGraph && mMediaControl)
{
if (!IsRunning())
{
if (SUCCEEDED(mMediaControl->Run()))
{
mGraphState = GS_Running;
return TRUE;
}
}
else
{
return TRUE;
}
}
return FALSE;
}
BOOL CDXGraph::Stop(void)
{
if (mGraph && mMediaControl)
{
if (!IsStopped())
{
if (SUCCEEDED(mMediaControl->Stop()))
{
mGraphState = GS_Stopped;
return TRUE;
}
}
else
{
return TRUE;
}
}
return FALSE;
}
BOOL CDXGraph::Pause(void)
{
if (mGraph && mMediaControl)
{
if (!IsPaused())
{
if (SUCCEEDED(mMediaControl->Pause()))
{
mGraphState = GS_Paused;
return TRUE;
}
}
else
{
return TRUE;
}
}
return FALSE;
}
BOOL CDXGraph::IsRunning(void)
{
/* if (mGraph && mMediaControl)
{
OAFilterState state = State_Stopped;
if (SUCCEEDED(mMediaControl->GetState(10, &state)))
{
return state == State_Running;
}
}
return FALSE;*/
return (mGraphState == GS_Running);
}
BOOL CDXGraph::IsStopped(void)
{
/* if (mGraph && mMediaControl)
{
OAFilterState state = State_Stopped;
if (SUCCEEDED(mMediaControl->GetState(10, &state)))
{
return state == State_Stopped;
}
}
return FALSE;*/
return (mGraphState == GS_Stopped);
}
BOOL CDXGraph::IsPaused(void)
{
/* if (mGraph && mMediaControl)
{
OAFilterState state = State_Stopped;
if (SUCCEEDED(mMediaControl->GetState(10, &state)))
{
return state == State_Paused;
}
}
return FALSE;*/
return (mGraphState == GS_Paused);
}
BOOL CDXGraph::SetFullScreen(BOOL inEnabled)
{
if (mVideoWindow)
{
HRESULT hr = mVideoWindow->put_FullScreenMode(inEnabled ? OATRUE : OAFALSE);
return SUCCEEDED(hr);
}
return FALSE;
}
BOOL CDXGraph::GetFullScreen(void)
{
if (mVideoWindow)
{
long fullScreenMode = OAFALSE;
mVideoWindow->get_FullScreenMode(&fullScreenMode);
return (fullScreenMode == OATRUE);
}
return FALSE;
}
BOOL CDXGraph::SetSyncSource(IBaseFilter * inFilter)
{
if (inFilter)
{
IReferenceClock *pClock = 0;
inFilter->QueryInterface(IID_IReferenceClock, (void**)&pClock);
if (pCloc
没有合适的资源?快使用搜索试试~ 我知道了~
C++ 视频聊天源码
共67个文件
h:31个
cpp:29个
rc:1个
5星 · 超过95%的资源 需积分: 10 156 下载量 108 浏览量
2009-04-24
12:11:23
上传
评论 1
收藏 180KB RAR 举报
温馨提示
VC++ 环境下开发,包括压缩传输和解压过程 ,
资源推荐
资源详情
资源评论
收起资源包目录
.rar (67个子文件)
AVChat
CSelfCheckDlg.cpp 3KB
CServerAdmin.h 539B
CVideoCaptureFilter2.cpp 4KB
AVChat.opt 348KB
Filters
CNetOutPin.cpp 3KB
CNetOutPin.h 754B
CFilterNetSender.cpp 2KB
CFilterNetReceiver.h 1KB
CXInputPin.cpp 3KB
CFilterNetReceiver.cpp 3KB
CFilterNetSender.h 765B
CXInputPin.h 1000B
CPreviewAdmin.h 1KB
StdAfx.cpp 208B
resource.h 1KB
AVChat.ncb 89KB
CMsgStation.cpp 2KB
CMsgStation.h 814B
CRoleAdmin.cpp 11KB
CRoleDlg.h 1KB
CVideoWindow.h 967B
CAudioCaptureFilter2.cpp 6KB
CRoleDlg.cpp 1KB
UFilterUtils.h 857B
CObjectList.h 460B
AVChat.rc 7KB
CDXGraph.cpp 13KB
UFilterUtils.cpp 5KB
AVChat.h 1KB
CAudioCaptureFilter2.h 1KB
CClientAdmin.h 598B
UDsUtils.h 695B
AVChatDlg.cpp 6KB
AVChatDlg.h 2KB
AVChat.cpp 2KB
CDXGraph.h 2KB
CPreviewAdmin.cpp 6KB
Debug
CMsgReceiver.h 569B
StdAfx.h 1KB
GlobalDefs.h 3KB
UDsUtils.cpp 7KB
CAVDevice.cpp 2KB
CServerAdmin.cpp 2KB
CClientAdmin.cpp 2KB
Network
CTCPListener.h 894B
CUDPManager.h 1KB
UNetwork.cpp 4KB
CUDPManager.cpp 5KB
CStreamSocket.h 1KB
CStreamSocket.cpp 5KB
UNetwork.h 271B
CTCPListener.cpp 5KB
CVideoCaptureFilter2.h 722B
CRoleAdmin.h 2KB
CAVDevice.h 863B
CObjectList.cpp 1KB
CMsgReceiver.cpp 1KB
res
AVChat.rc2 398B
AVChat.ico 1KB
CVideoWindow.cpp 2KB
CCallDlg.cpp 1KB
CCallDlg.h 1KB
CSelfCheckDlg.h 2KB
AVChat.dsw 537B
CDXFilter.h 961B
CDXFilter.cpp 2KB
AVChat.dsp 9KB
共 67 条
- 1
huangjinyin
- 粉丝: 3
- 资源: 13
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页