The DVB video device controls the MPEG2 video decoder of the DVB hardware. It can be accessed through /dev/dvb/adapter0/video0 . Data types and and ioctl definitions can be accessed by including linux/dvb/video.h in your application.

Note that the DVB video device only controls decoding of the MPEG video stream, not its presentation on the TV or computer screen. On PCs this is typically handled by an associated video4linux device, e.g. /dev/video , which allows scaling and defining output windows.

Some DVB cards don't have their own MPEG decoder, which results in the omission of the audio and video device as well as the video4linux device.

The ioctls that deal with SPUs (sub picture units) and navigation packets are only supported on some MPEG decoders made for DVD playback.

The video_format_t data type defined by

typedef enum { VIDEO_FORMAT_4_3, VIDEO_FORMAT_16_9 } video_format_t;

In case the display format of the video stream and of the display hardware differ the application has to specify how to handle the cropping of the picture. This can be done using the VIDEO_SET_DISPLAY_FORMAT call (4.2.12) which accepts

typedef enum { VIDEO_PAN_SCAN, VIDEO_LETTER_BOX, VIDEO_CENTER_CUT_OUT } video_display_format_t;



video stream source

typedef enum { VIDEO_SOURCE_DEMUX, VIDEO_SOURCE_MEMORY } video_stream_source_t;

write()



video play state

typedef enum { VIDEO_STOPPED, VIDEO_PLAYING, VIDEO_FREEZED } video_play_state_t;



struct video_event

struct video_event { int32_t type; time_t timestamp; union { video_format_t video_format; } u; };



struct video_status

struct video_status { boolean video_blank; video_play_state_t play_state; video_stream_source_t stream_source; video_format_t video_format; video_displayformat_t display_format; };



struct video_still_picture

/* pointer to and size of a single iframe in memory */ struct video_still_picture { char *iFrame; int32_t size; };



video capabilities

/* bit definitions for capabilities: */ /* can the hardware decode MPEG1 and/or MPEG2? */ #define VIDEO_CAP_MPEG1 1 #define VIDEO_CAP_MPEG2 2 /* can you send a system and/or program stream to video device? (you still have to open the video and the audio device but only send the stream to the video device) */ #define VIDEO_CAP_SYS 4 #define VIDEO_CAP_PROG 8 /* can the driver also handle SPU, NAVI and CSS encoded data? (CSS API is not present yet) */ #define VIDEO_CAP_SPU 16 #define VIDEO_CAP_NAVI 32 #define VIDEO_CAP_CSS 64



video system

typedef enum { VIDEO_SYSTEM_PAL, VIDEO_SYSTEM_NTSC, VIDEO_SYSTEM_PALN, VIDEO_SYSTEM_PALNc, VIDEO_SYSTEM_PALM, VIDEO_SYSTEM_NTSC60, VIDEO_SYSTEM_PAL60, VIDEO_SYSTEM_PALM60 } video_system_t;



struct video_highlight

typedef struct video_highlight { boolean active; /* 1=show highlight, 0=hide highlight */ uint8_t contrast1; /* 7- 4 Pattern pixel contrast */ /* 3- 0 Background pixel contrast */ uint8_t contrast2; /* 7- 4 Emphasis pixel-2 contrast */ /* 3- 0 Emphasis pixel-1 contrast */ uint8_t color1; /* 7- 4 Pattern pixel color */ /* 3- 0 Background pixel color */ uint8_t color2; /* 7- 4 Emphasis pixel-2 color */ /* 3- 0 Emphasis pixel-1 color */ uint32_t ypos; /* 23-22 auto action mode */ /* 21-12 start y */ /* 9- 0 end y */ uint32_t xpos; /* 23-22 button color number */ /* 21-12 start x */ /* 9- 0 end x */ } video_highlight_t;



video SPU

typedef struct video_spu { boolean active; int stream_id; } video_spu_t;



video SPU palette

typedef struct video_spu_palette{ int length; uint8_t *palette; } video_spu_palette_t;



video NAVI pack

typedef struct video_navi_pack{ int length; /* 0 ... 1024 */ uint8_t data[1024]; } video_navi_pack_t;



video attributes

typedef uint16_t video_attributes_t; /* bits: descr. */ /* 15-14 Video compression mode (0=MPEG-1, 1=MPEG-2) */ /* 13-12 TV system (0=525/60, 1=625/50) */ /* 11-10 Aspect ratio (0=4:3, 3=16:9) */ /* 9- 8 permitted display mode on 4:3 monitor (0=both, 1=only pan-sca */ /* 7 line 21-1 data present in GOP (1=yes, 0=no) */ /* 6 line 21-2 data present in GOP (1=yes, 0=no) */ /* 5- 3 source resolution (0=720x480/576, 1=704x480/576, 2=352x480/57 */ /* 2 source letterboxed (1=yes, 0=no) */ /* 0 film/camera mode (0=camera, 1=film (625/50 only)) */

DESCRIPTION





This system call opens a named video device (e.g. /dev/dvb/adapter0/video0) for subsequent use. When an open() call has succeeded, the device will be ready for use. The significance of blocking or non-blocking mode is described in the documentation for functions where there is a difference. It does not affect the semantics of the open() call itself. A device opened in blocking mode can later be put into non-blocking mode (and vice versa) using the F_SETFL command of the fcntl system call. This is a standard system call, documented in the Linux manual page for fcntl. Only one user can open the Video Device in O_RDWR mode. All other attempts to open the device in this mode will fail, and an error-code will be returned. If the Video Device is opened in O_RDONLY mode, the only ioctl call that can be used is VIDEO_GET_STATUS. All other call will return an error code.



SYNOPSIS





int open(const char *deviceName, int flags);



PARAMETERS





const char *deviceName Name of specific video device. int flags A bit-wise OR of the following flags: O_RDONLY read-only access O_RDWR read/write access O_NONBLOCK open in non-blocking mode (blocking mode is the default)



ERRORS





ENODEV Device driver not loaded/available. EINTERNAL Internal error. EBUSY Device or resource busy. EINVAL Invalid argument.





DESCRIPTION





This system call closes a previously opened video device.



SYNOPSIS





int close(int fd);



PARAMETERS





int fd File descriptor returned by a previous call to open().



ERRORS





EBADF fd is not a valid open file descriptor.





DESCRIPTION





This system call can only be used if VIDEO_SOURCE_MEMORY is selected in the ioctl call VIDEO_SELECT_SOURCE. The data provided shall be in PES format, unless the capability allows other formats. If O_NONBLOCK is not specified the function will block until buffer space is available. The amount of data to be transferred is implied by count.



SYNOPSIS





size_t write(int fd, const void *buf, size_t count);



PARAMETERS





int fd File descriptor returned by a previous call to open(). void *buf Pointer to the buffer containing the PES data. size_t count Size of buf.



ERRORS





EPERM Mode VIDEO_SOURCE_MEMORY not selected. ENOMEM Attempted to write more data than the internal buffer can hold. EBADF fd is not a valid open file descriptor.





DESCRIPTION





This ioctl call asks the Video Device to stop playing the current stream. Depending on the input parameter, the screen can be blanked out or displaying the last decoded frame.



SYNOPSIS





int ioctl(fd, int request = VIDEO_STOP, boolean mode);



PARAMETERS





int fd File descriptor returned by a previous call to open(). int request Equals VIDEO_STOP for this command. Boolean mode Indicates how the screen shall be handled. TRUE: Blank screen when stop. FALSE: Show last decoded frame.



ERRORS





EBADF fd is not a valid open file descriptor EINTERNAL Internal error, possibly in the communication with the DVB subsystem.





DESCRIPTION





This ioctl call asks the Video Device to start playing a video stream from the selected source.



SYNOPSIS





int ioctl(fd, int request = VIDEO_PLAY);



PARAMETERS





int fd File descriptor returned by a previous call to open(). int request Equals VIDEO_PLAY for this command.



ERRORS





EBADF fd is not a valid open file descriptor EINTERNAL Internal error, possibly in the communication with the DVB subsystem.





DESCRIPTION





This ioctl call suspends the live video stream being played. Decoding and playing are frozen. It is then possible to restart the decoding and playing process of the video stream using the VIDEO_CONTINUE command. If VIDEO_SOURCE_MEMORY is selected in the ioctl call VIDEO_SELECT_SOURCE, the DVB subsystem will not decode any more data until the ioctl call VIDEO_CONTINUE or VIDEO_PLAY is performed.



SYNOPSIS





int ioctl(fd, int request = VIDEO_FREEZE);



PARAMETERS





int fd File descriptor returned by a previous call to open(). int request Equals VIDEO_FREEZE for this command.



ERRORS





EBADF fd is not a valid open file descriptor EINTERNAL Internal error, possibly in the communication with the DVB subsystem.





DESCRIPTION





This ioctl call restarts decoding and playing processes of the video stream which was played before a call to VIDEO_FREEZE was made.



SYNOPSIS





int ioctl(fd, int request = VIDEO_CONTINUE);



PARAMETERS





int fd File descriptor returned by a previous call to open(). int request Equals VIDEO_CONTINUE for this command.



ERRORS





EBADF fd is not a valid open file descriptor EINTERNAL Internal error, possibly in the communication with the DVB subsystem.





DESCRIPTION





This ioctl call informs the video device which source shall be used for the input data. The possible sources are demux or memory. If memory is selected, the data is fed to the video device through the write command.



SYNOPSIS





int ioctl(fd, int request = VIDEO_SELECT_SOURCE, video_stream_source_t source);



PARAMETERS





int fd File descriptor returned by a previous call to open(). int request Equals VIDEO_SELECT_SOURCE for this command. video_stream_source_t source Indicates which source shall be used for the Video stream.



ERRORS





EBADF fd is not a valid open file descriptor EINTERNAL Internal error, possibly in the communication with the DVB subsystem.





DESCRIPTION





This ioctl call asks the Video Device to blank out the picture.



SYNOPSIS





int ioctl(fd, int request = VIDEO_SET_BLANK, boolean mode);



PARAMETERS





int fd File descriptor returned by a previous call to open(). int request Equals VIDEO_SET_BLANK for this command. boolean mode TRUE: Blank screen when stop. FALSE: Show last decoded frame.



ERRORS





EBADF fd is not a valid open file descriptor EINTERNAL Internal error, possibly in the communication with the DVB subsystem. EINVAL Illegal input parameter





DESCRIPTION





This ioctl call asks the Video Device to return the current status of the device.



SYNOPSIS





int ioctl(fd, int request = VIDEO_GET_STATUS, struct video_status *status);



PARAMETERS





int fd File descriptor returned by a previous call to open(). int request Equals VIDEO_GET_STATUS for this command. struct video_status *status Returns the current status of the Video Device.



ERRORS





EBADF fd is not a valid open file descriptor EINTERNAL Internal error, possibly in the communication with the DVB subsystem. EFAULT status points to invalid address





DESCRIPTION





This ioctl call returns an event of type video_event if available. If an event is not available, the behavior depends on whether the device is in blocking or non-blocking mode. In the latter case, the call fails immediately with errno set to EWOULDBLOCK. In the former case, the call blocks until an event becomes available. The standard Linux poll() and/or select() system calls can be used with the device file descriptor to watch for new events. For select(), the file descriptor should be included in the exceptfds argument, and for poll(), POLLPRI should be specified as the wake-up condition. Read-only permissions are sufficient for this ioctl call.



SYNOPSIS





int ioctl(fd, int request = VIDEO_GET_EVENT, struct video_event *ev);



PARAMETERS





int fd File descriptor returned by a previous call to open(). int request Equals VIDEO_GET_EVENT for this command. struct video_event *ev Points to the location where the event, if any, is to be stored.



ERRORS





EBADF fd is not a valid open file descriptor EFAULT ev points to invalid address EWOULDBLOCK There is no event pending, and the device is in non-blocking mode. EOVERFLOW Overflow in event queue - one or more events were lost.





DESCRIPTION





This ioctl call asks the Video Device to select the video format to be applied by the MPEG chip on the video.



SYNOPSIS





int ioctl(fd, int request = VIDEO_SET_DISPLAY_FORMAT, video_display_format_t format);



PARAMETERS





int fd File descriptor returned by a previous call to open(). int request Equals VIDEO_SET_DISPLAY_FORMAT for this command. video_display_format_t format Selects the video format to be used.



ERRORS





EBADF fd is not a valid open file descriptor EINTERNAL Internal error. EINVAL Illegal parameter format.





DESCRIPTION





This ioctl call asks the Video Device to display a still picture (I-frame). The input data shall contain an I-frame. If the pointer is NULL, then the current displayed still picture is blanked.



SYNOPSIS





int ioctl(fd, int request = VIDEO_STILLPICTURE, struct video_still_picture *sp);



PARAMETERS





int fd File descriptor returned by a previous call to open(). int request Equals VIDEO_STILLPICTURE for this command. struct video_still_picture *sp Pointer to a location where an I-frame and size is stored.



ERRORS





EBADF fd is not a valid open file descriptor EINTERNAL Internal error. EFAULT sp points to an invalid iframe.





DESCRIPTION





This ioctl call asks the Video Device to skip decoding of N number of I-frames. This call can only be used if VIDEO_SOURCE_MEMORY is selected.



SYNOPSIS





int ioctl(fd, int request = VIDEO_FAST_FORWARD, int nFrames);



PARAMETERS





int fd File descriptor returned by a previous call to open(). int request Equals VIDEO_FAST_FORWARD for this command. int nFrames The number of frames to skip.



ERRORS





EBADF fd is not a valid open file descriptor EINTERNAL Internal error. EPERM Mode VIDEO_SOURCE_MEMORY not selected. EINVAL Illegal parameter format.





DESCRIPTION





This ioctl call asks the video device to repeat decoding frames N number of times. This call can only be used if VIDEO_SOURCE_MEMORY is selected.



SYNOPSIS





int ioctl(fd, int request = VIDEO_SLOWMOTION, int nFrames);



PARAMETERS





int fd File descriptor returned by a previous call to open(). int request Equals VIDEO_SLOWMOTION for this command. int nFrames The number of times to repeat each frame.



ERRORS





EBADF fd is not a valid open file descriptor EINTERNAL Internal error. EPERM Mode VIDEO_SOURCE_MEMORY not selected. EINVAL Illegal parameter format.





DESCRIPTION





This ioctl call asks the video device about its decoding capabilities. On success it returns and integer which has bits set according to the defines in section 4.1.8.



SYNOPSIS





int ioctl(fd, int request = VIDEO_GET_CAPABILITIES, unsigned int *cap);



PARAMETERS





int fd File descriptor returned by a previous call to open(). int request Equals VIDEO_GET_CAPABILITIES for this command. unsigned int *cap Pointer to a location where to store the capability information.



ERRORS





EBADF fd is not a valid open file descriptor EFAULT cap points to an invalid iframe.





DESCRIPTION





This ioctl selects which sub-stream is to be decoded if a program or system stream is sent to the video device.



SYNOPSIS





int ioctl(int fd, int request = VIDEO_SET_ID, int id);



PARAMETERS





int fd File descriptor returned by a previous call to open(). int request Equals VIDEO_SET_ID for this command. int id video sub-stream id



ERRORS





EBADF fd is not a valid open file descriptor. EINTERNAL Internal error. EINVAL Invalid sub-stream id.





DESCRIPTION





This ioctl call clears all video buffers in the driver and in the decoder hardware.



SYNOPSIS





int ioctl(fd, int request = VIDEO_CLEAR_BUFFER);



PARAMETERS





int fd File descriptor returned by a previous call to open(). int request Equals VIDEO_CLEAR_BUFFER for this command.



ERRORS





EBADF fd is not a valid open file descriptor





DESCRIPTION





This ioctl tells the driver which kind of stream to expect being written to it. If this call is not used the default of video PES is used. Some drivers might not support this call and always expect PES.



SYNOPSIS





int ioctl(fd, int request = VIDEO_SET_STREAMTYPE, int type);



PARAMETERS





int fd File descriptor returned by a previous call to open(). int request Equals VIDEO_SET_STREAMTYPE for this command. int type stream type



ERRORS





EBADF fd is not a valid open file descriptor EINVAL type is not a valid or supported stream type.





DESCRIPTION





This ioctl sets the screen format (aspect ratio) of the connected output device (TV) so that the output of the decoder can be adjusted accordingly.



SYNOPSIS





int ioctl(fd, int request = VIDEO_SET_FORMAT, video_format_t format);



PARAMETERS





int fd File descriptor returned by a previous call to open(). int request Equals VIDEO_SET_FORMAT for this command. video_format_t format video format of TV as defined in section 4.1.1.



ERRORS





EBADF fd is not a valid open file descriptor EINVAL format is not a valid video format.





DESCRIPTION





This ioctl sets the television output format. The format (see section 4.1.9) may vary from the color format of the displayed MPEG stream. If the hardware is not able to display the requested format the call will return an error.



SYNOPSIS





int ioctl(fd, int request = VIDEO_SET_SYSTEM , video_system_t system);



PARAMETERS





int fd File descriptor returned by a previous call to open(). int request Equals VIDEO_SET_FORMAT for this command. video_system_t system video system of TV output.



ERRORS





EBADF fd is not a valid open file descriptor EINVAL system is not a valid or supported video system.





DESCRIPTION





This ioctl sets the SPU highlight information for the menu access of a DVD.



SYNOPSIS





int ioctl(fd, int request = VIDEO_SET_HIGHLIGHT ,video_highlight_t *vhilite)



PARAMETERS





int fd File descriptor returned by a previous call to open(). int request Equals VIDEO_SET_HIGHLIGHT for this command. video_highlight_t *vhilite SPU Highlight information according to section 4.1.10.



ERRORS





EBADF fd is not a valid open file descriptor. EINVAL input is not a valid highlight setting.





DESCRIPTION





This ioctl activates or deactivates SPU decoding in a DVD input stream. It can only be used, if the driver is able to handle a DVD stream.



SYNOPSIS





int ioctl(fd, int request = VIDEO_SET_SPU , video_spu_t *spu)



PARAMETERS





int fd File descriptor returned by a previous call to open(). int request Equals VIDEO_SET_SPU for this command. video_spu_t *spu SPU decoding (de)activation and subid setting according to section 4.1.11.



ERRORS





EBADF fd is not a valid open file descriptor EINVAL input is not a valid spu setting or driver cannot handle SPU.





DESCRIPTION





This ioctl sets the SPU color palette.



SYNOPSIS





int ioctl(fd, int request = VIDEO_SET_SPU_PALETTE ,video_spu_palette_t *palette )



PARAMETERS





int fd File descriptor returned by a previous call to open(). int request Equals VIDEO_SET_SPU_PALETTE for this command. video_spu_palette_t *palette SPU palette according to section 4.1.12.



ERRORS





EBADF fd is not a valid open file descriptor EINVAL input is not a valid palette or driver doesn't handle SPU.





DESCRIPTION





This ioctl returns navigational information from the DVD stream. This is especially needed if an encoded stream has to be decoded by the hardware.



SYNOPSIS





int ioctl(fd, int request = VIDEO_GET_NAVI , video_navi_pack_t *navipack)



PARAMETERS





int fd File descriptor returned by a previous call to open(). int request Equals VIDEO_GET_NAVI for this command. video_navi_pack_t *navipack PCI or DSI pack (private stream 2) according to section 4.1.13.



ERRORS





EBADF fd is not a valid open file descriptor EFAULT driver is not able to return navigational information





DESCRIPTION





This ioctl is intended for DVD playback and allows you to set certain information about the stream. Some hardware may not need this information, but the call also tells the hardware to prepare for DVD playback.



SYNOPSIS





int ioctl(fd, int request = VIDEO_SET_ATTRIBUTE ,video_attributes_t vattr)



PARAMETERS





int fd File descriptor returned by a previous call to open(). int request Equals VIDEO_SET_ATTRIBUTE for this command. video_attributes_t vattr video attributes according to section 4.1.14.



ERRORS





EBADF fd is not a valid open file descriptor EINVAL input is not a valid attribute setting.





LinuxTV DVB API