diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 997cb029..79c76808 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -40,6 +40,8 @@ jobs: node-version: "lts/*" - name: Use corepack run: corepack enable + - name: Install uv + uses: astral-sh/setup-uv@v6 - name: Install dependencies run: yarn install --immutable - name: Fetch SDK packages diff --git a/.github/workflows/static_check.yml b/.github/workflows/static_check.yml index 4615ce91..6dc23ac0 100644 --- a/.github/workflows/static_check.yml +++ b/.github/workflows/static_check.yml @@ -18,6 +18,8 @@ jobs: node-version: "lts/*" - name: Use corepack run: corepack enable + - name: Install uv + uses: astral-sh/setup-uv@v6 - name: Run prepare run: scripts/prepare.sh - name: Install node dependencies diff --git a/.gitignore b/.gitignore index 4a6c6459..e867858d 100644 --- a/.gitignore +++ b/.gitignore @@ -137,5 +137,6 @@ build docs/api/mobile/** docs/api/web/** docs/api/server/** +docs/api/server-python/** .cursor/ diff --git a/.gitmodules b/.gitmodules index bbecf2c7..6c7a308b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -16,3 +16,6 @@ [submodule "api/room-manager"] path = api/room-manager url = git@github.com:fishjam-cloud/room-manager.git +[submodule "packages/python-server-sdk"] + path = packages/python-server-sdk + url = https://github.com/fishjam-cloud/python-server-sdk.git diff --git a/.prettierignore b/.prettierignore index a7e1c764..ccdcb540 100644 --- a/.prettierignore +++ b/.prettierignore @@ -4,3 +4,4 @@ node_modules/* packages/* api/** versioned_docs/*/api/** +docs/api/server-python/* diff --git a/README.md b/README.md index 934fa5bf..494b80fd 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,12 @@ The Documentation explains how Fishjam works and how it can be integrated in you ### Local Development +#### Python + +`python-server-sdk` requires [uv](https://docs.astral.sh/uv/). Make sure to have it installed first. + +#### yarn + Get all dependencies ``` diff --git a/docusaurus.config.ts b/docusaurus.config.ts index fc5a625a..072d2b03 100644 --- a/docusaurus.config.ts +++ b/docusaurus.config.ts @@ -15,7 +15,9 @@ import { import { rendererClassic, transformerTwoslash } from "@shikijs/twoslash"; import { NormalizedSidebar, + NormalizedSidebarItem, SidebarItemsGeneratorVersion, + SidebarItemCategory, } from "@docusaurus/plugin-content-docs/src/sidebars/types.js"; function isErrorFromVersionedDocs(options: { meta?: { __raw?: string } }) { @@ -56,45 +58,74 @@ const rehypeShikiPlugin = [ } satisfies RehypeShikiOptions, ] satisfies MDXPlugin; +type CustomInjectedCategory = Omit & { + items: any; +}; + function injectTypeDocSidebar( version: SidebarItemsGeneratorVersion, items: NormalizedSidebar, ): NormalizedSidebar { + console.log(version.versionName); + const docs_without_python_reference = ["0.20.0", "0.21.0", "0.22.0"]; + + const exclude_python = docs_without_python_reference.includes( + version.versionName, + ); + return items.map((item) => { if (item.customProps?.id === "generated-api" && item.type === "category") { + const injectedItems: (CustomInjectedCategory | NormalizedSidebarItem)[] = + [ + { + type: "category", + label: "React Native SDK", + link: { type: "doc", id: "api/mobile/index" }, + items: require( + `${version.contentPath}/api/mobile/typedoc-sidebar.cjs`, + ), + }, + { + type: "category", + label: "React SDK", + link: { type: "doc", id: "api/web/index" }, + items: require( + `${version.contentPath}/api/web/typedoc-sidebar.cjs`, + ), + }, + { + type: "category", + label: "Server SDK for JS", + link: { type: "doc", id: "api/server/index" }, + items: require( + `${version.contentPath}/api/server/typedoc-sidebar.cjs`, + ), + }, + ]; + + if (!exclude_python) { + injectedItems.push({ + type: "category", + label: "Server SDK for Python", + link: { type: "doc", id: "api/server-python/fishjam" }, + items: [ + { + type: "autogenerated", + dirName: "api/server-python", + }, + ], + }); + } + return { ...item, items: [ - ...([ - { - type: "category", - label: "React Native SDK", - link: { type: "doc", id: "api/mobile/index" }, - items: require( - `${version.contentPath}/api/mobile/typedoc-sidebar.cjs`, - ), - }, - { - type: "category", - label: "React SDK", - link: { type: "doc", id: "api/web/index" }, - items: require( - `${version.contentPath}/api/web/typedoc-sidebar.cjs`, - ), - }, - { - type: "category", - label: "Server SDK for JS", - link: { type: "doc", id: "api/server/index" }, - items: require( - `${version.contentPath}/api/server/typedoc-sidebar.cjs`, - ), - }, - ] as const), - ...item.items.filter((element) => element.type == "doc"), - ], + ...injectedItems, + ...item.items.filter((element) => element.type === "doc"), + ] as NormalizedSidebar, }; } + return item; }); } diff --git a/package.json b/package.json index f7194c7d..e10b7701 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,9 @@ "private": true, "scripts": { "docusaurus": "docusaurus", - "start": "docusaurus start", - "build": "docusaurus build", + "generate:python:docs": "sh ./scripts/generate_python_docs.sh", + "start": "npm run generate:python:docs && docusaurus start", + "build": "npm run generate:python:docs && docusaurus build", "swizzle": "docusaurus swizzle", "deploy": "docusaurus deploy", "clear": "docusaurus clear", diff --git a/packages/python-server-sdk b/packages/python-server-sdk new file mode 160000 index 00000000..5544a540 --- /dev/null +++ b/packages/python-server-sdk @@ -0,0 +1 @@ +Subproject commit 5544a54041aec14c57a82d6463639502261cf7ef diff --git a/scripts/generate_python_docs.sh b/scripts/generate_python_docs.sh new file mode 100755 index 00000000..38c11e96 --- /dev/null +++ b/scripts/generate_python_docs.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +set -e + +ROOTDIR=$(dirname $(dirname "$(readlink -f $0)")) +echo $ROOTDIR +cd $ROOTDIR + +cd packages/python-server-sdk +uv sync --all-packages +uv run generate_docusaurus +cd $ROOTDIR + +rm -rf docs/api/server-python +cp -r packages/python-server-sdk/docusaurus docs/api/server-python diff --git a/versioned_docs/version-0.23.0/api/server-python/fishjam.md b/versioned_docs/version-0.23.0/api/server-python/fishjam.md new file mode 100644 index 00000000..98c39ed1 --- /dev/null +++ b/versioned_docs/version-0.23.0/api/server-python/fishjam.md @@ -0,0 +1,498 @@ +--- +title: fishjam +sidebar_label: fishjam +custom_edit_url: null +--- + +# fishjam + + +## Submodules +- [events](submodules/events) +- [errors](submodules/errors) +- [room](submodules/room) +- [peer](submodules/peer) +- [agent](submodules/agent) + +## FishjamClient +```python +class FishjamClient(Client): +``` +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_peer +```python +def create_peer( + self, + room_id: str, + options: PeerOptions | None = None +) -> tuple[Peer, str] +``` +Creates peer in the room + +Returns a tuple (`Peer`, `PeerToken`) - the token is needed by Peer +to authenticate to Fishjam. + +The possible options to pass for peer are `PeerOptions`. + +### create_agent +```python +def create_agent( + self, + room_id: str, + options: AgentOptions | None = None +) +``` + + +### create_room +```python +def create_room( + self, + options: RoomOptions | None = None +) -> Room +``` +Creates a new room +Returns the created `Room` + +### get_all_rooms +```python +def get_all_rooms(self) -> list[Room] +``` +Returns list of all rooms + +### get_room +```python +def get_room(self, room_id: str) -> Room +``` +Returns room with the given id + +### delete_peer +```python +def delete_peer(self, room_id: str, peer_id: str) -> None +``` +Deletes peer + +### delete_room +```python +def delete_room(self, room_id: str) -> None +``` +Deletes a room + +### refresh_peer_token +```python +def refresh_peer_token(self, room_id: str, peer_id: str) -> str +``` +Refreshes peer token + +### create_livestream_viewer_token +```python +def create_livestream_viewer_token(self, room_id: str) -> str +``` +Generates viewer token for livestream rooms + +### create_livestream_streamer_token +```python +def create_livestream_streamer_token(self, room_id: str) -> str +``` +Generates streamer token for livestream rooms + +### 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. + +### 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. + +#### Inherited Members +* **Client**: + * `client` +--- +## FishjamNotifier +```python +class FishjamNotifier: +``` +Allows for receiving WebSocket messages from Fishjam. + +### __init__ +```python +def __init__(fishjam_id: str, management_token: str) +``` +Create FishjamNotifier instance, providing the fishjam id and management token. + +### on_server_notification +```python +def on_server_notification( + self, + 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 + +### connect +```python +def connect(self) +``` +A coroutine which connects FishjamNotifier to Fishjam and listens for +all incoming messages from the Fishjam. + +It runs until the connection isn't closed. + +The incoming messages are handled by the functions defined using the +`on_server_notification` decorator. + +The handler have to be defined before calling `connect`, +otherwise the messages won't be received. + +### wait_ready +```python +def wait_ready(self) -> None +``` +Waits until the notifier is connected and authenticated to Fishjam. + +If already connected, returns immediately. + +--- +## receive_binary +```python +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. +The available notifications are listed in `fishjam.events` module. + +--- +## PeerMetadata +```python +class PeerMetadata: +``` +Custom metadata set by the peer + +Example: +- \{'name': 'FishjamUser'\} + +### __init__ +```python +def __init__() +``` +Method generated by attrs for class PeerMetadata. + +### additional_properties +```python +additional_properties: dict[str, typing.Any] +``` + + +### to_dict +```python +def to_dict(self) -> dict[str, typing.Any] +``` + + +### from_dict +```python +def from_dict(cls: type[~T], src_dict: Mapping[str, typing.Any]) -> ~T +``` + + +### additional_keys +```python +additional_keys: list[str] +``` + + +--- +## PeerOptions +```python +class PeerOptions: +``` +Options specific to a WebRTC Peer + +### __init__ +```python +def __init__( + enable_simulcast: bool = True, + metadata: dict[str, typing.Any] | None = None, + subscribe_mode: Literal['auto', 'manual'] = 'auto' +) +``` + + +### enable_simulcast +```python +enable_simulcast: bool = True + +``` +Enables the peer to use simulcast + +### metadata +```python +metadata: dict[str, typing.Any] | None = None + +``` +Peer metadata + +### subscribe_mode +```python +subscribe_mode: Literal['auto', 'manual'] = 'auto' + +``` +Configuration of peer's subscribing policy + +--- +## RoomOptions +```python +class RoomOptions: +``` +Description of a room options + +### __init__ +```python +def __init__( + max_peers: int | None = None, + video_codec: Optional[Literal['h264', 'vp8']] = None, + webhook_url: str | None = None, + room_type: Literal['conference', 'audio_only', 'livestream', 'full_feature', 'broadcaster', 'audio_only_livestream'] = 'conference', + public: bool = False +) +``` + + +### max_peers +```python +max_peers: int | None = None + +``` +Maximum amount of peers allowed into the room + +### video_codec +```python +video_codec: Optional[Literal['h264', 'vp8']] = None + +``` +Enforces video codec for each peer in the room + +### webhook_url +```python +webhook_url: str | None = None + +``` +URL where Fishjam notifications will be sent + +### room_type +```python +room_type: Literal['conference', 'audio_only', 'livestream', 'full_feature', 'broadcaster', 'audio_only_livestream'] = 'conference' + +``` +The use-case of the room. If not provided, this defaults to conference. + +### public +```python +public: bool = False + +``` +True if livestream viewers can omit specifying a token. + +--- +## AgentOptions +```python +class AgentOptions: +``` +Options specific to a WebRTC Peer + +### __init__ +```python +def __init__( + output: AgentOutputOptions = , + subscribe_mode: Literal['auto', 'manual'] = 'auto' +) +``` + + +### output +```python +output: AgentOutputOptions +``` + + +### subscribe_mode +```python +subscribe_mode: Literal['auto', 'manual'] = 'auto' + +``` + + +--- +## AgentOutputOptions +```python +class AgentOutputOptions: +``` +Options of the desired format of audio tracks going from Fishjam to the agent. + +### __init__ +```python +def __init__( + audio_format: Literal['pcm16'] = 'pcm16', + audio_sample_rate: Literal[16000, 24000] = 16000 +) +``` + + +### audio_format +```python +audio_format: Literal['pcm16'] = 'pcm16' + +``` + + +### audio_sample_rate +```python +audio_sample_rate: Literal[16000, 24000] = 16000 + +``` + + +--- +## Room +```python +class Room: +``` +Description of the room state + +### __init__ +```python +def __init__( + config: RoomConfig, + id: str, + peers: list[Peer] +) +``` + + +### config +```python +config: RoomConfig +``` +Room configuration + +### id +```python +id: str +``` +Room ID + +### peers +```python +peers: list[Peer] +``` +List of all peers + +--- +## Peer +```python +class Peer: +``` +Describes peer status + +Attributes: +- id (str): Assigned peer id Example: 4a1c1164-5fb7-425d-89d7-24cdb8fff1cf. +- metadata (Union['PeerMetadata', None]): Custom metadata set by the peer Example: \{'name': 'FishjamUser'\}. +- status (PeerStatus): Informs about the peer status Example: disconnected. +- subscribe_mode (SubscribeMode): Configuration of peer's subscribing policy +- subscriptions (Subscriptions): Describes peer's subscriptions in manual mode +- tracks (list['Track']): List of all peer's tracks +- type_ (PeerType): Peer type Example: webrtc. + +### __init__ +```python +def __init__( + id: str, + metadata: Optional[PeerMetadata], + status: PeerStatus, + subscribe_mode: SubscribeMode, + subscriptions: Subscriptions, + tracks: list[Track], + type_: PeerType +) +``` +Method generated by attrs for class Peer. + +### id +```python +id: str +``` + + +### metadata +```python +metadata: Optional[PeerMetadata] +``` + + +### status +```python +status: PeerStatus +``` + + +### subscribe_mode +```python +subscribe_mode: SubscribeMode +``` + + +### subscriptions +```python +subscriptions: Subscriptions +``` + + +### tracks +```python +tracks: list[Track] +``` + + +### type_ +```python +type_: PeerType +``` + + +### additional_properties +```python +additional_properties: dict[str, typing.Any] +``` + + +### to_dict +```python +def to_dict(self) -> dict[str, typing.Any] +``` + + +### from_dict +```python +def from_dict(cls: type[~T], src_dict: Mapping[str, typing.Any]) -> ~T +``` + + +### additional_keys +```python +additional_keys: list[str] +``` + + +--- diff --git a/versioned_docs/version-0.23.0/api/server-python/submodules/agent.md b/versioned_docs/version-0.23.0/api/server-python/submodules/agent.md new file mode 100644 index 00000000..3fae055c --- /dev/null +++ b/versioned_docs/version-0.23.0/api/server-python/submodules/agent.md @@ -0,0 +1,237 @@ +--- +title: agent +sidebar_label: agent +custom_edit_url: null +--- + +# agent + + + +## Agent +```python +class Agent: +``` +Allows for connecting to a Fishjam room as an agent peer. +Provides callbacks for receiving audio. + +### __init__ +```python +def __init__(id: str, room_id: str, token: str, fishjam_url: str) +``` +Create Agent instance, providing the fishjam id and management token. + +This constructor should not be called directly. +Instead, you should call :func:`fishjam.FishjamClient.create_agent`. + +### id +```python +id +``` + + +### room_id +```python +room_id +``` + + +### connect +```python +def connect(self) +``` +Connect the agent to Fishjam to start receiving messages. + +Incoming messages from Fishjam will be routed to handlers +defined with :func:`on_track_data`. + +:raises AgentAuthError: authentication failed + +--- +## AgentError +```python +class AgentError(Exception): +``` +Base exception class for all agent exceptions + +--- +## AgentSession +```python +class AgentSession: +``` + + +### __init__ +```python +def __init__( + agent: fishjam.agent.agent.Agent, + websocket: websockets.asyncio.client.ClientConnection +) +``` + + +### agent +```python +agent +``` + + +### receive +```python +def receive( + self +) -> AsyncIterator[AgentResponseTrackData] +``` +Returns an infinite async iterator over the incoming messages from Fishjam to +the agent. + +### add_track +```python +def add_track(self, options: fishjam.agent.agent.OutgoingAudioTrackOptions) +``` +Adds a track to the connected agent, with the specified options and metadata. + +Returns an instance of :class:`OutgoingTrack`, which can be used to send data +over the added track. + +### disconnect +```python +def disconnect(self) +``` +Ends the agent session by closing the websocket connection. +Useful when you don't use the context manager to obtain the session. + +--- +## AgentAuthError +```python +class AgentAuthError(fishjam.agent.errors.AgentError): +``` +Agent failed to authenticate properly + +### __init__ +```python +def __init__(reason: str) +``` + + +### reason +```python +reason +``` + + +--- +## IncomingTrackData +```python +IncomingTrackData = + +``` + + +--- +## OutgoingTrack +```python +class OutgoingTrack: +``` +Represents an outgoing track of an agent connected to Fishjam, +created by :func:`Agent.add_track`. + +### __init__ +```python +def __init__( + id: str, + session: fishjam.agent.agent.AgentSession, + options: fishjam.agent.agent.OutgoingAudioTrackOptions +) +``` + + +### id +```python +id: str +``` +The global identifier of the track. + +### session +```python +session: fishjam.agent.agent.AgentSession +``` +The agent the track belongs to. + +### options +```python +options: fishjam.agent.agent.OutgoingAudioTrackOptions +``` +The parameters used to create the track. + +### send_chunk +```python +def send_chunk(self, data: bytes) +``` +Send a chunk of audio to Fishjam on this track. + +Peers connected to the room of the agent will receive this data. + +### interrupt +```python +def interrupt(self) +``` +Interrupt current track. + +Any audio that has been sent, but not played +will be cleared and be prevented from playing. + +Audio sent after the interrupt will be played normally. + +--- +## OutgoingAudioTrackOptions +```python +class OutgoingAudioTrackOptions: +``` +Parameters of an outgoing audio track. + +### __init__ +```python +def __init__( + encoding: TrackEncoding = , + sample_rate: Literal[16000, 24000] = 16000, + channels: Literal[1, 2] = 1, + metadata: dict[str, typing.Any] | None = None +) +``` + + +### encoding +```python +encoding: TrackEncoding = + +``` +The encoding of the audio source. +Defaults to raw 16-bit PCM. + +### sample_rate +```python +sample_rate: Literal[16000, 24000] = 16000 + +``` +The sample rate of the audio source. +Defaults to 16000. + +### channels +```python +channels: Literal[1, 2] = 1 + +``` +The number of channels in the audio source. +Supported values are 1 (mono) and 2 (stereo). +Defaults to 1 (mono) + +### metadata +```python +metadata: dict[str, typing.Any] | None = None + +``` +Custom metadata for the track. +Must be JSON-encodable. + +--- diff --git a/versioned_docs/version-0.23.0/api/server-python/submodules/errors.md b/versioned_docs/version-0.23.0/api/server-python/submodules/errors.md new file mode 100644 index 00000000..41f7cc57 --- /dev/null +++ b/versioned_docs/version-0.23.0/api/server-python/submodules/errors.md @@ -0,0 +1,59 @@ +--- +title: errors +sidebar_label: errors +custom_edit_url: null +--- + +# errors + + + +## HTTPError +```python +class HTTPError(Exception): +``` + + +--- +## BadRequestError +```python +class BadRequestError(HTTPError): +``` + + +--- +## UnauthorizedError +```python +class UnauthorizedError(HTTPError): +``` + + +--- +## NotFoundError +```python +class NotFoundError(HTTPError): +``` + + +--- +## ServiceUnavailableError +```python +class ServiceUnavailableError(HTTPError): +``` + + +--- +## InternalServerError +```python +class InternalServerError(HTTPError): +``` + + +--- +## ConflictError +```python +class ConflictError(HTTPError): +``` + + +--- diff --git a/versioned_docs/version-0.23.0/api/server-python/submodules/events.md b/versioned_docs/version-0.23.0/api/server-python/submodules/events.md new file mode 100644 index 00000000..b36fd45a --- /dev/null +++ b/versioned_docs/version-0.23.0/api/server-python/submodules/events.md @@ -0,0 +1,863 @@ +--- +title: events +sidebar_label: events +custom_edit_url: null +--- + +# events + + + +## ServerMessageRoomCreated +```python +class ServerMessageRoomCreated(betterproto.Message): +``` +Notification sent when a room is created + +### __init__ +```python +def __init__(room_id: str = ) +``` + + +### room_id +```python +room_id: str +``` + + +#### Inherited Members +* **Message**: + * `SerializeToString` + * `parse` + * `FromString` + * `to_dict` + * `from_dict` + * `to_json` + * `from_json` + * `to_pydict` + * `from_pydict` + * `is_set` +--- +## ServerMessageRoomDeleted +```python +class ServerMessageRoomDeleted(betterproto.Message): +``` +Notification sent when a room is deleted + +### __init__ +```python +def __init__(room_id: str = ) +``` + + +### room_id +```python +room_id: str +``` + + +#### Inherited Members +* **Message**: + * `SerializeToString` + * `parse` + * `FromString` + * `to_dict` + * `from_dict` + * `to_json` + * `from_json` + * `to_pydict` + * `from_pydict` + * `is_set` +--- +## ServerMessageRoomCrashed +```python +class ServerMessageRoomCrashed(betterproto.Message): +``` +Notification sent when a room crashes + +### __init__ +```python +def __init__(room_id: str = ) +``` + + +### room_id +```python +room_id: str +``` + + +#### Inherited Members +* **Message**: + * `SerializeToString` + * `parse` + * `FromString` + * `to_dict` + * `from_dict` + * `to_json` + * `from_json` + * `to_pydict` + * `from_pydict` + * `is_set` +--- +## ServerMessagePeerAdded +```python +class ServerMessagePeerAdded(betterproto.Message): +``` +Notification sent when a peer is added + +### __init__ +```python +def __init__( + room_id: str = , + peer_id: str = , + peer_type: ServerMessagePeerType = +) +``` + + +### room_id +```python +room_id: str +``` + + +### peer_id +```python +peer_id: str +``` + + +### peer_type +```python +peer_type: ServerMessagePeerType +``` + + +#### Inherited Members +* **Message**: + * `SerializeToString` + * `parse` + * `FromString` + * `to_dict` + * `from_dict` + * `to_json` + * `from_json` + * `to_pydict` + * `from_pydict` + * `is_set` +--- +## ServerMessagePeerConnected +```python +class ServerMessagePeerConnected(betterproto.Message): +``` +Notification sent when a peer connects + +### __init__ +```python +def __init__( + room_id: str = , + peer_id: str = , + peer_type: ServerMessagePeerType = +) +``` + + +### room_id +```python +room_id: str +``` + + +### peer_id +```python +peer_id: str +``` + + +### peer_type +```python +peer_type: ServerMessagePeerType +``` + + +#### Inherited Members +* **Message**: + * `SerializeToString` + * `parse` + * `FromString` + * `to_dict` + * `from_dict` + * `to_json` + * `from_json` + * `to_pydict` + * `from_pydict` + * `is_set` +--- +## ServerMessagePeerDeleted +```python +class ServerMessagePeerDeleted(betterproto.Message): +``` +Notification sent when a peer is removed + +### __init__ +```python +def __init__( + room_id: str = , + peer_id: str = , + peer_type: ServerMessagePeerType = +) +``` + + +### room_id +```python +room_id: str +``` + + +### peer_id +```python +peer_id: str +``` + + +### peer_type +```python +peer_type: ServerMessagePeerType +``` + + +#### Inherited Members +* **Message**: + * `SerializeToString` + * `parse` + * `FromString` + * `to_dict` + * `from_dict` + * `to_json` + * `from_json` + * `to_pydict` + * `from_pydict` + * `is_set` +--- +## ServerMessagePeerDisconnected +```python +class ServerMessagePeerDisconnected(betterproto.Message): +``` +Notification sent when a peer disconnects from FJ + +### __init__ +```python +def __init__( + room_id: str = , + peer_id: str = , + peer_type: ServerMessagePeerType = +) +``` + + +### room_id +```python +room_id: str +``` + + +### peer_id +```python +peer_id: str +``` + + +### peer_type +```python +peer_type: ServerMessagePeerType +``` + + +#### Inherited Members +* **Message**: + * `SerializeToString` + * `parse` + * `FromString` + * `to_dict` + * `from_dict` + * `to_json` + * `from_json` + * `to_pydict` + * `from_pydict` + * `is_set` +--- +## ServerMessagePeerMetadataUpdated +```python +class ServerMessagePeerMetadataUpdated(betterproto.Message): +``` +Notification sent when peer updates its metadata + +### __init__ +```python +def __init__( + room_id: str = , + peer_id: str = , + metadata: str = , + peer_type: ServerMessagePeerType = +) +``` + + +### room_id +```python +room_id: str +``` + + +### peer_id +```python +peer_id: str +``` + + +### metadata +```python +metadata: str +``` + + +### peer_type +```python +peer_type: ServerMessagePeerType +``` + + +#### Inherited Members +* **Message**: + * `SerializeToString` + * `parse` + * `FromString` + * `to_dict` + * `from_dict` + * `to_json` + * `from_json` + * `to_pydict` + * `from_pydict` + * `is_set` +--- +## ServerMessagePeerCrashed +```python +class ServerMessagePeerCrashed(betterproto.Message): +``` +Notification sent when a peer crashes + +### __init__ +```python +def __init__( + room_id: str = , + peer_id: str = , + reason: str = , + peer_type: ServerMessagePeerType = +) +``` + + +### room_id +```python +room_id: str +``` + + +### peer_id +```python +peer_id: str +``` + + +### reason +```python +reason: str +``` + + +### peer_type +```python +peer_type: ServerMessagePeerType +``` + + +#### Inherited Members +* **Message**: + * `SerializeToString` + * `parse` + * `FromString` + * `to_dict` + * `from_dict` + * `to_json` + * `from_json` + * `to_pydict` + * `from_pydict` + * `is_set` +--- +## ServerMessageStreamConnected +```python +class ServerMessageStreamConnected(betterproto.Message): +``` +Notification sent when streamer successfully connects + +### __init__ +```python +def __init__(stream_id: str = ) +``` + + +### stream_id +```python +stream_id: str +``` + + +#### Inherited Members +* **Message**: + * `SerializeToString` + * `parse` + * `FromString` + * `to_dict` + * `from_dict` + * `to_json` + * `from_json` + * `to_pydict` + * `from_pydict` + * `is_set` +--- +## ServerMessageStreamDisconnected +```python +class ServerMessageStreamDisconnected(betterproto.Message): +``` +Notification sent when streamer disconnects + +### __init__ +```python +def __init__(stream_id: str = ) +``` + + +### stream_id +```python +stream_id: str +``` + + +#### Inherited Members +* **Message**: + * `SerializeToString` + * `parse` + * `FromString` + * `to_dict` + * `from_dict` + * `to_json` + * `from_json` + * `to_pydict` + * `from_pydict` + * `is_set` +--- +## ServerMessageTrackAdded +```python +class ServerMessageTrackAdded(betterproto.Message): +``` +Notification sent when peer or component adds new track + +### __init__ +```python +def __init__( + room_id: str = , + peer_id: str = , + component_id: str = , + track: Track = +) +``` + + +### room_id +```python +room_id: str +``` + + +### peer_id +```python +peer_id: str +``` + + +### component_id +```python +component_id: str +``` + + +### track +```python +track: Track +``` + + +#### Inherited Members +* **Message**: + * `SerializeToString` + * `parse` + * `FromString` + * `to_dict` + * `from_dict` + * `to_json` + * `from_json` + * `to_pydict` + * `from_pydict` + * `is_set` +--- +## ServerMessageTrackMetadataUpdated +```python +class ServerMessageTrackMetadataUpdated(betterproto.Message): +``` +Notification sent when metadata of a multimedia track is updated + +### __init__ +```python +def __init__( + room_id: str = , + peer_id: str = , + component_id: str = , + track: Track = +) +``` + + +### room_id +```python +room_id: str +``` + + +### peer_id +```python +peer_id: str +``` + + +### component_id +```python +component_id: str +``` + + +### track +```python +track: Track +``` + + +#### Inherited Members +* **Message**: + * `SerializeToString` + * `parse` + * `FromString` + * `to_dict` + * `from_dict` + * `to_json` + * `from_json` + * `to_pydict` + * `from_pydict` + * `is_set` +--- +## ServerMessageTrackRemoved +```python +class ServerMessageTrackRemoved(betterproto.Message): +``` +Notification sent when a track is removed + +### __init__ +```python +def __init__( + room_id: str = , + peer_id: str = , + component_id: str = , + track: Track = +) +``` + + +### room_id +```python +room_id: str +``` + + +### peer_id +```python +peer_id: str +``` + + +### component_id +```python +component_id: str +``` + + +### track +```python +track: Track +``` + + +#### Inherited Members +* **Message**: + * `SerializeToString` + * `parse` + * `FromString` + * `to_dict` + * `from_dict` + * `to_json` + * `from_json` + * `to_pydict` + * `from_pydict` + * `is_set` +--- +## ServerMessageViewerConnected +```python +class ServerMessageViewerConnected(betterproto.Message): +``` +Notification sent when viewer successfully connects + +### __init__ +```python +def __init__(stream_id: str = , viewer_id: str = ) +``` + + +### stream_id +```python +stream_id: str +``` + + +### viewer_id +```python +viewer_id: str +``` + + +#### Inherited Members +* **Message**: + * `SerializeToString` + * `parse` + * `FromString` + * `to_dict` + * `from_dict` + * `to_json` + * `from_json` + * `to_pydict` + * `from_pydict` + * `is_set` +--- +## ServerMessageViewerDisconnected +```python +class ServerMessageViewerDisconnected(betterproto.Message): +``` +Notification sent when viewer disconnects + +### __init__ +```python +def __init__(stream_id: str = , viewer_id: str = ) +``` + + +### stream_id +```python +stream_id: str +``` + + +### viewer_id +```python +viewer_id: str +``` + + +#### Inherited Members +* **Message**: + * `SerializeToString` + * `parse` + * `FromString` + * `to_dict` + * `from_dict` + * `to_json` + * `from_json` + * `to_pydict` + * `from_pydict` + * `is_set` +--- +## Track +```python +class Track(betterproto.Message): +``` +Describes a media track + +### __init__ +```python +def __init__( + id: str = , + type: TrackType = , + metadata: str = +) +``` + + +### id +```python +id: str +``` + + +### type +```python +type: TrackType +``` + + +### metadata +```python +metadata: str +``` + + +#### Inherited Members +* **Message**: + * `SerializeToString` + * `parse` + * `FromString` + * `to_dict` + * `from_dict` + * `to_json` + * `from_json` + * `to_pydict` + * `from_pydict` + * `is_set` +--- +## TrackEncoding +```python +class TrackEncoding(betterproto.Enum): +``` +The base class for protobuf enumerations, all generated enumerations will inherit +from this. Bases :class:`enum.IntEnum`. + +### TRACK_ENCODING_UNSPECIFIED +```python +TRACK_ENCODING_UNSPECIFIED = + +``` + + +### TRACK_ENCODING_PCM16 +```python +TRACK_ENCODING_PCM16 = + +``` + + +### TRACK_ENCODING_OPUS +```python +TRACK_ENCODING_OPUS = + +``` + + +#### Inherited Members +* **Enum**: + * `from_string` + + + + + +* **Enum**: + * `name` + * `value` +--- +## TrackType +```python +class TrackType(betterproto.Enum): +``` +Defines types of tracks being published by peers and component + +### TRACK_TYPE_UNSPECIFIED +```python +TRACK_TYPE_UNSPECIFIED = + +``` + + +### TRACK_TYPE_VIDEO +```python +TRACK_TYPE_VIDEO = + +``` + + +### TRACK_TYPE_AUDIO +```python +TRACK_TYPE_AUDIO = + +``` + + +#### Inherited Members +* **Enum**: + * `from_string` + + + + + +* **Enum**: + * `name` + * `value` +--- +## ServerMessagePeerType +```python +class ServerMessagePeerType(betterproto.Enum): +``` +The base class for protobuf enumerations, all generated enumerations will inherit +from this. Bases :class:`enum.IntEnum`. + +### PEER_TYPE_UNSPECIFIED +```python +PEER_TYPE_UNSPECIFIED = + +``` + + +### PEER_TYPE_WEBRTC +```python +PEER_TYPE_WEBRTC = + +``` + + +### PEER_TYPE_AGENT +```python +PEER_TYPE_AGENT = + +``` + + +#### Inherited Members +* **Enum**: + * `from_string` + + + + + +* **Enum**: + * `name` + * `value` +--- diff --git a/versioned_docs/version-0.23.0/api/server-python/submodules/peer.md b/versioned_docs/version-0.23.0/api/server-python/submodules/peer.md new file mode 100644 index 00000000..01c7c474 --- /dev/null +++ b/versioned_docs/version-0.23.0/api/server-python/submodules/peer.md @@ -0,0 +1,100 @@ +--- +title: peer +sidebar_label: peer +custom_edit_url: null +--- + +# peer + + + +## PeerMetadata +```python +class PeerMetadata: +``` +Custom metadata set by the peer + +Example: +- \{'name': 'FishjamUser'\} + +### __init__ +```python +def __init__() +``` +Method generated by attrs for class PeerMetadata. + +### additional_properties +```python +additional_properties: dict[str, typing.Any] +``` + + +### to_dict +```python +def to_dict(self) -> dict[str, typing.Any] +``` + + +### from_dict +```python +def from_dict(cls: type[~T], src_dict: Mapping[str, typing.Any]) -> ~T +``` + + +### additional_keys +```python +additional_keys: list[str] +``` + + +--- +## PeerStatus +```python +class PeerStatus(str, enum.Enum): +``` +Informs about the peer status + +### CONNECTED +```python +CONNECTED = + +``` + + +### DISCONNECTED +```python +DISCONNECTED = + +``` + + +#### Inherited Members +* **Enum**: + * `name` + * `value` +--- +## PeerType +```python +class PeerType(str, enum.Enum): +``` +Peer type + +### AGENT +```python +AGENT = + +``` + + +### WEBRTC +```python +WEBRTC = + +``` + + +#### Inherited Members +* **Enum**: + * `name` + * `value` +--- diff --git a/versioned_docs/version-0.23.0/api/server-python/submodules/room.md b/versioned_docs/version-0.23.0/api/server-python/submodules/room.md new file mode 100644 index 00000000..de5f7f91 --- /dev/null +++ b/versioned_docs/version-0.23.0/api/server-python/submodules/room.md @@ -0,0 +1,171 @@ +--- +title: room +sidebar_label: room +custom_edit_url: null +--- + +# room + + + +## RoomConfig +```python +class RoomConfig: +``` +Room configuration + +Attributes: +- max_peers (Union[None, Unset, int]): Maximum amount of peers allowed into the room Example: 10. +- public (Union[Unset, bool]): True if livestream viewers can omit specifying a token. Default: False. +- room_type (Union[Unset, RoomConfigRoomType]): The use-case of the room. If not provided, this defaults to + conference. Default: RoomConfigRoomType.CONFERENCE. +- video_codec (Union[Unset, RoomConfigVideoCodec]): Enforces video codec for each peer in the room Default: + RoomConfigVideoCodec.H264. +- webhook_url (Union[None, Unset, str]): URL where Fishjam notifications will be sent Example: + https://backend.address.com/fishjam-notifications-endpoint. + +### __init__ +```python +def __init__( + max_peers: Union[NoneType, Unset, int] = , + public: Union[Unset, bool] = False, + room_type: Union[Unset, RoomConfigRoomType] = , + video_codec: Union[Unset, RoomConfigVideoCodec] = , + webhook_url: Union[NoneType, Unset, str] = +) +``` +Method generated by attrs for class RoomConfig. + +### max_peers +```python +max_peers: Union[NoneType, Unset, int] +``` + + +### public +```python +public: Union[Unset, bool] +``` + + +### room_type +```python +room_type: Union[Unset, RoomConfigRoomType] +``` + + +### video_codec +```python +video_codec: Union[Unset, RoomConfigVideoCodec] +``` + + +### webhook_url +```python +webhook_url: Union[NoneType, Unset, str] +``` + + +### additional_properties +```python +additional_properties: dict[str, typing.Any] +``` + + +### to_dict +```python +def to_dict(self) -> dict[str, typing.Any] +``` + + +### from_dict +```python +def from_dict(cls: type[~T], src_dict: Mapping[str, typing.Any]) -> ~T +``` + + +### additional_keys +```python +additional_keys: list[str] +``` + + +--- +## RoomConfigVideoCodec +```python +class RoomConfigVideoCodec(str, enum.Enum): +``` +Enforces video codec for each peer in the room + +### H264 +```python +H264 = + +``` + + +### VP8 +```python +VP8 = + +``` + + +#### Inherited Members +* **Enum**: + * `name` + * `value` +--- +## RoomConfigRoomType +```python +class RoomConfigRoomType(str, enum.Enum): +``` +The use-case of the room. If not provided, this defaults to conference. + +### AUDIO_ONLY +```python +AUDIO_ONLY = + +``` + + +### AUDIO_ONLY_LIVESTREAM +```python +AUDIO_ONLY_LIVESTREAM = + +``` + + +### BROADCASTER +```python +BROADCASTER = + +``` + + +### CONFERENCE +```python +CONFERENCE = + +``` + + +### FULL_FEATURE +```python +FULL_FEATURE = + +``` + + +### LIVESTREAM +```python +LIVESTREAM = + +``` + + +#### Inherited Members +* **Enum**: + * `name` + * `value` +---