how to import a live buffer into gstreamer?
Nathan
zjustc at gmail.com
Tue Nov 29 20:47:23 PST 2011
Hi Thiago
Thanks for your quick reply very much. I really appreciated that.
video_h264encodingthread{
Frame_count i;
Byte* encbuffer; // will be copied into gst_thread
//bunch of codes, then the encbuffer will have a frame of compressed video
data;
// which will be copied into gst_thread gst buffer;
gst_omxbuf=memcpy(encbuffer, sizeof(encbuffer) );
}
I just create a new thread name gst_thread, which will create a fakesrc and
then link to filesink (later will use this fakesrc to do some complex gst
applications)
the data in gst_omxbuf will be copied into fakesrc.
Is any problem with the structure of my codes?
I donot really understand the buffer management of gst-fakesrc or
gst-appsrc;
like the data is keeping copying into gst_omxbuf in the h264encodingthread
, how the callback function of fakesrc in gst_thread can match the speed of
that. Sould I create a heap so that in one end the data is writing into the
heap and in the other end fakesrc keep reading data from heap?
My codes seems working okay, i didnot get any errors when running it.
however, when i check the file written by filesink, there are all zero.
Could you please give me any advice, or any comments on this problem?
Is any other better way to achieve my goal?
Thanks a lot,
Jun
========================================
void fill_src_buffer(GstElement *fakesrc, GstBuffer *gstbuf, GstPad *pad,
int i)
{
GstCaps *caps;
GST_BUFFER_MALLOCDATA(gstbuf)=GST_BUFFER_DATA(gstbuf)=gst_omxbuf;
GST_BUFFER_SIZE(gstbuf)=GST_BUFFER_SIZE(gst_omxbuf);
caps = gst_caps_new_simple ("video/x-h264", NULL);
memcpy (GST_BUFFER_DATA (gstbuf), gst_omxbuf,
GST_BUFFER_SIZE(gst_omxbuf));
gst_buffer_set_caps (gstbuf, caps);
g_print ("buffer caps setting done\n");
gst_caps_unref (caps);
}
void gst_pipelinetask()
{
// omit bunch of variables statements
fakesrc =gst_element_factory_make("fakesrc", "fakesrc");
printf (" fakesrc Init completed \n ");
filesink =gst_element_factory_make("filesink", "filesink");
printf (" filesink Init completed \n ");
g_object_set(filesink, "location", "gst.data", NULL );
g_object_set (fakesrc, "num-buffers", 4,
"sizemax", sizeof(gst_omxbuf),
"sizetype",2,
"filltype",2,
"is-live",TRUE,
"can-activate-pull",FALSE,
"signal-handoffs", TRUE, NULL);
g_signal_connect(fakesrc, "handoff", G_CALLBACK (fill_src_buffer), 0);
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
gst_bus_add_watch (bus, bus_call, loop);
gst_object_unref (bus);
printf (" Buss completed \n ");
gst_bin_add_many(GST_BIN(pipeline),fakesrc,filesink,NULL);
if (!gst_element_link(fakesrc,filesink)) {
g_print ("Failed to link elements! \n");
return -1;
}
printf (" Buss link completed \n ");
ret=gst_element_set_state(pipeline, GST_STATE_PLAYING);
g_print("Gst-Pipeline is Runningttttttt.........\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;
}
g_main_loop_run(loop);
/* Out of the main loop, clean up nicely */
g_print("Returned, stopping playback\n");
gst_element_set_state(pipeline, GST_STATE_NULL);
g_print("Deleting pipeline\n");
gst_object_unref(GST_OBJECT(pipeline));
return 0;
}
On Tue, Nov 29, 2011 at 10:37 PM, Thiago Sousa Santos-2 [via
GStreamer-devel] <ml-node+s966125n4121779h23 at n4.nabble.com> wrote:
> On Tue, 2011-11-29 at 13:00 -0800, Nathan wrote:
>
> > Greetings,
> >
> > I am trying to streaming a compressed video into networks.
> >
> > The data coming from non-gst h264encoder and I donot want to change my
> > existing codes a lot.
> >
> > So I just keep memcpying compressed data from the output of encode and
> load
> > them into fakesrc and create a thread in my codes to run the
> gst-pipeline.
> >
> > So far, I have not successfully done it.
>
> What error do you get?
>
> >
> > Anyone can suggest any easier approach?
> >
> > If I just want to keep feeding data into sink pad of a gst-pipeline,
> which
> > kind of elements is more suitable to do achieve this?
> >
> >
> >
> > I try to use gstpushsrc, however didnot find any useful example.
>
> Take a look at appsrc, from gst-plugins-base:
>
> http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-libs/html/gst-plugins-base-libs-appsrc.html
>
> You put the appsrc as a source of your pipeline and link your remaining
> elements as usual, set the pipeline to playing and feed appsrc with your
> data inside GstBuffers.
>
> >
> >
> >
> > Regards,
> >
> >
> >
> > Jun
> >
> > --
> > View this message in context:
> http://gstreamer-devel.966125.n4.nabble.com/how-to-import-a-live-buffer-into-gstreamer-tp4120766p4120766.html
> > Sent from the GStreamer-devel mailing list archive at Nabble.com.
> > _______________________________________________
> > gstreamer-devel mailing list
> > [hidden email] <http://user/SendEmail.jtp?type=node&node=4121779&i=0>
> > http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>
> --
> Thiago
>
>
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email] <http://user/SendEmail.jtp?type=node&node=4121779&i=1>
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://gstreamer-devel.966125.n4.nabble.com/how-to-import-a-live-buffer-into-gstreamer-tp4120766p4121779.html
> To unsubscribe from how to import a live buffer into gstreamer?, click
> here<http://gstreamer-devel.966125.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4120766&code=emp1c3RjQGdtYWlsLmNvbXw0MTIwNzY2fDE4NzQxNjA3ODI=>
> .
> NAML<http://gstreamer-devel.966125.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.InstantMailNamespace&breadcrumbs=instant+emails%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/how-to-import-a-live-buffer-into-gstreamer-tp4120766p4121915.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20111129/8508baf5/attachment.htm>
More information about the gstreamer-devel
mailing list