Skip to content

Commit

Permalink
Merge branch 'release/18.10.1-rc0'
Browse files Browse the repository at this point in the history
  • Loading branch information
voluntas committed Nov 14, 2018
2 parents 82f7005 + 98e2f77 commit b3b7a73
Show file tree
Hide file tree
Showing 42 changed files with 1,916 additions and 1,180 deletions.
6 changes: 0 additions & 6 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
[submodule "libs/civetweb"]
path = libs/civetweb
url = https://github.com/civetweb/civetweb.git
[submodule "libs/websocketpp"]
path = libs/websocketpp
url = https://github.com/zaphoyd/websocketpp.git
[submodule "libs/json"]
path = libs/json
url = https://github.com/nlohmann/json.git
Expand Down
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

## develop

- [UPDATE] websocketpp と civietweb を Boost.beast に置き換える

## 18.10.0

**18.10.0-rc4 から変更なし**
Expand Down
31 changes: 7 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ ifeq ($(UNAME),Linux)
CC = $(RTC_ROOT)/src/third_party/llvm-build/Release+Asserts/bin/clang
CXX = $(RTC_ROOT)/src/third_party/llvm-build/Release+Asserts/bin/clang++
AR = $(RTC_ROOT)/src/third_party/llvm-build/Release+Asserts/bin/llvm-ar
CIVETWEB_OPT += -DUSE_WEBSOCKET -nostdinc++ -isystem$(RTC_ROOT)/src/buildtools/third_party/libc++/trunk/include
CFLAGS += -fpic
LDFLAGS += -lX11 -lXau -lXdmcp -lxcb -lplds4 -lXext -lexpat -ldl -lnss3 -lnssutil3 -lplc4 -lnspr4 -lrt
CFLAGS += -I/root/boost-1.68.0/include
Expand All @@ -37,14 +36,12 @@ ifeq ($(UNAME),Linux)
ifneq (,$(findstring arm64,$(ARCH)))
CC += --sysroot=$(SYSROOT) --target=aarch64-linux-gnu
CXX += --sysroot=$(SYSROOT) --target=aarch64-linux-gnu
CIVETWEB_OPT += -I$(SYSROOT)/usr/include/aarch64-linux-gnu
CFLAGS += -I$(SYSROOT)/usr/include/aarch64-linux-gnu
LDFLAGS += -L$(SYSROOT)/usr/lib/aarch64-linux-gnu
else
USE_IL_ENCODER ?= 1
CC += --sysroot=$(SYSROOT) --target=arm-linux-gnueabihf
CXX += --sysroot=$(SYSROOT) --target=arm-linux-gnueabihf
CIVETWEB_OPT += -I$(SYSROOT)/usr/include/arm-linux-gnueabihf
CFLAGS += -I$(SYSROOT)/usr/include/arm-linux-gnueabihf
LDFLAGS += -L$(SYSROOT)/usr/lib/arm-linux-gnueabihf -B$(SYSROOT)/usr/lib/arm-linux-gnueabihf
# ilclient
Expand Down Expand Up @@ -78,22 +75,12 @@ endif
SOURCE += $(shell find $(CURDIR)/src -name '*.cpp') $(RTC_LIB)

# boost
LDFLAGS += -lboost_system -lboost_filesystem
CFLAGS += -I$(RTC_ROOT)/src/third_party/boringssl/src/include -DOPENSSL_IS_BORINGSSL
LDFLAGS += -L$(RTC_LIB_PATH)/obj/third_party/boringssl -lboost_system -lboost_filesystem -lboringssl

# json
CFLAGS += -Ilibs/json/include

# websocketpp
WEBSOCKETPP_DIR = libs/websocketpp
CFLAGS += -I$(WEBSOCKETPP_DIR)/ -I$(RTC_ROOT)/src/third_party/boringssl/src/include -D_WEBSOCKETPP_CPP11_STL_ -DOPENSSL_IS_BORINGSSL
LDFLAGS += -L$(RTC_LIB_PATH)/obj/third_party/boringssl -lboost_system -lboost_filesystem -lboringssl

# civetweb
CIVETWEB_DIR = libs/civetweb
CIVETWEB_LIB = libcivetweb.a
CFLAGS += -I$(CIVETWEB_DIR)/include
SOURCE += $(CIVETWEB_LIB)

# CLI11
CFLAGS += -Ilibs/CLI11/include

Expand All @@ -102,7 +89,11 @@ ifeq ($(BUILD_MODE),pkg)
LDFLAGS += -s
endif

all: $(TARGET)
all: git.init $(TARGET)

.PHONY: git.init
git.init:
git submodule update -i

$(IL_OBJECT): $(ILCLIENT_DIR)/%.o : $(ILCLIENT_DIR)/%.c
@rm -f $@
Expand All @@ -114,14 +105,6 @@ $(ILCLIENT_LIB): $(IL_OBJECT)
$(RTC_LIB): $(shell find $(RTC_LIB_PATH)/obj -name '*.o')
$(AR) -rcT $@ $^

$(CIVETWEB_LIB):
git submodule init
git submodule update
cd $(CIVETWEB_DIR) && git reset --hard
patch -p1 $(CIVETWEB_DIR)/src/civetweb.c < patch/civetweb_signal.patch
$(MAKE) -C $(CIVETWEB_DIR) clean lib WITH_CPP=1 WITH_WEBSOCKET=1 CC="$(CC)" CXX="$(CXX)" COPT="$(CIVETWEB_OPT)"
cp $(CIVETWEB_DIR)/$(CIVETWEB_LIB) .

$(TARGET): $(SOURCE)
$(CXX) -o $@ $(CFLAGS) $(INCLUDES) $^ $(LDFLAGS)

Expand Down
62 changes: 0 additions & 62 deletions NOTICE
Original file line number Diff line number Diff line change
@@ -1,33 +1,3 @@
# websocketpp

https://github.com/zaphoyd/websocketpp/

```
Copyright (c) 2014, Peter Thorson. 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 the WebSocket++ Project 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 PETER THORSON 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.
```

## Base 64 Library (base64/base64.hpp)

```
Expand Down Expand Up @@ -186,38 +156,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```

# civetweb

https://github.com/civetweb/civetweb/

```
Copyright (c) 2013-2018 The CivetWeb developers ([CREDITS.md](https://github.com/civetweb/civetweb/blob/master/CREDITS.md))

Copyright (c) 2004-2013 Sergey Lyubka

Copyright (c) 2013 No Face Press, LLC (Thomas Davis)

Copyright (c) 2013 F-Secure Corporation

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
```

# Boost

https://www.boost.org/LICENSE_1_0.txt
Expand Down
12 changes: 3 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,8 @@ https://github.com/shiguredo/momo/issues

ベストエフォートで運用しています。

https://discord.gg/gmEuZye
https://discord.gg/gmEuZye

### 有償サポートについて
### 有料サポートについて

WebRTC Native Client に対する有償でのサポート契約については WebRTC SFU Sora ライセンス契約をしているお客様が前提となります。

## サポーター

**サポーター企業募集中です**

- [株式会社時雨堂](https://shiguredo.jp)
WebRTC Native Client に対する有料でのサポート契約については WebRTC SFU Sora ライセンス契約をしているお客様が前提となります。
2 changes: 1 addition & 1 deletion build/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BUILD_NUMBER=$(shell date +"%Y%m%d%H%M%S")
WEBRTC_VERSION=70
MOMO_VERSION=18.10.0
MOMO_VERSION=18.10.1-rc0

TARGET=$@

Expand Down
2 changes: 1 addition & 1 deletion doc/BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ $ make x86_64

## ビルド時に Raspberry Pi の HWA を無効にする方法

- armv6, armv7 の場合、デフォルトで HWA を利用する。もし利用したくない場合は `make USE_IL_ENCODER=0 armv7` のように `USE_IL_ENCODER=0` を指定すること
- armv6, armv7 の場合、デフォルトで HWA を利用します。もし利用したくない場合は `make USE_IL_ENCODER=0 armv7` のように `USE_IL_ENCODER=0` を指定してください
1 change: 0 additions & 1 deletion libs/civetweb
Submodule civetweb deleted from 0f1b43
1 change: 0 additions & 1 deletion libs/websocketpp
Submodule websocketpp deleted from c6d7e2
23 changes: 0 additions & 23 deletions patch/civetweb_signal.patch

This file was deleted.

79 changes: 19 additions & 60 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@

#include "rtc_base/logsinks.h"

#include "CivetServer.h"

#include "connection_settings.h"
#include "rtc/manager.h"
#include "ws_client/client.h"
#include "sora/sora_server.h"
#include "p2p/p2p_server.h"

Expand All @@ -40,33 +37,6 @@ using json = nlohmann::json;

const size_t kDefaultMaxLogFileSize = 10 * 1024 * 1024;

struct signal_waiter {
void set_running(bool running) {
std::unique_lock<std::mutex> lock(_mutex);
_running = running;
_condition.notify_all();
}

void wait_until_running() {
std::unique_lock<std::mutex> lock(_mutex);
while (_running) {
_condition.wait(lock);
}
}

private:
std::mutex _mutex;
bool _running;
std::condition_variable _condition;

} _signal_waiter;

static void sigintHandler(int sig)
{
_signal_waiter.set_running(false);
}


// 列挙した文字列のみを許可するバリデータ
struct Enum : public CLI::Validator {
Enum(std::vector<std::string> xs) {
Expand Down Expand Up @@ -119,9 +89,6 @@ int main(int argc, char* argv[])
bool version = false;
int log_level = rtc::LS_NONE;

_signal_waiter.set_running(true);
signal(SIGINT, sigintHandler);

app.add_flag("--no-video", cs.no_video, "ビデオを表示しない");
app.add_flag("--no-audio", cs.no_audio, "オーディオを出さない");
app.add_option("--video-codec", cs.video_codec, "ビデオコーデック")->check(Enum({"VP8", "VP9", "H264"}));
Expand Down Expand Up @@ -194,38 +161,30 @@ int main(int argc, char* argv[])
rtc::LogMessage::AddLogToStream(log_sink.get(), rtc::LS_INFO);

std::unique_ptr<RTCManager> rtc_manager(new RTCManager(cs));
std::unique_ptr<WebSocketClient> ws_client(new WebSocketClient());

std::string currentPath = boost::filesystem::path(boost::filesystem::current_path()).string();
std::string port_str = std::to_string(cs.p2p_port);
const char* options[] = {
"document_root", currentPath.c_str(),
"listening_ports", port_str.c_str(),
0
};
std::unique_ptr<CivetServer> server(new CivetServer(options));

std::unique_ptr<SoraServer> sora_server;
if (sora_app->parsed()) {
sora_server.reset(new SoraServer(
server.get(), rtc_manager.get(), ws_client.get(), cs));
}

std::unique_ptr<P2PHandlerProxy> p2p_handler_proxy;
std::shared_ptr<P2PServer> p2p_server;
if (p2p_app->parsed()) {
p2p_handler_proxy.reset(new P2PHandlerProxy());
p2p_server = P2PServer::create(server.get(), p2p_handler_proxy.get(), rtc_manager.get(), cs);
}
{
boost::asio::io_context ioc{1};

boost::asio::signal_set signals(ioc, SIGINT, SIGTERM);
signals.async_wait([&](const boost::system::error_code&, int) {
ioc.stop();
});

_signal_waiter.wait_until_running();
if (sora_app->parsed()) {
const boost::asio::ip::tcp::endpoint endpoint{boost::asio::ip::make_address("127.0.0.1"), 8080};
std::make_shared<SoraServer>(ioc, endpoint, rtc_manager.get(), cs)->run();
}

if (p2p_app->parsed()) {
const boost::asio::ip::tcp::endpoint endpoint{boost::asio::ip::make_address("0.0.0.0"), static_cast<unsigned short>(cs.p2p_port)};
std::make_shared<P2PServer>(ioc, endpoint, std::make_shared<std::string>(currentPath), rtc_manager.get(), cs)->run();
}

ioc.run();
}

p2p_server = nullptr;
sora_server = nullptr;
server = nullptr;
// p2p_handler_proxy は必ず CivetServer より後に消すこと
p2p_handler_proxy = nullptr;
ws_client = nullptr;
rtc_manager = nullptr;

return 0;
Expand Down
18 changes: 13 additions & 5 deletions src/p2p/p2p_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
#include <nlohmann/json.hpp>

#include "p2p_connection.h"
#include "util.h"

using json = nlohmann::json;
using IceConnectionState = webrtc::PeerConnectionInterface::IceConnectionState;

P2PConnection::P2PConnection(RTCManager* rtc_manager, struct mg_connection* ws_conn) :
_ws_conn(ws_conn)
P2PConnection::P2PConnection(RTCManager* rtc_manager, std::function<void (std::string)> send) :
_send(send)
{
webrtc::PeerConnectionInterface::RTCConfiguration rtc_config;
webrtc::PeerConnectionInterface::IceServers servers;
Expand All @@ -19,12 +21,16 @@ P2PConnection::P2PConnection(RTCManager* rtc_manager, struct mg_connection* ws_c

void P2PConnection::onIceConnectionStateChange(IceConnectionState new_state)
{
RTC_LOG(LS_INFO) << __FUNCTION__ << " rtc_state " << Util::iceConnectionStateToString(_rtc_state) << " -> " << Util::iceConnectionStateToString(new_state);

_rtc_state = new_state;
}

void P2PConnection::onIceCandidate(
const std::string sdp_mid, const int sdp_mlineindex, const std::string sdp)
{
RTC_LOG(LS_INFO) << __FUNCTION__;

json json_cand = {
{"type", "candidate"}
};
Expand All @@ -34,15 +40,17 @@ void P2PConnection::onIceCandidate(
{"sdpMid", sdp_mid}
};
std::string str_cand = json_cand.dump();
mg_websocket_write(_ws_conn, WEBSOCKET_OPCODE_TEXT, str_cand.c_str(), str_cand.length());
_send(std::move(str_cand));
}

void P2PConnection::onCreateDescription(webrtc::SdpType type, const std::string sdp)
{
RTC_LOG(LS_INFO) << __FUNCTION__;

json json_desc = {
{"type", webrtc::SdpTypeToString(type)},
{"sdp", sdp}
};
std::string str_desc = json_desc.dump();
mg_websocket_write(_ws_conn, WEBSOCKET_OPCODE_TEXT, str_desc.c_str(), str_desc.length());
}
_send(std::move(str_desc));
}
Loading

0 comments on commit b3b7a73

Please sign in to comment.