appsrc undefined reference to 'gst_app_buffer_new'

Nathan zjustc at gmail.com
Thu Dec 8 12:59:22 PST 2011


Folllowing is my test codes. It runs ok with out gst_app_buffer_new and
gst_app_buffer_push.
Any advice?

Thanks,

Jun

#include <gst/gst.h>
#include <glib.h>
#include <unistd.h>
#include <stdlib.h>
#include <pthread.h>
#include <gst/app/gstappsrc.h>
#include <gst/app/gstappbuffer.h>
#include <gst/base/gstbasesrc.h>

#include <gst/gstbuffer.h>
#include <string.h>
#include <gst/app/gstappsink.h>
#include <stdio.h>


static const guint8 mp3[] = {
0x01, 0x02, 0x03, 0x04, 0x05, 0x06,0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13,
0x14, 0x15, 0x16,
0x01, 0x02, 0x03, 0x04, 0x05, 0x06,0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13,
0x14, 0x15, 0x16,
0x01, 0x02, 0x03, 0x04, 0x05, 0x06,0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13,
0x14, 0x15, 0x16,
0x01, 0x02, 0x03, 0x04, 0x05, 0x06,0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13,
0x14, 0x15, 0x16,
0x01, 0x02, 0x03, 0x04, 0x05, 0x06,0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13,
0x14, 0x15, 0x16,
0x01, 0x02, 0x03, 0x04, 0x05, 0x06,0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13,
0x14, 0x15, 0x16,
0x01, 0x02, 0x03, 0x04, 0x05, 0x06,0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13,
0x14, 0x15, 0x16,
0x01, 0x02, 0x03, 0x04, 0x05, 0x06,0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13,
0x14, 0x15, 0x16,
0x01, 0x02, 0x03, 0x04, 0x05, 0x06,0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13,
0x14, 0x15, 0x16,
0x01, 0x02, 0x03, 0x04, 0x05, 0x06,0x07, 0x08, 0x09, 0x10, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF};


typedef struct _App App;

struct  _App
{
  GstElement *appsrc;
  GstElement *h264parse;
  GstElement *gstperf;
  GstElement *queue1;
  GstElement *rtph264pay;
  GstElement *filesink;
  GstElement *queue;
  GstElement *pipeline;
  GMainLoop *loop;
  guint length;
  guint64 offset;
};


 App s_app;
 guint frame_num=sizeof(mp3);



static void FIFOwrite_data (App* app)
{

 guint8 framesize;
 guint8 *tmpdata=malloc(1);
 *tmpdata=0;
 guint frame_count1=0;

    gst_element_set_state(app->pipeline, GST_STATE_PLAYING); 
     GstFlowReturn ret;
     g_print("into FIFO write \n");


   
 while(1){
   GstBuffer *buffer;
 g_print("===================start================================ \n");
     framesize=1;
     buffer = gst_app_buffer_new (tmpdata, framesize, g_free, tmpdata);

   //  buffer = gst_buffer_new_and_alloc (framesize);

    *tmpdata=mp3[frame_count1];
     memcpy(GST_BUFFER_DATA(buffer),tmpdata,framesize);

    // buffer=malloc(framesize);
    // gst_buffer_set_data(buffer,tmpdata, framesize);
     g_signal_emit_by_name (app->appsrc, "push-buffer", buffer, &ret);
     if(ret != GST_FLOW_OK){
     g_print("error%x \n");
     return;

    }
     g_print("print data info in buffer 0x%x \n",*GST_BUFFER_DATA(buffer));

     g_print("framenum %d \n", frame_count1);
     frame_count1=frame_count1+1;


     g_print("=================end=================================== \n");
     if ( frame_count1 >= frame_num-1) {
      //gst_app_src_end_of_stream(app->appsrc);
       g_signal_emit_by_name (app->appsrc, "end-of-stream", &ret);
       g_print("this is the last frame \n");
        gst_buffer_unref (buffer);
       pthread_exit(NULL);
  	}


}
    	g_print("go out \n");
}

static gboolean
bus_call (GstBus *bus, GstMessage *msg, gpointer data)
{
	GMainLoop *loop = data;
	switch (GST_MESSAGE_TYPE (msg)) {
		case GST_MESSAGE_EOS:
			g_print ("End-of-stream\n");
			g_main_loop_quit (loop);
		break;
		case GST_MESSAGE_ERROR: {
			gchar *debug = NULL;
			GError *err = NULL;
			gst_message_parse_error (msg, &err, &debug);
			g_print ("Error: %s\n", err->message);
			g_error_free (err);
				if (debug) {
					g_print ("Debug details: %s\n", debug);
					g_free (debug);
				}
			g_main_loop_quit (loop);
		break;
	}
	default:
	break;
	}
return TRUE;
}

int main(){
    gst_init(NULL,NULL);

    App *app=&s_app;
    GstBus* bus;

    GstStateChangeReturn ret;

    g_print  (" Gstreamer Init completed \n ");
   
    app->appsrc = gst_element_factory_make("appsrc", "appsrc");
    g_assert(app->appsrc);

   app->filesink  = gst_element_factory_make("filesink", "filesink");
   g_assert(app->filesink);

   app->queue     = gst_element_factory_make("queue", "queue");
   g_assert(app->queue);

   app->pipeline  = gst_pipeline_new("server");

   app->loop     = g_main_loop_new(NULL, FALSE);


      pthread_t write_thread;
   
      g_object_set(G_OBJECT(app->filesink), "location", "appsyn0.data",
NULL);
      g_object_set(G_OBJECT(app->appsrc),"max-bytes",0,NULL);
     //g_object_set(G_OBJECT(app->appsrc),
"is-live",TRUE,"max-bytes",0,NULL); 


      bus = gst_pipeline_get_bus (GST_PIPELINE (app->pipeline));
      gst_bus_add_watch (bus, bus_call, app->loop);
      gst_object_unref(bus);

    
gst_bin_add_many(GST_BIN(app->pipeline),app->appsrc,app->queue,app->filesink,NULL);

      if (!gst_element_link_many (app->appsrc,app->queue,app->filesink,
NULL)) {
	g_print ("Failed to link one or more elements! \n");
	return -1;
	}

      g_print("Gst-Pipeline is Running.........\n");
      pthread_create(&write_thread, NULL,FIFOwrite_data, app);

     //  ret=gst_element_set_state(app->pipeline, GST_STATE_PLAYING);   

	if (ret == GST_STATE_CHANGE_FAILURE) {
		GstMessage *msg;
	g_print ("Failed to start up pipeline! \n");
/* check if there is an error message with details on the bus */
	msg = gst_bus_poll (bus, GST_MESSAGE_ERROR, 0);
	if (msg) {
	GError *err = NULL;
	gst_message_parse_error (msg, &err, NULL);
	g_print ("ERROR: %s\n", err->message);
	g_error_free (err);
	gst_message_unref (msg);
	}
	return -1;
     //pthread_exit (NULL);
     }

        g_main_loop_run(app->loop);
   
    /* Out of the main loop, clean up nicely */
        g_print("Returned, stopping playback\n");
        gst_element_set_state(app->pipeline, GST_STATE_NULL);
   
       g_print("Deleting pipeline\n");
       gst_object_unref(GST_OBJECT(app->pipeline));

      pthread_join(write_thread, NULL);

     return 0;
}


--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/appsrc-undefined-reference-to-gst-app-buffer-new-tp4174142p4174349.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.


More information about the gstreamer-devel mailing list