GstRtsp.RTSPConnection

Fields

None

Methods

class

accept (socket, cancellable)

class

create (url)

class

create_from_socket (socket, ip, port, initial_buffer)

clear_auth_params ()

close ()

connect (timeout)

connect_usec (timeout)

connect_with_response (timeout, response)

connect_with_response_usec (timeout, response)

do_tunnel (conn2)

flush (flush)

free ()

get_ignore_x_server_reply ()

get_ip ()

get_read_socket ()

get_remember_session_id ()

get_tls ()

get_tls_database ()

get_tls_interaction ()

get_tls_validation_flags ()

get_tunnelid ()

get_url ()

get_write_socket ()

is_tunneled ()

next_timeout (timeout)

next_timeout_usec ()

poll (events, timeout)

poll_usec (events, timeout)

read (data, timeout)

read_usec (data, timeout)

receive (message, timeout)

receive_usec (message, timeout)

reset_timeout ()

send (message, timeout)

send_messages (messages, timeout)

send_messages_usec (messages, timeout)

send_usec (message, timeout)

set_accept_certificate_func (func, *user_data)

set_auth (method, user, pass_)

set_auth_param (param, value)

set_content_length_limit (limit)

set_http_mode (enable)

set_ignore_x_server_reply (ignore)

set_ip (ip)

set_proxy (host, port)

set_qos_dscp (qos_dscp)

set_remember_session_id (remember)

set_tls_database (database)

set_tls_interaction (interaction)

set_tls_validation_flags (flags)

set_tunneled (tunneled)

write (data, timeout)

write_usec (data, timeout)

Details

class GstRtsp.RTSPConnection

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

classmethod accept(socket, cancellable)
Parameters:
Returns:

GstRtsp.RTSPResult.OK when conn contains a valid connection.

conn:

storage for a GstRtsp.RTSPConnection

Return type:

(GstRtsp.RTSPResult, conn: GstRtsp.RTSPConnection or None)

Accept a new connection on socket and create a new GstRtsp.RTSPConnection for handling communication on new socket.

classmethod create(url)
Parameters:

url (GstRtsp.RTSPUrl) – a GstRtsp.RTSPUrl

Returns:

GstRtsp.RTSPResult.OK when conn contains a valid connection.

conn:

storage for a GstRtsp.RTSPConnection

Return type:

(GstRtsp.RTSPResult, conn: GstRtsp.RTSPConnection)

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

A copy of url will be made.

classmethod create_from_socket(socket, ip, port, initial_buffer)
Parameters:
  • socket (Gio.Socket) – a Gio.Socket

  • ip (str) – the IP address of the other end

  • port (int) – the port used by the other end

  • initial_buffer (str) – GstRtsp.data already read from fd

Returns:

GstRtsp.RTSPResult.OK when conn contains a valid connection.

conn:

storage for a GstRtsp.RTSPConnection

Return type:

(GstRtsp.RTSPResult, conn: GstRtsp.RTSPConnection or None)

Create a new GstRtsp.RTSPConnection for handling communication on the existing socket socket. The initial_buffer contains zero terminated GstRtsp.data already read from socket which should be used before starting to read new GstRtsp.data.

clear_auth_params()

Clear the list of authentication directives stored in self.

close()
Returns:

GstRtsp.RTSPResult.OK on success.

Return type:

GstRtsp.RTSPResult

Close the connected self. After this call, the connection is in the same state as when it was first created.

connect(timeout)
Parameters:

timeout (GLib.TimeVal) – a GLib.TimeVal timeout

Returns:

GstRtsp.RTSPResult.OK when a connection could be made.

Return type:

GstRtsp.RTSPResult

Attempt to connect to the url of self made with GstRtsp.RTSPConnection.create(). If timeout is None this function can block forever. If timeout contains a valid timeout, this function will return GstRtsp.RTSPResult.ETIMEOUT after the timeout expired.

This function can be cancelled with GstRtsp.RTSPConnection.flush().

Deprecated since version 1.18.

connect_usec(timeout)
Parameters:

timeout (int) – a timeout in microseconds

Returns:

GstRtsp.RTSPResult.OK when a connection could be made.

Return type:

GstRtsp.RTSPResult

Attempt to connect to the url of self made with GstRtsp.RTSPConnection.create(). If timeout is 0 this function can block forever. If timeout contains a valid timeout, this function will return GstRtsp.RTSPResult.ETIMEOUT after the timeout expired.

This function can be cancelled with GstRtsp.RTSPConnection.flush().

New in version 1.18.

connect_with_response(timeout, response)
Parameters:
Returns:

GstRtsp.RTSPResult.OK when a connection could be made.

Return type:

GstRtsp.RTSPResult

Attempt to connect to the url of self made with GstRtsp.RTSPConnection.create(). If timeout is None this function can block forever. If timeout contains a valid timeout, this function will return GstRtsp.RTSPResult.ETIMEOUT after the timeout expired. If self is set to tunneled, response will contain a GstRtsp.response to the tunneling GstRtsp.request messages.

This function can be cancelled with GstRtsp.RTSPConnection.flush().

New in version 1.8.

Deprecated since version 1.18.

connect_with_response_usec(timeout, response)
Parameters:
Returns:

GstRtsp.RTSPResult.OK when a connection could be made.

Return type:

GstRtsp.RTSPResult

Attempt to connect to the url of self made with GstRtsp.RTSPConnection.create(). If timeout is 0 this function can block forever. If timeout contains a valid timeout, this function will return GstRtsp.RTSPResult.ETIMEOUT after the timeout expired. If self is set to tunneled, response will contain a GstRtsp.response to the tunneling GstRtsp.request messages.

This function can be cancelled with GstRtsp.RTSPConnection.flush().

New in version 1.18.

do_tunnel(conn2)
Parameters:

conn2 (GstRtsp.RTSPConnection or None) – a GstRtsp.RTSPConnection or None

Returns:

return GstRtsp.RTSPResult.OK on success.

Return type:

GstRtsp.RTSPResult

If self received the first tunnel connection and conn2 received the second tunnel connection, link the two connections together so that self manages the tunneled connection.

After this call, conn2 cannot be used anymore and must be freed with GstRtsp.RTSPConnection.free().

If conn2 is None then only the base64 decoding context will be setup for self.

flush(flush)
Parameters:

flush (bool) – start or stop the flush

Returns:

GstRtsp.RTSPResult.OK.

Return type:

GstRtsp.RTSPResult

Start or stop the flushing action on self. When flushing, all current and future actions on self will return GstRtsp.RTSPResult.EINTR until the connection is set to non-flushing mode again.

free()
Returns:

GstRtsp.RTSPResult.OK on success.

Return type:

GstRtsp.RTSPResult

Close and free self.

get_ignore_x_server_reply()
Returns:

returns True if the x-server-ip-address header reply will be ignored, else returns False

Return type:

bool

Get the ignore_x_server_reply value.

New in version 1.20.

get_ip()
Returns:

The IP address as a string. this value remains valid until the connection is closed.

Return type:

str

Retrieve the IP address of the other end of self.

get_read_socket()
Returns:

the file descriptor used for reading or None on error. The file descriptor remains valid until the connection is closed.

Return type:

Gio.Socket or None

Get the file descriptor for reading.

get_remember_session_id()
Returns:

True if the GstRtsp.RTSPConnection remembers the session id in the last GstRtsp.response to set it on any further GstRtsp.request.

Return type:

bool

get_tls()
Raises:

GLib.Error

Returns:

the TLS connection for self.

Return type:

Gio.TlsConnection

Get the TLS connection of self.

For client side this will return the Gio.TlsClientConnection when connected over TLS.

For server side connections, this function will create a Gio.TlsServerConnection when called the first time and will return that same connection on subsequent calls. The server is then responsible for configuring the TLS connection.

New in version 1.2.

get_tls_database()
Returns:

the anchor certificate authorities database, or None if no database has been previously set. Use GObject.Object.unref() to release the certificate database.

Return type:

Gio.TlsDatabase or None

Gets the anchor certificate authorities database that will be used after a server certificate can’t be verified with the default certificate database.

New in version 1.4.

get_tls_interaction()
Returns:

a reference on the Gio.TlsInteraction. Use GObject.Object.unref() to release.

Return type:

Gio.TlsInteraction or None

Gets a Gio.TlsInteraction object to be used when the connection or certificate database need to interact with the user. This will be used to prompt the user for passwords where necessary.

New in version 1.6.

get_tls_validation_flags()
Returns:

the validation flags.

Return type:

Gio.TlsCertificateFlags

Gets the TLS validation flags used to verify the peer certificate when a TLS connection is established.

GLib guarantees that if certificate verification fails, at least one error will be set, but it does not guarantee that all possible errors will be set. Accordingly, you may not safely decide to ignore any particular type of error.

For example, it would be incorrect to ignore Gio.TlsCertificateFlags.EXPIRED if you want to allow expired certificates, because this could potentially be the only error flag set even if other problems exist with the certificate.

New in version 1.2.1.

get_tunnelid()
Returns:

returns a non-empty string if self is being tunneled over HTTP.

Return type:

str or None

Get the tunnel session id the connection.

get_url()
Returns:

The URL. This value remains valid until the connection is freed.

Return type:

GstRtsp.RTSPUrl

Retrieve the URL of the other end of self.

get_write_socket()
Returns:

the file descriptor used for writing or None on error. The file descriptor remains valid until the connection is closed.

Return type:

Gio.Socket or None

Get the file descriptor for writing.

is_tunneled()
Returns:

if self is using HTTP tunneling.

Return type:

bool

Get the tunneling state of the connection.

next_timeout(timeout)
Parameters:

timeout (GLib.TimeVal) – a timeout

Returns:

GstRtsp.RTSPResult.OK.

Return type:

GstRtsp.RTSPResult

Calculate the next timeout for self, storing the result in timeout.

Deprecated since version 1.18.

next_timeout_usec()
Returns:

#the next timeout in microseconds

Return type:

int

Calculate the next timeout for self

New in version 1.18.

poll(events, timeout)
Parameters:
Returns:

GstRtsp.RTSPResult.OK on success.

revents:

location for result flags

Return type:

(GstRtsp.RTSPResult, revents: GstRtsp.RTSPEvent)

Wait up to the specified timeout for the connection to become available for at least one of the operations specified in events. When the function returns with GstRtsp.RTSPResult.OK, revents will contain a bitmask of available operations on self.

timeout can be None, in which case this function might block forever.

This function can be cancelled with GstRtsp.RTSPConnection.flush().

Deprecated since version 1.18.

poll_usec(events, timeout)
Parameters:
Returns:

GstRtsp.RTSPResult.OK on success.

revents:

location for result flags

Return type:

(GstRtsp.RTSPResult, revents: GstRtsp.RTSPEvent)

Wait up to the specified timeout for the connection to become available for at least one of the operations specified in events. When the function returns with GstRtsp.RTSPResult.OK, revents will contain a bitmask of available operations on self.

timeout can be 0, in which case this function might block forever.

This function can be cancelled with GstRtsp.RTSPConnection.flush().

New in version 1.18.

read(data, timeout)
Parameters:
Returns:

GstRtsp.RTSPResult.OK on success.

Return type:

GstRtsp.RTSPResult

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

This function can be cancelled with GstRtsp.RTSPConnection.flush().

Deprecated since version 1.18.

read_usec(data, timeout)
Parameters:
  • data (bytes) – the GstRtsp.data to read

  • timeout (int) – a timeout value in microseconds

Returns:

GstRtsp.RTSPResult.OK on success.

Return type:

GstRtsp.RTSPResult

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

This function can be cancelled with GstRtsp.RTSPConnection.flush().

New in version 1.18.

receive(message, timeout)
Parameters:
Returns:

GstRtsp.RTSPResult.OK on success.

Return type:

GstRtsp.RTSPResult

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

This function can be cancelled with GstRtsp.RTSPConnection.flush().

Deprecated since version 1.18.

receive_usec(message, timeout)
Parameters:
Returns:

GstRtsp.RTSPResult.OK on success.

Return type:

GstRtsp.RTSPResult

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

This function can be cancelled with GstRtsp.RTSPConnection.flush().

New in version 1.18.

reset_timeout()
Returns:

GstRtsp.RTSPResult.OK.

Return type:

GstRtsp.RTSPResult

Reset the timeout of self.

send(message, timeout)
Parameters:
Returns:

GstRtsp.RTSPResult.OK on success.

Return type:

GstRtsp.RTSPResult

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

This function can be cancelled with GstRtsp.RTSPConnection.flush().

Deprecated since version 1.18.

send_messages(messages, timeout)
Parameters:
Returns:

GstRtsp.RTSPResult.OK on success.

Return type:

GstRtsp.RTSPResult

Attempt to send messages to the connected self, blocking up to the specified timeout. timeout can be None, in which case this function might block forever.

This function can be cancelled with GstRtsp.RTSPConnection.flush().

New in version 1.16.

Deprecated since version 1.18.

send_messages_usec(messages, timeout)
Parameters:
Returns:

GstRtsp.RTSPResult.OK on Since.

Return type:

GstRtsp.RTSPResult

Attempt to send messages to the connected self, blocking up to the specified timeout. timeout can be 0, in which case this function might block forever.

This function can be cancelled with GstRtsp.RTSPConnection.flush().

New in version 1.18.

send_usec(message, timeout)
Parameters:
Returns:

GstRtsp.RTSPResult.OK on success.

Return type:

GstRtsp.RTSPResult

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

This function can be cancelled with GstRtsp.RTSPConnection.flush().

New in version 1.18.

set_accept_certificate_func(func, *user_data)
Parameters:

Sets a custom accept-certificate function for checking certificates for validity. This will directly map to Gio.TlsConnection ‘s “accept-certificate” signal and be performed after the default checks of GstRtsp.RTSPConnection (checking against the Gio.TlsDatabase with the given Gio.TlsCertificateFlags) have failed. If no Gio.TlsDatabase is set on this connection, only func will be called.

New in version 1.14.

set_auth(method, user, pass_)
Parameters:
Returns:

GstRtsp.RTSPResult.OK.

Return type:

GstRtsp.RTSPResult

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

set_auth_param(param, value)
Parameters:
  • param (str) – authentication directive

  • value (str) – value

Setup self with authentication directives. This is not necessary for methods GstRtsp.RTSPAuthMethod.NONE and GstRtsp.RTSPAuthMethod.BASIC. For GstRtsp.RTSPAuthMethod.DIGEST, directives should be taken from the digest challenge in the WWW-Authenticate GstRtsp.response header and can include realm, domain, nonce, opaque, stale, algorithm, qop as per RFC2617.

set_content_length_limit(limit)
Parameters:

limit (int) – Content-Length limit

Configure self to use the specified Content-Length limit. Both requests and responses are validated. If content-length is exceeded, ENOMEM error will be returned.

New in version 1.18.

set_http_mode(enable)
Parameters:

enable (bool) – True to enable manual HTTP mode

By setting the HTTP mode to True the message parsing will support HTTP messages in addition to the RTSP messages. It will also disable the automatic handling of setting up an HTTP tunnel.

set_ignore_x_server_reply(ignore)
Parameters:

ignore (bool) – True to ignore the x-server-ip-address header reply or False to comply with it (False is the default).

Set whether to ignore the x-server-ip-address header reply or not. If the header is ignored, the original address will be used instead.

New in version 1.20.

set_ip(ip)
Parameters:

ip (str) – an ip address

Set the IP address of the server.

set_proxy(host, port)
Parameters:
  • host (str) – the proxy host

  • port (int) – the proxy port

Returns:

GstRtsp.RTSPResult.OK.

Return type:

GstRtsp.RTSPResult

Set the proxy host and port.

set_qos_dscp(qos_dscp)
Parameters:

qos_dscp (int) – DSCP value

Returns:

GstRtsp.RTSPResult.OK on success.

Return type:

GstRtsp.RTSPResult

Configure self to use the specified DSCP value.

set_remember_session_id(remember)
Parameters:

remember (bool) – True if the connection should remember the session id

Sets if the GstRtsp.RTSPConnection should remember the session id from the last GstRtsp.response received and force it onto any further requests.

The default value is True

set_tls_database(database)
Parameters:

database (Gio.TlsDatabase or None) – a Gio.TlsDatabase

Sets the anchor certificate authorities database. This certificate database will be used to verify the server’s certificate in case it can’t be verified with the default certificate database first.

New in version 1.4.

set_tls_interaction(interaction)
Parameters:

interaction (Gio.TlsInteraction or None) – a Gio.TlsInteraction

Sets a Gio.TlsInteraction object to be used when the connection or certificate database need to interact with the user. This will be used to prompt the user for passwords where necessary.

New in version 1.6.

set_tls_validation_flags(flags)
Parameters:

flags (Gio.TlsCertificateFlags) – the validation flags.

Returns:

True if the validation flags are set correctly, or False if self is None or is not a TLS connection.

Return type:

bool

Sets the TLS validation flags to be used to verify the peer certificate when a TLS connection is established.

GLib guarantees that if certificate verification fails, at least one error will be set, but it does not guarantee that all possible errors will be set. Accordingly, you may not safely decide to ignore any particular type of error.

For example, it would be incorrect to mask Gio.TlsCertificateFlags.EXPIRED if you want to allow expired certificates, because this could potentially be the only error flag set even if other problems exist with the certificate.

New in version 1.2.1.

set_tunneled(tunneled)
Parameters:

tunneled (bool) – the new state

Set the HTTP tunneling state of the connection. This must be configured before the self is connected.

write(data, timeout)
Parameters:
Returns:

GstRtsp.RTSPResult.OK on success.

Return type:

GstRtsp.RTSPResult

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

This function can be cancelled with GstRtsp.RTSPConnection.flush().

Deprecated since version 1.18.

write_usec(data, timeout)
Parameters:
  • data (bytes) – the GstRtsp.data to write

  • timeout (int) – a timeout value or 0

Returns:

GstRtsp.RTSPResult.OK on success.

Return type:

GstRtsp.RTSPResult

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

This function can be cancelled with GstRtsp.RTSPConnection.flush().

New in version 1.18.