Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.

Commit bf77561

Browse files
authored
Merge pull request #62 from qwu16/cascading
Add quic_transport library for OWT clusters bridge
2 parents 9c72ad3 + 1c5a0ed commit bf77561

34 files changed

+3287
-0
lines changed

quic_transport/BUILD.gn

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Copyright (C) <2020> Intel Corporation
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
import("//chrome/process_version_rc_template.gni")
6+
import("//testing/test.gni")
7+
8+
config("owt_quic_transport_config") {
9+
include_dirs = [
10+
"sdk",
11+
"sdk/api",
12+
]
13+
defines = [ "OWT_QUIC_LIBRARY_IMPL" ]
14+
}
15+
16+
source_set("owt_quic_transport_impl") {
17+
public_deps = [
18+
":generate_version_info",
19+
"//base",
20+
"//net",
21+
"//net:simple_quic_tools",
22+
"//net/third_party/quiche:quiche_tool_support",
23+
"//third_party/boringssl",
24+
]
25+
sources = [
26+
"sdk/api/owt/quic/logging.h",
27+
"sdk/api/owt/quic/version.h",
28+
"sdk/api/owt/quic/quic_transport_client_interface.h",
29+
"sdk/api/owt/quic/quic_transport_factory.h",
30+
"sdk/api/owt/quic/quic_transport_server_interface.h",
31+
"sdk/api/owt/quic/quic_transport_server_session_interface.h",
32+
"sdk/api/owt/quic/quic_transport_stream_interface.h",
33+
"sdk/impl/logging.cc",
34+
"sdk/impl/proof_source_owt.cc",
35+
"sdk/impl/proof_source_owt.h",
36+
"sdk/impl/quic_transport_factory_impl.cc",
37+
"sdk/impl/quic_transport_factory_impl.h",
38+
"sdk/impl/quic_transport_owt_client_base.cc",
39+
"sdk/impl/quic_transport_owt_client_base.h",
40+
"sdk/impl/quic_transport_owt_client_impl.cc",
41+
"sdk/impl/quic_transport_owt_client_impl.h",
42+
"sdk/impl/quic_transport_owt_client_session.cc",
43+
"sdk/impl/quic_transport_owt_client_session.h",
44+
"sdk/impl/quic_transport_owt_dispatcher.cc",
45+
"sdk/impl/quic_transport_owt_dispatcher.h",
46+
"sdk/impl/quic_transport_owt_server_impl.cc",
47+
"sdk/impl/quic_transport_owt_server_impl.h",
48+
"sdk/impl/quic_transport_owt_server_session.cc",
49+
"sdk/impl/quic_transport_owt_server_session.h",
50+
"sdk/impl/quic_transport_owt_stream_impl.cc",
51+
"sdk/impl/quic_transport_owt_stream_impl.h",
52+
]
53+
configs += [ ":owt_quic_transport_config" ]
54+
}
55+
56+
action("update_last_change") {
57+
script = "//build/util/lastchange.py"
58+
args = [
59+
"-s",
60+
rebase_path("//owt"),
61+
"--filter",
62+
".*",
63+
"-o",
64+
rebase_path("$target_gen_dir/lastchange"),
65+
]
66+
outputs = [ "$target_gen_dir/lastchange" ]
67+
}
68+
69+
process_version("generate_version_info") {
70+
deps = [ ":update_last_change" ]
71+
template_file = "sdk/impl/version_info_values.h.template"
72+
sources = [
73+
"$target_gen_dir/lastchange",
74+
"sdk/VER",
75+
]
76+
output = "$target_gen_dir/version_info_values.h"
77+
}
78+
79+
shared_library("owt_quic_transport") {
80+
deps = [ ":owt_quic_transport_impl" ]
81+
configs += [ ":owt_quic_transport_config" ]
82+
}
83+

quic_transport/LICENSE

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright 2015 The Chromium Authors. All rights reserved.
2+
//
3+
// Redistribution and use in source and binary forms, with or without
4+
// modification, are permitted provided that the following conditions are
5+
// met:
6+
//
7+
// * Redistributions of source code must retain the above copyright
8+
// notice, this list of conditions and the following disclaimer.
9+
// * Redistributions in binary form must reproduce the above
10+
// copyright notice, this list of conditions and the following disclaimer
11+
// in the documentation and/or other materials provided with the
12+
// distribution.
13+
// * Neither the name of Google Inc. nor the names of its
14+
// contributors may be used to endorse or promote products derived from
15+
// this software without specific prior written permission.
16+
//
17+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Building OWT QUIC SDK
2+
3+
## System requirements
4+
5+
- At least 50GB of free disk space.
6+
- High speed network connection.
7+
- Ubuntu 18.04 for Ubuntu build.
8+
- Chromium source code base 109.0.5414.67
9+
10+
## Install dependencies
11+
12+
Please follow [Chromium Windows build instruction](https://chromium.googlesource.com/chromium/src/+/HEAD/docs/windows_build_instructions.md) or [Chromium Linux build instruction](https://chromium.googlesource.com/chromium/src/+/HEAD/docs/linux/build_instructions.md) to setup system and install `depot_tools`.
13+
14+
## Get the code
15+
16+
Create a new directory for the check out, and create a `.gclient` file in this directory. Add following code to `.gclient` file.
17+
18+
```
19+
solutions = [
20+
{ "name" : "src/owt",
21+
"url" : "https://github.com/open-webrtc-toolkit/owt-sdk-quic.git",
22+
"deps_file" : "DEPS",
23+
"managed" : False,
24+
"custom_deps" : {
25+
},
26+
"custom_vars": {},
27+
},
28+
]
29+
```
30+
31+
Run `gclient sync` to check out SDK code, Chromium code, and other dependencies. It may take one or two hours if your network connection is not fast enough.
32+
33+
You will see a `src` directory after sync completes. Switch to the `src` directory for following steps.
34+
35+
## Additional changes
36+
37+
Some manually changes to Chromium code are needed before building SDK.
38+
39+
1. Apply patches in `owt/quic_transport/patches` to `src` directory.
40+
41+
1. Create a file `gclient_args.gni` in `build/config` with following code.
42+
43+
```
44+
# Generated from 'DEPS'
45+
build_with_chromium = true
46+
checkout_android = false
47+
checkout_android_native_support = false
48+
checkout_ios_webkit = false
49+
checkout_nacl = true
50+
checkout_oculus_sdk = false
51+
checkout_openxr = false
52+
checkout_aemu = false
53+
checkout_google_benchmark = false
54+
```
55+
56+
Since we checked out code to `src/owt`, gclient cannot find buildtools under this directory. We need to add an environment variable `CHROMIUM_BUILDTOOLS_PATH`. Its value should be `<dir of .gclient file>/src/buildtools`.
57+
58+
## Build SDK
59+
60+
Run `gn gen out/debug` to generate ninja files, or `gn args out/debug` to configure GN arguments. For debug version, it may look like this
61+
```
62+
is_debug=true
63+
is_component_build=false
64+
symbol_level=1
65+
```
66+
67+
You may want to set `is_component_build` to `false` in order to get a single shared library, but you can also set it to `true` to reduce the compiling time for debugging. `symbol_level` is set to `1` since `2` is conflicted with `is_component_build=false`.
68+
69+
Then run `ninja -C out/debug/ owt_quic_transport` to build the SDK.
70+
71+
## Certificates
72+
73+
Encryption is mandatory for QUIC connections. You may generate a testing certificate by running `net/tools/quic/certs/generate-certs.sh`. It valids for 72 hours.

quic_transport/readme.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
## QUIC RAW Library
2+
3+
This library is based on chromium source code and exposes basic interfaces for raw data transporting.
4+
5+
## How to build
6+
1. Get the chromium code. (https://chromium.googlesource.com/chromium/src/+/master/docs/linux_build_instructions.md)
7+
2. Reset chromium commit close to 0d7f510fc898d4040d474a58b0eb609c43b6ac20.
8+
3. Copy the code into chromium directory.
9+
- cp -r src ${chromium}/src/net/tools/quic/raw
10+
4. Patch the BUILD.gn file in chromium code.
11+
- cd ${chroumium}
12+
- git apply ${this-repo}/build-gn.patch
13+
5. Set "is_debug=false" for gn args, build chromium target.
14+
- ninja -C ${out-directory} rawquic
15+
16+
## How to use
17+
1. Build the library yourself or download from link(TO-DO).
18+
2. Add ${this-repo}/src/wrapper to include dir.
19+
3. Same compile steps as other shared libraries.
20+
Note that since our .so file is compiled through chromium's clang, clang is recommended for linking.
21+
22+
## About example
23+
1. Place the .so file in ${this-repo}/lib
24+
2. cd example/ && make

quic_transport/sdk/VER

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
MAJOR=5
2+
MINOR=1
3+
BUILD=0
4+
PATCH=0
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright (C) 2019 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
8+
// Use of this source code is governed by a BSD-style license that can be
9+
// found in the LICENSE file.
10+
11+
#ifndef OWT_WEB_TRANSPORT_EXPORT_H_
12+
#define OWT_WEB_TRANSPORT_EXPORT_H_
13+
14+
// Defines OWT_EXPORT so that functionality implemented by the net module can
15+
// be exported to consumers, and OWT_EXPORT_PRIVATE that allows unit tests to
16+
// access features not intended to be used directly by real consumers.
17+
18+
#if defined(WIN32)
19+
20+
#ifdef OWT_QUIC_LIBRARY_IMPL
21+
#define OWT_EXPORT __declspec(dllexport)
22+
#define OWT_EXPORT_PRIVATE __declspec(dllexport)
23+
#else
24+
#define OWT_EXPORT __declspec(dllimport)
25+
#define OWT_EXPORT_PRIVATE __declspec(dllimport)
26+
#endif
27+
28+
#else // defined(WIN32)
29+
30+
#define OWT_EXPORT __attribute__((visibility("default")))
31+
#define OWT_EXPORT_PRIVATE __attribute__((visibility("default")))
32+
33+
#endif
34+
35+
#endif // OWT_QUIC_EXPORT_H_
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright (C) 2021 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef OWT_WEB_TRANSPORT_LOGGING_H_
8+
#define OWT_WEB_TRANSPORT_LOGGING_H_
9+
10+
#include "export.h"
11+
12+
namespace owt {
13+
namespace quic {
14+
15+
enum class LoggingSeverity : int {
16+
/// This level is for data which we do not want to appear in the normal debug
17+
/// log, but should appear in diagnostic logs.
18+
kVerbose,
19+
/// Chatty level used in debugging for all sorts of things, the default in
20+
/// debug builds.
21+
kInfo,
22+
/// Something that may warrant investigation.
23+
kWarning,
24+
/// Something that should not have occurred.
25+
kError,
26+
/// Fatal errors.
27+
kFatal
28+
};
29+
30+
class OWT_EXPORT Logging {
31+
public:
32+
/// Set logging severity. All logging messages with higher severity will be
33+
/// logged.
34+
static void Severity(LoggingSeverity severity);
35+
/// Get current logging severity.
36+
static LoggingSeverity Severity();
37+
// Init logging module.
38+
static void InitLogging();
39+
40+
private:
41+
static LoggingSeverity min_severity_;
42+
};
43+
44+
} // namespace quic
45+
} // namespace owt
46+
47+
#endif
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright (C) 2020 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef OWT_QUIC_TRANSPORT_CLIENT_INTERFACE_H_
8+
#define OWT_QUIC_TRANSPORT_CLIENT_INTERFACE_H_
9+
10+
#include "owt/quic/export.h"
11+
#include "owt/quic/quic_transport_stream_interface.h"
12+
13+
namespace owt {
14+
namespace quic {
15+
// A client manages a QuicTransport session with a QuicTransport server.
16+
class OWT_EXPORT QuicTransportClientInterface {
17+
public:
18+
class Visitor {
19+
public:
20+
virtual ~Visitor() = default;
21+
// Called when the connection state changed from connecting to connected.
22+
virtual void OnConnected() = 0;
23+
// Called when the connection state changed from connecting to failed.
24+
virtual void OnConnectionFailed() = 0;
25+
// Called when a session is closed.
26+
virtual void OnConnectionClosed(char*, size_t len) = 0;
27+
// Called when an incoming stream is received.
28+
virtual void OnIncomingStream(QuicTransportStreamInterface*) = 0;
29+
// Called when a stream is closed
30+
virtual void OnStreamClosed(uint32_t id) = 0;
31+
};
32+
33+
virtual ~QuicTransportClientInterface() = default;
34+
// Set a visitor for the client.
35+
virtual void SetVisitor(Visitor* visitor) = 0;
36+
virtual void Start() = 0;
37+
// Close QuicTransport session with server.
38+
virtual void Stop() = 0;
39+
40+
virtual const char* Id() = 0;
41+
virtual uint8_t length() = 0;
42+
// Create a bidirectional stream.
43+
virtual QuicTransportStreamInterface* CreateBidirectionalStream() = 0;
44+
virtual void CloseStream(uint32_t id) = 0;
45+
};
46+
} // namespace quic
47+
}
48+
#endif

0 commit comments

Comments
 (0)