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

Commit

Permalink
Merge pull request #62 from qwu16/cascading
Browse files Browse the repository at this point in the history
Add quic_transport library for OWT clusters bridge
  • Loading branch information
qwu16 authored Jan 5, 2023
2 parents 9c72ad3 + 1c5a0ed commit bf77561
Show file tree
Hide file tree
Showing 34 changed files with 3,287 additions and 0 deletions.
83 changes: 83 additions & 0 deletions quic_transport/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Copyright (C) <2020> Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0

import("//chrome/process_version_rc_template.gni")
import("//testing/test.gni")

config("owt_quic_transport_config") {
include_dirs = [
"sdk",
"sdk/api",
]
defines = [ "OWT_QUIC_LIBRARY_IMPL" ]
}

source_set("owt_quic_transport_impl") {
public_deps = [
":generate_version_info",
"//base",
"//net",
"//net:simple_quic_tools",
"//net/third_party/quiche:quiche_tool_support",
"//third_party/boringssl",
]
sources = [
"sdk/api/owt/quic/logging.h",
"sdk/api/owt/quic/version.h",
"sdk/api/owt/quic/quic_transport_client_interface.h",
"sdk/api/owt/quic/quic_transport_factory.h",
"sdk/api/owt/quic/quic_transport_server_interface.h",
"sdk/api/owt/quic/quic_transport_server_session_interface.h",
"sdk/api/owt/quic/quic_transport_stream_interface.h",
"sdk/impl/logging.cc",
"sdk/impl/proof_source_owt.cc",
"sdk/impl/proof_source_owt.h",
"sdk/impl/quic_transport_factory_impl.cc",
"sdk/impl/quic_transport_factory_impl.h",
"sdk/impl/quic_transport_owt_client_base.cc",
"sdk/impl/quic_transport_owt_client_base.h",
"sdk/impl/quic_transport_owt_client_impl.cc",
"sdk/impl/quic_transport_owt_client_impl.h",
"sdk/impl/quic_transport_owt_client_session.cc",
"sdk/impl/quic_transport_owt_client_session.h",
"sdk/impl/quic_transport_owt_dispatcher.cc",
"sdk/impl/quic_transport_owt_dispatcher.h",
"sdk/impl/quic_transport_owt_server_impl.cc",
"sdk/impl/quic_transport_owt_server_impl.h",
"sdk/impl/quic_transport_owt_server_session.cc",
"sdk/impl/quic_transport_owt_server_session.h",
"sdk/impl/quic_transport_owt_stream_impl.cc",
"sdk/impl/quic_transport_owt_stream_impl.h",
]
configs += [ ":owt_quic_transport_config" ]
}

action("update_last_change") {
script = "//build/util/lastchange.py"
args = [
"-s",
rebase_path("//owt"),
"--filter",
".*",
"-o",
rebase_path("$target_gen_dir/lastchange"),
]
outputs = [ "$target_gen_dir/lastchange" ]
}

process_version("generate_version_info") {
deps = [ ":update_last_change" ]
template_file = "sdk/impl/version_info_values.h.template"
sources = [
"$target_gen_dir/lastchange",
"sdk/VER",
]
output = "$target_gen_dir/version_info_values.h"
}

shared_library("owt_quic_transport") {
deps = [ ":owt_quic_transport_impl" ]
configs += [ ":owt_quic_transport_config" ]
}

28 changes: 28 additions & 0 deletions quic_transport/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright 2015 The Chromium Authors. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

73 changes: 73 additions & 0 deletions quic_transport/docs/build_instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Building OWT QUIC SDK

## System requirements

- At least 50GB of free disk space.
- High speed network connection.
- Ubuntu 18.04 for Ubuntu build.
- Chromium source code base 109.0.5414.67

## Install dependencies

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`.

## Get the code

Create a new directory for the check out, and create a `.gclient` file in this directory. Add following code to `.gclient` file.

```
solutions = [
{ "name" : "src/owt",
"url" : "https://github.com/open-webrtc-toolkit/owt-sdk-quic.git",
"deps_file" : "DEPS",
"managed" : False,
"custom_deps" : {
},
"custom_vars": {},
},
]
```

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.

You will see a `src` directory after sync completes. Switch to the `src` directory for following steps.

## Additional changes

Some manually changes to Chromium code are needed before building SDK.

1. Apply patches in `owt/quic_transport/patches` to `src` directory.

1. Create a file `gclient_args.gni` in `build/config` with following code.

```
# Generated from 'DEPS'
build_with_chromium = true
checkout_android = false
checkout_android_native_support = false
checkout_ios_webkit = false
checkout_nacl = true
checkout_oculus_sdk = false
checkout_openxr = false
checkout_aemu = false
checkout_google_benchmark = false
```

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`.

## Build SDK

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
```
is_debug=true
is_component_build=false
symbol_level=1
```

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`.

Then run `ninja -C out/debug/ owt_quic_transport` to build the SDK.

## Certificates

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.
24 changes: 24 additions & 0 deletions quic_transport/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
## QUIC RAW Library

This library is based on chromium source code and exposes basic interfaces for raw data transporting.

## How to build
1. Get the chromium code. (https://chromium.googlesource.com/chromium/src/+/master/docs/linux_build_instructions.md)
2. Reset chromium commit close to 0d7f510fc898d4040d474a58b0eb609c43b6ac20.
3. Copy the code into chromium directory.
- cp -r src ${chromium}/src/net/tools/quic/raw
4. Patch the BUILD.gn file in chromium code.
- cd ${chroumium}
- git apply ${this-repo}/build-gn.patch
5. Set "is_debug=false" for gn args, build chromium target.
- ninja -C ${out-directory} rawquic

## How to use
1. Build the library yourself or download from link(TO-DO).
2. Add ${this-repo}/src/wrapper to include dir.
3. Same compile steps as other shared libraries.
Note that since our .so file is compiled through chromium's clang, clang is recommended for linking.

## About example
1. Place the .so file in ${this-repo}/lib
2. cd example/ && make
4 changes: 4 additions & 0 deletions quic_transport/sdk/VER
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
MAJOR=5
MINOR=1
BUILD=0
PATCH=0
35 changes: 35 additions & 0 deletions quic_transport/sdk/api/owt/quic/export.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright (C) 2019 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/

// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef OWT_WEB_TRANSPORT_EXPORT_H_
#define OWT_WEB_TRANSPORT_EXPORT_H_

// Defines OWT_EXPORT so that functionality implemented by the net module can
// be exported to consumers, and OWT_EXPORT_PRIVATE that allows unit tests to
// access features not intended to be used directly by real consumers.

#if defined(WIN32)

#ifdef OWT_QUIC_LIBRARY_IMPL
#define OWT_EXPORT __declspec(dllexport)
#define OWT_EXPORT_PRIVATE __declspec(dllexport)
#else
#define OWT_EXPORT __declspec(dllimport)
#define OWT_EXPORT_PRIVATE __declspec(dllimport)
#endif

#else // defined(WIN32)

#define OWT_EXPORT __attribute__((visibility("default")))
#define OWT_EXPORT_PRIVATE __attribute__((visibility("default")))

#endif

#endif // OWT_QUIC_EXPORT_H_
47 changes: 47 additions & 0 deletions quic_transport/sdk/api/owt/quic/logging.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef OWT_WEB_TRANSPORT_LOGGING_H_
#define OWT_WEB_TRANSPORT_LOGGING_H_

#include "export.h"

namespace owt {
namespace quic {

enum class LoggingSeverity : int {
/// This level is for data which we do not want to appear in the normal debug
/// log, but should appear in diagnostic logs.
kVerbose,
/// Chatty level used in debugging for all sorts of things, the default in
/// debug builds.
kInfo,
/// Something that may warrant investigation.
kWarning,
/// Something that should not have occurred.
kError,
/// Fatal errors.
kFatal
};

class OWT_EXPORT Logging {
public:
/// Set logging severity. All logging messages with higher severity will be
/// logged.
static void Severity(LoggingSeverity severity);
/// Get current logging severity.
static LoggingSeverity Severity();
// Init logging module.
static void InitLogging();

private:
static LoggingSeverity min_severity_;
};

} // namespace quic
} // namespace owt

#endif
48 changes: 48 additions & 0 deletions quic_transport/sdk/api/owt/quic/quic_transport_client_interface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef OWT_QUIC_TRANSPORT_CLIENT_INTERFACE_H_
#define OWT_QUIC_TRANSPORT_CLIENT_INTERFACE_H_

#include "owt/quic/export.h"
#include "owt/quic/quic_transport_stream_interface.h"

namespace owt {
namespace quic {
// A client manages a QuicTransport session with a QuicTransport server.
class OWT_EXPORT QuicTransportClientInterface {
public:
class Visitor {
public:
virtual ~Visitor() = default;
// Called when the connection state changed from connecting to connected.
virtual void OnConnected() = 0;
// Called when the connection state changed from connecting to failed.
virtual void OnConnectionFailed() = 0;
// Called when a session is closed.
virtual void OnConnectionClosed(char*, size_t len) = 0;
// Called when an incoming stream is received.
virtual void OnIncomingStream(QuicTransportStreamInterface*) = 0;
// Called when a stream is closed
virtual void OnStreamClosed(uint32_t id) = 0;
};

virtual ~QuicTransportClientInterface() = default;
// Set a visitor for the client.
virtual void SetVisitor(Visitor* visitor) = 0;
virtual void Start() = 0;
// Close QuicTransport session with server.
virtual void Stop() = 0;

virtual const char* Id() = 0;
virtual uint8_t length() = 0;
// Create a bidirectional stream.
virtual QuicTransportStreamInterface* CreateBidirectionalStream() = 0;
virtual void CloseStream(uint32_t id) = 0;
};
} // namespace quic
}
#endif
Loading

0 comments on commit bf77561

Please sign in to comment.