Statistics
| Branch: | Revision:

peerstreamer-src / README.md @ 2b3d6257

History | View | Annotate | Download (3.08 KB)

1
# PeerStreamer-ng
2
PeerStreamer-ng [1] is P2P rel-time streaming platform.
3
It is specifically design for mesh networks and it is meant to be purely decentralized.
4

    
5
## Documentation
6
You can find documentation on usage and development on the official wiki:
7
https://ans.disi.unitn.it/redmine/projects/peerstreamer-ng/wiki
8

    
9
## Compilation
10
You need to install [Janus dependencies](https://github.com/meetecho/janus-gateway), on ubuntu:
11
```
12
sudo apt install libmicrohttpd-dev libjansson-dev libnice-dev 
13
	libssl-dev libsrtp-dev libsofia-sip-ua-dev libglib2.0-dev 
14
	libopus-dev libogg-dev libcurl4-openssl-dev pkg-config gengetopt 
15
	libtool automake
16
```
17

    
18
After that, you can get the executable by running:
19
``
20
$> make
21
``
22

    
23
To turn on all the debugging features, set the DEBUG environment variable:
24
``
25
$> DEBUG=1 make
26
``
27

    
28
## Test
29
PeerStreamer-ng comes with a unit test suite. It does require valgrind installed to run.
30
In the "test" folder are stored the test files. To run them and check code consistency run:
31
``
32
$> make tests
33
``
34

    
35
## Tutorial: Stream a web camera with WebRTC
36
_Tested on Ubuntu 17.10_
37

    
38
In this tutorial we are creating a streaming source first, 
39
 * Acquiring a media content from a local (usb) camera;
40
 * Encapsulating it in a RTP stream;
41
 * Creating a pstreamer P2P overlay;
42
 * Injecting the RTP stream in the overlay.
43

    
44
Then, we will launch PeerStreamer-ng to serve the P2P stream to the user through a browser supporting WebRTC.
45

    
46
#### The source
47
The following script captures a usb camera (/dev/video0) with FFmpeg which is used to stream it locally through RTP.
48
It is important to note, to be able to serve the stream through WebRTC, FFmpeg must transcode the video with VP8.
49
It also launches a source instance of pstreamer that takes such stream in input and use P2P mechanism to distribute it to the attaching peers.
50

    
51
Overall, this script creates a _PeerStreamer-ng channel_ at IP address 127.0.0.1 on port 6000 and it saves its description on a local channel list file called _channels.csv_ which we will use to feed PeerStreamer-ng with.
52

    
53
```
54
NAME="My Channel"
55
VIDEO=/dev/video0
56
SDPFILE="file://${PWD}/channel.sdp"
57
SOURCE_PEER_PORT=6000
58
RTP_BASE_PORT=5002
59
HOST_EXT_IP=127.0.0.1
60

    
61
echo "$NAME,$HOST_EXT_IP,$SOURCE_PEER_PORT,QUALITY,http://$HOST_EXT_IP:8000/channel.sdp" > channels.csv
62

    
63
ffmpeg -re -i ${VIDEO} -vcodec libvpx -deadline realtime -an -f rtp rtp://127.0.0.1:$((RTP_BASE_PORT+2))\
64
	-sdp_file $SDPFILE &
65
FFMPEG_PID=$!
66

    
67
Libs/pstreamer/pstreamer -p 0 -c "iface=lo,port=$SOURCE_PEER_PORT,chunkiser=rtp,audio=$RTP_BASE_PORT,\
68
	video=$((RTP_BASE_PORT+2)),addr=127.0.0.1,max_delay_ms=50" 
69
SOURCE_PEER_PID=$!
70

    
71
trap "kill $SOURCE_PEER_PID $FFMPEG_PID" SIGINT SIGTERM EXIT
72
```
73

    
74
You can download [the script above](https://ans.disi.unitn.it/redmine/attachments/download/118/webrtp_source_camera.sh) from the project site.
75

    
76
#### PeerStreamer-ng
77

    
78
The following command executes PeerStreamer-ng and it start the HTTP interfaces.
79
Pages are now served on port 3000 (overridable through the flags, see the command line help).
80

    
81
```
82
./peerstreamer-ng -c channel.csv
83
```
84

    
85
## References
86
[1] https://ans.disi.unitn.it/redmine/projects/peerstreamer-ng