AW: AW: Seems like set callbacks unsuccessful
Erickson.LU
ericksonlushan at gmail.com
Sat Apr 21 16:33:08 UTC 2018
Appreciate your reply and thanks a lot.
I haven't test your code...But I still think the problem is procedure of
constructing the pipeline.
Cause when i use
* gst_app_sink_set_drop(GST_APP_SINK(appsink), true);
gst_app_sink_set_max_buffers(GST_APP_SINK(appsink), 1);
gst_app_sink_set_callbacks(GST_APP_SINK(appsink), &appsinkCallbacks,
NULL, NULL);*
to set the callbacks.
The log will report critical error:
*** (test_now:21439): CRITICAL **: gst_app_sink_set_drop: assertion
'GST_IS_APP_SINK (appsink)' failed
** (test_now:21439): CRITICAL **: gst_app_sink_set_max_buffers: assertion
'GST_IS_APP_SINK (appsink)' failed
** (test_now:21439): CRITICAL **: gst_app_sink_set_callbacks: assertion
'GST_IS_APP_SINK (appsink)' failed
*
I think it cause i get a wrong appsink when i use "appsink =
gst_bin_get_by_name(GST_BIN(pipeline), appsink_name.c_str());" or the
pipeline is not ok, before i call set appcallbacks.
The procedure is below :
* gst_init(&argc, &argv);
// XInitThreads();
boost::thread g_main_loop_thread0;
GstAppSinkCallbacks appsinkCallbacks;
std::string pipelineString = SINK0;
std::string appsink_name="APP_SINK0";
GError* err = 0;
// pipeline = gst_parse_launch(pipelineString.c_str(), &err);
pipeline =gst_pipeline_new(NULL);
GstElement *filter1 = gst_element_factory_make ("capsfilter", NULL);
g_assert (filter1 != NULL); /* should always exist */
GstElement *filter2 = gst_element_factory_make ("capsfilter", NULL);
g_assert (filter2 != NULL); /* should always exist */
GstElement *filter3 = gst_element_factory_make ("capsfilter", NULL);
g_assert (filter3 != NULL); /* should always exist */
GstElement *v4l2src,*nvvidconv_1,*nvvidconv_2;
v4l2src = gst_element_factory_make("v4l2src", NULL);
g_object_set (G_OBJECT (v4l2src), "device", "/dev/video0", NULL);
nvvidconv_1 = gst_element_factory_make("videoconvert", NULL);
nvvidconv_2 = gst_element_factory_make("videoconvert", NULL);
appsink = gst_element_factory_make("appsink", "APP_SINK0");
g_object_set (G_OBJECT (appsink), "name","APP_SINK","caps",
gst_caps_new_simple("video/x-raw","format",G_TYPE_STRING,"BGR","width",G_TYPE_INT,"640","height",G_TYPE_INT,"480","pixel-aspect-ratio",GST_TYPE_FRACTION,1,1,NULL),
NULL);
GstCaps *number1 =
gst_caps_new_simple("video/x-raw","format",G_TYPE_STRING,"YV12","width",G_TYPE_INT,"640","height",G_TYPE_INT,"480",NULL);
GstCaps *number2 =
gst_caps_new_simple("video/x-raw","format",G_TYPE_STRING,"I420","width",G_TYPE_INT,"640","height",G_TYPE_INT,"480",NULL);
GstCaps *number3 =
gst_caps_new_simple("video/x-raw","format",G_TYPE_STRING,"BGR","width",G_TYPE_INT,"640","height",G_TYPE_INT,"480",NULL);
g_object_set (G_OBJECT (filter1), "caps", number1, NULL);
g_object_set (G_OBJECT (filter2), "caps", number2, NULL);
g_object_set (G_OBJECT (filter3), "caps", number3, NULL);
gst_bin_add_many(GST_BIN(pipeline), v4l2src,
filter1,nvvidconv_1,filter2,
nvvidconv_2,filter3,appsink, NULL);
gst_element_link_many (v4l2src, filter1,nvvidconv_1,filter2,
nvvidconv_2,filter3,appsink, NULL);gst_caps_unref
(number1);
bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));
gst_bus_add_watch(bus, (GstBusFunc)GstMessageParser, NULL);
// g_main_loop_thread_ = boost::thread(RunMainLoop);
// RunMainLoop();
appsink = gst_bin_get_by_name(GST_BIN(pipeline), appsink_name.c_str());
g_print("main thread lwpid = %u\n", syscall(SYS_gettid));
g_print("main thread tid = %u\n", pthread_self());
appsinkCallbacks.new_preroll = &PrerollCallback;
appsinkCallbacks.new_sample = &SampleCallback;
// appsinkCallbacks.eos = &EndOfStreamCallback;
gst_app_sink_set_drop(GST_APP_SINK(appsink), true);
gst_app_sink_set_max_buffers(GST_APP_SINK(appsink), 1);
gst_app_sink_set_callbacks(GST_APP_SINK(appsink), &appsinkCallbacks,
NULL, NULL);
GstStateChangeReturn ret = gst_element_set_state(pipeline,
GST_STATE_PLAYING);
if (ret == GST_STATE_CHANGE_FAILURE) {
g_printerr("Unable to set the pipeline to the playing state");
gst_object_unref(pipeline);
return false;
}
gst_caps_unref (number1);
gst_caps_unref (number2);
gst_caps_unref (number3);
*
Regards
--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
More information about the gstreamer-devel
mailing list