aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Clark2010-05-19 15:48:09 -0500
committerNikhil Devshatwar2013-05-15 06:20:49 -0500
commit039b9656692478d6fcd7a65c227b59eb12b75e83 (patch)
tree7bb2d545d1d78a278140b6089a05b631ffddf8f0
parent83cb98507f161e0d5610d4aa6a22d283334e131f (diff)
downloadgstreamer0-10-039b9656692478d6fcd7a65c227b59eb12b75e83.tar.gz
gstreamer0-10-039b9656692478d6fcd7a65c227b59eb12b75e83.tar.xz
gstreamer0-10-039b9656692478d6fcd7a65c227b59eb12b75e83.zip
add GstQueryBuffers query
This query is used by buffer allocator, for example a video sink element, to find out any minimum buffer requirements of upstream elements that uses pad_alloc() to allocate buffers. For example, some cameras may have need for additional padding/boarder around the frame (for vstab), or some video decoders may have requirements for a certain minimum number of buffers (so they can hold refs to reference-frames)
-rw-r--r--gst/gstquark.c3
-rw-r--r--gst/gstquark.h7
-rw-r--r--gst/gstquery.c141
-rw-r--r--gst/gstquery.h16
4 files changed, 164 insertions, 3 deletions
diff --git a/gst/gstquark.c b/gst/gstquark.c
index 91a201271..0459b4e2c 100644
--- a/gst/gstquark.c
+++ b/gst/gstquark.c
@@ -50,7 +50,8 @@ static const gchar *_quark_strings[] = {
50 "intermediate", "GstMessageStepStart", "active", "eos", "sink-message", 50 "intermediate", "GstMessageStepStart", "active", "eos", "sink-message",
51 "message", "GstMessageQOS", "running-time", "stream-time", "jitter", 51 "message", "GstMessageQOS", "running-time", "stream-time", "jitter",
52 "quality", "processed", "dropped", "buffering-ranges", "GstMessageProgress", 52 "quality", "processed", "dropped", "buffering-ranges", "GstMessageProgress",
53 "code", "text", "percent", "timeout" 53 "code", "text", "percent", "timeout",
54 "GstQueryBuffers", "caps", "count", "width", "height"
54}; 55};
55 56
56GQuark _priv_gst_quark_table[GST_QUARK_MAX]; 57GQuark _priv_gst_quark_table[GST_QUARK_MAX];
diff --git a/gst/gstquark.h b/gst/gstquark.h
index 6e16ee5d7..350f9fc68 100644
--- a/gst/gstquark.h
+++ b/gst/gstquark.h
@@ -132,8 +132,13 @@ typedef enum _GstQuarkId
132 GST_QUARK_TEXT = 103, 132 GST_QUARK_TEXT = 103,
133 GST_QUARK_PERCENT = 104, 133 GST_QUARK_PERCENT = 104,
134 GST_QUARK_TIMEOUT = 105, 134 GST_QUARK_TIMEOUT = 105,
135 GST_QUARK_QUERY_BUFFERS = 106,
136 GST_QUARK_CAPS = 107,
137 GST_QUARK_COUNT = 108,
138 GST_QUARK_WIDTH = 109,
139 GST_QUARK_HEIGHT = 110,
135 140
136 GST_QUARK_MAX = 106 141 GST_QUARK_MAX = 111
137} GstQuarkId; 142} GstQuarkId;
138 143
139extern GQuark _priv_gst_quark_table[GST_QUARK_MAX]; 144extern GQuark _priv_gst_quark_table[GST_QUARK_MAX];
diff --git a/gst/gstquery.c b/gst/gstquery.c
index 2b1c38229..1d7f5f99b 100644
--- a/gst/gstquery.c
+++ b/gst/gstquery.c
@@ -96,6 +96,7 @@ static GstQueryTypeDefinition standard_definitions[] = {
96 {GST_QUERY_BUFFERING, "buffering", "Buffering status", 0}, 96 {GST_QUERY_BUFFERING, "buffering", "Buffering status", 0},
97 {GST_QUERY_CUSTOM, "custom", "Custom query", 0}, 97 {GST_QUERY_CUSTOM, "custom", "Custom query", 0},
98 {GST_QUERY_URI, "uri", "URI of the source or sink", 0}, 98 {GST_QUERY_URI, "uri", "URI of the source or sink", 0},
99 {GST_QUERY_BUFFERS, "buffers", "Minimum buffer requirements", 0},
99 {GST_QUERY_NONE, NULL, NULL, 0} 100 {GST_QUERY_NONE, NULL, NULL, 0}
100}; 101};
101 102
@@ -1490,3 +1491,143 @@ gst_query_parse_uri (GstQuery * query, gchar ** uri)
1490 *uri = g_value_dup_string (gst_structure_id_get_value (query->structure, 1491 *uri = g_value_dup_string (gst_structure_id_get_value (query->structure,
1491 GST_QUARK (URI))); 1492 GST_QUARK (URI)));
1492} 1493}
1494
1495/**
1496 * gst_query_new_buffers:
1497 * @caps: the #GstCaps for the buffers that are going to be allocated
1498 *
1499 * Constructs a new buffer requirements query object to query buffer
1500 * requirements for a particular caps. Use gst_query_unref() when done
1501 * with it.
1502 *
1503 * Returns: A #GstQuery
1504 */
1505GstQuery *
1506gst_query_new_buffers (GstCaps * caps)
1507{
1508 GstQuery *query;
1509 GstStructure *structure;
1510
1511 /* XXX could add size here, for linear (non YUV/RGB) buffers? But I'm not
1512 * entirely sure what is the use-case for that.. it should be easy enough
1513 * to add more optional reply fields later
1514 */
1515 structure = gst_structure_id_new (GST_QUARK (QUERY_BUFFERS),
1516 GST_QUARK (CAPS), GST_TYPE_CAPS, caps,
1517 GST_QUARK (COUNT), G_TYPE_INT, -1,
1518 GST_QUARK (WIDTH), G_TYPE_INT, -1,
1519 GST_QUARK (HEIGHT), G_TYPE_INT, -1, NULL);
1520
1521 query = gst_query_new (GST_QUERY_BUFFERS, structure);
1522
1523 return query;
1524}
1525
1526/**
1527 * gst_query_set_buffers_count:
1528 * @count: minimum number of buffers required
1529 *
1530 * Answer a buffers query by setting the minimum number of buffers required.
1531 * If there is no minimum buffer count requirement, don't set this field in
1532 * the query.
1533 */
1534void
1535gst_query_set_buffers_count (GstQuery * query, gint count)
1536{
1537 GstStructure *structure;
1538
1539 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_BUFFERS);
1540
1541 structure = gst_query_get_structure (query);
1542 gst_structure_id_set (structure, GST_QUARK (COUNT), G_TYPE_INT, count, NULL);
1543}
1544
1545/**
1546 * gst_query_set_buffers_dimensions:
1547 * @width: minimum buffer width
1548 * @height: minimum buffer height
1549 *
1550 * Answer a buffers query by setting the minimum buffer dimensions required.
1551 * If there is no minimum buffer dimensions (beyond the width/height specified
1552 * in the #GstCaps), don't set this field in the query.
1553 */
1554void
1555gst_query_set_buffers_dimensions (GstQuery * query, gint width, gint height)
1556{
1557 GstStructure *structure;
1558
1559 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_BUFFERS);
1560
1561 structure = gst_query_get_structure (query);
1562 gst_structure_id_set (structure,
1563 GST_QUARK (WIDTH), G_TYPE_INT, width,
1564 GST_QUARK (HEIGHT), G_TYPE_INT, height, NULL);
1565}
1566
1567/**
1568 * gst_query_parse_buffers_caps:
1569 * @query: a #GstQuery
1570 * @caps: the storage for the #GstCaps pointer, or NULL
1571 *
1572 * Parse a buffers query.
1573 */
1574void
1575gst_query_parse_buffers_caps (GstQuery * query, const GstCaps ** caps)
1576{
1577 GstStructure *structure;
1578
1579 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_BUFFERS);
1580
1581 structure = gst_query_get_structure (query);
1582 if (caps)
1583 *caps = gst_value_get_caps (gst_structure_id_get_value (structure,
1584 GST_QUARK (CAPS)));
1585}
1586
1587/**
1588 * gst_query_parse_buffers_count:
1589 * @query: a #GstQuery
1590 * @count: the storage for minimum number of buffers, or NULL
1591 *
1592 * Parse a buffers query answer to see the minimum number of buffers
1593 * required. A returned value of -1 means there is no minimum requirement
1594 */
1595void
1596gst_query_parse_buffers_count (GstQuery * query, gint * count)
1597{
1598 GstStructure *structure;
1599
1600 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_BUFFERS);
1601
1602 structure = gst_query_get_structure (query);
1603 if (count)
1604 *count = g_value_get_int (gst_structure_id_get_value (structure,
1605 GST_QUARK (COUNT)));
1606}
1607
1608/**
1609 * gst_query_parse_buffers_dimensions:
1610 * @query: a #GstQuery
1611 * @width: the storage for minimum width, or NULL
1612 * @height: the storage for minimum height, or NULL
1613 *
1614 * Parse a buffers query answer to see the minimum buffer dimensions required.
1615 * A returned value of -1 for either dimension means there is no minimum
1616 * requirement in that axis
1617 */
1618void
1619gst_query_parse_buffers_dimensions (GstQuery * query, gint * width,
1620 gint * height)
1621{
1622 GstStructure *structure;
1623
1624 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_BUFFERS);
1625
1626 structure = gst_query_get_structure (query);
1627 if (width)
1628 *width = g_value_get_int (gst_structure_id_get_value (structure,
1629 GST_QUARK (WIDTH)));
1630 if (height)
1631 *height = g_value_get_int (gst_structure_id_get_value (structure,
1632 GST_QUARK (HEIGHT)));
1633}
diff --git a/gst/gstquery.h b/gst/gstquery.h
index 2166537ef..8dd710abd 100644
--- a/gst/gstquery.h
+++ b/gst/gstquery.h
@@ -31,6 +31,7 @@
31#include <gst/gstminiobject.h> 31#include <gst/gstminiobject.h>
32#include <gst/gststructure.h> 32#include <gst/gststructure.h>
33#include <gst/gstformat.h> 33#include <gst/gstformat.h>
34#include <gst/gstcaps.h>
34 35
35G_BEGIN_DECLS 36G_BEGIN_DECLS
36 37
@@ -51,6 +52,9 @@ G_BEGIN_DECLS
51 * @GST_QUERY_CUSTOM: a custom application or element defined query. Since 52 * @GST_QUERY_CUSTOM: a custom application or element defined query. Since
52 * 0.10.22. 53 * 0.10.22.
53 * @GST_QUERY_URI: query the URI of the source or sink. Since 0.10.22. 54 * @GST_QUERY_URI: query the URI of the source or sink. Since 0.10.22.
55 * @GST_QUERY_BUFFERS: query the upstream users of pad_alloc()'d buffers to
56 * find any particular requirements about buffer size (padding) or numbers of
57 * buffers. Since ?.?.?.
54 * 58 *
55 * Standard predefined Query types 59 * Standard predefined Query types
56 */ 60 */
@@ -69,7 +73,8 @@ typedef enum {
69 GST_QUERY_FORMATS, 73 GST_QUERY_FORMATS,
70 GST_QUERY_BUFFERING, 74 GST_QUERY_BUFFERING,
71 GST_QUERY_CUSTOM, 75 GST_QUERY_CUSTOM,
72 GST_QUERY_URI 76 GST_QUERY_URI,
77 GST_QUERY_BUFFERS
73} GstQueryType; 78} GstQueryType;
74 79
75/** 80/**
@@ -336,6 +341,15 @@ GstQuery * gst_query_new_uri (void) G_GNUC_MALLOC;
336void gst_query_parse_uri (GstQuery *query, gchar **uri); 341void gst_query_parse_uri (GstQuery *query, gchar **uri);
337void gst_query_set_uri (GstQuery *query, const gchar *uri); 342void gst_query_set_uri (GstQuery *query, const gchar *uri);
338 343
344/* buffer requirements query */
345GstQuery * gst_query_new_buffers (GstCaps * caps);
346void gst_query_set_buffers_count (GstQuery * query, gint count);
347void gst_query_set_buffers_dimensions (GstQuery * query, gint width, gint height);
348void gst_query_parse_buffers_caps (GstQuery * query, const GstCaps ** caps);
349void gst_query_parse_buffers_count (GstQuery * query, gint * count);
350void gst_query_parse_buffers_dimensions (GstQuery * query, gint * width, gint * height);
351
352
339G_END_DECLS 353G_END_DECLS
340 354
341#endif /* __GST_QUERY_H__ */ 355#endif /* __GST_QUERY_H__ */