1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>Chapter 11. DVB Video Device</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="LINUX MEDIA INFRASTRUCTURE API"><link rel="up" href="dvbapi.html" title="Part II. LINUX DVB API"><link rel="prev" href="dmx_fcalls.html" title="Demux Function Calls"><link rel="next" href="video_function_calls.html" title="Video Function Calls"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 11. DVB Video Device</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="dmx_fcalls.html">Prev</a> </td><th width="60%" align="center">Part II. LINUX DVB API</th><td width="20%" align="right"> <a accesskey="n" href="video_function_calls.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a name="dvb_video"></a>Chapter 11. DVB Video Device</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><dt><span class="section"><a href="dvb_video.html#video_types">Video Data Types</a></span></dt><dd><dl><dt><span class="section"><a href="dvb_video.html#video-format-t">video_format_t</a></span></dt><dt><span class="section"><a href="dvb_video.html#video-displayformat-t">video_displayformat_t</a></span></dt><dt><span class="section"><a href="dvb_video.html#video-stream-source-t">video_stream_source_t</a></span></dt><dt><span class="section"><a href="dvb_video.html#video-play-state-t">video_play_state_t</a></span></dt><dt><span class="section"><a href="dvb_video.html#video-command">struct video_command</a></span></dt><dt><span class="section"><a href="dvb_video.html#video-size-t">video_size_t</a></span></dt><dt><span class="section"><a href="dvb_video.html#video-event">struct video_event</a></span></dt><dt><span class="section"><a href="dvb_video.html#video-status">struct video_status</a></span></dt><dt><span class="section"><a href="dvb_video.html#video-still-picture">struct video_still_picture</a></span></dt><dt><span class="section"><a href="dvb_video.html#video_caps">video capabilities</a></span></dt><dt><span class="section"><a href="dvb_video.html#video-system">video_system_t</a></span></dt><dt><span class="section"><a href="dvb_video.html#video-highlight">struct video_highlight</a></span></dt><dt><span class="section"><a href="dvb_video.html#video-spu">struct video_spu</a></span></dt><dt><span class="section"><a href="dvb_video.html#video-spu-palette">struct video_spu_palette</a></span></dt><dt><span class="section"><a href="dvb_video.html#video-navi-pack">struct video_navi_pack</a></span></dt><dt><span class="section"><a href="dvb_video.html#video-attributes-t">video_attributes_t</a></span></dt></dl></dd><dt><span class="section"><a href="video_function_calls.html">Video Function Calls</a></span></dt><dd><dl><dt><span class="section"><a href="video_function_calls.html#video_fopen">open()</a></span></dt><dt><span class="section"><a href="video_function_calls.html#video_fclose">close()</a></span></dt><dt><span class="section"><a href="video_function_calls.html#video_fwrite">write()</a></span></dt><dt><span class="section"><a href="video_function_calls.html#VIDEO_STOP">VIDEO_STOP</a></span></dt><dt><span class="section"><a href="video_function_calls.html#VIDEO_PLAY">VIDEO_PLAY</a></span></dt><dt><span class="section"><a href="video_function_calls.html#VIDEO_FREEZE">VIDEO_FREEZE</a></span></dt><dt><span class="section"><a href="video_function_calls.html#VIDEO_CONTINUE">VIDEO_CONTINUE</a></span></dt><dt><span class="section"><a href="video_function_calls.html#VIDEO_SELECT_SOURCE">VIDEO_SELECT_SOURCE</a></span></dt><dt><span class="section"><a href="video_function_calls.html#VIDEO_SET_BLANK">VIDEO_SET_BLANK</a></span></dt><dt><span class="section"><a href="video_function_calls.html#VIDEO_GET_STATUS">VIDEO_GET_STATUS</a></span></dt><dt><span class="section"><a href="video_function_calls.html#VIDEO_GET_FRAME_COUNT">VIDEO_GET_FRAME_COUNT</a></span></dt><dt><span class="section"><a href="video_function_calls.html#VIDEO_GET_PTS">VIDEO_GET_PTS</a></span></dt><dt><span class="section"><a href="video_function_calls.html#VIDEO_GET_FRAME_RATE">VIDEO_GET_FRAME_RATE</a></span></dt><dt><span class="section"><a href="video_function_calls.html#VIDEO_GET_EVENT">VIDEO_GET_EVENT</a></span></dt><dt><span class="section"><a href="video_function_calls.html#VIDEO_COMMAND">VIDEO_COMMAND</a></span></dt><dt><span class="section"><a href="video_function_calls.html#VIDEO_TRY_COMMAND">VIDEO_TRY_COMMAND</a></span></dt><dt><span class="section"><a href="video_function_calls.html#VIDEO_GET_SIZE">VIDEO_GET_SIZE</a></span></dt><dt><span class="section"><a href="video_function_calls.html#VIDEO_SET_DISPLAY_FORMAT">VIDEO_SET_DISPLAY_FORMAT</a></span></dt><dt><span class="section"><a href="video_function_calls.html#VIDEO_STILLPICTURE">VIDEO_STILLPICTURE</a></span></dt><dt><span class="section"><a href="video_function_calls.html#VIDEO_FAST_FORWARD">VIDEO_FAST_FORWARD</a></span></dt><dt><span class="section"><a href="video_function_calls.html#VIDEO_SLOWMOTION">VIDEO_SLOWMOTION</a></span></dt><dt><span class="section"><a href="video_function_calls.html#VIDEO_GET_CAPABILITIES">VIDEO_GET_CAPABILITIES</a></span></dt><dt><span class="section"><a href="video_function_calls.html#VIDEO_SET_ID">VIDEO_SET_ID</a></span></dt><dt><span class="section"><a href="video_function_calls.html#VIDEO_CLEAR_BUFFER">VIDEO_CLEAR_BUFFER</a></span></dt><dt><span class="section"><a href="video_function_calls.html#VIDEO_SET_STREAMTYPE">VIDEO_SET_STREAMTYPE</a></span></dt><dt><span class="section"><a href="video_function_calls.html#VIDEO_SET_FORMAT">VIDEO_SET_FORMAT</a></span></dt><dt><span class="section"><a href="video_function_calls.html#VIDEO_SET_SYSTEM">VIDEO_SET_SYSTEM</a></span></dt><dt><span class="section"><a href="video_function_calls.html#VIDEO_SET_HIGHLIGHT">VIDEO_SET_HIGHLIGHT</a></span></dt><dt><span class="section"><a href="video_function_calls.html#VIDEO_SET_SPU">VIDEO_SET_SPU</a></span></dt><dt><span class="section"><a href="video_function_calls.html#VIDEO_SET_SPU_PALETTE">VIDEO_SET_SPU_PALETTE</a></span></dt><dt><span class="section"><a href="video_function_calls.html#VIDEO_GET_NAVI">VIDEO_GET_NAVI</a></span></dt><dt><span class="section"><a href="video_function_calls.html#VIDEO_SET_ATTRIBUTES">VIDEO_SET_ATTRIBUTES</a></span></dt></dl></dd></dl></div><p>The DVB video device controls the MPEG2 video decoder of the DVB hardware. It 2can be accessed through <span class="tt">/dev/dvb/adapter0/video0</span>. Data types and and 3ioctl definitions can be accessed by including <span class="tt">linux/dvb/video.h</span> in your 4application. 5</p><p>Note that the DVB video device only controls decoding of the MPEG video stream, not 6its presentation on the TV or computer screen. On PCs this is typically handled by an 7associated video4linux device, e.g. <span class="tt">/dev/video</span>, which allows scaling and defining output 8windows. 9</p><p>Some DVB cards don’t have their own MPEG decoder, which results in the omission of 10the audio and video device as well as the video4linux device. 11</p><p>The ioctls that deal with SPUs (sub picture units) and navigation packets are only 12supported on some MPEG decoders made for DVD playback. 13</p><p> 14These ioctls were also used by V4L2 to control MPEG decoders implemented in V4L2. The use 15of these ioctls for that purpose has been made obsolete and proper V4L2 ioctls or controls 16have been created to replace that functionality.</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="video_types"></a>Video Data Types</h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="section"><a href="dvb_video.html#video-format-t">video_format_t</a></span></dt><dt><span class="section"><a href="dvb_video.html#video-displayformat-t">video_displayformat_t</a></span></dt><dt><span class="section"><a href="dvb_video.html#video-stream-source-t">video_stream_source_t</a></span></dt><dt><span class="section"><a href="dvb_video.html#video-play-state-t">video_play_state_t</a></span></dt><dt><span class="section"><a href="dvb_video.html#video-command">struct video_command</a></span></dt><dt><span class="section"><a href="dvb_video.html#video-size-t">video_size_t</a></span></dt><dt><span class="section"><a href="dvb_video.html#video-event">struct video_event</a></span></dt><dt><span class="section"><a href="dvb_video.html#video-status">struct video_status</a></span></dt><dt><span class="section"><a href="dvb_video.html#video-still-picture">struct video_still_picture</a></span></dt><dt><span class="section"><a href="dvb_video.html#video_caps">video capabilities</a></span></dt><dt><span class="section"><a href="dvb_video.html#video-system">video_system_t</a></span></dt><dt><span class="section"><a href="dvb_video.html#video-highlight">struct video_highlight</a></span></dt><dt><span class="section"><a href="dvb_video.html#video-spu">struct video_spu</a></span></dt><dt><span class="section"><a href="dvb_video.html#video-spu-palette">struct video_spu_palette</a></span></dt><dt><span class="section"><a href="dvb_video.html#video-navi-pack">struct video_navi_pack</a></span></dt><dt><span class="section"><a href="dvb_video.html#video-attributes-t">video_attributes_t</a></span></dt></dl></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="video-format-t"></a>video_format_t</h3></div></div></div><p>The <span class="tt">video_format_t</span> data type defined by 17</p><pre class="programlisting"> 18typedef enum { 19 VIDEO_FORMAT_4_3, /⋆ Select 4:3 format ⋆/ 20 VIDEO_FORMAT_16_9, /⋆ Select 16:9 format. ⋆/ 21 VIDEO_FORMAT_221_1 /⋆ 2.21:1 ⋆/ 22} video_format_t; 23</pre><p>is used in the VIDEO_SET_FORMAT function (??) to tell the driver which aspect ratio 24the output hardware (e.g. TV) has. It is also used in the data structures video_status 25(??) returned by VIDEO_GET_STATUS (??) and video_event (??) returned by 26VIDEO_GET_EVENT (??) which report about the display format of the current video 27stream. 28</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="video-displayformat-t"></a>video_displayformat_t</h3></div></div></div><p>In case the display format of the video stream and of the display hardware differ the 29application has to specify how to handle the cropping of the picture. This can be done using 30the VIDEO_SET_DISPLAY_FORMAT call (??) which accepts 31</p><pre class="programlisting"> 32typedef enum { 33 VIDEO_PAN_SCAN, /⋆ use pan and scan format ⋆/ 34 VIDEO_LETTER_BOX, /⋆ use letterbox format ⋆/ 35 VIDEO_CENTER_CUT_OUT /⋆ use center cut out format ⋆/ 36} video_displayformat_t; 37</pre><p>as argument. 38</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="video-stream-source-t"></a>video_stream_source_t</h3></div></div></div><p>The video stream source is set through the VIDEO_SELECT_SOURCE call and can take 39the following values, depending on whether we are replaying from an internal (demuxer) or 40external (user write) source. 41</p><pre class="programlisting"> 42typedef enum { 43 VIDEO_SOURCE_DEMUX, /⋆ Select the demux as the main source ⋆/ 44 VIDEO_SOURCE_MEMORY /⋆ If this source is selected, the stream 45 comes from the user through the write 46 system call ⋆/ 47} video_stream_source_t; 48</pre><p>VIDEO_SOURCE_DEMUX selects the demultiplexer (fed either by the frontend or the 49DVR device) as the source of the video stream. If VIDEO_SOURCE_MEMORY 50is selected the stream comes from the application through the <span class="tt">write()</span> system 51call. 52</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="video-play-state-t"></a>video_play_state_t</h3></div></div></div><p>The following values can be returned by the VIDEO_GET_STATUS call representing the 53state of video playback. 54</p><pre class="programlisting"> 55typedef enum { 56 VIDEO_STOPPED, /⋆ Video is stopped ⋆/ 57 VIDEO_PLAYING, /⋆ Video is currently playing ⋆/ 58 VIDEO_FREEZED /⋆ Video is freezed ⋆/ 59} video_play_state_t; 60</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="video-command"></a>struct video_command</h3></div></div></div><p>The structure must be zeroed before use by the application 61This ensures it can be extended safely in the future.</p><pre class="programlisting"> 62struct video_command { 63 __u32 cmd; 64 __u32 flags; 65 union { 66 struct { 67 __u64 pts; 68 } stop; 69 70 struct { 71 /⋆ 0 or 1000 specifies normal speed, 72 1 specifies forward single stepping, 73 -1 specifies backward single stepping, 74 >>1: playback at speed/1000 of the normal speed, 75 <-1: reverse playback at (-speed/1000) of the normal speed. ⋆/ 76 __s32 speed; 77 __u32 format; 78 } play; 79 80 struct { 81 __u32 data[16]; 82 } raw; 83 }; 84}; 85</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="video-size-t"></a>video_size_t</h3></div></div></div><pre class="programlisting"> 86typedef struct { 87 int w; 88 int h; 89 video_format_t aspect_ratio; 90} video_size_t; 91</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="video-event"></a>struct video_event</h3></div></div></div><p>The following is the structure of a video event as it is returned by the VIDEO_GET_EVENT 92call. 93</p><pre class="programlisting"> 94struct video_event { 95 __s32 type; 96#define VIDEO_EVENT_SIZE_CHANGED 1 97#define VIDEO_EVENT_FRAME_RATE_CHANGED 2 98#define VIDEO_EVENT_DECODER_STOPPED 3 99#define VIDEO_EVENT_VSYNC 4 100 __kernel_time_t timestamp; 101 union { 102 video_size_t size; 103 unsigned int frame_rate; /⋆ in frames per 1000sec ⋆/ 104 unsigned char vsync_field; /⋆ unknown/odd/even/progressive ⋆/ 105 } u; 106}; 107</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="video-status"></a>struct video_status</h3></div></div></div><p>The VIDEO_GET_STATUS call returns the following structure informing about various 108states of the playback operation. 109</p><pre class="programlisting"> 110struct video_status { 111 int video_blank; /⋆ blank video on freeze? ⋆/ 112 video_play_state_t play_state; /⋆ current state of playback ⋆/ 113 video_stream_source_t stream_source; /⋆ current source (demux/memory) ⋆/ 114 video_format_t video_format; /⋆ current aspect ratio of stream ⋆/ 115 video_displayformat_t display_format;/⋆ selected cropping mode ⋆/ 116}; 117</pre><p>If video_blank is set video will be blanked out if the channel is changed or if playback is 118stopped. Otherwise, the last picture will be displayed. play_state indicates if the video is 119currently frozen, stopped, or being played back. The stream_source corresponds to the seleted 120source for the video stream. It can come either from the demultiplexer or from memory. 121The video_format indicates the aspect ratio (one of 4:3 or 16:9) of the currently 122played video stream. Finally, display_format corresponds to the selected cropping 123mode in case the source video format is not the same as the format of the output 124device. 125</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="video-still-picture"></a>struct video_still_picture</h3></div></div></div><p>An I-frame displayed via the VIDEO_STILLPICTURE call is passed on within the 126following structure. 127</p><pre class="programlisting"> 128/⋆ pointer to and size of a single iframe in memory ⋆/ 129struct video_still_picture { 130 char ⋆iFrame; /⋆ pointer to a single iframe in memory ⋆/ 131 int32_t size; 132}; 133</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="video_caps"></a>video capabilities</h3></div></div></div><p>A call to VIDEO_GET_CAPABILITIES returns an unsigned integer with the following 134bits set according to the hardwares capabilities. 135</p><pre class="programlisting"> 136 /⋆ bit definitions for capabilities: ⋆/ 137 /⋆ can the hardware decode MPEG1 and/or MPEG2? ⋆/ 138 #define VIDEO_CAP_MPEG1 1 139 #define VIDEO_CAP_MPEG2 2 140 /⋆ can you send a system and/or program stream to video device? 141 (you still have to open the video and the audio device but only 142 send the stream to the video device) ⋆/ 143 #define VIDEO_CAP_SYS 4 144 #define VIDEO_CAP_PROG 8 145 /⋆ can the driver also handle SPU, NAVI and CSS encoded data? 146 (CSS API is not present yet) ⋆/ 147 #define VIDEO_CAP_SPU 16 148 #define VIDEO_CAP_NAVI 32 149 #define VIDEO_CAP_CSS 64 150</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="video-system"></a>video_system_t</h3></div></div></div><p>A call to VIDEO_SET_SYSTEM sets the desired video system for TV output. The 151following system types can be set: 152</p><pre class="programlisting"> 153typedef enum { 154 VIDEO_SYSTEM_PAL, 155 VIDEO_SYSTEM_NTSC, 156 VIDEO_SYSTEM_PALN, 157 VIDEO_SYSTEM_PALNc, 158 VIDEO_SYSTEM_PALM, 159 VIDEO_SYSTEM_NTSC60, 160 VIDEO_SYSTEM_PAL60, 161 VIDEO_SYSTEM_PALM60 162} video_system_t; 163</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="video-highlight"></a>struct video_highlight</h3></div></div></div><p>Calling the ioctl VIDEO_SET_HIGHLIGHTS posts the SPU highlight information. The 164call expects the following format for that information: 165</p><pre class="programlisting"> 166 typedef 167 struct video_highlight { 168 boolean active; /⋆ 1=show highlight, 0=hide highlight ⋆/ 169 uint8_t contrast1; /⋆ 7- 4 Pattern pixel contrast ⋆/ 170 /⋆ 3- 0 Background pixel contrast ⋆/ 171 uint8_t contrast2; /⋆ 7- 4 Emphasis pixel-2 contrast ⋆/ 172 /⋆ 3- 0 Emphasis pixel-1 contrast ⋆/ 173 uint8_t color1; /⋆ 7- 4 Pattern pixel color ⋆/ 174 /⋆ 3- 0 Background pixel color ⋆/ 175 uint8_t color2; /⋆ 7- 4 Emphasis pixel-2 color ⋆/ 176 /⋆ 3- 0 Emphasis pixel-1 color ⋆/ 177 uint32_t ypos; /⋆ 23-22 auto action mode ⋆/ 178 /⋆ 21-12 start y ⋆/ 179 /⋆ 9- 0 end y ⋆/ 180 uint32_t xpos; /⋆ 23-22 button color number ⋆/ 181 /⋆ 21-12 start x ⋆/ 182 /⋆ 9- 0 end x ⋆/ 183 } video_highlight_t; 184</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="video-spu"></a>struct video_spu</h3></div></div></div><p>Calling VIDEO_SET_SPU deactivates or activates SPU decoding, according to the 185following format: 186</p><pre class="programlisting"> 187 typedef 188 struct video_spu { 189 boolean active; 190 int stream_id; 191 } video_spu_t; 192</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="video-spu-palette"></a>struct video_spu_palette</h3></div></div></div><p>The following structure is used to set the SPU palette by calling VIDEO_SPU_PALETTE: 193</p><pre class="programlisting"> 194 typedef 195 struct video_spu_palette { 196 int length; 197 uint8_t ⋆palette; 198 } video_spu_palette_t; 199</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="video-navi-pack"></a>struct video_navi_pack</h3></div></div></div><p>In order to get the navigational data the following structure has to be passed to the ioctl 200VIDEO_GET_NAVI: 201</p><pre class="programlisting"> 202 typedef 203 struct video_navi_pack { 204 int length; /⋆ 0 ... 1024 ⋆/ 205 uint8_t data[1024]; 206 } video_navi_pack_t; 207</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="video-attributes-t"></a>video_attributes_t</h3></div></div></div><p>The following attributes can be set by a call to VIDEO_SET_ATTRIBUTES: 208</p><pre class="programlisting"> 209 typedef uint16_t video_attributes_t; 210 /⋆ bits: descr. ⋆/ 211 /⋆ 15-14 Video compression mode (0=MPEG-1, 1=MPEG-2) ⋆/ 212 /⋆ 13-12 TV system (0=525/60, 1=625/50) ⋆/ 213 /⋆ 11-10 Aspect ratio (0=4:3, 3=16:9) ⋆/ 214 /⋆ 9- 8 permitted display mode on 4:3 monitor (0=both, 1=only pan-sca ⋆/ 215 /⋆ 7 line 21-1 data present in GOP (1=yes, 0=no) ⋆/ 216 /⋆ 6 line 21-2 data present in GOP (1=yes, 0=no) ⋆/ 217 /⋆ 5- 3 source resolution (0=720x480/576, 1=704x480/576, 2=352x480/57 ⋆/ 218 /⋆ 2 source letterboxed (1=yes, 0=no) ⋆/ 219 /⋆ 0 film/camera mode (0=camera, 1=film (625/50 only)) ⋆/ 220</pre></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="dmx_fcalls.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="dvbapi.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="video_function_calls.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Demux Function Calls </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Video Function Calls</td></tr></table></div></body></html> 221