Hi,
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.
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?
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 g_signal_emit_by_name (app->appsink, "pull-buffer", gstBuffer, &ret); is unusable.
I also provide the last log result of the GST_DEBUG at the end.
THANKS FOR YOUR HELP!
------------------------------------------------ Code starts here ----------------------------------------------------
//brief To run the encoding int GstEncoder::run() { App *app = &_app; GstBus *bus; gst_init (NULL, NULL); /* create a mainloop to get messages and to handle the idle handler that will * feed data to appsrc. */ app->loop = g_main_loop_new (NULL, TRUE); // Building a gst pipeline that take advantage out of vdpau GstElement *pipeline, *appsrc, *encoder, *appsink; pipeline = gst_pipeline_new ("pipeline"); appsrc = gst_element_factory_make ("appsrc", "app-src"); encoder = gst_element_factory_make ("x264enc","h264-enc"); // ffenc_mpeg2video appsink = gst_element_factory_make ("appsink", "app-sink"); if(!pipeline || !appsrc || !encoder || !appsink ) { printf("Error while building elements... \n"); return 0; } // Caps for raw data GstCaps *capsRaw; capsRaw = gst_caps_new_simple ("video/x-raw-yuv", "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I', '4', '2', '0'), "width", G_TYPE_INT, 1280, "height", G_TYPE_INT, 720, "framerate", GST_TYPE_FRACTION, 25, 1, NULL); /* buil and link the pipeline */ gst_bin_add_many (GST_BIN (pipeline), appsrc, encoder, appsink, NULL); gst_element_link_filtered (appsrc, encoder, capsRaw); gst_element_link (encoder, appsink); /* define elements required in app stuct */ app->playbin = pipeline; g_assert(app->playbin); app->appsrc = appsrc; g_assert(app->appsrc); app->appsink = appsink; g_assert(app->appsink); g_object_set (G_OBJECT(app->appsink), "emit-signals", true, "sync", false, NULL); /* connect the appsrc to the signals "need data" and "enough data" */ g_signal_connect (app->appsrc, "need-data", G_CALLBACK (VDPAUDecoder::start_feed), app); g_signal_connect (app->appsrc, "enough-data", G_CALLBACK (VDPAUDecoder::stop_feed), app); g_signal_connect (app->appsink, "new-buffer", G_CALLBACK (pull_buffer), app); /* message handler gestion*/ bus = gst_pipeline_get_bus (GST_PIPELINE (app->playbin)); gst_bus_add_watch (bus, (GstBusFunc) VDPAUDecoder::bus_message, app); gst_object_unref(bus); /* go to playing and wait in a mainloop. */ g_print ("Playing... \n"); gst_element_set_state (app->playbin, GST_STATE_PLAYING); /* this mainloop is stopped when we receive an error or EOS */ g_main_loop_run (app->loop); GST_DEBUG ("stopping"); gst_element_set_state (app->playbin, GST_STATE_NULL); gst_object_unref (bus); g_main_loop_unref (app->loop); return 0; } /** * \brief To pull the encoded buffer from the appsink when "new-buffer" message is emited */ gboolean GstEncoder::pull_buffer (App * app) { printf("new-buffer signal emitted!"); GstBuffer * gstBuffer; GstFlowReturn ret; Fifo * fifoOut = app->fifoOut; g_signal_emit_by_name (app->appsink, "pull-buffer", gstBuffer, &ret); if(ret == GST_FLOW_OK ) { VBuffer * vBuffer = new VBuffer((char *)GST_BUFFER_DATA(gstBuffer), GST_BUFFER_SIZE(gstBuffer)); vBuffer->setWidth(1280); vBuffer->setHeight(720); //vBuffer->setPixelFormat(720); vBuffer->setVideoCodec(CODEC_ID_H264); vBuffer->setDecimation(1); vBuffer->setBasicFramerate(25); vBuffer->setDecimation(1); fifoOut->push(vBuffer); printf(" OK\n"); } else { printf("...failed! \n"); return false; } return true; }
----------------------------------------- Log errors starts here ---------------------------------------------------- 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 0:00:02.542285393 8708 0x27e7990 INFO GST_STATES gstbin.c:2939:bin_handle_async_done:<pipeline> continue state change, pending PLAYING 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 0:00:02.542629619 8708 0x7f71dc3d5cb0 INFO GST_EVENT gstevent.c:1135:gst_event_new_latency: creating latency event 0:00:00.000000000 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 0:00:02.542712971 8708 0x7f71dc3d5cb0 INFO GST_STATES gstelement.c:2408:gst_element_continue_state:<app-sink> completed state change to PLAYING 0:00:02.542733986 8708 0x7f71dc3d5cb0 INFO GST_STATES gstelement.c:2421:gst_element_continue_state:<app-sink> posting state-changed PAUSED to PLAYING 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 0:00:02.542763205 8708 0x7f71dc3d5cb0 INFO GST_STATES gstelement.c:2408:gst_element_continue_state:<h264-enc> completed state change to PLAYING 0:00:02.542771494 8708 0x7f71dc3d5cb0 INFO GST_STATES gstelement.c:2421:gst_element_continue_state:<h264-enc> posting state-changed PAUSED to PLAYING 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 (<unknown>:8708): GLib-GObject-WARNING **: invalid (NULL) pointer instance 0:00:02.542793490 8708 0x7f71dc3d5cb0 INFO GST_STATES gstelement.c:2408:gst_element_continue_state:<capsfilter0> completed state change to PLAYING (<unknown>:8708): GLib-GObject-CRITICAL **: g_signal_emit_by_name: assertion `G_TYPE_CHECK_INSTANCE (instance)' failed 0:00:02.542803216 8708 0x7f71dc3d5cb0 INFO GST_STATES gstelement.c:2421:gst_element_continue_state:<capsfilter0> posting state-changed PAUSED to PLAYING new-buffer signal emitted! OK 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 0:00:02.542833817 8708 0x7f71dc3d5cb0 INFO GST_STATES gstelement.c:2408:gst_element_continue_state:<app-src> completed state change to PLAYING 0:00:02.542850587 8708 0x7f71dc3d5cb0 INFO GST_STATES gstelement.c:2421:gst_element_continue_state:<app-src> posting state-changed PAUSED to PLAYING 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 Start feed... 0:00:02.542873530 8708 0x7f71dc3d5cb0 INFO GST_STATES gstelement.c:2408:gst_element_continue_state:<pipeline> completed state change to PLAYING 0:00:02.542887630 8708 0x7f71dc3d5cb0 INFO GST_STATES gstelement.c:2421:gst_element_continue_state:<pipeline> posting state-changed PAUSED to PLAYING Read data... FifoIn is empty... Push in fifoIn... fifoOut is empty... skipping output treatment! Read data... fifoIn is read... Read data... FifoIn is empty... (<unknown>:8708): GLib-GObject-WARNING **: invalid (NULL) pointer instance (<unknown>:8708): GLib-GObject-CRITICAL **: g_signal_emit_by_name: assertion `G_TYPE_CHECK_INSTANCE (instance)' failed Erreur de segmentation _______________________________________________ gstreamer-devel mailing list [hidden email] http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Free forum by Nabble | Edit this page |