Name | huddle01 JSON |
Version |
1.0.5
JSON |
| download |
home_page | None |
Summary | Python Real-Time-SDK for Huddle01 dRTC Network |
upload_time | 2024-12-06 05:14:41 |
maintainer | Om Gupta |
docs_url | None |
author | Om Gupta |
requires_python | <4.0,>=3.12 |
license | BSD-3-Clause |
keywords |
huddle01
video
conferencing
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Huddle01 Python SDK
## Overview
The Huddle01 Python SDK provides a comprehensive solution for interacting with Huddle01's infrastructure. It enables developers to build real-time communication systems with support for rooms, peers, active speakers, permissions, and WebSocket-based connections.
## Features
- **Access Token Management**: Generate and manage access tokens for secure communication.
- **Room Management**: Create and manage rooms with various permissions and roles.
- **Local and Remote Peers**: Define and manage local and remote peers, including their producers and roles.
- **WebSocket Communication**: Connect to Huddle01's WebSocket server for real-time data exchange.
- **Enhanced Event Handling**: Utilize `EnhancedEventEmitter` for subscribing and handling events seamlessly.
- **Active Speaker Tracking**: Manage active speakers within a room.
- **Produce and Consume Media**: Produce and consume media tracks like video, audio, and screen sharing.
## Installation
To use the SDK, install it via pip:
```bash
pip install huddle01
```
## Getting Started
Here's a quick example to get started:
### 1. Create a Huddle01 Room
Every interaction with the Huddle01 dRTC Network start with a Room, which is a container for peers and media streams.
You can read how to create a room [here](https://docs.huddle01.com/docs/apis/meeting-details/create-room).
### 2. Create an Access Token
Generate an access token using your API key and room ID.
```python
from huddle01.access_token import AccessToken, AccessTokenData, Role
data = AccessTokenData(
api_key="your_api_key",
room_id="room_id",
role=Role.HOST
)
token = AccessToken(data)
jwt_token = await token.to_jwt()
```
### 3. Initialize the Huddle Client
Connect to a room using the generated token.
```python
from huddle01.huddle_client import HuddleClient, HuddleClientOptions
options = HuddleClientOptions(autoConsume=True)
client = HuddleClient(project_id="project_id", options=options)
room = await client.create(room_id="room_id", token=jwt_token)
```
### 4. Work with Peers and Rooms
Manage peers, producers, and permissions.
```python
# Example: Access the local peer
local_peer = room.local_peer
# Example: List remote peers
remote_peers = room.remote_peers
```
### 5. Produce and Consume Media
Produce and consume tracks like video, audio, or screen.
#### Producing Media
To produce media, use the `LocalPeer.produce()` method.
```python
track = "video_track" # Replace with the actual media track
producer = await local_peer.produce(track)
```
#### Consuming Media
To consume media from a remote peer, use the `LocalPeer.consume()` method.
```python
producer_id = "producer_id" # Replace with the actual producer ID
consumer = await local_peer.consume(producer_id)
```
##### Auto-Consuming Media
To automatically consume media from all producers, set the `autoConsume` option to `True`.
```python
options = HuddleClientOptions(autoConsume=True)
client = HuddleClient(project_id="project_id", options=options)
room = await client.create(room_id="room_id", token=jwt_token)
```
### 5. Close the Connection
Always close the connection when done.
```python
await client.close()
```
## Modules
### 1. `access_token`
Manages access tokens, including permissions and roles.
### 2. `huddle_client`
Main entry point for connecting to the Huddle01 infrastructure. Manages rooms, peers, and communication.
### 3. `room`
Defines the structure and management of rooms.
### 4. `remote_peer`
Handles remote peers connected to a room.
### 5. `socket`
Manages WebSocket connections with advanced features like reconnection.
## Room
Its defined as the grouping of Peers sharing Media Streams with one another,
### Methoods
- `connect`: Method allows to connect to a Room, which emits an Event `RoomEvents.RoomJoined`
### Properties
- `state`: Provides the current connection state of the Room
- `local_peer`: Provides the Local Peer of the Room
- `remote_peers`: Provides the list of Remote Peers connected to the Room
## LocalPeer
Its defined as the Peer connected to the Room, which can Produce and Consume Media Streams.
### Methods
- `produce`: Method allows to produce a Media Stream, which emits an Event `PeerEvents.ProducerAdded`
- `consume`: Method allows to consume a Media Stream, which emits an Event `PeerEvents.ConsumerAdded`
### Properties
- `peer_id`: Provides the Peer ID of the Peer
- `role`: Provides the Role of the Peer, which can be `HOST` or `GUEST`
- `producers`: Provides the list of Producers of the Peer
- `consumers`: Provides the list of Consumers of the Peer
## RemotePeer
Its defined as the Peer connected to the Room, which can Produce and Consume Media Streams.
### Methods
- `get_producer`: Method allows to get a Producer by its `producer_id`, `label` or using both.
- `is_producing_label`: Method allows to check if the Peer is producing a Media Stream with a specific `label`
- `labels`: Method allows to get the list of Labels of the Peer
`producer_ids`: Method allows to get the list of Producer IDs of the Peer
### Properties
- `peer_id`: Provides the Peer ID of the Peer
- `role`: Provides the Role of the Peer, which can be `HOST` or `GUEST`
- `labels_to_producers`: Provides the mapping of Labels to Producers of the Peer
## Classes and Functions
### `AccessToken`
- `to_jwt()`: Generates a JWT token for authentication.
### `HuddleClient`
- `create(room_id: str, token: str)`: Connects to a room.
- `close()`: Closes the client and associated resources.
### `Room`
- `connect()`: Connects to a room.
- `state`: Provides the current connection state.
### `Socket`
- `connect(token: str)`: Establishes a WebSocket connection.
- `close(code: int)`: Closes the WebSocket connection.
### `LocalPeer`
- `produce(track: Any)`: Produces a media track.
- `consume(producer_id: str)`: Consumes a media track.
Raw data
{
"_id": null,
"home_page": null,
"name": "huddle01",
"maintainer": "Om Gupta",
"docs_url": null,
"requires_python": "<4.0,>=3.12",
"maintainer_email": "omgupta0720@gmail.com",
"keywords": "huddle01, video, conferencing",
"author": "Om Gupta",
"author_email": "omgupta0720@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/ff/ae/ada1055b3f19c5737070a1ed5a06cd5ef47887b464d1dc0b058e2abfa319/huddle01-1.0.5.tar.gz",
"platform": null,
"description": "\n# Huddle01 Python SDK\n\n## Overview\n\nThe Huddle01 Python SDK provides a comprehensive solution for interacting with Huddle01's infrastructure. It enables developers to build real-time communication systems with support for rooms, peers, active speakers, permissions, and WebSocket-based connections.\n\n## Features\n\n- **Access Token Management**: Generate and manage access tokens for secure communication.\n- **Room Management**: Create and manage rooms with various permissions and roles.\n- **Local and Remote Peers**: Define and manage local and remote peers, including their producers and roles.\n- **WebSocket Communication**: Connect to Huddle01's WebSocket server for real-time data exchange.\n- **Enhanced Event Handling**: Utilize `EnhancedEventEmitter` for subscribing and handling events seamlessly.\n- **Active Speaker Tracking**: Manage active speakers within a room.\n- **Produce and Consume Media**: Produce and consume media tracks like video, audio, and screen sharing.\n\n## Installation\n\nTo use the SDK, install it via pip:\n\n```bash\npip install huddle01\n```\n\n## Getting Started\n\nHere's a quick example to get started:\n\n### 1. Create a Huddle01 Room\nEvery interaction with the Huddle01 dRTC Network start with a Room, which is a container for peers and media streams.\n\nYou can read how to create a room [here](https://docs.huddle01.com/docs/apis/meeting-details/create-room).\n\n### 2. Create an Access Token\nGenerate an access token using your API key and room ID.\n\n```python\nfrom huddle01.access_token import AccessToken, AccessTokenData, Role\n\ndata = AccessTokenData(\n api_key=\"your_api_key\",\n room_id=\"room_id\",\n role=Role.HOST\n)\ntoken = AccessToken(data)\n\njwt_token = await token.to_jwt()\n```\n\n### 3. Initialize the Huddle Client\nConnect to a room using the generated token.\n\n```python\nfrom huddle01.huddle_client import HuddleClient, HuddleClientOptions\n\noptions = HuddleClientOptions(autoConsume=True)\n\nclient = HuddleClient(project_id=\"project_id\", options=options)\n\nroom = await client.create(room_id=\"room_id\", token=jwt_token)\n```\n\n### 4. Work with Peers and Rooms\nManage peers, producers, and permissions.\n\n```python\n# Example: Access the local peer\nlocal_peer = room.local_peer\n\n# Example: List remote peers\nremote_peers = room.remote_peers\n```\n\n### 5. Produce and Consume Media\nProduce and consume tracks like video, audio, or screen.\n\n#### Producing Media\nTo produce media, use the `LocalPeer.produce()` method.\n\n```python\ntrack = \"video_track\" # Replace with the actual media track\nproducer = await local_peer.produce(track)\n```\n\n#### Consuming Media\nTo consume media from a remote peer, use the `LocalPeer.consume()` method.\n\n```python\nproducer_id = \"producer_id\" # Replace with the actual producer ID\nconsumer = await local_peer.consume(producer_id)\n```\n\n##### Auto-Consuming Media\nTo automatically consume media from all producers, set the `autoConsume` option to `True`.\n\n```python\noptions = HuddleClientOptions(autoConsume=True)\nclient = HuddleClient(project_id=\"project_id\", options=options)\n\nroom = await client.create(room_id=\"room_id\", token=jwt_token)\n```\n\n### 5. Close the Connection\nAlways close the connection when done.\n\n```python\nawait client.close()\n```\n\n## Modules\n\n### 1. `access_token`\nManages access tokens, including permissions and roles.\n\n### 2. `huddle_client`\nMain entry point for connecting to the Huddle01 infrastructure. Manages rooms, peers, and communication.\n\n### 3. `room`\nDefines the structure and management of rooms.\n\n### 4. `remote_peer`\nHandles remote peers connected to a room.\n\n### 5. `socket`\nManages WebSocket connections with advanced features like reconnection.\n\n## Room\nIts defined as the grouping of Peers sharing Media Streams with one another,\n\n### Methoods\n- `connect`: Method allows to connect to a Room, which emits an Event `RoomEvents.RoomJoined`\n\n### Properties\n- `state`: Provides the current connection state of the Room\n- `local_peer`: Provides the Local Peer of the Room\n- `remote_peers`: Provides the list of Remote Peers connected to the Room\n\n\n## LocalPeer\nIts defined as the Peer connected to the Room, which can Produce and Consume Media Streams.\n\n### Methods\n- `produce`: Method allows to produce a Media Stream, which emits an Event `PeerEvents.ProducerAdded`\n\n- `consume`: Method allows to consume a Media Stream, which emits an Event `PeerEvents.ConsumerAdded`\n\n### Properties\n- `peer_id`: Provides the Peer ID of the Peer\n- `role`: Provides the Role of the Peer, which can be `HOST` or `GUEST`\n- `producers`: Provides the list of Producers of the Peer\n- `consumers`: Provides the list of Consumers of the Peer\n\n## RemotePeer\nIts defined as the Peer connected to the Room, which can Produce and Consume Media Streams.\n\n### Methods\n- `get_producer`: Method allows to get a Producer by its `producer_id`, `label` or using both.\n- `is_producing_label`: Method allows to check if the Peer is producing a Media Stream with a specific `label`\n- `labels`: Method allows to get the list of Labels of the Peer\n`producer_ids`: Method allows to get the list of Producer IDs of the Peer\n\n### Properties\n- `peer_id`: Provides the Peer ID of the Peer\n- `role`: Provides the Role of the Peer, which can be `HOST` or `GUEST`\n- `labels_to_producers`: Provides the mapping of Labels to Producers of the Peer\n\n\n## Classes and Functions\n\n### `AccessToken`\n- `to_jwt()`: Generates a JWT token for authentication.\n\n### `HuddleClient`\n- `create(room_id: str, token: str)`: Connects to a room.\n- `close()`: Closes the client and associated resources.\n\n### `Room`\n- `connect()`: Connects to a room.\n- `state`: Provides the current connection state.\n\n### `Socket`\n- `connect(token: str)`: Establishes a WebSocket connection.\n- `close(code: int)`: Closes the WebSocket connection.\n\n### `LocalPeer`\n- `produce(track: Any)`: Produces a media track.\n- `consume(producer_id: str)`: Consumes a media track.\n\n",
"bugtrack_url": null,
"license": "BSD-3-Clause",
"summary": "Python Real-Time-SDK for Huddle01 dRTC Network",
"version": "1.0.5",
"project_urls": null,
"split_keywords": [
"huddle01",
" video",
" conferencing"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "974a20a786ecebcafd9a82141173e032cd5b282ef7e0651a87c7916f9dcd4103",
"md5": "bf9668a49c38c2a4917b3fd9d9df995f",
"sha256": "fd18266ca55d1f2fb89265760afb1828fd4065065c1cb3efdfc54a4309318a75"
},
"downloads": -1,
"filename": "huddle01-1.0.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "bf9668a49c38c2a4917b3fd9d9df995f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.12",
"size": 66513,
"upload_time": "2024-12-06T05:14:39",
"upload_time_iso_8601": "2024-12-06T05:14:39.023947Z",
"url": "https://files.pythonhosted.org/packages/97/4a/20a786ecebcafd9a82141173e032cd5b282ef7e0651a87c7916f9dcd4103/huddle01-1.0.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ffaeada1055b3f19c5737070a1ed5a06cd5ef47887b464d1dc0b058e2abfa319",
"md5": "5be674d581f5f13517719be1baa375fe",
"sha256": "0b0abeefa4614569a401c3410159ab46e9f3b03f020e84c3f7c5c28fb75e586e"
},
"downloads": -1,
"filename": "huddle01-1.0.5.tar.gz",
"has_sig": false,
"md5_digest": "5be674d581f5f13517719be1baa375fe",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.12",
"size": 49222,
"upload_time": "2024-12-06T05:14:41",
"upload_time_iso_8601": "2024-12-06T05:14:41.368104Z",
"url": "https://files.pythonhosted.org/packages/ff/ae/ada1055b3f19c5737070a1ed5a06cd5ef47887b464d1dc0b058e2abfa319/huddle01-1.0.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-06 05:14:41",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "huddle01"
}