Basic tutorial 6: Media formats and Pad Capabilities
Abstract |
Basic tutorial 3: Dynamic pipelines |
Authors |
Walter Fan |
Status |
WIP as draft |
Updated |
2024-08-21 |
目标
Pad Capabilities 是 GStreamer 的基本元素,尽管大多数时候它们是不可见的,因为框架会自动处理它们。
什么是 Pad Capabilities
如何找回它们。
何时取回它们。
为什么您需要了解它们。
介绍
Pad 允许信息进入和离开元素。 然后 Pad Caps 指定可以通过 Pad 传输的信息类型
例如:
分辨率为 640*360 像素,帧率为 30 fps 的 RGB 视频
音频采样为 16bit, 采样频率为 44.1k, 5.1 声道的音频
或者指定为 mp3 或 h264 的压缩格式
Pads 可以支持多种能力 Capabilities (例如, Video sink 可以支持不同类型的 RGB 或 YUV 格式的视频), 并且可以将 Caps 指定为一个范围 (例如 audio sink 可以支持 8k 到 48k的采样率)
然而,从一个 pad 到另一个 pad 实际上传输的信息必须只有一种明确指定的类型。 通过一个称为协商的过程,两个链接的 pad 就共同的类型达成一致,这样 pad 的 Capabilities 会固定下来。
为了将两个元素链接在一起,我们必须共享一个公共的 Capabilities 子集,否则它们不可能相互理解,这是 Capabilities 的主要目标
作为应用程序开发人员,您通常会通过将元素链接在一起来构建管道(如果您使用像 playbin 这样的 all-in-all 元素,则程度较小)。 在这种情况下,您需要了解元素的 Pad Caps(如人们所熟悉的那样),或者至少知道当 GStreamer 因协商错误而拒绝链接两个元素时它们是什么。
Pad templates
Pads are created from Pad Templates, which indicate all possible Capabilities a Pad could ever have. Templates are useful to create several similar Pads, and also allow early refusal of connections between elements: If the Capabilities of their Pad Templates do not have a common subset (their intersection is empty), there is no need to negotiate further.
Pad Templates can be viewed as the first step in the negotiation process. As the process evolves, actual Pads are instantiated and their Capabilities refined until they are fixed (or negotiation fails).