aboutsummaryrefslogtreecommitdiffstats
path: root/stream
diff options
context:
space:
mode:
Diffstat (limited to 'stream')
-rwxr-xr-xstream/encode/kliniskarbeidsflate/reflect-krosus.sh4
-rwxr-xr-xstream/encode/kliniskarbeidsflate/reflect.sh4
-rwxr-xr-xstream/encode/kliniskarbeidsflate/transcode-event-sd.sh7
-rwxr-xr-xstream/encode/kliniskarbeidsflate/transcode-fugle-flash.sh7
-rwxr-xr-xstream/encode/kliniskarbeidsflate/transcode-noc-fisheye-flash.sh6
-rwxr-xr-xstream/encode/kliniskarbeidsflate/transcode-south.sh9
-rwxr-xr-xstream/encode/politietno/foo-withoutreflect.sh6
-rwxr-xr-xstream/encode/politietno/foo.sh6
-rwxr-xr-xstream/encode/politietno/svineri.sh24
-rwxr-xr-xstream/encode/politietno/transcode-duplicate.sh7
-rwxr-xr-xstream/encode/politietno/transcode-duplicate2.sh10
-rwxr-xr-xstream/encode/politietno/transcode.sh6
-rwxr-xr-xstream/encode/politietno/vid.sh7
-rwxr-xr-xstream/reflect/count-retrofit.sh22
-rwxr-xr-xstream/reflect/count.sh22
-rwxr-xr-xstream/reflect/htb.sh79
-rwxr-xr-xstream/reflect/old/reflectsouth.sh5
-rwxr-xr-xstream/reflect/old/reflectsouth720p.sh6
-rwxr-xr-xstream/reflect/reflect-event-lol.sh7
-rwxr-xr-xstream/reflect/reflect-event-sd.sh5
-rwxr-xr-xstream/reflect/reflect-event.sh7
-rwxr-xr-xstream/reflect/reflect-fugle-flash.sh6
-rwxr-xr-xstream/reflect/reflect-fuglecam.sh5
-rwxr-xr-xstream/reflect/reflect-nicfisheye-flash.sh5
-rwxr-xr-xstream/reflect/reflect-noc-transcodes.sh5
-rwxr-xr-xstream/reflect/reflect-nocfisheye.sh5
-rwxr-xr-xstream/reflect/reflect-south-raw.sh5
-rwxr-xr-xstream/reflect/reflect-south-transcode.sh5
-rwxr-xr-xstream/reflect/transcode-event-flash.sh6
-rwxr-xr-xstream/reflect/transcode-fugle-flash.sh6
-rwxr-xr-xstream/reflect/transcode-nocfisheye-flash.sh6
-rwxr-xr-xstream/reflect/transcode-south-flash.sh6
-rw-r--r--stream/reflect/usage.txt3
-rwxr-xr-xstream/transcode/count.sh17
-rwxr-xr-xstream/transcode/flash.sh6
-rwxr-xr-xstream/transcode/flashtest.sh5
-rwxr-xr-xstream/transcode/ios-sd.sh7
-rwxr-xr-xstream/transcode/ios-south.sh7
-rw-r--r--stream/vlc-patches/listen_all.git.patch28
-rw-r--r--stream/vlc-patches/vlc-git-sesse.patch131
-rw-r--r--stream/vlc-patches/vlc-mark.patch136
41 files changed, 656 insertions, 0 deletions
diff --git a/stream/encode/kliniskarbeidsflate/reflect-krosus.sh b/stream/encode/kliniskarbeidsflate/reflect-krosus.sh
new file mode 100755
index 0000000..a40500c
--- /dev/null
+++ b/stream/encode/kliniskarbeidsflate/reflect-krosus.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+while :; do vlc -vvv udp://@:9017 --network-caching 2000 --no-sout-audio --sout '#std{access=udp,mux=ts,dst=151.216.125.4:4016}' --intf dummy --ttl 60 vlc://quit;
+ sleep 5
+done
diff --git a/stream/encode/kliniskarbeidsflate/reflect.sh b/stream/encode/kliniskarbeidsflate/reflect.sh
new file mode 100755
index 0000000..7419433
--- /dev/null
+++ b/stream/encode/kliniskarbeidsflate/reflect.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+while :; do vlc -vvv rtsp://151.216.106.2:554/live1.sdp --network-caching 2000 --no-sout-audio --sout '#std{access=udp,mux=ts,dst=127.0.0.1:9017}' --intf dummy --ttl 60 vlc://quit;
+ sleep 5
+done
diff --git a/stream/encode/kliniskarbeidsflate/transcode-event-sd.sh b/stream/encode/kliniskarbeidsflate/transcode-event-sd.sh
new file mode 100755
index 0000000..fb5c055
--- /dev/null
+++ b/stream/encode/kliniskarbeidsflate/transcode-event-sd.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+while :; do
+cvlc -vv udp://@:4014 --network-caching 2000 --sout-x264-preset fast --sout-x264-tune film --sout-transcode-threads 22 --no-sout-x264-interlaced --sout-x264-keyint 50 --sout-x264-lookahead 100 \
+--sout '#transcode{height=576,vcodec=h264,vb=2000,acodec=mp4a,aenc=fdkaac,ab=128}:std{access=udp,mux=ts,dst=151.216.125.4:4014}'
+sleep 1
+done
diff --git a/stream/encode/kliniskarbeidsflate/transcode-fugle-flash.sh b/stream/encode/kliniskarbeidsflate/transcode-fugle-flash.sh
new file mode 100755
index 0000000..a924de2
--- /dev/null
+++ b/stream/encode/kliniskarbeidsflate/transcode-fugle-flash.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+while :; do
+cvlc -vv --network-caching 3000 --sout-x264-preset fast --sout-transcode-threads 10 --sout-x264-tune film --no-sout-x264-interlaced --sout-x264-lookahead 50 --sout-x264-vbv-maxrate 800 --sout-x264-vbv-bufsize 800 --sout-x264-keyint 50 -v http://stream.tg13.gathering.org:3015 vlc://quit \
+--sout '#transcode{height=480,fps=25,vcodec=h264,vb=800,acodec=aac,ab=128,deinterlace}:std{access=udp,mux=ffmpeg{mux=flv},dst=151.216.125.4:4020}'
+ sleep 1
+done
+
diff --git a/stream/encode/kliniskarbeidsflate/transcode-noc-fisheye-flash.sh b/stream/encode/kliniskarbeidsflate/transcode-noc-fisheye-flash.sh
new file mode 100755
index 0000000..3491232
--- /dev/null
+++ b/stream/encode/kliniskarbeidsflate/transcode-noc-fisheye-flash.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+while :; do
+cvlc -vv --network-caching 5000 --sout-x264-preset fast --sout-transcode-threads 16 --sout-x264-tune film --no-sout-x264-interlaced --sout-x264-lookahead 50 --sout-x264-vbv-maxrate 800 --sout-x264-vbv-bufsize 800 --sout-x264-keyint 50 -v http://stream.tg13.gathering.org:3018 vlc://quit \
+--sout '#transcode{width=768,height=768,vcodec=h264,vb=800}:std{access=udp,mux=ts,dst=151.216.125.4:4019}'
+ sleep 1
+done
diff --git a/stream/encode/kliniskarbeidsflate/transcode-south.sh b/stream/encode/kliniskarbeidsflate/transcode-south.sh
new file mode 100755
index 0000000..d5a83e4
--- /dev/null
+++ b/stream/encode/kliniskarbeidsflate/transcode-south.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+while :; do cvlc -vv udp://@:9017 \
+ --sout-ts-shaping=1000 --sout-ts-use-key-frames --sout-ts-dts-delay=500 --sout-transcode-fps 0 --no-sout-transcode-audio-sync --network-caching 2000 \
+ --no-sout-x264-interlaced --sout-x264-preset veryfast --sout-x264-tune film \
+ --sout-transcode-threads 3 --sout-x264-keyint 25 --no-sout-audio \
+ --sout '#duplicate{dst="transcode{vcodec=h264,height=720,vb=3000}:std{access=udp,mux=ts,dst=151.216.125.4:4017}",dst="std{access=udp,mux=ts,dst=151.216.125.4:4016}"}' \
+ --intf dummy --ttl 20 vlc://quit;
+ sleep 1
+done
diff --git a/stream/encode/politietno/foo-withoutreflect.sh b/stream/encode/politietno/foo-withoutreflect.sh
new file mode 100755
index 0000000..21bcda6
--- /dev/null
+++ b/stream/encode/politietno/foo-withoutreflect.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+/home/techserver/vlc/vlc -I dummy -vvvv --decklink-audio-connection embedded --live-caching 3000 --decklink-aspect-ratio 16:9 --decklink-mode hp50 \
+ --sout-x264-preset slow --sout-x264-tune film --sout-transcode-threads 23 --no-sout-x264-interlaced \
+ --sout-x264-keyint 50 --sout-x264-lookahead 100 --sout-x264-vbv-maxrate 5000 --sout-x264-vbv-bufsize 5000 \
+ -v decklink:// vlc://quit \
+ --sout '#transcode{vcodec=h264,vb=3000,acodec=mp4a,aenc=fdkaac,ab=256}:std{access=udp,mux=ts,dst=151.216.124.80:9094}'
diff --git a/stream/encode/politietno/foo.sh b/stream/encode/politietno/foo.sh
new file mode 100755
index 0000000..dfdfc03
--- /dev/null
+++ b/stream/encode/politietno/foo.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+/home/techserver/vlc/vlc -I dummy -vvvv --decklink-audio-connection embedded --live-caching 3000 --decklink-aspect-ratio 16:9 --decklink-mode hp50 \
+ --sout-x264-preset slow --sout-x264-tune film --sout-transcode-threads 23 --no-sout-x264-interlaced \
+ --sout-x264-keyint 50 --sout-x264-lookahead 100 --sout-x264-vbv-maxrate 5000 --sout-x264-vbv-bufsize 5000 \
+ -v decklink:// vlc://quit \
+ --sout '#transcode{vcodec=h264,vb=3000,acodec=mp4a,aenc=fdkaac,ab=256}:std{access=udp,mux=ts,dst=151.216.125.4:4013}'
diff --git a/stream/encode/politietno/svineri.sh b/stream/encode/politietno/svineri.sh
new file mode 100755
index 0000000..ac09601
--- /dev/null
+++ b/stream/encode/politietno/svineri.sh
@@ -0,0 +1,24 @@
+~/decklink-sdk/Linux/Samples/bmdtools/bmdcapture $(
+ echo '-C 0' # Decklink card number
+ echo '-m 11' # Input format mode (ID 8 = 1080i/25)
+ echo '-V 4' # Video input (4 = SDI)
+ echo '-A 2' # Audio input (2 = Embedded)
+ echo '-c 2' # Number of audio channels
+ echo '-M 10' # Memory limit, in GB, for the output buffer (it leaks slightly...)
+ echo '-F nut -f pipe:1' # Output format and file name
+) | \
+ffmpeg $(
+ echo '-y -re -i -' # Input from pipe
+ echo '-v verbose' # Verbosity level
+# echo '-filter:v format=yuv420p,yadif=1:0:0' # Video format conversion and deinterlacing
+ echo '-filter:v scale=480x270'
+ echo '-c:v libx264' # Video encoder to use
+ echo '-tune film -preset slow' # Video encoder options
+ echo '-x264opts keyint=50:rc-lookahead=0' # x264-specific options
+# echo '-b:v 1M' # Video bitrate
+ echo '-c:a libfaac' # Audio encoder to use
+ echo '-b:a 192k' # Audio bitrate
+ echo '-threads auto' # Number of threads to use
+ echo '-f mpegts udp://151.216.125.4:4013' # Output format and file name
+)
+
diff --git a/stream/encode/politietno/transcode-duplicate.sh b/stream/encode/politietno/transcode-duplicate.sh
new file mode 100755
index 0000000..591e529
--- /dev/null
+++ b/stream/encode/politietno/transcode-duplicate.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+while :; do
+cvlc -vv --decklink-audio-connection embedded --live-caching 2000 --decklink-aspect-ratio 16:9 --decklink-mode hp50 \
+ --sout-x264-preset fast --sout-x264-tune film --sout-transcode-threads 24 --no-sout-x264-interlaced --sout-x264-keyint 50 --sout-x264-lookahead 100 --sout-x264-vbv-maxrate 4000 --sout-x264-vbv-bufsize 4000 decklink:// vlc://quit \
+ --sout '#duplicate{dst="transcode{vcodec=h264,vb=6000,acodec=mp4a,aenc=fdkaac,ab=256}:std{access=udp,mux=ts,dst=151.216.125.4:4013}",dst="transcode{height=576,vcodec=h264,vb=2000,acodec=mp4a,aenc=fdkaac,ab=128}:std{access=udp,mux=ts,dst=151.216.125.4:4014}"}'
+sleep 1
+done
diff --git a/stream/encode/politietno/transcode-duplicate2.sh b/stream/encode/politietno/transcode-duplicate2.sh
new file mode 100755
index 0000000..6b85d1d
--- /dev/null
+++ b/stream/encode/politietno/transcode-duplicate2.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+# event signal:
+# transcode hd and move to reflector
+# mirror signal to encoder2 (kliniskarbeidsflate) and transcode sd -> reflector
+while :; do
+cvlc -vv --decklink-audio-connection embedded --live-caching 2000 --decklink-aspect-ratio 16:9 --decklink-mode hp50 \
+ --sout-x264-preset fast --sout-x264-tune film --sout-transcode-threads 22 --no-sout-x264-interlaced --sout-x264-keyint 50 --sout-x264-lookahead 100 decklink:// vlc://quit \
+ --sout '#duplicate{dst="transcode{vcodec=h264,vb=6000,acodec=mp4a,aenc=fdkaac,ab=256}:std{access=udp,mux=ts,dst=151.216.125.4:4013}",dst="std{access=udp,mux=ts,dst=151.216.125.9:4014}"}'
+sleep 1
+done
diff --git a/stream/encode/politietno/transcode.sh b/stream/encode/politietno/transcode.sh
new file mode 100755
index 0000000..a4feda9
--- /dev/null
+++ b/stream/encode/politietno/transcode.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+cvlc -I dummy -vvvv --decklink-audio-connection embedded --live-caching 2000 --decklink-aspect-ratio 16:9 --decklink-mode hp50 \
+ --sout-x264-preset slow --sout-x264-tune film --sout-transcode-threads 23 --no-sout-x264-interlaced \
+ --sout-x264-keyint 50 --sout-x264-lookahead 100 --sout-x264-vbv-maxrate 6000 --sout-x264-vbv-bufsize 6000 \
+ -v decklink:// vlc://quit \
+ --sout '#transcode{vcodec=h264,vb=6000,acodec=mp4a,aenc=fdkaac,ab=256}:std{access=udp,mux=ts,dst=151.216.125.4:4013}'
diff --git a/stream/encode/politietno/vid.sh b/stream/encode/politietno/vid.sh
new file mode 100755
index 0000000..8c5bcba
--- /dev/null
+++ b/stream/encode/politietno/vid.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+# VLC for box connected to broadcast-equipment Blackmagic/Decklink: Audio and Video from SDI Transcodes HD and sends via UDP to reflector - Marius / Tech:Server
+while :; do cvlc -vv --no-decklink-tenbits --decklink-audio-connection embedded --live-caching 1800 --decklink-aspect-ratio 16:9 --decklink-mode hp50 \
+ --sout-x264-preset medium --sout-x264-tune film --sout-transcode-threads 15 --no-sout-x264-interlaced --sout-x264-keyint 100 --sout-x264-lookahead 50 --sout-x264-vbv-maxrate 7000 --sout-x264-vbv-bufsize 7000 -v decklink:// vlc://quit \
+ --sout '#transcode{vcodec=h264,vb=3000,acodec=mp3,ab=256}:std{access=udp,mux=ts,dst=151.216.125.4:4013}'
+ sleep 1
+done
diff --git a/stream/reflect/count-retrofit.sh b/stream/reflect/count-retrofit.sh
new file mode 100755
index 0000000..1ff8c30
--- /dev/null
+++ b/stream/reflect/count-retrofit.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+while :; do
+ date=$(date +"%Y-%m-%d-%H:%M:%S")
+ #( lsof -n | grep vlc ; ssh root@gaffeltruck.tg12.gathering.org 'lsof -n | grep vlc' ) > /var/log/stream-count/$date
+ sudo lsof -n | grep vlc > /var/log/stream-count/$date
+ for PORT in 3013 3014 3015 3016 3017 3018 3019 5013 5015 5019; do
+ for PROTO in IPv4 IPv6; do
+ if [ "$PROTO" = "IPv4" ]; then
+ GREPFOR='151\.216'
+ else
+ GREPFOR='2a02:ed02:'
+ fi
+
+ # 151.216.x.x / 2a02:ed02::/32 -> TG13
+ cat /var/log/stream-count/$date | grep EST | egrep $GREPFOR | egrep "(151\.216\..*|2a02:ed02:.*):$PORT->" | cut -d'>' -f2 | sed 's/:[0-9]\+ (ESTABLISHED)//' | sort -u | grep -vEc -e "\[2a02:ed02:|151\.216\." | while read foo; do echo "$date $PORT $PROTO external $foo"; done | tee -a better_datacube.log
+ cat /var/log/stream-count/$date | grep EST | egrep $GREPFOR | egrep "(151\.216\..*|2a02:ed02:.*):$PORT->" | cut -d'>' -f2 | sed 's/:[0-9]\+ (ESTABLISHED)//' | sort -u | grep -Ec -e "\[2a02:ed02:|151\.216\." | while read foo; do echo "$date $PORT $PROTO internal $foo"; done | tee -a better_datacube.log
+ done
+ done
+ sleep 60
+done;
+
diff --git a/stream/reflect/count.sh b/stream/reflect/count.sh
new file mode 100755
index 0000000..e1fa38c
--- /dev/null
+++ b/stream/reflect/count.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+while :; do
+ date=$(date +"%Y-%m-%d-%H:%M:%S")
+ #( lsof -n | grep vlc ; ssh root@gaffeltruck.tg12.gathering.org 'lsof -n | grep vlc' ) > /var/log/stream-count/$date
+ sudo lsof -n | grep vlc > /var/log/stream-count/$date
+ for PORT in 3013 3014 3015 3016 3017 3018 3019 5013 5015 5019; do
+ for PROTO in IPv4 IPv6; do
+ if [ "$PROTO" = "IPv4" ]; then
+ GREPFOR='151\.216'
+ else
+ GREPFOR='2a02:ed02:'
+ fi
+
+ # 151.216.x.x / 2a02:ed02::/32 -> TG13
+ cat /var/log/stream-count/$date | grep EST | egrep $GREPFOR | egrep "(151\.216\..*|2a02:ed02:.*):$PORT->" | cut -d'>' -f2 | sed 's/:[0-9]\+ (ESTABLISHED)//' | sort -u | grep -vEc -e "\[2a02:ed02:|151\.216\." | while read foo; do echo "$date $PORT $PROTO external $foo"; done | tee -a count_datacube.log
+ cat /var/log/stream-count/$date | grep EST | egrep $GREPFOR | egrep "(151\.216\..*|2a02:ed02:.*):$PORT->" | cut -d'>' -f2 | sed 's/:[0-9]\+ (ESTABLISHED)//' | sort -u | grep -Ec -e "\[2a02:ed02:|151\.216\." | while read foo; do echo "$date $PORT $PROTO internal $foo"; done | tee -a count_datacube.log
+ done
+ done
+ sleep 60
+done;
+
diff --git a/stream/reflect/htb.sh b/stream/reflect/htb.sh
new file mode 100755
index 0000000..c6107ea
--- /dev/null
+++ b/stream/reflect/htb.sh
@@ -0,0 +1,79 @@
+#!/bin/bash
+it () {
+ iptables $@
+ ip6tables $@
+}
+
+setup_htb() {
+ FROM=$1
+ TO=$2
+ RATEMBIT=$3
+ FIFOLIMIT=$(( RATEMBIT * 1048576 / 8 )) # about one second
+ echo $FROM..$TO ${RATEMBIT}Mbit fifolimit=$FIFOLIMIT >&2
+
+ for i in $( seq $FROM $TO ); do
+ # slots need to be in hex, crazy enough
+ slot=$( printf %x $(( i + 1 )) )
+
+ # no burst! perfectly even sending at the given rate
+ echo class add dev eth0 parent 8000: classid 8000:$slot htb rate ${RATEMBIT}Mbit burst 0 mtu 576
+
+ # every class needs a child qdisc, plug in a plain fifo
+ # 8000kbit = 512 000
+ echo qdisc add dev eth0 parent 8000:$slot handle $slot: bfifo limit $FIFOLIMIT
+ #echo qdisc add dev eth0 parent 8000:$slot handle $slot: fq_codel limit 1000
+ done
+}
+
+ethtool -K eth0 gso off tso off
+
+# iptables stuff
+it -t mangle -F OUTPUT
+it -t mangle -A OUTPUT -p tcp -m multiport ! --sport 3013,3014,3015,3016,3017,3018,5013,5015,5016,5018 -j MARK --set-mark 65000
+it -t mangle -A OUTPUT ! -p tcp -j MARK --set-mark 65000
+
+(
+ # reset tc
+ echo qdisc del dev eth0 root
+
+ # @Sesse Rockj: https://www.google.com/search?q=6000+kbit%2Fsec+*+0.5+seconds+in+byte
+ # @Sesse ViD: også trenger du flere sett med køer, for 2mbit-strømmer burde shapes annerledes enn 5mbit-strømmer :-P
+
+ # root qdisc should be htb
+ echo qdisc add dev eth0 root handle 8000: htb r2q 100
+
+ # all non-vlc traffic (fwmark 5) goes into the default class
+ echo class add dev eth0 parent 8000: classid 8000:1 htb rate 10Gbit burst 8192 mtu 1514
+ echo filter add dev eth0 parent 8000: handle 65000 pref 10 fw classid 8000:1
+
+ # setup_htb 1 799 6 # Main stream hq 3mbps
+ # setup_htb 800 1000 15 # Fuglecam raw 7-8mbps
+ # # setup_htb 10000 11999 15 # South raw ??
+ # # setup_htb 12000 13999 1 # South transcoded, 500 kbits
+ # # setup_htb 14000 15999 25 # NOC Fisheye 15mbps ish
+ # # setup_htb 20000 21999 2 # Flashstrøm 1mbps
+
+ # setup_htb 1 4999 10 # Main stream hq 6mbps
+ # setup_htb 5000 7999 5 # Main stream sd 2mbit
+ # setup_htb 8000 9999 15 # Fuglecam raw 7-8mbps
+ # setup_htb 10000 11999 15 # South raw ??
+ # setup_htb 12000 13999 1 # South transcoded, 500 kbits
+ # setup_htb 14000 15999 25 # NOC Fisheye 15mbps ish
+ # setup_htb 16000 18999 2 # Flashstrøm fugleberget 1mbps
+ # setup_htb 19000 21999 2 # Flashstrøm event 1mbps
+ # setup_htb 22000 24999 2 # Flashstrøm south 1mbps
+ # setup_htb 25000 27999 2 # Flashstrøm noc 1mbps
+ setup_htb 1 4999 10 # Main stream hq 6mbps
+ setup_htb 5000 5999 5 # Main stream sd 2mbit
+ setup_htb 8000 9999 15 # Fuglecam raw 7-8mbps
+ setup_htb 10000 11999 15 # South raw ??
+ setup_htb 12000 13999 1 # South transcoded, 500 kbits
+ setup_htb 14000 15999 25 # NOC Fisheye 15mbps ish
+ setup_htb 16000 18999 2 # Flashstrøm fugleberget 1mbps
+ setup_htb 19000 21999 2 # Flashstrøm event 1mbps
+ setup_htb 22000 24999 2 # Flashstrøm south 1mbps
+ setup_htb 25000 25999 2 # Flashstrøm noc 1mbps
+
+ # decide between the classes by mark
+ echo filter add dev eth0 parent 8000: handle 2 pref 20 flow map key mark baseclass 8000:2
+) | tc -b
diff --git a/stream/reflect/old/reflectsouth.sh b/stream/reflect/old/reflectsouth.sh
new file mode 100755
index 0000000..39504e5
--- /dev/null
+++ b/stream/reflect/old/reflectsouth.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+while :; do
+vlc --intf dummy -v http://pannekake.samfundet.no:9094 vlc://quit --sout '#duplicate{dst=std{access=http,mux=ts,dst=:3014},dst=std{access=udp,mux=ts,dst=233.191.12.2:2014}' --intf dummy --ttl 20
+ sleep 1
+done
diff --git a/stream/reflect/old/reflectsouth720p.sh b/stream/reflect/old/reflectsouth720p.sh
new file mode 100755
index 0000000..355cf8e
--- /dev/null
+++ b/stream/reflect/old/reflectsouth720p.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+while :; do
+cvlc --intf dummy -v "#transcode{vcodec=h264,width=320,height=180,acodec=aac,ab=128,vb=500}:rtp{port=4555,sdp=rtsp://151.216.106.2:4555/stream.sdp,mp4a­-latm}"
+vlc --intf dummy -v http://pannekake.samfundet.no:9093 vlc://quit --sout '#std{access=http,mux=ts,dst=:5014}' --intf dummy --ttl 30
+ sleep 1
+done
diff --git a/stream/reflect/reflect-event-lol.sh b/stream/reflect/reflect-event-lol.sh
new file mode 100755
index 0000000..74dbea6
--- /dev/null
+++ b/stream/reflect/reflect-event-lol.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+while :; do
+sudo cvlc --intf dummy -v --sout-http-mark-start 0 --sout-http-mark-end 4999 udp://@:4013 vlc://quit --sout \
+'#duplicate{dst=std{access=http,mux=ts,dst=[::]:3013}",dst=std{access=udp,mux=ts,dst=[ff7e:a40:2a02:ed02:ffff::13]:2013},dst=std{access=livehttp{seglen=5,delsegs=true,numsegs=5,index=/srv/stream.tg13.gathering.org/ios/event.m3u8,index-url=http://stream.tg13.gathering.org/ios/event-########.ts},mux=ts{use-key-frames},dst=/srv/stream.tg13.gathering.org/ios/event-########.ts}}}' \
+--intf dummy --ttl 60
+ sleep 1
+done
diff --git a/stream/reflect/reflect-event-sd.sh b/stream/reflect/reflect-event-sd.sh
new file mode 100755
index 0000000..aa38018
--- /dev/null
+++ b/stream/reflect/reflect-event-sd.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+while :; do
+sudo cvlc --intf dummy -v --sout-http-mark-start 5000 --sout-http-mark-end 7999 udp://@:4014 vlc://quit --sout '#duplicate{dst=std{access=http,mux=ts,dst=[::]:3014},dst=std{access=udp,mux=ts,dst=[ff7e:a40:2a02:ed02:ffff::14]:2014}' --intf dummy --ttl 60
+ sleep 1
+done
diff --git a/stream/reflect/reflect-event.sh b/stream/reflect/reflect-event.sh
new file mode 100755
index 0000000..3ab8c42
--- /dev/null
+++ b/stream/reflect/reflect-event.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+while :; do
+sudo cvlc --intf dummy -v --sout-http-mark-start 0 --sout-http-mark-end 4999 udp://@:4013 vlc://quit --sout \
+'#duplicate{dst=std{access=http,mux=ts,dst=[::]:3013}",dst=std{access=udp,mux=ts,dst=[ff7e:a40:2a02:ed02:ffff::13]:2013},dst=std{access=livehttp{seglen=5,delsegs=true,numsegs=5,index=/srv/stream.tg13.gathering.org/ios/stream.m3u8,index-url=http://stream.tg13.gathering.org/ios/stream-########.ts},mux=ts{use-key-frames},dst=/srv/stream.tg13.gathering.org/ios/stream-########.ts}}}' \
+--intf dummy --ttl 60
+ sleep 1
+done
diff --git a/stream/reflect/reflect-fugle-flash.sh b/stream/reflect/reflect-fugle-flash.sh
new file mode 100755
index 0000000..5de38bb
--- /dev/null
+++ b/stream/reflect/reflect-fugle-flash.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+while :; do
+sudo cvlc -vv --sout-http-mark-start 16000 --sout-http-mark-end 18999 --network-caching 3000 --sout-x264-preset fast --sout-transcode-threads 10 --sout-x264-tune film --no-sout-x264-interlaced --sout-x264-lookahead 50 --sout-x264-vbv-maxrate 800 --sout-x264-vbv-bufsize 800 --sout-x264-keyint 50 -v udp://@:4020 vlc://quit \
+--sout '#std{access=http{mime=video/x-flv},mux=ffmpeg{mux=flv},dst=[::]:5015/stream.flv}'
+ sleep 1
+done
diff --git a/stream/reflect/reflect-fuglecam.sh b/stream/reflect/reflect-fuglecam.sh
new file mode 100755
index 0000000..c9a8917
--- /dev/null
+++ b/stream/reflect/reflect-fuglecam.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+while :; do
+sudo vlc -vvv --intf dummy -v --sout-http-mark-start 8000 --sout-http-mark-end 9999 udp://@:4015 vlc://quit --sout '#duplicate{dst=std{access=http,mux=ts,dst=[::]:3015},dst=std{access=udp,mux=ts,dst=[ff7e:a40:2a02:ed02:ffff::15]:2015}' --intf dummy --ttl 60
+ sleep 1
+done
diff --git a/stream/reflect/reflect-nicfisheye-flash.sh b/stream/reflect/reflect-nicfisheye-flash.sh
new file mode 100755
index 0000000..dd4da84
--- /dev/null
+++ b/stream/reflect/reflect-nicfisheye-flash.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+while :; do
+sudo vlc -vvv --intf dummy -v --sout-http-mark-start 25000 --sout-http-mark-end 27999 udp://@:4018 vlc://quit --sout '#duplicate{dst=std{access=http,mux=ts,dst=[::]:3018},dst=std{access=udp,mux=ts,dst=[ff7e:a40:2a02:ed02:ffff::18]:2018}' --intf dummy --ttl 60
+ sleep 1
+done
diff --git a/stream/reflect/reflect-noc-transcodes.sh b/stream/reflect/reflect-noc-transcodes.sh
new file mode 100755
index 0000000..3a1fe4e
--- /dev/null
+++ b/stream/reflect/reflect-noc-transcodes.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+while :; do
+sudo cvlc -vvv --intf dummy -v --sout-http-mark-start 25000 --sout-http-mark-end 27999 udp://@:4019 vlc://quit --sout '#duplicate{dst="std{access=http{mime=video/x-flv},dst=[::]:5019/stream.flv}",dst="std{access=http,mux=ts,dst=[::]:3019}",dst="std{access=udp,mux=ts,dst=[ff7e:a40:2a02:ed02:ffff::19]:2019}"}' --intf dummy --ttl 60
+ sleep 1
+done
diff --git a/stream/reflect/reflect-nocfisheye.sh b/stream/reflect/reflect-nocfisheye.sh
new file mode 100755
index 0000000..6a003f4
--- /dev/null
+++ b/stream/reflect/reflect-nocfisheye.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+while :; do
+sudo cvlc -vvv --intf dummy -v --sout-http-mark-start 14000 --sout-http-mark-end 15999 --network-caching 2000 rtsp://151.216.124.79/live.sdp vlc://quit --sout '#duplicate{dst=std{access=http,mux=ts,dst=[::]:3018},dst=std{access=udp,mux=ts,dst=[ff7e:a40:2a02:ed02:ffff::18]:2018}' --intf dummy --ttl 60
+ sleep 1
+done
diff --git a/stream/reflect/reflect-south-raw.sh b/stream/reflect/reflect-south-raw.sh
new file mode 100755
index 0000000..720e94c
--- /dev/null
+++ b/stream/reflect/reflect-south-raw.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+while :; do
+sudo cvlc -vvv --intf dummy -v --sout-http-mark-start 10000 --sout-http-mark-end 11999 udp://@151.216.125.4:4016 vlc://quit --sout '#duplicate{dst=std{access=http,mux=ts,dst=[::]:3016},dst=std{access=udp,mux=ts,dst=[ff7e:a40:2a02:ed02:ffff::16]:2016}' --intf dummy --ttl 60
+ sleep 1
+done
diff --git a/stream/reflect/reflect-south-transcode.sh b/stream/reflect/reflect-south-transcode.sh
new file mode 100755
index 0000000..65798dc
--- /dev/null
+++ b/stream/reflect/reflect-south-transcode.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+while :; do
+vlc -vvv --intf dummy -v --sout-http-mark-start 12000 --sout-http-mark-end 13999 udp://@:4017 vlc://quit --sout '#duplicate{dst=std{access=http,mux=ts,dst=[::]:3017},dst=std{access=udp,mux=ts,dst=[ff7e:a40:2a02:ed02:ffff::17]:2017}' --intf dummy --ttl 60
+ sleep 1
+done
diff --git a/stream/reflect/transcode-event-flash.sh b/stream/reflect/transcode-event-flash.sh
new file mode 100755
index 0000000..34f546f
--- /dev/null
+++ b/stream/reflect/transcode-event-flash.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+while :; do
+sudo cvlc -vv --sout-http-mark-start 19000 --sout-http-mark-end 21999 --network-caching 5000 --sout-x264-preset fast --sout-transcode-threads 10 --sout-x264-tune film --no-sout-x264-interlaced --sout-x264-lookahead 50 --sout-x264-vbv-maxrate 800 --sout-x264-vbv-bufsize 800 --sout-x264-keyint 50 -v http://stream.tg13.gathering.org:3013 vlc://quit \
+--sout '#transcode{height=480,fps=25,vcodec=h264,vb=800,acodec=aac,ab=128}:std{access=http{mime=video/x-flv},dst=[::]:5013/stream.flv}'
+ sleep 1
+done
diff --git a/stream/reflect/transcode-fugle-flash.sh b/stream/reflect/transcode-fugle-flash.sh
new file mode 100755
index 0000000..110b8b8
--- /dev/null
+++ b/stream/reflect/transcode-fugle-flash.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+while :; do
+sudo cvlc -vv --sout-http-mark-start 16000 --sout-http-mark-end 18999 --network-caching 3000 --sout-x264-preset fast --sout-transcode-threads 10 --sout-x264-tune film --no-sout-x264-interlaced --sout-x264-lookahead 50 --sout-x264-vbv-maxrate 800 --sout-x264-vbv-bufsize 800 --sout-x264-keyint 50 -v http://stream.tg13.gathering.org:3015 vlc://quit \
+--sout '#transcode{height=480,fps=25,vcodec=h264,vb=800,acodec=aac,ab=128,deinterlace}:std{access=http{mime=video/x-flv},dst=[::]:5015/stream.flv}'
+ sleep 1
+done
diff --git a/stream/reflect/transcode-nocfisheye-flash.sh b/stream/reflect/transcode-nocfisheye-flash.sh
new file mode 100755
index 0000000..19f89ad
--- /dev/null
+++ b/stream/reflect/transcode-nocfisheye-flash.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+while :; do
+sudo cvlc -vv --sout-http-mark-start 25000 --sout-http-mark-end 27999 --network-caching 5000 --sout-x264-preset fast --sout-transcode-threads 10 --sout-x264-tune film --no-sout-x264-interlaced --sout-x264-lookahead 50 --sout-x264-vbv-maxrate 800 --sout-x264-vbv-bufsize 800 --sout-x264-keyint 50 -v http://stream.tg13.gathering.org:3018 vlc://quit \
+--sout '#transcode{height=480,fps=25,vcodec=h264,vb=800,acodec=aac,ab=128}:std{access=http{mime=video/x-flv},dst=[::]:5018/stream.flv}'
+ sleep 1
+done
diff --git a/stream/reflect/transcode-south-flash.sh b/stream/reflect/transcode-south-flash.sh
new file mode 100755
index 0000000..6bf2cb8
--- /dev/null
+++ b/stream/reflect/transcode-south-flash.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+while :; do
+sudo cvlc -vv --sout-http-mark-start 22000 --sout-http-mark-end 24999 --network-caching 5000 --sout-x264-preset fast --sout-transcode-threads 10 --sout-x264-tune film --no-sout-x264-interlaced --sout-x264-lookahead 50 --sout-x264-vbv-maxrate 800 --sout-x264-vbv-bufsize 800 --sout-x264-keyint 50 -v http://stream.tg13.gathering.org:3016 vlc://quit \
+--sout '#transcode{height=480,fps=25,vcodec=h264,vb=800,acodec=aac,ab=128}:std{access=http{mime=video/x-flv},dst=[::]:5016/stream.flv}'
+ sleep 1
+done
diff --git a/stream/reflect/usage.txt b/stream/reflect/usage.txt
new file mode 100644
index 0000000..8b90bee
--- /dev/null
+++ b/stream/reflect/usage.txt
@@ -0,0 +1,3 @@
+event-sd - ./reflect-event-sd.sh
+event - ./reflect-event-lol.sh
+event-flash - ./transcode-event-flash.sh
diff --git a/stream/transcode/count.sh b/stream/transcode/count.sh
new file mode 100755
index 0000000..22f6aa1
--- /dev/null
+++ b/stream/transcode/count.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+while :; do
+ date=$(date +"%Y-%m-%d-%H:%M:%S")
+ ( lsof -n | grep vlc ; ssh root@gaffeltruck.tg12.gathering.org 'lsof -n | grep vlc' ) > /var/log/stream-count/$date
+ for PORT in 3013 5013 3014 5014 3015; do
+ for PROTO in IPv4 IPv6; do
+ # 176.110.x.x / 2a01:798:76a:125:: -> TG12
+ # 176.31.230.19 / 2001:41d0:2:f700::2 -> OVH box
+ cat /var/log/stream-count/$date | grep EST | egrep $PROTO | egrep "(176\.31\.230\.19|2001:41d0:2:f700::.*):$PORT->" | cut -d'>' -f2 | sed 's/:[0-9]\+ (ESTABLISHED)//' | sort -u | grep -vEc 'fisk' | while read foo; do echo "$date $PORT $PROTO foreign $foo"; done | tee -a count_datacube.log
+ cat /var/log/stream-count/$date | grep EST | egrep $PROTO | egrep "(176\.110\..*|2a01:798:76a:125::.*):$PORT->" | cut -d'>' -f2 | sed 's/:[0-9]\+ (ESTABLISHED)//' | sort -u | grep -vEc -e "\[2a01:798:76a:|176\.110\." | while read foo; do echo "$date $PORT $PROTO external $foo"; done | tee -a count_datacube.log
+ cat /var/log/stream-count/$date | grep EST | egrep $PROTO | egrep "(176\.110\..*|2a01:798:76a:125::.*):$PORT->" | cut -d'>' -f2 | sed 's/:[0-9]\+ (ESTABLISHED)//' | sort -u | grep -Ec -e "\[2a01:798:76a:|176\.110\." | while read foo; do echo "$date $PORT $PROTO internal $foo"; done | tee -a count_datacube.log
+ done
+ done
+ sleep 60
+done;
+
diff --git a/stream/transcode/flash.sh b/stream/transcode/flash.sh
new file mode 100755
index 0000000..3c42a8c
--- /dev/null
+++ b/stream/transcode/flash.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+# udp://@:5013
+while :; do
+vlc --intf dummy -vvv http://vivace.tg12.gathering.org:5013/stream.flv vlc://quit --network-caching 2000 --sout-mux-caching 3000 --sout "#std{access=http{mime=video/x-flv},dst=:5013/stream.flv}"
+ sleep 1
+done
diff --git a/stream/transcode/flashtest.sh b/stream/transcode/flashtest.sh
new file mode 100755
index 0000000..83ea48d
--- /dev/null
+++ b/stream/transcode/flashtest.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+while :; do
+ vlc --intf dummy -vvv http://stream.tg12.gathering.org:3013 vlc://quit --udp-caching 1000 --sout-x264-tune film --sout-x264-keyint 25 --sout-x264-preset veryfast --sout "#transcode{width=980,height=550,vcodec=h264,vb=1000,acodec=aac,ab=128}:std{access=http{mime=video/x-flv},dst=:5013/stream.flv}"
+ sleep 1
+done
diff --git a/stream/transcode/ios-sd.sh b/stream/transcode/ios-sd.sh
new file mode 100755
index 0000000..28a907a
--- /dev/null
+++ b/stream/transcode/ios-sd.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+while :; do
+vlc -I dummy --live-caching 0 http://vivace.tg12.gathering.org:5013/stream.flv --sout-x264-profile baseline --sout-x264-preset veryfast --sout-x264-aud --sout-x264-keyint 30 --sout-x264-ref 1 vlc://quit --sout='#std{access=livehttp{seglen=10,delsegs=true,numsegs=5,index=/srv/stream.tg12.gathering.org/ios/sd.m3u8,index-url=http://stream.tg12.gathering.org/ios/sd-########.ts},mux=ts{use-key-frames},dst=/srv/stream.tg12.gathering.org/ios/sd-########.ts}'
+ sleep 2
+done
+
+# --sout-x264-level 30
diff --git a/stream/transcode/ios-south.sh b/stream/transcode/ios-south.sh
new file mode 100755
index 0000000..ac06968
--- /dev/null
+++ b/stream/transcode/ios-south.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+while :; do
+vlc -I dummy --live-caching 0 udp://@:5114 vlc://quit --sout='#std{access=livehttp{seglen=10,delsegs=true,numsegs=5,index=/srv/stream.tg12.gathering.org/ios/south.m3u8,index-url=http://stream.tg12.gathering.org/ios/south-########.ts},mux=ts{use-key-frames},dst=/srv/stream.tg12.gathering.org/ios/south-########.ts}'
+ sleep 2
+done
+
+# --sout-x264-level 30
diff --git a/stream/vlc-patches/listen_all.git.patch b/stream/vlc-patches/listen_all.git.patch
new file mode 100644
index 0000000..41e1c87
--- /dev/null
+++ b/stream/vlc-patches/listen_all.git.patch
@@ -0,0 +1,28 @@
+diff --git a/src/network/io.c b/src/network/io.c
+index 7cc9764..08a0b56 100644
+--- a/src/network/io.c
++++ b/src/network/io.c
+@@ -87,14 +87,15 @@ int net_Socket (vlc_object_t *p_this, int family, int socktype,
+
+ setsockopt (fd, SOL_SOCKET, SO_REUSEADDR, &(int){ 1 }, sizeof (int));
+
+-#ifdef IPV6_V6ONLY
+- /*
+- * Accepts only IPv6 connections on IPv6 sockets.
+- * If possible, we should open two sockets, but it is not always possible.
+- */
+- if (family == AF_INET6)
+- setsockopt (fd, IPPROTO_IPV6, IPV6_V6ONLY, &(int){ 1 }, sizeof (int));
+-#endif
++ // sesse fix monday night
++// #ifdef IPV6_V6ONLY
++// /*
++// * Accepts only IPv6 connections on IPv6 sockets.
++// * If possible, we should open two sockets, but it is not always possible.
++// */
++// if (family == AF_INET6)
++// setsockopt (fd, IPPROTO_IPV6, IPV6_V6ONLY, &(int){ 1 }, sizeof (int));
++// #endif
+
+ #if defined (WIN32)
+ # ifndef IPV6_PROTECTION_LEVEL
diff --git a/stream/vlc-patches/vlc-git-sesse.patch b/stream/vlc-patches/vlc-git-sesse.patch
new file mode 100644
index 0000000..a38b378
--- /dev/null
+++ b/stream/vlc-patches/vlc-git-sesse.patch
@@ -0,0 +1,131 @@
+diff --git a/modules/access_output/http.c b/modules/access_output/http.c
+index 61095f5..18ffc9a 100644
+--- a/modules/access_output/http.c
++++ b/modules/access_output/http.c
+@@ -72,9 +72,17 @@ vlc_module_begin ()
+ PASS_TEXT, PASS_LONGTEXT, true )
+ add_string( SOUT_CFG_PREFIX "mime", "",
+ MIME_TEXT, MIME_LONGTEXT, true )
++ add_integer( SOUT_CFG_PREFIX "mark-start", "",
++ "lol", "Fancy option", -1 )
++ add_integer( SOUT_CFG_PREFIX "mark-end", "",
++ "rotfl", "Should maybe also be set", -1 )
+ set_callbacks( Open, Close )
+ vlc_module_end ()
+
++// globals
++extern vlc_mutex_t mark_lock;
++extern int *mark_used;
++extern int mark_start, mark_end;
+
+ /*****************************************************************************
+ * Exported prototypes
+@@ -178,6 +186,21 @@ static int Open( vlc_object_t *p_this )
+ return VLC_EGENERIC;
+ }
+
++ fprintf(stderr, "tjobing\n");
++ if (mark_used == NULL) {
++ mark_start = var_InheritInteger( p_access, SOUT_CFG_PREFIX "mark-start");
++ mark_end = var_InheritInteger( p_access, SOUT_CFG_PREFIX "mark-end");
++ fprintf(stderr, "jabla: %d -> %d\n", mark_start, mark_end);
++
++ if (mark_start >= 0 && mark_end > mark_start) {
++ vlc_mutex_init(&mark_lock);
++ mark_used = (int *)malloc((mark_end - mark_start) * sizeof(int));
++ for (int i = 0; i < mark_end - mark_start; ++i) {
++ mark_used[i] = 0;
++ }
++ }
++ }
++
+ psz_user = var_GetNonEmptyString( p_access, SOUT_CFG_PREFIX "user" );
+ psz_pwd = var_GetNonEmptyString( p_access, SOUT_CFG_PREFIX "pwd" );
+ if( p_access->psz_access && !strcmp( p_access->psz_access, "mmsh" ) )
+diff --git a/src/libvlccore.sym b/src/libvlccore.sym
+index 25d83c5..335edda 100644
+--- a/src/libvlccore.sym
++++ b/src/libvlccore.sym
+@@ -631,3 +631,7 @@ xml_ReaderDelete
+ xml_ReaderReset
+ vlc_keycode2str
+ vlc_str2keycode
++mark_end
++mark_lock
++mark_start
++mark_used
+diff --git a/src/network/httpd.c b/src/network/httpd.c
+index f76c47c..d7897bb 100644
+--- a/src/network/httpd.c
++++ b/src/network/httpd.c
+@@ -67,6 +67,50 @@
+
+ static void httpd_ClientClean( httpd_client_t *cl );
+
++VLC_API vlc_mutex_t mark_lock;
++VLC_API int *mark_used = NULL;
++VLC_API int mark_start = -1;
++VLC_API int mark_end = -1;
++
++void mark_socket(int fd)
++{
++ vlc_mutex_lock(&mark_lock);
++ int best_mark = mark_start;
++ int best_mark_val = mark_used[0];
++
++ for (int i = 1; i < mark_end - mark_start; ++i) {
++ if (mark_used[i] < best_mark_val) {
++ best_mark = mark_start + i;
++ best_mark_val = mark_used[i];
++ }
++ }
++ fprintf( stderr, "PICKED MARK %d WITH OLD USAGE %d\n", best_mark, best_mark_val);
++ if (setsockopt (fd, SOL_SOCKET, SO_MARK, &best_mark, sizeof(best_mark)) == -1) {
++ perror("setsockopt(SO_MARK)");
++ } else {
++ ++mark_used[best_mark - mark_start];
++ }
++ vlc_mutex_unlock(&mark_lock);
++}
++
++void unmark_socket(int fd)
++{
++ int mark;
++ socklen_t mark_len = sizeof(mark);
++ if (getsockopt (fd, SOL_SOCKET, SO_MARK, &mark, &mark_len) == -1) {
++ perror("getsockopt(SO_MARK)");
++ return;
++ }
++ if (mark < mark_start || mark >= mark_end) {
++ fprintf("UNKNOWN MARK %d\n", mark);
++ }
++
++ vlc_mutex_lock(&mark_lock);
++ --mark_used[mark - mark_start];
++ fprintf(stderr, "UNMARKED MARK %d WITH NEW USAGE %d\n", mark, mark_used[mark - mark_start]);
++ vlc_mutex_unlock(&mark_lock);
++}
++
+ /* each host run in his own thread */
+ struct httpd_host_t
+ {
+@@ -1295,6 +1339,7 @@ static void httpd_ClientClean( httpd_client_t *cl )
+ {
+ if( cl->p_tls != NULL )
+ vlc_tls_SessionDelete( cl->p_tls );
++ unmark_socket( cl->fd );
+ net_Close( cl->fd );
+ cl->fd = -1;
+ }
+@@ -2309,6 +2354,11 @@ static void* httpd_HostThread( void *data )
+ setsockopt (fd, SOL_SOCKET, SO_REUSEADDR,
+ &(int){ 1 }, sizeof(int));
+
++ // find a free mark
++ if (mark_used != NULL) {
++ mark_socket(fd);
++ }
++
+ vlc_tls_t *p_tls;
+
+ if( host->p_tls != NULL )
diff --git a/stream/vlc-patches/vlc-mark.patch b/stream/vlc-patches/vlc-mark.patch
new file mode 100644
index 0000000..877b78c
--- /dev/null
+++ b/stream/vlc-patches/vlc-mark.patch
@@ -0,0 +1,136 @@
+diff -ur vlc-2.0.5/modules/access_output/http.c vlc-2.0.5.patchde/modules/access_output/http.c
+--- vlc-2.0.5/modules/access_output/http.c 2011-12-22 11:38:28.000000000 +0100
++++ vlc-2.0.5.patchde/modules/access_output/http.c 2013-02-07 01:23:10.966721881 +0100
+@@ -89,9 +89,17 @@
+ add_bool( SOUT_CFG_PREFIX "bonjour", false,
+ BONJOUR_TEXT, BONJOUR_LONGTEXT, true);
+ #endif
++ add_integer( SOUT_CFG_PREFIX "mark-start", "",
++ "lol", "Fancy option", -1 )
++ add_integer( SOUT_CFG_PREFIX "mark-end", "",
++ "rotfl", "Should maybe also be set", -1 )
+ set_callbacks( Open, Close )
+ vlc_module_end ()
+
++// globals
++extern vlc_mutex_t mark_lock;
++extern int *mark_used;
++extern int mark_start, mark_end;
+
+ /*****************************************************************************
+ * Exported prototypes
+@@ -199,6 +207,21 @@
+ return VLC_EGENERIC;
+ }
+
++ fprintf(stderr, "tjobing\n");
++ if (mark_used == NULL) {
++ mark_start = var_InheritInteger( p_access, SOUT_CFG_PREFIX "mark-start");
++ mark_end = var_InheritInteger( p_access, SOUT_CFG_PREFIX "mark-end");
++ fprintf(stderr, "jabla: %d -> %d\n", mark_start, mark_end);
++
++ if (mark_start >= 0 && mark_end > mark_start) {
++ vlc_mutex_init(&mark_lock);
++ mark_used = (int *)malloc((mark_end - mark_start) * sizeof(int));
++ for (int i = 0; i < mark_end - mark_start; ++i) {
++ mark_used[i] = 0;
++ }
++ }
++ }
++
+ psz_user = var_GetNonEmptyString( p_access, SOUT_CFG_PREFIX "user" );
+ psz_pwd = var_GetNonEmptyString( p_access, SOUT_CFG_PREFIX "pwd" );
+ if( p_access->psz_access && !strcmp( p_access->psz_access, "mmsh" ) )
+diff -ur vlc-2.0.5/src/libvlccore.sym vlc-2.0.5.patchde/src/libvlccore.sym
+--- vlc-2.0.5/src/libvlccore.sym 2012-05-15 14:41:19.000000000 +0200
++++ vlc-2.0.5.patchde/src/libvlccore.sym 2013-02-07 01:16:16.917330547 +0100
+@@ -673,3 +673,7 @@
+ xml_ReaderReset
+ vlc_keycode2str
+ vlc_str2keycode
++mark_end
++mark_lock
++mark_start
++mark_used
+diff -ur vlc-2.0.5/src/network/httpd.c vlc-2.0.5.patchde/src/network/httpd.c
+--- vlc-2.0.5/src/network/httpd.c 2012-09-04 00:14:53.000000000 +0200
++++ vlc-2.0.5.patchde/src/network/httpd.c 2013-02-07 01:35:50.777081814 +0100
+@@ -69,6 +69,50 @@
+
+ static void httpd_ClientClean( httpd_client_t *cl );
+
++VLC_API vlc_mutex_t mark_lock;
++VLC_API int *mark_used = NULL;
++VLC_API int mark_start = -1;
++VLC_API int mark_end = -1;
++
++void mark_socket(int fd)
++{
++ vlc_mutex_lock(&mark_lock);
++ int best_mark = mark_start;
++ int best_mark_val = mark_used[0];
++
++ for (int i = 1; i < mark_end - mark_start; ++i) {
++ if (mark_used[i] < best_mark_val) {
++ best_mark = mark_start + i;
++ best_mark_val = mark_used[i];
++ }
++ }
++ fprintf( stderr, "PICKED MARK %d WITH OLD USAGE %d\n", best_mark, best_mark_val);
++ if (setsockopt (fd, SOL_SOCKET, SO_MARK, &best_mark, sizeof(best_mark)) == -1) {
++ perror("setsockopt(SO_MARK)");
++ } else {
++ ++mark_used[best_mark - mark_start];
++ }
++ vlc_mutex_unlock(&mark_lock);
++}
++
++void unmark_socket(int fd)
++{
++ int mark;
++ socklen_t mark_len = sizeof(mark);
++ if (getsockopt (fd, SOL_SOCKET, SO_MARK, &mark, &mark_len) == -1) {
++ perror("getsockopt(SO_MARK)");
++ return;
++ }
++ if (mark < mark_start || mark >= mark_end) {
++ fprintf("UNKNOWN MARK %d\n", mark);
++ }
++
++ vlc_mutex_lock(&mark_lock);
++ --mark_used[mark - mark_start];
++ fprintf(stderr, "UNMARKED MARK %d WITH NEW USAGE %d\n", mark, mark_used[mark - mark_start]);
++ vlc_mutex_unlock(&mark_lock);
++}
++
+ /* each host run in his own thread */
+ struct httpd_host_t
+ {
+@@ -1412,6 +1456,7 @@
+ {
+ if( cl->p_tls != NULL )
+ vlc_tls_ServerSessionDelete( cl->p_tls );
++ unmark_socket( cl->fd );
+ net_Close( cl->fd );
+ cl->fd = -1;
+ }
+@@ -2461,6 +2506,11 @@
+ setsockopt (fd, SOL_SOCKET, SO_REUSEADDR,
+ &(int){ 1 }, sizeof(int));
+
++ // find a free mark
++ if (mark_used != NULL) {
++ mark_socket(fd);
++ }
++
+ vlc_tls_t *p_tls;
+
+ if( host->p_tls != NULL )
+@@ -2471,6 +2521,7 @@
+ case -1:
+ msg_Err( host, "Rejecting TLS connection" );
+ /* p_tls is destroyed implicitly */
++ unmark_socket( fd );
+ net_Close( fd );
+ fd = -1;
+ p_tls = NULL;