Hi,

 

How can I access external buffer to make my pipeline to work?   I tried to make use of “appsrc” plugin. Still I could not find the way.    

Example is give at   

 

../gst-plugins-bad-0.10.6/examples/app/appsrc_ex.c

 

Basically my aim to avoid using filesrc and give my own GstBuffer to the next element.  (gst-launch filesrc location=MPEG25_11_32_m.mp3 ! flump3dec ! alsasink )

 

 

 

The tried the following way in the given example testapplication.

 

 

#ifdef HAVE_CONFIG_H

#include "config.h"

#endif

 

#include <gst/gst.h>

#include <gst/app/gstappsrc.h>

#include <gst/app/gstappbuffer.h>

#include <gst/app/gstappsink.h>

 

#include <stdio.h>

#include <string.h>

#include <stdlib.h>

 

 

typedef struct _App App;

struct _App

{

  GstElement *pipe;

  GstElement *src;

  GstElement *id;

  GstElement *mp3dec;

  GstElement *alsa;

};

 

App s_app;

 

static void dont_eat_my_chicken_wings (void *priv);

 

int

main (int argc, char *argv[])

{

  App *app = &s_app;

  int chars_read,i=0;

  FILE *fp;

  int pos, sizeoffile;

  GstBuffer *buf;

  void *data;

 

  gst_init (&argc, &argv);

  app->pipe = gst_pipeline_new (NULL);

  g_assert (app->pipe);

 

  app->src = gst_element_factory_make ("appsrc", NULL);

  g_assert (app->src);

  gst_bin_add (GST_BIN (app->pipe), app->src);

 

  app->mp3dec = gst_element_factory_make ("flump3dec", NULL);

  g_assert (app->mp3dec);

  gst_bin_add (GST_BIN (app->pipe), app->mp3dec);

 

  app->alsa = gst_element_factory_make ("alsasink", NULL);

  g_assert (app->alsa);

  gst_bin_add (GST_BIN (app->pipe), app->alsa);

 

  app->id = gst_element_factory_make ("identity", NULL);

  g_assert (app->id);

  gst_bin_add (GST_BIN (app->pipe), app->id);

 

  gst_element_link (app->src, app->id);

  gst_element_link (app->id, app->mp3dec);

  gst_element_link (app->mp3dec, app->alsa);

 

  gst_element_set_state (app->pipe, GST_STATE_PLAYING);

 

  fp=fopen("MPEG25_11_32_m.mp3","rb");

  pos = ftell(fp);

  fseek (fp, 0, SEEK_END);

  sizeoffile = ftell(fp);

  fseek (fp, pos, SEEK_SET);

  printf("sizeoffile : %d\n",sizeoffile);

 

    data = (char*)malloc (sizeoffile);

    chars_read = fread(data,sizeof(char),sizeoffile,fp);

 

    buf = gst_app_buffer_new (data, sizeoffile, dont_eat_my_chicken_wings, data);

    gst_app_src_push_buffer (GST_APP_SRC (app->src), buf);

 

  gst_app_src_end_of_stream (GST_APP_SRC (app->src));

  gst_buffer_unref (buf);

  fclose(fp);

 

}

 

static void

dont_eat_my_chicken_wings (void *priv)

{

  printf ("freeing buffer for pointer %p\n", priv);

  free (priv);

}

 

**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the addressee(s). If you are not the intended recipient, please notify the sender by e-mail and delete the original message. Further, you are not to copy, disclose, or distribute this e-mail or its contents to any other person and any such actions are unlawful. This e-mail may contain viruses. Infosys has taken every reasonable precaution to minimize this risk, but is not liable for any damage you may sustain as a result of any virus in this e-mail. You should carry out your own virus checks before opening the e-mail or attachment. Infosys reserves the right to monitor and review the content of all messages sent to or from this e-mail address. Messages sent to or from this e-mail address may be stored on the Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***