Need a clarification about appsource in pull mode ...

Nostalgia akra.hanine at gmail.com
Mon Mar 12 09:27:46 UTC 2018


Hi,

I made a C++ code to test the functionality of appsource in pull mode, I use
the latter in pull mode to push buffer from an application (here for
simplicity the buffer has an input file as origin, for later this will be
change). 

What I understand from documentation (and from other topics and responses to
my old questions in this site), that in pull mode, appsrc sends a
"need-data" signal to the application every time its queue is empty and then
by attaching a callback to this need-data signal, what we have write in this
callback will be executed each time appsrc sends its signal (note that we
can manage the size of the queue and the buffers so we can manage the time,
the size and the number of buffers we can send to appsrc). Finally, when the
application doesn't have more buffers to push, it sends an "end-of-stream"
signal to  appsrc, so appsrc will not send a "need-data" signal and callback
will not be called again.

Hope that someone can verify that I have really understand the general
concept of appsrc ?

Now my question is about the code I have written, the following is the
callback function attached to appsrc :

/static gboolean cb_need_data (GstElement *appsrc, CustomData * data) {

	GstBuffer *buffer; 
	GstMemory *memory; 
	GstMapInfo map;    
	GstFlowReturn ret1, ret2;
	char *ptr;

	g_print ("\n AT THE BEGINNING OF CB_NEED_DATA !!\n");

	buffer = gst_buffer_new(); 
	memory = gst_allocator_alloc(NULL, buffer_size, NULL); 
	gst_buffer_insert_memory(buffer, -1, memory); 
	gst_buffer_map(buffer, &map, GST_MAP_WRITE); 

	ptr = (char*)malloc (buffer_size); 
	g_assert(ptr != NULL);

	fread(ptr, 1 , buffer_size, file);

	memcpy(map.data, ptr, buffer_size);

	gst_buffer_unmap(buffer, &map); 

	buffer -> pts = timestamp;           
	buffer -> dts = timestamp; 	  
	buffer -> duration = gst_util_uint64_scale_int (1, GST_SECOND, 1); 

	g_signal_emit_by_name (appsrc, "push-buffer", buffer, &ret1); 
	gst_buffer_unref(buffer); 

	timestamp += buffer -> duration; 
	free(ptr);

	if (ret1 != GST_FLOW_OK) {
		printf(" \n Error in pushing data to appsrc\n");
		g_main_loop_quit (data->loop);
	}
	else if (ret1 == GST_FLOW_OK) {
		printf(" \n Pushing frame to appsrc\n");
	}

	g_print ("\n BEFORE EMIITING THE EOS SIGNAL !!  \n");

	g_signal_emit_by_name (appsrc, "end-of-stream", &ret2);

	g_print ("\n AFTER EMIITING THE EOS SIGNAL !!  \n");

	goto end;

	if (ret2 != GST_FLOW_OK) {
		printf(" Error to sending eos signal to appsrc \n");
		g_main_loop_quit (data->loop);
	}
g_print ("\n AT THE end OF CB_NEED_DATA !!\n");

return true;

end :
return false;	
}/

Here for simplicity and for debugging, I push just one buffer to the appsrc
and then then the app sends an "eos signal", so what I expected that the app
will not return to this callback more than the first time but this doesn't
happen. Despite the eos signal, by executing this code, I observe that there
is a return to the callback, and this is the output of the execution :

Inside NvxLiteH264DecoderLowLatencyInitNvxLiteH264DecoderLowLatencyInit set
DPB and MjstreamingInside
NvxLiteH265DecoderLowLatencyInitNvxLiteH265DecoderLowLatencyInit set DPB and
Mjstreaming
 *AT THE BEGINNING OF CB_NEED_DATA !!*
 *
 Pushing frame to appsrc

 BEFORE EMIITING THE EOS SIGNAL !!  

 AFTER EMIITING THE EOS SIGNAL !!  *
NvMMLiteOpen : Block : BlockType = 261 
TVMR: NvMMLiteTVMRDecBlockOpen: 7818: NvMMLiteBlockOpen 
NvMMLiteBlockCreate : Block : BlockType = 261 
TVMR: cbBeginSequence: 1190: BeginSequence  640x368, bVPR = 0
TVMR: LowCorner Frequency = 100000 
TVMR: cbBeginSequence: 1583: DecodeBuffers = 17, pnvsi->eCodec = 4, codec =
0 
TVMR: cbBeginSequence: 1654: Display Resolution : (640x360) 
TVMR: cbBeginSequence: 1655: Display Aspect Ratio : (640x360) 
TVMR: cbBeginSequence: 1697: ColorFormat : 5 
TVMR: cbBeginSequence:1711 ColorSpace = NvColorSpace_YCbCr601
TVMR: cbBeginSequence: 1839: SurfaceLayout = 3
TVMR: cbBeginSequence: 1936: NumOfSurfaces = 21, InteraceStream = 0,
InterlaceEnabled = 0, bSecure = 0, MVC = 0 Semiplanar = 1, bReinit = 1,
BitDepthForSurface = 8 LumaBitDepth = 8, ChromaBitDepth = 8, ChromaFormat =
5
TVMR: cbBeginSequence: 1938: BeginSequence  ColorPrimaries = 2,
TransferCharacteristics = 2, MatrixCoefficients = 2
Allocating new output: 640x368 (x 21), ThumbnailMode = 0
*
 AT THE BEGINNING OF CB_NEED_DATA !!*
 
 Error in pushing data to appsrc
Segmentation fault (core dumped)

so :
1) Can someone tell me why there is a return to cb-need-data() function
although I have send an "eos" signal ? And how we can be sure to not return
to this function ?
2) When we send a large buffer to the appsrc (more than 10 MBytes for
example) and then we send an eos signal , what will happen, the buffer can
be processing along the pipeline or not ? And is the size of buffer affects
the quality of processing ?

Thanks for your helps,
Regards.
 





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


More information about the gstreamer-devel mailing list