├── .gitignore
├── CMakeLists.txt
├── Readme.md
├── autoapp
├── CMakeLists.txt
├── UI
│ ├── ConnectDialog.cpp
│ ├── MainWindow.cpp
│ ├── SettingsWindow.cpp
│ ├── connectdialog.ui
│ ├── mainwindow.ui
│ └── settingswindow.ui
├── assets
│ ├── aa_video.qml
│ ├── ico_androidauto.png
│ ├── ico_info.png
│ ├── ico_setting.png
│ ├── ico_warning.png
│ └── resources.qrc
└── autoapp.cpp
├── btservice
├── AndroidBluetoothServer.cpp
├── AndroidBluetoothService.cpp
└── btservice.cpp
├── btservice_proto
├── CMakeLists.txt
├── NetworkInfo.proto
├── SocketInfoRequest.proto
└── SocketInfoResponse.proto
├── cmake_modules
├── FindGObject.cmake
├── FindGStreamer.cmake
├── Findaasdk.cmake
├── Findh264.cmake
├── Findlibomx.cmake
├── Findlibusb-1.0.cmake
├── Findrtaudio.cmake
├── functions.cmake
└── gitversion.cmake
├── include
├── OpenautoLog.hpp
├── autoapp
│ └── UI
│ │ ├── ConnectDialog.hpp
│ │ ├── MainWindow.hpp
│ │ └── SettingsWindow.hpp
├── btservice
│ ├── AndroidBluetoothServer.hpp
│ ├── AndroidBluetoothService.hpp
│ ├── IAndroidBluetoothServer.hpp
│ ├── IAndroidBluetoothService.hpp
│ └── btservice.hpp
└── openauto
│ ├── App.hpp
│ ├── Configuration
│ ├── AudioOutputBackendType.hpp
│ ├── BluetootAdapterType.hpp
│ ├── Configuration.hpp
│ ├── HandednessOfTrafficType.hpp
│ ├── IConfiguration.hpp
│ ├── IRecentAddressesList.hpp
│ └── RecentAddressesList.hpp
│ ├── Projection
│ ├── DummyBluetoothDevice.hpp
│ ├── GSTVideoOutput.hpp
│ ├── IAudioInput.hpp
│ ├── IAudioOutput.hpp
│ ├── IBluetoothDevice.hpp
│ ├── IInputDevice.hpp
│ ├── IInputDeviceEventHandler.hpp
│ ├── IVideoOutput.hpp
│ ├── InputDevice.hpp
│ ├── InputEvent.hpp
│ ├── LocalBluetoothDevice.hpp
│ ├── OMXVideoOutput.hpp
│ ├── QtAudioInput.hpp
│ ├── QtAudioOutput.hpp
│ ├── QtVideoOutput.hpp
│ ├── RemoteBluetoothDevice.hpp
│ ├── RtAudioOutput.hpp
│ ├── SequentialBuffer.hpp
│ └── VideoOutput.hpp
│ └── Service
│ ├── AndroidAutoEntity.hpp
│ ├── AndroidAutoEntityFactory.hpp
│ ├── AudioInputService.hpp
│ ├── AudioService.hpp
│ ├── BluetoothService.hpp
│ ├── IAndroidAutoEntity.hpp
│ ├── IAndroidAutoEntityEventHandler.hpp
│ ├── IAndroidAutoEntityFactory.hpp
│ ├── IAndroidAutoInterface.hpp
│ ├── IPinger.hpp
│ ├── IService.hpp
│ ├── IServiceFactory.hpp
│ ├── InputService.hpp
│ ├── MediaAudioService.hpp
│ ├── MediaStatusService.hpp
│ ├── NavigationStatusService.hpp
│ ├── Pinger.hpp
│ ├── SensorService.hpp
│ ├── ServiceFactory.hpp
│ ├── SpeechAudioService.hpp
│ ├── SystemAudioService.hpp
│ └── VideoService.hpp
└── openauto
├── App.cpp
├── CMakeLists.txt
├── Configuration
├── Configuration.cpp
└── RecentAddressesList.cpp
├── Projection
├── DummyBluetoothDevice.cpp
├── GSTVideoOutput.cpp
├── InputDevice.cpp
├── LocalBluetoothDevice.cpp
├── OMXVideoOutput.cpp
├── QtAudioInput.cpp
├── QtAudioOutput.cpp
├── QtVideoOutput.cpp
├── RemoteBluetoothDevice.cpp
├── RtAudioOutput.cpp
├── SequentialBuffer.cpp
└── VideoOutput.cpp
└── Service
├── AndroidAutoEntity.cpp
├── AndroidAutoEntityFactory.cpp
├── AudioInputService.cpp
├── AudioService.cpp
├── BluetoothService.cpp
├── InputService.cpp
├── MediaAudioService.cpp
├── MediaStatusService.cpp
├── NavigationStatusService.cpp
├── Pinger.cpp
├── SensorService.cpp
├── ServiceFactory.cpp
├── SpeechAudioService.cpp
├── SystemAudioService.cpp
└── VideoService.cpp
/.gitignore:
--------------------------------------------------------------------------------
1 | # Add any directories, files, or patterns you don't want to be tracked by version control
2 | .vscode/
3 |
4 | lib/
5 | bin/
6 | .idea/
7 | build/
8 |
9 | CMakeLists.txt.user
10 | cmake-build-*/
11 | CMakeCache.txt
12 | CMakeFiles
13 | CMakeScripts
14 | Testing
15 | Makefile
16 | cmake_install.cmake
17 | install_manifest.txt
18 | compile_commands.json
19 | CTestTestfile.cmake
20 | _deps
21 | *_autogen/
22 | *.pb.cc
23 | *.pb.h
24 |
--------------------------------------------------------------------------------
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.5.1)
2 |
3 | set (openauto_VERSION_MAJOR 2)
4 | set (openauto_VERSION_MINOR 1)
5 | set (openauto_VERSION_PATCH 0)
6 |
7 | project(openauto
8 | VERSION ${openauto_VERSION_MAJOR}.${openauto_VERSION_MINOR}.${openauto_VERSION_PATCH}
9 | LANGUAGES CXX)
10 |
11 | find_program(CCACHE_PROGRAM ccache)
12 | if(CCACHE_PROGRAM)
13 | set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
14 | endif()
15 |
16 | set(CMAKE_AUTOMOC ON)
17 | set(CMAKE_AUTOUIC ON)
18 | set(CMAKE_AUTORCC ON)
19 |
20 | set(base_directory ${CMAKE_CURRENT_SOURCE_DIR})
21 | set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib)
22 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib)
23 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib)
24 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin)
25 | set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/bin)
26 |
27 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake_modules/")
28 | SET(CMAKE_CXX_STANDARD 14)
29 |
30 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_INIT} -Wall -pedantic")
31 | set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
32 | set(CMAKE_CXX_FLAGS_RELEASE "-g -O3")
33 |
34 | if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
35 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-psabi")
36 | endif()
37 |
38 | set(Boost_USE_STATIC_LIBS OFF)
39 | set(Boost_USE_MULTITHREADED ON)
40 | set(Boost_USE_STATIC_RUNTIME OFF)
41 | add_definitions(-DBOOST_ALL_DYN_LINK)
42 | find_package(Boost REQUIRED COMPONENTS system log OPTIONAL_COMPONENTS unit_test_framework)
43 |
44 | find_package(libusb-1.0 REQUIRED)
45 | find_package(Qt5 COMPONENTS Multimedia MultimediaWidgets Bluetooth Qml Quick QuickWidgets REQUIRED)
46 | find_package(Protobuf REQUIRED)
47 | find_package(OpenSSL REQUIRED)
48 | find_package(rtaudio REQUIRED)
49 | find_package(aasdk REQUIRED)
50 | find_package(h264 REQUIRED)
51 | find_package(Threads)
52 |
53 | include(${base_directory}/cmake_modules/gitversion.cmake)
54 | if(RPI_BUILD)
55 | find_package(libomx)
56 | endif()
57 |
58 | if(GST_BUILD)
59 | find_package(GObject)
60 | find_package(Qt5GStreamer)
61 | find_package(PkgConfig REQUIRED)
62 | pkg_check_modules(GST REQUIRED
63 | gstreamer-1.0>=1.4
64 | gstreamer-sdp-1.0>=1.4
65 | gstreamer-video-1.0>=1.4
66 | gstreamer-app-1.0>=1.4)
67 | add_definitions(-DUSE_GST)
68 | if(RPI_BUILD)
69 | add_definitions(-DRPI)
70 | include(${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/functions.cmake)
71 | findRpiRevision( RPI_REVISION )
72 | math(EXPR RPI_MODEL "(0x${RPI_REVISION}>>4)&0xFF")
73 | message( "-- Raspberry Pi Model: ${RPI_MODEL}" )
74 | if(RPI_MODEL EQUAL 17)
75 | message("Raspberry Pi 4 Found")
76 | add_definitions(-DPI4)
77 | endif(RPI_MODEL EQUAL 17)
78 | endif(RPI_BUILD)
79 | message(STATUS "${GST_LIBRARIES}")
80 | endif(GST_BUILD)
81 |
82 | add_subdirectory(btservice_proto)
83 | set(BTSERVICE_PROTO_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR})
84 | include_directories(${BTSERVICE_PROTO_INCLUDE_DIRS})
85 |
86 | add_subdirectory(openauto)
87 | add_subdirectory(autoapp)
88 | add_dependencies(autoapp btservice_proto)
89 |
90 | set (openauto_VERSION_PATCH ${_build_version})
91 | set (openauto_VERSION_STRING ${openauto_VERSION_MAJOR}.${openauto_VERSION_MINOR}.${openauto_VERSION_PATCH})
92 | set_target_properties(openauto PROPERTIES VERSION ${openauto_VERSION_STRING}
93 | SOVERSION ${openauto_VERSION_MAJOR})
94 | message(INFO " Project Version: ${openauto_VERSION_STRING}")
95 |
96 | install(DIRECTORY lib DESTINATION lib COMPONENT libraries)
97 | install(DIRECTORY include DESTINATION include COMPONENT headers)
98 | install(DIRECTORY bin DESTINATION bin COMPONENT applications)
99 |
100 | SET(CPACK_GENERATOR "DEB")
101 | SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "OpenDsh") #required
102 | SET(CPACK_PACKAGE_VENDOR "OpenDsh")
103 | set(CPACK_PACKAGE_VERSION ${openauto_VERSION_STRING})
104 | set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
105 | set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
106 | set(CPACK_COMPONENTS_ALL applications libraries headers Unspecified)
107 | set(CPACK_COMPONENT_APPLICATIONS_DISPLAY_NAME "Applications")
108 | set(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "Libraries")
109 | set(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C++ Headers")
110 | set(CPACK_COMPONENT_APPLICATIONS_DESCRIPTION
111 | "Applications provided by OpenAuto")
112 | set(CPACK_COMPONENT_LIBRARIES_DESCRIPTION
113 | "Static libraries used to build programs with OpenAuto")
114 | set(CPACK_COMPONENT_HEADERS_DESCRIPTION
115 | "C/C++ header files for use with OpenAuto")
116 | set(CPACK_COMPONENT_LIBRARIES_GROUP "Development")
117 | set(CPACK_COMPONENT_HEADERS_GROUP "Development")
118 | set(CPACK_COMPONENT_GROUP_DEVELOPMENT_EXPANDED ON)
119 | set(CPACK_COMPONENT_GROUP_DEVELOPMENT_DESCRIPTION
120 | "All of the tools you'll ever need to develop software")
121 | set(CPACK_COMPONENT_HEADERS_DEPENDS libraries)
122 | set(CPACK_COMPONENT_APPLICATIONS_DEPENDS libraries)
123 | set(CPACK_ALL_INSTALL_TYPES Full Developer)
124 | set(CPACK_INSTALL_TYPE_FULL_DISPLAY_NAME "Everything")
125 | set(CPACK_COMPONENT_LIBRARIES_INSTALL_TYPES Developer Full)
126 | set(CPACK_COMPONENT_HEADERS_INSTALL_TYPES Developer Full)
127 | set(CPACK_COMPONENT_APPLICATIONS_INSTALL_TYPES Full)
128 | INCLUDE(CPack)
--------------------------------------------------------------------------------
/Readme.md:
--------------------------------------------------------------------------------
1 |
2 | # OpenAuto
3 |
4 | ### Community
5 | [](https://gitter.im/openauto_androidauto/Lobby)
6 |
7 | ### Description
8 | OpenAuto is an AndroidAuto(tm) headunit emulator based on aasdk library and Qt libraries. Main goal is to run this application on the RaspberryPI 3 board computer smoothly.
9 |
10 | [See demo video](https://www.youtube.com/watch?v=k9tKRqIkQs8)
11 |
12 | ### Build Guide
13 | #### Local build instructions for Raspberry Pi
14 |
15 | Having aasdk built and install first is a prequisite for this task. Please complete the necessary aasdk steps before proceeding here.
16 |
17 | ```sudo apt-get update
18 | sudo apt-get -y install cmake build-essential git
19 |
20 | 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
21 |
22 | git clone https://github.com/OpenDsh/openauto
23 |
24 | mkdir openauto_build; cd openauto_build
25 |
26 | 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
27 |
28 | make -j2
29 | sudo make install
30 | ```
31 |
32 | The executable binary can then be found at ~/openauto/bin/autoapp
33 |
34 | ### Supported functionalities
35 | - 480p, 720p and 1080p with 30 or 60 FPS
36 | - RaspberryPI 3 hardware acceleration support to decode video stream (up to 1080p@60!)
37 | - Audio playback from all audio channels (Media, System and Speech)
38 | - Audio input for voice commands
39 | - Touchscreen and buttons input
40 | - Bluetooth
41 | - Automatic launch after device hotplug
42 | - Automatic detection of connected Android devices
43 | - Wireless (WiFi) mode via head unit server (must be enabled in hidden developer settings)
44 | - User-friendly settings
45 |
46 | ### Supported platforms
47 |
48 | - Linux
49 | - RaspberryPI 3
50 | - Windows
51 |
52 | ### License
53 | GNU GPLv3
54 |
55 | Copyrights (c) 2018 f1x.studio (Michal Szwaj)
56 |
57 | *AndroidAuto is registered trademark of Google Inc.*
58 |
59 | ### Used software
60 | - [aasdk](https://github.com/f1xpl/aasdk)
61 | - [Boost libraries](http://www.boost.org/)
62 | - [Qt libraries](https://www.qt.io/)
63 | - [CMake](https://cmake.org/)
64 | - [RtAudio](https://www.music.mcgill.ca/~gary/rtaudio/playback.html)
65 | - Broadcom ilclient from RaspberryPI 3 firmware
66 | - OpenMAX IL API
67 |
68 | ### Remarks
69 | **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.**
--------------------------------------------------------------------------------
/autoapp/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(autoapp
2 | autoapp.cpp
3 | UI/connectdialog.ui
4 | UI/ConnectDialog.cpp
5 | UI/mainwindow.ui
6 | UI/MainWindow.cpp
7 | UI/settingswindow.ui
8 | UI/SettingsWindow.cpp
9 | assets/resources.qrc
10 | ${CMAKE_SOURCE_DIR}/include/autoapp/UI/ConnectDialog.hpp
11 | ${CMAKE_SOURCE_DIR}/include/autoapp/UI/MainWindow.hpp
12 | ${CMAKE_SOURCE_DIR}/include/autoapp/UI/SettingsWindow.hpp
13 | )
14 |
15 | target_include_directories(autoapp PRIVATE
16 | ${CMAKE_SOURCE_DIR}/include
17 | ${CMAKE_CURRENT_BINARY_DIR}
18 | )
19 |
20 | target_link_libraries(autoapp
21 | openauto
22 | )
23 |
24 | if(RPI_BUILD AND NOT GST_BUILD)
25 | target_link_libraries(autoapp omx)
26 | endif()
27 |
28 | set_target_properties(autoapp
29 | PROPERTIES INSTALL_RPATH_USE_LINK_PATH 1)
30 |
31 | install(TARGETS autoapp
32 | RUNTIME DESTINATION bin)
33 |
--------------------------------------------------------------------------------
/autoapp/UI/ConnectDialog.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include "autoapp/UI/ConnectDialog.hpp"
3 | #include "ui_connectdialog.h"
4 |
5 | namespace autoapp
6 | {
7 | namespace ui
8 | {
9 |
10 | ConnectDialog::ConnectDialog(boost::asio::io_service& ioService, aasdk::tcp::ITCPWrapper& tcpWrapper, openauto::configuration::IRecentAddressesList& recentAddressesList, QWidget *parent)
11 | : QDialog(parent)
12 | , ioService_(ioService)
13 | , tcpWrapper_(tcpWrapper)
14 | , recentAddressesList_(recentAddressesList)
15 | , ui_(new Ui::ConnectDialog)
16 | {
17 | qRegisterMetaType("aasdk::tcp::ITCPEndpoint::SocketPointer");
18 | qRegisterMetaType("std::string");
19 |
20 | ui_->setupUi(this);
21 | connect(ui_->pushButtonCancel, &QPushButton::clicked, this, &ConnectDialog::close);
22 | connect(ui_->pushButtonConnect, &QPushButton::clicked, this, &ConnectDialog::onConnectButtonClicked);
23 | connect(ui_->listViewRecent, &QListView::clicked, this, &ConnectDialog::onRecentAddressClicked);
24 | connect(this, &ConnectDialog::connectionSucceed, this, &ConnectDialog::onConnectionSucceed);
25 | connect(this, &ConnectDialog::connectionFailed, this, &ConnectDialog::onConnectionFailed);
26 |
27 | ui_->listViewRecent->setModel(&recentAddressesModel_);
28 | this->loadRecentList();
29 | }
30 |
31 | ConnectDialog::~ConnectDialog()
32 | {
33 | delete ui_;
34 | }
35 |
36 | void ConnectDialog::onConnectButtonClicked()
37 | {
38 | this->setControlsEnabledStatus(false);
39 |
40 | const auto& ipAddress = ui_->lineEditIPAddress->text().toStdString();
41 | auto socket = std::make_shared(ioService_);
42 |
43 | try
44 | {
45 | tcpWrapper_.asyncConnect(*socket, ipAddress, 5277, std::bind(&ConnectDialog::connectHandler, this, std::placeholders::_1, ipAddress, socket));
46 | }
47 | catch(const boost::system::system_error& se)
48 | {
49 | emit connectionFailed(QString(se.what()));
50 | }
51 | }
52 |
53 | void ConnectDialog::connectHandler(const boost::system::error_code& ec, const std::string& ipAddress, aasdk::tcp::ITCPEndpoint::SocketPointer socket)
54 | {
55 | if(!ec)
56 | {
57 | emit connectionSucceed(std::move(socket), ipAddress);
58 | this->close();
59 | }
60 | else
61 | {
62 | emit connectionFailed(QString::fromStdString(ec.message()));
63 | }
64 | }
65 |
66 | void ConnectDialog::onConnectionSucceed(aasdk::tcp::ITCPEndpoint::SocketPointer, const std::string& ipAddress)
67 | {
68 | this->insertIpAddress(ipAddress);
69 | this->setControlsEnabledStatus(true);
70 | }
71 |
72 | void ConnectDialog::onConnectionFailed(const QString& message)
73 | {
74 | this->setControlsEnabledStatus(true);
75 |
76 | QMessageBox errorMessage(QMessageBox::Critical, "Connect error", message, QMessageBox::Ok);
77 | errorMessage.setWindowFlags(Qt::WindowStaysOnTopHint);
78 | errorMessage.exec();
79 | }
80 |
81 | void ConnectDialog::onRecentAddressClicked(const QModelIndex& index)
82 | {
83 | const auto& recentAddressesList = recentAddressesList_.getList();
84 |
85 | if(static_cast(index.row()) <= recentAddressesList.size())
86 | {
87 | ui_->lineEditIPAddress->setText(QString::fromStdString(recentAddressesList.at(index.row())));
88 | }
89 | }
90 |
91 | void ConnectDialog::setControlsEnabledStatus(bool status)
92 | {
93 | ui_->pushButtonConnect->setVisible(status);
94 | ui_->pushButtonCancel->setEnabled(status);
95 | ui_->lineEditIPAddress->setEnabled(status);
96 | ui_->listViewRecent->setEnabled(status);
97 | }
98 |
99 | void ConnectDialog::loadRecentList()
100 | {
101 | QStringList stringList;
102 | const auto& configList = recentAddressesList_.getList();
103 |
104 | for(const auto& element : configList)
105 | {
106 | stringList.append(QString::fromStdString(element));
107 | }
108 |
109 | recentAddressesModel_.setStringList(stringList);
110 | }
111 |
112 | void ConnectDialog::insertIpAddress(const std::string& ipAddress)
113 | {
114 | recentAddressesList_.insertAddress(ipAddress);
115 | this->loadRecentList();
116 | }
117 |
118 | }
119 | }
120 |
--------------------------------------------------------------------------------
/autoapp/UI/MainWindow.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #include
20 | #include "autoapp/UI/MainWindow.hpp"
21 | #include "ui_mainwindow.h"
22 |
23 | namespace autoapp
24 | {
25 | namespace ui
26 | {
27 |
28 | MainWindow::MainWindow(QWidget *parent)
29 | : QMainWindow(parent)
30 | , ui_(new Ui::MainWindow)
31 | {
32 | ui_->setupUi(this);
33 | connect(ui_->pushButtonSettings, &QPushButton::clicked, this, &MainWindow::openSettings);
34 | connect(ui_->pushButtonExit, &QPushButton::clicked, this, &MainWindow::exit);
35 | connect(ui_->pushButtonToggleCursor, &QPushButton::clicked, this, &MainWindow::toggleCursor);
36 | connect(ui_->pushButtonWirelessConnection, &QPushButton::clicked, this, &MainWindow::openConnectDialog);
37 | }
38 |
39 | MainWindow::~MainWindow()
40 | {
41 | delete ui_;
42 | }
43 |
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/autoapp/UI/connectdialog.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | ConnectDialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 301
10 | 389
11 |
12 |
13 |
14 | Connect to device
15 |
16 |
17 |
18 |
19 | 10
20 | 10
21 | 281
22 | 61
23 |
24 |
25 |
26 | IP Address
27 |
28 |
29 |
30 |
31 | 10
32 | 30
33 | 261
34 | 25
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 | 10
43 | 80
44 | 281
45 | 181
46 |
47 |
48 |
49 | Recent
50 |
51 |
52 |
53 |
54 | 10
55 | 30
56 | 261
57 | 141
58 |
59 |
60 |
61 | QAbstractItemView::NoEditTriggers
62 |
63 |
64 |
65 |
66 |
67 |
68 | 60
69 | 260
70 | 221
71 | 81
72 |
73 |
74 |
75 | <html><head/><body><p><span style=" font-style:italic;">In order to use wireless mode you must enable head unit server in developer settings.</span></p></body></html>
76 |
77 |
78 | true
79 |
80 |
81 |
82 |
83 |
84 | 20
85 | 290
86 | 21
87 | 21
88 |
89 |
90 |
91 | <html><head/><body><p><img src=":/ico_info.png"/></p></body></html>
92 |
93 |
94 |
95 |
96 |
97 | 40
98 | 340
99 | 121
100 | 41
101 |
102 |
103 |
104 | Cancel
105 |
106 |
107 |
108 |
109 |
110 | 170
111 | 340
112 | 121
113 | 41
114 |
115 |
116 |
117 | Connect
118 |
119 |
120 |
121 |
122 |
123 | 170
124 | 340
125 | 121
126 | 41
127 |
128 |
129 |
130 | 0
131 |
132 |
133 | 0
134 |
135 |
136 |
137 |
138 |
139 | 188
140 | 350
141 | 91
142 | 20
143 |
144 |
145 |
146 | Connecting...
147 |
148 |
149 | groupBoxIPAddress
150 | groupBoxRecent
151 | labelHeadUnitServerInfo
152 | labelCopyrightsInfoIcon
153 | pushButtonCancel
154 | progressBarConnect
155 | labelConnecting
156 | pushButtonConnect
157 |
158 |
159 |
160 |
161 |
--------------------------------------------------------------------------------
/autoapp/assets/aa_video.qml:
--------------------------------------------------------------------------------
1 | import QtQuick 2.0
2 | import QtGStreamer 1.0
3 |
4 | VideoItem {
5 | id: aaVideo
6 | width: 300
7 | height: 300
8 | surface: videoSurface
9 | }
10 |
--------------------------------------------------------------------------------
/autoapp/assets/ico_androidauto.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openDsh/openauto/e7caeb4d49186af867c1d4693c9f3bf9e9ef99e0/autoapp/assets/ico_androidauto.png
--------------------------------------------------------------------------------
/autoapp/assets/ico_info.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openDsh/openauto/e7caeb4d49186af867c1d4693c9f3bf9e9ef99e0/autoapp/assets/ico_info.png
--------------------------------------------------------------------------------
/autoapp/assets/ico_setting.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openDsh/openauto/e7caeb4d49186af867c1d4693c9f3bf9e9ef99e0/autoapp/assets/ico_setting.png
--------------------------------------------------------------------------------
/autoapp/assets/ico_warning.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openDsh/openauto/e7caeb4d49186af867c1d4693c9f3bf9e9ef99e0/autoapp/assets/ico_warning.png
--------------------------------------------------------------------------------
/autoapp/assets/resources.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | ico_androidauto.png
4 | ico_warning.png
5 | ico_setting.png
6 | ico_info.png
7 | aa_video.qml
8 |
9 |
10 |
--------------------------------------------------------------------------------
/autoapp/autoapp.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #include
20 | #include
21 | #include "aasdk/USB/USBHub.hpp"
22 | #include "aasdk/USB/ConnectedAccessoriesEnumerator.hpp"
23 | #include "aasdk/USB/AccessoryModeQueryChain.hpp"
24 | #include "aasdk/USB/AccessoryModeQueryChainFactory.hpp"
25 | #include "aasdk/USB/AccessoryModeQueryFactory.hpp"
26 | #include "aasdk/TCP/TCPWrapper.hpp"
27 | #include "openauto/App.hpp"
28 | #include "openauto/Configuration/IConfiguration.hpp"
29 | #include "openauto/Configuration/RecentAddressesList.hpp"
30 | #include "openauto/Service/AndroidAutoEntityFactory.hpp"
31 | #include "openauto/Service/ServiceFactory.hpp"
32 | #include "openauto/Configuration/Configuration.hpp"
33 | #include "autoapp/UI/MainWindow.hpp"
34 | #include "autoapp/UI/SettingsWindow.hpp"
35 | #include "autoapp/UI/ConnectDialog.hpp"
36 | #include "OpenautoLog.hpp"
37 |
38 | using namespace openauto;
39 | using ThreadPool = std::vector;
40 |
41 | void startUSBWorkers(boost::asio::io_service& ioService, libusb_context* usbContext, ThreadPool& threadPool)
42 | {
43 | auto usbWorker = [&ioService, usbContext]() {
44 | timeval libusbEventTimeout{180, 0};
45 |
46 | while(!ioService.stopped())
47 | {
48 | libusb_handle_events_timeout_completed(usbContext, &libusbEventTimeout, nullptr);
49 | }
50 | };
51 |
52 | threadPool.emplace_back(usbWorker);
53 | threadPool.emplace_back(usbWorker);
54 | threadPool.emplace_back(usbWorker);
55 | threadPool.emplace_back(usbWorker);
56 | }
57 |
58 | void startIOServiceWorkers(boost::asio::io_service& ioService, ThreadPool& threadPool)
59 | {
60 | auto ioServiceWorker = [&ioService]() {
61 | ioService.run();
62 | };
63 |
64 | threadPool.emplace_back(ioServiceWorker);
65 | threadPool.emplace_back(ioServiceWorker);
66 | threadPool.emplace_back(ioServiceWorker);
67 | threadPool.emplace_back(ioServiceWorker);
68 | }
69 |
70 | int main(int argc, char* argv[])
71 | {
72 | libusb_context* usbContext;
73 | if(libusb_init(&usbContext) != 0)
74 | {
75 | OPENAUTO_LOG(error) << "[OpenAuto] libusb init failed.";
76 | return 1;
77 | }
78 |
79 | boost::asio::io_service ioService;
80 | boost::asio::io_service::work work(ioService);
81 | std::vector threadPool;
82 | startUSBWorkers(ioService, usbContext, threadPool);
83 | startIOServiceWorkers(ioService, threadPool);
84 |
85 | QApplication qApplication(argc, argv);
86 | autoapp::ui::MainWindow mainWindow;
87 | mainWindow.setWindowFlags(Qt::WindowStaysOnTopHint);
88 |
89 | auto configuration = std::make_shared();
90 | autoapp::ui::SettingsWindow settingsWindow(configuration);
91 | settingsWindow.setWindowFlags(Qt::WindowStaysOnTopHint);
92 |
93 | openauto::configuration::RecentAddressesList recentAddressesList(7);
94 | recentAddressesList.read();
95 |
96 | aasdk::tcp::TCPWrapper tcpWrapper;
97 | autoapp::ui::ConnectDialog connectDialog(ioService, tcpWrapper, recentAddressesList);
98 | connectDialog.setWindowFlags(Qt::WindowStaysOnTopHint);
99 |
100 | QObject::connect(&mainWindow, &autoapp::ui::MainWindow::exit, []() { std::exit(0); });
101 | QObject::connect(&mainWindow, &autoapp::ui::MainWindow::openSettings, &settingsWindow, &autoapp::ui::SettingsWindow::showFullScreen);
102 | QObject::connect(&mainWindow, &autoapp::ui::MainWindow::openConnectDialog, &connectDialog, &autoapp::ui::ConnectDialog::exec);
103 |
104 | qApplication.setOverrideCursor(Qt::BlankCursor);
105 | QObject::connect(&mainWindow, &autoapp::ui::MainWindow::toggleCursor, [&qApplication]() {
106 | const auto cursor = qApplication.overrideCursor()->shape() == Qt::BlankCursor ? Qt::ArrowCursor : Qt::BlankCursor;
107 | qApplication.setOverrideCursor(cursor);
108 | });
109 |
110 | mainWindow.showFullScreen();
111 |
112 | aasdk::usb::USBWrapper usbWrapper(usbContext);
113 | aasdk::usb::AccessoryModeQueryFactory queryFactory(usbWrapper, ioService);
114 | aasdk::usb::AccessoryModeQueryChainFactory queryChainFactory(usbWrapper, ioService, queryFactory);
115 | openauto::service::ServiceFactory serviceFactory(ioService, configuration);
116 | openauto::service::AndroidAutoEntityFactory androidAutoEntityFactory(ioService, configuration, serviceFactory);
117 |
118 | auto usbHub(std::make_shared(usbWrapper, ioService, queryChainFactory));
119 | auto connectedAccessoriesEnumerator(std::make_shared(usbWrapper, ioService, queryChainFactory));
120 | auto app = std::make_shared(ioService, usbWrapper, tcpWrapper, androidAutoEntityFactory, std::move(usbHub), std::move(connectedAccessoriesEnumerator));
121 |
122 | QObject::connect(&connectDialog, &autoapp::ui::ConnectDialog::connectionSucceed, [&app](auto socket) {
123 | app->start(std::move(socket));
124 | });
125 |
126 | app->waitForDevice(true);
127 |
128 | auto result = qApplication.exec();
129 | std::for_each(threadPool.begin(), threadPool.end(), std::bind(&std::thread::join, std::placeholders::_1));
130 |
131 | libusb_exit(usbContext);
132 | return result;
133 | }
134 |
--------------------------------------------------------------------------------
/btservice/AndroidBluetoothService.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #include "btservice/AndroidBluetoothService.hpp"
20 |
21 | namespace openauto
22 | {
23 | namespace btservice
24 | {
25 |
26 | AndroidBluetoothService::AndroidBluetoothService(uint16_t portNumber)
27 | {
28 | //"4de17a00-52cb-11e6-bdf4-0800200c9a66";
29 | //"669a0c20-0008-f4bd-e611-cb52007ae14d";
30 | const QBluetoothUuid serviceUuid(QLatin1String("4de17a00-52cb-11e6-bdf4-0800200c9a66"));
31 |
32 | QBluetoothServiceInfo::Sequence classId;
33 | classId << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::SerialPort));
34 | serviceInfo_.setAttribute(QBluetoothServiceInfo::BluetoothProfileDescriptorList, classId);
35 | classId.prepend(QVariant::fromValue(serviceUuid));
36 | serviceInfo_.setAttribute(QBluetoothServiceInfo::ServiceClassIds, classId);
37 | serviceInfo_.setAttribute(QBluetoothServiceInfo::ServiceName, "OpenAuto Bluetooth Service");
38 | serviceInfo_.setAttribute(QBluetoothServiceInfo::ServiceDescription, "AndroidAuto WiFi projection automatic setup");
39 | serviceInfo_.setAttribute(QBluetoothServiceInfo::ServiceProvider, "openDsh");
40 | serviceInfo_.setServiceUuid(serviceUuid);
41 |
42 | QBluetoothServiceInfo::Sequence publicBrowse;
43 | publicBrowse << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::PublicBrowseGroup));
44 | serviceInfo_.setAttribute(QBluetoothServiceInfo::BrowseGroupList, publicBrowse);
45 |
46 | QBluetoothServiceInfo::Sequence protocolDescriptorList;
47 | QBluetoothServiceInfo::Sequence protocol;
48 | protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::L2cap));
49 | protocolDescriptorList.append(QVariant::fromValue(protocol));
50 | protocol.clear();
51 | protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::Rfcomm))
52 | << QVariant::fromValue(quint8(portNumber));
53 | protocolDescriptorList.append(QVariant::fromValue(protocol));
54 | serviceInfo_.setAttribute(QBluetoothServiceInfo::ProtocolDescriptorList, protocolDescriptorList);
55 | }
56 |
57 | bool AndroidBluetoothService::registerService(const QBluetoothAddress& bluetoothAddress)
58 | {
59 | return serviceInfo_.registerService(bluetoothAddress);
60 | }
61 |
62 | bool AndroidBluetoothService::unregisterService()
63 | {
64 | return serviceInfo_.unregisterService();
65 | }
66 |
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/btservice/btservice.cpp:
--------------------------------------------------------------------------------
1 | #include "btservice/btservice.hpp"
2 |
3 | namespace openauto
4 | {
5 | namespace btservice
6 | {
7 |
8 | btservice::btservice(openauto::configuration::IConfiguration::Pointer config)
9 | : androidBluetoothService_(cServicePortNumber)
10 | , androidBluetoothServer_(config)
11 | {
12 | QBluetoothAddress address;
13 | auto adapters = QBluetoothLocalDevice::allDevices();
14 | if(adapters.size() > 0)
15 | {
16 | address = adapters.at(0).address();
17 | }
18 | else
19 | {
20 | OPENAUTO_LOG(error) << "[btservice] No adapter found.";
21 | }
22 |
23 | if(!androidBluetoothServer_.start(address, cServicePortNumber))
24 | {
25 | OPENAUTO_LOG(error) << "[btservice] Server start failed.";
26 | return;
27 | }
28 |
29 | OPENAUTO_LOG(info) << "[btservice] Listening for connections, address: " << address.toString().toStdString()
30 | << ", port: " << cServicePortNumber;
31 |
32 | if(!androidBluetoothService_.registerService(address))
33 | {
34 | OPENAUTO_LOG(error) << "[btservice] Service registration failed.";
35 | }
36 | else
37 | {
38 | OPENAUTO_LOG(info) << "[btservice] Service registered, port: " << cServicePortNumber;
39 | }
40 | if(config->getAutoconnectBluetooth())
41 | connectToBluetooth(QBluetoothAddress(QString::fromStdString(config->getLastBluetoothPair())), address);
42 | }
43 |
44 | void btservice::connectToBluetooth(QBluetoothAddress addr, QBluetoothAddress controller)
45 | {
46 | // Update 07-12-22, with bluez update and krnbt, raspberry pi is behaving as expected. For this reason
47 | // the RPI specific code has been commented out. The commented out code (and comments below this one)
48 | // exist as legacy now - in case there's a scenario where someone cannot update to krnbt or newer bluez.
49 |
50 |
51 | // The raspberry pi has a really tough time using bluetoothctl (or really anything) to connect to an Android phone
52 | // even though phone connecting to the pi is fine.
53 | // I found a workaround where you can make the pi attempt an rfcomm connection to the phone, and it connects immediately
54 | // This might require setting u+s on rfcomm though
55 | // Other computers with more sane bluetooth shouldn't have an issue using bluetoothctl
56 |
57 | // Update 01-10-21, latest firmware/package updates seem to have made bluetoothctl more stable
58 | // and it won't drop a connection anymore. Only issue, is that the connection will fail
59 | // if the desired target hasn't been "seen" yet
60 | // we can use hcitool to force the pi to recognize that we're trying to connect to a valid device.
61 | // this causes the target device to be "seen"
62 | // bluetoothctl can then connect as normal.
63 | // 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
64 | // pi mic/speakers for android auto phone calls. bluetoothctl will connect all profiles.
65 |
66 | #ifdef RPI
67 | // QString program = QString::fromStdString("sudo hcitool cc ")+addr.toString();
68 | // btConnectProcess = new QProcess();
69 | // OPENAUTO_LOG(info)<<"[btservice] Attempting to connect to last bluetooth device, "<start(program, QProcess::Unbuffered | QProcess::ReadWrite);
71 | // btConnectProcess->waitForFinished();
72 | #endif
73 | btConnectProcess = new QProcess();
74 | btConnectProcess->setProcessChannelMode(QProcess::SeparateChannels);
75 | OPENAUTO_LOG(info)<<"[btservice] Attempting to connect to last bluetooth device, "<start("bluetoothctl");
77 | btConnectProcess->waitForStarted();
78 | btConnectProcess->write(QString("select %1\n").arg(controller.toString()).toUtf8());
79 | btConnectProcess->write(QString("connect %1\n").arg(addr.toString()).toUtf8());
80 | btConnectProcess->closeWriteChannel();
81 | btConnectProcess->waitForFinished();
82 | }
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/btservice_proto/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | include(FindProtobuf)
2 | find_package(Protobuf REQUIRED)
3 | include_directories(${PROTOBUF_INCLUDE_DIR})
4 |
5 | file(GLOB_RECURSE proto_files ${CMAKE_CURRENT_SOURCE_DIR}/*.proto)
6 | protobuf_generate_cpp(proto_sources proto_headers ${proto_files})
7 | add_library(btservice_proto SHARED ${proto_headers} ${proto_sources})
8 | target_link_libraries(btservice_proto ${PROTOBUF_LIBRARIES})
9 |
10 | install(TARGETS btservice_proto DESTINATION lib)
11 | install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} DESTINATION include
12 | FILES_MATCHING PATTERN *.h
13 | PATTERN CMakeFiles EXCLUDE)
14 |
--------------------------------------------------------------------------------
/btservice_proto/NetworkInfo.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto2";
2 |
3 | package openauto.btservice.proto;
4 |
5 | enum SecurityMode {
6 | UNKNOWN_SECURITY_MODE = 0;
7 | OPEN = 1;
8 | WEP_64 = 2;
9 | WEP_128 = 3;
10 | WPA_PERSONAL = 4;
11 | WPA2_PERSONAL = 8;
12 | WPA_WPA2_PERSONAL = 12;
13 | WPA_ENTERPRISE = 20;
14 | WPA2_ENTERPRISE = 24;
15 | WPA_WPA2_ENTERPRISE = 28;
16 | }
17 |
18 | enum AccessPointType {
19 | STATIC = 0;
20 | DYNAMIC = 1;
21 | }
22 |
23 | message NetworkInfo
24 | {
25 | required string ssid = 1;
26 | required string psk = 2;
27 | required string mac_addr = 3;
28 | required SecurityMode security_mode = 4;
29 | required AccessPointType ap_type = 5;
30 | }
31 |
--------------------------------------------------------------------------------
/btservice_proto/SocketInfoRequest.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto2";
2 |
3 | package openauto.btservice.proto;
4 |
5 | message SocketInfoRequest
6 | {
7 | required string ip_address = 1;
8 | optional uint32 port = 2;
9 | }
10 |
--------------------------------------------------------------------------------
/btservice_proto/SocketInfoResponse.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto2";
2 |
3 | package openauto.btservice.proto;
4 |
5 | enum Status {
6 | STATUS_UNSOLICITED_MESSAGE = 1;
7 | STATUS_SUCCESS = 0;
8 | STATUS_NO_COMPATIBLE_VERSION = -1;
9 | STATUS_WIFI_INACCESSIBLE_CHANNEL = -2;
10 | STATUS_WIFI_INCORRECT_CREDENTIALS = -3;
11 | STATUS_PROJECTION_ALREADY_STARTED = -4;
12 | STATUS_WIFI_DISABLED = -5;
13 | STATUS_WIFI_NOT_YET_STARTED = -6;
14 | STATUS_INVALID_HOST = -7;
15 | STATUS_NO_SUPPORTED_WIFI_CHANNELS = -8;
16 | STATUS_INSTRUCT_USER_TO_CHECK_THE_PHONE = -9;
17 | STATUS_PHONE_WIFI_DISABLED = -10;
18 | STATUS_WIFI_NETWORK_UNAVAILABLE = -11;
19 | }
20 |
21 | message SocketInfoResponse
22 | {
23 | optional string ip_address = 1;
24 | optional int32 port = 2;
25 | required Status status = 3;
26 | }
27 |
--------------------------------------------------------------------------------
/cmake_modules/FindGObject.cmake:
--------------------------------------------------------------------------------
1 | # - Try to find GObject
2 | # Once done this will define
3 | #
4 | # GOBJECT_FOUND - system has GObject
5 | # GOBJECT_INCLUDE_DIR - the GObject include directory
6 | # GOBJECT_LIBRARIES - the libraries needed to use GObject
7 | # GOBJECT_DEFINITIONS - Compiler switches required for using GObject
8 |
9 | # Copyright (c) 2006, Tim Beaulen
10 | #
11 | # Redistribution and use is allowed according to the terms of the BSD license.
12 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
13 |
14 |
15 | IF (GOBJECT_INCLUDE_DIR AND GOBJECT_LIBRARIES)
16 | # in cache already
17 | SET(GObject_FIND_QUIETLY TRUE)
18 | ELSE (GOBJECT_INCLUDE_DIR AND GOBJECT_LIBRARIES)
19 | SET(GObject_FIND_QUIETLY FALSE)
20 | ENDIF (GOBJECT_INCLUDE_DIR AND GOBJECT_LIBRARIES)
21 |
22 | IF (NOT WIN32)
23 | # use pkg-config to get the directories and then use these values
24 | # in the FIND_PATH() and FIND_LIBRARY() calls
25 | FIND_PACKAGE(PkgConfig)
26 | PKG_CHECK_MODULES(PC_GOBJECT gobject-2.0)
27 | #MESSAGE(STATUS "DEBUG: GObject include directory = ${GOBJECT_INCLUDE_DIRS}")
28 | #MESSAGE(STATUS "DEBUG: GObject link directory = ${GOBJECT_LIBRARY_DIRS}")
29 | #MESSAGE(STATUS "DEBUG: GObject CFlags = ${GOBJECT_CFLAGS}")
30 | SET(GOBJECT_DEFINITIONS ${PC_GOBJECT_CFLAGS_OTHER})
31 | ENDIF (NOT WIN32)
32 |
33 | FIND_PATH(GOBJECT_INCLUDE_DIR gobject.h
34 | PATHS
35 | ${PC_GOBJECT_INCLUDEDIR}
36 | ${PC_GOBJECT_INCLUDE_DIRS}
37 | PATH_SUFFIXES glib-2.0/gobject/
38 | )
39 |
40 | FIND_LIBRARY(_GObjectLibs NAMES gobject-2.0
41 | PATHS
42 | ${PC_GOBJECT_LIBDIR}
43 | ${PC_GOBJECT_LIBRARY_DIRS}
44 | )
45 | FIND_LIBRARY(_GModuleLibs NAMES gmodule-2.0
46 | PATHS
47 | ${PC_GOBJECT_LIBDIR}
48 | ${PC_GOBJECT_LIBRARY_DIRS}
49 | )
50 | FIND_LIBRARY(_GThreadLibs NAMES gthread-2.0
51 | PATHS
52 | ${PC_GOBJECT_LIBDIR}
53 | ${PC_GOBJECT_LIBRARY_DIRS}
54 | )
55 | FIND_LIBRARY(_GLibs NAMES glib-2.0
56 | PATHS
57 | ${PC_GOBJECT_LIBDIR}
58 | ${PC_GOBJECT_LIBRARY_DIRS}
59 | )
60 |
61 | SET( GOBJECT_LIBRARIES ${_GObjectLibs} ${_GModuleLibs} ${_GThreadLibs} ${_GLibs} )
62 |
63 | IF (GOBJECT_INCLUDE_DIR AND GOBJECT_LIBRARIES)
64 | SET(GOBJECT_FOUND TRUE)
65 | ELSE (GOBJECT_INCLUDE_DIR AND GOBJECT_LIBRARIES)
66 | SET(GOBJECT_FOUND FALSE)
67 | ENDIF (GOBJECT_INCLUDE_DIR AND GOBJECT_LIBRARIES)
68 |
69 | IF (GOBJECT_FOUND)
70 | IF (NOT GObject_FIND_QUIETLY)
71 | MESSAGE(STATUS "Found GObject libraries: ${GOBJECT_LIBRARIES}")
72 | MESSAGE(STATUS "Found GObject includes : ${GOBJECT_INCLUDE_DIR}")
73 | ENDIF (NOT GObject_FIND_QUIETLY)
74 | ELSE (GOBJECT_FOUND)
75 | IF (GObject_FIND_REQUIRED)
76 | MESSAGE(STATUS "Could NOT find GObject")
77 | ENDIF(GObject_FIND_REQUIRED)
78 | ENDIF (GOBJECT_FOUND)
79 |
80 | MARK_AS_ADVANCED(GOBJECT_INCLUDE_DIR _GObjectLibs _GModuleLibs _GThreadLibs _GLibs)
81 |
--------------------------------------------------------------------------------
/cmake_modules/Findaasdk.cmake:
--------------------------------------------------------------------------------
1 | set (AASDK_DIR ~/aasdk)
2 |
3 | find_path(AASDK_INCLUDE_DIR
4 | aasdk/Version.hpp
5 | PATHS ${AASDK_DIR}
6 | PATH_SUFFIXES include
7 | )
8 |
9 | find_path(AASDK_PROTO_INCLUDE_DIR
10 | aasdk_proto/AbsoluteInputEventData.pb.h
11 | PATHS ${AASDK_DIR}
12 | )
13 |
14 | find_path(AASDK_LIB_DIR
15 | libaasdk.so
16 | PATHS ${AASDK_DIR}
17 | PATH_SUFFIXES lib
18 | )
19 |
20 | if (AASDK_INCLUDE_DIR AND AASDK_PROTO_INCLUDE_DIR AND AASDK_LIB_DIR)
21 | set(AASDK_FOUND TRUE)
22 | endif()
23 |
24 | if (AASDK_FOUND)
25 | if (NOT aasdk_FIND_QUIETLY)
26 | message(STATUS "Found aasdk:")
27 | message(STATUS " - Includes: ${AASDK_INCLUDE_DIR}")
28 | message(STATUS " - Includes: ${AASDK_PROTO_INCLUDE_DIR}")
29 | message(STATUS " - Libraries: ${AASDK_LIB_DIR}")
30 | endif()
31 | add_library(aasdk INTERFACE)
32 | target_include_directories(aasdk INTERFACE ${AASDK_INCLUDE_DIR} ${AASDK_PROTO_INCLUDE_DIR})
33 | set_target_properties(aasdk PROPERTIES INTERFACE_LINK_DIRECTORIES ${AASDK_LIB_DIR})
34 | target_link_libraries(aasdk INTERFACE libaasdk.so libaasdk_proto.so)
35 | else()
36 | if (aasdk_FIND_REQUIRED)
37 | if(AASDK_INCLUDE_DIR AND NOT AASDK_PROTO_INCLUDE_DIR)
38 | message(FATAL_ERROR "aasdk was found but not built. Perform an in-source build.")
39 | else()
40 | message(FATAL_ERROR "Could not find aasdk")
41 | endif()
42 | endif()
43 | endif()
44 |
45 | mark_as_advanced(AASDK_INCLUDE_DIRS AASDK_LIBRARIES)
46 |
--------------------------------------------------------------------------------
/cmake_modules/Findh264.cmake:
--------------------------------------------------------------------------------
1 | set (H264_INCLUDE_DIR /usr/local/include/h264bitstream)
2 | set (H264_LIB_DIR /usr/local/lib)
3 |
4 | set(H264_FOUND TRUE)
5 |
6 | if (H264_FOUND)
7 | if (NOT h264_FIND_QUIETLY)
8 | message(STATUS "Found h264bitstream:")
9 | message(STATUS " - Includes: ${H264_INCLUDE_DIR}")
10 | message(STATUS " - Libraries: ${H264_LIB_DIR}")
11 | endif()
12 | add_library(h264 INTERFACE)
13 | target_include_directories(h264 INTERFACE ${H264_INCLUDE_DIR})
14 | set_target_properties(h264 PROPERTIES INTERFACE_LINK_DIRECTORIES ${H264_LIB_DIR})
15 | target_link_libraries(h264 INTERFACE libh264bitstream.so)
16 | else()
17 | if (h264_FIND_REQUIRED)
18 | if(H264_INCLUDE_DIR)
19 | message(FATAL_ERROR "h264 was found but not built. Perform an in-source build.")
20 | else()
21 | message(FATAL_ERROR "Could not find h264")
22 | endif()
23 | endif()
24 | endif()
25 |
26 | mark_as_advanced(H264_INCLUDE_DIR H264_LIBRARIES)
27 |
--------------------------------------------------------------------------------
/cmake_modules/Findlibomx.cmake:
--------------------------------------------------------------------------------
1 | set (OMX_DIR /opt/vc/)
2 |
3 | find_path(BCM_HOST_INCLUDE_DIR
4 | bcm_host.h
5 | PATHS
6 | ${OMX_DIR}
7 | PATH_SUFFIXES
8 | include
9 | )
10 |
11 | find_path(BCM_HOST_LIB_DIR
12 | libbcm_host.so
13 | PATHS
14 | ${OMX_DIR}
15 | PATH_SUFFIXES
16 | lib
17 | )
18 |
19 | find_path(ILCLIENT_INCLUDE_DIR
20 | ilclient.h
21 | PATHS
22 | ${OMX_DIR}
23 | PATH_SUFFIXES
24 | src/hello_pi/libs/ilclient
25 | )
26 |
27 | find_path(ILCLIENT_LIB_DIR
28 | libilclient.a
29 | PATHS
30 | ${OMX_DIR}
31 | PATH_SUFFIXES
32 | src/hello_pi/libs/ilclient
33 | )
34 |
35 | if (BCM_HOST_INCLUDE_DIR AND ILCLIENT_INCLUDE_DIR AND BCM_HOST_LIB_DIR AND ILCLIENT_LIB_DIR)
36 | set(libomx_FOUND TRUE)
37 | endif()
38 |
39 | if (libomx_FOUND)
40 | if (NOT libomx_FIND_QUIETLY)
41 | message(STATUS "Found omx:")
42 | message(STATUS " - Bcm Host: ${BCM_HOST_INCLUDE_DIR}")
43 | message(STATUS " - ilclient: ${ILCLIENT_INCLUDE_DIR}")
44 | endif()
45 |
46 | add_library(omx INTERFACE)
47 |
48 | target_include_directories(omx SYSTEM INTERFACE
49 | ${BCM_HOST_INCLUDE_DIR}
50 | ${ILCLIENT_INCLUDE_DIR}
51 | )
52 |
53 | target_link_libraries(omx INTERFACE
54 | ${BCM_HOST_LIB_DIR}/libbcm_host.so
55 | ${ILCLIENT_LIB_DIR}/libilclient.a
56 | ${BCM_HOST_LIB_DIR}/libvcos.so
57 | ${BCM_HOST_LIB_DIR}/libvcilcs.a
58 | ${BCM_HOST_LIB_DIR}/libvchiq_arm.so
59 | )
60 |
61 | target_compile_definitions(omx INTERFACE
62 | -DUSE_OMX
63 | -DOMX_SKIP64BIT
64 | -DRASPBERRYPI3
65 | )
66 |
67 | endif()
68 |
--------------------------------------------------------------------------------
/cmake_modules/Findlibusb-1.0.cmake:
--------------------------------------------------------------------------------
1 | # - Try to find libusb-1.0
2 | # Once done this will define
3 | #
4 | # LIBUSB_1_FOUND - system has libusb
5 | # LIBUSB_1_INCLUDE_DIRS - the libusb include directory
6 | # LIBUSB_1_LIBRARIES - Link these to use libusb
7 | # LIBUSB_1_DEFINITIONS - Compiler switches required for using libusb
8 | #
9 | # Adapted from cmake-modules Google Code project
10 | #
11 | # Copyright (c) 2006 Andreas Schneider
12 | #
13 | # (Changes for libusb) Copyright (c) 2008 Kyle Machulis
14 | #
15 | # Redistribution and use is allowed according to the terms of the New BSD license.
16 | #
17 | # CMake-Modules Project New BSD License
18 | #
19 | # Redistribution and use in source and binary forms, with or without
20 | # modification, are permitted provided that the following conditions are met:
21 | #
22 | # * Redistributions of source code must retain the above copyright notice, this
23 | # list of conditions and the following disclaimer.
24 | #
25 | # * Redistributions in binary form must reproduce the above copyright notice,
26 | # this list of conditions and the following disclaimer in the
27 | # documentation and/or other materials provided with the distribution.
28 | #
29 | # * Neither the name of the CMake-Modules Project nor the names of its
30 | # contributors may be used to endorse or promote products derived from this
31 | # software without specific prior written permission.
32 | #
33 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
34 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
35 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
36 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
37 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
38 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
39 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
40 | # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
41 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
42 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43 | #
44 |
45 |
46 | if (LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS)
47 | # in cache already
48 | set(LIBUSB_FOUND TRUE)
49 | else (LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS)
50 | find_path(LIBUSB_1_INCLUDE_DIR
51 | NAMES
52 | libusb.h
53 | PATHS
54 | /usr/include
55 | /usr/local/include
56 | /opt/local/include
57 | /sw/include
58 | PATH_SUFFIXES
59 | libusb-1.0
60 | )
61 |
62 | find_library(LIBUSB_1_LIBRARY
63 | NAMES
64 | usb-1.0 usb
65 | PATHS
66 | /usr/lib
67 | /usr/local/lib
68 | /opt/local/lib
69 | /sw/lib
70 | )
71 |
72 | set(LIBUSB_1_INCLUDE_DIRS
73 | ${LIBUSB_1_INCLUDE_DIR}
74 | )
75 | set(LIBUSB_1_LIBRARIES
76 | ${LIBUSB_1_LIBRARY}
77 | )
78 |
79 | if (LIBUSB_1_INCLUDE_DIRS AND LIBUSB_1_LIBRARIES)
80 | set(LIBUSB_1_FOUND TRUE)
81 | endif (LIBUSB_1_INCLUDE_DIRS AND LIBUSB_1_LIBRARIES)
82 |
83 | if (LIBUSB_1_FOUND)
84 | if (NOT libusb_1_FIND_QUIETLY)
85 | message(STATUS "Found libusb-1.0:")
86 | message(STATUS " - Includes: ${LIBUSB_1_INCLUDE_DIRS}")
87 | message(STATUS " - Libraries: ${LIBUSB_1_LIBRARIES}")
88 | add_library(libusb INTERFACE)
89 | target_include_directories(libusb SYSTEM INTERFACE ${LIBUSB_1_INCLUDE_DIR})
90 | target_link_libraries(libusb INTERFACE ${LIBUSB_1_LIBRARY})
91 | endif (NOT libusb_1_FIND_QUIETLY)
92 | else (LIBUSB_1_FOUND)
93 | if (libusb_1_FIND_REQUIRED)
94 | message(FATAL_ERROR "Could not find libusb")
95 | endif (libusb_1_FIND_REQUIRED)
96 | endif (LIBUSB_1_FOUND)
97 |
98 | # show the LIBUSB_1_INCLUDE_DIRS and LIBUSB_1_LIBRARIES variables only in the advanced view
99 | mark_as_advanced(LIBUSB_1_INCLUDE_DIRS LIBUSB_1_LIBRARIES)
100 |
101 | endif (LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS)
102 |
--------------------------------------------------------------------------------
/cmake_modules/Findrtaudio.cmake:
--------------------------------------------------------------------------------
1 | #
2 | # This file is part of openauto project.
3 | # Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | #
5 | # openauto is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation; either version 3 of the License, or
8 | # (at your option) any later version.
9 |
10 | # openauto is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with openauto. If not, see .
17 | #
18 |
19 | if (RTAUDIO_LIBRARIES AND RTAUDIO_INCLUDE_DIRS)
20 | # in cache already
21 | set(RTAUDIO_FOUND TRUE)
22 | else (RTAUDIO_LIBRARIES AND RTAUDIO_INCLUDE_DIRS)
23 | find_path(RTAUDIO_INCLUDE_DIR
24 | NAMES
25 | RtAudio.h
26 | PATHS
27 | /usr/include
28 | /usr/local/include
29 | /opt/local/include
30 | /sw/include
31 | PATH_SUFFIXES
32 | rtaudio
33 | )
34 |
35 | find_library(RTAUDIO_LIBRARY
36 | NAMES
37 | rtaudio
38 | PATHS
39 | /usr/lib
40 | /usr/local/lib
41 | /opt/local/lib
42 | /sw/lib
43 | )
44 |
45 | set(RTAUDIO_INCLUDE_DIRS
46 | ${RTAUDIO_INCLUDE_DIR}
47 | )
48 | set(RTAUDIO_LIBRARIES
49 | ${RTAUDIO_LIBRARY}
50 | )
51 |
52 | if (RTAUDIO_INCLUDE_DIRS AND RTAUDIO_LIBRARIES)
53 | set(RTAUDIO_FOUND TRUE)
54 | endif (RTAUDIO_INCLUDE_DIRS AND RTAUDIO_LIBRARIES)
55 |
56 | if (RTAUDIO_FOUND)
57 | if (NOT rtaudio_FIND_QUIETLY)
58 | message(STATUS "Found rtaudio:")
59 | message(STATUS " - Includes: ${RTAUDIO_INCLUDE_DIRS}")
60 | message(STATUS " - Libraries: ${RTAUDIO_LIBRARIES}")
61 | endif (NOT rtaudio_FIND_QUIETLY)
62 | else (RTAUDIO_FOUND)
63 | if (rtaudio_FIND_REQUIRED)
64 | message(FATAL_ERROR "Could not find rtaudio")
65 | endif (rtaudio_FIND_REQUIRED)
66 | endif (RTAUDIO_FOUND)
67 |
68 | mark_as_advanced(RTAUDIO_INCLUDE_DIRS RTAUDIO_LIBRARIES)
69 |
70 | endif (RTAUDIO_LIBRARIES AND RTAUDIO_INCLUDE_DIRS)
71 |
--------------------------------------------------------------------------------
/cmake_modules/functions.cmake:
--------------------------------------------------------------------------------
1 |
2 | function( findRpiRevision OUTPUT )
3 | # Find it with an automated script
4 | execute_process( COMMAND grep -Po "^Revision\\s*:\\s*\\K[[:xdigit:]]+" /proc/cpuinfo OUTPUT_VARIABLE TMP OUTPUT_STRIP_TRAILING_WHITESPACE )
5 |
6 | # If have not found the Revision number, use the last version
7 | if ( TMP )
8 | message( "-- Detecting Raspberry Pi Revision Number: ${TMP}" )
9 | else()
10 | set( TMP "0006" )
11 | message( WARNING "-- Could NOT find Raspberry Pi revision!" )
12 | endif()
13 |
14 | set( ${OUTPUT} "${TMP}" PARENT_SCOPE )
15 | endfunction()
16 |
--------------------------------------------------------------------------------
/cmake_modules/gitversion.cmake:
--------------------------------------------------------------------------------
1 | # cmake/gitversion.cmake
2 | cmake_minimum_required(VERSION 3.0.0)
3 |
4 | message(STATUS "Resolving GIT Version")
5 |
6 | set(_build_version "unknown")
7 | set(_commit_timestamp "unknown")
8 |
9 | find_package(Git)
10 | if(GIT_FOUND)
11 | execute_process(
12 | COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
13 | WORKING_DIRECTORY "${local_dir}"
14 | OUTPUT_VARIABLE _build_version
15 | ERROR_QUIET
16 | OUTPUT_STRIP_TRAILING_WHITESPACE
17 | )
18 | execute_process(
19 | COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
20 | WORKING_DIRECTORY "${local_dir}"
21 | OUTPUT_VARIABLE _build_branch
22 | ERROR_QUIET
23 | OUTPUT_STRIP_TRAILING_WHITESPACE
24 | )
25 | execute_process(
26 | COMMAND ${GIT_EXECUTABLE} log -1 --format=%at
27 | WORKING_DIRECTORY "${local_dir}"
28 | OUTPUT_VARIABLE _commit_timestamp
29 | ERROR_QUIET
30 | OUTPUT_STRIP_TRAILING_WHITESPACE
31 | )
32 | message( STATUS "GIT hash: ${_build_version}; branch: ${_build_branch}; Commit epoch: ${_commit_timestamp};")
33 | execute_process(
34 | COMMAND ${GIT_EXECUTABLE} diff --no-ext-diff --quiet
35 | WORKING_DIRECTORY "${local_dir}"
36 | RESULT_VARIABLE ret
37 | )
38 | if(ret EQUAL "1")
39 | set(_build_changes "*")
40 | else()
41 | set(_build_changes "")
42 | endif()
43 |
44 | else()
45 | message(STATUS "GIT not found")
46 | endif()
47 |
48 | # branch name
49 | # git rev-parse --abbrev-ref HEAD
50 | # changed
51 | # git diff --no-ext-diff --quiet
52 |
--------------------------------------------------------------------------------
/include/OpenautoLog.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include
22 |
23 | #define OPENAUTO_LOG(severity) BOOST_LOG_TRIVIAL(severity) << "[OpenAuto] "
24 |
--------------------------------------------------------------------------------
/include/autoapp/UI/ConnectDialog.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include "aasdk/TCP/ITCPEndpoint.hpp"
6 | #include "aasdk/TCP/ITCPWrapper.hpp"
7 | #include "openauto/Configuration/IRecentAddressesList.hpp"
8 |
9 | namespace Ui {
10 | class ConnectDialog;
11 | }
12 |
13 | namespace autoapp
14 | {
15 | namespace ui
16 | {
17 |
18 | class ConnectDialog : public QDialog
19 | {
20 | Q_OBJECT
21 |
22 | public:
23 | explicit ConnectDialog(boost::asio::io_service& ioService, aasdk::tcp::ITCPWrapper& tcpWrapper, openauto::configuration::IRecentAddressesList& recentAddressesList, QWidget *parent = nullptr);
24 | ~ConnectDialog() override;
25 |
26 | signals:
27 | void connectToDevice(const QString& ipAddress);
28 | void connectionSucceed(aasdk::tcp::ITCPEndpoint::SocketPointer socket, const std::string& ipAddress);
29 | void connectionFailed(const QString& message);
30 |
31 | private slots:
32 | void onConnectButtonClicked();
33 | void onConnectionFailed(const QString& message);
34 | void onConnectionSucceed(aasdk::tcp::ITCPEndpoint::SocketPointer socket, const std::string& ipAddress);
35 | void onRecentAddressClicked(const QModelIndex& index);
36 |
37 | private:
38 | void insertIpAddress(const std::string& ipAddress);
39 | void loadRecentList();
40 | void setControlsEnabledStatus(bool status);
41 | void connectHandler(const boost::system::error_code& ec, const std::string& ipAddress, aasdk::tcp::ITCPEndpoint::SocketPointer socket);
42 |
43 | boost::asio::io_service& ioService_;
44 | aasdk::tcp::ITCPWrapper& tcpWrapper_;
45 | openauto::configuration::IRecentAddressesList& recentAddressesList_;
46 | Ui::ConnectDialog *ui_;
47 | QStringListModel recentAddressesModel_;
48 | };
49 |
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/include/autoapp/UI/MainWindow.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include
22 | #include
23 |
24 | namespace Ui
25 | {
26 | class MainWindow;
27 | }
28 |
29 | namespace autoapp
30 | {
31 | namespace ui
32 | {
33 |
34 | class MainWindow : public QMainWindow
35 | {
36 | Q_OBJECT
37 | public:
38 | explicit MainWindow(QWidget *parent = nullptr);
39 | ~MainWindow() override;
40 |
41 | signals:
42 | void exit();
43 | void openSettings();
44 | void toggleCursor();
45 | void openConnectDialog();
46 |
47 | private:
48 | Ui::MainWindow* ui_;
49 | };
50 |
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/include/autoapp/UI/SettingsWindow.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include
22 | #include
23 | #include "openauto/Configuration/IConfiguration.hpp"
24 |
25 | class QCheckBox;
26 |
27 | namespace Ui
28 | {
29 | class SettingsWindow;
30 | }
31 |
32 | namespace autoapp
33 | {
34 | namespace ui
35 | {
36 |
37 | class SettingsWindow : public QWidget
38 | {
39 | Q_OBJECT
40 | public:
41 | explicit SettingsWindow(openauto::configuration::IConfiguration::Pointer configuration, QWidget *parent = nullptr);
42 | ~SettingsWindow() override;
43 |
44 | private slots:
45 | void onSave();
46 | void onResetToDefaults();
47 | void onUpdateScreenDPI(int value);
48 | void onShowBindings();
49 |
50 | private:
51 | void showEvent(QShowEvent* event);
52 | void load();
53 | void loadButtonCheckBoxes();
54 | void saveButtonCheckBoxes();
55 | void saveButtonCheckBox(const QCheckBox* checkBox, openauto::configuration::IConfiguration::ButtonCodes& buttonCodes, aasdk::proto::enums::ButtonCode::Enum buttonCode);
56 | void setButtonCheckBoxes(bool value);
57 |
58 | Ui::SettingsWindow* ui_;
59 | openauto::configuration::IConfiguration::Pointer configuration_;
60 | };
61 |
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/include/btservice/AndroidBluetoothServer.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 | #include
13 | #include "openauto/Configuration/Configuration.hpp"
14 | #include "IAndroidBluetoothServer.hpp"
15 |
16 | namespace openauto
17 | {
18 | namespace btservice
19 | {
20 |
21 | class AndroidBluetoothServer: public QObject, public IAndroidBluetoothServer
22 | {
23 | Q_OBJECT
24 |
25 | public:
26 | AndroidBluetoothServer(openauto::configuration::IConfiguration::Pointer config);
27 | bool start(const QBluetoothAddress& address, uint16_t portNumber) override;
28 |
29 | private slots:
30 | void onClientConnected();
31 | void readSocket();
32 |
33 | private:
34 | std::unique_ptr rfcommServer_;
35 | QBluetoothSocket* socket_;
36 | openauto::configuration::IConfiguration::Pointer config_;
37 |
38 | void handleUnknownMessage(int messageType, QByteArray data);
39 | void handleSocketInfoRequest(QByteArray data);
40 | void handleSocketInfoRequestResponse(QByteArray data);
41 | void writeSocketInfoRequest();
42 | void writeSocketInfoResponse();
43 | void writeNetworkInfoMessage();
44 | bool writeProtoMessage(uint16_t messageType, google::protobuf::Message& message);
45 |
46 | };
47 |
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/include/btservice/AndroidBluetoothService.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include
22 | #include "IAndroidBluetoothService.hpp"
23 |
24 | namespace openauto
25 | {
26 | namespace btservice
27 | {
28 |
29 | class AndroidBluetoothService: public IAndroidBluetoothService
30 | {
31 | public:
32 | AndroidBluetoothService(uint16_t portNumber);
33 |
34 | bool registerService(const QBluetoothAddress& bluetoothAddress) override;
35 | bool unregisterService() override;
36 |
37 | private:
38 | QBluetoothServiceInfo serviceInfo_;
39 | };
40 |
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/include/btservice/IAndroidBluetoothServer.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include
22 |
23 | namespace openauto
24 | {
25 | namespace btservice
26 | {
27 |
28 | class IAndroidBluetoothServer
29 | {
30 | public:
31 | virtual ~IAndroidBluetoothServer() = default;
32 |
33 | virtual bool start(const QBluetoothAddress& address, uint16_t portNumber) = 0;
34 | };
35 |
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/include/btservice/IAndroidBluetoothService.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include
22 |
23 | namespace openauto
24 | {
25 | namespace btservice
26 | {
27 |
28 | class IAndroidBluetoothService
29 | {
30 | public:
31 | virtual ~IAndroidBluetoothService() = default;
32 |
33 | virtual bool registerService(const QBluetoothAddress& bluetoothAddress) = 0;
34 | virtual bool unregisterService() = 0;
35 | };
36 |
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/include/btservice/btservice.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include "OpenautoLog.hpp"
6 | #include "btservice/AndroidBluetoothService.hpp"
7 | #include "btservice/AndroidBluetoothServer.hpp"
8 | #include "openauto/Configuration/Configuration.hpp"
9 |
10 | namespace openauto
11 | {
12 | namespace btservice
13 | {
14 |
15 | class btservice
16 | {
17 | public:
18 | btservice(openauto::configuration::IConfiguration::Pointer config);
19 |
20 | private:
21 | const uint16_t cServicePortNumber = 22;
22 | void connectToBluetooth(QBluetoothAddress addr, QBluetoothAddress controller);
23 | openauto::btservice::AndroidBluetoothService androidBluetoothService_;
24 | openauto::btservice::AndroidBluetoothServer androidBluetoothServer_;
25 | QProcess *btConnectProcess;
26 | };
27 |
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/include/openauto/App.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include "aasdk/USB/IUSBHub.hpp"
22 | #include "aasdk/USB/IConnectedAccessoriesEnumerator.hpp"
23 | #include "aasdk/USB/USBWrapper.hpp"
24 | #include "aasdk/TCP/ITCPWrapper.hpp"
25 | #include "aasdk/TCP/ITCPEndpoint.hpp"
26 | #include "openauto/Service/IAndroidAutoEntityEventHandler.hpp"
27 | #include "openauto/Service/IAndroidAutoEntityFactory.hpp"
28 |
29 | namespace openauto
30 | {
31 |
32 | class App: public openauto::service::IAndroidAutoEntityEventHandler, public std::enable_shared_from_this
33 | {
34 | public:
35 | typedef std::shared_ptr Pointer;
36 |
37 | App(boost::asio::io_service& ioService, aasdk::usb::USBWrapper& usbWrapper, aasdk::tcp::ITCPWrapper& tcpWrapper, openauto::service::IAndroidAutoEntityFactory& androidAutoEntityFactory,
38 | aasdk::usb::IUSBHub::Pointer usbHub, aasdk::usb::IConnectedAccessoriesEnumerator::Pointer connectedAccessoriesEnumerator);
39 |
40 | void waitForDevice(bool enumerate = false);
41 | void start(aasdk::tcp::ITCPEndpoint::SocketPointer socket);
42 | void stop();
43 | void onAndroidAutoQuit() override;
44 |
45 | private:
46 | using std::enable_shared_from_this::shared_from_this;
47 | void enumerateDevices();
48 | void waitForUSBDevice();
49 | void waitForWirelessDevice();
50 | void aoapDeviceHandler(aasdk::usb::DeviceHandle deviceHandle);
51 | void onUSBHubError(const aasdk::error::Error& error);
52 |
53 | boost::asio::io_service& ioService_;
54 | aasdk::usb::USBWrapper& usbWrapper_;
55 | aasdk::tcp::ITCPWrapper& tcpWrapper_;
56 | boost::asio::io_service::strand strand_;
57 | openauto::service::IAndroidAutoEntityFactory& androidAutoEntityFactory_;
58 | aasdk::usb::IUSBHub::Pointer usbHub_;
59 | boost::asio::ip::tcp::acceptor acceptor_;
60 | aasdk::usb::IConnectedAccessoriesEnumerator::Pointer connectedAccessoriesEnumerator_;
61 | openauto::service::IAndroidAutoEntity::Pointer androidAutoEntity_;
62 | bool isStopped_;
63 | };
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/include/openauto/Configuration/AudioOutputBackendType.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | namespace openauto
22 | {
23 | namespace configuration
24 | {
25 |
26 | enum class AudioOutputBackendType
27 | {
28 | RTAUDIO,
29 | QT
30 | };
31 |
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/include/openauto/Configuration/BluetootAdapterType.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | namespace openauto
22 | {
23 | namespace configuration
24 | {
25 |
26 | enum class BluetoothAdapterType
27 | {
28 | NONE,
29 | LOCAL,
30 | REMOTE
31 | };
32 |
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/include/openauto/Configuration/HandednessOfTrafficType.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | namespace openauto
22 | {
23 | namespace configuration
24 | {
25 |
26 | enum class HandednessOfTrafficType
27 | {
28 | LEFT_HAND_DRIVE,
29 | RIGHT_HAND_DRIVE
30 | };
31 |
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/include/openauto/Configuration/IConfiguration.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include
22 | #include
23 | #include "aasdk_proto/VideoFPSEnum.pb.h"
24 | #include "aasdk_proto/VideoResolutionEnum.pb.h"
25 | #include "aasdk_proto/ButtonCodeEnum.pb.h"
26 | #include "BluetootAdapterType.hpp"
27 | #include "HandednessOfTrafficType.hpp"
28 | #include "AudioOutputBackendType.hpp"
29 |
30 | namespace openauto
31 | {
32 | namespace configuration
33 | {
34 |
35 | class IConfiguration
36 | {
37 | public:
38 | typedef std::shared_ptr Pointer;
39 | typedef std::vector ButtonCodes;
40 |
41 | virtual ~IConfiguration() = default;
42 |
43 | virtual void load() = 0;
44 | virtual void reset() = 0;
45 | virtual void save() = 0;
46 |
47 | virtual void setHandednessOfTrafficType(HandednessOfTrafficType value) = 0;
48 | virtual HandednessOfTrafficType getHandednessOfTrafficType() const = 0;
49 | virtual void showClock(bool value) = 0;
50 | virtual bool showClock() const = 0;
51 |
52 | virtual aasdk::proto::enums::VideoFPS::Enum getVideoFPS() const = 0;
53 | virtual void setVideoFPS(aasdk::proto::enums::VideoFPS::Enum value) = 0;
54 | virtual aasdk::proto::enums::VideoResolution::Enum getVideoResolution() const = 0;
55 | virtual void setVideoResolution(aasdk::proto::enums::VideoResolution::Enum value) = 0;
56 | virtual size_t getScreenDPI() const = 0;
57 | virtual void setScreenDPI(size_t value) = 0;
58 | virtual void setOMXLayerIndex(int32_t value) = 0;
59 | virtual int32_t getOMXLayerIndex() const = 0;
60 | virtual void setVideoMargins(QRect value) = 0;
61 | virtual QRect getVideoMargins() const = 0;
62 | virtual void setWhitescreenWorkaround(bool value) = 0;
63 | virtual bool getWhitescreenWorkaround() const = 0;
64 |
65 | virtual bool getTouchscreenEnabled() const = 0;
66 | virtual void setTouchscreenEnabled(bool value) = 0;
67 | virtual ButtonCodes getButtonCodes() const = 0;
68 | virtual void setButtonCodes(const ButtonCodes& value) = 0;
69 |
70 | virtual BluetoothAdapterType getBluetoothAdapterType() const = 0;
71 | virtual void setBluetoothAdapterType(BluetoothAdapterType value) = 0;
72 | virtual std::string getBluetoothRemoteAdapterAddress() const = 0;
73 | virtual void setBluetoothRemoteAdapterAddress(const std::string& value) = 0;
74 |
75 | virtual bool musicAudioChannelEnabled() const = 0;
76 | virtual void setMusicAudioChannelEnabled(bool value) = 0;
77 | virtual bool speechAudioChannelEnabled() const = 0;
78 | virtual void setSpeechAudioChannelEnabled(bool value) = 0;
79 | virtual AudioOutputBackendType getAudioOutputBackendType() const = 0;
80 | virtual void setAudioOutputBackendType(AudioOutputBackendType value) = 0;
81 |
82 | virtual std::string getWifiSSID() = 0;
83 | virtual void setWifiSSID(std::string value) = 0;
84 | virtual std::string getWifiPassword() = 0;
85 | virtual void setWifiPassword(std::string value) = 0;
86 | virtual std::string getWifiMAC() = 0;
87 | virtual void setWifiMAC(std::string value) = 0;
88 | virtual bool getAutoconnectBluetooth() = 0;
89 | virtual void setAutoconnectBluetooth(bool value) = 0;
90 | virtual std::string getLastBluetoothPair() = 0;
91 | virtual void setLastBluetoothPair(std::string value) = 0;
92 | };
93 |
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/include/openauto/Configuration/IRecentAddressesList.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include
22 | #include
23 |
24 | namespace openauto
25 | {
26 | namespace configuration
27 | {
28 |
29 | class IRecentAddressesList
30 | {
31 | public:
32 | typedef std::deque RecentAddresses;
33 |
34 | virtual void read() = 0;
35 | virtual void insertAddress(const std::string& address) = 0;
36 | virtual RecentAddresses getList() const = 0;
37 | };
38 |
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/include/openauto/Configuration/RecentAddressesList.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include
22 | #include "IRecentAddressesList.hpp"
23 |
24 | namespace openauto
25 | {
26 | namespace configuration
27 | {
28 |
29 | class RecentAddressesList: public IRecentAddressesList
30 | {
31 | public:
32 | RecentAddressesList(size_t maxListSize);
33 |
34 | void read() override;
35 | void insertAddress(const std::string& address) override;
36 | RecentAddresses getList() const override;
37 |
38 | private:
39 | void load();
40 | void save();
41 |
42 | size_t maxListSize_;
43 | RecentAddresses list_;
44 |
45 | static const std::string cConfigFileName;
46 | static const std::string cRecentEntiresCount;
47 | static const std::string cRecentEntryPrefix;
48 | };
49 |
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/include/openauto/Projection/DummyBluetoothDevice.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include "IBluetoothDevice.hpp"
22 |
23 | namespace openauto
24 | {
25 | namespace projection
26 | {
27 |
28 | class DummyBluetoothDevice: public IBluetoothDevice
29 | {
30 | public:
31 | void stop() override;
32 | bool isPaired(const std::string& address) const override;
33 | void pair(const std::string& address, PairingPromise::Pointer promise) override;
34 | std::string getLocalAddress() const override;
35 | bool isAvailable() const override;
36 | };
37 |
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/include/openauto/Projection/GSTVideoOutput.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #ifdef USE_GST
20 | #pragma once
21 |
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include "openauto/Projection/VideoOutput.hpp"
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include
34 | #include
35 | #include
36 | #include
37 | #include
38 | #include
39 | #include
40 | #include
41 | #include
42 | #include
43 | #include
44 | #include
45 | #include
46 | #include
47 | #include
48 |
49 | namespace openauto
50 | {
51 | namespace projection
52 | {
53 |
54 | // enum of possible h264 decoders dash will attempt to use
55 | enum H264_Decoder {
56 | nvcodec,
57 | v4l2,
58 | omx,
59 | vaapi,
60 | libav,
61 | unknown
62 | };
63 |
64 | // order of priority for decoders - dash will use the first decoder it can find in this list
65 | // for sake of the code, don't include "unknown" as a decoder to search for - this is the default case.
66 | const H264_Decoder H264_Decoder_Priority_List[] = { nvcodec, v4l2, omx, libav };
67 |
68 | // A map of enum to actual pad name we want to use
69 | inline const char* ToString(H264_Decoder v)
70 | {
71 | switch (v)
72 | {
73 | case nvcodec: return "nvh264dec";
74 | case v4l2: return "v4l2h264dec";
75 | case omx: return "omxh264dec";
76 | case libav: return "avdec_h264";
77 | default: return "unknown";
78 | }
79 | }
80 | // A map of enum to pipeline steps to insert (because for some we need some video converting)
81 | inline const char* ToPipeline(H264_Decoder v)
82 | {
83 | switch (v)
84 | {
85 | // we're going to assume that any machine with an nvidia card has a cpu powerful enough for video convert.
86 | case nvcodec: return "nvh264dec ! videoconvert";
87 | case v4l2: return "v4l2h264dec";
88 | case omx: return "omxh264dec";
89 | case libav: return "avdec_h264";
90 | default: return "unknown";
91 | }
92 | }
93 |
94 | class GSTVideoOutput: public QObject, public VideoOutput, boost::noncopyable
95 | {
96 | Q_OBJECT
97 |
98 | public:
99 | GSTVideoOutput(configuration::IConfiguration::Pointer configuration, QWidget* videoContainer=nullptr, std::function activeCallback=nullptr);
100 | ~GSTVideoOutput();
101 | bool open() override;
102 | bool init() override;
103 | void write(uint64_t timestamp, const aasdk::common::DataConstBuffer& buffer) override;
104 | void stop() override;
105 | void resize();
106 |
107 | signals:
108 | void startPlayback();
109 | void stopPlayback();
110 |
111 | protected slots:
112 | void onStartPlayback();
113 | void onStopPlayback();
114 |
115 | public slots:
116 | void dumpDot();
117 | private:
118 | static GstPadProbeReturn convertProbe(GstPad* pad, GstPadProbeInfo* info, void*);
119 | static gboolean busCallback(GstBus*, GstMessage* message, gpointer*);
120 | H264_Decoder findPreferredVideoDecoder();
121 |
122 | bool firstHeaderParsed = false;
123 |
124 | QGst::ElementPtr videoSink_;
125 | QQuickWidget* videoWidget_;
126 | GstElement* vidPipeline_;
127 | GstVideoFilter* vidCrop_;
128 | GstAppSrc* vidSrc_;
129 | QWidget* videoContainer_;
130 | QGst::Quick::VideoSurface* surface_;
131 | std::function activeCallback_;
132 | };
133 |
134 | }
135 | }
136 |
137 | #endif
138 |
--------------------------------------------------------------------------------
/include/openauto/Projection/IAudioInput.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include
22 | #include "aasdk/IO/Promise.hpp"
23 | #include "aasdk/Common/Data.hpp"
24 |
25 | namespace openauto
26 | {
27 | namespace projection
28 | {
29 |
30 | class IAudioInput
31 | {
32 | public:
33 | typedef aasdk::io::Promise StartPromise;
34 | typedef aasdk::io::Promise ReadPromise;
35 | typedef std::shared_ptr Pointer;
36 |
37 | virtual ~IAudioInput() = default;
38 |
39 | virtual bool open() = 0;
40 | virtual bool isActive() const = 0;
41 | virtual void read(ReadPromise::Pointer promise) = 0;
42 | virtual void start(StartPromise::Pointer promise) = 0;
43 | virtual void stop() = 0;
44 | virtual uint32_t getSampleSize() const = 0;
45 | virtual uint32_t getChannelCount() const = 0;
46 | virtual uint32_t getSampleRate() const = 0;
47 | };
48 |
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/include/openauto/Projection/IAudioOutput.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include
22 | #include "aasdk/Messenger/Timestamp.hpp"
23 | #include "aasdk/Common/Data.hpp"
24 |
25 | namespace openauto
26 | {
27 | namespace projection
28 | {
29 |
30 | class IAudioOutput
31 | {
32 | public:
33 | typedef std::shared_ptr Pointer;
34 |
35 | IAudioOutput() = default;
36 | virtual ~IAudioOutput() = default;
37 |
38 | virtual bool open() = 0;
39 | virtual void write(aasdk::messenger::Timestamp::ValueType timestamp, const aasdk::common::DataConstBuffer& buffer) = 0;
40 | virtual void start() = 0;
41 | virtual void stop() = 0;
42 | virtual void suspend() = 0;
43 | virtual uint32_t getSampleSize() const = 0;
44 | virtual uint32_t getChannelCount() const = 0;
45 | virtual uint32_t getSampleRate() const = 0;
46 | };
47 |
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/include/openauto/Projection/IBluetoothDevice.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #include "aasdk/IO/Promise.hpp"
20 |
21 | #pragma once
22 |
23 | namespace openauto
24 | {
25 | namespace projection
26 | {
27 |
28 | class IBluetoothDevice
29 | {
30 | public:
31 | typedef aasdk::io::Promise PairingPromise;
32 | typedef std::shared_ptr Pointer;
33 |
34 | virtual void stop() = 0;
35 | virtual bool isPaired(const std::string& address) const = 0;
36 | virtual void pair(const std::string& address, PairingPromise::Pointer promise) = 0;
37 | virtual std::string getLocalAddress() const = 0;
38 | virtual bool isAvailable() const = 0;
39 | };
40 |
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/include/openauto/Projection/IInputDevice.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include
22 | #include "aasdk/IO/Promise.hpp"
23 | #include "InputEvent.hpp"
24 |
25 | namespace openauto
26 | {
27 | namespace projection
28 | {
29 |
30 | class IInputDeviceEventHandler;
31 |
32 | class IInputDevice
33 | {
34 | public:
35 | typedef std::shared_ptr Pointer;
36 | typedef std::vector ButtonCodes;
37 |
38 | virtual ~IInputDevice() = default;
39 | virtual void start(IInputDeviceEventHandler& eventHandler) = 0;
40 | virtual void stop() = 0;
41 | virtual ButtonCodes getSupportedButtonCodes() const = 0;
42 | virtual bool hasTouchscreen() const = 0;
43 | virtual QRect getTouchscreenGeometry() const = 0;
44 | };
45 |
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/include/openauto/Projection/IInputDeviceEventHandler.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include "InputEvent.hpp"
22 | #include "aasdk_proto/InputEventIndicationMessage.pb.h"
23 |
24 |
25 | namespace openauto
26 | {
27 | namespace projection
28 | {
29 |
30 | class IInputDeviceEventHandler
31 | {
32 | public:
33 | virtual ~IInputDeviceEventHandler() = default;
34 |
35 | virtual void onButtonEvent(const ButtonEvent& event) = 0;
36 | virtual void onTouchEvent(aasdk::proto::messages::InputEventIndication inputEventIndication) = 0;
37 | virtual void onMouseEvent(const projection::TouchEvent& event) = 0;
38 |
39 | };
40 |
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/include/openauto/Projection/IVideoOutput.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include
22 | #include
23 | #include "aasdk_proto/VideoFPSEnum.pb.h"
24 | #include "aasdk_proto/VideoResolutionEnum.pb.h"
25 | #include "aasdk/Common/Data.hpp"
26 |
27 | namespace openauto
28 | {
29 | namespace projection
30 | {
31 |
32 | class IVideoOutput
33 | {
34 | public:
35 | typedef std::shared_ptr Pointer;
36 |
37 | IVideoOutput() = default;
38 | virtual ~IVideoOutput() = default;
39 |
40 | virtual bool open() = 0;
41 | virtual bool init() = 0;
42 | virtual void write(uint64_t timestamp, const aasdk::common::DataConstBuffer& buffer) = 0;
43 | virtual void stop() = 0;
44 | virtual aasdk::proto::enums::VideoFPS::Enum getVideoFPS() const = 0;
45 | virtual aasdk::proto::enums::VideoResolution::Enum getVideoResolution() const = 0;
46 | virtual size_t getScreenDPI() const = 0;
47 | virtual QRect getVideoMargins() const = 0;
48 | };
49 |
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/include/openauto/Projection/InputDevice.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include
22 | #include
23 | #include "IInputDevice.hpp"
24 | #include "openauto/Configuration/IConfiguration.hpp"
25 | #include
26 |
27 | namespace openauto
28 | {
29 | namespace projection
30 | {
31 |
32 | class InputDevice: public QObject, public IInputDevice, boost::noncopyable
33 | {
34 | Q_OBJECT
35 |
36 | public:
37 | InputDevice(QObject& parent, configuration::IConfiguration::Pointer configuration, const QRect& touchscreenGeometry, const QRect& videoGeometry);
38 |
39 | void start(IInputDeviceEventHandler& eventHandler) override;
40 | void stop() override;
41 | ButtonCodes getSupportedButtonCodes() const override;
42 | bool eventFilter(QObject* obj, QEvent* event) override;
43 | bool hasTouchscreen() const override;
44 | QRect getTouchscreenGeometry() const override;
45 | void setTouchscreenGeometry(QRect& touchscreenGeometry);
46 |
47 | private:
48 | void setVideoGeometry();
49 | bool handleKeyEvent(QEvent* event, QKeyEvent* key);
50 | void dispatchKeyEvent(ButtonEvent event);
51 | bool handleTouchEvent(QEvent* event);
52 | bool handleMouseEvent(QEvent* event);
53 |
54 | QObject& parent_;
55 | configuration::IConfiguration::Pointer configuration_;
56 | QRect touchscreenGeometry_;
57 | QRect displayGeometry_;
58 | IInputDeviceEventHandler* eventHandler_;
59 | std::mutex mutex_;
60 |
61 | std::priority_queue , std::greater > pointer_id_queue;
62 | QMap pointer_map;
63 | int max_pointers = 0;
64 | };
65 |
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/include/openauto/Projection/InputEvent.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include "aasdk_proto/ButtonCodeEnum.pb.h"
22 | #include "aasdk_proto/TouchActionEnum.pb.h"
23 | #include "aasdk/IO/Promise.hpp"
24 |
25 | namespace openauto
26 | {
27 | namespace projection
28 | {
29 |
30 | enum class ButtonEventType
31 | {
32 | NONE,
33 | PRESS,
34 | RELEASE
35 | };
36 |
37 | enum class WheelDirection
38 | {
39 | NONE,
40 | LEFT,
41 | RIGHT
42 | };
43 |
44 | struct ButtonEvent
45 | {
46 | ButtonEventType type;
47 | WheelDirection wheelDirection;
48 | aasdk::proto::enums::ButtonCode::Enum code;
49 | };
50 |
51 | struct TouchEvent
52 | {
53 | aasdk::proto::enums::TouchAction::Enum type;
54 | uint32_t x;
55 | uint32_t y;
56 | uint32_t pointerId;
57 | };
58 |
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/include/openauto/Projection/LocalBluetoothDevice.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #include
20 | #include "IBluetoothDevice.hpp"
21 |
22 | #pragma once
23 |
24 | namespace openauto
25 | {
26 | namespace projection
27 | {
28 |
29 | class LocalBluetoothDevice: public QObject, public IBluetoothDevice
30 | {
31 | Q_OBJECT
32 |
33 | public:
34 | LocalBluetoothDevice();
35 |
36 | void stop() override;
37 | bool isPaired(const std::string& address) const override;
38 | void pair(const std::string& address, PairingPromise::Pointer promise) override;
39 | std::string getLocalAddress() const override;
40 | bool isAvailable() const override;
41 |
42 | signals:
43 | void startPairing(const QString& address, PairingPromise::Pointer promise);
44 |
45 | private slots:
46 | void createBluetoothLocalDevice();
47 | void onStartPairing(const QString& address, PairingPromise::Pointer promise);
48 | void onPairingDisplayConfirmation(const QBluetoothAddress &address, QString pin);
49 | void onPairingDisplayPinCode(const QBluetoothAddress &address, QString pin);
50 | void onPairingFinished(const QBluetoothAddress &address, QBluetoothLocalDevice::Pairing pairing);
51 | void onError(QBluetoothLocalDevice::Error error);
52 | void onHostModeStateChanged(QBluetoothLocalDevice::HostMode state);
53 |
54 | private:
55 | mutable std::mutex mutex_;
56 | std::unique_ptr localDevice_;
57 | PairingPromise::Pointer pairingPromise_;
58 | QBluetoothAddress pairingAddress_;
59 | };
60 |
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/include/openauto/Projection/OMXVideoOutput.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #ifdef USE_OMX
20 | #pragma once
21 |
22 | extern "C"
23 | {
24 | #include
25 | }
26 |
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include "VideoOutput.hpp"
33 |
34 | namespace openauto
35 | {
36 | namespace projection
37 | {
38 |
39 | struct DestRect
40 | {
41 | DestRect();
42 | DestRect(OMX_S16 xOffset, OMX_S16 yOffset, OMX_S16 width, OMX_S16 height);
43 |
44 | OMX_BOOL fullscreen;
45 | OMX_S16 xOffset;
46 | OMX_S16 yOffset;
47 | OMX_S16 width;
48 | OMX_S16 height;
49 | };
50 |
51 | class OMXVideoOutput: public VideoOutput
52 | {
53 | public:
54 | OMXVideoOutput(configuration::IConfiguration::Pointer configuration, DestRect destRect=DestRect(), std::function activeCallback=nullptr);
55 |
56 | bool open() override;
57 | bool init() override;
58 | void write(uint64_t timestamp, const aasdk::common::DataConstBuffer& buffer) override;
59 | void stop() override;
60 | void setOpacity(OMX_U32 alpha);
61 | void setDestRect(DestRect destRect);
62 |
63 | private:
64 | bool createComponents();
65 | bool initClock();
66 | bool setupTunnels();
67 | bool enablePortBuffers();
68 | bool setupDisplayRegion();
69 |
70 | std::mutex mutex_;
71 | bool isActive_;
72 | bool portSettingsChanged_;
73 | ILCLIENT_T* client_;
74 | COMPONENT_T* components_[5];
75 | TUNNEL_T tunnels_[4];
76 | DestRect destRect_;
77 | OMX_U32 alpha_;
78 | std::function activeCallback_;
79 | };
80 |
81 | }
82 | }
83 |
84 | #endif
85 |
--------------------------------------------------------------------------------
/include/openauto/Projection/QtAudioInput.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include
22 | #include
23 | #include
24 | #include "IAudioInput.hpp"
25 |
26 | namespace openauto
27 | {
28 | namespace projection
29 | {
30 |
31 | class QtAudioInput: public QObject, public IAudioInput
32 | {
33 | Q_OBJECT
34 | public:
35 | QtAudioInput(uint32_t channelCount, uint32_t sampleSize, uint32_t sampleRate);
36 |
37 | bool open() override;
38 | bool isActive() const override;
39 | void read(ReadPromise::Pointer promise) override;
40 | void start(StartPromise::Pointer promise) override;
41 | void stop() override;
42 | uint32_t getSampleSize() const override;
43 | uint32_t getChannelCount() const override;
44 | uint32_t getSampleRate() const override;
45 |
46 | signals:
47 | void startRecording(StartPromise::Pointer promise);
48 | void stopRecording();
49 |
50 | private slots:
51 | void createAudioInput();
52 | void onStartRecording(StartPromise::Pointer promise);
53 | void onStopRecording();
54 | void onReadyRead();
55 |
56 | private:
57 | QAudioFormat audioFormat_;
58 | QIODevice* ioDevice_;
59 | std::unique_ptr audioInput_;
60 | ReadPromise::Pointer readPromise_;
61 | mutable std::mutex mutex_;
62 |
63 | static constexpr size_t cSampleSize = 2056;
64 | };
65 |
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/include/openauto/Projection/QtAudioOutput.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include
22 | #include
23 | #include "IAudioOutput.hpp"
24 | #include "SequentialBuffer.hpp"
25 |
26 | namespace openauto
27 | {
28 | namespace projection
29 | {
30 |
31 | class QtAudioOutput: public QObject, public IAudioOutput
32 | {
33 | Q_OBJECT
34 |
35 | public:
36 | QtAudioOutput(uint32_t channelCount, uint32_t sampleSize, uint32_t sampleRate);
37 | bool open() override;
38 | void write(aasdk::messenger::Timestamp::ValueType, const aasdk::common::DataConstBuffer& buffer) override;
39 | void start() override;
40 | void stop() override;
41 | void suspend() override;
42 | uint32_t getSampleSize() const override;
43 | uint32_t getChannelCount() const override;
44 | uint32_t getSampleRate() const override;
45 |
46 | signals:
47 | void startPlayback();
48 | void suspendPlayback();
49 | void stopPlayback();
50 |
51 | protected slots:
52 | void createAudioOutput();
53 | void onStartPlayback();
54 | void onSuspendPlayback();
55 | void onStopPlayback();
56 |
57 | private:
58 | QAudioFormat audioFormat_;
59 | SequentialBuffer audioBuffer_;
60 | std::unique_ptr audioOutput_;
61 | bool playbackStarted_;
62 | };
63 |
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/include/openauto/Projection/QtVideoOutput.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include
22 | #include
23 | #include
24 | #include "VideoOutput.hpp"
25 | #include "SequentialBuffer.hpp"
26 |
27 | namespace openauto
28 | {
29 | namespace projection
30 | {
31 |
32 | class QtVideoOutput: public QObject, public VideoOutput, boost::noncopyable
33 | {
34 | Q_OBJECT
35 |
36 | public:
37 | QtVideoOutput(configuration::IConfiguration::Pointer configuration, QWidget* videoContainer=nullptr);
38 | bool open() override;
39 | bool init() override;
40 | void write(uint64_t timestamp, const aasdk::common::DataConstBuffer& buffer) override;
41 | void stop() override;
42 | void resize();
43 |
44 | signals:
45 | void startPlayback();
46 | void stopPlayback();
47 |
48 | protected slots:
49 | void createVideoOutput();
50 | void onStartPlayback();
51 | void onStopPlayback();
52 |
53 | private:
54 | SequentialBuffer videoBuffer_;
55 | std::unique_ptr videoWidget_;
56 | std::unique_ptr mediaPlayer_;
57 | QWidget* videoContainer_;
58 | };
59 |
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/include/openauto/Projection/RemoteBluetoothDevice.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include "IBluetoothDevice.hpp"
22 |
23 | namespace openauto
24 | {
25 | namespace projection
26 | {
27 |
28 | class RemoteBluetoothDevice: public IBluetoothDevice
29 | {
30 | public:
31 | RemoteBluetoothDevice(const std::string& address);
32 |
33 | void stop() override;
34 | bool isPaired(const std::string& address) const override;
35 | void pair(const std::string& address, PairingPromise::Pointer promise) override;
36 | std::string getLocalAddress() const override;
37 | bool isAvailable() const override;
38 |
39 | private:
40 | std::string address_;
41 | };
42 |
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/include/openauto/Projection/RtAudioOutput.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include
22 | #include "IAudioOutput.hpp"
23 | #include "SequentialBuffer.hpp"
24 |
25 | namespace openauto
26 | {
27 | namespace projection
28 | {
29 |
30 | class RtAudioOutput: public IAudioOutput
31 | {
32 | public:
33 | RtAudioOutput(uint32_t channelCount, uint32_t sampleSize, uint32_t sampleRate);
34 | bool open() override;
35 | void write(aasdk::messenger::Timestamp::ValueType timestamp, const aasdk::common::DataConstBuffer& buffer) override;
36 | void start() override;
37 | void stop() override;
38 | void suspend() override;
39 | uint32_t getSampleSize() const override;
40 | uint32_t getChannelCount() const override;
41 | uint32_t getSampleRate() const override;
42 |
43 | private:
44 | void doSuspend();
45 | static int audioBufferReadHandler(void* outputBuffer, void* inputBuffer, unsigned int nBufferFrames,
46 | double streamTime, RtAudioStreamStatus status, void* userData);
47 |
48 | uint32_t channelCount_;
49 | uint32_t sampleSize_;
50 | uint32_t sampleRate_;
51 | SequentialBuffer audioBuffer_;
52 | std::unique_ptr dac_;
53 | static std::mutex mutex_;
54 | };
55 |
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/include/openauto/Projection/SequentialBuffer.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include
22 | #include
23 | #include
24 | #include "aasdk/Common/Data.hpp"
25 |
26 | namespace openauto
27 | {
28 | namespace projection
29 | {
30 |
31 | class SequentialBuffer: public QIODevice
32 | {
33 | public:
34 | SequentialBuffer();
35 | bool isSequential() const override;
36 | qint64 size() const override;
37 | qint64 pos() const override;
38 | bool seek(qint64 pos) override;
39 | bool atEnd() const override;
40 | bool reset() override;
41 | bool canReadLine() const override;
42 | qint64 bytesAvailable() const override;
43 | bool open(OpenMode mode) override;
44 |
45 | protected:
46 | qint64 readData(char *data, qint64 maxlen) override;
47 | qint64 writeData(const char *data, qint64 len) override;
48 |
49 | private:
50 | boost::circular_buffer data_;
51 | mutable std::mutex mutex_;
52 | };
53 |
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/include/openauto/Projection/VideoOutput.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include "openauto/Configuration/IConfiguration.hpp"
22 | #include "IVideoOutput.hpp"
23 |
24 | namespace openauto
25 | {
26 | namespace projection
27 | {
28 |
29 | class VideoOutput: public IVideoOutput
30 | {
31 | public:
32 | VideoOutput(configuration::IConfiguration::Pointer configuration);
33 |
34 | aasdk::proto::enums::VideoFPS::Enum getVideoFPS() const override;
35 | aasdk::proto::enums::VideoResolution::Enum getVideoResolution() const override;
36 | size_t getScreenDPI() const override;
37 | QRect getVideoMargins() const override;
38 |
39 | protected:
40 | configuration::IConfiguration::Pointer configuration_;
41 | };
42 |
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/include/openauto/Service/AndroidAutoEntity.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include
22 | #include "aasdk/Transport/ITransport.hpp"
23 | #include "aasdk/Channel/Control/IControlServiceChannel.hpp"
24 | #include "aasdk/Channel/Control/IControlServiceChannelEventHandler.hpp"
25 | #include "aasdk/Channel/AV/VideoServiceChannel.hpp"
26 | #include "openauto/Configuration/IConfiguration.hpp"
27 | #include "IAndroidAutoEntity.hpp"
28 | #include "IService.hpp"
29 | #include "IPinger.hpp"
30 |
31 | namespace openauto
32 | {
33 | namespace service
34 | {
35 |
36 | class AndroidAutoEntity: public IAndroidAutoEntity, public aasdk::channel::control::IControlServiceChannelEventHandler, public std::enable_shared_from_this
37 | {
38 | public:
39 | AndroidAutoEntity(boost::asio::io_service& ioService,
40 | aasdk::messenger::ICryptor::Pointer cryptor,
41 | aasdk::transport::ITransport::Pointer transport,
42 | aasdk::messenger::IMessenger::Pointer messenger,
43 | configuration::IConfiguration::Pointer configuration,
44 | ServiceList serviceList,
45 | IPinger::Pointer pinger);
46 | ~AndroidAutoEntity() override;
47 |
48 | void start(IAndroidAutoEntityEventHandler& eventHandler) override;
49 | void stop() override;
50 | void onVersionResponse(uint16_t majorCode, uint16_t minorCode, aasdk::proto::enums::VersionResponseStatus::Enum status) override;
51 | void onHandshake(const aasdk::common::DataConstBuffer& payload) override;
52 | void onServiceDiscoveryRequest(const aasdk::proto::messages::ServiceDiscoveryRequest& request) override;
53 | void onAudioFocusRequest(const aasdk::proto::messages::AudioFocusRequest& request) override;
54 | void onShutdownRequest(const aasdk::proto::messages::ShutdownRequest& request) override;
55 | void onShutdownResponse(const aasdk::proto::messages::ShutdownResponse& response) override;
56 | void onNavigationFocusRequest(const aasdk::proto::messages::NavigationFocusRequest& request) override;
57 | void onPingRequest(const aasdk::proto::messages::PingRequest& request) override;
58 | void onPingResponse(const aasdk::proto::messages::PingResponse& response) override;
59 | void onChannelError(const aasdk::error::Error& e) override;
60 | void onVoiceSessionRequest(const aasdk::proto::messages::VoiceSessionRequest& request) override;
61 |
62 | private:
63 | using std::enable_shared_from_this::shared_from_this;
64 | void triggerQuit();
65 | void schedulePing();
66 | void sendPing();
67 |
68 | boost::asio::io_service::strand strand_;
69 | aasdk::messenger::ICryptor::Pointer cryptor_;
70 | aasdk::transport::ITransport::Pointer transport_;
71 | aasdk::messenger::IMessenger::Pointer messenger_;
72 | aasdk::channel::control::IControlServiceChannel::Pointer controlServiceChannel_;
73 | configuration::IConfiguration::Pointer configuration_;
74 | ServiceList serviceList_;
75 | IPinger::Pointer pinger_;
76 | IAndroidAutoEntityEventHandler* eventHandler_;
77 | };
78 |
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/include/openauto/Service/AndroidAutoEntityFactory.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include
22 | #include "aasdk/Transport/ITransport.hpp"
23 | #include "openauto/Configuration/IConfiguration.hpp"
24 | #include "IAndroidAutoEntityFactory.hpp"
25 | #include "IServiceFactory.hpp"
26 |
27 | namespace openauto
28 | {
29 | namespace service
30 | {
31 |
32 | class AndroidAutoEntityFactory: public IAndroidAutoEntityFactory
33 | {
34 | public:
35 | AndroidAutoEntityFactory(boost::asio::io_service& ioService,
36 | configuration::IConfiguration::Pointer configuration,
37 | IServiceFactory& serviceFactory);
38 |
39 | IAndroidAutoEntity::Pointer create(aasdk::usb::IAOAPDevice::Pointer aoapDevice) override;
40 | IAndroidAutoEntity::Pointer create(aasdk::tcp::ITCPEndpoint::Pointer tcpEndpoint) override;
41 |
42 | private:
43 | IAndroidAutoEntity::Pointer create(aasdk::transport::ITransport::Pointer transport);
44 |
45 | boost::asio::io_service& ioService_;
46 | configuration::IConfiguration::Pointer configuration_;
47 | IServiceFactory& serviceFactory_;
48 | };
49 |
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/include/openauto/Service/AudioInputService.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include "aasdk/Channel/AV/AVInputServiceChannel.hpp"
22 | #include "IService.hpp"
23 | #include "openauto/Projection/IAudioInput.hpp"
24 |
25 | namespace openauto
26 | {
27 | namespace service
28 | {
29 |
30 | class AudioInputService: public aasdk::channel::av::IAVInputServiceChannelEventHandler, public IService, public std::enable_shared_from_this
31 | {
32 | public:
33 | typedef std::shared_ptr Pointer;
34 |
35 | AudioInputService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IAudioInput::Pointer audioInput);
36 |
37 | void start() override;
38 | void stop() override;
39 | void fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response) override;
40 | void onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request) override;
41 | void onAVChannelSetupRequest(const aasdk::proto::messages::AVChannelSetupRequest& request) override;
42 | void onAVInputOpenRequest(const aasdk::proto::messages::AVInputOpenRequest& request) override;
43 | void onAVMediaAckIndication(const aasdk::proto::messages::AVMediaAckIndication& indication) override;
44 | void onChannelError(const aasdk::error::Error& e) override;
45 |
46 | private:
47 | using std::enable_shared_from_this::shared_from_this;
48 | void onAudioInputOpenSucceed();
49 | void onAudioInputDataReady(aasdk::common::Data data);
50 | void readAudioInput();
51 |
52 | boost::asio::io_service::strand strand_;
53 | aasdk::channel::av::AVInputServiceChannel::Pointer channel_;
54 | projection::IAudioInput::Pointer audioInput_;
55 | int32_t session_;
56 | };
57 |
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/include/openauto/Service/AudioService.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include "aasdk/Channel/AV/IAudioServiceChannel.hpp"
22 | #include "aasdk/Channel/AV/IAudioServiceChannelEventHandler.hpp"
23 | #include "openauto/Projection/IAudioOutput.hpp"
24 | #include "IService.hpp"
25 |
26 | namespace openauto
27 | {
28 | namespace service
29 | {
30 |
31 | class AudioService: public aasdk::channel::av::IAudioServiceChannelEventHandler, public IService, public std::enable_shared_from_this
32 | {
33 | public:
34 | typedef std::shared_ptr Pointer;
35 |
36 | AudioService(boost::asio::io_service& ioService, aasdk::channel::av::IAudioServiceChannel::Pointer channel, projection::IAudioOutput::Pointer audioOutput);
37 |
38 | void start() override;
39 | void stop() override;
40 | void fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response) override;
41 | void onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request) override;
42 | void onAVChannelSetupRequest(const aasdk::proto::messages::AVChannelSetupRequest& request) override;
43 | void onAVChannelStartIndication(const aasdk::proto::messages::AVChannelStartIndication& indication) override;
44 | void onAVChannelStopIndication(const aasdk::proto::messages::AVChannelStopIndication& indication) override;
45 | void onAVMediaWithTimestampIndication(aasdk::messenger::Timestamp::ValueType timestamp, const aasdk::common::DataConstBuffer& buffer) override;
46 | void onAVMediaIndication(const aasdk::common::DataConstBuffer& buffer) override;
47 | void onChannelError(const aasdk::error::Error& e) override;
48 |
49 | protected:
50 | using std::enable_shared_from_this::shared_from_this;
51 |
52 | boost::asio::io_service::strand strand_;
53 | aasdk::channel::av::IAudioServiceChannel::Pointer channel_;
54 | projection::IAudioOutput::Pointer audioOutput_;
55 | int32_t session_;
56 | };
57 |
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/include/openauto/Service/BluetoothService.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include "aasdk/Channel/Bluetooth/BluetoothServiceChannel.hpp"
22 | #include "openauto/Projection/IBluetoothDevice.hpp"
23 | #include "IService.hpp"
24 |
25 | namespace openauto
26 | {
27 | namespace service
28 | {
29 |
30 | class BluetoothService: public aasdk::channel::bluetooth::IBluetoothServiceChannelEventHandler, public IService, public std::enable_shared_from_this
31 | {
32 | public:
33 | BluetoothService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IBluetoothDevice::Pointer bluetoothDevice);
34 | void start() override;
35 | void stop() override;
36 | void fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response) override;
37 | void onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request) override;
38 | void onBluetoothPairingRequest(const aasdk::proto::messages::BluetoothPairingRequest& request) override;
39 | void onChannelError(const aasdk::error::Error& e) override;
40 |
41 | private:
42 | using std::enable_shared_from_this::shared_from_this;
43 |
44 | boost::asio::io_service::strand strand_;
45 | aasdk::channel::bluetooth::BluetoothServiceChannel::Pointer channel_;
46 | projection::IBluetoothDevice::Pointer bluetoothDevice_;
47 | };
48 |
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/include/openauto/Service/IAndroidAutoEntity.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include
22 | #include "IAndroidAutoEntityEventHandler.hpp"
23 |
24 | namespace openauto
25 | {
26 | namespace service
27 | {
28 |
29 | class IAndroidAutoEntity
30 | {
31 | public:
32 | typedef std::shared_ptr Pointer;
33 |
34 | virtual ~IAndroidAutoEntity() = default;
35 |
36 | virtual void start(IAndroidAutoEntityEventHandler& eventHandler) = 0;
37 | virtual void stop() = 0;
38 | };
39 |
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/include/openauto/Service/IAndroidAutoEntityEventHandler.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include "aasdk/Error/Error.hpp"
22 |
23 | namespace openauto
24 | {
25 | namespace service
26 | {
27 |
28 | class IAndroidAutoEntityEventHandler
29 | {
30 | public:
31 | virtual ~IAndroidAutoEntityEventHandler() = default;
32 | virtual void onAndroidAutoQuit() = 0;
33 | };
34 |
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/include/openauto/Service/IAndroidAutoEntityFactory.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include "aasdk/TCP/ITCPEndpoint.hpp"
22 | #include "aasdk/USB/IAOAPDevice.hpp"
23 | #include "IAndroidAutoEntity.hpp"
24 |
25 | namespace openauto
26 | {
27 | namespace service
28 | {
29 |
30 | class IAndroidAutoEntityFactory
31 | {
32 | public:
33 | virtual ~IAndroidAutoEntityFactory() = default;
34 |
35 | virtual IAndroidAutoEntity::Pointer create(aasdk::usb::IAOAPDevice::Pointer aoapDevice) = 0;
36 | virtual IAndroidAutoEntity::Pointer create(aasdk::tcp::ITCPEndpoint::Pointer tcpEndpoint) = 0;
37 | };
38 |
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/include/openauto/Service/IAndroidAutoInterface.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 | #include "aasdk_proto/ButtonCodeEnum.pb.h"
21 | #include "openauto/Projection/InputEvent.hpp"
22 | #include "aasdk_proto/MediaInfoChannelMetadataData.pb.h"
23 | #include "aasdk_proto/MediaInfoChannelPlaybackData.pb.h"
24 | #include "aasdk_proto/NavigationStatusMessage.pb.h"
25 | #include "aasdk_proto/NavigationDistanceEventMessage.pb.h"
26 | #include "aasdk_proto/NavigationTurnEventMessage.pb.h"
27 | #include "openauto/Service/ServiceFactory.hpp"
28 |
29 |
30 | namespace openauto
31 | {
32 | namespace service
33 | {
34 |
35 | class IAndroidAutoInterface: public std::enable_shared_from_this
36 | {
37 | public:
38 | std::shared_ptr getPtr()
39 | {
40 | return shared_from_this();
41 | }
42 | typedef std::shared_ptr Pointer;
43 |
44 | virtual ~IAndroidAutoInterface() = default;
45 |
46 | virtual void mediaPlaybackUpdate(const aasdk::proto::messages::MediaInfoChannelPlaybackData& playback) = 0;
47 | virtual void mediaMetadataUpdate(const aasdk::proto::messages::MediaInfoChannelMetadataData& metadata) = 0;
48 | virtual void navigationStatusUpdate(const aasdk::proto::messages::NavigationStatus& navStatus) = 0;
49 | virtual void navigationTurnEvent(const aasdk::proto::messages::NavigationTurnEvent& turnEvent) = 0;
50 | virtual void navigationDistanceEvent(const aasdk::proto::messages::NavigationDistanceEvent& distanceEvent) = 0;
51 | void setServiceFactory(ServiceFactory* serviceFactory)
52 | {
53 | this->m_serviceFactory = serviceFactory;
54 |
55 | }
56 | void injectButtonPress(aasdk::proto::enums::ButtonCode::Enum buttonCode, projection::WheelDirection wheelDirection=openauto::projection::WheelDirection::NONE, projection::ButtonEventType buttonEventType = projection::ButtonEventType::NONE)
57 | {
58 | if(m_serviceFactory != NULL)
59 | {
60 |
61 | m_serviceFactory->sendButtonPress(buttonCode, wheelDirection, buttonEventType);
62 | }
63 | }
64 | void injectButtonPress(aasdk::proto::enums::ButtonCode::Enum buttonCode, projection::ButtonEventType buttonEventType)
65 | {
66 | this->injectButtonPress(buttonCode, projection::WheelDirection::NONE, buttonEventType);
67 | }
68 | void setNightMode(bool mode)
69 | {
70 | if(m_serviceFactory != NULL)
71 | {
72 |
73 | m_serviceFactory->setNightMode(mode);
74 | }
75 | }
76 |
77 |
78 |
79 |
80 | private:
81 | using std::enable_shared_from_this::shared_from_this;
82 | ServiceFactory* m_serviceFactory;
83 | };
84 |
85 |
86 |
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/include/openauto/Service/IPinger.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include "aasdk/IO/Promise.hpp"
22 |
23 | namespace openauto
24 | {
25 | namespace service
26 | {
27 |
28 | class IPinger
29 | {
30 | public:
31 | typedef std::shared_ptr Pointer;
32 | typedef aasdk::io::Promise Promise;
33 |
34 | virtual ~IPinger() = default;
35 | virtual void ping(Promise::Pointer promise) = 0;
36 | virtual void pong() = 0;
37 | virtual void cancel() = 0;
38 | };
39 |
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/include/openauto/Service/IService.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include
22 | #include
23 | #include "aasdk_proto/ServiceDiscoveryResponseMessage.pb.h"
24 |
25 | namespace openauto
26 | {
27 | namespace service
28 | {
29 |
30 | class IService
31 | {
32 | public:
33 | typedef std::shared_ptr Pointer;
34 |
35 | virtual ~IService() = default;
36 |
37 | virtual void start() = 0;
38 | virtual void stop() = 0;
39 | virtual void fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response) = 0;
40 | };
41 |
42 | typedef std::vector ServiceList;
43 |
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/include/openauto/Service/IServiceFactory.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include "aasdk/Messenger/IMessenger.hpp"
22 | #include "IService.hpp"
23 |
24 | namespace openauto
25 | {
26 | namespace service
27 | {
28 |
29 | class IServiceFactory
30 | {
31 | public:
32 | virtual ~IServiceFactory() = default;
33 |
34 | virtual ServiceList create(aasdk::messenger::IMessenger::Pointer messenger) = 0;
35 | };
36 |
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/include/openauto/Service/InputService.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include "aasdk_proto/ButtonCodeEnum.pb.h"
22 | #include "aasdk/Channel/Input/InputServiceChannel.hpp"
23 | #include "IService.hpp"
24 | #include "openauto/Projection/IInputDevice.hpp"
25 | #include "openauto/Projection/IInputDeviceEventHandler.hpp"
26 |
27 | namespace openauto
28 | {
29 | namespace service
30 | {
31 |
32 | class InputService:
33 | public aasdk::channel::input::IInputServiceChannelEventHandler,
34 | public IService,
35 | public projection::IInputDeviceEventHandler,
36 | public std::enable_shared_from_this
37 | {
38 | public:
39 | InputService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IInputDevice::Pointer inputDevice);
40 |
41 | void sendButtonPress(aasdk::proto::enums::ButtonCode::Enum buttonCode, projection::WheelDirection wheelDirection = projection::WheelDirection::NONE, projection::ButtonEventType buttonEventType = projection::ButtonEventType::NONE);
42 | void start() override;
43 | void stop() override;
44 | void fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response) override;
45 | void onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request) override;
46 | void onBindingRequest(const aasdk::proto::messages::BindingRequest& request) override;
47 | void onChannelError(const aasdk::error::Error& e) override;
48 | void onButtonEvent(const projection::ButtonEvent& event) override;
49 | void onTouchEvent(aasdk::proto::messages::InputEventIndication inputEventIndication) override;
50 | void onMouseEvent(const projection::TouchEvent& event) override;
51 |
52 | private:
53 | using std::enable_shared_from_this::shared_from_this;
54 |
55 | boost::asio::io_service::strand strand_;
56 | aasdk::channel::input::InputServiceChannel::Pointer channel_;
57 | projection::IInputDevice::Pointer inputDevice_;
58 | bool serviceActive = false;
59 | };
60 |
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/include/openauto/Service/MediaAudioService.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include "aasdk/Messenger/IMessenger.hpp"
22 | #include "AudioService.hpp"
23 |
24 | namespace openauto
25 | {
26 | namespace service
27 | {
28 |
29 | class MediaAudioService: public AudioService
30 | {
31 | public:
32 | MediaAudioService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IAudioOutput::Pointer audioOutput);
33 | };
34 |
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/include/openauto/Service/MediaStatusService.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include "aasdk/Channel/AV/MediaStatusServiceChannel.hpp"
22 | #include "IService.hpp"
23 |
24 | namespace openauto
25 | {
26 | namespace service
27 | {
28 | class IAndroidAutoInterface;
29 | class MediaStatusService: public aasdk::channel::av::IMediaStatusServiceChannelEventHandler, public IService, public std::enable_shared_from_this
30 | {
31 | public:
32 | MediaStatusService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, IAndroidAutoInterface* aa_interface);
33 | void start() override;
34 | void stop() override;
35 | void fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response) override;
36 | void onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request) override;
37 | void onChannelError(const aasdk::error::Error& e) override;
38 | void onMetadataUpdate(const aasdk::proto::messages::MediaInfoChannelMetadataData& metadata) override;
39 | void onPlaybackUpdate(const aasdk::proto::messages::MediaInfoChannelPlaybackData& playback) override;
40 | void setAndroidAutoInterface(IAndroidAutoInterface* aa_interface);
41 |
42 |
43 | private:
44 | using std::enable_shared_from_this::shared_from_this;
45 |
46 | boost::asio::io_service::strand strand_;
47 | aasdk::channel::av::MediaStatusServiceChannel::Pointer channel_;
48 | IAndroidAutoInterface* aa_interface_ = nullptr;
49 | };
50 |
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/include/openauto/Service/NavigationStatusService.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include "aasdk/Channel/Navigation/NavigationStatusServiceChannel.hpp"
22 | #include "IService.hpp"
23 |
24 | namespace openauto
25 | {
26 | namespace service
27 | {
28 | class IAndroidAutoInterface;
29 | class NavigationStatusService: public aasdk::channel::navigation::INavigationStatusServiceChannelEventHandler, public IService, public std::enable_shared_from_this
30 | {
31 | public:
32 | NavigationStatusService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, IAndroidAutoInterface* aa_interface);
33 | void start() override;
34 | void stop() override;
35 | void fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response) override;
36 | void onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request) override;
37 | void onChannelError(const aasdk::error::Error& e) override;
38 | void onTurnEvent(const aasdk::proto::messages::NavigationTurnEvent& turnEvent) override;
39 | void onDistanceEvent(const aasdk::proto::messages::NavigationDistanceEvent& distanceEvent) override;
40 | void onStatusUpdate(const aasdk::proto::messages::NavigationStatus& navStatus) override;
41 | void setAndroidAutoInterface(IAndroidAutoInterface* aa_interface);
42 |
43 |
44 | private:
45 | using std::enable_shared_from_this::shared_from_this;
46 |
47 | boost::asio::io_service::strand strand_;
48 | aasdk::channel::navigation::NavigationStatusServiceChannel::Pointer channel_;
49 | IAndroidAutoInterface* aa_interface_ = nullptr;
50 |
51 | };
52 |
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/include/openauto/Service/Pinger.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include "IPinger.hpp"
22 |
23 | namespace openauto
24 | {
25 | namespace service
26 | {
27 |
28 | class Pinger: public IPinger, public std::enable_shared_from_this
29 | {
30 | public:
31 | Pinger(boost::asio::io_service& ioService, time_t duration);
32 |
33 | void ping(Promise::Pointer promise) override;
34 | void pong() override;
35 | void cancel() override;
36 |
37 | private:
38 | using std::enable_shared_from_this::shared_from_this;
39 |
40 | void onTimerExceeded(const boost::system::error_code& error);
41 |
42 | boost::asio::io_service::strand strand_;
43 | boost::asio::deadline_timer timer_;
44 | time_t duration_;
45 | bool cancelled_;
46 | Promise::Pointer promise_;
47 | int64_t pingsCount_;
48 | int64_t pongsCount_;
49 | };
50 |
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/include/openauto/Service/SensorService.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include "aasdk/Channel/Sensor/SensorServiceChannel.hpp"
22 | #include "IService.hpp"
23 |
24 | namespace openauto
25 | {
26 | namespace service
27 | {
28 |
29 | class SensorService: public aasdk::channel::sensor::ISensorServiceChannelEventHandler, public IService, public std::enable_shared_from_this
30 | {
31 | public:
32 | SensorService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, bool nightMode=false);
33 |
34 | void start() override;
35 | void stop() override;
36 | void fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response) override;
37 | void onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request) override;
38 | void onSensorStartRequest(const aasdk::proto::messages::SensorStartRequestMessage& request) override;
39 | void onChannelError(const aasdk::error::Error& e) override;
40 | void setNightMode(bool nightMode);
41 |
42 | private:
43 | using std::enable_shared_from_this::shared_from_this;
44 | void sendDrivingStatusUnrestricted();
45 | void sendNightData();
46 |
47 | boost::asio::io_service::strand strand_;
48 | aasdk::channel::sensor::SensorServiceChannel::Pointer channel_;
49 | bool nightMode_;
50 | };
51 |
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/include/openauto/Service/ServiceFactory.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include "openauto/Service/IServiceFactory.hpp"
22 | #include "openauto/Configuration/IConfiguration.hpp"
23 | #include "openauto/Projection/InputDevice.hpp"
24 | #include "openauto/Projection/OMXVideoOutput.hpp"
25 | #include "openauto/Projection/GSTVideoOutput.hpp"
26 | #include "openauto/Projection/QtVideoOutput.hpp"
27 | #include "openauto/Service/MediaStatusService.hpp"
28 | #include "openauto/Service/NavigationStatusService.hpp"
29 | #include "openauto/Service/SensorService.hpp"
30 | #include "openauto/Service/InputService.hpp"
31 | #include "btservice/btservice.hpp"
32 |
33 | namespace openauto
34 | {
35 | namespace service
36 | {
37 | class IAndroidAutoInterface;
38 | class ServiceFactory : public IServiceFactory
39 | {
40 | public:
41 | ServiceFactory(boost::asio::io_service& ioService, configuration::IConfiguration::Pointer configuration, QWidget* activeArea=nullptr, std::function activeCallback=nullptr, bool nightMode=false);
42 | ServiceList create(aasdk::messenger::IMessenger::Pointer messenger) override;
43 | void setOpacity(unsigned int alpha);
44 | void resize();
45 | void setNightMode(bool nightMode);
46 | void sendButtonPress(aasdk::proto::enums::ButtonCode::Enum buttonCode, projection::WheelDirection wheelDirection = projection::WheelDirection::NONE, projection::ButtonEventType buttonEventType = projection::ButtonEventType::NONE);
47 | void sendKeyEvent(QKeyEvent* event);
48 | void setAndroidAutoInterface(IAndroidAutoInterface* aa_interface);
49 | static QRect mapActiveAreaToGlobal(QWidget* activeArea);
50 | #ifdef USE_OMX
51 | static projection::DestRect QRectToDestRect(QRect rect);
52 | #endif
53 |
54 | private:
55 | IService::Pointer createVideoService(aasdk::messenger::IMessenger::Pointer messenger);
56 | IService::Pointer createBluetoothService(aasdk::messenger::IMessenger::Pointer messenger);
57 | std::shared_ptr createNavigationStatusService(aasdk::messenger::IMessenger::Pointer messenger);
58 | std::shared_ptr createMediaStatusService(aasdk::messenger::IMessenger::Pointer messenger);
59 | std::shared_ptr createInputService(aasdk::messenger::IMessenger::Pointer messenger);
60 | void createAudioServices(ServiceList& serviceList, aasdk::messenger::IMessenger::Pointer messenger);
61 |
62 | boost::asio::io_service& ioService_;
63 | configuration::IConfiguration::Pointer configuration_;
64 | QWidget* activeArea_;
65 | QRect screenGeometry_;
66 | std::function activeCallback_;
67 | std::shared_ptr inputDevice_;
68 | #if defined USE_OMX
69 | std::shared_ptr omxVideoOutput_;
70 | #elif defined USE_GST
71 | std::shared_ptr gstVideoOutput_;
72 | #else
73 | projection::QtVideoOutput *qtVideoOutput_;
74 | #endif
75 | btservice::btservice btservice_;
76 | bool nightMode_;
77 | std::weak_ptr sensorService_;
78 | std::weak_ptr inputService_;
79 | std::weak_ptr mediaStatusService_;
80 | std::weak_ptr navStatusService_;
81 | IAndroidAutoInterface* aa_interface_ = nullptr;
82 | };
83 |
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/include/openauto/Service/SpeechAudioService.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include "aasdk/Messenger/IMessenger.hpp"
22 | #include "AudioService.hpp"
23 |
24 | namespace openauto
25 | {
26 | namespace service
27 | {
28 |
29 | class SpeechAudioService: public AudioService
30 | {
31 | public:
32 | SpeechAudioService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IAudioOutput::Pointer audioOutput);
33 | };
34 |
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/include/openauto/Service/SystemAudioService.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include "aasdk/Messenger/IMessenger.hpp"
22 | #include "AudioService.hpp"
23 |
24 | namespace openauto
25 | {
26 | namespace service
27 | {
28 |
29 | class SystemAudioService: public AudioService
30 | {
31 | public:
32 | SystemAudioService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IAudioOutput::Pointer audioOutput);
33 | };
34 |
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/include/openauto/Service/VideoService.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #pragma once
20 |
21 | #include
22 | #include "aasdk/Channel/AV/VideoServiceChannel.hpp"
23 | #include "aasdk/Channel/AV/IVideoServiceChannelEventHandler.hpp"
24 | #include "openauto/Projection/IVideoOutput.hpp"
25 | #include "IService.hpp"
26 |
27 | namespace openauto
28 | {
29 | namespace service
30 | {
31 |
32 | class VideoService: public aasdk::channel::av::IVideoServiceChannelEventHandler, public IService, public std::enable_shared_from_this
33 | {
34 | public:
35 | typedef std::shared_ptr Pointer;
36 |
37 | VideoService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IVideoOutput::Pointer videoOutput);
38 |
39 | void start() override;
40 | void stop() override;
41 | void fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response) override;
42 | void onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request) override;
43 | void onAVChannelSetupRequest(const aasdk::proto::messages::AVChannelSetupRequest& request) override;
44 | void onAVChannelStartIndication(const aasdk::proto::messages::AVChannelStartIndication& indication) override;
45 | void onAVChannelStopIndication(const aasdk::proto::messages::AVChannelStopIndication& indication) override;
46 | void onAVMediaWithTimestampIndication(aasdk::messenger::Timestamp::ValueType timestamp, const aasdk::common::DataConstBuffer& buffer) override;
47 | void onAVMediaIndication(const aasdk::common::DataConstBuffer& buffer) override;
48 | void onVideoFocusRequest(const aasdk::proto::messages::VideoFocusRequest& request) override;
49 | void onChannelError(const aasdk::error::Error& e) override;
50 |
51 | private:
52 | using std::enable_shared_from_this::shared_from_this;
53 | void sendVideoFocusIndication();
54 |
55 | boost::asio::io_service::strand strand_;
56 | aasdk::channel::av::VideoServiceChannel::Pointer channel_;
57 | projection::IVideoOutput::Pointer videoOutput_;
58 | int32_t session_;
59 | };
60 |
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/openauto/Configuration/RecentAddressesList.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #include
20 | #include "OpenautoLog.hpp"
21 | #include "openauto/Configuration/RecentAddressesList.hpp"
22 |
23 | namespace openauto
24 | {
25 | namespace configuration
26 | {
27 |
28 | const std::string RecentAddressesList::cConfigFileName = "openauto_wifi_recent.ini";
29 | const std::string RecentAddressesList::cRecentEntiresCount = "Recent.EntiresCount";
30 | const std::string RecentAddressesList::cRecentEntryPrefix = "Recent.Entry_";
31 |
32 | RecentAddressesList::RecentAddressesList(size_t maxListSize)
33 | : maxListSize_(maxListSize)
34 | {
35 |
36 | }
37 |
38 | void RecentAddressesList::read()
39 | {
40 | this->load();
41 | }
42 |
43 | void RecentAddressesList::insertAddress(const std::string& address)
44 | {
45 | if(std::find(list_.begin(), list_.end(), address) != list_.end())
46 | {
47 | return;
48 | }
49 |
50 | if(list_.size() >= maxListSize_)
51 | {
52 | list_.pop_back();
53 | }
54 |
55 | list_.push_front(address);
56 | this->save();
57 | }
58 |
59 | RecentAddressesList::RecentAddresses RecentAddressesList::getList() const
60 | {
61 | return list_;
62 | }
63 |
64 | void RecentAddressesList::load()
65 | {
66 | boost::property_tree::ptree iniConfig;
67 |
68 | try
69 | {
70 | boost::property_tree::ini_parser::read_ini(cConfigFileName, iniConfig);
71 |
72 | const auto listSize = std::min(maxListSize_, iniConfig.get(cRecentEntiresCount, 0));
73 |
74 | for(size_t i = 0; i < listSize; ++i)
75 | {
76 | const auto key = cRecentEntryPrefix + std::to_string(i);
77 | const auto address = iniConfig.get(key, RecentAddresses::value_type());
78 |
79 | if(!address.empty())
80 | {
81 | list_.push_back(address);
82 | }
83 | }
84 | }
85 | catch(const boost::property_tree::ini_parser_error& e)
86 | {
87 | OPENAUTO_LOG(warning) << "[RecentAddressesList] failed to read configuration file: " << cConfigFileName
88 | << ", error: " << e.what()
89 | << ". Empty list will be used.";
90 | }
91 | }
92 |
93 | void RecentAddressesList::save()
94 | {
95 | boost::property_tree::ptree iniConfig;
96 |
97 | const auto entiresCount = std::min(maxListSize_, list_.size());
98 | iniConfig.put(cRecentEntiresCount, entiresCount);
99 |
100 | for(size_t i = 0; i < entiresCount; ++i)
101 | {
102 | const auto key = cRecentEntryPrefix + std::to_string(i);
103 | iniConfig.put(key, list_.at(i));
104 | }
105 |
106 | boost::property_tree::ini_parser::write_ini(cConfigFileName, iniConfig);
107 | }
108 |
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/openauto/Projection/DummyBluetoothDevice.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #include "openauto/Projection/DummyBluetoothDevice.hpp"
20 |
21 | namespace openauto
22 | {
23 | namespace projection
24 | {
25 |
26 | void DummyBluetoothDevice::stop()
27 | {
28 |
29 | }
30 |
31 | bool DummyBluetoothDevice::isPaired(const std::string&) const
32 | {
33 | return false;
34 | }
35 |
36 | void DummyBluetoothDevice::pair(const std::string&, PairingPromise::Pointer promise)
37 | {
38 | promise->reject();
39 | }
40 |
41 | std::string DummyBluetoothDevice::getLocalAddress() const
42 | {
43 | return "";
44 | }
45 |
46 | bool DummyBluetoothDevice::isAvailable() const
47 | {
48 | return false;
49 | }
50 |
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/openauto/Projection/QtAudioInput.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #include
20 | #include "openauto/Projection/QtAudioInput.hpp"
21 | #include "OpenautoLog.hpp"
22 |
23 | namespace openauto
24 | {
25 | namespace projection
26 | {
27 |
28 | QtAudioInput::QtAudioInput(uint32_t channelCount, uint32_t sampleSize, uint32_t sampleRate)
29 | : ioDevice_(nullptr)
30 | {
31 | qRegisterMetaType("StartPromise::Pointer");
32 |
33 | audioFormat_.setChannelCount(channelCount);
34 | audioFormat_.setSampleRate(sampleRate);
35 | audioFormat_.setSampleSize(sampleSize);
36 | audioFormat_.setCodec("audio/pcm");
37 | audioFormat_.setByteOrder(QAudioFormat::LittleEndian);
38 | audioFormat_.setSampleType(QAudioFormat::SignedInt);
39 |
40 | this->moveToThread(QApplication::instance()->thread());
41 | connect(this, &QtAudioInput::startRecording, this, &QtAudioInput::onStartRecording, Qt::QueuedConnection);
42 | connect(this, &QtAudioInput::stopRecording, this, &QtAudioInput::onStopRecording, Qt::QueuedConnection);
43 | QMetaObject::invokeMethod(this, "createAudioInput", Qt::BlockingQueuedConnection);
44 | }
45 |
46 | void QtAudioInput::createAudioInput()
47 | {
48 | OPENAUTO_LOG(debug) << "[AudioInput] create.";
49 | audioInput_ = (std::make_unique(QAudioDeviceInfo::defaultInputDevice(), audioFormat_));
50 | }
51 |
52 | bool QtAudioInput::open()
53 | {
54 | std::lock_guard lock(mutex_);
55 |
56 | return ioDevice_ == nullptr;
57 | }
58 |
59 | bool QtAudioInput::isActive() const
60 | {
61 | std::lock_guard lock(mutex_);
62 |
63 | return ioDevice_ != nullptr;
64 | }
65 |
66 | void QtAudioInput::read(ReadPromise::Pointer promise)
67 | {
68 | std::lock_guard lock(mutex_);
69 |
70 | if(ioDevice_ == nullptr)
71 | {
72 | promise->reject();
73 | }
74 | else if(readPromise_ != nullptr)
75 | {
76 | promise->reject();
77 | }
78 | else
79 | {
80 | readPromise_ = std::move(promise);
81 | }
82 | }
83 |
84 | void QtAudioInput::start(StartPromise::Pointer promise)
85 | {
86 | emit startRecording(std::move(promise));
87 | }
88 |
89 | void QtAudioInput::stop()
90 | {
91 | emit stopRecording();
92 | }
93 |
94 | uint32_t QtAudioInput::getSampleSize() const
95 | {
96 | return audioFormat_.sampleSize();
97 | }
98 |
99 | uint32_t QtAudioInput::getChannelCount() const
100 | {
101 | return audioFormat_.channelCount();
102 | }
103 |
104 | uint32_t QtAudioInput::getSampleRate() const
105 | {
106 | return audioFormat_.sampleRate();
107 | }
108 |
109 | void QtAudioInput::onStartRecording(StartPromise::Pointer promise)
110 | {
111 | std::lock_guard lock(mutex_);
112 |
113 | ioDevice_ = audioInput_->start();
114 |
115 | if(ioDevice_ != nullptr)
116 | {
117 | connect(ioDevice_, &QIODevice::readyRead, this, &QtAudioInput::onReadyRead, Qt::QueuedConnection);
118 | promise->resolve();
119 | }
120 | else
121 | {
122 | promise->reject();
123 | }
124 | }
125 |
126 | void QtAudioInput::onStopRecording()
127 | {
128 | std::lock_guard lock(mutex_);
129 |
130 | if(readPromise_ != nullptr)
131 | {
132 | readPromise_->reject();
133 | readPromise_.reset();
134 | }
135 |
136 | if(ioDevice_ != nullptr)
137 | {
138 | ioDevice_->reset();
139 | ioDevice_->disconnect();
140 | ioDevice_ = nullptr;
141 | }
142 |
143 | audioInput_->stop();
144 | }
145 |
146 | void QtAudioInput::onReadyRead()
147 | {
148 | std::lock_guard lock(mutex_);
149 |
150 | if(readPromise_ == nullptr)
151 | {
152 | return;
153 | }
154 |
155 | aasdk::common::Data data(cSampleSize, 0);
156 | aasdk::common::DataBuffer buffer(data);
157 | auto readSize = ioDevice_->read(reinterpret_cast(buffer.data), buffer.size);
158 |
159 | if(readSize != -1)
160 | {
161 | data.resize(readSize);
162 | readPromise_->resolve(std::move(data));
163 | readPromise_.reset();
164 | }
165 | else
166 | {
167 | readPromise_->reject();
168 | readPromise_.reset();
169 | }
170 | }
171 |
172 | }
173 | }
174 |
--------------------------------------------------------------------------------
/openauto/Projection/QtAudioOutput.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #include
20 | #include "openauto/Projection/QtAudioOutput.hpp"
21 | #include "OpenautoLog.hpp"
22 |
23 |
24 | namespace openauto
25 | {
26 | namespace projection
27 | {
28 |
29 | QtAudioOutput::QtAudioOutput(uint32_t channelCount, uint32_t sampleSize, uint32_t sampleRate)
30 | : playbackStarted_(false)
31 | {
32 | audioFormat_.setChannelCount(channelCount);
33 | audioFormat_.setSampleRate(sampleRate);
34 | audioFormat_.setSampleSize(sampleSize);
35 | audioFormat_.setCodec("audio/pcm");
36 | audioFormat_.setByteOrder(QAudioFormat::LittleEndian);
37 | audioFormat_.setSampleType(QAudioFormat::SignedInt);
38 |
39 | this->moveToThread(QApplication::instance()->thread());
40 | connect(this, &QtAudioOutput::startPlayback, this, &QtAudioOutput::onStartPlayback);
41 | connect(this, &QtAudioOutput::suspendPlayback, this, &QtAudioOutput::onSuspendPlayback);
42 | connect(this, &QtAudioOutput::stopPlayback, this, &QtAudioOutput::onStopPlayback);
43 |
44 | QMetaObject::invokeMethod(this, "createAudioOutput", Qt::BlockingQueuedConnection);
45 | }
46 |
47 | void QtAudioOutput::createAudioOutput()
48 | {
49 | OPENAUTO_LOG(debug) << "[QtAudioOutput] create.";
50 | audioOutput_ = std::make_unique(QAudioDeviceInfo::defaultOutputDevice(), audioFormat_);
51 | }
52 |
53 | bool QtAudioOutput::open()
54 | {
55 | return audioBuffer_.open(QIODevice::ReadWrite);
56 | }
57 |
58 | void QtAudioOutput::write(aasdk::messenger::Timestamp::ValueType, const aasdk::common::DataConstBuffer& buffer)
59 | {
60 | audioBuffer_.write(reinterpret_cast(buffer.cdata), buffer.size);
61 | }
62 |
63 | void QtAudioOutput::start()
64 | {
65 | emit startPlayback();
66 | }
67 |
68 | void QtAudioOutput::stop()
69 | {
70 | emit stopPlayback();
71 | }
72 |
73 | void QtAudioOutput::suspend()
74 | {
75 | emit suspendPlayback();
76 | }
77 |
78 | uint32_t QtAudioOutput::getSampleSize() const
79 | {
80 | return audioFormat_.sampleSize();
81 | }
82 |
83 | uint32_t QtAudioOutput::getChannelCount() const
84 | {
85 | return audioFormat_.channelCount();
86 | }
87 |
88 | uint32_t QtAudioOutput::getSampleRate() const
89 | {
90 | return audioFormat_.sampleRate();
91 | }
92 |
93 | void QtAudioOutput::onStartPlayback()
94 | {
95 | if(!playbackStarted_)
96 | {
97 | audioOutput_->start(&audioBuffer_);
98 | playbackStarted_ = true;
99 | }
100 | else
101 | {
102 | audioOutput_->resume();
103 | }
104 | }
105 |
106 | void QtAudioOutput::onSuspendPlayback()
107 | {
108 | audioOutput_->suspend();
109 | }
110 |
111 | void QtAudioOutput::onStopPlayback()
112 | {
113 | if(playbackStarted_)
114 | {
115 | audioOutput_->stop();
116 | playbackStarted_ = false;
117 | }
118 | }
119 |
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/openauto/Projection/QtVideoOutput.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #include
20 | #include "openauto/Projection/QtVideoOutput.hpp"
21 | #include "OpenautoLog.hpp"
22 |
23 | namespace openauto
24 | {
25 | namespace projection
26 | {
27 |
28 | QtVideoOutput::QtVideoOutput(configuration::IConfiguration::Pointer configuration, QWidget* videoContainer)
29 | : VideoOutput(std::move(configuration))
30 | , videoContainer_(videoContainer)
31 | {
32 | this->moveToThread(QApplication::instance()->thread());
33 | connect(this, &QtVideoOutput::startPlayback, this, &QtVideoOutput::onStartPlayback, Qt::QueuedConnection);
34 | connect(this, &QtVideoOutput::stopPlayback, this, &QtVideoOutput::onStopPlayback, Qt::QueuedConnection);
35 |
36 | QMetaObject::invokeMethod(this, "createVideoOutput", Qt::BlockingQueuedConnection);
37 | }
38 |
39 | void QtVideoOutput::createVideoOutput()
40 | {
41 | OPENAUTO_LOG(debug) << "[QtVideoOutput] create.";
42 | videoWidget_ = std::make_unique(videoContainer_);
43 | mediaPlayer_ = std::make_unique(nullptr, QMediaPlayer::StreamPlayback);
44 | }
45 |
46 |
47 | bool QtVideoOutput::open()
48 | {
49 | return videoBuffer_.open(QIODevice::ReadWrite);
50 | }
51 |
52 | bool QtVideoOutput::init()
53 | {
54 | emit startPlayback();
55 | return true;
56 | }
57 |
58 | void QtVideoOutput::stop()
59 | {
60 | emit stopPlayback();
61 | }
62 |
63 | void QtVideoOutput::write(uint64_t, const aasdk::common::DataConstBuffer& buffer)
64 | {
65 | videoBuffer_.write(reinterpret_cast(buffer.cdata), buffer.size);
66 | }
67 |
68 | void QtVideoOutput::resize()
69 | {
70 | if(videoWidget_ != nullptr && videoContainer_ != nullptr)
71 | {
72 | videoWidget_->resize(videoContainer_->size());
73 | }
74 | }
75 |
76 | void QtVideoOutput::onStartPlayback()
77 | {
78 | if(videoContainer_ == nullptr)
79 | {
80 | videoWidget_->setAspectRatioMode(Qt::IgnoreAspectRatio);
81 | videoWidget_->setFocus();
82 | videoWidget_->setWindowFlags(Qt::WindowStaysOnTopHint);
83 | videoWidget_->setFullScreen(true);
84 | }
85 | else
86 | {
87 | videoWidget_->resize(videoContainer_->size());
88 | }
89 | videoWidget_->show();
90 |
91 | mediaPlayer_->setVideoOutput(videoWidget_.get());
92 | mediaPlayer_->setMedia(QMediaContent(), &videoBuffer_);
93 | mediaPlayer_->play();
94 | }
95 |
96 | void QtVideoOutput::onStopPlayback()
97 | {
98 | videoWidget_->hide();
99 | mediaPlayer_->stop();
100 | }
101 |
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/openauto/Projection/RemoteBluetoothDevice.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #include "openauto/Projection/RemoteBluetoothDevice.hpp"
20 |
21 | namespace openauto
22 | {
23 | namespace projection
24 | {
25 |
26 | RemoteBluetoothDevice::RemoteBluetoothDevice(const std::string& address)
27 | : address_(address)
28 | {
29 |
30 | }
31 |
32 | void RemoteBluetoothDevice::stop()
33 | {
34 |
35 | }
36 |
37 | bool RemoteBluetoothDevice::isPaired(const std::string&) const
38 | {
39 | return true;
40 | }
41 |
42 | void RemoteBluetoothDevice::pair(const std::string&, PairingPromise::Pointer promise)
43 | {
44 | promise->resolve();
45 | }
46 |
47 | std::string RemoteBluetoothDevice::getLocalAddress() const
48 | {
49 | return address_;
50 | }
51 |
52 | bool RemoteBluetoothDevice::isAvailable() const
53 | {
54 | return true;
55 | }
56 |
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/openauto/Projection/RtAudioOutput.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #include "openauto/Projection/RtAudioOutput.hpp"
20 | #include "OpenautoLog.hpp"
21 |
22 | namespace openauto
23 | {
24 | namespace projection
25 | {
26 |
27 | std::mutex RtAudioOutput::mutex_;
28 |
29 | RtAudioOutput::RtAudioOutput(uint32_t channelCount, uint32_t sampleSize, uint32_t sampleRate)
30 | : channelCount_(channelCount)
31 | , sampleSize_(sampleSize)
32 | , sampleRate_(sampleRate)
33 | {
34 | std::vector apis;
35 | RtAudio::getCompiledApi(apis);
36 | dac_ = std::find(apis.begin(), apis.end(), RtAudio::LINUX_PULSE) == apis.end() ? std::make_unique() : std::make_unique(RtAudio::LINUX_PULSE);
37 | }
38 |
39 | bool RtAudioOutput::open()
40 | {
41 | std::lock_guard lock(mutex_);
42 |
43 | if(dac_->getDeviceCount() > 0)
44 | {
45 | RtAudio::StreamParameters parameters;
46 | parameters.deviceId = dac_->getDefaultOutputDevice();
47 | parameters.nChannels = channelCount_;
48 | parameters.firstChannel = 0;
49 |
50 | try
51 | {
52 | RtAudio::StreamOptions streamOptions;
53 | streamOptions.flags = RTAUDIO_MINIMIZE_LATENCY | RTAUDIO_SCHEDULE_REALTIME;
54 | uint32_t bufferFrames = sampleRate_ == 16000 ? 1024 : 2048; //according to the observation of audio packets
55 | dac_->openStream(¶meters, nullptr, RTAUDIO_SINT16, sampleRate_, &bufferFrames, &RtAudioOutput::audioBufferReadHandler, static_cast(this), &streamOptions);
56 | return audioBuffer_.open(QIODevice::ReadWrite);
57 | }
58 | catch(const RtAudioError& e)
59 | {
60 | OPENAUTO_LOG(error) << "[RtAudioOutput] Failed to open audio output, what: " << e.what();
61 | }
62 | }
63 | else
64 | {
65 | OPENAUTO_LOG(error) << "[RtAudioOutput] No output devices found.";
66 | }
67 |
68 | return false;
69 | }
70 |
71 | void RtAudioOutput::write(aasdk::messenger::Timestamp::ValueType timestamp, const aasdk::common::DataConstBuffer& buffer)
72 | {
73 | audioBuffer_.write(reinterpret_cast(buffer.cdata), buffer.size);
74 | }
75 |
76 | void RtAudioOutput::start()
77 | {
78 | std::lock_guard lock(mutex_);
79 |
80 | if(dac_->isStreamOpen() && !dac_->isStreamRunning())
81 | {
82 | try
83 | {
84 | dac_->startStream();
85 | }
86 | catch(const RtAudioError& e)
87 | {
88 | OPENAUTO_LOG(error) << "[RtAudioOutput] Failed to start audio output, what: " << e.what();
89 | }
90 | }
91 | }
92 |
93 | void RtAudioOutput::stop()
94 | {
95 | std::lock_guard lock(mutex_);
96 |
97 | this->doSuspend();
98 |
99 | if(dac_->isStreamOpen())
100 | {
101 | dac_->closeStream();
102 | }
103 | }
104 |
105 | void RtAudioOutput::suspend()
106 | {
107 | //not needed
108 | }
109 |
110 | uint32_t RtAudioOutput::getSampleSize() const
111 | {
112 | return sampleSize_;
113 | }
114 |
115 | uint32_t RtAudioOutput::getChannelCount() const
116 | {
117 | return channelCount_;
118 | }
119 |
120 | uint32_t RtAudioOutput::getSampleRate() const
121 | {
122 | return sampleRate_;
123 | }
124 |
125 | void RtAudioOutput::doSuspend()
126 | {
127 | if(dac_->isStreamOpen() && dac_->isStreamRunning())
128 | {
129 | try
130 | {
131 | dac_->stopStream();
132 | }
133 | catch(const RtAudioError& e)
134 | {
135 | OPENAUTO_LOG(error) << "[RtAudioOutput] Failed to suspend audio output, what: " << e.what();
136 | }
137 | }
138 | }
139 |
140 | int RtAudioOutput::audioBufferReadHandler(void* outputBuffer, void* inputBuffer, unsigned int nBufferFrames,
141 | double streamTime, RtAudioStreamStatus status, void* userData)
142 | {
143 | RtAudioOutput* self = static_cast(userData);
144 | std::lock_guardmutex_)> lock(self->mutex_);
145 |
146 | const auto bufferSize = nBufferFrames * (self->sampleSize_ / 8) * self->channelCount_;
147 | self->audioBuffer_.read(reinterpret_cast(outputBuffer), bufferSize);
148 | return 0;
149 | }
150 |
151 | }
152 | }
153 |
--------------------------------------------------------------------------------
/openauto/Projection/SequentialBuffer.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #include "openauto/Projection/SequentialBuffer.hpp"
20 |
21 | namespace openauto
22 | {
23 | namespace projection
24 | {
25 |
26 | SequentialBuffer::SequentialBuffer()
27 | : data_(aasdk::common::cStaticDataSize)
28 | {
29 | }
30 |
31 | bool SequentialBuffer::isSequential() const
32 | {
33 | return true;
34 | }
35 |
36 | bool SequentialBuffer::open(OpenMode mode)
37 | {
38 | std::lock_guard lock(mutex_);
39 |
40 | return QIODevice::open(mode);
41 | }
42 |
43 | qint64 SequentialBuffer::readData(char *data, qint64 maxlen)
44 | {
45 | std::lock_guard lock(mutex_);
46 |
47 | if(data_.empty())
48 | {
49 | return 0;
50 | }
51 |
52 | const auto len = std::min(maxlen, data_.size());
53 | std::copy(data_.begin(), data_.begin() + len, data);
54 | data_.erase_begin(len);
55 |
56 | return len;
57 | }
58 |
59 | qint64 SequentialBuffer::writeData(const char *data, qint64 len)
60 | {
61 | std::lock_guard lock(mutex_);
62 |
63 | data_.insert(data_.end(), data, data + len);
64 | emit readyRead();
65 | return len;
66 | }
67 |
68 | qint64 SequentialBuffer::size() const
69 | {
70 | return this->bytesAvailable();
71 | }
72 |
73 | qint64 SequentialBuffer::pos() const
74 | {
75 | return 0;
76 | }
77 |
78 |
79 | bool SequentialBuffer::seek(qint64)
80 | {
81 | return false;
82 | }
83 |
84 | bool SequentialBuffer::atEnd() const
85 | {
86 | return false;
87 | }
88 |
89 | bool SequentialBuffer::reset()
90 | {
91 | data_.clear();
92 | return true;
93 | }
94 |
95 | qint64 SequentialBuffer::bytesAvailable() const
96 | {
97 | std::lock_guard lock(mutex_);
98 |
99 | return QIODevice::bytesAvailable() + std::max(1, data_.size());
100 | }
101 |
102 | bool SequentialBuffer::canReadLine() const
103 | {
104 | return true;
105 | }
106 |
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/openauto/Projection/VideoOutput.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #include "openauto/Projection/VideoOutput.hpp"
20 |
21 | namespace openauto
22 | {
23 | namespace projection
24 | {
25 |
26 | VideoOutput::VideoOutput(configuration::IConfiguration::Pointer configuration)
27 | : configuration_(std::move(configuration))
28 | {
29 |
30 | }
31 |
32 | aasdk::proto::enums::VideoFPS::Enum VideoOutput::getVideoFPS() const
33 | {
34 | return configuration_->getVideoFPS();
35 | }
36 |
37 | aasdk::proto::enums::VideoResolution::Enum VideoOutput::getVideoResolution() const
38 | {
39 | return configuration_->getVideoResolution();
40 | }
41 |
42 | size_t VideoOutput::getScreenDPI() const
43 | {
44 | return configuration_->getScreenDPI();
45 | }
46 |
47 | QRect VideoOutput::getVideoMargins() const
48 | {
49 | return configuration_->getVideoMargins();
50 | }
51 |
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/openauto/Service/AndroidAutoEntityFactory.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #include "aasdk/USB/AOAPDevice.hpp"
20 | #include "aasdk/Transport/SSLWrapper.hpp"
21 | #include "aasdk/Transport/USBTransport.hpp"
22 | #include "aasdk/Transport/TCPTransport.hpp"
23 | #include "aasdk/Messenger/Cryptor.hpp"
24 | #include "aasdk/Messenger/MessageInStream.hpp"
25 | #include "aasdk/Messenger/MessageOutStream.hpp"
26 | #include "aasdk/Messenger/Messenger.hpp"
27 | #include "openauto/Service/AndroidAutoEntityFactory.hpp"
28 | #include "openauto/Service/AndroidAutoEntity.hpp"
29 | #include "openauto/Service/Pinger.hpp"
30 |
31 | namespace openauto
32 | {
33 | namespace service
34 | {
35 |
36 | AndroidAutoEntityFactory::AndroidAutoEntityFactory(boost::asio::io_service& ioService,
37 | configuration::IConfiguration::Pointer configuration,
38 | IServiceFactory& serviceFactory)
39 | : ioService_(ioService)
40 | , configuration_(std::move(configuration))
41 | , serviceFactory_(serviceFactory)
42 | {
43 |
44 | }
45 |
46 | IAndroidAutoEntity::Pointer AndroidAutoEntityFactory::create(aasdk::usb::IAOAPDevice::Pointer aoapDevice)
47 | {
48 | auto transport(std::make_shared(ioService_, std::move(aoapDevice)));
49 | return create(std::move(transport));
50 | }
51 |
52 | IAndroidAutoEntity::Pointer AndroidAutoEntityFactory::create(aasdk::tcp::ITCPEndpoint::Pointer tcpEndpoint)
53 | {
54 | auto transport(std::make_shared(ioService_, std::move(tcpEndpoint)));
55 | return create(std::move(transport));
56 | }
57 |
58 | IAndroidAutoEntity::Pointer AndroidAutoEntityFactory::create(aasdk::transport::ITransport::Pointer transport)
59 | {
60 | auto sslWrapper(std::make_shared());
61 | auto cryptor(std::make_shared(std::move(sslWrapper)));
62 | cryptor->init();
63 |
64 | auto messenger(std::make_shared(ioService_,
65 | std::make_shared(ioService_, transport, cryptor),
66 | std::make_shared(ioService_, transport, cryptor)));
67 |
68 | auto serviceList = serviceFactory_.create(messenger);
69 | auto pinger(std::make_shared(ioService_, 5000));
70 | return std::make_shared(ioService_, std::move(cryptor), std::move(transport), std::move(messenger), configuration_, std::move(serviceList), std::move(pinger));
71 | }
72 |
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/openauto/Service/BluetoothService.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #include "OpenautoLog.hpp"
20 | #include "openauto/Service/BluetoothService.hpp"
21 |
22 | namespace openauto
23 | {
24 | namespace service
25 | {
26 |
27 | BluetoothService::BluetoothService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IBluetoothDevice::Pointer bluetoothDevice)
28 | : strand_(ioService)
29 | , channel_(std::make_shared(strand_, std::move(messenger)))
30 | , bluetoothDevice_(std::move(bluetoothDevice))
31 | {
32 |
33 | }
34 |
35 | void BluetoothService::start()
36 | {
37 | strand_.dispatch([this, self = this->shared_from_this()]() {
38 | OPENAUTO_LOG(info) << "[BluetoothService] start.";
39 | channel_->receive(this->shared_from_this());
40 | });
41 | }
42 |
43 | void BluetoothService::stop()
44 | {
45 | strand_.dispatch([this, self = this->shared_from_this()]() {
46 | OPENAUTO_LOG(info) << "[BluetoothService] stop.";
47 | bluetoothDevice_->stop();
48 | });
49 | }
50 |
51 | void BluetoothService::fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response)
52 | {
53 | OPENAUTO_LOG(info) << "[BluetoothService] fill features";
54 |
55 | if(bluetoothDevice_->isAvailable())
56 | {
57 | OPENAUTO_LOG(info) << "[BluetoothService] sending local adapter adress: " << bluetoothDevice_->getLocalAddress();
58 |
59 | auto* channelDescriptor = response.add_channels();
60 | channelDescriptor->set_channel_id(static_cast(channel_->getId()));
61 | auto bluetoothChannel = channelDescriptor->mutable_bluetooth_channel();
62 | bluetoothChannel->set_adapter_address(bluetoothDevice_->getLocalAddress());
63 | bluetoothChannel->add_supported_pairing_methods(aasdk::proto::enums::BluetoothPairingMethod_Enum_HFP);
64 | }
65 | }
66 |
67 | void BluetoothService::onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request)
68 | {
69 | OPENAUTO_LOG(info) << "[BluetoothService] open request, priority: " << request.priority();
70 | const aasdk::proto::enums::Status::Enum status = aasdk::proto::enums::Status::OK;
71 | OPENAUTO_LOG(info) << "[BluetoothService] open status: " << status;
72 |
73 | aasdk::proto::messages::ChannelOpenResponse response;
74 | response.set_status(status);
75 |
76 | auto promise = aasdk::channel::SendPromise::defer(strand_);
77 | promise->then([]() {}, std::bind(&BluetoothService::onChannelError, this->shared_from_this(), std::placeholders::_1));
78 | channel_->sendChannelOpenResponse(response, std::move(promise));
79 |
80 | channel_->receive(this->shared_from_this());
81 | }
82 |
83 | void BluetoothService::onBluetoothPairingRequest(const aasdk::proto::messages::BluetoothPairingRequest& request)
84 | {
85 | OPENAUTO_LOG(info) << "[BluetoothService] pairing request, address: " << request.phone_address();
86 |
87 | aasdk::proto::messages::BluetoothPairingResponse response;
88 |
89 | const auto isPaired = bluetoothDevice_->isPaired(request.phone_address());
90 | response.set_already_paired(isPaired);
91 | response.set_status(isPaired ? aasdk::proto::enums::BluetoothPairingStatus::OK : aasdk::proto::enums::BluetoothPairingStatus::FAIL);
92 |
93 | auto promise = aasdk::channel::SendPromise::defer(strand_);
94 | promise->then([]() {}, std::bind(&BluetoothService::onChannelError, this->shared_from_this(), std::placeholders::_1));
95 | channel_->sendBluetoothPairingResponse(response, std::move(promise));
96 |
97 | channel_->receive(this->shared_from_this());
98 | }
99 |
100 | void BluetoothService::onChannelError(const aasdk::error::Error& e)
101 | {
102 | OPENAUTO_LOG(error) << "[BluetoothService] channel error: " << e.what();
103 | }
104 |
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/openauto/Service/MediaAudioService.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #include "aasdk/Channel/AV/MediaAudioServiceChannel.hpp"
20 | #include "openauto/Service/MediaAudioService.hpp"
21 |
22 | namespace openauto
23 | {
24 | namespace service
25 | {
26 |
27 | MediaAudioService::MediaAudioService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IAudioOutput::Pointer audioOutput)
28 | : AudioService(ioService, std::make_shared(strand_, std::move(messenger)), std::move(audioOutput))
29 | {
30 |
31 | }
32 |
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/openauto/Service/MediaStatusService.cpp:
--------------------------------------------------------------------------------
1 | #include "OpenautoLog.hpp"
2 | #include "openauto/Service/MediaStatusService.hpp"
3 | #include "openauto/Service/IAndroidAutoInterface.hpp"
4 |
5 | namespace openauto
6 | {
7 | namespace service
8 | {
9 |
10 | MediaStatusService::MediaStatusService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, IAndroidAutoInterface* aa_interface)
11 | : strand_(ioService)
12 | , channel_(std::make_shared(strand_, std::move(messenger)))
13 | {
14 | aa_interface_ = aa_interface;
15 | }
16 |
17 | void MediaStatusService::start()
18 | {
19 | strand_.dispatch([this, self = this->shared_from_this()]() {
20 | OPENAUTO_LOG(info) << "[MediaStatusService] start.";
21 | channel_->receive(this->shared_from_this());
22 | });
23 | }
24 |
25 | void MediaStatusService::stop()
26 | {
27 | strand_.dispatch([this, self = this->shared_from_this()]() {
28 | OPENAUTO_LOG(info) << "[MediaStatusService] stop.";
29 | });
30 | }
31 |
32 | void MediaStatusService::fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response)
33 | {
34 | OPENAUTO_LOG(info) << "[MediaStatusService] fill features";
35 |
36 | auto* channelDescriptor = response.add_channels();
37 | auto mediaStatusChannel = channelDescriptor->mutable_media_infochannel();
38 | channelDescriptor->set_channel_id(static_cast(channel_->getId()));
39 | }
40 |
41 | void MediaStatusService::onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request)
42 | {
43 | OPENAUTO_LOG(info) << "[MediaStatusService] open request, priority: " << request.priority();
44 | const aasdk::proto::enums::Status::Enum status = aasdk::proto::enums::Status::OK;
45 | OPENAUTO_LOG(info) << "[MediaStatusService] open status: " << status;
46 |
47 | aasdk::proto::messages::ChannelOpenResponse response;
48 | response.set_status(status);
49 |
50 | auto promise = aasdk::channel::SendPromise::defer(strand_);
51 | promise->then([]() {}, std::bind(&MediaStatusService::onChannelError, this->shared_from_this(), std::placeholders::_1));
52 | channel_->sendChannelOpenResponse(response, std::move(promise));
53 |
54 | channel_->receive(this->shared_from_this());
55 | }
56 |
57 |
58 | void MediaStatusService::onChannelError(const aasdk::error::Error& e)
59 | {
60 | OPENAUTO_LOG(error) << "[MediaStatusService] channel error: " << e.what();
61 | }
62 |
63 | void MediaStatusService::onMetadataUpdate(const aasdk::proto::messages::MediaInfoChannelMetadataData& metadata)
64 | {
65 | OPENAUTO_LOG(info) << "[MediaStatusService] Metadata update"
66 | << ", track: " << metadata.track_name()
67 | << (metadata.has_artist_name()?", artist: ":"") << (metadata.has_artist_name()?metadata.artist_name():"")
68 | << (metadata.has_album_name()?", album: ":"") << (metadata.has_album_name()?metadata.album_name():"")
69 | << ", length: " << metadata.track_length();
70 | if(aa_interface_ != NULL)
71 | {
72 | aa_interface_->mediaMetadataUpdate(metadata);
73 | }
74 | channel_->receive(this->shared_from_this());
75 | }
76 |
77 | void MediaStatusService::onPlaybackUpdate(const aasdk::proto::messages::MediaInfoChannelPlaybackData& playback)
78 | {
79 | OPENAUTO_LOG(info) << "[MediaStatusService] Playback update"
80 | << ", source: " << playback.media_source()
81 | << ", state: " << playback.playback_state()
82 | << ", progress: " << playback.track_progress();
83 | if(aa_interface_ != NULL)
84 | {
85 | aa_interface_->mediaPlaybackUpdate(playback);
86 | }
87 | channel_->receive(this->shared_from_this());
88 | }
89 |
90 | void MediaStatusService::setAndroidAutoInterface(IAndroidAutoInterface* aa_interface)
91 | {
92 | this->aa_interface_ = aa_interface;
93 | }
94 |
95 |
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/openauto/Service/NavigationStatusService.cpp:
--------------------------------------------------------------------------------
1 | #include "OpenautoLog.hpp"
2 | #include "openauto/Service/NavigationStatusService.hpp"
3 | #include "aasdk_proto/ManeuverTypeEnum.pb.h"
4 | #include "aasdk_proto/ManeuverDirectionEnum.pb.h"
5 | #include "aasdk_proto/DistanceUnitEnum.pb.h"
6 | #include "openauto/Service/IAndroidAutoInterface.hpp"
7 |
8 | namespace openauto
9 | {
10 | namespace service
11 | {
12 |
13 | NavigationStatusService::NavigationStatusService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, IAndroidAutoInterface* aa_interface)
14 | : strand_(ioService)
15 | , channel_(std::make_shared(strand_, std::move(messenger)))
16 | {
17 | this->aa_interface_ = aa_interface;
18 | }
19 |
20 | void NavigationStatusService::start()
21 | {
22 | strand_.dispatch([this, self = this->shared_from_this()]() {
23 | OPENAUTO_LOG(info) << "[NavigationStatusService] start.";
24 | channel_->receive(this->shared_from_this());
25 | });
26 | }
27 |
28 | void NavigationStatusService::stop()
29 | {
30 | strand_.dispatch([this, self = this->shared_from_this()]() {
31 | OPENAUTO_LOG(info) << "[NavigationStatusService] stop.";
32 | });
33 | }
34 |
35 | void NavigationStatusService::fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response)
36 | {
37 | OPENAUTO_LOG(info) << "[NavigationStatusService] fill features";
38 |
39 | auto* channelDescriptor = response.add_channels();
40 | channelDescriptor->set_channel_id(static_cast(channel_->getId()));
41 | auto navStatusChannel = channelDescriptor->mutable_navigation_channel();
42 | navStatusChannel->set_minimum_interval_ms(1000);
43 | navStatusChannel->set_type(aasdk::proto::enums::NavigationTurnType::IMAGE);
44 | auto* imageOptions = new aasdk::proto::data::NavigationImageOptions();
45 | imageOptions->set_colour_depth_bits(16);
46 | imageOptions->set_height(256);
47 | imageOptions->set_width(256);
48 | imageOptions->set_dunno(255);
49 | navStatusChannel->set_allocated_image_options(imageOptions);
50 | }
51 |
52 | void NavigationStatusService::onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request)
53 | {
54 | OPENAUTO_LOG(info) << "[NavigationStatusService] open request, priority: " << request.priority();
55 | const aasdk::proto::enums::Status::Enum status = aasdk::proto::enums::Status::OK;
56 | OPENAUTO_LOG(info) << "[NavigationStatusService] open status: " << status;
57 |
58 | aasdk::proto::messages::ChannelOpenResponse response;
59 | response.set_status(status);
60 |
61 | auto promise = aasdk::channel::SendPromise::defer(strand_);
62 | promise->then([]() {}, std::bind(&NavigationStatusService::onChannelError, this->shared_from_this(), std::placeholders::_1));
63 | channel_->sendChannelOpenResponse(response, std::move(promise));
64 |
65 | channel_->receive(this->shared_from_this());
66 | }
67 |
68 |
69 | void NavigationStatusService::onChannelError(const aasdk::error::Error& e)
70 | {
71 | OPENAUTO_LOG(error) << "[NavigationStatusService] channel error: " << e.what();
72 | }
73 |
74 | void NavigationStatusService::onStatusUpdate(const aasdk::proto::messages::NavigationStatus& navStatus)
75 | {
76 | OPENAUTO_LOG(info) << "[NavigationStatusService] Navigation Status Update"
77 | << ", Status: " << aasdk::proto::messages::NavigationStatus_Enum_Name(navStatus.status());
78 | if(aa_interface_ != NULL)
79 | {
80 | aa_interface_->navigationStatusUpdate(navStatus);
81 | }
82 | channel_->receive(this->shared_from_this());
83 | }
84 |
85 | void NavigationStatusService::onTurnEvent(const aasdk::proto::messages::NavigationTurnEvent& turnEvent)
86 | {
87 | OPENAUTO_LOG(info) << "[NavigationStatusService] Turn Event"
88 | << ", Street: " << turnEvent.street_name()
89 | << ", Maneuver: " << aasdk::proto::enums::ManeuverDirection_Enum_Name(turnEvent.maneuverdirection()) << " " << aasdk::proto::enums::ManeuverType_Enum_Name(turnEvent.maneuvertype());
90 | if(aa_interface_ != NULL)
91 | {
92 | aa_interface_->navigationTurnEvent(turnEvent);
93 | }
94 | channel_->receive(this->shared_from_this());
95 | }
96 |
97 | void NavigationStatusService::onDistanceEvent(const aasdk::proto::messages::NavigationDistanceEvent& distanceEvent)
98 | {
99 | OPENAUTO_LOG(info) << "[NavigationStatusService] Distance Event"
100 | << ", Distance (meters): " << distanceEvent.meters()
101 | << ", Time To Turn (seconds): " << distanceEvent.timetostepseconds()
102 | << ", Distance: " << distanceEvent.distancetostepmillis()/1000.0
103 | << " ("<navigationDistanceEvent(distanceEvent);
107 | }
108 | channel_->receive(this->shared_from_this());
109 | }
110 |
111 |
112 | void NavigationStatusService::setAndroidAutoInterface(IAndroidAutoInterface* aa_interface)
113 | {
114 | this->aa_interface_ = aa_interface;
115 | }
116 |
117 |
118 | }
119 | }
120 |
--------------------------------------------------------------------------------
/openauto/Service/Pinger.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #include "openauto/Service/Pinger.hpp"
20 |
21 | namespace openauto
22 | {
23 | namespace service
24 | {
25 |
26 | Pinger::Pinger(boost::asio::io_service& ioService, time_t duration)
27 | : strand_(ioService)
28 | , timer_(ioService)
29 | , duration_(duration)
30 | , cancelled_(false)
31 | , pingsCount_(0)
32 | , pongsCount_(0)
33 | {
34 |
35 | }
36 |
37 | void Pinger::ping(Promise::Pointer promise)
38 | {
39 | strand_.dispatch([this, self = this->shared_from_this(), promise = std::move(promise)]() mutable {
40 | cancelled_ = false;
41 |
42 | if(promise_ != nullptr)
43 | {
44 | promise_->reject(aasdk::error::Error(aasdk::error::ErrorCode::OPERATION_IN_PROGRESS));
45 | }
46 | else
47 | {
48 | ++pingsCount_;
49 |
50 | promise_ = std::move(promise);
51 | timer_.expires_from_now(boost::posix_time::milliseconds(duration_));
52 | timer_.async_wait(strand_.wrap(std::bind(&Pinger::onTimerExceeded, this->shared_from_this(), std::placeholders::_1)));
53 | }
54 | });
55 | }
56 |
57 | void Pinger::pong()
58 | {
59 | strand_.dispatch([this, self = this->shared_from_this()]() {
60 | ++pongsCount_;
61 | });
62 | }
63 |
64 | void Pinger::onTimerExceeded(const boost::system::error_code& error)
65 | {
66 | if(promise_ == nullptr)
67 | {
68 | return;
69 | }
70 | else if(error == boost::asio::error::operation_aborted || cancelled_)
71 | {
72 | promise_->reject(aasdk::error::Error(aasdk::error::ErrorCode::OPERATION_ABORTED));
73 | }
74 | else if(pingsCount_ - pongsCount_ > 1)
75 | {
76 | promise_->reject(aasdk::error::Error());
77 | }
78 | else
79 | {
80 | promise_->resolve();
81 | }
82 |
83 | promise_.reset();
84 | }
85 |
86 | void Pinger::cancel()
87 | {
88 | strand_.dispatch([this, self = this->shared_from_this()]() {
89 | cancelled_ = true;
90 | timer_.cancel();
91 | });
92 | }
93 |
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/openauto/Service/SensorService.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #include "aasdk_proto/DrivingStatusEnum.pb.h"
20 | #include "OpenautoLog.hpp"
21 | #include "openauto/Service/SensorService.hpp"
22 |
23 | namespace openauto
24 | {
25 | namespace service
26 | {
27 |
28 | SensorService::SensorService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, bool nightMode)
29 | : strand_(ioService)
30 | , channel_(std::make_shared(strand_, std::move(messenger)))
31 | , nightMode_(nightMode)
32 | {
33 |
34 | }
35 |
36 | void SensorService::start()
37 | {
38 | strand_.dispatch([this, self = this->shared_from_this()]() {
39 | OPENAUTO_LOG(info) << "[SensorService] start.";
40 | channel_->receive(this->shared_from_this());
41 | });
42 | }
43 |
44 | void SensorService::stop()
45 | {
46 | strand_.dispatch([this, self = this->shared_from_this()]() {
47 | OPENAUTO_LOG(info) << "[SensorService] stop.";
48 | });
49 | }
50 |
51 | void SensorService::fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response)
52 | {
53 | OPENAUTO_LOG(info) << "[SensorService] fill features.";
54 |
55 | auto* channelDescriptor = response.add_channels();
56 | channelDescriptor->set_channel_id(static_cast(channel_->getId()));
57 | auto* sensorChannel = channelDescriptor->mutable_sensor_channel();
58 | sensorChannel->add_sensors()->set_type(aasdk::proto::enums::SensorType::DRIVING_STATUS);
59 | //sensorChannel->add_sensors()->set_type(aasdk::proto::enums::SensorType::LOCATION);
60 | sensorChannel->add_sensors()->set_type(aasdk::proto::enums::SensorType::NIGHT_DATA);
61 | }
62 |
63 | void SensorService::onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request)
64 | {
65 | OPENAUTO_LOG(info) << "[SensorService] open request, priority: " << request.priority();
66 | const aasdk::proto::enums::Status::Enum status = aasdk::proto::enums::Status::OK;
67 | OPENAUTO_LOG(info) << "[SensorService] open status: " << status;
68 |
69 | aasdk::proto::messages::ChannelOpenResponse response;
70 | response.set_status(status);
71 |
72 | auto promise = aasdk::channel::SendPromise::defer(strand_);
73 | promise->then([]() {}, std::bind(&SensorService::onChannelError, this->shared_from_this(), std::placeholders::_1));
74 | channel_->sendChannelOpenResponse(response, std::move(promise));
75 |
76 | channel_->receive(this->shared_from_this());
77 | }
78 |
79 | void SensorService::onSensorStartRequest(const aasdk::proto::messages::SensorStartRequestMessage& request)
80 | {
81 | OPENAUTO_LOG(info) << "[SensorService] sensor start request, type: " << request.sensor_type();
82 |
83 | aasdk::proto::messages::SensorStartResponseMessage response;
84 | response.set_status(aasdk::proto::enums::Status::OK);
85 |
86 | auto promise = aasdk::channel::SendPromise::defer(strand_);
87 |
88 | if(request.sensor_type() == aasdk::proto::enums::SensorType::DRIVING_STATUS)
89 | {
90 | promise->then(std::bind(&SensorService::sendDrivingStatusUnrestricted, this->shared_from_this()),
91 | std::bind(&SensorService::onChannelError, this->shared_from_this(), std::placeholders::_1));
92 | }
93 | else if(request.sensor_type() == aasdk::proto::enums::SensorType::NIGHT_DATA)
94 | {
95 | promise->then(std::bind(&SensorService::sendNightData, this->shared_from_this()),
96 | std::bind(&SensorService::onChannelError, this->shared_from_this(), std::placeholders::_1));
97 | }
98 | else
99 | {
100 | promise->then([]() {}, std::bind(&SensorService::onChannelError, this->shared_from_this(), std::placeholders::_1));
101 | }
102 |
103 | channel_->sendSensorStartResponse(response, std::move(promise));
104 | channel_->receive(this->shared_from_this());
105 | }
106 |
107 | void SensorService::sendDrivingStatusUnrestricted()
108 | {
109 | aasdk::proto::messages::SensorEventIndication indication;
110 | indication.add_driving_status()->set_status(aasdk::proto::enums::DrivingStatus::UNRESTRICTED);
111 |
112 | auto promise = aasdk::channel::SendPromise::defer(strand_);
113 | promise->then([]() {}, std::bind(&SensorService::onChannelError, this->shared_from_this(), std::placeholders::_1));
114 | channel_->sendSensorEventIndication(indication, std::move(promise));
115 | }
116 |
117 | void SensorService::sendNightData()
118 | {
119 | aasdk::proto::messages::SensorEventIndication indication;
120 | indication.add_night_mode()->set_is_night(nightMode_);
121 |
122 | auto promise = aasdk::channel::SendPromise::defer(strand_);
123 | promise->then([]() {}, std::bind(&SensorService::onChannelError, this->shared_from_this(), std::placeholders::_1));
124 | channel_->sendSensorEventIndication(indication, std::move(promise));
125 | }
126 |
127 | void SensorService::onChannelError(const aasdk::error::Error& e)
128 | {
129 | OPENAUTO_LOG(error) << "[SensorService] channel error: " << e.what();
130 | }
131 |
132 | void SensorService::setNightMode(bool nightMode)
133 | {
134 | nightMode_ = nightMode;
135 | this->sendNightData();
136 | }
137 |
138 | }
139 | }
140 |
--------------------------------------------------------------------------------
/openauto/Service/SpeechAudioService.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #include "aasdk/Channel/AV/SpeechAudioServiceChannel.hpp"
20 | #include "openauto/Service/SpeechAudioService.hpp"
21 |
22 | namespace openauto
23 | {
24 | namespace service
25 | {
26 |
27 | SpeechAudioService::SpeechAudioService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IAudioOutput::Pointer audioOutput)
28 | : AudioService(ioService, std::make_shared(strand_, std::move(messenger)), std::move(audioOutput))
29 | {
30 |
31 | }
32 |
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/openauto/Service/SystemAudioService.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of openauto project.
3 | * Copyright (C) 2018 f1x.studio (Michal Szwaj)
4 | *
5 | * openauto is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 3 of the License, or
8 | * (at your option) any later version.
9 |
10 | * openauto is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with openauto. If not, see .
17 | */
18 |
19 | #include "aasdk/Channel/AV/SystemAudioServiceChannel.hpp"
20 | #include "openauto/Service/SystemAudioService.hpp"
21 |
22 | namespace openauto
23 | {
24 | namespace service
25 | {
26 |
27 | SystemAudioService::SystemAudioService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IAudioOutput::Pointer audioOutput)
28 | : AudioService(ioService, std::make_shared(strand_, std::move(messenger)), std::move(audioOutput))
29 | {
30 |
31 | }
32 |
33 | }
34 | }
35 |
--------------------------------------------------------------------------------