GStreamer 学习记录 - Caps and negotiation

https://gstreamer.freedesktop.org/documentation/plugin-development/advanced/negotiation.html

Caps negotiation

Caps negotiation is the act of finding a media format (GstCaps) between elements that they can handle. This process in GStreamer can in most cases find an optimal solution for the complete pipeline. In this section we explain how this works.

Caps negotiation basics

In GStreamer, negotiation of the media format always follows the following simple rules:

遵循的几个原则: 

  • A downstream element suggest a format on its sinkpad and places the suggestion in the result of the CAPS query performed on the sinkpad. See also Implementing a CAPS query function.

  • downstream的element可以通过其sinkpad给出建议的格式, 在其sinkpad收到CAPS query后,将其建议的格式作为结果返回。 

  • An upstream element decides on a format. It sends the selected media format downstream on its source pad with a CAPS event. Downstream elements reconfigure themselves to handle the media type in the CAPS event on the sinkpad.

  • 一个upstream element可以决定某种格式,该element可以将其选定的格式以CAPS event的方式通过其source pad发送向downstream。Downstream的element在其sinkpad收到CAPS event所发送的选定格式后,对自己做重新配置。

  • A downstream element can inform upstream that it would like to suggest a new format by sending a RECONFIGURE event upstream. The RECONFIGURE event simply instructs an upstream element to restart the negotiation phase. Because the element that sent out the RECONFIGURE event is now suggesting another format, the format in the pipeline might change.

  • 一个downstream的element可以通过发送RECONFIGURE event给upstream,通过这种方式提出自己的建议格式。RECONFIGURE event命令upstream element重启negotiation。

In addition to the CAPS and RECONFIGURE event and the CAPS query, there is an ACCEPT_CAPS query to quickly check if a certain caps can be accepted by an element.

Caps negotiation use cases

In what follows we will look at some use cases for push-mode scheduling. The pull-mode scheduling negotiation phase is discussed in Pull-mode Caps negotiation and is actually similar as we will see.

Since the sink pads only suggest formats and the source pads need to decide, the most complicated work is done in the source pads. We can identify 3 caps negotiation use cases for the source pads:

由于sink pads只是提出建议格式,而source pads需要决定什么格式,所以大部分复杂的工作都是由source pads完成的。

  • Fixed negotiation. An element can output one format only. See Fixed negotiation.

  • Transform negotiation. There is a (fixed) transform between the input and output format of the element, usually based on some element property. The caps that the element will produce depend on the upstream caps and the caps that the element can accept depend on the downstream caps. See Transform negotiation.

  • Dynamic negotiation. An element can output many formats. See Dynamic negotiation.

下边这个链接对这块介绍的比较好: 

https://blog.csdn.net/techx/article/details/44134911

发布了11 篇原创文章 · 获赞 5 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/gsymichael/article/details/81181145