[gst-devel] how to display/grap frames for displaying them ??
Alexander Bierbrauer
abierbrauer at gmx.org
Thu Jan 13 14:07:05 CET 2005
Hi people,
I'm trying to figure out all the GStreamer stuff lately. At present, I can
create a pipeline to decode a vid and update the corresponding bin. But how
can I display / grab the frame data so that I can preview it for example on a
widget of a toolkit ??
I've checked different programs and source codes how they are doing it but I
couldn't figure it out yet. Could anyone please help out ??
Bye, Alex
--------------------
PS: Here's my initialization code so far:
void GStreamer::initialize()
{
/* initializing GStreamer */
if(!gst_init_check(NULL, NULL))
{
printf("failed to initialize GStreamer for some reason\n");
return;
}
printf("initialized GStreamer\n");
/* create a new bin to hold the elements */
m_pPipeline = gst_pipeline_new ("pipeline");
if(m_pPipeline == NULL)
{
printf("failed to create GStreamer pipeline\n");
return;
}
printf("created GStreamer pipeline\n");
/* create a disk reader */
m_pFileSrc = gst_element_factory_make ("filesrc", "disk_source");
if(m_pFileSrc == NULL)
{
printf("failed to create GStreamer file source\n");
return;
}
printf("created GStreamer file source\n");
/* typefinder four filesrc */
m_pTypeFind = gst_element_factory_make ("typefind", "typefind");
//g_signal_connect (G_OBJECT (filesrc), "eos", G_CALLBACK (eos), thread);
/* creating our avi muxer */
m_pAviMux = gst_element_factory_make("avimux","avisrc");
if(m_pAviMux == NULL)
{
printf("failed to create GStreamer avi muxer");
return;
}
printf("created GStreamer avi mux\n");
/* creating queue */
m_pQueue = gst_element_factory_make("queue","queue");
if(m_pQueue == NULL)
{
printf("failed to create GStreamer queue\n");
return;
}
printf("created GStreamer queue\n");
/* now we add all elements to our pipeline */
gst_bin_add_many (GST_BIN (m_pPipeline), m_pFileSrc, m_pTypeFind, m_pAviMux,
m_pQueue, NULL);
/* now let's link all elements together */
if(!gst_element_link_many (m_pFileSrc, m_pTypeFind, m_pAviMux,
m_pQueue,NULL))
{
printf("failed to link GStreamer elements\n");
return;
}
printf("linked succesfully GStreamer elements\n");
/* let's set it ready */
gst_element_set_state (GST_ELEMENT (m_pPipeline), GST_STATE_READY);
m_bInitialized = true;
}
void GStreamer::shutdown()
{
if(isPlaying())
stopPlaying();
m_bInitialized = false;
}
/**
* sets the video source for the GstElement file source
**/
void GStreamer::setVideoSource(QString src)
{
if(!src || src.length() <= 0)
return;
g_object_set (G_OBJECT (m_pFileSrc), "location", src.ascii(), NULL);
printf("GStreamer file source location is: %s\n",src.ascii());
}
void GStreamer::startPlaying()
{
gst_element_set_state (GST_ELEMENT (m_pPipeline), GST_STATE_PLAYING);
printf("playing GStreamer\n");
}
void GStreamer::pausePlaying()
{
gst_element_set_state (GST_ELEMENT (m_pPipeline), GST_STATE_PAUSED);
printf("pauses GStreamer\n");
}
void GStreamer::stopPlaying()
{
gst_element_set_state (GST_ELEMENT (m_pPipeline), GST_STATE_NULL);
printf("stopped GStreamer\n");
}
bool GStreamer::isPlaying()
{
if(gst_element_get_state(GST_ELEMENT(m_pPipeline)) == GST_STATE_PLAYING)
return true;
return false;
}
/**
* call this method every frame to update the pipeline
**/
void GStreamer::update()
{
gst_bin_iterate (GST_BIN (m_pPipeline));
}
More information about the gstreamer-devel
mailing list