class CSampleGrabberCB : public ISampleGrabberCB
{
public:
long lWidth;
long lHeight;

STDMETHODIMP QueryInterface(REFIID riid, void ** ppv)
{
if( riid == IID_ISampleGrabberCB || riid == IID_IUnknown )
{
*ppv = (void *) static_cast<ISampleGrabberCB*> ( this );
return NOERROR;
}
return E_NOINTERFACE;
}
STDMETHODIMP_(ULONG) AddRef() { return 2; }
STDMETHODIMP_(ULONG) Release() { return 1; }
STDMETHODIMP SampleCB( double SampleTime, IMediaSample * pSample )
{
return 0;
}
STDMETHODIMP BufferCB( double dblSampleTime, BYTE * pBuffer, long lBufferSize )
{
return 0;
}

};
CSampleGrabberCB mCB;


Posted on 2010-03-17 03:12:51 by pmason_rose
I writen the code have been priew the camer,but I cant capture the picture!  please help !

;ds.asm
DEBUG equ 0
.386
.model flat, stdcall  ;32 bit memory model
option casemap :none  ;case sensitive
include windows.inc
include kernel32.inc
include user32.inc
include Comctl32.inc
include shell32.inc
include ole32.inc
includelib kernel32.lib
includelib user32.lib
includelib Comctl32.lib
includelib shell32.lib
includelib OLE32.LIB

include oaidl.inc
include macros.asm
include DirectShow.inc
.const
IDD_DS_DIALOG equ 102
ICO_MAIN equ 128
IDC_COMBO1 equ 1000
IDC_PHOTO equ 1001
IDC_HAVEALOOK equ 1002
IDC_STATIC_SCREEN equ 1003
IDC_LIST1 equ 1006

IID_FilterGraph GUID    sIID_FilterGraph
CLSID_FilterGraph GUID    sCLSID_FilterGraph
IID_IGraphBuilder GUID    sIID_IGraphBuilder
IID_IMediaControl GUID    sIID_IMediaControl
IID_IMediaEvent GUID    sIID_IMediaEvent
CLSID_CaptureGraphBuilder2 GUID sCLSID_CaptureGraphBuilder2
IID_ICaptureGraphBuilder2 GUID sIID_ICaptureGraphBuilder2
IID_IVideoWindow GUID    sIID_IVideoWindow
IID_IMediaEventEx GUID    sIID_IMediaEventEx
MEDIATYPE_Video GUID    sMEDIATYPE_Video
PIN_CATEGORY_PREVIEW GUID    sPIN_CATEGORY_PREVIEW
PIN_CATEGORY_CAPTURE GUID    sPIN_CATEGORY_CAPTURE
CLSID_SystemDeviceEnum GUID sCLSID_SystemDeviceEnum
IID_ICreateDevEnum GUID sIID_ICreateDevEnum
CLSID_VideoInputDeviceCategory GUID sCLSID_VideoInputDeviceCategory
IID_IBaseFilter GUID sIID_IBaseFilter
CLSID_SampleGrabber GUID sCLSID_SampleGrabber
IID_ISampleGrabber GUID sIID_ISampleGrabber
MEDIASUBTYPE_RGB24 GUID sMEDIASUBTYPE_RGB24
IID_ISampleGrabberCB GUID sIID_ISampleGrabberCB
.data?
hInstance dd ?
hWinMain dd ?
pCreateDevEnum dd ?
pEm dd ?
pM dd ?
cFetched dd ?
pBag dd ?
m_pGB dd ?
m_pCapture dd ?
m_pMC dd ?
m_pVW dd ?
m_pGrabber dd ?
pGrabBase dd ?
pFilter dd ?

hFile dd ?
bOneShot BOOL ?
bmfHdr BITMAPFILEHEADER<>
bi BITMAPINFO <>
pMemory dd ?
dwMemSize dd ?

ImageHeight dd ?
ImageWidth dd ?
.DATA
var VARIANT <>
mt AM_MEDIA_TYPE <>

.code
if DEBUG
pushad
include \masm32\debug\Debug.asm
popad
endif
CSampleGrabberCB proc uses ebx edi esi
pushad
popad
mov eax,TRUE
ret
CSampleGrabberCB endp
DlgProc proc uses ebx edi esi hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
mov eax,uMsg
.if eax==WM_INITDIALOG
push hWnd
pop hWinMain
INVOKE CoInitialize,NULL
invoke LoadIcon,hInstance,ICO_MAIN
invoke SendMessage,hWinMain,WM_SETICON,ICON_BIG,eax
mov bOneShot,FALSE
.elseif eax==WM_COMMAND
mov eax,wParam
.if ax == IDOK
invoke CoCreateInstance,addr CLSID_FilterGraph,NULL,CLSCTX_INPROC_SERVER,addr IID_IGraphBuilder,addr m_pGB
invoke CoCreateInstance,addr CLSID_CaptureGraphBuilder2 , NULL, CLSCTX_INPROC,addr IID_ICaptureGraphBuilder2,addr m_pCapture
.if eax!=S_OK
invoke MessageBox,NULL,CTXT("Failed to build CaptureGraphBuilder2 interface!"),NULL,MB_OK
.endif
coinvoke m_pCapture,ICaptureGraphBuilder2,SetFiltergraph,m_pGB
coinvoke m_pGB,IGraphBuilder,QueryInterface,ADDR IID_IMediaControl,ADDR m_pMC
.if eax!=S_OK
invoke MessageBox,NULL,CTXT("Failed to Query the Interface of IMediaControl!"),NULL,MB_OK
.endif
coinvoke m_pGB,IGraphBuilder,QueryInterface,ADDR IID_IVideoWindow,ADDR m_pVW
.if eax!=S_OK
invoke MessageBox,NULL,CTXT("Failed to get video interfaces!"),NULL,MB_OK
.endif
invoke CoCreateInstance,addr CLSID_SystemDeviceEnum,NULL,CLSCTX_INPROC_SERVER,addr IID_ICreateDevEnum,addr pCreateDevEnum
.if eax!=NOERROR
invoke MessageBox,NULL,CTXT("Failed to Create Instance of SystemDeviceEnum!"),NULL,MB_OK
.endif
coinvoke pCreateDevEnum,ICreateDevEnum,CreateClassEnumerator,addr CLSID_VideoInputDeviceCategory,addr pEm, 0
.if eax!=NOERROR
invoke MessageBox,NULL,CTXT("Failed to Create ClassEnumerator!"),NULL,MB_OK
.endif
coinvoke pEm,IEnumMoniker,Reset
coinvoke pEm,IEnumMoniker,Next,1,addr pM,addr cFetched
coinvoke pM,IMoniker,BindToObject,0,0,addr IID_IBaseFilter,addr pFilter
coinvoke pM,IMoniker,Release
coinvoke m_pGB,IGraphBuilder,AddFilter,pFilter,unicode("Capture Filter")
invoke CoCreateInstance,addr CLSID_SampleGrabber,NULL,CLSCTX_INPROC_SERVER,addr IID_IBaseFilter,addr m_pGrabber
.if !m_pGrabber
invoke MessageBox,NULL,CTXT("Fail to create SampleGrabber, maybe qedit.dll is not registered?"),NULL,MB_OK
.endif
invoke RtlZeroMemory,addr mt,sizeof AM_MEDIA_TYPE
invoke RtlMoveMemory,addr mt.majortype,addr MEDIATYPE_Video,sizeof MEDIATYPE_Video
invoke RtlMoveMemory,addr mt.subtype,addr MEDIASUBTYPE_RGB24,sizeof MEDIASUBTYPE_RGB24
coinvoke m_pGrabber,ISampleGrabber,SetMediaType,addr mt
.if eax
invoke MessageBox,NULL,CTXT("Fail to set media type!"),NULL,MB_OK
.endif
coinvoke m_pGB,IFilterGraph,AddFilter,pGrabBase,unicode("Grabber")
.if !eax
invoke MessageBox,NULL,CTXT("Fail to put sample grabber in graph"),NULL,MB_OK
.endif
coinvoke m_pCapture,ICaptureGraphBuilder2,RenderStream,addr PIN_CATEGORY_PREVIEW,addr MEDIATYPE_Video,pFilter,pGrabBase,NULL
.if eax
coinvoke m_pCapture,ICaptureGraphBuilder2,RenderStream,addr PIN_CATEGORY_CAPTURE,addr MEDIATYPE_Video,pFilter,pGrabBase,NULL
.endif
.if eax
invoke MessageBox,NULL,CTXT("Canít build the graph"),NULL,MB_OK
.endif
coinvoke m_pGrabber,ISampleGrabber,GetConnectedMediaType,addr mt
.if eax
invoke MessageBox,NULL,CTXT("Failt to read the connected media type"),NULL,MB_OK
.endif
mov ImageWidth,320
mov ImageHeight,240
.if mt.cbFormat
mov mt.cbFormat,NULL
mov mt.pbFormat,NULL
.endif
.if mt.pUnk
;coinvoke mt.pUnk,Release
mov mt.pUnk,NULL
.endif
coinvoke m_pGrabber,ISampleGrabber,SetBufferSamples,FALSE
coinvoke m_pGrabber,ISampleGrabber,SetOneShot,FALSE
;coinvoke m_pGrabber,ISampleGrabber,SetCallback,addr CSampleGrabberCB,1
coinvoke m_pMC,IMediaControl,Run
.if !eax
invoke MessageBox,NULL,CTXT("Couldnít run the graph!"),NULL,MB_OK
.endif

.elseif eax==IDC_PHOTO
mov bOneShot,TRUE
.endif
.elseif eax==WM_CLOSE
coinvoke m_pMC,IMediaControl,StopWhenReady
coinvoke m_pMC,IMediaControl,Release
coinvoke m_pGB,IFilterGraph,Release
coinvoke m_pGB,IGraphBuilder,Release
coinvoke m_pCapture,ICaptureGraphBuilder2,Release
INVOKE CoUninitialize
invoke EndDialog,hWinMain,0
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret
DlgProc endp
start:
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke DialogBoxParam,hInstance,IDD_DS_DIALOG,NULL,addr DlgProc,NULL
invoke ExitProcess,0
end start


Posted on 2010-03-17 03:16:54 by pmason_rose

#include "\MASM32\include\resource.h"

#define IDD_DS_DIALOG                   102
#define ICO_MAIN                   128
#define IDC_PHOTO                       1001
ICO_MAIN           ICON                    "MAIN.ico"
IDD_DS_DIALOG DIALOGEX 100, 100, 80, 20
STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "DS"
FONT 9, "MS Shell Dlg", 0, 0
BEGIN
   DEFPUSHBUTTON   "preview",IDOK,2,4,32,12
   PUSHBUTTON      "capture",IDC_PHOTO,40,4,32,12
END


Posted on 2010-03-17 03:17:43 by pmason_rose

OATRUE equ -1
OAFALSE equ 0

Stopped equ 0
Paused equ Stopped +1
Running equ Paused+1


sTIME_FORMAT_MEDIA_TIME TEXTEQU <{07b785574H, 08c82H, 011cfH, {0bcH, 00cH, 000H, 0aaH, 000H, 0acH, 074H, 0f6H}}>
; Name:DirectShow.inc
; Author:HuangLilong (EMail:landyu@163.com)
; modify by pmason_rose 2008-03-02
; Date:2004-10-17
; Version:V1.0
;--------------------------------------------------------------------------------------------------------

; Structures and Equates
;-------------------------------------------------------------------------------------------------------

OATRUE equ -1
OAFALSE equ 0

Stopped equ 0
Paused equ Stopped +1
Running equ Paused+1


sTIME_FORMAT_MEDIA_TIME TEXTEQU <{07b785574H, 08c82H, 011cfH, {0bcH, 00cH, 000H, 0aaH, 000H, 0acH, 074H, 0f6H}}>
sIID_IDispatch TEXTEQU <{000020400H, 00000H, 00000H, {0C0H, 000H, 000H, 000H, 000H, 000H, 000H, 046H}}>
sCLSID_IDispatch TEXTEQU <{000020400H, 00000H, 00000H, {0C0H, 000H, 000H, 000H, 000H, 000H, 000H, 046H}}>
_vtIDispatch MACRO CastName:REQ
;IUnknown methods
   _vtIUnknown CastName
   ; IDispatch methods
&CastName&_GetTypeInfoCount comethod2 ?
   &CastName&_GetTypeInfo comethod4 ?
   &CastName&_GetIDsOfNames comethod6 ?
   &CastName&_Invoke comethod9 ?
ENDM
IDispatch                      STRUCT
   _vtIDispatch  IDispatch
IDispatch                      ENDS
sIID_FilterGraph TEXTEQU <{0e436ebb3H, 0524fH, 011ceH, {09fH, 053H, 000H, 020H, 0afH, 00bH, 0a7H, 070H}}>
sCLSID_FilterGraph TEXTEQU <{0e436ebb3H, 0524fH, 011ceH, {09fH, 053H, 000H, 020H, 0afH, 00bH, 0a7H, 070H}}>
_vtIFilterGraph MACRO CastName:REQ
   ; IUnknown methods
   _vtIUnknown CastName
   ; IFilterGraph methods
;    &CastName&_GetPath                  comethod5 ? ;comment by pmason_rose
   &CastName&_AddFilter comethod3 ?
   &CastName&_RemoveFilter comethod2 ?
   &CastName&_EnumFilters comethod2 ?
   &CastName&_FindFilterByName comethod3 ?
   &CastName&_ConnectDirect comethod4 ?
   &CastName&_Reconnect comethod2 ?
   &CastName&_Disconnect comethod2 ?
   &CastName&_SetDefaultSyncSource comethod1 ?
ENDM
IFilterGraph                      STRUCT
   _vtIFilterGraph IFilterGraph
IFilterGraph                      ENDS
sIID_IGraphBuilder TEXTEQU <{056a868a9H, 00ad4H, 011ceH, {0b0H, 03aH, 000H, 020H, 0afH, 00bH, 0a7H, 070H}}>
sCLSID_IGraphBuilder TEXTEQU <{056a868a9H, 00ad4H, 011ceH, {0b0H, 03aH, 000H, 020H, 0afH, 00bH, 0a7H, 070H}}>
_vtIGraphBuilder MACRO CastName:REQ ;by pmason_rose
   ; IFilterGraph methods
   _vtIFilterGraph CastName
   ; IGraphBuilder methods
   &CastName&_Connect comethod3 ?
   &CastName&_Render comethod2 ?
&CastName&_RenderFile comethod3 ?
   &CastName&_AddSourceFilter comethod4 ?
   &CastName&_SetLogFile comethod2 ?
   &CastName&_Abort comethod1 ?
&CastName&_ShouldOperationContinue comethod1 ?
ENDM
IGraphBuilder                      STRUCT
   _vtIGraphBuilder IGraphBuilder
IGraphBuilder                      ENDS
sIID_IMediaControl TEXTEQU <{056a868b1H, 00ad4H, 011ceH, {0b0H, 03aH, 000H, 020H, 0afH, 00bH, 0a7H, 070H}}>
sCLSID_IMediaControl TEXTEQU <{056a868b1H, 00ad4H, 011ceH, {0b0H, 03aH, 000H, 020H, 0afH, 00bH, 0a7H, 070H}}>
_vtIMediaControl MACRO CastName:REQ ;by pmason_rose
   ; IDispatch methods
   _vtIDispatch CastName
   ; IMediaControl methods
&CastName&_Run comethod1 ?
&CastName&_Pause comethod1 ?
   &CastName&_Stop comethod1 ?
   &CastName&_GetState comethod3 ?
   &CastName&_RenderFile comethod2 ?
   &CastName&_AddSourceFilter comethod3 ?
   &CastName&_get_FilterCollection comethod2 ?
   &CastName&_get_RegFilterCollection comethod2 ?
   &CastName&_StopWhenReady comethod1 ?
ENDM
IMediaControl                      STRUCT
   _vtIMediaControl IMediaControl
IMediaControl                      ENDS
sIID_IMediaEvent TEXTEQU <{056a868b6H, 00ad4H, 011ceH, {0b0H, 03aH, 000H, 020H, 0afH, 00bH, 0a7H, 070H}}>
sCLSID_IMediaEvent TEXTEQU <{056a868b6H, 00ad4H, 011ceH, {0b0H, 03aH, 000H, 020H, 0afH, 00bH, 0a7H, 070H}}>
_vtIMediaEvent MACRO CastName:REQ ;by pmason_rose
   ; IDispatch methods
   _vtIDispatch CastName
   ; IMediaEvent methods
&CastName&_GetEventHandle comethod2 ?
   &CastName&_GetEvent comethod5 ?
&CastName&_WaitForCompletion comethod3 ?
   &CastName&_CancelDefaultHandling comethod2 ?
   &CastName&_RestoreDefaultHandling comethod2 ?
   &CastName&_FreeEventParams comethod4 ?
ENDM
IMediaEvent                      STRUCT
   _vtIMediaEvent IMediaEvent
IMediaEvent                      ENDS
sIID_IMediaEventEx TEXTEQU <{056a868c0H, 00ad4H, 011ceH, {0b0H, 03aH, 000H, 020H, 0afH, 00bH, 0a7H, 070H}}>
sCLSID_IMediaEventEx TEXTEQU <{056a868c0H, 00ad4H, 011ceH, {0b0H, 03aH, 000H, 020H, 0afH, 00bH, 0a7H, 070H}}>
_vtIMediaEventEx MACRO CastName:REQ
   ; IMediaEvent methods
   _vtIMediaEvent CastName
   ; IMediaEventEx methods
&CastName&_SetNotifyWindow comethod4 ?
   &CastName&_SetNotifyFlags comethod2 ?
   &CastName&_GetNotifyFlags comethod2 ?
ENDM
IMediaEventEx                      STRUCT
   _vtIMediaEventEx IMediaEventEx
IMediaEventEx                      ENDS
sIID_IBasicVideo TEXTEQU <{056a868b5H, 00ad4H, 011ceH, {0b0H, 03aH, 000H, 020H, 0afH, 00bH, 0a7H, 070H}}>
sCLSID_IBasicVideo TEXTEQU <{056a868b5H, 00ad4H, 011ceH, {0b0H, 03aH, 000H, 020H, 0afH, 00bH, 0a7H, 070H}}>
_vtIBasicVideo MACRO CastName:REQ
   ; IDispatch methods
   _vtIDispatch CastName
   ; IBasicVideo methods
&CastName&_get_AvgTimePerFrame comethod2 ?
   &CastName&_get_BitRate comethod2 ?
   &CastName&_get_BitErrorRate comethod2 ?
   &CastName&_get_VideoWidth comethod2 ?
   &CastName&_get_VideoHeight comethod2 ?
   &CastName&_put_SourceLeft comethod2 ?
   &CastName&_get_SourceLeft comethod2 ?
   &CastName&_put_SourceWidth comethod2 ?
   &CastName&_get_SourceWidth comethod2 ?
   &CastName&_put_SourceTop comethod2 ?
   &CastName&_get_SourceTop comethod2 ?
   &CastName&_put_SourceHeight comethod2 ?
   &CastName&_get_SourceHeight comethod2 ?
   &CastName&_put_DestinationLeft comethod2 ?
   &CastName&_get_DestinationLeft comethod2 ?
   &CastName&_put_DestinationWidth comethod2 ?
   &CastName&_get_DestinationWidth comethod2 ?
   &CastName&_put_DestinationTop comethod2 ?
   &CastName&_get_DestinationTop comethod2 ?
   &CastName&_put_DestinationHeight comethod2 ?
   &CastName&_get_DestinationHeight comethod2 ?
   &CastName&_SetSourcePosition comethod5 ?
   &CastName&_GetSourcePosition comethod5 ?
   &CastName&_SetDefaultSourcePosition comethod5 ?
   &CastName&_SetDestinationPosition comethod5 ?
   &CastName&_GetDestinationPosition comethod5 ?
   &CastName&_SetDefaultDestinationPosition comethod1 ?
   &CastName&_GetVideoSize comethod3 ?
   &CastName&_GetVideoPaletteEntries comethod5 ?
   &CastName&_GetCurrentImage comethod3 ?
   &CastName&_IsUsingDefaultSource comethod1 ?
   &CastName&_IsUsingDefaultDestination comethod1 ?
ENDM
IBasicVideo                      STRUCT
   _vtIBasicVideo IBasicVideo
IBasicVideo                      ENDS
sIID_IBasicAudio TEXTEQU <{056a868b3H, 00ad4H, 011ceH, {0b0H, 03aH, 000H, 020H, 0afH, 00bH, 0a7H, 070H}}>

sCLSID_IBasicAudio TEXTEQU <{056a868b3H, 00ad4H, 011ceH, {0b0H, 03aH, 000H, 020H, 0afH, 00bH, 0a7H, 070H}}>
_vtIBasicAudio MACRO CastName:REQ
   ; IDispatch methods
   _vtIDispatch CastName
   ; IBasicAudio methods
&CastName&_put_Volume comethod2 ?
   &CastName&_get_Volume comethod2 ?
   &CastName&_put_Balance comethod2 ?
   &CastName&_get_Balance comethod2 ?
ENDM
IBasicAudio                      STRUCT
   _vtIBasicAudio IBasicAudio
IBasicAudio                      ENDS
sIID_IVideoWindow TEXTEQU <{056a868b4H, 00ad4H, 011ceH, {0b0H, 03aH, 000H, 020H, 0afH, 00bH, 0a7H, 070H}}>
sCLSID_IVideoWindow TEXTEQU <{056a868b4H, 00ad4H, 011ceH, {0b0H, 03aH, 000H, 020H, 0afH, 00bH, 0a7H, 070H}}>
_vtIVideoWindow MACRO CastName:REQ
   ; IDispatch methods
   _vtIDispatch CastName
   ; IVideoWindow methods
&CastName&_put_Caption comethod2 ?
   &CastName&_get_Caption comethod2 ?
   &CastName&_put_WindowStyle comethod2 ?
   &CastName&_get_WindowStyle comethod2 ?
   &CastName&_put_WindowStyleEx comethod2 ?
   &CastName&_get_WindowStyleEx comethod2 ?
   &CastName&_put_AutoShow comethod2 ?
   &CastName&_get_AutoShow comethod2 ?
   &CastName&_put_WindowState comethod2 ?
   &CastName&_get_WindowState comethod2 ?
   &CastName&_put_BackgroundPalette comethod2 ?
   &CastName&_get_BackgroundPalette comethod2 ?
   &CastName&_put_Visible comethod2 ?
   &CastName&_get_Visible comethod2 ?
   &CastName&_put_Left comethod2 ?
   &CastName&_get_Left comethod2 ?
   &CastName&_put_Width comethod2 ?
   &CastName&_get_Width comethod2 ?
   &CastName&_put_Top comethod2 ?
   &CastName&_get_Top comethod2 ?
   &CastName&_put_Height comethod2 ?
   &CastName&_get_Height comethod2 ?
   &CastName&_put_Owner comethod2 ?
   &CastName&_get_Owner comethod2 ?
   &CastName&_put_MessageDrain comethod2 ?
   &CastName&_get_MessageDrain comethod2 ?
   &CastName&_get_BorderColor comethod2 ?
   &CastName&_put_BorderColor comethod2 ?
   &CastName&_get_FullScreenMode comethod2 ?
   &CastName&_put_FullScreenMode comethod2 ?
   &CastName&_SetWindowForeground comethod2 ?
   &CastName&_NotifyOwnerMessage comethod5 ?
   &CastName&_SetWindowPosition comethod5 ?
   &CastName&_GetWindowPosition comethod5 ?
   &CastName&_GetMinIdealImageSize comethod3 ?
   &CastName&_GetMaxIdealImageSize comethod3 ?
   &CastName&_GetRestorePosition comethod5 ?
   &CastName&_HideCursor comethod2 ?
   &CastName&_IsCursorHidden comethod2 ?
ENDM
IVideoWindow                      STRUCT
   _vtIVideoWindow IVideoWindow
IVideoWindow                      ENDS
sIID_IMediaSeeking TEXTEQU <{036b73880H, 0c2c8H, 011cfH, {08bH, 046H, 000H, 080H, 05fH, 06cH, 0efH, 060H}}>
sCLSID_IMediaSeeking TEXTEQU <{036b73880H, 0c2c8H, 011cfH, {08bH, 046H, 000H, 080H, 05fH, 06cH, 0efH, 060H}}>
_vtIMediaSeeking MACRO CastName:REQ
   ; IUnknown methods
   _vtIUnknown CastName
   ; IMediaSeeking methods
&CastName&_GetCapabilities comethod2 ?
   &CastName&_CheckCapabilities comethod2 ?
   &CastName&_IsFormatSupported comethod2 ?
   &CastName&_QueryPreferredFormat comethod2 ?
   &CastName&_GetTimeFormat comethod2 ?
&CastName&_IsUsingTimeFormat comethod2 ?
   &CastName&_SetTimeFormat comethod2 ?
&CastName&_GetDuration comethod2 ?
   &CastName&_GetStopPosition comethod2 ?
   &CastName&_GetCurrentPosition comethod2 ?
   &CastName&_ConvertTimeFormat comethod5 ?
   &CastName&_SetPositions comethod5 ?
&CastName&_GetPositions comethod3 ?
   &CastName&_GetAvailable comethod3 ?
   &CastName&_SetRate comethod2 ?
   &CastName&_GetRate comethod2 ?
   &CastName&_GetPreroll comethod2 ?
ENDM
IMediaSeeking                      STRUCT
   _vtIMediaSeeking IMediaSeeking
IMediaSeeking                      ENDS
;by pmason_rose
sIID_ICaptureGraphBuilder2 TEXTEQU <{093E5A4E0H, 02D50H, 011d2H, {0ABH, 0FAH, 000H, 0A0H, 0C9H, 0C6H, 0E3H, 08DH}}>
sCLSID_CaptureGraphBuilder2 TEXTEQU <{0BF87B6E1H, 08C27H, 011d0H, {0B3H, 0F0H, 000H, 0AAH, 000H, 037H, 061H, 0C5H}}>
_vtICaptureGraphBuilder2 MACRO CastName:REQ ;by pmason_rose
   ; IUnknown methods
   _vtIUnknown CastName
   ;ICaptureGraphBuilder2  methods
&CastName&_SetFiltergraph comethod2 ?
&CastName&_GetFiltergraph comethod2 ?
&CastName&_SetOutputFileName comethod5 ?
&CastName&_FindInterface comethod6 ?
&CastName&_RenderStream comethod6 ?
&CastName&_ControlStream comethod8 ?
&CastName&_AllocCapFile comethod3 ?
&CastName&_CopyCaptureFile comethod5 ?
&CastName&_FindPin comethod8 ?
ENDM

ICaptureGraphBuilder2                      STRUCT
   _vtICaptureGraphBuilder2 ICaptureGraphBuilder2
ICaptureGraphBuilder2                      ENDS
sMEDIATYPE_Video TEXTEQU <{073646976h,00000h,00010h,{080h,000h,000h,0AAh,000h,038h,09Bh,071h}}>
sPIN_CATEGORY_PREVIEW TEXTEQU <{0fb6c4282h,00353h,011d1h,{090h,05fh,000h,000h,0c0h,0cch,016h,0bah}}>
sPIN_CATEGORY_CAPTURE TEXTEQU <{0fb6c4281h,00353h,011d1h,{090h,05fh,000h,000h,0c0h,0cch,016h,0bah}}>
sCLSID_SystemDeviceEnum TEXTEQU <{062BE5D10h,060EBh,011d0h,{0BDh,03Bh,000h,0A0h,0C9h,011h,0CEh,086h}}>
sIID_ICreateDevEnum TEXTEQU <{029840822h,05B84h,011D0h,{0BDh,03Bh,000h,0A0h,0C9h,011h,0CEh,086h}}>
sCLSID_VideoInputDeviceCategory TEXTEQU <{0860BB310h,05D01h,011d0h,{0BDh,03Bh,000h,0A0h,0C9h,011h,0CEh,086h}}>
_vtICreateDevEnum MACRO CastName:REQ ;by pmason_rose
   ; IUnknown methods
   _vtIUnknown CastName
&CastName&_CreateClassEnumerator comethod4 ?
ENDM
ICreateDevEnum STRUCT ;by pmason_rose
_vtICreateDevEnum ICreateDevEnum
ICreateDevEnum ENDS

sIID_IBaseFilter TEXTEQU <{056a86895h,00ad4h,011ceh,{0b0h,03ah,000h,020h,0afh,00bh,0a7h,070h}}>

_vtIBaseFilter MACRO CastName:REQ ;by pmason_rose
   ; IUnknown methods
   _vtIUnknown CastName
&CastName&_EnumPins comethod2 ?
&CastName&_FindPin comethod3 ?
&CastName&_QueryFilterInfo comethod2 ?
&CastName&_JoinFilterGraph comethod3 ?
&CastName&_QueryVendorInfo comethod2 ?
ENDM
IBaseFilter STRUCT
_vtIBaseFilter IBaseFilter
IBaseFilter ENDS

_vtIEnumMoniker MACRO CastName:REQ ;by pmason_rose
   ; IUnknown methods
   _vtIUnknown CastName
&CastName&_Next comethod4 ?
&CastName&_Skip comethod2 ?
&CastName&_Reset comethod1 ?
&CastName&_Clone comethod2 ?
ENDM
IEnumMoniker STRUCT
_vtIEnumMoniker IEnumMoniker
IEnumMoniker ENDS
_vtIMoniker MACRO CastName:REQ ;by pmason_rose
   ; IUnknown methods
   _vtIUnknown CastName
&CastName&_GetClassID comethod3 ?
&CastName&_IsDirty comethod2 ?
&CastName&_Load comethod3 ?
&CastName&_Save comethod4 ?
&CastName&_GetSizeMax comethod3 ?

&CastName&_BindToObject comethod5 ?
&CastName&_BindToStorage comethod5 ?
&CastName&_Reduce comethod5 ?
&CastName&_ComposeWith comethod4 ?
&CastName&_Enum comethod3 ?
&CastName&_IsEqual comethod2 ?
&CastName&_Hash comethod2 ?
&CastName&_IsRunning comethod4 ?
&CastName&_GetTimeOfLastChange comethod4 ?
&CastName&_Inverse comethod2 ?
&CastName&_CommonPrefixWith comethod3 ?
&CastName&_RelativePathTo comethod3 ?
&CastName&_GetDisplayName comethod4 ?
&CastName&_ParseDisplayName comethod6 ?
&CastName&_IsSystemMoniker comethod2 ?
ENDM
IMoniker STRUCT
_vtIMoniker IMoniker
IMoniker ENDS
sIID_IPropertyBag TEXTEQU <{055272A00h,042CBh,011CEh,{081h,035h,000h,0AAh,000h,04Bh,0B8h,051h}}>
_vtIPropertyBag MACRO CastName:REQ ;by pmason_rose
   ; IUnknown methods
   _vtIUnknown CastName
&CastName&_Read comethod4 ?
&CastName&_Write comethod3 ?
ENDM
IPropertyBag STRUCT
_vtIPropertyBag IPropertyBag
IPropertyBag ENDS
sCLSID_SampleGrabber TEXTEQU <{0C1F400A0h,03F08h,011D3h,{09Fh,00Bh,000h,060h,008h,003h,09Eh,037h}}>
sIID_ISampleGrabber TEXTEQU <{06B652FFFh,011FEh,04fceh,{092h,0ADh,002h,066h,0B5h,0D7h,0C7h,08Fh}}>
_vtISampleGrabber MACRO CastName:REQ ;by pmason_rose
   ; IUnknown methods
   _vtIUnknown CastName
&CastName&_SetOneShot comethod2 ?
&CastName&_SetMediaType comethod2 ?
&CastName&_GetConnectedMediaType comethod2 ?
&CastName&_SetBufferSamples comethod2 ?
&CastName&_GetCurrentBuffer comethod3 ?
&CastName&_GetCurrentSample comethod2 ?
&CastName&_SetCallback comethod3 ?
ENDM
ISampleGrabber STRUCT
_vtISampleGrabber ISampleGrabber
ISampleGrabber ENDS

sMEDIASUBTYPE_RGB24 TEXTEQU <{0e436eb7dh,0524fh,011ceh,{09fh,053h,000h,020h,0afh,00bh,0a7h,070h}}>

sIID_ISampleGrabberCB TEXTEQU <{00579154Ah,02B53h,04994h,{0B0h,0D0h,0E7h,073h,014h,08Eh,0FFh,085h}}>
_vtISampleGrabberCB MACRO CastName:REQ ;by pmason_rose
   ; IUnknown methods
   _vtIUnknown CastName
&CastName&_SampleCB comethod3 ?
&CastName&_BufferCB comethod4 ?
ENDM
ISampleGrabberCB STRUCT
_vtISampleGrabberCB ISampleGrabberCB
ISampleGrabberCB ENDS
AM_MEDIA_TYPE STRUCT ;by pmason_rose
   majortype GUID <>
subtype GUID <>
bFixedSizeSamples DWORD ?
bTemporalCompression DWORD ?
lSampleSize DWORD ?
formattype GUID <>
pUnk DWORD ?
cbFormat DWORD ?
pbFormat DWORD ?
AM_MEDIA_TYPE ENDS


Posted on 2010-03-17 03:22:49 by pmason_rose

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// Include ???
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#include <atlbase.h>
#include <windows.h>
#include <DShow.h>
#include <qedit.h>

#define ICO_MAIN        1000
#define DLG_MAIN        1000
#define IDC_COUNTER     1001
#define IDC_PAUSE       1002

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// ????:
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
HWND hWinMain;
BOOL bOneShot=FALSE;//????
int m_pVW = NULL;
int m_pMC = NULL;
int m_pGB = NULL;
int m_pCapture = NULL;

class CSampleGrabberCB : public ISampleGrabberCB
{
public:
long lWidth;
long lHeight;

STDMETHODIMP QueryInterface(REFIID riid, void ** ppv)
{
if( riid == IID_ISampleGrabberCB || riid == IID_IUnknown )
{
*ppv = (void *) static_cast<ISampleGrabberCB*> ( this );
return NOERROR;
}
return E_NOINTERFACE;
}
STDMETHODIMP_(ULONG) AddRef() { return 2; }
STDMETHODIMP_(ULONG) Release() { return 1; }
STDMETHODIMP SampleCB( double SampleTime, IMediaSample * pSample )
{
return 0;
}
STDMETHODIMP BufferCB( double dblSampleTime, BYTE * pBuffer, long lBufferSize )
{
return 0;
}

};
CSampleGrabberCB mCB;

HRESULT CCaptureVideo::Init(int iDeviceID, HWND hWnd)
{
HRESULT hr;
hr=CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&m_pGB);
hr = CoCreateInstance (CLSID_CaptureGraphBuilder2 , NULL, CLSCTX_INPROC,
IID_ICaptureGraphBuilder2, (void **) &m_pCapture);
if (FAILED(hr))return hr;
m_pCapture->SetFiltergraph(m_pGB
hr = m_pGB->QueryInterface(IID_IMediaControl, (void **)&m_pMC);
if (FAILED(hr))return hr;
hr = m_pGB->QueryInterface(IID_IVideoWindow, (LPVOID *) &m_pVW);

if (FAILED(hr))
{
AfxMessageBox("Failed to get video interfaces!");
return hr;
}
// Bind Device Filter. We know the device because the id was passed in
// if(!BindFilter(iDeviceID, &m_pBF))return S_FALSE;
CComPtr<ICreateDevEnum> pCreateDevEnum;
hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER,
IID_ICreateDevEnum, (void**)&pCreateDevEnum);
if (hr != NOERROR)
{
return false;
}
CComPtr<IEnumMoniker> pEm;
hr = pCreateDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory,&pEm, 0);
if (hr != NOERROR)
{
return false;
}
pEm->Reset();
ULONG cFetched;
IMoniker *pM;
hr = pEm->Next(1, &pM, &cFetched);

IBaseFilter **pFilter;
pFilter = &m_pBF ;
pM->BindToObject(0, 0, IID_IBaseFilter, (void**)pFilter);
pM->Release();
hr = m_pGB->AddFilter(m_pBF, L"Capture Filter");

// create a sample grabber
hr = m_pGrabber.CoCreateInstance( CLSID_SampleGrabber );
if( !m_pGrabber )
{
AfxMessageBox("Fail to create SampleGrabber, maybe qedit.dll is not registered?");
return hr;
}
CComQIPtr< IBaseFilter, &IID_IBaseFilter > pGrabBase( m_pGrabber );

AM_MEDIA_TYPE mt;
ZeroMemory(&mt, sizeof(AM_MEDIA_TYPE));
mt.majortype = MEDIATYPE_Video;
mt.subtype = MEDIASUBTYPE_RGB24;
hr = m_pGrabber->SetMediaType(&mt);

if( FAILED( hr ) )
{
AfxMessageBox("Fail to set media type!");
return hr;
}

hr = m_pGB->AddFilter( pGrabBase, L"Grabber" );
if( FAILED( hr ) )
{
AfxMessageBox("Fail to put sample grabber in graph");
return hr;
}

// try to render preview/capture pin
hr = m_pCapture->RenderStream(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Video,m_pBF,pGrabBase,NULL);
if( FAILED( hr ) )
hr = m_pCapture->RenderStream(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video,m_pBF,pGrabBase,NULL);
if( FAILED( hr ) )
{
AfxMessageBox("Canít build the graph");
return hr;
}

hr = m_pGrabber->GetConnectedMediaType( &mt );//retrieves the media type for the connection
                                             //on the input pin of the Sample Grabber
if ( FAILED( hr) )
{
AfxMessageBox("Failt to read the connected media type");
return hr;
}

VIDEOINFOHEADER * vih = (VIDEOINFOHEADER*) mt.pbFormat;
mCB.lWidth = vih->bmiHeader.biWidth;
mCB.lHeight = vih->bmiHeader.biHeight;

hr = m_pGrabber->SetBufferSamples( FALSE );//
hr = m_pGrabber->SetOneShot( FALSE );//
hr = m_pGrabber->SetCallback( &mCB, 1 );//


hr = m_pMC->Run();//??????
if(FAILED(hr)){AfxMessageBox("Couldnít run the graph!");return hr;}
return S_OK;
}


Posted on 2010-03-17 03:23:35 by pmason_rose
Have you EVER heard about attachments, 'code' tags, or at least paste bin sites? o_O
Posted on 2010-03-17 12:38:09 by ti_mo_n

Have you EVER heard about attachments, 'code' tags, or at least paste bin sites? o_O


Evidentally not.

pmason_rose, first, the surest way to get people to ignore you is to plaster page after page of code.

Second, look into ObjAsm32.
Posted on 2010-03-17 12:45:31 by SpooK
Thank for your replay, here is the bin files,please have a look!
Attachments:
Posted on 2010-03-17 21:36:09 by pmason_rose