problem occured in pipeline creation stage of injecting source in to appsrc of playbin

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

problem occured in pipeline creation stage of injecting source in to appsrc of playbin

Sujith reddy
hi All

/This is the code for injecting data in to appsrc .But here i am exiting
from the code due to below error i am attaching the code can
you please suggest where i went wrong/

*(bufffer:14474): GLib-GObject-CRITICAL **: g_object_set: assertion
'G_IS_OBJECT (object)' failed

(bufffer:14474): GLib-GObject-CRITICAL **: g_object_set: assertion
'G_IS_OBJECT (object)' failed

(bufffer:14474): GLib-GObject-WARNING **: invalid (NULL) pointer instance

(bufffer:14474): GLib-GObject-CRITICAL **: g_signal_connect_data: assertion
'G_TYPE_CHECK_INSTANCE (instance)' failed

(bufffer:14474): GLib-GObject-WARNING **: invalid (NULL) pointer instance

(bufffer:14474): GLib-GObject-CRITICAL **: g_signal_connect_data: assertion
'G_TYPE_CHECK_INSTANCE (instance)' failed

command to use
gcc pipeline_buffer.c `pkg-config --cflags --libs glib-2.0 gstreamer-1.0
gstreamer-audio-1.0 gstreamer-app-1.0`

   #include <gst/gst.h>
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    extern char *gst_get_song_buffer(char *uri, int content_id, int
*data_len,int *is_eos);
    extern void gst_song_buffer_read_done(char *uri, int content_id);
    /*GST_DEBUG_CATEGORY (appsrc_playbin_debug);
    #define GST_CAT_DEFAULT appsrc_playbin_debug
     * an example application of using appsrc in streaming push mode. We
simply push
     * buffers into appsrc. The size of the buffers we push can be any size
     * choose.
     * This example is very close to how one would deal with a streaming
     * that does not support range requests or does not report the total
file size.
     * Some optimisations are done so that we don't push too much data. We
     * to the need-data and enough-data signals to start/stop sending
     * Appsrc in streaming mode (the default) does not support seeking so we
     * have to handle any seek callbacks.
     * Some formats are able to estimate the duration of the media file
based on the
     * file length (mp3, mpeg,..), others report an unknown length (ogg,..).
    typedef struct _App App;
    struct _App
      GstElement *playbin;
      GstElement *appsrc;
      GMainLoop *loop;
      guint sourceid;
      GMappedFile *file;
      guint8 *data;
      gsize length;
      guint64 offset;
        char uri[256];
        int content_id;

    App s_app;
    /* This method is called by the idle GSource in the mainloop.we feed the
data and length coming from the
     * and it is feeded in to appsrc .we will get length and pointer to a
buffer from the apis which we have written .
     * (enough-data signal).
    static gboolean
    read_data (App * app)
                GstBuffer *buffer;
                GstFlowReturn ret;
                GstMapInfo map;
                char *ptr;
                int data_len,is_eos;

                printf("read_data data_len=%d,is_eos=%d",data_len,is_eos);

                if(data_len >0)
                        buffer = gst_buffer_new_and_alloc (data_len);
                        gst_buffer_map (buffer, &map, GST_MAP_WRITE);
                        gst_buffer_unmap (buffer, &map);
                        /* Push the buffer into the appsrc */
                        g_signal_emit_by_name (app->appsrc, "push-buffer", buffer, &ret);
                        /* Create a new empty buffer */
                        gst_buffer_unref (buffer);


                if(is_eos == 1)
                   g_signal_emit_by_name (app->appsrc, "end-of-stream", &ret);
                   return FALSE;

                if (ret != GST_FLOW_OK) {
                /* We got some error, stop sending data */
                gst_app_src_end_of_stream (app->appsrc);
                 return FALSE;
                return TRUE;
   /* This signal callback is called when appsrc needs data, we add an idle
    * to the mainloop to start pushing data into the appsrc */
   static void
   start_feed (GstElement * playbin, guint size, App * app)
     if (app->sourceid == 0) {
       GST_DEBUG ("start feeding");
       app->sourceid = g_idle_add ((GSourceFunc) read_data, app);
   /* This callback is called when appsrc has enough data and we can stop
    * We remove the idle handler from the mainloop */
   static void
   stop_feed (GstElement * playbin, App * app)
     if (app->sourceid != 0) {
       GST_DEBUG ("stop feeding");
       g_source_remove (app->sourceid);
       app->sourceid = 0;
   /* this callback is called when playbin has constructed a source object
to read
    * from. Since we provided the appsrc:// uri to playbin, this will be the
    * appsrc that we must handle. We set up some signals to start and stop
    * data into appsrc */
   static void
   found_source (GObject * object, GObject * orig, GParamSpec * pspec, App *
     /* get a handle to the appsrc */
     //g_object_get (orig, pspec->name, &app->appsrc, NULL);
     //GST_DEBUG ("got appsrc %p", app->appsrc);
     /* we can set the length in appsrc. This allows some elements to
estimate the
      * total duration of the stream. It's a good idea to set the property
when you
      * can but it's not required. */
     g_object_set (app->appsrc, "size", (20*1024*1024), NULL);
     /* configure the appsrc, we will push data into the appsrc from the
     * mainloop. */
     g_object_set (app->appsrc,  "format", GST_FORMAT_TIME, NULL);
     g_signal_connect (app->appsrc, "need-data", G_CALLBACK (start_feed),
     g_signal_connect (app->appsrc, "enough-data", G_CALLBACK (stop_feed),
   static gboolean
   bus_message (GstBus * bus, GstMessage * message, App * app)
     GST_DEBUG ("got message %s",
         gst_message_type_get_name (GST_MESSAGE_TYPE (message)));
   printf("busssss messsages=%s",gst_message_type_get_name (GST_MESSAGE_TYPE
     switch (GST_MESSAGE_TYPE (message)) {
       case GST_MESSAGE_ERROR:
         g_error ("received error");
         g_main_loop_quit (app->loop);
       case GST_MESSAGE_EOS:
         g_main_loop_quit (app->loop);
     return TRUE;
     App *app = &s_app;
     GError *error = NULL;
     GstBus *bus;
     gst_init (NULL, NULL);
     app->content_id =6695031;
   app->loop = g_main_loop_new (NULL, TRUE);
     app->playbin = gst_element_factory_make ("playbin", NULL);
     g_assert (app->playbin);
     bus = gst_pipeline_get_bus (GST_PIPELINE (app->playbin));
     /* add watch for messages */
     gst_bus_add_watch (bus, (GstBusFunc) bus_message, app);
     /* set to read from appsrc */
     g_object_set (app->playbin, "uri", "appsrc://", NULL);
     /* get notification when the source is created so that we get a handle
to it
      * and can configure it */
     g_signal_connect (app->playbin, "deep-notify::source",
         (GCallback) found_source, app);
     /* go to playing and wait in a mainloop. */
     gst_element_set_state (app->playbin, GST_STATE_PLAYING);
     /* this mainloop is stopped when we receive an error or EOS */
     g_main_loop_run (app->loop);
     GST_DEBUG ("stopping");
     gst_element_set_state (app->playbin, GST_STATE_NULL);
     gst_object_unref (bus);
     g_main_loop_unref (app->loop);
     return 0;


Sent from:
gstreamer-devel mailing list
[hidden email]