Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/development'
Browse files Browse the repository at this point in the history
  • Loading branch information
f1xpl committed Apr 1, 2018
2 parents fba7aaf + 2c8daca commit 26826ae
Show file tree
Hide file tree
Showing 50 changed files with 1,934 additions and 485 deletions.
23 changes: 21 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ find_package(libusb-1.0 REQUIRED)
find_package(Qt5 COMPONENTS Multimedia MultimediaWidgets Bluetooth)
find_package(Protobuf REQUIRED)
find_package(OpenSSL REQUIRED)
find_package(rtaudio REQUIRED)

if(WIN32)
set(WINSOCK2_LIBRARIES "ws2_32")
Expand All @@ -54,6 +55,7 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}
${LIBUSB_1_INCLUDE_DIRS}
${PROTOBUF_INCLUDE_DIR}
${OPENSSL_INCLUDE_DIR}
${RTAUDIO_INCLUDE_DIRS}
${AASDK_PROTO_INCLUDE_DIRS}
${AASDK_INCLUDE_DIRS}
${BCM_HOST_INCLUDE_DIRS}
Expand All @@ -62,10 +64,13 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}

link_directories(${CMAKE_LIBRARY_OUTPUT_DIRECTORY})

set(common_include_directory ${include_directory}/f1x/openauto/Common)

set(autoapp_sources_directory ${sources_directory}/autoapp)
file(GLOB_RECURSE source_files ${autoapp_sources_directory}/*.ui ${autoapp_sources_directory}/*.cpp ${include_directory}/*.hpp ${resources_directory}/*.qrc)
set(autoapp_include_directory ${include_directory}/f1x/openauto/autoapp)
file(GLOB_RECURSE autoapp_source_files ${autoapp_sources_directory}/*.ui ${autoapp_sources_directory}/*.cpp ${autoapp_include_directory}/*.hpp ${common_include_directory}/*.hpp ${resources_directory}/*.qrc)

add_executable(autoapp ${source_files})
add_executable(autoapp ${autoapp_source_files})

target_link_libraries(autoapp
${Boost_LIBRARIES}
Expand All @@ -77,5 +82,19 @@ target_link_libraries(autoapp
${BCM_HOST_LIBRARIES}
${ILCLIENT_LIBRARIES}
${WINSOCK2_LIBRARIES}
${RTAUDIO_LIBRARIES}
${AASDK_PROTO_LIBRARIES}
${AASDK_LIBRARIES})

set(btservice_sources_directory ${sources_directory}/btservice)
set(btservice_include_directory ${include_directory}/f1x/openauto/btservice)
file(GLOB_RECURSE btservice_source_files ${btservice_sources_directory}/*.cpp ${btservice_include_directory}/*.hpp ${common_include_directory}/*.hpp)

add_executable(btservice ${btservice_source_files})

target_link_libraries(btservice
${Boost_LIBRARIES}
${Qt5Bluetooth_LIBRARIES}
${Qt5MultimediaWidgets_LIBRARIES}
${PROTOBUF_LIBRARIES}
${AASDK_PROTO_LIBRARIES})
3 changes: 3 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ OpenAuto is an AndroidAuto(tm) headunit emulator based on aasdk library and Qt l
- Touchscreen and buttons input
- Bluetooth
- Automatic launch after device hotplug
- Automatic detection of connected Android devices
- Wireless (WiFi) mode via head unit server (must be enabled in hidden developer settings)
- User-friendly settings

### Supported platforms
Expand All @@ -42,6 +44,7 @@ Copyrights (c) 2018 f1x.studio (Michal Szwaj)
- [Boost libraries](http://www.boost.org/)
- [Qt libraries](https://www.qt.io/)
- [CMake](https://cmake.org/)
- [RtAudio](https://www.music.mcgill.ca/~gary/rtaudio/playback.html)
- Broadcom ilclient from RaspberryPI 3 firmware
- OpenMAX IL API

Expand Down
70 changes: 70 additions & 0 deletions cmake_modules/Findrtaudio.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#
# This file is part of openauto project.
# Copyright (C) 2018 f1x.studio (Michal Szwaj)
#
# openauto is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.

# openauto is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with openauto. If not, see <http://www.gnu.org/licenses/>.
#

if (RTAUDIO_LIBRARIES AND RTAUDIO_INCLUDE_DIRS)
# in cache already
set(RTAUDIO_FOUND TRUE)
else (RTAUDIO_LIBRARIES AND RTAUDIO_INCLUDE_DIRS)
find_path(RTAUDIO_INCLUDE_DIR
NAMES
RtAudio.h
PATHS
/usr/include
/usr/local/include
/opt/local/include
/sw/include
PATH_SUFFIXES
rtaudio
)

find_library(RTAUDIO_LIBRARY
NAMES
rtaudio
PATHS
/usr/lib
/usr/local/lib
/opt/local/lib
/sw/lib
)

set(RTAUDIO_INCLUDE_DIRS
${RTAUDIO_INCLUDE_DIR}
)
set(RTAUDIO_LIBRARIES
${RTAUDIO_LIBRARY}
)

if (RTAUDIO_INCLUDE_DIRS AND RTAUDIO_LIBRARIES)
set(RTAUDIO_FOUND TRUE)
endif (RTAUDIO_INCLUDE_DIRS AND RTAUDIO_LIBRARIES)

if (RTAUDIO_FOUND)
if (NOT rtaudio_FIND_QUIETLY)
message(STATUS "Found rtaudio:")
message(STATUS " - Includes: ${RTAUDIO_INCLUDE_DIRS}")
message(STATUS " - Libraries: ${RTAUDIO_LIBRARIES}")
endif (NOT rtaudio_FIND_QUIETLY)
else (RTAUDIO_FOUND)
if (rtaudio_FIND_REQUIRED)
message(FATAL_ERROR "Could not find rtaudio")
endif (rtaudio_FIND_REQUIRED)
endif (RTAUDIO_FOUND)

mark_as_advanced(RTAUDIO_INCLUDE_DIRS RTAUDIO_LIBRARIES)

endif (RTAUDIO_LIBRARIES AND RTAUDIO_INCLUDE_DIRS)
2 changes: 1 addition & 1 deletion include/f1x/openauto/Common/Log.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@

#include <boost/log/trivial.hpp>

#define OPENAUTO_LOG(severity) BOOST_LOG_TRIVIAL(severity) << "[AaApp] "
#define OPENAUTO_LOG(severity) BOOST_LOG_TRIVIAL(severity) << "[OpenAuto] "
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
#pragma once

#include <f1x/aasdk/USB/IUSBHub.hpp>
#include <f1x/aasdk/USB/IConnectedAccessoriesEnumerator.hpp>
#include <f1x/aasdk/USB/USBWrapper.hpp>
#include <f1x/aasdk/TCP/ITCPWrapper.hpp>
#include <f1x/aasdk/TCP/ITCPEndpoint.hpp>
#include <f1x/openauto/autoapp/Projection/IAndroidAutoEntityEventHandler.hpp>
#include <f1x/openauto/autoapp/Projection/IAndroidAutoEntityFactory.hpp>

Expand All @@ -28,36 +32,39 @@ namespace openauto
{
namespace autoapp
{
namespace usb
{

class USBApp: public projection::IAndroidAutoEntityEventHandler, public std::enable_shared_from_this<USBApp>
class App: public projection::IAndroidAutoEntityEventHandler, public std::enable_shared_from_this<App>
{
public:
typedef std::shared_ptr<USBApp> Pointer;
typedef std::shared_ptr<App> Pointer;

USBApp(boost::asio::io_service& ioService, projection::IAndroidAutoEntityFactory& androidAutoEntityFactory, aasdk::usb::IUSBHub::Pointer usbHub);
App(boost::asio::io_service& ioService, aasdk::usb::USBWrapper& usbWrapper, aasdk::tcp::ITCPWrapper& tcpWrapper, projection::IAndroidAutoEntityFactory& androidAutoEntityFactory,
aasdk::usb::IUSBHub::Pointer usbHub, aasdk::usb::IConnectedAccessoriesEnumerator::Pointer connectedAccessoriesEnumerator);

void start();
void waitForUSBDevice();
void start(aasdk::tcp::ITCPEndpoint::SocketPointer socket);
void stop();
void onAndroidAutoQuit() override;

private:
using std::enable_shared_from_this<USBApp>::shared_from_this;
using std::enable_shared_from_this<App>::shared_from_this;

void enumerateDevices();
void waitForDevice();
void aoapDeviceHandler(aasdk::usb::DeviceHandle deviceHandle);
void onUSBHubError(const aasdk::error::Error& error);

boost::asio::io_service& ioService_;
aasdk::usb::USBWrapper& usbWrapper_;
aasdk::tcp::ITCPWrapper& tcpWrapper_;
boost::asio::io_service::strand strand_;
projection::IAndroidAutoEntityFactory& androidAutoEntityFactory_;
aasdk::usb::IUSBHub::Pointer usbHub_;
aasdk::usb::IConnectedAccessoriesEnumerator::Pointer connectedAccessoriesEnumerator_;
projection::IAndroidAutoEntity::Pointer androidAutoEntity_;
bool isStopped_;
};

}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* This file is part of openauto project.
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
*
* openauto is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
* openauto is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace configuration
{

enum class AudioOutputBackendType
{
RTAUDIO,
QT
};

}
}
}
}
9 changes: 9 additions & 0 deletions include/f1x/openauto/autoapp/Configuration/Configuration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class Configuration: public IConfiguration
void setScreenDPI(size_t value) override;
void setOMXLayerIndex(int32_t value) override;
int32_t getOMXLayerIndex() const override;
void setVideoMargins(QRect value) override;
QRect getVideoMargins() const override;

bool getTouchscreenEnabled() const override;
void setTouchscreenEnabled(bool value) override;
Expand All @@ -67,6 +69,8 @@ class Configuration: public IConfiguration
void setMusicAudioChannelEnabled(bool value) override;
bool speechAudioChannelEnabled() const override;
void setSpeechAudioChannelEnabled(bool value) override;
AudioOutputBackendType getAudioOutputBackendType() const override;
void setAudioOutputBackendType(AudioOutputBackendType value) override;

private:
void readButtonCodes(boost::property_tree::ptree& iniConfig);
Expand All @@ -79,12 +83,14 @@ class Configuration: public IConfiguration
aasdk::proto::enums::VideoResolution::Enum videoResolution_;
size_t screenDPI_;
int32_t omxLayerIndex_;
QRect videoMargins_;
bool enableTouchscreen_;
ButtonCodes buttonCodes_;
BluetoothAdapterType bluetoothAdapterType_;
std::string bluetoothRemoteAdapterAddress_;
bool musicAudioChannelEnabled_;
bool speechAudiochannelEnabled_;
AudioOutputBackendType audioOutputBackendType_;

static const std::string cConfigFileName;

Expand All @@ -95,9 +101,12 @@ class Configuration: public IConfiguration
static const std::string cVideoResolutionKey;
static const std::string cVideoScreenDPIKey;
static const std::string cVideoOMXLayerIndexKey;
static const std::string cVideoMarginWidth;
static const std::string cVideoMarginHeight;

static const std::string cAudioMusicAudioChannelEnabled;
static const std::string cAudioSpeechAudioChannelEnabled;
static const std::string cAudioOutputBackendType;

static const std::string cBluetoothAdapterTypeKey;
static const std::string cBluetoothRemoteAdapterAddressKey;
Expand Down
6 changes: 6 additions & 0 deletions include/f1x/openauto/autoapp/Configuration/IConfiguration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
#pragma once

#include <string>
#include <QRect>
#include <aasdk_proto/VideoFPSEnum.pb.h>
#include <aasdk_proto/VideoResolutionEnum.pb.h>
#include <aasdk_proto/ButtonCodeEnum.pb.h>
#include <f1x/openauto/autoapp/Configuration/BluetootAdapterType.hpp>
#include <f1x/openauto/autoapp/Configuration/HandednessOfTrafficType.hpp>
#include <f1x/openauto/autoapp/Configuration/AudioOutputBackendType.hpp>

namespace f1x
{
Expand Down Expand Up @@ -59,6 +61,8 @@ class IConfiguration
virtual void setScreenDPI(size_t value) = 0;
virtual void setOMXLayerIndex(int32_t value) = 0;
virtual int32_t getOMXLayerIndex() const = 0;
virtual void setVideoMargins(QRect value) = 0;
virtual QRect getVideoMargins() const = 0;

virtual bool getTouchscreenEnabled() const = 0;
virtual void setTouchscreenEnabled(bool value) = 0;
Expand All @@ -74,6 +78,8 @@ class IConfiguration
virtual void setMusicAudioChannelEnabled(bool value) = 0;
virtual bool speechAudioChannelEnabled() const = 0;
virtual void setSpeechAudioChannelEnabled(bool value) = 0;
virtual AudioOutputBackendType getAudioOutputBackendType() const = 0;
virtual void setAudioOutputBackendType(AudioOutputBackendType value) = 0;
};

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,31 @@
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
*/

#include <f1x/openauto/autoapp/USB/USBMain.hpp>
#include <f1x/openauto/Common/Log.hpp>
#pragma once

namespace aasdk = f1x::aasdk;
namespace autoapp = f1x::openauto::autoapp;
#include <deque>
#include <string>

int main(int argc, char* argv[])
namespace f1x
{
libusb_context* context;
if(libusb_init(&context) != 0)
{
OPENAUTO_LOG(error) << "[OpenAuto] libusb init failed.";
return 1;
}
namespace openauto
{
namespace autoapp
{
namespace configuration
{

class IRecentAddressesList
{
public:
typedef std::deque<std::string> RecentAddresses;

autoapp::usb::USBMain main(context);
auto result = main.exec(argc, argv);
virtual void read() = 0;
virtual void insertAddress(const std::string& address) = 0;
virtual RecentAddresses getList() const = 0;
};

libusb_exit(context);
return result;
}
}
}
}
Loading

0 comments on commit 26826ae

Please sign in to comment.