Lines 251-257
struct _GstBaseTransformPrivate
Link Here
|
251 |
/* upstream caps and size suggestions */ |
251 |
/* upstream caps and size suggestions */ |
252 |
GstCaps *sink_suggest; |
252 |
GstCaps *sink_suggest; |
253 |
guint size_suggest; |
253 |
guint size_suggest; |
254 |
gint suggest_pending; |
254 |
gboolean suggest_pending; |
255 |
|
255 |
|
256 |
gboolean reconfigure; |
256 |
gboolean reconfigure; |
257 |
}; |
257 |
}; |
Lines 896-901
gst_base_transform_find_transform (GstBa
Link Here
|
896 |
gst_pad_fixate_caps (otherpad, othercaps); |
896 |
gst_pad_fixate_caps (otherpad, othercaps); |
897 |
} |
897 |
} |
898 |
GST_DEBUG_OBJECT (trans, "after fixating %" GST_PTR_FORMAT, othercaps); |
898 |
GST_DEBUG_OBJECT (trans, "after fixating %" GST_PTR_FORMAT, othercaps); |
|
|
899 |
} else { |
900 |
/* else caps are fixed but the subclass may want to add fields */ |
901 |
if (klass->fixate_caps) { |
902 |
othercaps = gst_caps_make_writable (othercaps); |
903 |
|
904 |
GST_DEBUG_OBJECT (trans, "doing fixate %" GST_PTR_FORMAT |
905 |
" using caps %" GST_PTR_FORMAT |
906 |
" on pad %s:%s using fixate_caps vmethod", othercaps, caps, |
907 |
GST_DEBUG_PAD_NAME (otherpad)); |
908 |
|
909 |
klass->fixate_caps (trans, GST_PAD_DIRECTION (pad), caps, othercaps); |
910 |
} |
899 |
} |
911 |
} |
900 |
|
912 |
|
901 |
/* caps should be fixed now, if not we have to fail. */ |
913 |
/* caps should be fixed now, if not we have to fail. */ |
Lines 1074-1079
gst_base_transform_prepare_output_buffer
Link Here
|
1074 |
|
1086 |
|
1075 |
priv = trans->priv; |
1087 |
priv = trans->priv; |
1076 |
|
1088 |
|
|
|
1089 |
*out_buf = NULL; |
1090 |
|
1077 |
/* figure out how to allocate a buffer based on the current configuration */ |
1091 |
/* figure out how to allocate a buffer based on the current configuration */ |
1078 |
if (trans->passthrough) { |
1092 |
if (trans->passthrough) { |
1079 |
GST_DEBUG_OBJECT (trans, "doing passthrough alloc"); |
1093 |
GST_DEBUG_OBJECT (trans, "doing passthrough alloc"); |
Lines 1224-1230
gst_base_transform_prepare_output_buffer
Link Here
|
1224 |
gst_caps_unref (priv->sink_suggest); |
1238 |
gst_caps_unref (priv->sink_suggest); |
1225 |
priv->sink_suggest = gst_caps_ref (othercaps); |
1239 |
priv->sink_suggest = gst_caps_ref (othercaps); |
1226 |
priv->size_suggest = size_suggest; |
1240 |
priv->size_suggest = size_suggest; |
1227 |
g_atomic_int_set (&trans->priv->suggest_pending, 1); |
1241 |
trans->priv->suggest_pending = TRUE; |
1228 |
GST_OBJECT_UNLOCK (trans->sinkpad); |
1242 |
GST_OBJECT_UNLOCK (trans->sinkpad); |
1229 |
} |
1243 |
} |
1230 |
gst_caps_unref (othercaps); |
1244 |
gst_caps_unref (othercaps); |
Lines 1366-1372
gst_base_transform_buffer_alloc (GstPad
Link Here
|
1366 |
GstBaseTransform *trans; |
1380 |
GstBaseTransform *trans; |
1367 |
GstBaseTransformPrivate *priv; |
1381 |
GstBaseTransformPrivate *priv; |
1368 |
GstFlowReturn res; |
1382 |
GstFlowReturn res; |
1369 |
gboolean proxy, suggest; |
1383 |
gboolean proxy, suggest, same_caps; |
1370 |
GstCaps *sink_suggest; |
1384 |
GstCaps *sink_suggest; |
1371 |
guint size_suggest; |
1385 |
guint size_suggest; |
1372 |
|
1386 |
|
Lines 1384-1391
gst_base_transform_buffer_alloc (GstPad
Link Here
|
1384 |
|
1398 |
|
1385 |
/* we remember our previous alloc request to quickly see if we can proxy or |
1399 |
/* we remember our previous alloc request to quickly see if we can proxy or |
1386 |
* not. We skip this check if we have a pending suggestion. */ |
1400 |
* not. We skip this check if we have a pending suggestion. */ |
1387 |
if (g_atomic_int_get (&priv->suggest_pending) == 0 && caps && |
1401 |
GST_OBJECT_LOCK (pad); |
1388 |
gst_caps_is_equal (priv->sink_alloc, caps)) { |
1402 |
same_caps = !priv->suggest_pending && caps && |
|
|
1403 |
gst_caps_is_equal (priv->sink_alloc, caps); |
1404 |
GST_OBJECT_UNLOCK (pad); |
1405 |
|
1406 |
if (same_caps) { |
1389 |
/* we have seen this before, see below if we need to proxy */ |
1407 |
/* we have seen this before, see below if we need to proxy */ |
1390 |
GST_DEBUG_OBJECT (trans, "have old caps"); |
1408 |
GST_DEBUG_OBJECT (trans, "have old caps"); |
1391 |
sink_suggest = caps; |
1409 |
sink_suggest = caps; |
Lines 1414-1420
gst_base_transform_buffer_alloc (GstPad
Link Here
|
1414 |
size_suggest = size; |
1432 |
size_suggest = size; |
1415 |
suggest = FALSE; |
1433 |
suggest = FALSE; |
1416 |
} |
1434 |
} |
1417 |
g_atomic_int_set (&priv->suggest_pending, 0); |
1435 |
priv->suggest_pending = FALSE; |
1418 |
GST_OBJECT_UNLOCK (pad); |
1436 |
GST_OBJECT_UNLOCK (pad); |
1419 |
|
1437 |
|
1420 |
/* check if we actually handle this format on the sinkpad */ |
1438 |
/* check if we actually handle this format on the sinkpad */ |
Lines 1462-1468
gst_base_transform_buffer_alloc (GstPad
Link Here
|
1462 |
} |
1480 |
} |
1463 |
} |
1481 |
} |
1464 |
/* remember the new caps */ |
1482 |
/* remember the new caps */ |
|
|
1483 |
GST_OBJECT_LOCK (pad); |
1465 |
gst_caps_replace (&priv->sink_alloc, sink_suggest); |
1484 |
gst_caps_replace (&priv->sink_alloc, sink_suggest); |
|
|
1485 |
GST_OBJECT_UNLOCK (pad); |
1486 |
|
1466 |
proxy = priv->proxy_alloc; |
1487 |
proxy = priv->proxy_alloc; |
1467 |
GST_DEBUG_OBJECT (trans, "doing default alloc, proxy %d", proxy); |
1488 |
GST_DEBUG_OBJECT (trans, "doing default alloc, proxy %d", proxy); |
1468 |
|
1489 |
|
Lines 1487-1497
gst_base_transform_buffer_alloc (GstPad
Link Here
|
1487 |
if (!gst_caps_is_equal (newcaps, caps)) { |
1508 |
if (!gst_caps_is_equal (newcaps, caps)) { |
1488 |
GST_DEBUG_OBJECT (trans, "caps are new"); |
1509 |
GST_DEBUG_OBJECT (trans, "caps are new"); |
1489 |
/* we have new caps, see if we can proxy downstream */ |
1510 |
/* we have new caps, see if we can proxy downstream */ |
1490 |
if (gst_pad_peer_accept_caps (trans->sinkpad, newcaps)) { |
1511 |
if (gst_pad_peer_accept_caps (pad, newcaps)) { |
1491 |
/* peer accepts the caps, return a buffer in this format */ |
1512 |
/* peer accepts the caps, return a buffer in this format */ |
1492 |
GST_DEBUG_OBJECT (trans, "peer accepted new caps"); |
1513 |
GST_DEBUG_OBJECT (trans, "peer accepted new caps"); |
1493 |
/* remember the format */ |
1514 |
/* remember the format */ |
|
|
1515 |
GST_OBJECT_LOCK (pad); |
1494 |
gst_caps_replace (&priv->sink_alloc, newcaps); |
1516 |
gst_caps_replace (&priv->sink_alloc, newcaps); |
|
|
1517 |
GST_OBJECT_UNLOCK (pad); |
1495 |
} else { |
1518 |
} else { |
1496 |
GST_DEBUG_OBJECT (trans, "peer did not accept new caps"); |
1519 |
GST_DEBUG_OBJECT (trans, "peer did not accept new caps"); |
1497 |
/* peer does not accept the caps, free the buffer we received and |
1520 |
/* peer does not accept the caps, free the buffer we received and |
Lines 1694-1699
gst_base_transform_handle_buffer (GstBas
Link Here
|
1694 |
GST_OBJECT_UNLOCK (trans); |
1717 |
GST_OBJECT_UNLOCK (trans); |
1695 |
|
1718 |
|
1696 |
if (G_UNLIKELY (reconfigure)) { |
1719 |
if (G_UNLIKELY (reconfigure)) { |
|
|
1720 |
GST_DEBUG_OBJECT (trans, "we had a pending reconfigure"); |
1697 |
/* if we need to reconfigure we pretend a buffer with new caps arrived. This |
1721 |
/* if we need to reconfigure we pretend a buffer with new caps arrived. This |
1698 |
* will reconfigure the transform with the new output format. We can only |
1722 |
* will reconfigure the transform with the new output format. We can only |
1699 |
* do this if the buffer actually has caps. */ |
1723 |
* do this if the buffer actually has caps. */ |
Lines 1853-1867
gst_base_transform_getrange (GstPad * pa
Link Here
|
1853 |
trans = GST_BASE_TRANSFORM (gst_pad_get_parent (pad)); |
1877 |
trans = GST_BASE_TRANSFORM (gst_pad_get_parent (pad)); |
1854 |
|
1878 |
|
1855 |
ret = gst_pad_pull_range (trans->sinkpad, offset, length, &inbuf); |
1879 |
ret = gst_pad_pull_range (trans->sinkpad, offset, length, &inbuf); |
1856 |
if (ret == GST_FLOW_OK) { |
1880 |
if (G_UNLIKELY (ret != GST_FLOW_OK)) |
1857 |
GST_BASE_TRANSFORM_LOCK (trans); |
1881 |
goto pull_error; |
1858 |
ret = gst_base_transform_handle_buffer (trans, inbuf, buffer); |
1882 |
|
1859 |
GST_BASE_TRANSFORM_UNLOCK (trans); |
1883 |
GST_BASE_TRANSFORM_LOCK (trans); |
1860 |
} |
1884 |
ret = gst_base_transform_handle_buffer (trans, inbuf, buffer); |
|
|
1885 |
GST_BASE_TRANSFORM_UNLOCK (trans); |
1861 |
|
1886 |
|
|
|
1887 |
done: |
1862 |
gst_object_unref (trans); |
1888 |
gst_object_unref (trans); |
1863 |
|
1889 |
|
1864 |
return ret; |
1890 |
return ret; |
|
|
1891 |
|
1892 |
/* ERRORS */ |
1893 |
pull_error: |
1894 |
{ |
1895 |
GST_DEBUG_OBJECT (trans, "failed to pull a buffer: %s", |
1896 |
gst_flow_get_name (ret)); |
1897 |
goto done; |
1898 |
} |
1865 |
} |
1899 |
} |
1866 |
|
1900 |
|
1867 |
static GstFlowReturn |
1901 |
static GstFlowReturn |
Lines 2305-2311
gst_base_transform_suggest (GstBaseTrans
Link Here
|
2305 |
caps = gst_caps_copy (caps); |
2339 |
caps = gst_caps_copy (caps); |
2306 |
trans->priv->sink_suggest = caps; |
2340 |
trans->priv->sink_suggest = caps; |
2307 |
trans->priv->size_suggest = size; |
2341 |
trans->priv->size_suggest = size; |
2308 |
g_atomic_int_set (&trans->priv->suggest_pending, 1); |
2342 |
trans->priv->suggest_pending = TRUE; |
2309 |
GST_DEBUG_OBJECT (trans, "new suggest %" GST_PTR_FORMAT, caps); |
2343 |
GST_DEBUG_OBJECT (trans, "new suggest %" GST_PTR_FORMAT, caps); |
2310 |
GST_OBJECT_UNLOCK (trans->sinkpad); |
2344 |
GST_OBJECT_UNLOCK (trans->sinkpad); |
2311 |
} |
2345 |
} |
Lines 2326-2331
gst_base_transform_reconfigure (GstBaseT
Link Here
|
2326 |
g_return_if_fail (GST_IS_BASE_TRANSFORM (trans)); |
2360 |
g_return_if_fail (GST_IS_BASE_TRANSFORM (trans)); |
2327 |
|
2361 |
|
2328 |
GST_OBJECT_LOCK (trans); |
2362 |
GST_OBJECT_LOCK (trans); |
|
|
2363 |
GST_DEBUG_OBJECT (trans, "marking reconfigure"); |
2329 |
trans->priv->reconfigure = TRUE; |
2364 |
trans->priv->reconfigure = TRUE; |
2330 |
GST_OBJECT_UNLOCK (trans); |
2365 |
GST_OBJECT_UNLOCK (trans); |
2331 |
} |
2366 |
} |