seek failed with appsrc

leon dudi.reuveni at
Tue Apr 8 00:37:18 PDT 2014


Im using appsrc in my code (visual studio) and I have two pipelines-
transmitter and receiver. 
the transmitter loads file with RTP stream push the RTP packet into udpsink
and udpsink transmit is.
the transmission works great.

*pipeline 1 (transmitter)*:

   app->src = (GstAppSrc*)gst_element_factory_make("appsrc", "mysrc"); 
   app->sink = gst_element_factory_make ("udpsink", "sink"); 

   gst_bin_add_many(GST_BIN(app->pipeline1), (GstElement*)app->src,
app->sink, NULL); 
    if(!gst_element_link((GstElement*)app->src, app->sink)){ 
    g_warning("failed to link src and sink"); 

*callbacks to appsrc*:

  g_signal_connect(app->src, "need-data", G_CALLBACK(start_feed), app); 

*Start playing*:  

 gst_element_set_state((GstElement*)app->pipeline1, GST_STATE_PLAYING); 

*the goal is implementing fast forward and rewind by seek.*

 if (!gst_element_seek ((GstElement*)app->pipeline1, app->rate,
                         GST_SEEK_TYPE_SET, app->osition,
                         GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE)) {
    g_print ("Seek failed!\n");

*so I though to implement it inside "need-data" callback:*

static gboolean read_data(gst_app_t *app)
 GstBuffer *buffer;
 void *ptr;
 int size;
 GstFlowReturn ret;

 struct pcap_pkthdr *header;
 const u_char *data;
 u_char *RTP_ptr;


 int returnValue = pcap_next_ex(app->pcap, &header, &data); //read the next
packet from pcap file
 RTP_ptr= (u_char *)data + 42; //go to the start of RTP packet
 size = (header->caplen)-42; 

if (!gst_element_query_position ( (GstElement *)app->pipeline1, app->format
, &(app->position) ) ){
    g_printerr ("Unable to retrieve current position.\n");
else g_print ("position: %d \n", app->position);

 *if (!gst_element_seek ((GstElement*)app->pipeline1, 2.0, GST_FORMAT_BYTES,
                         GST_SEEK_TYPE_SET, app->position,
                         GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE)) {
    g_print ("Seek failed!\n");

 if (returnValue >= 0)

		RTP_ptr= (u_char *)data + 42;
		size = (header->caplen)-42;   

	    if(size == 0){
			   ret = gst_app_src_end_of_stream(app->src);
			   g_debug("eos returned %d at %d\n", ret, __LINE__);
			   return FALSE;

		buffer =gst_buffer_new_wrapped (g_memdup (RTP_ptr, size), size);

	    ret = gst_app_src_push_buffer(app->src, buffer);
        if(ret !=  GST_FLOW_OK){
               g_debug("push buffer returned %d for %d bytes \n", ret,
			   return FALSE;
 else if (returnValue == -2){

		printf("\n\n\ngot EOS\n\n\n");
		gst_element_set_state (app->pipeline2, GST_STATE_NULL);
		gst_object_unref (app->pipeline2);
		g_main_loop_quit (app->loop);
		return FALSE;

 else if (returnValue == -1){
		printf("\nreturn value of \"next packet\" is not o.k\n");

 else printf("Unknown error from reading next packet");

 return TRUE;

*now I have two questions-*

1. I know there is callback named "seek-data". what is the difference
between implementing it inside "need-data" and "seek-data". from my
understanding (correct me if I wrong) "need-data" is called every time the
buffer can get more data. so if I call "seek-data"  and the buffer is empty
and calling "need-data", what will happen? are they working in parallel?

2. in my code- the section of the seek command, I get "seek failed" and I
cant figure why.. the seek is in BYTES format and the input to the buffer of
appsrc, is file- with RTP packets. 

I will be happy for some help here.



View this message in context:
Sent from the GStreamer-devel mailing list archive at

More information about the gstreamer-devel mailing list