Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added example code that allows to send data streams or files using quicly #473

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,14 @@ cmake_install.cmake
xcuserdata
*.xccheckout
tmp/
cli
embedded-probes.h
examples-echo
libquicly.a
picotls-probes.h
quicly-probes.h
quicly-tracer.h
test.t
udpfw
examples-pipeclient
examples-pipeserver
54 changes: 54 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "example-pipe-server",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/build/examples-pipeserver",
"args": ["-c", "../tmp/server.cert", "-k", "../tmp/server.key"],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "lldb"
},{
"name": "example-pipe-client",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/build/examples-pipeclient",
"args": [""],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": true,
"MIMode": "lldb"
},{
"name": "example-echo-client",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/build/examples-echo",
"args": [""],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": true,
"MIMode": "lldb"
},
{
"name": "cli help",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/build/cli",
"args": ["-h"],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "lldb"
}
]
}
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"files.associations": {
"unistd.h": "c",
"sstream": "c"
}
}
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11...3.20)
CMAKE_POLICY(SET CMP0003 NEW)

PROJECT(quicly)
Expand Down Expand Up @@ -124,6 +124,12 @@ TARGET_LINK_LIBRARIES(test.t quicly ${OPENSSL_LIBRARIES} ${CMAKE_DL_LIBS})
ADD_EXECUTABLE(examples-echo ${PICOTLS_OPENSSL_FILES} examples/echo.c)
TARGET_LINK_LIBRARIES(examples-echo quicly ${OPENSSL_LIBRARIES} ${CMAKE_DL_LIBS})

ADD_EXECUTABLE(examples-pipeclient ${PICOTLS_OPENSSL_FILES} examples/pipeclient.c)
TARGET_LINK_LIBRARIES(examples-pipeclient quicly ${OPENSSL_LIBRARIES} ${CMAKE_DL_LIBS})

ADD_EXECUTABLE(examples-pipeserver ${PICOTLS_OPENSSL_FILES} examples/pipeserver.c)
TARGET_LINK_LIBRARIES(examples-pipeserver quicly ${OPENSSL_LIBRARIES} ${CMAKE_DL_LIBS})

ADD_EXECUTABLE(udpfw t/udpfw.c)

ADD_CUSTOM_TARGET(check env BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} WITH_DTRACE=${WITH_DTRACE} prove --exec "sh -c" -v ${CMAKE_CURRENT_BINARY_DIR}/*.t t/*.t
Expand Down
50 changes: 50 additions & 0 deletions examples/PIPE-README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
Send data streams over QUIC (Quicly)
===

Using the `pipeclient` and `pipeserver` binaries you can esaly send data streams (ex: live video) over QUIC

How to test it
---

- Install & compile the code, you can follow the [readme](../README.md) instructions

- Generate the certs in the `/tmp` dir:
```
mkdir -p tmp
openssl req -nodes -new -x509 -keyout tmp/server.key -out tmp/server.crt
```

- To run the server
```
./examples-pipeserver -c ../tmp/server.crt -k ../tmp/server.key -p 4433 > myReceivedFile.bin
```

- To run the client
```
cat myfile.bin | ./examples-pipeclient
```

- Check files
```
diff myfile.bin myReceivedFile.bin
```

Example with video (Assumes `ffmpeg` and `ffplay` installed)
---

- To run the server:
```
./examples-pipeserver -c ../tmp/server.cert -k ../tmp/server.key -p 4433 | ffplay -
```

- To run the client:
```
ffmpeg -re -f lavfi -i smptebars=duration=30:size=320x200:rate=30 -f lavfi -re -i sine=frequency=1000:duration=30:sample_rate=48000 -pix_fmt yuv420p -c:v libx264 -b:v 180k -g 60 -keyint_min 60 -profile:v baseline -preset veryfast -c:a aac -b:a 96k -vf "drawtext=fontfile=/Library/Fonts/Arial.ttf: text=\'Local time %{localtime\: %Y\/%m\/%d %H.%M.%S} (%{n})\': x=10: y=10: fontsize=16: fontcolor=white: box=1: boxcolor=0x00000099" -f mpegts - | ./examples-pipeclient
```

Note: The previous command will work on MACos, but if you have problems with `lavfi` filter or with the fonts path you can use the following one:
```
ffmpeg -re -i myVideoFile.mp4 -c copy -f mpegts - | ./examples-pipeclient
```

Now you should see live video!!!
Loading