Compilation error - undefined reference to `gst_app_sink_pull_sample'

Akmal akmalhisyam36 at gmail.com
Wed Jul 18 13:54:00 UTC 2018


Hi Pchaurasia,

I hope you have spotted the bug because I really need your help :)

I'm on a project (using GStreamer and Ffmpeg API) since last week but I
haven't yet managed to pull out a frame from the data of a variable of a
type GstMapInfo. Until I found this post, then I tried exactly the same
steps as you do to get the raw frame but still without success. 

Each time I launch my program in the terminal, it will stop at 

*/Available Sensor modes : 
4104 x 3046 FR=30.000000 CF=0x1009208a10 SensorModeType=4
CSIPixelBitDepth=12 DynPixelBitDepth=12

NvCameraSrc: Trying To Set Default Camera Resolution. Selected
sensorModeIndex = 0 WxH = 4104x3046 FrameRate = 30.000000 .../*

Even though it supposed to display some words from "cout" for debugging, but
then nothing happens.

So my code is as below :

      *  typedef struct _CustomData {
		GstState m_state;
		GstElement *m_pipeline = NULL;
		gboolean playing;
		GMainLoop *loop;
		GstElement *source;
		GstBus *bus;
		GIOChannel *io_stdin;
		GstElement *sink;
	} CustomData;

	CustomData gstData;

	
	GstElement *testsink;
	GstBuffer *buffer;
	gint size = 1920 * 1080 * 32;

Camera::Camera()
{
        gst_init(NULL, NULL);
	gstData.m_state = GST_STATE_NULL;
	cout << "Camera constructeur 2" << endl;
	gstData.m_pipeline = gst_parse_launch("nvcamerasrc !
video/x-raw(memory:NVMM),width=(int)1920,height=(int)1080,format=(string)I420,framerate=(fraction)30/1
! nvvidconv flip-method=2 ! video/x-raw,format=(string)BGRx ! appsink
name=sink", NULL);
	if (gstData.m_pipeline == NULL){ 
		cout << "Pipeline failed" << endl;
	} 
	else{
		cout << "Pipeline initialized" << endl;
	}
	g_assert (gstData.m_pipeline);

	gstData.bus = gst_pipeline_get_bus (GST_PIPELINE (gstData.m_pipeline));
	g_assert(gstData.bus);

}

void Camera::acquisitionEventLoop()
{
	int id;
	
	struct sched_param param;
	param.sched_priority = 1;
	pthread_setschedparam(pthread_self(), SCHED_FIFO, &param);

	numImage = 0;
	int error = 0;
	char* pim= NULL;
	NppStatus Nppres;
	CUresult cures;
	GstBuffer* buffer;
	while(checkAcquisitionLoopCondition())
	{		
		// attend une nouvelle image
		/* we use appsink in push mode, it sends us a signal when gstData is
available
		* and we pull out the gstData in the signal callback. We want the appsink
to
		* push as fast as it can, hence the sync=false */
		
		numImage++;

		//g_signal_connect (testsink, "new-sample", G_CALLBACK (retrieve_buffer),
gstData);
		GstSample *sample;
		GstMapInfo map; 
		GstAppSink *appsink = GST_APP_SINK(testsink); 
		/* get the sample from appsink */
		sample = gst_app_sink_pull_sample(appsink);
		gst_object_unref (testsink);
		gst_object_unref (appsink);
		if(sample){
			GstBuffer *app_buffer;
			app_buffer = gst_sample_get_buffer(sample);
			
			//setBuffer(app_buffer);
			
			gst_buffer_map(app_buffer, &map, GST_MAP_READ);
			gst_util_dump_mem((const guchar*)map.data, map.size);
			memcpy(pim, (int8_t*)map.data, map.size);
			//writePim(p);
			 
			gst_buffer_unmap(app_buffer, &map); 
			
			/* we don't need the appsink sample anymore */
			gst_sample_unref(sample);
		}
		if (onFrame)
		{
			// send frame to GPU
			cures = cuMemcpyHtoD(pdgrabRaw, pim, getLength());
			
			// process reccord image
			Nppres = nppiCFAToRGBA_8u_C1AC4R((Npp8u*)pdgrabRaw, pitch, acq_size,
acq_rect, (Npp8u*)pdgrab32bpp, getPitch(), NPPI_BAYER_BGGR,
NPPI_INTER_UNDEFINED, 0);
			cures = cuMemcpyDtoH(grabBuffer, pdgrab32bpp, 4 * getLength());
			onFrame(grabBuffer, getNowTimestamp(), cbCaller);

			//// process preview image
			//Nppres = nppiCFAToRGB_8u_C1C3R((Npp8u*)pdgrabRaw, pitch, acq_size,
acq_rect, (Npp8u*)pdDebayeredLiveBuffer, getLivePitch(), NPPI_BAYER_BGGR,
NPPI_INTER_UNDEFINED);
			//Nppres = nppiResize_8u_C3R((Npp8u*)pdDebayeredLiveBuffer,
getLivePitch(), acq_size, acq_rect, (Npp8u*)pdResizedLiveBuffer,
getResizedLivePitch(), resized_size, resized_rect, NPPI_INTER_CUBIC);
			//if (preview_mutex.try_lock())
			//{
			//	cures = cuMemcpyDtoH(previewImageBuffer, pdResizedLiveBuffer,
getResizedLivePitch() * getResizedLiveHeight());
			//	preview_mutex.unlock();
			//}


			std::unique_lock<std::mutex> lock(mutNewFrame);
			condNewFrame.notify_all();
		}
		break;
		gst_object_unref (testsink);	
		
		
	}
	if (onEndOfMovie)
		onEndOfMovie(numImage, cbCaller);

	condNewFrame.notify_all();

}

void Camera::start()
{	
        sectioncritique_acquisitionEventLoop.lock();	

	if (!gstData.m_pipeline){
		cout << "Pipeline faulty\n" << endl;
	}

	if (gstData.m_state != GST_STATE_NULL){
		cout << "Video encoder already recording\n" << endl;
	}

	// Start the pipeline.
	if (gst_element_set_state(gstData.m_pipeline, GST_STATE_PLAYING) ==
GST_STATE_CHANGE_FAILURE){
		cout << "Failed to start recording.\n" << endl;
	}
	gstData.m_state = GST_STATE_PLAYING;
	gstData.playing = TRUE;

	testsink = gst_bin_get_by_name (GST_BIN (gstData.m_pipeline), "sink");
	g_object_set (G_OBJECT (testsink), "emit-signals", TRUE, "sync", FALSE,
NULL);
	
	/* Create a GLib Main Loop and set it to run */
	gstData.loop = g_main_loop_new (NULL, FALSE);
	g_main_loop_run (gstData.loop);
	cout << "Start recording...\n" << endl;

	// start event loop thread
	acquisitionEventLoopThread = new
std::thread(std::bind(&Camera::acquisitionEventLoop, this));

	// update dynamic gstData

	// free acquisition Loop thread
	acquisitionLoopCondition = true;
	sectioncritique_acquisitionEventLoop.unlock();

}*

I begin always with the 'Camera' constructor, the the start() function in
which calls acquisitionEventLoop.

Does the way I structure it in multiple functions made It difficult to run
more further?

Thanks in advace




--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/


More information about the gstreamer-devel mailing list