On Sat, Feb 27, 2010 at 10:16 PM, na <nahmed31@hotmail.com> wrote:

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);

I think your problem is here, you have to specify the full caps, the not negotiated error is right, appsrc cant tell you the kind of data you are streaming and your caps only says that it is int with a 48000 rate... but how much channels? and the depth/ width of the samples? you must give full caps or the pipeline is unable to verify what kind of data you are streaming. Only appsrc/appsink works because they don't need to know the kind of data that you are streaming, so they can negotiate with each other, but audioresample need full caps of the stream to work.

Hope this helps ;)

Someone correct me if i said something wrong.

best regards,
Katcipis
 
 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.

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
gstreamer-devel mailing list
gstreamer-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel