OpenViduSession

OpenViduSession class.

class pyopenvidu.openvidusession.OpenViduSession(session: requests_toolbelt.sessions.BaseUrlSession, data: dict)[source]

Bases: object

This object represents an OpenVidu Session. A session is a group of users sharing communicating each other.

Direct instantiation of this class is not supported! Use OpenVidu.get_session to get an instance of this class.

close()[source]

Gracefully closes the Session: unpublishes all streams and evicts every participant. Further calls to this object will fail.

connection_count

Get the number of active connections to the session.

Returns:The number of active connections.
create_ipcam_connection(rtsp_uri: str, data: str = None, adaptive_bitrate: bool = None, only_play_with_subscribers: bool = None, network_cache: int = None) → pyopenvidu.openviduconnection.OpenViduIPCAMConnection[source]

Publishes a new IPCAM rtsp stream to the session.

Keep in mind, that if you want the newly created Connection to appear in the connections list, you should call fetch() before accessing the list!

https://docs.openvidu.io/en/2.16.0/reference-docs/REST-API/#post-openviduapisessionsltsession_idgtconnection

Parameters:
  • rtsp_uri – RTSP URI of the IP camera. For example: rtsp://your.camera.ip:7777/path.
  • data – Metadata you want to associate to the camera’s participant.
  • adaptive_bitrate – Whether to use adaptive bitrate or not.
  • only_play_with_subscribers – Enable the IP camera stream only when some user is subscribed to it.
  • network_cache – Size of the buffer of the endpoint receiving the IP camera’s stream, in milliseconds.
Returns:

An OpenVidu connection object represents the newly created connection.

create_webrtc_connection(role: str = 'PUBLISHER', data: str = None, video_max_recv_bandwidth: int = None, video_min_recv_bandwidth: int = None, video_max_send_bandwidth: int = None, video_min_send_bandwidth: int = None, allowed_filters: list = None) → pyopenvidu.openviduconnection.OpenViduWEBRTCConnection[source]

Creates a new Connection object of WEBRTC (Regular user) type to the session.

In the video bandwidth settings 0 means unconstrained. Setting any of them (other than None) overrides the values configured in for the server.

https://docs.openvidu.io/en/2.16.0/reference-docs/REST-API/#post-openviduapisessionsltsession_idgtconnection

Parameters:
  • role – Allowed values: SUBSCRIBER, PUBLISHER or MODERATOR
  • data – metadata associated to this token (usually participant’s information)
  • video_max_recv_bandwidth – Maximum number of Kbps that the client owning the token will be able to receive from Kurento Media Server.
  • video_min_recv_bandwidth – Minimum number of Kbps that the client owning the token will try to receive from Kurento Media Server.
  • video_max_send_bandwidth – Maximum number of Kbps that the client owning the token will be able to send to Kurento Media Server.
  • video_min_send_bandwidth – Minimum number of Kbps that the client owning the token will try to send to Kurento Media Server.
  • allowed_filters – Array of strings containing the names of the filters the user owning the token will be able to apply.
Returns:

An OpenVidu connection object represents the newly created connection.

fetch()[source]

Updates every property of the OpenViduSession with the current status it has in OpenVidu Server. This is especially useful for getting the list of active connections to the OpenViduSession through the connections property.

Returns:True if the OpenViduSession status has changed with respect to the server, False if not. This applies to any property or sub-property of the object
get_connection(connection_id: str) → pyopenvidu.openviduconnection.OpenViduConnection[source]

Get a currently active connection to the server.

Parameters:connection_id – Connection id.
Returns:A OpenViduConnection objects.
signal(type_: str = None, data: str = None, to: Optional[List[pyopenvidu.openviduconnection.OpenViduConnection]] = None)[source]

Sends a signal to all participants in the session or specific connections if the to property defined. OpenViduConnection objects also implement this method.

https://docs.openvidu.io/en/2.16.0/reference-docs/REST-API/#post-openviduapisignal

Parameters:
  • type – Type of the signal. In the body example of the table above, only users subscribed to Session.on(‘signal:MY_TYPE’) will trigger that signal. Users subscribed to Session.on(‘signal’) will trigger signals of any type.
  • data – Actual data of the signal.
  • to – List of OpenViduConnection objects to which you want to send the signal. If this property is not set (None) the signal will be sent to all participants of the session.