1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"> 2 <HTML 3 ><HEAD 4 ><TITLE 5 >ioctl VIDIOC_ENCODER_CMD, VIDIOC_TRY_ENCODER_CMD</TITLE 6 ><META 7 NAME="GENERATOR" 8 CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK 9 REL="HOME" 10 TITLE="Video for Linux Two API Specification" 11 HREF="book1.htm"><LINK 12 REL="UP" 13 TITLE="Function Reference" 14 HREF="r7624.htm"><LINK 15 REL="PREVIOUS" 16 TITLE="ioctl VIDIOC_DBG_G_REGISTER, VIDIOC_DBG_S_REGISTER" 17 HREF="r7900.htm"><LINK 18 REL="NEXT" 19 TITLE="ioctl VIDIOC_ENUMAUDIO" 20 HREF="r8242.htm"></HEAD 21 ><BODY 22 CLASS="REFENTRY" 23 BGCOLOR="#FFFFFF" 24 TEXT="#000000" 25 LINK="#0000FF" 26 VLINK="#840084" 27 ALINK="#0000FF" 28 ><DIV 29 CLASS="NAVHEADER" 30 ><TABLE 31 SUMMARY="Header navigation table" 32 WIDTH="100%" 33 BORDER="0" 34 CELLPADDING="0" 35 CELLSPACING="0" 36 ><TR 37 ><TH 38 COLSPAN="3" 39 ALIGN="center" 40 >Video for Linux Two API Specification: Revision 0.24</TH 41 ></TR 42 ><TR 43 ><TD 44 WIDTH="10%" 45 ALIGN="left" 46 VALIGN="bottom" 47 ><A 48 HREF="r7900.htm" 49 ACCESSKEY="P" 50 >Prev</A 51 ></TD 52 ><TD 53 WIDTH="80%" 54 ALIGN="center" 55 VALIGN="bottom" 56 ></TD 57 ><TD 58 WIDTH="10%" 59 ALIGN="right" 60 VALIGN="bottom" 61 ><A 62 HREF="r8242.htm" 63 ACCESSKEY="N" 64 >Next</A 65 ></TD 66 ></TR 67 ></TABLE 68 ><HR 69 ALIGN="LEFT" 70 WIDTH="100%"></DIV 71 ><H1 72 ><A 73 NAME="VIDIOC-ENCODER-CMD" 74 ></A 75 >ioctl VIDIOC_ENCODER_CMD, VIDIOC_TRY_ENCODER_CMD</H1 76 ><DIV 77 CLASS="REFNAMEDIV" 78 ><A 79 NAME="AEN8091" 80 ></A 81 ><H2 82 >Name</H2 83 >VIDIOC_ENCODER_CMD, VIDIOC_TRY_ENCODER_CMD -- Execute an encoder command</DIV 84 ><DIV 85 CLASS="REFSYNOPSISDIV" 86 ><A 87 NAME="AEN8095" 88 ></A 89 ><H2 90 >Synopsis</H2 91 ><DIV 92 CLASS="FUNCSYNOPSIS" 93 ><P 94 ></P 95 ><A 96 NAME="AEN8096" 97 ></A 98 ><P 99 ><CODE 100 ><CODE 101 CLASS="FUNCDEF" 102 >int ioctl</CODE 103 >(int fd, int request, struct v4l2_encoder_cmd *argp);</CODE 104 ></P 105 ><P 106 ></P 107 ></DIV 108 ></DIV 109 ><DIV 110 CLASS="REFSECT1" 111 ><A 112 NAME="AEN8106" 113 ></A 114 ><H2 115 >Arguments</H2 116 ><P 117 ></P 118 ><DIV 119 CLASS="VARIABLELIST" 120 ><DL 121 ><DT 122 ><CODE 123 CLASS="PARAMETER" 124 >fd</CODE 125 ></DT 126 ><DD 127 ><P 128 >File descriptor returned by <A 129 HREF="r14090.htm" 130 ><CODE 131 CLASS="FUNCTION" 132 >open()</CODE 133 ></A 134 >.</P 135 ></DD 136 ><DT 137 ><CODE 138 CLASS="PARAMETER" 139 >request</CODE 140 ></DT 141 ><DD 142 ><P 143 >VIDIOC_ENCODER_CMD, VIDIOC_TRY_ENCODER_CMD</P 144 ></DD 145 ><DT 146 ><CODE 147 CLASS="PARAMETER" 148 >argp</CODE 149 ></DT 150 ><DD 151 ><P 152 ></P 153 ></DD 154 ></DL 155 ></DIV 156 ></DIV 157 ><DIV 158 CLASS="REFSECT1" 159 ><A 160 NAME="AEN8126" 161 ></A 162 ><H2 163 >Description</H2 164 ><DIV 165 CLASS="NOTE" 166 ><BLOCKQUOTE 167 CLASS="NOTE" 168 ><P 169 ><B 170 >Experimental: </B 171 >This is an <A 172 HREF="x16453.htm" 173 >experimental</A 174 > 175 interface and may change in the future.</P 176 ></BLOCKQUOTE 177 ></DIV 178 ><P 179 >These ioctls control an audio/video (usually MPEG-) encoder. 180 <CODE 181 CLASS="CONSTANT" 182 >VIDIOC_ENCODER_CMD</CODE 183 > sends a command to the 184 encoder, <CODE 185 CLASS="CONSTANT" 186 >VIDIOC_TRY_ENCODER_CMD</CODE 187 > can be used to 188 try a command without actually executing it.</P 189 ><P 190 >To send a command applications must initialize all fields of a 191 struct <A 192 HREF="r8087.htm#V4L2-ENCODER-CMD" 193 >v4l2_encoder_cmd</A 194 > and call 195 <CODE 196 CLASS="CONSTANT" 197 >VIDIOC_ENCODER_CMD</CODE 198 > or 199 <CODE 200 CLASS="CONSTANT" 201 >VIDIOC_TRY_ENCODER_CMD</CODE 202 > with a pointer to this 203 structure.</P 204 ><P 205 >The <CODE 206 CLASS="STRUCTFIELD" 207 >cmd</CODE 208 > field must contain the 209 command code. The <CODE 210 CLASS="STRUCTFIELD" 211 >flags</CODE 212 > field is currently 213 only used by the STOP command and contains one bit: If the 214 <CODE 215 CLASS="CONSTANT" 216 >V4L2_ENC_CMD_STOP_AT_GOP_END</CODE 217 > flag is set, 218 encoding will continue until the end of the current <I 219 CLASS="WORDASWORD" 220 >Group 221 Of Pictures</I 222 >, otherwise it will stop immediately.</P 223 ><P 224 >A <CODE 225 CLASS="FUNCTION" 226 >read</CODE 227 >() call sends a START command to 228 the encoder if it has not been started yet. After a STOP command, 229 <CODE 230 CLASS="FUNCTION" 231 >read</CODE 232 >() calls will read the remaining data 233 buffered by the driver. When the buffer is empty, 234 <CODE 235 CLASS="FUNCTION" 236 >read</CODE 237 >() will return zero and the next 238 <CODE 239 CLASS="FUNCTION" 240 >read</CODE 241 >() call will restart the encoder.</P 242 ><P 243 >A <CODE 244 CLASS="FUNCTION" 245 >close</CODE 246 >() call sends an immediate STOP 247 to the encoder, and all buffered data is discarded.</P 248 ><P 249 >These ioctls are optional, not all drivers may support 250 them. They were introduced in Linux 2.6.21.</P 251 ><DIV 252 CLASS="TABLE" 253 ><A 254 NAME="V4L2-ENCODER-CMD" 255 ></A 256 ><P 257 ><B 258 >Table 1. struct <CODE 259 CLASS="STRUCTNAME" 260 >v4l2_encoder_cmd</CODE 261 ></B 262 ></P 263 ><TABLE 264 BORDER="0" 265 FRAME="void" 266 WIDTH="100%" 267 CLASS="CALSTABLE" 268 ><COL 269 WIDTH="25%" 270 TITLE="C1"><COL 271 WIDTH="25%" 272 TITLE="C2"><COL 273 WIDTH="50%" 274 TITLE="C3"><TBODY 275 VALIGN="TOP" 276 ><TR 277 ><TD 278 >__u32</TD 279 ><TD 280 ><CODE 281 CLASS="STRUCTFIELD" 282 >cmd</CODE 283 ></TD 284 ><TD 285 >The encoder command, see <A 286 HREF="r8087.htm#ENCODER-CMDS" 287 >Table 2</A 288 >.</TD 289 ></TR 290 ><TR 291 ><TD 292 >__u32</TD 293 ><TD 294 ><CODE 295 CLASS="STRUCTFIELD" 296 >flags</CODE 297 ></TD 298 ><TD 299 >Flags to go with the command, see <A 300 HREF="r8087.htm#ENCODER-FLAGS" 301 >Table 3</A 302 >. If no flags are defined for 303 this command, drivers and applications must set this field to 304 zero.</TD 305 ></TR 306 ><TR 307 ><TD 308 >__u32</TD 309 ><TD 310 ><CODE 311 CLASS="STRUCTFIELD" 312 >data</CODE 313 >[8]</TD 314 ><TD 315 >Reserved for future extensions. Drivers and 316 applications must set the array to zero.</TD 317 ></TR 318 ></TBODY 319 ></TABLE 320 ></DIV 321 ><DIV 322 CLASS="TABLE" 323 ><A 324 NAME="ENCODER-CMDS" 325 ></A 326 ><P 327 ><B 328 >Table 2. Encoder Commands</B 329 ></P 330 ><TABLE 331 BORDER="0" 332 FRAME="void" 333 WIDTH="100%" 334 CLASS="CALSTABLE" 335 ><COL 336 WIDTH="38%" 337 TITLE="C1"><COL 338 WIDTH="12%" 339 TITLE="C2"><COL 340 WIDTH="50%" 341 TITLE="C3"><TBODY 342 VALIGN="TOP" 343 ><TR 344 ><TD 345 ><CODE 346 CLASS="CONSTANT" 347 >V4L2_ENC_CMD_START</CODE 348 ></TD 349 ><TD 350 >0</TD 351 ><TD 352 >Start the encoder. When the encoder is already 353 running or paused, this command does nothing. No flags are defined for 354 this command.</TD 355 ></TR 356 ><TR 357 ><TD 358 ><CODE 359 CLASS="CONSTANT" 360 >V4L2_ENC_CMD_STOP</CODE 361 ></TD 362 ><TD 363 >1</TD 364 ><TD 365 >Stop the encoder. When the 366 <CODE 367 CLASS="CONSTANT" 368 >V4L2_ENC_CMD_STOP_AT_GOP_END</CODE 369 > flag is set, 370 encoding will continue until the end of the current <I 371 CLASS="WORDASWORD" 372 >Group 373 Of Pictures</I 374 >, otherwise encoding will stop immediately. 375 When the encoder is already stopped, this command does 376 nothing.</TD 377 ></TR 378 ><TR 379 ><TD 380 ><CODE 381 CLASS="CONSTANT" 382 >V4L2_ENC_CMD_PAUSE</CODE 383 ></TD 384 ><TD 385 >2</TD 386 ><TD 387 >Pause the encoder. When the encoder has not been 388 started yet, the driver will return an <SPAN 389 CLASS="ERRORCODE" 390 >EPERM</SPAN 391 > error code. When the encoder is 392 already paused, this command does nothing. No flags are defined for 393 this command.</TD 394 ></TR 395 ><TR 396 ><TD 397 ><CODE 398 CLASS="CONSTANT" 399 >V4L2_ENC_CMD_RESUME</CODE 400 ></TD 401 ><TD 402 >3</TD 403 ><TD 404 >Resume encoding after a PAUSE command. When the 405 encoder has not been started yet, the driver will return an <SPAN 406 CLASS="ERRORCODE" 407 >EPERM</SPAN 408 > error code. 409 When the encoder is already running, this command does nothing. No 410 flags are defined for this command.</TD 411 ></TR 412 ></TBODY 413 ></TABLE 414 ></DIV 415 ><DIV 416 CLASS="TABLE" 417 ><A 418 NAME="ENCODER-FLAGS" 419 ></A 420 ><P 421 ><B 422 >Table 3. Encoder Command Flags</B 423 ></P 424 ><TABLE 425 BORDER="0" 426 FRAME="void" 427 WIDTH="100%" 428 CLASS="CALSTABLE" 429 ><COL 430 WIDTH="38%" 431 TITLE="C1"><COL 432 WIDTH="12%" 433 TITLE="C2"><COL 434 WIDTH="50%" 435 TITLE="C3"><TBODY 436 VALIGN="TOP" 437 ><TR 438 ><TD 439 ><CODE 440 CLASS="CONSTANT" 441 >V4L2_ENC_CMD_STOP_AT_GOP_END</CODE 442 ></TD 443 ><TD 444 >0x0001</TD 445 ><TD 446 >Stop encoding at the end of the current <I 447 CLASS="WORDASWORD" 448 >Group Of 449 Pictures</I 450 >, rather than immediately.</TD 451 ></TR 452 ></TBODY 453 ></TABLE 454 ></DIV 455 ></DIV 456 ><DIV 457 CLASS="REFSECT1" 458 ><A 459 NAME="AEN8224" 460 ></A 461 ><H2 462 >Return Value</H2 463 ><P 464 >On success <SPAN 465 CLASS="RETURNVALUE" 466 >0</SPAN 467 > is returned, on error <SPAN 468 CLASS="RETURNVALUE" 469 >-1</SPAN 470 > and the <CODE 471 CLASS="VARNAME" 472 >errno</CODE 473 > variable is set appropriately:</P 474 ><P 475 ></P 476 ><DIV 477 CLASS="VARIABLELIST" 478 ><DL 479 ><DT 480 ><SPAN 481 CLASS="ERRORCODE" 482 >EINVAL</SPAN 483 ></DT 484 ><DD 485 ><P 486 >The driver does not support this ioctl, or the 487 <CODE 488 CLASS="STRUCTFIELD" 489 >cmd</CODE 490 > field is invalid.</P 491 ></DD 492 ><DT 493 ><SPAN 494 CLASS="ERRORCODE" 495 >EPERM</SPAN 496 ></DT 497 ><DD 498 ><P 499 >The application sent a PAUSE or RESUME command when 500 the encoder was not running.</P 501 ></DD 502 ></DL 503 ></DIV 504 ></DIV 505 ><DIV 506 CLASS="NAVFOOTER" 507 ><HR 508 ALIGN="LEFT" 509 WIDTH="100%"><TABLE 510 SUMMARY="Footer navigation table" 511 WIDTH="100%" 512 BORDER="0" 513 CELLPADDING="0" 514 CELLSPACING="0" 515 ><TR 516 ><TD 517 WIDTH="33%" 518 ALIGN="left" 519 VALIGN="top" 520 ><A 521 HREF="r7900.htm" 522 ACCESSKEY="P" 523 >Prev</A 524 ></TD 525 ><TD 526 WIDTH="34%" 527 ALIGN="center" 528 VALIGN="top" 529 ><A 530 HREF="book1.htm" 531 ACCESSKEY="H" 532 >Home</A 533 ></TD 534 ><TD 535 WIDTH="33%" 536 ALIGN="right" 537 VALIGN="top" 538 ><A 539 HREF="r8242.htm" 540 ACCESSKEY="N" 541 >Next</A 542 ></TD 543 ></TR 544 ><TR 545 ><TD 546 WIDTH="33%" 547 ALIGN="left" 548 VALIGN="top" 549 >ioctl VIDIOC_DBG_G_REGISTER, VIDIOC_DBG_S_REGISTER</TD 550 ><TD 551 WIDTH="34%" 552 ALIGN="center" 553 VALIGN="top" 554 ><A 555 HREF="r7624.htm" 556 ACCESSKEY="U" 557 >Up</A 558 ></TD 559 ><TD 560 WIDTH="33%" 561 ALIGN="right" 562 VALIGN="top" 563 >ioctl VIDIOC_ENUMAUDIO</TD 564 ></TR 565 ></TABLE 566 ></DIV 567 ></BODY 568 ></HTML 569 > 570