Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- { vfp -- pascal units for support of video for linux devices
- Version 0.5b
- Copyright (C) 1999-2002 Stefan Ziegenbalg
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version
- 2 of the License, or (at your option) any later version.
- This software is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
- You should have received a copy of the GNU General Public
- License along with this program; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
- !}
- unit videodev;
- {$PACKRECORDS C}
- //define[_IOC_NRBITS][8];
- //define[_IOC_TYPEBITS][8];
- //define[_IOC_SIZEBITS][14];
- //define[_IOC_DIRBITS][2];
- //define[_IOC_NRSHIFT][0]
- //define[_IOC_TYPESHIFT][(_IOC_NRSHIFT+_IOC_NRBITS)]
- //define[_IOC_SIZESHIFT][(_IOC_TYPESHIFT+_IOC_TYPEBITS)]
- //define[_IOC_DIRSHIFT][(_IOC_SIZESHIFT+_IOC_SIZEBITS)]
- //define[_IOC(][,#1,#2,#3);][((#0 shl _IOC_DIRSHIFT) or (#1 shl _IOC_TYPESHIFT) or (#2 shl _IOC_NRSHIFT) or (#3 shl _IOC_SIZESHIFT))]
- //define[_IOW(][,#1,#2)][_IOC(1,ord('#0'),#1,sizeof(#2));]
- //define[_IOR(][,#1,#2)][_IOC(2,ord('#0'),#1,sizeof(#2));]
- //define[_IOWR(][,#1,#2)][_IOC(3,ord('#0'),#1,sizeof(#2));]
- { *********************************************************************** }
- { ******* INTERFACE ***************************************************** }
- { *********************************************************************** }
- interface
- { ******* video_capability ******************************************* }
- const VID_TYPE_CAPTURE = 1; { Can capture }
- VID_TYPE_TUNER = 2; { Can tune }
- VID_TYPE_TELETEXT = 4; { Does teletext }
- VID_TYPE_OVERLAY = 8; { Overlay onto frame buffer }
- VID_TYPE_CHROMAKEY = 16; { Overlay by chromakey }
- VID_TYPE_CLIPPING = 32; { Can clip }
- VID_TYPE_FRAMERAM = 64; { Uses the frame buffer memory }
- VID_TYPE_SCALES = 128; { Scalable }
- VID_TYPE_MONOCHROME = 256; { Monochrome only }
- VID_TYPE_SUBCAPTURE = 512; { Can capture subareas of the image }
- type video_capability = record
- name : array[0..31] of char;
- typ : longint; { see VID_TYPE_* }
- channels : longint; { Number of channels }
- audios : longint; { Number of audio devices }
- maxwidth : longint; { Supported width }
- maxheight : longint; { Supported height }
- minwidth : longint; { Supported width }
- minheight : longint; { Supported height }
- end;
- procedure get_video_capability(fd:longint; var vc:video_capability); { fd : file descriptor }
- function vid_type_str(i:longint):string;
- { ******* video_channel ********************************************** }
- const VIDEO_VC_TUNER = 1; { Channel has a tuner }
- VIDEO_VC_AUDIO = 2; { Channel has audio }
- VIDEO_TYPE_TV = 1;
- VIDEO_TYPE_CAMERA = 2;
- VIDEO_MODE_PAL = 0;
- VIDEO_MODE_NTSC = 1;
- VIDEO_MODE_SECAM = 2;
- VIDEO_MODE_AUTO = 3;
- type video_channel = record
- channel : longint;
- name : array[0..31] of char;
- tuners : longint;
- flags : dword; { see VIDEO_VC_* }
- typ : word; { see VIDEO_TYPE_* }
- norm : word; { Norm set by channel, see VIDEO_MODE_* }
- end;
- procedure get_video_channel(fd,c:longint; var vc:video_channel); { fd : file decsriptor, c:channel }
- procedure set_video_channel(fd:longint; var vc:video_channel); { fd : file descriptor }
- function video_vc_str(i:longint):string;
- function video_type_str(i:longint):string;
- function video_mode_str(i:longint):string[15];
- { ******* video_tuner ************************************************ }
- const VIDEO_TUNER_PAL = 1;
- VIDEO_TUNER_NTSC = 2;
- VIDEO_TUNER_SECAM = 4;
- VIDEO_TUNER_LOW = 8; { Uses KHz not MHz }
- VIDEO_TUNER_NORM = 16; { Tuner can set norm }
- VIDEO_TUNER_STEREO_ON = 128; { Tuner is seeing stereo }
- VIDEO_TUNER_RDS_ON = 256; { Tuner is seeing an RDS datastream }
- VIDEO_TUNER_MBS_ON = 512; { Tuner is seeing an MBS datastream }
- type video_tuner = record
- tuner : longint;
- name : array[0..31] of char;
- rangelow,rangehigh : dword; { Tuner range }
- flags : dword; { see VIDEO_TUNER_* }
- mode : word; { see VIDEO_MODE_* }
- signal : word; { Signal strength 16bit scale }
- end;
- procedure get_video_tuner(fd,c:longint; var t:video_tuner); { fd : file decsriptor, c : tuner }
- procedure set_video_tuner(fd:longint; var t:video_tuner); { fd : file descriptor }
- function video_tuner_str(i:longint):string;
- procedure setfreq(fd:longint; f:dword); { fd : file descriptor, f : frequency }
- function getfreq(fd:longint):dword; { fd : file descriptor, result : frequency }
- { ******* video_picture *********************************************** }
- const VIDEO_PALETTE_GREY = 1; { Linear greyscale }
- VIDEO_PALETTE_HI240 = 2; { High 240 cube (BT848) }
- VIDEO_PALETTE_RGB565 = 3; { 565 16 bit RGB }
- VIDEO_PALETTE_RGB24 = 4; { 24bit RGB }
- VIDEO_PALETTE_RGB32 = 5; { 32bit RGB }
- VIDEO_PALETTE_RGB555 = 6; { 555 15bit RGB }
- VIDEO_PALETTE_YUV422 = 7; { YUV422 capture }
- VIDEO_PALETTE_YUYV = 8;
- VIDEO_PALETTE_UYVY = 9; { The great thing about standards is ... }
- VIDEO_PALETTE_YUV420 = 10;
- VIDEO_PALETTE_YUV411 = 11; { YUV411 capture }
- VIDEO_PALETTE_RAW = 12; { RAW capture (BT848) }
- VIDEO_PALETTE_YUV422P = 13; { YUV 4:2:2 Planar }
- VIDEO_PALETTE_YUV411P = 14; { YUV 4:1:1 Planar }
- VIDEO_PALETTE_YUV420P = 15; { YUV 4:2:0 Planar }
- VIDEO_PALETTE_YUV410P = 16; { YUV 4:1:0 Planar }
- VIDEO_PALETTE_PLANAR = 13; { start of planar entries }
- VIDEO_PALETTE_COMPONENT = 7; { start of component entries }
- type video_picture=record
- brightness : word;
- hue : word;
- colour : word;
- contrast : word;
- whiteness : word; { b/w only }
- depth : word; { capture depth }
- palette : word; { see VIDEO_PALETTE_* }
- end;
- procedure get_video_picture(fd:longint; var vp:video_picture); { fd : file descriptor }
- procedure set_video_picture(fd:longint; var vp:video_picture); { fd : file descriptor }
- function video_palette_str(i:longint):string[15];
- { ******* video_audio *********************************************** }
- const VIDEO_AUDIO_MUTE = 1;
- VIDEO_AUDIO_MUTABLE = 2;
- VIDEO_AUDIO_VOLUME = 4;
- VIDEO_AUDIO_BASS = 8;
- VIDEO_AUDIO_TREBLE = 16;
- VIDEO_SOUND_MONO = 1;
- VIDEO_SOUND_STEREO = 2;
- VIDEO_SOUND_LANG1 = 4;
- VIDEO_SOUND_LANG2 = 8;
- type video_audio = record
- audio : longint; { audio channel }
- volume : word; { if settable }
- bass,treble : word;
- flags : dword; { see VIDEO_AUDIO }
- name : array[0..15] of char;
- mode : word; { see VIDEO_SOUND }
- balance : word; { Stereo balance }
- step : word; { Step actual volume uses }
- end;
- procedure get_video_audio(fd:longint; var va:video_audio); { fd : file descriptor }
- procedure set_video_audio(fd:longint; var va:video_audio); { fd : file descriptor }
- function video_audio_str(i:longint):string[15];
- function video_sound_str(i:longint):string[15];
- { ******* video_windows *********************************************** }
- const VIDEO_WINDOW_INTERLACE = 1;
- VIDEO_CLIP_BITMAP = -1; { bitmap is 1024x625, a '1' bit represents a clipped pixel }
- VIDEO_CLIPMAP_SIZE = (128 * 625);
- type video_clip=record { clip area }
- x,y : longint;
- width,height : longint;
- next : ^video_clip;
- end;
- type video_window=record
- x,y : dword; { Position of window }
- width,height : dword; { Its size }
- chromakey : dword;
- flags : dword;
- clips : ^video_clip; { Set only }
- clipcount : longint;
- end;
- procedure get_video_window(fd:longint; var w:video_window); { fd : file descriptor }
- procedure set_video_window(fd:longint; var w:video_window); { fd : file descriptor }
- { ******* video_capture ********************************************* }
- const VIDEO_CAPTURE_ODD = 0;
- VIDEO_CAPTURE_EVEN = 1;
- type video_capture=record
- x,y : dword;
- width,height : dword;
- decimation : word;
- flags : word;
- end;
- procedure get_video_capture(fd:longint;var c:video_capture); { fd : file descriptor }
- procedure set_video_capture(fd:longint;var c:video_capture); { fd : file descriptor }
- { ******* video_buffer *********************************************** }
- type video_buffer=record { frame buffer of the video card }
- base : pointer;
- height : longint;
- width : longint;
- depth : longint;
- bytesperline : longint;
- end;
- procedure get_video_buffer(fd:longint;var vb:video_buffer); { fd : file descriptor }
- procedure set_video_buffer(fd:longint;var vb:video_buffer); { fd : file descriptor }
- { ******* video_mmap ************************************************* }
- type video_mmap = record { for grabbing one frame }
- frame : longint; { frame to grab (0 - video_mbuf.frames-1) }
- height,width : longint; { image size }
- format : longint; { see VIDEO_PALETTE_* }
- end;
- procedure grab_video_mmap(fd:longint; mmap:video_mmap); { fd : file descriptor}
- { ******* video_key ************************************************** }
- type video_key = record
- key : array[0..7] of byte;
- flags : dword;
- end;
- procedure get_video_key(fd:longint; key:video_key);
- { ******* video_mbuf ************************************************* }
- const VIDEO_MAX_FRAME = 32;
- type video_mbuf = record { info about the mmap memory for grabbing }
- size : longint; { total memory to map }
- frames : longint; { frames }
- offsets : array[0..VIDEO_MAX_FRAME-1] of longint;
- end;
- procedure get_video_mbuf(fd:longint; var mb:video_mbuf); { fd : file descriptor }
- { ******* video_unit ************************************************* }
- type video_unit = record
- video : longint; { Video minor }
- vbi : longint; { VBI minor }
- radio : longint; { Radio minor }
- audio : longint; { Audio minor }
- teletext : longint; { Teletext minor }
- end;
- procedure get_video_unit(fd:longint; var vu:video_unit); { fd : file descriptor }
- { ******* video ioctl comands **************************************** }
- const
- { vfp class } { declaration } { description }
- {---------------------------------------------------------------------------------- }
- { CVideo } VIDIOCGCAP = _IOR(v,1,video_capability); { Get capabilities }
- { CVFPP_channel } VIDIOCGCHAN = _IOWR(v,2,video_channel); { Get channel info (sources) }
- { CVFPP_channel } VIDIOCSCHAN = _IOW(v,3,video_channel); { Set channel }
- { CVFPP_tuner } VIDIOCGTUNER = _IOWR(v,4,video_tuner); { Get tuner abilities }
- { CVFPP_tuner } VIDIOCSTUNER = _IOW(v,5,video_tuner); { Tune the tuner for the current channel }
- { CVFPP_grab } VIDIOCGPICT = _IOR(v,6,video_picture); { Get picture properties }
- { CVFPP_grab } VIDIOCSPICT = _IOW(v,7,video_picture); { Set picture properties }
- { CVFPP_overlay } VIDIOCCAPTURE = _IOW(v,8,longint); { Start, stop overlay }
- { CFFPP_window } VIDIOCGWIN = _IOR(v,9,video_window); { Set the video overlay window }
- { CVFPP_window } VIDIOCSWIN = _IOW(v,10,video_window); { Set the video overlay window - passes clip list for hardware smarts , chromakey etc }
- { CVFPP_overlay } VIDIOCGFBUF = _IOR(v,11,video_buffer); { Get frame buffer (of graphic card for for overlaying) }
- { CVFPP_overlay } VIDIOCSFBUF = _IOW(v,12,video_buffer); { Set frame buffer (of graphic card for overlaying) - root only }
- VIDIOCKEY = _IOR(v,13,video_key); { Video key event - to dev 255 is to all - cuts capture on all DMA windows with this key (0xFFFFFFFF == all) }
- VIDIOCGFREQ = _IOR(v,14,dword); { Get tuner }
- VIDIOCSFREQ = _IOW(v,15,dword); { Set tuner }
- VIDIOCGAUDIO = _IOR(v,16,video_audio); { Get audio info }
- VIDIOCSAUDIO = _IOW(v,17,video_audio); { Audio source, mute etc }
- { CVFPP_grab } VIDIOCSYNC = _IOW(v,18,longint); { Sync with mmap grabbing }
- { CVFPP_grab } VIDIOCMCAPTURE = _IOW(v,19,video_mmap); { Grab frames via mmap }
- { CVFPP_grab } VIDIOCGMBUF = _IOR(v,20,video_mbuf); { Memory map (mmap) buffer info }
- { CVideo } VIDIOCGUNIT = _IOR(v,21,video_unit); { Get attached units }
- { CVFPP_capture } VIDIOCGCAPTURE = _IOR(v,22,video_capture); { Get capture params }
- { CVFPP_capture } VIDIOCSCAPTURE = _IOW(v,23,video_capture); { Set capture params}
- procedure video_sync(fd:longint;frame:longint); { fd: file descriptor; frame: frame (0 - video.mbuf-1) for wait }
- procedure video_startoverlay(fd:longint); { fd: file descriptor }
- procedure video_stopoverlay(fd:longint); { fd: file descriptor }
- { ******* video_mmbuf ************************************************ }
- type video_mmbuf = record
- map : ^byte; { pointer to mapped memory }
- size : longint; { rest like video_mbuf }
- frames : longint;
- offsets : array[0..VIDEO_MAX_FRAME-1] of dword;
- end;
- procedure get_video_mmbuf(fd:longint; var mmb:video_mmbuf); { fd : file descriptor; get the mapped memory }
- procedure free_video_mmbuf(var mmb:video_mmbuf);
- { ******* error routines ************************************************ }
- var videodev_error,videodev_warning : procedure(s:ansistring); { error routines; s : error message }
- { *********************************************************************** }
- { ******* IMPLEMENTATION ************************************************ }
- { *********************************************************************** }
- implementation
- uses
- {$ifdef VER0}
- linux
- {$else}
- {$ifdef VER1_0}
- linux
- {$else}
- unix
- {$endif}
- {$endif}
- ;
- { ******* error routines ************************************************ }
- procedure stdwarning(s:ansistring);
- begin
- writeln(stderr,'Warning: ',s);
- end;
- procedure stderror(s:ansistring);
- begin
- writeln(stderr,'Error: ',s);
- halt(1);
- end;
- { ******* video_capability ******************************************* }
- procedure get_video_capability(fd:longint;var vc:video_capability);
- begin
- if fd<0 then videodev_error('get_video_capability: invalid handle');
- if not ioctl(fd,VIDIOCGCAP,@vc) then videodev_error('get_video_capability: ioctl error');
- end;
- function vid_type_str(i:longint):string;
- begin
- vid_type_str:='';
- if i and VID_TYPE_CAPTURE >0 then vid_type_str+=', Capture';
- if i and VID_TYPE_TUNER >0 then vid_type_str+=', Tuner';
- if i and VID_TYPE_TELETEXT >0 then vid_type_str+=', Teletext';
- if i and VID_TYPE_OVERLAY >0 then vid_type_str+=', Overlay';
- if i and VID_TYPE_CHROMAKEY >0 then vid_type_str+=', Chromakey';
- if i and VID_TYPE_CLIPPING >0 then vid_type_str+=', Clipping';
- if i and VID_TYPE_FRAMERAM >0 then vid_type_str+=', FrameRAM';
- if i and VID_TYPE_SCALES >0 then vid_type_str+=', Scales';
- if i and VID_TYPE_MONOCHROME >0 then vid_type_str+=', Monochrome';
- if i and VID_TYPE_SUBCAPTURE >0 then vid_type_str+=', Subcapture';
- if length(vid_type_str)>1 then delete(vid_type_str,1,2)
- else vid_type_str:='Unknown';
- end;
- { ******* video_channel ********************************************** }
- procedure get_video_channel(fd,c:longint;var vc:video_channel);
- begin
- if fd<0 then videodev_error('get_video_channel: invalid handle');
- vc.channel:=c;
- if not ioctl(fd,VIDIOCGCHAN,@vc) then videodev_error('get_video_channel: ioctl error');
- end;
- procedure set_video_channel(fd:longint;var vc:video_channel);
- begin
- if fd<0 then videodev_error('set_video_channel: invalid handle');
- if not ioctl(fd,VIDIOCSCHAN,@vc) then videodev_warning('set_video_channel: ioctl error');
- end;
- function video_vc_str(i:longint):string;
- begin
- video_vc_str:='';
- if i and VIDEO_VC_TUNER>0 then video_vc_str+=', Tuner';
- if i and VIDEO_VC_AUDIO>0 then video_vc_str+=', Audio';
- if length(video_vc_str)>1 then delete(video_vc_str,1,2)
- else video_vc_str:='Unknown';
- end;
- function video_type_str(i:longint):string;
- begin
- video_type_str:='';
- if i and VIDEO_TYPE_TV>0 then video_type_str+=', TV';
- if i and VIDEO_TYPE_CAMERA>0 then video_type_str+=', Camera';
- if length(video_type_str)>1 then delete(video_type_str,1,2)
- else video_type_str:='Unknown';
- end;
- function video_mode_str(i:longint):string[15];
- begin
- video_mode_str:='Unknown';
- case i of
- VIDEO_MODE_PAL : video_mode_str:='PAL';
- VIDEO_MODE_NTSC : video_mode_str:='NTSC';
- VIDEO_MODE_SECAM : video_mode_str:='SECAM';
- VIDEO_MODE_AUTO : video_mode_str:='AUTO';
- end;
- end;
- { ******* video_tuner ********************************************** }
- procedure get_video_tuner(fd,c:longint;var t:video_tuner);
- begin
- if fd<0 then videodev_error('get_video_tuner: invalid handle');
- t.tuner:=c;
- if not ioctl(fd,VIDIOCGTUNER,@t) then videodev_error('get_video_tuner: ioctl error');
- end;
- procedure set_video_tuner(fd:longint;var t:video_tuner);
- begin
- if fd<0 then videodev_error('set_video_tuner: invalid handle');
- if not ioctl(fd,VIDIOCSTUNER,@t) then videodev_warning('set_video_tuner: ioctl error');
- end;
- function video_tuner_str(i:longint):string;
- begin
- video_tuner_str:='';
- if i and VIDEO_TUNER_PAL >0 then video_tuner_str:=', PAL';
- if i and VIDEO_TUNER_NTSC >0 then video_tuner_str:=', NTSC';
- if i and VIDEO_TUNER_SECAM >0 then video_tuner_str:=', SECAM';
- if i and VIDEO_TUNER_LOW >0 then video_tuner_str:=', Low';
- if i and VIDEO_TUNER_NORM >0 then video_tuner_str:=', Norm';
- if i and VIDEO_TUNER_STEREO_ON >0 then video_tuner_str:=', Stereo';
- if i and VIDEO_TUNER_RDS_ON >0 then video_tuner_str:=', RDS';
- if i and VIDEO_TUNER_MBS_ON >0 then video_tuner_str:=', MBS';
- if length(video_tuner_str)>1 then delete(video_tuner_str,1,2)
- else video_tuner_str:='Unknown';
- end;
- procedure setfreq(fd:longint; f:dword);
- begin
- if fd<0 then videodev_error('setfreq: invalid handle');
- if not ioctl(fd,VIDIOCSFREQ,@f) then videodev_warning('setfreq: ioctl error');
- end;
- function getfreq(fd:longint):dword;
- var f : dword;
- begin
- if fd<0 then videodev_error('getfreq: invalid handle');
- if not ioctl(fd,VIDIOCGFREQ,@f) then videodev_warning('getfreq: ioctl error');
- getfreq:=f;
- end;
- { ******* video_picture ********************************************** }
- procedure get_video_picture(fd:longint; var vp:video_picture);
- begin
- if fd<0 then videodev_error('get_video_picture: invalid handle');
- if not ioctl(fd,VIDIOCGPICT,@vp) then videodev_error('get_video_picture: ioctl error');
- end;
- procedure set_video_picture(fd:longint; var vp:video_picture);
- begin
- if fd<0 then videodev_error('set_video_picture: invalid handle');
- if not ioctl(fd,VIDIOCSPICT,@vp) then videodev_warning('set_video_picture: ioctl error');
- end;
- function video_palette_str(i:longint):string[15];
- begin
- video_palette_str:='Unknown';
- case i of
- VIDEO_PALETTE_GREY : video_palette_str:='GREY';
- VIDEO_PALETTE_HI240 : video_palette_str:='HI240';
- VIDEO_PALETTE_RGB565 : video_palette_str:='RGB565';
- VIDEO_PALETTE_RGB24 : video_palette_str:='RGB24';
- VIDEO_PALETTE_RGB32 : video_palette_str:='RGB32';
- VIDEO_PALETTE_RGB555 : video_palette_str:='RGB555';
- VIDEO_PALETTE_YUV422 : video_palette_str:='YUV422';
- VIDEO_PALETTE_YUYV : video_palette_str:='YUYV';
- VIDEO_PALETTE_UYVY : video_palette_str:='UYVY';
- VIDEO_PALETTE_YUV420 : video_palette_str:='YUV420';
- VIDEO_PALETTE_YUV411 : video_palette_str:='YUV411';
- VIDEO_PALETTE_RAW : video_palette_str:='RAW';
- VIDEO_PALETTE_YUV422P : video_palette_str:='YUV422P';
- VIDEO_PALETTE_YUV411P : video_palette_str:='YUV411P';
- VIDEO_PALETTE_YUV420P : video_palette_str:='YUV420P';
- VIDEO_PALETTE_YUV410P : video_palette_str:='YUV410P';
- end;
- end;
- { ******* video_audio ************************************************ }
- procedure get_video_audio(fd:longint; var va:video_audio);
- begin
- if fd<0 then videodev_error('get_video_audio: invalid handle');
- if not ioctl(fd,VIDIOCGAUDIO,@va) then videodev_error('get_video_audio: ioctl error');
- end;
- procedure set_video_audio(fd:longint; var va:video_audio);
- begin
- if fd<0 then videodev_error('set_video_audio: invalid handle');
- if not ioctl(fd,VIDIOCSAUDIO,@va) then videodev_warning('set_video_audio: ioctl error');
- end;
- function video_audio_str(i:longint):string[15];
- begin
- video_audio_str:='';
- if i and VIDEO_AUDIO_MUTE>0 then video_audio_str+=', MUTE';
- if i and VIDEO_AUDIO_MUTABLE>0 then video_audio_str+=', MUTABLE';
- if i and VIDEO_AUDIO_VOLUME>0 then video_audio_str+=', VOLUME';
- if i and VIDEO_AUDIO_BASS>0 then video_audio_str+=', BASS';
- if i and VIDEO_AUDIO_TREBLE>0 then video_audio_str+=', TREBLE';
- if length(video_audio_str)>1 then delete(video_audio_str,1,2);
- end;
- function video_sound_str(i:longint):string[15];
- begin
- video_sound_str:='';
- if i and VIDEO_SOUND_MONO>0 then video_SOUND_str+=', Mono';
- if i and VIDEO_SOUND_STEREO>0 then video_SOUND_str+=', Stereo';
- if i and VIDEO_SOUND_LANG1>0 then video_SOUND_str+=', Lang1';
- if i and VIDEO_SOUND_LANG2>0 then video_SOUND_str+=', Lang2';
- if length(video_SOUND_str)>1 then delete(video_SOUND_str,1,2);
- end;
- { ******* video_window ********************************************** }
- procedure get_video_window(fd:longint; var w:video_window);
- begin
- if fd<0 then videodev_error('get_video_window: invalid handle');
- if not ioctl(fd,VIDIOCGWIN,@w) then videodev_error('get_video_window: ioctl error');
- end;
- procedure set_video_window(fd:longint; var w:video_window);
- begin
- if fd<0 then videodev_error('set_video_window: invalid handle');
- if not ioctl(fd,VIDIOCSWIN,@w) then videodev_warning('set_video_window: ioctl error');
- end;
- { ******* video_capture ********************************************** }
- procedure get_video_capture(fd:longint; var c:video_capture);
- begin
- if fd<0 then videodev_error('get_video_capture: invalid handle');
- if not ioctl(fd,VIDIOCGCAPTURE,@c) then videodev_error('get_video_capture: ioctl error');
- end;
- procedure set_video_capture(fd:longint; var c:video_capture);
- begin
- if fd<0 then videodev_error('set_video_capture: invalid handle');
- if not ioctl(fd,VIDIOCSCAPTURE,@c) then videodev_warning('set_video_capture: ioctl error');
- end;
- { ******* video_buffer *********************************************** }
- procedure get_video_buffer(fd:longint;var vb:video_buffer);
- begin
- if fd<0 then videodev_error('get_video_buffer: invalid handle');
- if not ioctl(fd,VIDIOCGFBUF,@vb) then videodev_error('get_video_buffer: ioctl error');
- end;
- procedure set_video_buffer(fd:longint;var vb:video_buffer);
- begin
- if fd<0 then videodev_error('set_video_buffer: invalid handle');
- if not ioctl(fd,VIDIOCSFBUF,@vb) then videodev_warning('set_video_buffer: ioctl error');
- end;
- { ******* video_mmap ************************************************* }
- procedure grab_video_mmap(fd:longint; mmap:video_mmap);
- begin
- if fd<0 then videodev_error('grab_video_mmap: invalid handle');
- if not ioctl(fd,VIDIOCMCAPTURE,@mmap) then videodev_warning('grab_video_mmap: ioctl error');
- end;
- { ******* video_key ************************************************** }
- procedure get_video_key(fd:longint; key:video_key);
- begin
- if fd<0 then videodev_error('get_video_key: invalid handle');
- if not ioctl(fd,VIDIOCKEY,@key) then videodev_warning('get_video_key: ioctl error');
- end;
- { ******* video_mbuf ************************************************* }
- procedure get_video_mbuf(fd:longint; var mb:video_mbuf);
- begin
- if fd<0 then videodev_error('get_video_mbuf: invalid handle');
- if not ioctl(fd,VIDIOCGMBUF,@mb) then videodev_error('get_video_mbuf: ioctl error');
- end;
- { ******* video_sync ************************************************* }
- procedure video_sync(fd:longint;frame:longint);
- begin
- if fd<0 then videodev_error('video_sync: invalid handle');
- if not ioctl(fd,VIDIOCSYNC,@frame) then videodev_warning('video_sync: ioctl error');
- end;
- { ******* video_overlay ********************************************** }
- procedure video_startoverlay(fd:longint);
- var i : longint;
- begin
- i:=1;
- if fd<0 then videodev_error('video_startoverlay: invalid handle');
- if not ioctl(fd,VIDIOCCAPTURE,@i) then videodev_warning('video_startoverlay: ioctl error');
- end;
- procedure video_stopoverlay(fd:longint);
- var i : longint;
- begin
- i:=0;
- if fd<0 then videodev_error('video_stopoverlay: invalid handle');
- if not ioctl(fd,VIDIOCCAPTURE,@i) then videodev_warning('video_stopoverlay: ioctl error');
- end;
- { ******* get_video_unit ********************************************* }
- procedure get_video_unit(fd:longint; var vu:video_unit);
- begin
- if fd<0 then videodev_error('get_video_unit: invalid handle');
- if not ioctl(fd,VIDIOCGUNIT,@vu) then videodev_error('get_video_unit: ioctl error');
- end;
- { ******* video_mmbuf ************************************************ }
- procedure get_video_mmbuf(fd:longint;var mmb:video_mmbuf);
- var ma : tmmapargs;
- begin
- if fd<0 then videodev_error('get_video_mmbuf: invalid handle');
- if not ioctl(fd,VIDIOCGMBUF,@mmb.size) then videodev_error('get_video_mmbuf: ioctl error');
- if mmb.frames<1 then videodev_warning('get_video_mmbuf: no frames to grab');
- if mmb.size<1 then videodev_warning('get_video_mmbuf: no memory to map');
- if (mmb.frames>0) and (mmb.size>0)
- then begin
- ma.address:=0;
- ma.size:=mmb.size;
- ma.prot:=prot_read or prot_write;
- ma.flags:=map_shared;
- ma.fd:=fd;
- ma.offset:=0;
- mmb.map:=pointer(mmap(ma));
- end
- else mmb.map:=nil;
- if linuxerror<>0 then videodev_error('get_video_mmbuf: mmap failed');
- end;
- procedure free_video_mmbuf(var mmb:video_mmbuf);
- begin
- if (mmb.size<=0) or (mmb.map=nil) or (not munmap(mmb.map,mmb.size)) then
- videodev_error('free_video_mmbuf: munmap fails');
- end;
- begin
- videodev_error:=@stderror;
- videodev_warning:=@stdwarning;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement