<div>Hi,</div>
<div> </div>
<div>I have built an app that is simply an encoder : I feed the appsrc of the pipeline with my own buffer and get at the end the buffer encoded with h264 codec.</div>
<div> </div>
<div>It seem to work fine until I get back the buffer encoded : it seems that appsink return a GstBuffer with no data.... I get a segfault! :/ How is it possible?</div>
<div> </div>
<div>Here is part of the code : the run() and the pull_buffer() function.... pull_buffer() is called when the appsink emit the "new-buffer" signal which is done... but the return of <strong>g_signal_emit_by_name (app->appsink, "pull-buffer", gstBuffer, &ret); is unusable.</strong></div>
<div><strong></strong> </div>
<div>I also provide the last log result of the GST_DEBUG at the end.</div>
<div> </div>
<div>THANKS FOR YOUR HELP!</div>
<div> </div>
<div><font size="4">------------------------------------------------ Code starts here ----------------------------------------------------</font><span lang="FR"><span lang="FR"></span></span></div>
<div>
<p>//brief To run the encoding</p>
<p>int GstEncoder::run()</p>
<p>{</p>
<p>App *app = &_app;</p>
<p>GstBus *bus;</p>
<p>gst_init (NULL, NULL);</p>
<p>/* create a mainloop to get messages and to handle the idle handler that will</p>
<p>* feed data to appsrc.</p>
<p>*/</p>
<p>app->loop = g_main_loop_new (NULL, TRUE);</p>
<p>// Building a gst pipeline that take advantage out of vdpau</p>
<p>GstElement *pipeline, *appsrc, *encoder, *appsink;</p>
<p>pipeline = gst_pipeline_new ("pipeline");</p>
<p>appsrc = gst_element_factory_make ("appsrc", "app-src");</p>
<p>encoder = gst_element_factory_make ("x264enc","h264-enc"); // ffenc_mpeg2video</p>
<p>appsink = gst_element_factory_make ("appsink", "app-sink");</p>
<p>if(!pipeline || !appsrc || !encoder || !appsink )</p>
<p>{</p>
<p>printf("Error while building elements... \n");</p>
<p>return 0;</p>
<p>}</p>
<p>// Caps for raw data</p>
<p>GstCaps *capsRaw;</p>
<p>capsRaw = gst_caps_new_simple ("video/x-raw-yuv", "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I', '4', '2', '0'),</p>
<p>"width", G_TYPE_INT, 1280, "height", G_TYPE_INT, 720, "framerate", GST_TYPE_FRACTION, 25, 1, NULL);</p>
<p>/* buil and link the pipeline */</p>
<p>gst_bin_add_many (GST_BIN (pipeline),</p>
<p>appsrc, encoder, appsink, NULL);</p>
<p>gst_element_link_filtered (appsrc, encoder, capsRaw);</p>
<p>gst_element_link (encoder, appsink);</p>
<p>/* define elements required in app stuct */</p>
<p>app->playbin = pipeline;</p>
<p>g_assert(app->playbin);</p>
<p>app->appsrc = appsrc;</p>
<p>g_assert(app->appsrc);</p>
<p>app->appsink = appsink;</p>
<p>g_assert(app->appsink);</p>
<p>g_object_set (G_OBJECT(app->appsink), "emit-signals", true, "sync", false, NULL);</p>
<p>/* connect the appsrc to the signals "need data" and "enough data" */</p>
<p>g_signal_connect (app->appsrc, "need-data", G_CALLBACK (VDPAUDecoder::start_feed), app);</p>
<p>g_signal_connect (app->appsrc, "enough-data", G_CALLBACK (VDPAUDecoder::stop_feed), app);</p>
<p>g_signal_connect (app->appsink, "new-buffer", G_CALLBACK (pull_buffer), app);</p>
<p>/* message handler gestion*/</p>
<p>bus = gst_pipeline_get_bus (GST_PIPELINE (app->playbin));</p>
<p>gst_bus_add_watch (bus, (GstBusFunc) VDPAUDecoder::bus_message, app);</p>
<p>gst_object_unref(bus);</p>
<p>/* go to playing and wait in a mainloop. */</p>
<p>g_print ("Playing... \n");</p>
<p>gst_element_set_state (app->playbin, GST_STATE_PLAYING);</p>
<p>/* this mainloop is stopped when we receive an error or EOS */</p>
<p>g_main_loop_run (app->loop);</p>
<p>GST_DEBUG ("stopping");</p>
<p>gst_element_set_state (app->playbin, GST_STATE_NULL);</p>
<p>gst_object_unref (bus);</p>
<p>g_main_loop_unref (app->loop);</p>
<p>return 0;</p>
<p>}</p>
<p>/**</p>
<p>* \brief To pull the encoded buffer from the appsink when "new-buffer" message is emited</p>
<p>*/</p>
<p>gboolean GstEncoder::pull_buffer (App * app)</p>
<p>{</p>
<p>printf("new-buffer signal emitted!");</p>
<p>GstBuffer * gstBuffer;</p>
<p>GstFlowReturn ret;</p>
<p>Fifo * fifoOut = app->fifoOut;</p>
<p>g_signal_emit_by_name (app->appsink, "pull-buffer", gstBuffer, &ret);</p>
<p>if(ret == GST_FLOW_OK )</p>
<p>{</p>
<p>VBuffer * vBuffer = new VBuffer((char *)GST_BUFFER_DATA(gstBuffer), GST_BUFFER_SIZE(gstBuffer));</p>
<p>vBuffer->setWidth(1280);</p>
<p>vBuffer->setHeight(720);</p>
<p>//vBuffer->setPixelFormat(720);</p>
<p>vBuffer->setVideoCodec(CODEC_ID_H264);</p>
<p>vBuffer->setDecimation(1);</p>
<p>vBuffer->setBasicFramerate(25);</p>
<p>vBuffer->setDecimation(1);</p>
<p>fifoOut->push(vBuffer);</p>
<p>printf(" OK\n");</p>
<p>}</p>
<p>else</p>
<p>{</p>
<p> printf("...failed! \n");</p>
<p> return false;</p>
<p>}</p>
<p> return true;</p>
<p>}</p>
<p> </p>
<p><font size="4">----------------------------------------- Log errors starts here ----------------------------------------------------</font></p><span lang="FR">
<p>0:00:02.542250985 8708 0x27e7990 INFO GST_STATES gstbin.c:2910:bin_handle_async_done:<pipeline> committing state from READY to PAUSED, old pending PLAYING</p>
<p>0:00:02.542285393 8708 0x27e7990 INFO GST_STATES gstbin.c:2939:bin_handle_async_done:<pipeline> continue state change, pending PLAYING</p>
<p>0:00:02.542355532 8708 0x7f71dc3d5cb0 INFO GST_STATES gstbin.c:2732:gst_bin_continue_func:<pipeline> continue state change PAUSED to PLAYING, final PLAYING</p>
<p>0:00:02.542629619 8708 0x7f71dc3d5cb0 INFO GST_EVENT gstevent.c:1135:gst_event_new_latency: creating latency event 0:00:00.000000000</p>
<p>0:00:02.542667143 8708 0x7f71dc3d5cb0 WARN bin gstbin.c:2380:gst_bin_do_latency_func:<pipeline> did not really configure latency of 0:00:00.000000000</p>
<p>0:00:02.542712971 8708 0x7f71dc3d5cb0 INFO GST_STATES gstelement.c:2408:gst_element_continue_state:<app-sink> completed state change to PLAYING</p>
<p>0:00:02.542733986 8708 0x7f71dc3d5cb0 INFO GST_STATES gstelement.c:2421:gst_element_continue_state:<app-sink> posting state-changed PAUSED to PLAYING</p>
<p>0:00:02.542751235 8708 0x7f71dc3d5cb0 INFO GST_STATES gstbin.c:2497:gst_bin_change_state_func:<pipeline> child 'app-sink' changed state to 4(PLAYING) successfully</p>
<p>0:00:02.542763205 8708 0x7f71dc3d5cb0 INFO GST_STATES gstelement.c:2408:gst_element_continue_state:<h264-enc> completed state change to PLAYING</p>
<p>0:00:02.542771494 8708 0x7f71dc3d5cb0 INFO GST_STATES gstelement.c:2421:gst_element_continue_state:<h264-enc> posting state-changed PAUSED to PLAYING</p>
<p>0:00:02.542782454 8708 0x7f71dc3d5cb0 INFO GST_STATES gstbin.c:2497:gst_bin_change_state_func:<pipeline> child 'h264-enc' changed state to 4(PLAYING) successfully</p>
<p>(<unknown>:8708): GLib-GObject-WARNING **: invalid (NULL) pointer instance</p>
<p>0:00:02.542793490 8708 0x7f71dc3d5cb0 INFO GST_STATES gstelement.c:2408:gst_element_continue_state:<capsfilter0> completed state change to PLAYING</p>
<p>(<unknown>:8708): GLib-GObject-CRITICAL **: g_signal_emit_by_name: assertion `G_TYPE_CHECK_INSTANCE (instance)' failed</p>
<p>0:00:02.542803216 8708 0x7f71dc3d5cb0 INFO GST_STATES gstelement.c:2421:gst_element_continue_state:<capsfilter0> posting state-changed PAUSED to PLAYING</p>
<p>new-buffer signal emitted! OK</p>
<p>0:00:02.542821007 8708 0x7f71dc3d5cb0 INFO GST_STATES gstbin.c:2497:gst_bin_change_state_func:<pipeline> child 'capsfilter0' changed state to 4(PLAYING) successfully</p>
<p>0:00:02.542833817 8708 0x7f71dc3d5cb0 INFO GST_STATES gstelement.c:2408:gst_element_continue_state:<app-src> completed state change to PLAYING</p>
<p>0:00:02.542850587 8708 0x7f71dc3d5cb0 INFO GST_STATES gstelement.c:2421:gst_element_continue_state:<app-src> posting state-changed PAUSED to PLAYING</p>
<p>0:00:02.542861178 8708 0x7f71dc3d5cb0 INFO GST_STATES gstbin.c:2497:gst_bin_change_state_func:<pipeline> child 'app-src' changed state to 4(PLAYING) successfully</p>
<p>Start feed... </p>
<p>0:00:02.542873530 8708 0x7f71dc3d5cb0 INFO GST_STATES gstelement.c:2408:gst_element_continue_state:<pipeline> completed state change to PLAYING</p>
<p>0:00:02.542887630 8708 0x7f71dc3d5cb0 INFO GST_STATES gstelement.c:2421:gst_element_continue_state:<pipeline> posting state-changed PAUSED to PLAYING</p>
<p>Read data... </p>
<p>FifoIn is empty... </p>
<p>Push in fifoIn... </p>
<p>fifoOut is empty... skipping output treatment!</p>
<p>Read data... </p>
<p>fifoIn is read... </p>
<p>Read data... </p>
<p>FifoIn is empty... </p>
<p>(<unknown>:8708): GLib-GObject-WARNING **: invalid (NULL) pointer instance</p>
<p>(<unknown>:8708): GLib-GObject-CRITICAL **: g_signal_emit_by_name: assertion `G_TYPE_CHECK_INSTANCE (instance)' failed</p>
<p>Erreur de segmentation</p></span></div>