## GstBufferStraw

GstBufferStraw — Buffer interception code for GStreamer unit tests

## Synopsis

    #include <gst/check/gstbufferstraw.h>

    void                gst_buffer_straw_start_pipeline     (GstElement *bin,
                                                             GstPad *pad);
    GstBuffer*          gst_buffer_straw_get_buffer         (GstElement *bin,
                                                             GstPad *pad);
    void                gst_buffer_straw_stop_pipeline      (GstElement *bin,
                                                             GstPad *pad);

## Description

These macros and functions are for internal use of the unit tests found inside the 'check' directories of various GStreamer packages.

## Details

### gst_buffer_straw_start_pipeline ()

    void                gst_buffer_straw_start_pipeline     (GstElement *bin,
                                                             GstPad *pad);

Sets up a pipeline for buffer sucking. This will allow you to call `gst_buffer_straw_get_buffer()` to access buffers as they pass over `pad`.

This function is normally used in unit tests that want to verify that a particular element is outputting correct buffers. For example, you would make a pipeline via `gst_parse_launch()`, pull out the pad you want to monitor, then call `gst_buffer_straw_get_buffer()` to get the buffers that pass through `pad`. The pipeline will block until you have sucked off the buffers.

This function will set the state of `bin` to PLAYING; to clean up, be sure to call `gst_buffer_straw_stop_pipeline()`.

Note that you may not start two buffer straws at the same time. This function is intended for unit tests, not general API use. In fact it calls fail_if from libcheck, so you cannot use it outside unit tests.

`bin` : | the pipeline to run
`pad` : | a pad on an element in `bin`

### gst_buffer_straw_get_buffer ()

    GstBuffer*          gst_buffer_straw_get_buffer         (GstElement *bin,
                                                             GstPad *pad);

Get one buffer from `pad`. Implemented via buffer probes. This function will block until the pipeline passes a buffer over `pad`, so for robust behavior in unit tests, you need to use check's timeout to fail out in the case that a buffer never arrives.

You must have previously called `gst_buffer_straw_start_pipeline()` on `pipeline` and `pad`.

`bin` : | the pipeline previously started via `gst_buffer_straw_start_pipeline()`
`pad` : | the pad previously passed to `gst_buffer_straw_start_pipeline()`
Returns : | the captured GstBuffer.

### gst_buffer_straw_stop_pipeline ()

    void                gst_buffer_straw_stop_pipeline      (GstElement *bin,
                                                             GstPad *pad);

Set `bin` to GST_STATE_NULL and release resource allocated in `gst_buffer_straw_start_pipeline()`.

You must have previously called `gst_buffer_straw_start_pipeline()` on `pipeline` and `pad`.

`bin` : | the pipeline previously started via `gst_buffer_straw_start_pipeline()`
`pad` : | the pad previously passed to `gst_buffer_straw_start_pipeline()`