Compare commits

...

80 Commits

Author SHA1 Message Date
cab79ecd5f final fixes 2025-05-17 17:31:25 +03:00
94f5f5a382 fix button injection 2025-05-13 02:08:40 +03:00
4e265958eb initial button injection implementation 2025-05-11 18:39:23 +03:00
e30db459c6 refactor ws code and add remote wireless aa connect 2025-05-10 03:13:20 +03:00
b563281f78 add bt radio screen 2025-04-26 18:09:55 +03:00
58f7c65875 working websocket 2025-04-25 18:18:51 +03:00
381dcfa102 Merge branch 'develop' of https://git.tzatzikiweeb.moe/tza/openauto into develop 2025-04-24 21:05:34 +03:00
31ccf2a5c7 implement ws 2025-04-24 21:04:41 +03:00
6879a69ca1 remove dbus stuff 2025-04-24 17:48:20 +03:00
ccbef3b3e8 fix names again 2025-04-21 19:45:55 +03:00
d8d6568963 fix names 2025-04-21 19:44:50 +03:00
4ab5a162c4 Switch to opendsh openauto 2025-04-21 19:04:52 +03:00
deadmasterog
e7caeb4d49
use static mutex member in RtAudioOutput class to serialize RtAudio calls across instances (#32) 2024-10-22 21:32:09 -05:00
Cole Brinsfield
6496f8e360
gstreamer pipeline updates, pi bt updates. (#29)
* new services being added to openauto

* cmake for new services

* MediaStatusService, transitioning away from qt gstreamer

* Reverting change to qmlglsink as it's not functional on raspbian as of this moment

* Multitouch support within android auto

* add night mode toggle to aainterface

* Dot dump debug functionality

* NavigationStatusService, MediaStatusService, AAInterface, Hotkey migration

* Add a delay to dot dumping because caps aren't selected until data is streaming, so we can't rely on just a PLAYING status

* Update btservice connection method for pi4

* Update for pi4 compiling

* missing brace

* Yet another new bt connect process

* oops bad merge

* bad merge

* Remove pi specific bt connection

* Try to play nice with bullseye

* Select decoder automatically based on priority list

* Quick cleanup
2022-07-13 00:46:00 -05:00
Cole Brinsfield
8fa72b4f43
whitescreen workaround (#27)
* Terrible, Horrible, No Good, Very Bad Hack for h264

* Add setting to turn on this terrible hack

* Handle multiple video resolutions

* Use h264bitstream to do this better

* Remove all parameters we don't want

* Cleaning things up a little

* Renaming whitescreen workaround, defaulting to on
2022-02-12 14:33:02 -06:00
Cole Brinsfield
e2b6985d87
Navigation Status Service, Media Status Service, Touchscreen Multitouch Support, AAInterface (#26)
* new services being added to openauto

* cmake for new services

* MediaStatusService, transitioning away from qt gstreamer

* Reverting change to qmlglsink as it's not functional on raspbian as of this moment

* Multitouch support within android auto

* add night mode toggle to aainterface

* Dot dump debug functionality

* NavigationStatusService, MediaStatusService, AAInterface, Hotkey migration

* Add a delay to dot dumping because caps aren't selected until data is streaming, so we can't rely on just a PLAYING status

* PR cleanup
2022-01-20 11:47:15 -06:00
Matthew Hilton
cf77993f3c
switch patch version to use git hash (#25)
* switched patch version to use git hash

* added message to output version
2021-12-25 11:53:05 -06:00
Matthew Hilton
618a014100
add cpack support (#24)
Added CPack support
Fixed error with RPI_REVISION/RPI_MODEL IF not matching
2021-08-01 21:17:03 -05:00
Cole Brinsfield
efb9d8bc6f
Allow for scroll wheel injection (#23)
* Working on proper resizing of AA

* allow for custom aspect ratios

* A mess of code to support sending input events from dash

* Restructuring input injection to be much nicer

* Code Cleanup

* Allow for scroll wheel injection
2021-07-25 18:03:08 -07:00
Cole Brinsfield
658005da61
input service binding (#22)
* Working on proper resizing of AA

* allow for custom aspect ratios

* A mess of code to support sending input events from dash

* Restructuring input injection to be much nicer

* Code Cleanup
2021-07-15 18:11:59 -05:00
Cole Brinsfield
e940b8036e
custom aspect ratios (#21)
* Working on proper resizing of AA

* allow for custom aspect ratios
2021-05-21 21:59:57 -05:00
Cole Brinsfield
94ee66acd7
try connect to last bluetooth device (#20)
* Working on cleaning wifi

* Reworked bluetooth handshake based around @presslab-us's work

* Forgot to remove a line

* QOL: try to reconnect to last phone BT on openauto start

* bt autoconnect raspberry pi workaround

* Try to connect to last successful bluetooth device

* Bad merge fix

* pointers

* typo

* Update SocketInfoResponse.proto

* Added a config option to autoconnect to last bt device (defaults off)
2021-02-01 21:10:38 -06:00
Zero
5554052d84
Fix install for btservice_proto (#19) 2020-12-21 12:21:32 -06:00
Cole Brinsfield
3d96b6e6e3
bluetooth handshake / wifi rework (#18)
* Working on cleaning wifi

* Reworked bluetooth handshake based around @presslab-us's work

* Forgot to remove a line
2020-12-20 20:36:38 -06:00
Cole Brinsfield
88833fb5db
decode pi revision to grab model (#17) 2020-12-04 21:44:53 -06:00
Robert Stanley Judka
23c38158ee
cleanup wireless device connection (#14)
* initial cleanup passthrough

* bad copypaste

* add back ! and more style fixes

* handling ping and voice session
2020-08-28 17:36:43 -05:00
Robert Judka
ae66394b6b [HOTFIX] revert handling ping and voice session until aasdk change 2020-08-26 22:35:40 -05:00
Cole Brinsfield
50e077aa6e
automatic wireless device connection (#12)
* fix for omx when performing GST build

* wireless android auto bluetooth negotation

* Grab local bluetooth adapter

* Handling ping and voice session

* wait for both usb and wifi device ]connections

* Make btservice launch with openauto, allows for wireless connection automatically

* WiFi hotspot info pulled from openauto config

* Install btservice correctly

Co-authored-by: Rhys_M <rhys1802@hotmail.co.uk>
Co-authored-by: Robert Judka <robertjudka@gmail.com>
2020-08-26 19:48:36 -05:00
rhysmorgan134
88f71b813a
exclude omx when performing GST build (#11) 2020-08-09 17:47:05 -05:00
stefan-sherwood
310b346b3c
Updated Rpi4 revision list, improved readability of code (#10)
Co-authored-by: Stefan Sherwood <miraculum1@gmail.com>
2020-07-20 17:25:24 -05:00
Jason Wenger
c3f9c29ce7
Merge pull request #9 from jcwenger/feature/directory-structure
Feature/directory structure
2020-07-11 23:34:05 -05:00
Jason C. Wenger
35140352a6 Correct mistaken search/replace 2020-07-11 22:23:35 -05:00
Jason C. Wenger
bb0881e827 Correct relative paths 2020-07-11 22:01:08 -05:00
Jason C. Wenger
323c231d36 Convert tabs to spaces 2020-07-11 22:00:57 -05:00
Jason C. Wenger
f49b04b4e0 Correct linker paths after install. 2020-07-11 00:51:03 -05:00
Jason C. Wenger
6cc5a32016 Rearrange directory structure, namespaces, CMakeLists. 2020-07-11 00:51:03 -05:00
Jason C. Wenger
aef4b99cdf Hide psabi warnings regardless of GCC version 2020-07-10 11:18:54 -05:00
Jason C. Wenger
234ba0b22a CMakeLists cleanup 2020-07-09 21:19:21 -05:00
Jason C. Wenger
e541a042f1 Restore "Add OMX as a module"
This reverts commit 8bbef14efa4a30578654cfb4116f5a70b80c1d8f.
2020-07-09 20:49:35 -05:00
Jason Wenger
f18bce9e12
Merge pull request #8 from jcwenger/feature/deconflict-omx
Fold in gstreamer support -- fix conflicts with cmake module updates.
2020-07-09 19:21:02 -05:00
Jason C. Wenger
97be374a75 Deconflict changes with libOMX 2020-07-04 10:57:00 -05:00
Jason C. Wenger
8bbef14efa Partially revert "Add OMX as a module"
This reverts commit 16cec35bdde00615bdaec602b1b24646d067acbc.
2020-07-04 10:37:20 -05:00
Robert Stanley Judka
c1898e2dfc
Merge pull request #6 from kylegordon/develop
Build info for openauto
2020-06-30 09:24:16 -05:00
Kyle Gordon
7b52391020 Remove outdated contact info 2020-06-30 11:25:17 +01:00
Kyle Gordon
1357f96d4e aasdk required 2020-06-29 21:56:48 +01:00
Kyle Gordon
a2b54630b0 Build instructions 2020-06-29 21:36:18 +01:00
Kyle Gordon
5867a24f7f Shuffle original project info 2020-06-29 13:13:06 +01:00
Robert Stanley Judka
c806b15b61
add interface to send keyevents (#5)
* explicitly send keyevent to input device; style cleanup

* more style updates

* more style conformity
2020-06-22 15:59:33 -05:00
Jason Wenger
2f42c809c5
Merge pull request #3 from jcwenger/feature/warnings
Feature/warnings
2020-06-06 12:31:54 -10:00
Jason C. Wenger
ef47eecefa Strip extra whitespace 2020-05-25 21:45:41 -05:00
Robert Stanley Judka
5b0543ac10
add gstreamer support (#4)
* Implementing Gstreamer projection

* Moved back to QtQuick video sink, still no display

* "works" but spikes cpu

* merge upstream develop

* Missed a merge conflict

* added resize

* GSTVideoOutput works within ia openauto frame now

* Fixed up cmake for gst

* Add destructor for GST

* Added PI4 support

* Accidently added a bad cmake run at some point

* Stylistic changes

* Cleaning up unused variables

* Stylistic update

* Stylistic Changes

* Quick merge fix

* Review feedback

* Post review feedback

* Left handed pointers/CMake fix

Co-authored-by: Cole Brinsfield <brinsfield.cole@gmail.com>
2020-05-25 21:27:32 -05:00
Jason C. Wenger
7472369979 Support install 2020-05-25 17:34:55 -05:00
Jason C. Wenger
7506df26ee FPIC isn't necessary. Already provided. 2020-05-25 16:19:36 -05:00
Jason C. Wenger
1bd667da51 Hide GCC psabi warnings 2020-05-25 16:19:36 -05:00
Jason C. Wenger
16cec35bdd Add OMX as a module 2020-05-25 16:19:36 -05:00
Jason C. Wenger
df63241827 Mute const char* warnings related to ilclient
This does not actually fix the problem.  The right answer is for ilclient API to declare const char*, but they're system headers right now, so we work around.
2020-05-25 16:19:36 -05:00
Jason C. Wenger
e350341bfd Fix system warnings about libusb zero-size arrays 2020-05-25 16:19:36 -05:00
Jason C. Wenger
1100f7155c Add ccache support 2020-05-25 16:19:36 -05:00
Jason C. Wenger
fe4e5522ed Add zlib requirement
# Conflicts:
#	CMakeLists.txt
2020-05-25 16:19:36 -05:00
Jason C. Wenger
38b95057e9 find aasdk as a module 2020-05-25 16:19:36 -05:00
Robert Stanley Judka
254382acf6
fix fragile qtvideooutput (#3) 2020-05-16 19:14:48 -05:00
Robert Judka
6cda29433a use weak pointer for sensor service to track actual lifetime 2020-04-26 00:46:57 -05:00
Robert Stanley Judka
464da85686
add interface to allow for night mode control (#2) 2020-04-25 23:49:33 -05:00
Robert Stanley Judka
5f8d5f4f6a
add interfaces to dynamically adjust video size (#1)
* adding interfaces for toggling fullscreen

* passing in destrect to omx

* adding flag for deffering video update

* remove skipUpdate option for video output

* fixing omx player stop deadlock; setting omx alpha in constructor

* jk not setting opacity in constructor for omx

* removing unsed function
2020-03-22 16:08:44 -05:00
Robert Judka
5df4b957a1 updating path for cmake modules 2020-03-07 19:37:43 -06:00
Robert Judka
ae5a21a75e updates to make things work (stolen from other people); modifying interfaces for qt support 2020-03-06 13:43:39 -06:00
michal.szwaj
7513d99929 Merge remote-tracking branch 'remotes/origin/development' 2018-09-14 22:06:32 +02:00
michal.szwaj
6dc394c11f Update readme 2018-09-14 22:03:55 +02:00
michal.szwaj
70bc8a2f03 Merge remote-tracking branch 'remotes/origin/development' 2018-06-01 02:00:07 +02:00
michal.szwaj
0cfcab6d51 Adjust position of the controls 2018-06-01 01:59:26 +02:00
michal.szwaj
f3c6bf2d55 Merge remote-tracking branch 'remotes/origin/development' 2018-06-01 01:48:14 +02:00
michal.szwaj
eea5b1ea80 Reorganize layout of main window 2018-06-01 01:47:53 +02:00
michal.szwaj
c3d5ea8674 Merge remote-tracking branch 'remotes/origin/development' 2018-05-31 21:26:41 +02:00
michal.szwaj
7b2210268f Adjust positions 2018-05-31 21:25:35 +02:00
michal.szwaj
5c607f74e5 Merge remote-tracking branch 'remotes/origin/development' 2018-05-31 21:16:56 +02:00
michal.szwaj
77b5cc02fc Put additional information to the main screen 2018-05-31 21:16:28 +02:00
michal.szwaj
0f71738344 Merge remote-tracking branch 'remotes/origin/development' 2018-05-29 19:40:33 +02:00
michal.szwaj
ced8e22031 Update readme 2018-05-29 19:40:06 +02:00
michal.szwaj
400302901a Update readme 2018-05-29 19:34:00 +02:00
michal.szwaj
3df9958f6f Update Readme 2018-05-29 19:30:27 +02:00
137 changed files with 4128 additions and 1731 deletions

21
.gitignore vendored
View File

@ -1,4 +1,23 @@
# Add any directories, files, or patterns you don't want to be tracked by version control
.vscode/
lib/
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

View File

@ -1,100 +1,128 @@
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_AUTOUIC 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(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${base_directory}/lib)
set(base_directory ${CMAKE_CURRENT_SOURCE_DIR})
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(EXECUTABLE_OUTPUT_PATH ${base_directory}/bin)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake_modules/")
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_MULTITHREADED ON)
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)
find_package(Boost REQUIRED COMPONENTS system log OPTIONAL_COMPONENTS unit_test_framework)
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(OpenSSL REQUIRED)
find_package(rtaudio REQUIRED)
find_package(aasdk REQUIRED)
find_package(h264 REQUIRED)
find_package(Threads)
if(WIN32)
set(WINSOCK2_LIBRARIES "ws2_32")
endif(WIN32)
include(${base_directory}/cmake_modules/gitversion.cmake)
if(RPI_BUILD)
find_package(libomx)
endif()
if(RPI3_BUILD)
add_definitions(-DUSE_OMX -DOMX_SKIP64BIT -DRASPBERRYPI3)
set(BCM_HOST_LIBRARIES "/opt/vc/lib/libbcm_host.so")
set(BCM_HOST_INCLUDE_DIRS "/opt/vc/include")
set(ILCLIENT_INCLUDE_DIRS "/opt/vc/src/hello_pi/libs/ilclient")
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")
endif(RPI3_BUILD)
if(GST_BUILD)
find_package(GObject)
find_package(Qt5GStreamer)
find_package(PkgConfig REQUIRED)
pkg_check_modules(GST REQUIRED
gstreamer-1.0>=1.4
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}
${Qt5Multimedia_INCLUDE_DIRS}
${Qt5MultimediaWidgets_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})
add_subdirectory(btservice_proto)
set(BTSERVICE_PROTO_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR})
include_directories(${BTSERVICE_PROTO_INCLUDE_DIRS})
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(autoapp_include_directory ${include_directory}/f1x/openauto/autoapp)
file(GLOB_RECURSE autoapp_source_files ${autoapp_sources_directory}/*.ui ${autoapp_sources_directory}/*.cpp ${autoapp_include_directory}/*.hpp ${common_include_directory}/*.hpp ${resources_directory}/*.qrc)
set (openauto_VERSION_PATCH ${_build_version})
set (openauto_VERSION_STRING ${openauto_VERSION_MAJOR}.${openauto_VERSION_MINOR}.${openauto_VERSION_PATCH})
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
${Boost_LIBRARIES}
${Qt5Multimedia_LIBRARIES}
${Qt5MultimediaWidgets_LIBRARIES}
${Qt5Bluetooth_LIBRARIES}
${LIBUSB_1_LIBRARIES}
${PROTOBUF_LIBRARIES}
${BCM_HOST_LIBRARIES}
${ILCLIENT_LIBRARIES}
${WINSOCK2_LIBRARIES}
${RTAUDIO_LIBRARIES}
${AASDK_PROTO_LIBRARIES}
${AASDK_LIBRARIES})
set(btservice_sources_directory ${sources_directory}/btservice)
set(btservice_include_directory ${include_directory}/f1x/openauto/btservice)
file(GLOB_RECURSE btservice_source_files ${btservice_sources_directory}/*.cpp ${btservice_include_directory}/*.hpp ${common_include_directory}/*.hpp)
add_executable(btservice ${btservice_source_files})
target_link_libraries(btservice
${Boost_LIBRARIES}
${Qt5Bluetooth_LIBRARIES}
${Qt5MultimediaWidgets_LIBRARIES}
${PROTOBUF_LIBRARIES}
${AASDK_PROTO_LIBRARIES})
SET(CPACK_GENERATOR "DEB")
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "OpenDsh") #required
SET(CPACK_PACKAGE_VENDOR "OpenDsh")
set(CPACK_PACKAGE_VERSION ${openauto_VERSION_STRING})
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
set(CPACK_COMPONENTS_ALL applications libraries headers Unspecified)
set(CPACK_COMPONENT_APPLICATIONS_DISPLAY_NAME "Applications")
set(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "Libraries")
set(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C++ Headers")
set(CPACK_COMPONENT_APPLICATIONS_DESCRIPTION
"Applications provided by OpenAuto")
set(CPACK_COMPONENT_LIBRARIES_DESCRIPTION
"Static libraries used to build programs with OpenAuto")
set(CPACK_COMPONENT_HEADERS_DESCRIPTION
"C/C++ header files for use with OpenAuto")
set(CPACK_COMPONENT_LIBRARIES_GROUP "Development")
set(CPACK_COMPONENT_HEADERS_GROUP "Development")
set(CPACK_COMPONENT_GROUP_DEVELOPMENT_EXPANDED ON)
set(CPACK_COMPONENT_GROUP_DEVELOPMENT_DESCRIPTION
"All of the tools you'll ever need to develop software")
set(CPACK_COMPONENT_HEADERS_DEPENDS libraries)
set(CPACK_COMPONENT_APPLICATIONS_DEPENDS libraries)
set(CPACK_ALL_INSTALL_TYPES Full Developer)
set(CPACK_INSTALL_TYPE_FULL_DISPLAY_NAME "Everything")
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)

View File

@ -1,11 +1,6 @@
# OpenAuto
### Support project
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](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
[![Join the chat at https://gitter.im/publiclab/publiclab](https://badges.gitter.im/Join%20Chat.svg)](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)
### 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
- 480p, 720p and 1080p with 30 or 60 FPS
- 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
### 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.**

View File

@ -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
View 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)

View 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
View 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();
}
}

View File

@ -17,19 +17,15 @@
*/
#include <QMessageBox>
#include <f1x/openauto/autoapp/UI/SettingsWindow.hpp>
#include "autoapp/UI/SettingsWindow.hpp"
#include "ui_settingswindow.h"
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace ui
{
SettingsWindow::SettingsWindow(configuration::IConfiguration::Pointer configuration, QWidget *parent)
SettingsWindow::SettingsWindow(openauto::configuration::IConfiguration::Pointer configuration, QWidget *parent)
: QWidget(parent)
, ui_(new Ui::SettingsWindow)
, configuration_(std::move(configuration))
@ -54,7 +50,7 @@ SettingsWindow::~SettingsWindow()
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_->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())
{
configuration_->setBluetoothAdapterType(configuration::BluetoothAdapterType::NONE);
configuration_->setBluetoothAdapterType(openauto::configuration::BluetoothAdapterType::NONE);
}
else if(ui_->radioButtonUseLocalBluetoothAdapter->isChecked())
{
configuration_->setBluetoothAdapterType(configuration::BluetoothAdapterType::LOCAL);
configuration_->setBluetoothAdapterType(openauto::configuration::BluetoothAdapterType::LOCAL);
}
else if(ui_->radioButtonUseExternalBluetoothAdapter->isChecked())
{
configuration_->setBluetoothAdapterType(configuration::BluetoothAdapterType::REMOTE);
configuration_->setBluetoothAdapterType(openauto::configuration::BluetoothAdapterType::REMOTE);
}
configuration_->setBluetoothRemoteAdapterAddress(ui_->lineEditExternalBluetoothAdapterAddress->text().toStdString());
configuration_->setMusicAudioChannelEnabled(ui_->checkBoxMusicAudioChannel->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();
this->close();
@ -122,8 +118,8 @@ void SettingsWindow::showEvent(QShowEvent* event)
void SettingsWindow::load()
{
ui_->radioButtonLeftHandDrive->setChecked(configuration_->getHandednessOfTrafficType() == configuration::HandednessOfTrafficType::LEFT_HAND_DRIVE);
ui_->radioButtonRightHandDrive->setChecked(configuration_->getHandednessOfTrafficType() == configuration::HandednessOfTrafficType::RIGHT_HAND_DRIVE);
ui_->radioButtonLeftHandDrive->setChecked(configuration_->getHandednessOfTrafficType() == openauto::configuration::HandednessOfTrafficType::LEFT_HAND_DRIVE);
ui_->radioButtonRightHandDrive->setChecked(configuration_->getHandednessOfTrafficType() == openauto::configuration::HandednessOfTrafficType::RIGHT_HAND_DRIVE);
ui_->checkBoxShowClock->setChecked(configuration_->showClock());
ui_->radioButton30FPS->setChecked(configuration_->getVideoFPS() == aasdk::proto::enums::VideoFPS::_30);
@ -142,18 +138,18 @@ void SettingsWindow::load()
ui_->checkBoxEnableTouchscreen->setChecked(configuration_->getTouchscreenEnabled());
this->loadButtonCheckBoxes();
ui_->radioButtonDisableBluetooth->setChecked(configuration_->getBluetoothAdapterType() == configuration::BluetoothAdapterType::NONE);
ui_->radioButtonUseLocalBluetoothAdapter->setChecked(configuration_->getBluetoothAdapterType() == configuration::BluetoothAdapterType::LOCAL);
ui_->radioButtonUseExternalBluetoothAdapter->setChecked(configuration_->getBluetoothAdapterType() == configuration::BluetoothAdapterType::REMOTE);
ui_->lineEditExternalBluetoothAdapterAddress->setEnabled(configuration_->getBluetoothAdapterType() == configuration::BluetoothAdapterType::REMOTE);
ui_->radioButtonDisableBluetooth->setChecked(configuration_->getBluetoothAdapterType() == openauto::configuration::BluetoothAdapterType::NONE);
ui_->radioButtonUseLocalBluetoothAdapter->setChecked(configuration_->getBluetoothAdapterType() == openauto::configuration::BluetoothAdapterType::LOCAL);
ui_->radioButtonUseExternalBluetoothAdapter->setChecked(configuration_->getBluetoothAdapterType() == openauto::configuration::BluetoothAdapterType::REMOTE);
ui_->lineEditExternalBluetoothAdapterAddress->setEnabled(configuration_->getBluetoothAdapterType() == openauto::configuration::BluetoothAdapterType::REMOTE);
ui_->lineEditExternalBluetoothAdapterAddress->setText(QString::fromStdString(configuration_->getBluetoothRemoteAdapterAddress()));
ui_->checkBoxMusicAudioChannel->setChecked(configuration_->musicAudioChannelEnabled());
ui_->checkBoxSpeechAudioChannel->setChecked(configuration_->speechAudioChannelEnabled());
const auto& audioOutputBackendType = configuration_->getAudioOutputBackendType();
ui_->radioButtonRtAudio->setChecked(audioOutputBackendType == configuration::AudioOutputBackendType::RTAUDIO);
ui_->radioButtonQtAudio->setChecked(audioOutputBackendType == configuration::AudioOutputBackendType::QT);
ui_->radioButtonRtAudio->setChecked(audioOutputBackendType == openauto::configuration::AudioOutputBackendType::RTAUDIO);
ui_->radioButtonQtAudio->setChecked(audioOutputBackendType == openauto::configuration::AudioOutputBackendType::QT);
}
void SettingsWindow::loadButtonCheckBoxes()
@ -199,7 +195,7 @@ void SettingsWindow::setButtonCheckBoxes(bool value)
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_->checkBoxPauseButton, buttonCodes, aasdk::proto::enums::ButtonCode::PAUSE);
this->saveButtonCheckBox(ui_->checkBoxTogglePlayButton, buttonCodes, aasdk::proto::enums::ButtonCode::TOGGLE_PLAY);
@ -219,7 +215,7 @@ void SettingsWindow::saveButtonCheckBoxes()
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())
{
@ -259,5 +255,3 @@ void SettingsWindow::onShowBindings()
}
}
}
}

464
autoapp/UI/mainwindow.ui Normal file
View 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>

View 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

Binary file not shown.

After

Width:  |  Height:  |  Size: 896 B

BIN
autoapp/assets/artist.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 935 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 931 B

View File

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

Before

Width:  |  Height:  |  Size: 438 B

After

Width:  |  Height:  |  Size: 438 B

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Before

Width:  |  Height:  |  Size: 751 B

After

Width:  |  Height:  |  Size: 751 B

BIN
autoapp/assets/radio.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 816 B

View 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

Binary file not shown.

After

Width:  |  Height:  |  Size: 821 B

194
autoapp/autoapp.cpp Normal file
View 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;
}

View 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;
}
}
}
}

View File

@ -16,10 +16,8 @@
* 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 btservice
@ -38,7 +36,7 @@ AndroidBluetoothService::AndroidBluetoothService(uint16_t portNumber)
serviceInfo_.setAttribute(QBluetoothServiceInfo::ServiceClassIds, classId);
serviceInfo_.setAttribute(QBluetoothServiceInfo::ServiceName, "OpenAuto Bluetooth Service");
serviceInfo_.setAttribute(QBluetoothServiceInfo::ServiceDescription, "AndroidAuto WiFi projection automatic setup");
serviceInfo_.setAttribute(QBluetoothServiceInfo::ServiceProvider, "f1xstudio.com");
serviceInfo_.setAttribute(QBluetoothServiceInfo::ServiceProvider, "openDsh");
serviceInfo_.setServiceUuid(serviceUuid);
QBluetoothServiceInfo::Sequence publicBrowse;
@ -51,7 +49,7 @@ AndroidBluetoothService::AndroidBluetoothService(uint16_t portNumber)
protocolDescriptorList.append(QVariant::fromValue(protocol));
protocol.clear();
protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::Rfcomm))
<< QVariant::fromValue(quint16(portNumber));
<< QVariant::fromValue(quint8(portNumber));
protocolDescriptorList.append(QVariant::fromValue(protocol));
serviceInfo_.setAttribute(QBluetoothServiceInfo::ProtocolDescriptorList, protocolDescriptorList);
}
@ -68,4 +66,3 @@ bool AndroidBluetoothService::unregisterService()
}
}
}

84
btservice/btservice.cpp Normal file
View 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();
}
}
}

View 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)

View 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;
}

View File

@ -0,0 +1,9 @@
syntax = "proto2";
package openauto.btservice.proto;
message SocketInfoRequest
{
required string ip_address = 1;
optional uint32 port = 2;
}

View 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;
}

View 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)

View 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
)

View 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)

View 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)

View 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()

View File

@ -49,14 +49,14 @@ if (LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS)
else (LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS)
find_path(LIBUSB_1_INCLUDE_DIR
NAMES
libusb.h
libusb.h
PATHS
/usr/include
/usr/local/include
/opt/local/include
/sw/include
PATH_SUFFIXES
libusb-1.0
PATH_SUFFIXES
libusb-1.0
)
find_library(LIBUSB_1_LIBRARY
@ -83,8 +83,11 @@ else (LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS)
if (LIBUSB_1_FOUND)
if (NOT libusb_1_FIND_QUIETLY)
message(STATUS "Found libusb-1.0:")
message(STATUS " - Includes: ${LIBUSB_1_INCLUDE_DIRS}")
message(STATUS " - Libraries: ${LIBUSB_1_LIBRARIES}")
message(STATUS " - Includes: ${LIBUSB_1_INCLUDE_DIRS}")
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)
else (LIBUSB_1_FOUND)
if (libusb_1_FIND_REQUIRED)

View File

@ -28,8 +28,8 @@ else (RTAUDIO_LIBRARIES AND RTAUDIO_INCLUDE_DIRS)
/usr/local/include
/opt/local/include
/sw/include
PATH_SUFFIXES
rtaudio
PATH_SUFFIXES
rtaudio
)
find_library(RTAUDIO_LIBRARY

View 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()

View 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

View File

@ -2,18 +2,14 @@
#include <QDialog>
#include <QStringListModel>
#include <f1x/aasdk/TCP/ITCPEndpoint.hpp>
#include <f1x/aasdk/TCP/ITCPWrapper.hpp>
#include <f1x/openauto/autoapp/Configuration/IRecentAddressesList.hpp>
#include "aasdk/TCP/ITCPEndpoint.hpp"
#include "aasdk/TCP/ITCPWrapper.hpp"
#include "openauto/Configuration/IRecentAddressesList.hpp"
namespace Ui {
class ConnectDialog;
}
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace ui
@ -24,8 +20,9 @@ class ConnectDialog : public QDialog
Q_OBJECT
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;
void connectToAddress(const QString& ip);
signals:
void connectToDevice(const QString& ipAddress);
@ -46,12 +43,10 @@ private:
boost::asio::io_service& ioService_;
aasdk::tcp::ITCPWrapper& tcpWrapper_;
openauto::autoapp::configuration::IRecentAddressesList& recentAddressesList_;
openauto::configuration::IRecentAddressesList& recentAddressesList_;
Ui::ConnectDialog *ui_;
QStringListModel recentAddressesModel_;
};
}
}
}
}

View File

@ -23,36 +23,32 @@
namespace Ui
{
class MainWindow;
class MainWindow;
}
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace ui
{
namespace ui
{
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = nullptr);
~MainWindow() override;
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = nullptr);
~MainWindow() override;
void handleIncomingMessage(const QJsonObject &rootObj);
signals:
void exit();
void openSettings();
void toggleCursor();
void openConnectDialog();
signals:
void exit();
void openSettings();
void toggleCursor();
void openConnectDialog();
private:
Ui::MainWindow* ui_;
};
private slots:
}
}
}
private:
Ui::MainWindow *ui_;
};
}
}

View File

@ -20,7 +20,7 @@
#include <memory>
#include <QWidget>
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
#include "openauto/Configuration/IConfiguration.hpp"
class QCheckBox;
@ -29,10 +29,6 @@ namespace Ui
class SettingsWindow;
}
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace ui
@ -42,7 +38,7 @@ class SettingsWindow : public QWidget
{
Q_OBJECT
public:
explicit SettingsWindow(configuration::IConfiguration::Pointer configuration, QWidget *parent = nullptr);
explicit SettingsWindow(openauto::configuration::IConfiguration::Pointer configuration, QWidget *parent = nullptr);
~SettingsWindow() override;
private slots:
@ -56,14 +52,12 @@ private:
void load();
void loadButtonCheckBoxes();
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);
Ui::SettingsWindow* ui_;
configuration::IConfiguration::Pointer configuration_;
openauto::configuration::IConfiguration::Pointer configuration_;
};
}
}
}
}

View 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);
};
}
}

View File

@ -19,10 +19,8 @@
#pragma once
#include <QBluetoothServiceInfo>
#include <f1x/openauto/btservice/IAndroidBluetoothService.hpp>
#include "IAndroidBluetoothService.hpp"
namespace f1x
{
namespace openauto
{
namespace btservice
@ -42,4 +40,3 @@ private:
}
}
}

View File

@ -20,8 +20,6 @@
#include <QBluetoothAddress>
namespace f1x
{
namespace openauto
{
namespace btservice
@ -37,4 +35,3 @@ public:
}
}
}

View File

@ -20,8 +20,6 @@
#include <QBluetoothAddress>
namespace f1x
{
namespace openauto
{
namespace btservice
@ -38,4 +36,3 @@ public:
}
}
}

View 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;
};
}
}

View File

@ -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_;
};
}
}
}
}

View File

@ -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_;
};
}
}
}

View File

@ -18,30 +18,26 @@
#pragma once
#include <f1x/aasdk/USB/IUSBHub.hpp>
#include <f1x/aasdk/USB/IConnectedAccessoriesEnumerator.hpp>
#include <f1x/aasdk/USB/USBWrapper.hpp>
#include <f1x/aasdk/TCP/ITCPWrapper.hpp>
#include <f1x/aasdk/TCP/ITCPEndpoint.hpp>
#include <f1x/openauto/autoapp/Service/IAndroidAutoEntityEventHandler.hpp>
#include <f1x/openauto/autoapp/Service/IAndroidAutoEntityFactory.hpp>
#include "aasdk/USB/IUSBHub.hpp"
#include "aasdk/USB/IConnectedAccessoriesEnumerator.hpp"
#include "aasdk/USB/USBWrapper.hpp"
#include "aasdk/TCP/ITCPWrapper.hpp"
#include "aasdk/TCP/ITCPEndpoint.hpp"
#include "openauto/Service/IAndroidAutoEntityEventHandler.hpp"
#include "openauto/Service/IAndroidAutoEntityFactory.hpp"
namespace f1x
{
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:
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);
void waitForUSBDevice();
void waitForDevice(bool enumerate = false);
void start(aasdk::tcp::ITCPEndpoint::SocketPointer socket);
void stop();
void onAndroidAutoQuit() override;
@ -49,7 +45,8 @@ public:
private:
using std::enable_shared_from_this<App>::shared_from_this;
void enumerateDevices();
void waitForDevice();
void waitForUSBDevice();
void waitForWirelessDevice();
void aoapDeviceHandler(aasdk::usb::DeviceHandle deviceHandle);
void onUSBHubError(const aasdk::error::Error& error);
@ -57,13 +54,12 @@ private:
aasdk::usb::USBWrapper& usbWrapper_;
aasdk::tcp::ITCPWrapper& tcpWrapper_;
boost::asio::io_service::strand strand_;
service::IAndroidAutoEntityFactory& androidAutoEntityFactory_;
openauto::service::IAndroidAutoEntityFactory& androidAutoEntityFactory_;
aasdk::usb::IUSBHub::Pointer usbHub_;
boost::asio::ip::tcp::acceptor acceptor_;
aasdk::usb::IConnectedAccessoriesEnumerator::Pointer connectedAccessoriesEnumerator_;
service::IAndroidAutoEntity::Pointer androidAutoEntity_;
openauto::service::IAndroidAutoEntity::Pointer androidAutoEntity_;
bool isStopped_;
};
}
}
}

View File

@ -18,12 +18,8 @@
#pragma once
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace configuration
{
@ -35,5 +31,3 @@ enum class AudioOutputBackendType
}
}
}
}

View File

@ -18,12 +18,8 @@
#pragma once
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace configuration
{
@ -36,5 +32,3 @@ enum class BluetoothAdapterType
}
}
}
}

View File

@ -19,14 +19,10 @@
#pragma once
#include <boost/property_tree/ini_parser.hpp>
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
#include "IConfiguration.hpp"
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace configuration
{
@ -54,6 +50,8 @@ public:
int32_t getOMXLayerIndex() const override;
void setVideoMargins(QRect value) override;
QRect getVideoMargins() const override;
void setWhitescreenWorkaround(bool value) override;
bool getWhitescreenWorkaround() const override;
bool getTouchscreenEnabled() const override;
void setTouchscreenEnabled(bool value) override;
@ -72,6 +70,17 @@ public:
AudioOutputBackendType getAudioOutputBackendType() const 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:
void readButtonCodes(boost::property_tree::ptree& iniConfig);
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_;
int32_t omxLayerIndex_;
QRect videoMargins_;
bool whitescreenWorkaround_;
bool enableTouchscreen_;
ButtonCodes buttonCodes_;
BluetoothAdapterType bluetoothAdapterType_;
@ -91,6 +101,11 @@ private:
bool musicAudioChannelEnabled_;
bool speechAudiochannelEnabled_;
AudioOutputBackendType audioOutputBackendType_;
std::string wifiSSID_;
std::string wifiPassword_;
std::string wifiMAC_;
bool autoconnectBluetooth_;
std::string lastBluetoothPair_;
static const std::string cConfigFileName;
@ -103,6 +118,7 @@ private:
static const std::string cVideoOMXLayerIndexKey;
static const std::string cVideoMarginWidth;
static const std::string cVideoMarginHeight;
static const std::string cVideoWhitescreenWorkaround;
static const std::string cAudioMusicAudioChannelEnabled;
static const std::string cAudioSpeechAudioChannelEnabled;
@ -128,9 +144,13 @@ private:
static const std::string cInputScrollWheelButtonKey;
static const std::string cInputBackButtonKey;
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;
};
}
}
}
}

View File

@ -18,12 +18,8 @@
#pragma once
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace configuration
{
@ -35,5 +31,3 @@ enum class HandednessOfTrafficType
}
}
}
}

View File

@ -20,19 +20,15 @@
#include <string>
#include <QRect>
#include <aasdk_proto/VideoFPSEnum.pb.h>
#include <aasdk_proto/VideoResolutionEnum.pb.h>
#include <aasdk_proto/ButtonCodeEnum.pb.h>
#include <f1x/openauto/autoapp/Configuration/BluetootAdapterType.hpp>
#include <f1x/openauto/autoapp/Configuration/HandednessOfTrafficType.hpp>
#include <f1x/openauto/autoapp/Configuration/AudioOutputBackendType.hpp>
#include "aasdk_proto/VideoFPSEnum.pb.h"
#include "aasdk_proto/VideoResolutionEnum.pb.h"
#include "aasdk_proto/ButtonCodeEnum.pb.h"
#include "BluetootAdapterType.hpp"
#include "HandednessOfTrafficType.hpp"
#include "AudioOutputBackendType.hpp"
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace configuration
{
@ -63,6 +59,8 @@ public:
virtual int32_t getOMXLayerIndex() const = 0;
virtual void setVideoMargins(QRect value) = 0;
virtual QRect getVideoMargins() const = 0;
virtual void setWhitescreenWorkaround(bool value) = 0;
virtual bool getWhitescreenWorkaround() const = 0;
virtual bool getTouchscreenEnabled() const = 0;
virtual void setTouchscreenEnabled(bool value) = 0;
@ -80,9 +78,18 @@ public:
virtual void setSpeechAudioChannelEnabled(bool value) = 0;
virtual AudioOutputBackendType getAudioOutputBackendType() const = 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;
};
}
}
}
}

View File

@ -21,12 +21,8 @@
#include <deque>
#include <string>
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace configuration
{
@ -42,5 +38,3 @@ public:
}
}
}
}

View File

@ -19,14 +19,10 @@
#pragma once
#include <deque>
#include <f1x/openauto/autoapp/Configuration/IRecentAddressesList.hpp>
#include "IRecentAddressesList.hpp"
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace configuration
{
@ -53,5 +49,3 @@ private:
}
}
}
}

View File

@ -18,14 +18,10 @@
#pragma once
#include <f1x/openauto/autoapp/Projection/IBluetoothDevice.hpp>
#include "IBluetoothDevice.hpp"
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace projection
{
@ -41,5 +37,3 @@ public:
}
}
}
}

View 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

View File

@ -19,15 +19,11 @@
#pragma once
#include <memory>
#include <f1x/aasdk/IO/Promise.hpp>
#include <f1x/aasdk/Common/Data.hpp>
#include "aasdk/IO/Promise.hpp"
#include "aasdk/Common/Data.hpp"
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace projection
{
@ -52,5 +48,3 @@ public:
}
}
}
}

View File

@ -19,15 +19,11 @@
#pragma once
#include <memory>
#include <f1x/aasdk/Messenger/Timestamp.hpp>
#include <f1x/aasdk/Common/Data.hpp>
#include "aasdk/Messenger/Timestamp.hpp"
#include "aasdk/Common/Data.hpp"
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace projection
{
@ -51,5 +47,3 @@ public:
}
}
}
}

View File

@ -16,16 +16,12 @@
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
*/
#include <f1x/aasdk/IO/Promise.hpp>
#include "aasdk/IO/Promise.hpp"
#pragma once
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace projection
{
@ -44,5 +40,3 @@ public:
}
}
}
}

View File

@ -19,15 +19,11 @@
#pragma once
#include <QRect>
#include <f1x/aasdk/IO/Promise.hpp>
#include <f1x/openauto/autoapp/Projection/InputEvent.hpp>
#include "aasdk/IO/Promise.hpp"
#include "InputEvent.hpp"
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace projection
{
@ -49,5 +45,3 @@ public:
}
}
}
}

View File

@ -18,14 +18,12 @@
#pragma once
#include <f1x/openauto/autoapp/Projection/InputEvent.hpp>
#include "InputEvent.hpp"
#include "aasdk_proto/InputEventIndicationMessage.pb.h"
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace projection
{
@ -35,10 +33,10 @@ public:
virtual ~IInputDeviceEventHandler() = default;
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;
};
}
}
}
}

View File

@ -20,16 +20,12 @@
#include <memory>
#include <QRect>
#include <aasdk_proto/VideoFPSEnum.pb.h>
#include <aasdk_proto/VideoResolutionEnum.pb.h>
#include <f1x/aasdk/Common/Data.hpp>
#include "aasdk_proto/VideoFPSEnum.pb.h"
#include "aasdk_proto/VideoResolutionEnum.pb.h"
#include "aasdk/Common/Data.hpp"
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace projection
{
@ -53,5 +49,3 @@ public:
}
}
}
}

View File

@ -20,15 +20,12 @@
#include <QObject>
#include <QKeyEvent>
#include <f1x/openauto/autoapp/Projection/IInputDevice.hpp>
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
#include "IInputDevice.hpp"
#include "openauto/Configuration/IConfiguration.hpp"
#include <bits/stdc++.h>
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace projection
{
@ -45,12 +42,14 @@ public:
bool eventFilter(QObject* obj, QEvent* event) override;
bool hasTouchscreen() const override;
QRect getTouchscreenGeometry() const override;
void setTouchscreenGeometry(QRect& touchscreenGeometry);
private:
void setVideoGeometry();
bool handleKeyEvent(QEvent* event, QKeyEvent* key);
void dispatchKeyEvent(ButtonEvent event);
bool handleTouchEvent(QEvent* event);
bool handleMouseEvent(QEvent* event);
QObject& parent_;
configuration::IConfiguration::Pointer configuration_;
@ -58,9 +57,11 @@ private:
QRect displayGeometry_;
IInputDeviceEventHandler* eventHandler_;
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;
};
}
}
}
}

View File

@ -18,16 +18,12 @@
#pragma once
#include <aasdk_proto/ButtonCodeEnum.pb.h>
#include <aasdk_proto/TouchActionEnum.pb.h>
#include <f1x/aasdk/IO/Promise.hpp>
#include "aasdk_proto/ButtonCodeEnum.pb.h"
#include "aasdk_proto/TouchActionEnum.pb.h"
#include "aasdk/IO/Promise.hpp"
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace projection
{
@ -62,5 +58,3 @@ struct TouchEvent
}
}
}
}

View File

@ -17,16 +17,12 @@
*/
#include <QBluetoothLocalDevice>
#include <f1x/openauto/autoapp/Projection/IBluetoothDevice.hpp>
#include "IBluetoothDevice.hpp"
#pragma once
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace projection
{
@ -64,5 +60,3 @@ private:
}
}
}
}

View File

@ -26,28 +26,39 @@ extern "C"
#include <mutex>
#include <condition_variable>
#include <functional>
#include <thread>
#include <boost/circular_buffer.hpp>
#include <f1x/openauto/autoapp/Projection/VideoOutput.hpp>
#include "VideoOutput.hpp"
namespace f1x
{
namespace openauto
{
namespace autoapp
{
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
{
public:
OMXVideoOutput(configuration::IConfiguration::Pointer configuration);
OMXVideoOutput(configuration::IConfiguration::Pointer configuration, DestRect destRect=DestRect(), std::function<void(bool)> activeCallback=nullptr);
bool open() override;
bool init() override;
void write(uint64_t timestamp, const aasdk::common::DataConstBuffer& buffer) override;
void stop() override;
void setOpacity(OMX_U32 alpha);
void setDestRect(DestRect destRect);
private:
bool createComponents();
@ -62,10 +73,11 @@ private:
ILCLIENT_T* client_;
COMPONENT_T* components_[5];
TUNNEL_T tunnels_[4];
DestRect destRect_;
OMX_U32 alpha_;
std::function<void(bool)> activeCallback_;
};
}
}
}
}

View File

@ -21,14 +21,10 @@
#include <mutex>
#include <QAudioInput>
#include <QAudioFormat>
#include <f1x/openauto/autoapp/Projection/IAudioInput.hpp>
#include "IAudioInput.hpp"
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace projection
{
@ -69,5 +65,3 @@ private:
}
}
}
}

View File

@ -20,15 +20,11 @@
#include <QAudioOutput>
#include <QAudioFormat>
#include <f1x/openauto/autoapp/Projection/IAudioOutput.hpp>
#include <f1x/openauto/autoapp/Projection/SequentialBuffer.hpp>
#include "IAudioOutput.hpp"
#include "SequentialBuffer.hpp"
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace projection
{
@ -67,5 +63,3 @@ private:
}
}
}
}

View File

@ -21,15 +21,11 @@
#include <QMediaPlayer>
#include <QVideoWidget>
#include <boost/noncopyable.hpp>
#include <f1x/openauto/autoapp/Projection/VideoOutput.hpp>
#include <f1x/openauto/autoapp/Projection/SequentialBuffer.hpp>
#include "VideoOutput.hpp"
#include "SequentialBuffer.hpp"
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace projection
{
@ -38,11 +34,12 @@ class QtVideoOutput: public QObject, public VideoOutput, boost::noncopyable
Q_OBJECT
public:
QtVideoOutput(configuration::IConfiguration::Pointer configuration);
QtVideoOutput(configuration::IConfiguration::Pointer configuration, QWidget* videoContainer=nullptr);
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();
@ -57,9 +54,8 @@ private:
SequentialBuffer videoBuffer_;
std::unique_ptr<QVideoWidget> videoWidget_;
std::unique_ptr<QMediaPlayer> mediaPlayer_;
QWidget* videoContainer_;
};
}
}
}
}

View File

@ -18,14 +18,10 @@
#pragma once
#include <f1x/openauto/autoapp/Projection/IBluetoothDevice.hpp>
#include "IBluetoothDevice.hpp"
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace projection
{
@ -46,5 +42,3 @@ private:
}
}
}
}

View File

@ -19,15 +19,11 @@
#pragma once
#include <RtAudio.h>
#include <f1x/openauto/autoapp/Projection/IAudioOutput.hpp>
#include <f1x/openauto/autoapp/Projection/SequentialBuffer.hpp>
#include "IAudioOutput.hpp"
#include "SequentialBuffer.hpp"
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace projection
{
@ -54,10 +50,8 @@ private:
uint32_t sampleRate_;
SequentialBuffer audioBuffer_;
std::unique_ptr<RtAudio> dac_;
std::mutex mutex_;
static std::mutex mutex_;
};
}
}
}
}

View File

@ -21,14 +21,10 @@
#include <QIODevice>
#include <mutex>
#include <boost/circular_buffer.hpp>
#include <f1x/aasdk/Common/Data.hpp>
#include "aasdk/Common/Data.hpp"
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace projection
{
@ -57,5 +53,3 @@ private:
}
}
}
}

View File

@ -18,15 +18,11 @@
#pragma once
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
#include <f1x/openauto/autoapp/Projection/IVideoOutput.hpp>
#include "openauto/Configuration/IConfiguration.hpp"
#include "IVideoOutput.hpp"
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace projection
{
@ -46,5 +42,3 @@ protected:
}
}
}
}

View File

@ -19,21 +19,17 @@
#pragma once
#include <boost/asio.hpp>
#include <f1x/aasdk/Transport/ITransport.hpp>
#include <f1x/aasdk/Channel/Control/IControlServiceChannel.hpp>
#include <f1x/aasdk/Channel/Control/IControlServiceChannelEventHandler.hpp>
#include <f1x/aasdk/Channel/AV/VideoServiceChannel.hpp>
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
#include <f1x/openauto/autoapp/Service/IAndroidAutoEntity.hpp>
#include <f1x/openauto/autoapp/Service/IService.hpp>
#include <f1x/openauto/autoapp/Service/IPinger.hpp>
#include "aasdk/Transport/ITransport.hpp"
#include "aasdk/Channel/Control/IControlServiceChannel.hpp"
#include "aasdk/Channel/Control/IControlServiceChannelEventHandler.hpp"
#include "aasdk/Channel/AV/VideoServiceChannel.hpp"
#include "openauto/Configuration/IConfiguration.hpp"
#include "IAndroidAutoEntity.hpp"
#include "IService.hpp"
#include "IPinger.hpp"
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace service
{
@ -58,8 +54,10 @@ public:
void onShutdownRequest(const aasdk::proto::messages::ShutdownRequest& request) override;
void onShutdownResponse(const aasdk::proto::messages::ShutdownResponse& response) 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 onChannelError(const aasdk::error::Error& e) override;
void onVoiceSessionRequest(const aasdk::proto::messages::VoiceSessionRequest& request) override;
private:
using std::enable_shared_from_this<AndroidAutoEntity>::shared_from_this;
@ -80,5 +78,3 @@ private:
}
}
}
}

View File

@ -19,17 +19,13 @@
#pragma once
#include <boost/asio.hpp>
#include <f1x/aasdk/Transport/ITransport.hpp>
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
#include <f1x/openauto/autoapp/Service/IAndroidAutoEntityFactory.hpp>
#include <f1x/openauto/autoapp/Service/IServiceFactory.hpp>
#include "aasdk/Transport/ITransport.hpp"
#include "openauto/Configuration/IConfiguration.hpp"
#include "IAndroidAutoEntityFactory.hpp"
#include "IServiceFactory.hpp"
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace service
{
@ -53,5 +49,3 @@ private:
}
}
}
}

View File

@ -18,16 +18,12 @@
#pragma once
#include <f1x/aasdk/Channel/AV/AVInputServiceChannel.hpp>
#include <f1x/openauto/autoapp/Service/IService.hpp>
#include <f1x/openauto/autoapp/Projection/IAudioInput.hpp>
#include "aasdk/Channel/AV/AVInputServiceChannel.hpp"
#include "IService.hpp"
#include "openauto/Projection/IAudioInput.hpp"
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace service
{
@ -61,5 +57,3 @@ private:
}
}
}
}

View File

@ -18,17 +18,13 @@
#pragma once
#include <f1x/aasdk/Channel/AV/IAudioServiceChannel.hpp>
#include <f1x/aasdk/Channel/AV/IAudioServiceChannelEventHandler.hpp>
#include <f1x/openauto/autoapp/Projection/IAudioOutput.hpp>
#include <f1x/openauto/autoapp/Service/IService.hpp>
#include "aasdk/Channel/AV/IAudioServiceChannel.hpp"
#include "aasdk/Channel/AV/IAudioServiceChannelEventHandler.hpp"
#include "openauto/Projection/IAudioOutput.hpp"
#include "IService.hpp"
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace service
{
@ -61,5 +57,3 @@ protected:
}
}
}
}

View File

@ -18,16 +18,12 @@
#pragma once
#include <f1x/aasdk/Channel/Bluetooth/BluetoothServiceChannel.hpp>
#include <f1x/openauto/autoapp/Projection/IBluetoothDevice.hpp>
#include <f1x/openauto/autoapp/Service/IService.hpp>
#include "aasdk/Channel/Bluetooth/BluetoothServiceChannel.hpp"
#include "openauto/Projection/IBluetoothDevice.hpp"
#include "IService.hpp"
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace service
{
@ -52,5 +48,3 @@ private:
}
}
}
}

View File

@ -19,14 +19,10 @@
#pragma once
#include <memory>
#include <f1x/openauto/autoapp/Service/IAndroidAutoEntityEventHandler.hpp>
#include "IAndroidAutoEntityEventHandler.hpp"
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace service
{
@ -43,5 +39,3 @@ public:
}
}
}
}

View File

@ -18,14 +18,10 @@
#pragma once
#include <f1x/aasdk/Error/Error.hpp>
#include "aasdk/Error/Error.hpp"
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace service
{
@ -38,5 +34,3 @@ public:
}
}
}
}

View File

@ -18,16 +18,12 @@
#pragma once
#include <f1x/aasdk/TCP/ITCPEndpoint.hpp>
#include <f1x/aasdk/USB/IAOAPDevice.hpp>
#include <f1x/openauto/autoapp/Service/IAndroidAutoEntity.hpp>
#include "aasdk/TCP/ITCPEndpoint.hpp"
#include "aasdk/USB/IAOAPDevice.hpp"
#include "IAndroidAutoEntity.hpp"
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace service
{
@ -42,5 +38,3 @@ public:
}
}
}
}

View 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;
};
}
}

View File

@ -18,14 +18,10 @@
#pragma once
#include <f1x/aasdk/IO/Promise.hpp>
#include "aasdk/IO/Promise.hpp"
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace service
{
@ -43,5 +39,3 @@ public:
}
}
}
}

View File

@ -20,14 +20,10 @@
#include <vector>
#include <memory>
#include <aasdk_proto/ServiceDiscoveryResponseMessage.pb.h>
#include "aasdk_proto/ServiceDiscoveryResponseMessage.pb.h"
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace service
{
@ -47,5 +43,3 @@ typedef std::vector<IService::Pointer> ServiceList;
}
}
}
}

View File

@ -18,15 +18,11 @@
#pragma once
#include <f1x/aasdk/Messenger/IMessenger.hpp>
#include <f1x/openauto/autoapp/Service/IService.hpp>
#include "aasdk/Messenger/IMessenger.hpp"
#include "IService.hpp"
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace service
{
@ -40,5 +36,3 @@ public:
}
}
}
}

View File

@ -18,18 +18,14 @@
#pragma once
#include <aasdk_proto/ButtonCodeEnum.pb.h>
#include <f1x/aasdk/Channel/Input/InputServiceChannel.hpp>
#include <f1x/openauto/autoapp/Service/IService.hpp>
#include <f1x/openauto/autoapp/Projection/IInputDevice.hpp>
#include <f1x/openauto/autoapp/Projection/IInputDeviceEventHandler.hpp>
#include "aasdk_proto/ButtonCodeEnum.pb.h"
#include "aasdk/Channel/Input/InputServiceChannel.hpp"
#include "IService.hpp"
#include "openauto/Projection/IInputDevice.hpp"
#include "openauto/Projection/IInputDeviceEventHandler.hpp"
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace service
{
@ -42,6 +38,7 @@ class InputService:
public:
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 stop() override;
void fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response) override;
@ -49,7 +46,8 @@ public:
void onBindingRequest(const aasdk::proto::messages::BindingRequest& request) override;
void onChannelError(const aasdk::error::Error& e) 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:
using std::enable_shared_from_this<InputService>::shared_from_this;
@ -57,9 +55,8 @@ private:
boost::asio::io_service::strand strand_;
aasdk::channel::input::InputServiceChannel::Pointer channel_;
projection::IInputDevice::Pointer inputDevice_;
bool serviceActive = false;
};
}
}
}
}

View File

@ -18,15 +18,11 @@
#pragma once
#include <f1x/aasdk/Messenger/IMessenger.hpp>
#include <f1x/openauto/autoapp/Service/AudioService.hpp>
#include "aasdk/Messenger/IMessenger.hpp"
#include "AudioService.hpp"
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace service
{
@ -38,5 +34,3 @@ public:
}
}
}
}

View 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;
};
}
}

View 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;
};
}
}

View File

@ -18,14 +18,10 @@
#pragma once
#include <f1x/openauto/autoapp/Service/IPinger.hpp>
#include "IPinger.hpp"
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace service
{
@ -54,5 +50,3 @@ private:
}
}
}
}

View File

@ -18,22 +18,18 @@
#pragma once
#include <f1x/aasdk/Channel/Sensor/SensorServiceChannel.hpp>
#include <f1x/openauto/autoapp/Service/IService.hpp>
#include "aasdk/Channel/Sensor/SensorServiceChannel.hpp"
#include "IService.hpp"
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace service
{
class SensorService: public aasdk::channel::sensor::ISensorServiceChannelEventHandler, public IService, public std::enable_shared_from_this<SensorService>
{
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 stop() override;
@ -41,6 +37,7 @@ public:
void onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request) override;
void onSensorStartRequest(const aasdk::proto::messages::SensorStartRequestMessage& request) override;
void onChannelError(const aasdk::error::Error& e) override;
void setNightMode(bool nightMode);
private:
using std::enable_shared_from_this<SensorService>::shared_from_this;
@ -49,9 +46,8 @@ private:
boost::asio::io_service::strand strand_;
aasdk::channel::sensor::SensorServiceChannel::Pointer channel_;
bool nightMode_;
};
}
}
}
}

View 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;
};
}
}

View File

@ -18,15 +18,11 @@
#pragma once
#include <f1x/aasdk/Messenger/IMessenger.hpp>
#include <f1x/openauto/autoapp/Service/AudioService.hpp>
#include "aasdk/Messenger/IMessenger.hpp"
#include "AudioService.hpp"
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace service
{
@ -38,5 +34,3 @@ public:
}
}
}
}

View File

@ -18,15 +18,11 @@
#pragma once
#include <f1x/aasdk/Messenger/IMessenger.hpp>
#include <f1x/openauto/autoapp/Service/AudioService.hpp>
#include "aasdk/Messenger/IMessenger.hpp"
#include "AudioService.hpp"
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace service
{
@ -38,5 +34,3 @@ public:
}
}
}
}

View File

@ -19,17 +19,13 @@
#pragma once
#include <memory>
#include <f1x/aasdk/Channel/AV/VideoServiceChannel.hpp>
#include <f1x/aasdk/Channel/AV/IVideoServiceChannelEventHandler.hpp>
#include <f1x/openauto/autoapp/Projection/IVideoOutput.hpp>
#include <f1x/openauto/autoapp/Service/IService.hpp>
#include "aasdk/Channel/AV/VideoServiceChannel.hpp"
#include "aasdk/Channel/AV/IVideoServiceChannelEventHandler.hpp"
#include "openauto/Projection/IVideoOutput.hpp"
#include "IService.hpp"
namespace f1x
{
namespace openauto
{
namespace autoapp
{
namespace service
{
@ -46,6 +42,7 @@ public:
void onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request) override;
void onAVChannelSetupRequest(const aasdk::proto::messages::AVChannelSetupRequest& request) 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 onAVMediaIndication(const aasdk::common::DataConstBuffer& buffer) override;
void onVideoFocusRequest(const aasdk::proto::messages::VideoFocusRequest& request) override;
@ -63,5 +60,3 @@ private:
}
}
}
}

View File

@ -17,19 +17,15 @@
*/
#include <thread>
#include <f1x/aasdk/USB/AOAPDevice.hpp>
#include <f1x/aasdk/TCP/TCPEndpoint.hpp>
#include <f1x/openauto/autoapp/App.hpp>
#include <f1x/openauto/Common/Log.hpp>
#include "aasdk/USB/AOAPDevice.hpp"
#include "aasdk/TCP/TCPEndpoint.hpp"
#include "openauto/App.hpp"
#include "OpenautoLog.hpp"
namespace f1x
{
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)
: ioService_(ioService)
, usbWrapper_(usbWrapper)
@ -37,22 +33,30 @@ App::App(boost::asio::io_service& ioService, aasdk::usb::USBWrapper& usbWrapper,
, strand_(ioService_)
, androidAutoEntityFactory_(androidAutoEntityFactory)
, usbHub_(std::move(usbHub))
, acceptor_(ioService_, boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), 5000))
, connectedAccessoriesEnumerator_(std::move(connectedAccessoriesEnumerator))
, isStopped_(false)
{
}
void App::waitForUSBDevice()
void App::waitForDevice(bool enumerate)
{
strand_.dispatch([this, self = this->shared_from_this()]() {
this->waitForDevice();
this->enumerateDevices();
});
this->waitForUSBDevice();
this->waitForWirelessDevice();
if(enumerate)
{
strand_.dispatch([this, self = this->shared_from_this()]() {
this->enumerateDevices();
});
}
}
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 {
if(androidAutoEntity_ != nullptr)
{
@ -97,7 +101,7 @@ void App::stop()
void App::aoapDeviceHandler(aasdk::usb::DeviceHandle deviceHandle)
{
OPENAUTO_LOG(info) << "[App] Device connected.";
OPENAUTO_LOG(info) << "[App] USB Device connected.";
if(androidAutoEntity_ != nullptr)
{
@ -135,9 +139,9 @@ void App::enumerateDevices()
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_);
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));
}
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()
{
strand_.dispatch([this, self = this->shared_from_this()]() {
@ -172,5 +184,3 @@ void App::onUSBHubError(const aasdk::error::Error& error)
}
}
}
}

Some files were not shown because too many files have changed in this diff Show More