Plugin¶
VideoRoom Plugin¶
- class janus_client.JanusVideoRoomPlugin(*args, **kwargs)¶
Janus VideoRoom plugin implementation
Implements API to interact with VideoRoom plugin.
Each plugin object is expected to have only 1 PeerConnection.
Each VideoRoom plugin instance is expected to have one of the following three uses: - Administration - Publisher - Subscriber
An instance meant for administration can be used as publisher or subscriber, but usually there isn’t a reason to share. Just create another instance. On the other hand, a publisher instance cannot subscribe to a stream and vice versa.
- async allowed(room_id: int, secret: str = '', action: AllowedAction = AllowedAction.ENABLE, allowed: List[str] = []) bool ¶
Configure ACL of a room.
- async create_room(room_id: int, configuration: dict = {}) bool ¶
Create a room.
Refer to documentation for description of parameters. https://janus.conf.meetecho.com/docs/videoroom.html
- async destroy_room(room_id: int, secret: str = '', permanent: bool = False) bool ¶
Destroy a room.
All other participants in the room will also get the “destroyed” event.
- async edit(room_id: int, secret: str = '', new_description: str = '', new_secret: str = '', new_pin: str = '', new_is_private: bool = False, new_require_pvtid: bool = False, new_bitrate: Optional[int] = None, new_fir_freq: Optional[int] = None, new_publishers: int = 3, new_lock_record: bool = False, new_rec_dir: Optional[str] = None, permanent: bool = False) bool ¶
Edit a room.
- async exists(room_id: int) bool ¶
Check if a room exists.
- async join(room_id: int, publisher_id: Optional[int] = None, display_name: str = '', token: Optional[str] = None) bool ¶
Join a room
A handle can join a room and then do nothing, but this should be called before publishing. There is an API to configure and publish at the same time, but it’s not implemented yet.
- Parameters:
room_id – unique ID of the room to join.
publisher_id – unique ID to register for the publisher; optional, will be chosen by the plugin if missing.
display_name – display name for the publisher; optional.
token – invitation token, in case the room has an ACL; optional.
- Returns:
True if room is created.
- async kick(room_id: int, id: str, secret: str = '') bool ¶
Kick a participant by ID.
Only works for room administrators (i.e. you created the room).
- async leave() bool ¶
Leave the room. Will unpublish if publishing.
- Returns:
True if successfully leave.
- async list_participants(room_id: int) list ¶
Get participant list in a room
Get a list of publishers in the room, that are currently publishing.
- Parameters:
room_id – List participants in this room
- Returns:
A list containing the participants. Can be empty.
- async list_room() List[dict] ¶
List all rooms created.
If admin_key is included, then private rooms will be listed as well. TODO: Find out how to include admin_key.
- async moderate(room_id: int, id: str, mid: str, mute: bool, secret: str = '') bool ¶
Moderate a participant by ID.
Only works for room administrators (i.e. you created the room).
- name: str = 'janus.plugin.videoroom'¶
Plugin name
- async on_receive(response: dict)¶
Handle asynchronous messages
- async pause() None ¶
Pause media streaming
- async publish(stream_track: List[MediaStreamTrack], configuration: dict = {}) None ¶
Publish video stream to the room
Should already have joined a room before this.
- async start(jsep: Optional[dict] = None) bool ¶
Signal WebRTC start.
- async subscribe_and_start(room_id: int, on_track_created, stream: dict, use_msid: bool = False, autoupdate: bool = True, private_id: Optional[int] = None) bool ¶
Subscribe to a feed. Only supporting subscribe to 1 stream.
- Parameters:
room_id – Room ID containing the feed. The same ID that you would use to join the room.
on_track_created – A callback function that will be called when AIORTC PC creates a media track
stream – Configuration of the stream to subscribe to. Minimum should have a feed ID.
use_msid – whether subscriptions should include an msid that references the publisher; false by default.
autoupdate – whether a new SDP offer is sent automatically when a subscribed publisher leaves; true by default.
private_id – unique ID of the publisher that originated this request; optional, unless mandated by the room configuration.
- async unpublish() bool ¶
Stop publishing.
- Returns:
True if successfully unpublished.
- async unsubscribe() None ¶
Unsubscribe from the feed
VideoCall Plugin¶
- class janus_client.JanusVideoCallPlugin¶
Janus Video Call plugin implementation
- name: str = 'janus.plugin.videocall'¶
Plugin name
- async on_incoming_call(jsep: dict)¶
Override this. This will be called when plugin receive incoming call event
- async on_receive(response: dict)¶
Handle asynchronous events from Janus
- async register(username: str) bool ¶
Register a username
Detach plugin to de-register the username
EchoTest Plugin¶
- class janus_client.JanusEchoTestPlugin¶
Janus EchoTest plugin implementation
- async close_stream()¶
Close stream
This should cause the stream to stop and a done event to be received.
- name: str = 'janus.plugin.echotest'¶
Plugin name
Must override to match plugin name in Janus server.
- async on_receive(response: dict)¶
Handle asynchronous events from Janus
Base Class¶
- class janus_client.JanusPlugin¶
Base class to inherit when implementing a plugin
- async destroy()¶
Destroy plugin handle
- async send(message: dict) MessageTransaction ¶
Send raw message to plugin
Will auto attach plugin ID to the message.
- Parameters:
message – JSON serializable dictionary to send
- Returns:
Synchronous reply from server
- async trickle(sdpMLineIndex, candidate)¶
Send WebRTC candidates to Janus
- Parameters:
sdpMLineIndex – (I don’t know what is this)
candidate – Candidate payload. (I got it from WebRTC instance callback)