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