2 the current capsnegotiation sucks and plainly doesn't work for queues.
3 one of the reasons is that the core is trying to do too much, like
4 being a mediator in the negotiation process. There is also way too much
5 interaction between plugins. Plugins have to keep a lot of state too.
7 The proposed method works by sending chains of caps instead, requiring
8 a worst case of 2 interactions between plugins. The drawback is that
9 a negotiating plugin has to do a bit more work, but in pactice this is
10 not a real argument against the proposed method, as the actions it has
11 to perform cannot be avoided. We will provide sufficient APIs to
14 We are not going to send random chains of caps between plugins but we
15 are going to filter them by using a new gst_caps_intersect() function
16 that can find the common media types and properties between the plugins.
17 The main idea is that the simple case should remain simple.
19 We also introduce app specific filters that can be set while doing a
22 We proceed with a few use cases because they tend to explain the ideas
31 no pad restrictions set on pad_connect
32 v4lsrc can do many formats, so can xvideosink
34 - v4lsrc request caps:
36 width and height properties were set on v4lsrc so it provides them as hints.
38 GstCaps *peercaps = gst_pad_request_caps (v4lsrc->srcpad,
42 "width", GST_PROPS_INT (352),
43 "height", GST_PROPS_INT (288)));
45 - core fetches xvideosink caps. if xvideosink has a request_caps function,
46 then the intersection of the hint, v4lsrcpad template caps and xvideosink
47 sinkpad template are sent as input.
48 If xvideosink has no request_caps function, the padtemplate
49 caps of xvideosink are taken.
50 - after intersect on both caps, peercaps equals:
57 "format", GST_PROPS_FOURCC (GST_STR_FOURCC ("YV12")),
58 "width", GST_PROPS_INT (352),
59 "height", GST_PROPS_INT (288)
64 "format", GST_PROPS_FOURCC (GST_STR_FOURCC ("I420")),
65 "width", GST_PROPS_INT (352),
66 "height", GST_PROPS_INT (288)
71 "format", GST_PROPS_FOURCC (GST_STR_FOURCC ("YUY2")),
72 "width", GST_PROPS_INT (352),
73 "height", GST_PROPS_INT (288)
78 "format", GST_PROPS_FOURCC (GST_STR_FOURCC ("UYVY")),
79 "width", GST_PROPS_INT (352),
80 "height", GST_PROPS_INT (288)
85 "format", GST_PROPS_FOURCC (GST_STR_FOURCC ("RGB ")),
86 "bpp", GST_PROPS_INT (16),
87 "depth", GST_PROPS_INT (16),
88 "endianness", GST_PROPS_INT (G_BYTE_ORDER),
89 "red_mask", GST_PROPS_INT (0xf800),
90 "green_mask", GST_PROPS_INT (0x07e0),
91 "blue_mask", GST_PROPS_INT (0x001f),
92 "width", GST_PROPS_INT (352),
93 "height", GST_PROPS_INT (288)
100 /* check if the caps can be used */
101 if (caps_are_useful (peercaps)) {
106 peercaps = gst_caps_new (peercaps);
109 gst_pad_set_caps (v4lsrc->srcpad, peercaps);
111 - core check compatibility with v4lsrc and xvideosink caps. if all goes well
112 caps are set on the pads.
114 - negotiation was more effective if v4lsrc provided srcpad caps since maybe
115 YUY2 etc could be removed in the intersect (when v4lsrc doesn't support that
122 mpeg2dec -> colorspace -> xvideosink
127 gst_pad_set_caps (mpeg2dec->srcpad,
131 "format", GST_PROPS_FOURCC (GST_STR_FOURCC ("I420")),
132 "width", GST_PROPS_INT (720),
133 "height", GST_PROPS_INT (480)
137 - core checks compatibility with mpeg2dec srcpad caps and colorspace caps.
138 - newcaps function of colorspace is called.
139 - colorspace requests peer pad caps with the hint.
140 - xvideosink doesn't have a request_caps function, the hint is ignored and
141 the padtemplate caps are returned.
142 - colorspace runs intersect on the two caps.
143 - if the intersection is NULL, colorspace has to set up a conversion function.
144 - runs through the list of caps, picking the first one for which a
145 converter exists between the received caps and the target caps. set up
146 the converter and set the target caps on the srcpad.
147 - if the intersection is not NULL, set received caps on colorspace srcpad.
153 mpeg2dec -> queue -> colorspace -> queue -> xvideosink
156 Same as use case 2, really. the queue just forwards the caps and the
159 can we use a default implementation for this proxying? probably.
160 for an element with no newcaps function or request_caps function, we can
161 simply set the caps on all srcpads when a set_caps is performed, or we
162 can request and intersect all srcpad caps when a peer element does
163 request_caps. This will actually work for tee too, to some degree.
169 gst_pad_connect_caps (...),
170 gst_element_connect_caps (v4lsrc, "src", xvideosink, "sink",
174 "format", GST_PROPS_FOURCC (GST_STR_FOURCC ("I420")),
175 "width", GST_PROPS_INT (352),
176 "height", GST_PROPS_INT (288)
180 - as long as the connection is not broken, the caps are set as a filter to the
183 - when v4lsrc requests pads, the intersection with the filter is also made.
185 - v4lsrc has no other choice but to use I420.
192 in this case, mad can both send "int" audio samples and "float" samples.
194 - mad request_caps from osssink, sending the fixed properties as hints (rate,
196 - osssink has a request_caps function, the core first makes the intersection
197 between the hint and mad srcpad template. the core then does the intersection
198 between osssink sinkpad template and sends this list to osssinks request_caps
199 function. osssink can try this list (or whatever remains of it) and whatever
200 works is sent back as the return value of the request_caps function.
201 - mad receives the caps list, takes the top caps and does a pad_set_caps
202 - osssink recieves the final caps on its new_caps function and configures the
209 gsm -> audioscaler -> osssink
211 Somebody sets some crazy low rate on the gsm srcpad (1000Hz).
213 - audioscalers newcaps function is called.
214 - audioscaler does a request_caps on its srcpad with the provided
216 - osssink tries the caps in the request_caps function (by opening the
217 device, seeing that it doesn't support this rate at all...)
218 - osssink tries to comply as closely with the rate and sends the
219 intersection between its padtemplate caps and the findings (rate 8000Hz
221 - audioscaler does the intersection between the caps list and the hint.
222 - intersection == NULL, a converter is needed between the hint and
223 the first caps of the request_caps list.
224 - intersection != NULL, set those caps (== the hint).