tests/examples/snapshot/snapshot.c: get caps from the sample

pull-preroll signal returns a GstSample, not a GstBuffer

https://bugzilla.gnome.org/show_bug.cgi?id=684063
This commit is contained in:
Javier Jardón 2012-09-14 02:18:52 +09:00 committed by Tim-Philipp Müller
parent b19944d1e4
commit f0d3f33540

View file

@ -29,7 +29,7 @@ main (int argc, char *argv[])
{ {
GstElement *pipeline, *sink; GstElement *pipeline, *sink;
gint width, height; gint width, height;
GstBuffer *buffer; GstSample *sample;
gchar *descr; gchar *descr;
GError *error = NULL; GError *error = NULL;
GdkPixbuf *pixbuf; GdkPixbuf *pixbuf;
@ -103,11 +103,11 @@ main (int argc, char *argv[])
/* get the preroll buffer from appsink, this block untils appsink really /* get the preroll buffer from appsink, this block untils appsink really
* prerolls */ * prerolls */
g_signal_emit_by_name (sink, "pull-preroll", &buffer, NULL); g_signal_emit_by_name (sink, "pull-preroll", &sample, NULL);
/* if we have a buffer now, convert it to a pixbuf. It's possible that we /* if we have a buffer now, convert it to a pixbuf. It's possible that we
* don't have a buffer because we went EOS right away or had an error. */ * don't have a buffer because we went EOS right away or had an error. */
if (buffer) { if (sample) {
GstCaps *caps; GstCaps *caps;
GstStructure *s; GstStructure *s;
@ -115,11 +115,7 @@ main (int argc, char *argv[])
* that it can only be an rgb buffer. The only thing we have not specified * that it can only be an rgb buffer. The only thing we have not specified
* on the caps is the height, which is dependant on the pixel-aspect-ratio * on the caps is the height, which is dependant on the pixel-aspect-ratio
* of the source material */ * of the source material */
#if 0 sample_caps = gst_sample_get_caps (sample);
caps = GST_BUFFER_CAPS (buffer);
#endif
/* FIXME, get buffer caps somehow */
caps = NULL;
if (!caps) { if (!caps) {
g_print ("could not get snapshot format\n"); g_print ("could not get snapshot format\n");
exit (-1); exit (-1);
@ -144,9 +140,6 @@ main (int argc, char *argv[])
/* save the pixbuf */ /* save the pixbuf */
gdk_pixbuf_save (pixbuf, "snapshot.png", "png", &error, NULL); gdk_pixbuf_save (pixbuf, "snapshot.png", "png", &error, NULL);
gst_buffer_unmap (buffer, &map); gst_buffer_unmap (buffer, &map);
/* save the pixbuf */
gdk_pixbuf_save (pixbuf, "snapshot.png", "png", &error, NULL);
} else { } else {
g_print ("could not make snapshot\n"); g_print ("could not make snapshot\n");
} }