h264 streaming - byte buffer a source

Tim-Philipp Müller t.i.m at zen.co.uk
Fri Jul 26 07:23:57 PDT 2013


On Fri, 2013-07-26 at 06:15 -0700, thegoodgiant wrote:

Hi,

> every time there is new data available (in the form of an uint8_t pointer).
> This should be my data source, but I have some issues: my compiles and runs
> with no errors, but I see no video :)

Try with

 appsrc ! h264parse ! fakesink

first, and check if buffers make it to fakesink (either via
GST_DEBUG=*sink:5 or by using the "handoff" signal which should be fired
for each buffer).


> void play_data(void *inBuf ,  size_t len) {
> 
> 	static gboolean white = FALSE;
> 	static GstClockTime timestamp = 0;
> 	GstBuffer *buffer;
> 	guint size;
> 	GstFlowReturn ret_;
> 	size = len;
> 
> 	buffer =  gst_buffer_new();
> 	GST_BUFFER_MALLOCDATA(buffer) = GST_BUFFER_DATA(buffer) = inBuf;
> 	GST_BUFFER_SIZE(buffer) = len;
> 
> 
> 	GstCaps* caps = gst_caps_new_simple ("video/x-h264",
> 		                                         "width", G_TYPE_INT, 800,
> 		                                         "height", G_TYPE_INT, 480,
> 		                                         "framerate", GST_TYPE_FRACTION,
> 25,
> 		   1,
> 		                            NULL);
> 
> 	 gst_buffer_set_caps(buffer, caps);
> 
> 
> 	GST_BUFFER_TIMESTAMP (buffer) = timestamp;
> 
> 	GST_BUFFER_DURATION (buffer) = gst_util_uint64_scale_int (1, GST_SECOND,
> 2);
> 
> 	timestamp += GST_BUFFER_DURATION (buffer);
> 
> 	g_signal_emit_by_name (app->appsrc, "push-buffer", buffer, &ret_);
> 
> 	if (ret_ != GST_FLOW_OK) {
> 
> 	/* something wrong, stop pushing */
> 
> 	g_main_loop_quit (app->loop);
> 
> 	}

This looks a bit dodgy - there doesn't seem to be any memory management
- so either you're leaking data, or you need to actually *copy* the data
before pushing it into the pipeline. It depends on the lifecycle
management of inBuf.

Cheers
 -Tim



More information about the gstreamer-devel mailing list