LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   gstreamer (http://www.linuxquestions.org/questions/programming-9/gstreamer-803263/)

puneeth bhat 04-21-2010 06:29 AM

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;
}
~


All times are GMT -5. The time now is 11:38 AM.