{"id":54,"date":"2015-12-24T23:27:54","date_gmt":"2015-12-24T23:27:54","guid":{"rendered":"http:\/\/www.ferzkopp.org\/wordpress\/?p=54"},"modified":"2016-01-08T07:44:29","modified_gmt":"2016-01-08T15:44:29","slug":"historical-code","status":"publish","type":"post","link":"https:\/\/www.ferzkopp.net\/wordpress\/2015\/12\/24\/historical-code\/","title":{"rendered":"Historical Code"},"content":{"rendered":"<p>My collection of historical open source code written over the years as part of the various ventures and involvements &#8211; mostly in C and Linux based &#8211; for archival purpose.<\/p>\n<p><!--more--><\/p>\n<h4>Pig Shoot (2000)<\/h4>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"pig1.gif\" src=\"http:\/\/cms.ferzkopp.net\/images\/stories\/pig1.gif\" alt=\"pig1.gif\" width=\"50\" height=\"43\" border=\"0\" hspace=\"5\" vspace=\"5\" \/> <img loading=\"lazy\" decoding=\"async\" title=\"pig1.gif\" src=\"http:\/\/cms.ferzkopp.net\/images\/stories\/pig1.gif\" alt=\"pig1.gif\" width=\"50\" height=\"43\" border=\"0\" hspace=\"5\" vspace=\"5\" \/> <img loading=\"lazy\" decoding=\"async\" title=\"pig1.gif\" src=\"http:\/\/cms.ferzkopp.net\/images\/stories\/pig1.gif\" alt=\"pig1.gif\" width=\"50\" height=\"43\" border=\"0\" hspace=\"5\" vspace=\"5\" \/><\/p>\n<p>Simple &#8220;shoot the pig&#8221; game for the Cybiko portable game device.<\/p>\n<p><strong>DOWNLOAD<\/strong><br \/>\n<a href=\"http:\/\/www.ferzkopp.net\/Software\/PigShoot-1.1\/PigShoot-1.1.zip\">[ PigShoot-1.1.zip (129k) ]<\/a><\/p>\n<h4>jasciimovie (1999)<\/h4>\n<p>Play ASCII movies &#8211; sequences of digitized video converted into an ASCII representation &#8211; in a webbrowser via Java. Licenced under the GPL; see the file LICENSE in the archive for details.<\/p>\n<p><strong>DOWNLOAD<\/strong><\/p>\n<p><a href=\"http:\/\/www.ferzkopp.org\/Software\/jasciimovie-2.0\/jasciimovie-2.0.tar.gz\">[ jasciimovie-2.0.tar.gz (89k)]<\/a><\/p>\n<p><strong>DEMOS<\/strong><\/p>\n<ul>\n<li><a href=\"http:\/\/www.ferzkopp.org\/Software\/jasciimovie-2.0\/jasciimovie1.html\">Demo 1: Short film<\/a><\/li>\n<li><a href=\"http:\/\/www.ferzkopp.org\/Software\/jasciimovie-2.0\/jasciimovie2.html\">Demo 2: Face<\/a><\/li>\n<li><a href=\"http:\/\/www.ferzkopp.org\/Software\/jasciimovie-2.0\/jasciimovie3.html\">Demo 3: Keyboard<\/a><\/li>\n<\/ul>\n<p><strong>README<\/strong><\/p>\n<pre style=\"height: 400px; width: 740px;\">[ JASCIIMOVIE ]\r\n\r\n(c) under GPL, A. Schiffler, 1999\r\n\r\n[ Introduction ]\r\n\r\njasciimovie is a java program designed to play back an ascii-movie within a\r\nbrowser. An ascii-movie is a plain text file of screens seperated by escape\r\ncodes for clearing the screen (in hex notation 1B 5B 48 1B 5B 4A).\r\n\r\nThese ascii-movies can get produced by the asciivideo sample program that is\r\nincluded with the \"libbgrab\" package by me.\r\n\r\nThe movie files have to be compressed with \"gzip -9\" which saves incredible\r\namounts of space.\r\n\r\n\r\n[ Compilation and Usage ]\r\n\r\n- Prerequisites: JDK 1.1.x+ installed and in the path\r\n- To compile type: make\r\n- To test: fire up a java-capable browser with the file jasciimovie.html\r\n\r\nSee the file jasciimovie.html for how to incorporate the applet in your\r\nwebpage.\r\n\r\nConfigurable parameters are: the filename (the movie file must be in the same \r\ndirectory as the .html file), the fontsize (usable are 8,10,12,14), a flag of the\r\nmovies gets repeated at the end, the frame rate and the colors.\r\n\r\nThe program tries to center the ascii-movie within the applet. \r\n\r\nA copyright message is beeing displayed for 2 seconds at the beginning of\r\nplayback.\r\n\r\nA sample movie (cfilm.txt.gz) is included - look at the file also with\r\n\"zless cfilm.txt.gz\" to see the individual frames.\r\n\r\nKeep the image files \r\n\tback.gif\r\n\tcopyright.gif\r\n\tpause.gif\r\n\tstop.gif\r\nalso in the same directory as the .html file.\r\n\r\n<\/pre>\n<h4>lcd2 (2001)<\/h4>\n<p>Commandline info display driver for Matrix Orbital 20&#215;2 LCD displays.<\/p>\n<ul>\n<li><a href=\"http:\/\/www.ferzkopp.org\/Software\/lcd2\/lcd2.tar.gz\">lcd2.tar.gz<\/a> (.tgz archive, 3K)<\/li>\n<\/ul>\n<h4>robtrack16 (1998)<\/h4>\n<p>&#8220;robtrack16&#8221; is a visual tracking program that uses a segment of 16bit YUV-color-space to locate points in a 2D image.<\/p>\n<p>The available tracking colors are determined manually and read from a configuation file. the program returns an x,y coordinate pair in the range between 0.0 and 1.0 for each color beeing tracked. The tracking shapes should be roughly circular for best results, although any shape will work since the &#8220;center-of-mass&#8221; (average x and y coordinates of all points in one set) is beeing formed. The interface to the results is a standard TCP socket with ASCII in- and output.<\/p>\n<p>Requirements:<br \/>\n&#8211; Linux PC<br \/>\n&#8211; Matrox Meteor framegrabber card<\/p>\n<p><strong>DOWNLOAD<\/strong><\/p>\n<ul>\n<li><a href=\"http:\/\/WWW.ferzkopp.net\/Software\/robtrack16\/robtrack16.tar.gz\">robtrack16.tar.gz<\/a> (.tgz archive, 80K)<\/li>\n<\/ul>\n<h4>ppm2dp (1999)<\/h4>\n<p>Image format converter for the (now defunct) Deskplayer interactive desktop graphics engine.<\/p>\n<p>ppm2smap: Converts .ppm &#8212;into&#8212; .smap<\/p>\n<blockquote>\n<pre>Usage: ppm2smap [Input Filename] [Output Filename]<\/pre>\n<\/blockquote>\n<p>smap2dp: Concatenates .smap &#8212;onto&#8212; .dp<\/p>\n<blockquote>\n<pre><span style=\"font-size: small;\">Usage:  smap2dp -input name [-delay delay] [ -url url] [-input ...] [-output name] [-version #] delay = 1\/10th seconds url is optional<\/span><\/pre>\n<\/blockquote>\n<p><strong>DOWNLOAD<\/strong><\/p>\n<ul>\n<li><a href=\"http:\/\/WWW.ferzkopp.net\/Software\/ppm2dp\/ppm2dp.tar.gz\">ppm2dp.tar.gz<\/a><\/li>\n<\/ul>\n<h4>dpwatch (2001<\/h4>\n<p>Watchdog program for the Berkshire Products Internal-Serial Watchdog in Command mode which was developed for the Deskplayer servers (a rack of 14 computers) and can be run as a client service that hard-reboots the computer if it becomes unresponsive. Licenced under the GPL; see the file LICENSE in the archive for details.<\/p>\n<blockquote><p>dpwatch &#8211; Berkshire products watchdog driver<br \/>\nDevice settings:<br \/>\n-device dev watchdog device (default: \/dev\/ttyS1)<br \/>\nRuntime settings:<br \/>\n-delay # # seconds delay between commands (default: 60)<br \/>\n-status # # loops between status messages (default: 60)<br \/>\n-error # tolerate # errors before exiting (default: 100) Special commands:<br \/>\n-reset reset computer after 10 seconds (use with caution)<\/p><\/blockquote>\n<p><strong>DOWNLOAD<\/strong><\/p>\n<ul>\n<li><a href=\"http:\/\/WWW.ferzkopp.net\/Software\/dpwatch\/dpwatch.tar,gz\">dpwatch.tar.gz<\/a> (Linux source, 3.6K, .tgz archive)<\/li>\n<\/ul>\n<h4>furbyctl (2000)<\/h4>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"margin: 0px 0px 18px;\" title=\"poor_furby.gif\" src=\"http:\/\/cms.ferzkopp.net\/images\/stories\/poor_furby.gif\" alt=\"poor_furby.gif\" width=\"82\" height=\"156\" align=\"middle\" border=\"0\" hspace=\"5\" vspace=\"5\" \/><\/p>\n<p>Control a Tiger Electronics &#8220;Furby&#8221; [TM] via IR port of your PC. Licenced under the LGPL; see the file COPYING for details.<\/p>\n<p><strong>DOWNLOAD<\/strong><\/p>\n<p><a href=\"http:\/\/www.ferzkopp.org\/Software\/furbyctl\/furbyctl.tar.gz\">[ furbyctl.tar.gz (1k)]<\/a><\/p>\n<h4>asciireflector (1999)<\/h4>\n<p>Network-reflector for ASCII data &#8211; very useful tool to distribute data between different networked programs. Licenced under the GPL; see the file COPYING for details.<\/p>\n<p><strong>DOWNLOAD<\/strong><\/p>\n<p><a href=\"http:\/\/www.ferzkopp.org\/Software\/asciireflector\/asciireflector-1.2.tar.gz\"><strong>[ asciireflector-1.2.tar.gz (10k) ]<\/strong><\/a><\/p>\n<p><strong>README<\/strong><\/p>\n<pre style=\"height: 400px; width: 740px;\">[ asciireflector Ver. 1.2 ]\r\n\r\n(c) under the GPL, A. Schiffler.\r\n\r\nPlease see file LICENSE for GPL notes.\r\n\r\n\r\n[ version history ]\r\n\r\nVer 1.2 - Fri Sep 17 15:36:33 CEST 1999\r\n- Fixed connection count\r\n- Added a few messages\r\n- Fixed PUSH behaviour\r\nVer 1.1 - Sun Aug 29 12:24:30 CEST 1999\r\n- Put timeouts in read routine to fix \"hang\" after clients terminated\r\nVer 1.0 - Thu Aug 19 14:56:04 CEST 1999\r\n- Initial release\r\n\r\n\r\n[ introduction ]\r\n\r\nThe asciireflector is a simple, unix based reflector program that allows\r\nsharing of data between clients through a TCP stream-socket connection. The\r\nreflector reads ASCII lines from each connected client, buffers them in a\r\nshared pool (ringbuffer) and sends all lines back to each client.\r\n\r\n\r\n[ usage and protocol ]\r\n\r\nClient reception is initiated by sending a textline to the reflector. This\r\nwill usually be the data that is to be shared between clients. This line \r\ngets stored in the reflectors buffer unless it is the text \"POLL\". All lines\r\nsend to the reflector have to end with a newline character. If the line is\r\npreceded by the keyword \"PUSH\", the line gets distributed by the reflector\r\nwith the PUSH removed, but no lines get send back to the client. Otherwise\r\nimmediately after the reception from the client, all textlines that have \r\nbeen received since the last sending of text will be written back to the \r\nclient. This sequence is finished when the text \"OVER\" is send from the\r\nreflector. This means no new textlines are in the ringbuffer. To close the\r\nsocket connection with the reflector, send the word \"LOGOUT\". \r\n\r\nNote that the reflector sends the last textline that was received from \r\nthe client back to the client during the next iteration. This can be \r\nused to test if the speed of the network connection is sufficient \r\nto maintain complete reception of the ringbuffer. If the first line \r\nreceived is not equal to the last line send, the ringbuffer has been \r\noverwritten by another client in the mean time, indicating that \r\nreception is too slow. Reflector use should be stopped in such a case.\r\n\r\nThus the client should run the following sequence repeatedly:\r\n\r\n1. Connect to reflector\r\n2.)   Send data\r\n\r\n2.1.) Send data as \"textline\", store as \"last_textline\"\r\n\r\nOR\r\n\r\n2.2) Send \"POLL\"\r\n\r\nOR\r\n\r\n2.3) Send \"PUSH__and__some_text\" to send text without having to receive\r\nanything (i.e. proceed to 4.)\r\n\r\n3.)  Read data\r\n3.1.) Read \"textline\" unless PUSH was send\r\n3.1.2) If first \"textline\" is not \"last_textline\" abort with an error\r\n3.2.) Repeat from 3.1 until \"textline\" is the \"OVER\"\r\n4.) ... do other stuff ...\r\n5.) Goto 2. or send \"LOGOUT\"\r\n\r\nThe use of ASCII and stream-sockets was used for its easy of use and\r\ntransparency - its not very efficient though for realtime applications that\r\nhave to transport a lot of data.\r\n\r\n\r\n[ compilation and test ]\r\n\r\nTo compile the source type\r\n\tmake\r\n\r\nThen run\r\n\tasciireflector\r\n\r\nTo test, connect to the reflector in (a few) different terminal(s) with\r\n\ttelnet localhost 1522\r\nand type a few lines.\r\n\r\nThe program was developed on a RedHat Linux system but should work with\r\nany unix system that provides a pthread implementation.\r\n\r\n\r\n[ limits and settings ]\r\n\r\nThe current (compiled-in defaults) are:\r\n\r\nPort number\t\t1522\r\nConnections\t\t20\r\nLine Length\t\t128 chars (including newline)\r\nSize of Ringbuffer\t1024 lines\r\n\r\nChange the defines in the .h files to adjust to your application.\r\n\r\n<\/pre>\n<h4>CloneIt (2000)<\/h4>\n<p>A Networked Harddisk Replication System<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.ferzkopp.net\/Software\/CloneIt\/clone.jpg\" alt=\"clone.jpg\" align=\"left\" border=\"0\" hspace=\"10\" vspace=\"10\" \/><\/p>\n<p><span style=\"color: #ff0000;\">Please note that CloneIt is now <strong>completely out-of-date<\/strong> for current hardware and not actively developed for over a decade. For modern hardware your best bet would be to search &#8220;<em>The Google<\/em>&#8221; for &#8220;Backup with Knoppix&#8221;.<\/span><\/p>\n<h6>Introduction<\/h6>\n<p>The CloneIt system was created to copy and essentially clone harddisks of <strong>identical<\/strong> PCs through a network. This is a common task when installing server racks or farms or update a computer-lab setup where one deals with identical machines. The system software consists of a Linux boot floppy and a ramdisk floppy with minimal system utilities that can perform the task of copying the complete content of disk devices through a network.<\/p>\n<p>The CloneIt software is not specific to any operating system, since the raw harddrive is beeing copied. The limitation for the use of CloneIt is, that the hardware used in the cloning procedure has to be identical.<\/p>\n<p>CloneIt can also be used to perform a <strong>Backup<\/strong> and <strong>Restore<\/strong> of harddisks to and from files using a Linux server. Refer to <a href=\"http:\/\/www.ferzkopp.net\/Software\/CloneIt\/CloneIt-Backup.html\">this<\/a> document for more information. If you worry about getting the size of your backup files smaller, have a look at this <a href=\"http:\/\/www.ferzkopp.net\/Software\/CloneIt\/CloneIt-Compression.txt\">email<\/a> and the included script.<\/p>\n<p>These disks were prepared for personal use and have not been extensively tested on a variety of platforms &#8211; after all its FREE (as in free beer).<\/p>\n<h6>Backup HD with CloneIt<\/h6>\n<p>Please check this added info and files on how to use CloneIt for <a href=\"http:\/\/www.ferzkopp.net\/Software\/CloneIt\/CloneIt-Backup.html\">Backup<\/a> purposes.<br \/>\n<em><br \/>\n<\/em><\/p>\n<h6>Kernel and Supported Devices<\/h6>\n<p>The distributed boot floppy contains a 2.2.16 vintage kernel with support for the following devices:<\/p>\n<p>Harddisks<\/p>\n<ul>\n<li>IDE<\/li>\n<li>SCSI<\/li>\n<\/ul>\n<p>SCSI controller<\/p>\n<ul>\n<li>AIC 7xxx<\/li>\n<li>BusLogic<\/li>\n<li>AdvanSys<\/li>\n<li>Tekram DC390<\/li>\n<li>Symbios 53c8xx<\/li>\n<li>Initio A100U2W<\/li>\n<li>Initio 9100U<\/li>\n<li>AMI MegaRaid<\/li>\n<\/ul>\n<p>Ethernet<\/p>\n<ul>\n<li>3COM 3c509<\/li>\n<li>3COM 3c90x<\/li>\n<li>ISA NE2000<\/li>\n<li>PCI NE2000<\/li>\n<li>DEC DC21x4x<\/li>\n<li>Intel EtherExpressPro 200<\/li>\n<li>VIA Rhine<\/li>\n<li>Sis 900\/7016<\/li>\n<\/ul>\n<p>The system has been developed and tested on the following systems:<\/p>\n<ul>\n<li>Intel L440GX+ Server board with on-board Adaptec SCSI and Intel EEPro ethernet<\/li>\n<li>Asus Athlon\/IronGate board with IDE drive and 3COM 905B ethernet card<\/li>\n<\/ul>\n<h6>Usage and Software Notes<\/h6>\n<p>The CloneIt software will install itself and run completely from a 4MB ramdisk without mounting any filesystems or interacting in any way with the system harddrives.<\/p>\n<p>During initialization the RedHat configuration tool <em>netconfig<\/em> is used to setup networking with either a static IP or by performing aDHCP query. To test the networking setup, tools such as <em>ifconfig<\/em>, <em>route<\/em> and <em>ping<\/em> are included.<\/p>\n<p>After the computer is networked, one has to find out the device name of the harddisk or partition to clone. The utility fdisk is provided on the system for querying the partition table. Normally one will clone the <em>\/dev\/hda<\/em> (IDE) or <em>\/dev\/sda<\/em> (SCSI) devices that should have been detected during startup.<\/p>\n<p>The command alias <em>clone<\/em> will start up a dialog based script for cloning a device. There are two options at this stage: <em>server<\/em> and <em>client <\/em>. One machine will act as a server and is beeing read from &#8211; the other is the client and is beeing written to. When <em>server<\/em> is choosen, the software will provide a network socket to a CloneIt client that will send the complete content of a device (i.e. the harddisk) that can be selected. When <em>client<\/em> is choosen, one can connect to a give CloneIt server by IP number and write the incoming data to a selected device. The transport programs is implemented using the tools <em>faucet<\/em> and <em>hose <\/em>which are part of the netpipes package (ver 4.0). They are not multicast capable but provide point-to-point connections.<\/p>\n<p>To preserve network bandwidth, the transferred data is gzip compressed (in fast mode) when send by the server and decompressed on the client before beeing written to the target device. This allows parallel clone sessions over the same ethernet to be still feasable.<\/p>\n<p>The boot floppy and ramdisk are build using the yard utility (ver 2.0). All software to create these disks is provided &#8211; so should the distributed kernel NOT work with your system, try to create a new boto floppy using yard.<\/p>\n<h6>Downloads<\/h6>\n<p>Quickstart:<\/p>\n<p>Get rootdisk and bootdisk disk image (i.e. choose a rootdisk from the two provided), unpack them using GZIP and copy them to a 1.44MB HD floppy disk using <em>cat file &gt;\/dev\/fd0<\/em> under Linux or using RAWRITE.EXE under DOS. (GZIP.EXE and RAWRITE.EXE are available with most Linux distributions). Then boot the system using the freshly made bootdisk, insert the rootdisk when asked for and follow instructions on the screen after the system has reached the login prompt.<\/p>\n<ul>\n<li><a href=\"http:\/\/www.ferzkopp.net\/Software\/CloneIt\/cloneit-bootdisk.gz\">cloneit-bootdisk.gz (1.44MB floppy disk image, GZIPped)<\/a><\/li>\n<li><a href=\"http:\/\/www.ferzkopp.net\/Software\/CloneIt\/cloneit-bootdisk2218.gz\">cloneit-bootdisk2218.gz (1.44MB floppy disk image, GZIPped)<\/a><\/li>\n<li><a href=\"http:\/\/www.ferzkopp.net\/Software\/CloneIt\/cloneit-rootdisk.gz\">cloneit-rootdisk.gz (1.44MB floppy disk image, GZIPped)<\/a><\/li>\n<\/ul>\n<p>To use CloneIt for <a href=\"http:\/\/www.ferzkopp.org\/Software\/CloneIt\/CloneIt-Backup.html\">Backups<\/a>:<\/p>\n<ul>\n<li><a href=\"http:\/\/www.ferzkopp.net\/Software\/CloneIt\/netpipes4.0.tar.gz\">netpipes4.0.tar.gz<\/a><\/li>\n<li><a href=\"http:\/\/www.ferzkopp.net\/Software\/CloneIt\/CloneIt-Client.txt\">CloneIt-Client<\/a><\/li>\n<li><a href=\"http:\/\/www.ferzkopp.net\/Software\/CloneIt\/CloneIt-Server.txt\">CloneIt-Server<\/a><\/li>\n<\/ul>\n<p>For advanced users:<\/p>\n<p>To build your own CloneIt disks, use the following set of configuration files for yard (extracts to etc\/yard &#8211; so extract from root directory AFTER yard was installed).<\/p>\n<ul>\n<li><a href=\"http:\/\/www.ferzkopp.net\/Software\/CloneIt\/yard-configuration.tar.gz\">yard-configuration.tar.gz<\/a><\/li>\n<\/ul>\n<p>The following utilities have to be installed as well for the yard build process to work:<\/p>\n<ul>\n<li><a href=\"http:\/\/www.ferzkopp.net\/Software\/CloneIt\/netpipes4.0.tar.gz\">netpipes4.0.tar.gz<\/a><\/li>\n<li><a href=\"http:\/\/www.ferzkopp.net\/Software\/CloneIt\/report.tar.gz\">report.tar.gz<\/a> (run make and copy binaries to \/usr\/bin)<\/li>\n<\/ul>\n<h4>libgaudio (2001)<\/h4>\n<p>Mixing engine for games as game audio library for multi-voice playback. Licenced under the dual MPL\/GPL; see the file sources for details.<\/p>\n<p><strong>DOWNLOAD<\/strong><\/p>\n<p><a href=\"http:\/\/www.ferzkopp.org\/Software\/libgaudio\/libgaudio-1.6.tar.gz\"><strong>[ libgaudio-1.6.tar.gz (596k) ]<\/strong><\/a><\/p>\n<p><a href=\"http:\/\/www.ferzkopp.org\/Software\/libgaudio\/libgaudio-1.6-samples.tar.gz\"><strong>[ libgaudio-1.6-samples.tar.gz (5.95M)]<\/strong><\/a><\/p>\n<p><strong>README<\/strong><\/p>\n<pre style=\"height: 400px; width: 740px;\">libgaudio  -  Game-Audio Library\r\n------------------------------------------------------------\r\n\r\n(C) A. Schiffler, 1999-2001 under the dual MPL\/GPL license. \r\n\r\nPlease see source code for details.\r\nPlease see the file LICENSE for GPL info.\r\n\r\n! Important Note ! \r\n\r\nSince Ver. 1.6 libgaudio usees 'libsoundfile' for all sample loading. \r\nFor more info, see below.\r\n\r\n\r\nIntroduction\r\n============\r\n\r\nlibgaudio is a library to facilitate easy incorporation of sound and sound\r\neffects in games. Samples are loaded into memory and playback is then\r\ntriggered or stopped. The system mixes any number of concurrently playing\r\nsamples together (up to a predefined maximum). Also possible is the\r\ninclusion of a background MP3 soundfile (external program \"mpg123\" required).\r\nSince version 1.4 panning and volume control has been added. Since version 1.5\r\neach playing sample can be controlled individually. \r\n\r\nCurrently this multithreaded library is set to mix a maximum of 12\r\nconcurrent 16bit signed stereo samples at 44100Hz. The included wav2raw.sh\r\nshell-script will take any file with the extension .wav and convert it into\r\nthe proper .raw format used by libgaudio. The total number of samples that\r\ncan be loaded is 256. The total size of samples depends on the main memory\r\nof the computer.\r\n\r\nSystem load on my P3-450 is about 4% for the MP3-player and 0.5-4% for\r\nthe testaudio application.\r\n\r\nSee the sample program \"testaudio.c\" for a demo implementation. Get the\r\nseperatly distributed file \"Sample.mp3\" (any .mp3 will actually do, but it \r\nhas to be called Sample.mp3 for testaudio.c to use it) and \r\nactivate its playback in the test application by editing the Makefile.\r\n\r\nA second sample program called \"halloween.c\" shows how easy it can be to load\r\nmultiple WAV files and play them back at random. This was a great effect during\r\nHalloween night. Start it up with the seperatly distributed \"ScarySounds\" WAV files\r\nfor a cool effect. :-)\r\n\r\n\r\nVersion History\r\n===============\r\n\r\nVer. 1.0 - Wed Sep 22 14:15:01 CEST 1999\r\n* Initial release.\r\n\r\nVer. 1.1 - Wed Sep 29 16:41:01 CEST 1999\r\n* Changed audio format to 16bit\/stereo\/44.1KHz\r\n* Added MP3 background-playback function\r\n\r\nVer. 1.2 - Thu Mar  9 12:20:27 CET 2000\r\n* Changed header to include C++ defines\r\n* Moved Sample.mp3 out of the main distribution\r\n\r\nVer. 1.3 - Thu Apr 27 09:47:44 EDT 2000\r\n* Thanks to Karl Robillard  the following additions\r\n  have been included in this version:\r\n  - Added pauseAudio, unpauseAudio, stopAllSamples, and copySample functions.\r\n  - Added audioValid and audioPaused query macros.\r\n  - All functions handle a failed startAudio.\r\n  - Added comments for each function in the source.\r\n  - Added GAUDIO_RATE to header.\r\n  - Renamed tsample\/tplaying structures to ga_sample\/ga_playing to \r\n    make the name more unique.\r\n  - playBackground now specifies rate to mpg123 (it sometimes played too fast).\r\n  - Re-wrote testaudio.c to take keyboard input.\r\n* Updated README and testaudio.c\r\n\r\nVer. 1.4 - Sat Jul  8 22:08:19 EDT 2000\r\n* Added stereo panning and volume control support.\r\n\r\nVer. 1.5 - Wed Jul 19 17:39:54 EDT 2000\r\n* Changed licensing to a dual MPL\/GPL license.\r\n* Added function to load\/copy only left or right channel of a sample (required\r\n  for panning control).\r\n* Added unique playing ID after each playSample() call for better control \r\n  of individual playing samples.\r\n\r\nVer 1.6 - Tue Dec 12 14:47:11 EST 2000\r\n* Added support for libsndfile (included). \r\n  No more RAW audio loading required. Any WAV file can be loaded now.\r\n* Added ScarySounds collection (distributed seperately) and halloween.c \r\n  demo application.\r\n* Added function to query MP3 stream playing time.\r\n\r\n\r\nCompilation\r\n===========\r\n\r\nCompile and install libsndfile.\r\n\tcd libsndfile-0.0.22\r\n\t.\/configure\r\n\tmake\r\n\tmake install\r\n\tcd ..\r\n\r\nNow, have a look at the comments in the libgaudio Makefile and maybe edit it.\r\n\r\nTo compile the library use\r\n\tmake\r\n\r\nWhen the library is to be linked into your program, add \r\n\t-lpthread -D_REENTRANT_ \r\nfor multithreading support plus the libsoundfile library\r\n\t-L\/usr\/local\/lib -lsndfile\r\n\r\nThe MP3 functionality expects the mpg123 player at \/usr\/bin. \r\nTo restart or queue background MP3s, the main program has to poll the status using \r\ncheckBackground() and restart the MP3 player using playBackground(). libgaudio will\r\nnot do this automatically.\r\n\t\t\r\nNote that the samples have to be using the same rate as libgaudio (default 44.1kHz).\r\n\r\n\r\nFunctions and Procedures\r\n========================\r\n\r\n int startAudio (struct gameaudio *ga, const char *device_name);\r\n\r\n* Start gameaudio system: open device (usually \/dev\/dsp), setup device\r\nparameters, initialize tables, start thread. Returns -1 on error.\r\n\r\n\r\n int stopAudio (struct gameaudio *ga);\r\n\r\n* Stop gameaudio system: turn of all playing sounds, kill thread, close\r\ndevice. Returns -1 on error.\r\n\r\n\r\n void pauseAudio( struct gameaudio* ga );\r\n\r\n* Mutes all audio playback. No return code. \r\nCheck pause-state with the macro audioPaused(ga).\r\n\r\n\r\n void unpauseAudio( struct gameaudio* ga );\r\n\r\n* Turn off muting of audio playback set by pauseAudio(). No return code.\r\nCheck pause-state with the macro audioPaused(ga).\r\n\r\n\r\n int loadSample (struct gameaudio *ga, const char *filename);\r\n int loadSampleLeft (struct gameaudio *ga, const char *filename);\r\n int loadSampleRight (struct gameaudio *ga, const char *filename);\r\n\r\n* Load a (signed 16bit stereo 44100Hz) sample into memory for use with the\r\ngameaudio system. Returns sample id or -1 on error. \r\n\r\nThe alternative functions loadSampleLeft() and loadSampleRight() will only load \r\nthe left or the right channel of a stereo file. This function should help in \r\ncreating sample sets from mono wave files that can be panned using the ctrlSample()\r\nfunction.\r\n\r\nSince version 1.6 gaudio uses libsoundfile for sample loading. Several file formats\r\nare supported. For more information on the available formats refer to the \r\ndocumentation for libsoundfile. The only restriction to the sample is, that the \r\nsample-rate must correspond to libgaudio's rate (since no resampling is done) - \r\nwhich defaults to 44.1kHz. It is possible to load 8bit or mono samples.\r\n\r\n \r\n int copySample( struct gameaudio* ga, void* data, int bytelen );\r\n int copySampleLeft( struct gameaudio* ga, void* data, int bytelen );\r\n int copySampleRight( struct gameaudio* ga, void* data, int bytelen );\r\n\r\n* Copy a (signed 16bit stereo 44100Hz) sample from a memory location \"data\"\r\nfor use with the gameaudio system. Returns sample id or -1 on error.\r\n\r\nThe alternative functions copySampleLeft() and copySampleRight() will only copy \r\nthe left or the right channel of a stereo set. This function should help in \r\ncreating sample sets from sets that have equal volume on each channel to ones\r\nthat can be panned using the ctrlSample() function.\r\n\r\n\r\n int playSample (struct gameaudio *ga, int sample_id, int repeat_count);\r\n\r\n* Play sample referenced by id 'repeat_count' times. if the repeat_count is\r\n0 playing will loop forever. The return code is a negative number corresponding\r\nto a unique playing ID or 0 on error. The playing id can be used to control\r\nthis instance of the playing sample using ctrlSample() or stopSample().\r\n\r\n\r\n void ctrlSample (struct gameaudio *ga, int sample_id, int volume, int pan);\r\n\r\n* Change playback parameters of sample with the give id (sample or playing id).\r\nChange volume of playing sound by adjusting volume parameter in the range 0-256. \r\nAdjust stereo channel panning using the pan variable in the range 0-256.\r\nAt a value of 0 (default) the left channel plays left and the right channel\r\nright. At a value of 128 we have center (mono) playback. At a value of\r\n256 the left channel plays right and the right channel plays left.\r\n\r\n\r\n void stopSample (struct gameaudio *ga, int sample_id);\r\n\r\n* Stop all playing samples with the given id (sample or playing id). No return code.\r\n\r\n\r\n void stopAllSamples( struct gameaudio* ga );\r\n\r\n* Stop all playing samples (regardless of id). Background audio continues to\r\nplay. No return code.\r\n\r\n\r\n void playBackground(struct gameaudio *ga, const char *filename);\r\n\r\n* Start background playing of a MP3 file given in filename.\r\n\r\n\r\n void stopBackground(struct gameaudio *ga);\r\n\r\n* Stop currently playing MP3 stream.\r\n\r\n\r\n int checkBackground(struct gameaudio *ga);\r\n\r\n* Check if the background MP3 stream is playing (1=playing, 0=not playing).\r\n\r\n\r\n float timeBackground(struct gameaudio *ga);\r\n\r\n* If the background stream is playing, this function will return the time of\r\nplayback since start (in seconds) or 0.0 of the stream is not playing.\r\n\r\n\r\nNOTE:\r\nThere are two kinds of ID number used in the library. The sample_id is generated\r\nduring the loading (or copying) of a sample into the libgaudio library. It uniquely \r\nidentifies a specific sample and is always a positive number. The playing_id \r\nis a unique negative number that identifes an instance of a playing sample. Since\r\nthe same sample can be triggered for playback several times, each time the\r\nplaySample() function will return a different number. Both forms of id can be used\r\nto control a playing sample (as in ctrlSample() or stopSample()). Only the sample_id \r\ncan be used to start a sample for playback (as in playSample()).\r\n\r\n\r\nNOTE: \r\nTo use panning effects, either create stereo wave files with only one channel \r\nused for the samples or load using the loadSampleLeft()\/loadSampleRight() functions.\r\nThen control the pan value using ctrlSample().\r\n\r\nNOTE:\r\nSee also the comments in the source code (gaudio.c) for even more gory details on \r\nhow its done.\r\n\r\n<\/pre>\n<p>&nbsp;<\/p>\n<h3>libbgrab (2005)<\/h3>\n<p>Easy to use framegrabber library with many demo programs. Licenced under the GPL\/MPL, see the files in the archive for details.<\/p>\n<p><strong>DOWNLOAD<\/strong><\/p>\n<p><a href=\"http:\/\/www.ferzkopp.net\/Software\/libbgrab\/libbgrab-2.1h.tar.gz\"><strong>[ libbgrab-2.1h.tar.gz (566k)]<\/strong><\/a><\/p>\n<p><strong>README<\/strong><\/p>\n<pre style=\"height: 400px; width: 740px;\">[ libbgrab ]\r\n\r\n\r\n... is an easy to use framegrabber interface library \r\nwith many sample and utility programs ...\r\n(C) A. Schiffler, 1999-2005 under the dual MPL\/GPL license. \r\nPlease see source code for details.\r\nPlease see the file LICENSE.GPL for GPL info.\r\nPlease see the file LICENSE.MPL for MPL info.\r\n\r\n[ Introduction ]\r\n[ ------------ ]\r\nlibbgrab is a video4linux grabbing library to facilitate easy use of the\r\nbrooktree\/conexant (bt848\/bt878) family of framegrabber cards through\r\na few function calls. \r\nTo implement constant throughput and to avoid frame loss delays, triple \r\nbuffering is used through local buffer copying in a separate grabbing thread.\r\nThe library consists of two parts that are usually used together:\r\n1. framegrabber access (bgrab.c\/bgrab.h) \r\n2. xwindows output (xutils.c\/xutils.h)\r\nAdditional routines allow for image processing:\r\n3. Motion JPG compression (RTjpeg.c, RTjpeg.h, mmx.h)\r\n4. MMX optimized image filters (asm\/*) \r\n\r\n[ Examples and Demo Programs ]\r\n[ -------------------------- ]\r\nNote: All demo programs are hardcoded for Tuner\/NTSC input. You have to \r\nmodify the code and recompile for other inputs!\r\n+++ testgrab\r\nSee demo program \"testgrab\" for a quick intro on how to use libbgrab. See\r\nsource code comments for additional usage notes. The source code will\r\nprobably have to be edited to adapt for your video input - it is just a\r\ndemoprogram! Use Q to quit with the live-video window active. Use F and D\r\nto change channels. \r\n\r\n+++ glgrab (GLX only)\r\nA very similar program uses OpenGL as output driver and maps the live \r\nimage as a texture on a polygon - try \"glgrab\" for nicely scaled, \r\nfull-screen output ... not always at full frame rates ;-). Works fine with\r\nmy Matrox G400 and Geforce2MX cards and the GLX drivers.\r\n\r\n+++ asciigrab\r\nAlso included is a demo \"asciigrab\" that converts video in realtime into \r\nASCII CHARACTERS - just start it in a large enough terminal ... . \r\nSee source code for additional usage notes. This program has actually been\r\nexhibited in the \"net_condition\" art exhibition at the ZKM, Karlsruhe,\r\nGermany on a big projection screen http:\/\/www.zkm.de).\r\n\r\n+++ delaygrab\r\nA nice example of using MUCH memory, try \"delaygrab\" in which a few\r\nseconds of video is beeing stored and shown according to a delay-map. If it\r\nruns, try pressing the keys 1, 2 and 3 to switch effects. This effect will\r\nbe used in upcoming exhibitions at the ZKM, Karlsruhe, Germany with\r\ntemperature sensors. A similar program with a network interface was\r\ndeveloped for the world exhibition Expo2000, Hannover 2000 and can be found\r\nin the \"expograb\" directory.\r\n\r\n+++ zoomgrab (3Dfx Glide only)\r\nAlso included is a demo \"zoomgrab\" that shows a live video image at any\r\nscale using a 3dfx graphics card (required). The numbers in \"zoomdef.txt\" \r\ndefine zoom scales in ONE SECOND intervals (range: 0.01 to 200.0, first \r\nnumber in line) and mixer volume settings (range: 0 to 100, second number \r\nin line) that will be smoothly applied to the image and the volume. See\r\nsource code for additional usage notes. This program was also part of an art\r\nexhibition at Weimar, Germany in 1999.\r\n\r\n+++ artcam (3Dfx Glide only)\r\nA similar demo called \"artcam\" also uses glide for display. This demo\r\nchanges the colors of an image in realtime using a precalculated \r\nconversion table.\r\n+++ webcam\r\nAnd then there is the really complete and useful \"webcam\" application - see\r\nthe README in the \/webcam directory for more explanation and usage \r\ninformation of this nice little utility.\r\n\r\n+++ greydetect\r\nA utility program called \"greydetect\" makes measurements of the mean\r\ngreyscale values in rectangular areas. It can be used for scientific\r\nmeasurements. See the README in the \/greydetect subdirectory for more info\r\nand usage information.\r\n\r\n+++ difftrigger\r\nThe tool program \"difftrigger\" can be used as a security or interface \r\napplication to detect changes in images (i.e. from moving objects). \r\nSee the README in the \/difftrigger subdirectory for more info and usage \r\ninformation. Very similar is the application \"tracker\". Here the \r\ndifference images can be used to track the motion within a rectangular\r\narea and send it to an external program via TCP\/IP.\r\n\r\n+++ rgbmix\r\nYet another art-program is the demo \"rgbmix\". It uses three framegrabber\r\ninputs to get b\/w images and mixes them together into a single RGB color\r\noutput image. This might make it into the lobby of a big company someday. \r\nAny buyers ... :-)\r\n\r\n+++ tracker\r\nYet another specialized tracking program is \"tracker\". Again this a program\r\nthat was developed for an installation and requires several other utilities\r\nto be useful (asciireflector and reflector2midi). See the local README for \r\ninformation on this tool. If you want to see it in action, check the passage\r\nfrom the Frankfurt Airport Terminal to the Trainstation June-December 2000.\r\nDiagrams of the installation and documentation are included in the \/tracker \r\ndirectory.\r\n\r\n+++ rtjpegrecord\r\n+++ rtjpegplay\r\nA new addition to libbgrab for capturing live video is RTjpeg. This library \r\nworks only on MMX capable CPUs and provides fast motion Jpeg compression\r\nroutines. The resulting format is NOT compatible with standard MPEG or JPEG\r\nfiles - i.e. one needs the RTjpeg library to decompress the generated stream.\r\nThe sample applications for recording and playback can be found in the \/examples\r\ndirectory. Since the input video format is YUV420 and a color conversion\r\nwould be required for standard RGB X-windows screens, no output will be shown\r\nduring the recording phase. To record use \"rtjpegrecord\" - experiment with the \r\nquality settings for best results. The default setting achieves a 12:1 compression\r\nration at excellent image quality. To view use \"rtjpegplay\" on 16bit bpp screens.\r\nSee also the README files:\r\nRTjpeg\/README\r\ngreydetect\/README\r\nwebcam\/README\r\ndifftrigger\/README\r\nexpograb\/README\r\ntracker\/README\r\n\r\n[ Version History ]\r\n[ --------------- ]\r\n\r\nSee CHANGES file for what has changed.\r\n[ Usage - Step-by-Step Programming Instructions ]\r\n[ --------------------------------------------- ]\r\n\r\n1. Define access structure\r\n..........................\r\nDefine a variable with the \"fgdevice\" structure and use it as pointer \r\nto handle all accesses to the framegrabber. \r\ni.e.:\r\nstruct fgdevice fg;\r\nfg_open_device(&amp;fg,\"\/dev\/video\");\r\n\r\n2. Open (and close) the device\r\n..............................\r\nUse these calls to open the device. A typical device name is \/dev\/video\r\nor \/dev\/video0. \r\nint fg_open_device (struct fgdevice *fg, char *devicename);\r\nint fg_close_device (struct fgdevice *fg);\r\n\r\n3. Get general framegrabber information\r\n.......................................\r\nUse this optional call to retrieve general info and a channel list of the \r\ncard. This can be helpful in debugging and setup of the card. The\r\ninformation gets written to \"stderr\".\r\nint fg_print_info(struct fgdevice *fg); \r\n\r\n4. Setup FPS calculation\r\n........................\r\nBefore grabbing, one can set the update interval for frames-per-second\r\n(FPS) calculation. The FPS is the rate of image retrieval using \r\nfg_get_next_image() call and can be a useful performance parameter. If\r\n\"interval\" is 100, then every 100 calls to fg_get_next_image() the FPS\r\nnumber available through fg_get_fps() will be updated. Useful intervalls\r\nare 1-100.\r\nvoid fg_set_fps_interval(struct fgdevice *fg, int interval);\r\ndouble fg_get_fps(struct fgdevice *fg);\r\n\r\n5. Define the setting and channel values\r\n........................................\r\nTo configure the framegrabber for different input channels and to\r\nprogramm the brightness, contrast and color settings use the following\r\nroutines. The channel setup is required.\r\nint fg_set_channel(struct fgdevice *fg, int channel, int videomode);\r\nint fg_get_setting(struct fgdevice *fg, int which_setting);\r\nint fg_set_setting(struct fgdevice *fg, int which_setting, int value);\r\nChannel defines are these:\r\n#define CHANNEL_TUNER           0\r\n#define CHANNEL_COMPOSITE       1\r\n#define CHANNEL_SVIDEO          2  \r\nThe channel defines can vary from card to card. Please see the output of the\r\nfg_print_info() call for a list of available channel of your card.\r\nVideomode defines are these:\r\n#define VIDEOMODE_PAL\t\tVIDEO_MODE_PAL\t\t\t\r\n#define VIDEOMODE_NTSC\t\tVIDEO_MODE_NTSC\r\n#define VIDEOMODE_SECAM\t\tVIDEO_MODE_SECAM\r\nSetting defines are these:\r\n#define SETTING_BRIGHTNESS\t0\r\n#define SETTING_HUE\t\t1\r\n#define SETTING_COLOUR\t\t2\r\n#define SETTING_CONTRAST\t3\r\nThe value can range from 0 to 32767.\r\nTo setup a tuner frequency for TUNER input use these calls:\r\nregion=REGION_NTSC_CABLE;\r\nchannel=1;\r\nif (fg_set_frequency (&amp;fg, region, channel)!=0) exit(-1);\r\n\r\n6. Start the background grabbing thread\r\n.......................................\r\nNow you want to initiate grabbing at a specific size and format using the\r\nfg_start_grab_image() call. Grabbing will constantly run in a thread in the\r\nbackground. All one has to do now in the main program, is to retrieve \r\nthe latest image through the fg_get_next_image() call. The thread can be \r\nstopped and CPU resources freed, using the fg_stop_grab_image() call. The\r\nthread also stopps when the program terminates.\r\nint fg_start_grab_image (struct fgdevice *fg, int width, int height, int format);\r\nint fg_stop_grab_image (struct fgdevice *fg);\r\nThe format settings are:\r\n#define FORMAT_GREY\t\tVIDEO_PALETTE_GREY\r\n#define FORMAT_RGB565\t\tVIDEO_PALETTE_RGB565\r\n#define FORMAT_RGB24\t\tVIDEO_PALETTE_RGB24\r\n#define FORMAT_RGB32\t\tVIDEO_PALETTE_RGB32\r\n#define FORMAT_YUV422P\t\tVIDEO_PALETTE_YUV422P\r\nThe widht and height settings are usually limited by the framegrabber. \r\nUseful values are typically 32 to 800.\r\n\r\n7. Get new images and use them\r\n..............................\r\nThe fg_get_next_image() blocks until a new image is available and returns\r\nthe image as a pointer. A pointer to the latest image is also stored in the\r\nfgdevice structure. If the grabbing is not active (i.e. the thread is\r\nnot running) the routine returns a NULL pointer.\r\nvoid * fg_get_next_image(struct fgdevice *fg);\r\nchar *curimage;\r\nif (fg_get_next_image(&amp;fg)!=NULL) { \r\ncurimage=(char *)fg.current_image;\r\n}\r\n\r\n8. XWindow output of the images\r\n...............................\r\nNormally we want to see the aquired images on the screen. To do that, the\r\nXWindows utility routines can be used.\r\nFor following sample code shows how this can be done easily (see also\r\ntestgrab.c).\r\n\/\/ Define structure and open window\r\nstruct xwinbuffer xwin; \r\nif (setup_xwinbuffer (&amp;xwin, argv[0], WIDTH, HEIGHT, DEPTH)!=0) exit(-1); \r\n\/\/ ... setup framegrabber ...\r\n\/\/ loop: get images and display them \r\nwhile (1) {\r\nif (fg_get_next_image(&amp;fg)!=NULL) {\r\n\/* Copy image to screenbuffer *\/\r\nmemcpy((char *)xwin.shmimage-&gt;data,(char *)fg.current_image,fg.image_size);\r\n\/* Draw it *\/\r\nsync_xwinbuffer(&amp;xwin);\r\n} \r\n}\r\n\/\/ Close window\r\nif (close_xwinbuffer(&amp;xwin)!=0) exit(-1);\r\n\r\n9. Other features and function\r\n..............................\r\nTwo tables are initialized within the framegrabber device structure that\r\nallow fast color conversion between the RBG565 color-space and Y8 B\/W screen\r\nformats. This can be useful when one grabs greyscale images but want to\r\ndisplay on a 16bit color screen (i.e. the \"greydetect\" utility program).\r\nunsigned short *y8_to_rgb565;\r\nunsigned char  *rgb565_to_y8; \r\nTo convert a 8bit Y8 value (pixel of a B\/W image) to a 16bit RGB pixel:\r\n(unsigned short)outpixel=fg.y8_to_rgb565[(unsigned char)inpixel]\r\nTo convert a 16bit RGB pixel to a Y8 value (pixel of a B\/W image);\r\n(unsigned char)outpixel=fg.rgb565_to_y8[(unsigned short)inpixel]\r\n\r\n[ Compilation and Running the Programs ]\r\n[ ------------------------------------ ]\r\n- Make sure you have the required modules for video input loaded. The\r\nprovided \"loadbttv.sh\" might be used to load the drivers. It probably\r\nrequires customization of tuner type (type=XX) and the card type (card=YY).\r\nEspecially the tuner needs optne manual settings.\r\n- The include file \"linux\/videodev.h\" has to be available.\r\n- Create the video devices if they are not alreay there. (Run \"cd \/dev; \r\n.\/MAKEDEV video\").  \r\n- Edit the optimization flags setting in the \"Makefile\". Possible options\r\nare for the Pentium and Athlon CPUs or a general setting (default).\r\n- Optionally install glide libraries if you have a 3Dfx graphics card.\r\n- Run \"make clean; make\" to compile. \r\n- Test with \"testgrab\" (running XWindows at depth 16 weight 565) that can be\r\nfound in the .\/examples directory.\r\n- If you have a 3Dfx graphics card and the glide libraries installed, run\r\n\"make glideprgs\" in the .\/examples directory. Test with \"artcam\".\r\n- If you have a 3D graphics card with GL\/GLX drivers installed try \r\n\"make glprgs\" in the .\/examples directory. \r\nMost demos and testprograms have the video device and framegrabber setup\r\nhardcoded. To get an image, one probably needs to edit the source and \r\nrecompile. Notable exceptions are: \"webcam\" and \"greydetect\" with a\r\ncommand-line interface.\r\n- To install the assembly demos and the tracker application, get NASM and\r\ninstall it (see below). Then run \"make\" in the .\/asm and .\/tracker \r\ndirectories.\r\n\r\n[ xutil - The XWindows utility functions ]\r\n[ -------------------------------------- ]\r\nThese functions are added to the bgrab-library to facilitate easy X-Window\r\ncreation and use. See sample programs for details.\r\n----- IMPORTANT note on shared memory use ---------------------------------- \r\nCrucial is the proper closure and removal of the X-Windows shared \r\nmemory segment in the close_xwinbuffer() function. After abnormal program\r\ntermination (i.e. programm chashes), one usually has to manually remove \r\nthe shared-memory segment using \"ipcs\" (to check for the SHM ID) and \r\n\"ipcrm shm ID\" (to actually remove the segment).\r\nThe best method is to install an exit handler that calls close_xwinbuffer()\r\nand\/or quit by user request only, rather than using Ctrl-C or coredumps :-). \r\n----------------------------------------------------------------------------\r\n\r\nA.) Basic screen setup and drawing routines\r\n...........................................\r\nint setup_xwinbuffer(struct xwinbuffer *xwin, char *prgname, int width, int height, int depth);\r\nint sync_xwinbuffer(struct xwinbuffer *xwin);\r\nint close_xwinbuffer (struct xwinbuffer *xwin);\r\n\r\nB.) Keyboard and Mouse information\r\n..................................\r\nint keypoll_xwinbuffer (struct xwinbuffer *xwin, KeySym *key, int *button, int *mousex, *mousey);\r\nSee \"Examples\" section below.\r\n\r\nC.) Simple Drawing Commands\r\n...........................\r\nvoid vline (struct xwinbuffer *xwin, int x, int y1, int y2, int color);\r\nvoid hline (struct xwinbuffer *xwin, int x1, int x2, int y, int color);\r\nvoid drawchar (struct xwinbuffer *xwin, int x, int y, char c, unsigned int color);\r\nvoid drawstring (struct xwinbuffer *xwin, int x, int y, char *s, unsigned int color);\r\nvoid drawpixel(struct xwinbuffer *xwin, int x, int y, unsigned int color);\r\nvoid drawline(struct xwinbuffer *xwin, int x1, int y1, int x2, int y2, unsigned int color); \r\n\r\nD.) Video mode switching\r\n........................\r\nvoid videoModeChange(struct xwinbuffer *xwin, int width, int height);\r\nvoid videoModeReset(struct xwinbuffer *xwin);\r\n \r\nExamples\r\n........\r\nTo implement keyboard\/mouse functionality use the following code fragment.\r\n\/\/ Sample keyboard polling\r\n\/\/ ...\r\nKeySym key;\r\nint button;\r\nint x,y;\r\n\/\/ ...\r\n\/* Poll keyboard *\/\r\nif (keypoll_xwinbuffer (&amp;xwin, &amp;key, &amp;button, &amp;x, &amp;y)) {\r\n\/* Check for mouse button press *\/\r\nif (button) {\r\nprintf (\"Mouse was pressed at coordinate (%i,%i)\\n\",x,y);\r\n}\r\n\/* Check for keyboard press +\/\r\nswitch (key) {\r\ncase XK_Home:\r\nbreak;\r\ncase XK_Left:\r\nbreak;\r\ncase XK_Right:\r\nbreak;\r\ncase XK_Up:\r\nbreak;\r\ncase XK_Down:\r\nbreak;\r\n\/\/     ...\r\ncase XK_q:\r\nbreak; \r\n}\r\n}\r\n\r\n[ Assembly Image Processing Routines]\r\n[-----------------------------------]\r\nExperimental MMX assembly routines for image processing tasks have been\r\nadded as of version 2.1. They require the installation of the NASM compiler.\r\nThe NASM homepage with links for RPMs and source archives of NASM is here:\r\nhttp:\/\/www.web-sites.co.uk\/nasm\/\r\nOnce installed, the documentation for NASM 0.98 can be found here:\r\nfile:\/usr\/doc\/nasm-0.98\/html\/nasmdoc0.html\r\nTo compile the routines use:\r\nmake assembly\r\nA demo program that uses the one of the assembly routines is called \r\n'testabsdiff' and can be compiled within the \/examples directory using:\r\nmake asmprgs\r\nAnother program that relies on the assembly routines is 'tracker'.\r\n\r\n[ Bugs &amp; TO-DO List ]\r\n[ ----------------- ]\r\nI've got several 2.2 and 2.3 beta source trees hanging around, but my new \r\njob doesn't leave me much time. Maybe later ...\r\nTO-DO\/NICE-TO-HAVE: \r\n- Webcam appliction with support for logging and\/or statistics.\r\n- Webcam with multipart-mime support.\r\n- Generic command line setup for all programs.\r\n- Assembly image-transfer routines that do color conversion.\r\n<\/pre>\n<h4><\/h4>\n<h4>SDL_bgrab<\/h4>\n<p>SDL based framegrabber client library with a threaded image capture architecture.<\/p>\n<p><strong>Downloads<\/strong><\/p>\n<p><a href=\"http:\/\/www.ferzkopp.net\/Software\/SDL_bgrab\/SDL_bgrab-1.0.0.tar.gz\">SDL_bgrab-1.0.0.tar.gz<\/a><\/p>\n<p><strong>README<\/strong><\/p>\n<pre style=\"height: 400px; width: 740px;\">Intro\r\n-----\r\n\r\nSDL convertion of libbgrab (a framegrabber lib from the same author).\r\n\r\n\r\nThe library uses a separate thread to grab images into a \"triple buffer\" \r\nqueue independent of an external \"game loop\". This uses memory bandwidth\r\nbut makes it easy to integrate live video into other applications. \r\nImages are always grabbed at 32bit RGBx resolutions. YUV grabbing is \r\ncurrently not implemented. To improve image quality, several deinterlace \r\nalgorithms are available.\r\n\r\nThis library is licenced under the LGPL, see the file LICENSE for details. \r\n\r\n\r\nSupported Platforms\r\n-------------------\r\n\r\nThe library compiles and is tested on a Linux target.\r\n\r\nWindows will probably never be supported due to the lack of v4l API.\r\nOther SDL platforms might be supported in the future if an API \r\nsimilar to v4l is available.\r\n\r\n\r\nInstallation and Test\r\n---------------------\r\n\r\nTo compile the library your need the SDL 1.2 installed from source or \r\ninstalled with the 'devel' RPM package. For example on Mandrake, run:\r\n\turpmi libSDL1.2-devel\r\n\r\nThe run\r\n\t.\/autogen.sh\t(optional)\r\n\t.\/configure\r\n\tmake\r\n\tmake install\r\n\tldconfig\r\n\r\nto compile and install the library. The default location for the \r\ninstallation is \/usr\/local\/lib and \/usr\/local\/include. The libary \r\npath \/usr\/local\/lib might need to be added to the file\r\n\t\/etc\/ld.so.conf\r\nThen run ldconfig again.\r\n\r\n\r\nAPI and Usage\r\n-------------\r\n\r\nCreate a variable of type tSDL_bgrab and reference a pointer to it on every \r\nlibrary call.\r\n\r\n\r\n  int bgrabOpen(tSDL_bgrab *bgrab, char *device);\r\n\r\nOpen framegrabber device. \"device\" is usually \"\/dev\/video\"\r\n\r\n\r\nvoid bgrabSetFpsInterval(tSDL_bgrab *bgrab, int interval);\r\n\r\n  double bgrabGetFps(tSDL_bgrab *bgrab);\r\n\r\nQuery internal framerate tracker.\r\n\r\n\r\n  int bgrabPrintInfo(tSDL_bgrab *bgrab);\r\n\r\nPrint v4l device info.\r\n\r\n\r\n  int bgrabGetSetting(tSDL_bgrab *bgrab, int which_setting);\r\n  int bgrabSetSetting(tSDL_bgrab *bgrab, int which_setting, int value);\r\n\r\nGet and set device settings (contrast, brightness, etc.). See the SDL_bgrab.h\r\nfile for the relevant device for the \"which_setting\" variable.\r\n\r\n\r\n  int bgrabSetChannel(tSDL_bgrab *bgrab, int channel, int bgrabmode);\r\n\r\nSet the input channel (tuner, svideo, composite) and mode (pal, ntsc, secam)\r\nfor your device.\r\n\r\n\r\n  int bgrabSetFrequency(tSDL_bgrab *bgrab, int region, int index);\r\n\r\nSet the tuner frequency (when in tuner mode). See the SDL_bgrab.h file for\r\nregion settings.\r\n\r\n\r\n  int bgrabStart (tSDL_bgrab *bgrab, int width, int height, int bgra);\r\n  int bgrabStop(tSDL_bgrab *bgrab);\r\n\r\nStart and stop the grabbing thread. The \"width\" and \"height\" parameters define\r\nthe size of the 32bit RGB buffer to use. Set the \"bgra\" flag to 1 for some\r\ncards that store pixels in BGR order.\r\n\r\n\r\n  int bgrabBlitFramebuffer(tSDL_bgrab *bgrab, SDL_Surface *screen, int deinterlace);\r\n\r\nBlit the current franebuffer to a target surface. Set \"deinterlace\" to a number &gt;1\r\nto enable processing of the frame with various deinterlace algorithms. Use TestVideo\r\nto see the various algorithms at work (and check their CPU usage).\r\n\r\n\r\n  int bgrabClose(tSDL_bgrab *bgrab);\r\n\r\nClose device. Be sure to call bgrabStop() before. \r\n\r\n\r\nQuickie Sample Program\r\n----------------------\r\n\r\nSDL_Surface *screen;\r\ntSDL_bgrab bgrab;\r\nint drawing;\r\n\/\/ ... open screen ...\r\nbgrabOpen(&amp;bgrab,\"\/dev\/video\");\r\nbgrabSetChannel(&amp;bgrab, CHANNEL_COMPOSITE, VIDEOMODE_NTSC);\r\nbgrabStart (&amp;bgrab, 320, 240, 0);\r\ndrawing=1;\r\nwhile (drawing) {\r\n if (bgrabBlitFramebuffer(&amp;bgrab, screen,  1)) {\r\n  SDL_UpdateRect(screen,0,0,0,0);\r\n }\r\n SDL_Delay(10);\r\n}\r\nbgrabStop(&amp;bgrab);\r\nbgrabClose(&amp;bgrab);\r\n\r\n\r\nTest Program\r\n------------\r\n\r\nChange to the .\/Test directory and run\r\n\t.\/configure\r\n\tmake\r\nto creates a sample TV player. You can check and maybe edit the \r\ndefault settings in the source for your device and input.\r\n\r\nBest is to see some command line options. Run:\r\n\t.\/TestVideo -help\r\n\r\n\r\nUse the source code TestVideo.c for some sample code on how to \r\ncreate a simple TV viewer in your SDL app.\r\n\r\n\r\nDevelopment and To-Do\r\n---------------------\r\n\r\nHere is what I'd like to do.\r\n\r\n* Implement a YUV mode for the lib.\r\n* Make better use of v4l API capabilities \r\n  (i,e, when we have &gt;2 mmap buffers, use them).\r\n* Add faster (MMX) deinterlace routines.\r\n* Add some other image-improvement and -modification \r\n  algorithms (greyscale, sharpen, soften, temporal smooth, etc.).\r\n\r\n\r\nThanks\r\n------\r\n\r\nThanks to 'AppWares Development Group' for supporting this project - please \r\nvisit http:\/\/www.appwares.com for more information.\r\n\r\n\r\nContributors\r\n------------\r\n\r\n* None so far. Want to be the first one ...??? Get coding!<\/pre>\n<p>&nbsp;<\/p>\n<h4>SDL_vnc<\/h4>\n<p>SDL based VNC client library with a threaded renderer.<\/p>\n<p>Current Development<\/p>\n<ul>\n<li><a href=\"https:\/\/sourceforge.net\/projects\/sdlvnc\/\">Sourceforge Project Page<\/a><\/li>\n<li><a href=\"https:\/\/sourceforge.net\/scm\/?type=svn&amp;group_id=342775\">SVN Repository<\/a><\/li>\n<\/ul>\n<p><strong>Downloads<\/strong><\/p>\n<p><a href=\"http:\/\/www.ferzkopp.net\/Software\/SDL_vnc\/SDL_vnc-1.0.0.tar.gz\">SDL_vnc-1.0.0.tar.gz<\/a>\u00a0 (old)<\/p>\n<p><strong>README<\/strong><\/p>\n<pre style=\"height: 400px; width: 740px;\">Intro\r\n-----\r\n\r\nThe SDL_vnc library was created to offer a VNC client system that:\r\n- is LGPL licensed and can be used in commercial applications\r\n- integrates with SDL (framebuffer is a SDL surface)\r\n- IO and processing runs as a thread, so it does not interfere \r\n  with a traditional \"game loop\"\r\n\r\n\r\nSupported Platforms\r\n-------------------\r\n\r\nThe library compiles and is tested on a Linux target with a\r\nTightVNC server running on windows.\r\n\r\n\r\nInstallation and Test\r\n---------------------\r\n\r\nTo compile the library your need the SDL 1.2 installed from source or \r\ninstalled with the 'devel' RPM package. For example on Mandrake, run:\r\n\turpmi libSDL1.2-devel\r\n\r\nThe run\r\n\t.\/autogen.sh\t(optional)\r\n\t.\/configure\r\n\tmake\r\n\tmake install\r\n\tldconfig\r\n\r\nto compile and install the library. The default location for the \r\ninstallation is \/usr\/local\/lib and \/usr\/local\/include. The libary \r\npath \/usr\/local\/lib might need to be added to the file\r\n\t\/etc\/ld.so.conf\r\nThen run ldconfig again.\r\n\r\n\r\nAPI and Usage\r\n-------------\r\n\r\nint vncConnect(tSDL_vnc *vnc, char *host, int port, char *mode, \r\n               char *password, int framerate);\r\n\r\n  Connect to VNC server \r\n\r\n  Parameters\r\n   vnc  = pointer to tSDL_vnc structure\r\n   host = hostname or hostip\r\n   port = port\r\n   mode = submode,submode,...\r\n    submode =\traw | \r\n    \t\tcopyrect | \r\n    \t\trre | \r\n    \t\tcorre(broken) |\r\n    \t\thextile | \r\n    \t\tzrle(unimplemented) | \r\n    \t\tcursor | \r\n    \t\tdesktop(unimplemented)\r\n   password = text\r\n   framerate = 1 to 100\r\n\r\n  Notes;\r\n   - Returns 1 if connection was established, 0 otherwise.\r\n   - This call will establish a connection to the VNC server requesting \r\n     a 32bit transfer.\r\n   - framerate is the rate in which update requests are send to the server.\r\n\r\n\r\n \r\nint vncBlitFramebuffer(tSDL_vnc *vnc, SDL_Surface *target, SDL_Rect *urec);\r\n\r\n Blit current framebuffer to target\r\n\r\n Parameters\r\n  vnc = pointer to tSDL_vnc structure\r\n  target = target surface to blit framebuffer to\r\n  urec = pointer to SDL_Rect structure to receive updated area, can be NULL\r\n\r\n  Notes:\r\n   - Returns 1 if the blit occured, 0 otherwise.\r\n   - Only blits if framebuffer exists and was updated. \r\n   - Updated region is stored in urec if it is not NULL.\r\n   - Framebuffer is a RGB surface.\r\n\r\n\r\n \r\nint vncBlitCursor(tSDL_vnc *vnc, SDL_Surface *target, SDL_Rect *trec);\r\n\r\n  Blit current cursor to target\r\n\r\n  Parameters\r\n   vnc = pointer to tSDL_vnc structure\r\n   target = target surface to blit cursoe to\r\n   trec = pointer to SDL_Rect structure to receive updated area, can be NULL\r\n \r\n  Notes\r\n   - Returns 1 if blit occured, 0 otherwise \r\n   - Blitting is at the trec position.\r\n   - Cursor image is a 32x32 RGBA image (with A set).\r\n\r\n\r\n\r\n\r\nSDL_Rect vncCursorHotspot(tSDL_vnc *vnc);\r\n\r\n  Return cursor hotspot location\r\n\r\n  Parameters\r\n   vnc = pointer to tSDL_vnc structure\r\n\r\n  Notes: \r\n   - In the returned parameter, only .x and .y are used.\r\n\r\n\r\n\r\nint vncClientKeyevent(tSDL_vnc *vnc, unsigned char downflag, unsigned int key);\r\nint vncClientPointerevent(tSDL_vnc *vnc, unsigned char buttonmask, \r\n                          unsigned short x, unsigned short y);\r\n\r\n  Send keyboard and pointer events to server\r\n\r\n  Parameters\r\n   vnc = pointer to tSDL_vnc structure\r\n   downflag = 1 for key is down, 0 for key is up\r\n   key = VNC keycode (basically X11\/keysymdef.h plus some special codes)\r\n   buttonmask = VNC mousebutton bitmask 1=left, 2-=middle, 4=right, 8\/16=wheel\r\n   x,y = mouse position\r\n\r\n  Notes:\r\n   - The client is responsible for key-code conversions into the VNC format.\r\n\r\n\r\n\r\nvoid vncDisconnect(tSDL_vnc *vnc);\r\n\r\n  Disconnect from vnc server\r\n\r\n  Parameters\r\n   vnc = pointer to tSDL_vnc structure\r\n\r\n  Notes:\r\n   - Closes socket connection and kills client thread. \r\n\r\n\r\nTest Program\r\n------------\r\n\r\nChange to the .\/Test directory and run\r\n\t.\/configure\r\n\tmake\r\nto creates a VNC client program. Run\r\n\t.\/TestVNC -help\r\n\r\nTypically one connects to a VNC server like this:\r\n\r\n\t.\/TestVNC -server myserver -password mypass\r\n\r\n\r\nAlso see the source code TestVNC.c for sample code on how to \r\ncreate a simple VNC client.\r\n\r\n\r\nDevelopment and To-Do\r\n---------------------\r\n\r\nOne can edit the SDL_vnc.c code to enable extensive debugging by setting the\r\nDEBUG flag.\r\n\r\nTODO:\r\n- Add function to query server framebuffer size after connect.\r\n- Fix CoRRE code\r\n- Implement Desktop pseudoencoding\r\n- Implement Bell (as callback)\r\n- Implement ClientCutText\r\n- Implement ZRLE protocol\r\n- Implement tight protocol and options (zlib,tight,zlibhex)\r\n  (Anyone have the specs for this?)\r\n- Improved speed and interactive response\r\n  (Implement a threaded socket reader. Check all code for optimizations.)\r\n  ('vncviewer' feels a lot faster and more interactive.)\r\n- Create proper SDL_keysym --&gt; VNC key conversion routine.\r\n- Add local-cursor sample code to TestVNC program.\r\n\r\n\r\nThanks\r\n------\r\n\r\nThanks to 'AppWares Development Group' for supporting this project - please \r\nvisit http:\/\/www.appwares.com for more information.\r\n\r\n\r\nContributors\r\n------------\r\n\r\n* See AUTHORS<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>My collection of historical open source code written over the years as part of the various ventures and involvements &#8211; mostly in C and Linux based &#8211; for archival purpose.<\/p>\n","protected":false},"author":1,"featured_media":138,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[22],"tags":[30,36,28,29,31,37,25],"class_list":["post-54","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-software","tag-audio","tag-c","tag-framegrabber","tag-games","tag-media-art","tag-sdl","tag-unix"],"_links":{"self":[{"href":"https:\/\/www.ferzkopp.net\/wordpress\/wp-json\/wp\/v2\/posts\/54","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ferzkopp.net\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ferzkopp.net\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ferzkopp.net\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ferzkopp.net\/wordpress\/wp-json\/wp\/v2\/comments?post=54"}],"version-history":[{"count":17,"href":"https:\/\/www.ferzkopp.net\/wordpress\/wp-json\/wp\/v2\/posts\/54\/revisions"}],"predecessor-version":[{"id":137,"href":"https:\/\/www.ferzkopp.net\/wordpress\/wp-json\/wp\/v2\/posts\/54\/revisions\/137"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ferzkopp.net\/wordpress\/wp-json\/wp\/v2\/media\/138"}],"wp:attachment":[{"href":"https:\/\/www.ferzkopp.net\/wordpress\/wp-json\/wp\/v2\/media?parent=54"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ferzkopp.net\/wordpress\/wp-json\/wp\/v2\/categories?post=54"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ferzkopp.net\/wordpress\/wp-json\/wp\/v2\/tags?post=54"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}