Chapter 24. Writing a N-to-1 Element or Demuxer

N-to-1 elements have been previously mentioned and discussed in both Chapter 14 and in Chapter 12. The main noteworthy thing about N-to-1 elements is that they should always, without any single exception, be _loop ()-based. Apart from that, there is not much general that you need to know. We will discuss one special type of N-to-1 elements here, these being muxers. The first two of these sections apply to N-to-1 elements in general, though.

24.1. The Data Loop Function

As previously mentioned in Chapter 12, N-to-1 elements generally try to have one buffer from each sink pad and then handle the one with the earliest timestamp. There's some exceptions to this rule, we will come to those later. This only works if all streams actually continuously provide input. There might be cases where this is not true, for example subtitles (there might be no subtitle for a while), overlay images and so forth. For this purpose, there is a _select () function in GStreamer. It checks whether input is available on a (list of) pad(s). In this way, you can skip over the pads that are 'non- continuous'.


/* Pad selection is currently broken, FIXME some day */