/usr/share/doc/gstreamer0.10-doc/pwg/html/chapter-other-base.html is in gstreamer0.10-doc 0.10.36-1.5ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>Pre-made base classes</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79;charset=UTF-8"><LINK
REL="HOME"
TITLE="GStreamer Plugin Writer's Guide (0.10.36)"
HREF="index.html"><LINK
REL="UP"
TITLE="Creating special element types"
HREF="part-other.html"><LINK
REL="PREVIOUS"
TITLE="Creating special element types"
HREF="part-other.html"><LINK
REL="NEXT"
TITLE="Writing a source"
HREF="section-base-src.html"></HEAD
><BODY
CLASS="chapter"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
><SPAN
CLASS="application"
>GStreamer</SPAN
> Plugin Writer's Guide (0.10.36)</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="part-other.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="section-base-src.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="chapter"
><H1
><A
NAME="chapter-other-base"
></A
>Chapter 19. Pre-made base classes</H1
><P
> So far, we've been looking at low-level concepts of creating any type of
<SPAN
CLASS="application"
>GStreamer</SPAN
> element. Now, let's assume that all you want is to create an
simple audiosink that works exactly the same as, say,
<SPAN
CLASS="QUOTE"
>"esdsink"</SPAN
>, or a filter that simply normalizes audio volume.
Such elements are very general in concept and since they do nothing
special, they should be easier to code than to provide your own scheduler
activation functions and doing complex caps negotiation. For this purpose,
<SPAN
CLASS="application"
>GStreamer</SPAN
> provides base classes that simplify some types of elements.
Those base classes will be discussed in this chapter.
</P
><DIV
CLASS="sect1"
><H1
CLASS="sect1"
><A
NAME="section-base-sink"
>19.1. Writing a sink</A
></H1
><P
> Sinks are special elements in <SPAN
CLASS="application"
>GStreamer</SPAN
>. This is because sink elements
have to take care of <SPAN
CLASS="emphasis"
><I
CLASS="emphasis"
>preroll</I
></SPAN
>, which is the process
that takes care that elements going into the
<CODE
CLASS="classname"
>GST_STATE_PAUSED</CODE
> state will have buffers ready
after the state change. The result of this is that such elements can
start processing data immediately after going into the
<CODE
CLASS="classname"
>GST_STATE_PLAYING</CODE
> state, without requiring to
take some time to initialize outputs or set up decoders; all that is done
already before the state-change to <CODE
CLASS="classname"
>GST_STATE_PAUSED</CODE
>
successfully completes.
</P
><P
> Preroll, however, is a complex process that would require the same
code in many elements. Therefore, sink elements can derive from the
<CODE
CLASS="classname"
>GstBaseSink</CODE
> base-class, which does preroll and
a few other utility functions automatically. The derived class only
needs to implement a bunch of virtual functions and will work
automatically.
</P
><P
> The <CODE
CLASS="classname"
>GstBaseSink</CODE
> base-class specifies some
limitations on elements, though:
</P
><P
></P
><UL
><LI
><P
> It requires that the sink only has one sinkpad. Sink elements that
need more than one sinkpad, cannot use this base-class.
</P
></LI
><LI
><P
> The base-class owns the pad, and specifies caps negotiation, data
handling, pad allocation and such functions. If you need more than
the ones provided as virtual functions, then you cannot use this
base-class.
</P
></LI
><LI
><P
> By implementing the <CODE
CLASS="function"
>pad_allocate ()</CODE
> function,
it is possible for upstream elements to use special memory, such
as memory on the X server side that only the sink can allocate, or
even hardware memory <CODE
CLASS="function"
>mmap ()</CODE
>'ed from the kernel.
Note that in almost all cases, you will want to subclass the
<CODE
CLASS="classname"
>GstBuffer</CODE
> object, so that your own set of
functions will be called when the buffer loses its last reference.
</P
></LI
></UL
><P
> Sink elements can derive from <CODE
CLASS="classname"
>GstBaseSink</CODE
> using
the usual <CODE
CLASS="classname"
>GObject</CODE
> type creation voodoo, or by
using the convenience macro <CODE
CLASS="function"
>GST_BOILERPLATE ()</CODE
>:
</P
><PRE
CLASS="programlisting"
> GST_BOILERPLATE_FULL (GstMySink, gst_my_sink, GstBaseSink, GST_TYPE_BASE_SINK);
[..]
static void
gst_my_sink_class_init (GstMySinkClass * klass)
{
klass->set_caps = [..];
klass->render = [..];
[..]
}
</PRE
><P
> The advantages of deriving from <CODE
CLASS="classname"
>GstBaseSink</CODE
> are
numerous:
</P
><P
></P
><UL
><LI
><P
> Derived implementations barely need to be aware of preroll, and do
not need to know anything about the technical implementation
requirements of preroll. The base-class does all the hard work.
</P
><P
> Less code to write in the derived class, shared code (and thus
shared bugfixes).
</P
></LI
></UL
><P
> There are also specialized base classes for audio and video, let's look
at those a bit.
</P
><DIV
CLASS="sect2"
><H2
CLASS="sect2"
><A
NAME="section-base-audiosink"
>19.1.1. Writing an audio sink</A
></H2
><P
> Essentially, audio sink implementations are just a special case of a
general sink. There are two audio base classes that you can choose to
derive from, depending on your needs:
<CODE
CLASS="classname"
>GstBaseAudiosink</CODE
> and
<CODE
CLASS="classname"
>GstAudioSink</CODE
>. The baseaudiosink provides full
control over how synchronization and scheduling is handled, by using
a ringbuffer that the derived class controls and provides. The
audiosink base-class is a derived class of the baseaudiosink,
implementing a standard ringbuffer implementing default
synchronization and providing a standard audio-sample clock. Derived
classes of this base class merely need to provide a <CODE
CLASS="function"
>_open
()</CODE
>, <CODE
CLASS="function"
>_close ()</CODE
> and a <CODE
CLASS="function"
>_write
()</CODE
> function implementation, and some optional functions.
This should suffice for many sound-server output elements and even
most interfaces. More demanding audio systems, such as Jack, would
want to implement the <CODE
CLASS="classname"
>GstBaseAudioSink</CODE
>
base-class.
</P
><P
> The <CODE
CLASS="classname"
>GstBaseAusioSink</CODE
> has little to no
limitations and should fit virtually every implementation, but is
hard to implement. The <CODE
CLASS="classname"
>GstAudioSink</CODE
>, on the
other hand, only fits those systems with a simple <CODE
CLASS="function"
>open
()</CODE
> / <CODE
CLASS="function"
>close ()</CODE
> / <CODE
CLASS="function"
>write
()</CODE
> API (which practically means pretty much all of them),
but has the advantage that it is a lot easier to implement. The
benefits of this second base class are large:
</P
><P
></P
><UL
><LI
><P
> Automatic synchronization, without any code in the derived class.
</P
></LI
><LI
><P
> Also automatically provides a clock, so that other sinks (e.g. in
case of audio/video playback) are synchronized.
</P
></LI
><LI
><P
> Features can be added to all audiosinks by making a change in the
base class, which makes maintenance easy.
</P
></LI
><LI
><P
> Derived classes require only three small functions, plus some
<CODE
CLASS="classname"
>GObject</CODE
> boilerplate code.
</P
></LI
></UL
><P
> In addition to implementing the audio base-class virtual functions,
derived classes can (should) also implement the
<CODE
CLASS="classname"
>GstBaseSink</CODE
> <CODE
CLASS="function"
>set_caps ()</CODE
> and
<CODE
CLASS="function"
>get_caps ()</CODE
> virtual functions for negotiation.
</P
></DIV
><DIV
CLASS="sect2"
><H2
CLASS="sect2"
><A
NAME="section-base-videosink"
>19.1.2. Writing a video sink</A
></H2
><P
> Writing a videosink can be done using the
<CODE
CLASS="classname"
>GstVideoSink</CODE
> base-class, which derives from
<CODE
CLASS="classname"
>GstBaseSink</CODE
> internally. Currently, it does
nothing yet but add another compile dependency, so derived classes
will need to implement all base-sink virtual functions. When they do
this correctly, this will have some positive effects on the end user
experience with the videosink:
</P
><P
></P
><UL
><LI
><P
> Because of preroll (and the <CODE
CLASS="function"
>preroll ()</CODE
> virtual
function), it is possible to display a video frame already when
going into the <CODE
CLASS="classname"
>GST_STATE_PAUSED</CODE
> state.
</P
></LI
><LI
><P
> By adding new features to <CODE
CLASS="classname"
>GstVideoSink</CODE
>, it
will be possible to add extensions to videosinks that affect all of
them, but only need to be coded once, which is a huge maintenance
benefit.
</P
></LI
></UL
></DIV
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="part-other.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="section-base-src.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Creating special element types</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="part-other.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Writing a source</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>
|