## HLS Streaming
gst-launch-1.0 videotestsrc is-live=true ! x264enc ! h264parse ! hlssink3

gst-launch-1.0 srtsrc uri="srt://" ! \
    tsdemux ! queue ! h264parse ! \
    hlssink3 enable-program-date-time=true playlist-length=3 target-duration=5 max-files=5

## SRT Streaming
### Video Only
#### producer
gst-launch-1.0 -v videotestsrc ! clockoverlay ! video/x-raw, height=360, width=640 ! videoconvert ! \
    x264enc tune=zerolatency ! video/x-h264, profile=high ! \
    mpegtsmux ! srtsink uri=srt://:1234 wait-for-connection=false

ffmpeg -f lavfi -i testsrc=size=640x360:rate=3 -pix_fmt yuv420p -c:v libx264 -vprofile main -f mpegts "srt://127.0.0.1:1234?mode=listener"

#### trasmitter
gst-launch-1.0 srtsrc uri="srt://127.0.0.1:8888" ! queue !  srtserversink uri="srt://:1234" wait-for-connection=false

#### consumer
gst-launch-1.0 playbin uri="srt://127.0.0.1:1235?mode=caller"

gst-launch-1.0 srtsrc uri="srt://127.0.0.1:1234?mode=caller" ! queue ! decodebin ! queue ! autovideosink

gst-launch-1.0 srtsrc uri="srt://127.0.0.1:1234?mode=caller" ! queue ! tsdemux ! queue ! h264parse ! avdec_h264 ! videoconvert ! autovideosink

gst-launch-1.0 srtsrc uri="srt://127.0.0.1:1234?mode=listener" ! queue ! decodebin name=d \
    d. ! queue ! videoconvert ! x264enc tune=zerolatency ! video/x-h264, profile=constrained-baseline ! mux. \
    mpegtsmux name=mux ! queue ! srtsink uri="srt://127.0.0.1:1235?mode=caller" wait-for-connection=false

gst-launch-1.0 srtsrc uri="srt://127.0.0.1:1234?mode=caller" ! queue ! decodebin ! queue ! videoconvert ! \
    x264enc tune=zerolatency ! video/x-h264, profile=constrained-baseline ! \
    mpegtsmux ! queue ! srtsink uri="srt://127.0.0.1:1235?mode=listener" wait-for-connection=false

### Video & Audio
#### producer
gst-launch-1.0 -v \
    videotestsrc ! clockoverlay ! video/x-raw, height=360, width=640 ! videoconvert ! x264enc tune=zerolatency ! video/x-h264, profile=constrained-baseline ! mux. \
    audiotestsrc ! audio/x-raw, format=S16LE, channels=2, rate=44100 ! audioconvert ! voaacenc ! aacparse ! mux. \
    mpegtsmux name=mux ! queue ! srtsink uri="srt://127.0.0.1:1234?mode=caller" wait-for-connection=false latency=5000

gst-launch-1.0 -v \
    audiotestsrc ! audio/x-raw, format=S16LE, channels=2, rate=44100 ! audioconvert ! voaacenc ! aacparse ! mux. \
    mpegtsmux name=mux ! queue ! srtsink uri="srt://127.0.0.1:1234?mode=listener" wait-for-connection=false

gst-launch-1.0 -v \
    videotestsrc pattern=smpte ! clockoverlay ! video/x-raw, height=360, width=640 ! videoconvert ! x264enc tune=zerolatency ! video/x-h264, profile=constrained-baseline ! mux. \
    audiotestsrc ! audio/x-raw, format=S16LE, channels=2, rate=44100 ! audioconvert ! voaacenc ! aacparse ! mux. \
    mpegtsmux name=mux ! queue ! srtsink uri="srt://127.0.0.1:1234?mode=listener" wait-for-connection=false

#### consumer
gst-launch-1.0 -v playbin  uri="srt://127.0.0.1:1234?mode=listener"

gst-launch-1.0 srtsrc uri="srt://127.0.0.1:1234?mode=listener"  ! typefind ! queue ! tsdemux name=demux \
    demux. ! queue ! h264parse ! rtph264pay ! udpsink host=localhost port=5000 \
    demux. ! queue ! aacparse  ! avdec_aac  ! audioconvert ! audioresample ! opusenc ! rtpopuspay ! udpsink host=localhost port=5001

gst-launch-1.0 srtsrc uri="srt://127.0.0.1:1234?mode=listener"  ! typefind ! queue ! tsdemux name=demux \
    demux. ! queue ! h264parse ! rtph264pay ! whipsink whip-endpoint="http://localhost:8000/subscriptions" name=ws

gst-launch-1.0 srtsrc uri="srt://127.0.0.1:1234?mode=listener" ! tee name=t \
    t. ! queue ! typefind ! queue ! fakesink \
    t. ! queue ! srtsink uri="srt://127.0.0.1:8888?mode=caller" wait-for-connection=false

## WebRTC
### Signalling Server
WEBRTCSINK_SIGNALLING_SERVER_LOG=debug cargo run --bin gst-webrtc-signalling-server

### WebRTC Sink
gst-launch-1.0 -v srtsrc  uri="srt://127.0.0.1:1234" ! decodebin name=d \
    d. ! queue ! audioconvert ! webrtcsink name=ws meta="meta,name=gst-stream" \
    d. ! queue ! ws.

### WebRTC Source
gst-launch-1.0 webrtcsrc name=ws signaller::producer-peer-id="" \
    ws. ! videoconvert ! autovideosink \
    ws. ! audioconvert ! autoaudiosink

## WebRTC HTTP
## WHIP Sink
gst-launch-1.0 -v \
    avfvideosrc capture-screen=true ! video/x-raw,framerate=20/1 ! videoscale ! videoconvert ! x264enc tune=zerolatency ! mux. \
    audiotestsrc ! audio/x-raw, format=S16LE, channels=2, rate=44100 ! audioconvert ! voaacenc ! aacparse ! mux. \
    mpegtsmux name=mux ! rtpmp2tpay ! whipsink whip-endpoint="http://localhost:8000/subscriptions"

## WHEP Source
gst-launch-1.0 -v whepsrc whep-endpoint="http://localhost:8000/subscriptions" \
    video-caps = "application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, payload=(int)33" \
    audio-caps = "application/x-rtp, media=(string)audio, encoding-name=(string)AAC, payload=(int)96" ! \
    rtpmp2tdepay ! decodebin name=d \
    d. ! queue ! autovideosink sync=false \
    d. ! queue ! audioconvert ! autoaudiosink sync=false


## FFmpeg cmds
#### producer
ffmpeg -f lavfi -re -i testsrc=size=1280x720:rate=30 -f lavfi -re \
       -i sine=frequency=1000:sample_rate=44100 -pix_fmt yuv420p \
       -c:v libx264 -b:v 1000k -g 30 -keyint_min 120 -profile:v baseline -preset veryfast \
       -c:a aac -f mpegts "srt://127.0.0.1:1234?mode=caller&pkt_size=1316"
