Skip to content

Commit cba1094

Browse files
committed
create documentation using mkdocs
1 parent 3fbeb05 commit cba1094

70 files changed

Lines changed: 14510 additions & 19 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.readthedocs.yaml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55
# Required
66
version: 2
77

8-
# Build documentation in the docs/ directory with Sphinx
9-
sphinx:
10-
configuration: docs/conf.py
8+
# Build documentation with MkDocs
9+
mkdocs:
10+
configuration: mkdocs.yml
1111

1212
# Optionally build your docs in additional formats such as PDF
1313
formats: all
1414

1515
build:
1616
os: "ubuntu-22.04"
1717
tools:
18-
python: "3.7"
18+
python: "3.11"
1919
jobs:
2020
post_create_environment:
2121
# Install poetry
@@ -24,6 +24,12 @@ build:
2424
# Tell poetry to not use a virtual environment
2525
- poetry config virtualenvs.create false
2626
post_install:
27-
# Install dependencies with 'docs' dependency group
27+
# Install dependencies with 'dev' dependency group
2828
# https://python-poetry.org/docs/managing-dependencies/#dependency-groups
2929
- poetry install --with dev
30+
31+
# Python configuration
32+
python:
33+
install:
34+
- method: pip
35+
path: .

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,46 @@ Server ping:
161161

162162
https://janus-client-in-python.readthedocs.io/
163163

164+
### Documentation Development
165+
166+
This project uses [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/) for documentation.
167+
168+
#### Setup
169+
170+
Install development dependencies:
171+
172+
```bash
173+
poetry install --with dev
174+
```
175+
176+
#### Local Development
177+
178+
To serve the documentation locally with live reload:
179+
180+
```bash
181+
poetry run mkdocs serve
182+
```
183+
184+
The documentation will be available at http://127.0.0.1:8000/
185+
186+
#### Building Documentation
187+
188+
To build the documentation for production:
189+
190+
```bash
191+
poetry run mkdocs build
192+
```
193+
194+
The built documentation will be in the `site/` directory.
195+
196+
#### Documentation Structure
197+
198+
- `docs/index.md` - Main documentation page
199+
- `docs/session.md` - Session API documentation
200+
- `docs/plugins.md` - Plugin API documentation
201+
- `docs/transport.md` - Transport API documentation
202+
- `mkdocs.yml` - MkDocs configuration file
203+
164204
## Experiments
165205

166206
FFmpeg support for VideoRoom plugin has now been moved to `experiments` folder, together with GStreamer support.
Lines changed: 1 addition & 0 deletions
Loading

docs/index.md

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# Python Janus Client
2+
3+
Easily send and share WebRTC media through [Janus](https://github.com/meetecho/janus-gateway) WebRTC server.
4+
5+
## Key Features
6+
7+
- Supports HTTP/s and WebSockets communication with Janus.
8+
- Support Admin/Monitor API:
9+
- Generic requests
10+
- Configuration related requests
11+
- Token related requests
12+
- Supports Janus plugin:
13+
- EchoTest Plugin
14+
- VideoCall Plugin
15+
- VideoRoom Plugin
16+
- Extendable Transport class and Plugin class
17+
18+
## Library Installation
19+
20+
```bash
21+
pip install janus-client
22+
```
23+
24+
## Getting Started
25+
26+
### Simple Connect And Disconnect
27+
28+
```python
29+
import asyncio
30+
from janus_client import JanusSession, JanusEchoTestPlugin, JanusVideoRoomPlugin
31+
32+
# Protocol will be derived from base_url
33+
base_url = "wss://janusmy.josephgetmyip.com/janusbasews/janus"
34+
# OR
35+
base_url = "https://janusmy.josephgetmyip.com/janusbase/janus"
36+
37+
session = JanusSession(base_url=base_url)
38+
39+
plugin_handle = JanusEchoTestPlugin()
40+
41+
# Attach to Janus session
42+
await plugin_handle.attach(session=session)
43+
44+
# Destroy plugin handle
45+
await plugin_handle.destroy()
46+
```
47+
48+
This will create a plugin handle and then destroy it.
49+
50+
Notice that we don't need to call connect or disconnect explicitly. It's managed internally.
51+
52+
### Make Video Calls
53+
54+
```python
55+
import asyncio
56+
from janus_client import JanusSession, JanusVideoCallPlugin
57+
from aiortc.contrib.media import MediaPlayer, MediaRecorder
58+
59+
async def main():
60+
# Create session
61+
session = JanusSession(
62+
base_url="wss://janusmy.josephgetmyip.com/janusbasews/janus",
63+
)
64+
65+
# Create plugin
66+
plugin_handle = JanusVideoCallPlugin()
67+
68+
# Attach to Janus session
69+
await plugin_handle.attach(session=session)
70+
71+
# Prepare username and media stream
72+
username = "testusernamein"
73+
username_out = "testusernameout"
74+
75+
player = MediaPlayer(
76+
"desktop",
77+
format="gdigrab",
78+
options={
79+
"video_size": "640x480",
80+
"framerate": "30",
81+
"offset_x": "20",
82+
"offset_y": "30",
83+
},
84+
)
85+
recorder = MediaRecorder("./videocall_record_out.mp4")
86+
87+
# Register myself as testusernameout
88+
result = await plugin_handle.register(username=username_out)
89+
90+
# Call testusernamein
91+
result = await plugin_handle.call(
92+
username=username, player=player, recorder=recorder
93+
)
94+
95+
# Wait awhile then hangup
96+
await asyncio.sleep(30)
97+
98+
result = await plugin_handle.hangup()
99+
100+
# Destroy plugin
101+
await plugin_handle.destroy()
102+
103+
# Destroy session
104+
await session.destroy()
105+
106+
107+
if __name__ == "__main__":
108+
try:
109+
asyncio.run(main())
110+
except KeyboardInterrupt:
111+
pass
112+
```
113+
114+
This example will register to the VideoCall plugin using username `testusernameout`. It will then call the user registered using the username `testusernamein`.
115+
116+
A portion of the screen will be captured and sent in the call media stream.
117+
The incoming media stream will be saved into `videocall_record_out.mp4` file.

0 commit comments

Comments
 (0)