Hi Mike,<br><br>Thanks for your quick reply.<br><br>Here is my codes for test.<br>pipeline: appsrc->queue->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 <gst/gst.h><br>#include <glib.h><br>#include <unistd.h><br>#include <stdlib.h><br>#include <pthread.h><br>
#include <gst/app/gstappsrc.h><br>#include <string.h><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("************************start********************************** \n");<br><br> if (app->offset >= app->length) {<br> /* we are EOS, send end-of-stream */<br>
g_signal_emit_by_name (appsrc, "end-of-stream", &ret);<br> return;<br> }<br><br> GstBuffer *buffer;<br> guint8 frame_size;<br> guint8 *tmpdata=malloc(1);<br> *tmpdata=mp3[app->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("buffer data = 0x%x \n", *GST_BUFFER_DATA(buffer));<br>
g_signal_emit_by_name (appsrc, "push-buffer", buffer, &ret);<br><br> gst_buffer_unref (buffer);<br><br> app->offset=app->offset+1;<br> g_print("Read thread frame offset = %d \n", app->offset);<br>
return;<br>}<br><br>static gboolean<br>bus_call(GstBus * bus, GstMessage * msg, App * app)<br>{<br> GST_DEBUG ("got message %s",<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->loop);<br> g_error ("End of streame");<br> break;<br><br> case GST_MESSAGE_ERROR: {<br> gchar *debug = NULL;<br> GError *err = NULL;<br>
gst_message_parse_error (msg, &err, &debug);<br> g_print ("Error: %s\n", err->message);<br> g_error_free (err);<br> if (debug) {<br> g_print ("Debug details: %s\n", debug);<br>
g_free (debug);<br> }<br> g_main_loop_quit (app->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=&s_app;<br> g_print (" app->FIFObuf ok \n ");<br><br><br> GstBus* bus;<br> app->length=sizeof(mp3);<br> app->offset=0;<br><br> GstStateChangeReturn ret;<br>
g_print (" Gstreamer Init completed \n ");<br> <br><br><br> <br> app->appsrc = gst_element_factory_make("appsrc", "appsrc");<br> app->filesink = gst_element_factory_make(" filesink", " filesink");<br>
app->queue = gst_element_factory_make("queue", "queue");<br> app->pipeline = gst_pipeline_new("server");<br> app->loop = g_main_loop_new(NULL, TRUE);<br> g_print ("1 \n");<br>
// g_object_set(G_OBJECT(app->appsrc, "is-live", TRUE, "caps","video/x-264",NULL);<br><br> // g_object_set(G_OBJECT(app->appsrc), "is-live",TRUE,"max-bytes",0,NULL); <br>
g_object_set(G_OBJECT(app->filesink), "location", "appsrc.data", NULL);<br>g_print ("2 \n");<br> g_signal_connect(G_OBJECT(app->appsrc), "need-data", G_CALLBACK(feed_data), app);<br>
<br>g_print ("3 \n");<br><br> bus = gst_pipeline_get_bus (GST_PIPELINE (app->pipeline));<br> gst_bus_add_watch (bus, (GstBusFunc)bus_call, app->loop);<br> gst_object_unref(bus);<br><br> gst_bin_add_many(GST_BIN(app->pipeline),app->appsrc,app->queue,app->filesink,NULL);<br>
<br> if (!gst_element_link_many (app->appsrc,app->queue,app->filesink, NULL)) {<br> g_print ("Failed to link one or more elements! \n");<br> return -1;<br> }<br><br><br> ret=gst_element_set_state(app->pipeline, GST_STATE_PLAYING); <br>
g_print("Gst-Pipeline is Running.........\n");<br><br> if (ret == GST_STATE_CHANGE_FAILURE) {<br> GstMessage *msg;<br> g_print ("Failed to start up pipeline! \n");<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, &err, NULL);<br> g_print ("ERROR: %s\n", err->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->loop);<br> <br> /* Out of the main loop, clean up nicely */<br> g_print("Returned, stopping playback\n");<br>
gst_element_set_state(app->pipeline, GST_STATE_NULL);<br> <br> g_print("Deleting pipeline\n");<br> gst_object_unref(GST_OBJECT(app->pipeline));<br><br> g_object_unref(app->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"><<a href="mailto:msmith@xiph.org">msmith@xiph.org</a>></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't<br>
be a problem unless the rest of your pipeline isn't running. Also, 300<br>
is a lot smaller than 200000, so perhaps you have another problem.<br>
<br>
Perhaps there'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'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 <<a href="mailto:zjustc@gmail.com">zjustc@gmail.com</a>> wrote:<br>
> Greetings,<br>
><br>
> Currently, I am testing the appsrc element, which will use "need-data"<br>
> signal.<br>
> g_signal_connect(G_OBJECT(app->appsrc), "need-data",<br>
> G_CALLBACK(feed_data), app)<br>
> my feed_data function will read data from a array with 300 guint8 numbers.<br>
><br>
> The codes work fine in the beginning, however it will stop when the<br>
> feed_data read the 200th number.<br>
> I run it for many times, the code will exactly stop at 200th number.<br>
><br>
> Anyone knows how that happen?<br>
> Any trick to set the properties of appsrc?<br>
><br>
> Thanks,<br>
><br>
> Jun<br>
><br>
> --<br>
> 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>
> Sent from the GStreamer-devel mailing list archive at Nabble.com.<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>
_______________________________________________<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>