Browse Source

Merge branch 'Focusrite-Novation-javascript' into dev

Paul-Louis Ageneau 5 years ago
parent
commit
13b29ae6de

+ 1 - 1
.gitignore

@@ -5,4 +5,4 @@ build/
 *.so
 compile_commands.json
 tests
-
+.DS_Store

+ 6 - 0
.gitmodules

@@ -7,3 +7,9 @@
 [submodule "deps/libjuice"]
 	path = deps/libjuice
 	url = https://github.com/paullouisageneau/libjuice
+[submodule "deps/httplib"]
+	path = deps/httplib
+	url = https://github.com/yhirose/cpp-httplib.git
+[submodule "deps/json"]
+	path = deps/json
+	url = https://github.com/nlohmann/json.git

+ 10 - 0
.vscode/settings.json

@@ -0,0 +1,10 @@
+{
+    "files.associations": {
+        "__functional_03": "cpp",
+        "iosfwd": "cpp",
+        "ostream": "cpp",
+        "memory": "cpp",
+        "functional": "cpp",
+        "chrono": "cpp"
+    }
+}

+ 6 - 1
CMakeLists.txt

@@ -71,6 +71,9 @@ set(TESTS_ANSWERER_SOURCES
     ${CMAKE_CURRENT_SOURCE_DIR}/test/p2p/answerer.cpp
 )
 
+set(JSON_BuildTests OFF CACHE INTERNAL "")
+add_subdirectory(deps/json)
+
 set(THREADS_PREFER_PTHREAD_FLAG ON)
 find_package(Threads REQUIRED)
 
@@ -162,7 +165,7 @@ set_target_properties(datachannel-tests PROPERTIES
 	CXX_STANDARD 17)
 set_target_properties(datachannel-tests PROPERTIES OUTPUT_NAME tests)
 target_include_directories(datachannel-tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
-target_link_libraries(datachannel-tests datachannel)
+target_link_libraries(datachannel-tests datachannel nlohmann_json::nlohmann_json)
 
 # P2P Test: offerer
 add_executable(datachannel-offerer ${TESTS_OFFERER_SOURCES})
@@ -171,6 +174,8 @@ set_target_properties(datachannel-offerer PROPERTIES
 	CXX_STANDARD 17)
 set_target_properties(datachannel-offerer PROPERTIES OUTPUT_NAME offerer)
 target_link_libraries(datachannel-offerer datachannel)
+target_include_directories(datachannel-offerer PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/deps/httplib)
+target_include_directories(datachannel-offerer PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/deps/json/include)
 
 # P2P Test: answerer
 add_executable(datachannel-answerer ${TESTS_ANSWERER_SOURCES})

+ 1 - 0
deps/httplib

@@ -0,0 +1 @@
+Subproject commit 26deffe0c6a1e177e393416b94cdc0f340ca79bd

+ 1 - 0
deps/json

@@ -0,0 +1 @@
+Subproject commit 973c52dd4a9e92ede5ca4afe8b3d01ef677dc57f

+ 2 - 0
include/rtc/peerconnection.hpp

@@ -95,6 +95,8 @@ public:
 	size_t bytesReceived();
 	std::optional<std::chrono::milliseconds> rtt();
 
+	std::string connectionInfo;
+
 private:
 	init_token mInitToken = Init::Token();
 

+ 69 - 32
test/p2p/offerer.cpp

@@ -18,6 +18,9 @@
 
 #include "rtc/rtc.hpp"
 
+#include <httplib.h>
+#include <nlohmann/json.hpp>
+
 #include <chrono>
 #include <iostream>
 #include <memory>
@@ -25,30 +28,86 @@
 
 using namespace rtc;
 using namespace std;
+using namespace std::chrono_literals;
 
 template <class T> weak_ptr<T> make_weak_ptr(shared_ptr<T> ptr) { return ptr; }
 
+const char base64_url_alphabet[] = {
+    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
+    'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
+    'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
+    'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
+    '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', '_'
+};
+
+std::string base64_encode(const std::string & in) {
+  std::string out;
+  int val =0, valb=-6;
+  size_t len = in.length();
+  unsigned int i = 0;
+  for (i = 0; i < len; i++) {
+    unsigned char c = in[i];
+    val = (val<<8) + c;
+    valb += 8;
+    while (valb >= 0) {
+      out.push_back(base64_url_alphabet[(val>>valb)&0x3F]);
+      valb -= 6;
+    }
+  }
+  if (valb > -6) {
+    out.push_back(base64_url_alphabet[((val<<8)>>(valb+8))&0x3F]);
+  }
+  return out;
+}
+
 int main(int argc, char **argv) {
 	InitLogger(LogLevel::Warning);
 
 	Configuration config;
 	// config.iceServers.emplace_back("stun.l.google.com:19302");
 
+	std::string payload;
+
 	auto pc = std::make_shared<PeerConnection>(config);
 
-	pc->onLocalDescription([](const Description &description) {
-		cout << "Local Description (Paste this to the other peer):" << endl;
-		cout << string(description) << endl;
+	pc->onLocalDescription([wpc = make_weak_ptr(pc)](const Description &description){
+		auto pc = wpc.lock();
+		if (!pc)
+			return;
+
+		pc->connectionInfo += description;
+		pc->connectionInfo += ",";
 	});
 
-	pc->onLocalCandidate([](const Candidate &candidate) {
-		cout << "Local Candidate (Paste this to the other peer after the local description):"
-		     << endl;
-		cout << string(candidate) << endl << endl;
+	pc->onLocalCandidate([wpc = make_weak_ptr(pc)](const Candidate &candidate) {
+		auto pc = wpc.lock();
+		if (!pc)
+			return;
+
+		pc->connectionInfo += candidate;
+
+		cout << pc->connectionInfo << endl << endl;
+
+		auto encoded = base64_encode(pc->connectionInfo);
+		cout << "http://localhost:8080/answerer.html?connection=" << encoded << endl << endl;
+
+		httplib::Client cli("localhost", 8000);
+
+		auto res = cli.Get("/state/json");
+		if (!res)
+			return;
+
+		while (res->body.empty()) {
+			std::this_thread::sleep_for(2s);
+			res = cli.Get("/state/json");
+		}
+
+		pc->setRemoteDescription(res->body);
 	});
 
-	pc->onStateChange(
-	    [](PeerConnection::State state) { cout << "[State: " << state << "]" << endl; });
+	pc->onStateChange([wpc = make_weak_ptr(pc)](PeerConnection::State state) {
+		cout << "[State: " << state << "]" << endl;
+	});
 
 	pc->onGatheringStateChange([](PeerConnection::GatheringState state) {
 		cout << "[Gathering State: " << state << "]" << endl;
@@ -75,10 +134,7 @@ int main(int argc, char **argv) {
 		        "*****"
 		     << endl
 		     << "* 0: Exit /"
-		     << " 1: Enter remote description /"
-		     << " 2: Enter remote candidate /"
-		     << " 3: Send message /"
-		     << " 4: Print Connection Info *" << endl
+		     << " 1: Send message *" << endl
 		     << "[Command]: ";
 
 		int command = -1;
@@ -91,25 +147,6 @@ int main(int argc, char **argv) {
 			break;
 		}
 		case 1: {
-			// Parse Description
-			cout << "[Description]: ";
-			string sdp, line;
-			while (getline(cin, line) && !line.empty()) {
-				sdp += line;
-				sdp += "\r\n";
-			}
-			pc->setRemoteDescription(sdp);
-			break;
-		}
-		case 2: {
-			// Parse Candidate
-			cout << "[Candidate]: ";
-			string candidate;
-			getline(cin, candidate);
-			pc->addRemoteCandidate(candidate);
-			break;
-		}
-		case 3: {
 			// Send Message
 			if (!dc->isOpen()) {
 				cout << "** Channel is not Open ** ";

+ 111 - 0
web-client/answerScript.js

@@ -0,0 +1,111 @@
+function el(type, style, content) {
+  const element = document.createElement(type);
+  element.setAttribute('class', style);
+  element.append(content);
+  return element;
+}
+
+const UI = {
+  createMessageElement: function(style, message) {
+    const conversation =  document.getElementById('messages');
+    const messageElement = el('p', style + ' message', message);
+    conversation.append(messageElement);
+
+    const d = new Date();
+    const time = el('span', 'time', [
+      d.getHours().toString().padStart(2, '0'),
+      d.getMinutes().toString().padStart(2, '0'),
+      d.getSeconds().toString().padStart(2, '0')
+    ].join(':'));
+    messageElement.append(time);
+  },
+  messageTextBoxValue: function() {
+    return document.getElementById('message-text-box').value;
+  },
+  sendMessageButton: function() {
+    return document.getElementById('send-message-button');
+  },
+  setConnectionState: function(state) {
+    const stateEl = document.getElementById('connection-state');
+    stateEl.innerHTML = state;
+  }
+};
+(function (){
+  const connectionParam = getQueryParameter('connection');
+  const parsedConnection = atob(connectionParam).split(',');
+  const connectionMetadata = {
+    description: parsedConnection[0],
+    candidate: parsedConnection[1]
+  };
+  createRemoteConnection(connectionMetadata);
+})();
+
+function createRemoteConnection(connectionMetadata) {
+  console.log(connectionMetadata);
+  const connection = new RTCPeerConnection();
+
+  const remoteDesc = {
+    type: 'offer',
+    sdp: connectionMetadata.description
+  };
+  connection.setRemoteDescription(remoteDesc)
+    .then(() => UI.setConnectionState('set remote description'));
+  let connectionDescription = '';
+
+  const remoteCandidate = {
+    candidate: connectionMetadata.candidate,
+    sdpMid: '0', // Media stream ID for audio
+    sdpMLineIndex: 0 // Something to do with media
+  };
+  connection.addIceCandidate(remoteCandidate).then(
+    () => UI.setConnectionState('candidate added')
+  );
+
+  connection.createAnswer().then((desc) => {
+    connection.setLocalDescription(desc);
+    connectionDescription = desc.sdp;
+  });
+
+  connection.onicecandidate = e => {
+    if (e.candidate) {
+      const body = connectionDescription;
+      fetch(
+        'http://localhost:8000/state/json',
+        {
+          method: 'post',
+          headers: {'Content-Type': 'text/plain'},
+          body
+        }
+      ).then(response => {
+        if (response.status !== 200) {
+          throw new Error('bad status ' + response.status);
+        }
+      });
+    }
+  };
+  connection.ondatachannel = (e) => {
+    UI.setConnectionState('received channel: ' + JSON.stringify(e));
+    const channel = e.channel;
+    console.log(channel);
+    const sendButton = UI.sendMessageButton();
+    sendButton.addEventListener('click', sendMessage.bind(null, channel), false);
+    channel.onopen = () => {
+      console.log('open');
+      UI.setConnectionState('channel open');
+    };
+    channel.onmessage = (msg) => {
+      UI.createMessageElement('from-them', msg.data);
+    };
+  };
+}
+
+function sendMessage(channel) {
+  const message = UI.messageTextBoxValue();
+  UI.createMessageElement('from-me', message);
+  channel.send(message);
+}
+
+function getQueryParameter(name) {
+  const urlParams = new URLSearchParams(window.location.search);
+  return urlParams.get(name);
+}

+ 22 - 0
web-client/answerer.html

@@ -0,0 +1,22 @@
+<!doctype html>
+<html>
+    <head>
+        <title>Web Rtc Answerer</title>
+        <link rel="stylesheet" href="/style.css" />
+    </head>
+    <body>
+        <div id="message-container">
+            <h1>Web Rtc</h1>
+            <div id="messages"></div>
+        </div>
+        <div id="message-input">
+            <p id="connection-state">Pending</p>
+            <textarea id="message-text-box"
+                placeholder="Send a message"
+            ></textarea>
+            <br/>
+            <button id="send-message-button">Send</button>
+        </div>
+        <script src="/answerScript.js"></script>
+    </body>
+</html>

+ 15 - 0
web-client/index.html

@@ -0,0 +1,15 @@
+<!doctype html>
+<html>
+    <head>
+        <title>Web Rtc Example</title>
+    </head>
+    <body>
+        <h1>Web Rtc</h1>
+        <button id="createConnectionBtn">Create Connection</button>
+        <br/>
+        <textarea id="sendData" placeholder="Send a message" style="width: 500px; height: 50px"></textarea>
+        <br/>
+        <button id="sendDataBtn">Send Data</button>
+        <script src="/script.js"></script>
+    </body>
+</html>

+ 69 - 0
web-client/script.js

@@ -0,0 +1,69 @@
+(function (){
+  console.log('Hello');
+  const connectButton = document.getElementById('createConnectionBtn');
+  connectButton.addEventListener('click', createConnection, false);
+})();
+
+function createConnection() {
+  const localConnection = new RTCPeerConnection();
+  const sendChannel = localConnection.createDataChannel('channel');
+  const connectionInfo = {};
+  localConnection.onicecandidate = e => {
+    if (e.candidate) {
+      const candidate = e.candidate.candidate;
+      connectionInfo.candidate = candidate;
+      const answererUrl = 'http://localhost:8080/answerer.html?connection=' + btoa(JSON.stringify(connectionInfo));
+      const createLink = document.createElement('a');
+      createLink.setAttribute('href', answererUrl);
+      createLink.setAttribute('target', 'new');
+      createLink.append('Open me ;)');
+      document.body.append(createLink);
+      const pollForConnection = setInterval(() => {
+        fetch(
+          'http://localhost:8000/state/json'
+        ).then(response => {
+          if (response.status !== 200) {
+            throw new Error('bad status ' + response.status);
+          }
+          return response.json();
+        }).then(data => {
+          if (data.description) {
+            console.log('yes');
+            clearInterval(pollForConnection);
+            createRemoteConnection(data.description);
+          }
+          else {
+            console.log('no');
+          }
+        });
+      }, 5000);
+    }
+  };
+
+  localConnection.createOffer().then((desc) => {
+    connectionInfo.description = desc.sdp;
+    localConnection.setLocalDescription(desc);
+  });
+
+  function createRemoteConnection(desc) {
+    const remoteDesc = {
+      type: 'answer',
+      sdp: desc
+    };
+    localConnection.setRemoteDescription(remoteDesc).then((e) => {
+      console.log(e);
+    });
+  }
+
+  const sendButton = document.getElementById('sendDataBtn');
+  sendButton.addEventListener('click', sendMessage, false);
+  function sendMessage() {
+    const messageText = document.getElementById('sendData').value;
+    sendChannel.send(messageText);   
+  }
+  sendChannel.onmessage = (msg) => {
+    document.body.append(msg.data);
+  };
+}
+
+

+ 29 - 0
web-client/server.js

@@ -0,0 +1,29 @@
+const http = require('http');
+
+let connectionMetadata;
+http.createServer(function(req, res) {
+  console.log(req.method.toUpperCase(), req.url);
+  if (req.method === 'POST') {
+    let body = '';
+    req.on('data', chunk => body += chunk);
+    req.on('end', () => {
+      connectionMetadata = body;
+      res.writeHead(200);
+      res.end();
+    });
+    return;
+  }
+  if (req.method === 'GET') {
+    res.writeHead(200, {'Content-Type': 'text/plain'});
+    res.end(connectionMetadata);
+    return;
+  }
+  if (req.method === 'OPTIONS') {
+    res.writeHead(200, {
+      'Access-Control-Allow-Origin': '*',
+    });
+    res.end(connectionMetadata);
+    return;
+  }
+  console.error('unknown method: ' + req.method);
+}).listen(8000);

+ 79 - 0
web-client/style.css

@@ -0,0 +1,79 @@
+body {
+  background-color: #fff5e3;
+  font-family: sans-serif;
+  display: flex;
+  flex-wrap: wrap;
+  margin: 0;
+}
+
+#message-container {
+  padding: 0 5%;
+  width: 100%;
+}
+
+h1 {
+  width: 100%;
+}
+
+#message-input {
+  width: 100%;
+  position: fixed;
+  top: 90%;
+  height: 10%;
+  display: flex;
+  background-color: #a0a0a0f7;
+}
+
+#message-text-box {
+  width: 90%;
+  border: none;
+  border-radius: 20px 0 0 20px;
+  padding: 5px;
+  vertical-align: middle;
+  font-size: medium;
+  resize: none;
+  vertical-align: middle;
+}
+
+#message-text-box:focus {
+  outline: none;
+}
+
+#messages {
+  display: flex;
+  flex-direction:column;
+  width: 100%;
+  margin: auto;
+}
+
+#send-message-button {
+  width: 10%;
+  font-size: medium;
+}
+#send-message-button:hover {
+  opacity: 10%;
+}
+
+.message {
+  width: 40%;
+  flex-basis: 100%;
+  border: 1px solid;
+  padding: 1%;
+  border-radius: 8px;
+  box-shadow: 2px 2px #a0a0a0f7;
+}
+
+.message .time {
+  font-size: x-small;
+  display: flex;
+  align-self:flex-end;
+}
+
+.from-me {
+  background-color: #dcf8c6;
+}
+
+.from-them {
+  background-color: #fff;
+  align-self:flex-end;
+}

+ 1 - 0
webrtc_server/.gitignore

@@ -0,0 +1 @@
+/target

+ 909 - 0
webrtc_server/Cargo.lock

@@ -0,0 +1,909 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+[[package]]
+name = "aho-corasick"
+version = "0.7.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8716408b8bc624ed7f65d223ddb9ac2d044c0547b6fa4b0d554f3a9540496ada"
+dependencies = [
+ "memchr",
+]
+
+[[package]]
+name = "atty"
+version = "0.2.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
+dependencies = [
+ "hermit-abi",
+ "libc",
+ "winapi 0.3.8",
+]
+
+[[package]]
+name = "autocfg"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d"
+
+[[package]]
+name = "base64"
+version = "0.9.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "489d6c0ed21b11d038c31b6ceccca973e65d73ba3bd8ecb9a2babf5546164643"
+dependencies = [
+ "byteorder",
+ "safemem",
+]
+
+[[package]]
+name = "base64"
+version = "0.10.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e"
+dependencies = [
+ "byteorder",
+]
+
+[[package]]
+name = "bincode"
+version = "1.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5753e2a71534719bf3f4e57006c3a4f0d2c672a4b676eec84161f763eca87dbf"
+dependencies = [
+ "byteorder",
+ "serde",
+]
+
+[[package]]
+name = "bitflags"
+version = "1.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
+
+[[package]]
+name = "byteorder"
+version = "1.3.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
+
+[[package]]
+name = "cc"
+version = "1.0.50"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd"
+
+[[package]]
+name = "cfg-if"
+version = "0.1.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
+
+[[package]]
+name = "cookie"
+version = "0.11.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d9fac5e7bdefb6160fb181ee0eaa6f96704b625c70e6d61c465cb35750a4ea12"
+dependencies = [
+ "base64 0.9.3",
+ "ring",
+ "time",
+ "url",
+]
+
+[[package]]
+name = "devise"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "74e04ba2d03c5fa0d954c061fc8c9c288badadffc272ebb87679a89846de3ed3"
+dependencies = [
+ "devise_codegen",
+ "devise_core",
+]
+
+[[package]]
+name = "devise_codegen"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "066ceb7928ca93a9bedc6d0e612a8a0424048b0ab1f75971b203d01420c055d7"
+dependencies = [
+ "devise_core",
+ "quote 0.6.13",
+]
+
+[[package]]
+name = "devise_core"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cf41c59b22b5e3ec0ea55c7847e5f358d340f3a8d6d53a5cf4f1564967f96487"
+dependencies = [
+ "bitflags",
+ "proc-macro2 0.4.30",
+ "quote 0.6.13",
+ "syn 0.15.44",
+]
+
+[[package]]
+name = "filetime"
+version = "0.2.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1ff6d4dab0aa0c8e6346d46052e93b13a16cf847b54ed357087c35011048cc7d"
+dependencies = [
+ "cfg-if",
+ "libc",
+ "redox_syscall",
+ "winapi 0.3.8",
+]
+
+[[package]]
+name = "fsevent"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5ab7d1bd1bd33cc98b0889831b72da23c0aa4df9cec7e0702f46ecea04b35db6"
+dependencies = [
+ "bitflags",
+ "fsevent-sys",
+]
+
+[[package]]
+name = "fsevent-sys"
+version = "2.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f41b048a94555da0f42f1d632e2e19510084fb8e303b0daa2816e733fb3644a0"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "fuchsia-zircon"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82"
+dependencies = [
+ "bitflags",
+ "fuchsia-zircon-sys",
+]
+
+[[package]]
+name = "fuchsia-zircon-sys"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
+
+[[package]]
+name = "glob"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
+
+[[package]]
+name = "hermit-abi"
+version = "0.1.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1010591b26bbfe835e9faeabeb11866061cc7dcebffd56ad7d0942d0e61aefd8"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "httparse"
+version = "1.3.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9"
+
+[[package]]
+name = "hyper"
+version = "0.10.16"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0a0652d9a2609a968c14be1a9ea00bf4b1d64e2e1f53a1b51b6fff3a6e829273"
+dependencies = [
+ "base64 0.9.3",
+ "httparse",
+ "language-tags",
+ "log 0.3.9",
+ "mime",
+ "num_cpus",
+ "time",
+ "traitobject",
+ "typeable",
+ "unicase 1.4.2",
+ "url",
+]
+
+[[package]]
+name = "idna"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e"
+dependencies = [
+ "matches",
+ "unicode-bidi",
+ "unicode-normalization",
+]
+
+[[package]]
+name = "indexmap"
+version = "1.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "076f042c5b7b98f31d205f1249267e12a6518c1481e9dae9764af19b707d2292"
+dependencies = [
+ "autocfg",
+]
+
+[[package]]
+name = "inotify"
+version = "0.7.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "24e40d6fd5d64e2082e0c796495c8ef5ad667a96d03e5aaa0becfd9d47bcbfb8"
+dependencies = [
+ "bitflags",
+ "inotify-sys",
+ "libc",
+]
+
+[[package]]
+name = "inotify-sys"
+version = "0.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e74a1aa87c59aeff6ef2cc2fa62d41bc43f54952f55652656b18a02fd5e356c0"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "iovec"
+version = "0.1.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "itoa"
+version = "0.4.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b8b7a7c0c47db5545ed3fef7468ee7bb5b74691498139e4b3f6a20685dc6dd8e"
+
+[[package]]
+name = "kernel32-sys"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
+dependencies = [
+ "winapi 0.2.8",
+ "winapi-build",
+]
+
+[[package]]
+name = "language-tags"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a"
+
+[[package]]
+name = "lazy_static"
+version = "1.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
+
+[[package]]
+name = "lazycell"
+version = "1.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f"
+
+[[package]]
+name = "libc"
+version = "0.2.67"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "eb147597cdf94ed43ab7a9038716637d2d1bf2bc571da995d0028dec06bd3018"
+
+[[package]]
+name = "log"
+version = "0.3.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b"
+dependencies = [
+ "log 0.4.8",
+]
+
+[[package]]
+name = "log"
+version = "0.4.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7"
+dependencies = [
+ "cfg-if",
+]
+
+[[package]]
+name = "matches"
+version = "0.1.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08"
+
+[[package]]
+name = "memchr"
+version = "2.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400"
+
+[[package]]
+name = "mime"
+version = "0.2.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ba626b8a6de5da682e1caa06bdb42a335aee5a84db8e5046a3e8ab17ba0a3ae0"
+dependencies = [
+ "log 0.3.9",
+]
+
+[[package]]
+name = "mio"
+version = "0.6.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "302dec22bcf6bae6dfb69c647187f4b4d0fb6f535521f7bc022430ce8e12008f"
+dependencies = [
+ "cfg-if",
+ "fuchsia-zircon",
+ "fuchsia-zircon-sys",
+ "iovec",
+ "kernel32-sys",
+ "libc",
+ "log 0.4.8",
+ "miow",
+ "net2",
+ "slab",
+ "winapi 0.2.8",
+]
+
+[[package]]
+name = "mio-extras"
+version = "2.0.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "52403fe290012ce777c4626790c8951324a2b9e3316b3143779c72b029742f19"
+dependencies = [
+ "lazycell",
+ "log 0.4.8",
+ "mio",
+ "slab",
+]
+
+[[package]]
+name = "miow"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919"
+dependencies = [
+ "kernel32-sys",
+ "net2",
+ "winapi 0.2.8",
+ "ws2_32-sys",
+]
+
+[[package]]
+name = "net2"
+version = "0.2.33"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88"
+dependencies = [
+ "cfg-if",
+ "libc",
+ "winapi 0.3.8",
+]
+
+[[package]]
+name = "notify"
+version = "4.0.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "80ae4a7688d1fab81c5bf19c64fc8db920be8d519ce6336ed4e7efe024724dbd"
+dependencies = [
+ "bitflags",
+ "filetime",
+ "fsevent",
+ "fsevent-sys",
+ "inotify",
+ "libc",
+ "mio",
+ "mio-extras",
+ "walkdir",
+ "winapi 0.3.8",
+]
+
+[[package]]
+name = "num_cpus"
+version = "1.12.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "46203554f085ff89c235cd12f7075f3233af9b11ed7c9e16dfe2560d03313ce6"
+dependencies = [
+ "hermit-abi",
+ "libc",
+]
+
+[[package]]
+name = "pear"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c26d2b92e47063ffce70d3e3b1bd097af121a9e0db07ca38a6cc1cf0cc85ff25"
+dependencies = [
+ "pear_codegen",
+]
+
+[[package]]
+name = "pear_codegen"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "336db4a192cc7f54efeb0c4e11a9245394824cc3bcbd37ba3ff51240c35d7a6e"
+dependencies = [
+ "proc-macro2 0.4.30",
+ "quote 0.6.13",
+ "syn 0.15.44",
+ "version_check 0.1.5",
+ "yansi 0.4.0",
+]
+
+[[package]]
+name = "percent-encoding"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831"
+
+[[package]]
+name = "proc-macro2"
+version = "0.4.30"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
+dependencies = [
+ "unicode-xid 0.1.0",
+]
+
+[[package]]
+name = "proc-macro2"
+version = "1.0.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6c09721c6781493a2a492a96b5a5bf19b65917fe6728884e7c44dd0c60ca3435"
+dependencies = [
+ "unicode-xid 0.2.0",
+]
+
+[[package]]
+name = "quote"
+version = "0.6.13"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1"
+dependencies = [
+ "proc-macro2 0.4.30",
+]
+
+[[package]]
+name = "quote"
+version = "1.0.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f"
+dependencies = [
+ "proc-macro2 1.0.9",
+]
+
+[[package]]
+name = "redox_syscall"
+version = "0.1.56"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84"
+
+[[package]]
+name = "regex"
+version = "1.3.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "322cf97724bea3ee221b78fe25ac9c46114ebb51747ad5babd51a2fc6a8235a8"
+dependencies = [
+ "aho-corasick",
+ "memchr",
+ "regex-syntax",
+ "thread_local",
+]
+
+[[package]]
+name = "regex-syntax"
+version = "0.6.16"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1132f845907680735a84409c3bebc64d1364a5683ffbce899550cd09d5eaefc1"
+
+[[package]]
+name = "ring"
+version = "0.13.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2c4db68a2e35f3497146b7e4563df7d4773a2433230c5e4b448328e31740458a"
+dependencies = [
+ "cc",
+ "lazy_static",
+ "libc",
+ "untrusted",
+]
+
+[[package]]
+name = "rocket"
+version = "0.4.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e20afbad214b001cabbe31dd270b48b3be980a7153ee2ed8392e241f856d651b"
+dependencies = [
+ "atty",
+ "base64 0.10.1",
+ "log 0.4.8",
+ "memchr",
+ "num_cpus",
+ "pear",
+ "rocket_codegen",
+ "rocket_http",
+ "state",
+ "time",
+ "toml",
+ "version_check 0.9.1",
+ "yansi 0.5.0",
+]
+
+[[package]]
+name = "rocket_codegen"
+version = "0.4.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2108b35e2c3a35759d3f16cc3002ece05523191d884d3ad6523693fd43324dde"
+dependencies = [
+ "devise",
+ "glob",
+ "indexmap",
+ "quote 0.6.13",
+ "rocket_http",
+ "version_check 0.9.1",
+ "yansi 0.5.0",
+]
+
+[[package]]
+name = "rocket_contrib"
+version = "0.4.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a10e7471279bc2d4a21b6fddd9589016bb119e6fbb547b216dd54ef237f28341"
+dependencies = [
+ "log 0.4.8",
+ "notify",
+ "rocket",
+ "serde",
+ "serde_json",
+]
+
+[[package]]
+name = "rocket_cors"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "270a960cba5a0b7928ad74268db7773ce932da6b550478383cefebe9f46c4e13"
+dependencies = [
+ "log 0.3.9",
+ "regex",
+ "rocket",
+ "serde",
+ "serde_derive",
+ "unicase 2.6.0",
+ "unicase_serde",
+ "url",
+]
+
+[[package]]
+name = "rocket_http"
+version = "0.4.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6ce8ca76247376ea21cf271af0f95e3f2014596e3e4c7cc04e44ee6242a40ff2"
+dependencies = [
+ "cookie",
+ "hyper",
+ "indexmap",
+ "pear",
+ "percent-encoding",
+ "smallvec",
+ "state",
+ "time",
+ "unicode-xid 0.1.0",
+]
+
+[[package]]
+name = "ryu"
+version = "1.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bfa8506c1de11c9c4e4c38863ccbe02a305c8188e85a05a784c9e11e1c3910c8"
+
+[[package]]
+name = "safemem"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072"
+
+[[package]]
+name = "same-file"
+version = "1.0.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
+dependencies = [
+ "winapi-util",
+]
+
+[[package]]
+name = "serde"
+version = "1.0.104"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449"
+
+[[package]]
+name = "serde_derive"
+version = "1.0.104"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "128f9e303a5a29922045a830221b8f78ec74a5f544944f3d5984f8ec3895ef64"
+dependencies = [
+ "proc-macro2 1.0.9",
+ "quote 1.0.3",
+ "syn 1.0.16",
+]
+
+[[package]]
+name = "serde_json"
+version = "1.0.48"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9371ade75d4c2d6cb154141b9752cf3781ec9c05e0e5cf35060e1e70ee7b9c25"
+dependencies = [
+ "itoa",
+ "ryu",
+ "serde",
+]
+
+[[package]]
+name = "slab"
+version = "0.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"
+
+[[package]]
+name = "smallvec"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5c2fb2ec9bcd216a5b0d0ccf31ab17b5ed1d627960edff65bbe95d3ce221cefc"
+
+[[package]]
+name = "state"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7345c971d1ef21ffdbd103a75990a15eb03604fc8b8852ca8cb418ee1a099028"
+
+[[package]]
+name = "syn"
+version = "0.15.44"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5"
+dependencies = [
+ "proc-macro2 0.4.30",
+ "quote 0.6.13",
+ "unicode-xid 0.1.0",
+]
+
+[[package]]
+name = "syn"
+version = "1.0.16"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "123bd9499cfb380418d509322d7a6d52e5315f064fe4b3ad18a53d6b92c07859"
+dependencies = [
+ "proc-macro2 1.0.9",
+ "quote 1.0.3",
+ "unicode-xid 0.2.0",
+]
+
+[[package]]
+name = "thread_local"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14"
+dependencies = [
+ "lazy_static",
+]
+
+[[package]]
+name = "time"
+version = "0.1.42"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f"
+dependencies = [
+ "libc",
+ "redox_syscall",
+ "winapi 0.3.8",
+]
+
+[[package]]
+name = "toml"
+version = "0.4.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f"
+dependencies = [
+ "serde",
+]
+
+[[package]]
+name = "traitobject"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079"
+
+[[package]]
+name = "typeable"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1410f6f91f21d1612654e7cc69193b0334f909dcf2c790c4826254fbb86f8887"
+
+[[package]]
+name = "unicase"
+version = "1.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7f4765f83163b74f957c797ad9253caf97f103fb064d3999aea9568d09fc8a33"
+dependencies = [
+ "version_check 0.1.5",
+]
+
+[[package]]
+name = "unicase"
+version = "2.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6"
+dependencies = [
+ "version_check 0.9.1",
+]
+
+[[package]]
+name = "unicase_serde"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6ef53697679d874d69f3160af80bc28de12730a985d57bdf2b47456ccb8b11f1"
+dependencies = [
+ "serde",
+ "unicase 2.6.0",
+]
+
+[[package]]
+name = "unicode-bidi"
+version = "0.3.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5"
+dependencies = [
+ "matches",
+]
+
+[[package]]
+name = "unicode-normalization"
+version = "0.1.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5479532badd04e128284890390c1e876ef7a993d0570b3597ae43dfa1d59afa4"
+dependencies = [
+ "smallvec",
+]
+
+[[package]]
+name = "unicode-xid"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
+
+[[package]]
+name = "unicode-xid"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
+
+[[package]]
+name = "untrusted"
+version = "0.6.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "55cd1f4b4e96b46aeb8d4855db4a7a9bd96eeeb5c6a1ab54593328761642ce2f"
+
+[[package]]
+name = "url"
+version = "1.7.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a"
+dependencies = [
+ "idna",
+ "matches",
+ "percent-encoding",
+]
+
+[[package]]
+name = "version_check"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd"
+
+[[package]]
+name = "version_check"
+version = "0.9.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce"
+
+[[package]]
+name = "walkdir"
+version = "2.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d"
+dependencies = [
+ "same-file",
+ "winapi 0.3.8",
+ "winapi-util",
+]
+
+[[package]]
+name = "webrtc_server"
+version = "0.1.0"
+dependencies = [
+ "bincode",
+ "rocket",
+ "rocket_contrib",
+ "rocket_cors",
+ "serde",
+ "serde_derive",
+ "serde_json",
+]
+
+[[package]]
+name = "winapi"
+version = "0.2.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
+
+[[package]]
+name = "winapi"
+version = "0.3.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6"
+dependencies = [
+ "winapi-i686-pc-windows-gnu",
+ "winapi-x86_64-pc-windows-gnu",
+]
+
+[[package]]
+name = "winapi-build"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
+
+[[package]]
+name = "winapi-i686-pc-windows-gnu"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
+
+[[package]]
+name = "winapi-util"
+version = "0.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4ccfbf554c6ad11084fb7517daca16cfdcaccbdadba4fc336f032a8b12c2ad80"
+dependencies = [
+ "winapi 0.3.8",
+]
+
+[[package]]
+name = "winapi-x86_64-pc-windows-gnu"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
+
+[[package]]
+name = "ws2_32-sys"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e"
+dependencies = [
+ "winapi 0.2.8",
+ "winapi-build",
+]
+
+[[package]]
+name = "yansi"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d60c3b48c9cdec42fb06b3b84b5b087405e1fa1c644a1af3930e4dfafe93de48"
+
+[[package]]
+name = "yansi"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9fc79f4a1e39857fc00c3f662cbf2651c771f00e9c15fe2abc341806bd46bd71"

+ 18 - 0
webrtc_server/Cargo.toml

@@ -0,0 +1,18 @@
+[package]
+name = "webrtc_server"
+version = "0.1.0"
+authors = ["Nico Chatzi <[email protected]>"]
+edition = "2018"
+
+[dependencies]
+rocket = "0.4.4"
+rocket_cors = "0.5.0"
+serde = "1.0"
+serde_json = "1.0"
+serde_derive = "1.0"
+bincode = "1.2.1"
+
+[dependencies.rocket_contrib]
+version = "0.4.4"
+default-features = false
+features = ["json"]

+ 147 - 0
webrtc_server/src/main.rs

@@ -0,0 +1,147 @@
+#![feature(proc_macro_hygiene, decl_macro)]
+
+#[macro_use]
+extern crate rocket;
+extern crate rocket_cors;
+#[macro_use]
+extern crate rocket_contrib;
+#[macro_use]
+extern crate serde_derive;
+
+extern crate bincode;
+
+use std::sync::Mutex;
+
+use rocket_contrib::json::{Json, JsonValue};
+
+use rocket::http::Method; // 1.
+
+use rocket_cors::{
+    AllowedHeaders, AllowedOrigins, Error, // 2.
+    Cors, CorsOptions // 3.
+};
+
+fn make_cors() -> Cors {
+    let allowed_origins = AllowedOrigins::some_exact(&[ // 4.
+        "http://localhost:8080",
+        "http://127.0.0.1:8080",
+        "http://localhost:8000",
+        "http://0.0.0.0:8000",
+    ]);
+
+    CorsOptions { // 5.
+        allowed_origins,
+        allowed_methods: vec![Method::Get, Method::Post].into_iter().map(From::from).collect(), // 1.
+        allowed_headers: AllowedHeaders::some(&[
+            "Authorization",
+            "Accept",
+            "Content-Type",
+            "User-Agent",
+            "Access-Control-Allow-Origin", // 6.
+        ]),
+        allow_credentials: true,
+        ..Default::default()
+    }
+    .to_cors()
+    .expect("error while building CORS")
+}
+
+type Data = Mutex<String>;
+
+#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
+pub struct ChannelData {
+    pub description: String,
+    pub candidate: String,
+}
+
+impl Default for ChannelData {
+    fn default() -> ChannelData {
+        ChannelData {
+            description: "".to_owned(),
+            candidate: "".to_owned(),
+        }
+    }
+}
+
+#[post("/json", data = "<payload>")]
+fn new(payload: String, state: rocket::State<Data>) -> JsonValue {
+    let mut data = state.lock().expect("state locked");
+    *data = payload;
+    json!({ "status": "ok" })
+}
+
+#[get("/json")]
+fn get(state: rocket::State<Data>) -> Option<String> {
+    let data = state.lock().expect("state locked");
+    Some(data.clone())
+}
+
+#[catch(404)]
+fn not_found() -> JsonValue {
+    json!({
+        "status": "error",
+        "reason": "Resource was not found."
+    })
+}
+
+fn rocket() -> rocket::Rocket {
+    rocket::ignite()
+        .mount("/state", routes![new, get])
+        .register(catchers![not_found])
+        .manage(Mutex::new(String::new()))
+        .attach(make_cors())
+}
+
+fn main() {
+    rocket().launch();
+}
+
+#[cfg(test)]
+mod test {
+    use super::*;
+
+    use rocket::http::{ContentType, Status};
+    use rocket::local::Client;
+
+    #[test]
+    fn test_save_load() {
+        let data = ChannelData {
+            description: "v=0
+            o=- 3294530454 0 IN IP4 127.0.0.1
+            s=-
+            t=0 0
+            a=group:BUNDLE 0
+            m=application 9 UDP/DTLS/SCTP webrtc-datachannel
+            c=IN IP4 0.0.0.0
+            a=ice-ufrag:ntAX
+            a=ice-pwd:H59OKuJgItlvJZR5E78QYo
+            a=ice-options:trickle
+            a=mid:0
+            a=setup:actpass
+            a=dtls-id:1
+            a=fingerprint:sha-256 72:0E:8D:8C:9F:A2:E4:40:E7:2E:23:EF:F6:E7:89:94:0F:6B:78:9A:36:61:43:2C:6A:45:30:62:CB:68:B3:73
+            a=sctp-port:5000
+            a=max-message-size:262144".to_owned(),
+            candidate: "a=candidate:1 1 UDP 2122317823 10.0.1.83 55100 typ host".to_owned(),
+        };
+        println!("{:?}", data);
+        let client = Client::new(rocket()).unwrap();
+
+        let res = client
+            .post("/state/json")
+            .header(ContentType::JSON)
+            .remote("127.0.0.1:8000".parse().unwrap())
+            .body(serde_json::to_vec(&data).unwrap())
+            .dispatch();
+        assert_eq!(res.status(), Status::Ok);
+
+        let mut res = client
+            .get("/state/json")
+            .header(ContentType::JSON)
+            .dispatch();
+        assert_eq!(res.status(), Status::Ok);
+
+        let body = res.body().unwrap().into_string().unwrap();
+        println!("{}", body);
+    }
+}