issue with appsrc and audioresample

classic Classic list List threaded Threaded
5 messages Options
na
Reply | Threaded
Open this post in threaded view
|

issue with appsrc and audioresample

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

}










Reply | Threaded
Open this post in threaded view
|

Re: issue with appsrc and audioresample

Tiago Katcipis


On Sat, Feb 27, 2010 at 10:16 PM, na <[hidden email]> 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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel


------------------------------------------------------------------------------
Download Intel&#174; 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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
na
Reply | Threaded
Open this post in threaded view
|

Re: issue with appsrc and audioresample

na
Hello Katcipis,

Thanks for your kind reply.

I changed the caps on the appsrc buffer and caps filter to:

 GstCaps *rescaps;
  rescaps = gst_caps_new_simple("audio/x-raw-int", "rate", G_TYPE_INT, 48000, "channels" ,G_TYPE_INT, (gint)1, "endianness",G_TYPE_INT,(gint)1234, "width", G_TYPE_INT, (gint)8, "depth", G_TYPE_INT, (gint)8, "signed", G_TYPE_BOOLEAN, TRUE, NULL);
  g_object_set(capsfilt_res,"caps",rescaps,NULL);

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

However, the result is the same "not negotiated" error.  I have attached the relevant debug output. If you do have any other ideas, please do let me know.  Thanks

Best regards,

Nadeem

0:00:00.219005295  3697  0x884d008 INFO               GST_EVENT gstevent.c:597:gst_event_new_new_segment_full: creating newsegment update 0, rate 1.000000, format bytes, start 0, stop -1, position 0
0:00:00.220594821  3697  0x884d008 INFO              GST_STATES gstelement.c:2238:gst_element_continue_state:<appsrc> completed state change to PAUSED
0:00:00.220625877  3697  0x884d008 INFO              GST_STATES gstelement.c:2251:gst_element_continue_state:<appsrc> posting state-changed READY to PAUSED
0:00:00.220644133  3697  0x884d008 INFO              GST_STATES gstbin.c:2425:gst_bin_change_state_func:<pipeline0> child 'appsrc' changed state to 3(PAUSED) successfully
0:00:00.220765315  3697  0x8956458 WARN           basetransform gstbasetransform.c:1969:gst_base_transform_handle_buffer:<audiores> error: not negotiated
0:00:00.220820395  3697  0x8956458 WARN           basetransform gstbasetransform.c:1969:gst_base_transform_handle_buffer:<audiores> error: not negotiated
0:00:00.220877203  3697  0x8956458 INFO        GST_ERROR_SYSTEM gstelement.c:1763:gst_element_message_full:<audiores> posting message: not negotiated
0:00:00.220930220  3697  0x8956458 INFO        GST_ERROR_SYSTEM gstelement.c:1786:gst_element_message_full:<audiores> posted error message: not negotiated
0:00:00.220960984  3697  0x8956458 INFO                 basesrc gstbasesrc.c:2326:gst_base_src_loop:<appsrc> pausing after gst_pad_push() = not-negotiated
0:00:00.221001947  3697  0x8956458 WARN                 basesrc gstbasesrc.c:2378:gst_base_src_loop:<appsrc> error: Internal data flow error.
0:00:00.221025676  3697  0x8956458 WARN                 basesrc gstbasesrc.c:2378:gst_base_src_loop:<appsrc> error: streaming task paused, reason not-negotiated (-4)
0:00:00.221057825  3697  0x8956458 INFO        GST_ERROR_SYSTEM gstelement.c:1763:gst_element_message_full:<appsrc> posting message: Internal data flow error.
0:00:00.221090188  3697  0x8956458 INFO        GST_ERROR_SYSTEM gstelement.c:1786:gst_element_message_full:<appsrc> posted error message: Internal data flow error.
0:00:00.221205570  3697  0x8956458 INFO              GST_STATES gstbin.c:2815:bin_handle_async_done:<pipeline0> committing state from READY to PAUSED, old pending PLAYING
0:00:00.221236480  3697  0x8956458 INFO              GST_STATES gstbin.c:2844:bin_handle_async_done:<pipeline0> continue state change, pending PLAYING
Reply | Threaded
Open this post in threaded view
|

Re: issue with appsrc and audioresample

Tiago Katcipis
Try to set the property "caps" on the appsrc instead of using a capsfilter. But setting full caps is still a need, maybe to work properly appsrc need to have the caps property defined, i never used appsrc, only appsink, and using only capsfilters usually worked when i needed then, but i remember that some problems with udpsrc where solved when i defined the "caps" property.

best regards,
Katcipis

On Mon, Mar 1, 2010 at 3:05 AM, na <[hidden email]> wrote:

Hello Katcipis,

Thanks for your kind reply.

I changed the caps on the appsrc buffer and caps filter to:

 GstCaps *rescaps;
 rescaps = gst_caps_new_simple("audio/x-raw-int", "rate", G_TYPE_INT,
48000, "channels" ,G_TYPE_INT, (gint)1, "endianness",G_TYPE_INT,(gint)1234,
"width", G_TYPE_INT, (gint)8, "depth", G_TYPE_INT, (gint)8, "signed",
G_TYPE_BOOLEAN, TRUE, NULL);
 g_object_set(capsfilt_res,"caps",rescaps,NULL);

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

However, the result is the same "not negotiated" error.  I have attached the
relevant debug output. If you do have any other ideas, please do let me
know.  Thanks

Best regards,

Nadeem

0:00:00.219005295  3697  0x884d008 INFO               GST_EVENT
gstevent.c:597:gst_event_new_new_segment_full: creating newsegment update 0,
rate 1.000000, format bytes, start 0, stop -1, position 0
0:00:00.220594821  3697  0x884d008 INFO              GST_STATES
gstelement.c:2238:gst_element_continue_state:<appsrc> completed state change
to PAUSED
0:00:00.220625877  3697  0x884d008 INFO              GST_STATES
gstelement.c:2251:gst_element_continue_state:<appsrc> posting state-changed
READY to PAUSED
0:00:00.220644133  3697  0x884d008 INFO              GST_STATES
gstbin.c:2425:gst_bin_change_state_func:<pipeline0> child 'appsrc' changed
state to 3(PAUSED) successfully
0:00:00.220765315  3697  0x8956458 WARN           basetransform
gstbasetransform.c:1969:gst_base_transform_handle_buffer:<audiores> error:
not negotiated
0:00:00.220820395  3697  0x8956458 WARN           basetransform
gstbasetransform.c:1969:gst_base_transform_handle_buffer:<audiores> error:
not negotiated
0:00:00.220877203  3697  0x8956458 INFO        GST_ERROR_SYSTEM
gstelement.c:1763:gst_element_message_full:<audiores> posting message: not
negotiated
0:00:00.220930220  3697  0x8956458 INFO        GST_ERROR_SYSTEM
gstelement.c:1786:gst_element_message_full:<audiores> posted error message:
not negotiated
0:00:00.220960984  3697  0x8956458 INFO                 basesrc
gstbasesrc.c:2326:gst_base_src_loop:<appsrc> pausing after gst_pad_push() =
not-negotiated
0:00:00.221001947  3697  0x8956458 WARN                 basesrc
gstbasesrc.c:2378:gst_base_src_loop:<appsrc> error: Internal data flow
error.
0:00:00.221025676  3697  0x8956458 WARN                 basesrc
gstbasesrc.c:2378:gst_base_src_loop:<appsrc> error: streaming task paused,
reason not-negotiated (-4)
0:00:00.221057825  3697  0x8956458 INFO        GST_ERROR_SYSTEM
gstelement.c:1763:gst_element_message_full:<appsrc> posting message:
Internal data flow error.
0:00:00.221090188  3697  0x8956458 INFO        GST_ERROR_SYSTEM
gstelement.c:1786:gst_element_message_full:<appsrc> posted error message:
Internal data flow error.
0:00:00.221205570  3697  0x8956458 INFO              GST_STATES
gstbin.c:2815:bin_handle_async_done:<pipeline0> committing state from READY
to PAUSED, old pending PLAYING
0:00:00.221236480  3697  0x8956458 INFO              GST_STATES
gstbin.c:2844:bin_handle_async_done:<pipeline0> continue state change,
pending PLAYING

--
View this message in context: http://n4.nabble.com/issue-with-appsrc-and-audioresample-tp1572395p1573184.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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel


------------------------------------------------------------------------------
Download Intel&#174; 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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
na
Reply | Threaded
Open this post in threaded view
|

Re: issue with appsrc and audioresample

na
Katcipis,

Thank you for your help.  Setting the caps on the appsrc worked!  

Best regards,

Nadeem