Pads are element’s input and output, where you can connect other elements. They used to negotiate links and data flow between elements in GStreamer. A pad can be viewed as a “plug” or “port” on an element
where links may be made with other elements, and through which data can flow to or from those elements. Pads have specific data handling capabilities: A pad can restrict the type of data that flows
through it. Links are only allowed between two pads when the allowed data types of the two pads are compatible. Data types are negotiated between pads using a process called caps negotiation. Data types
are described as a GstCaps.
An analogy may be helpful here. A pad is similar to a plug or jack on a physical device. Consider, for example, a home theater system consisting of an amplifier, a DVD player, and a (silent) video projector.
Linking the DVD player to the amplifier is allowed because both devices have audio jacks, and linking the projector to the DVD player is allowed because both devices have compatible video jacks. Links
between the projector and the amplifier may not be made because the projector and amplifier have different types of jacks. Pads in GStreamer serve the same purpose as the jacks in the home theater system.
Pads就像是元素上的接口,它们约束了可以通过的数据类型。通过caps negotiation机制,pads之间被定义是否兼容。就好像不同的设备的接口,扩音器只能接在音频接口上,而不能接在视频接口。
For the most part, all data in GStreamer flows one way through a link between elements. Data flows out of one element through one or more source pads, and elements accept incoming data through one or
more sink pads. Source and sink elements have only source and sink pads, respectively. Data usually means buffers(described by the GstBuffer
()object) and events (described by the GstEvent()object).
数据经常从SRC pad流出一个元素,而从SINK pad流进一个元素。而SRC 元素只有SRC pad, SINK 元素只有SINK pad。数据总是意味着缓冲区对象或者事件对象。
Bins and pipelines:容器和流水线
A bin is a container for a collection of elements. A pipeline is a special subtype of a bin that allows execution of all of its contained child elements. Since bins are subclasses of elements themselves, you
can mostly control a bin as if it were an element, thereby abstracting away a lot of complexity for your application. You can, for example change state on all elements in a bin by changing the state of that bin
itself. Bins also forward bus messages from their contained children (such as error messages, tag messages or EOS messages).
A pipeline is a top-level bin. As you set it to PAUSED or PLAYING state, data flow will start and media processing will take place. Once started, pipelines will run in a separate thread until you stop them or the
end of the data stream is reached.