Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
157 changes: 131 additions & 26 deletions versioned_docs/version-0.23.0/api/server-python/fishjam.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@ custom_edit_url: null
```python
class FishjamClient(Client):
```
Allows for managing rooms
Allows for managing rooms.

### __init__
```python
def __init__(fishjam_id: str, management_token: str)
```
Create a FishjamClient instance, providing the fishjam id and management token.
Create a FishjamClient instance.

Args:
- fishjam_id: The unique identifier for the Fishjam instance.
- management_token: The token used for authenticating management operations.

### create_peer
```python
Expand All @@ -34,12 +38,16 @@ def create_peer(
options: PeerOptions | None = None
) -> tuple[Peer, str]
```
Creates peer in the room
Creates a peer in the room.

Returns a tuple (`Peer`, `PeerToken`) - the token is needed by Peer
to authenticate to Fishjam.
Args:
- room_id: The ID of the room where the peer will be created.
- options: Configuration options for the peer. Defaults to None.

The possible options to pass for peer are `PeerOptions`.
Returns:
- A tuple containing:
- Peer: The created peer object.
- str: The peer token needed to authenticate to Fishjam.

### create_agent
```python
Expand All @@ -49,7 +57,15 @@ def create_agent(
options: AgentOptions | None = None
)
```
Creates an agent in the room.

Args:
- room_id: The ID of the room where the agent will be created.
- options: Configuration options for the agent. Defaults to None.

Returns:
- Agent: The created agent instance initialized with peer ID, room ID, token,
and Fishjam URL.

### create_room
```python
Expand All @@ -58,62 +74,112 @@ def create_room(
options: RoomOptions | None = None
) -> Room
```
Creates a new room
Returns the created `Room`
Creates a new room.

Args:
- options: Configuration options for the room. Defaults to None.

Returns:
- Room: The created Room object.

### get_all_rooms
```python
def get_all_rooms(self) -> list[Room]
```
Returns list of all rooms
Returns list of all rooms.

Returns:
- list[Room]: A list of all available Room objects.

### get_room
```python
def get_room(self, room_id: str) -> Room
```
Returns room with the given id
Returns room with the given id.

Args:
- room_id: The ID of the room to retrieve.

Returns:
- Room: The Room object corresponding to the given ID.

### delete_peer
```python
def delete_peer(self, room_id: str, peer_id: str) -> None
```
Deletes peer
Deletes a peer from a room.

Args:
- room_id: The ID of the room the peer belongs to.
- peer_id: The ID of the peer to delete.

### delete_room
```python
def delete_room(self, room_id: str) -> None
```
Deletes a room
Deletes a room.

Args:
- room_id: The ID of the room to delete.

### refresh_peer_token
```python
def refresh_peer_token(self, room_id: str, peer_id: str) -> str
```
Refreshes peer token
Refreshes a peer token.

Args:
- room_id: The ID of the room.
- peer_id: The ID of the peer whose token needs refreshing.

Returns:
- str: The new peer token.

### create_livestream_viewer_token
```python
def create_livestream_viewer_token(self, room_id: str) -> str
```
Generates viewer token for livestream rooms
Generates a viewer token for livestream rooms.

Args:
- room_id: The ID of the livestream room.

Returns:
- str: The generated viewer token.

### create_livestream_streamer_token
```python
def create_livestream_streamer_token(self, room_id: str) -> str
```
Generates streamer token for livestream rooms
Generates a streamer token for livestream rooms.

Args:
- room_id: The ID of the livestream room.

Returns:
- str: The generated streamer token.

### subscribe_peer
```python
def subscribe_peer(self, room_id: str, peer_id: str, target_peer_id: str)
```
Subscribe a peer to all tracks of another peer.
Subscribes a peer to all tracks of another peer.

Args:
- room_id: The ID of the room.
- peer_id: The ID of the subscribing peer.
- target_peer_id: The ID of the peer to subscribe to.

### subscribe_tracks
```python
def subscribe_tracks(self, room_id: str, peer_id: str, track_ids: list[str])
```
Subscribe a peer to specific tracks of another peer.
Subscribes a peer to specific tracks of another peer.

Args:
- room_id: The ID of the room.
- peer_id: The ID of the subscribing peer.
- track_ids: A list of track IDs to subscribe to.

#### Inherited Members
* **Client**:
Expand All @@ -129,7 +195,7 @@ Allows for receiving WebSocket messages from Fishjam.
```python
def __init__(fishjam_id: str, management_token: str)
```
Create FishjamNotifier instance, providing the fishjam id and management token.
Create a FishjamNotifier instance with an ID and management token.

### on_server_notification
```python
Expand All @@ -138,14 +204,19 @@ def on_server_notification(
handler: Union[Callable[[Union[ServerMessageRoomCreated, ServerMessageRoomDeleted, ServerMessageRoomCrashed, ServerMessagePeerAdded, ServerMessagePeerDeleted, ServerMessagePeerConnected, ServerMessagePeerDisconnected, ServerMessagePeerMetadataUpdated, ServerMessagePeerCrashed, ServerMessageStreamConnected, ServerMessageStreamDisconnected, ServerMessageViewerConnected, ServerMessageViewerDisconnected, ServerMessageTrackAdded, ServerMessageTrackRemoved, ServerMessageTrackMetadataUpdated]], NoneType], Callable[[Union[ServerMessageRoomCreated, ServerMessageRoomDeleted, ServerMessageRoomCrashed, ServerMessagePeerAdded, ServerMessagePeerDeleted, ServerMessagePeerConnected, ServerMessagePeerDisconnected, ServerMessagePeerMetadataUpdated, ServerMessagePeerCrashed, ServerMessageStreamConnected, ServerMessageStreamDisconnected, ServerMessageViewerConnected, ServerMessageViewerDisconnected, ServerMessageTrackAdded, ServerMessageTrackRemoved, ServerMessageTrackMetadataUpdated]], Coroutine[Any, Any, None]]]
)
```
Decorator used for defining handler for Fishjam Notifications
Decorator for defining a handler for Fishjam notifications.

Args:
- handler: The function to be registered as the notification handler.

Returns:
- NotificationHandler: The original handler function (unmodified).

### connect
```python
def connect(self)
```
A coroutine which connects FishjamNotifier to Fishjam and listens for
all incoming messages from the Fishjam.
Connects to Fishjam and listens for all incoming messages.

It runs until the connection isn't closed.

Expand All @@ -170,9 +241,17 @@ def receive_binary(
binary: bytes
) -> Union[ServerMessageRoomCreated, ServerMessageRoomDeleted, ServerMessageRoomCrashed, ServerMessagePeerAdded, ServerMessagePeerDeleted, ServerMessagePeerConnected, ServerMessagePeerDisconnected, ServerMessagePeerMetadataUpdated, ServerMessagePeerCrashed, ServerMessageStreamConnected, ServerMessageStreamDisconnected, ServerMessageViewerConnected, ServerMessageViewerDisconnected, ServerMessageTrackAdded, ServerMessageTrackRemoved, ServerMessageTrackMetadataUpdated, NoneType]
```
Transform received protobuf notification to adequate notification instance.
Transforms a received protobuf notification into a notification instance.

The available notifications are listed in `fishjam.events` module.

Args:
- binary: The raw binary data received from the webhook.

Returns:
- AllowedNotification | None: The parsed notification object, or None if
the message type is not supported.

---
## PeerMetadata
```python
Expand Down Expand Up @@ -218,7 +297,12 @@ additional_keys: list[str]
```python
class PeerOptions:
```
Options specific to a WebRTC Peer
Options specific to a WebRTC Peer.

Attributes:
- enable_simulcast: Enables the peer to use simulcast.
- metadata: Peer metadata.
- subscribe_mode: Configuration of peer's subscribing policy.

### __init__
```python
Expand Down Expand Up @@ -256,7 +340,15 @@ Configuration of peer's subscribing policy
```python
class RoomOptions:
```
Description of a room options
Description of a room options.

Attributes:
- max_peers: Maximum amount of peers allowed into the room.
- video_codec: Enforces video codec for each peer in the room.
- webhook_url: URL where Fishjam notifications will be sent.
- room_type: The use-case of the room. If not provided, this defaults
to conference.
- public: True if livestream viewers can omit specifying a token.

### __init__
```python
Expand Down Expand Up @@ -310,7 +402,11 @@ True if livestream viewers can omit specifying a token.
```python
class AgentOptions:
```
Options specific to a WebRTC Peer
Options specific to a WebRTC Peer.

Attributes:
- output: Configuration for the agent's output options.
- subscribe_mode: Configuration of peer's subscribing policy.

### __init__
```python
Expand Down Expand Up @@ -341,6 +437,10 @@ class AgentOutputOptions:
```
Options of the desired format of audio tracks going from Fishjam to the agent.

Attributes:
- audio_format: The format of the audio stream (e.g., 'pcm16').
- audio_sample_rate: The sample rate of the audio stream.

### __init__
```python
def __init__(
Expand Down Expand Up @@ -369,7 +469,12 @@ audio_sample_rate: Literal[16000, 24000] = 16000
```python
class Room:
```
Description of the room state
Description of the room state.

Attributes:
- config: Room configuration.
- id: Room ID.
- peers: List of all peers.

### __init__
```python
Expand Down
Loading