Hi Mike,<br><br>Thanks for your quick reply.<br><br>Here is my codes for test.<br>pipeline: appsrc-&gt;queue-&gt;filesink<br><br>appsrc will read data from array mp3;<br><br><br>Would you please take a look and give me some advice?<br>
<br><br><br>//=====================begin of test codes==========<br><br>// 200 error<br><br>#include &lt;gst/gst.h&gt;<br>#include &lt;glib.h&gt;<br>#include &lt;unistd.h&gt;<br>#include &lt;stdlib.h&gt;<br>#include &lt;pthread.h&gt;<br>
#include &lt;gst/app/gstappsrc.h&gt;<br>#include &lt;string.h&gt;<br><br><br>static const guint8 mp3[] = { 0x11, 0x22, 0x33, 0x44, 0x50, 0x66,<br>  0x08, 0xbb, 0x4b, 0x00, 0xff, 0xff, 0xff, 0x20, 0xbb, 0xff,0x08, 0xbb, 0x4b, 0x00, 0xff, 0xff, 0xff, 0x20, 0xbb, 0xff,<br>
  0x08, 0xbb, 0x4b, 0x00, 0xff, 0xff, 0xff, 0x20, 0xbb, 0xff,0x08, 0xbb, 0x4b, 0x00, 0xff, 0xff, 0xff, 0x20, 0xbb, 0xff,<br>  0x08, 0xbb, 0x4b, 0x00, 0xff, 0xff, 0xff, 0x20, 0xbb, 0xff,0x08, 0xbb, 0x4b, 0x00, 0xff, 0xff, 0xff, 0x20, 0xbb, 0xff,<br>
  0x08, 0xbb, 0x4b, 0x00, 0xff, 0xff, 0xff, 0x20, 0xbb, 0xff,0x08, 0xbb, 0x4b, 0x00, 0xff, 0xff, 0xff, 0x20, 0xbb, 0xff,<br>  0x08, 0xbb, 0x4b, 0x00, 0xff, 0xff, 0xff, 0x20, 0xbb, 0xff,0x08, 0xbb, 0x4b, 0x00, 0xff, 0xff, 0xff, 0x20, 0xbb, 0xff,<br>
  0x08, 0xbb, 0x4b, 0x00, 0xff, 0xff, 0xff, 0x20, 0xbb, 0xff,0x08, 0xbb, 0x4b, 0x00, 0xff, 0xff, 0xff, 0x20, 0xbb, 0xff,<br>  0x08, 0xbb, 0x4b, 0x00, 0xff, 0xff, 0xff, 0x20, 0xbb, 0xff,0x08, 0xbb, 0x4b, 0x00, 0xff, 0xff, 0xff, 0x20, 0xbb, 0xff,<br>
  0x08, 0xbb, 0x4b, 0x00, 0xff, 0xff, 0xff, 0x20, 0xbb, 0xff,0x08, 0xbb, 0x4b, 0x00, 0xff, 0xff, 0xff, 0x20, 0xbb, 0xff,<br>  0x08, 0xbb, 0x4b, 0x00, 0xff, 0xff, 0xff, 0x20, 0xbb, 0xff,0x08, 0xbb, 0x4b, 0x00, 0xff, 0xff, 0xff, 0x20, 0xbb, 0xff,<br>
  0x08, 0xbb, 0x4b, 0x00, 0xff, 0xff, 0xff, 0x20, 0xbb, 0xff,0x08, 0xbb, 0x4b, 0x00, 0xff, 0xff, 0xff, 0x20, 0xbb, 0xff,<br>  0x08, 0xbb, 0x4b, 0x00, 0xff, 0xff, 0xff, 0x20, 0xbb, 0xff,0x08, 0xbb, 0x4b, 0x00, 0xff, 0xff, 0xff, 0x20, 0xbb, 0xff,<br>
  0x08, 0xbb, 0x4b, 0x00, 0xff, 0xff, 0xff, 0x20, 0xbb, 0xff,0x08, 0xbb, 0x4b, 0x00, 0xff, 0xff, 0xff, 0x20, 0x45, 0x32<br>};<br><br><br>typedef struct _App App;<br><br>struct  _App<br>{<br>  GstElement *appsrc;<br>  GstElement *filesink;<br>
  GstElement *queue;<br>  GstElement *pipeline;<br>  GMainLoop *loop;<br>  guint length;<br>  guint64 offset;<br>};<br><br><br> App s_app;<br><br><br><br>static void feed_data (GstElement * appsrc, guint size, App* app)<br>
{<br>      GstFlowReturn ret;<br>  g_print(&quot;************************start********************************** \n&quot;);<br><br>  if (app-&gt;offset &gt;= app-&gt;length) {<br>    /* we are EOS, send end-of-stream */<br>
     g_signal_emit_by_name (appsrc, &quot;end-of-stream&quot;, &amp;ret);<br>    return;<br>  }<br><br>    GstBuffer *buffer;<br>    guint8 frame_size;<br>    guint8 *tmpdata=malloc(1);<br>    *tmpdata=mp3[app-&gt;offset];<br>
    frame_size=1;<br><br><br>    buffer = gst_buffer_new_and_alloc (frame_size);<br>    gst_buffer_set_data(buffer, tmpdata, frame_size);<br><br>    g_print(&quot;buffer data = 0x%x \n&quot;, *GST_BUFFER_DATA(buffer));<br>
    g_signal_emit_by_name (appsrc, &quot;push-buffer&quot;, buffer, &amp;ret);<br><br>    gst_buffer_unref (buffer);<br><br>    app-&gt;offset=app-&gt;offset+1;<br>    g_print(&quot;Read thread frame offset = %d \n&quot;, app-&gt;offset);<br>
  return;<br>}<br><br>static gboolean<br>bus_call(GstBus * bus, GstMessage * msg, App * app)<br>{<br>  GST_DEBUG (&quot;got message %s&quot;,<br>      gst_message_type_get_name (GST_MESSAGE_TYPE (msg)));<br><br>  switch (GST_MESSAGE_TYPE (msg)) {<br>
    case GST_MESSAGE_EOS:<br>      g_main_loop_quit (app-&gt;loop);<br>      g_error (&quot;End of streame&quot;);<br>      break;<br><br>   case GST_MESSAGE_ERROR: {<br>            gchar *debug = NULL;<br>            GError *err = NULL;<br>
            gst_message_parse_error (msg, &amp;err, &amp;debug);<br>            g_print (&quot;Error: %s\n&quot;, err-&gt;message);<br>            g_error_free (err);<br>                if (debug) {<br>                    g_print (&quot;Debug details: %s\n&quot;, debug);<br>
                    g_free (debug);<br>                }<br>            g_main_loop_quit (app-&gt;loop);<br>        break;<br>    }<br>    default:<br>    break;<br>    }<br>return TRUE;<br>}<br><br><br>int main()<br>{<br>
   gst_init(NULL,NULL);<br><br>    App *app=&amp;s_app;<br>    g_print  (&quot; app-&gt;FIFObuf ok \n &quot;);<br><br><br>    GstBus* bus;<br>    app-&gt;length=sizeof(mp3);<br>    app-&gt;offset=0;<br><br>    GstStateChangeReturn ret;<br>
    g_print  (&quot; Gstreamer Init completed \n &quot;);<br>  <br><br><br> <br>  app-&gt;appsrc    = gst_element_factory_make(&quot;appsrc&quot;, &quot;appsrc&quot;);<br>  app-&gt;filesink  = gst_element_factory_make(&quot; filesink&quot;, &quot; filesink&quot;);<br>
  app-&gt;queue     = gst_element_factory_make(&quot;queue&quot;, &quot;queue&quot;);<br>  app-&gt;pipeline  = gst_pipeline_new(&quot;server&quot;);<br>  app-&gt;loop     = g_main_loop_new(NULL, TRUE);<br>    g_print (&quot;1 \n&quot;);<br>
  //    g_object_set(G_OBJECT(app-&gt;appsrc, &quot;is-live&quot;, TRUE, &quot;caps&quot;,&quot;video/x-264&quot;,NULL);<br><br>     // g_object_set(G_OBJECT(app-&gt;appsrc), &quot;is-live&quot;,TRUE,&quot;max-bytes&quot;,0,NULL); <br>
      g_object_set(G_OBJECT(app-&gt;filesink), &quot;location&quot;, &quot;appsrc.data&quot;, NULL);<br>g_print (&quot;2 \n&quot;);<br>      g_signal_connect(G_OBJECT(app-&gt;appsrc),  &quot;need-data&quot;,  G_CALLBACK(feed_data), app);<br>
  <br>g_print (&quot;3 \n&quot;);<br><br>    bus = gst_pipeline_get_bus (GST_PIPELINE (app-&gt;pipeline));<br>    gst_bus_add_watch (bus, (GstBusFunc)bus_call, app-&gt;loop);<br>        gst_object_unref(bus);<br><br>    gst_bin_add_many(GST_BIN(app-&gt;pipeline),app-&gt;appsrc,app-&gt;queue,app-&gt;filesink,NULL);<br>
<br>      if (!gst_element_link_many (app-&gt;appsrc,app-&gt;queue,app-&gt;filesink, NULL)) {<br>    g_print (&quot;Failed to link one or more elements! \n&quot;);<br>    return -1;<br>    }<br><br><br>      ret=gst_element_set_state(app-&gt;pipeline, GST_STATE_PLAYING);   <br>
      g_print(&quot;Gst-Pipeline is Running.........\n&quot;);<br><br>    if (ret == GST_STATE_CHANGE_FAILURE) {<br>        GstMessage *msg;<br>    g_print (&quot;Failed to start up pipeline! \n&quot;);<br>/* check if there is an error message with details on the bus */<br>
    msg = gst_bus_poll (bus, GST_MESSAGE_ERROR, 0);<br>    if (msg) {<br>    GError *err = NULL;<br>    gst_message_parse_error (msg, &amp;err, NULL);<br>    g_print (&quot;ERROR: %s\n&quot;, err-&gt;message);<br>    g_error_free (err);<br>
    gst_message_unref (msg);<br>    }<br>    return -1;<br>     //pthread_exit (NULL);<br>     }<br><br>        g_main_loop_run(app-&gt;loop);<br>   <br>    /* Out of the main loop, clean up nicely */<br>        g_print(&quot;Returned, stopping playback\n&quot;);<br>
        gst_element_set_state(app-&gt;pipeline, GST_STATE_NULL);<br>   <br>       g_print(&quot;Deleting pipeline\n&quot;);<br>       gst_object_unref(GST_OBJECT(app-&gt;pipeline));<br><br>    g_object_unref(app-&gt;appsrc); <br>
<br>     return 0;<br>}<br><br><br>//=================end of test codes<br><br><br><br><br><div class="gmail_quote">On Tue, Dec 6, 2011 at 1:26 PM, Michael Smith <span dir="ltr">&lt;<a href="mailto:msmith@xiph.org">msmith@xiph.org</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">There is no such limitation in appsrc - it does have a maximum number<br>
of bytes to buffer internally (defaults to 200000), but that shouldn&#39;t<br>
be a problem unless the rest of your pipeline isn&#39;t running. Also, 300<br>
is a lot smaller than 200000, so perhaps you have another problem.<br>
<br>
Perhaps there&#39;s a bug with how the rest of your pipeline works. Of<br>
course, since you provided no details about your application other<br>
than that it uses appsrc, I can&#39;t suggest anything specific.<br>
<br>
Mike<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
On Tue, Dec 6, 2011 at 9:09 AM, Nathan &lt;<a href="mailto:zjustc@gmail.com">zjustc@gmail.com</a>&gt; wrote:<br>
&gt; Greetings,<br>
&gt;<br>
&gt;  Currently, I am testing the appsrc element, which will use  &quot;need-data&quot;<br>
&gt; signal.<br>
&gt; g_signal_connect(G_OBJECT(app-&gt;appsrc),  &quot;need-data&quot;,<br>
&gt; G_CALLBACK(feed_data), app)<br>
&gt;  my feed_data function will read data from a array with 300 guint8 numbers.<br>
&gt;<br>
&gt; The codes work fine in the beginning, however it will stop when the<br>
&gt; feed_data read the 200th number.<br>
&gt; I run it for many times, the code will exactly stop at 200th number.<br>
&gt;<br>
&gt; Anyone knows how that happen?<br>
&gt; Any trick to set the properties of appsrc?<br>
&gt;<br>
&gt; Thanks,<br>
&gt;<br>
&gt; Jun<br>
&gt;<br>
&gt; --<br>
&gt; View this message in context: <a href="http://gstreamer-devel.966125.n4.nabble.com/why-appsrc-can-only-work-200-times-tp4165570p4165570.html" target="_blank">http://gstreamer-devel.966125.n4.nabble.com/why-appsrc-can-only-work-200-times-tp4165570p4165570.html</a><br>

&gt; Sent from the GStreamer-devel mailing list archive at Nabble.com.<br>
&gt; _______________________________________________<br>
&gt; gstreamer-devel mailing list<br>
&gt; <a href="mailto:gstreamer-devel@lists.freedesktop.org">gstreamer-devel@lists.freedesktop.org</a><br>
&gt; <a href="http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a><br>
_______________________________________________<br>
gstreamer-devel mailing list<br>
<a href="mailto:gstreamer-devel@lists.freedesktop.org">gstreamer-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a><br>
</div></div></blockquote></div><br>