Metadata-Version: 2.4
Name: p2p-stream-v2-yoyo
Version: 3.0.0
Summary: Billion-scale P2P live streaming — H.264 ABR, FEC, tiered mesh, HLS export
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: C++
Classifier: Topic :: Multimedia :: Video
Classifier: Topic :: System :: Networking
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: aiortc>=1.9.0
Requires-Dist: opencv-python>=4.9.0
Requires-Dist: click>=8.1.0
Requires-Dist: kademlia>=2.2.2
Requires-Dist: numpy>=1.26.0
Requires-Dist: av>=12.0.0
Requires-Dist: pybind11>=2.12.0
Requires-Dist: reedsolo>=1.7.0
Provides-Extra: gstreamer
Requires-Dist: PyGObject>=3.44.0; extra == "gstreamer"
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: provides-extra
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# p2p-stream v3

Billion-scale decentralised live streaming — H.264 multi-quality, FEC,
adaptive bitrate, tiered mesh, HLS/RTMP export, hardware encoder support.

## Architecture

```
Publisher (TIER_0: super-seed)
  └─ Relay nodes ×N  (TIER_1: 50 Mbps+, up to 100 children each)
      └─ Peer nodes ×N (TIER_2: 5 Mbps+,  up to 20 children each)
          └─ Viewers ×∞ (TIER_3: any bandwidth)
```

Every node caches segments. Fan-out=20, depth=10 → 20^10 viewers max.

## Install

```
sudo apt install libssl-dev liblz4-dev libminiupnpc-dev
pip install pybind11 cmake
pip install -e .
```

## Quick start

### Publisher
```python
import asyncio, p2p_stream

async def main():
    s = p2p_stream.StreamSession("myroom", qualities=(0,1,2), hls_dir="/tmp/hls")
    await s.publish(bootstrap=[("seed.example.com", 8468)])
    await asyncio.Event().wait()

asyncio.run(main())
```

### Watcher
```python
import asyncio, p2p_stream

async def main():
    s = p2p_stream.StreamSession("myroom")
    await s.watch(bootstrap=[("seed.example.com", 8468)])
    await p2p_stream.display_track(s.node.upstream_track)

asyncio.run(main())
```

## CLI

```
p2p-stream genkey
p2p-stream publish --room live --qualities 0,1,2 --hls /tmp/hls
p2p-stream watch   --room live --bootstrap seed:8468
p2p-stream relay   --room live --bootstrap seed:8468
p2p-stream stats   --room live --bootstrap seed:8468
```

## Quality levels

| ID | Name  | Resolution | Bitrate |
|----|-------|------------|---------|
| 0  | 360p  | 640×360    | 500 kbps|
| 1  | 480p  | 854×480    | 1 Mbps  |
| 2  | 720p  | 1280×720   | 2.5 Mbps|
| 3  | 1080p | 1920×1080  | 5 Mbps  |
| 4  | 4K    | 3840×2160  | 15 Mbps |

## HLS / RTMP export

VLC, OBS, and all video editors can consume the HLS output directly:
```
vlc /tmp/hls/stream.m3u8
ffmpeg -i /tmp/hls/stream.m3u8 -c copy output.mp4
ffmpeg -re -i /tmp/hls/stream.m3u8 -c copy -f flv rtmp://live.twitch.tv/app/KEY
```

## GStreamer

```python
from p2p_stream.compat import GStreamerSink
print(GStreamerSink.pipeline_string(1280, 720, 30))
```

## License

MIT
