Skip to content

Commit b4d1580

Browse files
committed
chore: make demo step-by-step
1 parent 4b33792 commit b4d1580

File tree

1 file changed

+64
-18
lines changed

1 file changed

+64
-18
lines changed

README.md

Lines changed: 64 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,69 +34,115 @@ To ensure wide hardware acceleration support, compatibility with embedded device
3434

3535
## Quickstart
3636

37-
The easiest way to run PulseBeam is with Docker:
37+
Getting started is a simple, step-by-step process. First, you'll run the server on your machine, and then you'll connect to it using the browser-based demos.
38+
39+
### Step 1: Run the PulseBeam Server
40+
41+
You must have the server running before the demo clients can connect. The easiest way to start it is with Docker.
42+
43+
Open your terminal and run the following command:
3844

3945
```bash
4046
docker run --rm --net=host ghcr.io/pulsebeamdev/pulsebeam:pulsebeam-v0.1.12
41-
````
47+
```
48+
49+
This command starts the PulseBeam server, which is now listening for connections on your machine. Keep this terminal window running.
4250

43-
Other ways to run:
51+
> **Other ways to run:**
52+
>
53+
> * **Binary:** download from [Releases](https://github.com/pulsebeamdev/pulsebeam/releases/latest)
54+
> * **Source:** `cargo run --release -p pulsebeam`
4455
45-
* **Binary:** download from [Releases](https://github.com/pulsebeamdev/pulsebeam/releases)
46-
* **Source:** `cargo run --release -p pulsebeam`
56+
### Step 2: Run the Browser Demo
4757

58+
With the server running, you can use the demo clients. The snippets below show the core JavaScript logic.
4859

49-
### Demo: Broadcast
60+
**Note:** The linked JSFiddles are configured to connect to `http://localhost:3000` and are intended to be run on the **same machine** as the server. See the section below for instructions on testing with other devices.
5061

51-
The following snippets demonstrate how to use the browser-native WebRTC API to interact with PulseBeam. The HTML and UI code has been removed for clarity.
62+
#### A. Start the Publisher
5263

53-
Full, runnable examples are available in the JSFiddle links.
64+
The publisher page accesses your webcam and sends the video stream to your local PulseBeam server.
5465

55-
#### Publisher (sends video)
66+
* **[Open Publisher Demo in JSFiddle](https://jsfiddle.net/lherman/0bqe6xnv/)**
5667

57-
This snippet shows the core JavaScript logic for publishing a video stream.
68+
Once the page loads, click **"Start Publishing"** to begin the stream.
5869

5970
```javascript
71+
// Core publisher logic
6072
const pc = new RTCPeerConnection();
6173

74+
// 1. Get user's video and add it to the connection
6275
const stream = await navigator.mediaDevices.getUserMedia({ video: true });
63-
pc.addTransceiver("video", { direction: "sendonly" }).sender.replaceTrack(stream.getVideoTracks()[0]);
76+
const trans = pc.addTransceiver("video", { direction: "sendonly" });
77+
trans.sender.replaceTrack(stream.getVideoTracks()[0]);
6478

79+
// 2. Create an SDP offer and send it to your local PulseBeam server
6580
const offer = await pc.createOffer();
6681
await pc.setLocalDescription(offer);
67-
6882
const res = await fetch("http://localhost:3000/api/v1/rooms/demo", {
6983
method: "POST",
7084
headers: { "Content-Type": "application/sdp" },
7185
body: offer.sdp
7286
});
7387

74-
await pc.setRemoteDescription({ type: "answer", sdp: await res.text() });
88+
// 3. Set the remote description with PulseBeam's answer
89+
const answer = await res.text();
90+
await pc.setRemoteDescription({ type: "answer", sdp: answer });
7591
```
7692

77-
**See the full example:** [Open Publisher JSFiddle](https://jsfiddle.net/lherman/0bqe6xnv/)
93+
---
94+
95+
#### B. Start the Viewer
96+
97+
The viewer page subscribes to the video stream. Open the link in a **new browser tab on the same machine** to test.
7898

79-
#### Viewer (receives video)
99+
* **[Open Viewer Demo in JSFiddle](https://jsfiddle.net/lherman/xotv9h6m)**
100+
101+
Click **"Start Viewing,"** and you should see the video from the publisher tab.
80102

81103
```javascript
104+
// Core viewer logic
82105
const pc = new RTCPeerConnection();
83106

107+
// 1. Set up the connection to receive video
84108
pc.addTransceiver("video", { direction: "recvonly" });
85109
pc.ontrack = e => remoteVideo.srcObject = e.streams[0]; // 'remoteVideo' is a <video> element
86110

111+
// 2. Create an SDP offer to signal intent to receive
87112
const offer = await pc.createOffer();
88113
await pc.setLocalDescription(offer);
89-
90114
const res = await fetch("http://localhost:3000/api/v1/rooms/demo", {
91115
method: "POST",
92116
headers: { "Content-Type": "application/sdp" },
93117
body: offer.sdp
94118
});
95119

96-
await pc.setRemoteDescription({ type: "answer", sdp: await res.text() });
120+
// 3. Set the remote description with PulseBeam's answer
121+
const answer = await res.text();
122+
await pc.setRemoteDescription({ type: "answer", sdp: answer });
97123
```
98124

99-
**See the full example:** [Open Viewer JSFiddle](https://jsfiddle.net/lherman/xotv9h6m)
125+
### Optional: Testing From Another Device
126+
127+
To run the viewer on a different device on your local network (like your phone), you must replace `localhost` with your computer's local network IP address.
128+
129+
1. **Find your computer's Local IP Address.** On the machine running the Docker container, open a terminal and run:
130+
* **macOS / Linux**: `ifconfig` or `ip a`
131+
* **Windows**: `ipconfig`
132+
Look for an address like `192.168.1.123`.
133+
134+
2. **Modify the JSFiddle Code.** Open the [Viewer JSFiddle](https://jsfiddle.net/lherman/xotv9h6m) on your second device. In the JavaScript panel, find the `fetch` call and replace `localhost` with your computer's IP address:
135+
136+
```javascript
137+
// Change this line in the JSFiddle on your second device
138+
const res = await fetch("http://YOUR_COMPUTER_IP_ADDRESS:3000/api/v1/rooms/demo", {
139+
// ...
140+
});
141+
```
142+
143+
3. **Run the demo.** Now, when you click "Start Viewing," it will connect to the server running on your other computer.
144+
145+
> **Note:** This may require you to adjust your computer's firewall settings to allow incoming connections on port `3000`.
100146
101147
## Roadmap
102148

0 commit comments

Comments
 (0)