GstRtspServer.RTSPServer

g GObject.Object GObject.Object GstRtspServer.RTSPServer GstRtspServer.RTSPServer GObject.Object->GstRtspServer.RTSPServer

Subclasses:

GstRtspServer.RTSPOnvifServer

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

io_func (socket, condition, server)

class

new ()

attach (context)

client_filter (func, *user_data)

create_socket (cancellable)

create_source (cancellable)

get_address ()

get_auth ()

get_backlog ()

get_bound_port ()

get_content_length_limit ()

get_mount_points ()

get_service ()

get_session_pool ()

get_thread_pool ()

set_address (address)

set_auth (auth)

set_backlog (backlog)

set_content_length_limit (limit)

set_mount_points (mounts)

set_service (service)

set_session_pool (pool)

set_thread_pool (pool)

transfer_connection (socket, ip, port, initial_buffer)

Virtual Methods

Inherited:

GObject.Object (7)

do_client_connected (client)

Properties

Name

Type

Flags

Short Description

address

str

r/w

The address the server uses to listen on

backlog

int

r/w

The maximum length to which the queue of pending connections may grow

bound-port

int

r

The port number the server is listening on

content-length-limit

int

r/w

Limitation of Content-Length

mount-points

GstRtspServer.RTSPMountPoints

r/w

The mount points to use for client session

service

str

r/w

The service or port number the server uses to listen on

session-pool

GstRtspServer.RTSPSessionPool

r/w

The session pool to use for client session

Signals

Inherited:

GObject.Object (1)

Name

Short Description

client-connected

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent

GObject.Object

r

Class Details

class GstRtspServer.RTSPServer(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

GstRtspServer.RTSPServerClass

This object listens on a port, creates and manages the clients connected to it.

classmethod io_func(socket, condition, server)[source]
Parameters:
Returns:

True if the source could be connected, False if an error occurred.

Return type:

bool

A default Gio.SocketSourceFunc that creates a new GstRtspServer.RTSPClient to accept and handle a new connection on socket or server.

classmethod new()[source]
Returns:

a new GstRtspServer.RTSPServer

Return type:

GstRtspServer.RTSPServer

Create a new GstRtspServer.RTSPServer instance.

attach(context)[source]
Parameters:

context (GLib.MainContext or None) – a GLib.MainContext

Returns:

the ID (greater than 0) for the source within the GLib.MainContext.

Return type:

int

Attaches self to context. When the mainloop for context is run, the server will be dispatched. When context is None, the default context will be used).

This function should be called when the server properties and urls are fully configured and the server is ready to start.

This takes a reference on self until the source is destroyed. Note that if context is not the default main context as returned by GLib.MainContext.default() (or None), GLib.Source.remove() cannot be used to destroy the source. In that case it is recommended to use GstRtspServer.RTSPServer.create_source() and attach it to context manually.

client_filter(func, *user_data)[source]
Parameters:
Returns:

a GLib.List with all clients for which func returned GstRtspServer.RTSPFilterResult.REF. After usage, each element in the GLib.List should be unreffed before the list is freed.

Return type:

[GstRtspServer.RTSPClient]

Call func for each client managed by self. The result value of func determines what happens to the client. func will be called with self locked so no further actions on self can be performed from func.

If func returns GstRtspServer.RTSPFilterResult.REMOVE, the client will be removed from self.

If func returns GstRtspServer.RTSPFilterResult.KEEP, the client will remain in self.

If func returns GstRtspServer.RTSPFilterResult.REF, the client will remain in self but will also be added with an additional ref to the result GLib.List of this function..

When func is None, GstRtspServer.RTSPFilterResult.REF will be assumed for each client.

create_socket(cancellable)[source]
Parameters:

cancellable (Gio.Cancellable or None) – a Gio.Cancellable

Raises:

GLib.Error

Returns:

the Gio.Socket for self or None when an error occurred.

Return type:

Gio.Socket

Create a Gio.Socket for self. The socket will listen on the configured service.

create_source(cancellable)[source]
Parameters:

cancellable (Gio.Cancellable or None) – a Gio.Cancellable or None.

Raises:

GLib.Error

Returns:

the GLib.Source for self or None when an error occurred. Free with GLib.Source.unref ()

Return type:

GLib.Source

Create a GLib.Source for self. The new source will have a default Gio.SocketSourceFunc of GstRtspServer.RTSPServer.io_func().

cancellable if not None can be used to cancel the source, which will cause the source to trigger, reporting the current condition (which is likely 0 unless cancellation happened at the same time as a condition change). You can check for this in the callback using Gio.Cancellable.is_cancelled().

This takes a reference on self until source is destroyed.

get_address()[source]
Returns:

the server address. GLib.free() after usage.

Return type:

str or None

Get the address on which the server will accept connections.

get_auth()[source]
Returns:

the GstRtspServer.RTSPAuth of self. GObject.Object.unref() after usage.

Return type:

GstRtspServer.RTSPAuth or None

Get the GstRtspServer.RTSPAuth used as the authentication manager of self.

get_backlog()[source]
Returns:

the server backlog.

Return type:

int

The maximum amount of queued requests for the server.

get_bound_port()[source]
Returns:

the port number

Return type:

int

Get the port number where the server was bound to.

get_content_length_limit()[source]
Returns:

the Content-Length limit.

Return type:

int

Get the Content-Length limit of self.

New in version 1.18.

get_mount_points()[source]
Returns:

the GstRtspServer.RTSPMountPoints of self. GObject.Object.unref() after usage.

Return type:

GstRtspServer.RTSPMountPoints or None

Get the GstRtspServer.RTSPMountPoints used as the mount points of self.

get_service()[source]
Returns:

the service. use GLib.free() after usage.

Return type:

str

Get the service on which the server will accept connections.

get_session_pool()[source]
Returns:

the GstRtspServer.RTSPSessionPool used for sessions. GObject.Object.unref() after usage.

Return type:

GstRtspServer.RTSPSessionPool or None

Get the GstRtspServer.RTSPSessionPool used as the session pool of self.

get_thread_pool()[source]
Returns:

the GstRtspServer.RTSPThreadPool of self. GObject.Object.unref() after usage.

Return type:

GstRtspServer.RTSPThreadPool or None

Get the GstRtspServer.RTSPThreadPool used as the thread pool of self.

set_address(address)[source]
Parameters:

address (str) – the address

Configure self to accept connections on the given address.

This function must be called before the server is bound.

set_auth(auth)[source]
Parameters:

auth (GstRtspServer.RTSPAuth or None) – a GstRtspServer.RTSPAuth

configure auth to be used as the authentication manager of self.

set_backlog(backlog)[source]
Parameters:

backlog (int) – the backlog

configure the maximum amount of requests that may be queued for the server.

This function must be called before the server is bound.

set_content_length_limit(limit)[source]
Parameters:

limit (int) –

Define an appropriate GstRtsp.request size limit and reject requests exceeding the limit.

New in version 1.18.

set_mount_points(mounts)[source]
Parameters:

mounts (GstRtspServer.RTSPMountPoints or None) – a GstRtspServer.RTSPMountPoints

configure mounts to be used as the mount points of self.

set_service(service)[source]
Parameters:

service (str) – the service

Configure self to accept connections on the given service. service should be a string containing the service name (see services(5)) or a string containing a port number between 1 and 65535.

When service is set to “0”, the server will listen on a random free port. The actual used port can be retrieved with GstRtspServer.RTSPServer.get_bound_port().

This function must be called before the server is bound.

set_session_pool(pool)[source]
Parameters:

pool (GstRtspServer.RTSPSessionPool or None) – a GstRtspServer.RTSPSessionPool

configure pool to be used as the session pool of self.

set_thread_pool(pool)[source]
Parameters:

pool (GstRtspServer.RTSPThreadPool or None) – a GstRtspServer.RTSPThreadPool

configure pool to be used as the thread pool of self.

transfer_connection(socket, ip, port, initial_buffer)[source]
Parameters:
  • socket (Gio.Socket) – a network socket

  • ip (str) – the IP address of the remote client

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

  • initial_buffer (str or None) – any initial GstRtsp.data that was already read from the socket

Returns:

True if all was ok, False if an error occurred.

Return type:

bool

Take an existing network socket and use it for an RTSP connection. This is used when transferring a socket from an HTTP server which should be used as an RTSP over HTTP tunnel. The initial_buffer contains any remaining GstRtsp.data that the HTTP server read from the socket while parsing the HTTP header.

do_client_connected(client) virtual
Parameters:

client (GstRtspServer.RTSPClient) –

Signal Details

GstRtspServer.RTSPServer.signals.client_connected(r_t_s_p_server, object)
Signal Name:

client-connected

Flags:

RUN_LAST

Parameters:

Property Details

GstRtspServer.RTSPServer.props.address
Name:

address

Type:

str

Default Value:

'0.0.0.0'

Flags:

READABLE, WRITABLE

The address the server uses to listen on

GstRtspServer.RTSPServer.props.backlog
Name:

backlog

Type:

int

Default Value:

5

Flags:

READABLE, WRITABLE

The maximum length to which the queue of pending connections may grow

GstRtspServer.RTSPServer.props.bound_port
Name:

bound-port

Type:

int

Default Value:

-1

Flags:

READABLE

The port number the server is listening on

GstRtspServer.RTSPServer.props.content_length_limit
Name:

content-length-limit

Type:

int

Default Value:

4294967295

Flags:

READABLE, WRITABLE

Limitation of Content-Length

GstRtspServer.RTSPServer.props.mount_points
Name:

mount-points

Type:

GstRtspServer.RTSPMountPoints

Default Value:

None

Flags:

READABLE, WRITABLE

The mount points to use for client session

GstRtspServer.RTSPServer.props.service
Name:

service

Type:

str

Default Value:

'8554'

Flags:

READABLE, WRITABLE

The service or port number the server uses to listen on

GstRtspServer.RTSPServer.props.session_pool
Name:

session-pool

Type:

GstRtspServer.RTSPSessionPool

Default Value:

None

Flags:

READABLE, WRITABLE

The session pool to use for client session