Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
StdAfx.cpp
Package: WebCamVideo.zip [view]
Upload User: shining60
Upload Date: 2017-05-30
Package Size: 4714k
Code Size: 3k
Category:
Video Capture
Development Platform:
Visual C++
- // stdafx.cpp : source file that includes just the standard includes
- // capUsbVideo.pch will be the pre-compiled header
- // stdafx.obj will contain the pre-compiled type information
- //by edson
- //
- #include "stdafx.h"
- // TODO: reference any additional headers you need in STDAFX.H
- // and not in this file
- USB_VIDEO::USB_VIDEO(){
- pg = NULL; //graph builder
- pde = NULL; //device list
- pvde = NULL; //video Device enum
- pvd = NULL; //video device
- pvr = NULL; //base filter MJPG expected...
- pip = NULL; //input
- pop = NULL; //output
- pvc = NULL; //Video capturer
- pwc = NULL;
- }
- USB_VIDEO::~USB_VIDEO(){
- }
- HWND USB_VIDEO::gethandle(void){
- return 0;
- }
- void USB_VIDEO::StartDevice(HWND mwin){
- if (!mwin) return;
- myHwnd = mwin; //main window handle;
- Start();
- }
- BOOL USB_VIDEO::Start(void){
- HRESULT hr = S_OK;
- Started = ((hr = CoInitialize(NULL)) == S_OK);
- if(Started){
- //graph builder... stage
- hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC,IID_IGraphBuilder, (void **)&pg);
- if(hr == S_OK){
- //video input device
- hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC,IID_ICreateDevEnum, (void **)&pde);
- if (hr == S_OK){
- //get plug and play video devices...
- hr = pde->CreateClassEnumerator(CLSID_VideoInputDeviceCategory,&pvde,0);
- if (hr == S_OK){
- hr = pvde->Next(1,&pvd,0);
- if(hr == S_OK){
- hr = pvd->BindToObject(NULL,NULL,IID_IBaseFilter,(void **)&pvc);
- if(hr == S_OK){
- hr = pg->AddFilter(pvc,L"VideoCap");
- if(hr == S_OK){
- hr = CoCreateInstance(CLSID_VideoRenderer, NULL, CLSCTX_INPROC_SERVER,
- IID_IBaseFilter, (LPVOID*) &pvr);
- if(hr == S_OK){
- hr = pg->AddFilter(pvr,L"VideoRenderer");
- if(hr == S_OK){
- //connect pins....
- hr = pg->QueryInterface(IID_IMediaControl, (void **)&pmc);
- hr = pg->QueryInterface(IID_IVideoWindow,(void **)&pwc);
- pwc->put_Owner((OAHWND)myHwnd);
- pwc->put_WindowStyle(WS_CHILD);
- RECT grc;
- GetClientRect(myHwnd, &grc);
- pwc->SetWindowPosition(0, 0, 100, 100);
- pwc->put_Visible(OATRUE);
- if(hr == S_OK)
- MessageBox(0,"Consegui","teste",0);
- hr = pvc->EnumPins(&pep);
- if(hr == S_OK){
- hr = pep->Next(1,&pop,NULL);
- //video device output pin
- if(hr == S_OK){
- //find video render input pin
- hr = pvr->EnumPins(&pep);
- if(hr == S_OK){
- hr = pep->Next(1,&pip,NULL);
- if(hr == S_OK){
- pg->Connect(pop,pip); //connect output video device to
- //input video renderer;
- if(hr == S_OK){
- pmc->Run();
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- return Started;
- }
- BOOL USB_VIDEO::End(void){
- if(Started)
- pmc->Stop();
- if(pg){
- if (pvc)
- pg->RemoveFilter(pvc);
- if (pvr)
- pg->RemoveFilter(pvc);
- }
- if(pwc){
- pwc->put_Visible(OAFALSE);
- pwc->put_Owner(NULL);
- }
- SECURE_RELEASE(pg); //graph builder
- SECURE_RELEASE(pde); //device list
- SECURE_RELEASE(pvde); //video Device enum
- SECURE_RELEASE(pvc); //video device
- SECURE_RELEASE(pvd); //video device
- SECURE_RELEASE(pvr); //base filter MJPG expected...
- SECURE_RELEASE(pip); //input
- SECURE_RELEASE(pop); //output
- //SECURE_RELEASE(pwi); //output
- CoUninitialize();
- return TRUE;
- }
- BOOL USB_VIDEO::isStarted(void){
- return Started;
- }