## gstrtspconnection gstrtspconnection — manage RTSP connections |

## Synopsis

    #include <gst/rtsp/gstrtspconnection.h>

                        GstRTSPConnection;
    GstRTSPResult       gst_rtsp_connection_create          (GstRTSPUrl *url,
                                                             GstRTSPConnection **conn);
    GstRTSPResult       gst_rtsp_connection_connect         (GstRTSPConnection *conn,
                                                             GTimeVal *timeout);
    GstRTSPResult       gst_rtsp_connection_close           (GstRTSPConnection *conn);
    GstRTSPResult       gst_rtsp_connection_free            (GstRTSPConnection *conn);
    GstRTSPResult       gst_rtsp_connection_read            (GstRTSPConnection *conn,
                                                             guint8 *data,
                                                             guint size,
                                                             GTimeVal *timeout);
    GstRTSPResult       gst_rtsp_connection_write           (GstRTSPConnection *conn,
                                                             const guint8 *data,
                                                             guint size,
                                                             GTimeVal *timeout);
    GstRTSPResult       gst_rtsp_connection_send            (GstRTSPConnection *conn,
                                                             GstRTSPMessage *message,
                                                             GTimeVal *timeout);
    GstRTSPResult       gst_rtsp_connection_receive         (GstRTSPConnection *conn,
                                                             GstRTSPMessage *message,
                                                             GTimeVal *timeout);
    GstRTSPResult       gst_rtsp_connection_next_timeout    (GstRTSPConnection *conn,
                                                             GTimeVal *timeout);
    GstRTSPResult       gst_rtsp_connection_reset_timeout   (GstRTSPConnection *conn);
    GstRTSPResult       gst_rtsp_connection_flush           (GstRTSPConnection *conn,
                                                             gboolean flush);
    GstRTSPResult       gst_rtsp_connection_set_auth        (GstRTSPConnection *conn,
                                                             GstRTSPAuthMethod method,
                                                             const gchar *user,
                                                             const gchar *pass);

## Description

This object manages the RTSP connection to the server. It provides function to receive and send bytes and messages.

Last reviewed on 2007-07-24 (0.10.14)

## Details

### GstRTSPConnection

    typedef struct {
    } GstRTSPConnection;

Opaque RTSP connection object.

### gst_rtsp_connection_create ()

    GstRTSPResult       gst_rtsp_connection_create          (GstRTSPUrl *url,
                                                             GstRTSPConnection **conn);

Create a newly allocated GstRTSPConnection from `url` and store it in `conn`. The connection will not yet attempt to connect to `url`, use `gst_rtsp_connection_connect()`.

`url` : | a GstRTSPUrl
`conn` : | a GstRTSPConnection
Returns : | GST_RTSP_OK when `conn` contains a valid connection.

### gst_rtsp_connection_connect ()

    GstRTSPResult       gst_rtsp_connection_connect         (GstRTSPConnection *conn,
                                                             GTimeVal *timeout);

Attempt to connect to the url of `conn` made with `gst_rtsp_connection_create()`. If `timeout` is NULL this function can block forever. If `timeout` contains a valid timeout, this function will return GST_RTSP_ETIMEOUT after the timeout expired.

`conn` : | a GstRTSPConnection
`timeout` : | a GTimeVal timeout
Returns : | GST_RTSP_OK when a connection could be made.

### gst_rtsp_connection_close ()

    GstRTSPResult       gst_rtsp_connection_close           (GstRTSPConnection *conn);

Close the connected `conn`.

`conn` : | a GstRTSPConnection
Returns : | GST_RTSP_OK on success.

### gst_rtsp_connection_free ()

    GstRTSPResult       gst_rtsp_connection_free            (GstRTSPConnection *conn);

Close and free `conn`.

`conn` : | a GstRTSPConnection
Returns : | GST_RTSP_OK on success.

### gst_rtsp_connection_read ()

    GstRTSPResult       gst_rtsp_connection_read            (GstRTSPConnection *conn,
                                                             guint8 *data,
                                                             guint size,
                                                             GTimeVal *timeout);

Attempt to read `size` bytes into `data` from the connected `conn`, blocking up to the specified `timeout`. `timeout` can be NULL, in which case this function might block forever.

This function can be canceled with `gst_rtsp_connection_flush()`.

`conn` : | a GstRTSPConnection
`data` : | the data to read
`size` : | the size of `data`
`timeout` : | a timeout value or NULL
Returns : | GST_RTSP_OK on success.

### gst_rtsp_connection_write ()

    GstRTSPResult       gst_rtsp_connection_write           (GstRTSPConnection *conn,
                                                             const guint8 *data,
                                                             guint size,
                                                             GTimeVal *timeout);

Attempt to write `size` bytes of `data` to the connected `conn`, blocking up to the specified `timeout`. `timeout` can be NULL, in which case this function might block forever.

This function can be canceled with `gst_rtsp_connection_flush()`.

`conn` : | a GstRTSPConnection
`data` : | the data to write
`size` : | the size of `data`
`timeout` : | a timeout value or NULL
Returns : | GST_RTSP_OK on success.

### gst_rtsp_connection_send ()

    GstRTSPResult       gst_rtsp_connection_send            (GstRTSPConnection *conn,
                                                             GstRTSPMessage *message,
                                                             GTimeVal *timeout);

Attempt to send `message` to the connected `conn`, blocking up to the specified `timeout`. `timeout` can be NULL, in which case this function might block forever.

This function can be canceled with `gst_rtsp_connection_flush()`.

`conn` : | a GstRTSPConnection
`message` : | the message to send
`timeout` : | a timeout value or NULL
Returns : | GST_RTSP_OK on success.

### gst_rtsp_connection_receive ()

    GstRTSPResult       gst_rtsp_connection_receive         (GstRTSPConnection *conn,
                                                             GstRTSPMessage *message,
                                                             GTimeVal *timeout);

Attempt to read into `message` from the connected `conn`, blocking up to the specified `timeout`. `timeout` can be NULL, in which case this function might block forever.

This function can be canceled with `gst_rtsp_connection_flush()`.

`conn` : | a GstRTSPConnection
`message` : | the message to read
`timeout` : | a timeout value or NULL
Returns : | GST_RTSP_OK on success.

### gst_rtsp_connection_next_timeout ()

    GstRTSPResult       gst_rtsp_connection_next_timeout    (GstRTSPConnection *conn,
                                                             GTimeVal *timeout);

Calculate the next timeout for `conn`, storing the result in `timeout`.

`conn` : | a GstRTSPConnection
`timeout` : | a timeout
Returns : | GST_RTSP_OK.

### gst_rtsp_connection_reset_timeout ()

    GstRTSPResult       gst_rtsp_connection_reset_timeout   (GstRTSPConnection *conn);

Reset the timeout of `conn`.

`conn` : | a GstRTSPConnection
Returns : | GST_RTSP_OK.

### gst_rtsp_connection_flush ()

    GstRTSPResult       gst_rtsp_connection_flush           (GstRTSPConnection *conn,
                                                             gboolean flush);

Start or stop the flushing action on `conn`. When flushing, all current and future actions on `conn` will return GST_RTSP_EINTR until the connection is set to non-flushing mode again.

`conn` : | a GstRTSPConnection
`flush` : | start or stop the flush
Returns : | GST_RTSP_OK.

### gst_rtsp_connection_set_auth ()

    GstRTSPResult       gst_rtsp_connection_set_auth        (GstRTSPConnection *conn,
                                                             GstRTSPAuthMethod method,
                                                             const gchar *user,
                                                             const gchar *pass);

Configure `conn` for authentication mode `method` with `user` and `pass` as the user and password respectively.

`conn` : | a GstRTSPConnection
`method` : | authentication method
`user` : | the user
`pass` : | the password
Returns : | GST_RTSP_OK.

## See Also

gstrtspurl