Skip to content

Instantly share code, notes, and snippets.

@mariotaku
Created November 16, 2023 09:57
Show Gist options
  • Save mariotaku/c49807b6547423c02bce0d0b24c00d76 to your computer and use it in GitHub Desktop.
Save mariotaku/c49807b6547423c02bce0d0b24c00d76 to your computer and use it in GitHub Desktop.
MonaServer for OpenWRT
include $(TOPDIR)/rules.mk
PKG_NAME:=monaserver
PKG_VERSION:=2.750
PKG_RELEASE:=1
PKG_BUILD_DIR:=$(BUILD_DIR)/monaserver-$(PKG_VERSION)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/MonaSolutions/MonaServer2
PKG_SOURCE_VERSION:=5490a5814d00528b043da1005d65e08686e212e1
PKG_SOURCE_DATE:=2022-11-29
PKG_HASH:=e7beed5983c2a4bbadffeef049243ad88418ba8ba2d29cedcea5780777f1a7dc
include $(INCLUDE_DIR)/package.mk
define Package/monaserver
SECTION:=base
CATEGORY:=Utilities
SUBMENU:=Multimedia
TITLE:=MonaServer2
DEPENDS:=+libstdcpp +libatomic +libopenssl +luajit
URL:=https://github.com/MonaSolutions/MonaServer2
endef
define Package/monaserver/description
A lightweight RTMFP, RTMP, WebSocket and HTTP server!
endef
define Build/Compile
+$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
$(TARGET_CONFIGURE_OPTS) LIBS=-latomic
endef
define Package/monaserver/install
$(INSTALL_DIR) $(1)/etc/init.d $(1)/etc/MonaServer $(1)/usr/bin $(1)/usr/lib
$(INSTALL_BIN) ./files/monaserver.init $(1)/etc/init.d/monaserver
$(INSTALL_BIN) $(PKG_BUILD_DIR)/MonaServer/MonaServer $(1)/usr/bin/
$(CP) $(PKG_BUILD_DIR)/Mona*/lib/libMona*.so $(1)/usr/lib/
$(INSTALL_CONF) ./files/MonaServer.ini $(1)/etc/MonaServer
endef
$(eval $(call BuildPackage,monaserver))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; This file documents all the ini parameters of MonaServer ;;;
;;; and list them with their values by default, ;;;
;;; without this file their parameters values are these ;;;
;;; ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; By default MonaServer.exe search a "MonaServer.ini" ;;;
;;; in the same folder, but you can also start MonaServer ;;;
;;; with path to one other ini file as first argument: ;;;
;;; /> MonaServer /currentPath/Server.ini ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;; GENERAL ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; application description (displaid with --help argument for example)
description=MonaServer
; number of cores to use, default value 0 give a cores auto detection
cores=0
; reuses buffer rather delete them
poolBuffers=true
; www folder of Mona, containing server applications
wwwDir="www"
; data folder of Mona, containing database
dataDir="data"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;; CATEGORIZED ;;;;;;;;;;;;;;;;;;;;;;;;;;;
; configure logs of Mona, in addition if you set [logs=Publication]
; it makes logs accessible remotely by all protocols supported by mona
; (a 'logs' mona publication is created, see 'PUBLICATIONS' part above)
; For example you can see logs in real-time in a browser in opening http://locahost/logs.dat
[logs]
; directory where are stored logs
directory=/var/log/MonaServer
; max size for a log file, if exceeds it starts a new log file, 0 value continues indefinitely to write the same file
maxSize=1000000
; number of log files to preserve, 1 value write all logs in the same file, 0 value will write a illimited number of files
rotation=10
; configure path for TLS certificat and key
[TLS]
certificat=cert.pem
key=key.pem
; configure all sockets in mona
[net]
; bufferSize, base parameters for recvBufferSize and sendBufferSize
bufferSize=65536
; recvBufferSize, customize receiving socket buffer size
recvBufferSize=65536
; recvBufferSize, customize sending socket buffer size
sendBufferSize=65536
; Common properties and setting of publication, valable for all publication,
; can be specialized for one publication:see PUBLICATIONS below part
[publication]
; an user property
server=mona
; segmenting the publication to be available from HLS and configure the number of segments (0 by default for not segmenting)
; If just segments is set without value the default value is 4
segments=0
; max duration of every segments, by default (or if equals 0) it’s minimized to key-frame interval (one key by segment).
duration=0
; Define if a recording must override or append an old record, for details on recording see PUBLICATIONS below part
append=false
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;; SERVERS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Configure server and protocol of Mona, every protocol parameters can be
; generalized with general parameters (see above in GENERAL), for example
; you can set the same publicHost and bufferSize for all protocols and
; configure a specific bufferSize just for HTTP:
; publicHost=69.89.31.226
; bufferSize=65536
; [HTTP]
; bufferSize=131072
; [HTTP(=true|false)] HTTP server
[HTTP=false]
; socket bind
port=80
host=0.0.0.0
publicPort=80
publicHost=127.0.0.1
; socket parameters, if not set use [net] parameters (see above in CATEGORIZED)
bufferSize=65536
recvBufferSize=65536
sendBufferSize=65536
; timeout connection in seconds
timeout=10
; boolean or string, build a "index" files page on a folder GET request, if false returns a 401 unauthorized error
; value can be a file name to redirect a folder GET request to a file, for example index="index.html"
index=true
; rendezVous experimental service (HTTP 'RDV' command), allow to meet (with data exchange) two clients
; can be usefull to start a WebRTC session for example between two peers (with SDP exchange)
rendezVous=false
; Add HTTP header in response to isolated cross origin request, make working page with SharedArrayBuffer
; For more details see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Embedder-Policy
crossOriginIsolated=false
; [HTTPS(=true|false)] HTTP SSL server, disabled if TLS certificate and key are missing
[HTTPS=false]
; socket bind
port=443
host=0.0.0.0
publicPort=443
publicHost=127.0.0.1
; socket parameters, if not set use [net] parameters (see above in CATEGORIZED)
bufferSize=65536
recvBufferSize=65536
sendBufferSize=65536
; timeout connection in seconds
timeout=10
; boolean or string, build a "index" files page on a folder GET request, if false returns a 401 unauthorized error
; value can be a file name to redirect a folder GET request to a file, for example index="index.html"
index=true
; rendezVous experimental service (HTTP 'RDV' command), allow to meet (with data exchange) two clients
; can be usefull to start a WebRTC session for example between two peers (with SDP exchange)
rendezVous=false
; Add HTTP header in response to isolated cross origin request, make working page with SharedArrayBuffer
; For more details see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Embedder-Policy
crossOriginIsolated=false
; [WS(=true|false)] WebSocket server, disabled if HTTP is disabled
[WS]
; socket parameters only for clients, if not set use [net] parameters (see above in CATEGORIZED)
bufferSize=65536
recvBufferSize=65536
sendBufferSize=65536
; timeout connection in seconds
timeout=80
; [WSS(=true|false)] WebSocket SSL server, disabled if HTTPS is disabled
[WSS]
; socket parameters only for clients, if not set use [net] parameters (see above in CATEGORIZED)
bufferSize=65536
recvBufferSize=65536
sendBufferSize=65536
; timeout connection in seconds
timeout=80
; [STUN(=true|false)] STUN server
[STUN=false]
; socket bind
port=3478
host=0.0.0.0
publicPort=3478
publicHost=127.0.0.1
; socket parameters, if not set use [net] parameters (see above in CATEGORIZED)
bufferSize=65536
recvBufferSize=65536
sendBufferSize=65536
; [SRT(=true|false)] SRT server, disabled if Mona is not built with ENABLE_SRT
; Parameters also any SRT socket in mona even if server is disabled with [SRT=false]
[SRT]
; socket bind
port=9710
host=0.0.0.0
publicPort=9710
publicHost=127.0.0.1
; socket parameters, if not set use [net] parameters (see above in CATEGORIZED)
bufferSize=65536
recvBufferSize=65536
sendBufferSize=65536
; SRTO_TLPKTDROP, see https://github.com/Haivision/srt/blob/master/docs/API.md#options
pktdrop=true
; SRTO_PBKEYLEN, see https://github.com/Haivision/srt/blob/master/docs/API.md#options
encryption=0
; SRTO_PASSPHRASE, see https://github.com/Haivision/srt/blob/master/docs/API.md#options
passphrase=
; SRTO_RCVLATENCY, see https://github.com/Haivision/srt/blob/master/docs/API.md#options
latency=120
; SRTO_PEERLATENCY, see https://github.com/Haivision/srt/blob/master/docs/API.md#options
peerlatency=0
; SRTO_MSS, see https://github.com/Haivision/srt/blob/master/docs/API.md#options
mss=1500
; SRTO_OHEADBW, see https://github.com/Haivision/srt/blob/master/docs/API.md#options
overheadbw=25
; SRTO_MAXBW, see https://github.com/Haivision/srt/blob/master/docs/API.md#options
maxbw=-1
; [RTMP(=true|false)] RTMP (and RTMPE) server
[RTMP]
; socket bind
port=1935
host=0.0.0.0
publicPort=1935
publicHost=127.0.0.1
; socket parameters, if not set use [net] parameters (see above in CATEGORIZED)
bufferSize=65536
recvBufferSize=65536
sendBufferSize=65536
; timeout connection in seconds
timeout=60
; [RTMPS(=true|false)] RTMPS server, disabled if TLS certificat and key are missing
[RTMPS]
; socket bind
port=8443
host=0.0.0.0
publicPort=8443
publicHost=127.0.0.1
; socket parameters, if not set use [net] parameters (see above in CATEGORIZED)
bufferSize=65536
recvBufferSize=65536
sendBufferSize=65536
; timeout connection in seconds
timeout=60
; [RTMFP(=true|false)] RTMFP server
[RTMFP]
; socket bind
port=1935
host=0.0.0.0
publicPort=1935
publicHost=127.0.0.1
; socket parameters, if not set use [net] parameters (see above in CATEGORIZED)
bufferSize=65536
recvBufferSize=65536
sendBufferSize=65536
; keepalive frequency between peers in seconds
keepalivePeer=10
; keepalive frequency between peers in seconds
keepalivePeer=10
; addresses separated by semicolon of other RTMFP server to make scalable the rendezvous service of RTMFP
addresses=
;;;;;;;;;;;;;;;; MUTLIPLE SERVER INSTANCES ;;;;;;;;;;;;;;;;;;;;
; Start multiple server instances with [name=protocol], parameters inherit from those of the base protocol.
; Uncomment the two lines below for example to start a 2nd server HTTP on port 88
; [myHTTP2=HTTP]
; port=88
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;; PUBLICATIONS ;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Mona publication are media stream shared between all the protocol supported by Mona
; Any protocol can publish a new publication, or subscribe to a publication
; Use sub category with [name=Publication] to configure some publication properties and settings,
; as soon as a publication with this name is created these properties will be assigned to it.
; By this way it inherits of properties and settings set in [publication] section (see CATEGORIZED part below)
; [test=Publication]
; description= publication of test
; name=value
;
; Also allow of mapping a publication with input and output stream (TODO document it!)
; A publication with input streams will be created when a stream input start
; A publication with output streams will serve them one time the publication started by any protocol publisher
; Examples:
;
; create a publication 'test' reading Sintel.ts with its Sintel.vtt subtitle
; [test=publication]
; IN Sintel.ts
; IN Sintel.vtt
;
; will record publication 'test' in flv and its subtitle in srt
; [test=publication]
; OUT record.flv
; OUT record.srt
; UDP/TS input on port 1234 will be recorded in a mp4 file
; [test=publication]
; IN udp://0.0.0.0:1234 TS
; OUT record.mp4
; SRT/TS input on port 1234 will be pushed to https://localhost/test.mp4
; [test=publication]
; IN srt://0.0.0.0:1234
; OUT https://127.0.0.1/test.mp4
; resource 127.0.0.1:88/path/video.mp4 will be served to SRT on port 1234
; with encryption enabled and the passphrase "mypassphrase"
; [test=publication]
; IN http://127.0.0.1:88/path/video.mp4
; OUT srt://@0.0.0.0:1234 ?passphrase=mypassphrase
#!/bin/sh /etc/rc.common
# "new(er)" style init script
# Look at /lib/functions/service.sh on a running system for explanations of what other SERVICE_
# options you can use, and when you might want them.
START=99
APP=MonaServer
SERVICE_WRITE_PID=1
SERVICE_DAEMONIZE=1
start() {
service_start /usr/bin/$APP /etc/MonaServer/MonaServer.ini
}
stop() {
service_stop /usr/bin/$APP
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment