From 96bdde3251893f29bd6a99159d8da4ba4e7b2b1e Mon Sep 17 00:00:00 2001
From: Michel Promonet <michel.promonet@free.fr>
Date: Tue, 5 Mar 2019 21:14:39 +0000
Subject: [PATCH] v4l2rtspserver: simplify build using release 0.1.6

Signed-off-by: Michel Promonet <michel.promonet@free.fr>
---
 multimedia/v4l2rtspserver/Makefile            | 47 +++++------------
 .../v4l2rtspserver/files/config.openwrt       | 19 -------
 .../v4l2rtspserver/files/v4l2rtspserver.init  | 11 ++--
 ...40-Switch-Makefile-to-compile-with-g.patch | 51 -------------------
 4 files changed, 18 insertions(+), 110 deletions(-)
 delete mode 100644 multimedia/v4l2rtspserver/files/config.openwrt
 delete mode 100644 multimedia/v4l2rtspserver/patches/040-Switch-Makefile-to-compile-with-g.patch

diff --git a/multimedia/v4l2rtspserver/Makefile b/multimedia/v4l2rtspserver/Makefile
index b7c75b107..4ea69b2bc 100644
--- a/multimedia/v4l2rtspserver/Makefile
+++ b/multimedia/v4l2rtspserver/Makefile
@@ -7,23 +7,23 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=v4l2rtspserver
-PKG_VERSION:=0.1.3
+PKG_VERSION:=0.1.6
 PKG_RELEASE:=1
 
 #cannot use codeload as this uses submodules
 PKG_SOURCE_PROTO:=git
 PKG_SOURCE_URL:=https://github.com/mpromonet/v4l2rtspserver
 PKG_SOURCE_VERSION:=v$(PKG_VERSION)
-PKG_MIRROR_HASH:=73499d0db515ae0d66c6d2a73c9c474ca35007aaf17451da01e793d972eab35a
-
-PKG_MAINTAINER:=Roger Dammit <rogerdammit@gmail.com>
-PKG_LICENSE:=Unlicense
-PKG_LICENSE_FILES:=LICENSE
+PKG_MIRROR_HASH:=9e076d2ecac08d5cbd0af7cfaa355e077e03fe35be73259ae7f520e2ef4243f8
 
 LIVE555_VERSION:=2019.02.03
 LIVE555_HASH:=1c938d91553eff224c7a860f8f38b3256028704b474a3fc6bcf2eddc42268710
 LIVE555_FILE:=live.$(LIVE555_VERSION).tar.gz
 
+PKG_MAINTAINER:=Roger Dammit <rogerdammit@gmail.com>
+PKG_LICENSE:=Unlicense
+PKG_LICENSE_FILES:=LICENSE
+
 PKG_BUILD_PARALLEL:=1
 CMAKE_INSTALL:=1
 
@@ -57,38 +57,19 @@ TARGET_CFLAGS += -flto
 TARGET_CXXFLAGS += -fno-rtti
 TARGET_LDFLAGS += -Wl,--gc-sections
 
-define Build/Prepare
+CMAKE_OPTIONS += -DALSA=OFF -DLIVE555CFLAGS="-DSOCKLEN_T=socklen_t -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64 -DLOCALE_NOT_USED -DNO_SSTREAM=1 -DALLOW_RTSP_SERVER_PORT_REUSE=1" 
+
+
+define Build/Prepare	
 	$(Build/Prepare/Default)
 
-	## need to compile some dependencies so that cmake will find them
-
-	# build live555
+	# download live555
 	$(eval $(call Download,live555))
-
-	mkdir -p $(PKG_BUILD_DIR)/live555
-	$(TAR) -xf $(DL_DIR)/$(LIVE555_FILE) --strip=1 -C $(PKG_BUILD_DIR)/live555
-	$(CP) files/config.openwrt $(PKG_BUILD_DIR)/live555
-	( cd $(PKG_BUILD_DIR)/live555; ./genMakefiles openwrt )
-
-	+$(MAKE_VARS) $(MAKE) $(MAKE_FLAGS) -C $(PKG_BUILD_DIR)/live555
-	 $(MAKE_VARS) $(MAKE) $(MAKE_FLAGS) -C $(PKG_BUILD_DIR)/live555 PREFIX="$(STAGING_DIR)/usr/" install
-
-	# build v4l2wrapper
-	+$(MAKE_VARS) $(MAKE) $(MAKE_FLAGS) -C $(PKG_BUILD_DIR)/v4l2wrapper
-	$(CP) $(PKG_BUILD_DIR)/v4l2wrapper/libv4l2wrapper.a $(PKG_BUILD_DIR)
-
-	# cmake patches (these are very hacky and should be a lot cleaner)
-
-	# prevent root path override
-	$(SED) 's/SET(CMAKE_FIND_ROOT_PATH/#SET(CMAKE_FIND_ROOT_PATH/' $(PKG_BUILD_DIR)/CMakeLists.txt
-
-	# set search path for v4l2wrapper to current build dir
-	$(SED) 's/V4L2WRAPPER_LIBRARY libv4l2wrapper.a/V4L2WRAPPER_LIBRARY libv4l2wrapper.a PATHS "." NO_CMAKE_FIND_ROOT_PATH/' $(PKG_BUILD_DIR)/CMakeLists.txt
-
-	# disable ALSA
-	$(SED) 's/find_package(ALSA QUIET)//' $(PKG_BUILD_DIR)/CMakeLists.txt
+	mkdir -p $(PKG_BUILD_DIR)/live
+	$(TAR) -xf $(DL_DIR)/$(LIVE555_FILE) --strip=1 -C $(PKG_BUILD_DIR)/live
 endef
 
+
 define Package/v4l2rtspserver/install
 	$(INSTALL_DIR) $(1)/usr/bin
 	$(INSTALL_BIN) $(PKG_BUILD_DIR)/v4l2rtspserver-$(PKG_VERSION) $(1)/usr/bin/
diff --git a/multimedia/v4l2rtspserver/files/config.openwrt b/multimedia/v4l2rtspserver/files/config.openwrt
deleted file mode 100644
index 382a11e31..000000000
--- a/multimedia/v4l2rtspserver/files/config.openwrt
+++ /dev/null
@@ -1,19 +0,0 @@
-COMPILE_OPTS =			$(INCLUDES) -DSOCKLEN_T=socklen_t -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64 -DLOCALE_NOT_USED -DNO_SSTREAM=1 -DALLOW_RTSP_SERVER_PORT_REUSE=1 
-C =				c
-C_COMPILER =			$(GCC)
-CFLAGS +=			$(COMPILE_OPTS)
-C_FLAGS =			$(CFLAGS)
-CPP =				cpp
-CPLUSPLUS_COMPILER =		$(AS) # optimizations are only in AR apparently, so use instead of CXX
-CPLUSPLUS_FLAGS =		$(COMPILE_OPTS) -Wall -DBSD=1
-CPLUSPLUS_FLAGS +=		$(CPPFLAGS) -fexceptions
-OBJ =				o
-LINK =				$(CXX) -o
-LINK_OPTS =			-L. $(LDFLAGS)
-CONSOLE_LINK_OPTS =		$(LINK_OPTS)
-LIBRARY_LINK =			$(AR) cr 
-LIBRARY_LINK_OPTS =    
-LIB_SUFFIX =			a
-LIBS_FOR_CONSOLE_APPLICATION =	$(CXXLIBS)
-LIBS_FOR_GUI_APPLICATION =	$(LIBS_FOR_CONSOLE_APPLICATION)
-EXE =
diff --git a/multimedia/v4l2rtspserver/files/v4l2rtspserver.init b/multimedia/v4l2rtspserver/files/v4l2rtspserver.init
index e4c837e8f..7a19ef520 100644
--- a/multimedia/v4l2rtspserver/files/v4l2rtspserver.init
+++ b/multimedia/v4l2rtspserver/files/v4l2rtspserver.init
@@ -40,10 +40,6 @@ start_instance() {
 	config_get path "$s" 'path'
 	config_get format "$s" 'format'
 
-	# pull out resolution width and height from string
-	local w="$(echo $resolution | cut -d'x' -f1)"
-	local h="$(echo $resolution | cut -d'x' -f2)"
-	
 	# make sure format is uppercase
 	format="$(echo $format | tr a-z A-Z)"
 
@@ -52,9 +48,10 @@ start_instance() {
 	args="$args -P $port"
 	args="$args -u ${path}"
 	args="$args -F $fps"
-	args="$args -W $w"
-	args="$args -H $h"
-	args="$args -f$format"
+	args="$args -G ${resolution}"
+        if [ ! -z "$format" ]; then
+                args="$args -f$format"
+        fi
 	args="$args -c" # fixes issue with corrupt frames with H264
 		
 	if [ -n "$username" ]; then
diff --git a/multimedia/v4l2rtspserver/patches/040-Switch-Makefile-to-compile-with-g.patch b/multimedia/v4l2rtspserver/patches/040-Switch-Makefile-to-compile-with-g.patch
deleted file mode 100644
index 0277d8a97..000000000
--- a/multimedia/v4l2rtspserver/patches/040-Switch-Makefile-to-compile-with-g.patch
+++ /dev/null
@@ -1,51 +0,0 @@
-From f732d44c2bc47e6eccf65e5eb3160734f11e5d3e Mon Sep 17 00:00:00 2001
-From: Rosen Penev <rosenp@gmail.com>
-Date: Thu, 27 Dec 2018 20:16:59 -0800
-Subject: [PATCH] Switch Makefile to compile with g++
-
-With this change I managed to get OpenWrt to compile with uclibcxx
-instead of libstdcpp.
-
-Made CXX adjustable by the shell as OpenWrt needs to override this.
-It also has its own ar.
-
-EXTRA_CXXFLAGS seems to be the proper variable based on usage in the
-OpenWrt tree.
----
- Makefile | 12 ++++++------
- 1 file changed, 6 insertions(+), 6 deletions(-)
-
-diff --git a/Makefile b/Makefile
-index 51aaa37..f05bf0d 100644
---- a/v4l2wrapper/Makefile
-+++ b/v4l2wrapper/Makefile
-@@ -1,12 +1,12 @@
--CFLAGS = -W -Wall -pthread -g -pipe $(CFLAGS_EXTRA)
--CFLAGS += -I inc
-+CXXFLAGS ?= -W -Wall -pthread -g -pipe $(EXTRA_CXXFLAGS)
-+CXXFLAGS += -I inc
- RM = rm -rf
--CC = $(CROSS)gcc
--AR = $(CROSS)ar
-+CXX ?= $(CROSS)g++
-+AR ?= $(CROSS)ar
- PREFIX?=/usr
- 
- ifneq ($(wildcard $(SYSROOT)$(PREFIX)/include/log4cpp/Category.hh),)
--CFLAGS += -DHAVE_LOG4CPP -I $(SYSROOT)$(PREFIX)/include
-+CXXFLAGS += -DHAVE_LOG4CPP -I $(SYSROOT)$(PREFIX)/include
- endif
- 
- V4L2WRAPPER_CPP:=$(wildcard src/*.cpp)
-@@ -17,7 +17,7 @@ V4L2WRAPPER_OBJ:=$(V4L2WRAPPER_CPP:%.cpp=%.o)
- all: libv4l2wrapper.a
- 
- %.o: %.cpp
--	$(CC) -c -o $@ $< $(CFLAGS)
-+	$(CXX) -c -o $@ $< $(CXXFLAGS)
- 
- libv4l2wrapper.a: $(V4L2WRAPPER_OBJ)
- 	$(AR) rcs $@ $^
--- 
-2.20.1
-