?? video.tex
字號(hào):
\devsec{DVB Video Device}The DVB video device controls the MPEG2 video decoder of the DVB hardware.It can be accessed through \texttt{/dev/dvb/adapter0/video0}.Data types and and ioctl definitions can be accessed by including\texttt{linux/dvb/video.h} in your application.Note that the DVB video device only controls decoding of the MPEGvideo stream, not its presentation on the TV or computer screen.On PCs this is typically handled by an associated video4linux device, e.g.\texttt{/dev/video}, which allows scaling and defining output windows.Some DVB cards don't have their own MPEG decoder, which results in the omissionof the audio and video device as well as the video4linux device.The ioctls that deal with SPUs (sub picture units) and navigationpackets are only supported on some MPEG decoders made for DVD playback.\devsubsec{Video Data Types}\devsubsubsec{video\_format\_t}\label{videoformat}The \texttt{video\_format\_t} data type defined by \begin{verbatim}typedef enum { VIDEO_FORMAT_4_3, VIDEO_FORMAT_16_9} video_format_t;\end{verbatim}is used in the VIDEO\_SET\_FORMAT function (\ref{videosetformat}) to tell the driver which aspect ratio the output hardware (e.g. TV) has.It is also used in the data structures video\_status (\ref{videostatus})returned by VIDEO\_GET\_STATUS (\ref{videogetstatus}) andvideo\_event (\ref{videoevent}) returned by VIDEO\_GET\_EVENT (\ref{videogetevent}) which report about the display format of the current video stream.\devsubsubsec{video\_display\_format\_t}\label{videodispformat}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(\ref{videosetdisplayformat}) which accepts \begin{verbatim}typedef enum { VIDEO_PAN_SCAN, VIDEO_LETTER_BOX, VIDEO_CENTER_CUT_OUT} video_display_format_t;\end{verbatim}as argument.\devsubsubsec{video stream source}\label{videostreamsource}The video stream source is set through the VIDEO\_SELECT\_SOURCEcall and can take the following values, depending on whether we arereplaying from an internal (demuxer) or external (user write) source.\begin{verbatim}typedef enum { VIDEO_SOURCE_DEMUX, VIDEO_SOURCE_MEMORY } video_stream_source_t;\end{verbatim}VIDEO\_SOURCE\_DEMUX selects the demultiplexer (fedeither by the frontend or the DVR device) as the source of the video stream.If VIDEO\_SOURCE\_MEMORY is selected the stream comes from the application through the \texttt{write()} system call.\devsubsubsec{video play state}\label{videoplaystate}The following values can be returned by the VIDEO\_GET\_STATUS callrepresenting the state of video playback.\begin{verbatim}typedef enum { VIDEO_STOPPED, VIDEO_PLAYING, VIDEO_FREEZED } video_play_state_t; \end{verbatim}\devsubsubsec{struct video\_event}\label{videoevent}The following is the structure of a video event as it is returned bythe VIDEO\_GET\_EVENT call.\begin{verbatim}struct video_event { int32_t type; time_t timestamp; union { video_format_t video_format; } u; };\end{verbatim}\devsubsubsec{struct video\_status}\label{videostatus}The VIDEO\_GET\_STATUS call returns the following structure informingabout various states of the playback operation.\begin{verbatim}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; };\end{verbatim}If video\_blank is set video will be blanked out if the channel is changed orif playback is stopped. Otherwise, the last picture will be displayed.play\_state indicates if the video is currently frozen, stopped, orbeing played back. The stream\_source corresponds to the seleted source for the video stream. It can come either from the demultiplexer or from memory.The video\_format indicates the aspect ratio (one of 4:3 or 16:9)of the currently played video stream.Finally, display\_format corresponds to the selected cropping mode in case the source video format is not the same as the format of the output device.\devsubsubsec{struct video\_still\_picture}\label{videostill}An I-frame displayed via the VIDEO\_STILLPICTURE call is passed onwithin the following structure.\begin{verbatim}/* pointer to and size of a single iframe in memory */struct video_still_picture { char *iFrame; int32_t size; };\end{verbatim}\devsubsubsec{video capabilities}\label{videocaps}A call to VIDEO\_GET\_CAPABILITIES returns an unsigned integer withthe following bits set according to the hardwares capabilities.\begin{verbatim}/* 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\end{verbatim}\devsubsubsec{video system}\label{videosys}A call to VIDEO\_SET\_SYSTEM sets the desired video system for TVoutput. The following system types can be set:\begin{verbatim}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;\end{verbatim}\devsubsubsec{struct video\_highlight}\label{vhilite}Calling the ioctl VIDEO\_SET\_HIGHLIGHTS posts the SPU highlightinformation. The call expects the following format for that information:\begin{verbatim}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;\end{verbatim}\devsubsubsec{video SPU}\label{videospu}Calling VIDEO\_SET\_SPU deactivates or activates SPU decoding,according to the following format:\begin{verbatim}typedef struct video_spu { boolean active; int stream_id;} video_spu_t;\end{verbatim}\devsubsubsec{video SPU palette}\label{vspupal}The following structure is used to set the SPU palette by calling VIDEO\_SPU\_PALETTE:\begin{verbatim}typedef struct video_spu_palette{ int length; uint8_t *palette;} video_spu_palette_t;\end{verbatim}\devsubsubsec{video NAVI pack}\label{videonavi}In order to get the navigational data the following structure has tobe passed to the ioctl VIDEO\_GET\_NAVI:\begin{verbatim}typedef struct video_navi_pack{ int length; /* 0 ... 1024 */ uint8_t data[1024];} video_navi_pack_t;\end{verbatim}\devsubsubsec{video attributes}\label{vattrib}The following attributes can be set by a call to VIDEO\_SET\_ATTRIBUTES:\begin{verbatim}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)) */\end{verbatim}\clearpage\devsubsec{Video Function Calls}\function{open()}{ int open(const char *deviceName, int flags);}{ 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. }{ const char *deviceName & Name of specific video device.\\ int flags & A bit-wise OR of the following flags:\\ & \hspace{1em} O\_RDONLY read-only access\\ & \hspace{1em} O\_RDWR read/write access\\ & \hspace{1em} O\_NONBLOCK open in non-blocking mode \\ & \hspace{1em} (blocking mode is the default)\\ }{ ENODEV & Device driver not loaded/available.\\ EINTERNAL & Internal error.\\ EBUSY & Device or resource busy.\\ EINVAL & Invalid argument.\\}\function{close()}{ int close(int fd);}{ This system call closes a previously opened video device. }{ int fd & File descriptor returned by a previous call to open().\\ }{ EBADF & fd is not a valid open file descriptor.\\}\function{write()}{ size\_t write(int fd, const void *buf, size\_t count);}{ 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. }{ 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.\\ }{ 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.\\}\ifunction{VIDEO\_STOP}{ int ioctl(fd, int request = VIDEO\_STOP, boolean mode);}{ 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.}{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.\\}{EBADF& fd is not a valid open file descriptor \\EINTERNAL & Internal error, possibly in the communication with the DVB subsystem.\\}\ifunction{VIDEO\_PLAY}{ int ioctl(fd, int request = VIDEO\_PLAY);}{ This ioctl call asks the Video Device to start playing a video stream from the selected source.}{int fd & File descriptor returned by a previous call to open(). \\int request & Equals VIDEO\_PLAY for this command. \\
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -