Using the GstAutoplugCache element

The GstAutoplugCache element is used to cache the media stream when performing typedetection. As we have have seen in the previous chapter (typedetection), the type typefind function consumes a buffer to determine the media type of it. After we have set up the pipeline to play the media stream we should be able to 'replay' the previous buffer(s). This is where the autoplugcache is used for.

The basic usage pattern for the autoplugcache in combination with the typefind element is like this:

  1. Add the autoplugcache element to a bin and link the sink pad to the source pad of an element with unknown caps.

  2. Link the source pad of the autoplugcache to the sink pad of the typefind element.

  3. Iterate the pipeline until the typefind element has found a type.

  4. Remove the typefind element and add the plugins needed to play back the discovered media type to the autoplugcache source pad.

  5. Reset the cache to start playback of the cached data. Connect to the "cache_empty" signal.

  6. In the cache_empty signal callback function, remove the autoplugcache and relink the pads.

In the next chapter we will create a new version of our helloworld example using the autoplugger, the autoplugcache and the typefind element.