LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 04-21-2010, 06:29 AM   #1
puneeth bhat
Member
 
Registered: Jan 2010
Posts: 30

Rep: Reputation: 15
gstreamer


Hi
i m passing shared memory data in to raw buffer but it is not working how can i store my data in a buffer which i get continuously in to a container what changes i have to do this in program.Is there any way to push data continuously in to push buffer and storing...can i able to succeed with out using g_main_loop_run and push data in to raw_buffer forming a loop.Here is the sample program where u may get some idea.
* to the mainloop to start pushing data into the appsrc */
static void start_feed(GstElement *appsrc, guint size, GS_Server_RtpHandle *pRtpHandle)
{
gpointer raw_buffer;
GstBuffer *vbuffer;
GstFlowReturn ret;
static int num_frame;

num_frame = 0;

/* Allocating the memory for the buffer */
raw_buffer = g_malloc(BUFFER_SIZE);

memcpy(raw_buffer,pRtpHandle->pShmVideoInfo->frame_buf,pRtpHandle->pShmVideoInfo->frame_size);
vbuffer = gst_app_buffer_new(raw_buffer, BUFFER_SIZE, g_free, raw_buffer);
gst_buffer_set_caps(vbuffer, gst_caps_from_string(video_caps));
GST_BUFFER_TIMESTAMP(vbuffer) =
(GstClockTime) ((num_frame / 30.0) * 1e9);
num_frame++;
/* push new buffer */
g_signal_emit_by_name(appsrc, "push-buffer", vbuffer, &ret);
gst_buffer_unref(vbuffer);
}

static gboolean on_pipeline_message(GstBus * bus, GstMessage * message, gpointer data)
{
GMainLoop *loop = (GMainLoop *) data;

switch (GST_MESSAGE_TYPE(message)) {
case GST_MESSAGE_EOS:
g_print("Received End of Stream message\n");
g_main_loop_quit(loop);
break;
case GST_MESSAGE_ERROR:
g_print("Received error\n");
g_main_loop_quit(loop);
break;
default:
break;
}
return TRUE;
}

int store(GS_Server_RtpHandle *pRtpHandle)
{
gchar *string = NULL;
GMainLoop *loop = NULL;
GstBus *bus = NULL;
GstElement *appsrc = NULL, *pipeline = NULL;


loop = g_main_loop_new(NULL, FALSE);

/* setting up pipeline, we push video data into this pipeline that will
* then be recorded to an avi file*/
string = g_strdup_printf("appsrc is-live=true name=source "
"caps=\"%s\" ! h264parse ! queue ! avimux ! "
"queue ! filesink location=test.avi", video_caps);
pipeline = gst_parse_launch(string, NULL);
g_free(string);

if (pipeline == NULL) {
g_print("Bad pipeline\n");
return -1;
}

appsrc = gst_bin_get_by_name(GST_BIN(pipeline), "source");
g_object_set(appsrc, "format", GST_FORMAT_TIME, NULL);
gst_app_src_set_max_bytes((GstAppSrc *) appsrc,
QUEUED_FRAMES * BUFFER_SIZE);
g_object_set(appsrc, "block", TRUE, NULL);

/* add watch for messages */
bus = gst_element_get_bus(pipeline);
gst_bus_add_watch(bus, (GstBusFunc) on_pipeline_message, loop);
gst_object_unref(bus);

/* configure the appsrc, we will push data into the appsrc from the
* mainloop */
g_signal_connect(appsrc, "need-data", G_CALLBACK(start_feed), pRtpHandle);

/* go to playing and wait in a mainloop */
gst_element_set_state(pipeline, GST_STATE_PLAYING);

/* this mainloop is stopped when we receive an error or EOS */
g_print("Creating movie...\n");
g_main_loop_run(loop);
g_print("Done.\n");

gst_app_src_end_of_stream(GST_APP_SRC(appsrc));

gst_element_set_state(pipeline, GST_STATE_NULL);

/* Cleaning up */
gst_object_unref(appsrc);
gst_object_unref(pipeline);
g_main_loop_unref(loop);

return 0;
}
~
 
  


Reply

Tags
avi, container


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] gstreamer-plugins-base conflicts with gstreamer-plugins-good Raveolution Linux - Software 14 11-17-2009 12:24 PM
What actually is Gstreamer ? michalng Debian 6 05-03-2009 03:13 AM
What is Gstreamer ? michalng Linux - Newbie 2 03-29-2009 07:15 AM
gstreamer ranacse05 Suse/Novell 1 10-26-2007 03:22 PM
gstreamer how to rem1986 Programming 2 01-02-2006 12:25 PM


All times are GMT -5. The time now is 09:43 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration