[gst-devel] issue with appsrc and audioresample

na nahmed31 at hotmail.com
Sun Feb 28 02:16:40 CET 2010


Hello,

I am trying to write a sample example where I can push and pull audio
buffers via appsrc and appsink to a simple pipeline that will resample the
audio.  

I created a simple example that sets up the pipeline and tries to push and
pull a single buffer. When I run the code below, I get the following output:

 ./rxpipeline --gst-debug-level=2
0:00:00.148913625 22049  0x94e42c0 WARN           basetransform
gstbasetransform.c:1969:gst_base_transform_handle_buffer:<audiores> error:
not negotiated
0:00:00.149326247 22049  0x94e42c0 WARN           basetransform
gstbasetransform.c:1969:gst_base_transform_handle_buffer:<audiores> error:
not negotiated
0:00:00.149653838 22049  0x94e42c0 WARN                 basesrc
gstbasesrc.c:2378:gst_base_src_loop:<appsrc> error: Internal data flow
error.
0:00:00.149971963 22049  0x94e42c0 WARN                 basesrc
gstbasesrc.c:2378:gst_base_src_loop:<appsrc> error: streaming task paused,
reason not-negotiated (-4)

(rxpipeline:22049): GStreamer-CRITICAL **: gst_mini_object_unref: assertion
`mini_object->refcount > 0' failed

I have attached the source code below. Please also note that if I remove the
resample element and caps filter from the pipeline, I can successfully push
and pull the buffer.  

Any help would be greatly appreciated.  Thanks. 
 
Best regards,

Nadeem

---------------------------------------------
#include <gst/gst.h>
#include <gst/app/gstappbuffer.h> 
#include <gst/app/gstappsrc.h> 
#include <gst/app/gstappsink.h>

#define BUFFER_SIZE 160

int main (int argc, char *argv[])
{
  GstBuffer *app_buffer_src, *app_buffer_sink; 
  GMainLoop *loop;

  GstElement *pipeline;
  GstElement *appsrc;
  GstElement *appsink;
  GstElement *audiores;
  GstElement *capsfilt_res;

  // initialize

  gst_init(&argc, &argv);

  // create elements

  loop           = g_main_loop_new (NULL, FALSE);
  pipeline       = gst_pipeline_new(NULL);
  appsrc         = gst_element_factory_make("appsrc","appsrc");
  appsink        = gst_element_factory_make("appsink","appsink");
  audiores       = gst_element_factory_make("audioresample","audiores");
  capsfilt_res   = gst_element_factory_make("capsfilter","capsfilt_res");

  // setup pipeline

  GstCaps *rescaps;
  rescaps = gst_caps_new_simple("audio/x-raw-int", "rate", G_TYPE_INT,
(gint)48000, NULL);
  g_object_set(capsfilt_res,"caps",rescaps,NULL);

  gst_bin_add_many (GST_BIN
(pipeline),appsrc,appsink,audiores,capsfilt_res,NULL);

  gboolean res;
  res = gst_element_link_many(appsrc,audiores,capsfilt_res,appsink,NULL);
  g_assert (res == TRUE);

  gst_element_set_state(pipeline,GST_STATE_PLAYING);

  // create buffer

  gpointer raw_buffer;
  raw_buffer = g_malloc0(BUFFER_SIZE);

  int ii = 0;
  for (ii=0; ii<BUFFER_SIZE; ii++)
  {
     ((guint8*)raw_buffer)[ii] = (guint8)ii;
  }

  // push buffer to pipeline via appsrc

  GstCaps *caps;
  caps = gst_caps_new_simple("audio/x-raw-int", "width", G_TYPE_INT,
(gint)8, "depth", G_TYPE_INT, (gint)8, "channels" ,G_TYPE_INT, (gint)1, 
                            
"rate",G_TYPE_INT,8000,"endianness",G_TYPE_INT,(gint)1234,NULL);

  app_buffer_src = gst_app_buffer_new (raw_buffer, BUFFER_SIZE, g_free,
raw_buffer);
  GST_BUFFER_CAPS(app_buffer_src) = caps;

  gst_app_src_push_buffer(GST_APP_SRC(appsrc),app_buffer_src);
  gst_buffer_unref (app_buffer_src); 

  // read buffers from pipeline via appsink

  app_buffer_sink = gst_app_sink_pull_buffer(GST_APP_SINK(appsink));
 
  for (ii = 0; ii<GST_BUFFER_SIZE(app_buffer_sink); ii++ )
  {
    printf("data(ii) %d\n",GST_BUFFER_DATA(app_buffer_sink)[ii]);
  }

  // cleanup

  gst_element_set_state(pipeline,GST_STATE_NULL);
  gst_object_unref(GST_OBJECT(pipeline));


  return 0;

}











-- 
View this message in context: http://n4.nabble.com/issue-with-appsrc-and-audioresample-tp1572395p1572395.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.




More information about the gstreamer-devel mailing list