Skip to content

Commit

Permalink
Prepare for 1.0.0 Release
Browse files Browse the repository at this point in the history
  • Loading branch information
mawebmw authored and mincequi committed Dec 12, 2024
1 parent ec02873 commit 0f27607
Show file tree
Hide file tree
Showing 47 changed files with 52 additions and 2,352 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "thirdparty/libcornrow"]
path = thirdparty/libcornrow
url = https://github.com/mincequi/libcornrow
41 changes: 11 additions & 30 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.7)

project(cornrow)

include(ExternalProject)
include(cmake/CPM.cmake)

set(CMAKE_AUTOMOC ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
Expand All @@ -12,41 +12,22 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-Wno-deprecated-declarations \
-Wno-zero-as-null-pointer-constant")
set(CMAKE_CXX_STANDARD 17)
# -Werror \

find_package(Qt5 REQUIRED COMPONENTS Core Network)

# Add thirdparty libs
add_subdirectory(thirdparty/libcornrow)
#add_subdirectory(thirdparty/qtzeroprops)

# Add internal libs
add_subdirectory(common)
add_subdirectory(cornrowd)
#add_subdirectory(net)
#add_subdirectory(bluebricated)

# Mandatory debian variables
SET(CPACK_GENERATOR "DEB")
SET(CPACK_PACKAGE_CONTACT "mincequi@web.de")
SET(CPACK_PACKAGE_VERSION "0.9.0")
install(TARGETS cornrowd DESTINATION bin)
install(FILES ${PROJECT_SOURCE_DIR}/debian/cornrowd.service DESTINATION /usr/lib/systemd/system)

set(CPACK_GENERATOR "DEB")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Manuel Weichselbaumer <mincequi@web.de>") #required
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
set(CPACK_DEBIAN_PACKAGE_DEPENDS adduser)
SET(CPACK_PACKAGE_DESCRIPTION "Bluetooth audio player")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "This daemon accepts and plays audio from any Bluetooth source and turns your linux PC into a Bluetooth speaker.")
#CPACK_SYSTEM_NAME -> CMAKE_SYSTEM_NAME
##CPACK_DEBIAN_PACKAGE_NAME -> CPACK_PACKAGE_NAME -> project name
#CPACK_DEBIAN_FILE_NAME -> CPACK_PACKAGE_FILE_NAME -> ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}
#CPACK_DEBIAN_PACKAGE_VERSION -> CPACK_PACKAGE_VERSION
#CPACK_DEBIAN_PACKAGE_RELEASE
#CPACK_DEBIAN_PACKAGE_ARCHITECTURE
#CPACK_DEBIAN_PACKAGE_MAINTAINER -> CPACK_PACKAGE_CONTACT
#CPACK_DEBIAN_PACKAGE_DESCRIPTION -> CPACK_PACKAGE_DESCRIPTION_SUMMARY
#CPACK_DEBIAN_COMPRESSION_TYPE
#CPACK_DEBIAN_PACKAGE_PRIORITY

# DEBIAN OPTIONS
#SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Manuel Weichselbaumer <mincequi@web.de>")
#SET(CPACK_DEBIAN_PACKAGE_SECTION "Sound")
#SET(CPACK_DEBIAN_PACKAGE_DEPENDS "${OSG_PACKAGE_DEPENDS}")
#SET(CPACK_DEBIAN_PACKAGE_CONFLICTS "${OSG_PACKAGE_CONFLICTS}")
#SET(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${OpenSceneGraph_SOURCE_DIR}/debian/postinst;")
#SET(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${OpenSceneGraph_SOURCE_DIR}/debian/conffiles;")
SET(CPACK_PACKAGE_VERSION "1.0.0")
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${PROJECT_SOURCE_DIR}/debian/postinst;${PROJECT_SOURCE_DIR}/debian/postrm;${PROJECT_SOURCE_DIR}/debian/install")
include(CPack)
24 changes: 14 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@
Cornrow is an audio sink daemon for Bluetooth and Airplay streams. It is designed for low-powered boards like the Raspberry Pi, but can also be used for SBCs/VMs with a Bluetooth dongle instead of a built-in module (first Bluetooth adapter found will be used).

It is made for Debian based environments and compatible with Ubuntu and Debian. This means that this service runs as a dedicated user and can be cleanly installed and removed using Debian package management.
**Note:** for Debian Buster and Ubuntu Bionic (18.04) please use cornrow **v0.8.0**.
For Debian Bullseye and Ubuntu Focal (20.04) and later, please use cornrow **v0.8.1**.
**Note:**
For Debian Bullseye and Ubuntu 20.04 (Focal) and later, please use cornrow **v0.8.1**.
For Debian Bookworm and later, please use cornrow **v0.9.0**.
For Debian Trixie and Ubuntu 24.10 (Oracular) and later, please use cornrow **v1.0.0**.

## Installation (binary)
Compiled debian/ubuntu packages are available for [armhf](https://github.com/mincequi/cornrow/releases/download/v0.8.1/cornrowd_0.8.1_armhf.deb) and [amd64](https://github.com/mincequi/cornrow/releases/download/v0.6.0/cornrowd_0.6.0_amd64.deb).
Compiled debian/ubuntu packages are available for [armhf](https://github.com/mincequi/cornrow/releases/download/v1.0.0/cornrow_1.0.0_armhf.deb).

```
wget https://github.com/mincequi/cornrow/releases/download/v0.9.0/cornrowd_0.9.0_arm64.deb
wget https://github.com/mincequi/cornrow/releases/download/v1.0.0/cornrow_1.0.0_armhf.deb
sudo apt update
sudo apt install ./cornrowd_0.9.0_arm64.deb
sudo apt install ./cornrow_1.0.0_armhf.deb
sudo systemctl unmask cornrowd.service # unmask service
sudo systemctl start cornrowd.service # start-up service. You should now be able to connect any bluetooth audio device.
sudo systemctl enable cornrowd.service # start-up service on each reboot.
Expand All @@ -40,12 +41,15 @@ sudo apt install \
libssl-dev \
qtconnectivity5-dev \
libqt5websockets5-dev
wget https://github.com/mincequi/cornrow/archive/refs/tags/v0.9.0.tar.gz
tar xf cornrowd-0.9.0.tar.xz
wget https://github.com/mincequi/cornrow/archive/refs/tags/v1.0.0.tar.gz
tar xf cornrowd-1.0.0.tar.xz
cd cornrow
dpkg-buildpackage -us -uc -nc # build unsigned debian package
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
cpack # build debian package
cd ..
sudo apt install ./cornrowd_0.9.0_<your_arch>.deb # install package
sudo apt install ./cornrow_1.0.0_<your_arch>.deb # install package
sudo systemctl unmask cornrowd.service # unmask service
sudo systemctl start cornrowd.service # start-up service. You should now be able to connect any bluetooth audio device.
sudo systemctl enable cornrowd.service # start-up service on each reboot.
Expand All @@ -54,7 +58,7 @@ sudo systemctl enable cornrowd.service # start-up service on each r
### Arbitrary distro
Get the dependencies. Basically, these are ffmpeg (libav*), qt5bluetooth, qt5websockets
```
git clone --recursive https://github.com/mincequi/cornrow
git clone https://github.com/mincequi/cornrow
cd cornrow
mkdir build
cd build
Expand Down
24 changes: 24 additions & 0 deletions cmake/CPM.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# SPDX-License-Identifier: MIT
#
# SPDX-FileCopyrightText: Copyright (c) 2019-2023 Lars Melchior and contributors

set(CPM_DOWNLOAD_VERSION 0.40.2)
set(CPM_HASH_SUM "c8cdc32c03816538ce22781ed72964dc864b2a34a310d3b7104812a5ca2d835d")

if(CPM_SOURCE_CACHE)
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
else()
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
endif()

# Expand relative path. This is important if the provided path contains a tilde (~)
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)

file(DOWNLOAD
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
${CPM_DOWNLOAD_LOCATION} EXPECTED_HASH SHA256=${CPM_HASH_SUM}
)

include(${CPM_DOWNLOAD_LOCATION})
6 changes: 1 addition & 5 deletions common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,10 @@ add_library(common STATIC

target_include_directories(common
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
PRIVATE
include/common
include/common/ble
)

# @TODO(mawe): remove qt dependency
target_link_libraries(common
Qt5::Core
)
8 changes: 0 additions & 8 deletions common/include/common/ble/Converter.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
#include <common/Types.h>
#include <common/ble/Types.h>

class QByteArray;

namespace common
{
namespace ble
Expand All @@ -16,12 +14,6 @@ class Converter
Converter();
virtual ~Converter();

virtual QByteArray toBle(const std::vector<common::IoInterface>& interfaces) const;
virtual std::vector<common::IoInterface> fromBle(const QByteArray& bytes) const;

virtual QByteArray filtersToBle(const std::vector<common::Filter>& filters) const;
virtual std::vector<common::Filter> filtersFromBle(const QByteArray& array) const;

protected:
virtual uint8_t fToBle(float f) const;
virtual float fFromBle(uint8_t i) const;
Expand Down
59 changes: 0 additions & 59 deletions common/src/ble/Converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

#include <math.h>

#include <QByteArray>

namespace common
{
namespace ble
Expand All @@ -17,63 +15,6 @@ Converter::~Converter()
{
}

QByteArray Converter::toBle(const std::vector<common::IoInterface>& interfaces) const
{
QByteArray value;
value.reserve(interfaces.size());

for (const auto& interface : interfaces) {
value.append(*reinterpret_cast<const char*>(&interface));
}

return value;
}

std::vector<common::IoInterface> Converter::fromBle(const QByteArray& bytes) const
{
std::vector<common::IoInterface> interfaces;
interfaces.reserve(bytes.size());

for (const auto& c : bytes) {
auto interface = *reinterpret_cast<const common::IoInterface*>(&c);
interfaces.push_back(interface);
}

return interfaces;
}

QByteArray Converter::filtersToBle(const std::vector<common::Filter>& filters) const
{
QByteArray value;
value.reserve(filters.size()*4);

for (const auto& filter : filters) {
value.append(static_cast<char>(filter.type));
value.append(fToBle(filter.f));
value.append(gToBle(filter.g));
value.append(qToBle(filter.q));
}

return value;
}

std::vector<common::Filter> Converter::filtersFromBle(const QByteArray& array) const
{
if (array.size()%4 != 0) {
return {};
}

std::vector<common::Filter> filters;
filters.reserve(array.size()/4);
for (int i = 0; i < array.size(); i+=4) {
filters.push_back( { static_cast<common::FilterType>(array.at(i)),
fFromBle(array.at(i+1)),
gFromBle(array.at(i+2)),
qFromBle(array.at(i+3)) } );
}
return filters;
}

uint8_t Converter::fToBle(float f) const
{
uint8_t i = 0;
Expand Down
1 change: 0 additions & 1 deletion cornrowd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ target_link_libraries(${PROJECT_NAME}
audio
bluetooth
config
#qtzeroprops
)

install(TARGETS ${PROJECT_NAME}
Expand Down
2 changes: 2 additions & 0 deletions cornrowd/src/audio/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
CPMAddPackage(gh:mincequi/libcornrow@0.1.1)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DLOGURU_WITH_STREAMS")

add_library(audio STATIC
Expand Down
77 changes: 0 additions & 77 deletions cornrowd/src/bluetooth/Controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ Controller::Controller(QObject *parent)
adapter->setDiscoverable(true);
adapter->setPairable(true);
}

initBle();
}

Controller::~Controller()
Expand All @@ -121,37 +119,6 @@ void Controller::setReadIoConfCallback(ReadIoConfCallback callback)
m_readIoConfCallback = callback;
}

void Controller::initBle()
{
if (!m_manager->usableAdapter() || !m_manager->usableAdapter()->leAdvertisingManager()) {
LOG_F(WARNING, "No BLE adapter present");
return;
}

m_advertisement = new LEAdvertisement({QStringLiteral("ad100000-d901-11e8-9f8b-f2801f1b9fd1")}, this);
m_manager->usableAdapter()->leAdvertisingManager()->registerAdvertisement(m_advertisement);

m_application = new GattApplication(this);
auto service = new GattService(QStringLiteral("ad100000-d901-11e8-9f8b-f2801f1b9fd1"), true, m_application);

auto peqCharc = new GattCharacteristic(QStringLiteral("ad10e100-d901-11e8-9f8b-f2801f1b9fd1"), service);
peqCharc->setReadCallback(std::bind(&Controller::onReadPeqFilters, this));
connect(peqCharc, &GattCharacteristic::valueWritten, std::bind(&Controller::onWriteFilters, this, common::ble::CharacteristicType::Peq, _1));

auto auxCharc = new GattCharacteristic(QStringLiteral("ad10a100-d901-11e8-9f8b-f2801f1b9fd1"), service);
auxCharc->setReadCallback(std::bind(&Controller::onReadAuxFilters, this));
connect(auxCharc, &GattCharacteristic::valueWritten, std::bind(&Controller::onWriteFilters, this, common::ble::CharacteristicType::Aux, _1));

auto ioCapsCharc = new GattCharacteristic(QString::fromStdString(common::ble::ioCapsCharacteristicUuid), service);
ioCapsCharc->setReadCallback(std::bind(&Controller::onReadIoCaps, this));

auto ioConfCharc = new GattCharacteristic(QString::fromStdString(common::ble::ioConfCharacteristicUuid), service);
ioConfCharc->setReadCallback(std::bind(&Controller::onReadIoConf, this));
connect(ioConfCharc, &GattCharacteristic::valueWritten, this, &Controller::onWriteIoConf);

m_manager->usableAdapter()->gattManager()->registerApplication(m_application);
}

void Controller::onTransportChanged(MediaTransportPtr transport)
{
if (m_transport == transport) {
Expand Down Expand Up @@ -215,48 +182,4 @@ void Controller::onTransportVolumeChanged(uint16_t volume)
emit volumeChanged(pow(10.0f, (volume-127)/(factor*20.0f)));
}

QByteArray Controller::onReadPeqFilters()
{
return m_converter.filtersToBle(m_readFiltersCallback(common::ble::CharacteristicType::Peq));
}

QByteArray Controller::onReadAuxFilters()
{
return m_converter.filtersToBle(m_readFiltersCallback(common::ble::CharacteristicType::Aux));
}

QByteArray Controller::onReadIoCaps()
{
return m_converter.toBle(m_readIoCapsCallback());
}

QByteArray Controller::onReadIoConf()
{
return m_converter.toBle(m_readIoConfCallback());
}

void Controller::onWriteFilters(common::ble::CharacteristicType group, const QByteArray& value)
{
emit filtersWritten(group, m_converter.filtersFromBle(value));
}

void Controller::onWriteIoConf(const QByteArray& value)
{
auto interfaces = m_converter.fromBle(value);

common::IoInterface input;
common::IoInterface output;

for (const auto& interface : interfaces) {
if (interface.isOutput) {
output = interface;
} else {
input = interface;
}
}

emit inputSet(input);
emit outputSet(output);
}

} // namespace bluetooth
6 changes: 0 additions & 6 deletions cornrowd/src/bluetooth/Controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,9 @@ class Controller : public QObject
void outputSet(common::IoInterface output);

private:
void initBle();

void onTransportChanged(BluezQt::MediaTransportPtr transport);
void onTransportStateChanged(BluezQt::MediaTransport::State state);
void onTransportVolumeChanged(uint16_t volume);
QByteArray onReadPeqFilters();
QByteArray onReadAuxFilters();
QByteArray onReadIoCaps();
QByteArray onReadIoConf();
void onWriteFilters(common::ble::CharacteristicType group, const QByteArray& value);
void onWriteIoConf(const QByteArray& value);

Expand Down
2 changes: 0 additions & 2 deletions debian/cornrowd-rpi.install

This file was deleted.

1 change: 0 additions & 1 deletion debian/cornrowd-rpi.postinst

This file was deleted.

1 change: 0 additions & 1 deletion debian/cornrowd-rpi.postrm

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 0f27607

Please sign in to comment.