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