0bb166b6063582724a6050773d00e687f447c0db
[platform/upstream/gstreamer.git] / docs / random / example
1 Here's a pipeline that does audio/video MPEG streams with a queue on
2 either side of each decompressor, for a total of 5 threads (read/split,
3 decode audio, decode video, play audio, play video):
4
5 NOTES: mpegsplit is the intelligence in this pipeline, providing an IDL
6 that allows one to connect things to a GUI.  
7
8 Pipeline(mpegplay)
9         Thread(reader)
10                 Element(:disk_async_src) [StreamerAsyncSrc]
11                         OutPad(disk1)
12                 Element(:mpegsplit)
13                         InPad(disk1)
14                         OutPad(audio1)
15                         OutPad(video1)
16
17         Queue(audioQ1)
18                 InPad(audio1)
19                 OutPad(audio2)
20         Thread(audiodecode)
21                 Element(:mpeg_audio_decode) [StreamerVideoFilter]
22                         InPad(audio2)
23                         OutPad(audio3)
24         Queue(audioQ2)
25                 InPad(audio3)
26                 OutPad(audio4)
27         Thread(audioplay)
28                 Element(:audio_play) [StreamerAudioSink]
29                         InPad(audio4)
30
31         Queue(videoQ1)
32                 InPad(video1)
33                 OutPad(video2)
34         Thread(videodecode)
35                 Element(:mpeg_video_decode) [StreamerVideoFilter]
36                         InPad(video2)
37                         OutPad(video3)
38         Queue(videoQ2)
39                 InPad(video3)
40                 OutPad(video4)
41         Thread(videoplay)
42                 Element(:video_play) [StreamerVideoSink]
43                         InPad(video4)
44
45
46 A simpler pipeline that just does MPEG videos:
47
48 Pipeline(mpegplay)
49         Thread(reader)
50                 Element(:disk_async_src) [GstAsyncSrc]
51                         OutPad(disk1)
52                 Element(:mpeg_control)
53                         InPad(disk1)
54                         OutPad(video1)
55                 Element(:mpeg_video_decode) [GstVideoFilter]
56                         InPad(video1)
57                         InPad(video2)
58         Queue(queue)
59                 InPad(video2)
60                 OutPad(video3)
61         Thread(play)
62                 Element(:video_play) [GstVideoSink]
63                         InPad(video3)
64
65 The code for the above looks roughly like:
66
67 /* all the objects we're worried about */
68 GstPipeline *mpegplay;
69 GstThread *reader;
70 GstSrc *disk_src;
71 GstControl *mpeg_control;
72 GstFilter *mpeg_video_decode;
73 GstQueue *queue;
74 GstThread *play;
75 GstSink *video_play;
76
77 /*** first we create all of the objects ***/
78
79 mpegplay = gst_pipeline_new();
80 reader = gst_thread_new();
81 disk_src = gst_async_disk_src_new("filename.mpg");
82 mpeg_control = gst_mpeg_control_new();
83 mpeg_video_decode = gst_mpeg_video_decode_new();
84 queue = gst_queue_new();
85 play = gst_thread_new();
86 video_play = gst_video_sink_new();
87
88
89 /*** now we start to create the pipeline ***/
90
91 /* first set up the reader thread */
92 gst_bin_add(reader,disk_src);
93 gst_object_connect(disk_src,"out",mpeg_control,"in");
94 gst_object_connect(mpeg_control,"out",mpeg_audio_decode,"in");
95 gst_bin_ghost_pad(reader,mpeg_audio_decode,"out");
96
97 /* then set up the player thread */
98 gst_bin_add(play,audio_play);
99 gst_bin_ghost_pad(play,audio_play,"in");
100
101 /* now plug them all into the main pipeline */
102 gst_bin_add(mp3play,reader);
103 gst_object_connect(reader,"out",queue,"in");
104 gst_object_connect(queue,"out",play,"in");