| 1 |
Dynamic pads are pads that are created while the element is playing. |
| 2 |
This means that the element will create a new pas depending on the |
| 3 |
media type it is handling. For example, the mpeg1pdemuxer element will |
| 4 |
create one or more video pads and one or more audio pads depending |
| 5 |
on the number of elementary streams found in the media stream. |
| 6 |
|
| 7 |
The element will present its dynamic pads with the padtemplate list |
| 8 |
attached to the elementfactory. both the MIME type, direction, presence |
| 9 |
and properties of a pad can be obtained from the elementfactory using |
| 10 |
the padtemplates. |
| 11 |
|
| 12 |
Dynamic pad usually have the presence indicator set to |
| 13 |
GST_PAD_SOMETIMES. This indicated that the pad might become |
| 14 |
available at runtime. When the pad is actually created in the |
| 15 |
element, the element will signal the new_pad signal. This signal can |
| 16 |
then be used to attach a desired (compatible) element to the |
| 17 |
pad. |
| 18 |
|
| 19 |
For certain elements, like a tee and a muxer, we need another pad |
| 20 |
presence flag: GST_PAD_REQUEST. With this flag, the |
| 21 |
elementfactory will announce that some of the pads are available on |
| 22 |
request. For the tee element, for example, one might obtain a new output |
| 23 |
pad by looking up a suitable padtemplate (temp) and performing: |
| 24 |
gst_element_request_new_pad (element, temp). The element will then |
| 25 |
create a new pad from the template (sink or source) and will return |
| 26 |
a handle to it. You can then connect elements to this new pad. |
| 27 |
|
| 28 |
The muxer element (an avi encoder, for example) might expose several |
| 29 |
padtemplates for audio and video. The typical usage pattern for the |
| 30 |
muxer would then be: create a compressor element (JPEG). Get the |
| 31 |
src pad of the compressor, Request a new pad from the element using the |
| 32 |
padtemplate provided by the compressor src pad and connect the |
| 33 |
compressor element to this pad. |
| 34 |
|
| 35 |
An element that can be requested for a new pad has to implement the |
| 36 |
gst_element_request_new_pad method and perform the necessary steps |
| 37 |
to create a pad from that template. |
| 38 |
|
| 39 |
This interesting behaviour can be extended to ghostpads too. A |
| 40 |
compound element (a bin with internal elements) will also expose some |
| 41 |
padtemplates, either from the internal elements or from itself. Along |
| 42 |
with a new GstGhostPad class, this also solves the naming conflicts |
| 43 |
we might have with the ghostpads. The compound element will override |
| 44 |
the request_new_pad function and figure out which element it needs |
| 45 |
to get a pad from. |
| 46 |
|
| 47 |
Related to this solution: we will move the tee element to the |
| 48 |
gst/elements/ directory because there is no point in having the |
| 49 |
header files anymore. The new pad request API will become a feature |
| 50 |
of gstelement so gsttee becomes a real element too. |