f6b21fad821c835e70d6a94f9d089ce02dc04788
[platform/upstream/gstreamer.git] / docs / random / walkthrough
1 You might start by creating a source element and put it into a pipeline.
2 At this point both element's state would be GST_STATE_NEW, since they
3 don't have enough state to actually run yet.  At this point you can set
4 the filename of the source, and possibly bytesperread and other things.
5
6 Then you'd want to discover the data type of the file you're sourcing.
7 This will typically be handled by the pipeline itself by calling
8 gst_pipeline_autoplug(), or gst_pipeline_find_pad_type(), or somesuch. The
9 pipeline would first set its state to GST_STATE_DISCOVERY.  A gstfindtype
10 sink would be added to the pipeline and connected to the source.  Its
11 HAVE_TYPE signal would be connected to a private pipeline function.
12
13 The pipeline would then set the the src state to GST_STATE_DISCOVERY, and
14 call the src's push() function until a the type is set by the function
15 connected to the gstfindtype element's signal.  At this point the pipeline
16 would disconnect the gstfindtype element from the src, set the type of the
17 pad to the type returned by the gstfindtype element.  At disconnection of
18 the find element, the src's state automatically reverts to NEW.
19
20 (The trick with the sources when they do DISCOVERY is that synchronous
21 sources can't go back and read data again.  So perhaps I should set up a
22 wrapper function for the push() function that uses either a sync or
23 async function as provided by the src instance to provide DISCOVERY and
24 normal operations.  It would use a [GstBufferCache] to read ahead into
25 memory if necessary, creating baby buffers as necessary to answer the
26 needs of each DISCOVERY sequence.)
27
28 If you called find_pad_type(), it would return right about now, with the
29 ID of the type it found.  At the same time, if you have connected a signal
30 to the pad's SET_TYPE signal, it would fire right as the type is set by
31 the find_pad_type() function.  This would allow your application to do its
32 own selection of filters to connect to the pad.
33
34 If you called autoplug(), the pipeline would make a selection of element
35 to connect.  The element would be created (state=NEW), added to the
36 pipeline, and the appropriate sink pad connected to the src in question.
37 (Note that multi-sink elements won't be supported unless there's a really
38 good and obvious way to do so)  The whole process would repeat until the
39 recently added element no longer has a src pad.