# gstreamer.rs — Video Streaming

<span style="white-space: pre-wrap;">Receives H.264 video from the rover over UDP, decodes it, and serves it as MJPEG over HTTP so the frontend can display it in </span>`<span class="editor-theme-code"><img></span>`<span style="white-space: pre-wrap;"> tags.</span>

### Pipeline per camera

```
udpsrc (UDP port) → rtpjitterbuffer → rtph264depay → avdec_h264 → videoconvert → jpegenc → appsink
```

<span style="white-space: pre-wrap;">Each decoded JPEG frame is placed into a shared </span>`<span class="editor-theme-code">FrameBuffer</span>`<span style="white-space: pre-wrap;"> (</span>`<span class="editor-theme-code">Arc<Mutex<Option<Bytes>>></span>`<span style="white-space: pre-wrap;">). A separate async HTTP server (using </span>`<span class="editor-theme-code">warp</span>`<span style="white-space: pre-wrap;">) reads from that buffer and streams it as </span>`<span class="editor-theme-code">multipart/x-mixed-replace</span>`<span style="white-space: pre-wrap;"> — the standard MJPEG format.</span>

### Port mapping

<table id="bkmrk-udp-input-porthttp-o"><colgroup><col style="width: 240px;"></col><col style="width: 240px;"></col><col style="width: 240px;"></col></colgroup><tbody><tr><td>**UDP input port**

</td><td>**HTTP output port**

</td><td>**Camera**

</td></tr><tr style="height: 10px;"><td>4500

</td><td>5000

</td><td>Depth / front camera

</td></tr><tr><td>4501

</td><td>5001

</td><td>Secondary camera

</td></tr><tr><td>4502

</td><td>5002

</td><td>Arm camera

</td></tr></tbody></table>

### Feed health monitoring

A background task (`<span class="editor-theme-code">watch_feed_health</span>`<span style="white-space: pre-wrap;">) polls each stream every 500ms. If no frame has been received within 2 seconds, the stream is considered stale. The backend emits a </span>`<span class="editor-theme-code">camera-feed-status</span>`<span style="white-space: pre-wrap;"> Tauri event to the frontend with the payload:</span>

```json
{ "port": 5000, "stale": true }
```

The frontend listens for this event to show feed status indicators.

<p class="callout info">**For development without rover hardware**<span style="white-space: pre-wrap;">, run the </span>`<span class="editor-theme-code">fake_camera_gstreamer</span>`<span style="white-space: pre-wrap;">. For instructions see </span>[Common Operations](https://bookstack.roboteamtwente.nl/link/159#bkmrk-video-feeds).</p>