Compare commits
80 Commits
crankshaft
...
develop
Author | SHA1 | Date | |
---|---|---|---|
cab79ecd5f | |||
94f5f5a382 | |||
4e265958eb | |||
e30db459c6 | |||
b563281f78 | |||
58f7c65875 | |||
381dcfa102 | |||
31ccf2a5c7 | |||
6879a69ca1 | |||
ccbef3b3e8 | |||
d8d6568963 | |||
4ab5a162c4 | |||
|
e7caeb4d49 | ||
|
6496f8e360 | ||
|
8fa72b4f43 | ||
|
e2b6985d87 | ||
|
cf77993f3c | ||
|
618a014100 | ||
|
efb9d8bc6f | ||
|
658005da61 | ||
|
e940b8036e | ||
|
94ee66acd7 | ||
|
5554052d84 | ||
|
3d96b6e6e3 | ||
|
88833fb5db | ||
|
23c38158ee | ||
|
ae66394b6b | ||
|
50e077aa6e | ||
|
88f71b813a | ||
|
310b346b3c | ||
|
c3f9c29ce7 | ||
|
35140352a6 | ||
|
bb0881e827 | ||
|
323c231d36 | ||
|
f49b04b4e0 | ||
|
6cc5a32016 | ||
|
aef4b99cdf | ||
|
234ba0b22a | ||
|
e541a042f1 | ||
|
f18bce9e12 | ||
|
97be374a75 | ||
|
8bbef14efa | ||
|
c1898e2dfc | ||
|
7b52391020 | ||
|
1357f96d4e | ||
|
a2b54630b0 | ||
|
5867a24f7f | ||
|
c806b15b61 | ||
|
2f42c809c5 | ||
|
ef47eecefa | ||
|
5b0543ac10 | ||
|
7472369979 | ||
|
7506df26ee | ||
|
1bd667da51 | ||
|
16cec35bdd | ||
|
df63241827 | ||
|
e350341bfd | ||
|
1100f7155c | ||
|
fe4e5522ed | ||
|
38b95057e9 | ||
|
254382acf6 | ||
|
6cda29433a | ||
|
464da85686 | ||
|
5f8d5f4f6a | ||
|
5df4b957a1 | ||
|
ae5a21a75e | ||
|
7513d99929 | ||
|
6dc394c11f | ||
|
70bc8a2f03 | ||
|
0cfcab6d51 | ||
|
f3c6bf2d55 | ||
|
eea5b1ea80 | ||
|
c3d5ea8674 | ||
|
7b2210268f | ||
|
5c607f74e5 | ||
|
77b5cc02fc | ||
|
0f71738344 | ||
|
ced8e22031 | ||
|
400302901a | ||
|
3df9958f6f |
21
.gitignore
vendored
@ -1,4 +1,23 @@
|
|||||||
# Add any directories, files, or patterns you don't want to be tracked by version control
|
# Add any directories, files, or patterns you don't want to be tracked by version control
|
||||||
|
.vscode/
|
||||||
|
|
||||||
lib/
|
lib/
|
||||||
bin/
|
bin/
|
||||||
CMakeLists.txt.user
|
.idea/
|
||||||
|
build/
|
||||||
|
|
||||||
|
CMakeLists.txt.user
|
||||||
|
cmake-build-*/
|
||||||
|
CMakeCache.txt
|
||||||
|
CMakeFiles
|
||||||
|
CMakeScripts
|
||||||
|
Testing
|
||||||
|
Makefile
|
||||||
|
cmake_install.cmake
|
||||||
|
install_manifest.txt
|
||||||
|
compile_commands.json
|
||||||
|
CTestTestfile.cmake
|
||||||
|
_deps
|
||||||
|
*_autogen/
|
||||||
|
*.pb.cc
|
||||||
|
*.pb.h
|
||||||
|
180
CMakeLists.txt
@ -1,100 +1,128 @@
|
|||||||
cmake_minimum_required(VERSION 3.5.1)
|
cmake_minimum_required(VERSION 3.5.1)
|
||||||
project(openauto CXX)
|
|
||||||
|
set (openauto_VERSION_MAJOR 2)
|
||||||
|
set (openauto_VERSION_MINOR 1)
|
||||||
|
set (openauto_VERSION_PATCH 0)
|
||||||
|
|
||||||
|
project(openauto
|
||||||
|
VERSION ${openauto_VERSION_MAJOR}.${openauto_VERSION_MINOR}.${openauto_VERSION_PATCH}
|
||||||
|
LANGUAGES CXX)
|
||||||
|
|
||||||
|
find_program(CCACHE_PROGRAM ccache)
|
||||||
|
if(CCACHE_PROGRAM)
|
||||||
|
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
|
||||||
|
endif()
|
||||||
|
|
||||||
set(CMAKE_AUTOMOC ON)
|
set(CMAKE_AUTOMOC ON)
|
||||||
set(CMAKE_AUTOUIC ON)
|
set(CMAKE_AUTOUIC ON)
|
||||||
set(CMAKE_AUTORCC ON)
|
set(CMAKE_AUTORCC ON)
|
||||||
set(base_directory ${CMAKE_CURRENT_SOURCE_DIR})
|
|
||||||
set(resources_directory ${base_directory}/assets)
|
|
||||||
set(sources_directory ${base_directory}/src)
|
|
||||||
set(include_directory ${base_directory}/include)
|
|
||||||
|
|
||||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${base_directory}/lib)
|
set(base_directory ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${base_directory}/lib)
|
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib)
|
||||||
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib)
|
||||||
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib)
|
||||||
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin)
|
||||||
|
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/bin)
|
||||||
|
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${base_directory}/bin)
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake_modules/")
|
||||||
set(EXECUTABLE_OUTPUT_PATH ${base_directory}/bin)
|
SET(CMAKE_CXX_STANDARD 14)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_INIT} -Wall -pedantic")
|
||||||
|
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
||||||
|
set(CMAKE_CXX_FLAGS_RELEASE "-g -O3")
|
||||||
|
|
||||||
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-psabi")
|
||||||
|
endif()
|
||||||
|
|
||||||
set(Boost_USE_STATIC_LIBS OFF)
|
set(Boost_USE_STATIC_LIBS OFF)
|
||||||
set(Boost_USE_MULTITHREADED ON)
|
set(Boost_USE_MULTITHREADED ON)
|
||||||
set(Boost_USE_STATIC_RUNTIME OFF)
|
set(Boost_USE_STATIC_RUNTIME OFF)
|
||||||
|
|
||||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake_modules/")
|
|
||||||
SET(CMAKE_CXX_STANDARD 14)
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_INIT} -Wall -pedantic -fPIC")
|
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "-g -O3")
|
|
||||||
|
|
||||||
add_definitions(-DBOOST_ALL_DYN_LINK)
|
add_definitions(-DBOOST_ALL_DYN_LINK)
|
||||||
|
|
||||||
find_package(Boost REQUIRED COMPONENTS system log OPTIONAL_COMPONENTS unit_test_framework)
|
find_package(Boost REQUIRED COMPONENTS system log OPTIONAL_COMPONENTS unit_test_framework)
|
||||||
|
|
||||||
find_package(libusb-1.0 REQUIRED)
|
find_package(libusb-1.0 REQUIRED)
|
||||||
find_package(Qt5 COMPONENTS Multimedia MultimediaWidgets Bluetooth)
|
find_package(Qt5 COMPONENTS Multimedia MultimediaWidgets Bluetooth Qml Quick QuickWidgets WebSockets REQUIRED)
|
||||||
find_package(Protobuf REQUIRED)
|
find_package(Protobuf REQUIRED)
|
||||||
find_package(OpenSSL REQUIRED)
|
find_package(OpenSSL REQUIRED)
|
||||||
find_package(rtaudio REQUIRED)
|
find_package(rtaudio REQUIRED)
|
||||||
|
find_package(aasdk REQUIRED)
|
||||||
|
find_package(h264 REQUIRED)
|
||||||
|
find_package(Threads)
|
||||||
|
|
||||||
if(WIN32)
|
include(${base_directory}/cmake_modules/gitversion.cmake)
|
||||||
set(WINSOCK2_LIBRARIES "ws2_32")
|
if(RPI_BUILD)
|
||||||
endif(WIN32)
|
find_package(libomx)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(RPI3_BUILD)
|
if(GST_BUILD)
|
||||||
add_definitions(-DUSE_OMX -DOMX_SKIP64BIT -DRASPBERRYPI3)
|
find_package(GObject)
|
||||||
set(BCM_HOST_LIBRARIES "/opt/vc/lib/libbcm_host.so")
|
find_package(Qt5GStreamer)
|
||||||
set(BCM_HOST_INCLUDE_DIRS "/opt/vc/include")
|
find_package(PkgConfig REQUIRED)
|
||||||
set(ILCLIENT_INCLUDE_DIRS "/opt/vc/src/hello_pi/libs/ilclient")
|
pkg_check_modules(GST REQUIRED
|
||||||
set(ILCLIENT_LIBRARIES "/opt/vc/src/hello_pi/libs/ilclient/libilclient.a;/opt/vc/lib/libvcos.so;/opt/vc/lib/libvcilcs.a;/opt/vc/lib/libvchiq_arm.so")
|
gstreamer-1.0>=1.4
|
||||||
endif(RPI3_BUILD)
|
gstreamer-sdp-1.0>=1.4
|
||||||
|
gstreamer-video-1.0>=1.4
|
||||||
|
gstreamer-app-1.0>=1.4)
|
||||||
|
add_definitions(-DUSE_GST)
|
||||||
|
if(RPI_BUILD)
|
||||||
|
add_definitions(-DRPI)
|
||||||
|
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/functions.cmake)
|
||||||
|
findRpiRevision( RPI_REVISION )
|
||||||
|
math(EXPR RPI_MODEL "(0x${RPI_REVISION}>>4)&0xFF")
|
||||||
|
message( "-- Raspberry Pi Model: ${RPI_MODEL}" )
|
||||||
|
if(RPI_MODEL EQUAL 17)
|
||||||
|
message("Raspberry Pi 4 Found")
|
||||||
|
add_definitions(-DPI4)
|
||||||
|
endif(RPI_MODEL EQUAL 17)
|
||||||
|
endif(RPI_BUILD)
|
||||||
|
message(STATUS "${GST_LIBRARIES}")
|
||||||
|
endif(GST_BUILD)
|
||||||
|
|
||||||
include_directories(${CMAKE_CURRENT_BINARY_DIR}
|
add_subdirectory(btservice_proto)
|
||||||
${Qt5Multimedia_INCLUDE_DIRS}
|
set(BTSERVICE_PROTO_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
${Qt5MultimediaWidgets_INCLUDE_DIRS}
|
include_directories(${BTSERVICE_PROTO_INCLUDE_DIRS})
|
||||||
${Qt5Widgets_INCLUDE_DIRS}
|
|
||||||
${Qt5Bluetooth_INCLUDE_DIRS}
|
|
||||||
${Boost_INCLUDE_DIRS}
|
|
||||||
${LIBUSB_1_INCLUDE_DIRS}
|
|
||||||
${PROTOBUF_INCLUDE_DIR}
|
|
||||||
${OPENSSL_INCLUDE_DIR}
|
|
||||||
${RTAUDIO_INCLUDE_DIRS}
|
|
||||||
${AASDK_PROTO_INCLUDE_DIRS}
|
|
||||||
${AASDK_INCLUDE_DIRS}
|
|
||||||
${BCM_HOST_INCLUDE_DIRS}
|
|
||||||
${ILCLIENT_INCLUDE_DIRS}
|
|
||||||
${include_directory})
|
|
||||||
|
|
||||||
link_directories(${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
|
|
||||||
|
|
||||||
set(common_include_directory ${include_directory}/f1x/openauto/Common)
|
add_subdirectory(openauto)
|
||||||
|
add_subdirectory(autoapp)
|
||||||
|
add_dependencies(autoapp btservice_proto)
|
||||||
|
|
||||||
set(autoapp_sources_directory ${sources_directory}/autoapp)
|
set (openauto_VERSION_PATCH ${_build_version})
|
||||||
set(autoapp_include_directory ${include_directory}/f1x/openauto/autoapp)
|
set (openauto_VERSION_STRING ${openauto_VERSION_MAJOR}.${openauto_VERSION_MINOR}.${openauto_VERSION_PATCH})
|
||||||
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)
|
set_target_properties(openauto PROPERTIES VERSION ${openauto_VERSION_STRING}
|
||||||
|
SOVERSION ${openauto_VERSION_MAJOR})
|
||||||
|
message(INFO " Project Version: ${openauto_VERSION_STRING}")
|
||||||
|
|
||||||
add_executable(autoapp ${autoapp_source_files})
|
install(DIRECTORY lib DESTINATION lib COMPONENT libraries)
|
||||||
|
install(DIRECTORY include DESTINATION include COMPONENT headers)
|
||||||
|
install(DIRECTORY bin DESTINATION bin COMPONENT applications)
|
||||||
|
|
||||||
target_link_libraries(autoapp
|
SET(CPACK_GENERATOR "DEB")
|
||||||
${Boost_LIBRARIES}
|
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "OpenDsh") #required
|
||||||
${Qt5Multimedia_LIBRARIES}
|
SET(CPACK_PACKAGE_VENDOR "OpenDsh")
|
||||||
${Qt5MultimediaWidgets_LIBRARIES}
|
set(CPACK_PACKAGE_VERSION ${openauto_VERSION_STRING})
|
||||||
${Qt5Bluetooth_LIBRARIES}
|
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
|
||||||
${LIBUSB_1_LIBRARIES}
|
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
|
||||||
${PROTOBUF_LIBRARIES}
|
set(CPACK_COMPONENTS_ALL applications libraries headers Unspecified)
|
||||||
${BCM_HOST_LIBRARIES}
|
set(CPACK_COMPONENT_APPLICATIONS_DISPLAY_NAME "Applications")
|
||||||
${ILCLIENT_LIBRARIES}
|
set(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "Libraries")
|
||||||
${WINSOCK2_LIBRARIES}
|
set(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C++ Headers")
|
||||||
${RTAUDIO_LIBRARIES}
|
set(CPACK_COMPONENT_APPLICATIONS_DESCRIPTION
|
||||||
${AASDK_PROTO_LIBRARIES}
|
"Applications provided by OpenAuto")
|
||||||
${AASDK_LIBRARIES})
|
set(CPACK_COMPONENT_LIBRARIES_DESCRIPTION
|
||||||
|
"Static libraries used to build programs with OpenAuto")
|
||||||
set(btservice_sources_directory ${sources_directory}/btservice)
|
set(CPACK_COMPONENT_HEADERS_DESCRIPTION
|
||||||
set(btservice_include_directory ${include_directory}/f1x/openauto/btservice)
|
"C/C++ header files for use with OpenAuto")
|
||||||
file(GLOB_RECURSE btservice_source_files ${btservice_sources_directory}/*.cpp ${btservice_include_directory}/*.hpp ${common_include_directory}/*.hpp)
|
set(CPACK_COMPONENT_LIBRARIES_GROUP "Development")
|
||||||
|
set(CPACK_COMPONENT_HEADERS_GROUP "Development")
|
||||||
add_executable(btservice ${btservice_source_files})
|
set(CPACK_COMPONENT_GROUP_DEVELOPMENT_EXPANDED ON)
|
||||||
|
set(CPACK_COMPONENT_GROUP_DEVELOPMENT_DESCRIPTION
|
||||||
target_link_libraries(btservice
|
"All of the tools you'll ever need to develop software")
|
||||||
${Boost_LIBRARIES}
|
set(CPACK_COMPONENT_HEADERS_DEPENDS libraries)
|
||||||
${Qt5Bluetooth_LIBRARIES}
|
set(CPACK_COMPONENT_APPLICATIONS_DEPENDS libraries)
|
||||||
${Qt5MultimediaWidgets_LIBRARIES}
|
set(CPACK_ALL_INSTALL_TYPES Full Developer)
|
||||||
${PROTOBUF_LIBRARIES}
|
set(CPACK_INSTALL_TYPE_FULL_DISPLAY_NAME "Everything")
|
||||||
${AASDK_PROTO_LIBRARIES})
|
set(CPACK_COMPONENT_LIBRARIES_INSTALL_TYPES Developer Full)
|
||||||
|
set(CPACK_COMPONENT_HEADERS_INSTALL_TYPES Developer Full)
|
||||||
|
set(CPACK_COMPONENT_APPLICATIONS_INSTALL_TYPES Full)
|
||||||
|
INCLUDE(CPack)
|
||||||
|
29
Readme.md
@ -1,11 +1,6 @@
|
|||||||
|
|
||||||
# OpenAuto
|
# OpenAuto
|
||||||
|
|
||||||
### Support project
|
|
||||||
[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=R4HXE5ESDR4U4)
|
|
||||||
|
|
||||||
For support of other platforms please contact me at f1xstudiopl@gmail.com
|
|
||||||
|
|
||||||
### Community
|
### Community
|
||||||
[](https://gitter.im/openauto_androidauto/Lobby)
|
[](https://gitter.im/openauto_androidauto/Lobby)
|
||||||
|
|
||||||
@ -14,6 +9,28 @@ OpenAuto is an AndroidAuto(tm) headunit emulator based on aasdk library and Qt l
|
|||||||
|
|
||||||
[See demo video](https://www.youtube.com/watch?v=k9tKRqIkQs8)
|
[See demo video](https://www.youtube.com/watch?v=k9tKRqIkQs8)
|
||||||
|
|
||||||
|
### Build Guide
|
||||||
|
#### Local build instructions for Raspberry Pi
|
||||||
|
|
||||||
|
Having <a href="https://github.com/openDsh/aasdk">aasdk</a> built and install first is a prequisite for this task. Please complete the necessary aasdk steps before proceeding here.
|
||||||
|
|
||||||
|
```sudo apt-get update
|
||||||
|
sudo apt-get -y install cmake build-essential git
|
||||||
|
|
||||||
|
sudo apt-get install libboost-all-dev libusb-1.0.0-dev libssl-dev cmake libprotobuf-dev protobuf-c-compiler protobuf-compiler libqt5multimedia5 libqt5multimedia5-plugins libqt5multimediawidgets5 qtmultimedia5-dev libqt5bluetooth5 libqt5bluetooth5-bin qtconnectivity5-dev pulseaudio librtaudio-dev
|
||||||
|
|
||||||
|
git clone https://github.com/OpenDsh/openauto
|
||||||
|
|
||||||
|
mkdir openauto_build; cd openauto_build
|
||||||
|
|
||||||
|
cmake -DCMAKE_BUILD_TYPE=Release -DRPI3_BUILD=TRUE -DAASDK_INCLUDE_DIRS="../aasdk/include" -DAASDK_LIBRARIES="../aasdk/lib/libaasdk.so" -DAASDK_PROTO_INCLUDE_DIRS="../aasdk" -DAASDK_PROTO_LIBRARIES="../aasdk/lib/libaasdk_proto.so" ../openauto
|
||||||
|
|
||||||
|
make -j2
|
||||||
|
sudo make install
|
||||||
|
```
|
||||||
|
|
||||||
|
The executable binary can then be found at ~/openauto/bin/autoapp
|
||||||
|
|
||||||
### Supported functionalities
|
### Supported functionalities
|
||||||
- 480p, 720p and 1080p with 30 or 60 FPS
|
- 480p, 720p and 1080p with 30 or 60 FPS
|
||||||
- RaspberryPI 3 hardware acceleration support to decode video stream (up to 1080p@60!)
|
- RaspberryPI 3 hardware acceleration support to decode video stream (up to 1080p@60!)
|
||||||
@ -49,4 +66,4 @@ Copyrights (c) 2018 f1x.studio (Michal Szwaj)
|
|||||||
- OpenMAX IL API
|
- OpenMAX IL API
|
||||||
|
|
||||||
### Remarks
|
### Remarks
|
||||||
**This software is not certified by Google Inc. It is created for R&D purposes and may not work as expected by the original authors. Do not use while driving. You use this software at your own risk.**
|
**This software is not certified by Google Inc. It is created for R&D purposes and may not work as expected by the original authors. Do not use while driving. You use this software at your own risk.**
|
@ -1,8 +0,0 @@
|
|||||||
<RCC>
|
|
||||||
<qresource prefix="/">
|
|
||||||
<file>ico_androidauto.png</file>
|
|
||||||
<file>ico_warning.png</file>
|
|
||||||
<file>ico_setting.png</file>
|
|
||||||
<file>ico_info.png</file>
|
|
||||||
</qresource>
|
|
||||||
</RCC>
|
|
33
autoapp/CMakeLists.txt
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
add_executable(autoapp
|
||||||
|
autoapp.cpp
|
||||||
|
UI/connectdialog.ui
|
||||||
|
UI/ConnectDialog.cpp
|
||||||
|
UI/mainwindow.ui
|
||||||
|
UI/MainWindow.cpp
|
||||||
|
UI/settingswindow.ui
|
||||||
|
UI/SettingsWindow.cpp
|
||||||
|
assets/resources.qrc
|
||||||
|
${CMAKE_SOURCE_DIR}/include/autoapp/UI/ConnectDialog.hpp
|
||||||
|
${CMAKE_SOURCE_DIR}/include/autoapp/UI/MainWindow.hpp
|
||||||
|
${CMAKE_SOURCE_DIR}/include/autoapp/UI/SettingsWindow.hpp
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(autoapp PRIVATE
|
||||||
|
${CMAKE_SOURCE_DIR}/include
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(autoapp
|
||||||
|
Qt5::WebSockets
|
||||||
|
openauto
|
||||||
|
)
|
||||||
|
|
||||||
|
if(RPI_BUILD AND NOT GST_BUILD)
|
||||||
|
target_link_libraries(autoapp omx)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set_target_properties(autoapp
|
||||||
|
PROPERTIES INSTALL_RPATH_USE_LINK_PATH 1)
|
||||||
|
|
||||||
|
install(TARGETS autoapp
|
||||||
|
RUNTIME DESTINATION bin)
|
128
autoapp/UI/ConnectDialog.cpp
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
#include <QMessageBox>
|
||||||
|
#include "autoapp/UI/ConnectDialog.hpp"
|
||||||
|
#include "ui_connectdialog.h"
|
||||||
|
|
||||||
|
namespace autoapp
|
||||||
|
{
|
||||||
|
namespace ui
|
||||||
|
{
|
||||||
|
|
||||||
|
ConnectDialog::ConnectDialog(boost::asio::io_service &ioService, aasdk::tcp::ITCPWrapper &tcpWrapper, openauto::configuration::IRecentAddressesList &recentAddressesList, QWidget *parent)
|
||||||
|
: QDialog(parent), ioService_(ioService), tcpWrapper_(tcpWrapper), recentAddressesList_(recentAddressesList), ui_(new Ui::ConnectDialog)
|
||||||
|
{
|
||||||
|
qRegisterMetaType<aasdk::tcp::ITCPEndpoint::SocketPointer>("aasdk::tcp::ITCPEndpoint::SocketPointer");
|
||||||
|
qRegisterMetaType<std::string>("std::string");
|
||||||
|
|
||||||
|
ui_->setupUi(this);
|
||||||
|
connect(ui_->pushButtonCancel, &QPushButton::clicked, this, &ConnectDialog::close);
|
||||||
|
connect(ui_->pushButtonConnect, &QPushButton::clicked, this, &ConnectDialog::onConnectButtonClicked);
|
||||||
|
connect(ui_->listViewRecent, &QListView::clicked, this, &ConnectDialog::onRecentAddressClicked);
|
||||||
|
connect(this, &ConnectDialog::connectionSucceed, this, &ConnectDialog::onConnectionSucceed);
|
||||||
|
connect(this, &ConnectDialog::connectionFailed, this, &ConnectDialog::onConnectionFailed);
|
||||||
|
|
||||||
|
ui_->listViewRecent->setModel(&recentAddressesModel_);
|
||||||
|
this->loadRecentList();
|
||||||
|
}
|
||||||
|
|
||||||
|
ConnectDialog::~ConnectDialog()
|
||||||
|
{
|
||||||
|
delete ui_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConnectDialog::onConnectButtonClicked()
|
||||||
|
{
|
||||||
|
this->setControlsEnabledStatus(false);
|
||||||
|
|
||||||
|
const auto &ipAddress = ui_->lineEditIPAddress->text().toStdString();
|
||||||
|
auto socket = std::make_shared<boost::asio::ip::tcp::socket>(ioService_);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
tcpWrapper_.asyncConnect(*socket, ipAddress, 5277, std::bind(&ConnectDialog::connectHandler, this, std::placeholders::_1, ipAddress, socket));
|
||||||
|
}
|
||||||
|
catch (const boost::system::system_error &se)
|
||||||
|
{
|
||||||
|
emit connectionFailed(QString(se.what()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConnectDialog::connectHandler(const boost::system::error_code &ec, const std::string &ipAddress, aasdk::tcp::ITCPEndpoint::SocketPointer socket)
|
||||||
|
{
|
||||||
|
if (!ec)
|
||||||
|
{
|
||||||
|
emit connectionSucceed(std::move(socket), ipAddress);
|
||||||
|
this->close();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
emit connectionFailed(QString::fromStdString(ec.message()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConnectDialog::onConnectionSucceed(aasdk::tcp::ITCPEndpoint::SocketPointer, const std::string &ipAddress)
|
||||||
|
{
|
||||||
|
this->insertIpAddress(ipAddress);
|
||||||
|
this->setControlsEnabledStatus(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConnectDialog::onConnectionFailed(const QString &message)
|
||||||
|
{
|
||||||
|
this->setControlsEnabledStatus(true);
|
||||||
|
|
||||||
|
/*QMessageBox errorMessage(QMessageBox::Critical, "Connect error", message, QMessageBox::Ok);
|
||||||
|
errorMessage.setWindowFlags(Qt::WindowStaysOnTopHint);
|
||||||
|
errorMessage.exec();*/
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConnectDialog::onRecentAddressClicked(const QModelIndex &index)
|
||||||
|
{
|
||||||
|
const auto &recentAddressesList = recentAddressesList_.getList();
|
||||||
|
|
||||||
|
if (static_cast<size_t>(index.row()) <= recentAddressesList.size())
|
||||||
|
{
|
||||||
|
ui_->lineEditIPAddress->setText(QString::fromStdString(recentAddressesList.at(index.row())));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConnectDialog::setControlsEnabledStatus(bool status)
|
||||||
|
{
|
||||||
|
ui_->pushButtonConnect->setVisible(status);
|
||||||
|
ui_->pushButtonCancel->setEnabled(status);
|
||||||
|
ui_->lineEditIPAddress->setEnabled(status);
|
||||||
|
ui_->listViewRecent->setEnabled(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConnectDialog::loadRecentList()
|
||||||
|
{
|
||||||
|
QStringList stringList;
|
||||||
|
const auto &configList = recentAddressesList_.getList();
|
||||||
|
|
||||||
|
for (const auto &element : configList)
|
||||||
|
{
|
||||||
|
stringList.append(QString::fromStdString(element));
|
||||||
|
}
|
||||||
|
|
||||||
|
recentAddressesModel_.setStringList(stringList);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConnectDialog::insertIpAddress(const std::string &ipAddress)
|
||||||
|
{
|
||||||
|
recentAddressesList_.insertAddress(ipAddress);
|
||||||
|
this->loadRecentList();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConnectDialog::connectToAddress(const QString &ip)
|
||||||
|
{
|
||||||
|
const auto &ipAddress = ip.toStdString();
|
||||||
|
auto socket = std::make_shared<boost::asio::ip::tcp::socket>(ioService_);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
tcpWrapper_.asyncConnect(*socket, ipAddress, 5277, std::bind(&ConnectDialog::connectHandler, this, std::placeholders::_1, ipAddress, socket));
|
||||||
|
}
|
||||||
|
catch (const boost::system::system_error &se)
|
||||||
|
{
|
||||||
|
emit connectionFailed(QString(se.what()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
75
autoapp/UI/MainWindow.cpp
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
/*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QJsonObject>
|
||||||
|
|
||||||
|
#include "autoapp/UI/MainWindow.hpp"
|
||||||
|
#include "ui_mainwindow.h"
|
||||||
|
|
||||||
|
namespace autoapp
|
||||||
|
{
|
||||||
|
namespace ui
|
||||||
|
{
|
||||||
|
MainWindow::MainWindow(QWidget *parent)
|
||||||
|
: QMainWindow(parent), ui_(new Ui::MainWindow)
|
||||||
|
{
|
||||||
|
ui_->setupUi(this);
|
||||||
|
//connect(ui_->pushButtonSettings, &QPushButton::clicked, this, &MainWindow::openSettings);
|
||||||
|
//connect(ui_->pushButtonExit, &QPushButton::clicked, this, &MainWindow::exit);
|
||||||
|
//connect(ui_->pushButtonToggleCursor, &QPushButton::clicked, this, &MainWindow::toggleCursor);
|
||||||
|
//connect(ui_->pushButtonWirelessConnection, &QPushButton::clicked, this, &MainWindow::openConnectDialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
MainWindow::~MainWindow()
|
||||||
|
{
|
||||||
|
delete ui_;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void autoapp::ui::MainWindow::handleIncomingMessage(const QJsonObject &rootObj)
|
||||||
|
{
|
||||||
|
if (rootObj.contains("bluetooth")) {
|
||||||
|
ui_->stackedWidget->setCurrentIndex(0);
|
||||||
|
QJsonObject btObj = rootObj["bluetooth"].toObject();
|
||||||
|
ui_->btSongName->setText(btObj["song"].toString());
|
||||||
|
ui_->btArtistName->setText(btObj["artist"].toString());
|
||||||
|
ui_->btAlbumName->setText(btObj["album"].toString());
|
||||||
|
if (btObj.contains("screen")) {
|
||||||
|
ui_->btRadioScreen->setText(btObj["screen"].toString());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ui_->btRadioScreen->setText("");
|
||||||
|
}
|
||||||
|
} else if (rootObj.contains("radio")) {
|
||||||
|
ui_->stackedWidget->setCurrentIndex(1);
|
||||||
|
QJsonObject radioObj = rootObj["radio"].toObject();
|
||||||
|
ui_->radioScreen->setText(radioObj["screen"].toString());
|
||||||
|
ui_->radioPreset->setText(radioObj["preset"].toString());
|
||||||
|
ui_->radioSecondLine->setText(radioObj["second"].toString());
|
||||||
|
} else if (rootObj.contains("connect_wireless_aa")) {
|
||||||
|
QJsonObject aaObj = rootObj["connect_wireless_aa"].toObject();
|
||||||
|
//connectWirelessAndroidAuto(aaObj["address"].toString());
|
||||||
|
}
|
||||||
|
else if (rootObj.contains("settings")) {
|
||||||
|
MainWindow::openSettings();
|
||||||
|
}
|
||||||
|
}
|
@ -17,19 +17,15 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <f1x/openauto/autoapp/UI/SettingsWindow.hpp>
|
#include "autoapp/UI/SettingsWindow.hpp"
|
||||||
#include "ui_settingswindow.h"
|
#include "ui_settingswindow.h"
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
|
||||||
{
|
|
||||||
namespace autoapp
|
namespace autoapp
|
||||||
{
|
{
|
||||||
namespace ui
|
namespace ui
|
||||||
{
|
{
|
||||||
|
|
||||||
SettingsWindow::SettingsWindow(configuration::IConfiguration::Pointer configuration, QWidget *parent)
|
SettingsWindow::SettingsWindow(openauto::configuration::IConfiguration::Pointer configuration, QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, ui_(new Ui::SettingsWindow)
|
, ui_(new Ui::SettingsWindow)
|
||||||
, configuration_(std::move(configuration))
|
, configuration_(std::move(configuration))
|
||||||
@ -54,7 +50,7 @@ SettingsWindow::~SettingsWindow()
|
|||||||
|
|
||||||
void SettingsWindow::onSave()
|
void SettingsWindow::onSave()
|
||||||
{
|
{
|
||||||
configuration_->setHandednessOfTrafficType(ui_->radioButtonLeftHandDrive->isChecked() ? configuration::HandednessOfTrafficType::LEFT_HAND_DRIVE : configuration::HandednessOfTrafficType::RIGHT_HAND_DRIVE);
|
configuration_->setHandednessOfTrafficType(ui_->radioButtonLeftHandDrive->isChecked() ? openauto::configuration::HandednessOfTrafficType::LEFT_HAND_DRIVE : openauto::configuration::HandednessOfTrafficType::RIGHT_HAND_DRIVE);
|
||||||
configuration_->showClock(ui_->checkBoxShowClock->isChecked());
|
configuration_->showClock(ui_->checkBoxShowClock->isChecked());
|
||||||
configuration_->setVideoFPS(ui_->radioButton30FPS->isChecked() ? aasdk::proto::enums::VideoFPS::_30 : aasdk::proto::enums::VideoFPS::_60);
|
configuration_->setVideoFPS(ui_->radioButton30FPS->isChecked() ? aasdk::proto::enums::VideoFPS::_30 : aasdk::proto::enums::VideoFPS::_60);
|
||||||
|
|
||||||
@ -82,22 +78,22 @@ void SettingsWindow::onSave()
|
|||||||
|
|
||||||
if(ui_->radioButtonDisableBluetooth->isChecked())
|
if(ui_->radioButtonDisableBluetooth->isChecked())
|
||||||
{
|
{
|
||||||
configuration_->setBluetoothAdapterType(configuration::BluetoothAdapterType::NONE);
|
configuration_->setBluetoothAdapterType(openauto::configuration::BluetoothAdapterType::NONE);
|
||||||
}
|
}
|
||||||
else if(ui_->radioButtonUseLocalBluetoothAdapter->isChecked())
|
else if(ui_->radioButtonUseLocalBluetoothAdapter->isChecked())
|
||||||
{
|
{
|
||||||
configuration_->setBluetoothAdapterType(configuration::BluetoothAdapterType::LOCAL);
|
configuration_->setBluetoothAdapterType(openauto::configuration::BluetoothAdapterType::LOCAL);
|
||||||
}
|
}
|
||||||
else if(ui_->radioButtonUseExternalBluetoothAdapter->isChecked())
|
else if(ui_->radioButtonUseExternalBluetoothAdapter->isChecked())
|
||||||
{
|
{
|
||||||
configuration_->setBluetoothAdapterType(configuration::BluetoothAdapterType::REMOTE);
|
configuration_->setBluetoothAdapterType(openauto::configuration::BluetoothAdapterType::REMOTE);
|
||||||
}
|
}
|
||||||
|
|
||||||
configuration_->setBluetoothRemoteAdapterAddress(ui_->lineEditExternalBluetoothAdapterAddress->text().toStdString());
|
configuration_->setBluetoothRemoteAdapterAddress(ui_->lineEditExternalBluetoothAdapterAddress->text().toStdString());
|
||||||
|
|
||||||
configuration_->setMusicAudioChannelEnabled(ui_->checkBoxMusicAudioChannel->isChecked());
|
configuration_->setMusicAudioChannelEnabled(ui_->checkBoxMusicAudioChannel->isChecked());
|
||||||
configuration_->setSpeechAudioChannelEnabled(ui_->checkBoxSpeechAudioChannel->isChecked());
|
configuration_->setSpeechAudioChannelEnabled(ui_->checkBoxSpeechAudioChannel->isChecked());
|
||||||
configuration_->setAudioOutputBackendType(ui_->radioButtonRtAudio->isChecked() ? configuration::AudioOutputBackendType::RTAUDIO : configuration::AudioOutputBackendType::QT);
|
configuration_->setAudioOutputBackendType(ui_->radioButtonRtAudio->isChecked() ? openauto::configuration::AudioOutputBackendType::RTAUDIO : openauto::configuration::AudioOutputBackendType::QT);
|
||||||
|
|
||||||
configuration_->save();
|
configuration_->save();
|
||||||
this->close();
|
this->close();
|
||||||
@ -122,8 +118,8 @@ void SettingsWindow::showEvent(QShowEvent* event)
|
|||||||
|
|
||||||
void SettingsWindow::load()
|
void SettingsWindow::load()
|
||||||
{
|
{
|
||||||
ui_->radioButtonLeftHandDrive->setChecked(configuration_->getHandednessOfTrafficType() == configuration::HandednessOfTrafficType::LEFT_HAND_DRIVE);
|
ui_->radioButtonLeftHandDrive->setChecked(configuration_->getHandednessOfTrafficType() == openauto::configuration::HandednessOfTrafficType::LEFT_HAND_DRIVE);
|
||||||
ui_->radioButtonRightHandDrive->setChecked(configuration_->getHandednessOfTrafficType() == configuration::HandednessOfTrafficType::RIGHT_HAND_DRIVE);
|
ui_->radioButtonRightHandDrive->setChecked(configuration_->getHandednessOfTrafficType() == openauto::configuration::HandednessOfTrafficType::RIGHT_HAND_DRIVE);
|
||||||
ui_->checkBoxShowClock->setChecked(configuration_->showClock());
|
ui_->checkBoxShowClock->setChecked(configuration_->showClock());
|
||||||
|
|
||||||
ui_->radioButton30FPS->setChecked(configuration_->getVideoFPS() == aasdk::proto::enums::VideoFPS::_30);
|
ui_->radioButton30FPS->setChecked(configuration_->getVideoFPS() == aasdk::proto::enums::VideoFPS::_30);
|
||||||
@ -142,18 +138,18 @@ void SettingsWindow::load()
|
|||||||
ui_->checkBoxEnableTouchscreen->setChecked(configuration_->getTouchscreenEnabled());
|
ui_->checkBoxEnableTouchscreen->setChecked(configuration_->getTouchscreenEnabled());
|
||||||
this->loadButtonCheckBoxes();
|
this->loadButtonCheckBoxes();
|
||||||
|
|
||||||
ui_->radioButtonDisableBluetooth->setChecked(configuration_->getBluetoothAdapterType() == configuration::BluetoothAdapterType::NONE);
|
ui_->radioButtonDisableBluetooth->setChecked(configuration_->getBluetoothAdapterType() == openauto::configuration::BluetoothAdapterType::NONE);
|
||||||
ui_->radioButtonUseLocalBluetoothAdapter->setChecked(configuration_->getBluetoothAdapterType() == configuration::BluetoothAdapterType::LOCAL);
|
ui_->radioButtonUseLocalBluetoothAdapter->setChecked(configuration_->getBluetoothAdapterType() == openauto::configuration::BluetoothAdapterType::LOCAL);
|
||||||
ui_->radioButtonUseExternalBluetoothAdapter->setChecked(configuration_->getBluetoothAdapterType() == configuration::BluetoothAdapterType::REMOTE);
|
ui_->radioButtonUseExternalBluetoothAdapter->setChecked(configuration_->getBluetoothAdapterType() == openauto::configuration::BluetoothAdapterType::REMOTE);
|
||||||
ui_->lineEditExternalBluetoothAdapterAddress->setEnabled(configuration_->getBluetoothAdapterType() == configuration::BluetoothAdapterType::REMOTE);
|
ui_->lineEditExternalBluetoothAdapterAddress->setEnabled(configuration_->getBluetoothAdapterType() == openauto::configuration::BluetoothAdapterType::REMOTE);
|
||||||
ui_->lineEditExternalBluetoothAdapterAddress->setText(QString::fromStdString(configuration_->getBluetoothRemoteAdapterAddress()));
|
ui_->lineEditExternalBluetoothAdapterAddress->setText(QString::fromStdString(configuration_->getBluetoothRemoteAdapterAddress()));
|
||||||
|
|
||||||
ui_->checkBoxMusicAudioChannel->setChecked(configuration_->musicAudioChannelEnabled());
|
ui_->checkBoxMusicAudioChannel->setChecked(configuration_->musicAudioChannelEnabled());
|
||||||
ui_->checkBoxSpeechAudioChannel->setChecked(configuration_->speechAudioChannelEnabled());
|
ui_->checkBoxSpeechAudioChannel->setChecked(configuration_->speechAudioChannelEnabled());
|
||||||
|
|
||||||
const auto& audioOutputBackendType = configuration_->getAudioOutputBackendType();
|
const auto& audioOutputBackendType = configuration_->getAudioOutputBackendType();
|
||||||
ui_->radioButtonRtAudio->setChecked(audioOutputBackendType == configuration::AudioOutputBackendType::RTAUDIO);
|
ui_->radioButtonRtAudio->setChecked(audioOutputBackendType == openauto::configuration::AudioOutputBackendType::RTAUDIO);
|
||||||
ui_->radioButtonQtAudio->setChecked(audioOutputBackendType == configuration::AudioOutputBackendType::QT);
|
ui_->radioButtonQtAudio->setChecked(audioOutputBackendType == openauto::configuration::AudioOutputBackendType::QT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsWindow::loadButtonCheckBoxes()
|
void SettingsWindow::loadButtonCheckBoxes()
|
||||||
@ -199,7 +195,7 @@ void SettingsWindow::setButtonCheckBoxes(bool value)
|
|||||||
|
|
||||||
void SettingsWindow::saveButtonCheckBoxes()
|
void SettingsWindow::saveButtonCheckBoxes()
|
||||||
{
|
{
|
||||||
configuration::IConfiguration::ButtonCodes buttonCodes;
|
openauto::configuration::IConfiguration::ButtonCodes buttonCodes;
|
||||||
this->saveButtonCheckBox(ui_->checkBoxPlayButton, buttonCodes, aasdk::proto::enums::ButtonCode::PLAY);
|
this->saveButtonCheckBox(ui_->checkBoxPlayButton, buttonCodes, aasdk::proto::enums::ButtonCode::PLAY);
|
||||||
this->saveButtonCheckBox(ui_->checkBoxPauseButton, buttonCodes, aasdk::proto::enums::ButtonCode::PAUSE);
|
this->saveButtonCheckBox(ui_->checkBoxPauseButton, buttonCodes, aasdk::proto::enums::ButtonCode::PAUSE);
|
||||||
this->saveButtonCheckBox(ui_->checkBoxTogglePlayButton, buttonCodes, aasdk::proto::enums::ButtonCode::TOGGLE_PLAY);
|
this->saveButtonCheckBox(ui_->checkBoxTogglePlayButton, buttonCodes, aasdk::proto::enums::ButtonCode::TOGGLE_PLAY);
|
||||||
@ -219,7 +215,7 @@ void SettingsWindow::saveButtonCheckBoxes()
|
|||||||
configuration_->setButtonCodes(buttonCodes);
|
configuration_->setButtonCodes(buttonCodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsWindow::saveButtonCheckBox(const QCheckBox* checkBox, configuration::IConfiguration::ButtonCodes& buttonCodes, aasdk::proto::enums::ButtonCode::Enum buttonCode)
|
void SettingsWindow::saveButtonCheckBox(const QCheckBox* checkBox, openauto::configuration::IConfiguration::ButtonCodes& buttonCodes, aasdk::proto::enums::ButtonCode::Enum buttonCode)
|
||||||
{
|
{
|
||||||
if(checkBox->isChecked())
|
if(checkBox->isChecked())
|
||||||
{
|
{
|
||||||
@ -259,5 +255,3 @@ void SettingsWindow::onShowBindings()
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
464
autoapp/UI/mainwindow.ui
Normal file
@ -0,0 +1,464 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>MainWindow</class>
|
||||||
|
<widget class="QMainWindow" name="MainWindow">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>1046</width>
|
||||||
|
<height>571</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>MainWindow</string>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">background-color: rgb(46, 52, 54);
|
||||||
|
color: rgb(238, 238, 236);</string>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="centralwidget">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QStackedWidget" name="stackedWidget">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>1024</width>
|
||||||
|
<height>500</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>1024</width>
|
||||||
|
<height>500</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="currentIndex">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="page">
|
||||||
|
<widget class="QFrame" name="verticalFrame">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>1021</width>
|
||||||
|
<height>500</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>500</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>1024</width>
|
||||||
|
<height>500</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item alignment="Qt::AlignVCenter">
|
||||||
|
<widget class="QFrame" name="verticalFrame">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
|
<item alignment="Qt::AlignHCenter">
|
||||||
|
<widget class="QWidget" name="btNowPlaying" native="true">
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>16777215</width>
|
||||||
|
<height>300</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_6">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>200</width>
|
||||||
|
<height>200</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>200</width>
|
||||||
|
<height>200</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="pixmap">
|
||||||
|
<pixmap>:/bluetooth.png</pixmap>
|
||||||
|
</property>
|
||||||
|
<property name="scaledContents">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item alignment="Qt::AlignHCenter">
|
||||||
|
<widget class="QWidget" name="widget" native="true">
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>16777215</width>
|
||||||
|
<height>300</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>10</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_9">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_8">
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>60</width>
|
||||||
|
<height>60</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="pixmap">
|
||||||
|
<pixmap>:/song.png</pixmap>
|
||||||
|
</property>
|
||||||
|
<property name="scaledContents">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="btSongName">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>24</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Lorem Ipsum Dorem</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_9">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>60</width>
|
||||||
|
<height>60</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>60</width>
|
||||||
|
<height>60</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="pixmap">
|
||||||
|
<pixmap>:/artist.png</pixmap>
|
||||||
|
</property>
|
||||||
|
<property name="scaledContents">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="btArtistName">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>16</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Example Artist</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_10">
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>60</width>
|
||||||
|
<height>60</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="pixmap">
|
||||||
|
<pixmap>:/album.png</pixmap>
|
||||||
|
</property>
|
||||||
|
<property name="scaledContents">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="btAlbumName">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>16</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Example Album</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item alignment="Qt::AlignHCenter|Qt::AlignBottom">
|
||||||
|
<widget class="QLabel" name="btRadioScreen">
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>16777215</width>
|
||||||
|
<height>50</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>24</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>ABCD,EFGH</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="page_2">
|
||||||
|
<widget class="QFrame" name="horizontalFrame">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>1024</width>
|
||||||
|
<height>550</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>550</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>1024</width>
|
||||||
|
<height>550</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item alignment="Qt::AlignHCenter|Qt::AlignVCenter">
|
||||||
|
<widget class="QWidget" name="horizontalWidget" native="true">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="radioIcon">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>200</width>
|
||||||
|
<height>200</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>200</width>
|
||||||
|
<height>200</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="pixmap">
|
||||||
|
<pixmap>:/radio.png</pixmap>
|
||||||
|
</property>
|
||||||
|
<property name="scaledContents">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="radioScreen">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>276</width>
|
||||||
|
<height>140</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>276</width>
|
||||||
|
<height>140</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>40</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>ABCD,EFGH</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="radioPreset">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>50</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>16777215</width>
|
||||||
|
<height>50</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>20</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>0</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="radioSecondLine">
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>16777215</width>
|
||||||
|
<height>50</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>16</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Tuner List</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item alignment="Qt::AlignHCenter|Qt::AlignBottom">
|
||||||
|
<widget class="QWidget" name="horizontalWidget" native="true">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>1024</width>
|
||||||
|
<height>30</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>1024</width>
|
||||||
|
<height>50</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="baseSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>30</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<resources>
|
||||||
|
<include location="../assets/resources.qrc"/>
|
||||||
|
</resources>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
9
autoapp/assets/aa_video.qml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import QtQuick 2.0
|
||||||
|
import QtGStreamer 1.0
|
||||||
|
|
||||||
|
VideoItem {
|
||||||
|
id: aaVideo
|
||||||
|
width: 300
|
||||||
|
height: 300
|
||||||
|
surface: videoSurface
|
||||||
|
}
|
BIN
autoapp/assets/album.png
Normal file
After Width: | Height: | Size: 896 B |
BIN
autoapp/assets/artist.png
Normal file
After Width: | Height: | Size: 935 B |
BIN
autoapp/assets/bluetooth.png
Normal file
After Width: | Height: | Size: 931 B |
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 438 B After Width: | Height: | Size: 438 B |
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 751 B After Width: | Height: | Size: 751 B |
BIN
autoapp/assets/radio.png
Normal file
After Width: | Height: | Size: 816 B |
14
autoapp/assets/resources.qrc
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<RCC>
|
||||||
|
<qresource prefix="/">
|
||||||
|
<file>radio.png</file>
|
||||||
|
<file>album.png</file>
|
||||||
|
<file>artist.png</file>
|
||||||
|
<file>bluetooth.png</file>
|
||||||
|
<file>song.png</file>
|
||||||
|
<file>ico_androidauto.png</file>
|
||||||
|
<file>ico_warning.png</file>
|
||||||
|
<file>ico_setting.png</file>
|
||||||
|
<file>ico_info.png</file>
|
||||||
|
<file>aa_video.qml</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
BIN
autoapp/assets/song.png
Normal file
After Width: | Height: | Size: 821 B |
194
autoapp/autoapp.cpp
Normal file
@ -0,0 +1,194 @@
|
|||||||
|
/*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <thread>
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QtWebSockets/QWebSocket>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QJsonDocument>
|
||||||
|
#include <QJsonObject>
|
||||||
|
#include <QJsonParseError>
|
||||||
|
#include "aasdk/USB/USBHub.hpp"
|
||||||
|
#include "aasdk/USB/ConnectedAccessoriesEnumerator.hpp"
|
||||||
|
#include "aasdk/USB/AccessoryModeQueryChain.hpp"
|
||||||
|
#include "aasdk/USB/AccessoryModeQueryChainFactory.hpp"
|
||||||
|
#include "aasdk/USB/AccessoryModeQueryFactory.hpp"
|
||||||
|
#include "aasdk/TCP/TCPWrapper.hpp"
|
||||||
|
#include "openauto/App.hpp"
|
||||||
|
#include "openauto/Configuration/IConfiguration.hpp"
|
||||||
|
#include "openauto/Configuration/RecentAddressesList.hpp"
|
||||||
|
#include "openauto/Service/AndroidAutoEntityFactory.hpp"
|
||||||
|
#include "openauto/Service/ServiceFactory.hpp"
|
||||||
|
#include "openauto/Configuration/Configuration.hpp"
|
||||||
|
#include "autoapp/UI/MainWindow.hpp"
|
||||||
|
#include "autoapp/UI/SettingsWindow.hpp"
|
||||||
|
#include "autoapp/UI/ConnectDialog.hpp"
|
||||||
|
#include "OpenautoLog.hpp"
|
||||||
|
|
||||||
|
using namespace openauto;
|
||||||
|
using ThreadPool = std::vector<std::thread>;
|
||||||
|
|
||||||
|
void startUSBWorkers(boost::asio::io_service &ioService, libusb_context *usbContext, ThreadPool &threadPool)
|
||||||
|
{
|
||||||
|
auto usbWorker = [&ioService, usbContext]()
|
||||||
|
{
|
||||||
|
timeval libusbEventTimeout{180, 0};
|
||||||
|
|
||||||
|
while (!ioService.stopped())
|
||||||
|
{
|
||||||
|
libusb_handle_events_timeout_completed(usbContext, &libusbEventTimeout, nullptr);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
threadPool.emplace_back(usbWorker);
|
||||||
|
threadPool.emplace_back(usbWorker);
|
||||||
|
threadPool.emplace_back(usbWorker);
|
||||||
|
threadPool.emplace_back(usbWorker);
|
||||||
|
}
|
||||||
|
|
||||||
|
void startIOServiceWorkers(boost::asio::io_service &ioService, ThreadPool &threadPool)
|
||||||
|
{
|
||||||
|
auto ioServiceWorker = [&ioService]()
|
||||||
|
{
|
||||||
|
ioService.run();
|
||||||
|
};
|
||||||
|
|
||||||
|
threadPool.emplace_back(ioServiceWorker);
|
||||||
|
threadPool.emplace_back(ioServiceWorker);
|
||||||
|
threadPool.emplace_back(ioServiceWorker);
|
||||||
|
threadPool.emplace_back(ioServiceWorker);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
libusb_context *usbContext;
|
||||||
|
if (libusb_init(&usbContext) != 0)
|
||||||
|
{
|
||||||
|
OPENAUTO_LOG(error) << "[OpenAuto] libusb init failed.";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::asio::io_service ioService;
|
||||||
|
boost::asio::io_service::work work(ioService);
|
||||||
|
std::vector<std::thread> threadPool;
|
||||||
|
startUSBWorkers(ioService, usbContext, threadPool);
|
||||||
|
startIOServiceWorkers(ioService, threadPool);
|
||||||
|
|
||||||
|
QApplication qApplication(argc, argv);
|
||||||
|
autoapp::ui::MainWindow mainWindow;
|
||||||
|
mainWindow.setWindowFlags(Qt::WindowStaysOnTopHint);
|
||||||
|
|
||||||
|
auto configuration = std::make_shared<openauto::configuration::Configuration>();
|
||||||
|
autoapp::ui::SettingsWindow settingsWindow(configuration);
|
||||||
|
settingsWindow.setWindowFlags(Qt::WindowStaysOnTopHint);
|
||||||
|
|
||||||
|
openauto::configuration::RecentAddressesList recentAddressesList(7);
|
||||||
|
recentAddressesList.read();
|
||||||
|
|
||||||
|
aasdk::tcp::TCPWrapper tcpWrapper;
|
||||||
|
autoapp::ui::ConnectDialog connectDialog(ioService, tcpWrapper, recentAddressesList);
|
||||||
|
connectDialog.setWindowFlags(Qt::WindowStaysOnTopHint);
|
||||||
|
|
||||||
|
QObject::connect(&mainWindow, &autoapp::ui::MainWindow::exit, []()
|
||||||
|
{ std::exit(0); });
|
||||||
|
QObject::connect(&mainWindow, &autoapp::ui::MainWindow::openSettings, &settingsWindow, &autoapp::ui::SettingsWindow::showFullScreen);
|
||||||
|
QObject::connect(&mainWindow, &autoapp::ui::MainWindow::openConnectDialog, &connectDialog, &autoapp::ui::ConnectDialog::exec);
|
||||||
|
|
||||||
|
qApplication.setOverrideCursor(Qt::BlankCursor);
|
||||||
|
QObject::connect(&mainWindow, &autoapp::ui::MainWindow::toggleCursor, [&qApplication]()
|
||||||
|
{
|
||||||
|
const auto cursor = qApplication.overrideCursor()->shape() == Qt::BlankCursor ? Qt::ArrowCursor : Qt::BlankCursor;
|
||||||
|
qApplication.setOverrideCursor(cursor); });
|
||||||
|
|
||||||
|
mainWindow.showFullScreen();
|
||||||
|
|
||||||
|
aasdk::usb::USBWrapper usbWrapper(usbContext);
|
||||||
|
aasdk::usb::AccessoryModeQueryFactory queryFactory(usbWrapper, ioService);
|
||||||
|
aasdk::usb::AccessoryModeQueryChainFactory queryChainFactory(usbWrapper, ioService, queryFactory);
|
||||||
|
openauto::service::ServiceFactory serviceFactory(ioService, configuration);
|
||||||
|
openauto::service::AndroidAutoEntityFactory androidAutoEntityFactory(ioService, configuration, serviceFactory);
|
||||||
|
|
||||||
|
auto usbHub(std::make_shared<aasdk::usb::USBHub>(usbWrapper, ioService, queryChainFactory));
|
||||||
|
auto connectedAccessoriesEnumerator(std::make_shared<aasdk::usb::ConnectedAccessoriesEnumerator>(usbWrapper, ioService, queryChainFactory));
|
||||||
|
auto app = std::make_shared<openauto::App>(ioService, usbWrapper, tcpWrapper, androidAutoEntityFactory, std::move(usbHub), std::move(connectedAccessoriesEnumerator));
|
||||||
|
|
||||||
|
QObject::connect(&connectDialog, &autoapp::ui::ConnectDialog::connectionSucceed, [&app](auto socket)
|
||||||
|
{ app->start(std::move(socket)); });
|
||||||
|
|
||||||
|
app->waitForDevice(true);
|
||||||
|
|
||||||
|
QWebSocket webSocket;
|
||||||
|
QTimer reconnectTimer;
|
||||||
|
const QUrl websocketUrl(QStringLiteral("ws://127.0.0.1:5959/ws"));
|
||||||
|
|
||||||
|
auto tryConnect = [&webSocket, &websocketUrl]()
|
||||||
|
{
|
||||||
|
if (webSocket.state() != QAbstractSocket::ConnectedState &&
|
||||||
|
webSocket.state() != QAbstractSocket::ConnectingState)
|
||||||
|
{
|
||||||
|
qDebug() << "[WebSocket] Attempting to connect to" << websocketUrl.toString();
|
||||||
|
webSocket.open(websocketUrl);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Connect events
|
||||||
|
QObject::connect(&webSocket, &QWebSocket::connected, [&]()
|
||||||
|
{
|
||||||
|
qDebug() << "[WebSocket] Connected.";
|
||||||
|
webSocket.sendTextMessage("Hello from OpenAuto WebSocket client!");
|
||||||
|
reconnectTimer.stop(); });
|
||||||
|
|
||||||
|
QObject::connect(&webSocket, &QWebSocket::disconnected, [&]()
|
||||||
|
{
|
||||||
|
qDebug() << "[WebSocket] Disconnected. Will retry...";
|
||||||
|
reconnectTimer.start(3000); });
|
||||||
|
|
||||||
|
QObject::connect(&webSocket, &QWebSocket::textMessageReceived, [&mainWindow, &connectDialog, &serviceFactory](const QString &message)
|
||||||
|
{
|
||||||
|
QJsonParseError error;
|
||||||
|
QJsonDocument doc = QJsonDocument::fromJson(message.toUtf8(), &error);
|
||||||
|
if (error.error != QJsonParseError::NoError) {
|
||||||
|
qDebug() << "JSON parse error:" << error.errorString();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QJsonObject rootObj = doc.object();
|
||||||
|
if (rootObj.contains("wireless_aa_ip")) {
|
||||||
|
QString ipAddr = rootObj["wireless_aa_ip"].toString();
|
||||||
|
connectDialog.connectToAddress(ipAddr);
|
||||||
|
}
|
||||||
|
else if (rootObj.contains("button")) {
|
||||||
|
QJsonObject btnObj = rootObj["button"].toObject();
|
||||||
|
QString btn = btnObj["btn"].toString();
|
||||||
|
int state = btnObj["state"].toInt();
|
||||||
|
serviceFactory.sendButtonPressFromString(btn.toStdString(), state);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
mainWindow.handleIncomingMessage(rootObj);
|
||||||
|
} });
|
||||||
|
|
||||||
|
reconnectTimer.setInterval(3000);
|
||||||
|
reconnectTimer.setSingleShot(true);
|
||||||
|
QObject::connect(&reconnectTimer, &QTimer::timeout, tryConnect);
|
||||||
|
tryConnect();
|
||||||
|
|
||||||
|
auto result = qApplication.exec();
|
||||||
|
std::for_each(threadPool.begin(), threadPool.end(), std::bind(&std::thread::join, std::placeholders::_1));
|
||||||
|
|
||||||
|
libusb_exit(usbContext);
|
||||||
|
return result;
|
||||||
|
}
|
222
btservice/AndroidBluetoothServer.cpp
Normal file
@ -0,0 +1,222 @@
|
|||||||
|
#include <QNetworkInterface>
|
||||||
|
#include <QThread>
|
||||||
|
#include "OpenautoLog.hpp"
|
||||||
|
#include "btservice/AndroidBluetoothServer.hpp"
|
||||||
|
|
||||||
|
namespace openauto
|
||||||
|
{
|
||||||
|
namespace btservice
|
||||||
|
{
|
||||||
|
|
||||||
|
AndroidBluetoothServer::AndroidBluetoothServer(openauto::configuration::IConfiguration::Pointer config)
|
||||||
|
: rfcommServer_(std::make_unique<QBluetoothServer>(QBluetoothServiceInfo::RfcommProtocol, this))
|
||||||
|
, socket_(nullptr)
|
||||||
|
, config_(std::move(config))
|
||||||
|
{
|
||||||
|
connect(rfcommServer_.get(), &QBluetoothServer::newConnection, this, &AndroidBluetoothServer::onClientConnected);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AndroidBluetoothServer::start(const QBluetoothAddress& address, uint16_t portNumber)
|
||||||
|
{
|
||||||
|
OPENAUTO_LOG(info) << "[AndroidBluetoothServer] listening.";
|
||||||
|
return rfcommServer_->listen(address, portNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AndroidBluetoothServer::onClientConnected()
|
||||||
|
{
|
||||||
|
socket_ = rfcommServer_->nextPendingConnection();
|
||||||
|
if(socket_ != nullptr)
|
||||||
|
{
|
||||||
|
OPENAUTO_LOG(info) << "[AndroidBluetoothServer] Device Connected: " << socket_->peerName().toStdString();
|
||||||
|
connect(socket_, SIGNAL(readyRead()), this, SLOT(readSocket()));
|
||||||
|
writeSocketInfoRequest();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OPENAUTO_LOG(error) << "[AndroidBluetoothServer] received null socket during client connection.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AndroidBluetoothServer::writeProtoMessage(uint16_t messageType, google::protobuf::Message& message)
|
||||||
|
{
|
||||||
|
QByteArray byteArray(message.SerializeAsString().c_str(), message.ByteSize());
|
||||||
|
uint16_t messageLength = message.ByteSize();
|
||||||
|
byteArray.prepend(messageType & 0x000000ff);
|
||||||
|
byteArray.prepend((messageType & 0x0000ff00) >> 8);
|
||||||
|
byteArray.prepend(messageLength & 0x000000ff);
|
||||||
|
byteArray.prepend((messageLength & 0x0000ff00) >> 8);
|
||||||
|
|
||||||
|
if(socket_->write(byteArray) != byteArray.length())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AndroidBluetoothServer::writeSocketInfoRequest()
|
||||||
|
{
|
||||||
|
OPENAUTO_LOG(info) << "[AndroidBluetoothServer] Sending SocketInfoRequest.";
|
||||||
|
|
||||||
|
QString ipAddr;
|
||||||
|
foreach(QHostAddress addr, QNetworkInterface::allAddresses())
|
||||||
|
{
|
||||||
|
if(!addr.isLoopback() && (addr.protocol() == QAbstractSocket::IPv4Protocol))
|
||||||
|
{
|
||||||
|
ipAddr = addr.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
btservice::proto::SocketInfoRequest socketInfoRequest;
|
||||||
|
socketInfoRequest.set_ip_address(ipAddr.toStdString());
|
||||||
|
OPENAUTO_LOG(info) << "[AndroidBluetoothServer] ipAddress: "<< ipAddr.toStdString();
|
||||||
|
|
||||||
|
socketInfoRequest.set_port(5000);
|
||||||
|
OPENAUTO_LOG(info) << "[AndroidBluetoothServer] port: "<< 5000;
|
||||||
|
|
||||||
|
if(this->writeProtoMessage(1, socketInfoRequest))
|
||||||
|
{
|
||||||
|
OPENAUTO_LOG(info) << "[AndroidBluetoothServer] Sent SocketInfoRequest.";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OPENAUTO_LOG(error) << "[AndroidBluetoothServer] Error sending SocketInfoRequest.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void AndroidBluetoothServer::writeSocketInfoResponse()
|
||||||
|
{
|
||||||
|
OPENAUTO_LOG(info) << "[AndroidBluetoothServer] Sending SocketInfoResponse.";
|
||||||
|
QString ipAddr;
|
||||||
|
foreach(QHostAddress addr, QNetworkInterface::allAddresses())
|
||||||
|
{
|
||||||
|
if(!addr.isLoopback() && (addr.protocol() == QAbstractSocket::IPv4Protocol))
|
||||||
|
{
|
||||||
|
ipAddr = addr.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
btservice::proto::SocketInfoResponse socketInfoResponse;
|
||||||
|
socketInfoResponse.set_ip_address(ipAddr.toStdString());
|
||||||
|
OPENAUTO_LOG(info) << "[AndroidBluetoothServer] ipAddress: "<< ipAddr.toStdString();
|
||||||
|
|
||||||
|
socketInfoResponse.set_port(5000);
|
||||||
|
OPENAUTO_LOG(info) << "[AndroidBluetoothServer] port: "<< 5000;
|
||||||
|
|
||||||
|
socketInfoResponse.set_status(btservice::proto::Status::STATUS_SUCCESS);
|
||||||
|
OPENAUTO_LOG(info) << "[AndroidBluetoothServer] status: "<< btservice::proto::Status::STATUS_SUCCESS;
|
||||||
|
|
||||||
|
|
||||||
|
if(this->writeProtoMessage(7, socketInfoResponse))
|
||||||
|
{
|
||||||
|
OPENAUTO_LOG(info) << "[AndroidBluetoothServer] Sent SocketInfoResponse.";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OPENAUTO_LOG(error) << "[AndroidBluetoothServer] Error sending SocketInfoResponse.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AndroidBluetoothServer::handleSocketInfoRequestResponse(QByteArray data)
|
||||||
|
{
|
||||||
|
btservice::proto::SocketInfoResponse socketInfoResponse;
|
||||||
|
socketInfoResponse.ParseFromArray(data, data.size());
|
||||||
|
OPENAUTO_LOG(info) <<"[AndroidBluetoothServer] Received SocketInfoRequestResponse, status: "<<socketInfoResponse.status();
|
||||||
|
if(socketInfoResponse.status() == 0)
|
||||||
|
{
|
||||||
|
// A status of 0 should be successful handshake (unless phone later reports an error, aw well)
|
||||||
|
// save this phone so we can autoconnect to it next time
|
||||||
|
config_->setLastBluetoothPair(socket_->peerAddress().toString().toStdString());
|
||||||
|
config_->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AndroidBluetoothServer::handleSocketInfoRequest(QByteArray data)
|
||||||
|
{
|
||||||
|
OPENAUTO_LOG(info) << "[AndroidBluetoothServer] Reading SocketInfoRequest.";
|
||||||
|
|
||||||
|
btservice::proto::SocketInfoRequest socketInfoRequest;
|
||||||
|
|
||||||
|
writeSocketInfoResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AndroidBluetoothServer::writeNetworkInfoMessage()
|
||||||
|
{
|
||||||
|
OPENAUTO_LOG(info) << "[AndroidBluetoothServer] Sending NetworkInfoMessage.";
|
||||||
|
|
||||||
|
btservice::proto::NetworkInfo networkMessage;
|
||||||
|
networkMessage.set_ssid(config_->getWifiSSID());
|
||||||
|
OPENAUTO_LOG(info) << "[AndroidBluetoothServer] SSID: "<<config_->getWifiSSID();
|
||||||
|
|
||||||
|
networkMessage.set_psk(config_->getWifiPassword());
|
||||||
|
OPENAUTO_LOG(info) << "[AndroidBluetoothServer] PSKEY: "<<config_->getWifiPassword();
|
||||||
|
|
||||||
|
if(config_->getWifiMAC().empty())
|
||||||
|
{
|
||||||
|
networkMessage.set_mac_addr(QNetworkInterface::interfaceFromName("wlan0").hardwareAddress().toStdString());
|
||||||
|
OPENAUTO_LOG(info) << "[AndroidBluetoothServer] MAC: "<<QNetworkInterface::interfaceFromName("wlan0").hardwareAddress().toStdString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
networkMessage.set_mac_addr(config_->getWifiMAC());
|
||||||
|
OPENAUTO_LOG(info) << "[AndroidBluetoothServer] MAC: "<< config_->getWifiMAC();
|
||||||
|
}
|
||||||
|
|
||||||
|
networkMessage.set_security_mode(btservice::proto::SecurityMode::WPA2_PERSONAL);
|
||||||
|
OPENAUTO_LOG(info) << "[AndroidBluetoothServer] Security: "<< btservice::proto::SecurityMode::WPA2_PERSONAL;
|
||||||
|
|
||||||
|
networkMessage.set_ap_type(btservice::proto::AccessPointType::STATIC);
|
||||||
|
OPENAUTO_LOG(info) << "[AndroidBluetoothServer] AP Type: "<< btservice::proto::AccessPointType::STATIC;
|
||||||
|
|
||||||
|
|
||||||
|
if(this->writeProtoMessage(3, networkMessage))
|
||||||
|
{
|
||||||
|
OPENAUTO_LOG(info) << "[AndroidBluetoothServer] Sent NetworkInfoMessage";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OPENAUTO_LOG(info) << "[AndroidBluetoothServer] Error sending NetworkInfoMessage.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AndroidBluetoothServer::handleUnknownMessage(int messageType, QByteArray data)
|
||||||
|
{
|
||||||
|
OPENAUTO_LOG(info) << "[AndroidBluetoothServer] Received unknown MessageType of "<<messageType;
|
||||||
|
OPENAUTO_LOG(info) << "[AndroidBluetoothServer] Unknown Message Data: "<<data.toHex(' ').toStdString() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AndroidBluetoothServer::readSocket()
|
||||||
|
{
|
||||||
|
if(!socket_)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto data = socket_->readAll();
|
||||||
|
if(data.length() == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t messageType = (data[2] << 8) | data[3];
|
||||||
|
switch(messageType)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
handleSocketInfoRequest(data);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
writeNetworkInfoMessage();
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
data.remove(0, 4);
|
||||||
|
handleSocketInfoRequestResponse(data);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
data.remove(0, 4);
|
||||||
|
handleUnknownMessage(messageType, data);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -16,10 +16,8 @@
|
|||||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <f1x/openauto/btservice/AndroidBluetoothService.hpp>
|
#include "btservice/AndroidBluetoothService.hpp"
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace btservice
|
namespace btservice
|
||||||
@ -38,7 +36,7 @@ AndroidBluetoothService::AndroidBluetoothService(uint16_t portNumber)
|
|||||||
serviceInfo_.setAttribute(QBluetoothServiceInfo::ServiceClassIds, classId);
|
serviceInfo_.setAttribute(QBluetoothServiceInfo::ServiceClassIds, classId);
|
||||||
serviceInfo_.setAttribute(QBluetoothServiceInfo::ServiceName, "OpenAuto Bluetooth Service");
|
serviceInfo_.setAttribute(QBluetoothServiceInfo::ServiceName, "OpenAuto Bluetooth Service");
|
||||||
serviceInfo_.setAttribute(QBluetoothServiceInfo::ServiceDescription, "AndroidAuto WiFi projection automatic setup");
|
serviceInfo_.setAttribute(QBluetoothServiceInfo::ServiceDescription, "AndroidAuto WiFi projection automatic setup");
|
||||||
serviceInfo_.setAttribute(QBluetoothServiceInfo::ServiceProvider, "f1xstudio.com");
|
serviceInfo_.setAttribute(QBluetoothServiceInfo::ServiceProvider, "openDsh");
|
||||||
serviceInfo_.setServiceUuid(serviceUuid);
|
serviceInfo_.setServiceUuid(serviceUuid);
|
||||||
|
|
||||||
QBluetoothServiceInfo::Sequence publicBrowse;
|
QBluetoothServiceInfo::Sequence publicBrowse;
|
||||||
@ -51,7 +49,7 @@ AndroidBluetoothService::AndroidBluetoothService(uint16_t portNumber)
|
|||||||
protocolDescriptorList.append(QVariant::fromValue(protocol));
|
protocolDescriptorList.append(QVariant::fromValue(protocol));
|
||||||
protocol.clear();
|
protocol.clear();
|
||||||
protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::Rfcomm))
|
protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::Rfcomm))
|
||||||
<< QVariant::fromValue(quint16(portNumber));
|
<< QVariant::fromValue(quint8(portNumber));
|
||||||
protocolDescriptorList.append(QVariant::fromValue(protocol));
|
protocolDescriptorList.append(QVariant::fromValue(protocol));
|
||||||
serviceInfo_.setAttribute(QBluetoothServiceInfo::ProtocolDescriptorList, protocolDescriptorList);
|
serviceInfo_.setAttribute(QBluetoothServiceInfo::ProtocolDescriptorList, protocolDescriptorList);
|
||||||
}
|
}
|
||||||
@ -68,4 +66,3 @@ bool AndroidBluetoothService::unregisterService()
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
84
btservice/btservice.cpp
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
#include "btservice/btservice.hpp"
|
||||||
|
|
||||||
|
namespace openauto
|
||||||
|
{
|
||||||
|
namespace btservice
|
||||||
|
{
|
||||||
|
|
||||||
|
btservice::btservice(openauto::configuration::IConfiguration::Pointer config)
|
||||||
|
: androidBluetoothService_(cServicePortNumber)
|
||||||
|
, androidBluetoothServer_(config)
|
||||||
|
{
|
||||||
|
QBluetoothAddress address;
|
||||||
|
auto adapters = QBluetoothLocalDevice::allDevices();
|
||||||
|
if(adapters.size() > 0)
|
||||||
|
{
|
||||||
|
address = adapters.at(0).address();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OPENAUTO_LOG(error) << "[btservice] No adapter found.";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!androidBluetoothServer_.start(address, cServicePortNumber))
|
||||||
|
{
|
||||||
|
OPENAUTO_LOG(error) << "[btservice] Server start failed.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
OPENAUTO_LOG(info) << "[btservice] Listening for connections, address: " << address.toString().toStdString()
|
||||||
|
<< ", port: " << cServicePortNumber;
|
||||||
|
|
||||||
|
if(!androidBluetoothService_.registerService(address))
|
||||||
|
{
|
||||||
|
OPENAUTO_LOG(error) << "[btservice] Service registration failed.";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OPENAUTO_LOG(info) << "[btservice] Service registered, port: " << cServicePortNumber;
|
||||||
|
}
|
||||||
|
if(config->getAutoconnectBluetooth())
|
||||||
|
connectToBluetooth(QBluetoothAddress(QString::fromStdString(config->getLastBluetoothPair())), address);
|
||||||
|
}
|
||||||
|
|
||||||
|
void btservice::connectToBluetooth(QBluetoothAddress addr, QBluetoothAddress controller)
|
||||||
|
{
|
||||||
|
// Update 07-12-22, with bluez update and krnbt, raspberry pi is behaving as expected. For this reason
|
||||||
|
// the RPI specific code has been commented out. The commented out code (and comments below this one)
|
||||||
|
// exist as legacy now - in case there's a scenario where someone cannot update to krnbt or newer bluez.
|
||||||
|
|
||||||
|
|
||||||
|
// The raspberry pi has a really tough time using bluetoothctl (or really anything) to connect to an Android phone
|
||||||
|
// even though phone connecting to the pi is fine.
|
||||||
|
// I found a workaround where you can make the pi attempt an rfcomm connection to the phone, and it connects immediately
|
||||||
|
// This might require setting u+s on rfcomm though
|
||||||
|
// Other computers with more sane bluetooth shouldn't have an issue using bluetoothctl
|
||||||
|
|
||||||
|
// Update 01-10-21, latest firmware/package updates seem to have made bluetoothctl more stable
|
||||||
|
// and it won't drop a connection anymore. Only issue, is that the connection will fail
|
||||||
|
// if the desired target hasn't been "seen" yet
|
||||||
|
// we can use hcitool to force the pi to recognize that we're trying to connect to a valid device.
|
||||||
|
// this causes the target device to be "seen"
|
||||||
|
// bluetoothctl can then connect as normal.
|
||||||
|
// Why don't we just use rfcomm (as we had previously on pis)? Because an rfcomm initiated connection doesn't connect HFP, which breaks the use of
|
||||||
|
// pi mic/speakers for android auto phone calls. bluetoothctl will connect all profiles.
|
||||||
|
|
||||||
|
#ifdef RPI
|
||||||
|
// QString program = QString::fromStdString("sudo hcitool cc ")+addr.toString();
|
||||||
|
// btConnectProcess = new QProcess();
|
||||||
|
// OPENAUTO_LOG(info)<<"[btservice] Attempting to connect to last bluetooth device, "<<addr.toString().toStdString()<<" using hcitool/bluetoothctl hybrid";
|
||||||
|
// btConnectProcess->start(program, QProcess::Unbuffered | QProcess::ReadWrite);
|
||||||
|
// btConnectProcess->waitForFinished();
|
||||||
|
#endif
|
||||||
|
btConnectProcess = new QProcess();
|
||||||
|
btConnectProcess->setProcessChannelMode(QProcess::SeparateChannels);
|
||||||
|
OPENAUTO_LOG(info)<<"[btservice] Attempting to connect to last bluetooth device, "<<addr.toString().toStdString()<<" with bluetoothctl";
|
||||||
|
btConnectProcess->start("bluetoothctl");
|
||||||
|
btConnectProcess->waitForStarted();
|
||||||
|
btConnectProcess->write(QString("select %1\n").arg(controller.toString()).toUtf8());
|
||||||
|
btConnectProcess->write(QString("connect %1\n").arg(addr.toString()).toUtf8());
|
||||||
|
btConnectProcess->closeWriteChannel();
|
||||||
|
btConnectProcess->waitForFinished();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
13
btservice_proto/CMakeLists.txt
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
include(FindProtobuf)
|
||||||
|
find_package(Protobuf REQUIRED)
|
||||||
|
include_directories(${PROTOBUF_INCLUDE_DIR})
|
||||||
|
|
||||||
|
file(GLOB_RECURSE proto_files ${CMAKE_CURRENT_SOURCE_DIR}/*.proto)
|
||||||
|
protobuf_generate_cpp(proto_sources proto_headers ${proto_files})
|
||||||
|
add_library(btservice_proto SHARED ${proto_headers} ${proto_sources})
|
||||||
|
target_link_libraries(btservice_proto ${PROTOBUF_LIBRARIES})
|
||||||
|
|
||||||
|
install(TARGETS btservice_proto DESTINATION lib)
|
||||||
|
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} DESTINATION include
|
||||||
|
FILES_MATCHING PATTERN *.h
|
||||||
|
PATTERN CMakeFiles EXCLUDE)
|
30
btservice_proto/NetworkInfo.proto
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
syntax = "proto2";
|
||||||
|
|
||||||
|
package openauto.btservice.proto;
|
||||||
|
|
||||||
|
enum SecurityMode {
|
||||||
|
UNKNOWN_SECURITY_MODE = 0;
|
||||||
|
OPEN = 1;
|
||||||
|
WEP_64 = 2;
|
||||||
|
WEP_128 = 3;
|
||||||
|
WPA_PERSONAL = 4;
|
||||||
|
WPA2_PERSONAL = 8;
|
||||||
|
WPA_WPA2_PERSONAL = 12;
|
||||||
|
WPA_ENTERPRISE = 20;
|
||||||
|
WPA2_ENTERPRISE = 24;
|
||||||
|
WPA_WPA2_ENTERPRISE = 28;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum AccessPointType {
|
||||||
|
STATIC = 0;
|
||||||
|
DYNAMIC = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message NetworkInfo
|
||||||
|
{
|
||||||
|
required string ssid = 1;
|
||||||
|
required string psk = 2;
|
||||||
|
required string mac_addr = 3;
|
||||||
|
required SecurityMode security_mode = 4;
|
||||||
|
required AccessPointType ap_type = 5;
|
||||||
|
}
|
9
btservice_proto/SocketInfoRequest.proto
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
syntax = "proto2";
|
||||||
|
|
||||||
|
package openauto.btservice.proto;
|
||||||
|
|
||||||
|
message SocketInfoRequest
|
||||||
|
{
|
||||||
|
required string ip_address = 1;
|
||||||
|
optional uint32 port = 2;
|
||||||
|
}
|
26
btservice_proto/SocketInfoResponse.proto
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
syntax = "proto2";
|
||||||
|
|
||||||
|
package openauto.btservice.proto;
|
||||||
|
|
||||||
|
enum Status {
|
||||||
|
STATUS_UNSOLICITED_MESSAGE = 1;
|
||||||
|
STATUS_SUCCESS = 0;
|
||||||
|
STATUS_NO_COMPATIBLE_VERSION = -1;
|
||||||
|
STATUS_WIFI_INACCESSIBLE_CHANNEL = -2;
|
||||||
|
STATUS_WIFI_INCORRECT_CREDENTIALS = -3;
|
||||||
|
STATUS_PROJECTION_ALREADY_STARTED = -4;
|
||||||
|
STATUS_WIFI_DISABLED = -5;
|
||||||
|
STATUS_WIFI_NOT_YET_STARTED = -6;
|
||||||
|
STATUS_INVALID_HOST = -7;
|
||||||
|
STATUS_NO_SUPPORTED_WIFI_CHANNELS = -8;
|
||||||
|
STATUS_INSTRUCT_USER_TO_CHECK_THE_PHONE = -9;
|
||||||
|
STATUS_PHONE_WIFI_DISABLED = -10;
|
||||||
|
STATUS_WIFI_NETWORK_UNAVAILABLE = -11;
|
||||||
|
}
|
||||||
|
|
||||||
|
message SocketInfoResponse
|
||||||
|
{
|
||||||
|
optional string ip_address = 1;
|
||||||
|
optional int32 port = 2;
|
||||||
|
required Status status = 3;
|
||||||
|
}
|
80
cmake_modules/FindGObject.cmake
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
# - Try to find GObject
|
||||||
|
# Once done this will define
|
||||||
|
#
|
||||||
|
# GOBJECT_FOUND - system has GObject
|
||||||
|
# GOBJECT_INCLUDE_DIR - the GObject include directory
|
||||||
|
# GOBJECT_LIBRARIES - the libraries needed to use GObject
|
||||||
|
# GOBJECT_DEFINITIONS - Compiler switches required for using GObject
|
||||||
|
|
||||||
|
# Copyright (c) 2006, Tim Beaulen <tbscope@gmail.com>
|
||||||
|
#
|
||||||
|
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||||
|
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||||
|
|
||||||
|
|
||||||
|
IF (GOBJECT_INCLUDE_DIR AND GOBJECT_LIBRARIES)
|
||||||
|
# in cache already
|
||||||
|
SET(GObject_FIND_QUIETLY TRUE)
|
||||||
|
ELSE (GOBJECT_INCLUDE_DIR AND GOBJECT_LIBRARIES)
|
||||||
|
SET(GObject_FIND_QUIETLY FALSE)
|
||||||
|
ENDIF (GOBJECT_INCLUDE_DIR AND GOBJECT_LIBRARIES)
|
||||||
|
|
||||||
|
IF (NOT WIN32)
|
||||||
|
# use pkg-config to get the directories and then use these values
|
||||||
|
# in the FIND_PATH() and FIND_LIBRARY() calls
|
||||||
|
FIND_PACKAGE(PkgConfig)
|
||||||
|
PKG_CHECK_MODULES(PC_GOBJECT gobject-2.0)
|
||||||
|
#MESSAGE(STATUS "DEBUG: GObject include directory = ${GOBJECT_INCLUDE_DIRS}")
|
||||||
|
#MESSAGE(STATUS "DEBUG: GObject link directory = ${GOBJECT_LIBRARY_DIRS}")
|
||||||
|
#MESSAGE(STATUS "DEBUG: GObject CFlags = ${GOBJECT_CFLAGS}")
|
||||||
|
SET(GOBJECT_DEFINITIONS ${PC_GOBJECT_CFLAGS_OTHER})
|
||||||
|
ENDIF (NOT WIN32)
|
||||||
|
|
||||||
|
FIND_PATH(GOBJECT_INCLUDE_DIR gobject.h
|
||||||
|
PATHS
|
||||||
|
${PC_GOBJECT_INCLUDEDIR}
|
||||||
|
${PC_GOBJECT_INCLUDE_DIRS}
|
||||||
|
PATH_SUFFIXES glib-2.0/gobject/
|
||||||
|
)
|
||||||
|
|
||||||
|
FIND_LIBRARY(_GObjectLibs NAMES gobject-2.0
|
||||||
|
PATHS
|
||||||
|
${PC_GOBJECT_LIBDIR}
|
||||||
|
${PC_GOBJECT_LIBRARY_DIRS}
|
||||||
|
)
|
||||||
|
FIND_LIBRARY(_GModuleLibs NAMES gmodule-2.0
|
||||||
|
PATHS
|
||||||
|
${PC_GOBJECT_LIBDIR}
|
||||||
|
${PC_GOBJECT_LIBRARY_DIRS}
|
||||||
|
)
|
||||||
|
FIND_LIBRARY(_GThreadLibs NAMES gthread-2.0
|
||||||
|
PATHS
|
||||||
|
${PC_GOBJECT_LIBDIR}
|
||||||
|
${PC_GOBJECT_LIBRARY_DIRS}
|
||||||
|
)
|
||||||
|
FIND_LIBRARY(_GLibs NAMES glib-2.0
|
||||||
|
PATHS
|
||||||
|
${PC_GOBJECT_LIBDIR}
|
||||||
|
${PC_GOBJECT_LIBRARY_DIRS}
|
||||||
|
)
|
||||||
|
|
||||||
|
SET( GOBJECT_LIBRARIES ${_GObjectLibs} ${_GModuleLibs} ${_GThreadLibs} ${_GLibs} )
|
||||||
|
|
||||||
|
IF (GOBJECT_INCLUDE_DIR AND GOBJECT_LIBRARIES)
|
||||||
|
SET(GOBJECT_FOUND TRUE)
|
||||||
|
ELSE (GOBJECT_INCLUDE_DIR AND GOBJECT_LIBRARIES)
|
||||||
|
SET(GOBJECT_FOUND FALSE)
|
||||||
|
ENDIF (GOBJECT_INCLUDE_DIR AND GOBJECT_LIBRARIES)
|
||||||
|
|
||||||
|
IF (GOBJECT_FOUND)
|
||||||
|
IF (NOT GObject_FIND_QUIETLY)
|
||||||
|
MESSAGE(STATUS "Found GObject libraries: ${GOBJECT_LIBRARIES}")
|
||||||
|
MESSAGE(STATUS "Found GObject includes : ${GOBJECT_INCLUDE_DIR}")
|
||||||
|
ENDIF (NOT GObject_FIND_QUIETLY)
|
||||||
|
ELSE (GOBJECT_FOUND)
|
||||||
|
IF (GObject_FIND_REQUIRED)
|
||||||
|
MESSAGE(STATUS "Could NOT find GObject")
|
||||||
|
ENDIF(GObject_FIND_REQUIRED)
|
||||||
|
ENDIF (GOBJECT_FOUND)
|
||||||
|
|
||||||
|
MARK_AS_ADVANCED(GOBJECT_INCLUDE_DIR _GObjectLibs _GModuleLibs _GThreadLibs _GLibs)
|
135
cmake_modules/FindGStreamer.cmake
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
# - Try to find GStreamer and its plugins
|
||||||
|
# Once done, this will define
|
||||||
|
#
|
||||||
|
# GSTREAMER_FOUND - system has GStreamer
|
||||||
|
# GSTREAMER_INCLUDE_DIRS - the GStreamer include directories
|
||||||
|
# GSTREAMER_LIBRARIES - link these to use GStreamer
|
||||||
|
#
|
||||||
|
# Additionally, gstreamer-base is always looked for and required, and
|
||||||
|
# the following related variables are defined:
|
||||||
|
#
|
||||||
|
# GSTREAMER_BASE_INCLUDE_DIRS - gstreamer-base's include directory
|
||||||
|
# GSTREAMER_BASE_LIBRARIES - link to these to use gstreamer-base
|
||||||
|
#
|
||||||
|
# Optionally, the COMPONENTS keyword can be passed to find_package()
|
||||||
|
# and GStreamer plugins can be looked for. Currently, the following
|
||||||
|
# plugins can be searched, and they define the following variables if
|
||||||
|
# found:
|
||||||
|
#
|
||||||
|
# gstreamer-app: GSTREAMER_APP_INCLUDE_DIRS and GSTREAMER_APP_LIBRARIES
|
||||||
|
# gstreamer-audio: GSTREAMER_AUDIO_INCLUDE_DIRS and GSTREAMER_AUDIO_LIBRARIES
|
||||||
|
# gstreamer-fft: GSTREAMER_FFT_INCLUDE_DIRS and GSTREAMER_FFT_LIBRARIES
|
||||||
|
# gstreamer-gl: GSTREAMER_GL_INCLUDE_DIRS and GSTREAMER_GL_LIBRARIES
|
||||||
|
# gstreamer-mpegts: GSTREAMER_MPEGTS_INCLUDE_DIRS and GSTREAMER_MPEGTS_LIBRARIES
|
||||||
|
# gstreamer-pbutils: GSTREAMER_PBUTILS_INCLUDE_DIRS and GSTREAMER_PBUTILS_LIBRARIES
|
||||||
|
# gstreamer-tag: GSTREAMER_TAG_INCLUDE_DIRS and GSTREAMER_TAG_LIBRARIES
|
||||||
|
# gstreamer-video: GSTREAMER_VIDEO_INCLUDE_DIRS and GSTREAMER_VIDEO_LIBRARIES
|
||||||
|
# gstreamer-codecparser:GSTREAMER_CODECPARSERS_INCLUDE_DIRS and GSTREAMER_CODECPARSERS_LIBRARIES
|
||||||
|
#
|
||||||
|
# Copyright (C) 2012 Raphael Kubo da Costa <rakuco@webkit.org>
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND ITS CONTRIBUTORS ``AS
|
||||||
|
# IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ITS
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
find_package(PkgConfig QUIET)
|
||||||
|
|
||||||
|
# Helper macro to find a GStreamer plugin (or GStreamer itself)
|
||||||
|
# _component_prefix is prepended to the _INCLUDE_DIRS and _LIBRARIES variables (eg. "GSTREAMER_AUDIO")
|
||||||
|
# _pkgconfig_name is the component's pkg-config name (eg. "gstreamer-1.0", or "gstreamer-video-1.0").
|
||||||
|
# _library is the component's library name (eg. "gstreamer-1.0" or "gstvideo-1.0")
|
||||||
|
macro(FIND_GSTREAMER_COMPONENT _component_prefix _pkgconfig_name _library)
|
||||||
|
|
||||||
|
string(REGEX MATCH "(.*)>=(.*)" _dummy "${_pkgconfig_name}")
|
||||||
|
if ("${CMAKE_MATCH_2}" STREQUAL "")
|
||||||
|
pkg_check_modules(PC_${_component_prefix} "${_pkgconfig_name} >= ${GStreamer_FIND_VERSION}")
|
||||||
|
else ()
|
||||||
|
pkg_check_modules(PC_${_component_prefix} ${_pkgconfig_name})
|
||||||
|
endif ()
|
||||||
|
set(${_component_prefix}_INCLUDE_DIRS ${PC_${_component_prefix}_INCLUDE_DIRS})
|
||||||
|
|
||||||
|
find_library(${_component_prefix}_LIBRARIES
|
||||||
|
NAMES ${_library}
|
||||||
|
HINTS ${PC_${_component_prefix}_LIBRARY_DIRS} ${PC_${_component_prefix}_LIBDIR}
|
||||||
|
)
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
# ------------------------
|
||||||
|
# 1. Find GStreamer itself
|
||||||
|
# ------------------------
|
||||||
|
|
||||||
|
# 1.1. Find headers and libraries
|
||||||
|
FIND_GSTREAMER_COMPONENT(GSTREAMER gstreamer-1.0 gstreamer-1.0)
|
||||||
|
FIND_GSTREAMER_COMPONENT(GSTREAMER_BASE gstreamer-base-1.0 gstbase-1.0)
|
||||||
|
|
||||||
|
# -------------------------
|
||||||
|
# 2. Find GStreamer plugins
|
||||||
|
# -------------------------
|
||||||
|
|
||||||
|
FIND_GSTREAMER_COMPONENT(GSTREAMER_APP gstreamer-app-1.0 gstapp-1.0)
|
||||||
|
FIND_GSTREAMER_COMPONENT(GSTREAMER_AUDIO gstreamer-audio-1.0 gstaudio-1.0)
|
||||||
|
FIND_GSTREAMER_COMPONENT(GSTREAMER_FFT gstreamer-fft-1.0 gstfft-1.0)
|
||||||
|
FIND_GSTREAMER_COMPONENT(GSTREAMER_GL gstreamer-gl-1.0 gstgl-1.0)
|
||||||
|
FIND_GSTREAMER_COMPONENT(GSTREAMER_MPEGTS gstreamer-mpegts-1.0>=1.4.0 gstmpegts-1.0)
|
||||||
|
FIND_GSTREAMER_COMPONENT(GSTREAMER_PBUTILS gstreamer-pbutils-1.0 gstpbutils-1.0)
|
||||||
|
FIND_GSTREAMER_COMPONENT(GSTREAMER_TAG gstreamer-tag-1.0 gsttag-1.0)
|
||||||
|
FIND_GSTREAMER_COMPONENT(GSTREAMER_VIDEO gstreamer-video-1.0 gstvideo-1.0)
|
||||||
|
FIND_GSTREAMER_COMPONENT(GSTREAMER_CODECPARSERS gstreamer-codecparsers-1.0 gstcodecparsers-1.0)
|
||||||
|
|
||||||
|
# ------------------------------------------------
|
||||||
|
# 3. Process the COMPONENTS passed to FIND_PACKAGE
|
||||||
|
# ------------------------------------------------
|
||||||
|
set(_GSTREAMER_REQUIRED_VARS GSTREAMER_INCLUDE_DIRS GSTREAMER_LIBRARIES GSTREAMER_VERSION GSTREAMER_BASE_INCLUDE_DIRS GSTREAMER_BASE_LIBRARIES)
|
||||||
|
|
||||||
|
foreach (_component ${GStreamer_FIND_COMPONENTS})
|
||||||
|
set(_gst_component "GSTREAMER_${_component}")
|
||||||
|
string(TOUPPER ${_gst_component} _UPPER_NAME)
|
||||||
|
|
||||||
|
list(APPEND _GSTREAMER_REQUIRED_VARS ${_UPPER_NAME}_INCLUDE_DIRS ${_UPPER_NAME}_LIBRARIES)
|
||||||
|
endforeach ()
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GStreamer REQUIRED_VARS _GSTREAMER_REQUIRED_VARS
|
||||||
|
VERSION_VAR GSTREAMER_VERSION)
|
||||||
|
|
||||||
|
mark_as_advanced(
|
||||||
|
GSTREAMER_APP_INCLUDE_DIRS
|
||||||
|
GSTREAMER_APP_LIBRARIES
|
||||||
|
GSTREAMER_AUDIO_INCLUDE_DIRS
|
||||||
|
GSTREAMER_AUDIO_LIBRARIES
|
||||||
|
GSTREAMER_BASE_INCLUDE_DIRS
|
||||||
|
GSTREAMER_BASE_LIBRARIES
|
||||||
|
GSTREAMER_FFT_INCLUDE_DIRS
|
||||||
|
GSTREAMER_FFT_LIBRARIES
|
||||||
|
GSTREAMER_GL_INCLUDE_DIRS
|
||||||
|
GSTREAMER_GL_LIBRARIES
|
||||||
|
GSTREAMER_INCLUDE_DIRS
|
||||||
|
GSTREAMER_LIBRARIES
|
||||||
|
GSTREAMER_MPEGTS_INCLUDE_DIRS
|
||||||
|
GSTREAMER_MPEGTS_LIBRARIES
|
||||||
|
GSTREAMER_PBUTILS_INCLUDE_DIRS
|
||||||
|
GSTREAMER_PBUTILS_LIBRARIES
|
||||||
|
GSTREAMER_TAG_INCLUDE_DIRS
|
||||||
|
GSTREAMER_TAG_LIBRARIES
|
||||||
|
GSTREAMER_VIDEO_INCLUDE_DIRS
|
||||||
|
GSTREAMER_VIDEO_LIBRARIES
|
||||||
|
GSTREAMER_CODECPARSERS_INCLUDE_DIRS
|
||||||
|
GSTREAMER_CODECPARSERS_LIBRARIES
|
||||||
|
)
|
45
cmake_modules/Findaasdk.cmake
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
set (AASDK_DIR ~/aasdk)
|
||||||
|
|
||||||
|
find_path(AASDK_INCLUDE_DIR
|
||||||
|
aasdk/Version.hpp
|
||||||
|
PATHS ${AASDK_DIR}
|
||||||
|
PATH_SUFFIXES include
|
||||||
|
)
|
||||||
|
|
||||||
|
find_path(AASDK_PROTO_INCLUDE_DIR
|
||||||
|
aasdk_proto/AbsoluteInputEventData.pb.h
|
||||||
|
PATHS ${AASDK_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
find_path(AASDK_LIB_DIR
|
||||||
|
libaasdk.so
|
||||||
|
PATHS ${AASDK_DIR}
|
||||||
|
PATH_SUFFIXES lib
|
||||||
|
)
|
||||||
|
|
||||||
|
if (AASDK_INCLUDE_DIR AND AASDK_PROTO_INCLUDE_DIR AND AASDK_LIB_DIR)
|
||||||
|
set(AASDK_FOUND TRUE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (AASDK_FOUND)
|
||||||
|
if (NOT aasdk_FIND_QUIETLY)
|
||||||
|
message(STATUS "Found aasdk:")
|
||||||
|
message(STATUS " - Includes: ${AASDK_INCLUDE_DIR}")
|
||||||
|
message(STATUS " - Includes: ${AASDK_PROTO_INCLUDE_DIR}")
|
||||||
|
message(STATUS " - Libraries: ${AASDK_LIB_DIR}")
|
||||||
|
endif()
|
||||||
|
add_library(aasdk INTERFACE)
|
||||||
|
target_include_directories(aasdk INTERFACE ${AASDK_INCLUDE_DIR} ${AASDK_PROTO_INCLUDE_DIR})
|
||||||
|
set_target_properties(aasdk PROPERTIES INTERFACE_LINK_DIRECTORIES ${AASDK_LIB_DIR})
|
||||||
|
target_link_libraries(aasdk INTERFACE libaasdk.so libaasdk_proto.so)
|
||||||
|
else()
|
||||||
|
if (aasdk_FIND_REQUIRED)
|
||||||
|
if(AASDK_INCLUDE_DIR AND NOT AASDK_PROTO_INCLUDE_DIR)
|
||||||
|
message(FATAL_ERROR "aasdk was found but not built. Perform an in-source build.")
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "Could not find aasdk")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
mark_as_advanced(AASDK_INCLUDE_DIRS AASDK_LIBRARIES)
|
26
cmake_modules/Findh264.cmake
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
set (H264_INCLUDE_DIR /usr/local/include/h264bitstream)
|
||||||
|
set (H264_LIB_DIR /usr/local/lib)
|
||||||
|
|
||||||
|
set(H264_FOUND TRUE)
|
||||||
|
|
||||||
|
if (H264_FOUND)
|
||||||
|
if (NOT h264_FIND_QUIETLY)
|
||||||
|
message(STATUS "Found h264bitstream:")
|
||||||
|
message(STATUS " - Includes: ${H264_INCLUDE_DIR}")
|
||||||
|
message(STATUS " - Libraries: ${H264_LIB_DIR}")
|
||||||
|
endif()
|
||||||
|
add_library(h264 INTERFACE)
|
||||||
|
target_include_directories(h264 INTERFACE ${H264_INCLUDE_DIR})
|
||||||
|
set_target_properties(h264 PROPERTIES INTERFACE_LINK_DIRECTORIES ${H264_LIB_DIR})
|
||||||
|
target_link_libraries(h264 INTERFACE libh264bitstream.so)
|
||||||
|
else()
|
||||||
|
if (h264_FIND_REQUIRED)
|
||||||
|
if(H264_INCLUDE_DIR)
|
||||||
|
message(FATAL_ERROR "h264 was found but not built. Perform an in-source build.")
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "Could not find h264")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
mark_as_advanced(H264_INCLUDE_DIR H264_LIBRARIES)
|
67
cmake_modules/Findlibomx.cmake
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
set (OMX_DIR /opt/vc/)
|
||||||
|
|
||||||
|
find_path(BCM_HOST_INCLUDE_DIR
|
||||||
|
bcm_host.h
|
||||||
|
PATHS
|
||||||
|
${OMX_DIR}
|
||||||
|
PATH_SUFFIXES
|
||||||
|
include
|
||||||
|
)
|
||||||
|
|
||||||
|
find_path(BCM_HOST_LIB_DIR
|
||||||
|
libbcm_host.so
|
||||||
|
PATHS
|
||||||
|
${OMX_DIR}
|
||||||
|
PATH_SUFFIXES
|
||||||
|
lib
|
||||||
|
)
|
||||||
|
|
||||||
|
find_path(ILCLIENT_INCLUDE_DIR
|
||||||
|
ilclient.h
|
||||||
|
PATHS
|
||||||
|
${OMX_DIR}
|
||||||
|
PATH_SUFFIXES
|
||||||
|
src/hello_pi/libs/ilclient
|
||||||
|
)
|
||||||
|
|
||||||
|
find_path(ILCLIENT_LIB_DIR
|
||||||
|
libilclient.a
|
||||||
|
PATHS
|
||||||
|
${OMX_DIR}
|
||||||
|
PATH_SUFFIXES
|
||||||
|
src/hello_pi/libs/ilclient
|
||||||
|
)
|
||||||
|
|
||||||
|
if (BCM_HOST_INCLUDE_DIR AND ILCLIENT_INCLUDE_DIR AND BCM_HOST_LIB_DIR AND ILCLIENT_LIB_DIR)
|
||||||
|
set(libomx_FOUND TRUE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (libomx_FOUND)
|
||||||
|
if (NOT libomx_FIND_QUIETLY)
|
||||||
|
message(STATUS "Found omx:")
|
||||||
|
message(STATUS " - Bcm Host: ${BCM_HOST_INCLUDE_DIR}")
|
||||||
|
message(STATUS " - ilclient: ${ILCLIENT_INCLUDE_DIR}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_library(omx INTERFACE)
|
||||||
|
|
||||||
|
target_include_directories(omx SYSTEM INTERFACE
|
||||||
|
${BCM_HOST_INCLUDE_DIR}
|
||||||
|
${ILCLIENT_INCLUDE_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(omx INTERFACE
|
||||||
|
${BCM_HOST_LIB_DIR}/libbcm_host.so
|
||||||
|
${ILCLIENT_LIB_DIR}/libilclient.a
|
||||||
|
${BCM_HOST_LIB_DIR}/libvcos.so
|
||||||
|
${BCM_HOST_LIB_DIR}/libvcilcs.a
|
||||||
|
${BCM_HOST_LIB_DIR}/libvchiq_arm.so
|
||||||
|
)
|
||||||
|
|
||||||
|
target_compile_definitions(omx INTERFACE
|
||||||
|
-DUSE_OMX
|
||||||
|
-DOMX_SKIP64BIT
|
||||||
|
-DRASPBERRYPI3
|
||||||
|
)
|
||||||
|
|
||||||
|
endif()
|
@ -49,14 +49,14 @@ if (LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS)
|
|||||||
else (LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS)
|
else (LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS)
|
||||||
find_path(LIBUSB_1_INCLUDE_DIR
|
find_path(LIBUSB_1_INCLUDE_DIR
|
||||||
NAMES
|
NAMES
|
||||||
libusb.h
|
libusb.h
|
||||||
PATHS
|
PATHS
|
||||||
/usr/include
|
/usr/include
|
||||||
/usr/local/include
|
/usr/local/include
|
||||||
/opt/local/include
|
/opt/local/include
|
||||||
/sw/include
|
/sw/include
|
||||||
PATH_SUFFIXES
|
PATH_SUFFIXES
|
||||||
libusb-1.0
|
libusb-1.0
|
||||||
)
|
)
|
||||||
|
|
||||||
find_library(LIBUSB_1_LIBRARY
|
find_library(LIBUSB_1_LIBRARY
|
||||||
@ -83,8 +83,11 @@ else (LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS)
|
|||||||
if (LIBUSB_1_FOUND)
|
if (LIBUSB_1_FOUND)
|
||||||
if (NOT libusb_1_FIND_QUIETLY)
|
if (NOT libusb_1_FIND_QUIETLY)
|
||||||
message(STATUS "Found libusb-1.0:")
|
message(STATUS "Found libusb-1.0:")
|
||||||
message(STATUS " - Includes: ${LIBUSB_1_INCLUDE_DIRS}")
|
message(STATUS " - Includes: ${LIBUSB_1_INCLUDE_DIRS}")
|
||||||
message(STATUS " - Libraries: ${LIBUSB_1_LIBRARIES}")
|
message(STATUS " - Libraries: ${LIBUSB_1_LIBRARIES}")
|
||||||
|
add_library(libusb INTERFACE)
|
||||||
|
target_include_directories(libusb SYSTEM INTERFACE ${LIBUSB_1_INCLUDE_DIR})
|
||||||
|
target_link_libraries(libusb INTERFACE ${LIBUSB_1_LIBRARY})
|
||||||
endif (NOT libusb_1_FIND_QUIETLY)
|
endif (NOT libusb_1_FIND_QUIETLY)
|
||||||
else (LIBUSB_1_FOUND)
|
else (LIBUSB_1_FOUND)
|
||||||
if (libusb_1_FIND_REQUIRED)
|
if (libusb_1_FIND_REQUIRED)
|
||||||
|
@ -28,8 +28,8 @@ else (RTAUDIO_LIBRARIES AND RTAUDIO_INCLUDE_DIRS)
|
|||||||
/usr/local/include
|
/usr/local/include
|
||||||
/opt/local/include
|
/opt/local/include
|
||||||
/sw/include
|
/sw/include
|
||||||
PATH_SUFFIXES
|
PATH_SUFFIXES
|
||||||
rtaudio
|
rtaudio
|
||||||
)
|
)
|
||||||
|
|
||||||
find_library(RTAUDIO_LIBRARY
|
find_library(RTAUDIO_LIBRARY
|
||||||
|
15
cmake_modules/functions.cmake
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
|
||||||
|
function( findRpiRevision OUTPUT )
|
||||||
|
# Find it with an automated script
|
||||||
|
execute_process( COMMAND grep -Po "^Revision\\s*:\\s*\\K[[:xdigit:]]+" /proc/cpuinfo OUTPUT_VARIABLE TMP OUTPUT_STRIP_TRAILING_WHITESPACE )
|
||||||
|
|
||||||
|
# If have not found the Revision number, use the last version
|
||||||
|
if ( TMP )
|
||||||
|
message( "-- Detecting Raspberry Pi Revision Number: ${TMP}" )
|
||||||
|
else()
|
||||||
|
set( TMP "0006" )
|
||||||
|
message( WARNING "-- Could NOT find Raspberry Pi revision!" )
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set( ${OUTPUT} "${TMP}" PARENT_SCOPE )
|
||||||
|
endfunction()
|
51
cmake_modules/gitversion.cmake
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
# cmake/gitversion.cmake
|
||||||
|
cmake_minimum_required(VERSION 3.0.0)
|
||||||
|
|
||||||
|
message(STATUS "Resolving GIT Version")
|
||||||
|
|
||||||
|
set(_build_version "unknown")
|
||||||
|
set(_commit_timestamp "unknown")
|
||||||
|
|
||||||
|
find_package(Git)
|
||||||
|
if(GIT_FOUND)
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
|
||||||
|
WORKING_DIRECTORY "${local_dir}"
|
||||||
|
OUTPUT_VARIABLE _build_version
|
||||||
|
ERROR_QUIET
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
|
||||||
|
WORKING_DIRECTORY "${local_dir}"
|
||||||
|
OUTPUT_VARIABLE _build_branch
|
||||||
|
ERROR_QUIET
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${GIT_EXECUTABLE} log -1 --format=%at
|
||||||
|
WORKING_DIRECTORY "${local_dir}"
|
||||||
|
OUTPUT_VARIABLE _commit_timestamp
|
||||||
|
ERROR_QUIET
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
message( STATUS "GIT hash: ${_build_version}; branch: ${_build_branch}; Commit epoch: ${_commit_timestamp};")
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${GIT_EXECUTABLE} diff --no-ext-diff --quiet
|
||||||
|
WORKING_DIRECTORY "${local_dir}"
|
||||||
|
RESULT_VARIABLE ret
|
||||||
|
)
|
||||||
|
if(ret EQUAL "1")
|
||||||
|
set(_build_changes "*")
|
||||||
|
else()
|
||||||
|
set(_build_changes "")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
else()
|
||||||
|
message(STATUS "GIT not found")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# branch name
|
||||||
|
# git rev-parse --abbrev-ref HEAD
|
||||||
|
# changed
|
||||||
|
# git diff --no-ext-diff --quiet
|
@ -2,18 +2,14 @@
|
|||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QStringListModel>
|
#include <QStringListModel>
|
||||||
#include <f1x/aasdk/TCP/ITCPEndpoint.hpp>
|
#include "aasdk/TCP/ITCPEndpoint.hpp"
|
||||||
#include <f1x/aasdk/TCP/ITCPWrapper.hpp>
|
#include "aasdk/TCP/ITCPWrapper.hpp"
|
||||||
#include <f1x/openauto/autoapp/Configuration/IRecentAddressesList.hpp>
|
#include "openauto/Configuration/IRecentAddressesList.hpp"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class ConnectDialog;
|
class ConnectDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
|
||||||
{
|
|
||||||
namespace autoapp
|
namespace autoapp
|
||||||
{
|
{
|
||||||
namespace ui
|
namespace ui
|
||||||
@ -24,8 +20,9 @@ class ConnectDialog : public QDialog
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ConnectDialog(boost::asio::io_service& ioService, aasdk::tcp::ITCPWrapper& tcpWrapper, openauto::autoapp::configuration::IRecentAddressesList& recentAddressesList, QWidget *parent = nullptr);
|
explicit ConnectDialog(boost::asio::io_service& ioService, aasdk::tcp::ITCPWrapper& tcpWrapper, openauto::configuration::IRecentAddressesList& recentAddressesList, QWidget *parent = nullptr);
|
||||||
~ConnectDialog() override;
|
~ConnectDialog() override;
|
||||||
|
void connectToAddress(const QString& ip);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void connectToDevice(const QString& ipAddress);
|
void connectToDevice(const QString& ipAddress);
|
||||||
@ -46,12 +43,10 @@ private:
|
|||||||
|
|
||||||
boost::asio::io_service& ioService_;
|
boost::asio::io_service& ioService_;
|
||||||
aasdk::tcp::ITCPWrapper& tcpWrapper_;
|
aasdk::tcp::ITCPWrapper& tcpWrapper_;
|
||||||
openauto::autoapp::configuration::IRecentAddressesList& recentAddressesList_;
|
openauto::configuration::IRecentAddressesList& recentAddressesList_;
|
||||||
Ui::ConnectDialog *ui_;
|
Ui::ConnectDialog *ui_;
|
||||||
QStringListModel recentAddressesModel_;
|
QStringListModel recentAddressesModel_;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
@ -23,36 +23,32 @@
|
|||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
{
|
{
|
||||||
class MainWindow;
|
class MainWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
|
||||||
{
|
|
||||||
namespace autoapp
|
namespace autoapp
|
||||||
{
|
{
|
||||||
namespace ui
|
namespace ui
|
||||||
{
|
{
|
||||||
|
|
||||||
class MainWindow : public QMainWindow
|
class MainWindow : public QMainWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit MainWindow(QWidget *parent = nullptr);
|
explicit MainWindow(QWidget *parent = nullptr);
|
||||||
~MainWindow() override;
|
~MainWindow() override;
|
||||||
|
void handleIncomingMessage(const QJsonObject &rootObj);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void exit();
|
void exit();
|
||||||
void openSettings();
|
void openSettings();
|
||||||
void toggleCursor();
|
void toggleCursor();
|
||||||
void openConnectDialog();
|
void openConnectDialog();
|
||||||
|
|
||||||
private:
|
private slots:
|
||||||
Ui::MainWindow* ui_;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
private:
|
||||||
}
|
Ui::MainWindow *ui_;
|
||||||
}
|
};
|
||||||
|
}
|
||||||
}
|
}
|
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
|
#include "openauto/Configuration/IConfiguration.hpp"
|
||||||
|
|
||||||
class QCheckBox;
|
class QCheckBox;
|
||||||
|
|
||||||
@ -29,10 +29,6 @@ namespace Ui
|
|||||||
class SettingsWindow;
|
class SettingsWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
|
||||||
{
|
|
||||||
namespace autoapp
|
namespace autoapp
|
||||||
{
|
{
|
||||||
namespace ui
|
namespace ui
|
||||||
@ -42,7 +38,7 @@ class SettingsWindow : public QWidget
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit SettingsWindow(configuration::IConfiguration::Pointer configuration, QWidget *parent = nullptr);
|
explicit SettingsWindow(openauto::configuration::IConfiguration::Pointer configuration, QWidget *parent = nullptr);
|
||||||
~SettingsWindow() override;
|
~SettingsWindow() override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
@ -56,14 +52,12 @@ private:
|
|||||||
void load();
|
void load();
|
||||||
void loadButtonCheckBoxes();
|
void loadButtonCheckBoxes();
|
||||||
void saveButtonCheckBoxes();
|
void saveButtonCheckBoxes();
|
||||||
void saveButtonCheckBox(const QCheckBox* checkBox, configuration::IConfiguration::ButtonCodes& buttonCodes, aasdk::proto::enums::ButtonCode::Enum buttonCode);
|
void saveButtonCheckBox(const QCheckBox* checkBox, openauto::configuration::IConfiguration::ButtonCodes& buttonCodes, aasdk::proto::enums::ButtonCode::Enum buttonCode);
|
||||||
void setButtonCheckBoxes(bool value);
|
void setButtonCheckBoxes(bool value);
|
||||||
|
|
||||||
Ui::SettingsWindow* ui_;
|
Ui::SettingsWindow* ui_;
|
||||||
configuration::IConfiguration::Pointer configuration_;
|
openauto::configuration::IConfiguration::Pointer configuration_;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
49
include/btservice/AndroidBluetoothServer.hpp
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <atomic>
|
||||||
|
#include <memory>
|
||||||
|
#include <sstream>
|
||||||
|
#include <QBluetoothServer>
|
||||||
|
#include <QBluetoothLocalDevice>
|
||||||
|
#include <QDataStream>
|
||||||
|
#include <btservice_proto/NetworkInfo.pb.h>
|
||||||
|
#include <btservice_proto/SocketInfoRequest.pb.h>
|
||||||
|
#include <btservice_proto/SocketInfoResponse.pb.h>
|
||||||
|
#include "openauto/Configuration/Configuration.hpp"
|
||||||
|
#include "IAndroidBluetoothServer.hpp"
|
||||||
|
|
||||||
|
namespace openauto
|
||||||
|
{
|
||||||
|
namespace btservice
|
||||||
|
{
|
||||||
|
|
||||||
|
class AndroidBluetoothServer: public QObject, public IAndroidBluetoothServer
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
AndroidBluetoothServer(openauto::configuration::IConfiguration::Pointer config);
|
||||||
|
bool start(const QBluetoothAddress& address, uint16_t portNumber) override;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onClientConnected();
|
||||||
|
void readSocket();
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::unique_ptr<QBluetoothServer> rfcommServer_;
|
||||||
|
QBluetoothSocket* socket_;
|
||||||
|
openauto::configuration::IConfiguration::Pointer config_;
|
||||||
|
|
||||||
|
void handleUnknownMessage(int messageType, QByteArray data);
|
||||||
|
void handleSocketInfoRequest(QByteArray data);
|
||||||
|
void handleSocketInfoRequestResponse(QByteArray data);
|
||||||
|
void writeSocketInfoRequest();
|
||||||
|
void writeSocketInfoResponse();
|
||||||
|
void writeNetworkInfoMessage();
|
||||||
|
bool writeProtoMessage(uint16_t messageType, google::protobuf::Message& message);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -19,10 +19,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QBluetoothServiceInfo>
|
#include <QBluetoothServiceInfo>
|
||||||
#include <f1x/openauto/btservice/IAndroidBluetoothService.hpp>
|
#include "IAndroidBluetoothService.hpp"
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace btservice
|
namespace btservice
|
||||||
@ -42,4 +40,3 @@ private:
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
@ -20,8 +20,6 @@
|
|||||||
|
|
||||||
#include <QBluetoothAddress>
|
#include <QBluetoothAddress>
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace btservice
|
namespace btservice
|
||||||
@ -37,4 +35,3 @@ public:
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
@ -20,8 +20,6 @@
|
|||||||
|
|
||||||
#include <QBluetoothAddress>
|
#include <QBluetoothAddress>
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace btservice
|
namespace btservice
|
||||||
@ -38,4 +36,3 @@ public:
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
29
include/btservice/btservice.hpp
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QProcess>
|
||||||
|
#include <QBluetoothAddress>
|
||||||
|
#include "OpenautoLog.hpp"
|
||||||
|
#include "btservice/AndroidBluetoothService.hpp"
|
||||||
|
#include "btservice/AndroidBluetoothServer.hpp"
|
||||||
|
#include "openauto/Configuration/Configuration.hpp"
|
||||||
|
|
||||||
|
namespace openauto
|
||||||
|
{
|
||||||
|
namespace btservice
|
||||||
|
{
|
||||||
|
|
||||||
|
class btservice
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
btservice(openauto::configuration::IConfiguration::Pointer config);
|
||||||
|
|
||||||
|
private:
|
||||||
|
const uint16_t cServicePortNumber = 22;
|
||||||
|
void connectToBluetooth(QBluetoothAddress addr, QBluetoothAddress controller);
|
||||||
|
openauto::btservice::AndroidBluetoothService androidBluetoothService_;
|
||||||
|
openauto::btservice::AndroidBluetoothServer androidBluetoothServer_;
|
||||||
|
QProcess *btConnectProcess;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -1,52 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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
|
|
||||||
|
|
||||||
#include <f1x/openauto/autoapp/Service/IServiceFactory.hpp>
|
|
||||||
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
|
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
|
||||||
{
|
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace service
|
|
||||||
{
|
|
||||||
|
|
||||||
class ServiceFactory: public IServiceFactory
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ServiceFactory(boost::asio::io_service& ioService, configuration::IConfiguration::Pointer configuration);
|
|
||||||
ServiceList create(aasdk::messenger::IMessenger::Pointer messenger) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
IService::Pointer createVideoService(aasdk::messenger::IMessenger::Pointer messenger);
|
|
||||||
IService::Pointer createBluetoothService(aasdk::messenger::IMessenger::Pointer messenger);
|
|
||||||
IService::Pointer createInputService(aasdk::messenger::IMessenger::Pointer messenger);
|
|
||||||
void createAudioServices(ServiceList& serviceList, aasdk::messenger::IMessenger::Pointer messenger);
|
|
||||||
|
|
||||||
boost::asio::io_service& ioService_;
|
|
||||||
configuration::IConfiguration::Pointer configuration_;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,51 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <memory>
|
|
||||||
#include <QBluetoothServer>
|
|
||||||
#include <f1x/openauto/btservice/IAndroidBluetoothServer.hpp>
|
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
|
||||||
{
|
|
||||||
namespace btservice
|
|
||||||
{
|
|
||||||
|
|
||||||
class AndroidBluetoothServer: public QObject, public IAndroidBluetoothServer
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
AndroidBluetoothServer();
|
|
||||||
|
|
||||||
bool start(const QBluetoothAddress& address, uint16_t portNumber) override;
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void onClientConnected();
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::unique_ptr<QBluetoothServer> rfcommServer_;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -18,30 +18,26 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <f1x/aasdk/USB/IUSBHub.hpp>
|
#include "aasdk/USB/IUSBHub.hpp"
|
||||||
#include <f1x/aasdk/USB/IConnectedAccessoriesEnumerator.hpp>
|
#include "aasdk/USB/IConnectedAccessoriesEnumerator.hpp"
|
||||||
#include <f1x/aasdk/USB/USBWrapper.hpp>
|
#include "aasdk/USB/USBWrapper.hpp"
|
||||||
#include <f1x/aasdk/TCP/ITCPWrapper.hpp>
|
#include "aasdk/TCP/ITCPWrapper.hpp"
|
||||||
#include <f1x/aasdk/TCP/ITCPEndpoint.hpp>
|
#include "aasdk/TCP/ITCPEndpoint.hpp"
|
||||||
#include <f1x/openauto/autoapp/Service/IAndroidAutoEntityEventHandler.hpp>
|
#include "openauto/Service/IAndroidAutoEntityEventHandler.hpp"
|
||||||
#include <f1x/openauto/autoapp/Service/IAndroidAutoEntityFactory.hpp>
|
#include "openauto/Service/IAndroidAutoEntityFactory.hpp"
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
|
|
||||||
class App: public service::IAndroidAutoEntityEventHandler, public std::enable_shared_from_this<App>
|
class App: public openauto::service::IAndroidAutoEntityEventHandler, public std::enable_shared_from_this<App>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef std::shared_ptr<App> Pointer;
|
typedef std::shared_ptr<App> Pointer;
|
||||||
|
|
||||||
App(boost::asio::io_service& ioService, aasdk::usb::USBWrapper& usbWrapper, aasdk::tcp::ITCPWrapper& tcpWrapper, service::IAndroidAutoEntityFactory& androidAutoEntityFactory,
|
App(boost::asio::io_service& ioService, aasdk::usb::USBWrapper& usbWrapper, aasdk::tcp::ITCPWrapper& tcpWrapper, openauto::service::IAndroidAutoEntityFactory& androidAutoEntityFactory,
|
||||||
aasdk::usb::IUSBHub::Pointer usbHub, aasdk::usb::IConnectedAccessoriesEnumerator::Pointer connectedAccessoriesEnumerator);
|
aasdk::usb::IUSBHub::Pointer usbHub, aasdk::usb::IConnectedAccessoriesEnumerator::Pointer connectedAccessoriesEnumerator);
|
||||||
|
|
||||||
void waitForUSBDevice();
|
void waitForDevice(bool enumerate = false);
|
||||||
void start(aasdk::tcp::ITCPEndpoint::SocketPointer socket);
|
void start(aasdk::tcp::ITCPEndpoint::SocketPointer socket);
|
||||||
void stop();
|
void stop();
|
||||||
void onAndroidAutoQuit() override;
|
void onAndroidAutoQuit() override;
|
||||||
@ -49,7 +45,8 @@ public:
|
|||||||
private:
|
private:
|
||||||
using std::enable_shared_from_this<App>::shared_from_this;
|
using std::enable_shared_from_this<App>::shared_from_this;
|
||||||
void enumerateDevices();
|
void enumerateDevices();
|
||||||
void waitForDevice();
|
void waitForUSBDevice();
|
||||||
|
void waitForWirelessDevice();
|
||||||
void aoapDeviceHandler(aasdk::usb::DeviceHandle deviceHandle);
|
void aoapDeviceHandler(aasdk::usb::DeviceHandle deviceHandle);
|
||||||
void onUSBHubError(const aasdk::error::Error& error);
|
void onUSBHubError(const aasdk::error::Error& error);
|
||||||
|
|
||||||
@ -57,13 +54,12 @@ private:
|
|||||||
aasdk::usb::USBWrapper& usbWrapper_;
|
aasdk::usb::USBWrapper& usbWrapper_;
|
||||||
aasdk::tcp::ITCPWrapper& tcpWrapper_;
|
aasdk::tcp::ITCPWrapper& tcpWrapper_;
|
||||||
boost::asio::io_service::strand strand_;
|
boost::asio::io_service::strand strand_;
|
||||||
service::IAndroidAutoEntityFactory& androidAutoEntityFactory_;
|
openauto::service::IAndroidAutoEntityFactory& androidAutoEntityFactory_;
|
||||||
aasdk::usb::IUSBHub::Pointer usbHub_;
|
aasdk::usb::IUSBHub::Pointer usbHub_;
|
||||||
|
boost::asio::ip::tcp::acceptor acceptor_;
|
||||||
aasdk::usb::IConnectedAccessoriesEnumerator::Pointer connectedAccessoriesEnumerator_;
|
aasdk::usb::IConnectedAccessoriesEnumerator::Pointer connectedAccessoriesEnumerator_;
|
||||||
service::IAndroidAutoEntity::Pointer androidAutoEntity_;
|
openauto::service::IAndroidAutoEntity::Pointer androidAutoEntity_;
|
||||||
bool isStopped_;
|
bool isStopped_;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
@ -18,12 +18,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace configuration
|
namespace configuration
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -35,5 +31,3 @@ enum class AudioOutputBackendType
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
@ -18,12 +18,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace configuration
|
namespace configuration
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -36,5 +32,3 @@ enum class BluetoothAdapterType
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
@ -19,14 +19,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <boost/property_tree/ini_parser.hpp>
|
#include <boost/property_tree/ini_parser.hpp>
|
||||||
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
|
#include "IConfiguration.hpp"
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace configuration
|
namespace configuration
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -54,6 +50,8 @@ public:
|
|||||||
int32_t getOMXLayerIndex() const override;
|
int32_t getOMXLayerIndex() const override;
|
||||||
void setVideoMargins(QRect value) override;
|
void setVideoMargins(QRect value) override;
|
||||||
QRect getVideoMargins() const override;
|
QRect getVideoMargins() const override;
|
||||||
|
void setWhitescreenWorkaround(bool value) override;
|
||||||
|
bool getWhitescreenWorkaround() const override;
|
||||||
|
|
||||||
bool getTouchscreenEnabled() const override;
|
bool getTouchscreenEnabled() const override;
|
||||||
void setTouchscreenEnabled(bool value) override;
|
void setTouchscreenEnabled(bool value) override;
|
||||||
@ -72,6 +70,17 @@ public:
|
|||||||
AudioOutputBackendType getAudioOutputBackendType() const override;
|
AudioOutputBackendType getAudioOutputBackendType() const override;
|
||||||
void setAudioOutputBackendType(AudioOutputBackendType value) override;
|
void setAudioOutputBackendType(AudioOutputBackendType value) override;
|
||||||
|
|
||||||
|
std::string getWifiSSID() override;
|
||||||
|
void setWifiSSID(std::string value) override;
|
||||||
|
std::string getWifiPassword() override;
|
||||||
|
void setWifiPassword(std::string value) override;
|
||||||
|
std::string getWifiMAC() override;
|
||||||
|
void setWifiMAC(std::string value) override;
|
||||||
|
bool getAutoconnectBluetooth() override;
|
||||||
|
void setAutoconnectBluetooth(bool value) override;
|
||||||
|
std::string getLastBluetoothPair() override;
|
||||||
|
void setLastBluetoothPair(std::string value) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void readButtonCodes(boost::property_tree::ptree& iniConfig);
|
void readButtonCodes(boost::property_tree::ptree& iniConfig);
|
||||||
void insertButtonCode(boost::property_tree::ptree& iniConfig, const std::string& buttonCodeKey, aasdk::proto::enums::ButtonCode::Enum buttonCode);
|
void insertButtonCode(boost::property_tree::ptree& iniConfig, const std::string& buttonCodeKey, aasdk::proto::enums::ButtonCode::Enum buttonCode);
|
||||||
@ -84,6 +93,7 @@ private:
|
|||||||
size_t screenDPI_;
|
size_t screenDPI_;
|
||||||
int32_t omxLayerIndex_;
|
int32_t omxLayerIndex_;
|
||||||
QRect videoMargins_;
|
QRect videoMargins_;
|
||||||
|
bool whitescreenWorkaround_;
|
||||||
bool enableTouchscreen_;
|
bool enableTouchscreen_;
|
||||||
ButtonCodes buttonCodes_;
|
ButtonCodes buttonCodes_;
|
||||||
BluetoothAdapterType bluetoothAdapterType_;
|
BluetoothAdapterType bluetoothAdapterType_;
|
||||||
@ -91,6 +101,11 @@ private:
|
|||||||
bool musicAudioChannelEnabled_;
|
bool musicAudioChannelEnabled_;
|
||||||
bool speechAudiochannelEnabled_;
|
bool speechAudiochannelEnabled_;
|
||||||
AudioOutputBackendType audioOutputBackendType_;
|
AudioOutputBackendType audioOutputBackendType_;
|
||||||
|
std::string wifiSSID_;
|
||||||
|
std::string wifiPassword_;
|
||||||
|
std::string wifiMAC_;
|
||||||
|
bool autoconnectBluetooth_;
|
||||||
|
std::string lastBluetoothPair_;
|
||||||
|
|
||||||
static const std::string cConfigFileName;
|
static const std::string cConfigFileName;
|
||||||
|
|
||||||
@ -103,6 +118,7 @@ private:
|
|||||||
static const std::string cVideoOMXLayerIndexKey;
|
static const std::string cVideoOMXLayerIndexKey;
|
||||||
static const std::string cVideoMarginWidth;
|
static const std::string cVideoMarginWidth;
|
||||||
static const std::string cVideoMarginHeight;
|
static const std::string cVideoMarginHeight;
|
||||||
|
static const std::string cVideoWhitescreenWorkaround;
|
||||||
|
|
||||||
static const std::string cAudioMusicAudioChannelEnabled;
|
static const std::string cAudioMusicAudioChannelEnabled;
|
||||||
static const std::string cAudioSpeechAudioChannelEnabled;
|
static const std::string cAudioSpeechAudioChannelEnabled;
|
||||||
@ -128,9 +144,13 @@ private:
|
|||||||
static const std::string cInputScrollWheelButtonKey;
|
static const std::string cInputScrollWheelButtonKey;
|
||||||
static const std::string cInputBackButtonKey;
|
static const std::string cInputBackButtonKey;
|
||||||
static const std::string cInputEnterButtonKey;
|
static const std::string cInputEnterButtonKey;
|
||||||
|
|
||||||
|
static const std::string cWifiSSID;
|
||||||
|
static const std::string cWifiPskey;
|
||||||
|
static const std::string cWifiMAC;
|
||||||
|
static const std::string cAutoconnectBluetooth;
|
||||||
|
static const std::string cLastBluetoothPair;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
@ -18,12 +18,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace configuration
|
namespace configuration
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -35,5 +31,3 @@ enum class HandednessOfTrafficType
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
@ -20,19 +20,15 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <QRect>
|
#include <QRect>
|
||||||
#include <aasdk_proto/VideoFPSEnum.pb.h>
|
#include "aasdk_proto/VideoFPSEnum.pb.h"
|
||||||
#include <aasdk_proto/VideoResolutionEnum.pb.h>
|
#include "aasdk_proto/VideoResolutionEnum.pb.h"
|
||||||
#include <aasdk_proto/ButtonCodeEnum.pb.h>
|
#include "aasdk_proto/ButtonCodeEnum.pb.h"
|
||||||
#include <f1x/openauto/autoapp/Configuration/BluetootAdapterType.hpp>
|
#include "BluetootAdapterType.hpp"
|
||||||
#include <f1x/openauto/autoapp/Configuration/HandednessOfTrafficType.hpp>
|
#include "HandednessOfTrafficType.hpp"
|
||||||
#include <f1x/openauto/autoapp/Configuration/AudioOutputBackendType.hpp>
|
#include "AudioOutputBackendType.hpp"
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace configuration
|
namespace configuration
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -63,6 +59,8 @@ public:
|
|||||||
virtual int32_t getOMXLayerIndex() const = 0;
|
virtual int32_t getOMXLayerIndex() const = 0;
|
||||||
virtual void setVideoMargins(QRect value) = 0;
|
virtual void setVideoMargins(QRect value) = 0;
|
||||||
virtual QRect getVideoMargins() const = 0;
|
virtual QRect getVideoMargins() const = 0;
|
||||||
|
virtual void setWhitescreenWorkaround(bool value) = 0;
|
||||||
|
virtual bool getWhitescreenWorkaround() const = 0;
|
||||||
|
|
||||||
virtual bool getTouchscreenEnabled() const = 0;
|
virtual bool getTouchscreenEnabled() const = 0;
|
||||||
virtual void setTouchscreenEnabled(bool value) = 0;
|
virtual void setTouchscreenEnabled(bool value) = 0;
|
||||||
@ -80,9 +78,18 @@ public:
|
|||||||
virtual void setSpeechAudioChannelEnabled(bool value) = 0;
|
virtual void setSpeechAudioChannelEnabled(bool value) = 0;
|
||||||
virtual AudioOutputBackendType getAudioOutputBackendType() const = 0;
|
virtual AudioOutputBackendType getAudioOutputBackendType() const = 0;
|
||||||
virtual void setAudioOutputBackendType(AudioOutputBackendType value) = 0;
|
virtual void setAudioOutputBackendType(AudioOutputBackendType value) = 0;
|
||||||
|
|
||||||
|
virtual std::string getWifiSSID() = 0;
|
||||||
|
virtual void setWifiSSID(std::string value) = 0;
|
||||||
|
virtual std::string getWifiPassword() = 0;
|
||||||
|
virtual void setWifiPassword(std::string value) = 0;
|
||||||
|
virtual std::string getWifiMAC() = 0;
|
||||||
|
virtual void setWifiMAC(std::string value) = 0;
|
||||||
|
virtual bool getAutoconnectBluetooth() = 0;
|
||||||
|
virtual void setAutoconnectBluetooth(bool value) = 0;
|
||||||
|
virtual std::string getLastBluetoothPair() = 0;
|
||||||
|
virtual void setLastBluetoothPair(std::string value) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
@ -21,12 +21,8 @@
|
|||||||
#include <deque>
|
#include <deque>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace configuration
|
namespace configuration
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -42,5 +38,3 @@ public:
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
@ -19,14 +19,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <f1x/openauto/autoapp/Configuration/IRecentAddressesList.hpp>
|
#include "IRecentAddressesList.hpp"
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace configuration
|
namespace configuration
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -53,5 +49,3 @@ private:
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
@ -18,14 +18,10 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <f1x/openauto/autoapp/Projection/IBluetoothDevice.hpp>
|
#include "IBluetoothDevice.hpp"
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace projection
|
namespace projection
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -41,5 +37,3 @@ public:
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
137
include/openauto/Projection/GSTVideoOutput.hpp
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
/*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef USE_GST
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <mutex>
|
||||||
|
#include <condition_variable>
|
||||||
|
#include <functional>
|
||||||
|
#include <thread>
|
||||||
|
#include <boost/circular_buffer.hpp>
|
||||||
|
#include <boost/noncopyable.hpp>
|
||||||
|
#include "openauto/Projection/VideoOutput.hpp"
|
||||||
|
#include <gst/gst.h>
|
||||||
|
#include <gst/app/gstappsrc.h>
|
||||||
|
#include <gst/app/gstappsink.h>
|
||||||
|
#include <gst/video/video.h>
|
||||||
|
#include <QGlib/Error>
|
||||||
|
#include <QGlib/Connect>
|
||||||
|
#include <QGst/Init>
|
||||||
|
#include <QGst/Bus>
|
||||||
|
#include <QGst/Pipeline>
|
||||||
|
#include <QGst/Parse>
|
||||||
|
#include <QGst/Message>
|
||||||
|
#include <QGst/Utils/ApplicationSink>
|
||||||
|
#include <QGst/Utils/ApplicationSource>
|
||||||
|
#include <QGst/Ui/VideoWidget>
|
||||||
|
#include <QGst/ElementFactory>
|
||||||
|
#include <QGst/Quick/VideoSurface>
|
||||||
|
#include <QtQml/QQmlContext>
|
||||||
|
#include <QtQuickWidgets/QQuickWidget>
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
|
namespace openauto
|
||||||
|
{
|
||||||
|
namespace projection
|
||||||
|
{
|
||||||
|
|
||||||
|
// enum of possible h264 decoders dash will attempt to use
|
||||||
|
enum H264_Decoder {
|
||||||
|
nvcodec,
|
||||||
|
v4l2,
|
||||||
|
omx,
|
||||||
|
vaapi,
|
||||||
|
libav,
|
||||||
|
unknown
|
||||||
|
};
|
||||||
|
|
||||||
|
// order of priority for decoders - dash will use the first decoder it can find in this list
|
||||||
|
// for sake of the code, don't include "unknown" as a decoder to search for - this is the default case.
|
||||||
|
const H264_Decoder H264_Decoder_Priority_List[] = { nvcodec, v4l2, omx, libav };
|
||||||
|
|
||||||
|
// A map of enum to actual pad name we want to use
|
||||||
|
inline const char* ToString(H264_Decoder v)
|
||||||
|
{
|
||||||
|
switch (v)
|
||||||
|
{
|
||||||
|
case nvcodec: return "nvh264dec";
|
||||||
|
case v4l2: return "v4l2h264dec";
|
||||||
|
case omx: return "omxh264dec";
|
||||||
|
case libav: return "avdec_h264";
|
||||||
|
default: return "unknown";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// A map of enum to pipeline steps to insert (because for some we need some video converting)
|
||||||
|
inline const char* ToPipeline(H264_Decoder v)
|
||||||
|
{
|
||||||
|
switch (v)
|
||||||
|
{
|
||||||
|
// we're going to assume that any machine with an nvidia card has a cpu powerful enough for video convert.
|
||||||
|
case nvcodec: return "nvh264dec ! videoconvert";
|
||||||
|
case v4l2: return "v4l2h264dec";
|
||||||
|
case omx: return "omxh264dec";
|
||||||
|
case libav: return "avdec_h264";
|
||||||
|
default: return "unknown";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class GSTVideoOutput: public QObject, public VideoOutput, boost::noncopyable
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
GSTVideoOutput(configuration::IConfiguration::Pointer configuration, QWidget* videoContainer=nullptr, std::function<void(bool)> activeCallback=nullptr);
|
||||||
|
~GSTVideoOutput();
|
||||||
|
bool open() override;
|
||||||
|
bool init() override;
|
||||||
|
void write(uint64_t timestamp, const aasdk::common::DataConstBuffer& buffer) override;
|
||||||
|
void stop() override;
|
||||||
|
void resize();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void startPlayback();
|
||||||
|
void stopPlayback();
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
void onStartPlayback();
|
||||||
|
void onStopPlayback();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void dumpDot();
|
||||||
|
private:
|
||||||
|
static GstPadProbeReturn convertProbe(GstPad* pad, GstPadProbeInfo* info, void*);
|
||||||
|
static gboolean busCallback(GstBus*, GstMessage* message, gpointer*);
|
||||||
|
H264_Decoder findPreferredVideoDecoder();
|
||||||
|
|
||||||
|
bool firstHeaderParsed = false;
|
||||||
|
|
||||||
|
QGst::ElementPtr videoSink_;
|
||||||
|
QQuickWidget* videoWidget_;
|
||||||
|
GstElement* vidPipeline_;
|
||||||
|
GstVideoFilter* vidCrop_;
|
||||||
|
GstAppSrc* vidSrc_;
|
||||||
|
QWidget* videoContainer_;
|
||||||
|
QGst::Quick::VideoSurface* surface_;
|
||||||
|
std::function<void(bool)> activeCallback_;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -19,15 +19,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <f1x/aasdk/IO/Promise.hpp>
|
#include "aasdk/IO/Promise.hpp"
|
||||||
#include <f1x/aasdk/Common/Data.hpp>
|
#include "aasdk/Common/Data.hpp"
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace projection
|
namespace projection
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -52,5 +48,3 @@ public:
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
@ -19,15 +19,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <f1x/aasdk/Messenger/Timestamp.hpp>
|
#include "aasdk/Messenger/Timestamp.hpp"
|
||||||
#include <f1x/aasdk/Common/Data.hpp>
|
#include "aasdk/Common/Data.hpp"
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace projection
|
namespace projection
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -51,5 +47,3 @@ public:
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
@ -16,16 +16,12 @@
|
|||||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <f1x/aasdk/IO/Promise.hpp>
|
#include "aasdk/IO/Promise.hpp"
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace projection
|
namespace projection
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -44,5 +40,3 @@ public:
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
@ -19,15 +19,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QRect>
|
#include <QRect>
|
||||||
#include <f1x/aasdk/IO/Promise.hpp>
|
#include "aasdk/IO/Promise.hpp"
|
||||||
#include <f1x/openauto/autoapp/Projection/InputEvent.hpp>
|
#include "InputEvent.hpp"
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace projection
|
namespace projection
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -49,5 +45,3 @@ public:
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
@ -18,14 +18,12 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <f1x/openauto/autoapp/Projection/InputEvent.hpp>
|
#include "InputEvent.hpp"
|
||||||
|
#include "aasdk_proto/InputEventIndicationMessage.pb.h"
|
||||||
|
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace projection
|
namespace projection
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -35,10 +33,10 @@ public:
|
|||||||
virtual ~IInputDeviceEventHandler() = default;
|
virtual ~IInputDeviceEventHandler() = default;
|
||||||
|
|
||||||
virtual void onButtonEvent(const ButtonEvent& event) = 0;
|
virtual void onButtonEvent(const ButtonEvent& event) = 0;
|
||||||
virtual void onTouchEvent(const TouchEvent& event) = 0;
|
virtual void onTouchEvent(aasdk::proto::messages::InputEventIndication inputEventIndication) = 0;
|
||||||
|
virtual void onMouseEvent(const projection::TouchEvent& event) = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
@ -20,16 +20,12 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <QRect>
|
#include <QRect>
|
||||||
#include <aasdk_proto/VideoFPSEnum.pb.h>
|
#include "aasdk_proto/VideoFPSEnum.pb.h"
|
||||||
#include <aasdk_proto/VideoResolutionEnum.pb.h>
|
#include "aasdk_proto/VideoResolutionEnum.pb.h"
|
||||||
#include <f1x/aasdk/Common/Data.hpp>
|
#include "aasdk/Common/Data.hpp"
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace projection
|
namespace projection
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -53,5 +49,3 @@ public:
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
@ -20,15 +20,12 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <f1x/openauto/autoapp/Projection/IInputDevice.hpp>
|
#include "IInputDevice.hpp"
|
||||||
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
|
#include "openauto/Configuration/IConfiguration.hpp"
|
||||||
|
#include <bits/stdc++.h>
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace projection
|
namespace projection
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -45,12 +42,14 @@ public:
|
|||||||
bool eventFilter(QObject* obj, QEvent* event) override;
|
bool eventFilter(QObject* obj, QEvent* event) override;
|
||||||
bool hasTouchscreen() const override;
|
bool hasTouchscreen() const override;
|
||||||
QRect getTouchscreenGeometry() const override;
|
QRect getTouchscreenGeometry() const override;
|
||||||
|
void setTouchscreenGeometry(QRect& touchscreenGeometry);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setVideoGeometry();
|
void setVideoGeometry();
|
||||||
bool handleKeyEvent(QEvent* event, QKeyEvent* key);
|
bool handleKeyEvent(QEvent* event, QKeyEvent* key);
|
||||||
void dispatchKeyEvent(ButtonEvent event);
|
void dispatchKeyEvent(ButtonEvent event);
|
||||||
bool handleTouchEvent(QEvent* event);
|
bool handleTouchEvent(QEvent* event);
|
||||||
|
bool handleMouseEvent(QEvent* event);
|
||||||
|
|
||||||
QObject& parent_;
|
QObject& parent_;
|
||||||
configuration::IConfiguration::Pointer configuration_;
|
configuration::IConfiguration::Pointer configuration_;
|
||||||
@ -58,9 +57,11 @@ private:
|
|||||||
QRect displayGeometry_;
|
QRect displayGeometry_;
|
||||||
IInputDeviceEventHandler* eventHandler_;
|
IInputDeviceEventHandler* eventHandler_;
|
||||||
std::mutex mutex_;
|
std::mutex mutex_;
|
||||||
|
|
||||||
|
std::priority_queue <int, std::vector<int>, std::greater<int> > pointer_id_queue;
|
||||||
|
QMap<int, int> pointer_map;
|
||||||
|
int max_pointers = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
@ -18,16 +18,12 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <aasdk_proto/ButtonCodeEnum.pb.h>
|
#include "aasdk_proto/ButtonCodeEnum.pb.h"
|
||||||
#include <aasdk_proto/TouchActionEnum.pb.h>
|
#include "aasdk_proto/TouchActionEnum.pb.h"
|
||||||
#include <f1x/aasdk/IO/Promise.hpp>
|
#include "aasdk/IO/Promise.hpp"
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace projection
|
namespace projection
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -62,5 +58,3 @@ struct TouchEvent
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
@ -17,16 +17,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <QBluetoothLocalDevice>
|
#include <QBluetoothLocalDevice>
|
||||||
#include <f1x/openauto/autoapp/Projection/IBluetoothDevice.hpp>
|
#include "IBluetoothDevice.hpp"
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace projection
|
namespace projection
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -64,5 +60,3 @@ private:
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
@ -26,28 +26,39 @@ extern "C"
|
|||||||
|
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
|
#include <functional>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <boost/circular_buffer.hpp>
|
#include <boost/circular_buffer.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/VideoOutput.hpp>
|
#include "VideoOutput.hpp"
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace projection
|
namespace projection
|
||||||
{
|
{
|
||||||
|
|
||||||
|
struct DestRect
|
||||||
|
{
|
||||||
|
DestRect();
|
||||||
|
DestRect(OMX_S16 xOffset, OMX_S16 yOffset, OMX_S16 width, OMX_S16 height);
|
||||||
|
|
||||||
|
OMX_BOOL fullscreen;
|
||||||
|
OMX_S16 xOffset;
|
||||||
|
OMX_S16 yOffset;
|
||||||
|
OMX_S16 width;
|
||||||
|
OMX_S16 height;
|
||||||
|
};
|
||||||
|
|
||||||
class OMXVideoOutput: public VideoOutput
|
class OMXVideoOutput: public VideoOutput
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
OMXVideoOutput(configuration::IConfiguration::Pointer configuration);
|
OMXVideoOutput(configuration::IConfiguration::Pointer configuration, DestRect destRect=DestRect(), std::function<void(bool)> activeCallback=nullptr);
|
||||||
|
|
||||||
bool open() override;
|
bool open() override;
|
||||||
bool init() override;
|
bool init() override;
|
||||||
void write(uint64_t timestamp, const aasdk::common::DataConstBuffer& buffer) override;
|
void write(uint64_t timestamp, const aasdk::common::DataConstBuffer& buffer) override;
|
||||||
void stop() override;
|
void stop() override;
|
||||||
|
void setOpacity(OMX_U32 alpha);
|
||||||
|
void setDestRect(DestRect destRect);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool createComponents();
|
bool createComponents();
|
||||||
@ -62,10 +73,11 @@ private:
|
|||||||
ILCLIENT_T* client_;
|
ILCLIENT_T* client_;
|
||||||
COMPONENT_T* components_[5];
|
COMPONENT_T* components_[5];
|
||||||
TUNNEL_T tunnels_[4];
|
TUNNEL_T tunnels_[4];
|
||||||
|
DestRect destRect_;
|
||||||
|
OMX_U32 alpha_;
|
||||||
|
std::function<void(bool)> activeCallback_;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -21,14 +21,10 @@
|
|||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <QAudioInput>
|
#include <QAudioInput>
|
||||||
#include <QAudioFormat>
|
#include <QAudioFormat>
|
||||||
#include <f1x/openauto/autoapp/Projection/IAudioInput.hpp>
|
#include "IAudioInput.hpp"
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace projection
|
namespace projection
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -69,5 +65,3 @@ private:
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
@ -20,15 +20,11 @@
|
|||||||
|
|
||||||
#include <QAudioOutput>
|
#include <QAudioOutput>
|
||||||
#include <QAudioFormat>
|
#include <QAudioFormat>
|
||||||
#include <f1x/openauto/autoapp/Projection/IAudioOutput.hpp>
|
#include "IAudioOutput.hpp"
|
||||||
#include <f1x/openauto/autoapp/Projection/SequentialBuffer.hpp>
|
#include "SequentialBuffer.hpp"
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace projection
|
namespace projection
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -67,5 +63,3 @@ private:
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
@ -21,15 +21,11 @@
|
|||||||
#include <QMediaPlayer>
|
#include <QMediaPlayer>
|
||||||
#include <QVideoWidget>
|
#include <QVideoWidget>
|
||||||
#include <boost/noncopyable.hpp>
|
#include <boost/noncopyable.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/VideoOutput.hpp>
|
#include "VideoOutput.hpp"
|
||||||
#include <f1x/openauto/autoapp/Projection/SequentialBuffer.hpp>
|
#include "SequentialBuffer.hpp"
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace projection
|
namespace projection
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -38,11 +34,12 @@ class QtVideoOutput: public QObject, public VideoOutput, boost::noncopyable
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QtVideoOutput(configuration::IConfiguration::Pointer configuration);
|
QtVideoOutput(configuration::IConfiguration::Pointer configuration, QWidget* videoContainer=nullptr);
|
||||||
bool open() override;
|
bool open() override;
|
||||||
bool init() override;
|
bool init() override;
|
||||||
void write(uint64_t timestamp, const aasdk::common::DataConstBuffer& buffer) override;
|
void write(uint64_t timestamp, const aasdk::common::DataConstBuffer& buffer) override;
|
||||||
void stop() override;
|
void stop() override;
|
||||||
|
void resize();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void startPlayback();
|
void startPlayback();
|
||||||
@ -57,9 +54,8 @@ private:
|
|||||||
SequentialBuffer videoBuffer_;
|
SequentialBuffer videoBuffer_;
|
||||||
std::unique_ptr<QVideoWidget> videoWidget_;
|
std::unique_ptr<QVideoWidget> videoWidget_;
|
||||||
std::unique_ptr<QMediaPlayer> mediaPlayer_;
|
std::unique_ptr<QMediaPlayer> mediaPlayer_;
|
||||||
|
QWidget* videoContainer_;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
@ -18,14 +18,10 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <f1x/openauto/autoapp/Projection/IBluetoothDevice.hpp>
|
#include "IBluetoothDevice.hpp"
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace projection
|
namespace projection
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -46,5 +42,3 @@ private:
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
@ -19,15 +19,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <RtAudio.h>
|
#include <RtAudio.h>
|
||||||
#include <f1x/openauto/autoapp/Projection/IAudioOutput.hpp>
|
#include "IAudioOutput.hpp"
|
||||||
#include <f1x/openauto/autoapp/Projection/SequentialBuffer.hpp>
|
#include "SequentialBuffer.hpp"
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace projection
|
namespace projection
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -54,10 +50,8 @@ private:
|
|||||||
uint32_t sampleRate_;
|
uint32_t sampleRate_;
|
||||||
SequentialBuffer audioBuffer_;
|
SequentialBuffer audioBuffer_;
|
||||||
std::unique_ptr<RtAudio> dac_;
|
std::unique_ptr<RtAudio> dac_;
|
||||||
std::mutex mutex_;
|
static std::mutex mutex_;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
@ -21,14 +21,10 @@
|
|||||||
#include <QIODevice>
|
#include <QIODevice>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <boost/circular_buffer.hpp>
|
#include <boost/circular_buffer.hpp>
|
||||||
#include <f1x/aasdk/Common/Data.hpp>
|
#include "aasdk/Common/Data.hpp"
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace projection
|
namespace projection
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -57,5 +53,3 @@ private:
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
@ -18,15 +18,11 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
|
#include "openauto/Configuration/IConfiguration.hpp"
|
||||||
#include <f1x/openauto/autoapp/Projection/IVideoOutput.hpp>
|
#include "IVideoOutput.hpp"
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace projection
|
namespace projection
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -46,5 +42,3 @@ protected:
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
@ -19,21 +19,17 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
#include <f1x/aasdk/Transport/ITransport.hpp>
|
#include "aasdk/Transport/ITransport.hpp"
|
||||||
#include <f1x/aasdk/Channel/Control/IControlServiceChannel.hpp>
|
#include "aasdk/Channel/Control/IControlServiceChannel.hpp"
|
||||||
#include <f1x/aasdk/Channel/Control/IControlServiceChannelEventHandler.hpp>
|
#include "aasdk/Channel/Control/IControlServiceChannelEventHandler.hpp"
|
||||||
#include <f1x/aasdk/Channel/AV/VideoServiceChannel.hpp>
|
#include "aasdk/Channel/AV/VideoServiceChannel.hpp"
|
||||||
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
|
#include "openauto/Configuration/IConfiguration.hpp"
|
||||||
#include <f1x/openauto/autoapp/Service/IAndroidAutoEntity.hpp>
|
#include "IAndroidAutoEntity.hpp"
|
||||||
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
#include "IService.hpp"
|
||||||
#include <f1x/openauto/autoapp/Service/IPinger.hpp>
|
#include "IPinger.hpp"
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace service
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -58,8 +54,10 @@ public:
|
|||||||
void onShutdownRequest(const aasdk::proto::messages::ShutdownRequest& request) override;
|
void onShutdownRequest(const aasdk::proto::messages::ShutdownRequest& request) override;
|
||||||
void onShutdownResponse(const aasdk::proto::messages::ShutdownResponse& response) override;
|
void onShutdownResponse(const aasdk::proto::messages::ShutdownResponse& response) override;
|
||||||
void onNavigationFocusRequest(const aasdk::proto::messages::NavigationFocusRequest& request) override;
|
void onNavigationFocusRequest(const aasdk::proto::messages::NavigationFocusRequest& request) override;
|
||||||
|
void onPingRequest(const aasdk::proto::messages::PingRequest& request) override;
|
||||||
void onPingResponse(const aasdk::proto::messages::PingResponse& response) override;
|
void onPingResponse(const aasdk::proto::messages::PingResponse& response) override;
|
||||||
void onChannelError(const aasdk::error::Error& e) override;
|
void onChannelError(const aasdk::error::Error& e) override;
|
||||||
|
void onVoiceSessionRequest(const aasdk::proto::messages::VoiceSessionRequest& request) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using std::enable_shared_from_this<AndroidAutoEntity>::shared_from_this;
|
using std::enable_shared_from_this<AndroidAutoEntity>::shared_from_this;
|
||||||
@ -80,5 +78,3 @@ private:
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
@ -19,17 +19,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
#include <f1x/aasdk/Transport/ITransport.hpp>
|
#include "aasdk/Transport/ITransport.hpp"
|
||||||
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
|
#include "openauto/Configuration/IConfiguration.hpp"
|
||||||
#include <f1x/openauto/autoapp/Service/IAndroidAutoEntityFactory.hpp>
|
#include "IAndroidAutoEntityFactory.hpp"
|
||||||
#include <f1x/openauto/autoapp/Service/IServiceFactory.hpp>
|
#include "IServiceFactory.hpp"
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace service
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -53,5 +49,3 @@ private:
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
@ -18,16 +18,12 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <f1x/aasdk/Channel/AV/AVInputServiceChannel.hpp>
|
#include "aasdk/Channel/AV/AVInputServiceChannel.hpp"
|
||||||
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
#include "IService.hpp"
|
||||||
#include <f1x/openauto/autoapp/Projection/IAudioInput.hpp>
|
#include "openauto/Projection/IAudioInput.hpp"
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace service
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -61,5 +57,3 @@ private:
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
@ -18,17 +18,13 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <f1x/aasdk/Channel/AV/IAudioServiceChannel.hpp>
|
#include "aasdk/Channel/AV/IAudioServiceChannel.hpp"
|
||||||
#include <f1x/aasdk/Channel/AV/IAudioServiceChannelEventHandler.hpp>
|
#include "aasdk/Channel/AV/IAudioServiceChannelEventHandler.hpp"
|
||||||
#include <f1x/openauto/autoapp/Projection/IAudioOutput.hpp>
|
#include "openauto/Projection/IAudioOutput.hpp"
|
||||||
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
#include "IService.hpp"
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace service
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -61,5 +57,3 @@ protected:
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
@ -18,16 +18,12 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <f1x/aasdk/Channel/Bluetooth/BluetoothServiceChannel.hpp>
|
#include "aasdk/Channel/Bluetooth/BluetoothServiceChannel.hpp"
|
||||||
#include <f1x/openauto/autoapp/Projection/IBluetoothDevice.hpp>
|
#include "openauto/Projection/IBluetoothDevice.hpp"
|
||||||
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
#include "IService.hpp"
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace service
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -52,5 +48,3 @@ private:
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
@ -19,14 +19,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <f1x/openauto/autoapp/Service/IAndroidAutoEntityEventHandler.hpp>
|
#include "IAndroidAutoEntityEventHandler.hpp"
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace service
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -43,5 +39,3 @@ public:
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
@ -18,14 +18,10 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <f1x/aasdk/Error/Error.hpp>
|
#include "aasdk/Error/Error.hpp"
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace service
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -38,5 +34,3 @@ public:
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
@ -18,16 +18,12 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <f1x/aasdk/TCP/ITCPEndpoint.hpp>
|
#include "aasdk/TCP/ITCPEndpoint.hpp"
|
||||||
#include <f1x/aasdk/USB/IAOAPDevice.hpp>
|
#include "aasdk/USB/IAOAPDevice.hpp"
|
||||||
#include <f1x/openauto/autoapp/Service/IAndroidAutoEntity.hpp>
|
#include "IAndroidAutoEntity.hpp"
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace service
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -42,5 +38,3 @@ public:
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
88
include/openauto/Service/IAndroidAutoInterface.hpp
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
#include "aasdk_proto/ButtonCodeEnum.pb.h"
|
||||||
|
#include "openauto/Projection/InputEvent.hpp"
|
||||||
|
#include "aasdk_proto/MediaInfoChannelMetadataData.pb.h"
|
||||||
|
#include "aasdk_proto/MediaInfoChannelPlaybackData.pb.h"
|
||||||
|
#include "aasdk_proto/NavigationStatusMessage.pb.h"
|
||||||
|
#include "aasdk_proto/NavigationDistanceEventMessage.pb.h"
|
||||||
|
#include "aasdk_proto/NavigationTurnEventMessage.pb.h"
|
||||||
|
#include "openauto/Service/ServiceFactory.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
namespace openauto
|
||||||
|
{
|
||||||
|
namespace service
|
||||||
|
{
|
||||||
|
|
||||||
|
class IAndroidAutoInterface: public std::enable_shared_from_this<IAndroidAutoInterface>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
std::shared_ptr<IAndroidAutoInterface> getPtr()
|
||||||
|
{
|
||||||
|
return shared_from_this();
|
||||||
|
}
|
||||||
|
typedef std::shared_ptr<IAndroidAutoInterface> Pointer;
|
||||||
|
|
||||||
|
virtual ~IAndroidAutoInterface() = default;
|
||||||
|
|
||||||
|
virtual void mediaPlaybackUpdate(const aasdk::proto::messages::MediaInfoChannelPlaybackData& playback) = 0;
|
||||||
|
virtual void mediaMetadataUpdate(const aasdk::proto::messages::MediaInfoChannelMetadataData& metadata) = 0;
|
||||||
|
virtual void navigationStatusUpdate(const aasdk::proto::messages::NavigationStatus& navStatus) = 0;
|
||||||
|
virtual void navigationTurnEvent(const aasdk::proto::messages::NavigationTurnEvent& turnEvent) = 0;
|
||||||
|
virtual void navigationDistanceEvent(const aasdk::proto::messages::NavigationDistanceEvent& distanceEvent) = 0;
|
||||||
|
void setServiceFactory(ServiceFactory* serviceFactory)
|
||||||
|
{
|
||||||
|
this->m_serviceFactory = serviceFactory;
|
||||||
|
|
||||||
|
}
|
||||||
|
void injectButtonPress(aasdk::proto::enums::ButtonCode::Enum buttonCode, projection::WheelDirection wheelDirection=openauto::projection::WheelDirection::NONE, projection::ButtonEventType buttonEventType = projection::ButtonEventType::NONE)
|
||||||
|
{
|
||||||
|
if(m_serviceFactory != NULL)
|
||||||
|
{
|
||||||
|
|
||||||
|
m_serviceFactory->sendButtonPress(buttonCode, wheelDirection, buttonEventType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void injectButtonPress(aasdk::proto::enums::ButtonCode::Enum buttonCode, projection::ButtonEventType buttonEventType)
|
||||||
|
{
|
||||||
|
this->injectButtonPress(buttonCode, projection::WheelDirection::NONE, buttonEventType);
|
||||||
|
}
|
||||||
|
void setNightMode(bool mode)
|
||||||
|
{
|
||||||
|
if(m_serviceFactory != NULL)
|
||||||
|
{
|
||||||
|
|
||||||
|
m_serviceFactory->setNightMode(mode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
using std::enable_shared_from_this<IAndroidAutoInterface>::shared_from_this;
|
||||||
|
ServiceFactory* m_serviceFactory;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -18,14 +18,10 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <f1x/aasdk/IO/Promise.hpp>
|
#include "aasdk/IO/Promise.hpp"
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace service
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -43,5 +39,3 @@ public:
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
@ -20,14 +20,10 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <aasdk_proto/ServiceDiscoveryResponseMessage.pb.h>
|
#include "aasdk_proto/ServiceDiscoveryResponseMessage.pb.h"
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace service
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -47,5 +43,3 @@ typedef std::vector<IService::Pointer> ServiceList;
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
@ -18,15 +18,11 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <f1x/aasdk/Messenger/IMessenger.hpp>
|
#include "aasdk/Messenger/IMessenger.hpp"
|
||||||
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
#include "IService.hpp"
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace service
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -40,5 +36,3 @@ public:
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
@ -18,18 +18,14 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <aasdk_proto/ButtonCodeEnum.pb.h>
|
#include "aasdk_proto/ButtonCodeEnum.pb.h"
|
||||||
#include <f1x/aasdk/Channel/Input/InputServiceChannel.hpp>
|
#include "aasdk/Channel/Input/InputServiceChannel.hpp"
|
||||||
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
#include "IService.hpp"
|
||||||
#include <f1x/openauto/autoapp/Projection/IInputDevice.hpp>
|
#include "openauto/Projection/IInputDevice.hpp"
|
||||||
#include <f1x/openauto/autoapp/Projection/IInputDeviceEventHandler.hpp>
|
#include "openauto/Projection/IInputDeviceEventHandler.hpp"
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace service
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -42,6 +38,7 @@ class InputService:
|
|||||||
public:
|
public:
|
||||||
InputService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IInputDevice::Pointer inputDevice);
|
InputService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IInputDevice::Pointer inputDevice);
|
||||||
|
|
||||||
|
void sendButtonPress(aasdk::proto::enums::ButtonCode::Enum buttonCode, projection::WheelDirection wheelDirection = projection::WheelDirection::NONE, projection::ButtonEventType buttonEventType = projection::ButtonEventType::NONE);
|
||||||
void start() override;
|
void start() override;
|
||||||
void stop() override;
|
void stop() override;
|
||||||
void fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response) override;
|
void fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response) override;
|
||||||
@ -49,7 +46,8 @@ public:
|
|||||||
void onBindingRequest(const aasdk::proto::messages::BindingRequest& request) override;
|
void onBindingRequest(const aasdk::proto::messages::BindingRequest& request) override;
|
||||||
void onChannelError(const aasdk::error::Error& e) override;
|
void onChannelError(const aasdk::error::Error& e) override;
|
||||||
void onButtonEvent(const projection::ButtonEvent& event) override;
|
void onButtonEvent(const projection::ButtonEvent& event) override;
|
||||||
void onTouchEvent(const projection::TouchEvent& event) override;
|
void onTouchEvent(aasdk::proto::messages::InputEventIndication inputEventIndication) override;
|
||||||
|
void onMouseEvent(const projection::TouchEvent& event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using std::enable_shared_from_this<InputService>::shared_from_this;
|
using std::enable_shared_from_this<InputService>::shared_from_this;
|
||||||
@ -57,9 +55,8 @@ private:
|
|||||||
boost::asio::io_service::strand strand_;
|
boost::asio::io_service::strand strand_;
|
||||||
aasdk::channel::input::InputServiceChannel::Pointer channel_;
|
aasdk::channel::input::InputServiceChannel::Pointer channel_;
|
||||||
projection::IInputDevice::Pointer inputDevice_;
|
projection::IInputDevice::Pointer inputDevice_;
|
||||||
|
bool serviceActive = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
@ -18,15 +18,11 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <f1x/aasdk/Messenger/IMessenger.hpp>
|
#include "aasdk/Messenger/IMessenger.hpp"
|
||||||
#include <f1x/openauto/autoapp/Service/AudioService.hpp>
|
#include "AudioService.hpp"
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace service
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -38,5 +34,3 @@ public:
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
52
include/openauto/Service/MediaStatusService.hpp
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
#include "aasdk/Channel/AV/MediaStatusServiceChannel.hpp"
|
||||||
|
#include "IService.hpp"
|
||||||
|
|
||||||
|
namespace openauto
|
||||||
|
{
|
||||||
|
namespace service
|
||||||
|
{
|
||||||
|
class IAndroidAutoInterface;
|
||||||
|
class MediaStatusService: public aasdk::channel::av::IMediaStatusServiceChannelEventHandler, public IService, public std::enable_shared_from_this<MediaStatusService>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MediaStatusService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, IAndroidAutoInterface* aa_interface);
|
||||||
|
void start() override;
|
||||||
|
void stop() override;
|
||||||
|
void fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response) override;
|
||||||
|
void onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request) override;
|
||||||
|
void onChannelError(const aasdk::error::Error& e) override;
|
||||||
|
void onMetadataUpdate(const aasdk::proto::messages::MediaInfoChannelMetadataData& metadata) override;
|
||||||
|
void onPlaybackUpdate(const aasdk::proto::messages::MediaInfoChannelPlaybackData& playback) override;
|
||||||
|
void setAndroidAutoInterface(IAndroidAutoInterface* aa_interface);
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
using std::enable_shared_from_this<MediaStatusService>::shared_from_this;
|
||||||
|
|
||||||
|
boost::asio::io_service::strand strand_;
|
||||||
|
aasdk::channel::av::MediaStatusServiceChannel::Pointer channel_;
|
||||||
|
IAndroidAutoInterface* aa_interface_ = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
54
include/openauto/Service/NavigationStatusService.hpp
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
#include "aasdk/Channel/Navigation/NavigationStatusServiceChannel.hpp"
|
||||||
|
#include "IService.hpp"
|
||||||
|
|
||||||
|
namespace openauto
|
||||||
|
{
|
||||||
|
namespace service
|
||||||
|
{
|
||||||
|
class IAndroidAutoInterface;
|
||||||
|
class NavigationStatusService: public aasdk::channel::navigation::INavigationStatusServiceChannelEventHandler, public IService, public std::enable_shared_from_this<NavigationStatusService>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NavigationStatusService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, IAndroidAutoInterface* aa_interface);
|
||||||
|
void start() override;
|
||||||
|
void stop() override;
|
||||||
|
void fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response) override;
|
||||||
|
void onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request) override;
|
||||||
|
void onChannelError(const aasdk::error::Error& e) override;
|
||||||
|
void onTurnEvent(const aasdk::proto::messages::NavigationTurnEvent& turnEvent) override;
|
||||||
|
void onDistanceEvent(const aasdk::proto::messages::NavigationDistanceEvent& distanceEvent) override;
|
||||||
|
void onStatusUpdate(const aasdk::proto::messages::NavigationStatus& navStatus) override;
|
||||||
|
void setAndroidAutoInterface(IAndroidAutoInterface* aa_interface);
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
using std::enable_shared_from_this<NavigationStatusService>::shared_from_this;
|
||||||
|
|
||||||
|
boost::asio::io_service::strand strand_;
|
||||||
|
aasdk::channel::navigation::NavigationStatusServiceChannel::Pointer channel_;
|
||||||
|
IAndroidAutoInterface* aa_interface_ = nullptr;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -18,14 +18,10 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <f1x/openauto/autoapp/Service/IPinger.hpp>
|
#include "IPinger.hpp"
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace service
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -54,5 +50,3 @@ private:
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
@ -18,22 +18,18 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <f1x/aasdk/Channel/Sensor/SensorServiceChannel.hpp>
|
#include "aasdk/Channel/Sensor/SensorServiceChannel.hpp"
|
||||||
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
#include "IService.hpp"
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace service
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
class SensorService: public aasdk::channel::sensor::ISensorServiceChannelEventHandler, public IService, public std::enable_shared_from_this<SensorService>
|
class SensorService: public aasdk::channel::sensor::ISensorServiceChannelEventHandler, public IService, public std::enable_shared_from_this<SensorService>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SensorService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger);
|
SensorService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, bool nightMode=false);
|
||||||
|
|
||||||
void start() override;
|
void start() override;
|
||||||
void stop() override;
|
void stop() override;
|
||||||
@ -41,6 +37,7 @@ public:
|
|||||||
void onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request) override;
|
void onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request) override;
|
||||||
void onSensorStartRequest(const aasdk::proto::messages::SensorStartRequestMessage& request) override;
|
void onSensorStartRequest(const aasdk::proto::messages::SensorStartRequestMessage& request) override;
|
||||||
void onChannelError(const aasdk::error::Error& e) override;
|
void onChannelError(const aasdk::error::Error& e) override;
|
||||||
|
void setNightMode(bool nightMode);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using std::enable_shared_from_this<SensorService>::shared_from_this;
|
using std::enable_shared_from_this<SensorService>::shared_from_this;
|
||||||
@ -49,9 +46,8 @@ private:
|
|||||||
|
|
||||||
boost::asio::io_service::strand strand_;
|
boost::asio::io_service::strand strand_;
|
||||||
aasdk::channel::sensor::SensorServiceChannel::Pointer channel_;
|
aasdk::channel::sensor::SensorServiceChannel::Pointer channel_;
|
||||||
|
bool nightMode_;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
86
include/openauto/Service/ServiceFactory.hpp
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
#include "openauto/Service/IServiceFactory.hpp"
|
||||||
|
#include "openauto/Configuration/IConfiguration.hpp"
|
||||||
|
#include "openauto/Projection/InputDevice.hpp"
|
||||||
|
#include "openauto/Projection/OMXVideoOutput.hpp"
|
||||||
|
#include "openauto/Projection/GSTVideoOutput.hpp"
|
||||||
|
#include "openauto/Projection/QtVideoOutput.hpp"
|
||||||
|
#include "openauto/Service/MediaStatusService.hpp"
|
||||||
|
#include "openauto/Service/NavigationStatusService.hpp"
|
||||||
|
#include "openauto/Service/SensorService.hpp"
|
||||||
|
#include "openauto/Service/InputService.hpp"
|
||||||
|
#include "btservice/btservice.hpp"
|
||||||
|
|
||||||
|
namespace openauto
|
||||||
|
{
|
||||||
|
namespace service
|
||||||
|
{
|
||||||
|
class IAndroidAutoInterface;
|
||||||
|
class ServiceFactory : public IServiceFactory
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ServiceFactory(boost::asio::io_service& ioService, configuration::IConfiguration::Pointer configuration, QWidget* activeArea=nullptr, std::function<void(bool)> activeCallback=nullptr, bool nightMode=false);
|
||||||
|
ServiceList create(aasdk::messenger::IMessenger::Pointer messenger) override;
|
||||||
|
void setOpacity(unsigned int alpha);
|
||||||
|
void resize();
|
||||||
|
void setNightMode(bool nightMode);
|
||||||
|
void sendButtonPress(aasdk::proto::enums::ButtonCode::Enum buttonCode, projection::WheelDirection wheelDirection = projection::WheelDirection::NONE, projection::ButtonEventType buttonEventType = projection::ButtonEventType::NONE);
|
||||||
|
void sendKeyEvent(QKeyEvent* event);
|
||||||
|
void setAndroidAutoInterface(IAndroidAutoInterface* aa_interface);
|
||||||
|
void sendButtonPressFromString(const std::string& btn, const int state);
|
||||||
|
static QRect mapActiveAreaToGlobal(QWidget* activeArea);
|
||||||
|
#ifdef USE_OMX
|
||||||
|
static projection::DestRect QRectToDestRect(QRect rect);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
private:
|
||||||
|
IService::Pointer createVideoService(aasdk::messenger::IMessenger::Pointer messenger);
|
||||||
|
IService::Pointer createBluetoothService(aasdk::messenger::IMessenger::Pointer messenger);
|
||||||
|
std::shared_ptr<NavigationStatusService> createNavigationStatusService(aasdk::messenger::IMessenger::Pointer messenger);
|
||||||
|
std::shared_ptr<MediaStatusService> createMediaStatusService(aasdk::messenger::IMessenger::Pointer messenger);
|
||||||
|
std::shared_ptr<InputService> createInputService(aasdk::messenger::IMessenger::Pointer messenger);
|
||||||
|
void createAudioServices(ServiceList& serviceList, aasdk::messenger::IMessenger::Pointer messenger);
|
||||||
|
|
||||||
|
boost::asio::io_service& ioService_;
|
||||||
|
configuration::IConfiguration::Pointer configuration_;
|
||||||
|
QWidget* activeArea_;
|
||||||
|
QRect screenGeometry_;
|
||||||
|
std::function<void(bool)> activeCallback_;
|
||||||
|
std::shared_ptr<projection::InputDevice> inputDevice_;
|
||||||
|
#if defined USE_OMX
|
||||||
|
std::shared_ptr<projection::OMXVideoOutput> omxVideoOutput_;
|
||||||
|
#elif defined USE_GST
|
||||||
|
std::shared_ptr<projection::GSTVideoOutput> gstVideoOutput_;
|
||||||
|
#else
|
||||||
|
projection::QtVideoOutput *qtVideoOutput_;
|
||||||
|
#endif
|
||||||
|
btservice::btservice btservice_;
|
||||||
|
bool nightMode_;
|
||||||
|
std::weak_ptr<SensorService> sensorService_;
|
||||||
|
std::weak_ptr<InputService> inputService_;
|
||||||
|
std::weak_ptr<MediaStatusService> mediaStatusService_;
|
||||||
|
std::weak_ptr<NavigationStatusService> navStatusService_;
|
||||||
|
IAndroidAutoInterface* aa_interface_ = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -18,15 +18,11 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <f1x/aasdk/Messenger/IMessenger.hpp>
|
#include "aasdk/Messenger/IMessenger.hpp"
|
||||||
#include <f1x/openauto/autoapp/Service/AudioService.hpp>
|
#include "AudioService.hpp"
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace service
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -38,5 +34,3 @@ public:
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
@ -18,15 +18,11 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <f1x/aasdk/Messenger/IMessenger.hpp>
|
#include "aasdk/Messenger/IMessenger.hpp"
|
||||||
#include <f1x/openauto/autoapp/Service/AudioService.hpp>
|
#include "AudioService.hpp"
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace service
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -38,5 +34,3 @@ public:
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
@ -19,17 +19,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <f1x/aasdk/Channel/AV/VideoServiceChannel.hpp>
|
#include "aasdk/Channel/AV/VideoServiceChannel.hpp"
|
||||||
#include <f1x/aasdk/Channel/AV/IVideoServiceChannelEventHandler.hpp>
|
#include "aasdk/Channel/AV/IVideoServiceChannelEventHandler.hpp"
|
||||||
#include <f1x/openauto/autoapp/Projection/IVideoOutput.hpp>
|
#include "openauto/Projection/IVideoOutput.hpp"
|
||||||
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
#include "IService.hpp"
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace service
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -46,6 +42,7 @@ public:
|
|||||||
void onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request) override;
|
void onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request) override;
|
||||||
void onAVChannelSetupRequest(const aasdk::proto::messages::AVChannelSetupRequest& request) override;
|
void onAVChannelSetupRequest(const aasdk::proto::messages::AVChannelSetupRequest& request) override;
|
||||||
void onAVChannelStartIndication(const aasdk::proto::messages::AVChannelStartIndication& indication) override;
|
void onAVChannelStartIndication(const aasdk::proto::messages::AVChannelStartIndication& indication) override;
|
||||||
|
void onAVChannelStopIndication(const aasdk::proto::messages::AVChannelStopIndication& indication) override;
|
||||||
void onAVMediaWithTimestampIndication(aasdk::messenger::Timestamp::ValueType timestamp, const aasdk::common::DataConstBuffer& buffer) override;
|
void onAVMediaWithTimestampIndication(aasdk::messenger::Timestamp::ValueType timestamp, const aasdk::common::DataConstBuffer& buffer) override;
|
||||||
void onAVMediaIndication(const aasdk::common::DataConstBuffer& buffer) override;
|
void onAVMediaIndication(const aasdk::common::DataConstBuffer& buffer) override;
|
||||||
void onVideoFocusRequest(const aasdk::proto::messages::VideoFocusRequest& request) override;
|
void onVideoFocusRequest(const aasdk::proto::messages::VideoFocusRequest& request) override;
|
||||||
@ -63,5 +60,3 @@ private:
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
@ -17,19 +17,15 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <f1x/aasdk/USB/AOAPDevice.hpp>
|
#include "aasdk/USB/AOAPDevice.hpp"
|
||||||
#include <f1x/aasdk/TCP/TCPEndpoint.hpp>
|
#include "aasdk/TCP/TCPEndpoint.hpp"
|
||||||
#include <f1x/openauto/autoapp/App.hpp>
|
#include "openauto/App.hpp"
|
||||||
#include <f1x/openauto/Common/Log.hpp>
|
#include "OpenautoLog.hpp"
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
namespace openauto
|
||||||
{
|
{
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
|
|
||||||
App::App(boost::asio::io_service& ioService, aasdk::usb::USBWrapper& usbWrapper, aasdk::tcp::ITCPWrapper& tcpWrapper, service::IAndroidAutoEntityFactory& androidAutoEntityFactory,
|
App::App(boost::asio::io_service& ioService, aasdk::usb::USBWrapper& usbWrapper, aasdk::tcp::ITCPWrapper& tcpWrapper, openauto::service::IAndroidAutoEntityFactory& androidAutoEntityFactory,
|
||||||
aasdk::usb::IUSBHub::Pointer usbHub, aasdk::usb::IConnectedAccessoriesEnumerator::Pointer connectedAccessoriesEnumerator)
|
aasdk::usb::IUSBHub::Pointer usbHub, aasdk::usb::IConnectedAccessoriesEnumerator::Pointer connectedAccessoriesEnumerator)
|
||||||
: ioService_(ioService)
|
: ioService_(ioService)
|
||||||
, usbWrapper_(usbWrapper)
|
, usbWrapper_(usbWrapper)
|
||||||
@ -37,22 +33,30 @@ App::App(boost::asio::io_service& ioService, aasdk::usb::USBWrapper& usbWrapper,
|
|||||||
, strand_(ioService_)
|
, strand_(ioService_)
|
||||||
, androidAutoEntityFactory_(androidAutoEntityFactory)
|
, androidAutoEntityFactory_(androidAutoEntityFactory)
|
||||||
, usbHub_(std::move(usbHub))
|
, usbHub_(std::move(usbHub))
|
||||||
|
, acceptor_(ioService_, boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), 5000))
|
||||||
, connectedAccessoriesEnumerator_(std::move(connectedAccessoriesEnumerator))
|
, connectedAccessoriesEnumerator_(std::move(connectedAccessoriesEnumerator))
|
||||||
, isStopped_(false)
|
, isStopped_(false)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::waitForUSBDevice()
|
void App::waitForDevice(bool enumerate)
|
||||||
{
|
{
|
||||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
this->waitForUSBDevice();
|
||||||
this->waitForDevice();
|
this->waitForWirelessDevice();
|
||||||
this->enumerateDevices();
|
|
||||||
});
|
if(enumerate)
|
||||||
|
{
|
||||||
|
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||||
|
this->enumerateDevices();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::start(aasdk::tcp::ITCPEndpoint::SocketPointer socket)
|
void App::start(aasdk::tcp::ITCPEndpoint::SocketPointer socket)
|
||||||
{
|
{
|
||||||
|
OPENAUTO_LOG(info) << "[App] Wireless Device connected.";
|
||||||
|
|
||||||
strand_.dispatch([this, self = this->shared_from_this(), socket = std::move(socket)]() mutable {
|
strand_.dispatch([this, self = this->shared_from_this(), socket = std::move(socket)]() mutable {
|
||||||
if(androidAutoEntity_ != nullptr)
|
if(androidAutoEntity_ != nullptr)
|
||||||
{
|
{
|
||||||
@ -97,7 +101,7 @@ void App::stop()
|
|||||||
|
|
||||||
void App::aoapDeviceHandler(aasdk::usb::DeviceHandle deviceHandle)
|
void App::aoapDeviceHandler(aasdk::usb::DeviceHandle deviceHandle)
|
||||||
{
|
{
|
||||||
OPENAUTO_LOG(info) << "[App] Device connected.";
|
OPENAUTO_LOG(info) << "[App] USB Device connected.";
|
||||||
|
|
||||||
if(androidAutoEntity_ != nullptr)
|
if(androidAutoEntity_ != nullptr)
|
||||||
{
|
{
|
||||||
@ -135,9 +139,9 @@ void App::enumerateDevices()
|
|||||||
connectedAccessoriesEnumerator_->enumerate(std::move(promise));
|
connectedAccessoriesEnumerator_->enumerate(std::move(promise));
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::waitForDevice()
|
void App::waitForUSBDevice()
|
||||||
{
|
{
|
||||||
OPENAUTO_LOG(info) << "[App] Waiting for device...";
|
OPENAUTO_LOG(info) << "[App] Waiting for USB device...";
|
||||||
|
|
||||||
auto promise = aasdk::usb::IUSBHub::Promise::defer(strand_);
|
auto promise = aasdk::usb::IUSBHub::Promise::defer(strand_);
|
||||||
promise->then(std::bind(&App::aoapDeviceHandler, this->shared_from_this(), std::placeholders::_1),
|
promise->then(std::bind(&App::aoapDeviceHandler, this->shared_from_this(), std::placeholders::_1),
|
||||||
@ -145,6 +149,14 @@ void App::waitForDevice()
|
|||||||
usbHub_->start(std::move(promise));
|
usbHub_->start(std::move(promise));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void App::waitForWirelessDevice()
|
||||||
|
{
|
||||||
|
OPENAUTO_LOG(info) << "[App] Waiting for Wireless device...";
|
||||||
|
|
||||||
|
auto socket = std::make_shared<boost::asio::ip::tcp::socket>(ioService_);
|
||||||
|
acceptor_.async_accept(*socket, [this, socket](const boost::system::error_code &) { this->start(socket); });
|
||||||
|
}
|
||||||
|
|
||||||
void App::onAndroidAutoQuit()
|
void App::onAndroidAutoQuit()
|
||||||
{
|
{
|
||||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||||
@ -172,5 +184,3 @@ void App::onUSBHubError(const aasdk::error::Error& error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|