提交 57fe729f authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

Split code into mediasoup-hub (Node) and mediasoup-worker (C++)

上级 6c23ab20
*.o /mediasoup-worker/**/*.o
/bin/ /mediasoup-worker/bin/
/etc/mediasoup.cfg /mediasoup-worker/mediasoup-tester.sh
/etc/*.pem /mediasoup-worker/cldoc/
/mediasoup-tester.sh
/cldoc/
/TODO /TODO
[submodule "deps/jsoncpp"] [submodule "mediasoup-worker/submodules/usrsctp"]
path = deps/jsoncpp path = mediasoup-worker/submodules/usrsctp
url = https://github.com/open-source-parsers/jsoncpp.git
[submodule "deps/usrsctp"]
path = deps/usrsctp
url = https://github.com/sctplab/usrsctp.git url = https://github.com/sctplab/usrsctp.git
[submodule "mediasoup-worker/submodules/jsoncpp"]
path = mediasoup-worker/submodules/jsoncpp
url = https://github.com/open-source-parsers/jsoncpp.git
Copyright (c) 2014, Iñaki Baz Castillo <ibc@aliax.net> Copyright (c) 2015, Iñaki Baz Castillo <ibc@aliax.net>
Permission to use, copy, modify, and/or distribute this software for any Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above purpose with or without fee is hereby granted, provided that the above
......
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
# MediaSoup # MediaSoup
Flexible and powerful multi-stream media server ready for [WebRTC](http://www.webrtc.org/) and other RTP based technologies. Flexible and powerful Node.js library handling a C++ multi-stream media server ready for [WebRTC](http://www.webrtc.org/) and other RTP based technologies.
## IMPORTANT! ## IMPORTANT!
* Not ready yet. Work must be done on the *ControlProtocol* and the high level API in order to make MediaSoup usable. Working on it. * Working on it!
## Features ## Features
...@@ -18,75 +18,9 @@ Flexible and powerful multi-stream media server ready for [WebRTC](http://www.we ...@@ -18,75 +18,9 @@ Flexible and powerful multi-stream media server ready for [WebRTC](http://www.we
* IPv6 ready. * IPv6 ready.
* Signaling agnostic. MediaSoup does not deal with SIP or other signaling protocols. In the other side, it can deal with *any* signaling protocol. * Signaling agnostic. MediaSoup does not deal with SIP or other signaling protocols. In the other side, it can deal with *any* signaling protocol.
* SDP unaware. Really, MediaSoup will not parse a SDP for you. * SDP unaware. Really, MediaSoup will not parse a SDP for you.
* Just media. MediaSoup cares about media processing so it relies on an external application which deals with your preferred signaling protocol and manages MediaSoup by using the *MediaSoup ControlProtocol*.
* Extremely powerful. MediaSoup is coded in C++ on top of the awesome [libuv](https://github.com/libuv/libuv) asychronous I/O library. MediaSoup is a single process application with multiple *Worker* threads for media handling. MediaSoup takes full advantage of your CPU capabilities. * Extremely powerful. MediaSoup is coded in C++ on top of the awesome [libuv](https://github.com/libuv/libuv) asychronous I/O library. MediaSoup is a single process application with multiple *Worker* threads for media handling. MediaSoup takes full advantage of your CPU capabilities.
## Dependencies
* [libuv](https://github.com/libuv/libuv): Cross-platform asychronous I/O C library. Version ~1.0.2 required.
* [libconfig](http://www.hyperrealm.com/libconfig/): C/C++ library for processing configuration files. Version ~1.4.8 required.
* [openssl](https://www.openssl.org). Version >=1.0.1 required.
* [libsrtp](https://github.com/cisco/libsrtp). Version >=1.5.0 required.
## Requirements
MediaSoup runs in any Posix system (tested in Linux Debian 7 "Wheezy" and OSX 10.9 "Mavericks") in both 32 or 64 bits architectures (Big or Little Endian).
MediaSoup requires *C++11* and other features available in *gcc* >= 4.7 or *clang* >= 5.
## Installation
* Install dependencies (see above).
* Compile MediaSoup:
```
$ make
```
*TODO:* `make install`, `make test`, etc still missing.
## Running MediaSoup
The `mediasoup` binary is placed at the `bin/` directory. For help on its usage run it with `-h` or `--help`:
```
$ ./bin/mediasoup --help
MediaSoup v0.0.1
Copyright (c) 2014 Iñaki Baz Castillo | https://github.com/ibc
Usage: mediasoup [options]
Options:
-c, --configfile FILE Path to the configuration file
-d, --daemonize Run in daemon mode
-p, --pidfile FILE Create a PID file (requires daemon mode)
-u, --user USER Run with the given system user
-g, --group GROUP Run with the given system group
-v, --version Show version
-h, --help Show this message
```
An example configuration file is provided at `etc/mediasoup.default.cfg`. Rename it to `mediasoup.cfg` and edit it as per your needs.
### Reloading MediaSoup
Once it is running MediaSoup configuration can be reload by sending a *SIGUSR1* signal to the process:
```
$ kill -USR1 $(pidof mediasoup)
```
NOTE: Just certain options in the configuration file are reloaded (currently just *logLevel*).
## Documentation
[MediaSoup Documentation](docs/index.md) is placed in the `docs/` folder.
## Author ## Author
Iñaki Baz Castillo ([@ibc](https://github.com/ibc/) at Github) Iñaki Baz Castillo ([@ibc](https://github.com/ibc/) at Github)
......
Subproject commit d84702c9036505d0906b2f3d222ce5498ec65bc6
Subproject commit 2475e02ca0ecd1cb1f562bae5f11ee586919cc50
# ControlProtocol
The MediaSoup ControlProtocol is a bidirectional protocol to manage MediaSoup and multimedia sessions.
## Definitions
### ControlProtocol Request
A message which typically expects a Response.
### ControlProtocol Response
A message which is the response to a Request.
### ControlProtocol Notification
A message that does not expect a Response and its not a Response.
## Message Types
### Request
Every ControlProtocol Request conforms to the following syntax (note that CRLF means "\r\n" symbols):
```
Request type CRLF
uuid CRLF
*(key: value CRLF)
CRLF
```
where:
* *Request* is the "Request" literal string.
* *type* is a string indicating a valid ControlProtocol Request type.
* *uuid* is the integer identifier for this transaction (max length: 9 digits).
* *key* is a string indicating a parameter name.
* *value* is a string representing the value for a parameter.
### Response
Every ControlProtocol Response conforms to the following syntax (note that CRLF means "\r\n" symbols):
```
Response type CRLF
uuid status CRLF
[code: error_code CRLF]
[reason: error_reason CRLF]
*(key: value CRLF)
CRLF
```
where:
* *Response* is the "Response" literal string.
* *type* is a string indicating the type of the Request this Response is for.
* *uuid* matches the value in the Request.
* *status* is the "OK" or "ERROR" literal string.
* *code* is string indicating the exact error.
* *reason* is a descriptive string for the error.
* *key* is a string indicating a parameter name.
* *value* is a string representing the value for a parameter.
### Notification
Every ControlProtocol Notification conforms to the following syntax (note that CRLF means "\r\n" symbols):
```
Notification type CRLF
*(key: value CRLF)
CRLF
```
where:
* *Notification* is the "Notification" literal string.
* *type* is a string indicating a valid ControlProtocol Notification type.
* *key* is a string indicating a parameter name.
* *value* is a string representing the value for a parameter.
# Overview
## Definitions
### MediaSoup
The media server itself is a single process internally comprised of two main components: the *Dispatcher* and *Workers*.
### MediaSoup ControlProtocol
The MediaSoup [ControlProtocol](./ControlProtocol.md) is a bidirectional protocol to manage MediaSoup and multimedia sessions.
### Controller
The Controller is a separate application (not provided by MediaSoup) that can run in the same or a different host. The Controller manages the signaling protocol (for example SIP in case the Controller is a SIP proxy/server) and communicates with MediaSoup by using the MediaSoup [ControlProtocol](./ControlProtocol.md) over a TCP connection.
By using the MediaSoup ControlProtocol, the Controller requests MediaSoup to create multimedia sessions by providing MediaSoup with the required media information (this is, the media information of the remote peer) and receiving from MediaSoup its media information to be transmitted to the remote peer.
The Controller can generate multiparticipant sessions (let's say multi-conferences) or single sessions between two remote participants that communicate through MediaSoup (for example having MediaSoup behaving as a media gateway between a WebRTC endpoint and a legacy SIP device).
Multiple Controllers can communicate with the same instance of MediaSoup.
### MediaSoup Dispatcher
The Dispatcher is the MediaSoup component that listens for messages from Controllers and sends messages back to them when appropriate. The messages exchanged between both a Controller and the Dispatcher conform to the MediaSoup [ControlProtocol](./ControlProtocol.md).
The Dispatcher also uses the MediaSoup ControlProtocol to communicate with the MediaSoup Workers.
### MediaSoup Worker
An instance of MediaSoup runs N Workers instances (N is typically the number of cores detected in the host). A Worker manages multimedia sessions by handling the RTP, RTCP, ICE, DTLS and so on. A MediaSoup session (let it be a single session of two participants or a multiparticipant session) is handled by a single Worker, but a Worker can handle more than one session.
The MediaSoup Dispatcher communicates with the MediaSoup Workers (and vice-versa) by sending MediaSoup [ControlProtocol](./ControlProtocol.md) messages over UNIX sockets. The Dispatcher runs a separate communication channel with each Worker.
# MediaSoup Documentation
* [Overview](./Overview.md)
* [ControlProtocol](./ControlProtocol.md)
# Log level
# - Values: "debug", "info", "notice", "warning", "error" (double quoted)
# - Default value: "debug"
logLevel: "debug"
# Syslog facility
# - Values: "user", "local0"..."local7" (double quoted)
# - Default value: "user"
syslogFacility: "user"
# Number of workers
# - Default value: 0 (set it to the number of CPU cores)
numWorkers: 0
# ControlProtocol server
ControlProtocol:
{
# Listening IP
# - Values: IPv4 or IPv6 (double quoted)
# - Default value: "127.0.0.1"
listenIP: "127.0.0.1"
# Listening port
# - Default value: 4080
listenPort: 4080
}
# Real-Time Communication
RTC:
{
# IPv4 and IPv6 for media
# - Values:
# - IPv4 or IPv6 (double quoted)
# - true: the first auto-discovered and bindeable non-local IP is chosen
# - false: IP family disabled
# - Default value: true
# listenIPv4: "1.2.3.4"
listenIPv4: true
# listenIPv6: "A:B:C::D"
listenIPv6: true
# Minimun port for media
# - Default value: 10000
minPort: 10000
# Maximum port for media
# - Default value: 59999
maxPort: 59999
# DTLS certificate and private key files in PEM format
# - Values:
# - Absolute path to PEM files (double quoted)
# - false: certificate and private key are auto-generated
# - Default value: false
dtlsCertificateFile: false
dtlsPrivateKeyFile: false
}
...@@ -53,16 +53,16 @@ PKG_LIBS += libsrtp >= 1.5.2 ...@@ -53,16 +53,16 @@ PKG_LIBS += libsrtp >= 1.5.2
# Dependencies source files. # Dependencies source files.
DEP_SOURCES := DEP_SOURCES :=
DEP_SOURCES += ./deps/jsoncpp/dist/jsoncpp.cpp DEP_SOURCES += ./submodules/jsoncpp/dist/jsoncpp.cpp
# Dependencies header directories. # Dependencies header directories.
DEP_HEADERS_DIRS := DEP_HEADERS_DIRS :=
DEP_HEADERS_DIRS += ./deps/jsoncpp/dist DEP_HEADERS_DIRS += ./submodules/jsoncpp/dist
DEP_HEADERS_DIRS += ./deps/usrsctp/usrsctplib DEP_HEADERS_DIRS += ./submodules/usrsctp/usrsctplib
# Dependencies static libraries to link with. # Dependencies static libraries to link with.
DEP_LIBS := DEP_LIBS :=
DEP_LIBS += ./deps/usrsctp/usrsctplib/.libs/libusrsctp.a DEP_LIBS += ./submodules/usrsctp/usrsctplib/.libs/libusrsctp.a
# Object files to build. # Object files to build.
ALL_OBJS := ${APP_SOURCES:.cpp=.o} ${DEP_SOURCES:.cpp=.o} ALL_OBJS := ${APP_SOURCES:.cpp=.o} ${DEP_SOURCES:.cpp=.o}
...@@ -91,7 +91,7 @@ LDFLAGS += $(shell pkg-config --libs "$(PKG_LIBS)") ...@@ -91,7 +91,7 @@ LDFLAGS += $(shell pkg-config --libs "$(PKG_LIBS)")
# This indicates that "all", APP_NAME, "check_pkg_libs" and "clean" are # This indicates that "all", APP_NAME, "check_pkg_libs" and "clean" are
# "phony targets". Therefore calling "make XXXX" should execute the content of its # "phony targets". Therefore calling "make XXXX" should execute the content of its
# build rules, even if a newer file named "XXXX" exists. # build rules, even if a newer file named "XXXX" exists.
.PHONY: all $(APP_NAME) check_pkg_libs echo_all_objs clean deps doc .PHONY: all $(APP_NAME) check_pkg_libs echo_all_objs clean submodules doc
# This is first build rule in the Makefile, and so executing "make" and executing # This is first build rule in the Makefile, and so executing "make" and executing
# "make all" are the same. The target simply depends on $(APP_NAME). # "make all" are the same. The target simply depends on $(APP_NAME).
...@@ -126,14 +126,14 @@ clean: ...@@ -126,14 +126,14 @@ clean:
@ echo "INFO: deleting .o object files ..." @ echo "INFO: deleting .o object files ..."
@ $(RM) $(ALL_OBJS) @ $(RM) $(ALL_OBJS)
deps: submodules:
@ echo "INFO: retrieving Git submodules ..." @ echo "INFO: retrieving Git submodules ..."
git submodule init git submodule init
git submodule update git submodule update
@ echo "INFO: building jsoncpp lib ..." @ echo "INFO: building jsoncpp lib ..."
cd ./deps/jsoncpp && python amalgamate.py >/dev/null cd ./submodules/jsoncpp && python amalgamate.py >/dev/null
@ echo "INFO: building usrsctp lib ..." @ echo "INFO: building usrsctp lib ..."
cd ./deps/usrsctp && ./bootstrap && autoconf && ./configure && make cd ./submodules/usrsctp && ./bootstrap && autoconf && ./configure && make
doc: doc:
@ echo "INFO: generating documentation ..." @ echo "INFO: generating documentation ..."
......
Subproject commit 9234cbbc90d1f6c70dd5a90b4d533779e45c820c
Subproject commit 49335e137be22deec1eeb518c8b3e192c3d9a452
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论