Re: Video Capture
- Posted by Dan Moyer <DANIELMOYER at prodigy.net> Oct 16, 2002
- 450 views
Jordah, Don't know if this relates to what you're trying to do or not, but there are a bunch of people constructing Personal Video Recorders (Tivo emulator) on Linux boxes. Downloadable code, drivers, & links can be found at: http://www.linuxtv.org/ http://www.cadsoft.de/vdr/ and there's an article talking about it in November Popular Science magazine. Might be an interesting Euphoria / Linux project? Dan Moyer ----- Original Message ----- From: "jordah ferguson" <jorfergie03 at yahoo.com> To: "EUforum" <EUforum at topica.com> Sent: Friday, October 04, 2002 3:10 AM Subject: Video Capture > > Hi All, > I was doing some simple coding last night and got disappointing > results, those annoying enuff to make you dump a project. i keep getting > the message saying my AVI capture driver is poorly installed. i have run > this same program on my dads computer and it still gives me the same > result. If the it works on any other systems without erroring out please > inform me. And if you have any idea how i can properly install a video > capture driver please inform me. > > The first half of the code is my latest low-level routines include > file. the real code is at the bottom. Please give me feeback > > Jordah Ferguson > > > --------------------------------------------------------- > --File : SpyLoJiK ver 0.0.1 > --Version: 0.0.1 > --Date : 1/10/2002 > --Author : Jordah Ferguson > --------------------------------------------------------- > > include dll.e > include msgbox.e > > --------------------------------------------------------- > -- Start of the latest version of llrtns.e By me :) > --------------------------------------------------------- > > global constant > CHAR = #01000001, UCHAR = #02000001, > SHORT = #01000002, USHORT = #02000002, > INT = #01000004, UINT = #02000004, > LONG = INT , ULONG = UINT , > POINTER = ULONG , FLOAT = #03000004, > DOUBLE = #03000008, BOOL = CHAR , > BYTE = CHAR , WORD = SHORT , > UWORD = USHORT , DWORD = ULONG , > PTR = POINTER , LPSZ = #04000004, > FLOAT32 = FLOAT , FLOAT64 = DOUBLE , > HANDLE = ULONG > -------------------[ Structure Constants ]------------------- > > constant > lladdress = 1, > llsize = 2, > llctype = 3, > llevalue = 4, > lloffset = 5 > --------------------------------------------------------- > > constant kernel32 = open_dll("kernel32.dll"), > HEAP_ZERO_MEMORY = #00000008, > HEAP_NO_SERIALIZE = #00000001, > HEAP_GROWABLE = #00000002, > > zHeapCreate = define_c_func(kernel32, "HeapCreate", {C_LONG, C_LONG, > C_LONG}, C_LONG), > zHeapAlloc = define_c_func(kernel32, "HeapAlloc", {C_LONG, C_LONG, > C_LONG}, C_LONG), > zHeapFree = define_c_func(kernel32, "HeapFree", {C_LONG, C_LONG, > C_LONG}, C_LONG), > zHeapDestroy = define_c_func(kernel32, "HeapDestroy", {C_LONG}, C_LONG), > zlstrlen = define_c_func(kernel32, "lstrlenA",{C_POINTER}, C_INT) > -------------------------------------------------------- > atom InternalHeap > --------------------------------------------------------- > > global type Struct(sequence x) > if length(x) != 5 then > return 0 > else > return atom(x[1]) > and integer(x[2]) > and sequence(x[3]) > and sequence(x[4]) > and sequence(x[5]) > end if > end type > --------------------------------------------------------- > > global type string(sequence s) > object x > for i = 1 to length(s) do > x = s[i] > if integer(x) then > if x < 0 or x > #FF then > return 0 > end if > else > return 0 > end if > end for > return 1 > end type > --------------------------------------------------------- > > global function HeapCreate(integer size) > return > c_func(zHeapCreate,{or_bits(HEAP_NO_SERIALIZE,HEAP_GROWABLE),size,0}) <snip> LONG,INT},LONG), > > zcapGetDriverDescription= > e_c_func(avicap32,"capGetDriverDescriptionA",{UINT,LONG,LONG,LONG},LONG) > , > > -- Some Constants: > WM_CREATE = 1, > WM_CLOSE = 16, > WM_SIZE = #5, > WM_USER = 1024, > WM_CAP_START = WM_USER, > WM_CAP_DRIVER_CONNECT= WM_CAP_START + 10, > WM_CAP_SET_CALLBACK_ERROR = WM_CAP_START + 2, > CapWndStyle = or_bits(#10000000,#40000000), > ProgName = "AVI Capture Demonstration by Jordah Ferguson 2002", > ClassName = "AVI Capture: Lojik Software" > > atom MainWnd,CaptWnd > MainWnd = 0 > CaptWnd = 0 > -------------------[ WNDCLASSEX STRUCTRURE ]------------ > Struct WNDCLASSEX,POINTAPI,MSG > WNDCLASSEX = defineStructure({ > {UINT ,"cbSize" }, > {UINT ,"style" }, > {PTR ,"lpfnWndProc" }, > {INT ,"cbClsExtra" }, > {INT ,"cbWndExtra" }, > {HANDLE,"hInstance" }, > {HANDLE,"hIcon" }, > {HANDLE,"hCursor" }, > {HANDLE,"hbrBackground"}, > {PTR ,"lpszMenuName" }, > {LPSZ ,"lpszClassName"}, > {HANDLE,"hIconSm" }}) > WNDCLASSEX = AllocateStructure(WNDCLASSEX) > -------------------[ POINTAPI Structure ]---------------- > POINTAPI = defineStructure({ > {LONG,"x"}, > {LONG,"y"}}) > -------------------[ MSG Structure ]------------------- > MSG = defineStructure({ > {HANDLE ,"hwnd" }, > {UINT ,"message"}, > {WORD ,"wParam" }, > {LONG ,"lParam" }, > {DWORD ,"time" }, > {POINTAPI,"" }}) > MSG = AllocateStructure(MSG) > constant MSGPOINTER = addressOf(MSG) > > -------------------[ Error Box: MACRO] > > procedure Error(sequence msg) > if message_box(msg,"Spy LoJik 2002",MB_ICONINFORMATION) then end if > end procedure > > --------------------------------------------------------- > integer junk,ret > -- Wrap of the functions > > procedure RegisterClassEx(atom lp) > ret = c_func(zRegisterClassEx,{lp}) > if not ret then > Error("Failed to reister class") > end if > end procedure > --------------------------------------------------------- > > function CreateWindowEx(atom ex,sequence lpsz,sequence wndname,atom st, > atom x,atom y,atom cx,atom cy,atom pHwnd) > atom buffer1,buffer2 > buffer1 = Alloc(lpsz) > buffer2 = Alloc(wndname) > ret = > c_func(zCreateWindowEx,{ex,buffer1,buffer2,st,x,y,cx,cy,pHwnd,0,instance(),0 }) > > if not ret then > Error("CreateWindowEx failed") > end if > Free(buffer1) > Free(buffer2) > return ret > end function > --------------------------------------------------------- > > function SendMessage(atom hwnd,atom msg,atom wParam,atom lParam) > return c_func(zSendMessage,{hwnd,msg,wParam,lParam}) > end function > --------------------------------------------------------- > > function capCreateCaptureWindow(sequence Name,atom ExS,atom x,atom > y,atom cx,atom cy,atom pHwnd,atom cId) > atom buffer,ret > buffer = Alloc(Name) > ret = c_func(zcapCreateCaptureWindow,{buffer,ExS,x,y,cx,cy,pHwnd,cId}) > if not ret then > Error("Failed to create the capture window") > end if > Free(buffer) > return ret > end function > --------------------------------------------------------- > > procedure GetDriverDescription() > atom buffer1,buffer2 > sequence Desc Desc = {} > buffer1 = Alloc(80) > buffer2 = Alloc(80) > for n = 1 to 10 do > junk = c_func(zcapGetDriverDescription,{buffer1,80,buffer2,80}) > Desc &= PeekString(buffer1)&" "&PeekString(buffer2) &"\n" > end for > Error("Device Names: Device Versions\n"&Desc) > Free(buffer1) > Free(buffer2) > end procedure > > --------------------------------------------------------- > ------[ Callack Functions: The real Code at work~ ]------ > --------------------------------------------------------- > > function ErrorCallBack(atom hwnd,atom ErrId,atom lp) > if hwnd != CaptWnd then > return 0 > elsif not ErrId then > return 1 > else > Error(sprintf("Code: %d \nMSG: ",ErrId)&PeekString(lp)) > end if > return 1 > end function > constant ECB = call_back(routine_id("ErrorCallBack")) > --------------------------------------------------------- > > atom xPos,yPos > function WndProc(atom hwnd,atom msg,atom wParam,atom lParam) > if msg = WM_CREATE then > CaptWnd = > capCreateCaptureWindow(ClassName,CapWndStyle,10,10,180,180,hwnd,1) > GetDriverDescription() > junk = SendMessage(CaptWnd,WM_CAP_SET_CALLBACK_ERROR,0,ECB) > junk = SendMessage(CaptWnd,WM_CAP_DRIVER_CONNECT,0,0) > elsif msg = WM_SIZE then > xPos = LOWORD(lParam) > yPos = HIWORD(lParam) > junk = c_func(zMoveWindow,{CaptWnd,0,0,xPos,yPos-50,1}) > elsif msg = WM_CLOSE then > if hwnd = MainWnd then > c_proc(zPostQuitMessage,{0}) > end if > end if > return c_func(zDefWindowProc,{hwnd,msg,wParam,lParam}) > end function > constant lpfnWndProc = call_back(routine_id("WndProc")) > --------------------------------------------------------- > > procedure WinMain() > atom size,aWNDCLASSEX,icon,cursor > aWNDCLASSEX = addressOf(WNDCLASSEX) > size = sizeOf(WNDCLASSEX) > icon = c_func(zLoadIcon,{0,#7F04}) > cursor = c_func(zLoadCursor,{0,#7F00}) > Store(WNDCLASSEX,{ > {"cbSize" ,size }, > {"lpfnWndProc" ,lpfnWndProc}, > {"hInstance" , instance()}, > {"hIcon" , icon }, > {"hCursor" , cursor }, > {"style" , #0020 }, -- CS_OWNDC > {"hbrBackground", 16 }, > {"lpszClassName", ClassName }}) > RegisterClassEx(aWNDCLASSEX) > WNDCLASSEX = FreeStructure(WNDCLASSEX) > MainWnd = CreateWindowEx(0,ClassName,ProgName, > #104F0000, --or_bits(WS_OVERLAPPEDWINDOW,WS_VISIBLE) <snip> > > >