gstreamer/docs/random/example

109 lines
2.6 KiB
Text
Raw Normal View History

OUTDATED, methods have different names now
------------------------------------------
Here's a pipeline that does audio/video MPEG streams with a queue on
either side of each decompressor, for a total of 5 threads (read/split,
decode audio, decode video, play audio, play video):
NOTES: mpegsplit is the intelligence in this pipeline, providing an IDL
that allows one to connect things to a GUI.
Pipeline(mpegplay)
Thread(reader)
Element(:disk_async_src) [StreamerAsyncSrc]
OutPad(disk1)
Element(:mpegsplit)
InPad(disk1)
OutPad(audio1)
OutPad(video1)
Queue(audioQ1)
InPad(audio1)
OutPad(audio2)
Thread(audiodecode)
Element(:mpeg_audio_decode) [StreamerVideoFilter]
InPad(audio2)
OutPad(audio3)
Queue(audioQ2)
InPad(audio3)
OutPad(audio4)
Thread(audioplay)
Element(:audio_play) [StreamerAudioSink]
InPad(audio4)
Queue(videoQ1)
InPad(video1)
OutPad(video2)
Thread(videodecode)
Element(:mpeg_video_decode) [StreamerVideoFilter]
InPad(video2)
OutPad(video3)
Queue(videoQ2)
InPad(video3)
OutPad(video4)
Thread(videoplay)
Element(:video_play) [StreamerVideoSink]
InPad(video4)
A simpler pipeline that just does MPEG videos:
Pipeline(mpegplay)
Thread(reader)
Element(:disk_async_src) [GstAsyncSrc]
OutPad(disk1)
Element(:mpeg_control)
InPad(disk1)
OutPad(video1)
Element(:mpeg_video_decode) [GstVideoFilter]
InPad(video1)
InPad(video2)
Queue(queue)
InPad(video2)
OutPad(video3)
Thread(play)
Element(:video_play) [GstVideoSink]
InPad(video3)
The code for the above looks roughly like:
/* all the objects we're worried about */
GstPipeline *mpegplay;
GstThread *reader;
GstSrc *disk_src;
GstControl *mpeg_control;
GstFilter *mpeg_video_decode;
GstQueue *queue;
GstThread *play;
GstSink *video_play;
/*** first we create all of the objects ***/
mpegplay = gst_pipeline_new();
reader = gst_thread_new();
disk_src = gst_async_disk_src_new("filename.mpg");
mpeg_control = gst_mpeg_control_new();
mpeg_video_decode = gst_mpeg_video_decode_new();
queue = gst_queue_new();
play = gst_thread_new();
video_play = gst_video_sink_new();
/*** now we start to create the pipeline ***/
/* first set up the reader thread */
gst_bin_add(reader,disk_src);
gst_object_connect(disk_src,"out",mpeg_control,"in");
gst_object_connect(mpeg_control,"out",mpeg_audio_decode,"in");
gst_bin_ghost_pad(reader,mpeg_audio_decode,"out");
/* then set up the player thread */
gst_bin_add(play,audio_play);
gst_bin_ghost_pad(play,audio_play,"in");
/* now plug them all into the main pipeline */
gst_bin_add(mp3play,reader);
gst_object_connect(reader,"out",queue,"in");
gst_object_connect(queue,"out",play,"in");