<div dir="ltr">it's 0.10. apt-get install on Ubuntu 12.04 fwiw<div><br></div><div>I found that I had to set the sink/src caps explicitly. Otherwise, I got pipeline execution errors. I would just bail out after a frame or two. I did try setting the caps on videotestsrc with the hope they would flow through.</div>
<div><br></div><div>Here's the complete set of code</div><div><br></div><div><div>#include <gst/gst.h></div><div>#include <glib.h></div><div>#include <gst/app/gstappsink.h></div><div>#include <gst/app/gstappsrc.h></div>
<div>#include <iostream></div><div>#include <stdio.h></div><div><br></div><div>using namespace std;</div><div><br></div><div>static GMainLoop *loop = NULL;</div><div>static GstElement *pipelineIn = NULL;</div>
<div>static GstElement *pipelineOut = NULL;</div><div><br></div><div>static const char app_src_name[] = "app-src_01";</div><div>static const char app_sink_name[] = "app-sink_01";</div><div><br></div><div>
static GstFlowReturn</div><div>new_buffer (GstAppSink *app_sink,</div><div> gpointer user_data)</div><div>{</div><div> GstBuffer *buffer = gst_app_sink_pull_buffer( </div><div> (GstAppSink*) gst_bin_get_by_name( GST_BIN(pipelineIn), </div>
<div> app_sink_name));</div><div><br></div><div> //debugging</div><div> if (!gst_bin_get_by_name( GST_BIN(pipelineIn), app_sink_name))</div><div> {</div><div> g_print("app-sink bailed!\n");</div><div>
}</div><div> if (!gst_bin_get_by_name( GST_BIN(pipelineOut), app_src_name))</div><div> {</div><div> g_print("app-src bailed!\n");</div><div> }</div><div><br></div><div> //pushes the buffer to AppSrc, it takes the ownership of the buffer. you do not need to unref</div>
<div> gst_app_src_push_buffer( GST_APP_SRC( gst_bin_get_by_name(GST_BIN(pipelineOut),app_src_name)) , buffer);</div><div> </div><div> return GST_FLOW_OK;</div><div>}</div><div><br></div><div>static gboolean</div><div>bus_call (GstBus *bus,</div>
<div> GstMessage *msg,</div><div> gpointer data)</div><div>{</div><div> gchar *userdata = (gchar *) data;</div><div><br></div><div> switch (GST_MESSAGE_TYPE (msg)) </div><div> {</div><div><br></div>
<div> case GST_MESSAGE_EOS:</div><div> {</div><div> //sender check - input pipeline send EOS to output pipeline</div><div> if ( g_ascii_strcasecmp(userdata, gst_element_get_name(pipelineIn)) == 0)</div><div>
{</div><div> g_print("EOS detected (%s)\n",userdata);</div><div> gst_app_src_end_of_stream( GST_APP_SRC( gst_bin_get_by_name( GST_BIN(pipelineOut), app_src_name ) ) );</div><div> }</div>
<div> //sender check - when pipelineOut sends the EOS msg, quite.</div><div> if ( g_ascii_strcasecmp(userdata, gst_element_get_name(pipelineOut)) == 0)</div><div> {</div><div> g_print("Finished playback (%s)\n",userdata);</div>
<div> g_main_loop_quit(loop);</div><div> </div><div> }</div><div> break;</div><div> }</div><div><br></div><div> case GST_MESSAGE_STATE_CHANGED : </div><div> {</div><div> GstState oldstate;</div>
<div> GstState newstate;</div><div> GstState pending;</div><div><br></div><div> gst_message_parse_state_changed (msg,&oldstate,&newstate,&pending);</div><div> g_debug("pipeline:%s old:%s new:%s pending:%s", userdata,</div>
<div> gst_element_state_get_name(oldstate),</div><div> gst_element_state_get_name(newstate),</div><div> gst_element_state_get_name(pending));</div><div> break;</div><div> }</div>
<div><br></div><div> case GST_MESSAGE_WARNING: </div><div> {</div><div> gchar *debug;</div><div> GError *error;</div><div><br></div><div> gst_message_parse_warning (msg, &error, &debug);</div>
<div> g_warning("pipeline:%s",userdata);</div><div> g_warning("debug: %s", debug);</div><div> g_warning("error: %s", error->message);</div><div> g_free (debug);</div><div>
g_error_free (error);</div><div> break;</div><div> }</div><div><br></div><div> case GST_MESSAGE_ERROR:</div><div> {</div><div> gchar *debug;</div><div> GError *error;</div><div><br></div><div>
gst_message_parse_error (msg, &error, &debug);</div><div> g_free (debug);</div><div> g_printerr ("Error in pipeline: %s\n", error->message);</div><div> g_error_free (error);</div>
<div> g_main_loop_quit (loop);</div><div> break;</div><div> }</div><div><br></div><div> default:</div><div> break;</div><div> }</div><div><br></div><div> return TRUE;</div><div>}</div><div><br></div>
<div>int</div><div>main (int argc,</div><div> char *argv[])</div><div>{</div><div> GError *error = NULL;</div><div> GstBus *bus = NULL;</div><div> GstAppSinkCallbacks callbacks;</div><div><br></div><div> gchar pipelineInStr[256];</div>
<div> gchar pipelineOutStr[256];</div><div> guint bus_watch_id;</div><div><br></div><div> gst_init (&argc, &argv);</div><div><br></div><div> loop = g_main_loop_new (NULL, FALSE);</div><div><br></div><div> // creating pipelines from strings</div>
<div> sprintf(pipelineInStr, "videotestsrc num-buffers=10 pattern=4 ! queue ! appsink name=\"%s\"",app_sink_name);</div><div> sprintf(pipelineOutStr, "appsrc name=\"%s\" ! queue ! ximagesink",app_src_name);</div>
<div><br></div><div> pipelineIn = gst_parse_launch(pipelineInStr, &error);</div><div> if (error)</div><div> {</div><div> g_printerr("Could not create pipelineIn\n");</div><div> return -1;</div><div>
}</div><div> pipelineOut = gst_parse_launch(pipelineOutStr, &error);</div><div> if (error)</div><div> {</div><div> g_printerr("Could not create pipelineOut\n");</div><div> return -1;</div><div> }</div>
<div> if (!gst_bin_get_by_name(GST_BIN(pipelineIn), app_sink_name))</div><div> {</div><div> g_printerr("Error creating app-sink\n");</div><div> return -1;</div><div> }</div><div> if (!gst_bin_get_by_name(GST_BIN(pipelineOut), app_src_name))</div>
<div> {</div><div> g_printerr("Error creating app-src\n");</div><div> return -1;</div><div> }</div><div>GstCaps *caps;</div><div>caps = gst_caps_new_simple ("video/x-raw-rgb",</div><div> "width", G_TYPE_INT, 640,</div>
<div> "height", G_TYPE_INT, 480,</div><div> "framerate", GST_TYPE_FRACTION, 30000, 1001,</div><div> NULL);</div><div> gst_app_sink_set_caps( (GstAppSink*) gst_bin_get_by_name(GST_BIN(pipelineIn),app_sink_name) , caps);</div>
<div> gst_app_src_set_caps( (GstAppSrc*) gst_bin_get_by_name(GST_BIN(pipelineOut),app_src_name) , caps);</div><div><br></div><div> bus = gst_pipeline_get_bus (GST_PIPELINE (pipelineIn));</div><div> bus_watch_id = gst_bus_add_watch (bus, bus_call, gst_element_get_name(pipelineIn));</div>
<div> gst_object_unref (bus);</div><div> bus = gst_pipeline_get_bus (GST_PIPELINE (pipelineOut));</div><div> bus_watch_id = gst_bus_add_watch (bus, bus_call, gst_element_get_name(pipelineOut));</div><div> gst_object_unref (bus);</div>
<div><br></div><div> // app sink callback </div><div> callbacks.eos = NULL;</div><div> callbacks.new_preroll = NULL;</div><div> callbacks.new_buffer = new_buffer;</div><div> gst_app_sink_set_callbacks( (GstAppSink*) gst_bin_get_by_name(GST_BIN(pipelineIn), </div>
<div> app_sink_name), </div><div> &callbacks, </div><div> NULL, </div><div> NULL);</div><div><br></div>
<div> g_print ("Now playing: %s\n", argv[1]);</div><div> gst_element_set_state (pipelineIn, GST_STATE_PLAYING);</div><div> gst_element_set_state (pipelineOut, GST_STATE_PLAYING);</div><div><br></div><div> g_print ("Running...\n");</div>
<div> g_main_loop_run (loop);</div><div><br></div><div> g_print ("Returned, stopping playback\n");</div><div> gst_element_set_state (pipelineIn, GST_STATE_NULL);</div><div> gst_element_set_state (pipelineOut, GST_STATE_NULL);</div>
<div><br></div><div> g_print ("Deleting pipeline\n");</div><div> gst_object_unref (GST_OBJECT (pipelineIn));</div><div> gst_object_unref (GST_OBJECT (pipelineOut));</div><div> g_source_remove (bus_watch_id);</div>
<div> g_main_loop_unref (loop);</div><div><br></div><div> return 0;</div><div>}</div></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, May 25, 2013 at 4:00 PM, Tim-Philipp Müller <span dir="ltr"><<a href="mailto:t.i.m@zen.co.uk" target="_blank">t.i.m@zen.co.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Sat, 2013-05-25 at 15:49 -0700, Richard Cagley wrote:<br>
<br>
Hi,<br>
<div class="im"><br>
> I'm using videotestsrc and ximagesink and changing the patterns on<br>
> videotestsrc and looking at the output. I also have some print<br>
> statements to read the raw data pointers.<br>
><br>
><br>
> What would cause this? I'm setting the caps like this...<br>
><br>
><br>
> caps = gst_caps_new_simple ("video/x-raw-rgb",<br>
> "format", G_TYPE_STRING, "RGB",<br>
<br>
</div>Are you using 1.0 or 0.10 ? Those caps look like a mix of both.<br>
<br>
<br>
In 0.10 it's<br>
video/x-raw-rgb,endianness=...,{red,blue,green,alpha}_mask=..<br>
<br>
In 1.0 it's video/x-raw,format=(string)xyz<br>
<br>
Why are you creating the caps yourself anyway? Why not just forward/set<br>
the caps you get on the appsink?<br>
<br>
Cheers<br>
-Tim<br>
<br>
<br>
_______________________________________________<br>
gstreamer-devel mailing list<br>
<a href="mailto:gstreamer-devel@lists.freedesktop.org">gstreamer-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a><br>
</blockquote></div><br></div>