diff mbox series

[1/2] package/libopenaptx: new package

Message ID 20211103083111.4016058-1-t123yh.xyz@gmail.com
State Accepted
Headers show
Series [1/2] package/libopenaptx: new package | expand

Commit Message

Yunhao Tian Nov. 3, 2021, 8:31 a.m. UTC
This adds support for libopenaptx, an aptX encoder and decoder.

Because the original project has no proper Makefile for cross
compilation, we provide a new CMakeLists file.

Signed-off-by: Yunhao Tian <t123yh.xyz@gmail.com>
---
 package/Config.in                             |  1 +
 .../libopenaptx/0001-fix-include-format.patch | 21 ++++++++
 package/libopenaptx/0002-add-cmake.patch      | 48 +++++++++++++++++++
 package/libopenaptx/Config.in                 |  9 ++++
 package/libopenaptx/libopenaptx.hash          |  3 ++
 package/libopenaptx/libopenaptx.mk            | 15 ++++++
 6 files changed, 97 insertions(+)
 create mode 100644 package/libopenaptx/0001-fix-include-format.patch
 create mode 100644 package/libopenaptx/0002-add-cmake.patch
 create mode 100644 package/libopenaptx/Config.in
 create mode 100644 package/libopenaptx/libopenaptx.hash
 create mode 100644 package/libopenaptx/libopenaptx.mk
diff mbox series

Patch

diff --git a/package/Config.in b/package/Config.in
index 2f83c87582..0412dfc13c 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -1721,6 +1721,7 @@  menu "Multimedia"
 	source "package/libmms/Config.in"
 	source "package/libmpeg2/Config.in"
 	source "package/libogg/Config.in"
+	source "package/libopenaptx/Config.in"
 	source "package/libopenh264/Config.in"
 	source "package/libopusenc/Config.in"
 	source "package/libtheora/Config.in"
diff --git a/package/libopenaptx/0001-fix-include-format.patch b/package/libopenaptx/0001-fix-include-format.patch
new file mode 100644
index 0000000000..01bd6e01a1
--- /dev/null
+++ b/package/libopenaptx/0001-fix-include-format.patch
@@ -0,0 +1,21 @@ 
+Fix include style in openaptx.c
+
+As openaptx.h resides in the same directory with the .c,
+we should use quotes to include rather than using angle
+brackets.
+
+Signed-off-by: Yunhao Tian <t123yh.xyz@gmail.com>
+
+Index: libopenaptx/openaptx.c
+===================================================================
+--- libopenaptx.orig/openaptx.c
++++ libopenaptx/openaptx.c
+@@ -24,7 +24,7 @@
+ #include <stdint.h>
+ #include <string.h>
+ 
+-#include <openaptx.h>
++#include "openaptx.h"
+ 
+ #if (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L) && !defined(inline)
+ #define inline
diff --git a/package/libopenaptx/0002-add-cmake.patch b/package/libopenaptx/0002-add-cmake.patch
new file mode 100644
index 0000000000..73735d6b4a
--- /dev/null
+++ b/package/libopenaptx/0002-add-cmake.patch
@@ -0,0 +1,48 @@ 
+Add CMakeLists.txt and libopenaptx.pc.in files.
+
+The original Makefile provided by the project is not suitable for
+cross-compilation. This patch provides cmake build infrastructure
+and pkg-config support.
+
+Signed-off-by: Yunhao Tian <t123yh.xyz@gmail.com>
+
+Index: libopenaptx/CMakeLists.txt
+===================================================================
+--- /dev/null
++++ libopenaptx/CMakeLists.txt
+@@ -0,0 +1,20 @@
++cmake_minimum_required(VERSION 3.10)
++
++project(openaptx VERSION 0.2.1 LANGUAGES C
++  DESCRIPTION "Open Source implementation of aptX codec")
++
++include(GNUInstallDirs)
++
++add_library(openaptx SHARED openaptx.c)
++
++set_target_properties(openaptx PROPERTIES PUBLIC_HEADER openaptx.h)
++
++# generate pc file for pkg-config
++set(target1 openaptx)
++configure_file(libopenaptx.pc.in libopenaptx.pc @ONLY)
++
++install(TARGETS openaptx
++    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
++    PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
++install(FILES ${CMAKE_BINARY_DIR}/libopenaptx.pc
++    DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
+Index: libopenaptx/libopenaptx.pc.in
+===================================================================
+--- /dev/null
++++ libopenaptx/libopenaptx.pc.in
+@@ -0,0 +1,10 @@
++prefix="@CMAKE_INSTALL_PREFIX@"
++exec_prefix="${prefix}"
++libdir="${prefix}/lib"
++includedir="${prefix}/include"
++
++Name: @PROJECT_NAME@
++Description: @CMAKE_PROJECT_DESCRIPTION@
++Version: @PROJECT_VERSION@
++Cflags: -I${includedir}
++Libs: -L${libdir} -l@target1@
diff --git a/package/libopenaptx/Config.in b/package/libopenaptx/Config.in
new file mode 100644
index 0000000000..1fdcbdd4a6
--- /dev/null
+++ b/package/libopenaptx/Config.in
@@ -0,0 +1,9 @@ 
+config BR2_PACKAGE_LIBOPENAPTX
+	bool "libopenaptx"
+	help
+          This is Open Source implementation of Audio Processing 
+          Technology codec (aptX) originally derived from ffmpeg 
+          4.0 project and licensed under GPLv3+. This codec is 
+          mainly used in Bluetooth A2DP profile.
+
+	  https://github.com/pali/libopenaptx
diff --git a/package/libopenaptx/libopenaptx.hash b/package/libopenaptx/libopenaptx.hash
new file mode 100644
index 0000000000..76b4e66c9b
--- /dev/null
+++ b/package/libopenaptx/libopenaptx.hash
@@ -0,0 +1,3 @@ 
+# Locally calculated:
+sha256 8ceb4b9ee5adedde47b31e975c1d90c73ad27b6b165a1dcd80c7c545eb65b903 COPYING
+sha256 a19b3b642def6f86441b73dd4efda6e6f13d49e7e2d6e5e91cc7eb464ebb505a libopenaptx-0.2.1.tar.gz
diff --git a/package/libopenaptx/libopenaptx.mk b/package/libopenaptx/libopenaptx.mk
new file mode 100644
index 0000000000..1b4bfa956c
--- /dev/null
+++ b/package/libopenaptx/libopenaptx.mk
@@ -0,0 +1,15 @@ 
+################################################################################
+#
+# libogg
+#
+################################################################################
+
+LIBOPENAPTX_VERSION = 0.2.1
+LIBOPENAPTX_SITE = $(call github,pali,libopenaptx,$(LIBOPENAPTX_VERSION))
+LIBOPENAPTX_LICENSE = GPL-3.0
+LIBOPENAPTX_LICENSE_FILES = COPYING
+
+LIBOPENAPTX_INSTALL_STAGING = YES
+
+$(eval $(cmake-package))
+