#
-# Copyright (C) 2013 OpenWrt.org
+# Copyright (C) 2014 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
PKG_NAME:=rtpproxy
PKG_VERSION:=1.2.1
-PKG_RELEASE:=1
+PKG_RELEASE:=2
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://b2bua.org/chrome/site/
URL:=http://www.rtpproxy.org/
endef
-# uses GNU configure
-
define Package/rtpproxy/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/rtpproxy $(1)/usr/bin/
+
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(INSTALL_BIN) ./files/rtpproxy.init $(1)/etc/init.d/rtpproxy
+
+ $(INSTALL_DIR) $(1)/etc/config
+ $(INSTALL_BIN) ./files/rtpproxy.config $(1)/etc/config/rtpproxy
endef
$(eval $(call BuildPackage,rtpproxy))
--- /dev/null
+config rtpproxy global
+ option enabled 0 # 0 - disabled, 1 - enabled
+
+config instance 'site1'
+ option socket 'udp:127.0.0.1:7723' # socket
+ option ipaddr '127.0.0.1' # IPv4 address
+ option ip6addr '2001:0db8:0000:0000:0000:0000:1428:57ab' # IPv6 address
+ option user 'nobody' # userid to run rtpproxy instance from
+ option opts '' # additional options for rtpproxy instance
+
+config instance 'site2'
+ option socket 'udp:127.0.0.1:7724'
+ option ipaddr '192.168.1.1'
+
--- /dev/null
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2014 CESNET, z.s.p.o
+
+START=99
+RTPPROXY_BIN="/usr/bin/rtpproxy"
+
+run_instance(){
+ local params="$1"
+
+ ${RTPPROXY_BIN} $1
+ echo "[INFO] rtpproxy instance $2 has started"
+}
+
+check_param(){
+ local param="$1"
+ local value="$2"
+ local default_value="$3"
+
+ if [ "$value" != "" ]; then
+ rtpproxy_options=$rtpproxy_options" $param $value"
+ else
+ if [ "$default_value" != "" ]; then
+ rtpproxy_options=$rtpproxy_options" $param $default_value"
+ fi
+ fi
+}
+
+check_special_param(){
+ local param="$1"
+
+ if [ "$param" != "" ]; then
+ rtpproxy_options=$rtpproxy_options" $param"
+ fi
+}
+
+handle_instance() {
+ local site="$1"
+ local socket opts ipaddr ip6addr rtpproxy_options
+
+ config_get socket "$site" socket
+ config_get opts "$site" opts
+ config_get ipaddr "$site" ipaddr
+ config_get ip6addr "$site" ip6addr
+ config_get user "$site" user
+
+ check_param "-s" "$socket"
+ check_param "-l" "$ipaddr"
+ check_param "-6" "$ip6addr"
+ check_param "-u" "$user" "nobody"
+ check_special_param "$opts"
+
+ run_instance "$rtpproxy_options" "$site"
+}
+
+start(){
+ config_load rtpproxy
+ local section="global"
+ config_get_bool enabled global enabled 0
+
+ if [ "$enabled" -eq 1 ]; then
+ config_foreach handle_instance instance
+ else
+ echo "[WARNING] rtpproxy not yet configured. Edit /etc/config/rtpproxy first."
+ fi
+}
+
+stop() {
+ killall rtpproxy
+}
+