## SwfdecStream SwfdecStream — object used for input |

## Synopsis

    #include <swfdec/swfdec.h>

                        SwfdecStream;
                        SwfdecStreamClass;
    gboolean            swfdec_stream_is_open               (SwfdecStream *stream);
    gboolean            swfdec_stream_is_complete           (SwfdecStream *stream);
    void                swfdec_stream_open                  (SwfdecStream *stream);
    void                swfdec_stream_push                  (SwfdecStream *stream,
                                                             SwfdecBuffer *buffer);
    void                swfdec_stream_close                 (SwfdecStream *stream);
    void                swfdec_stream_error                 (SwfdecStream *stream,
                                                             const char *error,
                                                             ...);
    void                swfdec_stream_errorv                (SwfdecStream *stream,
                                                             const char *error,
                                                             va_list args);

## Object Hierarchy

      GObject
       +----SwfdecStream
             +----SwfdecLoader
             +----SwfdecSocket

## Properties

      "complete"                 gboolean              : Read
      "error"                    gchar*                : Read
      "open"                     gboolean              : Read

## Description

SwfdecStream is the base class used for communication inside Swfdec. If you are a UNIX developer, think of this class as the equivalent to a file descriptor. SwfdecLoader and SwfdecSocket are the subclasses supposed to be used for files or network sockets, respectively.

This class provides the functions necessary to implement subclasses of streams. None of the functions described in this section should be used by anything but subclass implementations. Consider them "protected".

## Details

### SwfdecStream

    typedef struct _SwfdecStream SwfdecStream;

This is the base object used for providing input. It is abstract, use a subclass to provide your input. All members are considered private.

### SwfdecStreamClass

    typedef struct {
      /* get a nice description string */
      const char *		(* describe)		(SwfdecStream *		stream);
      /* close the stream. */
      void			(* close)		(SwfdecStream *		stream);
    } SwfdecStreamClass;

This is the base class used for providing input. You are supposed to create a subclass that fills in the function pointers mentioned above.

`describe` () | Provide a string describing your string. Default implementations of this function exist for both the SwfdecLoader and SwfdecStream subclasses. They return the URL for the stream.
`close` () | Called when Swfdec requests that the stream be closed. After this function was called, Swfdec will consider the stream finished and will not ever read data from it again.

### swfdec_stream_is_open ()

    gboolean            swfdec_stream_is_open               (SwfdecStream *stream);

Checks if the given `stream` is currrently open. Some functions, for example `swfdec_socket_send()`, require an open stream.

`stream` : | a SwfdecStream
Returns : | `TRUE` if the stream is open, `FALSE` otherwise.

### swfdec_stream_is_complete ()

    gboolean            swfdec_stream_is_complete           (SwfdecStream *stream);

Checks if all data has successfully been transmitted through the `stream` and it has been closed.

`stream` : | a SwfdecStream
Returns : | `TRUE` if the stream is completed, `FALSE` otherwise.

### swfdec_stream_open ()

    void                swfdec_stream_open                  (SwfdecStream *stream);

Call this function when your stream opened the resulting file. For HTTP this is when having received the headers. You must call this function before `swfdec_stream_push()` can be called.

`stream` : | a SwfdecStream

### swfdec_stream_push ()

    void                swfdec_stream_push                  (SwfdecStream *stream,
                                                             SwfdecBuffer *buffer);

Makes the data in `buffer` available to `stream` and processes it. The `stream` must be open.

`stream` : | a SwfdecStream
`buffer` : | new data to make available. The stream takes the reference to the buffer.

### swfdec_stream_close ()

    void                swfdec_stream_close                 (SwfdecStream *stream);

Indicates to `stream` that no more data will follow. The stream must be open.

`stream` : | a SwfdecStream

### swfdec_stream_error ()

    void                swfdec_stream_error                 (SwfdecStream *stream,
                                                             const char *error,
                                                             ...);

Moves the stream in the error state if it wasn't before. A stream that is in the error state will not process any more data. Also, internal error handling scripts may be executed.

`stream` : | a SwfdecStream
`error` : | a printf-style string describing the error
`...` : | arguments for the `error` string

### swfdec_stream_errorv ()

    void                swfdec_stream_errorv                (SwfdecStream *stream,
                                                             const char *error,
                                                             va_list args);

This function is the va_list alternative to `swfdec_stream_error()`. See that function for details.

`stream` : | a SwfdecStream
`error` : | a printf-style error string
`args` : | arguments for `error`

## Property Details

### The `"complete"` property

      "complete"                 gboolean              : Read

TRUE when all data has been transmitted.

Default value: FALSE

### The `"error"` property

      "error"                    gchar*                : Read

NULL when no error or string describing error.

Default value: NULL

### The `"open"` property

      "open"                     gboolean              : Read

TRUE while data is flowing.

Default value: FALSE